Browse Source

[ehci] Use meaningful device names in debug messages

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 years ago
parent
commit
5832e9ea93
2 changed files with 52 additions and 43 deletions
  1. 50
    43
      src/drivers/usb/ehci.c
  2. 2
    0
      src/drivers/usb/ehci.h

+ 50
- 43
src/drivers/usb/ehci.c View File

@@ -75,13 +75,13 @@ static void ehci_init ( struct ehci_device *ehci, void *regs ) {
75 75
 	ehci->cap = regs;
76 76
 	caplength = readb ( ehci->cap + EHCI_CAP_CAPLENGTH );
77 77
 	ehci->op = ( ehci->cap + caplength );
78
-	DBGC2 ( ehci, "EHCI %p cap %08lx op %08lx\n", ehci,
78
+	DBGC2 ( ehci, "EHCI %s cap %08lx op %08lx\n", ehci->name,
79 79
 		virt_to_phys ( ehci->cap ), virt_to_phys ( ehci->op ) );
80 80
 
81 81
 	/* Read structural parameters */
82 82
 	hcsparams = readl ( ehci->cap + EHCI_CAP_HCSPARAMS );
83 83
 	ehci->ports = EHCI_HCSPARAMS_PORTS ( hcsparams );
84
-	DBGC ( ehci, "EHCI %p has %d ports\n", ehci, ehci->ports );
84
+	DBGC ( ehci, "EHCI %s has %d ports\n", ehci->name, ehci->ports );
85 85
 
86 86
 	/* Read capability parameters 1 */
87 87
 	hccparams = readl ( ehci->cap + EHCI_CAP_HCCPARAMS );
@@ -89,7 +89,7 @@ static void ehci_init ( struct ehci_device *ehci, void *regs ) {
89 89
 	ehci->flsize = ( EHCI_HCCPARAMS_FLSIZE ( hccparams ) ?
90 90
 			 EHCI_FLSIZE_SMALL : EHCI_FLSIZE_DEFAULT );
91 91
 	ehci->eecp = EHCI_HCCPARAMS_EECP ( hccparams );
92
-	DBGC2 ( ehci, "EHCI %p %d-bit flsize %d\n", ehci,
92
+	DBGC2 ( ehci, "EHCI %s %d-bit flsize %d\n", ehci->name,
93 93
 		( ehci->addr64 ? 64 : 32 ), ehci->flsize );
94 94
 }
95 95
 
@@ -198,8 +198,8 @@ static void ehci_legacy_init ( struct ehci_device *ehci,
198 198
 	legacy = ehci_extended_capability ( ehci, pci, EHCI_EECP_ID_LEGACY, 0 );
199 199
 	if ( ! legacy ) {
200 200
 		/* Not an error; capability may not be present */
201
-		DBGC ( ehci, "EHCI %p has no USB legacy support capability\n",
202
-		       ehci );
201
+		DBGC ( ehci, "EHCI %s has no USB legacy support capability\n",
202
+		       ehci->name );
203 203
 		return;
204 204
 	}
205 205
 
@@ -207,8 +207,8 @@ static void ehci_legacy_init ( struct ehci_device *ehci,
207 207
 	pci_read_config_byte ( pci, ( legacy + EHCI_USBLEGSUP_BIOS ), &bios );
208 208
 	if ( ! ( bios & EHCI_USBLEGSUP_BIOS_OWNED ) ) {
209 209
 		/* Not an error; already owned by OS */
210
-		DBGC ( ehci, "EHCI %p USB legacy support already disabled\n",
211
-		       ehci );
210
+		DBGC ( ehci, "EHCI %s USB legacy support already disabled\n",
211
+		       ehci->name );
212 212
 		return;
213 213
 	}
214 214
 
@@ -244,14 +244,14 @@ static void ehci_legacy_claim ( struct ehci_device *ehci,
244 244
 		pci_read_config_byte ( pci, ( legacy + EHCI_USBLEGSUP_BIOS ),
245 245
 				       &bios );
246 246
 		if ( ! ( bios & EHCI_USBLEGSUP_BIOS_OWNED ) ) {
247
-			DBGC ( ehci, "EHCI %p claimed ownership from BIOS\n",
248
-			       ehci );
247
+			DBGC ( ehci, "EHCI %s claimed ownership from BIOS\n",
248
+			       ehci->name );
249 249
 			pci_read_config_dword ( pci, ( legacy +
250 250
 						       EHCI_USBLEGSUP_CTLSTS ),
251 251
 						&ctlsts );
252 252
 			if ( ctlsts ) {
253
-				DBGC ( ehci, "EHCI %p warning: BIOS retained "
254
-				       "SMIs: %08x\n", ehci, ctlsts );
253
+				DBGC ( ehci, "EHCI %s warning: BIOS retained "
254
+				       "SMIs: %08x\n", ehci->name, ctlsts );
255 255
 			}
256 256
 			return;
257 257
 		}
@@ -263,8 +263,8 @@ static void ehci_legacy_claim ( struct ehci_device *ehci,
263 263
 	/* BIOS did not release ownership.  Claim it forcibly by
264 264
 	 * disabling all SMIs.
265 265
 	 */
266
-	DBGC ( ehci, "EHCI %p could not claim ownership from BIOS: forcibly "
267
-	       "disabling SMIs\n", ehci );
266
+	DBGC ( ehci, "EHCI %s could not claim ownership from BIOS: forcibly "
267
+	       "disabling SMIs\n", ehci->name );
268 268
 	pci_write_config_dword ( pci, ( legacy + EHCI_USBLEGSUP_CTLSTS ), 0 );
269 269
 }
270 270
 
@@ -283,13 +283,14 @@ static void ehci_legacy_release ( struct ehci_device *ehci,
283 283
 
284 284
 	/* Do nothing if releasing ownership is prevented */
285 285
 	if ( ehci_legacy_prevent_release ) {
286
-		DBGC ( ehci, "EHCI %p not releasing ownership to BIOS\n", ehci);
286
+		DBGC ( ehci, "EHCI %s not releasing ownership to BIOS\n",
287
+		       ehci->name );
287 288
 		return;
288 289
 	}
289 290
 
290 291
 	/* Release ownership */
291 292
 	pci_write_config_byte ( pci, ( ehci->legacy + EHCI_USBLEGSUP_OS ), 0 );
292
-	DBGC ( ehci, "EHCI %p released ownership to BIOS\n", ehci );
293
+	DBGC ( ehci, "EHCI %s released ownership to BIOS\n", ehci->name );
293 294
 }
294 295
 
295 296
 /******************************************************************************
@@ -333,6 +334,8 @@ static void ehci_poll_companions ( struct ehci_device *ehci ) {
333 334
 			continue;
334 335
 
335 336
 		/* Poll child companion controller bus */
337
+		DBGC2 ( ehci, "EHCI %s polling companion %s\n",
338
+			ehci->name, bus->name );
336 339
 		usb_poll ( bus );
337 340
 	}
338 341
 }
@@ -415,7 +418,7 @@ static int ehci_stop ( struct ehci_device *ehci ) {
415 418
 		mdelay ( 1 );
416 419
 	}
417 420
 
418
-	DBGC ( ehci, "EHCI %p timed out waiting for stop\n", ehci );
421
+	DBGC ( ehci, "EHCI %s timed out waiting for stop\n", ehci->name );
419 422
 	return -ETIMEDOUT;
420 423
 }
421 424
 
@@ -453,7 +456,7 @@ static int ehci_reset ( struct ehci_device *ehci ) {
453 456
 		mdelay ( 1 );
454 457
 	}
455 458
 
456
-	DBGC ( ehci, "EHCI %p timed out waiting for reset\n", ehci );
459
+	DBGC ( ehci, "EHCI %s timed out waiting for reset\n", ehci->name );
457 460
 	return -ETIMEDOUT;
458 461
 }
459 462
 
@@ -498,7 +501,7 @@ static int ehci_ring_alloc ( struct ehci_device *ehci,
498 501
 		goto err_alloc_queue;
499 502
 	}
500 503
 	if ( ( rc = ehci_ctrl_reachable ( ehci, ring->head ) ) != 0 ) {
501
-		DBGC ( ehci, "EHCI %p queue head unreachable\n", ehci );
504
+		DBGC ( ehci, "EHCI %s queue head unreachable\n", ehci->name );
502 505
 		goto err_unreachable_queue;
503 506
 	}
504 507
 	memset ( ring->head, 0, sizeof ( *ring->head ) );
@@ -516,7 +519,8 @@ static int ehci_ring_alloc ( struct ehci_device *ehci,
516 519
 	for ( i = 0 ; i < EHCI_RING_COUNT ; i++ ) {
517 520
 		desc = &ring->desc[i];
518 521
 		if ( ( rc = ehci_ctrl_reachable ( ehci, desc ) ) != 0 ) {
519
-			DBGC ( ehci, "EHCI %p descriptor unreachable\n", ehci );
522
+			DBGC ( ehci, "EHCI %s descriptor unreachable\n",
523
+			       ehci->name );
520 524
 			goto err_unreachable_desc;
521 525
 		}
522 526
 		next = &ring->desc[ ( i + 1 ) % EHCI_RING_COUNT ];
@@ -785,8 +789,8 @@ static int ehci_async_del ( struct ehci_endpoint *endpoint ) {
785 789
 	}
786 790
 
787 791
 	/* Bad things will probably happen now */
788
-	DBGC ( ehci, "EHCI %p timed out waiting for asynchronous schedule "
789
-	       "to advance\n", ehci );
792
+	DBGC ( ehci, "EHCI %s timed out waiting for asynchronous schedule "
793
+	       "to advance\n", ehci->name );
790 794
 	return -ETIMEDOUT;
791 795
 }
792 796
 
@@ -808,7 +812,7 @@ static void ehci_periodic_schedule ( struct ehci_device *ehci ) {
808 812
 	 * safely run concurrently with hardware execution of the
809 813
 	 * schedule.
810 814
 	 */
811
-	DBGCP ( ehci, "EHCI %p periodic schedule: ", ehci );
815
+	DBGCP ( ehci, "EHCI %s periodic schedule: ", ehci->name );
812 816
 	link = EHCI_LINK_TERMINATE;
813 817
 	list_for_each_entry_reverse ( endpoint, &ehci->periodic, schedule ) {
814 818
 		queue = endpoint->ring.head;
@@ -822,7 +826,7 @@ static void ehci_periodic_schedule ( struct ehci_device *ehci ) {
822 826
 	DBGCP ( ehci, "\n" );
823 827
 
824 828
 	/* Populate periodic frame list */
825
-	DBGCP ( ehci, "EHCI %p periodic frame list:", ehci );
829
+	DBGCP ( ehci, "EHCI %s periodic frame list:", ehci->name );
826 830
 	frames = EHCI_PERIODIC_FRAMES ( ehci->flsize );
827 831
 	for ( i = 0 ; i < frames ; i++ ) {
828 832
 
@@ -1092,8 +1096,8 @@ static void ehci_endpoint_close ( struct usb_endpoint *ep ) {
1092 1096
 		/* No way to prevent hardware from continuing to
1093 1097
 		 * access the memory, so leak it.
1094 1098
 		 */
1095
-		DBGC ( ehci, "EHCI %p %s endpoint %02x could not unschedule: "
1096
-		       "%s\n", ehci, usb->name, ep->address, strerror ( rc ) );
1099
+		DBGC ( ehci, "EHCI %s %s could not unschedule: %s\n",
1100
+		       usb->name, usb_endpoint_name ( ep ), strerror ( rc ) );
1097 1101
 		return;
1098 1102
 	}
1099 1103
 
@@ -1291,9 +1295,10 @@ static void ehci_endpoint_poll ( struct ehci_endpoint *endpoint ) {
1291 1295
 		 */
1292 1296
 		if ( status & EHCI_STATUS_HALTED ) {
1293 1297
 			rc = -EIO_STATUS ( status );
1294
-			DBGC ( ehci, "EHCI %p %s endpoint %02x completion %d "
1295
-			       "failed (status %02x): %s\n", ehci, usb->name,
1296
-			       ep->address, index, status, strerror ( rc ) );
1298
+			DBGC ( ehci, "EHCI %s %s completion %d failed (status "
1299
+			       "%02x): %s\n", usb->name,
1300
+			       usb_endpoint_name ( ep ), index, status,
1301
+			       strerror ( rc ) );
1297 1302
 			while ( ! iobuf )
1298 1303
 				iobuf = ehci_dequeue ( ring );
1299 1304
 			usb_complete_err ( endpoint->ep, iobuf, rc );
@@ -1373,8 +1378,8 @@ static int ehci_device_address ( struct usb_device *usb ) {
1373 1378
 	address = usb_alloc_address ( bus );
1374 1379
 	if ( address < 0 ) {
1375 1380
 		rc = address;
1376
-		DBGC ( ehci, "EHCI %p %s could not allocate address: %s\n",
1377
-		       ehci, usb->name, strerror ( rc ) );
1381
+		DBGC ( ehci, "EHCI %s could not allocate address: %s\n",
1382
+		       usb->name, strerror ( rc ) );
1378 1383
 		goto err_alloc_address;
1379 1384
 	}
1380 1385
 
@@ -1496,8 +1501,8 @@ static int ehci_root_enable ( struct usb_hub *hub, struct usb_port *port ) {
1496 1501
 	portsc = readl ( ehci->op + EHCI_OP_PORTSC ( port->address ) );
1497 1502
 	line = EHCI_PORTSC_LINE_STATUS ( portsc );
1498 1503
 	if ( line == EHCI_PORTSC_LINE_STATUS_LOW ) {
1499
-		DBGC ( ehci, "EHCI %p port %d detected low-speed device: "
1500
-		       "disowning\n", ehci, port->address );
1504
+		DBGC ( ehci, "EHCI %s-%d detected low-speed device: "
1505
+		       "disowning\n", ehci->name, port->address );
1501 1506
 		goto disown;
1502 1507
 	}
1503 1508
 
@@ -1517,8 +1522,8 @@ static int ehci_root_enable ( struct usb_hub *hub, struct usb_port *port ) {
1517 1522
 		if ( ! ( portsc & EHCI_PORTSC_PR ) ) {
1518 1523
 			if ( portsc & EHCI_PORTSC_PED )
1519 1524
 				return 0;
1520
-			DBGC ( ehci, "EHCI %p port %d not enabled after reset: "
1521
-			       "disowning\n", ehci, port->address );
1525
+			DBGC ( ehci, "EHCI %s-%d not enabled after reset: "
1526
+			       "disowning\n", ehci->name, port->address );
1522 1527
 			goto disown;
1523 1528
 		}
1524 1529
 
@@ -1526,8 +1531,8 @@ static int ehci_root_enable ( struct usb_hub *hub, struct usb_port *port ) {
1526 1531
 		mdelay ( 1 );
1527 1532
 	}
1528 1533
 
1529
-	DBGC ( ehci, "EHCI %p timed out waiting for port %d to reset\n",
1530
-	       ehci, port->address );
1534
+	DBGC ( ehci, "EHCI %s-%d timed out waiting for port to reset\n",
1535
+	       ehci->name, port->address );
1531 1536
 	return -ETIMEDOUT;
1532 1537
 
1533 1538
  disown:
@@ -1582,8 +1587,8 @@ static int ehci_root_speed ( struct usb_hub *hub, struct usb_port *port ) {
1582 1587
 
1583 1588
 	/* Read port status */
1584 1589
 	portsc = readl ( ehci->op + EHCI_OP_PORTSC ( port->address ) );
1585
-	DBGC2 ( ehci, "EHCI %p port %d status is %08x\n",
1586
-		ehci, port->address, portsc );
1590
+	DBGC2 ( ehci, "EHCI %s-%d status is %08x\n",
1591
+		ehci->name, port->address, portsc );
1587 1592
 	ccs = ( portsc & EHCI_PORTSC_CCS );
1588 1593
 	csc = ( portsc & EHCI_PORTSC_CSC );
1589 1594
 	ped = ( portsc & EHCI_PORTSC_PED );
@@ -1626,8 +1631,8 @@ static int ehci_root_clear_tt ( struct usb_hub *hub, struct usb_port *port,
1626 1631
 	struct ehci_device *ehci = usb_hub_get_drvdata ( hub );
1627 1632
 
1628 1633
 	/* Should never be called; this is a root hub */
1629
-	DBGC ( ehci, "EHCI %p port %d nonsensical CLEAR_TT for %s endpoint "
1630
-	       "%02x\n", ehci, port->address, ep->usb->name, ep->address );
1634
+	DBGC ( ehci, "EHCI %s-%d nonsensical CLEAR_TT for %s %s\n", ehci->name,
1635
+	       port->address, ep->usb->name, usb_endpoint_name ( ep ) );
1631 1636
 
1632 1637
 	return -ENOTSUP;
1633 1638
 }
@@ -1701,7 +1706,8 @@ static int ehci_bus_open ( struct usb_bus *bus ) {
1701 1706
 	if ( ehci->addr64 ) {
1702 1707
 		writel ( ehci->ctrldssegment, ehci->op + EHCI_OP_CTRLDSSEGMENT);
1703 1708
 	} else if ( ehci->ctrldssegment ) {
1704
-		DBGC ( ehci, "EHCI %p CTRLDSSEGMENT not supported\n", ehci );
1709
+		DBGC ( ehci, "EHCI %s CTRLDSSEGMENT not supported\n",
1710
+		       ehci->name );
1705 1711
 		rc = -ENOTSUP;
1706 1712
 		goto err_ctrldssegment;
1707 1713
 	}
@@ -1715,7 +1721,7 @@ static int ehci_bus_open ( struct usb_bus *bus ) {
1715 1721
 		goto err_alloc_frame;
1716 1722
 	}
1717 1723
 	if ( ( rc = ehci_ctrl_reachable ( ehci, ehci->frame ) ) != 0 ) {
1718
-		DBGC ( ehci, "EHCI %p frame list unreachable\n", ehci );
1724
+		DBGC ( ehci, "EHCI %s frame list unreachable\n", ehci->name );
1719 1725
 		goto err_unreachable_frame;
1720 1726
 	}
1721 1727
 	ehci_periodic_schedule ( ehci );
@@ -1807,7 +1813,7 @@ static void ehci_bus_poll ( struct usb_bus *bus ) {
1807 1813
 
1808 1814
 	/* Report fatal errors */
1809 1815
 	if ( change & EHCI_USBSTS_SYSERR )
1810
-		DBGC ( ehci, "EHCI %p host system error\n", ehci );
1816
+		DBGC ( ehci, "EHCI %s host system error\n", ehci->name );
1811 1817
 }
1812 1818
 
1813 1819
 /******************************************************************************
@@ -1871,6 +1877,7 @@ static int ehci_probe ( struct pci_device *pci ) {
1871 1877
 		rc = -ENOMEM;
1872 1878
 		goto err_alloc;
1873 1879
 	}
1880
+	ehci->name = pci->dev.name;
1874 1881
 	INIT_LIST_HEAD ( &ehci->endpoints );
1875 1882
 	INIT_LIST_HEAD ( &ehci->async );
1876 1883
 	INIT_LIST_HEAD ( &ehci->periodic );

+ 2
- 0
src/drivers/usb/ehci.h View File

@@ -483,6 +483,8 @@ struct ehci_transfer {
483 483
 struct ehci_device {
484 484
 	/** Registers */
485 485
 	void *regs;
486
+	/** Name */
487
+	const char *name;
486 488
 
487 489
 	/** Capability registers */
488 490
 	void *cap;

Loading…
Cancel
Save