From: Jiaxun Yang <jiaxun.yang@flygoat.com>
To: linux-mips@vger.kernel.org
Cc: paul.burton@mips.com, yasha.che3@gmail.com, aurelien@aurel32.net,
sfr@canb.auug.org.au, fancer.lancer@gmail.com,
matt.redfearn@mips.com, chenhc@lemote.com,
Jiaxun Yang <jiaxun.yang@flygoat.com>
Subject: [PATCH v1 7/8] MIPS: mm: Drop boot_mem_map
Date: Mon, 19 Aug 2019 22:23:12 +0800 [thread overview]
Message-ID: <20190819142313.3535-8-jiaxun.yang@flygoat.com> (raw)
In-Reply-To: <20190819142313.3535-1-jiaxun.yang@flygoat.com>
Initialize maar by resource map and replace page_is_ram
by memblock_is_memory.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
arch/mips/include/asm/maar.h | 8 +++-
arch/mips/mm/init.c | 82 ++++++++++++++----------------------
2 files changed, 38 insertions(+), 52 deletions(-)
diff --git a/arch/mips/include/asm/maar.h b/arch/mips/include/asm/maar.h
index 6908b93c4ff9..8caa2512d504 100644
--- a/arch/mips/include/asm/maar.h
+++ b/arch/mips/include/asm/maar.h
@@ -78,6 +78,7 @@ extern void maar_init(void);
* aligned to one byte before a 2^16 byte boundary.
* @attrs: The accessibility attributes to program, eg. MIPS_MAAR_S. The
* MIPS_MAAR_VL attribute will automatically be set.
+ * @used: Determine if the config entry is used.
*
* Describes the configuration of a pair of Memory Accessibility Attribute
* Registers - applying attributes from attrs to the range of physical
@@ -87,7 +88,9 @@ struct maar_config {
phys_addr_t lower;
phys_addr_t upper;
unsigned attrs;
+ bool used;
};
+#define MAX_MAAR_CONFIGS 32
/**
* maar_config() - configure MAARs according to provided data
@@ -105,8 +108,11 @@ static inline unsigned maar_config(const struct maar_config *cfg,
{
unsigned i;
- for (i = 0; i < min(num_cfg, num_pairs); i++)
+ for (i = 0; i < num_cfg; i++) {
+ if (!cfg[i].used)
+ continue;
write_maar_pair(i, cfg[i].lower, cfg[i].upper, cfg[i].attrs);
+ }
return i;
}
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 8a038b30d3c4..5b89bdebb3ab 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -269,31 +269,39 @@ void __init fixrange_init(unsigned long start, unsigned long end,
#endif
}
-unsigned __weak platform_maar_init(unsigned num_pairs)
+static int maar_res_walk(unsigned long start, unsigned long nr_pages,
+ void *data)
{
- struct maar_config cfg[BOOT_MEM_MAP_MAX];
- unsigned i, num_configured, num_cfg = 0;
-
- for (i = 0; i < boot_mem_map.nr_map; i++) {
- switch (boot_mem_map.map[i].type) {
- case BOOT_MEM_RAM:
- case BOOT_MEM_INIT_RAM:
- break;
- default:
+ struct maar_config *cfg = (struct maar_config *)data;
+ int i;
+
+ /* Find next free config entry and fill from res */
+ for (i = 0; i < MAX_MAAR_CONFIGS; i++) {
+ if (cfg->used)
continue;
- }
+ cfg->used = true;
+ cfg->lower = PFN_DOWN(start);
+ cfg->lower = (cfg->lower + 0xffff) & ~0xffff;
+ cfg->upper = PFN_UP(start + nr_pages);
+ cfg->upper = (cfg->upper & ~0xffff) - 1;
+ cfg->attrs = MIPS_MAAR_S;
+ cfg++;
+ }
- /* Round lower up */
- cfg[num_cfg].lower = boot_mem_map.map[i].addr;
- cfg[num_cfg].lower = (cfg[num_cfg].lower + 0xffff) & ~0xffff;
+ return 0;
+}
- /* Round upper down */
- cfg[num_cfg].upper = boot_mem_map.map[i].addr +
- boot_mem_map.map[i].size;
- cfg[num_cfg].upper = (cfg[num_cfg].upper & ~0xffff) - 1;
- cfg[num_cfg].attrs = MIPS_MAAR_S;
- num_cfg++;
+unsigned __weak platform_maar_init(unsigned num_pairs)
+{
+ struct maar_config cfg[MAX_MAAR_CONFIGS];
+ unsigned int num_configured, i, num_cfg = 0;
+
+ walk_system_ram_range(0, max_pfn, &cfg, maar_res_walk);
+
+ for (i = 0; i < MAX_MAAR_CONFIGS; i++) {
+ if (cfg[i].used)
+ num_cfg++;
}
num_configured = maar_config(cfg, num_cfg, num_pairs);
@@ -376,39 +384,13 @@ void maar_init(void)
recorded.cfgs[recorded.used].lower = lower;
recorded.cfgs[recorded.used].upper = upper;
recorded.cfgs[recorded.used].attrs = attr;
+ recorded.cfgs[recorded.used].used = true;
recorded.used++;
}
}
}
#ifndef CONFIG_NEED_MULTIPLE_NODES
-int page_is_ram(unsigned long pagenr)
-{
- int i;
-
- for (i = 0; i < boot_mem_map.nr_map; i++) {
- unsigned long addr, end;
-
- switch (boot_mem_map.map[i].type) {
- case BOOT_MEM_RAM:
- case BOOT_MEM_INIT_RAM:
- break;
- default:
- /* not usable memory */
- continue;
- }
-
- addr = PFN_UP(boot_mem_map.map[i].addr);
- end = PFN_DOWN(boot_mem_map.map[i].addr +
- boot_mem_map.map[i].size);
-
- if (pagenr >= addr && pagenr < end)
- return 1;
- }
-
- return 0;
-}
-
void __init paging_init(void)
{
unsigned long max_zone_pfns[MAX_NR_ZONES];
@@ -443,7 +425,7 @@ void __init paging_init(void)
static struct kcore_list kcore_kseg0;
#endif
-static inline void mem_init_free_highmem(void)
+static inline void __init mem_init_free_highmem(void)
{
#ifdef CONFIG_HIGHMEM
unsigned long tmp;
@@ -452,9 +434,7 @@ static inline void mem_init_free_highmem(void)
return;
for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) {
- struct page *page = pfn_to_page(tmp);
-
- if (!page_is_ram(tmp))
+ if (!memblock_is_memory(PFN_PHYS(tmp)))
SetPageReserved(page);
else
free_highmem_page(page);
--
2.22.0
next prev parent reply other threads:[~2019-08-19 14:24 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-08 7:50 Drop boot_mem_map Jiaxun Yang
2019-08-08 7:50 ` [PATCH 1/7] MIPS: init: " Jiaxun Yang
2019-08-14 11:54 ` Serge Semin
2019-08-14 13:40 ` Jiaxun Yang
2019-08-08 7:50 ` [PATCH 2/7] MIPS: OCTEON: " Jiaxun Yang
2019-08-08 7:50 ` [PATCH 3/7] MIPS: fw: Record prom memory Jiaxun Yang
2019-08-14 12:03 ` Serge Semin
2019-08-14 12:50 ` Thomas Bogendoerfer
2019-08-14 13:45 ` Jiaxun Yang
2019-08-08 7:50 ` [PATCH 4/7] MIPS: malta: Drop prom_free_prom_memory Jiaxun Yang
2019-08-08 7:50 ` [PATCH 5/7] MIPS: msp: Record prom memory Jiaxun Yang
2019-08-14 12:12 ` Serge Semin
2019-08-08 7:50 ` [PATCH 6/7] MIPS: ip22: Drop addr_is_ram Jiaxun Yang
2019-08-08 7:50 ` [PATCH 7/7] MIPS: xlp: Drop boot_mem_map Jiaxun Yang
2019-08-12 4:56 ` [EXTERNAL]Drop boot_mem_map Paul Burton
2019-08-12 5:28 ` Jiaxun Yang
2019-08-13 8:39 ` Serge Semin
2019-08-13 15:09 ` Jiaxun Yang
2019-08-19 14:23 ` [PATCH v1 0/8] MIPS: Drop boot_mem_map Jiaxun Yang
2019-08-19 14:23 ` [PATCH v1 1/8] MIPS: OCTEON: " Jiaxun Yang
2019-08-19 14:23 ` [PATCH v1 2/8] MIPS: fw: Record prom memory Jiaxun Yang
2019-08-19 14:23 ` [PATCH v1 3/8] MIPS: malta: Drop prom_free_prom_memory Jiaxun Yang
2019-08-19 14:23 ` [PATCH v1 4/8] MIPS: msp: Record prom memory Jiaxun Yang
2019-08-19 14:23 ` [PATCH v1 5/8] MIPS: ip22: Drop addr_is_ram Jiaxun Yang
2019-08-19 14:23 ` [PATCH v1 6/8] MIPS: xlp: Drop boot_mem_map Jiaxun Yang
2019-08-19 14:23 ` Jiaxun Yang [this message]
2019-08-19 14:23 ` [PATCH v1 8/8] MIPS: init: " Jiaxun Yang
2019-08-23 14:45 ` [PATCH v1 0/8] MIPS: " Paul Burton
2019-08-23 17:20 ` Jiaxun Yang
2019-08-23 17:36 ` Jiaxun Yang
2019-08-23 18:05 ` Serge Semin
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=20190819142313.3535-8-jiaxun.yang@flygoat.com \
--to=jiaxun.yang@flygoat.com \
--cc=aurelien@aurel32.net \
--cc=chenhc@lemote.com \
--cc=fancer.lancer@gmail.com \
--cc=linux-mips@vger.kernel.org \
--cc=matt.redfearn@mips.com \
--cc=paul.burton@mips.com \
--cc=sfr@canb.auug.org.au \
--cc=yasha.che3@gmail.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).