OSDN Git Service

usb: gadget: f_mass_storage: Perform async runtime suspend after ep disable
authorVijayavardhan Vennapusa <vvreddy@codeaurora.org>
Wed, 5 Apr 2017 07:07:46 +0000 (12:37 +0530)
committerVijayavardhan Vennapusa <vvreddy@codeaurora.org>
Fri, 7 Apr 2017 06:13:07 +0000 (11:43 +0530)
commit 82f29356165b6a584 ("usb: gadget: f_mass_storage: Allow USB LPM
upon ep disable") decrements power usage count by 1 for dwc3 device
in thread handler as part of do_set_interface(). fsg_disable() and
fsg_unbind() will raise exception for status change so that status change
is handled in thread handler. Due to this, there is a chance that
fsg_thread can run two times and results in calling do_set_interface()
twice for disabling endpoints. This causes decrementing power usage count
two times instead of 1 and power usage count can become negative. If cable
is disconnected at this time, it could cause unclocked access or fsg_thread
gets stuck. common->fsg bieng non NULL confirms that MSC interface is being
enabled. Hence fix the issue by decrementing power usage count only right
after disbling endpoints as disabling endpoints happens once due to check
of common->fsg.

Change-Id: Ia870838f5a7055436b7412fec5910b5cdbb42de2
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
drivers/usb/gadget/function/f_mass_storage.c

index 1fd5a95..59d6ac6 100644 (file)
@@ -2284,16 +2284,15 @@ reset:
                        fsg->bulk_out_enabled = 0;
                }
 
+               /* allow usb LPM after eps are disabled */
+               usb_gadget_autopm_put_async(common->gadget);
                common->fsg = NULL;
                wake_up(&common->fsg_wait);
        }
 
        common->running = 0;
-       if (!new_fsg || rc) {
-               /* allow usb LPM after eps are disabled */
-               usb_gadget_autopm_put_async(common->gadget);
+       if (!new_fsg || rc)
                return rc;
-       }
 
        common->fsg = new_fsg;
        fsg = common->fsg;