All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc: add kernel parameter iommu_alloc_quiet
@ 2016-09-01 12:56 Mauricio Faria de Oliveira
  2016-09-01 13:32 ` Mauricio Faria de Oliveira
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Mauricio Faria de Oliveira @ 2016-09-01 12:56 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: jthumshirn, duwe

This patch introduces the 'iommu_alloc_quiet=driver_name' parameter
to suppress the 'iommu_alloc failures' messages for that one driver.

This is an additional approach for this 'problem' of flooding logs,
not as fine-grained and not enabled by default as DMA_ATTR_NO_WARN,
but it has the advantage that it doesn't introduce any ABI changes.

That is important/requirement for the distribution kernels - where
the DMA_ATTR_NO_WARN changes to 'enum dma_attr' are not acceptable
because it breaks the kernel ABI.

Tested on next-20160825 + nvme changed not to use DMA_ATTR_NO_WARN.

 - test-case: default / no iommu_alloc_quiet
 - result:    messages occur

    # dmesg -c | grep iommu_alloc_quiet
    #

    # dd if=/dev/zero of=/dev/nvme0n1p1 bs=64k count=128k 2>/dev/null; dmesg -c
    <...>
    [   31.753230] nvme 0000:00:06.0: iommu_alloc failed, tbl c0000003f7080c00 vaddr c00000022bf30000 npages 16

 - test-case: iommu_alloc_quiet=(null)
 - result:    messages occur

    # dmesg -c | grep iommu_alloc_quiet
    [    0.000000] Kernel command line: root=<...> ro disable_ddw iommu_alloc_quiet=
    [    0.000000] iommu_alloc_quiet: driver ''

    # dd if=/dev/zero of=/dev/nvme0n1p1 bs=64k count=128k 2>/dev/null; dmesg -c
    <...>
    [   29.032848] nvme 0000:00:06.0: iommu_alloc failed, tbl c0000003f7190c00 vaddr c000000238fc0000 npages 16

 - test-case: iommu_alloc_quiet=(length overflow)
 - result:    messages occur

    # dmesg -c | grep iommu_alloc_quiet
    [    0.000000] Kernel command line: root=<...> ro disable_ddw iommu_alloc_quiet=0123456789abcdef0123456789abcdef
    [    0.000000] iommu_alloc_quiet: driver '0123456789abcde'

    # dd if=/dev/zero of=/dev/nvme0n1p1 bs=64k count=128k 2>/dev/null; dmesg -c
    <...>
    [   54.913279] nvme 0000:00:06.0: iommu_alloc failed, tbl c0000003f7120c00 vaddr c00000022d960000 npages 16

 - test-case: iommu_alloc_quiet=nvme
 - result:    messages do not occur

    # dmesg -c | grep iommu_alloc_quiet
    [    0.000000] Kernel command line: root=<...> ro disable_ddw iommu_alloc_quiet=nvme
    [    0.000000] iommu_alloc_quiet: driver 'nvme'

    # dd if=/dev/zero of=/dev/nvme0n1p1 bs=64k count=128k 2>/dev/null; dmesg -c

    # dd if=/dev/zero of=/dev/nvme0n1p1 bs=64k count=128k 2>/dev/null; dmesg -c

    # dd if=/dev/zero of=/dev/nvme0n1p1 bs=64k count=128k 2>/dev/null; dmesg -c

    # dd if=/dev/zero of=/dev/nvme0n1p1 bs=64k count=128k 2>/dev/null; dmesg -c

    # dd if=/dev/zero of=/dev/nvme0n1p1 bs=64k count=128k 2>/dev/null; dmesg -c

Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/iommu.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index 5f202a5..8524d91 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -65,6 +65,23 @@ static int __init setup_iommu(char *str)
 
 __setup("iommu=", setup_iommu);
 
+/*
+ * iommu_alloc_quiet: string with one driver name
+ * not to print 'iommu_alloc failed' messages for.
+ */
+#define IOMMU_ALLOC_QUIET_LEN	16 /* includes '\0' */
+static char iommu_alloc_quiet[IOMMU_ALLOC_QUIET_LEN];
+
+static int __init setup_iommu_alloc_quiet(char *str)
+{
+	strncpy(iommu_alloc_quiet, str, IOMMU_ALLOC_QUIET_LEN);
+	iommu_alloc_quiet[IOMMU_ALLOC_QUIET_LEN - 1] = '\0';
+	pr_info("iommu_alloc_quiet: driver '%s'\n", iommu_alloc_quiet);
+	return 1;
+}
+
+__setup("iommu_alloc_quiet=", setup_iommu_alloc_quiet);
+
 static DEFINE_PER_CPU(unsigned int, iommu_pool_hash);
 
 /*
@@ -479,8 +496,8 @@ int ppc_iommu_map_sg(struct device *dev, struct iommu_table *tbl,
 
 		/* Handle failure */
 		if (unlikely(entry == DMA_ERROR_CODE)) {
-			if (!(attrs & DMA_ATTR_NO_WARN) &&
-			    printk_ratelimit())
+			if (strncmp(iommu_alloc_quiet, dev->driver->name, IOMMU_ALLOC_QUIET_LEN) &&
+			    !(attrs & DMA_ATTR_NO_WARN) && printk_ratelimit())
 				dev_info(dev, "iommu_alloc failed, tbl %p "
 					 "vaddr %lx npages %lu\n", tbl, vaddr,
 					 npages);
@@ -777,8 +794,8 @@ dma_addr_t iommu_map_page(struct device *dev, struct iommu_table *tbl,
 					 mask >> tbl->it_page_shift, align,
 					 attrs);
 		if (dma_handle == DMA_ERROR_CODE) {
-			if (!(attrs & DMA_ATTR_NO_WARN) &&
-			    printk_ratelimit())  {
+			if (strncmp(iommu_alloc_quiet, dev->driver->name, IOMMU_ALLOC_QUIET_LEN) &&
+			    !(attrs & DMA_ATTR_NO_WARN) && printk_ratelimit()) {
 				dev_info(dev, "iommu_alloc failed, tbl %p "
 					 "vaddr %p npages %d\n", tbl, vaddr,
 					 npages);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-10-03 15:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-01 12:56 [PATCH] powerpc: add kernel parameter iommu_alloc_quiet Mauricio Faria de Oliveira
2016-09-01 13:32 ` Mauricio Faria de Oliveira
2016-09-01 13:39 ` Torsten Duwe
2016-09-01 14:26   ` Mauricio Faria de Oliveira
2016-09-21 13:51 ` Michael Ellerman
2016-09-21 14:34   ` Mauricio Faria de Oliveira
2016-10-03 15:44     ` Mauricio Faria de Oliveira

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.