Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[ehci] Use meaningful device names in debug messages
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed May 9, 2015
1 parent 91a4ad2 commit 5832e9e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 43 deletions.
93 changes: 50 additions & 43 deletions src/drivers/usb/ehci.c
Expand Up @@ -75,21 +75,21 @@ static void ehci_init ( struct ehci_device *ehci, void *regs ) {
ehci->cap = regs;
caplength = readb ( ehci->cap + EHCI_CAP_CAPLENGTH );
ehci->op = ( ehci->cap + caplength );
DBGC2 ( ehci, "EHCI %p cap %08lx op %08lx\n", ehci,
DBGC2 ( ehci, "EHCI %s cap %08lx op %08lx\n", ehci->name,
virt_to_phys ( ehci->cap ), virt_to_phys ( ehci->op ) );

/* Read structural parameters */
hcsparams = readl ( ehci->cap + EHCI_CAP_HCSPARAMS );
ehci->ports = EHCI_HCSPARAMS_PORTS ( hcsparams );
DBGC ( ehci, "EHCI %p has %d ports\n", ehci, ehci->ports );
DBGC ( ehci, "EHCI %s has %d ports\n", ehci->name, ehci->ports );

/* Read capability parameters 1 */
hccparams = readl ( ehci->cap + EHCI_CAP_HCCPARAMS );
ehci->addr64 = EHCI_HCCPARAMS_ADDR64 ( hccparams );
ehci->flsize = ( EHCI_HCCPARAMS_FLSIZE ( hccparams ) ?
EHCI_FLSIZE_SMALL : EHCI_FLSIZE_DEFAULT );
ehci->eecp = EHCI_HCCPARAMS_EECP ( hccparams );
DBGC2 ( ehci, "EHCI %p %d-bit flsize %d\n", ehci,
DBGC2 ( ehci, "EHCI %s %d-bit flsize %d\n", ehci->name,
( ehci->addr64 ? 64 : 32 ), ehci->flsize );
}

Expand Down Expand Up @@ -198,17 +198,17 @@ static void ehci_legacy_init ( struct ehci_device *ehci,
legacy = ehci_extended_capability ( ehci, pci, EHCI_EECP_ID_LEGACY, 0 );
if ( ! legacy ) {
/* Not an error; capability may not be present */
DBGC ( ehci, "EHCI %p has no USB legacy support capability\n",
ehci );
DBGC ( ehci, "EHCI %s has no USB legacy support capability\n",
ehci->name );
return;
}

/* Check if legacy USB support is enabled */
pci_read_config_byte ( pci, ( legacy + EHCI_USBLEGSUP_BIOS ), &bios );
if ( ! ( bios & EHCI_USBLEGSUP_BIOS_OWNED ) ) {
/* Not an error; already owned by OS */
DBGC ( ehci, "EHCI %p USB legacy support already disabled\n",
ehci );
DBGC ( ehci, "EHCI %s USB legacy support already disabled\n",
ehci->name );
return;
}

Expand Down Expand Up @@ -244,14 +244,14 @@ static void ehci_legacy_claim ( struct ehci_device *ehci,
pci_read_config_byte ( pci, ( legacy + EHCI_USBLEGSUP_BIOS ),
&bios );
if ( ! ( bios & EHCI_USBLEGSUP_BIOS_OWNED ) ) {
DBGC ( ehci, "EHCI %p claimed ownership from BIOS\n",
ehci );
DBGC ( ehci, "EHCI %s claimed ownership from BIOS\n",
ehci->name );
pci_read_config_dword ( pci, ( legacy +
EHCI_USBLEGSUP_CTLSTS ),
&ctlsts );
if ( ctlsts ) {
DBGC ( ehci, "EHCI %p warning: BIOS retained "
"SMIs: %08x\n", ehci, ctlsts );
DBGC ( ehci, "EHCI %s warning: BIOS retained "
"SMIs: %08x\n", ehci->name, ctlsts );
}
return;
}
Expand All @@ -263,8 +263,8 @@ static void ehci_legacy_claim ( struct ehci_device *ehci,
/* BIOS did not release ownership. Claim it forcibly by
* disabling all SMIs.
*/
DBGC ( ehci, "EHCI %p could not claim ownership from BIOS: forcibly "
"disabling SMIs\n", ehci );
DBGC ( ehci, "EHCI %s could not claim ownership from BIOS: forcibly "
"disabling SMIs\n", ehci->name );
pci_write_config_dword ( pci, ( legacy + EHCI_USBLEGSUP_CTLSTS ), 0 );
}

Expand All @@ -283,13 +283,14 @@ static void ehci_legacy_release ( struct ehci_device *ehci,

/* Do nothing if releasing ownership is prevented */
if ( ehci_legacy_prevent_release ) {
DBGC ( ehci, "EHCI %p not releasing ownership to BIOS\n", ehci);
DBGC ( ehci, "EHCI %s not releasing ownership to BIOS\n",
ehci->name );
return;
}

/* Release ownership */
pci_write_config_byte ( pci, ( ehci->legacy + EHCI_USBLEGSUP_OS ), 0 );
DBGC ( ehci, "EHCI %p released ownership to BIOS\n", ehci );
DBGC ( ehci, "EHCI %s released ownership to BIOS\n", ehci->name );
}

/******************************************************************************
Expand Down Expand Up @@ -333,6 +334,8 @@ static void ehci_poll_companions ( struct ehci_device *ehci ) {
continue;

/* Poll child companion controller bus */
DBGC2 ( ehci, "EHCI %s polling companion %s\n",
ehci->name, bus->name );
usb_poll ( bus );
}
}
Expand Down Expand Up @@ -415,7 +418,7 @@ static int ehci_stop ( struct ehci_device *ehci ) {
mdelay ( 1 );
}

DBGC ( ehci, "EHCI %p timed out waiting for stop\n", ehci );
DBGC ( ehci, "EHCI %s timed out waiting for stop\n", ehci->name );
return -ETIMEDOUT;
}

Expand Down Expand Up @@ -453,7 +456,7 @@ static int ehci_reset ( struct ehci_device *ehci ) {
mdelay ( 1 );
}

DBGC ( ehci, "EHCI %p timed out waiting for reset\n", ehci );
DBGC ( ehci, "EHCI %s timed out waiting for reset\n", ehci->name );
return -ETIMEDOUT;
}

