Implement boot time analysis framework.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-03-19 20:25:09 +01:00
parent e5a2dd7b55
commit e744219bb6
14 changed files with 232 additions and 8 deletions

View file

@ -715,6 +715,7 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
usblegsup = grub_pci_read (pciaddr_eecp);
if (usblegsup & GRUB_EHCI_BIOS_OWNED)
{
grub_boot_time ("Taking ownership of EHCI port");
grub_dprintf ("ehci",
"EHCI grub_ehci_pci_iter: EHCI owned by: BIOS\n");
/* Ownership change - set OS_OWNED bit */
@ -741,6 +742,7 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
/* Ensure PCI register is written */
grub_pci_read (pciaddr_eecp);
}
grub_boot_time ("Ownership of EHCI port taken");
}
else if (usblegsup & GRUB_EHCI_OS_OWNED)
/* XXX: What to do in this case - nothing ? Can it happen ? */
@ -1706,10 +1708,12 @@ grub_ehci_portstatus (grub_usb_controller_t dev,
/* Reset RESET bit and wait for the end of reset */
grub_ehci_port_resbits (e, port, GRUB_EHCI_PORT_RESET);
endtime = grub_get_time_ms () + 1000;
grub_boot_time ("Resetting port %d", port);
while (grub_ehci_port_read (e, port) & GRUB_EHCI_PORT_RESET)
if (grub_get_time_ms () > endtime)
return grub_error (GRUB_ERR_IO,
"portstatus: EHCI Timed out - reset port");
grub_boot_time ("Port %d reset", port);
/* Remember "we did the reset" - needed by detect_dev */
e->reset |= (1 << port);
/* Test if port enabled, i.e. HIGH speed device connected */
@ -1911,8 +1915,11 @@ GRUB_MOD_INIT (ehci)
{
COMPILE_TIME_ASSERT (sizeof (struct grub_ehci_td) == 64);
COMPILE_TIME_ASSERT (sizeof (struct grub_ehci_qh) == 96);
grub_boot_time ("Initing EHCI hardware");
grub_ehci_inithw ();
grub_boot_time ("Registering EHCI driver");
grub_usb_controller_dev_register (&usb_controller);
grub_boot_time ("EHCI driver registered");
grub_loader_register_preboot_hook (grub_ehci_fini_hw, grub_ehci_restore_hw,
GRUB_LOADER_PREBOOT_HOOK_PRIO_DISK);
}

View file

@ -262,8 +262,13 @@ void grub_usb_device_attach (grub_usb_device_t dev)
continue;
for (desc = attach_hooks; desc; desc = desc->next)
if (interf->class == desc->class && desc->hook (dev, 0, i))
dev->config[0].interf[i].attached = 1;
if (interf->class == desc->class)
{
grub_boot_time ("Probing USB device driver class %x", desc->class);
if (desc->hook (dev, 0, i))
dev->config[0].interf[i].attached = 1;
grub_boot_time ("Probed USB device driver class %x", desc->class);
}
if (dev->config[0].interf[i].attached)
continue;

View file

@ -52,6 +52,8 @@ grub_usb_hub_add_dev (grub_usb_controller_t controller,
int i;
grub_usb_err_t err;
grub_boot_time ("Attaching USB device");
dev = grub_zalloc (sizeof (struct grub_usb_device));
if (! dev)
return NULL;
@ -108,8 +110,12 @@ grub_usb_hub_add_dev (grub_usb_controller_t controller,
/* Wait "recovery interval", spec. says 2ms */
grub_millisleep (2);
grub_boot_time ("Probing USB device driver");
grub_usb_device_attach (dev);
grub_boot_time ("Attached USB device");
return dev;
}
@ -194,6 +200,8 @@ attach_root_port (struct grub_usb_hub *hub, int portno,
grub_usb_speed_t current_speed = GRUB_USB_SPEED_NONE;
int changed=0;
grub_boot_time ("detect_dev USB root portno=%d\n", portno);
#if 0
/* Specification does not say about disabling of port when device
* connected. If disabling is really necessary for some devices,
@ -203,6 +211,9 @@ attach_root_port (struct grub_usb_hub *hub, int portno,
if (err)
return;
#endif
grub_boot_time ("Before the stable power wait portno=%d", portno);
/* Wait for completion of insertion and stable power (USB spec.)
* Should be at least 100ms, some devices requires more...
* There is also another thing - some devices have worse contacts
@ -239,6 +250,8 @@ attach_root_port (struct grub_usb_hub *hub, int portno,
/* If the device is a Hub, scan it for more devices. */
if (dev->descdev.class == 0x09)
grub_usb_add_hub (dev);
grub_boot_time ("Attached root port");
}
grub_usb_err_t
@ -248,6 +261,8 @@ grub_usb_root_hub (grub_usb_controller_t controller)
struct grub_usb_hub *hub;
int changed=0;
grub_boot_time ("Registering USB root hub");
hub = grub_malloc (sizeof (*hub));
if (!hub)
return GRUB_USB_ERR_INTERNAL;
@ -287,6 +302,8 @@ grub_usb_root_hub (grub_usb_controller_t controller)
}
}
grub_boot_time ("USB root hub registered");
return GRUB_USB_ERR_NONE;
}
@ -407,12 +424,13 @@ poll_nonroot_hub (grub_usb_device_t dev)
/* Connected and status of connection changed ? */
if (status & GRUB_USB_HUB_STATUS_PORT_CONNECTED)
{
grub_boot_time ("Before the stable power wait portno=%d", i);
/* A device is actually connected to this port. */
/* Wait for completion of insertion and stable power (USB spec.)
* Should be at least 100ms, some devices requires more...
* There is also another thing - some devices have worse contacts
* and connected signal is unstable for some time - we should handle
* it - but prevent deadlock in case when device is too faulty... */
/* Wait for completion of insertion and stable power (USB spec.)
* Should be at least 100ms, some devices requires more...
* There is also another thing - some devices have worse contacts
* and connected signal is unstable for some time - we should handle
* it - but prevent deadlock in case when device is too faulty... */
for (total = j = 0; (j < 250) && (total < 2000); j++, total++)
{
grub_millisleep (1);
@ -432,6 +450,9 @@ poll_nonroot_hub (grub_usb_device_t dev)
if (!(current_status & GRUB_USB_HUB_STATUS_PORT_CONNECTED))
j = 0;
}
grub_boot_time ("After the stable power wait portno=%d", i);
grub_dprintf ("usb", "(non-root) total=%d\n", total);
if (total >= 2000)
continue;
@ -443,6 +464,8 @@ poll_nonroot_hub (grub_usb_device_t dev)
GRUB_USB_REQ_SET_FEATURE,
GRUB_USB_HUB_FEATURE_PORT_RESET,
i, 0, 0);
grub_boot_time ("Resetting port %d", i);
rescan = 1;
/* We cannot reset more than one device at the same time !
* Resetting more devices together results in very bad
@ -464,6 +487,8 @@ poll_nonroot_hub (grub_usb_device_t dev)
GRUB_USB_REQ_CLEAR_FEATURE,
GRUB_USB_HUB_FEATURE_C_PORT_RESET, i, 0, 0);
grub_boot_time ("Port %d reset", i);
if (status & GRUB_USB_HUB_STATUS_PORT_CONNECTED)
{
grub_usb_speed_t speed;