Skip to content

Commit 0393ff7

Browse files
Sebastian Andrzej Siewiorgregkh
Sebastian Andrzej Siewior
authored andcommitted
usb: musb: only cancel work if it is initialized
commit 66fadea upstream. Since commit c5340bd ("usb: musb: cancel work on removal") the workqueue is cancelled but then if we bail out before the workqueue is setup we get this: |INFO: trying to register non-static key. |the code is fine but needs lockdep annotation. |turning off the locking correctness validator. |CPU: 0 PID: 708 Comm: modprobe Not tainted 3.12.0+ #435 |[<c00867bc>] (lock_acquire+0xf0/0x108) from [<c00529d0>] (flush_work+0x38/0x2ec) |[<c00529d0>] (flush_work+0x38/0x2ec) from [<c0052d24>] (__cancel_work_timer+0xa0/0x134) |[<c0052d24>] (__cancel_work_timer+0xa0/0x134) from [<bf0e4ae4>] (musb_free+0x40/0x60 [musb_hdrc]) |[<bf0e4ae4>] (musb_free+0x40/0x60 [musb_hdrc]) from [<bf0e5364>] (musb_probe+0x678/0xb78 [musb_hdrc]) |[<bf0e5364>] (musb_probe+0x678/0xb78 [musb_hdrc]) from [<c0294bf0>] (platform_drv_probe+0x1c/0x24) |[<c0294bf0>] (platform_drv_probe+0x1c/0x24) from [<c0293970>] (driver_probe_device+0x90/0x224) |[<c0293970>] (driver_probe_device+0x90/0x224) from [<c0291ef0>] (bus_for_each_drv+0x60/0x8c) |[<c0291ef0>] (bus_for_each_drv+0x60/0x8c) from [<c02938bc>] (device_attach+0x80/0xa4) |[<c02938bc>] (device_attach+0x80/0xa4) from [<c0292b24>] (bus_probe_device+0x88/0xac) |[<c0292b24>] (bus_probe_device+0x88/0xac) from [<c0291490>] (device_add+0x388/0x6c8) |[<c0291490>] (device_add+0x388/0x6c8) from [<c02952a0>] (platform_device_add+0x188/0x22c) |[<c02952a0>] (platform_device_add+0x188/0x22c) from [<bf11ea30>] (dsps_probe+0x294/0x394 [musb_dsps]) |[<bf11ea30>] (dsps_probe+0x294/0x394 [musb_dsps]) from [<c0294bf0>] (platform_drv_probe+0x1c/0x24) |platform musb-hdrc.1.auto: Driver musb-hdrc requests probe deferral |musb-hdrc musb-hdrc.1.auto: musb_init_controller failed with status -517 This patch moves the init part to earlier part so it can be cleaned as part of the fail3 label because now it is surrounded by the fail4 label. Step two is to remove it from musb_free() and add it to the two cleanup paths (error path and device removal) separately. Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Felipe Balbi <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 00e0aaa commit 0393ff7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/usb/musb/musb_core.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,6 @@ static void musb_free(struct musb *musb)
18091809
disable_irq_wake(musb->nIrq);
18101810
free_irq(musb->nIrq, musb);
18111811
}
1812-
cancel_work_sync(&musb->irq_work);
18131812

18141813
musb_host_free(musb);
18151814
}
@@ -1891,6 +1890,9 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
18911890
musb_platform_disable(musb);
18921891
musb_generic_disable(musb);
18931892

1893+
/* Init IRQ workqueue before request_irq */
1894+
INIT_WORK(&musb->irq_work, musb_irq_work);
1895+
18941896
/* setup musb parts of the core (especially endpoints) */
18951897
status = musb_core_init(plat->config->multipoint
18961898
? MUSB_CONTROLLER_MHDRC
@@ -1900,9 +1902,6 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
19001902

19011903
setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) musb);
19021904

1903-
/* Init IRQ workqueue before request_irq */
1904-
INIT_WORK(&musb->irq_work, musb_irq_work);
1905-
19061905
/* attach to the IRQ */
19071906
if (request_irq(nIrq, musb->isr, 0, dev_name(dev), musb)) {
19081907
dev_err(dev, "request_irq %d failed!\n", nIrq);
@@ -1976,6 +1975,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
19761975
musb_host_cleanup(musb);
19771976

19781977
fail3:
1978+
cancel_work_sync(&musb->irq_work);
19791979
if (musb->dma_controller)
19801980
dma_controller_destroy(musb->dma_controller);
19811981
pm_runtime_put_sync(musb->controller);
@@ -2037,6 +2037,7 @@ static int musb_remove(struct platform_device *pdev)
20372037
if (musb->dma_controller)
20382038
dma_controller_destroy(musb->dma_controller);
20392039

2040+
cancel_work_sync(&musb->irq_work);
20402041
musb_free(musb);
20412042
device_init_wakeup(dev, 0);
20422043
return 0;

0 commit comments

Comments
 (0)