Skip to contentSkip to conversation

input: do not use tasklet_disable before tasklet_kill

PATCH Applied Xiaotian Feng 5 participants 8 messages Oct 31, 2012 – Nov 25, 2012

Subsystems (6)
Networking Network drivers USB HID +2 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 input: do not use tasklet_disable before tasklet_kill

If tasklet_disable() is called before related tasklet handled, tasklet_kill will never be finished. tasklet_kill is enough.

Cc Dmitry Torokhov <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Sourav Poddar <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/input/keyboard/omap-keypad.c |    3 +--
 drivers/input/serio/hil_mlc.c        |    1 -
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/input/keyboard/omap-keypad.c +1 -2
index 4a5fcc8..6c52447 100644
@@ -362,12 +362,11 @@ static int __devexit omap_kp_remove(struct platform_device *pdev)
 	struct omap_kp *omap_kp = platform_get_drvdata(pdev);
 
 	/* disable keypad interrupt handling */
-	tasklet_disable(&kp_tasklet);
+	tasklet_kill(&kp_tasklet);
 	omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
 	free_irq(omap_kp->irq, omap_kp);
 
 	del_timer_sync(&omap_kp->timer);
-	tasklet_kill(&kp_tasklet);
 
 	/* unregister everything */
 	input_unregister_device(omap_kp->input);
drivers/input/serio/hil_mlc.c +0 -1
index bfd3865..7fc1700 100644
@@ -1011,7 +1011,6 @@ static void __exit hil_mlc_exit(void)
 {
 	del_timer_sync(&hil_mlcs_kicker);
 
-	tasklet_disable(&hil_mlcs_tasklet);
 	tasklet_kill(&hil_mlcs_tasklet);
 }
 
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 2/3 usb: gadget: fsl_qe_udc: do not use tasklet_disable before tasklet_kill

If tasklet_disable() is called before related tasklet handled, tasklet_kill will never be finished. tasklet_kill is enough.

---
 drivers/usb/gadget/fsl_qe_udc.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/usb/gadget/fsl_qe_udc.c +1 -3
index b09452d..4ad3b82 100644
@@ -2661,7 +2661,7 @@ static int __devexit qe_udc_remove(struct platform_device *ofdev)
 	usb_del_gadget_udc(&udc->gadget);
 
 	udc->done = &done;
