Skip to contentSkip to conversation

PCI: Use PCIe service name in dmesg logs

PATCH Superseded [email protected] 4 participants 15 messages Apr 27, 2019 – Apr 30, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover PCI: Use PCIe service name in dmesg logs

From: Frederick Lawler <[email protected]>

In referrence to [1], PCIe services did not have unifrom logging via pci_*() printk wrappers. This patch series first replaces left over dev_*() calls for port services. Then, replaces all hotplug ctrl_*() calls with pci_*() to bring hotplug in line with the other services, and removes the custom ctrl_*() definitions. Lastly, to satisfy [1], add in dev_fmt()'s to each of the services.

1. https://lore.kernel.org/linux-pci/[email protected]/

Frederick Lawler (4):
PCI: Replace dev_*() printk wrappers with pci_*() printk wrappers
PCI: pciehp: Replace ctrl_*() with pci_*()
PCI: pciehp: Remove unused macro definitions PCI/portdrv: Add dev_fmt() to port drivers

 drivers/pci/hotplug/pciehp.h       |  27 -----
 drivers/pci/hotplug/pciehp_core.c  |  25 +++--
 drivers/pci/hotplug/pciehp_ctrl.c  |  88 +++++++++--------
 drivers/pci/hotplug/pciehp_hpc.c   | 154 ++++++++++++++++-------------
 drivers/pci/hotplug/pciehp_pci.c   |  12 ++-
 drivers/pci/pcie/aer.c             |  16 +--
 drivers/pci/pcie/aer_inject.c      |   6 +-
 drivers/pci/pcie/bw_notification.c |   2 +
 drivers/pci/pcie/dpc.c             |  29 +++---
 drivers/pci/pcie/pme.c             |   2 +
 10 files changed, 187 insertions(+), 174 deletions(-)

--
2.17.1

#1 lore raw

PATCH 1/4 PCI: Replace dev_*() printk wrappers with pci_*() printk wrappers

From: Frederick Lawler <[email protected]>

Replace remaining instances of dev_*() printk wrappers with pci_*() printk wrappers. No functional change intended.

---
 drivers/pci/pcie/aer.c        | 13 ++++++-------
 drivers/pci/pcie/aer_inject.c |  4 ++--
 drivers/pci/pcie/dpc.c        | 27 ++++++++++++---------------
 3 files changed, 20 insertions(+), 24 deletions(-)
drivers/pci/pcie/aer.c +6 -7
index f8fc2114ad39..224d878a28b4 100644
@@ -964,8 +964,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_dbg(parent, "can't find device of ID%04x\n", e_info->id);
 		return false;
 	}
 	return true;
@@ -1377,10 +1376,11 @@ static int aer_probe(struct pcie_device *dev)
 	int status;
 	struct aer_rpc *rpc;
 	struct device *device = &dev->device;
+	struct pci_dev *pdev = dev->port;
 
 	rpc = devm_kzalloc(device, sizeof(struct aer_rpc), GFP_KERNEL);
 	if (!rpc) {
-		dev_printk(KERN_DEBUG, device, "alloc AER rpc failed\n");
+		pci_dbg(pdev, "alloc AER rpc failed\n");
 		return -ENOMEM;
 	}
 	rpc->rpd = dev->port;
@@ -1389,13 +1389,12 @@ static int aer_probe(struct pcie_device *dev)
 	status = devm_request_threaded_irq(device, dev->irq, aer_irq, aer_isr,
 					   IRQF_SHARED, "aerdrv", dev);
 	if (status) {
-		dev_printk(KERN_DEBUG, device, "request AER IRQ %d failed\n",
-			   dev->irq);
+		pci_dbg(pdev, "request AER IRQ %d failed\n", dev->irq);
 		return status;
 	}
 
 	aer_enable_rootport(rpc);
-	dev_info(device, "AER enabled with IRQ %d\n", dev->irq);
+	pci_info(pdev, "AER enabled with IRQ %d\n", dev->irq);
 	return 0;
 }
 
@@ -1419,7 +1418,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev)
 	pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, reg32);
 
 	rc = pci_bus_error_reset(dev);
-	pci_printk(KERN_DEBUG, dev, "Root Port link has been reset\n");
+	pci_dbg(dev, "Root Port link has been reset\n");
 
 	/* Clear Root Error Status */
 	pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, &reg32);
drivers/pci/pcie/aer_inject.c +2 -2
index 95d4759664b3..610b617ae600 100644
@@ -460,12 +460,12 @@ static int aer_inject(struct aer_error_inj *einj)
 	if (device) {
 		edev = to_pcie_device(device);
 		if (!get_service_data(edev)) {
-			dev_warn(&edev->device,
+			pci_warn(edev->port,
 				 "aer_inject: AER service is not initialized\n");
 			ret = -EPROTONOSUPPORT;
 			goto out_put;
 		}
-		dev_info(&edev->device,
+		pci_info(edev->port,
 			 "aer_inject: Injecting errors %08x/%08x into device %s\n",
 			 einj->cor_status, einj->uncor_status, pci_name(dev));
 		local_irq_disable();
drivers/pci/pcie/dpc.c +12 -15
index 7b77754a82de..72659286191b 100644
@@ -100,7 +100,6 @@ static int dpc_wait_rp_inactive(struct dpc_dev *dpc)
 {
 	unsigned long timeout = jiffies + HZ;
 	struct pci_dev *pdev = dpc->dev->port;
-	struct device *dev = &dpc->dev->device;
 	u16 cap = dpc->cap_pos, status;
 
 	pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &status);
@@ -110,7 +109,7 @@ static int dpc_wait_rp_inactive(struct dpc_dev *dpc)
 		pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &status);
 	}
 	if (status & PCI_EXP_DPC_RP_BUSY) {
-		dev_warn(dev, "DPC root port still busy\n");
+		pci_warn(pdev, "DPC root port still busy\n");
 		return -EBUSY;
 	}
 	return 0;
@@ -148,7 +147,6 @@ static pci_ers_result_t dpc_reset_link(struct pci_dev *pdev)
 
 static void dpc_process_rp_pio_error(struct dpc_dev *dpc)
 {
-	struct device *dev = &dpc->dev->device;
 	struct pci_dev *pdev = dpc->dev->port;
 	u16 cap = dpc->cap_pos, dpc_status, first_error;
 	u32 status, mask, sev, syserr, exc, dw0, dw1, dw2, dw3, log, prefix;
@@ -156,13 +154,13 @@ static void dpc_process_rp_pio_error(struct dpc_dev *dpc)
 
 	pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_STATUS, &status);
 	pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_MASK, &mask);
-	dev_err(dev, "rp_pio_status: %#010x, rp_pio_mask: %#010x\n",
+	pci_err(pdev, "rp_pio_status: %#010x, rp_pio_mask: %#010x\n",
 		status, mask);
 
 	pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_SEVERITY, &sev);
 	pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_SYSERROR, &syserr);
 	pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_EXCEPTION, &exc);
