From f55a3ae7724f3e40edeba837e877b9ba6bca888e Mon Sep 17 00:00:00 2001 From: Allen Pais Date: Fri, 2 Dec 2016 13:31:47 +0530 Subject: [PATCH] Allow default value of npools used for iommu to be configured from cmdline The default value of the number of pools used by the pooled IOMMU allocator in lib/iommu-common.c is a constant today (set at 16). It is possible that, for some platforms and some devices, the combination of latency and frequency of iommu alloc/free requests may be such as to trigger fragmentation within a pool, leading to iommu alloc failure. Reducing the number of pools (and thus increasing the pool size) can minimize the risk of those failures. This patch provides a command line hook to set the default number of pools at boot time. Ported to UEK4 Signed-off-by: Sowmini Varadhan Signed-off-by: Allen Pais --- arch/sparc/kernel/setup_64.c | 8 ++++++++ include/linux/iommu-common.h | 2 ++ lib/iommu-common.c | 4 +++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c index 64a7002ee544..9e86df09a8e4 100644 --- a/arch/sparc/kernel/setup_64.c +++ b/arch/sparc/kernel/setup_64.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -145,6 +146,13 @@ static void __init boot_flags_init(char *commands) process_switch(*commands++); continue; } + if (!strncmp(commands, "npools=", 7)) { + int npools; + + npools = simple_strtoul(commands + 7, &commands, 0); + if (npools <= IOMMU_NR_POOLS) + iommu_default_npools = npools; + } if (!strncmp(commands, "mem=", 4)) cmdline_memory_size = memparse(commands + 4, &commands); diff --git a/include/linux/iommu-common.h b/include/linux/iommu-common.h index 376a27c9cc6a..9ecabf791a32 100644 --- a/include/linux/iommu-common.h +++ b/include/linux/iommu-common.h @@ -49,4 +49,6 @@ extern void iommu_tbl_range_free(struct iommu_map_table *iommu, u64 dma_addr, unsigned long npages, unsigned long entry); +extern int iommu_default_npools; + #endif diff --git a/lib/iommu-common.c b/lib/iommu-common.c index 858dc1aae478..baa7fd2e19c5 100644 --- a/lib/iommu-common.c +++ b/lib/iommu-common.c @@ -11,6 +11,8 @@ #include #include +int iommu_default_npools = IOMMU_NR_POOLS; + static unsigned long iommu_large_alloc = 15; static DEFINE_PER_CPU(unsigned int, iommu_hash_common); @@ -60,7 +62,7 @@ void iommu_tbl_pool_init(struct iommu_map_table *iommu, setup_iommu_pool_hash(); if (npools == 0) - iommu->nr_pools = IOMMU_NR_POOLS; + iommu->nr_pools = iommu_default_npools; else iommu->nr_pools = npools; BUG_ON(npools > IOMMU_NR_POOLS); -- 2.50.1