[vfio-users] How to enable and disable pci bus mastering for device with VFIO framework ?

Alex Williamson alex.williamson at redhat.com
Sat Jan 19 15:17:30 UTC 2019


On Sat, 19 Jan 2019 18:05:09 +0530
Steevan Rodrigues <steevanxperia at gmail.com> wrote:

> Hello,
> I am trying to port kernel mode driver for PCIe device to user space with
> the help of VFIO.
> I am wondering how to enable and disable pci bus mastering for the device ?
> 
> In  Kerenel mode we call pci_set_master() and pci_clear_master() .

>From the vfio device file descriptor call the
VFIO_DEVICE_GET_REGION_INFO ioctl with the VFIO_PCI_CONFIG_REGION_INDEX
as the index field to get the offset of PCI config space for the device.
Bus master is in the command register, which is a word register at
offset 0x4 into PCI config space, so you'd do a read, modify, write
using pread/pwrite or equivalent of the word at config space offset +
0x4, setting the but master bit within that word.  Thanks,

Alex




More information about the vfio-users mailing list