From: Pingfan Liu <hidden> Date: 2020-02-28 09:46:01
Splitting out new_property() for coming reusing and moving it to
of_helpers.c.
Also do some coding style cleanup.
Signed-off-by: Pingfan Liu <redacted>
To: linuxppc-dev@lists.ozlabs.org
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <redacted>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Aneesh Kumar K.V <redacted>
Cc: Oliver O'Halloran <oohall@gmail.com>
Cc: Dan Williams <redacted>
Cc: Andrew Donnellan <redacted>
Cc: Christophe Leroy <redacted>
Cc: kexec@lists.infradead.org
---
arch/powerpc/platforms/pseries/of_helpers.c | 28 ++++++++++++++++++++++++++++
arch/powerpc/platforms/pseries/of_helpers.h | 3 +++
arch/powerpc/platforms/pseries/reconfig.c | 26 --------------------------
3 files changed, 31 insertions(+), 26 deletions(-)
From: Pingfan Liu <hidden> Date: 2020-02-28 09:47:54
At present, plpar_hcall(H_SCM_BIND_MEM, ...) takes a very long time, so
if dumping to fsdax, it will take a very long time.
Take a closer look, during the papr_scm initialization, the only
configuration is through drc_pmem_bind()-> plpar_hcall(H_SCM_BIND_MEM,
...), which helps to set up the bound address.
On pseries, for kexec -l/-p kernel, there is no reset of hardware, and this
step can be stepped around to save times. So the pmem bound address can be
passed to the 2nd kernel through a dynamic added property "bound-addr" in
dt node 'ibm,pmemory'.
Signed-off-by: Pingfan Liu <redacted>
To: linuxppc-dev@lists.ozlabs.org
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <redacted>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Aneesh Kumar K.V <redacted>
Cc: Oliver O'Halloran <oohall@gmail.com>
Cc: Dan Williams <redacted>
Cc: Andrew Donnellan <redacted>
Cc: Christophe Leroy <redacted>
Cc: kexec@lists.infradead.org
---
note: This patch has not been tested since I can not get such a pseries with pmem.
Please kindly to give some suggestion, thanks.
arch/powerpc/platforms/pseries/papr_scm.c | 32 +++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
@@ -383,7 +384,7 @@ static int papr_scm_probe(struct platform_device *pdev){structdevice_node*dn=pdev->dev.of_node;u32drc_index,metadata_size;-u64blocks,block_size;+u64blocks,block_size,bound_addr=0;structpapr_scm_priv*p;constchar*uuid_str;u64uuid[2];
@@ -440,17 +441,28 @@ static int papr_scm_probe(struct platform_device *pdev)p->metadata_size=metadata_size;p->pdev=pdev;-/* request the hypervisor to bind this region to somewhere in memory */-rc=drc_pmem_bind(p);+of_property_read_u64(dn,"bound-addr",&bound_addr);+if(bound_addr){+p->bound_addr=bound_addr;+}else{+structproperty*property;+u64big;-/* If phyp says drc memory still bound then force unbound and retry */-if(rc==H_OVERLAP)-rc=drc_pmem_query_n_bind(p);+/* request the hypervisor to bind this region to somewhere in memory */+rc=drc_pmem_bind(p);-if(rc!=H_SUCCESS){-dev_err(&p->pdev->dev,"bind err: %d\n",rc);-rc=-ENXIO;-gotoerr;+/* If phyp says drc memory still bound then force unbound and retry */+if(rc==H_OVERLAP)+rc=drc_pmem_query_n_bind(p);++if(rc!=H_SUCCESS){+dev_err(&p->pdev->dev,"bind err: %d\n",rc);+rc=-ENXIO;+gotoerr;+}+big=cpu_to_be64(p->bound_addr);+property=new_property("bound-addr",sizeof(u64),&big,NULL);+of_add_property(dn,property);}/* setup the resource for the newly bound range */
From: Pingfan Liu <hidden> Date: 2020-03-04 08:54:07
Splitting out new_property() for coming reusing and moving it to
of_helpers.c.
Also do some coding style cleanup.
Signed-off-by: Pingfan Liu <redacted>
To: linuxppc-dev@lists.ozlabs.org
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <redacted>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Aneesh Kumar K.V <redacted>
Cc: Oliver O'Halloran <oohall@gmail.com>
Cc: Dan Williams <redacted>
Cc: Andrew Donnellan <redacted>
Cc: Christophe Leroy <redacted>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <redacted>
Cc: kexec@lists.infradead.org
---
arch/powerpc/platforms/pseries/of_helpers.c | 28 ++++++++++++++++++++++++++++
arch/powerpc/platforms/pseries/of_helpers.h | 3 +++
arch/powerpc/platforms/pseries/reconfig.c | 26 --------------------------
3 files changed, 31 insertions(+), 26 deletions(-)
From: Pingfan Liu <hidden> Date: 2020-03-04 08:55:43
At present, plpar_hcall(H_SCM_BIND_MEM, ...) takes a very long time, so
if dumping to fsdax, it will take a very long time.
Take a closer look, during the papr_scm initialization, the only
configuration is through drc_pmem_bind()-> plpar_hcall(H_SCM_BIND_MEM,
...), which helps to set up the bound address.
On pseries, for kexec -l/-p kernel, there is no reset of hardware, and this
step can be stepped around to save times. So the pmem bound address can be
passed to the 2nd kernel through a dynamic added property "bound-addr" in
dt node 'ibm,pmemory'.
Signed-off-by: Pingfan Liu <redacted>
To: linuxppc-dev@lists.ozlabs.org
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <redacted>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Aneesh Kumar K.V <redacted>
Cc: Oliver O'Halloran <oohall@gmail.com>
Cc: Dan Williams <redacted>
Cc: Andrew Donnellan <redacted>
Cc: Christophe Leroy <redacted>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <redacted>
Cc: kexec@lists.infradead.org
---
note: This patch has not been tested since I can not get such a pseries with pmem.
Please kindly to give some suggestion, thanks.
---
arch/powerpc/platforms/pseries/of_helpers.c | 1 +
arch/powerpc/platforms/pseries/papr_scm.c | 33 ++++++++++++++++++++---------
drivers/of/base.c | 1 +
3 files changed, 25 insertions(+), 10 deletions(-)
@@ -383,7 +384,7 @@ static int papr_scm_probe(struct platform_device *pdev){structdevice_node*dn=pdev->dev.of_node;u32drc_index,metadata_size;-u64blocks,block_size;+u64blocks,block_size,bound_addr=0;structpapr_scm_priv*p;constchar*uuid_str;u64uuid[2];
@@ -440,17 +441,29 @@ static int papr_scm_probe(struct platform_device *pdev)p->metadata_size=metadata_size;p->pdev=pdev;-/* request the hypervisor to bind this region to somewhere in memory */-rc=drc_pmem_bind(p);+of_property_read_u64(dn,"bound-addr",&bound_addr);+if(bound_addr){+p->bound_addr=bound_addr;+}else{+structproperty*property;+u64big;-/* If phyp says drc memory still bound then force unbound and retry */-if(rc==H_OVERLAP)-rc=drc_pmem_query_n_bind(p);+/* request the hypervisor to bind this region to somewhere in memory */+rc=drc_pmem_bind(p);-if(rc!=H_SUCCESS){-dev_err(&p->pdev->dev,"bind err: %d\n",rc);-rc=-ENXIO;-gotoerr;+/* If phyp says drc memory still bound then force unbound and retry */+if(rc==H_OVERLAP)+rc=drc_pmem_query_n_bind(p);++if(rc!=H_SUCCESS){+dev_err(&p->pdev->dev,"bind err: %d\n",rc);+rc=-ENXIO;+gotoerr;+}+big=cpu_to_be64(p->bound_addr);+property=new_property("bound-addr",sizeof(u64),(constunsignedchar*)&big,+NULL);+of_add_property(dn,property);}/* setup the resource for the newly bound range */
From: Andrew Donnellan <hidden> Date: 2020-03-05 04:00:39
On 4/3/20 7:47 pm, Pingfan Liu wrote:
Splitting out new_property() for coming reusing and moving it to
of_helpers.c.
Also do some coding style cleanup.
Signed-off-by: Pingfan Liu <redacted>
To: linuxppc-dev@lists.ozlabs.org
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <redacted>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Aneesh Kumar K.V <redacted>
Cc: Oliver O'Halloran <oohall@gmail.com>
Cc: Dan Williams <redacted>
Cc: Andrew Donnellan <redacted>
Cc: Christophe Leroy <redacted>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <redacted>
Cc: kexec@lists.infradead.org
Would this be useful to move into generic OF code?
Also if more functions are moving into of_helpers.c perhaps there should
be a common function name prefix.
Otherwise your style cleanup looks good.
Reviewed-by: Andrew Donnellan <redacted>
--
Andrew Donnellan OzLabs, ADL Canberra
ajd@linux.ibm.com IBM Australia Limited
This function in its current form isn't suitable for more general use:
* It appears to be tailored to string properties - note the char * value
parameter, the length + 1 allocation and nul termination.
* Most code shouldn't need the 'last' argument. The code where this
currently resides builds a list of properties and attaches it to a new
node, bypassing of_add_property().
Let's look at the call site you add in your next patch:
+ big = cpu_to_be64(p->bound_addr);
+ property = new_property("bound-addr", sizeof(u64), (const unsigned char *)&big,
+ NULL);
+ of_add_property(dn, property);
So you have to use a cast, and this is going to allocate (sizeof(u64) + 1)
for the value, is that what you want?
I think you should leave that legacy pseries reconfig code undisturbed
(frankly that stuff should get deprecated and removed) and if you want a
generic helper it should look more like:
struct property *of_property_new(const char *name, size_t length,
const void *value, gfp_t allocflags)
__of_prop_dup() looks like a good model/guide here.
This function in its current form isn't suitable for more general use:
* It appears to be tailored to string properties - note the char * value
parameter, the length + 1 allocation and nul termination.
* Most code shouldn't need the 'last' argument. The code where this
currently resides builds a list of properties and attaches it to a new
node, bypassing of_add_property().
Let's look at the call site you add in your next patch:
+ big = cpu_to_be64(p->bound_addr);
+ property = new_property("bound-addr", sizeof(u64), (const unsigned char *)&big,
+ NULL);
+ of_add_property(dn, property);
So you have to use a cast, and this is going to allocate (sizeof(u64) + 1)
for the value, is that what you want?
I think you should leave that legacy pseries reconfig code undisturbed
(frankly that stuff should get deprecated and removed) and if you want a
generic helper it should look more like:
struct property *of_property_new(const char *name, size_t length,
const void *value, gfp_t allocflags)
__of_prop_dup() looks like a good model/guide here.
Thanks for your good suggestion.
I will re-code based on your suggestion, if [2/2] turns out acceptable.
Regards,
Pingfan
On Wed, Mar 4, 2020 at 7:50 PM Pingfan Liu [off-list ref] wrote:
At present, plpar_hcall(H_SCM_BIND_MEM, ...) takes a very long time, so
if dumping to fsdax, it will take a very long time.
Take a closer look, during the papr_scm initialization, the only
configuration is through drc_pmem_bind()-> plpar_hcall(H_SCM_BIND_MEM,
...), which helps to set up the bound address.
On pseries, for kexec -l/-p kernel, there is no reset of hardware, and this
step can be stepped around to save times. So the pmem bound address can be
passed to the 2nd kernel through a dynamic added property "bound-addr" in
dt node 'ibm,pmemory'.
Signed-off-by: Pingfan Liu <redacted>
To: linuxppc-dev@lists.ozlabs.org
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <redacted>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Aneesh Kumar K.V <redacted>
Cc: Oliver O'Halloran <oohall@gmail.com>
Cc: Dan Williams <redacted>
Cc: Andrew Donnellan <redacted>
Cc: Christophe Leroy <redacted>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <redacted>
Cc: kexec@lists.infradead.org
---
note: This patch has not been tested since I can not get such a pseries with pmem.
Please kindly to give some suggestion, thanks.
There was some qemu patches to implement the Hcall interface floating
around a while ago. I'm not sure they ever made it into upstream qemu
though.
@@ -383,7 +384,7 @@ static int papr_scm_probe(struct platform_device *pdev){structdevice_node*dn=pdev->dev.of_node;u32drc_index,metadata_size;-u64blocks,block_size;+u64blocks,block_size,bound_addr=0;structpapr_scm_priv*p;constchar*uuid_str;u64uuid[2];
@@ -440,17 +441,29 @@ static int papr_scm_probe(struct platform_device *pdev)p->metadata_size=metadata_size;p->pdev=pdev;-/* request the hypervisor to bind this region to somewhere in memory */-rc=drc_pmem_bind(p);+of_property_read_u64(dn,"bound-addr",&bound_addr);+if(bound_addr){+p->bound_addr=bound_addr;+}else{+structproperty*property;+u64big;-/* If phyp says drc memory still bound then force unbound and retry */-if(rc==H_OVERLAP)-rc=drc_pmem_query_n_bind(p);+/* request the hypervisor to bind this region to somewhere in memory */+rc=drc_pmem_bind(p);-if(rc!=H_SUCCESS){-dev_err(&p->pdev->dev,"bind err: %d\n",rc);-rc=-ENXIO;-gotoerr;+/* If phyp says drc memory still bound then force unbound and retry */+if(rc==H_OVERLAP)+rc=drc_pmem_query_n_bind(p);++if(rc!=H_SUCCESS){+dev_err(&p->pdev->dev,"bind err: %d\n",rc);+rc=-ENXIO;+gotoerr;+}+big=cpu_to_be64(p->bound_addr);+property=new_property("bound-addr",sizeof(u64),(constunsignedchar*)&big,+NULL);
That should probably be "linux,bound-addr"
The other thing that stands out to me is that you aren't removing the
property when the region is unbound. As a general rule I'd prefer we
didn't hack the DT at runtime, but if we are going to then we should
make sure we're not putting anything wrong in there.
quoted hunk
+ of_add_property(dn, property);
}
/* setup the resource for the newly bound range */
From: Pingfan Liu <hidden> Date: 2020-03-16 02:55:31
Appreciate for your kind review. And I have some comment as below.
On Fri, Mar 13, 2020 at 11:18 AM Oliver O'Halloran [off-list ref] wrote:
On Wed, Mar 4, 2020 at 7:50 PM Pingfan Liu [off-list ref] wrote:
quoted
At present, plpar_hcall(H_SCM_BIND_MEM, ...) takes a very long time, so
if dumping to fsdax, it will take a very long time.
Take a closer look, during the papr_scm initialization, the only
configuration is through drc_pmem_bind()-> plpar_hcall(H_SCM_BIND_MEM,
...), which helps to set up the bound address.
On pseries, for kexec -l/-p kernel, there is no reset of hardware, and this
step can be stepped around to save times. So the pmem bound address can be
passed to the 2nd kernel through a dynamic added property "bound-addr" in
dt node 'ibm,pmemory'.
Signed-off-by: Pingfan Liu <redacted>
To: linuxppc-dev@lists.ozlabs.org
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <redacted>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Aneesh Kumar K.V <redacted>
Cc: Oliver O'Halloran <oohall@gmail.com>
Cc: Dan Williams <redacted>
Cc: Andrew Donnellan <redacted>
Cc: Christophe Leroy <redacted>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <redacted>
Cc: kexec@lists.infradead.org
---
note: This patch has not been tested since I can not get such a pseries with pmem.
Please kindly to give some suggestion, thanks.
There was some qemu patches to implement the Hcall interface floating
around a while ago. I'm not sure they ever made it into upstream qemu
though.
Unfortunately, it does not appear in latest qemu code. I think
probably virt-pmem has achieved the same feature.
@@ -383,7 +384,7 @@ static int papr_scm_probe(struct platform_device *pdev){structdevice_node*dn=pdev->dev.of_node;u32drc_index,metadata_size;-u64blocks,block_size;+u64blocks,block_size,bound_addr=0;structpapr_scm_priv*p;constchar*uuid_str;u64uuid[2];
@@ -440,17 +441,29 @@ static int papr_scm_probe(struct platform_device *pdev)p->metadata_size=metadata_size;p->pdev=pdev;-/* request the hypervisor to bind this region to somewhere in memory */-rc=drc_pmem_bind(p);+of_property_read_u64(dn,"bound-addr",&bound_addr);+if(bound_addr){+p->bound_addr=bound_addr;+}else{+structproperty*property;+u64big;-/* If phyp says drc memory still bound then force unbound and retry */-if(rc==H_OVERLAP)-rc=drc_pmem_query_n_bind(p);+/* request the hypervisor to bind this region to somewhere in memory */+rc=drc_pmem_bind(p);-if(rc!=H_SUCCESS){-dev_err(&p->pdev->dev,"bind err: %d\n",rc);-rc=-ENXIO;-gotoerr;+/* If phyp says drc memory still bound then force unbound and retry */+if(rc==H_OVERLAP)+rc=drc_pmem_query_n_bind(p);++if(rc!=H_SUCCESS){+dev_err(&p->pdev->dev,"bind err: %d\n",rc);+rc=-ENXIO;+gotoerr;+}+big=cpu_to_be64(p->bound_addr);+property=new_property("bound-addr",sizeof(u64),(constunsignedchar*)&big,+NULL);
That should probably be "linux,bound-addr"
OK, thanks for suggestion.
The other thing that stands out to me is that you aren't removing the
Yes, you are right. I will fix it in V2.
property when the region is unbound. As a general rule I'd prefer we
didn't hack the DT at runtime, but if we are going to then we should
make sure we're not putting anything wrong in there.
Actually, the dynamically building of DT is widely used by "kexec -l".
The pre-condition for the hacked method is that the bound pmem-addr
will not change. And on pseries, during kexec -l/-p, a machine reset
will not be invoked, so the bound address should be changed.
Thanks,
Pingfan
[...]
At present, plpar_hcall(H_SCM_BIND_MEM, ...) takes a very long time, so
if dumping to fsdax, it will take a very long time.
that should be fixed by
faa6d21153fd11e139dd880044521389b34a24f2
Author: Aneesh Kumar K.V [off-list ref]
AuthorDate: Tue Sep 3 18:04:52 2019 +0530
Commit: Michael Ellerman [off-list ref]
CommitDate: Wed Sep 25 08:32:59 2019 +1000
powerpc/nvdimm: use H_SCM_QUERY hcall on H_OVERLAP error
Right now we force an unbind of SCM memory at drcindex on H_OVERLAP error.
This really slows down operations like kexec where we get the H_OVERLAP
error because we don't go through a full hypervisor re init.
H_OVERLAP error for a H_SCM_BIND_MEM hcall indicates that SCM memory at
drc index is already bound. Since we don't specify a logical memory
address for bind hcall, we can use the H_SCM_QUERY hcall to query
the already bound logical address.
Take a closer look, during the papr_scm initialization, the only
configuration is through drc_pmem_bind()-> plpar_hcall(H_SCM_BIND_MEM,
...), which helps to set up the bound address.
On pseries, for kexec -l/-p kernel, there is no reset of hardware, and this
step can be stepped around to save times. So the pmem bound address can be
passed to the 2nd kernel through a dynamic added property "bound-addr" in
dt node 'ibm,pmemory'.
From: Pingfan Liu <hidden> Date: 2020-03-16 08:40:03
On Mon, Mar 16, 2020 at 10:53 AM Aneesh Kumar K.V
[off-list ref] wrote:
On 3/4/20 2:17 PM, Pingfan Liu wrote:
quoted
At present, plpar_hcall(H_SCM_BIND_MEM, ...) takes a very long time, so
if dumping to fsdax, it will take a very long time.
that should be fixed by
faa6d21153fd11e139dd880044521389b34a24f2
Author: Aneesh Kumar K.V [off-list ref]
AuthorDate: Tue Sep 3 18:04:52 2019 +0530
Commit: Michael Ellerman [off-list ref]
CommitDate: Wed Sep 25 08:32:59 2019 +1000
powerpc/nvdimm: use H_SCM_QUERY hcall on H_OVERLAP error
Right now we force an unbind of SCM memory at drcindex on H_OVERLAP error.
This really slows down operations like kexec where we get the H_OVERLAP
error because we don't go through a full hypervisor re init.
H_OVERLAP error for a H_SCM_BIND_MEM hcall indicates that SCM memory at
drc index is already bound. Since we don't specify a logical memory
address for bind hcall, we can use the H_SCM_QUERY hcall to query
the already bound logical address.
Good to know it.
Thanks,
Pingfan
quoted
Take a closer look, during the papr_scm initialization, the only
configuration is through drc_pmem_bind()-> plpar_hcall(H_SCM_BIND_MEM,
...), which helps to set up the bound address.
On pseries, for kexec -l/-p kernel, there is no reset of hardware, and this
step can be stepped around to save times. So the pmem bound address can be
passed to the 2nd kernel through a dynamic added property "bound-addr" in
dt node 'ibm,pmemory'.