All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ana Rodriguez Lopez <rodrilopez.ana@gmail.com>
To: balbi@kernel.org
Cc: linux-usb@vger.kernel.org
Subject: at91_udc Bug: USB gadget unplug not noticed by kernel
Date: Mon, 22 Jan 2018 13:38:41 +0100	[thread overview]
Message-ID: <d585636e-3b03-4dc0-4549-e6293260bb07@gmail.com> (raw)

Hello Felipe,

I am not an expert on Linux Kernel but I have a problem with the USB
gadget and the origin seems to be there.

I am working with Kernel 4.13.0 on Stamp 9G20 from Taskit GmbH (CPU:
Atmel AT91SAM9G20 Embedded Processor featuring an ARM926EJ-STM ARM®
Thumb® Core).

The problem is, the disconnection of the USB gadget cable is not
acquainted by the Kernel. There is nothing in dmesg.

When I connect the cable, there is a reaction visible in dmesg:

[ 1711.406250] g_ether gadget: full-speed config #1: CDC Ethernet (ECM)
[ 1711.414062] IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready

Kernel modules loaded:

Module                  Size  Used by
usb_f_ecm               9123  1
g_ether                 4488  0
usb_f_rndis            20935  2 g_ether
u_ether                10799  3 usb_f_ecm,g_ether,usb_f_rndis
libcomposite           44168  3 usb_f_ecm,g_ether,usb_f_rndis

After disconnecting the cable, usb0 is still shown as connected:

4: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
state UP group default qlen 1000
    link/ether 8e:8e:76:28:44:ab brd ff:ff:ff:ff:ff:ff
    inet 169.254.169.4/16 brd 169.254.255.255 scope link usb0
       valid_lft forever preferred_lft forever
    inet6 fe80::8c8e:76ff:fe28:44ab/64 scope link
       valid_lft forever preferred_lft forever


We used to work with an older Kernel (3.2) and we had a patch for this
problem. We expected it to be solved in 4.13 but it isn't.

             /*

Please let me know if I can supply more information or if I should
address another maintainer.


Thanks

Ana
---
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

diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 8efe0fa..423fc6a 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1395,6 +1395,7 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc)
     u32            rescans = 5;
     int            disable_clock = 0;
     unsigned long        flags;
+    struct usb_ctrlrequest    req;
 
     spin_lock_irqsave(&udc->lock, flags);
 
@@ -1443,7 +1444,18 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc)
             at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_RXSUSP);
             /* VDBG("bus suspend\n"); */
             if (udc->suspended)
-                continue;
+                continue;   
+
+            /* tell the driver the disconnect */
+            if (udc->driver) {
+                spin_unlock(&udc->lock);
+                memset(&req, 0, sizeof(req));
+                req.bRequestType = USB_DIR_OUT | USB_TYPE_STANDARD |
USB_RECIP_DEVICE;    
+                req.bRequest = USB_REQ_SET_CONFIGURATION;    
+                status = udc->driver->setup(&udc->gadget, &req);
+                spin_lock(&udc->lock);
+            }
+
             udc->suspended = 1;
 

             reply	other threads:[~2018-01-22 12:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-22 12:38 Ana Rodriguez Lopez [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-01-22 12:49 at91_udc Bug: USB gadget unplug not noticed by kernel Felipe Balbi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d585636e-3b03-4dc0-4549-e6293260bb07@gmail.com \
    --to=rodrilopez.ana@gmail.com \
    --cc=balbi@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.