From 8b7e4d1fee0448af1b0776b93d0e0b33f697100f Mon Sep 17 00:00:00 2001 From: Sriharsha Allenki Date: Wed, 23 Dec 2020 15:38:03 +0530 Subject: [PATCH] usb: gadget: gsi: Ensure the doorbell is blocked before suspend The doorbell is blocked as part of gsi_suspend, but a continuous resume and suspend calls can cause a race where resume handling overwrites the blocking of doorbell leading to the controller accessing IPA doorbell after suspend. Here are the series of events that is causing the issue. gsi_resume queue_work with EVT_RESUME gsi_suspend Block the doorbell queue_work with EVT_SUSPEND resume_work_handler xdci_resume Unblock the doorbell suspend_work_handler xdci_suspend Fix this by ensuring that the doorbell is blocked before suspend call to IPA as part of suspend handling. Change-Id: I4d0254c88ed3bec6338d040480b5df2e3f81251e Signed-off-by: Sriharsha Allenki --- drivers/usb/gadget/function/f_gsi.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/usb/gadget/function/f_gsi.c b/drivers/usb/gadget/function/f_gsi.c index 82cfe1776a36..64cae4fc43ee 100644 --- a/drivers/usb/gadget/function/f_gsi.c +++ b/drivers/usb/gadget/function/f_gsi.c @@ -785,6 +785,13 @@ static int ipa_suspend_work_handler(struct gsi_data_port *d_port) goto done; } + /* + * Ensure that the DBL is blocked before suspend. + */ + block_db = true; + usb_gsi_ep_op(gsi->d_port.in_ep, (void *)&block_db, + GSI_EP_OP_SET_CLR_BLOCK_DBL); + log_event_dbg("%s: Calling xdci_suspend", __func__); ret = ipa_usb_xdci_suspend(gsi->d_port.out_channel_handle, gsi->d_port.in_channel_handle, gsi->prot_id,