mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Mohr <andi@lisas.de>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	OndrejZary <linux@rainbow-software.org>,
	Ming Lei <ming.lei@canonical.com>
Subject: [PATCH] usbnet: improve/fix status interrupt endpoint interval
Date: Tue, 4 Jun 2013 20:28:30 +0200	[thread overview]
Message-ID: <20130604182830.GA13186@rhlx01.hs-esslingen.de> (raw)


>From 307685fe8e6dfc8181e30167b9c31479332cb22f Mon Sep 17 00:00:00 2001
From: Andreas Mohr <andim2@users.sourceforge.net>
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
---
 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 <andim2@users.sourceforge.net>


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) {
-- 
1.7.10.4


             reply	other threads:[~2013-06-04 18:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-04 18:28 Andreas Mohr [this message]
2013-06-05  1:22 ` Ming Lei
2013-06-05 16:34   ` Andreas Mohr
2013-06-06  1:33     ` Ming Lei
2013-06-06  6:54       ` Andreas Mohr
2013-06-06 11:05         ` Ming Lei
2013-06-06  8:07     ` Oliver Neukum
2013-06-05  6:06 ` Oliver Neukum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130604182830.GA13186@rhlx01.hs-esslingen.de \
    --to=andi@lisas.de \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rainbow-software.org \
    --cc=ming.lei@canonical.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®