Skip to content

Commit c6406d8

Browse files
Gavin Shanozbenh
authored andcommitted
powerpc/eeh: Remove device_node dependency
The patch removes struct eeh_dev::dn and the corresponding helper functions: eeh_dev_to_of_node() and of_node_to_eeh_dev(). Instead, eeh_dev_to_pdn() and pdn_to_eeh_dev() should be used to get the pdn, which might contain device_node on PowerNV platform. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
1 parent 0bd7858 commit c6406d8

9 files changed

Lines changed: 55 additions & 81 deletions

File tree

‎arch/powerpc/include/asm/eeh.h‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
struct pci_dev;
3131
struct pci_bus;
32-
struct device_node;
3332
struct pci_dn;
3433

3534
#ifdef CONFIG_EEH
@@ -137,17 +136,11 @@ struct eeh_dev {
137136
struct eeh_pe *pe; /* Associated PE */
138137
struct list_head list; /* Form link list in the PE */
139138
struct pci_controller *phb; /* Associated PHB */
140-
struct device_node *dn; /* Associated device node */
141139
struct pci_dn *pdn; /* Associated PCI device node */
142140
struct pci_dev *pdev; /* Associated PCI device */
143141
struct pci_bus *bus; /* PCI bus for partial hotplug */
144142
};
145143

146-
static inline struct device_node *eeh_dev_to_of_node(struct eeh_dev *edev)
147-
{
148-
return edev ? edev->dn : NULL;
149-
}
150-
151144
static inline struct pci_dn *eeh_dev_to_pdn(struct eeh_dev *edev)
152145
{
153146
return edev ? edev->pdn : NULL;

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -201,25 +201,11 @@ static inline int pci_device_from_OF_node(struct device_node *np,
201201
}
202202

203203
#if defined(CONFIG_EEH)
204-
static inline struct eeh_dev *of_node_to_eeh_dev(struct device_node *dn)
205-
{
206-
/*
207-
* For those OF nodes whose parent isn't PCI bridge, they
208-
* don't have PCI_DN actually. So we have to skip them for
209-
* any EEH operations.
210-
*/
211-
if (!dn || !PCI_DN(dn))
212-
return NULL;
213-
214-
return PCI_DN(dn)->edev;
215-
}
216-
217204
static inline struct eeh_dev *pdn_to_eeh_dev(struct pci_dn *pdn)
218205
{
219206
return pdn ? pdn->edev : NULL;
220207
}
221208
#else
222-
#define of_node_to_eeh_dev(x) (NULL)
223209
#define pdn_to_eeh_dev(x) (NULL)
224210
#endif
225211

‎arch/powerpc/kernel/eeh.c‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,11 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
418418
int ret;
419419
int active_flags = (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE);
420420
unsigned long flags;
421-
struct device_node *dn;
421+
struct pci_dn *pdn;
422422
struct pci_dev *dev;
423423
struct eeh_pe *pe, *parent_pe, *phb_pe;
424424
int rc = 0;
425-
const char *location;
425+
const char *location = NULL;
426426

427427
eeh_stats.total_mmio_ffs++;
428428

@@ -433,15 +433,14 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
433433
eeh_stats.no_dn++;
434434
return 0;
435435
}
436-
dn = eeh_dev_to_of_node(edev);
437436
dev = eeh_dev_to_pci_dev(edev);
438437
pe = eeh_dev_to_pe(edev);
439438

440439
/* Access to IO BARs might get this far and still not want checking. */
441440
if (!pe) {
442441
eeh_stats.ignored_check++;
443-
pr_debug("EEH: Ignored check for %s %s\n",
444-
eeh_pci_name(dev), dn->full_name);
442+
pr_debug("EEH: Ignored check for %s\n",
443+
eeh_pci_name(dev));
445444
return 0;
446445
}
447446