Expand Down Expand Up @@ -498,7 +501,7 @@ static int ehci_ring_alloc ( struct ehci_device *ehci,
goto err_alloc_queue;
}
if ( ( rc = ehci_ctrl_reachable ( ehci, ring->head ) ) != 0 ) {
DBGC ( ehci, "EHCI %p queue head unreachable\n", ehci );
DBGC ( ehci, "EHCI %s queue head unreachable\n", ehci->name );
goto err_unreachable_queue;
}
memset ( ring->head, 0, sizeof ( *ring->head ) );
Expand All @@ -516,7 +519,8 @@ static int ehci_ring_alloc ( struct ehci_device *ehci,
for ( i = 0 ; i < EHCI_RING_COUNT ; i++ ) {
desc = &ring->desc[i];
if ( ( rc = ehci_ctrl_reachable ( ehci, desc ) ) != 0 ) {
DBGC ( ehci, "EHCI %p descriptor unreachable\n", ehci );
DBGC ( ehci, "EHCI %s descriptor unreachable\n",
ehci->name );
goto err_unreachable_desc;
}
next = &ring->desc[ ( i + 1 ) % EHCI_RING_COUNT ];
Expand Down Expand Up @@ -785,8 +789,8 @@ static int ehci_async_del ( struct ehci_endpoint *endpoint ) {
}

/* Bad things will probably happen now */
DBGC ( ehci, "EHCI %p timed out waiting for asynchronous schedule "
"to advance\n", ehci );
DBGC ( ehci, "EHCI %s timed out waiting for asynchronous schedule "
"to advance\n", ehci->name );
return -ETIMEDOUT;
}

Expand All @@ -808,7 +812,7 @@ static void ehci_periodic_schedule ( struct ehci_device *ehci ) {
* safely run concurrently with hardware execution of the
* schedule.
*/
DBGCP ( ehci, "EHCI %p periodic schedule: ", ehci );
DBGCP ( ehci, "EHCI %s periodic schedule: ", ehci->name );
link = EHCI_LINK_TERMINATE;
list_for_each_entry_reverse ( endpoint, &ehci->periodic, schedule ) {
queue = endpoint->ring.head;
Expand All @@ -822,7 +826,7 @@ static void ehci_periodic_schedule ( struct ehci_device *ehci ) {
DBGCP ( ehci, "\n" );

/* Populate periodic frame list */
DBGCP ( ehci, "EHCI %p periodic frame list:", ehci );
DBGCP ( ehci, "EHCI %s periodic frame list:", ehci->name );
frames = EHCI_PERIODIC_FRAMES ( ehci->flsize );
for ( i = 0 ; i < frames ; i++ ) {

Expand Down Expand Up @@ -1092,8 +1096,8 @@ static void ehci_endpoint_close ( struct usb_endpoint *ep ) {
/* No way to prevent hardware from continuing to
* access the memory, so leak it.
*/
DBGC ( ehci, "EHCI %p %s endpoint %02x could not unschedule: "
"%s\n", ehci, usb->name, ep->address, strerror ( rc ) );
DBGC ( ehci, "EHCI %s %s could not unschedule: %s\n",
usb->name, usb_endpoint_name ( ep ), strerror ( rc ) );
return;
}

Expand Down Expand Up @@ -1291,9 +1295,10 @@ static void ehci_endpoint_poll ( struct ehci_endpoint *endpoint ) {
*/
if ( status & EHCI_STATUS_HALTED ) {
rc = -EIO_STATUS ( status );
DBGC ( ehci, "EHCI %p %s endpoint %02x completion %d "
"failed (status %02x): %s\n", ehci, usb->name,
ep->address, index, status, strerror ( rc ) );
DBGC ( ehci, "EHCI %s %s completion %d failed (status "
"%02x): %s\n", usb->name,
usb_endpoint_name ( ep ), index, status,
strerror ( rc ) );
while ( ! iobuf )
iobuf = ehci_dequeue ( ring );
usb_complete_err ( endpoint->ep, iobuf, rc );
Expand Down Expand Up @@ -1373,8 +1378,8 @@ static int ehci_device_address ( struct usb_device *usb ) {
address = usb_alloc_address ( bus );
if ( address < 0 ) {
rc = address;
DBGC ( ehci, "EHCI %p %s could not allocate address: %s\n",
ehci, usb->name, strerror ( rc ) );
DBGC ( ehci, "EHCI %s could not allocate address: %s\n",
usb->name, strerror ( rc ) );
goto err_alloc_address;
}

Expand Down Expand Up @@ -1496,8 +1501,8 @@ static int ehci_root_enable ( struct usb_hub *hub, struct usb_port *port ) {
portsc = readl ( ehci->op + EHCI_OP_PORTSC ( port->address ) );
line = EHCI_PORTSC_LINE_STATUS ( portsc );
if ( line == EHCI_PORTSC_LINE_STATUS_LOW ) {
DBGC ( ehci, "EHCI %p port %d detected low-speed device: "
"disowning\n", ehci, port->address );
DBGC ( ehci, "EHCI %s-%d detected low-speed device: "
"disowning\n", ehci->name, port->address );
goto disown;
}

Expand All @@ -1517,17 +1522,17 @@ static int ehci_root_enable ( struct usb_hub *hub, struct usb_port *port ) {
if ( ! ( portsc & EHCI_PORTSC_PR ) ) {
if ( portsc & EHCI_PORTSC_PED )
return 0;
DBGC ( ehci, "EHCI %p port %d not enabled after reset: "
"disowning\n", ehci, port->address );
DBGC ( ehci, "EHCI %s-%d not enabled after reset: "
"disowning\n", ehci->name, port->address );
goto disown;
}

/* Delay */
mdelay ( 1 );
}

DBGC ( ehci, "EHCI %p timed out waiting for port %d to reset\n",
ehci, port->address );
DBGC ( ehci, "EHCI %s-%d timed out waiting for port to reset\n",
ehci->name, port->address );
return -ETIMEDOUT;

disown:
Expand Down Expand Up @@ -1582,8 +1587,8 @@ static int ehci_root_speed ( struct usb_hub *hub, struct usb_port *port ) {

/* Read port status */
portsc = readl ( ehci->op + EHCI_OP_PORTSC ( port->address ) );
DBGC2 ( ehci, "EHCI %p port %d status is %08x\n",
ehci, port->address, portsc );
DBGC2 ( ehci, "EHCI %s-%d status is %08x\n",
ehci->name, port->address, portsc );
ccs = ( portsc & EHCI_PORTSC_CCS );
csc = ( portsc & EHCI_PORTSC_CSC );
ped = ( portsc & EHCI_PORTSC_PED );
Expand Down Expand Up @@ -1626,8 +1631,8 @@ static int ehci_root_clear_tt ( struct usb_hub *hub, struct usb_port *port,
struct ehci_device *ehci = usb_hub_get_drvdata ( hub );

/* Should never be called; this is a root hub */
DBGC ( ehci, "EHCI %p port %d nonsensical CLEAR_TT for %s endpoint "
"%02x\n", ehci, port->address, ep->usb->name, ep->address );
DBGC ( ehci, "EHCI %s-%d nonsensical CLEAR_TT for %s %s\n", ehci->name,
port->address, ep->usb->name, usb_endpoint_name ( ep ) );

return -ENOTSUP;
}
Expand Down Expand Up @@ -1701,7 +1706,8 @@ static int ehci_bus_open ( struct usb_bus *bus ) {
if ( ehci->addr64 ) {
writel ( ehci->ctrldssegment, ehci->op + EHCI_OP_CTRLDSSEGMENT);
} else if ( ehci->ctrldssegment ) {
DBGC ( ehci, "EHCI %p CTRLDSSEGMENT not supported\n", ehci );
DBGC ( ehci, "EHCI %s CTRLDSSEGMENT not supported\n",
ehci->name );
rc = -ENOTSUP;
goto err_ctrldssegment;
}
Expand All @@ -1715,7 +1721,7 @@ static int ehci_bus_open ( struct usb_bus *bus ) {
goto err_alloc_frame;
}
if ( ( rc = ehci_ctrl_reachable ( ehci, ehci->frame ) ) != 0 ) {
DBGC ( ehci, "EHCI %p frame list unreachable\n", ehci );
DBGC ( ehci, "EHCI %s frame list unreachable\n", ehci->name );
goto err_unreachable_frame;
}
ehci_periodic_schedule ( ehci );
Expand Down Expand Up @@ -1807,7 +1813,7 @@ static void ehci_bus_poll ( struct usb_bus *bus ) {

/* Report fatal errors */
if ( change & EHCI_USBSTS_SYSERR )
DBGC ( ehci, "EHCI %p host system error\n", ehci );
DBGC ( ehci, "EHCI %s host system error\n", ehci->name );
}

/******************************************************************************
Expand Down Expand Up @@ -1871,6 +1877,7 @@ static int ehci_probe ( struct pci_device *pci ) {
rc = -ENOMEM;
goto err_alloc;
}
ehci->name = pci->dev.name;
INIT_LIST_HEAD ( &ehci->endpoints );
INIT_LIST_HEAD ( &ehci->async );
INIT_LIST_HEAD ( &ehci->periodic );
Expand Down
2 changes: 2 additions & 0 deletions src/drivers/usb/ehci.h
Expand Up @@ -483,6 +483,8 @@ struct ehci_transfer {
struct ehci_device {
/** Registers */
void *regs;
/** Name */
const char *name;

/** Capability registers */
void *cap;
Expand Down

0 comments on commit 5832e9e

Please sign in to comment.