msm: smd_pkt: Poll/Write operations return error under SSR
Under subsystem restart, poll operation is not returning error at all.
This causes user-space modules, which perform poll operation before read
operation, not able to detect subsystem restart. Also return error
condition continuously for write operation when a subsystem linked by an
SMD channel is in reset.
Change-Id: I2dc34d174ac08bb8d654668e6aaf8821bb190c57
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
diff --git a/arch/arm/mach-msm/smd_pkt.c b/arch/arm/mach-msm/smd_pkt.c
index 912e129..446a69f 100644
--- a/arch/arm/mach-msm/smd_pkt.c
+++ b/arch/arm/mach-msm/smd_pkt.c
@@ -436,7 +436,7 @@
return -EINVAL;
}
- if (smd_pkt_devp->do_reset_notification) {
+ if (smd_pkt_devp->do_reset_notification || smd_pkt_devp->has_reset) {
pr_err("%s notifying reset for smd_pkt_dev id:%d\n",
__func__, smd_pkt_devp->i);
/* notify client that a reset occurred */
@@ -522,11 +522,20 @@
smd_pkt_devp->poll_mode = 1;
poll_wait(file, &smd_pkt_devp->ch_read_wait_queue, wait);
+ mutex_lock(&smd_pkt_devp->ch_lock);
+ if (smd_pkt_devp->has_reset || !smd_pkt_devp->ch) {
+ mutex_unlock(&smd_pkt_devp->ch_lock);
+ pr_err("%s notifying reset for smd_pkt_dev id:%d\n",
+ __func__, smd_pkt_devp->i);
+ return POLLERR;
+ }
+
if (smd_read_avail(smd_pkt_devp->ch)) {
mask |= POLLIN | POLLRDNORM;
D_POLL("%s sets POLLIN for smd_pkt_dev id: %d\n",
__func__, smd_pkt_devp->i);
}
+ mutex_unlock(&smd_pkt_devp->ch_lock);
return mask;
}