From: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au
Cc: Nathan Lynch <nathanl@linux.ibm.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
Hari Bathini <hbathini@linux.ibm.com>
Subject: [RFC PATCH] powerpc/drmem: use global variable instead of fetching again
Date: Thu, 6 Aug 2020 18:22:00 +0530 [thread overview]
Message-ID: <20200806125200.252403-1-aneesh.kumar@linux.ibm.com> (raw)
In-Reply-To: <20200806123604.248361-1-aneesh.kumar@linux.ibm.com>
use mem_addr_cells/mem_size_cells instead of fetching the values
again from device tree.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/mm/drmem.c | 24 ++++++------------------
1 file changed, 6 insertions(+), 18 deletions(-)
diff --git a/arch/powerpc/mm/drmem.c b/arch/powerpc/mm/drmem.c
index b2eeea39684c..f533a7b04ab9 100644
--- a/arch/powerpc/mm/drmem.c
+++ b/arch/powerpc/mm/drmem.c
@@ -14,8 +14,6 @@
#include <asm/prom.h>
#include <asm/drmem.h>
-static int n_root_addr_cells, n_root_size_cells;
-
static struct drmem_lmb_info __drmem_info;
struct drmem_lmb_info *drmem_info = &__drmem_info;
@@ -196,8 +194,8 @@ static void read_drconf_v1_cell(struct drmem_lmb *lmb,
{
const __be32 *p = *prop;
- lmb->base_addr = of_read_number(p, n_root_addr_cells);
- p += n_root_addr_cells;
+ lmb->base_addr = of_read_number(p, mem_addr_cells);
+ p += mem_addr_cells;
lmb->drc_index = of_read_number(p++, 1);
p++; /* skip reserved field */
@@ -233,8 +231,8 @@ static void read_drconf_v2_cell(struct of_drconf_cell_v2 *dr_cell,
const __be32 *p = *prop;
dr_cell->seq_lmbs = of_read_number(p++, 1);
- dr_cell->base_addr = of_read_number(p, n_root_addr_cells);
- p += n_root_addr_cells;
+ dr_cell->base_addr = of_read_number(p, mem_addr_cells);
+ p += mem_addr_cells;
dr_cell->drc_index = of_read_number(p++, 1);
dr_cell->aa_index = of_read_number(p++, 1);
dr_cell->flags = of_read_number(p++, 1);
@@ -285,10 +283,6 @@ int __init walk_drmem_lmbs_early(unsigned long node, void *data,
if (!prop || len < dt_root_size_cells * sizeof(__be32))
return ret;
- /* Get the address & size cells */
- n_root_addr_cells = dt_root_addr_cells;
- n_root_size_cells = dt_root_size_cells;
-
drmem_info->lmb_size = dt_mem_next_cell(dt_root_size_cells, &prop);
usm = of_get_flat_dt_prop(node, "linux,drconf-usable-memory", &len);
@@ -318,12 +312,12 @@ static int init_drmem_lmb_size(struct device_node *dn)
return 0;
prop = of_get_property(dn, "ibm,lmb-size", &len);
- if (!prop || len < n_root_size_cells * sizeof(__be32)) {
+ if (!prop || len < mem_size_cells * sizeof(__be32)) {
pr_info("Could not determine LMB size\n");
return -1;
}
- drmem_info->lmb_size = of_read_number(prop, n_root_size_cells);
+ drmem_info->lmb_size = of_read_number(prop, mem_size_cells);
return 0;
}
@@ -353,12 +347,6 @@ int walk_drmem_lmbs(struct device_node *dn, void *data,
if (!of_root)
return ret;
- /* Get the address & size cells */
- of_node_get(of_root);
- n_root_addr_cells = of_n_addr_cells(of_root);
- n_root_size_cells = of_n_size_cells(of_root);
- of_node_put(of_root);
-
if (init_drmem_lmb_size(dn))
return ret;
--
2.26.2
next prev parent reply other threads:[~2020-08-06 13:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-06 12:36 [RFC PATCH 1/3] powerpc/mem: Store the dt_root_size/addr cell values for later usage Aneesh Kumar K.V
2020-08-06 12:36 ` [RFC PATCH 2/3] powerpc/numa: Use global variable instead of fetching again Aneesh Kumar K.V
2020-08-06 12:36 ` [RFC PATCH 3/3] powerpc/lmb-size: Use addr #size-cells value when fetching lmb-size Aneesh Kumar K.V
2020-08-06 12:52 ` Aneesh Kumar K.V [this message]
2020-08-17 17:31 ` [RFC PATCH] powerpc/drmem: use global variable instead of fetching again Hari Bathini
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=20200806125200.252403-1-aneesh.kumar@linux.ibm.com \
--to=aneesh.kumar@linux.ibm.com \
--cc=hbathini@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=nathanl@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