git: 46d08fd085dc - stable/13 - LinuxKPI: PCI: add counter for linux_dma_map_phys_common() errors
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 14 Apr 2022 18:01:22 UTC
The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=46d08fd085dcb013b6ae09cd36b272f93fc84574 commit 46d08fd085dcb013b6ae09cd36b272f93fc84574 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2022-03-30 17:38:23 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2022-04-14 16:37:53 +0000 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 Differential Revision: https://reviews.freebsd.org/D34715 (cherry picked from commit e86707418c8e84e1ebf8b4c5f35ff641c234d067) --- sys/compat/linuxkpi/common/src/linux_pci.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index acfc760f092f..3fa6de92bce4 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; @@ -953,7 +962,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); @@ -961,6 +970,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); } @@ -1023,6 +1033,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); }