Skip to content

Commit 1ff8f36

Browse files
Sam Bobroffmpe
authored andcommitted
powerpc/eeh: Convert log messages to eeh_edev_* macros
Convert existing messages, where appropriate, to use the eeh_edev_* logging macros. The only effect should be minor adjustments to the log messages, apart from: - A new message in pseries_eeh_probe() "Probing device" to match the powernv case. - The "Probing device" message in pnv_eeh_probe() is now generated slightly later, which will mean that it is no longer emitted for devices that aren't probed due to the initial checks. Signed-off-by: Sam Bobroff <sbobroff@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/ce505a0a7a4a5b0367f0f40f8b26e7c0a9cf4cb7.1565930772.git.sbobroff@linux.ibm.com
1 parent b093f2c commit 1ff8f36

7 files changed

Lines changed: 39 additions & 89 deletions

File tree

‎arch/powerpc/include/asm/ppc-pci.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ void eeh_pe_dev_mode_mark(struct eeh_pe *pe, int mode);
6262
void eeh_sysfs_add_device(struct pci_dev *pdev);
6363
void eeh_sysfs_remove_device(struct pci_dev *pdev);
6464

65-
static inline const char *eeh_pci_name(struct pci_dev *pdev)
66-
{
67-
return pdev ? pci_name(pdev) : "<null>";
68-
}
69-
7065
static inline const char *eeh_driver_name(struct pci_dev *pdev)
7166
{
7267
return (pdev && pdev->driver) ? pdev->driver->name : "<null>";

‎arch/powerpc/kernel/eeh.c‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,7 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
470470
/* Access to IO BARs might get this far and still not want checking. */
471471
if (!pe) {
472472
eeh_stats.ignored_check++;
473-
pr_debug("EEH: Ignored check for %s\n",
474-
eeh_pci_name(dev));
473+
eeh_edev_dbg(edev, "Ignored check\n");
475474
return 0;
476475
}
477476

@@ -511,12 +510,11 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
511510
if (dn)
512511
location = of_get_property(dn, "ibm,loc-code",
513512
NULL);
514-
printk(KERN_ERR "EEH: %d reads ignored for recovering device at "
515-
"location=%s driver=%s pci addr=%s\n",
513+
eeh_edev_err(edev, "%d reads ignored for recovering device at location=%s driver=%s\n",
516514
pe->check_count,
517515
location ? location : "unknown",
518-
eeh_driver_name(dev), eeh_pci_name(dev));
519-
printk(KERN_ERR "EEH: Might be infinite loop in %s driver\n",
516+
eeh_driver_name(dev));
517+
eeh_edev_err(edev, "Might be infinite loop in %s driver\n",
520518
eeh_driver_name(dev));
521519
dump_stack();
522520
}
@@ -1188,12 +1186,11 @@ void eeh_add_device_late(struct pci_dev *dev)
11881186
if (!dev)
11891187
return;
11901188

1191-
pr_debug("EEH: Adding device %s\n", pci_name(dev));
1192-
11931189
pdn = pci_get_pdn_by_devfn(dev->bus, dev->devfn);
11941190
edev = pdn_to_eeh_dev(pdn);
1191+
eeh_edev_dbg(edev, "Adding device\n");
11951192
if (edev->pdev == dev) {
1196-
pr_debug("EEH: Device %s already referenced!\n", pci_name(dev));
1193+
eeh_edev_dbg(edev, "Device already referenced!\n");
11971194
return;
11981195
}
11991196

@@ -1296,10 +1293,10 @@ void eeh_remove_device(struct pci_dev *dev)
12961293
edev = pci_dev_to_eeh_dev(dev);
12971294

12981295
/* Unregister the device with the EEH/PCI address search system */
1299-
pr_debug("EEH: Removing device %s\n", pci_name(dev));
1296+
dev_dbg(&dev->dev, "EEH: Removing device\n");
13001297

13011298
if (!edev || !edev->pdev || !edev->pe) {
1302-
pr_debug("EEH: Not referenced !\n");
1299+
dev_dbg(&dev->dev, "EEH: Device not referenced!\n");
13031300
return;
13041301
}
13051302

‎arch/powerpc/kernel/eeh_cache.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ eeh_addr_cache_insert(struct pci_dev *dev, resource_size_t alo,
148148
piar->pcidev = dev;
149149
piar->flags = flags;
150150

151-
pr_debug("PIAR: insert range=[%pap:%pap] dev=%s\n",
152-
&alo, &ahi, pci_name(dev));
151+
eeh_edev_dbg(piar->edev, "PIAR: insert range=[%pap:%pap]\n",
152+
&alo, &ahi);
153153

154154
rb_link_node(&piar->rb_node, parent, p);
155155
rb_insert_color(&piar->rb_node, &pci_io_addr_cache_root.rb_root);
@@ -229,8 +229,8 @@ static inline void __eeh_addr_cache_rmv_dev(struct pci_dev *dev)
229229
piar = rb_entry(n, struct pci_io_addr_range, rb_node);
230230

231231
if (piar->pcidev == dev) {
232-
pr_debug("PIAR: remove range=[%pap:%pap] dev=%s\n",
233-
&piar->addr_lo, &piar->addr_hi, pci_name(dev));
232+
eeh_edev_dbg(piar->edev, "PIAR: remove range=[%pap:%pap]\n",
233+
&piar->addr_lo, &piar->addr_hi);
234234
rb_erase(n, &pci_io_addr_cache_root.rb_root);
235235
kfree(piar);
236236
goto restart;

‎arch/powerpc/kernel/eeh_driver.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -456,12 +456,9 @@ static void *eeh_add_virt_device(struct eeh_dev *edev)
456456
{
457457
struct pci_driver *driver;
458458
struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
459-
struct pci_dn *pdn = eeh_dev_to_pdn(edev);
460459

461460
if (!(edev->physfn)) {
462-
pr_warn("%s: EEH dev %04x:%02x:%02x.%01x not for VF\n",
463-
__func__, pdn->phb->global_number, pdn->busno,
464-
PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn));
461+
eeh_edev_warn(edev, "Not for VF\n");
465462
return NULL;
466463
}
467464

@@ -475,7 +472,7 @@ static void *eeh_add_virt_device(struct eeh_dev *edev)
475472
}
476473

477474
#ifdef CONFIG_PCI_IOV
478-
pci_iov_add_virtfn(edev->physfn, pdn->vf_index);
475+
pci_iov_add_virtfn(edev->physfn, eeh_dev_to_pdn(edev)->vf_index);
479476
#endif
480477
return NULL;
481478
}

‎arch/powerpc/kernel/eeh_pe.c‎

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,7 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
379379

380380
/* Check if the PE number is valid */
381381
if (!eeh_has_flag(EEH_VALID_PE_ZERO) && !edev->pe_config_addr) {
382-
pr_err("%s: Invalid PE#0 for edev 0x%x on PHB#%x\n",
383-
__func__, config_addr, pdn->phb->global_number);
382+
eeh_edev_err(edev, "PE#0 is invalid for this PHB!\n");
384383
return -EINVAL;
385384
}
386385

@@ -398,12 +397,7 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
398397

399398
/* Put the edev to PE */
400399
list_add_tail(&edev->entry, &pe->edevs);
401-
pr_debug("EEH: Add %04x:%02x:%02x.%01x to Bus PE#%x\n",
402-
pdn->phb->global_number,
403-
pdn->busno,
404-
PCI_SLOT(pdn->devfn),
405-
PCI_FUNC(pdn->devfn),
406-
pe->addr);
400+
eeh_edev_dbg(edev, "Added to bus PE\n");
407401
return 0;
408402
} else if (pe && (pe->type & EEH_PE_INVALID)) {
409403
list_add_tail(&edev->entry, &pe->edevs);
@@ -420,13 +414,8 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
420414
parent = parent->parent;
421415
}
422416

