powerpc/kernel: Change retrieval of pci_dn
PATCH 1/1 powerpc/kernel: Change retrieval of pci_dn
For a PCI device it's pci_dn can be retrieved from pdev->dev.archdata.firmware_data, PCI_DN(devnode), or parent's list. Thus, we should just use the generic function pci_get_pdn_by_devfn to get the pci_dn.
--- arch/powerpc/kernel/rtas_pci.c | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-)
arch/powerpc/kernel/rtas_pci.c +2 -28
@@ -91,25 +91,13 @@ static int rtas_pci_read_config(struct pci_bus *bus,unsigned int devfn, int where, int size, u32 *val) { - struct device_node *busdn, *dn; struct pci_dn *pdn; -bool found = false;int ret;/* Search only direct children of the bus */ *val =0xFFFFFFFF ; - busdn =pci_bus_to_OF_node (bus); -for (dn = busdn->child; dn; dn = dn->sibling) { - pdn =PCI_DN (dn); -if (pdn && pdn->devfn == devfn - &&of_device_is_available (dn)) { - found = true; -break ; - } - } -if (!found) -return PCIBIOS_DEVICE_NOT_FOUND ; + pdn =pci_get_pdn_by_devfn (bus, devfn); ret =rtas_read_config (pdn, where, size, val); if (*val == EEH_IO_ERROR_VALUE(size) &&
@@ -153,23 +141,9 @@ static int rtas_pci_write_config(struct pci_bus *bus,unsigned int devfn, int where, int size, u32 val) { - struct device_node *busdn, *dn; struct pci_dn *pdn; -bool found = false; - -/* Search only direct children of the bus */ - busdn =pci_bus_to_OF_node (bus); -for (dn = busdn->child; dn; dn = dn->sibling) { - pdn =PCI_DN (dn); -if (pdn && pdn->devfn == devfn - &&of_device_is_available (dn)) { - found = true; -break ; - } - } -if (!found) -return PCIBIOS_DEVICE_NOT_FOUND ; + pdn =pci_get_pdn_by_devfn (bus, devfn);return rtas_write_config (pdn, where, size, val); }
Signature · 1 line
2.5.4 (Apple Git-61)
Quoted 6 lines · Bryant G. Ly
For a PCI device it's
pci_dncan be retrieved frompdev->dev.archdata.firmware_data,PCI_DN(devnode), or parent's list. Thus, we should just use the generic functionpci_get_pdn_by_devfnto get thepci_dn.Signed-off-by Bryant G. Ly <[email protected]>
I don't know this area but I tested it using a patched kernel with the old and new code together. My test kernel booted fine (in QEMU+KVM) and I saw 26 reads and 4 writes, all of which got the same value with either code block.
I also checked that the error result in the "not found" case is the same as well, which it is, because rtas_{read,write}_config() will return PCIBIOS_DEVICE_NOT_FOUND if given a NULL pdn.
So, looks good to me.
Cheers,
Sam.
Quoted 62 lines
--- arch/powerpc/kernel/rtas_pci.c | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-)arch/powerpc/kernel/rtas_pci.c +2
-28@@ -91,25 +91,13 @@ static int rtas_pci_read_config(struct pci_bus *bus,unsigned int devfn, int where, int size, u32 *val) { - struct device_node *busdn, *dn; struct pci_dn *pdn; -bool found = false;int ret;/* Search only direct children of the bus */ *val =0xFFFFFFFF ; - busdn =pci_bus_to_OF_node (bus); -for (dn = busdn->child; dn; dn = dn->sibling) { - pdn =PCI_DN (dn); -if (pdn && pdn->devfn == devfn - &&of_device_is_available (dn)) { - found = true; -break ; - } - } -if (!found) -return PCIBIOS_DEVICE_NOT_FOUND ; + pdn =pci_get_pdn_by_devfn (bus, devfn); ret =rtas_read_config (pdn, where, size, val); if (*val == EEH_IO_ERROR_VALUE(size) &&@@ -153,23 +141,9 @@ static int rtas_pci_write_config(struct pci_bus *bus,unsigned int devfn, int where, int size, u32 val) { - struct device_node *busdn, *dn; struct pci_dn *pdn; -bool found = false; - -/* Search only direct children of the bus */ - busdn =pci_bus_to_OF_node (bus); -for (dn = busdn->child; dn; dn = dn->sibling) { - pdn =PCI_DN (dn); -if (pdn && pdn->devfn == devfn - &&of_device_is_available (dn)) { - found = true; -break ; - } - } -if (!found) -return PCIBIOS_DEVICE_NOT_FOUND ; + pdn =pci_get_pdn_by_devfn (bus, devfn);return rtas_write_config (pdn, where, size, val); }Signature · 1 line
2.5.4 (Apple Git-61)
Michael Ellerman
reviewerHi Bryant,
Thanks for the patch, a few comments/questions.
How have you tested this?
Quoted 4 lines · Bryant G. Ly
For a PCI device it's
pci_dncan be retrieved frompdev->dev.archdata.firmware_data,PCI_DN(devnode), or parent's list. Thus, we should just use the generic functionpci_get_pdn_by_devfnto get thepci_dn.
"generic" means shared between architectures, which is not true for pci_get_pdn_by_devfn(). "existing" would be more appropriate.
Quoted 5 lines
arch/powerpc/kernel/rtas_pci.c +0
-0
arch/powerpc/kernel/rtas_pci.c static int rtas_pci_read_config(struct pci_bus *bus, · line 97
Quoted 9 lines
arch/powerpc/kernel/rtas_pci.c +0
-2@@ -91,25 +91,13 @@ static int rtas_pci_read_config(struct pci_bus *bus,unsigned int devfn, int where, int size, u32 *val) { - struct device_node *busdn, *dn; struct pci_dn *pdn; -bool found = false;int ret;/* Search only direct children of the bus */
You kept the comment, but is it still true, and what does it apply to now?
Also you removed the comment below in write, I'd expect it to either stay in both or be removed in both?
Quoted 4 lines
arch/powerpc/kernel/rtas_pci.c +0
-3*val =0xFFFFFFFF ; - busdn =pci_bus_to_OF_node (bus); -for (dn = busdn->child; dn; dn = dn->sibling) { - pdn =PCI_DN (dn);
arch/powerpc/kernel/rtas_pci.c static int rtas_pci_read_config(struct pci_bus *bus, · line 100
Quoted 10 lines
arch/powerpc/kernel/rtas_pci.c +1
-8-if (pdn && pdn->devfn == devfn - &&of_device_is_available (dn)) { - found = true; -break ; - } - } -if (!found) -return PCIBIOS_DEVICE_NOT_FOUND ; + pdn =pci_get_pdn_by_devfn (bus, devfn);
This appears to not handle the pdn == NULL case.
arch/powerpc/kernel/rtas_pci.c static int rtas_pci_read_config(struct pci_bus *bus, · line 102
Quoted 1 line
arch/powerpc/kernel/rtas_pci.c +0
-0ret =rtas_read_config (pdn, where, size, val);
But actually is handled in there ^
That would have been worth mentioning in the change log.
cheers
Quoted 28 lines
arch/powerpc/kernel/rtas_pci.c +1
-15if (*val == EEH_IO_ERROR_VALUE(size) &&@@ -153,23 +141,9 @@ static int rtas_pci_write_config(struct pci_bus *bus,unsigned int devfn, int where, int size, u32 val) { - struct device_node *busdn, *dn; struct pci_dn *pdn; -bool found = false; - -/* Search only direct children of the bus */ - busdn =pci_bus_to_OF_node (bus); -for (dn = busdn->child; dn; dn = dn->sibling) { - pdn =PCI_DN (dn); -if (pdn && pdn->devfn == devfn - &&of_device_is_available (dn)) { - found = true; -break ; - } - } -if (!found) -return PCIBIOS_DEVICE_NOT_FOUND ; + pdn =pci_get_pdn_by_devfn (bus, devfn);return rtas_write_config (pdn, where, size, val); }Signature · 1 line
2.5.4 (Apple Git-61)
Michael Ellerman
reviewerQuoted 6 lines · Bryant G. Ly
For a PCI device it's
pci_dncan be retrieved frompdev->dev.archdata.firmware_data,PCI_DN(devnode), or parent's list. Thus, we should just use the generic functionpci_get_pdn_by_devfnto get thepci_dn.Signed-off-by Bryant G. Ly <[email protected]>
Minor issue, it's preferable if the email in your Signed-off-by matches the email you send patches from.
cheers
Quoted 7 lines · Michael Ellerman
Quoted 5 lines · Bryant G. Ly
For a PCI device it's
pci_dncan be retrieved frompdev->dev.archdata.firmware_data,PCI_DN(devnode), or parent's list. Thus, we should just use the generic functionpci_get_pdn_by_devfnto get thepci_dn.
Quoted 6 lines
Quoted 1 line
Signed-off-by Bryant G. Ly <[email protected]>Minor issue, it's preferable if the email in your Signed-off-by matches the email you send patches from.
cheers
Hi Michael,
Thanks for the review. I apologize for the email's not matching, I switch between the two frequently throughout the day for internal gerrit commits and Linux patches. I have addressed all your comments in the new patch that I had just put up. Also, I have tested it with mellanox cx4 cards on P8 systems.
I'd also like to let you know that I am working on patches to enable SRIOV on power and would like your feedback on design, which I will send in a private email.
-Bryant
Quoted 14 lines · Sam Bobroff
Quoted 6 lines · Bryant G. Ly
For a PCI device it's
pci_dncan be retrieved frompdev->dev.archdata.firmware_data,PCI_DN(devnode), or parent's list. Thus, we should just use the generic functionpci_get_pdn_by_devfnto get thepci_dn.Signed-off-by Bryant G. Ly <[email protected]>Reviewed-by Sam Bobroff <[email protected]>I don't know this area but I tested it using a patched kernel with the old and new code together. My test kernel booted fine (in QEMU+KVM) and I saw 26 reads and 4 writes, all of which got the same value with either code block.
Quoted 9 lines
I also checked that the error result in the "not found" case is the same as well, which it is, because rtas_{read,write}_config() will return
PCIBIOS_DEVICE_NOT_FOUNDif given a NULL pdn.So, looks good to me.
Cheers,
Sam.
Thanks for the review Sam!