-	dev_err(dev, "RP PIO severity=%#010x, syserror=%#010x, exception=%#010x\n",
+	pci_err(pdev, "RP PIO severity=%#010x, syserror=%#010x, exception=%#010x\n",
 		sev, syserr, exc);
 
 	/* Get First Error Pointer */
@@ -171,7 +169,7 @@ static void dpc_process_rp_pio_error(struct dpc_dev *dpc)
 
 	for (i = 0; i < ARRAY_SIZE(rp_pio_error_string); i++) {
 		if ((status & ~mask) & (1 << i))
-			dev_err(dev, "[%2d] %s%s\n", i, rp_pio_error_string[i],
+			pci_err(pdev, "[%2d] %s%s\n", i, rp_pio_error_string[i],
 				first_error == i ? " (First)" : "");
 	}
 
@@ -185,18 +183,18 @@ static void dpc_process_rp_pio_error(struct dpc_dev *dpc)
 			      &dw2);
 	pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG + 12,
 			      &dw3);
-	dev_err(dev, "TLP Header: %#010x %#010x %#010x %#010x\n",
+	pci_err(pdev, "TLP Header: %#010x %#010x %#010x %#010x\n",
 		dw0, dw1, dw2, dw3);
 
 	if (dpc->rp_log_size < 5)
 		goto clear_status;
 	pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_IMPSPEC_LOG, &log);
-	dev_err(dev, "RP PIO ImpSpec Log %#010x\n", log);
+	pci_err(pdev, "RP PIO ImpSpec Log %#010x\n", log);
 
 	for (i = 0; i < dpc->rp_log_size - 5; i++) {
 		pci_read_config_dword(pdev,
 			cap + PCI_EXP_DPC_RP_PIO_TLPPREFIX_LOG, &prefix);
-		dev_err(dev, "TLP Prefix Header: dw%d, %#010x\n", i, prefix);
+		pci_err(pdev, "TLP Prefix Header: dw%d, %#010x\n", i, prefix);
 	}
  clear_status:
 	pci_write_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_STATUS, status);
@@ -229,18 +227,17 @@ static irqreturn_t dpc_handler(int irq, void *context)
 	struct aer_err_info info;
 	struct dpc_dev *dpc = context;
 	struct pci_dev *pdev = dpc->dev->port;
-	struct device *dev = &dpc->dev->device;
 	u16 cap = dpc->cap_pos, status, source, reason, ext_reason;
 
 	pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &status);
 	pci_read_config_word(pdev, cap + PCI_EXP_DPC_SOURCE_ID, &source);
 
-	dev_info(dev, "DPC containment event, status:%#06x source:%#06x\n",
+	pci_info(pdev, "DPC containment event, status:%#06x source:%#06x\n",
 		 status, source);
 
 	reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN) >> 1;
 	ext_reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT) >> 5;
