Fix a conflict between ports structures with 2 controllers of

same kind.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-03-20 17:07:08 +01:00
parent e9dabdfad8
commit ef8810e9f3
3 changed files with 27 additions and 19 deletions

View file

@ -1,3 +1,8 @@
2013-03-20 Vladimir Serbinenko <phcoder@gmail.com>
Fix a conflict between ports structures with 2 controllers of
same kind.
2013-03-20 Vladimir Serbinenko <phcoder@gmail.com> 2013-03-20 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/boottime.h: Add missing file. * include/grub/boottime.h: Add missing file.

View file

@ -37,6 +37,7 @@ struct grub_usb_hub
grub_usb_controller_t controller; grub_usb_controller_t controller;
int nports; int nports;
struct grub_usb_device **devices; struct grub_usb_device **devices;
struct grub_usb_hub_port *ports;
grub_usb_device_t dev; grub_usb_device_t dev;
}; };
@ -263,11 +264,11 @@ grub_usb_controller_dev_register_iter (grub_usb_controller_t controller, void *d
/* Query the number of ports the root Hub has. */ /* Query the number of ports the root Hub has. */
hub->nports = controller->dev->hubports (controller); hub->nports = controller->dev->hubports (controller);
hub->devices = grub_zalloc (sizeof (hub->devices[0]) * hub->nports); hub->devices = grub_zalloc (sizeof (hub->devices[0]) * hub->nports);
usb->ports = grub_zalloc (sizeof (usb->ports[0]) * hub->nports); hub->ports = grub_zalloc (sizeof (hub->ports[0]) * hub->nports);
if (!hub->devices || !usb->ports) if (!hub->devices || !hub->ports)
{ {
grub_free (hub->devices); grub_free (hub->devices);
grub_free (usb->ports); grub_free (hub->ports);
grub_free (hub->controller); grub_free (hub->controller);
grub_free (hub); grub_free (hub);
grub_print_error (); grub_print_error ();
@ -323,33 +324,37 @@ grub_usb_controller_dev_register (grub_usb_controller_dev_t usb)
speed = hub->controller->dev->detect_dev (hub->controller, portno, speed = hub->controller->dev->detect_dev (hub->controller, portno,
&changed); &changed);
if (usb->ports[portno].state == PORT_STATE_NORMAL if (hub->ports[portno].state == PORT_STATE_NORMAL
&& speed != GRUB_USB_SPEED_NONE) && speed != GRUB_USB_SPEED_NONE)
{ {
usb->ports[portno].soft_limit_time = grub_get_time_ms () + 250; hub->ports[portno].soft_limit_time = grub_get_time_ms () + 250;
usb->ports[portno].hard_limit_time = usb->ports[portno].soft_limit_time + 1750; hub->ports[portno].hard_limit_time = hub->ports[portno].soft_limit_time + 1750;
usb->ports[portno].state = PORT_STATE_WAITING_FOR_STABLE_POWER; hub->ports[portno].state = PORT_STATE_WAITING_FOR_STABLE_POWER;
grub_boot_time ("Scheduling stable power wait for port %p:%d",
usb, portno);
continue_waiting++; continue_waiting++;
continue; continue;
} }
if (usb->ports[portno].state == PORT_STATE_WAITING_FOR_STABLE_POWER if (hub->ports[portno].state == PORT_STATE_WAITING_FOR_STABLE_POWER
&& speed == GRUB_USB_SPEED_NONE) && speed == GRUB_USB_SPEED_NONE)
{ {
usb->ports[portno].soft_limit_time = grub_get_time_ms () + 250; hub->ports[portno].soft_limit_time = grub_get_time_ms () + 250;
continue; continue;
} }
if (usb->ports[portno].state == PORT_STATE_WAITING_FOR_STABLE_POWER if (hub->ports[portno].state == PORT_STATE_WAITING_FOR_STABLE_POWER
&& grub_get_time_ms () > usb->ports[portno].soft_limit_time) && grub_get_time_ms () > hub->ports[portno].soft_limit_time)
{ {
usb->ports[portno].state = PORT_STATE_STABLE_POWER; hub->ports[portno].state = PORT_STATE_STABLE_POWER;
grub_boot_time ("Got stable power wait for port %p:%d",
usb, portno);
continue_waiting--; continue_waiting--;
continue; continue;
} }
if (usb->ports[portno].state == PORT_STATE_WAITING_FOR_STABLE_POWER if (hub->ports[portno].state == PORT_STATE_WAITING_FOR_STABLE_POWER
&& grub_get_time_ms () > usb->ports[portno].hard_limit_time) && grub_get_time_ms () > hub->ports[portno].hard_limit_time)
{ {
usb->ports[portno].state = PORT_STATE_FAILED_DEVICE; hub->ports[portno].state = PORT_STATE_FAILED_DEVICE;
continue_waiting--; continue_waiting--;
continue; continue;
} }
@ -365,11 +370,11 @@ grub_usb_controller_dev_register (grub_usb_controller_dev_t usb)
for (hub = hubs; hub; hub = hub->next) for (hub = hubs; hub; hub = hub->next)
if (hub->controller->dev == usb) if (hub->controller->dev == usb)
for (portno = 0; portno < hub->nports; portno++) for (portno = 0; portno < hub->nports; portno++)
if (usb->ports[portno].state == PORT_STATE_STABLE_POWER) if (hub->ports[portno].state == PORT_STATE_STABLE_POWER)
{ {
grub_usb_speed_t speed; grub_usb_speed_t speed;
int changed = 0; int changed = 0;
usb->ports[portno].state = PORT_STATE_NORMAL; hub->ports[portno].state = PORT_STATE_NORMAL;
speed = hub->controller->dev->detect_dev (hub->controller, portno, &changed); speed = hub->controller->dev->detect_dev (hub->controller, portno, &changed);
attach_root_port (hub, portno, speed); attach_root_port (hub, portno, speed);
} }

View file

@ -121,8 +121,6 @@ struct grub_usb_controller_dev
grub_usb_speed_t (*detect_dev) (grub_usb_controller_t dev, int port, int *changed); grub_usb_speed_t (*detect_dev) (grub_usb_controller_t dev, int port, int *changed);
struct grub_usb_hub_port *ports;
/* Per controller flag - port reset pending, don't do another reset */ /* Per controller flag - port reset pending, don't do another reset */
grub_uint64_t pending_reset; grub_uint64_t pending_reset;