Skip to content

Commit 564af7a

Browse files
committed
Merge branch 'pci/enumeration-logging'
- Log device type (Root Port, Switch Port, etc) during enumeration (Bjorn Helgaas) - Log resource names (BAR 0, VF BAR 0, bridge window, etc) consistently instead of a mix of names and "reg 0x10" (Puranjay Mohan, Bjorn Helgaas) - Log bridges before devices below the bridges (Bjorn Helgaas) * pci/enumeration-logging: PCI: Log bridge info when first enumerating bridge PCI: Log bridge windows conditionally PCI: Supply bridge device, not secondary bus, to read window details PCI: Move pci_read_bridge_windows() below individual window accessors PCI: Use resource names in PCI log messages PCI: Update BAR # and window messages PCI: Log device type during enumeration
2 parents 78e5ad7 + 95140c2 commit 564af7a

File tree

7 files changed

+286
-143
lines changed

7 files changed

+286
-143
lines changed

drivers/pci/iov.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ static int sriov_init(struct pci_dev *dev, int pos)
745745
u16 ctrl, total;
746746
struct pci_sriov *iov;
747747
struct resource *res;
748+
const char *res_name;
748749
struct pci_dev *pdev;
749750

750751
pci_read_config_word(dev, pos + PCI_SRIOV_CTRL, &ctrl);
@@ -785,6 +786,8 @@ static int sriov_init(struct pci_dev *dev, int pos)
785786
nres = 0;
786787
for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
787788
res = &dev->resource[i + PCI_IOV_RESOURCES];
789+
res_name = pci_resource_name(dev, i + PCI_IOV_RESOURCES);
790+
788791
/*
789792
* If it is already FIXED, don't change it, something
790793
* (perhaps EA or header fixups) wants it this way.
@@ -802,8 +805,8 @@ static int sriov_init(struct pci_dev *dev, int pos)
802805
}
803806
iov->barsz[i] = resource_size(res);
804807
res->end = res->start + resource_size(res) * total - 1;
805-
pci_info(dev, "VF(n) BAR%d space: %pR (contains BAR%d for %d VFs)\n",
806-
i, res, i, total);
808+
pci_info(dev, "%s %pR: contains BAR %d for %d VFs\n",
809+
res_name, res, i, total);
807810
i += bar64;
808811
nres++;
809812
}

drivers/pci/pci.c

Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,66 @@ struct resource *pci_find_resource(struct pci_dev *dev, struct resource *res)
850850
}
851851
EXPORT_SYMBOL(pci_find_resource);
852852

853+
/**
854+
* pci_resource_name - Return the name of the PCI resource
855+
* @dev: PCI device to query
856+
* @i: index of the resource
857+
*
858+
* Return the standard PCI resource (BAR) name according to their index.
859+
*/
860+
const char *pci_resource_name(struct pci_dev *dev, unsigned int i)
861+
{
862+
static const char * const bar_name[] = {
863+
"BAR 0",
864+
"BAR 1",
865+
"BAR 2",
866+
"BAR 3",
867+
"BAR 4",
868+
"BAR 5",
869+
"ROM",
870+
#ifdef CONFIG_PCI_IOV
871+
"VF BAR 0",
872+
"VF BAR 1",
873+
"VF BAR 2",
874+
"VF BAR 3",
875+
"VF BAR 4",
876+
"VF BAR 5",
877+
#endif
878+
"bridge window", /* "io" included in %pR */
879+
"bridge window", /* "mem" included in %pR */
880+
"bridge window", /* "mem pref" included in %pR */
881+
};
882+
static const char * const cardbus_name[] = {
883+
"BAR 1",
884+
"unknown",
885+
"unknown",
886+
"unknown",
887+
"unknown",
888+
"unknown",
889+
#ifdef CONFIG_PCI_IOV
890+
"unknown",
891+
"unknown",
892+
"unknown",
893+
"unknown",
894+
"unknown",
895+
"unknown",
896+
#endif
897+
"CardBus bridge window 0", /* I/O */
898+
"CardBus bridge window 1", /* I/O */
899+
"CardBus bridge window 0", /* mem */
900+
"CardBus bridge window 1", /* mem */
901+
};
902+
903+
if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS &&
904+
i < ARRAY_SIZE(cardbus_name))
905+
return cardbus_name[i];
906+
907+
if (i < ARRAY_SIZE(bar_name))
908+
return bar_name[i];
909+
910+
return "unknown";
911+
}
912+
853913
/**
854914
* pci_wait_for_pending - wait for @mask bit(s) to clear in status word @pos
855915
* @dev: the PCI device to operate on
@@ -3290,6 +3350,7 @@ static struct resource *pci_ea_get_resource(struct pci_dev *dev, u8 bei,
32903350
static int pci_ea_read(struct pci_dev *dev, int offset)
32913351
{
32923352
struct resource *res;
3353+
const char *res_name;
32933354
int ent_size, ent_offset = offset;
32943355
resource_size_t start, end;
32953356
unsigned long flags;
@@ -3319,6 +3380,7 @@ static int pci_ea_read(struct pci_dev *dev, int offset)
33193380
goto out;
33203381

33213382
res = pci_ea_get_resource(dev, bei, prop);
3383+
res_name = pci_resource_name(dev, bei);
33223384
if (!res) {
33233385
pci_err(dev, "Unsupported EA entry BEI: %u\n", bei);
33243386
goto out;
@@ -3392,16 +3454,16 @@ static int pci_ea_read(struct pci_dev *dev, int offset)
33923454
res->flags = flags;
33933455

33943456
if (bei <= PCI_EA_BEI_BAR5)
3395-
pci_info(dev, "BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n",
3396-
bei, res, prop);
3457+
pci_info(dev, "%s %pR: from Enhanced Allocation, properties %#02x\n",
3458+
res_name, res, prop);
33973459
else if (bei == PCI_EA_BEI_ROM)
3398-
pci_info(dev, "ROM: %pR (from Enhanced Allocation, properties %#02x)\n",
3399-
res, prop);
3460+
pci_info(dev, "%s %pR: from Enhanced Allocation, properties %#02x\n",
3461+
res_name, res, prop);
34003462
else if (bei >= PCI_EA_BEI_VF_BAR0 && bei <= PCI_EA_BEI_VF_BAR5)
3401-
pci_info(dev, "VF BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n",
3402-
bei - PCI_EA_BEI_VF_BAR0, res, prop);
3463+
pci_info(dev, "%s %pR: from Enhanced Allocation, properties %#02x\n",
3464+
res_name, res, prop);
34033465
else
3404-
pci_info(dev, "BEI %d res: %pR (from Enhanced Allocation, properties %#02x)\n",
3466+
pci_info(dev, "BEI %d %pR: from Enhanced Allocation, properties %#02x\n",
34053467
bei, res, prop);
34063468

34073469
out:
@@ -6689,14 +6751,15 @@ static void pci_request_resource_alignment(struct pci_dev *dev, int bar,
66896751
resource_size_t align, bool resize)
66906752
{
66916753
struct resource *r = &dev->resource[bar];
6754+
const char *r_name = pci_resource_name(dev, bar);
66926755
resource_size_t size;
66936756

66946757
if (!(r->flags & IORESOURCE_MEM))
66956758
return;
66966759

66976760
if (r->flags & IORESOURCE_PCI_FIXED) {
6698-
pci_info(dev, "BAR%d %pR: ignoring requested alignment %#llx\n",
6699-
bar, r, (unsigned long long)align);
6761+
pci_info(dev, "%s %pR: ignoring requested alignment %#llx\n",
6762+
r_name, r, (unsigned long long)align);
67006763
return;
67016764
}
67026765

@@ -6732,8 +6795,8 @@ static void pci_request_resource_alignment(struct pci_dev *dev, int bar,
67326795
* devices and we use the second.
67336796
*/
67346797

6735-
pci_info(dev, "BAR%d %pR: requesting alignment to %#llx\n",
6736-
bar, r, (unsigned long long)align);
6798+
pci_info(dev, "%s %pR: requesting alignment to %#llx\n",
6799+
r_name, r, (unsigned long long)align);
67376800

67386801
if (resize) {
67396802
r->start = 0;

drivers/pci/pci.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ void __pci_bus_assign_resources(const struct pci_bus *bus,
255255
struct list_head *fail_head);
256256
bool pci_bus_clip_resource(struct pci_dev *dev, int idx);
257257

258+
const char *pci_resource_name(struct pci_dev *dev, unsigned int i);
259+
258260
void pci_reassigndev_resource_alignment(struct pci_dev *dev);
259261
void pci_disable_bridge_window(struct pci_dev *dev);
260262
struct pci_bus *pci_bus_get(struct pci_bus *bus);

0 commit comments

Comments
 (0)