-	dev_warn(dev, "DPC %s detected\n",
+	pci_warn(pdev, "DPC %s detected\n",
 		 (reason == 0) ? "unmasked uncorrectable error" :
 		 (reason == 1) ? "ERR_NONFATAL" :
 		 (reason == 2) ? "ERR_FATAL" :
@@ -307,7 +304,7 @@ static int dpc_probe(struct pcie_device *dev)
 					   dpc_handler, IRQF_SHARED,
 					   "pcie-dpc", dpc);
 	if (status) {
-		dev_warn(device, "request IRQ%d failed: %d\n", dev->irq,
+		pci_warn(pdev, "request IRQ%d failed: %d\n", dev->irq,
 			 status);
 		return status;
 	}
@@ -319,7 +316,7 @@ static int dpc_probe(struct pcie_device *dev)
 	if (dpc->rp_extensions) {
 		dpc->rp_log_size = (cap & PCI_EXP_DPC_RP_PIO_LOG_SIZE) >> 8;
 		if (dpc->rp_log_size < 4 || dpc->rp_log_size > 9) {
-			dev_err(device, "RP PIO log size %u is invalid\n",
+			pci_err(pdev, "RP PIO log size %u is invalid\n",
 				dpc->rp_log_size);
 			dpc->rp_log_size = 0;
 		}
@@ -328,7 +325,7 @@ static int dpc_probe(struct pcie_device *dev)
 	ctl = (ctl & 0xfff4) | PCI_EXP_DPC_CTL_EN_FATAL | PCI_EXP_DPC_CTL_INT_EN;
 	pci_write_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_CTL, ctl);
 
-	dev_info(device, "DPC error containment capabilities: Int Msg #%d, RPExt%c PoisonedTLP%c SwTrigger%c RP PIO Log %d, DL_ActiveErr%c\n",
+	pci_info(pdev, "DPC error containment capabilities: Int Msg #%d, RPExt%c PoisonedTLP%c SwTrigger%c RP PIO Log %d, DL_ActiveErr%c\n",
 		cap & PCI_EXP_DPC_IRQ, FLAG(cap, PCI_EXP_DPC_CAP_RP_EXT),
 		FLAG(cap, PCI_EXP_DPC_CAP_POISONED_TLP),
 		FLAG(cap, PCI_EXP_DPC_CAP_SW_TRIGGER), dpc->rp_log_size,
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 1/4] PCI: Replace dev_*() printk wrappers with pci_*() printk wrappers

drivers/pci/pcie/aer.c static bool find_source_device(struct pci_dev *parent, · line 967

Quoted 8 lines · On Sat, Apr 27, 2019 at 02:13:01PM -0500, [email protected] wrote:

From: Frederick Lawler <[email protected]>

Replace remaining instances of dev_*() printk wrappers with pci_*() printk wrappers. No functional change intended.

drivers/pci/pcie/aer.c +1 -2
-		pci_printk(KERN_DEBUG, parent, "can't find device of ID%04x\n",
-			   e_info->id);
+		pci_dbg(parent, "can't find device of ID%04x\n", e_info->id);

These are not equivalent.

drivers/pci/pcie/aer.c static int aer_probe(struct pcie_device *dev) · line 1383

Quoted 2 lines
drivers/pci/pcie/aer.c +1 -1
-		dev_printk(KERN_DEBUG, device, "alloc AER rpc failed\n");
+		pci_dbg(pdev, "alloc AER rpc failed\n");

Ditto.

drivers/pci/pcie/aer.c static int aer_probe(struct pcie_device *dev) · line 1392

Quoted 3 lines
drivers/pci/pcie/aer.c +1 -2
-		dev_printk(KERN_DEBUG, device, "request AER IRQ %d failed\n",
-			   dev->irq);
+		pci_dbg(pdev, "request AER IRQ %d failed\n", dev->irq);

Ditto.

And so on.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw

Re: [PATCH 1/4] PCI: Replace dev_*() printk wrappers with pci_*() printk wrappers

Andy,

Andy Shevchenko wrote on 4/28/19 10:43 AM:

Quoted 17 lines · On Sat, Apr 27, 2019 at 02:13:01PM -0500, [email protected] wrote:

drivers/pci/pcie/aer.c static bool find_source_device(struct pci_dev *parent, · line 967

Quoted 8 lines

From: Frederick Lawler <[email protected]>

Replace remaining instances of dev_*() printk wrappers with pci_*() printk wrappers. No functional change intended.

drivers/pci/pcie/aer.c +1 -2
-		pci_printk(KERN_DEBUG, parent, "can't find device of ID%04x\n",
-			   e_info->id);
+		pci_dbg(parent, "can't find device of ID%04x\n", e_info->id);

These are not equivalent.

drivers/pci/pcie/aer.c static int aer_probe(struct pcie_device *dev) · line 1383

Quoted 2 lines
drivers/pci/pcie/aer.c +1 -1
-		dev_printk(KERN_DEBUG, device, "alloc AER rpc failed\n");
+		pci_dbg(pdev, "alloc AER rpc failed\n");

Ditto.

Quoted 8 lines

drivers/pci/pcie/aer.c static int aer_probe(struct pcie_device *dev) · line 1392

Quoted 3 lines
drivers/pci/pcie/aer.c +1 -2
-		dev_printk(KERN_DEBUG, device, "request AER IRQ %d failed\n",
-			   dev->irq);
+		pci_dbg(pdev, "request AER IRQ %d failed\n", dev->irq);

Ditto.

And so on.

Thanks for the review. Clearly this was an oversight on my part and I'll have that corrected. Thanks!

Frederick Lawler

#4 lore raw

Re: [PATCH 1/4] PCI: Replace dev_*() printk wrappers with pci_*() printk wrappers

In reply to [email protected]
Quoted 17 lines · On Sat, Apr 27, 2019 at 02:13:01PM -0500, [email protected] wrote:

From: Frederick Lawler <[email protected]>

Replace remaining instances of dev_*() printk wrappers with pci_*() printk wrappers. No functional change intended.

---
 drivers/pci/pcie/aer.c        | 13 ++++++-------
 drivers/pci/pcie/aer_inject.c |  4 ++--
 drivers/pci/pcie/dpc.c        | 27 ++++++++++++---------------
 3 files changed, 20 insertions(+), 24 deletions(-)
drivers/pci/pcie/aer.c +0 -0
index f8fc2114ad39..224d878a28b4 100644

drivers/pci/pcie/aer.c static bool find_source_device(struct pci_dev *parent, · line 967

Quoted 6 lines
drivers/pci/pcie/aer.c +1 -2
@@ -964,8 +964,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_dbg(parent, "can't find device of ID%04x\n", e_info->id);

I don't like dev_dbg() and pci_dbg() because the behavior depends on CONFIG_DYNAMIC_DEBUG, DEBUG, etc.

They may be fine for development, but for production, I want to be able to users for "a complete dmesg log". I don't want to have to ask them to "please rebuild your kernel with CONFIG_DYNAMIC_DEBUG=n and boot with 'dyndbg=xxx'"

For that reason I prefer the "pci_printk(KERN_DEBUG)" because that output always goes to the dmesg log.

But "pci_printk(KERN_DEBUG)" is definitely ugly. I think the way to fix that is to convert it to "pci_info()" instead.

drivers/pci/pcie/aer.c static int aer_probe(struct pcie_device *dev) · line 1383

Quoted 13 lines
drivers/pci/pcie/aer.c +2 -1
 		return false;
 	}
 	return true;
@@ -1377,10 +1376,11 @@ static int aer_probe(struct pcie_device *dev)
 	int status;
 	struct aer_rpc *rpc;
 	struct device *device = &dev->device;
+	struct pci_dev *pdev = dev->port;
 
 	rpc = devm_kzalloc(device, sizeof(struct aer_rpc), GFP_KERNEL);
 	if (!rpc) {
-		dev_printk(KERN_DEBUG, device, "alloc AER rpc failed\n");
+		pci_dbg(pdev, "alloc AER rpc failed\n");

This hunk converts from using the pcie_device to the pci_dev, so it belongs in a different patch.

drivers/pci/pcie/aer.c static int aer_probe(struct pcie_device *dev) · line 1393

Quoted 11 lines
drivers/pci/pcie/aer.c +1 -2
 		return -ENOMEM;
 	}
 	rpc->rpd = dev->port;
@@ -1389,13 +1389,12 @@ static int aer_probe(struct pcie_device *dev)
 	status = devm_request_threaded_irq(device, dev->irq, aer_irq, aer_isr,
 					   IRQF_SHARED, "aerdrv", dev);
 	if (status) {
-		dev_printk(KERN_DEBUG, device, "request AER IRQ %d failed\n",
-			   dev->irq);
+		pci_dbg(pdev, "request AER IRQ %d failed\n", dev->irq);
 		return status;

This one also.

drivers/pci/pcie/aer.c static int aer_probe(struct pcie_device *dev) · line 1397

Quoted 5 lines
drivers/pci/pcie/aer.c +1 -1
 	}
 
 	aer_enable_rootport(rpc);
-	dev_info(device, "AER enabled with IRQ %d\n", dev->irq);
+	pci_info(pdev, "AER enabled with IRQ %d\n", dev->irq);

And this, and many others below. *This* patch should only convert

- pci_printk(KERN_DEBUG, pdev, ...)
+ pci_info(pdev, ...)

and

- dev_printk(KERN_DEBUG, pcie_dev, ...)
+ dev_info(pcie_dev, ...)

Quoted 158 lines
drivers/pci/pcie/aer.c +1 -1
 	return 0;
 }
 
@@ -1419,7 +1418,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev)
 	pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, reg32);
 
 	rc = pci_bus_error_reset(dev);
-	pci_printk(KERN_DEBUG, dev, "Root Port link has been reset\n");
+	pci_dbg(dev, "Root Port link has been reset\n");
 
 	/* Clear Root Error Status */
 	pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, &reg32);
drivers/pci/pcie/aer_inject.c +2 -2
index 95d4759664b3..610b617ae600 100644
@@ -460,12 +460,12 @@ static int aer_inject(struct aer_error_inj *einj)
 	if (device) {
 		edev = to_pcie_device(device);
 		if (!get_service_data(edev)) {
-			dev_warn(&edev->device,
+			pci_warn(edev->port,
 				 "aer_inject: AER service is not initialized\n");
 			ret = -EPROTONOSUPPORT;
 			goto out_put;
 		}
-		dev_info(&edev->device,
+		pci_info(edev->port,
 			 "aer_inject: Injecting errors %08x/%08x into device %s\n",
 			 einj->cor_status, einj->uncor_status, pci_name(dev));
 		local_irq_disable();
drivers/pci/pcie/dpc.c +12 -15
index 7b77754a82de..72659286191b 100644
@@ -100,7 +100,6 @@ static int dpc_wait_rp_inactive(struct dpc_dev *dpc)
 {
 	unsigned long timeout = jiffies + HZ;
 	struct pci_dev *pdev = dpc->dev->port;
-	struct device *dev = &dpc->dev->device;
 	u16 cap = dpc->cap_pos, status;
 
 	pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &status);
@@ -110,7 +109,7 @@ static int dpc_wait_rp_inactive(struct dpc_dev *dpc)
 		pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &status);
 	}
 	if (status & PCI_EXP_DPC_RP_BUSY) {
-		dev_warn(dev, "DPC root port still busy\n");
+		pci_warn(pdev, "DPC root port still busy\n");
 		return -EBUSY;
 	}
 	return 0;
@@ -148,7 +147,6 @@ static pci_ers_result_t dpc_reset_link(struct pci_dev *pdev)
 
 static void dpc_process_rp_pio_error(struct dpc_dev *dpc)
 {
-	struct device *dev = &dpc->dev->device;
 	struct pci_dev *pdev = dpc->dev->port;
 	u16 cap = dpc->cap_pos, dpc_status, first_error;
 	u32 status, mask, sev, syserr, exc, dw0, dw1, dw2, dw3, log, prefix;
@@ -156,13 +154,13 @@ static void dpc_process_rp_pio_error(struct dpc_dev *dpc)
 
 	pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_STATUS, &status);
 	pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_MASK, &mask);
-	dev_err(dev, "rp_pio_status: %#010x, rp_pio_mask: %#010x\n",
+	pci_err(pdev, "rp_pio_status: %#010x, rp_pio_mask: %#010x\n",
 		status, mask);
 
 	pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_SEVERITY, &sev);
 	pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_SYSERROR, &syserr);
 	pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_EXCEPTION, &exc);
