Skip to content

Commit a90922f

Browse files
Doug BergerChristoph Hellwig
authored andcommitted
swiotlb: relocate PageHighMem test away from rmem_swiotlb_setup
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: 0b84e4f ("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>
1 parent c00a60d commit a90922f

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

kernel/dma/swiotlb.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,11 @@ static int rmem_swiotlb_device_init(struct reserved_mem *rmem,
998998
/* Set Per-device io tlb area to one */
999999
unsigned int nareas = 1;
10001000

1001+
if (PageHighMem(pfn_to_page(PHYS_PFN(rmem->base)))) {
1002+
dev_err(dev, "Restricted DMA pool must be accessible within the linear mapping.");
1003+
return -EINVAL;
1004+
}
1005+
10011006
/*
10021007
* Since multiple devices can share the same pool, the private data,
10031008
* io_tlb_mem struct, will be initialized by the first device attached
@@ -1059,11 +1064,6 @@ static int __init rmem_swiotlb_setup(struct reserved_mem *rmem)
10591064
of_get_flat_dt_prop(node, "no-map", NULL))
10601065
return -EINVAL;
10611066

1062-
if (PageHighMem(pfn_to_page(PHYS_PFN(rmem->base)))) {
1063-
pr_err("Restricted DMA pool must be accessible within the linear mapping.");
1064-
return -EINVAL;
1065-
}
1066-
10671067
rmem->ops = &rmem_swiotlb_ops;
10681068
pr_info("Reserved memory: created restricted DMA pool at %pa, size %ld MiB\n",
10691069
&rmem->base, (unsigned long)rmem->size / SZ_1M);

0 commit comments

Comments
 (0)