Re: [PATCH] usb otg: use atomic notifier instead of blocking notifier

From: Ming Lei
Date: Wed Jan 19 2011 - 10:19:12 EST


Hi Yang,

2011/1/19 Yang Ruirui <ruirui.r.yang@xxxxxxxxx>:
> [   28.990997] [<c00326a0>] (unwind_backtrace+0x0/0xec) from [<c007a39c>] (print_usage_bug+0x170/0x1b4)
> [   29.007293] [<c007a39c>] (print_usage_bug+0x170/0x1b4) from [<c007a738>] (mark_lock+0x358/0x628)
> [   29.019836] [<c007a738>] (mark_lock+0x358/0x628) from [<c007c118>] (__lock_acquire+0x554/0x1730)
> [   29.032409] [<c007c118>] (__lock_acquire+0x554/0x1730) from [<c007d354>] (lock_acquire+0x60/0x74)
> [   29.045166] [<c007d354>] (lock_acquire+0x60/0x74) from [<c037e6d8>] (down_read+0x48/0x5c)
> [   29.057250] [<c037e6d8>] (down_read+0x48/0x5c) from [<c0070770>] (__blocking_notifier_call_chain+0x2c/0x5c)
> [   29.074920] [<c0070770>] (__blocking_notifier_call_chain+0x2c/0x5c) from [<c00707b4>] (blocking_notifier_call_chain+0x14/0x18)
> [   29.094573] [<c00707b4>] (blocking_notifier_call_chain+0x14/0x18) from [<c02784d8>] (musb_gadget_vbus_draw+0x38/0x60)

I am a little confused, why is blocking_notifier_call_chain called from
musb_gadget_vbus_draw? See source code of musb_gadget_vbus_draw:

1587 static int musb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
1588 {
1589 struct musb *musb = gadget_to_musb(gadget);
1590
1591 if (!musb->xceiv->set_power)
1592 return -EOPNOTSUPP;
1593 return otg_set_power(musb->xceiv, mA);
1594 }

>
> Actually the blocking notifier chain runs in process context, so not fit for use here.
>
> For mainline kernel there's such issue as well.
> Here fix this problem by changing to use atomic_notifier.

Are you sure the issue can be reproduced in 2.6.37 or -next tree?

In mainline code(2.6.37), blocking_notifier_call_chain is only called in
threaded irq handler of otg driver wrt. musb driver, so seems enough.

thanks,
--
Lei Ming
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/