]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
Allow default value of npools used for iommu to be configured from cmdline
authorAllen Pais <allen.pais@oracle.com>
Fri, 2 Dec 2016 08:01:47 +0000 (13:31 +0530)
committerShannon Nelson <shannon.nelson@oracle.com>
Wed, 31 May 2017 23:43:49 +0000 (16:43 -0700)
    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 <sowmini.varadhan@oracle.com>
Signed-off-by: Allen Pais <allen.pais@oracle.com>
arch/sparc/kernel/setup_64.c
include/linux/iommu-common.h
lib/iommu-common.c

index 64a7002ee5447da6572f31f6f416b3425f0c895f..9e86df09a8e4a29556054117c2b97a1432a06d65 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/module.h>
 #include <linux/start_kernel.h>
 #include <linux/bootmem.h>
+#include <linux/iommu-common.h>
 
 #include <asm/io.h>
 #include <asm/processor.h>
@@ -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);
 
index 376a27c9cc6aa4901a1870c13749ce762f4fe69f..9ecabf791a3236cee82e9950ca0264f8daf6cc2e 100644 (file)
@@ -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
index 858dc1aae478bad9cb30275cb7fd7905d73f6ede..baa7fd2e19c5230d97ab04e0e0cf7a79e967b47a 100644 (file)
@@ -11,6 +11,8 @@
 #include <linux/dma-mapping.h>
 #include <linux/hash.h>
 
+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);