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

(cherry picked from commit 7098f3c7569c21ecdfc990772e96a416f1a94eee)
This commit is contained in:
Andrew Turner 2023-10-13 11:08:21 +01:00
parent 45ffdd4ea5
commit 729576a3d5

View file

@ -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,