pci: pci_printk use
Subsystems (2)
All the pci_printk uses are at KERN_DEBUG which is always emitted into the kernel logging whenever the console log level is high enough.
Are any of these appropriate for conversion to pci_dbg to allow these only to be emitted via dynamic_debug or if necessary via a #define DEBUG during compilation?
$ git grep -w -n pci_printk drivers drivers/pci/bus.c:291: pci_printk(KERN_DEBUG, dev, "%pR clipped to %pR\n", drivers/pci/hotplug/shpchp.h:51: pci_printk(KERN_DEBUG, ctrl->pci_dev, \ drivers/pci/pci.c:2484: pci_printk(KERN_DEBUG, dev, "supports%s%s\n", drivers/pci/pci.c:2491: pci_printk(KERN_DEBUG, dev, "PME# supported from%s%s%s%s%s\n", drivers/pci/pci.c:2655: pci_printk(KERN_DEBUG, dev, "BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n", drivers/pci/pci.c:2658: pci_printk(KERN_DEBUG, dev, "ROM: %pR (from Enhanced Allocation, properties %#02x)\n", drivers/pci/pci.c:2661: pci_printk(KERN_DEBUG, dev, "VF BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n", drivers/pci/pci.c:2664: pci_printk(KERN_DEBUG, dev, "BEI %d res: %pR (from Enhanced Allocation, properties %#02x)\n", drivers/pci/pci.c:3775: pci_printk(KERN_DEBUG, dev, "cache line size of %d is not supported\n", drivers/pci/pcie/aer.c:775: pci_printk(KERN_DEBUG, parent, "can't find device of ID%04x\n", drivers/pci/pcie/aer.c:1317: pci_printk(KERN_DEBUG, dev, "Root Port link has been reset\n"); drivers/pci/pcie/err.c:75: pci_printk(KERN_DEBUG, dev, "device has %s\n", drivers/pci/pcie/err.c:179: pci_printk(KERN_DEBUG, dev, "downstream link has been reset\n"); drivers/pci/pcie/err.c:205: pci_printk(KERN_DEBUG, dev, "no link-reset support at upstream device %s\n", drivers/pci/pcie/err.c:211: pci_printk(KERN_DEBUG, dev, "link reset at upstream device %s failed\n", drivers/pci/pcie/err.c:237: pci_printk(KERN_DEBUG, dev, "broadcast %s message\n", error_mesg); drivers/pci/probe.c:321: pci_printk(KERN_DEBUG, dev, "reg 0x%x: %pR\n", pos, res); drivers/pci/probe.c:388: pci_printk(KERN_DEBUG, dev, " bridge window %pR\n", res); drivers/pci/probe.c:410: pci_printk(KERN_DEBUG, dev, " bridge window %pR\n", res); drivers/pci/probe.c:463: pci_printk(KERN_DEBUG, dev, " bridge window %pR\n", res); drivers/pci/probe.c:493: pci_printk(KERN_DEBUG, dev, drivers/pci/probe.c:1598: pci_printk(KERN_DEBUG, dev, "[%04x:%04x] type %02x class %#08x\n", drivers/pci/setup-bus.c:258: pci_printk(KERN_DEBUG, add_res->dev, drivers/pci/setup-bus.c:954: pci_printk(KERN_DEBUG, bus->self, "bridge window %pR to %pR add_size %llx\n", drivers/pci/setup-bus.c:1101: pci_printk(KERN_DEBUG, bus->self, "bridge window %pR to %pR add_size %llx add_align %llx\n", drivers/pci/setup-bus.c:1569: pci_printk(KERN_DEBUG, dev, "resource %d %pR released\n",
Quoted 7 lines · Joe Perches
All the
pci_printkuses are atKERN_DEBUGwhich is always emitted into the kernel logging whenever the console log level is high enough.Are any of these appropriate for conversion to
pci_dbgto allow these only to be emitted viadynamic_debugor if necessary via a #define DEBUG during compilation?
I think pci_printk(KERN_DEBUG) is a little ugly to read. My preference would be to remove them (and pci_dbg() uses) completely or convert them to pci_info(). Most of these are boot-time or low frequency messages, so I doubt the loglevel differentiation of DEBUG/INFO is really necessary.
Using pci_dbg() means the messages depend on the kernel config and the dynamic debug config, which is a bit of a hassle.
When I get bug reports, I'd much rather simply ask for a dmesg log than ask people to reproduce it with a different config or figure out the right dynamic debug option.
Quoted 28 lines
$ git grep -w -n pci_printk drivers drivers/pci/bus.c:291: pci_printk(KERN_DEBUG, dev, "%pR clipped to %pR\n", drivers/pci/hotplug/shpchp.h:51: pci_printk(KERN_DEBUG, ctrl->pci_dev, \ drivers/pci/pci.c:2484: pci_printk(KERN_DEBUG, dev, "supports%s%s\n", drivers/pci/pci.c:2491: pci_printk(KERN_DEBUG, dev, "PME# supported from%s%s%s%s%s\n", drivers/pci/pci.c:2655: pci_printk(KERN_DEBUG, dev, "BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n", drivers/pci/pci.c:2658: pci_printk(KERN_DEBUG, dev, "ROM: %pR (from Enhanced Allocation, properties %#02x)\n", drivers/pci/pci.c:2661: pci_printk(KERN_DEBUG, dev, "VF BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n", drivers/pci/pci.c:2664: pci_printk(KERN_DEBUG, dev, "BEI %d res: %pR (from Enhanced Allocation, properties %#02x)\n", drivers/pci/pci.c:3775: pci_printk(KERN_DEBUG, dev, "cache line size of %d is not supported\n", drivers/pci/pcie/aer.c:775: pci_printk(KERN_DEBUG, parent, "can't find device of ID%04x\n", drivers/pci/pcie/aer.c:1317: pci_printk(KERN_DEBUG, dev, "Root Port link has been reset\n"); drivers/pci/pcie/err.c:75: pci_printk(KERN_DEBUG, dev, "device has %s\n", drivers/pci/pcie/err.c:179: pci_printk(KERN_DEBUG, dev, "downstream link has been reset\n"); drivers/pci/pcie/err.c:205: pci_printk(KERN_DEBUG, dev, "no link-reset support at upstream device %s\n", drivers/pci/pcie/err.c:211: pci_printk(KERN_DEBUG, dev, "link reset at upstream device %s failed\n", drivers/pci/pcie/err.c:237: pci_printk(KERN_DEBUG, dev, "broadcast %s message\n", error_mesg); drivers/pci/probe.c:321: pci_printk(KERN_DEBUG, dev, "reg 0x%x: %pR\n", pos, res); drivers/pci/probe.c:388: pci_printk(KERN_DEBUG, dev, " bridge window %pR\n", res); drivers/pci/probe.c:410: pci_printk(KERN_DEBUG, dev, " bridge window %pR\n", res); drivers/pci/probe.c:463: pci_printk(KERN_DEBUG, dev, " bridge window %pR\n", res); drivers/pci/probe.c:493: pci_printk(KERN_DEBUG, dev, drivers/pci/probe.c:1598: pci_printk(KERN_DEBUG, dev, "[%04x:%04x] type %02x class %#08x\n", drivers/pci/setup-bus.c:258: pci_printk(KERN_DEBUG, add_res->dev, drivers/pci/setup-bus.c:954: pci_printk(KERN_DEBUG, bus->self, "bridge window %pR to %pR add_size %llx\n", drivers/pci/setup-bus.c:1101: pci_printk(KERN_DEBUG, bus->self, "bridge window %pR to %pR add_size %llx add_align %llx\n", drivers/pci/setup-bus.c:1569: pci_printk(KERN_DEBUG, dev, "resource %d %pR released\n",
Quoted 10 lines · Bjorn Helgaas
Quoted 7 lines · Joe Perches
All the
pci_printkuses are atKERN_DEBUGwhich is always emitted into the kernel logging whenever the console log level is high enough.Are any of these appropriate for conversion to
pci_dbgto allow these only to be emitted viadynamic_debugor if necessary via a #define DEBUG during compilation?I think
pci_printk(KERN_DEBUG)is a little ugly to read.
As do I which is why I bring it up.
Quoted 5 lines
My
preference would be to remove them (andpci_dbg()uses) completely or convert them topci_info(). Most of these are boot-time or low frequency messages, so I doubt the loglevel differentiation of DEBUG/INFO is really necessary.
Perhaps so.
Does anyone have objections to a patch that removes the #define pci_printk and does:
$ git ls-files -- 'drivers/pci/*.[ch]' \ xargs sed -i 's/pci_printk(KERN_DEBUG, /pci_info(/' with some alignment neatening?
Only issue I see is ctrl_dbg in the hotplug code being emitted at KERN_INFO but it is only output when a guard flag is set. Maybe those should use the normal pci_dbg instead of the shpchp_debug guard.
--- drivers/pci/bus.c | 3 +-- drivers/pci/hotplug/shpchp.h | 3 +-- drivers/pci/pci.c | 28 ++++++++++++++-------------- drivers/pci/pcie/aer.c | 5 ++--- drivers/pci/pcie/err.c | 18 +++++++++--------- drivers/pci/probe.c | 18 +++++++++--------- drivers/pci/setup-bus.c | 26 +++++++++++++------------- include/linux/pci.h | 3 --- 8 files changed, 49 insertions(+), 55 deletions(-)
drivers/pci/bus.c +1 -2
@@ -288,8 +288,7 @@ bool pci_bus_clip_resource(struct pci_dev *dev, int idx) res->end = end; res->flags &= ~IORESOURCE_UNSET ; orig_res.flags &= ~IORESOURCE_UNSET ; -pci_printk (KERN_DEBUG , dev,"%pR clipped to %pR\n" , - &orig_res, res); +pci_info (dev,"%pR clipped to %pR\n" , &orig_res, res);return true; }
drivers/pci/hotplug/shpchp.h +1 -2
@@ -48,8 +48,7 @@ do { \ #define ctrl_dbg(ctrl, format, arg...) \ do { \ if (shpchp_debug) \ - pci_printk(KERN_DEBUG, ctrl->pci_dev, \ - format, ## arg); \ + pci_info(ctrl->pci_dev, format, ## arg); \ } while (0) #define ctrl_err(ctrl, format, arg...) \ pci_err(ctrl->pci_dev, format, ## arg)
drivers/pci/pci.c +14 -14
@@ -2481,14 +2481,14 @@ void pci_pm_init(struct pci_dev *dev) dev->d2_support = true;if (dev->d1_support || dev->d2_support) -pci_printk (KERN_DEBUG , dev,"supports%s%s\n" , - dev->d1_support ?" D1" :"" , - dev->d2_support ?" D2" :"" ); +pci_info (dev,"supports%s%s\n" , + dev->d1_support ?" D1" :"" , + dev->d2_support ?" D2" :"" ); } pmc &=PCI_PM_CAP_PME_MASK ;if (pmc) { - pci_printk(KERN_DEBUG, dev, "PME# supported from%s%s%s%s%s\n", + pci_info(dev, "PME# supported from%s%s%s%s%s\n", (pmc & PCI_PM_CAP_PME_D0) ? " D0" : "", (pmc & PCI_PM_CAP_PME_D1) ? " D1" : "", (pmc & PCI_PM_CAP_PME_D2) ? " D2" : "",
@@ -2652,17 +2652,17 @@ static int pci_ea_read(struct pci_dev *dev, int offset) res->flags = flags;if (bei <=PCI_EA_BEI_BAR5 ) -pci_printk (KERN_DEBUG , dev,"BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n" , - bei, res, prop); +pci_info (dev,"BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n" , + bei, res, prop);else if (bei ==PCI_EA_BEI_ROM ) -pci_printk (KERN_DEBUG , dev,"ROM: %pR (from Enhanced Allocation, properties %#02x)\n" , - res, prop); +pci_info (dev,"ROM: %pR (from Enhanced Allocation, properties %#02x)\n" , + res, prop);else if (bei >=PCI_EA_BEI_VF_BAR0 && bei <=PCI_EA_BEI_VF_BAR5 ) -pci_printk (KERN_DEBUG , dev,"VF BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n" , - bei -PCI_EA_BEI_VF_BAR0 , res, prop); +pci_info (dev,"VF BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n" , + bei -PCI_EA_BEI_VF_BAR0 , res, prop);else -pci_printk (KERN_DEBUG , dev,"BEI %d res: %pR (from Enhanced Allocation, properties %#02x)\n" , - bei, res, prop); +pci_info (dev,"BEI %d res: %pR (from Enhanced Allocation, properties %#02x)\n" , + bei, res, prop); out:return offset + ent_size;
@@ -3772,8 +3772,8 @@ int pci_set_cacheline_size(struct pci_dev *dev)if (cacheline_size == pci_cache_line_size)return 0 ; -pci_printk (KERN_DEBUG , dev,"cache line size of %d is not supported\n" , - pci_cache_line_size <<2 ); +pci_info (dev,"cache line size of %d is not supported\n" , + pci_cache_line_size <<2 );return -EINVAL ; }
drivers/pci/pcie/aer.c +2 -3
@@ -772,8 +772,7 @@ static bool find_source_device(struct pci_dev *parent,pci_walk_bus (parent->subordinate, find_device_iter, e_info);if (!e_info->error_dev_num) { -pci_printk (KERN_DEBUG , parent,"can't find device of ID%04x\n" , - e_info->id); +pci_info (parent,"can't find device of ID%04x\n" , e_info->id);return false; }return true;
@@ -1314,7 +1313,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev)pci_write_config_dword (dev, pos +PCI_ERR_ROOT_COMMAND , reg32);pci_reset_bridge_secondary_bus (dev); -pci_printk (KERN_DEBUG , dev,"Root Port link has been reset\n" ); +pci_info (dev,"Root Port link has been reset\n" );/* Clear Root Error Status */ pci_read_config_dword (dev, pos +PCI_ERR_ROOT_STATUS , ®32);
drivers/pci/pcie/err.c +9 -9
@@ -72,9 +72,9 @@ static int report_error_detected(struct pci_dev *dev, void *data)* of a driver for this device is unaware of * its hw state. */ -pci_printk (KERN_DEBUG , dev,"device has %s\n" , - dev->driver ? -"no AER-aware driver" :"no driver" ); +pci_info (dev,"device has %s\n" , + dev->driver ? +"no AER-aware driver" :"no driver" ); }/*
@@ -176,7 +176,7 @@ static int report_resume(struct pci_dev *dev, void *data)static pci_ers_result_t default_reset_link (struct pci_dev *dev) {pci_reset_bridge_secondary_bus (dev); -pci_printk (KERN_DEBUG , dev,"downstream link has been reset\n" ); +pci_info (dev,"downstream link has been reset\n" );return PCI_ERS_RESULT_RECOVERED ; }
@@ -202,14 +202,14 @@ static pci_ers_result_t reset_link(struct pci_dev *dev, u32 service) }else if (udev->has_secondary_link) { status =default_reset_link (udev); }else { -pci_printk (KERN_DEBUG , dev,"no link-reset support at upstream device %s\n" , -pci_name (udev)); +pci_info (dev,"no link-reset support at upstream device %s\n" , +pci_name (udev));return PCI_ERS_RESULT_DISCONNECT ; }if (status !=PCI_ERS_RESULT_RECOVERED ) { -pci_printk (KERN_DEBUG , dev,"link reset at upstream device %s failed\n" , -pci_name (udev)); +pci_info (dev,"link reset at upstream device %s failed\n" , +pci_name (udev));return PCI_ERS_RESULT_DISCONNECT ; }
@@ -234,7 +234,7 @@ static pci_ers_result_t broadcast_error_message(struct pci_dev *dev, {struct aer_broadcast_data result_data; -pci_printk (KERN_DEBUG , dev,"broadcast %s message\n" , error_mesg); +pci_info (dev,"broadcast %s message\n" , error_mesg); result_data.state = state;if (cb == report_error_detected) result_data.result =PCI_ERS_RESULT_CAN_RECOVER ;
drivers/pci/probe.c +9 -9
@@ -318,7 +318,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, res->flags =0 ; out:if (res->flags) -pci_printk (KERN_DEBUG , dev,"reg 0x%x: %pR\n" , pos, res); +pci_info (dev,"reg 0x%x: %pR\n" , pos, res);return (res->flags &IORESOURCE_MEM_64 ) ?1 :0 ; }
@@ -385,7 +385,7 @@ static void pci_read_bridge_io(struct pci_bus *child) region.start = base; region.end = limit + io_granularity -1 ;pcibios_bus_to_resource (dev->bus, res, ®ion); -pci_printk (KERN_DEBUG , dev," bridge window %pR\n" , res); +pci_info (dev," bridge window %pR\n" , res); } }
@@ -407,7 +407,7 @@ static void pci_read_bridge_mmio(struct pci_bus *child) region.start = base; region.end = limit +0xfffff ;pcibios_bus_to_resource (dev->bus, res, ®ion); -pci_printk (KERN_DEBUG , dev," bridge window %pR\n" , res); +pci_info (dev," bridge window %pR\n" , res); } }
@@ -460,7 +460,7 @@ static void pci_read_bridge_mmio_pref(struct pci_bus *child) region.start = base; region.end = limit +0xfffff ;pcibios_bus_to_resource (dev->bus, res, ®ion); -pci_printk (KERN_DEBUG , dev," bridge window %pR\n" , res); +pci_info (dev," bridge window %pR\n" , res); } }
@@ -490,9 +490,9 @@ void pci_read_bridge_bases(struct pci_bus *child)if (res && res->flags) {pci_bus_add_resource (child, res,PCI_SUBTRACTIVE_DECODE ); -pci_printk (KERN_DEBUG , dev, -" bridge window %pR (subtractive decode)\n" , - res); +pci_info (dev, +" bridge window %pR (subtractive decode)\n" , + res); } } }
@@ -1595,8 +1595,8 @@ int pci_setup_device(struct pci_dev *dev) dev->revision = class &0xff ; dev->class = class >>8 ;/* upper 3 bytes */ -pci_printk (KERN_DEBUG , dev,"[%04x:%04x] type %02x class %#08x\n" , - dev->vendor, dev->device, dev->hdr_type, dev->class); +pci_info (dev,"[%04x:%04x] type %02x class %#08x\n" , + dev->vendor, dev->device, dev->hdr_type, dev->class);/* Need to have dev->class ready */ dev->cfg_size =pci_cfg_space_size (dev);
drivers/pci/setup-bus.c +13 -13
@@ -255,10 +255,10 @@ static void reassign_resources_sorted(struct list_head *realloc_head, (IORESOURCE_STARTALIGN |IORESOURCE_SIZEALIGN );if (pci_reassign_resource (add_res->dev, idx, add_size, align)) -pci_printk (KERN_DEBUG , add_res->dev, -"failed to add %llx res[%d]=%pR\n" , - (unsigned long long )add_size, - idx, res); +pci_info (add_res->dev, +"failed to add %llx res[%d]=%pR\n" , + (unsigned long long )add_size, + idx, res); } out:list_del (&add_res->list);
@@ -951,9 +951,9 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,if (size1 > size0 && realloc_head) {add_to_list (realloc_head, bus->self, b_res, size1-size0, min_align); -pci_printk (KERN_DEBUG , bus->self,"bridge window %pR to %pR add_size %llx\n" , - b_res, &bus->busn_res, - (unsigned long long )size1-size0); +pci_info (bus->self,"bridge window %pR to %pR add_size %llx\n" , + b_res, &bus->busn_res, + (unsigned long long )size1 - size0); } }
@@ -1098,10 +1098,10 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, b_res->flags |=IORESOURCE_STARTALIGN ;if (size1 > size0 && realloc_head) {add_to_list (realloc_head, bus->self, b_res, size1-size0, add_align); -pci_printk (KERN_DEBUG , bus->self,"bridge window %pR to %pR add_size %llx add_align %llx\n" , - b_res, &bus->busn_res, - (unsigned long long ) (size1 - size0), - (unsigned long long ) add_align); +pci_info (bus->self,"bridge window %pR to %pR add_size %llx add_align %llx\n" , + b_res, &bus->busn_res, + (unsigned long long )size1 - size0, + (unsigned long long )add_align); }return 0 ; }
@@ -1566,8 +1566,8 @@ static void pci_bridge_release_resources(struct pci_bus *bus,release_child_resources (r);if (!release_resource (r)) { type = old_flags = r->flags &PCI_RES_TYPE_MASK ; -pci_printk (KERN_DEBUG , dev,"resource %d %pR released\n" , -PCI_BRIDGE_RESOURCES + idx, r); +pci_info (dev,"resource %d %pR released\n" , +PCI_BRIDGE_RESOURCES + idx, r);/* keep the old size */ r->end =resource_size (r) -1 ; r->start =0 ;
include/linux/pci.h +0 -3
@@ -2298,9 +2298,6 @@ void pci_uevent_ers(struct pci_dev *pdev, enum pci_ers_result err_type);/* Provide the legacy pci_dma_* API */ #include <linux/pci-dma-compat.h> -#define pci_printk(level, pdev, fmt, arg...) \ - dev_printk(level, &(pdev)->dev, fmt, ##arg) - #define pci_emerg(pdev, fmt, arg...) dev_emerg(&(pdev)->dev, fmt, ##arg) #define pci_alert(pdev, fmt, arg...) dev_alert(&(pdev)->dev, fmt, ##arg) #define pci_crit(pdev, fmt, arg...) dev_crit(&(pdev)->dev, fmt, ##arg)