From patchwork Tue Jun 4 18:28:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Mohr X-Patchwork-Id: 248798 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 8F8B62C0095 for ; Wed, 5 Jun 2013 04:36:41 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751436Ab3FDSgd (ORCPT ); Tue, 4 Jun 2013 14:36:33 -0400 Received: from rhlx01.hs-esslingen.de ([129.143.116.10]:33691 "EHLO rhlx01.hs-esslingen.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750907Ab3FDSgc convert rfc822-to-8bit (ORCPT ); Tue, 4 Jun 2013 14:36:32 -0400 X-Greylist: delayed 481 seconds by postgrey-1.27 at vger.kernel.org; Tue, 04 Jun 2013 14:36:32 EDT Received: by rhlx01.hs-esslingen.de (Postfix, from userid 102) id 67137A10CE; Tue, 4 Jun 2013 20:28:30 +0200 (CEST) Date: Tue, 4 Jun 2013 20:28:30 +0200 From: Andreas Mohr To: "David S. Miller" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, OndrejZary , Ming Lei Subject: [PATCH] usbnet: improve/fix status interrupt endpoint interval Message-ID: <20130604182830.GA13186@rhlx01.hs-esslingen.de> MIME-Version: 1.0 Content-Disposition: inline X-Priority: none User-Agent: Mutt/1.5.21 (2010-09-15) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From 307685fe8e6dfc8181e30167b9c31479332cb22f Mon Sep 17 00:00:00 2001 From: Andreas Mohr Date: Sun, 2 Jun 2013 20:37:05 +0200 Subject: [PATCH] usbnet: improve/fix status interrupt endpoint interval tweaking. - failed to take super-speed into account - <= full-speed seems to have wrong value (specified as frames [ms], thus 3 is not suitable to achieve 8ms) Value 8 now managed to reduce powertop wakeups from ~ 540 to ~ 155 - add detailed docs and question marks about current practice Acked-by: Oliver Neukum --- drivers/net/usb/usbnet.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) Found this with MCS7830 on a full-speed USB 1.1 port (Inspiron 8000). Good to have a rusty notebook with noisy PSU coils, else it would have taken a lot longer to nail it ;) Tested on -rc4, checkpath.pl:d. Signed-off-by: Andreas Mohr diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 06ee82f..b6e9569 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -231,8 +231,23 @@ static int init_status (struct usbnet *dev, struct usb_interface *intf) maxp = usb_maxpacket (dev->udev, pipe, 0); /* avoid 1 msec chatter: min 8 msec poll rate */ + /* High/SuperSpeed expresses intervals in microframes + * (in logarithmic encoding, PRIOR to encoding in URB) + * rather than frames. + * Thus, for >= HighSpeed: == X [microframes] * 125us [-> 8ms], + * <= FullSpeed: == X [ms] [-> 8ms]. + * Finally, it's questionable whether we'll even get away unscathed + * with doing such rate tweaking at all: + * bInterval value is declared as being a hard demand by a device + * in order to guarantee having its I/O needs serviced properly... + * if we don't do this, then... [overruns], [fire], [apocalypse]? + * If this turns out to be problematic, such policy should be moved + * to individual drivers (indicate flag to [dis]allow rate tweaking + * as tolerated by specific devices). + */ period = max ((int) dev->status->desc.bInterval, - (dev->udev->speed == USB_SPEED_HIGH) ? 7 : 3); + ((dev->udev->speed == USB_SPEED_HIGH) || + (dev->udev->speed == USB_SPEED_SUPER)) ? 7 : 8); buf = kmalloc (maxp, GFP_KERNEL); if (buf) {