kernel_optimize_test/drivers/usb/musb
Paul Cercueil 1cf76e4ca6 usb: musb: Fix runtime PM race in musb_queue_resume_work
commit 0eaa1a3714db34a59ce121de5733c3909c529463 upstream.

musb_queue_resume_work() would call the provided callback if the runtime
PM status was 'active'. Otherwise, it would enqueue the request if the
hardware was still suspended (musb->is_runtime_suspended is true).

This causes a race with the runtime PM handlers, as it is possible to be
in the case where the runtime PM status is not yet 'active', but the
hardware has been awaken (PM resume function has been called).

When hitting the race, the resume work was not enqueued, which probably
triggered other bugs further down the stack. For instance, a telnet
connection on Ingenic SoCs would result in a 50/50 chance of a
segmentation fault somewhere in the musb code.

Rework the code so that either we call the callback directly if
(musb->is_runtime_suspended == 0), or enqueue the query otherwise.

Fixes: ea2f35c01d ("usb: musb: Fix sleeping function called from invalid context for hdrc glue")
Cc: stable@vger.kernel.org # v4.9+
Tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20210123142502.16980-1-paul@crapouillou.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-03-04 11:38:24 +01:00
..
am35x.c usb: musb: remove references to default_a of struct usb_otg 2018-05-22 12:03:25 +02:00
cppi_dma.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
cppi_dma.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
da8xx.c usb: musb: remove an unused variable 2018-05-31 12:44:39 +02:00
davinci.c usb: musb: davinci: Convert to use GPIO descriptor 2020-01-15 14:47:00 +01:00
davinci.h USB: musb: Use the correct style for SPDX License Identifier 2020-04-16 14:32:47 +02:00
jz4740.c usb: musb: jz4740: Prevent lockup when CONFIG_SMP is set 2020-05-25 13:36:30 +02:00
Kconfig USB: rename USB OTG hub configuration option 2020-06-19 08:58:42 +02:00
Makefile usb: musb: remove dummy driver musb_am335x.c 2020-01-15 14:47:00 +01:00
mediatek.c usb: musb: mediatek: add reset FADDR to zero in reset interrupt handle 2020-05-25 13:36:30 +02:00
musb_core.c usb: musb: Fix runtime PM race in musb_queue_resume_work 2021-03-04 11:38:24 +01:00
musb_core.h USB: musb: Use the correct style for SPDX License Identifier 2020-04-16 14:32:47 +02:00
musb_cppi41.c usb: musb: remove duplicated quirks flag 2018-05-22 12:03:24 +02:00
musb_debug.h USB: musb: Use the correct style for SPDX License Identifier 2020-04-16 14:32:47 +02:00
musb_debugfs.c usb: musb: Fix runtime PM imbalance on error 2020-05-25 13:36:31 +02:00
musb_dma.h USB: musb: Use the correct style for SPDX License Identifier 2020-04-16 14:32:47 +02:00
musb_dsps.c Revert "usb: musb: convert to devm_platform_ioremap_resource_byname" 2020-11-13 14:30:23 +01:00
musb_gadget_ep0.c usb: musb: gadget: Use fallthrough pseudo-keyword 2020-10-10 12:32:29 +02:00
musb_gadget.c usb: Spelling s/enpoint/endpoint/ 2019-11-04 15:53:00 +01:00
musb_gadget.h USB: musb: Use the correct style for SPDX License Identifier 2020-04-16 14:32:47 +02:00
musb_host.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
musb_host.h USB: musb: Remove unused inline function 2020-07-15 16:48:10 +02:00
musb_io.h USB: musb: Use the correct style for SPDX License Identifier 2020-04-16 14:32:47 +02:00
musb_regs.h USB: musb: Use the correct style for SPDX License Identifier 2020-04-16 14:32:47 +02:00
musb_trace.c USB: musb: Remove redundant license text 2017-11-07 15:45:01 +01:00
musb_trace.h USB: musb: Use the correct style for SPDX License Identifier 2020-04-16 14:32:47 +02:00
musb_virthub.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
musbhsdma.c usb: musb: Add musb_clearb/w() interface 2020-01-15 14:46:59 +01:00
omap2430.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
omap2430.h USB: musb: Use the correct style for SPDX License Identifier 2020-04-16 14:32:47 +02:00
sunxi.c usb: musb: Add musb_clearb/w() interface 2020-01-15 14:46:59 +01:00
tusb6010_omap.c USB: musb: Remove redundant license text 2017-11-07 15:45:01 +01:00
tusb6010.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
tusb6010.h USB: musb: Use the correct style for SPDX License Identifier 2020-04-16 14:32:47 +02:00
ux500_dma.c usb: musb/ux500: Use dma_request_chan() instead dma_request_slave_channel() 2020-01-15 14:46:58 +01:00
ux500.c usb: musb: remove references to default_a of struct usb_otg 2018-05-22 12:03:25 +02:00