arm64: mm: only initialize swiotlb when necessary
we only initialize swiotlb when swiotlb_force is true or not all system memory is DMA-able, this trivial optimization saves us 64MB when swiotlb is not necessary. Signed-off-by: Jisheng Zhang <jszhang@marvell.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
This commit is contained in:
parent
83ce0efc12
commit
b67a8b29df
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <linux/gfp.h>
|
#include <linux/gfp.h>
|
||||||
#include <linux/acpi.h>
|
#include <linux/acpi.h>
|
||||||
|
#include <linux/bootmem.h>
|
||||||
#include <linux/export.h>
|
#include <linux/export.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/genalloc.h>
|
#include <linux/genalloc.h>
|
||||||
@ -29,6 +30,8 @@
|
|||||||
|
|
||||||
#include <asm/cacheflush.h>
|
#include <asm/cacheflush.h>
|
||||||
|
|
||||||
|
static int swiotlb __read_mostly;
|
||||||
|
|
||||||
static pgprot_t __get_dma_pgprot(struct dma_attrs *attrs, pgprot_t prot,
|
static pgprot_t __get_dma_pgprot(struct dma_attrs *attrs, pgprot_t prot,
|
||||||
bool coherent)
|
bool coherent)
|
||||||
{
|
{
|
||||||
@ -341,6 +344,13 @@ static int __swiotlb_get_sgtable(struct device *dev, struct sg_table *sgt,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int __swiotlb_dma_supported(struct device *hwdev, u64 mask)
|
||||||
|
{
|
||||||
|
if (swiotlb)
|
||||||
|
return swiotlb_dma_supported(hwdev, mask);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static struct dma_map_ops swiotlb_dma_ops = {
|
static struct dma_map_ops swiotlb_dma_ops = {
|
||||||
.alloc = __dma_alloc,
|
.alloc = __dma_alloc,
|
||||||
.free = __dma_free,
|
.free = __dma_free,
|
||||||
@ -354,7 +364,7 @@ static struct dma_map_ops swiotlb_dma_ops = {
|
|||||||
.sync_single_for_device = __swiotlb_sync_single_for_device,
|
.sync_single_for_device = __swiotlb_sync_single_for_device,
|
||||||
.sync_sg_for_cpu = __swiotlb_sync_sg_for_cpu,
|
.sync_sg_for_cpu = __swiotlb_sync_sg_for_cpu,
|
||||||
.sync_sg_for_device = __swiotlb_sync_sg_for_device,
|
.sync_sg_for_device = __swiotlb_sync_sg_for_device,
|
||||||
.dma_supported = swiotlb_dma_supported,
|
.dma_supported = __swiotlb_dma_supported,
|
||||||
.mapping_error = swiotlb_dma_mapping_error,
|
.mapping_error = swiotlb_dma_mapping_error,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -513,6 +523,9 @@ EXPORT_SYMBOL(dummy_dma_ops);
|
|||||||
|
|
||||||
static int __init arm64_dma_init(void)
|
static int __init arm64_dma_init(void)
|
||||||
{
|
{
|
||||||
|
if (swiotlb_force || max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT))
|
||||||
|
swiotlb = 1;
|
||||||
|
|
||||||
return atomic_pool_init();
|
return atomic_pool_init();
|
||||||
}
|
}
|
||||||
arch_initcall(arm64_dma_init);
|
arch_initcall(arm64_dma_init);
|
||||||
|
@ -403,7 +403,8 @@ static void __init free_unused_memmap(void)
|
|||||||
*/
|
*/
|
||||||
void __init mem_init(void)
|
void __init mem_init(void)
|
||||||
{
|
{
|
||||||
swiotlb_init(1);
|
if (swiotlb_force || max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT))
|
||||||
|
swiotlb_init(1);
|
||||||
|
|
||||||
set_max_mapnr(pfn_to_page(max_pfn) - mem_map);
|
set_max_mapnr(pfn_to_page(max_pfn) - mem_map);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user