-	dev_err(dev, "RP PIO severity=%#010x, syserror=%#010x, exception=%#010x\n",
+	pci_err(pdev, "RP PIO severity=%#010x, syserror=%#010x, exception=%#010x\n",
 		sev, syserr, exc);
 
 	/* Get First Error Pointer */
@@ -171,7 +169,7 @@ static void dpc_process_rp_pio_error(struct dpc_dev *dpc)
 
 	for (i = 0; i < ARRAY_SIZE(rp_pio_error_string); i++) {
 		if ((status & ~mask) & (1 << i))
-			dev_err(dev, "[%2d] %s%s\n", i, rp_pio_error_string[i],
+			pci_err(pdev, "[%2d] %s%s\n", i, rp_pio_error_string[i],
 				first_error == i ? " (First)" : "");
 	}
 
@@ -185,18 +183,18 @@ static void dpc_process_rp_pio_error(struct dpc_dev *dpc)
 			      &dw2);
 	pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG + 12,
 			      &dw3);
-	dev_err(dev, "TLP Header: %#010x %#010x %#010x %#010x\n",
+	pci_err(pdev, "TLP Header: %#010x %#010x %#010x %#010x\n",
 		dw0, dw1, dw2, dw3);
 
 	if (dpc->rp_log_size < 5)
 		goto clear_status;
 	pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_IMPSPEC_LOG, &log);
-	dev_err(dev, "RP PIO ImpSpec Log %#010x\n", log);
+	pci_err(pdev, "RP PIO ImpSpec Log %#010x\n", log);
 
 	for (i = 0; i < dpc->rp_log_size - 5; i++) {
 		pci_read_config_dword(pdev,
 			cap + PCI_EXP_DPC_RP_PIO_TLPPREFIX_LOG, &prefix);
-		dev_err(dev, "TLP Prefix Header: dw%d, %#010x\n", i, prefix);
+		pci_err(pdev, "TLP Prefix Header: dw%d, %#010x\n", i, prefix);
 	}
  clear_status:
 	pci_write_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_STATUS, status);
@@ -229,18 +227,17 @@ static irqreturn_t dpc_handler(int irq, void *context)
 	struct aer_err_info info;
 	struct dpc_dev *dpc = context;
 	struct pci_dev *pdev = dpc->dev->port;
-	struct device *dev = &dpc->dev->device;
 	u16 cap = dpc->cap_pos, status, source, reason, ext_reason;
 
 	pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &status);
 	pci_read_config_word(pdev, cap + PCI_EXP_DPC_SOURCE_ID, &source);
 
-	dev_info(dev, "DPC containment event, status:%#06x source:%#06x\n",
+	pci_info(pdev, "DPC containment event, status:%#06x source:%#06x\n",
 		 status, source);
 
 	reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN) >> 1;
 	ext_reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT) >> 5;
-	dev_warn(dev, "DPC %s detected\n",
+	pci_warn(pdev, "DPC %s detected\n",
 		 (reason == 0) ? "unmasked uncorrectable error" :
 		 (reason == 1) ? "ERR_NONFATAL" :
 		 (reason == 2) ? "ERR_FATAL" :
@@ -307,7 +304,7 @@ static int dpc_probe(struct pcie_device *dev)
 					   dpc_handler, IRQF_SHARED,
 					   "pcie-dpc", dpc);
 	if (status) {
-		dev_warn(device, "request IRQ%d failed: %d\n", dev->irq,
+		pci_warn(pdev, "request IRQ%d failed: %d\n", dev->irq,
 			 status);
 		return status;
 	}
@@ -319,7 +316,7 @@ static int dpc_probe(struct pcie_device *dev)
 	if (dpc->rp_extensions) {
 		dpc->rp_log_size = (cap & PCI_EXP_DPC_RP_PIO_LOG_SIZE) >> 8;
 		if (dpc->rp_log_size < 4 || dpc->rp_log_size > 9) {
-			dev_err(device, "RP PIO log size %u is invalid\n",
+			pci_err(pdev, "RP PIO log size %u is invalid\n",
 				dpc->rp_log_size);
 			dpc->rp_log_size = 0;
 		}
@@ -328,7 +325,7 @@ static int dpc_probe(struct pcie_device *dev)
 	ctl = (ctl & 0xfff4) | PCI_EXP_DPC_CTL_EN_FATAL | PCI_EXP_DPC_CTL_INT_EN;
 	pci_write_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_CTL, ctl);
 
-	dev_info(device, "DPC error containment capabilities: Int Msg #%d, RPExt%c PoisonedTLP%c SwTrigger%c RP PIO Log %d, DL_ActiveErr%c\n",
+	pci_info(pdev, "DPC error containment capabilities: Int Msg #%d, RPExt%c PoisonedTLP%c SwTrigger%c RP PIO Log %d, DL_ActiveErr%c\n",
 		cap & PCI_EXP_DPC_IRQ, FLAG(cap, PCI_EXP_DPC_CAP_RP_EXT),
 		FLAG(cap, PCI_EXP_DPC_CAP_POISONED_TLP),
 		FLAG(cap, PCI_EXP_DPC_CAP_SW_TRIGGER), dpc->rp_log_size,
Signature · 1 line
2.17.1
#5 lore raw

Re: [PATCH 1/4] PCI: Replace dev_*() printk wrappers with pci_*() printk wrappers

Quoted 19 lines · Bjorn Helgaas
Quoted 12 lines · On Sat, Apr 27, 2019 at 02:13:01PM -0500, [email protected] wrote:

From: Frederick Lawler <[email protected]>

Replace remaining instances of dev_*() printk wrappers with pci_*() printk wrappers. No functional change intended.

---
 drivers/pci/pcie/aer.c        | 13 ++++++-------
 drivers/pci/pcie/aer_inject.c |  4 ++--
 drivers/pci/pcie/dpc.c        | 27 ++++++++++++---------------
 3 files changed, 20 insertions(+), 24 deletions(-)

drivers/pci/pcie/aer.c static int aer_probe(struct pcie_device *dev) · line 1397

Quoted 3 lines
drivers/pci/pcie/aer.c +1 -1
 	aer_enable_rootport(rpc);
-	dev_info(device, "AER enabled with IRQ %d\n", dev->irq);
+	pci_info(pdev, "AER enabled with IRQ %d\n", dev->irq);

And this, and many others below. *This* patch should only convert

Quoted 7 lines

- pci_printk(KERN_DEBUG, pdev, ...)
+ pci_info(pdev, ...)

and

- dev_printk(KERN_DEBUG, pcie_dev, ...)
+ dev_info(pcie_dev, ...)

Just to clarify, I do *want* both changes, just in separate patches. So we'd have

1) Convert KERN_DEBUG uses to pci_info() for pci_dev usage and to dev_info() for pcie_device usage. I think pciehp is probably an exception to this; this patch shouldn't touch ctrl_dbg().

2) Convert "dev_info(pcie_device)" to "pci_info(pci_dev)". It might be worth doing this in separate patches for each service. If we decide they're simple enough to combine, that's trivial for me to do. It's a little more hassle to split things up afterwards.

In pciehp, if you do this in the ctrl_*() definitions, it will make the patch much smaller.

3) In pciehp, ctrl_dbg() could probably be changed to use pci_dbg() so we'd use the standard kernel dynamic debug stuff instead of having the pciehp-specific module parameter.

Thanks a lot for working on all this. I think it will make the user experience significantly simpler.

Bjorn

#6 lore raw

Re: [PATCH 1/4] PCI: Replace dev_*() printk wrappers with pci_*() printk wrappers

Bjorn,

Bjorn Helgaas wrote on 4/28/19 7:52 PM:

Quoted 43 lines · Bjorn Helgaas
Quoted 19 lines · On Sat, Apr 27, 2019 at 02:13:01PM -0500, [email protected] wrote:
Quoted 13 lines

From: Frederick Lawler <[email protected]>

Replace remaining instances of dev_*() printk wrappers with pci_*() printk wrappers. No functional change intended.

---
  drivers/pci/pcie/aer.c        | 13 ++++++-------
  drivers/pci/pcie/aer_inject.c |  4 ++--
  drivers/pci/pcie/dpc.c        | 27 ++++++++++++---------------
  3 files changed, 20 insertions(+), 24 deletions(-)
  	aer_enable_rootport(rpc);

drivers/pci/pcie/aer.c static int aer_probe(struct pcie_device *dev) · line 1397

Quoted 2 lines
drivers/pci/pcie/aer.c +1 -1
-	dev_info(device, "AER enabled with IRQ %d\n", dev->irq);
+	pci_info(pdev, "AER enabled with IRQ %d\n", dev->irq);

And this, and many others below. *This* patch should only convert

Quoted 7 lines

- pci_printk(KERN_DEBUG, pdev, ...)
+ pci_info(pdev, ...)

and

- dev_printk(KERN_DEBUG, pcie_dev, ...)
+ dev_info(pcie_dev, ...)

Just to clarify, I do *want* both changes, just in separate patches. So we'd have

1) Convert KERN_DEBUG uses to pci_info() for pci_dev usage and to dev_info() for pcie_device usage. I think pciehp is probably an exception to this; this patch shouldn't touch ctrl_dbg().

2) Convert "dev_info(pcie_device)" to "pci_info(pci_dev)". It might be worth doing this in separate patches for each service. If we decide they're simple enough to combine, that's trivial for me to do. It's a little more hassle to split things up afterwards.

