From patchwork Mon Jun 11 14:41:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: huajun li X-Patchwork-Id: 164141 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 10FBDB703D for ; Tue, 12 Jun 2012 00:41:10 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753760Ab2FKOlH (ORCPT ); Mon, 11 Jun 2012 10:41:07 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:34758 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752040Ab2FKOlE convert rfc822-to-8bit (ORCPT ); Mon, 11 Jun 2012 10:41:04 -0400 Received: by wibhj8 with SMTP id hj8so2977976wib.1 for ; Mon, 11 Jun 2012 07:41:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=1h4Wd+o64yRvWKlG+TeuZABcCi/hKx1C6nZ9MigjW3w=; b=Bwi5mEHwjts9TrdeQ3d7gGQ8nmM7FwW5jNV8MmNHvOU1jaog+rFUjcWXWWAK9QjSRz NNcsJQMLXCv09U15DViL7y7N39Es/41kKN2Jh7RF+YzN0XIS+a+D0hSMZHwBpwV8KpP7 Vw1PkQXurw29TlzWEeHvC6wFJEttAqcq4co+CGDtb5HKBRPszAgIircUIQX4B+QaEr9q ET4G+l3tyYAoEy4aPgQSSx32LjxRUlxH1oXqNxRs7YR6SbAhwzxy6zeR8ok2QzEEfUm1 +WPfFa8wexK+qW7qnASOtmVsJZkrNQOu+ljmXQR/okrA45SUwms9tbFNVN7uj9HK820S GfEA== MIME-Version: 1.0 Received: by 10.180.83.168 with SMTP id r8mr21448591wiy.22.1339425663178; Mon, 11 Jun 2012 07:41:03 -0700 (PDT) Received: by 10.223.74.74 with HTTP; Mon, 11 Jun 2012 07:41:03 -0700 (PDT) In-Reply-To: <20120607.145438.1351539405712214173.davem@davemloft.net> References: <20120607.145438.1351539405712214173.davem@davemloft.net> Date: Mon, 11 Jun 2012 22:41:03 +0800 Message-ID: Subject: Re: [PATCH] usbnet: Activate the halt interrupt endpoint to fix endless "XactErr" error From: Huajun Li To: David Miller , Ming Lei , Alan Stern Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, Jun 8, 2012 at 5:54 AM, David Miller wrote: > From: Huajun Li > Date: Tue, 5 Jun 2012 22:12:17 +0800 > >> 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 > > A USB expert needs to review this as I lack the knowledge to adequately > go over this patch. Update the patch according to Ming and Alan's comments, it only handles "-EPIPE" error of interrupt endpoint. Welcome comments: --- To unsubscribe from this list: send the line "unsubscribe netdev" 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/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 9f58330..bd8ebef 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -537,6 +537,10 @@ static void intr_complete (struct urb *urb) "intr shutdown, code %d\n", status); return; + case -EPIPE: + usbnet_defer_kevent(dev, EVENT_STS_HALT); + return; + /* NOTE: not throttling like RX/TX, since this endpoint * already polls infrequently */ @@ -967,6 +971,33 @@ 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); + if (status < 0) { + usb_autopm_put_interface(dev->intf); +fail_sts: + netdev_err(dev->net, + "can't clear intr halt, status %d\n", status); + } else { + clear_bit(EVENT_STS_HALT, &dev->flags); + status = usb_submit_urb(dev->interrupt, GFP_KERNEL); + if (status != 0) + netif_err(dev, timer, dev->net, + "intr resubmit --> %d\n", status); + + usb_autopm_put_interface(dev->intf); + } + } + /* 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)