aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern A. Zeeb <bz@FreeBSD.org>2022-03-30 17:38:23 +0000
committerBjoern A. Zeeb <bz@FreeBSD.org>2022-04-03 23:05:47 +0000
commite86707418c8e84e1ebf8b4c5f35ff641c234d067 (patch)
tree48f4c364c6640b39e3dc168eed88ac18e6538abd
parent0a21252adf11f7e839eabeb530e75cd1f9cd5386 (diff)
LinuxKPI: PCI: add counter for linux_dma_map_phys_common() errors
LinuxKPI is asking for single-segment mappings. Some (wireless) drivers are using this to map multi-pages and our busdma framework is not very friendly to that as single-segments [D31823]. Add a counter so we can track when this happens to gather more information. Sponsored by: The FreeBSD Foundation Reviewed by: hselasky MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D34715
-rw-r--r--sys/compat/linuxkpi/common/src/linux_pci.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c
index f8ae03d2bf28..34bac3843378 100644
--- a/sys/compat/linuxkpi/common/src/linux_pci.c
+++ b/sys/compat/linuxkpi/common/src/linux_pci.c
@@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pci_iov.h>
#include <dev/backlight/backlight.h>
+#include <linux/kernel.h>
#include <linux/kobject.h>
#include <linux/device.h>
#include <linux/slab.h>
@@ -77,6 +78,14 @@ __FBSDID("$FreeBSD$");
/* Undef the linux function macro defined in linux/pci.h */
#undef pci_get_class
+extern int linuxkpi_debug;
+
+SYSCTL_DECL(_compat_linuxkpi);
+
+static counter_u64_t lkpi_pci_nseg1_fail;
+SYSCTL_COUNTER_U64(_compat_linuxkpi, OID_AUTO, lkpi_pci_nseg1_fail, CTLFLAG_RD,
+ &lkpi_pci_nseg1_fail, "Count of busdma mapping failures of single-segment");
+
static device_probe_t linux_pci_probe;
static device_attach_t linux_pci_attach;
static device_detach_t linux_pci_detach;
@@ -796,7 +805,7 @@ linux_dma_init(void *arg)
linux_dma_obj_zone = uma_zcreate("linux_dma_object",
sizeof(struct linux_dma_obj), NULL, NULL, NULL, NULL,
UMA_ALIGN_PTR, 0);
-
+ lkpi_pci_nseg1_fail = counter_u64_alloc(M_WAITOK);
}
SYSINIT(linux_dma, SI_SUB_DRIVERS, SI_ORDER_THIRD, linux_dma_init, NULL);
@@ -804,6 +813,7 @@ static void
linux_dma_uninit(void *arg)
{
+ counter_u64_free(lkpi_pci_nseg1_fail);
uma_zdestroy(linux_dma_obj_zone);
uma_zdestroy(linux_dma_trie_zone);
}
@@ -866,6 +876,9 @@ linux_dma_map_phys_common(struct device *dev, vm_paddr_t phys, size_t len,
bus_dmamap_destroy(obj->dmat, obj->dmamap);
DMA_PRIV_UNLOCK(priv);
uma_zfree(linux_dma_obj_zone, obj);
+ counter_u64_add(lkpi_pci_nseg1_fail, 1);
+ if (linuxkpi_debug)
+ dump_stack();
return (0);
}