* [PATCH] powerpc/powernv: retrieve m64_bar_idx from device node
@ 2015-10-21 7:17 Wei Yang
2015-10-21 7:52 ` Michael Ellerman
0 siblings, 1 reply; 3+ messages in thread
From: Wei Yang @ 2015-10-21 7:17 UTC (permalink / raw)
To: aik, benh; +Cc: linuxppc-dev, Wei Yang
Count of M64 BAR would differ with the evolution of hardware.
This patch retieves this count from device node instead of a hard coded
value.
Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 5c65d8f..4635d25 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -368,6 +368,7 @@ static void __init pnv_ioda_parse_m64_window(struct pnv_phb *phb)
struct resource *res;
const u32 *r;
u64 pci_addr;
+ const __be32 *prop32;
/* FIXME: Support M64 for P7IOC */
if (phb->type != PNV_PHB_IODA2) {
@@ -402,7 +403,11 @@ static void __init pnv_ioda_parse_m64_window(struct pnv_phb *phb)
res->start, res->end, pci_addr);
/* Use last M64 BAR to cover M64 window */
- phb->ioda.m64_bar_idx = 15;
+ prop32 = of_get_property(dn, "ibm,opal-m64-count", NULL);
+ if (prop32)
+ phb->ioda.m64_bar_idx = be32_to_cpup(prop32) - 1;
+ else
+ phb->ioda.m64_bar_idx = 15;
phb->init_m64 = pnv_ioda2_init_m64;
phb->reserve_m64_pe = pnv_ioda2_reserve_m64_pe;
phb->pick_m64_pe = pnv_ioda2_pick_m64_pe;
--
2.5.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] powerpc/powernv: retrieve m64_bar_idx from device node
2015-10-21 7:17 [PATCH] powerpc/powernv: retrieve m64_bar_idx from device node Wei Yang
@ 2015-10-21 7:52 ` Michael Ellerman
2015-10-21 8:20 ` Wei Yang
0 siblings, 1 reply; 3+ messages in thread
From: Michael Ellerman @ 2015-10-21 7:52 UTC (permalink / raw)
To: Wei Yang, aik, benh; +Cc: linuxppc-dev
On Wed, 2015-10-21 at 15:17 +0800, Wei Yang wrote:
> Count of M64 BAR would differ with the evolution of hardware.
>
> This patch retieves this count from device node instead of a hard coded
> value.
>
> Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
> ---
> arch/powerpc/platforms/powernv/pci-ioda.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index 5c65d8f..4635d25 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -368,6 +368,7 @@ static void __init pnv_ioda_parse_m64_window(struct pnv_phb *phb)
> struct resource *res;
> const u32 *r;
> u64 pci_addr;
> + const __be32 *prop32;
>
> /* FIXME: Support M64 for P7IOC */
> if (phb->type != PNV_PHB_IODA2) {
> @@ -402,7 +403,11 @@ static void __init pnv_ioda_parse_m64_window(struct pnv_phb *phb)
> res->start, res->end, pci_addr);
>
> /* Use last M64 BAR to cover M64 window */
> - phb->ioda.m64_bar_idx = 15;
> + prop32 = of_get_property(dn, "ibm,opal-m64-count", NULL);
> + if (prop32)
> + phb->ioda.m64_bar_idx = be32_to_cpup(prop32) - 1;
> + else
> + phb->ioda.m64_bar_idx = 15;
Please use of_property_read_u32() instead of using of_get_property() directly.
Also the "-1" is a bit unclear, I think it would be clearer if you did
something like:
if (of_property_read_u32(dn, "ibm,opal-m64-count", &count))
count = 16;
/* Use last M64 BAR to cover M64 window */
phb->ioda.m64_bar_idx = count - 1;
cheers
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] powerpc/powernv: retrieve m64_bar_idx from device node
2015-10-21 7:52 ` Michael Ellerman
@ 2015-10-21 8:20 ` Wei Yang
0 siblings, 0 replies; 3+ messages in thread
From: Wei Yang @ 2015-10-21 8:20 UTC (permalink / raw)
To: Michael Ellerman; +Cc: Wei Yang, aik, benh, linuxppc-dev
On Wed, Oct 21, 2015 at 06:52:51PM +1100, Michael Ellerman wrote:
>On Wed, 2015-10-21 at 15:17 +0800, Wei Yang wrote:
>
>> Count of M64 BAR would differ with the evolution of hardware.
>>
>> This patch retieves this count from device node instead of a hard coded
>> value.
>>
>> Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
>> ---
>> arch/powerpc/platforms/powernv/pci-ioda.c | 7 ++++++-
>> 1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
>> index 5c65d8f..4635d25 100644
>> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
>> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
>> @@ -368,6 +368,7 @@ static void __init pnv_ioda_parse_m64_window(struct pnv_phb *phb)
>> struct resource *res;
>> const u32 *r;
>> u64 pci_addr;
>> + const __be32 *prop32;
>>
>> /* FIXME: Support M64 for P7IOC */
>> if (phb->type != PNV_PHB_IODA2) {
>> @@ -402,7 +403,11 @@ static void __init pnv_ioda_parse_m64_window(struct pnv_phb *phb)
>> res->start, res->end, pci_addr);
>>
>> /* Use last M64 BAR to cover M64 window */
>> - phb->ioda.m64_bar_idx = 15;
>> + prop32 = of_get_property(dn, "ibm,opal-m64-count", NULL);
>> + if (prop32)
>> + phb->ioda.m64_bar_idx = be32_to_cpup(prop32) - 1;
>> + else
>> + phb->ioda.m64_bar_idx = 15;
>
>Please use of_property_read_u32() instead of using of_get_property() directly.
>
>Also the "-1" is a bit unclear, I think it would be clearer if you did
>something like:
>
> if (of_property_read_u32(dn, "ibm,opal-m64-count", &count))
> count = 16;
>
> /* Use last M64 BAR to cover M64 window */
> phb->ioda.m64_bar_idx = count - 1;
>
Ok, thanks for the suggestion :-)
>
>cheers
--
Richard Yang
Help you, Help me
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-10-21 8:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-21 7:17 [PATCH] powerpc/powernv: retrieve m64_bar_idx from device node Wei Yang
2015-10-21 7:52 ` Michael Ellerman
2015-10-21 8:20 ` Wei Yang
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).