From: Laurent Dufour <ldufour@linux.ibm.com>
To: Sourabh Jain <sourabhjain@linux.ibm.com>,
linuxppc-dev@ozlabs.org, mpe@ellerman.id.au
Cc: mahesh@linux.vnet.ibm.com, eric.devolder@oracle.com,
kexec@lists.infradead.org, bhe@redhat.com,
hbathini@linux.ibm.com
Subject: Re: [PATCH v5 1/5] powerpc/kexec: make update_cpus_node non-static
Date: Tue, 21 Jun 2022 10:59:09 +0200 [thread overview]
Message-ID: <2df3da07-9384-d8b2-15f5-b124538b93c2@linux.ibm.com> (raw)
In-Reply-To: <20220620070106.93141-2-sourabhjain@linux.ibm.com>
On 20/06/2022, 09:01:02, Sourabh Jain wrote:
> Make the update_cpus_node function non-static and export it for
> usage in other kexec components.
>
> The update_cpus_node definition is moved to core_64.c so that it
> can be used with both kexec_load and kexec_file_load system calls.
>
> No functional change intended.
And FWIW
Reviewed-by: Laurent Dufour <laurent.dufour@fr.ibm.com>
>
> Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
> ---
> arch/powerpc/include/asm/kexec.h | 1 +
> arch/powerpc/kexec/core_64.c | 88 +++++++++++++++++++++++++++++++
> arch/powerpc/kexec/file_load_64.c | 87 ------------------------------
> 3 files changed, 89 insertions(+), 87 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h
> index 2aefe14e1442..c8040c93b15a 100644
> --- a/arch/powerpc/include/asm/kexec.h
> +++ b/arch/powerpc/include/asm/kexec.h
> @@ -129,6 +129,7 @@ unsigned int kexec_extra_fdt_size_ppc64(struct kimage *image);
> int setup_new_fdt_ppc64(const struct kimage *image, void *fdt,
> unsigned long initrd_load_addr,
> unsigned long initrd_len, const char *cmdline);
> +int update_cpus_node(void *fdt);
> #endif /* CONFIG_PPC64 */
>
> #endif /* CONFIG_KEXEC_FILE */
> diff --git a/arch/powerpc/kexec/core_64.c b/arch/powerpc/kexec/core_64.c
> index 6cc7793b8420..65b3afb2169a 100644
> --- a/arch/powerpc/kexec/core_64.c
> +++ b/arch/powerpc/kexec/core_64.c
> @@ -16,6 +16,7 @@
> #include <linux/kernel.h>
> #include <linux/cpu.h>
> #include <linux/hardirq.h>
> +#include <linux/libfdt.h>
>
> #include <asm/page.h>
> #include <asm/current.h>
> @@ -377,6 +378,93 @@ void default_machine_kexec(struct kimage *image)
> /* NOTREACHED */
> }
>
> +/**
> + * add_node_props - Reads node properties from device node structure and add
> + * them to fdt.
> + * @fdt: Flattened device tree of the kernel
> + * @node_offset: offset of the node to add a property at
> + * @dn: device node pointer
> + *
> + * Returns 0 on success, negative errno on error.
> + */
> +static int add_node_props(void *fdt, int node_offset, const struct device_node *dn)
> +{
> + int ret = 0;
> + struct property *pp;
> +
> + if (!dn)
> + return -EINVAL;
> +
> + for_each_property_of_node(dn, pp) {
> + ret = fdt_setprop(fdt, node_offset, pp->name, pp->value, pp->length);
> + if (ret < 0) {
> + pr_err("Unable to add %s property: %s\n", pp->name, fdt_strerror(ret));
> + return ret;
> + }
> + }
> + return ret;
> +}
> +
> +/**
> + * update_cpus_node - Update cpus node of flattened device tree using of_root
> + * device node.
> + * @fdt: Flattened device tree of the kernel.
> + *
> + * Returns 0 on success, negative errno on error.
> + */
> +int update_cpus_node(void *fdt)
> +{
> + struct device_node *cpus_node, *dn;
> + int cpus_offset, cpus_subnode_offset, ret = 0;
> +
> + cpus_offset = fdt_path_offset(fdt, "/cpus");
> + if (cpus_offset < 0 && cpus_offset != -FDT_ERR_NOTFOUND) {
> + pr_err("Malformed device tree: error reading /cpus node: %s\n",
> + fdt_strerror(cpus_offset));
> + return cpus_offset;
> + }
> +
> + if (cpus_offset > 0) {
> + ret = fdt_del_node(fdt, cpus_offset);
> + if (ret < 0) {
> + pr_err("Error deleting /cpus node: %s\n", fdt_strerror(ret));
> + return -EINVAL;
> + }
> + }
> +
> + /* Add cpus node to fdt */
> + cpus_offset = fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"), "cpus");
> + if (cpus_offset < 0) {
> + pr_err("Error creating /cpus node: %s\n", fdt_strerror(cpus_offset));
> + return -EINVAL;
> + }
> +
> + /* Add cpus node properties */
> + cpus_node = of_find_node_by_path("/cpus");
> + ret = add_node_props(fdt, cpus_offset, cpus_node);
> + of_node_put(cpus_node);
> + if (ret < 0)
> + return ret;
> +
> + /* Loop through all subnodes of cpus and add them to fdt */
> + for_each_node_by_type(dn, "cpu") {
> + cpus_subnode_offset = fdt_add_subnode(fdt, cpus_offset, dn->full_name);
> + if (cpus_subnode_offset < 0) {
> + pr_err("Unable to add %s subnode: %s\n", dn->full_name,
> + fdt_strerror(cpus_subnode_offset));
> + ret = cpus_subnode_offset;
> + goto out;
> + }
> +
> + ret = add_node_props(fdt, cpus_subnode_offset, dn);
> + if (ret < 0)
> + goto out;
> + }
> +out:
> + of_node_put(dn);
> + return ret;
> +}
> +
> #ifdef CONFIG_PPC_64S_HASH_MMU
> /* Values we need to export to the second kernel via the device tree. */
> static unsigned long htab_base;
> diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
> index 07da6bf1cf24..57f991b0a9da 100644
> --- a/arch/powerpc/kexec/file_load_64.c
> +++ b/arch/powerpc/kexec/file_load_64.c
> @@ -951,93 +951,6 @@ unsigned int kexec_extra_fdt_size_ppc64(struct kimage *image)
> return (unsigned int)(usm_entries * sizeof(u64));
> }
>
> -/**
> - * add_node_props - Reads node properties from device node structure and add
> - * them to fdt.
> - * @fdt: Flattened device tree of the kernel
> - * @node_offset: offset of the node to add a property at
> - * @dn: device node pointer
> - *
> - * Returns 0 on success, negative errno on error.
> - */
> -static int add_node_props(void *fdt, int node_offset, const struct device_node *dn)
> -{
> - int ret = 0;
> - struct property *pp;
> -
> - if (!dn)
> - return -EINVAL;
> -
> - for_each_property_of_node(dn, pp) {
> - ret = fdt_setprop(fdt, node_offset, pp->name, pp->value, pp->length);
> - if (ret < 0) {
> - pr_err("Unable to add %s property: %s\n", pp->name, fdt_strerror(ret));
> - return ret;
> - }
> - }
> - return ret;
> -}
> -
> -/**
> - * update_cpus_node - Update cpus node of flattened device tree using of_root
> - * device node.
> - * @fdt: Flattened device tree of the kernel.
> - *
> - * Returns 0 on success, negative errno on error.
> - */
> -static int update_cpus_node(void *fdt)
> -{
> - struct device_node *cpus_node, *dn;
> - int cpus_offset, cpus_subnode_offset, ret = 0;
> -
> - cpus_offset = fdt_path_offset(fdt, "/cpus");
> - if (cpus_offset < 0 && cpus_offset != -FDT_ERR_NOTFOUND) {
> - pr_err("Malformed device tree: error reading /cpus node: %s\n",
> - fdt_strerror(cpus_offset));
> - return cpus_offset;
> - }
> -
> - if (cpus_offset > 0) {
> - ret = fdt_del_node(fdt, cpus_offset);
> - if (ret < 0) {
> - pr_err("Error deleting /cpus node: %s\n", fdt_strerror(ret));
> - return -EINVAL;
> - }
> - }
> -
> - /* Add cpus node to fdt */
> - cpus_offset = fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"), "cpus");
> - if (cpus_offset < 0) {
> - pr_err("Error creating /cpus node: %s\n", fdt_strerror(cpus_offset));
> - return -EINVAL;
> - }
> -
> - /* Add cpus node properties */
> - cpus_node = of_find_node_by_path("/cpus");
> - ret = add_node_props(fdt, cpus_offset, cpus_node);
> - of_node_put(cpus_node);
> - if (ret < 0)
> - return ret;
> -
> - /* Loop through all subnodes of cpus and add them to fdt */
> - for_each_node_by_type(dn, "cpu") {
> - cpus_subnode_offset = fdt_add_subnode(fdt, cpus_offset, dn->full_name);
> - if (cpus_subnode_offset < 0) {
> - pr_err("Unable to add %s subnode: %s\n", dn->full_name,
> - fdt_strerror(cpus_subnode_offset));
> - ret = cpus_subnode_offset;
> - goto out;
> - }
> -
> - ret = add_node_props(fdt, cpus_subnode_offset, dn);
> - if (ret < 0)
> - goto out;
> - }
> -out:
> - of_node_put(dn);
> - return ret;
> -}
> -
> /**
> * setup_new_fdt_ppc64 - Update the flattend device-tree of the kernel
> * being loaded.
next prev parent reply other threads:[~2022-06-21 9:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-20 7:01 [PATCH v5 0/5] In kernel handling of CPU hotplug events for crash kernel Sourabh Jain
2022-06-20 7:01 ` [PATCH v5 1/5] powerpc/kexec: make update_cpus_node non-static Sourabh Jain
2022-06-21 8:59 ` Laurent Dufour [this message]
2022-06-22 8:40 ` Sourabh Jain
2022-06-20 7:01 ` [PATCH v5 2/5] powerpc/crash hp: update kimage_arch struct Sourabh Jain
2022-06-20 7:01 ` [PATCH v5 3/5] powerpc/crash hp: add crash hotplug support for kexec_file_load Sourabh Jain
2022-06-22 15:11 ` Laurent Dufour
2022-06-20 7:01 ` [PATCH v5 4/5] powerpc/crash hp: add crash hotplug support for kexec_load Sourabh Jain
2022-06-22 15:25 ` Laurent Dufour
2022-06-20 7:01 ` [PATCH v5 5/5] powerpc/crash hp: add crash page helper functions Sourabh Jain
2022-06-22 15:33 ` Laurent Dufour
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=2df3da07-9384-d8b2-15f5-b124538b93c2@linux.ibm.com \
--to=ldufour@linux.ibm.com \
--cc=bhe@redhat.com \
--cc=eric.devolder@oracle.com \
--cc=hbathini@linux.ibm.com \
--cc=kexec@lists.infradead.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=mahesh@linux.vnet.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=sourabhjain@linux.ibm.com \
/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).