From 265b668a1047f345aa2b69178f54dbf38c95c47b Mon Sep 17 00:00:00 2001 From: Mayank Rana Date: Wed, 15 Mar 2017 16:12:35 -0700 Subject: [PATCH] usb: gadget: f_mass_storage: Perform async runtime resume upon set_alt commit 82f29356165b6a584 ("usb: gadget: f_mass_storage: Allow USB LPM upon ep disable") just increments power usage count by 1 for dwc3 device in thread handler. Since child count for dwc3 parent remains 0, there is possibility of dwc3 parent going into suspend even if dwc3 power usage count is set to 1. This causes unclocked register access as mdwc gets runtime suspended and mass storage thread handler disables the endpoint. Fix this issue by calling usb_gadget_autopm_get_async() in set_alt which increments dwc3 power usage count and carry out resume asynchronously. Change-Id: Iccce928590d8e67e234f0aa371f78eb1e6a326b7 Signed-off-by: Mayank Rana --- drivers/usb/gadget/function/f_mass_storage.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index e309dec68a75..1fd5a95b6e99 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c @@ -2336,9 +2336,6 @@ reset: bh->outreq->complete = bulk_out_complete; } - /* prevents usb LPM until thread runs to completion */ - usb_gadget_autopm_get_noresume(common->gadget); - common->running = 1; for (i = 0; i < ARRAY_SIZE(common->luns); ++i) if (common->luns[i]) @@ -2354,6 +2351,10 @@ static int fsg_set_alt(struct usb_function *f, unsigned intf, unsigned alt) { struct fsg_dev *fsg = fsg_from_func(f); fsg->common->new_fsg = fsg; + + /* prevents usb LPM until thread runs to completion */ + usb_gadget_autopm_get_async(fsg->common->gadget); + raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE); return USB_GADGET_DELAYED_STATUS; }