]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
USB-RNDIS: Send RNDIS state on disconnecting
authorVitaly Kuzmichev <vkuzmichev@mvista.com>
Fri, 11 Feb 2011 15:18:35 +0000 (18:18 +0300)
committerRemy Bohmer <linux@bohmer.net>
Sat, 19 Feb 2011 19:32:38 +0000 (20:32 +0100)
Add waiting for receiving Ethernet gadget state on the Windows host
side before dropping pullup, but keep it for debug.

Signed-off-by: Vitaly Kuzmichev <vkuzmichev@mvista.com>
drivers/usb/gadget/ether.c
drivers/usb/gadget/rndis.c
drivers/usb/gadget/rndis.h

index f909267f65a6341d51645a30617923a564b3c261..9fb0e80ad1f3b01a13d881fd09304d346d2d10a1 100644 (file)
@@ -1921,10 +1921,22 @@ static void eth_start(struct eth_dev *dev, gfp_t gfp_flags)
 
 static int eth_stop(struct eth_dev *dev)
 {
+#ifdef RNDIS_COMPLETE_SIGNAL_DISCONNECT
+       unsigned long ts;
+       unsigned long timeout = CONFIG_SYS_HZ; /* 1 sec to stop RNDIS */
+#endif
+
        if (rndis_active(dev)) {
                rndis_set_param_medium(dev->rndis_config, NDIS_MEDIUM_802_3, 0);
                rndis_signal_disconnect(dev->rndis_config);
 
+#ifdef RNDIS_COMPLETE_SIGNAL_DISCONNECT
+               /* Wait until host receives OID_GEN_MEDIA_CONNECT_STATUS */
+               ts = get_timer(0);
+               while (get_timer(ts) < timeout)
+                       usb_gadget_handle_interrupts();
+#endif
+
                rndis_uninit(dev->rndis_config);
                dev->rndis = 0;
        }
@@ -2486,6 +2498,17 @@ void usb_eth_halt(struct eth_device *netdev)
        if (!dev->gadget)
                return;
 
+       /*
+        * Some USB controllers may need additional deinitialization here
+        * before dropping pull-up (also due to hardware issues).
+        * For example: unhandled interrupt with status stage started may
+        * bring the controller to fully broken state (until board reset).
+        * There are some variants to debug and fix such cases:
+        * 1) In the case of RNDIS connection eth_stop can perform additional
+        * interrupt handling. See RNDIS_COMPLETE_SIGNAL_DISCONNECT definition.
+        * 2) 'pullup' callback in your UDC driver can be improved to perform
+        * this deinitialization.
+        */
        eth_stop(dev);
 
        usb_gadget_disconnect(dev->gadget);
index 3e3f740ea55c555ee1883a393b5dc6049d4ed4af..886c0936e6ae74e2b7c2e6d8366039412bf855f9 100644 (file)
@@ -995,7 +995,12 @@ int rndis_signal_disconnect(int configNr)
        rndis_per_dev_params[configNr].media_state
                        = NDIS_MEDIA_STATE_DISCONNECTED;
 
+#ifdef RNDIS_COMPLETE_SIGNAL_DISCONNECT
+       return rndis_indicate_status_msg(configNr,
+                                         RNDIS_STATUS_MEDIA_DISCONNECT);
+#else
        return 0;
+#endif
 }
 
 void rndis_uninit(int configNr)
index 73a1204a0310807f6072d38aac78089baf1556cf..d9e3a75287220a0f18e02cfff94d6b044c694c3a 100644 (file)
 
 #include "ndis.h"
 
+/*
+ * By default rndis_signal_disconnect does not send status message about
+ * RNDIS disconnection to USB host (indicated as cable disconnected).
+ * Define RNDIS_COMPLETE_SIGNAL_DISCONNECT to send it.
+ * However, this will cause 1 sec delay on Ethernet device halt.
+ * Usually you do not need to define it. Mostly usable for debugging.
+ */
+
 #define RNDIS_MAXIMUM_FRAME_SIZE       1518
 #define RNDIS_MAX_TOTAL_SIZE           1558