Skip to contentSkip to conversation

omap2430 musb: Make musb_otg_notification non-blocking

PATCH Applied NeilBrown 2 participants 4 messages Dec 30, 2011 – Jan 25, 2012

Subsystems (3)
lore
Share & tools
lore

NeilBrown

author
#0 lore raw

PATCH 1/1 omap2430 musb: Make musb_otg_notification non-blocking

This callback is on an 'atomic notificaitons' queue but is written as a blocking notifier.

Convert to use a work-queue to run from non-atomic context.

drivers/usb/musb/musb_core.h +2 -0
index b3c065a..fb90d94 100644
@@ -352,6 +352,8 @@ struct musb {
 
 	struct timer_list	otg_timer;
 	struct notifier_block	nb;
+	struct work_struct	notify_work;
+	unsigned long		event;
 
 	struct dma_controller	*dma_controller;
 
drivers/usb/musb/omap2430.c +17 -5
index ba85f27..a0fe317 100644
@@ -223,11 +223,11 @@ static inline void omap2430_low_level_init(struct musb *musb)
 	musb_writel(musb->mregs, OTG_FORCESTDBY, l);
 }
 
-/* blocking notifier support */
-static int musb_otg_notifications(struct notifier_block *nb,
-		unsigned long event, void *unused)
+/* work function for atomic notifier  */
+static void musb_otg_notify_work(struct work_struct *ws)
 {
-	struct musb	*musb = container_of(nb, struct musb, nb);
+	struct musb	*musb = container_of(ws, struct musb, notify_work);
+	unsigned long event = musb->event;
 	struct device *dev = musb->controller;
 	struct musb_hdrc_platform_data *pdata = dev->platform_data;
 	struct omap_musb_board_data *data = pdata->board_data;
@@ -274,8 +274,18 @@ static int musb_otg_notifications(struct notifier_block *nb,
 		break;
 	default:
 		dev_dbg(musb->controller, "ID float\n");
-		return NOTIFY_DONE;
+		break;
 	}
+}
+
+static int musb_otg_notifications(struct notifier_block *nb,
+				  unsigned long event,
+				  void *unused)
+{
+	struct musb *musb = container_of(nb, struct musb, nb);
+
+	musb->event = event;
+	schedule_work(&musb->notify_work);
 
 	return NOTIFY_OK;
 }
@@ -323,6 +333,7 @@ static int omap2430_musb_init(struct musb *musb)
 			musb_readl(musb->mregs, OTG_INTERFSEL),
 			musb_readl(musb->mregs, OTG_SIMENABLE));
 
+	INIT_WORK(&musb->notify_work, musb_otg_notify_work);
 	musb->nb.notifier_call = musb_otg_notifications;
 	status = otg_register_notifier(musb->xceiv, &musb->nb);
 
@@ -386,6 +397,7 @@ static void omap2430_musb_disable(struct musb *musb)
 static int omap2430_musb_exit(struct musb *musb)
 {
 	del_timer_sync(&musb_idle_timer);
+	cancel_work_sync(&musb->notify_work);
 
 	omap2430_low_level_exit(musb);
 	otg_put_transceiver(musb->xceiv);
#1 lore raw
Quoted 8 lines · NeilBrown

This callback is on an 'atomic notificaitons' queue but is written as a blocking notifier.

Convert to use a work-queue to run from non-atomic context.

doesn't apply.

Signature · 1 line
balbi
author
#2 lore raw
Quoted 12 lines · On Tue, 24 Jan 2012 10:56:12 +0200 Felipe Balbi <[email protected]> wrote:
Quoted 8 lines · NeilBrown

This callback is on an 'atomic notificaitons' queue but is written as a blocking notifier.

Convert to use a work-queue to run from non-atomic context.

doesn't apply.

It did 1 month ago when I sent it :-)

It seems that commit 712d8efafbbcbe617f9ad706f6ca1ffea4bbf2e8 fixed the same problem already.

The following patch adds a few little bits

Thanks,
NeilBrown

musb/omap2430 minor cleanups.

1/ remove incorrect comment (it is a non-blocking notifier) 2/ Use correct symbolic return value for notifier
3/ Make sure otg_notifier_work is cancelled before module exit.

drivers/usb/musb/omap2430.c +2 -2
index c27bbbf..df719ea 100644
@@ -222,7 +222,6 @@ static inline void omap2430_low_level_init(struct musb *musb)
 	musb_writel(musb->mregs, OTG_FORCESTDBY, l);
 }
 
-/* blocking notifier support */
 static int musb_otg_notifications(struct notifier_block *nb,
 		unsigned long event, void *unused)
 {
@@ -231,7 +230,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
 	musb->xceiv_event = event;
 	schedule_work(&musb->otg_notifier_work);
 
-	return 0;
+	return NOTIFY_OK;
 }
 
 static void musb_otg_notifier_work(struct work_struct *data_notifier_work)
@@ -386,6 +385,7 @@ static void omap2430_musb_disable(struct musb *musb)
 static int omap2430_musb_exit(struct musb *musb)
 {
 	del_timer_sync(&musb_idle_timer);
+	cancel_work_sync(&musb->otg_notifier_work);
 
 	omap2430_low_level_exit(musb);
 	otg_put_transceiver(musb->xceiv);
Applied
#3 lore raw
Quoted 27 lines · NeilBrown
Quoted 12 lines · On Tue, 24 Jan 2012 10:56:12 +0200 Felipe Balbi <[email protected]> wrote:
Quoted 8 lines · NeilBrown

This callback is on an 'atomic notificaitons' queue but is written as a blocking notifier.

Convert to use a work-queue to run from non-atomic context.

doesn't apply.

It did 1 month ago when I sent it :-)

It seems that commit 712d8efafbbcbe617f9ad706f6ca1ffea4bbf2e8 fixed the same problem already.

The following patch adds a few little bits

Thanks,
NeilBrown

Quoted 7 lines

musb/omap2430 minor cleanups.

1/ remove incorrect comment (it is a non-blocking notifier) 2/ Use correct symbolic return value for notifier
3/ Make sure otg_notifier_work is cancelled before module exit.

applied, thanks

Signature · 1 line
balbi