@@ -477,10 +476,13 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
477476
if (pe->state & EEH_PE_ISOLATED) {
478477
pe->check_count++;
479478
if (pe->check_count % EEH_MAX_FAILS == 0) {
480-
location = of_get_property(dn, "ibm,loc-code", NULL);
479+
pdn = eeh_dev_to_pdn(edev);
480+
if (pdn->node)
481+
location = of_get_property(pdn->node, "ibm,loc-code", NULL);
481482
printk(KERN_ERR "EEH: %d reads ignored for recovering device at "
482483
"location=%s driver=%s pci addr=%s\n",
483-
pe->check_count, location,
484+
pe->check_count,
485+
location ? location : "unknown",
484486
eeh_driver_name(dev), eeh_pci_name(dev));
485487
printk(KERN_ERR "EEH: Might be infinite loop in %s driver\n",
486488
eeh_driver_name(dev));
@@ -1035,7 +1037,7 @@ int eeh_init(void)
10351037
core_initcall_sync(eeh_init);
10361038

10371039
/**
1038-
* eeh_add_device_early - Enable EEH for the indicated device_node
1040+
* eeh_add_device_early - Enable EEH for the indicated device node
10391041
* @pdn: PCI device node for which to set up EEH
10401042
*
10411043
* This routine must be used to perform EEH initialization for PCI
@@ -1093,16 +1095,16 @@ EXPORT_SYMBOL_GPL(eeh_add_device_tree_early);
10931095
*/
10941096
void eeh_add_device_late(struct pci_dev *dev)
10951097
{
1096-
struct device_node *dn;
1098+
struct pci_dn *pdn;
10971099
struct eeh_dev *edev;
10981100

10991101
if (!dev || !eeh_enabled())
11001102
return;
11011103

11021104
pr_debug("EEH: Adding device %s\n", pci_name(dev));
11031105

1104-
dn = pci_device_to_OF_node(dev);
1105-
edev = of_node_to_eeh_dev(dn);
1106+
pdn = pci_get_pdn_by_devfn(dev->bus, dev->devfn);
1107+
edev = pdn_to_eeh_dev(pdn);
11061108
if (edev->pdev == dev) {
11071109
pr_debug("EEH: Already referenced !\n");
11081110
return;

‎arch/powerpc/kernel/eeh_cache.c‎

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -171,30 +171,27 @@ eeh_addr_cache_insert(struct pci_dev *dev, unsigned long alo,
171171

172172
static void __eeh_addr_cache_insert_dev(struct pci_dev *dev)
173173
{
174-
struct device_node *dn;
174+
struct pci_dn *pdn;
175175
struct eeh_dev *edev;
176176
int i;
177177

178-
dn = pci_device_to_OF_node(dev);
179-
if (!dn) {
178+
pdn = pci_get_pdn_by_devfn(dev->bus, dev->devfn);
179+
if (!pdn) {
180180
pr_warn("PCI: no pci dn found for dev=%s\n",
181181
pci_name(dev));
182182
return;
183183
}
184184

185-
edev = of_node_to_eeh_dev(dn);
185+
edev = pdn_to_eeh_dev(pdn);
186186
if (!edev) {
187-
pr_warn("PCI: no EEH dev found for dn=%s\n",
188-
dn->full_name);
187+
pr_warn("PCI: no EEH dev found for %s\n",
188+
pci_name(dev));
189189
return;
190190
}
191191

192192
/* Skip any devices for which EEH is not enabled. */
193193
if (!edev->pe) {
194-
#ifdef DEBUG
195-
pr_info("PCI: skip building address cache for=%s - %s\n",
196-
pci_name(dev), dn->full_name);
197-
#endif
194+
dev_dbg(&dev->dev, "EEH: Skip building address cache\n");
198195
return;
199196
}
200197

@@ -282,18 +279,18 @@ void eeh_addr_cache_rmv_dev(struct pci_dev *dev)
282279
*/
283280
void eeh_addr_cache_build(void)
284281
{
285-
struct device_node *dn;
282+
struct pci_dn *pdn;
286283
struct eeh_dev *edev;
287284
struct pci_dev *dev = NULL;
288285

289286
spin_lock_init(&pci_io_addr_cache_root.piar_lock);
290287

291288
for_each_pci_dev(dev) {
292-
dn = pci_device_to_OF_node(dev);
293-
if (!dn)
289+
pdn = pci_get_pdn_by_devfn(dev->bus, dev->devfn);
290+
if (!pdn)
294291
continue;
295292

296-
edev = of_node_to_eeh_dev(dn);
293+
edev = pdn_to_eeh_dev(pdn);
297294
if (!edev)
298295
continue;
299296

‎arch/powerpc/kernel/eeh_driver.c‎

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -83,28 +83,6 @@ static inline void eeh_pcid_put(struct pci_dev *pdev)
8383
module_put(pdev->driver->driver.owner);
8484
}
8585

86-
#if 0
87-
static void print_device_node_tree(struct pci_dn *pdn, int dent)
88-
{
89-
int i;
90-
struct device_node *pc;
91-
92-
if (!pdn)
93-
return;
94-
for (i = 0; i < dent; i++)
95-
printk(" ");
96-
printk("dn=%s mode=%x \tcfg_addr=%x pe_addr=%x \tfull=%s\n",
97-
pdn->node->name, pdn->eeh_mode, pdn->eeh_config_addr,
98-
pdn->eeh_pe_config_addr, pdn->node->full_name);
99-
dent += 3;
100-
pc = pdn->node->child;
101-
while (pc) {
102-
print_device_node_tree(PCI_DN(pc), dent);
103-
pc = pc->sibling;
104-
}
105-
}
106-
#endif
107-
10886
/**
10987
* eeh_disable_irq - Disable interrupt for the recovering device
11088
* @dev: PCI device

‎arch/powerpc/kernel/eeh_pe.c‎

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,12 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
348348

349349
/* Put the edev to PE */
350350
list_add_tail(&edev->list, &pe->edevs);
351-
pr_debug("EEH: Add %s to Bus PE#%x\n",
352-
edev->dn->full_name, pe->addr);
353-
351+
pr_debug("EEH: Add %04x:%02x:%02x.%01x to Bus PE#%x\n",
352+
edev->phb->global_number,
353+
edev->config_addr >> 8,
354+
PCI_SLOT(edev->config_addr & 0xFF),
355+
PCI_FUNC(edev->config_addr & 0xFF),
356+
pe->addr);
354357
return 0;
355358
} else if (pe && (pe->type & EEH_PE_INVALID)) {
356359
list_add_tail(&edev->list, &pe->edevs);
@@ -366,9 +369,14 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
366369
parent->type &= ~(EEH_PE_INVALID | EEH_PE_KEEP);
367370
parent = parent->parent;
368371
}
369-
pr_debug("EEH: Add %s to Device PE#%x, Parent PE#%x\n",
370-
edev->dn->full_name, pe->addr, pe->parent->addr);
371372

373+
pr_debug("EEH: Add %04x:%02x:%02x.%01x to Device "
374+
"PE#%x, Parent PE#%x\n",
375+
edev->phb->global_number,
376+
edev->config_addr >> 8,
377+
PCI_SLOT(edev->config_addr & 0xFF),
378+
PCI_FUNC(edev->config_addr & 0xFF),
379+
pe->addr, pe->parent->addr);
372380
return 0;
373381
}
374382

@@ -407,8 +415,13 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
407415
list_add_tail(&pe->child, &parent->child_list);
408416
list_add_tail(&edev->list, &pe->edevs);
409417
edev->pe = pe;
410-
pr_debug("EEH: Add %s to Device PE#%x, Parent PE#%x\n",
411-
edev->dn->full_name, pe->addr, pe->parent->addr);
418+
pr_debug("EEH: Add %04x:%02x:%02x.%01x to "
419+
"Device PE#%x, Parent PE#%x\n",
420+
edev->phb->global_number,
421+
edev->config_addr >> 8,
422+
PCI_SLOT(edev->config_addr & 0xFF),
423+
PCI_FUNC(edev->config_addr & 0xFF),
424+
pe->addr, pe->parent->addr);
412425

413426
return 0;
414427
}
@@ -428,8 +441,11 @@ int eeh_rmv_from_parent_pe(struct eeh_dev *edev)
428441
int cnt;
429442

430443
if (!edev->pe) {
431-
pr_debug("%s: No PE found for EEH device %s\n",
432-
__func__, edev->dn->full_name);
444+
pr_debug("%s: No PE found for device %04x:%02x:%02x.%01x\n",
445+
__func__, edev->phb->global_number,
446+
edev->config_addr >> 8,
447+
PCI_SLOT(edev->config_addr & 0xFF),
448+
PCI_FUNC(edev->config_addr & 0xFF));
433449
return -EEXIST;
434450
}
435451

‎arch/powerpc/kernel/pci_of_scan.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ static struct pci_dev *of_scan_pci_dev(struct pci_bus *bus,
305305
const __be32 *reg;
306306
int reglen, devfn;
307307
#ifdef CONFIG_EEH
308-
struct eeh_dev *edev = of_node_to_eeh_dev(dn);
308+
struct eeh_dev *edev = pdn_to_eeh_dev(PCI_DN(dn));
309309
#endif
310310

311311
pr_debug(" * %s\n", dn->full_name);

‎arch/powerpc/kernel/rtas_pci.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static int rtas_pci_read_config(struct pci_bus *bus,
113113

114114
ret = rtas_read_config(pdn, where, size, val);
115115
if (*val == EEH_IO_ERROR_VALUE(size) &&
116-
eeh_dev_check_failure(of_node_to_eeh_dev(dn)))
116+
eeh_dev_check_failure(pdn_to_eeh_dev(pdn)))
117117
return PCIBIOS_DEVICE_NOT_FOUND;
118118

119119
return ret;

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ static struct device_node *find_pe_total_msi(struct pci_dev *dev, int *total)
195195
static struct device_node *find_pe_dn(struct pci_dev *dev, int *total)
196196
{
197197
struct device_node *dn;
198+
struct pci_dn *pdn;
198199
struct eeh_dev *edev;
199200

200201
/* Found our PE and assume 8 at that point. */
@@ -204,10 +205,11 @@ static struct device_node *find_pe_dn(struct pci_dev *dev, int *total)
204205
return NULL;
205206

206207
/* Get the top level device in the PE */
207-
edev = of_node_to_eeh_dev(dn);
208+
edev = pdn_to_eeh_dev(PCI_DN(dn));
208209
if (edev->pe)
209210
edev = list_first_entry(&edev->pe->edevs, struct eeh_dev, list);
210-
dn = eeh_dev_to_of_node(edev);
211+
pdn = eeh_dev_to_pdn(edev);
212+
dn = pdn ? pdn->node : NULL;
211213
if (!dn)
212214
return NULL;
213215

0 commit comments

Comments
 (0)