423-
pr_debug("EEH: Add %04x:%02x:%02x.%01x to Device "
424-
"PE#%x, Parent PE#%x\n",
425-
pdn->phb->global_number,
426-
pdn->busno,
427-
PCI_SLOT(pdn->devfn),
428-
PCI_FUNC(pdn->devfn),
429-
pe->addr, pe->parent->addr);
417+
eeh_edev_dbg(edev, "Added to device PE (parent: PE#%x)\n",
418+
pe->parent->addr);
430419
return 0;
431420
}
432421

@@ -468,13 +457,8 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
468457
list_add_tail(&pe->child, &parent->child_list);
469458
list_add_tail(&edev->entry, &pe->edevs);
470459
edev->pe = pe;
471-
pr_debug("EEH: Add %04x:%02x:%02x.%01x to "
472-
"Device PE#%x, Parent PE#%x\n",
473-
pdn->phb->global_number,
474-
pdn->busno,
475-
PCI_SLOT(pdn->devfn),
476-
PCI_FUNC(pdn->devfn),
477-
pe->addr, pe->parent->addr);
460+
eeh_edev_dbg(edev, "Added to device PE (parent: PE#%x)\n",
461+
pe->parent->addr);
478462

479463
return 0;
480464
}
@@ -492,15 +476,10 @@ int eeh_rmv_from_parent_pe(struct eeh_dev *edev)
492476
{
493477
struct eeh_pe *pe, *parent, *child;
494478
int cnt;
495-
struct pci_dn *pdn = eeh_dev_to_pdn(edev);
496479

497480
pe = eeh_dev_to_pe(edev);
498481
if (!pe) {
499-
pr_debug("%s: No PE found for device %04x:%02x:%02x.%01x\n",
500-
__func__, pdn->phb->global_number,
501-
pdn->busno,
502-
PCI_SLOT(pdn->devfn),
503-
PCI_FUNC(pdn->devfn));
482+
eeh_edev_dbg(edev, "No PE found for device.\n");
504483
return -EEXIST;
505484
}
506485

@@ -717,17 +696,13 @@ static void eeh_bridge_check_link(struct eeh_dev *edev)
717696
if (!(edev->mode & (EEH_DEV_ROOT_PORT | EEH_DEV_DS_PORT)))
718697
return;
719698

720-
pr_debug("%s: Check PCIe link for %04x:%02x:%02x.%01x ...\n",
721-
__func__, pdn->phb->global_number,
722-
pdn->busno,
723-
PCI_SLOT(pdn->devfn),
724-
PCI_FUNC(pdn->devfn));
699+
eeh_edev_dbg(edev, "Checking PCIe link...\n");
725700

726701
/* Check slot status */
727702
cap = edev->pcie_cap;
728703
eeh_ops->read_config(pdn, cap + PCI_EXP_SLTSTA, 2, &val);
729704
if (!(val & PCI_EXP_SLTSTA_PDS)) {
730-
pr_debug(" No card in the slot (0x%04x) !\n", val);
705+
eeh_edev_dbg(edev, "No card in the slot (0x%04x) !\n", val);
731706
return;
732707
}
733708

@@ -736,7 +711,7 @@ static void eeh_bridge_check_link(struct eeh_dev *edev)
736711
if (val & PCI_EXP_SLTCAP_PCP) {
737712
eeh_ops->read_config(pdn, cap + PCI_EXP_SLTCTL, 2, &val);
738713
if (val & PCI_EXP_SLTCTL_PCC) {
739-
pr_debug(" In power-off state, power it on ...\n");
714+
eeh_edev_dbg(edev, "In power-off state, power it on ...\n");
740715
val &= ~(PCI_EXP_SLTCTL_PCC | PCI_EXP_SLTCTL_PIC);
741716
val |= (0x0100 & PCI_EXP_SLTCTL_PIC);
742717
eeh_ops->write_config(pdn, cap + PCI_EXP_SLTCTL, 2, val);
@@ -752,7 +727,7 @@ static void eeh_bridge_check_link(struct eeh_dev *edev)
752727
/* Check link */
753728
eeh_ops->read_config(pdn, cap + PCI_EXP_LNKCAP, 4, &val);
754729
if (!(val & PCI_EXP_LNKCAP_DLLLARC)) {
755-
pr_debug(" No link reporting capability (0x%08x) \n", val);
730+
eeh_edev_dbg(edev, "No link reporting capability (0x%08x) \n", val);
756731
msleep(1000);
757732
return;
758733
}
@@ -769,10 +744,10 @@ static void eeh_bridge_check_link(struct eeh_dev *edev)
769744
}
770745

771746
if (val & PCI_EXP_LNKSTA_DLLLA)
772-
pr_debug(" Link up (%s)\n",
747+
eeh_edev_dbg(edev, "Link up (%s)\n",
773748
(val & PCI_EXP_LNKSTA_CLS_2_5GB) ? "2.5GB" : "5GB");
774749
else
775-
pr_debug(" Link not ready (0x%04x)\n", val);
750+
eeh_edev_dbg(edev, "Link not ready (0x%04x)\n", val);
776751
}
777752

778753
#define BYTE_SWAP(OFF) (8*((OFF)/4)+3-(OFF))

‎arch/powerpc/platforms/powernv/eeh-powernv.c‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void pnv_pcibios_bus_add_device(struct pci_dev *pdev)
4444
if (eeh_has_flag(EEH_FORCE_DISABLED))
4545
return;
4646

47-
pr_debug("%s: EEH: Setting up device %s.\n", __func__, pci_name(pdev));
47+
dev_dbg(&pdev->dev, "EEH: Setting up device\n");
4848
eeh_add_device_early(pdn);
4949
eeh_add_device_late(pdev);
5050
eeh_sysfs_add_device(pdev);
@@ -370,10 +370,6 @@ static void *pnv_eeh_probe(struct pci_dn *pdn, void *data)
370370
int ret;
371371
int config_addr = (pdn->busno << 8) | (pdn->devfn);
372372

373-
pr_debug("%s: probing %04x:%02x:%02x.%01x\n",
374-
__func__, hose->global_number, pdn->busno,
375-
PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn));
376-
377373
/*
378374
* When probing the root bridge, which doesn't have any
379375
* subordinate PCI devices. We don't have OF node for
@@ -387,6 +383,8 @@ static void *pnv_eeh_probe(struct pci_dn *pdn, void *data)
387383
if ((pdn->class_code >> 8) == PCI_CLASS_BRIDGE_ISA)
388384
return NULL;
389385

386+
eeh_edev_dbg(edev, "Probing device\n");
387+
390388
/* Initialize eeh device */
391389
edev->class_code = pdn->class_code;
392390
edev->mode &= 0xFFFFFF00;
@@ -412,9 +410,7 @@ static void *pnv_eeh_probe(struct pci_dn *pdn, void *data)
412410
/* Create PE */
413411
ret = eeh_add_to_parent_pe(edev);
414412
if (ret) {
415-
pr_warn("%s: Can't add PCI dev %04x:%02x:%02x.%01x to parent PE (%x)\n",
416-
__func__, hose->global_number, pdn->busno,
417-
PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn), ret);
413+
eeh_edev_warn(edev, "Failed to add device to PE (code %d)\n", ret);
418414
return NULL;
419415
}
420416

