[v2] usb/fsl_usb2_udc: Report disconnect before unbinding

Submitted by Anton Vorontsov on Nov. 13, 2008, noon

Details

Message ID 20081113120046.GA29942@oksana.dev.rtsoft.ru
State Accepted, archived
Commit 1f15a506f356aa21c29b6a7b0e9e826695273dfc
Delegated to: Kumar Gala
Headers show

Commit Message

Anton Vorontsov Nov. 13, 2008, noon
Gadgets disable endpoints in their disconnect callbacks, so
we must call disconnect before unbinding.

The patch fixes following badness:

root@b1:~# insmod fsl_usb2_udc.ko
Freescale High-Speed USB SOC Device Controller driver (Apr 20, 2007)
root@b1:~# insmod g_ether.ko
g_ether gadget: using random self ethernet address
g_ether gadget: using random host ethernet address
usb0: MAC 26:07:ba:c0:44:33
usb0: HOST MAC 96:81:0c:05:4d:e3
g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
g_ether gadget: g_ether ready
fsl-usb2-udc: bind to driver g_ether
g_ether gadget: high speed config #1: CDC Ethernet (ECM)
root@b1:~# rmmod g_ether.ko
------------[ cut here ]------------
Badness at drivers/usb/gadget/composite.c:871
[...]
NIP [e10c3454] composite_unbind+0x24/0x15c [g_ether]
LR [e10aa454] usb_gadget_unregister_driver+0x13c/0x164 [fsl_usb2_udc]
Call Trace:
[df145e80] [ffffff94] 0xffffff94 (unreliable)
[df145eb0] [e10aa454] usb_gadget_unregister_driver+0x13c/0x164 [fsl_usb2_udc]
[df145ed0] [e10c4c40] usb_composite_unregister+0x3c/0x4c [g_ether]
[df145ee0] [c006bcc0] sys_delete_module+0x130/0x19c
[df145f40] [c00142d8] ret_from_syscall+0x0/0x38
[...]
unregistered gadget driver 'g_ether'

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---

v2:
- Comment update per Alan Stern review.

 drivers/usb/gadget/fsl_usb2_udc.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

Comments

David Brownell Nov. 18, 2008, 1:01 a.m.
On Thursday 13 November 2008, Anton Vorontsov wrote:
> Gadgets disable endpoints in their disconnect callbacks, so
> we must call disconnect before unbinding.
> 
> The patch fixes following badness:
> 
> root@b1:~# insmod fsl_usb2_udc.ko
> Freescale High-Speed USB SOC Device Controller driver (Apr 20, 2007)
> root@b1:~# insmod g_ether.ko
> g_ether gadget: using random self ethernet address
> g_ether gadget: using random host ethernet address
> usb0: MAC 26:07:ba:c0:44:33
> usb0: HOST MAC 96:81:0c:05:4d:e3
> g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
> g_ether gadget: g_ether ready
> fsl-usb2-udc: bind to driver g_ether
> g_ether gadget: high speed config #1: CDC Ethernet (ECM)
> root@b1:~# rmmod g_ether.ko
> ------------[ cut here ]------------
> Badness at drivers/usb/gadget/composite.c:871
> [...]
> NIP [e10c3454] composite_unbind+0x24/0x15c [g_ether]
> LR [e10aa454] usb_gadget_unregister_driver+0x13c/0x164 [fsl_usb2_udc]
> Call Trace:
> [df145e80] [ffffff94] 0xffffff94 (unreliable)
> [df145eb0] [e10aa454] usb_gadget_unregister_driver+0x13c/0x164 [fsl_usb2_udc]
> [df145ed0] [e10c4c40] usb_composite_unregister+0x3c/0x4c [g_ether]
> [df145ee0] [c006bcc0] sys_delete_module+0x130/0x19c
> [df145f40] [c00142d8] ret_from_syscall+0x0/0x38
> [...]
> unregistered gadget driver 'g_ether'
> 
> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>

Acked-by: David Brownell <dbrownell@users.sourceforge.net>


> ---
> 
> v2:
> - Comment update per Alan Stern review.
> 
>  drivers/usb/gadget/fsl_usb2_udc.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c
> index 091bb55..f3c6703 100644
> --- a/drivers/usb/gadget/fsl_usb2_udc.c
> +++ b/drivers/usb/gadget/fsl_usb2_udc.c
> @@ -1836,6 +1836,9 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
>  		nuke(loop_ep, -ESHUTDOWN);
>  	spin_unlock_irqrestore(&udc_controller->lock, flags);
>  
> +	/* report disconnect; the controller is already quiesced */
> +	driver->disconnect(&udc_controller->gadget);
> +
>  	/* unbind gadget and unhook driver. */
>  	driver->unbind(&udc_controller->gadget);
>  	udc_controller->gadget.dev.driver = NULL;
> -- 
> 1.5.6.3
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
>

Patch hide | download patch | download mbox

diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c
index 091bb55..f3c6703 100644
--- a/drivers/usb/gadget/fsl_usb2_udc.c
+++ b/drivers/usb/gadget/fsl_usb2_udc.c
@@ -1836,6 +1836,9 @@  int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
 		nuke(loop_ep, -ESHUTDOWN);
 	spin_unlock_irqrestore(&udc_controller->lock, flags);
 
+	/* report disconnect; the controller is already quiesced */
+	driver->disconnect(&udc_controller->gadget);
+
 	/* unbind gadget and unhook driver. */
 	driver->unbind(&udc_controller->gadget);
 	udc_controller->gadget.dev.driver = NULL;