In pciehp, if you do this in the ctrl_*() definitions, it will make the patch much smaller.

Quoted 9 lines

3) In pciehp, ctrl_dbg() could probably be changed to use pci_dbg() so we'd use the standard kernel dynamic debug stuff instead of having the pciehp-specific module parameter.

Thanks a lot for working on all this. I think it will make the user experience significantly simpler.

Bjorn

Will do, thanks!

Frederick Lawler

#7 lore raw

PATCH 2/4 PCI: pciehp: Replace ctrl_*() with pci_*()

In reply to [email protected]

From: Frederick Lawler <[email protected]>

Hotplug useses custom ctrl_*() dev_*() printk wrappers for logging messages. To make hotplug conform to pci logging, replace uses of these wrappers with pci_*() printk wrappers. In addition, replace any printk() calls with pr_*() wrappers.

---
 drivers/pci/hotplug/pciehp_core.c |  22 +++--
 drivers/pci/hotplug/pciehp_ctrl.c |  86 +++++++++--------
 drivers/pci/hotplug/pciehp_hpc.c  | 149 ++++++++++++++++--------------
 drivers/pci/hotplug/pciehp_pci.c  |  10 +-
 4 files changed, 145 insertions(+), 122 deletions(-)
drivers/pci/hotplug/pciehp_core.c +12 -10
index fc5366b50e95..430a47556813 100644
@@ -51,6 +51,7 @@ static int get_adapter_status(struct hotplug_slot *slot, u8 *value);
 
 static int init_slot(struct controller *ctrl)
 {
+	struct pci_dev *pdev = ctrl->pcie->port;
 	struct hotplug_slot_ops *ops;
 	char name[SLOT_NAME_SIZE];
 	int retval;
@@ -82,7 +83,7 @@ static int init_slot(struct controller *ctrl)
 	retval = pci_hp_initialize(&ctrl->hotplug_slot,
 				   ctrl->pcie->port->subordinate, 0, name);
 	if (retval) {
-		ctrl_err(ctrl, "pci_hp_initialize failed: error %d\n", retval);
+		pci_err(pdev, "pci_hp_initialize failed: error %d\n", retval);
 		kfree(ops);
 	}
 	return retval;
@@ -175,6 +176,7 @@ static int pciehp_probe(struct pcie_device *dev)
 {
 	int rc;
 	struct controller *ctrl;
+	struct pci_dev *pdev;
 
 	/* If this is not a "hotplug" service, we have no business here. */
 	if (dev->service != PCIE_PORT_SERVICE_HP)
@@ -182,39 +184,39 @@ static int pciehp_probe(struct pcie_device *dev)
 
 	if (!dev->port->subordinate) {
 		/* Can happen if we run out of bus numbers during probe */
-		dev_err(&dev->device,
-			"Hotplug bridge without secondary bus, ignoring\n");
+		pci_err(dev->port, "Hotplug bridge without secondary bus, ignoring\n");
 		return -ENODEV;
 	}
 
 	ctrl = pcie_init(dev);
 	if (!ctrl) {
-		dev_err(&dev->device, "Controller initialization failed\n");
+		pci_err(dev->port, "Controller initialization failed\n");
 		return -ENODEV;
 	}
 	set_service_data(dev, ctrl);
+	pdev = ctrl->pcie->port;
 
 	/* Setup the slot information structures */
 	rc = init_slot(ctrl);
 	if (rc) {
 		if (rc == -EBUSY)
-			ctrl_warn(ctrl, "Slot already registered by another hotplug driver\n");
+			pci_warn(pdev, "Slot already registered by another hotplug driver\n");
 		else
-			ctrl_err(ctrl, "Slot initialization failed (%d)\n", rc);
+			pci_err(pdev, "Slot initialization failed (%d)\n", rc);
 		goto err_out_release_ctlr;
 	}
 
 	/* Enable events after we have setup the data structures */
 	rc = pcie_init_notification(ctrl);
 	if (rc) {
-		ctrl_err(ctrl, "Notification initialization failed (%d)\n", rc);
+		pci_err(pdev, "Notification initialization failed (%d)\n", rc);
 		goto err_out_free_ctrl_slot;
 	}
 
 	/* Publish to user space */
 	rc = pci_hp_add(&ctrl->hotplug_slot);
 	if (rc) {
-		ctrl_err(ctrl, "Publication to user space failed (%d)\n", rc);
+		pci_err(pdev, "Publication to user space failed (%d)\n", rc);
 		goto err_out_shutdown_notification;
 	}
 
@@ -328,9 +330,9 @@ int __init pcie_hp_init(void)
 	int retval = 0;
 
 	retval = pcie_port_service_register(&hpdriver_portdrv);
-	dbg("pcie_port_service_register = %d\n", retval);
+	pr_debug("pcie_port_service_register = %d\n", retval);
 	if (retval)
-		dbg("Failure to register service\n");
+		pr_debug("Failure to register service\n");
 
 	return retval;
 }
drivers/pci/hotplug/pciehp_ctrl.c +47 -39

221 lines not on this page · raw message

drivers/pci/hotplug/pciehp_hpc.c +81 -68

355 lines not on this page · raw message

drivers/pci/hotplug/pciehp_pci.c +5 -5
index b9c1396db6fe..55967ce567f6 100644
@@ -42,8 +42,8 @@ int pciehp_configure_device(struct controller *ctrl)
 		 * The device is already there. Either configured by the
 		 * boot firmware or a previous hotplug event.
 		 */
-		ctrl_dbg(ctrl, "Device %s already exists at %04x:%02x:00, skipping hot-add\n",
-			 pci_name(dev), pci_domain_nr(parent), parent->number);
+		pci_dbg(bridge, "Device %s already exists at %04x:%02x:00, skipping hot-add\n",
+			pci_name(dev), pci_domain_nr(parent), parent->number);
 		pci_dev_put(dev);
 		ret = -EEXIST;
 		goto out;
@@ -51,7 +51,7 @@ int pciehp_configure_device(struct controller *ctrl)
 
 	num = pci_scan_slot(parent, PCI_DEVFN(0, 0));
 	if (num == 0) {
-		ctrl_err(ctrl, "No new device found\n");
+		pci_err(bridge, "No new device found\n");
 		ret = -ENODEV;
 		goto out;
 	}
@@ -85,8 +85,8 @@ void pciehp_unconfigure_device(struct controller *ctrl, bool presence)
 	struct pci_bus *parent = ctrl->pcie->port->subordinate;
 	u16 command;
 
-	ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:00\n",
-		 __func__, pci_domain_nr(parent), parent->number);
+	pci_dbg(ctrl->pcie->port, "%s: domain:bus:dev = %04x:%02x:00\n",
+		__func__, pci_domain_nr(parent), parent->number);
 
 	if (!presence)
 		pci_walk_bus(parent, pci_dev_set_disconnected, NULL);
