[PATCH] microblaze: cleanup memory start aliases

From: Mike Rapoport
Date: Tue Jun 30 2020 - 06:37:53 EST


There are several variables that have the same meaning and value, but they
are used with different configuration options:

- memory_start - "main memory where the kernel is"
- __page_offset - an alias for memory_start disguised as PAGE_OFFSET fot
no-MMU case
- min_low_pfn - a legacy from i386 memory layout weirdness, an alias for
(memory_start >> PAGE_SHIFT)

Since there are "different" variables that point to the start of the
memory, MMU and no-MMU variants of pfn_valid() and ARCH_PFN_OFFSET used
memory_start and __page_offset with min_low_pfn respectively.

Use memory_start for both MMU and no-MMU versions of pfn_valid() and
ARCH_PFN_OFFSET and get rid of __page_offset entirely.

Signed-off-by: Mike Rapoport <rppt@xxxxxxxxxxxxx>
---
arch/microblaze/include/asm/page.h | 18 ++++--------------
arch/microblaze/mm/init.c | 1 -
2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/arch/microblaze/include/asm/page.h b/arch/microblaze/include/asm/page.h
index b13463d39b38..d664c437b377 100644
--- a/arch/microblaze/include/asm/page.h
+++ b/arch/microblaze/include/asm/page.h
@@ -50,8 +50,7 @@
* using MMU this corresponds to the first free page in physical memory (aligned
* on a page boundary).
*/
-extern unsigned int __page_offset;
-#define PAGE_OFFSET __page_offset
+#define PAGE_OFFSET memory_start

#else /* CONFIG_MMU */

@@ -124,10 +123,6 @@ typedef struct { p4d_t pge[1]; } pgd_t;
*
*/

-extern unsigned long max_low_pfn;
-extern unsigned long min_low_pfn;
-extern unsigned long max_pfn;
-
extern unsigned long memory_start;
extern unsigned long memory_size;
extern unsigned long lowmem_size;
@@ -156,14 +151,9 @@ extern int page_is_ram(unsigned long pfn);
# define phys_to_page(paddr) (pfn_to_page(phys_to_pfn(paddr)))
# endif /* CONFIG_MMU */

-# ifndef CONFIG_MMU
-# define pfn_valid(pfn) (((pfn) >= min_low_pfn) && \
- ((pfn) <= (min_low_pfn + max_mapnr)))
-# define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT)
-# else /* CONFIG_MMU */
-# define ARCH_PFN_OFFSET (memory_start >> PAGE_SHIFT)
-# define pfn_valid(pfn) ((pfn) < (max_mapnr + ARCH_PFN_OFFSET))
-# endif /* CONFIG_MMU */
+#define ARCH_PFN_OFFSET (memory_start >> PAGE_SHIFT)
+#define pfn_valid(pfn) (((pfn) >= ARCH_PFN_OFFSET) && \
+ ((pfn) < (ARCH_PFN_OFFSET + max_mapnr)))

# endif /* __ASSEMBLY__ */

diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 521b59ba716c..0ddc5fcc55c2 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -117,7 +117,6 @@ void __init setup_memory(void)
if ((memory_start <= (u32)_text) &&
((u32)_text <= (memory_start + lowmem_size - 1))) {
memory_size = lowmem_size;
- PAGE_OFFSET = memory_start;
pr_info("%s: Main mem: 0x%x, size 0x%08x\n",
__func__, (u32) memory_start,
(u32) memory_size);
--
2.26.2

--
Sincerely yours,
Mike.