[PATCH] powerpc: add kernel parameter iommu_alloc_quiet
Mauricio Faria de Oliveira
mauricfo at linux.vnet.ibm.com
Thu Sep 1 22:56:42 AEST 2016
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 at 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
More information about the Linuxppc-dev
mailing list