Couple of patches for the systems with multiple PCIe controllers. In my case it has 2 controllers and output of the lspci (with patches applied) looks like this:
0000:00:00.0 [060400]: [17cb:0113] 0000:01:00.0 [0c0330]: [1912:0014] (rev 03) xhci_hcd 0001:00:00.0 [060400]: [17cb:0113] 0001:01:00.0 [060400]: [1179:0623] 0001:02:01.0 [060400]: [1179:0623] 0001:02:02.0 [060400]: [1179:0623] 0001:02:03.0 [060400]: [1179:0623] 0001:03:00.0 [040000]: [17cd:0202] 0001:04:00.0 [0c0330]: [1912:0014] (rev 03) xhci_hcd 0001:05:00.0 [020000]: [1179:0220] tc956x_pci-eth 0001:05:00.1 [020000]: [1179:0220] tc956x_pci-eth 1. Fix "lspci -x" taking into account full PCI_PATH_NAME 2. Print full PCI_PATH_NAME to the output. -- Dima
From b5dce05ecdb63d5691262a8652a2fc2f4cef8b43 Mon Sep 17 00:00:00 2001 From: Dima Buzdyk <dima.buz...@gmail.com> Date: Fri, 14 Jun 2024 16:36:42 +0500 Subject: [PATCH 1/2] lsusb: config space dump with multiple PCIe controllers Fix config space dump (-x option) on machines with mulptiple PCIe controllers. In this case device IDs will be named '0001:00:00.0' and so on. --- toys/other/lsusb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/toys/other/lsusb.c b/toys/other/lsusb.c index 6bbfe0df..7642b094 100644 --- a/toys/other/lsusb.c +++ b/toys/other/lsusb.c @@ -234,9 +234,7 @@ static int list_pci(struct dirtree *new) FILE *fp; int b, col = 0, max = (TT.x >= 4) ? 4096 : ((TT.x >= 3) ? 256 : 64); - // TODO: where does the "0000:" come from? - snprintf(toybuf, sizeof(toybuf), "/sys/bus/pci/devices/0000:%s/config", - new->name+5); + snprintf(toybuf, sizeof(toybuf), "/sys/bus/pci/devices/%s/config", new->name); fp = xfopen(toybuf, "r"); while ((b = fgetc(fp)) != EOF) { if ((col % 16) == 0) printf("%02x: ", col & 0xf0); -- 2.43.0
From 003143957b4a5a490967630b7a52aae1c64dd876 Mon Sep 17 00:00:00 2001 From: Dima Buzdyk <dima.buz...@gmail.com> Date: Fri, 14 Jun 2024 18:33:47 +0500 Subject: [PATCH 2/2] lspci: print full pci path Print full PCI path including controller ID. --- toys/other/lsusb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toys/other/lsusb.c b/toys/other/lsusb.c index 7642b094..05113a33 100644 --- a/toys/other/lsusb.c +++ b/toys/other/lsusb.c @@ -214,7 +214,7 @@ static int list_pci(struct dirtree *new) if (!FLAG(e)) cvd[0] >>= 8; // Output line according to flags - printf("%s", new->name+5); + printf("%s", new->name); for (ii = 0; ii<3; ii++) { sprintf(buf, "%0*x", 6-2*(ii||!FLAG(e)), cvd[ii]); if (!TT.n) printf(FLAG(m) ? " \"%s\"" : ": %s"+(ii!=1), names[ii] ? : buf); -- 2.43.0
_______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net