Signature · 1 line
2.17.1
#8 lore raw

Re: [PATCH 2/4] PCI: pciehp: Replace ctrl_*() with pci_*()

Quoted 4 lines · On Sat, Apr 27, 2019 at 02:13:02PM -0500, [email protected] wrote:

Hotplug useses custom ctrl_*() dev_*() printk wrappers for logging messages. To make hotplug conform to pci logging, replace uses of these wrappers with pci_*() printk wrappers. In addition, replace any printk() calls with pr_*() wrappers.

A lot of pciehp's messages are preceded by "Slot(%s): ", where %s is replaced by the Physical Slot Number in the Slot Capabilities register (which is cached in struct controller) plus an optional suffix if the same PSN is used by multiple slots. For some reason (probably a historic artefact), this prefix is included only in *some* of the messages.

I think it would be useful to make the messages consistent by *always* including the "Slot(%s): " prefix. However the prefix is unknown until pci_hp_initialize() has been called. I'd solve this by keeping the ctrl_*() wrappers and amending them to print the "Slot(%s): " prefix, then making sure that ctrl_*() is not called before pci_hp_initialize(). (pci_*() has to be used instead).

drivers/pci/hotplug/pciehp_core.c static int pciehp_probe(struct pcie_device *dev) · line 187

Quoted 7 lines
drivers/pci/hotplug/pciehp_core.c +1 -2
@@ -182,39 +184,39 @@ static int pciehp_probe(struct pcie_device *dev)
 
 	if (!dev->port->subordinate) {
 		/* Can happen if we run out of bus numbers during probe */
-		dev_err(&dev->device,
-			"Hotplug bridge without secondary bus, ignoring\n");
+		pci_err(dev->port, "Hotplug bridge without secondary bus, ignoring\n");

Hm, the string was likely deliberately put on a new line to avoid exceeding 80 chars, so I'd keep it that way.

Thanks,

Lukas

#9 lore raw

Re: [PATCH 2/4] PCI: pciehp: Replace ctrl_*() with pci_*()

Quoted 13 lines · Lukas Wunner
Quoted 4 lines · On Sat, Apr 27, 2019 at 02:13:02PM -0500, [email protected] wrote:

Hotplug useses custom ctrl_*() dev_*() printk wrappers for logging messages. To make hotplug conform to pci logging, replace uses of these wrappers with pci_*() printk wrappers. In addition, replace any printk() calls with pr_*() wrappers.

A lot of pciehp's messages are preceded by "Slot(%s): ", where %s is replaced by the Physical Slot Number in the Slot Capabilities register (which is cached in struct controller) plus an optional suffix if the same PSN is used by multiple slots. For some reason (probably a historic artefact), this prefix is included only in *some* of the messages.

Quoted 6 lines

I think it would be useful to make the messages consistent by *always* including the "Slot(%s): " prefix. However the prefix is unknown until pci_hp_initialize() has been called. I'd solve this by keeping the ctrl_*() wrappers and amending them to print the "Slot(%s): " prefix, then making sure that ctrl_*() is not called before pci_hp_initialize(). (pci_*() has to be used instead).

I was hoping to get rid of the ctrl_*() wrappers completely, but the "Slot(%s)" prefix is actually a pretty good reason to keep them.

Moving the prefix from the call site to the ctrl_*() wrappers should be a separate patch that doesn't change the output at all (except maybe adding the prefix to messages that don't currently include it).

So you probably need three steps (each in a separate patch):

1) Convert ctrl_*() to use pci_dev instead of pcie_device, something like this:

+ #define pr_fmt(fmt) "pciehp: " fmt
+ #define dev_fmt pr_fmt

#define ctrl_info(ctrl, format, arg...) \
- dev_info(&ctrl->pcie->device, format, ## arg)
+ pci_info(&ctrl->pcie->port, format, ## arg)

2) Convert any output before pci_hp_initialize() from ctrl_*() to

     pci_*().

3) Centralize the "Slot(%s): " prefix, something like this:

