arc: fix memory initialization for systems with two memory banks
authorMike Rapoport <rppt@linux.ibm.com>
Fri, 28 Aug 2020 16:39:02 +0000 (19:39 +0300)
committerVineet Gupta <vgupta@synopsys.com>
Tue, 1 Sep 2020 18:23:50 +0000 (11:23 -0700)
commit4af22ded0ecf23adea1b26ea264c53f9f1cfc310
tree95ecfb74ac66298bfcf4b3958d43ef2439f32c4b
parent89d29997f103d08264b0685796b420d911658b96
arc: fix memory initialization for systems with two memory banks

Rework of memory map initialization broke initialization of ARC systems
with two memory banks. Before these changes, memblock was not aware of
nodes configuration and the memory map was always allocated from the
"lowmem" bank. After the addition of node information to memblock, the core
mm attempts to allocate the memory map for the "highmem" bank from its
node. The access to this memory using __va() fails because it can be only
accessed using kmap.

Anther problem that was uncovered is that {min,max}_high_pfn are calculated
from u64 high_mem_start variable which prevents truncation to 32-bit
physical address and the PFN values are above the node and zone boundaries.

Use phys_addr_t type for high_mem_start and high_mem_size to ensure
correspondence between PFNs and highmem zone boundaries and reserve the
entire highmem bank until mem_init() to avoid accesses to it before highmem
is enabled.

To test this:
1. Enable HIGHMEM in ARC config
2. Enable 2 memory banks in haps_hs.dts (uncomment the 2nd bank)

Fixes: 51930df5801e ("mm: free_area_init: allow defining max_zone_pfn in descending order")
Cc: stable@vger.kernel.org [5.8]
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
[vgupta: added instructions to test highmem]
arch/arc/mm/init.c