From: Jason Wessel <jason.wessel@windriver.com>
To: greg@kroah.com
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Jason Wessel <jason.wessel@windriver.com>
Subject: [PATCH 5/5] usb_debug: EXPERIMENTAL - poll hcd device to force writes
Date: Tue, 5 May 2009 21:00:05 -0500 [thread overview]
Message-ID: <1241575205-12199-6-git-send-email-jason.wessel@windriver.com> (raw)
In-Reply-To: <1241575205-12199-5-git-send-email-jason.wessel@windriver.com>
The problem that this patch tries to solve is that data is lost
because there are too many outstanding transmit urb's.
The question is what is the right way to force the controller to catch
up, and ideally let the kernel do some other things in the mean time?
This patch takes the route of forcibly polling the hcd device to drain
the urb queue and initiate the bulk write call backs.
NOTE this patch is not signed off, it is a question of what is the
right way to do this?
---
drivers/usb/core/hcd.c | 1 +
drivers/usb/serial/usb_debug.c | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 42b93da..57c09c2 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1760,6 +1760,7 @@ irqreturn_t usb_hcd_irq (int irq, void *__hcd)
local_irq_restore(flags);
return rc;
}
+EXPORT_SYMBOL_GPL(usb_hcd_irq);
/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c
index 58feab9..8838418 100644
--- a/drivers/usb/serial/usb_debug.c
+++ b/drivers/usb/serial/usb_debug.c
@@ -15,6 +15,7 @@
#include <linux/module.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>
+#include "../core/hcd.h"
#define URB_UPPER_LIMIT 42
#define USB_DEBUG_MAX_PACKET_SIZE 8
@@ -91,6 +92,23 @@ static int usb_debug_port_probe(struct usb_serial_port *port)
return 0;
}
+/* If the driver is close to running of tx urb's try to free some up
+ * by asking the hcd device to do some processing. XXX This needs
+ * review as to if this is a reasonable way to implement forcing the
+ * HCD device to run.
+ */
+static void poll_hcd_irq(struct urb *urb)
+{
+ struct usb_hcd *hcd;
+
+ if (!urb)
+ return;
+
+ hcd = bus_to_hcd(urb->dev->bus);
+ if (hcd)
+ usb_hcd_irq(0, hcd);
+}
+
static int usb_debug_write_room(struct tty_struct *tty)
{
unsigned long flags;
@@ -156,10 +174,15 @@ static int usb_debug_write(struct tty_struct *tty,
dbg("%s - write request of 0 bytes", __func__);
while (count > 0) {
+ int loops = 1000;
+try_again:
spin_lock_irqsave(&priv->tx_lock, flags);
if (priv->tx_outstanding_urbs > URB_UPPER_LIMIT) {
spin_unlock_irqrestore(&priv->tx_lock, flags);
dbg("%s - write limit hit\n", __func__);
+ poll_hcd_irq(port->read_urb);
+ if (loops-- > 0)
+ goto try_again;
return bwrite;
}
--
1.6.3.rc0.1.gf800
next prev parent reply other threads:[~2009-05-06 2:02 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-06 2:00 [PATCH 0/5] usb_debug driver improvements Jason Wessel
2009-05-06 2:00 ` [PATCH 1/5] usb_debug: implement multi urb write Jason Wessel
2009-05-06 2:00 ` [PATCH 2/5] usb_debug,usb_generic_serial: implement sysrq and serial break Jason Wessel
2009-05-06 2:00 ` [PATCH 3/5] usb,early_printk: insert cr prior to nl as needed Jason Wessel
2009-05-06 2:00 ` [PATCH 4/5] usb,early_printk: unregister early usb before rest_init() Jason Wessel
2009-05-06 2:00 ` Jason Wessel [this message]
2009-05-06 15:18 ` [PATCH 5/5] usb_debug: EXPERIMENTAL - poll hcd device to force writes Alan Stern
2009-05-06 15:25 ` Greg KH
2009-05-06 15:42 ` Alan Cox
2009-05-06 15:59 ` Jason Wessel
2009-05-06 15:41 ` Alan Cox
2009-05-06 15:45 ` Greg KH
2009-05-06 17:17 ` Oliver Neukum
2009-05-06 19:24 ` Alan Stern
2009-05-06 20:01 ` Oliver Neukum
2009-05-06 20:24 ` Alan Stern
2009-05-06 22:24 ` Oliver Neukum
2009-05-07 14:35 ` Alan Stern
2009-05-07 15:01 ` Oliver Neukum
2009-05-07 16:32 ` Alan Stern
2009-05-06 20:24 ` Jason Wessel
2009-05-06 20:28 ` Greg KH
2009-05-06 20:51 ` [PATCH 5/5] usb_debug: EXPERIMENTAL - poll hcd device to forcewrites Jason Wessel
2009-05-06 21:32 ` Greg KH
2009-05-07 14:00 ` Alan Stern
2009-05-07 0:06 ` [PATCH 5/5] usb_debug: EXPERIMENTAL - poll hcd device to force writes Alan Cox
2009-05-07 14:27 ` Alan Stern
2009-05-07 14:49 ` Oliver Neukum
2009-05-06 7:34 ` [PATCH 4/5] usb,early_printk: unregister early usb before rest_init() Ingo Molnar
2009-05-06 13:02 ` Jason Wessel
2009-05-07 15:09 ` Ingo Molnar
2009-05-06 7:30 ` [PATCH 3/5] usb,early_printk: insert cr prior to nl as needed Ingo Molnar
2009-05-06 15:25 ` Greg KH
2009-05-07 15:04 ` Ingo Molnar
2009-05-06 7:16 ` [PATCH 1/5] usb_debug: implement multi urb write Oliver Neukum
2009-05-06 11:57 ` Jason Wessel
2009-05-06 12:31 ` Oliver Neukum
2009-05-06 15:26 ` Greg KH
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=1241575205-12199-6-git-send-email-jason.wessel@windriver.com \
--to=jason.wessel@windriver.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@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®