-	tasklet_disable(&udc->rx_tasklet);
+	tasklet_kill(&udc->rx_tasklet);
 
 	if (udc->nullmap) {
 		dma_unmap_single(udc->gadget.dev.parent,
@@ -2698,8 +2698,6 @@ static int __devexit qe_udc_remove(struct platform_device *ofdev)
 	free_irq(udc->usb_irq, udc);
 	irq_dispose_mapping(udc->usb_irq);
 
-	tasklet_kill(&udc->rx_tasklet);
-
 	iounmap(udc->usb_regs);
 
 	device_unregister(&udc->gadget.dev);
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH 3/3 tipc: do not use tasklet_disable before tasklet_kill

In reply to Xiaotian Feng

If tasklet_disable() is called before related tasklet handled, tasklet_kill will never be finished. tasklet_kill is enough.

---
 net/tipc/handler.c |    1 -
 1 file changed, 1 deletion(-)
net/tipc/handler.c +0 -1
index 111ff83..b36f0fc 100644
@@ -116,7 +116,6 @@ void tipc_handler_stop(void)
 		return;
 
 	handler_enabled = 0;
-	tasklet_disable(&tipc_tasklet);
 	tasklet_kill(&tipc_tasklet);
 
 	spin_lock_bh(&qitem_lock);
Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH 2/3] usb: gadget: fsl_qe_udc: do not use tasklet_disable before tasklet_kill

In reply to Xiaotian Feng
Quoted 2 lines · Xiaotian Feng

If tasklet_disable() is called before related tasklet handled, tasklet_kill will never be finished. tasklet_kill is enough.

how did you test this ? Why changing FSL driver instead of switching over to chipidea which is supposed to be shared by every licensee of the chipidea core ?

Quoted 35 lines
---
 drivers/usb/gadget/fsl_qe_udc.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/usb/gadget/fsl_qe_udc.c +1 -3
index b09452d..4ad3b82 100644
@@ -2661,7 +2661,7 @@ static int __devexit qe_udc_remove(struct platform_device *ofdev)
 	usb_del_gadget_udc(&udc->gadget);
 
 	udc->done = &done;
-	tasklet_disable(&udc->rx_tasklet);
+	tasklet_kill(&udc->rx_tasklet);
 
 	if (udc->nullmap) {
 		dma_unmap_single(udc->gadget.dev.parent,
@@ -2698,8 +2698,6 @@ static int __devexit qe_udc_remove(struct platform_device *ofdev)
 	free_irq(udc->usb_irq, udc);
 	irq_dispose_mapping(udc->usb_irq);
 
-	tasklet_kill(&udc->rx_tasklet);
-
 	iounmap(udc->usb_regs);
 
 	device_unregister(&udc->gadget.dev);
Signature · 1 line
1.7.9.5
Signature · 1 line
balbi
#3 lore raw

Re: [PATCH 2/3] usb: gadget: fsl_qe_udc: do not use tasklet_disable before tasklet_kill

Quoted 7 lines · Felipe Balbi
Quoted 2 lines · Xiaotian Feng

If tasklet_disable() is called before related tasklet handled, tasklet_kill will never be finished. tasklet_kill is enough.

how did you test this ? Why changing FSL driver instead of switching over to chipidea which is supposed to be shared by every licensee of the chipidea core ?

The QE UDC is an private controller that is not compatible with the Chipidea core.

- Leo

#4 lore raw

Re: [PATCH 2/3] usb: gadget: fsl_qe_udc: do not use tasklet_disable before tasklet_kill

Hi,

Quoted 11 lines · Li Yang
Quoted 7 lines · Felipe Balbi
Quoted 2 lines · Xiaotian Feng

If tasklet_disable() is called before related tasklet handled, tasklet_kill will never be finished. tasklet_kill is enough.

how did you test this ? Why changing FSL driver instead of switching over to chipidea which is supposed to be shared by every licensee of the chipidea core ?

The QE UDC is an private controller that is not compatible with the Chipidea core.

thanks for the clarification, but you still haven't answered how you tested this ;-)

Signature · 1 line
balbi
maintainer
#7 lore raw
In reply to Xiaotian Feng

Hi Xiaotian,

Quoted 3 lines · Xiaotian Feng

If tasklet_disable() is called before related tasklet handled, tasklet_kill will never be finished. tasklet_kill is enough.

Could you please elaborate on this? Needing to disable tasket before killing it is quite often needed when dealing with self-rescheduling tasklets and so tasklet_disable() followed by tasklet_kill() must work. If it does not we need to take care of it in softirq code instead of individual drivers.

Quoted 17 lines
Cc Dmitry Torokhov <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Sourav Poddar <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/input/keyboard/omap-keypad.c |    3 +--
 drivers/input/serio/hil_mlc.c        |    1 -
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/input/keyboard/omap-keypad.c +0 -0
index 4a5fcc8..6c52447 100644

drivers/input/keyboard/omap-keypad.c static int __devexit omap_kp_remove(struct platform_device *pdev) · line 370

Quoted 10 lines
drivers/input/keyboard/omap-keypad.c +1 -2
@@ -362,12 +362,11 @@ static int __devexit omap_kp_remove(struct platform_device *pdev)
 	struct omap_kp *omap_kp = platform_get_drvdata(pdev);
 
 	/* disable keypad interrupt handling */
-	tasklet_disable(&kp_tasklet);
+	tasklet_kill(&kp_tasklet);
 	omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
 	free_irq(omap_kp->irq, omap_kp);
 
 	del_timer_sync(&omap_kp->timer);
-	tasklet_kill(&kp_tasklet);

Exactly like here. If we do not disable tasklet before disabling IRQ and freeing timer we may get into scenario when timer schedules tasket and tasklet schedules timer again after we canceled it.

drivers/input/serio/hil_mlc.c static void __exit hil_mlc_exit(void) · line 1014

Quoted 13 lines
drivers/input/keyboard/omap-keypad.c +0 -0
 	/* unregister everything */
 	input_unregister_device(omap_kp->input);
drivers/input/serio/hil_mlc.c +0 -1
index bfd3865..7fc1700 100644
@@ -1011,7 +1011,6 @@ static void __exit hil_mlc_exit(void)
 {
 	del_timer_sync(&hil_mlcs_kicker);
 
-	tasklet_disable(&hil_mlcs_tasklet);
 	tasklet_kill(&hil_mlcs_tasklet);

This seems like safe change.

Thanks.

Signature · 1 line
Dmitry