swiotlb: relocate PageHighMem test away from rmem_swiotlb_setup
authorDoug Berger <opendmb@gmail.com>
Fri, 14 Apr 2023 21:29:25 +0000 (14:29 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2023 14:03:35 +0000 (23:03 +0900)
commite6c69b06e720da33a8b53edb7bdda8a368ef092d
treee2dcb03bb3dbdc1a2872c10c494f502e4b50b8d6
parent36d087e49dabd28d2c13a7532dac72d625ce69fb
swiotlb: relocate PageHighMem test away from rmem_swiotlb_setup

[ Upstream commit a90922fa25370902322e9de6640e58737d459a50 ]

The reservedmem_of_init_fn's are invoked very early at boot before the
memory zones have even been defined. This makes it inappropriate to test
whether the page corresponding to a PFN is in ZONE_HIGHMEM from within
one.

Removing the check allows an ARM 32-bit kernel with SPARSEMEM enabled to
boot properly since otherwise we would be de-referencing an
uninitialized sparsemem map to perform pfn_to_page() check.

The arm64 architecture happens to work (and also has no high memory) but
other 32-bit architectures could also be having similar issues.

While it would be nice to provide early feedback about a reserved DMA
pool residing in highmem, it is not possible to do that until the first
time we try to use it, which is where the check is moved to.

Fixes: 0b84e4f8b793 ("swiotlb: Add restricted DMA pool initialization")
Signed-off-by: Doug Berger <opendmb@gmail.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/dma/swiotlb.c