summaryrefslogtreecommitdiff
path: root/drivers/char
diff options
context:
space:
mode:
authorMohit Aggarwal <maggarwa@codeaurora.org>2016-11-24 13:48:12 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2016-11-28 19:47:57 -0800
commit59045a49161a13e6cfc4ed5b44d15c0cf5c052f3 (patch)
treebcd95e08bf5c137a7bc81dbb4549dc84f52cb33d /drivers/char
parent9aa1df0cf5ffb58b52b55b4fe2ea6531f795e186 (diff)
diag: Set in_busy only after initialization of read buffers
Currently, there is a possibility that read buffers are not initialized but diag ends up marking buffers busy and stops reading from peripheral, which leads to port loss. Also reset the in_busy variable for the buffer that reads the data from smd channel when diag smd state is closed. CRs-Fixed: 1093989 Change-Id: I1990d0ded5a212c9185c149ac297a3630d64bc59 Signed-off-by: Mohit Aggarwal <maggarwa@codeaurora.org>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/diag/diagfwd_peripheral.c12
-rw-r--r--drivers/char/diag/diagfwd_smd.c5
2 files changed, 10 insertions, 7 deletions
diff --git a/drivers/char/diag/diagfwd_peripheral.c b/drivers/char/diag/diagfwd_peripheral.c
index c78a5f4fbe74..9c9d000c94db 100644
--- a/drivers/char/diag/diagfwd_peripheral.c
+++ b/drivers/char/diag/diagfwd_peripheral.c
@@ -989,8 +989,6 @@ void diagfwd_channel_read(struct diagfwd_info *fwd_info)
}
if (fwd_info->buf_1 && !atomic_read(&fwd_info->buf_1->in_busy)) {
- temp_buf = fwd_info->buf_1;
- atomic_set(&temp_buf->in_busy, 1);
if (driver->feature[fwd_info->peripheral].encode_hdlc &&
(fwd_info->type == TYPE_DATA ||
fwd_info->type == TYPE_CMD)) {
@@ -1000,9 +998,11 @@ void diagfwd_channel_read(struct diagfwd_info *fwd_info)
read_buf = fwd_info->buf_1->data;
read_len = fwd_info->buf_1->len;
}
+ if (read_buf) {
+ temp_buf = fwd_info->buf_1;
+ atomic_set(&temp_buf->in_busy, 1);
+ }
} else if (fwd_info->buf_2 && !atomic_read(&fwd_info->buf_2->in_busy)) {
- temp_buf = fwd_info->buf_2;
- atomic_set(&temp_buf->in_busy, 1);
if (driver->feature[fwd_info->peripheral].encode_hdlc &&
(fwd_info->type == TYPE_DATA ||
fwd_info->type == TYPE_CMD)) {
@@ -1012,6 +1012,10 @@ void diagfwd_channel_read(struct diagfwd_info *fwd_info)
read_buf = fwd_info->buf_2->data;
read_len = fwd_info->buf_2->len;
}
+ if (read_buf) {
+ temp_buf = fwd_info->buf_2;
+ atomic_set(&temp_buf->in_busy, 1);
+ }
} else {
pr_debug("diag: In %s, both buffers are empty for p: %d, t: %d\n",
__func__, fwd_info->peripheral, fwd_info->type);
diff --git a/drivers/char/diag/diagfwd_smd.c b/drivers/char/diag/diagfwd_smd.c
index 12069df1224d..f0698f0814d6 100644
--- a/drivers/char/diag/diagfwd_smd.c
+++ b/drivers/char/diag/diagfwd_smd.c
@@ -765,14 +765,13 @@ static int diag_smd_read(void *ctxt, unsigned char *buf, int buf_len)
}
/*
- * In this case don't reset the buffers as there is no need to further
- * read over peripherals. Also release the wake source hold earlier.
+ * Reset the buffers. Also release the wake source hold earlier.
*/
if (atomic_read(&smd_info->diag_state) == 0) {
DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
"%s closing read thread. diag state is closed\n",
smd_info->name);
- diag_ws_release();
+ diagfwd_channel_read_done(smd_info->fwd_ctxt, buf, 0);
return 0;
}