From: "Oliver O'Halloran" <oohall@gmail.com>
To: Pingfan Liu <kernelfans@gmail.com>
Cc: Andrew Donnellan <ajd@linux.ibm.com>,
Frank Rowand <frowand.list@gmail.com>,
kexec@lists.infradead.org, Rob Herring <robh+dt@kernel.org>,
Paul Mackerras <paulus@samba.org>,
"Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>,
Dan Williams <dan.j.williams@intel.com>,
linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
Hari Bathini <hbathini@linux.ibm.com>
Subject: Re: [PATCHv3 2/2] pseries/scm: buffer pmem's bound addr in dt for kexec kernel
Date: Fri, 13 Mar 2020 14:17:50 +1100 [thread overview]
Message-ID: <CAOSf1CG5VPasqhuVDPnm58mjgGkN7isJt_UCwdb7pwAip8K2aQ@mail.gmail.com> (raw)
In-Reply-To: <1583311651-29310-3-git-send-email-kernelfans@gmail.com>
On Wed, Mar 4, 2020 at 7:50 PM Pingfan Liu <kernelfans@gmail.com> 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 <kernelfans@gmail.com>
> To: linuxppc-dev@lists.ozlabs.org
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Hari Bathini <hbathini@linux.ibm.com>
> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> Cc: Oliver O'Halloran <oohall@gmail.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Andrew Donnellan <ajd@linux.ibm.com>
> Cc: Christophe Leroy <christophe.leroy@c-s.fr>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> 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.
> ---
> 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(-)
>
> diff --git a/arch/powerpc/platforms/pseries/of_helpers.c b/arch/powerpc/platforms/pseries/of_helpers.c
> index 1022e0f..2c7bab4 100644
> --- a/arch/powerpc/platforms/pseries/of_helpers.c
> +++ b/arch/powerpc/platforms/pseries/of_helpers.c
> @@ -34,6 +34,7 @@ struct property *new_property(const char *name, const int length,
> kfree(new);
> return NULL;
> }
> +EXPORT_SYMBOL(new_property);
>
> /**
> * pseries_of_derive_parent - basically like dirname(1)
> diff --git a/arch/powerpc/platforms/pseries/papr_scm.c b/arch/powerpc/platforms/pseries/papr_scm.c
> index 0b4467e..54ae903 100644
> --- a/arch/powerpc/platforms/pseries/papr_scm.c
> +++ b/arch/powerpc/platforms/pseries/papr_scm.c
> @@ -14,6 +14,7 @@
> #include <linux/delay.h>
>
> #include <asm/plpar_wrappers.h>
> +#include "of_helpers.h"
>
> #define BIND_ANY_ADDR (~0ul)
>
> @@ -383,7 +384,7 @@ static int papr_scm_probe(struct platform_device *pdev)
> {
> struct device_node *dn = pdev->dev.of_node;
> u32 drc_index, metadata_size;
> - u64 blocks, block_size;
> + u64 blocks, block_size, bound_addr = 0;
> struct papr_scm_priv *p;
> const char *uuid_str;
> u64 uuid[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 {
> + struct property *property;
> + u64 big;
>
> - /* 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;
> - goto err;
> + /* 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;
> + goto err;
> + }
> + big = cpu_to_be64(p->bound_addr);
> + property = new_property("bound-addr", sizeof(u64), (const unsigned char *)&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.
> + of_add_property(dn, property);
> }
>
> /* setup the resource for the newly bound range */
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index ae03b12..602d2a9 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -1817,6 +1817,7 @@ int of_add_property(struct device_node *np, struct property *prop)
>
> return rc;
> }
> +EXPORT_SYMBOL_GPL(of_add_property);
>
> int __of_remove_property(struct device_node *np, struct property *prop)
> {
> --
> 2.7.5
>
next prev parent reply other threads:[~2020-03-13 3:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-28 9:41 [PATCHv2 1/2] powerpc/of: split out new_property() for reusing Pingfan Liu
2020-02-28 9:41 ` [PATCHv2 2/2] pSeries/papr_scm: buffer pmem's bound addr in dt for kexec kernel Pingfan Liu
2020-03-04 8:47 ` [PATCHv3 0/2] pseries/scm: " Pingfan Liu
2020-03-04 8:47 ` [PATCHv3 1/2] powerpc/of: split out new_property() for reusing Pingfan Liu
2020-03-05 3:58 ` Andrew Donnellan
2020-03-06 19:59 ` Nathan Lynch
2020-03-09 1:50 ` Pingfan Liu
2020-03-04 8:47 ` [PATCHv3 2/2] pseries/scm: buffer pmem's bound addr in dt for kexec kernel Pingfan Liu
2020-03-13 3:17 ` Oliver O'Halloran [this message]
2020-03-16 2:49 ` Pingfan Liu
2020-03-16 2:53 ` Aneesh Kumar K.V
2020-03-16 8:37 ` Pingfan Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOSf1CG5VPasqhuVDPnm58mjgGkN7isJt_UCwdb7pwAip8K2aQ@mail.gmail.com \
--to=oohall@gmail.com \
--cc=ajd@linux.ibm.com \
--cc=aneesh.kumar@linux.ibm.com \
--cc=dan.j.williams@intel.com \
--cc=frowand.list@gmail.com \
--cc=hbathini@linux.ibm.com \
--cc=kernelfans@gmail.com \
--cc=kexec@lists.infradead.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=paulus@samba.org \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).