Skip to content

Commit 990c9b3

Browse files
committed
Merge branch 'r8152-fixes'
Hayes Wang says: ==================== r8152: device reset v3: For patch #2, remove cancel_delayed_work(). v2: For patch #1, remove usb_autopm_get_interface(), usb_autopm_put_interface(), and the checking of intf->condition. For patch #2, replace the original method with usb_queue_reset_device() to reset the device. v1: Although the driver works normally, we find the device may get all 0xff data when transmitting packets on certain platforms. It would break the device and no packet could be transmitted. The reset is necessary to recover the hw for this situation. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 15f1bb1 + 37608f3 commit 990c9b3

File tree

1 file changed

+57
-4
lines changed

1 file changed

+57
-4
lines changed

drivers/net/usb/r8152.c

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include <linux/usb/cdc.h>
2828

2929
/* Version Information */
30-
#define DRIVER_VERSION "v1.08.0 (2015/01/13)"
30+
#define DRIVER_VERSION "v1.08.1 (2015/07/28)"
3131
#define DRIVER_AUTHOR "Realtek linux nic maintainers <[email protected]>"
3232
#define DRIVER_DESC "Realtek RTL8152/RTL8153 Based USB Ethernet Adapters"
3333
#define MODULENAME "r8152"
@@ -1902,11 +1902,10 @@ static void rtl_drop_queued_tx(struct r8152 *tp)
19021902
static void rtl8152_tx_timeout(struct net_device *netdev)
19031903
{
19041904
struct r8152 *tp = netdev_priv(netdev);
1905-
int i;
19061905

19071906
netif_warn(tp, tx_err, netdev, "Tx timeout\n");
1908-
for (i = 0; i < RTL8152_MAX_TX; i++)
1909-
usb_unlink_urb(tp->tx_info[i].urb);
1907+
1908+
usb_queue_reset_device(tp->intf);
19101909
}
19111910

19121911
static void rtl8152_set_rx_mode(struct net_device *netdev)
@@ -3342,6 +3341,58 @@ static void r8153_init(struct r8152 *tp)
33423341
r8153_u2p3en(tp, true);
33433342
}
33443343

3344+
static int rtl8152_pre_reset(struct usb_interface *intf)
3345+
{
3346+
struct r8152 *tp = usb_get_intfdata(intf);
3347+
struct net_device *netdev;
3348+
3349+
if (!tp)
3350+
return 0;
3351+
3352+
netdev = tp->netdev;
3353+
if (!netif_running(netdev))
3354+
return 0;
3355+
3356+
napi_disable(&tp->napi);
3357+
clear_bit(WORK_ENABLE, &tp->flags);
3358+
usb_kill_urb(tp->intr_urb);
3359+
cancel_delayed_work_sync(&tp->schedule);
3360+
if (netif_carrier_ok(netdev)) {
3361+
netif_stop_queue(netdev);
3362+
mutex_lock(&tp->control);
3363+
tp->rtl_ops.disable(tp);
3364+
mutex_unlock(&tp->control);
3365+
}
3366+
3367+
return 0;
3368+
}
3369+
3370+
static int rtl8152_post_reset(struct usb_interface *intf)
3371+
{
3372+
struct r8152 *tp = usb_get_intfdata(intf);
3373+
struct net_device *netdev;
3374+
3375+
if (!tp)
3376+
return 0;
3377+
3378+
netdev = tp->netdev;
3379+
if (!netif_running(netdev))
3380+
return 0;
3381+
3382+
set_bit(WORK_ENABLE, &tp->flags);
3383+
if (netif_carrier_ok(netdev)) {
3384+
mutex_lock(&tp->control);
3385+
tp->rtl_ops.enable(tp);
3386+
rtl8152_set_rx_mode(netdev);
3387+
mutex_unlock(&tp->control);
3388+
netif_wake_queue(netdev);
3389+
}
3390+
3391+
napi_enable(&tp->napi);
3392+
3393+
return 0;
3394+
}
3395+
33453396
static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
33463397
{
33473398
struct r8152 *tp = usb_get_intfdata(intf);
@@ -4164,6 +4215,8 @@ static struct usb_driver rtl8152_driver = {
41644215
.suspend = rtl8152_suspend,
41654216
.resume = rtl8152_resume,
41664217
.reset_resume = rtl8152_resume,
4218+
.pre_reset = rtl8152_pre_reset,
4219+
.post_reset = rtl8152_post_reset,
41674220
.supports_autosuspend = 1,
41684221
.disable_hub_initiated_lpm = 1,
41694222
};

0 commit comments

Comments
 (0)