Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1193823 > unrolled thread

[PATCH net 2/2] r8152: reset device when tx timeout

Started byHayes Wang <hayeswang@realtek.com>
First post2015-07-28 09:40 +0200
Last post2015-07-28 12:00 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH net 2/2] r8152: reset device when tx timeout Hayes Wang <hayeswang@realtek.com> - 2015-07-28 09:40 +0200
    Re: [PATCH net 2/2] r8152: reset device when tx timeout Oliver Neukum <oneukum@suse.com> - 2015-07-28 11:00 +0200
      RE: [PATCH net 2/2] r8152: reset device when tx timeout Hayes Wang <hayeswang@realtek.com> - 2015-07-28 12:00 +0200

#1193823 — [PATCH net 2/2] r8152: reset device when tx timeout

FromHayes Wang <hayeswang@realtek.com>
Date2015-07-28 09:40 +0200
Subject[PATCH net 2/2] r8152: reset device when tx timeout
Message-ID<pR7Eu-2w2-9@gated-at.bofh.it>
The device reset is necessary if the hw becomes abnormal and stops
transmitting packets.

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
 drivers/net/usb/r8152.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index a6caa60..9bf6e0c 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -27,7 +27,7 @@
 #include <linux/usb/cdc.h>
 
 /* Version Information */
-#define DRIVER_VERSION "v1.08.0 (2015/01/13)"
+#define DRIVER_VERSION "v1.08.1 (2015/07/28)"
 #define DRIVER_AUTHOR "Realtek linux nic maintainers <nic_swsd@realtek.com>"
 #define DRIVER_DESC "Realtek RTL8152/RTL8153 Based USB Ethernet Adapters"
 #define MODULENAME "r8152"
@@ -591,6 +591,7 @@ struct r8152 {
 	struct sk_buff_head tx_queue, rx_queue;
 	spinlock_t rx_lock, tx_lock;
 	struct delayed_work schedule;
+	struct delayed_work work_reset;
 	struct mii_if_info mii;
 	struct mutex control;	/* use for hw setting */
 
@@ -1902,11 +1903,11 @@ static void rtl_drop_queued_tx(struct r8152 *tp)
 static void rtl8152_tx_timeout(struct net_device *netdev)
 {
 	struct r8152 *tp = netdev_priv(netdev);
-	int i;
 
 	netif_warn(tp, tx_err, netdev, "Tx timeout\n");
-	for (i = 0; i < RTL8152_MAX_TX; i++)
-		usb_unlink_urb(tp->tx_info[i].urb);
+
+	schedule_delayed_work(&tp->work_reset, 0);
+	cancel_delayed_work(&tp->schedule);
 }
 
 static void rtl8152_set_rx_mode(struct net_device *netdev)
@@ -3408,6 +3409,18 @@ static int rtl8152_post_reset(struct usb_interface *intf)
 	return ret;
 }
 
+static void rtl_hw_reset(struct work_struct *work)
+{
+	struct r8152 *tp = container_of(work, struct r8152, work_reset.work);
+
+	netif_info(tp, drv, tp->netdev, "usb reset device\n");
+
+	if (test_bit(RTL8152_UNPLUG, &tp->flags))
+		return;
+
+	usb_reset_device(tp->udev);
+}
+
 static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
 {
 	struct r8152 *tp = usb_get_intfdata(intf);
@@ -4102,6 +4115,7 @@ static int rtl8152_probe(struct usb_interface *intf,
 
 	mutex_init(&tp->control);
 	INIT_DELAYED_WORK(&tp->schedule, rtl_work_func_t);
+	INIT_DELAYED_WORK(&tp->work_reset, rtl_hw_reset);
 
 	netdev->netdev_ops = &rtl8152_netdev_ops;
 	netdev->watchdog_timeo = RTL8152_TX_TIMEOUT;
-- 
2.4.2

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

[toc] | [next] | [standalone]


#1193910

FromOliver Neukum <oneukum@suse.com>
Date2015-07-28 11:00 +0200
Message-ID<pR8TU-4eR-23@gated-at.bofh.it>
In reply to#1193823
On Tue, 2015-07-28 at 15:36 +0800, Hayes Wang wrote:
> The device reset is necessary if the hw becomes abnormal and stops
> transmitting packets.

You are not the first one to face this problem. Hence there
is a helper:

 * usb_queue_reset_device - Reset a USB device from an atomic context
 * @iface: USB interface belonging to the device to reset
 *
 * This function can be used to reset a USB device from an atomic
 * context, where usb_reset_device() won't work (as it blocks).

Please use it if you can. Your version for example is buggy.
It will oops if you unplug the device while a reset is scheduled.

	Regards
		Oliver


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

[toc] | [prev] | [next] | [standalone]


#1193979

FromHayes Wang <hayeswang@realtek.com>
Date2015-07-28 12:00 +0200
Message-ID<pR9PZ-5AL-49@gated-at.bofh.it>
In reply to#1193910
T2xpdmVyIE5ldWt1bSBbbWFpbHRvOm9uZXVrdW1Ac3VzZS5jb21dDQo+IFNlbnQ6IFR1ZXNkYXks
IEp1bHkgMjgsIDIwMTUgNDo1NyBQTQ0KWy4uLl0NCj4gICogdXNiX3F1ZXVlX3Jlc2V0X2Rldmlj
ZSAtIFJlc2V0IGEgVVNCIGRldmljZSBmcm9tIGFuIGF0b21pYyBjb250ZXh0DQo+ICAqIEBpZmFj
ZTogVVNCIGludGVyZmFjZSBiZWxvbmdpbmcgdG8gdGhlIGRldmljZSB0byByZXNldA0KPiAgKg0K
PiAgKiBUaGlzIGZ1bmN0aW9uIGNhbiBiZSB1c2VkIHRvIHJlc2V0IGEgVVNCIGRldmljZSBmcm9t
IGFuIGF0b21pYw0KPiAgKiBjb250ZXh0LCB3aGVyZSB1c2JfcmVzZXRfZGV2aWNlKCkgd29uJ3Qg
d29yayAoYXMgaXQgYmxvY2tzKS4NCj4gDQo+IFBsZWFzZSB1c2UgaXQgaWYgeW91IGNhbi4gWW91
ciB2ZXJzaW9uIGZvciBleGFtcGxlIGlzIGJ1Z2d5Lg0KPiBJdCB3aWxsIG9vcHMgaWYgeW91IHVu
cGx1ZyB0aGUgZGV2aWNlIHdoaWxlIGEgcmVzZXQgaXMgc2NoZWR1bGVkLg0KDQpUaGFua3MgZm9y
IHlvdXIgc3VnZ2VzdGlvbi4gSSB3b3VsZCByZXBsYWNlIGl0LiANCg0KQmVzdCBSZWdhcmRzLA0K
SGF5ZXMNCg0K
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web