* [PATCH] powerpc/kernel: Change retrieval of pci_dn
@ 2017-08-28 16:05 Bryant G. Ly
2017-08-29 6:20 ` Sam Bobroff
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Bryant G. Ly @ 2017-08-28 16:05 UTC (permalink / raw)
To: benh, paulus, mpe
Cc: martin.petersen, linuxppc-dev, Bryant G. Ly, Bryant G. Ly
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.
Signed-off-by: Bryant G. Ly <bgly@us.ibm.com>
---
arch/powerpc/kernel/rtas_pci.c | 30 ++----------------------------
1 file changed, 2 insertions(+), 28 deletions(-)
diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c
index 73f1934..c21e6c5 100644
--- a/arch/powerpc/kernel/rtas_pci.c
+++ b/arch/powerpc/kernel/rtas_pci.c
@@ -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);
}
--
2.5.4 (Apple Git-61)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] powerpc/kernel: Change retrieval of pci_dn
2017-08-28 16:05 [PATCH] " Bryant G. Ly
@ 2017-08-29 6:20 ` Sam Bobroff
2017-08-29 13:19 ` Bryant G. Ly
2017-08-29 6:31 ` Michael Ellerman
2017-08-29 6:33 ` Michael Ellerman
2 siblings, 1 reply; 8+ messages in thread
From: Sam Bobroff @ 2017-08-29 6:20 UTC (permalink / raw)
To: Bryant G. Ly
Cc: benh, paulus, mpe, Bryant G. Ly, linuxppc-dev, martin.petersen
On Mon, Aug 28, 2017 at 11:05:03AM -0500, Bryant G. Ly wrote:
> 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.
>
> Signed-off-by: Bryant G. Ly <bgly@us.ibm.com>
Reviewed-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
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.
> ---
> arch/powerpc/kernel/rtas_pci.c | 30 ++----------------------------
> 1 file changed, 2 insertions(+), 28 deletions(-)
>
> diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c
> index 73f1934..c21e6c5 100644
> --- a/arch/powerpc/kernel/rtas_pci.c
> +++ b/arch/powerpc/kernel/rtas_pci.c
> @@ -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);
> }
> --
> 2.5.4 (Apple Git-61)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] powerpc/kernel: Change retrieval of pci_dn
2017-08-28 16:05 [PATCH] " Bryant G. Ly
2017-08-29 6:20 ` Sam Bobroff
@ 2017-08-29 6:31 ` Michael Ellerman
2017-08-29 6:33 ` Michael Ellerman
2 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2017-08-29 6:31 UTC (permalink / raw)
To: Bryant G. Ly, benh, paulus
Cc: martin.petersen, linuxppc-dev, Bryant G. Ly, Bryant G. Ly
Hi Bryant,
Thanks for the patch, a few comments/questions.
How have you tested this?
"Bryant G. Ly" <bryantly@linux.vnet.ibm.com> writes:
> 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.
"generic" means shared between architectures, which is not true for
pci_get_pdn_by_devfn(). "existing" would be more appropriate.
> diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c
> index 73f1934..c21e6c5 100644
> --- a/arch/powerpc/kernel/rtas_pci.c
> +++ b/arch/powerpc/kernel/rtas_pci.c
> @@ -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?
> *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);
This appears to not handle the pdn == NULL case.
> ret = rtas_read_config(pdn, where, size, val);
But actually is handled in there ^
That would have been worth mentioning in the change log.
cheers
> 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);
> }
> --
> 2.5.4 (Apple Git-61)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] powerpc/kernel: Change retrieval of pci_dn
2017-08-28 16:05 [PATCH] " Bryant G. Ly
2017-08-29 6:20 ` Sam Bobroff
2017-08-29 6:31 ` Michael Ellerman
@ 2017-08-29 6:33 ` Michael Ellerman
2017-08-29 13:18 ` Bryant G. Ly
2 siblings, 1 reply; 8+ messages in thread
From: Michael Ellerman @ 2017-08-29 6:33 UTC (permalink / raw)
To: Bryant G. Ly, benh, paulus
Cc: martin.petersen, linuxppc-dev, Bryant G. Ly, Bryant G. Ly
"Bryant G. Ly" <bryantly@linux.vnet.ibm.com> writes:
> 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.
>
> Signed-off-by: Bryant G. Ly <bgly@us.ibm.com>
Minor issue, it's preferable if the email in your Signed-off-by matches
the email you send patches from.
cheers
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] powerpc/kernel: Change retrieval of pci_dn
@ 2017-08-29 13:11 Bryant G. Ly
2017-08-31 11:36 ` Michael Ellerman
0 siblings, 1 reply; 8+ messages in thread
From: Bryant G. Ly @ 2017-08-29 13:11 UTC (permalink / raw)
To: benh, paulus, mpe; +Cc: sam.bobroff, linuxppc-dev, Bryant G. Ly
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 existing function pci_get_pdn_by_devfn
to get the pci_dn.
Signed-off-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com>
Reviewed-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
---
arch/powerpc/kernel/rtas_pci.c | 33 ++++-----------------------------
1 file changed, 4 insertions(+), 29 deletions(-)
diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c
index 73f1934..c2b148b 100644
--- a/arch/powerpc/kernel/rtas_pci.c
+++ b/arch/powerpc/kernel/rtas_pci.c
@@ -91,26 +91,14 @@ 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);
+ /* Validity of pdn is checked in here */
ret = rtas_read_config(pdn, where, size, val);
if (*val == EEH_IO_ERROR_VALUE(size) &&
eeh_dev_check_failure(pdn_to_eeh_dev(pdn)))
@@ -153,24 +141,11 @@ 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);
+ /* Validity of pdn is checked in here. */
return rtas_write_config(pdn, where, size, val);
}
--
2.5.4 (Apple Git-61)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] powerpc/kernel: Change retrieval of pci_dn
2017-08-29 6:33 ` Michael Ellerman
@ 2017-08-29 13:18 ` Bryant G. Ly
0 siblings, 0 replies; 8+ messages in thread
From: Bryant G. Ly @ 2017-08-29 13:18 UTC (permalink / raw)
To: Michael Ellerman, benh, paulus
Cc: martin.petersen, linuxppc-dev, Bryant G. Ly
On 8/29/17 1:33 AM, Michael Ellerman wrote:
> "Bryant G. Ly" <bryantly@linux.vnet.ibm.com> writes:
>
>> 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.
>>
>> Signed-off-by: Bryant G. Ly <bgly@us.ibm.com>
> 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] powerpc/kernel: Change retrieval of pci_dn
2017-08-29 6:20 ` Sam Bobroff
@ 2017-08-29 13:19 ` Bryant G. Ly
0 siblings, 0 replies; 8+ messages in thread
From: Bryant G. Ly @ 2017-08-29 13:19 UTC (permalink / raw)
To: Sam Bobroff
Cc: benh, paulus, mpe, Bryant G. Ly, linuxppc-dev, martin.petersen
On 8/29/17 1:20 AM, Sam Bobroff wrote:
> On Mon, Aug 28, 2017 at 11:05:03AM -0500, Bryant G. Ly wrote:
>> 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.
>>
>> Signed-off-by: Bryant G. Ly <bgly@us.ibm.com>
> Reviewed-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
>
> 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.
>
Thanks for the review Sam!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: powerpc/kernel: Change retrieval of pci_dn
2017-08-29 13:11 [PATCH] powerpc/kernel: Change retrieval of pci_dn Bryant G. Ly
@ 2017-08-31 11:36 ` Michael Ellerman
0 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2017-08-31 11:36 UTC (permalink / raw)
To: Bryant G. Ly, benh, paulus; +Cc: linuxppc-dev, Bryant G. Ly, sam.bobroff
On Tue, 2017-08-29 at 13:11:51 UTC, "Bryant G. Ly" wrote:
> 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 existing function pci_get_pdn_by_devfn
> to get the pci_dn.
>
> Signed-off-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com>
> Reviewed-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/f9df74dfce542ad2aea2e601ef1a12
cheers
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-08-31 11:36 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-29 13:11 [PATCH] powerpc/kernel: Change retrieval of pci_dn Bryant G. Ly
2017-08-31 11:36 ` Michael Ellerman
-- strict thread matches above, loose matches on Subject: below --
2017-08-28 16:05 [PATCH] " Bryant G. Ly
2017-08-29 6:20 ` Sam Bobroff
2017-08-29 13:19 ` Bryant G. Ly
2017-08-29 6:31 ` Michael Ellerman
2017-08-29 6:33 ` Michael Ellerman
2017-08-29 13:18 ` Bryant G. Ly
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).