|
|
f96e0b |
From 1d79a30acc9b9cf67c9d669a2a57b3ce26683ff6 Mon Sep 17 00:00:00 2001
|
|
|
f96e0b |
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
Date: Tue, 19 Mar 2013 20:35:21 +0100
|
|
|
f96e0b |
Subject: [PATCH 214/482] Fix USB devices not being detected when
|
|
|
f96e0b |
requested due to delayed attach.
|
|
|
f96e0b |
|
|
|
f96e0b |
---
|
|
|
f96e0b |
ChangeLog | 5 +++++
|
|
|
f96e0b |
grub-core/bus/usb/usbhub.c | 29 ++++++++++++++++++++++++-----
|
|
|
f96e0b |
grub-core/commands/keystatus.c | 2 +-
|
|
|
f96e0b |
grub-core/commands/terminal.c | 12 ++++++++++--
|
|
|
f96e0b |
grub-core/commands/usbtest.c | 2 +-
|
|
|
f96e0b |
grub-core/disk/usbms.c | 5 +++--
|
|
|
f96e0b |
grub-core/kern/term.c | 4 ++--
|
|
|
f96e0b |
include/grub/term.h | 2 +-
|
|
|
f96e0b |
include/grub/usb.h | 2 +-
|
|
|
f96e0b |
9 files changed, 48 insertions(+), 15 deletions(-)
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/ChangeLog b/ChangeLog
|
|
|
f96e0b |
index 94dd5bb..725fbe2 100644
|
|
|
f96e0b |
--- a/ChangeLog
|
|
|
f96e0b |
+++ b/ChangeLog
|
|
|
f96e0b |
@@ -1,5 +1,10 @@
|
|
|
f96e0b |
2013-03-19 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
|
|
|
f96e0b |
+ Fix USB devices not being detected when requested
|
|
|
f96e0b |
+ due to delayed attach.
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+2013-03-19 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
+
|
|
|
f96e0b |
Implement boot time analysis framework.
|
|
|
f96e0b |
|
|
|
f96e0b |
2013-03-19 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
diff --git a/grub-core/bus/usb/usbhub.c b/grub-core/bus/usb/usbhub.c
|
|
|
f96e0b |
index f95a567..253e49f 100644
|
|
|
f96e0b |
--- a/grub-core/bus/usb/usbhub.c
|
|
|
f96e0b |
+++ b/grub-core/bus/usb/usbhub.c
|
|
|
f96e0b |
@@ -29,6 +29,7 @@
|
|
|
f96e0b |
static struct grub_usb_device *grub_usb_devs[GRUB_USBHUB_MAX_DEVICES];
|
|
|
f96e0b |
|
|
|
f96e0b |
static int rescan = 0;
|
|
|
f96e0b |
+static int npending = 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
struct grub_usb_hub
|
|
|
f96e0b |
{
|
|
|
f96e0b |
@@ -227,21 +228,33 @@ attach_root_port (struct grub_usb_hub *hub, int portno,
|
|
|
f96e0b |
if (current_speed == GRUB_USB_SPEED_NONE)
|
|
|
f96e0b |
i = 0;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ grub_boot_time ("After the stable power wait portno=%d", portno);
|
|
|
f96e0b |
+
|
|
|
f96e0b |
grub_dprintf ("usb", "total=%d\n", total);
|
|
|
f96e0b |
if (total >= 2000)
|
|
|
f96e0b |
- return;
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_boot_time ("Root port timeout");
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ grub_boot_time ("After detect_dev");
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Enable the port. */
|
|
|
f96e0b |
err = hub->controller->dev->portstatus (hub->controller, portno, 1);
|
|
|
f96e0b |
if (err)
|
|
|
f96e0b |
return;
|
|
|
f96e0b |
hub->controller->dev->pending_reset = grub_get_time_ms () + 5000;
|
|
|
f96e0b |
+ npending++;
|
|
|
f96e0b |
|
|
|
f96e0b |
grub_millisleep (10);
|
|
|
f96e0b |
|
|
|
f96e0b |
+ grub_boot_time ("Port enabled");
|
|
|
f96e0b |
+
|
|
|
f96e0b |
/* Enable the port and create a device. */
|
|
|
f96e0b |
dev = grub_usb_hub_add_dev (hub->controller, speed, portno, 0);
|
|
|
f96e0b |
hub->controller->dev->pending_reset = 0;
|
|
|
f96e0b |
+ npending--;
|
|
|
f96e0b |
if (! dev)
|
|
|
f96e0b |
return;
|
|
|
f96e0b |
|
|
|
f96e0b |
@@ -475,6 +488,7 @@ poll_nonroot_hub (grub_usb_device_t dev)
|
|
|
f96e0b |
* anywhere on the same OHCI controller until
|
|
|
f96e0b |
* we will finish addressing of reseted device ! */
|
|
|
f96e0b |
dev->controller.dev->pending_reset = grub_get_time_ms () + 5000;
|
|
|
f96e0b |
+ npending++;
|
|
|
f96e0b |
return;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
}
|
|
|
f96e0b |
@@ -510,7 +524,11 @@ poll_nonroot_hub (grub_usb_device_t dev)
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Add the device and assign a device address to it. */
|
|
|
f96e0b |
next_dev = grub_usb_hub_add_dev (&dev->controller, speed, i, dev->addr);
|
|
|
f96e0b |
- dev->controller.dev->pending_reset = 0;
|
|
|
f96e0b |
+ if (dev->controller.dev->pending_reset)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ dev->controller.dev->pending_reset = 0;
|
|
|
f96e0b |
+ npending--;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
if (! next_dev)
|
|
|
f96e0b |
continue;
|
|
|
f96e0b |
|
|
|
f96e0b |
@@ -525,7 +543,7 @@ poll_nonroot_hub (grub_usb_device_t dev)
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
void
|
|
|
f96e0b |
-grub_usb_poll_devices (void)
|
|
|
f96e0b |
+grub_usb_poll_devices (int wait_for_completion)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
struct grub_usb_hub *hub;
|
|
|
f96e0b |
int i;
|
|
|
f96e0b |
@@ -539,7 +557,7 @@ grub_usb_poll_devices (void)
|
|
|
f96e0b |
grub_usb_speed_t speed = GRUB_USB_SPEED_NONE;
|
|
|
f96e0b |
int changed = 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
- if (!hub->controller->dev->pending_reset)
|
|
|
f96e0b |
+ if (hub->controller->dev->pending_reset)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
/* Check for possible timeout */
|
|
|
f96e0b |
if (grub_get_time_ms () > hub->controller->dev->pending_reset)
|
|
|
f96e0b |
@@ -547,6 +565,7 @@ grub_usb_poll_devices (void)
|
|
|
f96e0b |
/* Something went wrong, reset device was not
|
|
|
f96e0b |
* addressed properly, timeout happened */
|
|
|
f96e0b |
hub->controller->dev->pending_reset = 0;
|
|
|
f96e0b |
+ npending--;
|
|
|
f96e0b |
speed = hub->controller->dev->detect_dev (hub->controller,
|
|
|
f96e0b |
i, &changed);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
@@ -573,7 +592,7 @@ grub_usb_poll_devices (void)
|
|
|
f96e0b |
if (dev && dev->descdev.class == 0x09)
|
|
|
f96e0b |
poll_nonroot_hub (dev);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
- if (!rescan)
|
|
|
f96e0b |
+ if (!(rescan || (npending && wait_for_completion)))
|
|
|
f96e0b |
break;
|
|
|
f96e0b |
grub_millisleep (50);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
diff --git a/grub-core/commands/keystatus.c b/grub-core/commands/keystatus.c
|
|
|
f96e0b |
index 0925c6a..460cf4e 100644
|
|
|
f96e0b |
--- a/grub-core/commands/keystatus.c
|
|
|
f96e0b |
+++ b/grub-core/commands/keystatus.c
|
|
|
f96e0b |
@@ -42,7 +42,7 @@ grub_getkeystatus (void)
|
|
|
f96e0b |
grub_term_input_t term;
|
|
|
f96e0b |
|
|
|
f96e0b |
if (grub_term_poll_usb)
|
|
|
f96e0b |
- grub_term_poll_usb ();
|
|
|
f96e0b |
+ grub_term_poll_usb (0);
|
|
|
f96e0b |
|
|
|
f96e0b |
FOR_ACTIVE_TERM_INPUTS(term)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
diff --git a/grub-core/commands/terminal.c b/grub-core/commands/terminal.c
|
|
|
f96e0b |
index 425a411..3002186 100644
|
|
|
f96e0b |
--- a/grub-core/commands/terminal.c
|
|
|
f96e0b |
+++ b/grub-core/commands/terminal.c
|
|
|
f96e0b |
@@ -108,9 +108,9 @@ handle_command (int argc, char **args, struct abstract_terminal **enabled,
|
|
|
f96e0b |
if (term)
|
|
|
f96e0b |
break;
|
|
|
f96e0b |
if (again)
|
|
|
f96e0b |
- return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
|
|
f96e0b |
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
|
|
f96e0b |
N_("terminal `%s' isn't found"),
|
|
|
f96e0b |
- args[i]);
|
|
|
f96e0b |
+ args[i]);
|
|
|
f96e0b |
for (aut = autoloads; aut; aut = aut->next)
|
|
|
f96e0b |
if (grub_strcmp (args[i], aut->name) == 0
|
|
|
f96e0b |
|| (grub_strcmp (args[i], "ofconsole") == 0
|
|
|
f96e0b |
@@ -126,6 +126,14 @@ handle_command (int argc, char **args, struct abstract_terminal **enabled,
|
|
|
f96e0b |
grub_errno = GRUB_ERR_NONE;
|
|
|
f96e0b |
break;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
+ if (grub_memcmp (args[i], "serial_usb",
|
|
|
f96e0b |
+ sizeof ("serial_usb") - 1) == 0
|
|
|
f96e0b |
+ && grub_term_poll_usb)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_term_poll_usb (1);
|
|
|
f96e0b |
+ again = 1;
|
|
|
f96e0b |
+ continue;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
if (!aut)
|
|
|
f96e0b |
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
|
|
f96e0b |
N_("terminal `%s' isn't found"),
|
|
|
f96e0b |
diff --git a/grub-core/commands/usbtest.c b/grub-core/commands/usbtest.c
|
|
|
f96e0b |
index af35b8c..01cdca9 100644
|
|
|
f96e0b |
--- a/grub-core/commands/usbtest.c
|
|
|
f96e0b |
+++ b/grub-core/commands/usbtest.c
|
|
|
f96e0b |
@@ -196,7 +196,7 @@ grub_cmd_usbtest (grub_command_t cmd __attribute__ ((unused)),
|
|
|
f96e0b |
int argc __attribute__ ((unused)),
|
|
|
f96e0b |
char **args __attribute__ ((unused)))
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- grub_usb_poll_devices ();
|
|
|
f96e0b |
+ grub_usb_poll_devices (1);
|
|
|
f96e0b |
|
|
|
f96e0b |
grub_printf ("USB devices:\n\n");
|
|
|
f96e0b |
grub_usb_iterate (usb_iterate, NULL);
|
|
|
f96e0b |
diff --git a/grub-core/disk/usbms.c b/grub-core/disk/usbms.c
|
|
|
f96e0b |
index 2cfc537..da01be3 100644
|
|
|
f96e0b |
--- a/grub-core/disk/usbms.c
|
|
|
f96e0b |
+++ b/grub-core/disk/usbms.c
|
|
|
f96e0b |
@@ -277,7 +277,7 @@ grub_usbms_iterate (grub_scsi_dev_iterate_hook_t hook, void *hook_data,
|
|
|
f96e0b |
if (pull != GRUB_DISK_PULL_NONE)
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
- grub_usb_poll_devices ();
|
|
|
f96e0b |
+ grub_usb_poll_devices (1);
|
|
|
f96e0b |
|
|
|
f96e0b |
for (i = 0; i < ARRAY_SIZE (grub_usbms_devices); i++)
|
|
|
f96e0b |
if (grub_usbms_devices[i])
|
|
|
f96e0b |
@@ -611,7 +611,8 @@ grub_usbms_open (int id, int devnum, struct grub_scsi *scsi)
|
|
|
f96e0b |
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
|
|
|
f96e0b |
"not USB Mass Storage device");
|
|
|
f96e0b |
|
|
|
f96e0b |
- grub_usb_poll_devices ();
|
|
|
f96e0b |
+ if (!grub_usbms_devices[devnum])
|
|
|
f96e0b |
+ grub_usb_poll_devices (1);
|
|
|
f96e0b |
|
|
|
f96e0b |
if (!grub_usbms_devices[devnum])
|
|
|
f96e0b |
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
|
|
|
f96e0b |
diff --git a/grub-core/kern/term.c b/grub-core/kern/term.c
|
|
|
f96e0b |
index 44ada25..66c5971 100644
|
|
|
f96e0b |
--- a/grub-core/kern/term.c
|
|
|
f96e0b |
+++ b/grub-core/kern/term.c
|
|
|
f96e0b |
@@ -32,7 +32,7 @@ struct grub_term_input *grub_term_inputs;
|
|
|
f96e0b |
grub_uint8_t grub_term_normal_color = GRUB_TERM_DEFAULT_NORMAL_COLOR;
|
|
|
f96e0b |
grub_uint8_t grub_term_highlight_color = GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR;
|
|
|
f96e0b |
|
|
|
f96e0b |
-void (*grub_term_poll_usb) (void) = NULL;
|
|
|
f96e0b |
+void (*grub_term_poll_usb) (int wait_for_completion) = NULL;
|
|
|
f96e0b |
void (*grub_net_poll_cards_idle) (void) = NULL;
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Put a Unicode character. */
|
|
|
f96e0b |
@@ -90,7 +90,7 @@ grub_getkey_noblock (void)
|
|
|
f96e0b |
grub_term_input_t term;
|
|
|
f96e0b |
|
|
|
f96e0b |
if (grub_term_poll_usb)
|
|
|
f96e0b |
- grub_term_poll_usb ();
|
|
|
f96e0b |
+ grub_term_poll_usb (0);
|
|
|
f96e0b |
|
|
|
f96e0b |
if (grub_net_poll_cards_idle)
|
|
|
f96e0b |
grub_net_poll_cards_idle ();
|
|
|
f96e0b |
diff --git a/include/grub/term.h b/include/grub/term.h
|
|
|
f96e0b |
index 84f5766..655a5e3 100644
|
|
|
f96e0b |
--- a/include/grub/term.h
|
|
|
f96e0b |
+++ b/include/grub/term.h
|
|
|
f96e0b |
@@ -467,7 +467,7 @@ grub_print_spaces (struct grub_term_output *term, int number_spaces)
|
|
|
f96e0b |
grub_putcode (' ', term);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
-extern void (*EXPORT_VAR (grub_term_poll_usb)) (void);
|
|
|
f96e0b |
+extern void (*EXPORT_VAR (grub_term_poll_usb)) (int wait_for_completion);
|
|
|
f96e0b |
|
|
|
f96e0b |
#define GRUB_TERM_REPEAT_PRE_INTERVAL 400
|
|
|
f96e0b |
#define GRUB_TERM_REPEAT_INTERVAL 50
|
|
|
f96e0b |
diff --git a/include/grub/usb.h b/include/grub/usb.h
|
|
|
f96e0b |
index 32f0ecd..7164dd5 100644
|
|
|
f96e0b |
--- a/include/grub/usb.h
|
|
|
f96e0b |
+++ b/include/grub/usb.h
|
|
|
f96e0b |
@@ -291,7 +291,7 @@ struct grub_usb_attach_desc
|
|
|
f96e0b |
void grub_usb_register_attach_hook_class (struct grub_usb_attach_desc *desc);
|
|
|
f96e0b |
void grub_usb_unregister_attach_hook_class (struct grub_usb_attach_desc *desc);
|
|
|
f96e0b |
|
|
|
f96e0b |
-void grub_usb_poll_devices (void);
|
|
|
f96e0b |
+void grub_usb_poll_devices (int wait_for_completion);
|
|
|
f96e0b |
|
|
|
f96e0b |
void grub_usb_device_attach (grub_usb_device_t dev);
|
|
|
f96e0b |
grub_usb_err_t
|
|
|
f96e0b |
--
|
|
|
f96e0b |
1.8.2.1
|
|
|
f96e0b |
|