public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jim Lin <jilin@nvidia.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 1/2] console: usbkbd: Improve TFTP booting performance
Date: Thu, 27 Jun 2013 17:45:22 +0800	[thread overview]
Message-ID: <1372326323-8661-1-git-send-email-jilin@nvidia.com> (raw)

TFTP booting is observed a little bit slow, especially when a USB
keyboard is installed.
The fix is to move polling to every second if we sense that other task
like TFTP boot is running.

Signed-off-by: Jim Lin <jilin@nvidia.com>
---
Changes in v2:
 1. Change configuration name from CONFIG_CTRLC_POLL_MS to CONFIG_CTRLC_POLL_S.
 2. New code will be executed only when CONFIG_CTRLC_POLL_S is defined in
    configuration header file.
 3. Add description in README.console.
Changes in v3:
 1. Move changes to common/usb_kbd.c and doc/README.usb
 2. Rename config setting to CONFIG_USBKB_TESTC_PERIOD.
 3. Remove slow response on USB-keyboard input when TFTP boot is not running.

 common/usb_kbd.c |   20 ++++++++++++++++++++
 doc/README.usb   |   15 ++++++++++++++-
 2 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 3174b5e..25bf677 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -121,6 +121,11 @@ struct usb_kbd_pdata {
 	uint8_t		flags;
 };
 
+#ifdef CONFIG_USBKB_TESTC_PERIOD
+/* The period of time between two calls of usb_kbd_testc(). */
+static unsigned long kbd_testc_tms;
+#endif
+
 /* Generic keyboard event polling. */
 void usb_kbd_generic_poll(void)
 {
@@ -366,6 +371,21 @@ static int usb_kbd_testc(void)
 	struct usb_device *usb_kbd_dev;
 	struct usb_kbd_pdata *data;
 
+#ifdef CONFIG_USBKB_TESTC_PERIOD
+	/*
+	 * T is the time between two calls of usb_kbd_testc().
+	 * If CONFIG_USBKB_TESTC_PERIOD ms < T < 1000 ms,
+	 * it implies other task like TFTP boot is running,
+	 * then we reduce polling to every second
+	 * to improve TFTP booting performance.
+	 */
+	if ((get_timer(kbd_testc_tms) >=
+	    (CONFIG_USBKB_TESTC_PERIOD * CONFIG_SYS_HZ / 1000)) &&
+	    (get_timer(kbd_testc_tms) < CONFIG_SYS_HZ))
+		return 0;
+	else
+		kbd_testc_tms = get_timer(0);
+#endif
 	dev = stdio_get_by_name(DEVNAME);
 	usb_kbd_dev = (struct usb_device *)dev->priv;
 	data = usb_kbd_dev->privptr;
diff --git a/doc/README.usb b/doc/README.usb
index b4c3ef5..ff4ee6f 100644
--- a/doc/README.usb
+++ b/doc/README.usb
@@ -80,7 +80,20 @@ CONFIG_USB_UHCI	    defines the lowlevel part.A lowlevel part must be defined
 CONFIG_USB_KEYBOARD enables the USB Keyboard
 CONFIG_USB_STORAGE  enables the USB storage devices
 CONFIG_USB_HOST_ETHER	enables USB ethernet adapter support
-
+CONFIG_USBKB_TESTC_PERIOD defines the average time (in ms) between two calls
+			of usb_kbd_testc() when TFTP boot is not running
+			In u-boot console, usb_kbd_testc() will be called
+			periodically.
+			When this configuration is defined and other task like
+			TFTP boot is running, USB keyboard will be polled less
+			frequently and will be polled every second.
+			This is to improve TFTP booting performance when USB
+			keyboard is installed.
+			In u-boot console, no impact on keyboard input if TFTP
+			boot is not running.
+			Example:
+			Define the following in configuration header file
+			#define CONFIG_USBKB_TESTC_PERIOD 100
 
 USB Host Networking
 ===================
-- 
1.7.7

             reply	other threads:[~2013-06-27  9:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-27  9:45 Jim Lin [this message]
2013-06-27  9:45 ` [U-Boot] [PATCH v3 2/2] config: Tegra: Improve TFTP booting performance Jim Lin
2013-06-27 18:20 ` [U-Boot] [PATCH v3 1/2] console: usbkbd: " Stephen Warren
2013-06-28  3:59   ` Jim Lin
2013-06-28  5:09     ` Stephen Warren
2013-06-28 10:01       ` Jim Lin

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=1372326323-8661-1-git-send-email-jilin@nvidia.com \
    --to=jilin@nvidia.com \
    --cc=u-boot@lists.denx.de \
    /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