char: diag: add write done sync function
In factory mode the tty_diag module needs a spinlock eliminated from the diag_usb_write_done call. Change-Id: Ic7196276e1d07fa9eb5c58b2f7c35d4e24ffa9b6 Reviewed-on: https://gerrit.mot.com/1128708 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Kenneth Kessler <kennykessler@motorola.com> Submit-Approved: Jira Key Reviewed-on: https://gerrit.mot.com/1180282 Reviewed-by: Ling Jin <lingjin@motorola.com> Reviewed-on: https://gerrit.mot.com/1242985 Reviewed-by: Master Yoda Reviewed-by: Shengqi Wang <wangsq2@motorola.com> Reviewed-by: Yuecai Liu <liuyc20@motorola.com> Reviewed-on: https://gerrit.mot.com/1448855 Reviewed-by: Ryan Lattrel <ryanl@motorola.com> Reviewed-on: https://gerrit.mot.com/1510727
This commit is contained in:
1 parent
b50e45fab9
commit
e062def56e
2 files changed
+15
-7
No files matched your search
@@ -352,7 +352,8 @@ static void usb_read_done_work_fn(struct work_struct *work)
|
||||
}
|
||||
|
||||
static void diag_usb_write_done(struct diag_usb_info *ch,
|
||||
struct diag_request *req)
|
||||
struct diag_request *req,
|
||||
int sync)
|
||||
{
|
||||
int ctxt = 0;
|
||||
int len = 0;
|
||||
@@ -362,14 +363,15 @@ static void diag_usb_write_done(struct diag_usb_info *ch,
|
||||
|
||||
if (!ch || !req)
|
||||
return;
|
||||
|
||||
spin_lock_irqsave(&ch->write_lock, flags);
|
||||
if (!sync)
|
||||
spin_lock_irqsave(&ch->write_lock, flags);
|
||||
ch->write_cnt++;
|
||||
entry = diag_usb_buf_tbl_get(ch, req->context);
|
||||
if (!entry) {
|
||||
pr_err_ratelimited("diag: In %s, unable to find entry %pK in the table\n",
|
||||
__func__, req->context);
|
||||
spin_unlock_irqrestore(&ch->write_lock, flags);
|
||||
if (!sync)
|
||||
spin_unlock_irqrestore(&ch->write_lock, flags);
|
||||
return;
|
||||
}
|
||||
if (atomic_read(&entry->ref_count) != 0) {
|
||||
@@ -377,7 +379,8 @@ static void diag_usb_write_done(struct diag_usb_info *ch,
|
||||
atomic_read(&entry->ref_count));
|
||||
diag_ws_on_copy_complete(DIAG_WS_MUX);
|
||||
diagmem_free(driver, req, ch->mempool);
|
||||
spin_unlock_irqrestore(&ch->write_lock, flags);
|
||||
if (!sync)
|
||||
spin_unlock_irqrestore(&ch->write_lock, flags);
|
||||
return;
|
||||
}
|
||||
DIAG_LOG(DIAG_DEBUG_MUX, "full write_done\n");
|
||||
@@ -394,7 +397,8 @@ static void diag_usb_write_done(struct diag_usb_info *ch,
|
||||
len = 0;
|
||||
ctxt = 0;
|
||||
diagmem_free(driver, req, ch->mempool);
|
||||
spin_unlock_irqrestore(&ch->write_lock, flags);
|
||||
if(!sync)
|
||||
spin_unlock_irqrestore(&ch->write_lock, flags);
|
||||
}
|
||||
|
||||
static void diag_usb_notifier(void *priv, unsigned int event,
|
||||
@@ -439,7 +443,10 @@ static void diag_usb_notifier(void *priv, unsigned int event,
|
||||
&usb_info->read_done_work);
|
||||
break;
|
||||
case USB_DIAG_WRITE_DONE:
|
||||
diag_usb_write_done(usb_info, d_req);
|
||||
diag_usb_write_done(usb_info, d_req, 0);
|
||||
break;
|
||||
case USB_DIAG_WRITE_DONE_SYNC:
|
||||
diag_usb_write_done(usb_info, d_req, 1);
|
||||
break;
|
||||
default:
|
||||
pr_err_ratelimited("diag: Unknown event from USB diag\n");
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#define USB_DIAG_DISCONNECT 1
|
||||
#define USB_DIAG_WRITE_DONE 2
|
||||
#define USB_DIAG_READ_DONE 3
|
||||
#define USB_DIAG_WRITE_DONE_SYNC 4
|
||||
|
||||
struct diag_request {
|
||||
char *buf;
|
||||
|
||||
Reference in new issue
Block a user