Index: include/cpufunc.h =================================================================== RCS file: /cvs/src/sys/arch/amd64/include/cpufunc.h,v retrieving revision 1.36 diff -u -p -r1.36 cpufunc.h --- include/cpufunc.h 13 Sep 2020 11:53:16 -0000 1.36 +++ include/cpufunc.h 26 Oct 2020 09:19:14 -0000 @@ -293,6 +293,12 @@ mfence(void) __asm volatile("mfence" : : : "memory"); } +static __inline void +lfence(void) +{ + __asm volatile("lfence" : : : "memory"); +} + static __inline u_int64_t rdtsc(void) { Index: pci/pci_machdep.c =================================================================== RCS file: /cvs/src/sys/arch/amd64/pci/pci_machdep.c,v retrieving revision 1.75 diff -u -p -r1.75 pci_machdep.c --- pci/pci_machdep.c 17 Jun 2020 06:14:52 -0000 1.75 +++ pci/pci_machdep.c 26 Oct 2020 09:19:14 -0000 @@ -75,6 +75,7 @@ #include #include #include +#include #include #include @@ -118,6 +119,9 @@ do { \ #define PCI_MODE1_ADDRESS_REG 0x0cf8 #define PCI_MODE1_DATA_REG 0x0cfc +void _pci_bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, + bus_addr_t, bus_size_t, int); + /* * PCI doesn't have any special needs; just use the generic versions * of these functions. @@ -131,7 +135,7 @@ struct bus_dma_tag pci_bus_dma_tag = { _bus_dmamap_load_uio, _bus_dmamap_load_raw, _bus_dmamap_unload, - _bus_dmamap_sync, + _pci_bus_dmamap_sync, _bus_dmamem_alloc, _bus_dmamem_alloc_range, _bus_dmamem_free, @@ -139,6 +143,19 @@ struct bus_dma_tag pci_bus_dma_tag = { _bus_dmamem_unmap, _bus_dmamem_mmap, }; + +void +_pci_bus_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset, + bus_size_t len, int op) +{ + if (len == 0) + return; + + if (ISSET(op, BUS_DMASYNC_PREWRITE|BUS_DMASYNC_POSTWRITE)) + mfence(); + else if (ISSET(op, BUS_DMASYNC_PREREAD|BUS_DMASYNC_POSTREAD)) + lfence(); +} void pci_mcfg_init(bus_space_tag_t iot, bus_addr_t addr, int segment,