From patchwork Tue Jun 5 14:12:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: huajun li X-Patchwork-Id: 163087 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 22722B6EF1 for ; Wed, 6 Jun 2012 00:12:22 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756563Ab2FEOMU (ORCPT ); Tue, 5 Jun 2012 10:12:20 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:46033 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752769Ab2FEOMS (ORCPT ); Tue, 5 Jun 2012 10:12:18 -0400 Received: by weyu7 with SMTP id u7so3602441wey.19 for ; Tue, 05 Jun 2012 07:12:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=ThKLWQSDxX+B3kx4QSTy8J1uNgWq0v0Q3Yf40ooh5hg=; b=H2Aw1HoQBk6jK1Bt6DzEYenVcqTlEz2gAvPe7rcnyTQatMOzE1t7cTGtteN5n0pDOB BGjt2waSM375HL15FGn2O1/ZUS9VITcf0K6aUhqJ07YxkaerTiCCpX2NQEdYbnoxRLPo OB5lyC9aRCkfGRkrzO1BNq3OWRGUbf+Q6W3ZqgUz6gfQUpEuNnIjnMgmxql9+P1dwhuO yZl/qqwJF2yjFSFFMBQ7KMjQY4rBZg1r2QvA9A3G4pJGBmciuzXNLg66cyylA6oIOE2G sqTrFZczGXglBHe3jegW1Fh96XgEU9bRRopFFg0UV98QrafAYubRFTWEL6kvA6i5J7sA GZnA== MIME-Version: 1.0 Received: by 10.216.228.232 with SMTP id f82mr14691314weq.211.1338905537672; Tue, 05 Jun 2012 07:12:17 -0700 (PDT) Received: by 10.223.74.74 with HTTP; Tue, 5 Jun 2012 07:12:17 -0700 (PDT) Date: Tue, 5 Jun 2012 22:12:17 +0800 Message-ID: Subject: [PATCH] usbnet: Activate the halt interrupt endpoint to fix endless "XactErr" error From: Huajun Li To: "David S. Miller" Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org, Huajun Li Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There prints endless "XactErr" error msg once switch my device to the configuration which needs cdc_ether driver, the root cause is the interrupt endpoint halts. Maybe this is a common issue, so fix it by activating the endpoint once the error occurs. Signed-off-by: Huajun Li --- drivers/net/usb/usbnet.c | 33 +++++++++++++++++++++++++++++++++ include/linux/usb/usbnet.h | 15 ++++++++------- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 9f58330..f13922b 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -537,6 +537,11 @@ static void intr_complete (struct urb *urb) "intr shutdown, code %d\n", status); return; + case -EPIPE: + case -EPROTO: + usbnet_defer_kevent(dev, EVENT_STS_HALT); + return; + /* NOTE: not throttling like RX/TX, since this endpoint * already polls infrequently */ @@ -967,6 +972,34 @@ fail_halt: } } + if (test_bit(EVENT_STS_HALT, &dev->flags)) { + unsigned pipe; + struct usb_endpoint_descriptor *desc; + + desc = &dev->status->desc; + pipe = usb_rcvintpipe(dev->udev, + desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); + status = usb_autopm_get_interface(dev->intf); + if (status < 0) + goto fail_sts; + status = usb_clear_halt(dev->udev, pipe); + usb_autopm_put_interface(dev->intf); + + if (status < 0 && status != -EPIPE && status != -ESHUTDOWN) { +fail_sts: + netdev_err(dev->net, + "can't clear intr halt, status %d\n", status); + } else { + clear_bit(EVENT_STS_HALT, &dev->flags); + memset(dev->interrupt->transfer_buffer, 0, + dev->interrupt->transfer_buffer_length); + status = usb_submit_urb(dev->interrupt, GFP_KERNEL); + if (status != 0) + netif_err(dev, timer, dev->net, + "intr resubmit --> %d\n", status); + } + } + /* tasklet could resubmit itself forever if memory is tight */ if (test_bit (EVENT_RX_MEMORY, &dev->flags)) { struct urb *urb = NULL; diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h index 76f4396..c0bcb61 100644 --- a/include/linux/usb/usbnet.h +++ b/include/linux/usb/usbnet.h @@ -62,13 +62,14 @@ struct usbnet { unsigned long flags; # define EVENT_TX_HALT 0 # define EVENT_RX_HALT 1 -# define EVENT_RX_MEMORY 2 -# define EVENT_STS_SPLIT 3 -# define EVENT_LINK_RESET 4 -# define EVENT_RX_PAUSED 5 -# define EVENT_DEV_WAKING 6 -# define EVENT_DEV_ASLEEP 7 -# define EVENT_DEV_OPEN 8 +# define EVENT_STS_HALT 2 +# define EVENT_RX_MEMORY 3 +# define EVENT_STS_SPLIT 4 +# define EVENT_LINK_RESET 5 +# define EVENT_RX_PAUSED 6 +# define EVENT_DEV_WAKING 7 +# define EVENT_DEV_ASLEEP 8 +# define EVENT_DEV_OPEN 9 }; static inline struct usb_driver *driver_of(struct usb_interface *intf)