@@ -472,10 +468,7 @@ static void *pnv_eeh_probe(struct pci_dn *pdn, void *data)
472468
/* Save memory bars */
473469
eeh_save_bars(edev);
474470

475-
pr_debug("%s: EEH enabled on %02x:%02x.%01x PHB#%x-PE#%x\n",
476-
__func__, pdn->busno, PCI_SLOT(pdn->devfn),
477-
PCI_FUNC(pdn->devfn), edev->pe->phb->global_number,
478-
edev->pe->addr);
471+
eeh_edev_dbg(edev, "EEH enabled on device\n");
479472

480473
return NULL;
481474
}

‎arch/powerpc/platforms/pseries/eeh_pseries.c‎

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void pseries_pcibios_bus_add_device(struct pci_dev *pdev)
4949
if (eeh_has_flag(EEH_FORCE_DISABLED))
5050
return;
5151

52-
pr_debug("%s: EEH: Setting up device %s.\n", __func__, pci_name(pdev));
52+
dev_dbg(&pdev->dev, "EEH: Setting up device\n");
5353
#ifdef CONFIG_PCI_IOV
5454
if (pdev->is_virtfn) {
5555
struct pci_dn *physfn_pdn;
@@ -238,10 +238,6 @@ static void *pseries_eeh_probe(struct pci_dn *pdn, void *data)
238238
int enable = 0;
239239
int ret;
240240

241-
pr_debug("%s: probing %04x:%02x:%02x.%01x\n",
242-
__func__, pdn->phb->global_number, pdn->busno,
243-
PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn));
244-
245241
/* Retrieve OF node and eeh device */
246242
edev = pdn_to_eeh_dev(pdn);
247243
if (!edev || edev->pe)
@@ -255,6 +251,8 @@ static void *pseries_eeh_probe(struct pci_dn *pdn, void *data)
255251
if ((pdn->class_code >> 8) == PCI_CLASS_BRIDGE_ISA)
256252
return NULL;
257253

