git: 7098f3c7569c - main - pci: Set the domain in the pci_generic driver
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 16 Oct 2023 10:47:27 UTC
The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=7098f3c7569c21ecdfc990772e96a416f1a94eee commit 7098f3c7569c21ecdfc990772e96a416f1a94eee Author: Andrew Turner <andrew@FreeBSD.org> AuthorDate: 2023-10-13 10:08:21 +0000 Commit: Andrew Turner <andrew@FreeBSD.org> CommitDate: 2023-10-16 09:36:39 +0000 pci: Set the domain in the pci_generic driver Tell bus_dma(9) which NUMA domain the PCI driver is closest to so it can allocate memory from there when possible. Reviewed by: markj, jhb Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D42186 --- sys/dev/pci/pci_host_generic.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/dev/pci/pci_host_generic.c b/sys/dev/pci/pci_host_generic.c index cef83069c371..90361a7258ed 100644 --- a/sys/dev/pci/pci_host_generic.c +++ b/sys/dev/pci/pci_host_generic.c @@ -83,7 +83,7 @@ pci_host_generic_core_attach(device_t dev) uint64_t phys_base; uint64_t pci_base; uint64_t size; - int error; + int domain, error; int rid, tuple; sc = device_get_softc(dev); @@ -104,6 +104,13 @@ pci_host_generic_core_attach(device_t dev) if (error != 0) return (error); + /* + * Attempt to set the domain. If it's missing, or we are unable to + * set it then memory allocations may be placed in the wrong domain. + */ + if (bus_get_domain(dev, &domain) == 0) + (void)bus_dma_tag_set_domain(sc->dmat, domain); + if ((sc->quirks & PCIE_CUSTOM_CONFIG_SPACE_QUIRK) == 0) { rid = 0; sc->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,