]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Add ioctl to conveniently mmap a PCI device BAR into userspace.
authorkib <kib@FreeBSD.org>
Wed, 1 Aug 2018 18:58:24 +0000 (18:58 +0000)
committerkib <kib@FreeBSD.org>
Wed, 1 Aug 2018 18:58:24 +0000 (18:58 +0000)
commitcfe7aa28cb6cecb2eb924b4ad2950fb18a866ce1
tree9a6ed426d52f1ffcb504c8de7bdc745d85e1621d
parent2e6b904ec58369f0f70a064b47fb05cfbbf5beb1
Add ioctl to conveniently mmap a PCI device BAR into userspace.

Add the ioctl PCIOCBARMMAP on /dev/pci to conveniently create
userspace mapping of a PCI device BAR.  This is enormously superior to
read the BAR value with PCIOCREAD and then try to mmap /dev/mem, and
should allow to automatically activate the mapped BARs when needed in
future.

Current implementation creates new sg pager for each user mmap
request.  If the pointer (and reference) to a managed device pager is
stored in pci_map, we would be able to revoke all mappings on the BAR
deactivation or relocation.  This is related to the unimplemented BAR
activation on mmap, and is postponed for the future.

Discussed with: imp, jhb
Sponsored by: The FreeBSD Foundation, Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D15583
share/man/man4/pci.4
sys/compat/freebsd32/freebsd32_ioctl.c
sys/compat/freebsd32/freebsd32_ioctl.h
sys/dev/pci/pci_user.c
sys/sys/pciio.h