#define ctrl_info(ctrl, format, arg...) \
- pci_info(&ctrl->pcie->port, format, ## arg)
+ pci_info(&ctrl->pcie->port, "Slot(%s): " format, slot_name(ctrl), ## arg)

- ctrl_info(ctrl, "Slot(%s): ...", slot_name(ctrl));
+ ctrl_info(ctrl, "...");

#10 lore raw

PATCH 3/4 PCI: pciehp: Remove unused macro definitions

In reply to [email protected]

From: Frederick Lawler <[email protected]>

Now that all uses for the ctrl_*() printk wrappers are removed from files and replaces with pci_*() or pr_*() printk wrappers, remove the unused macro definitions. In addition to that, remove the MY_NAME macro.

---
 drivers/pci/hotplug/pciehp.h     | 27 ---------------------------
 drivers/pci/hotplug/pciehp_hpc.c |  2 +-
 2 files changed, 1 insertion(+), 28 deletions(-)
drivers/pci/hotplug/pciehp.h +0 -27
index 506e1d923a1f..7d3a32a1504a 100644
@@ -25,37 +25,10 @@
 
 #include "../pcie/portdrv.h"
 
-#define MY_NAME	"pciehp"
-
 extern bool pciehp_poll_mode;
 extern int pciehp_poll_time;
 extern bool pciehp_debug;
 
-#define dbg(format, arg...)						\
-do {									\
-	if (pciehp_debug)						\
-		printk(KERN_DEBUG "%s: " format, MY_NAME, ## arg);	\
-} while (0)
-#define err(format, arg...)						\
-	printk(KERN_ERR "%s: " format, MY_NAME, ## arg)
-#define info(format, arg...)						\
-	printk(KERN_INFO "%s: " format, MY_NAME, ## arg)
-#define warn(format, arg...)						\
-	printk(KERN_WARNING "%s: " format, MY_NAME, ## arg)
-
-#define ctrl_dbg(ctrl, format, arg...)					\
-	do {								\
-		if (pciehp_debug)					\
-			dev_printk(KERN_DEBUG, &ctrl->pcie->device,	\
-					format, ## arg);		\
-	} while (0)
-#define ctrl_err(ctrl, format, arg...)					\
-	dev_err(&ctrl->pcie->device, format, ## arg)
-#define ctrl_info(ctrl, format, arg...)					\
-	dev_info(&ctrl->pcie->device, format, ## arg)
-#define ctrl_warn(ctrl, format, arg...)					\
-	dev_warn(&ctrl->pcie->device, format, ## arg)
-
 #define SLOT_NAME_SIZE 10
 
 /**
drivers/pci/hotplug/pciehp_hpc.c +1 -1
index 5e5631fd0171..28a132a0d9db 100644
@@ -47,7 +47,7 @@ static inline int pciehp_request_irq(struct controller *ctrl)
 
 	/* Installs the interrupt handler */
 	retval = request_threaded_irq(irq, pciehp_isr, pciehp_ist,
-				      IRQF_SHARED, MY_NAME, ctrl);
+				      IRQF_SHARED, "pciehp", ctrl);
 	if (retval)
 		pci_err(pdev, "Cannot get irq %d for the hotplug controller\n",
 			irq);
Signature · 1 line
2.17.1
#11 lore raw

Re: [PATCH 3/4] PCI: pciehp: Remove unused macro definitions

Quoted 5 lines · On Sat, Apr 27, 2019 at 02:13:03PM -0500, [email protected] wrote:

Now that all uses for the ctrl_*() printk wrappers are removed from files and replaces with pci_*() or pr_*() printk wrappers, remove the unused macro definitions. In addition to that, remove the MY_NAME macro.

extern bool pciehp_debug;

How it's used after all?

drivers/pci/hotplug/pciehp.h line 51

Quoted 12 lines
drivers/pci/hotplug/pciehp.h +0 -11
-#define dbg(format, arg...)						\
-do {									\
-	if (pciehp_debug)						\
-		printk(KERN_DEBUG "%s: " format, MY_NAME, ## arg);	\
-} while (0)
 
-#define ctrl_dbg(ctrl, format, arg...)					\
-	do {								\
-		if (pciehp_debug)					\
-			dev_printk(KERN_DEBUG, &ctrl->pcie->device,	\
-					format, ## arg);		\
-	} while (0)

Besides ruining the pciehp_debug support this will make unequivalent behaviour.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#12 lore raw

Re: [PATCH 3/4] PCI: pciehp: Remove unused macro definitions

Quoted 15 lines · Andy Shevchenko
Quoted 5 lines · On Sat, Apr 27, 2019 at 02:13:03PM -0500, [email protected] wrote:

Now that all uses for the ctrl_*() printk wrappers are removed from files and replaces with pci_*() or pr_*() printk wrappers, remove the unused macro definitions. In addition to that, remove the MY_NAME macro.

extern bool pciehp_debug;

How it's used after all?

Quoted 5 lines
drivers/pci/hotplug/pciehp.h +0 -5
-#define dbg(format, arg...)						\
-do {									\
-	if (pciehp_debug)						\
-		printk(KERN_DEBUG "%s: " format, MY_NAME, ## arg);	\
-} while (0)
Quoted 8 lines

drivers/pci/hotplug/pciehp.h line 51

Quoted 6 lines
drivers/pci/hotplug/pciehp.h +0 -6
-#define ctrl_dbg(ctrl, format, arg...)					\
-	do {								\
-		if (pciehp_debug)					\
-			dev_printk(KERN_DEBUG, &ctrl->pcie->device,	\
-					format, ## arg);		\
-	} while (0)

Besides ruining the pciehp_debug support this will make unequivalent behaviour.

I'm not super attached to pciehp_debug. But perhaps pciehp is one place where it would make sense to use pci_dbg().

There are a lot of uses of ctrl_dbg() and some of them look like they're too low-level to just convert to pci_info(), e.g., info about every command we write to the controller. We probably don't need all that info all the time.

But if we want to keep it, maybe we could convert it to use pci_dbg() and the dynamic debug stuff. I'm pretty sure the dyndbg syntax is complicated enough to enable pciehp logging specifically. Then we could use that instead of the pciehp-specific module parameter.

Bjorn

#13 lore raw

PATCH 4/4 PCI/portdrv: Add dev_fmt() to port drivers

In reply to [email protected]

From: Frederick Lawler <[email protected]>

Add dev_fmt() to port drivers.

---
 drivers/pci/hotplug/pciehp_core.c  | 3 +++
 drivers/pci/hotplug/pciehp_ctrl.c  | 2 ++
 drivers/pci/hotplug/pciehp_hpc.c   | 3 +++
 drivers/pci/hotplug/pciehp_pci.c   | 2 ++
 drivers/pci/pcie/aer.c             | 3 +++
 drivers/pci/pcie/aer_inject.c      | 2 ++
 drivers/pci/pcie/bw_notification.c | 2 ++
 drivers/pci/pcie/dpc.c             | 2 ++
 drivers/pci/pcie/pme.c             | 2 ++
 9 files changed, 21 insertions(+)
drivers/pci/hotplug/pciehp_core.c +3 -0
index 430a47556813..b07d713fd4bd 100644
@@ -17,6 +17,9 @@
  *   Dely Sy <[email protected]>"
  */
 
+#define pr_fmt(fmt) "pciehp: " fmt
+#define dev_fmt(fmt) pr_fmt(fmt)
+
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
drivers/pci/hotplug/pciehp_ctrl.c +2 -0
index 345c02b1e8d7..969a9c72f65d 100644
@@ -13,6 +13,8 @@
  *
  */
 
+#define dev_fmt(fmt) "pciehp: " fmt
+
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/pm_runtime.h>
drivers/pci/hotplug/pciehp_hpc.c +3 -0
index 28a132a0d9db..f2a3da105f5b 100644
@@ -12,6 +12,9 @@
  * Send feedback to <[email protected]>,<[email protected]>
  */
 
+#define pr_fmt(fmt) "pciehp: " fmt
+#define dev_fmt(fmt) pr_fmt(fmt)
+
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/jiffies.h>
drivers/pci/hotplug/pciehp_pci.c +2 -0
index 55967ce567f6..04ccd535aca7 100644
@@ -13,6 +13,8 @@
  *
  */
 
+#define dev_fmt(fmt) "pciehp: " fmt
+
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/pci.h>
drivers/pci/pcie/aer.c +3 -0
index 224d878a28b4..6fd67285423d 100644
@@ -12,6 +12,9 @@
  *    Andrew Patterson <[email protected]>
  */
 
+#define pr_fmt(fmt) "AER: " fmt
+#define dev_fmt(fmt) pr_fmt(fmt)
+
 #include <linux/cper.h>
 #include <linux/pci.h>
 #include <linux/pci-acpi.h>
drivers/pci/pcie/aer_inject.c +2 -0
index 610b617ae600..d4f6d49acd0c 100644
@@ -12,6 +12,8 @@
  *     Huang Ying <[email protected]>
  */
 
+#define dev_fmt(fmt) "AER: " fmt
+
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/irq.h>
drivers/pci/pcie/bw_notification.c +2 -0
index d2eae3b7cc0f..a4bb90562cd5 100644
@@ -14,6 +14,8 @@
  * and warns when links become degraded in operation.
  */
 
+#define dev_fmt(fmt) "BWN: " fmt
+
 #include "../pci.h"
 #include "portdrv.h"
 
drivers/pci/pcie/dpc.c +2 -0
index 72659286191b..b3c10cdc508a 100644
@@ -6,6 +6,8 @@
  * Copyright (C) 2016 Intel Corp.
  */
 
+#define dev_fmt(fmt) "DPC: " fmt
+
 #include <linux/aer.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
drivers/pci/pcie/pme.c +2 -0
index 54d593d10396..d6698423a6d6 100644
@@ -7,6 +7,8 @@
  * Copyright (C) 2009 Rafael J. Wysocki <[email protected]>, Novell Inc.
  */
 
+#define dev_fmt(fmt) "PME: " fmt
+
 #include <linux/pci.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
Signature · 1 line
2.17.1
#14 lore raw

Re: [PATCH 4/4] PCI/portdrv: Add dev_fmt() to port drivers

Quoted 22 lines · On Sat, Apr 27, 2019 at 02:13:04PM -0500, [email protected] wrote:

From: Frederick Lawler <[email protected]>

Add dev_fmt() to port drivers.

---
 drivers/pci/hotplug/pciehp_core.c  | 3 +++
 drivers/pci/hotplug/pciehp_ctrl.c  | 2 ++
 drivers/pci/hotplug/pciehp_hpc.c   | 3 +++
 drivers/pci/hotplug/pciehp_pci.c   | 2 ++
 drivers/pci/pcie/aer.c             | 3 +++
 drivers/pci/pcie/aer_inject.c      | 2 ++
 drivers/pci/pcie/bw_notification.c | 2 ++
 drivers/pci/pcie/dpc.c             | 2 ++
 drivers/pci/pcie/pme.c             | 2 ++
 9 files changed, 21 insertions(+)
drivers/pci/hotplug/pciehp_core.c +0 -0
index 430a47556813..b07d713fd4bd 100644

drivers/pci/hotplug/pciehp_core.c line 21

Quoted 5 lines
drivers/pci/hotplug/pciehp_core.c +2 -0
@@ -17,6 +17,9 @@
  *   Dely Sy <[email protected]>"
  */
 
+#define pr_fmt(fmt) "pciehp: " fmt
+#define dev_fmt(fmt) pr_fmt(fmt)

This should be in the same patch that converts from using the pcie_device to the pci_dev. That way the "pciehp" that came from the pcie_device is atomically replaced with the "pciehp" from pr_fmt()/dev_fmt().

If you do it in separate patches, there's an intermediate stage where there's no prefix at all, and we want to avoid that.

BTW, in most cases you can simply do this, which is slightly simpler:

  #define dev_fmt pr_fmt
Quoted 112 lines
drivers/pci/hotplug/pciehp_core.c +0 -0
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
drivers/pci/hotplug/pciehp_ctrl.c +2 -0
index 345c02b1e8d7..969a9c72f65d 100644
@@ -13,6 +13,8 @@
  *
  */
 
+#define dev_fmt(fmt) "pciehp: " fmt
+
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/pm_runtime.h>
drivers/pci/hotplug/pciehp_hpc.c +3 -0
index 28a132a0d9db..f2a3da105f5b 100644
@@ -12,6 +12,9 @@
  * Send feedback to <[email protected]>,<[email protected]>
  */
 
+#define pr_fmt(fmt) "pciehp: " fmt
+#define dev_fmt(fmt) pr_fmt(fmt)
+
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/jiffies.h>
drivers/pci/hotplug/pciehp_pci.c +2 -0
index 55967ce567f6..04ccd535aca7 100644
@@ -13,6 +13,8 @@
  *
  */
 
+#define dev_fmt(fmt) "pciehp: " fmt
+
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/pci.h>
drivers/pci/pcie/aer.c +3 -0
index 224d878a28b4..6fd67285423d 100644
@@ -12,6 +12,9 @@
  *    Andrew Patterson <[email protected]>
  */
 
+#define pr_fmt(fmt) "AER: " fmt
+#define dev_fmt(fmt) pr_fmt(fmt)
+
 #include <linux/cper.h>
 #include <linux/pci.h>
 #include <linux/pci-acpi.h>
drivers/pci/pcie/aer_inject.c +2 -0
index 610b617ae600..d4f6d49acd0c 100644
@@ -12,6 +12,8 @@
  *     Huang Ying <[email protected]>
  */
 
+#define dev_fmt(fmt) "AER: " fmt
+
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/irq.h>
drivers/pci/pcie/bw_notification.c +2 -0
index d2eae3b7cc0f..a4bb90562cd5 100644
@@ -14,6 +14,8 @@
  * and warns when links become degraded in operation.
  */
 
+#define dev_fmt(fmt) "BWN: " fmt
+
 #include "../pci.h"
 #include "portdrv.h"
 
drivers/pci/pcie/dpc.c +2 -0
index 72659286191b..b3c10cdc508a 100644
@@ -6,6 +6,8 @@
  * Copyright (C) 2016 Intel Corp.
  */
 
+#define dev_fmt(fmt) "DPC: " fmt
+
 #include <linux/aer.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
drivers/pci/pcie/pme.c +2 -0
index 54d593d10396..d6698423a6d6 100644
@@ -7,6 +7,8 @@
  * Copyright (C) 2009 Rafael J. Wysocki <[email protected]>, Novell Inc.
  */
 
+#define dev_fmt(fmt) "PME: " fmt
+
 #include <linux/pci.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
Signature · 1 line
2.17.1