Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/powernv: Use pci_dn, not device_node, in PCI config accessor

The PCI config accessors previously relied on device_node. Unfortunately,
VFs don't have a corresponding device_node, so change the accessors to use
pci_dn instead.

[bhelgaas: changelog]
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Gavin Shan and committed by
Benjamin Herrenschmidt
3532a741 cca87d30

+42 -49
+12 -2
arch/powerpc/platforms/powernv/eeh-powernv.c
··· 1038 1038 static int pnv_eeh_read_config(struct device_node *dn, 1039 1039 int where, int size, u32 *val) 1040 1040 { 1041 + struct pci_dn *pdn = PCI_DN(dn); 1042 + 1043 + if (!pdn) 1044 + return PCIBIOS_DEVICE_NOT_FOUND; 1045 + 1041 1046 if (pnv_eeh_cfg_blocked(dn)) { 1042 1047 *val = 0xFFFFFFFF; 1043 1048 return PCIBIOS_SET_FAILED; 1044 1049 } 1045 1050 1046 - return pnv_pci_cfg_read(dn, where, size, val); 1051 + return pnv_pci_cfg_read(pdn, where, size, val); 1047 1052 } 1048 1053 1049 1054 static int pnv_eeh_write_config(struct device_node *dn, 1050 1055 int where, int size, u32 val) 1051 1056 { 1057 + struct pci_dn *pdn = PCI_DN(dn); 1058 + 1059 + if (!pdn) 1060 + return PCIBIOS_DEVICE_NOT_FOUND; 1061 + 1052 1062 if (pnv_eeh_cfg_blocked(dn)) 1053 1063 return PCIBIOS_SET_FAILED; 1054 1064 1055 - return pnv_pci_cfg_write(dn, where, size, val); 1065 + return pnv_pci_cfg_write(pdn, where, size, val); 1056 1066 } 1057 1067 1058 1068 static void pnv_eeh_dump_hub_diag_common(struct OpalIoP7IOCErrorData *data)
+28 -45
arch/powerpc/platforms/powernv/pci.c
··· 366 366 spin_unlock_irqrestore(&phb->lock, flags); 367 367 } 368 368 369 - static void pnv_pci_config_check_eeh(struct pnv_phb *phb, 370 - struct device_node *dn) 369 + static void pnv_pci_config_check_eeh(struct pci_dn *pdn) 371 370 { 371 + struct pnv_phb *phb = pdn->phb->private_data; 372 372 u8 fstate; 373 373 __be16 pcierr; 374 374 int pe_no; ··· 379 379 * setup that yet. So all ER errors should be mapped to 380 380 * reserved PE. 381 381 */ 382 - pe_no = PCI_DN(dn)->pe_number; 382 + pe_no = pdn->pe_number; 383 383 if (pe_no == IODA_INVALID_PE) { 384 384 if (phb->type == PNV_PHB_P5IOC2) 385 385 pe_no = 0; ··· 407 407 } 408 408 409 409 cfg_dbg(" -> EEH check, bdfn=%04x PE#%d fstate=%x\n", 410 - (PCI_DN(dn)->busno << 8) | (PCI_DN(dn)->devfn), 411 - pe_no, fstate); 410 + (pdn->busno << 8) | (pdn->devfn), pe_no, fstate); 412 411 413 412 /* Clear the frozen state if applicable */ 414 413 if (fstate == OPAL_EEH_STOPPED_MMIO_FREEZE || ··· 424 425 } 425 426 } 426 427 427 - int pnv_pci_cfg_read(struct device_node *dn, 428 + int pnv_pci_cfg_read(struct pci_dn *pdn, 428 429 int where, int size, u32 *val) 429 430 { 430 - struct pci_dn *pdn = PCI_DN(dn); 431 431 struct pnv_phb *phb = pdn->phb->private_data; 432 432 u32 bdfn = (pdn->busno << 8) | pdn->devfn; 433 433 s64 rc; ··· 460 462 return PCIBIOS_SUCCESSFUL; 461 463 } 462 464 463 - int pnv_pci_cfg_write(struct device_node *dn, 465 + int pnv_pci_cfg_write(struct pci_dn *pdn, 464 466 int where, int size, u32 val) 465 467 { 466 - struct pci_dn *pdn = PCI_DN(dn); 467 468 struct pnv_phb *phb = pdn->phb->private_data; 468 469 u32 bdfn = (pdn->busno << 8) | pdn->devfn; 469 470 ··· 486 489 } 487 490 488 491 #if CONFIG_EEH 489 - static bool pnv_pci_cfg_check(struct pci_controller *hose, 490 - struct device_node *dn) 492 + static bool pnv_pci_cfg_check(struct pci_dn *pdn) 491 493 { 492 494 struct eeh_dev *edev = NULL; 493 - struct pnv_phb *phb = hose->private_data; 495 + struct pnv_phb *phb = pdn->phb->private_data; 494 496 495 497 /* EEH not enabled ? */ 496 498 if (!(phb->flags & PNV_PHB_FLAG_EEH)) 497 499 return true; 498 500 499 501 /* PE reset or device removed ? */ 500 - edev = of_node_to_eeh_dev(dn); 502 + edev = pdn->edev; 501 503 if (edev) { 502 504 if (edev->pe && 503 505 (edev->pe->state & EEH_PE_CFG_BLOCKED)) ··· 509 513 return true; 510 514 } 511 515 #else 512 - static inline pnv_pci_cfg_check(struct pci_controller *hose, 513 - struct device_node *dn) 516 + static inline pnv_pci_cfg_check(struct pci_dn *pdn) 514 517 { 515 518 return true; 516 519 } ··· 519 524 unsigned int devfn, 520 525 int where, int size, u32 *val) 521 526 { 522 - struct device_node *dn, *busdn = pci_bus_to_OF_node(bus); 523 527 struct pci_dn *pdn; 524 528 struct pnv_phb *phb; 525 - bool found = false; 526 529 int ret; 527 530 528 531 *val = 0xFFFFFFFF; 529 - for (dn = busdn->child; dn; dn = dn->sibling) { 530 - pdn = PCI_DN(dn); 531 - if (pdn && pdn->devfn == devfn) { 532 - phb = pdn->phb->private_data; 533 - found = true; 534 - break; 535 - } 536 - } 537 - 538 - if (!found || !pnv_pci_cfg_check(pdn->phb, dn)) 532 + pdn = pci_get_pdn_by_devfn(bus, devfn); 533 + if (!pdn) 539 534 return PCIBIOS_DEVICE_NOT_FOUND; 540 535 541 - ret = pnv_pci_cfg_read(dn, where, size, val); 542 - if (phb->flags & PNV_PHB_FLAG_EEH) { 536 + if (!pnv_pci_cfg_check(pdn)) 537 + return PCIBIOS_DEVICE_NOT_FOUND; 538 + 539 + ret = pnv_pci_cfg_read(pdn, where, size, val); 540 + phb = pdn->phb->private_data; 541 + if (phb->flags & PNV_PHB_FLAG_EEH && pdn->edev) { 543 542 if (*val == EEH_IO_ERROR_VALUE(size) && 544 - eeh_dev_check_failure(of_node_to_eeh_dev(dn))) 543 + eeh_dev_check_failure(pdn->edev)) 545 544 return PCIBIOS_DEVICE_NOT_FOUND; 546 545 } else { 547 - pnv_pci_config_check_eeh(phb, dn); 546 + pnv_pci_config_check_eeh(pdn); 548 547 } 549 548 550 549 return ret; ··· 548 559 unsigned int devfn, 549 560 int where, int size, u32 val) 550 561 { 551 - struct device_node *dn, *busdn = pci_bus_to_OF_node(bus); 552 562 struct pci_dn *pdn; 553 563 struct pnv_phb *phb; 554 - bool found = false; 555 564 int ret; 556 565 557 - for (dn = busdn->child; dn; dn = dn->sibling) { 558 - pdn = PCI_DN(dn); 559 - if (pdn && pdn->devfn == devfn) { 560 - phb = pdn->phb->private_data; 561 - found = true; 562 - break; 563 - } 564 - } 565 - 566 - if (!found || !pnv_pci_cfg_check(pdn->phb, dn)) 566 + pdn = pci_get_pdn_by_devfn(bus, devfn); 567 + if (!pdn) 567 568 return PCIBIOS_DEVICE_NOT_FOUND; 568 569 569 - ret = pnv_pci_cfg_write(dn, where, size, val); 570 + if (!pnv_pci_cfg_check(pdn)) 571 + return PCIBIOS_DEVICE_NOT_FOUND; 572 + 573 + ret = pnv_pci_cfg_write(pdn, where, size, val); 574 + phb = pdn->phb->private_data; 570 575 if (!(phb->flags & PNV_PHB_FLAG_EEH)) 571 - pnv_pci_config_check_eeh(phb, dn); 576 + pnv_pci_config_check_eeh(pdn); 572 577 573 578 return ret; 574 579 }
+2 -2
arch/powerpc/platforms/powernv/pci.h
··· 196 196 197 197 void pnv_pci_dump_phb_diag_data(struct pci_controller *hose, 198 198 unsigned char *log_buff); 199 - int pnv_pci_cfg_read(struct device_node *dn, 199 + int pnv_pci_cfg_read(struct pci_dn *pdn, 200 200 int where, int size, u32 *val); 201 - int pnv_pci_cfg_write(struct device_node *dn, 201 + int pnv_pci_cfg_write(struct pci_dn *pdn, 202 202 int where, int size, u32 val); 203 203 extern void pnv_pci_setup_iommu_table(struct iommu_table *tbl, 204 204 void *tce_mem, u64 tce_size,