254+
eeh_edev_dbg(edev, "Probing device\n");
255+
258256
/*
259257
* Update class code and mode of eeh device. We need
260258
* correctly reflects that current device is root port
@@ -284,12 +282,10 @@ static void *pseries_eeh_probe(struct pci_dn *pdn, void *data)
284282
pe.config_addr = (pdn->busno << 16) | (pdn->devfn << 8);
285283

286284
/* Enable EEH on the device */
285+
eeh_edev_dbg(edev, "Enabling EEH on device\n");
287286
ret = eeh_ops->set_option(&pe, EEH_OPT_ENABLE);
288287
if (ret) {
289-
pr_debug("%s: EEH failed to enable on %02x:%02x.%01x PHB#%x-PE#%x (code %d)\n",
290-
__func__, pdn->busno, PCI_SLOT(pdn->devfn),
291-
PCI_FUNC(pdn->devfn), pe.phb->global_number,
292-
pe.addr, ret);
288+
eeh_edev_dbg(edev, "EEH failed to enable on device (code %d)\n", ret);
293289
} else {
294290
/* Retrieve PE address */
295291
edev->pe_config_addr = eeh_ops->get_pe_addr(&pe);
@@ -314,11 +310,8 @@ static void *pseries_eeh_probe(struct pci_dn *pdn, void *data)
314310
edev->pe_config_addr = pdn_to_eeh_dev(pdn->parent)->pe_config_addr;
315311
eeh_add_to_parent_pe(edev);
316312
}
317-
pr_debug("%s: EEH %s on %02x:%02x.%01x PHB#%x-PE#%x (code %d)\n",
318-
__func__, (enable ? "enabled" : "unsupported"),
319-
pdn->busno, PCI_SLOT(pdn->devfn),
320-
PCI_FUNC(pdn->devfn), pe.phb->global_number,
321-
pe.addr, ret);
313+
eeh_edev_dbg(edev, "EEH is %s on device (code %d)\n",
314+
(enable ? "enabled" : "unsupported"), ret);
322315
}
323316

324317
/* Save memory bars */

0 commit comments

Comments
 (0)