git: f2f1ab39c040 - main - pci_user: call bus_translate_resource before BAR mmap
Marcin Wojtas
mw at FreeBSD.org
Tue Apr 6 15:16:40 UTC 2021
The branch main has been updated by mw:
URL: https://cgit.FreeBSD.org/src/commit/?id=f2f1ab39c04088ce53287528549e652cf68cee09
commit f2f1ab39c04088ce53287528549e652cf68cee09
Author: Marcin Wojtas <mw at FreeBSD.org>
AuthorDate: 2021-04-06 15:10:04 +0000
Commit: Marcin Wojtas <mw at FreeBSD.org>
CommitDate: 2021-04-06 15:15:04 +0000
pci_user: call bus_translate_resource before BAR mmap
On some armv8 machines it is possible that the mapping between CPU
and PCI bus BAR base addresses is not 1:1. In case a BAR is allocated
in kernel using bus_alloc_resource_any this translation is handled in
ofw_pci_activate_resource.
Do the same in pci_user.c by calling bus_translate_resource devmethod.
This fixes mmaping BARs to userspace on Marvell SoCs (Armada 7k8k/CN913x)
and possibly many other platforms.
Submitted by: Kornel Duleba <mindal at semihalf.com>
Reviewed by: kib
Obtained from: Semihalf
Sponsored by: Marvell
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D29604
---
sys/dev/pci/pci_user.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/sys/dev/pci/pci_user.c b/sys/dev/pci/pci_user.c
index c34fd715707e..0496b3bf6c06 100644
--- a/sys/dev/pci/pci_user.c
+++ b/sys/dev/pci/pci_user.c
@@ -878,6 +878,11 @@ pci_bar_mmap(device_t pcidev, struct pci_bar_mmap *pbm)
if (!PCI_BAR_MEM(pm->pm_value))
return (EIO);
membase = pm->pm_value & PCIM_BAR_MEM_BASE;
+ error = BUS_TRANSLATE_RESOURCE(pcidev, SYS_RES_MEMORY, membase,
+ &membase);
+ if (error != 0)
+ return (error);
+
pbase = trunc_page(membase);
plen = round_page(membase + ((pci_addr_t)1 << pm->pm_size)) -
pbase;
More information about the dev-commits-src-main
mailing list