Content-Type: multipart/mixed; boundary="===============0669264421007815091==" MIME-Version: 1.0 From: Harris, James R Subject: [SPDK] Re: How to do mmio correctly when vfio-pci is used? Date: Thu, 17 Sep 2020 15:03:58 +0000 Message-ID: <42D6AD6B-9CBF-4301-9517-E409830C440D@intel.com> In-Reply-To: 20200917071732.2750.3970@ml01.vlan13.01.org List-ID: To: spdk@lists.01.org --===============0669264421007815091== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi Oscar, Do you have an SPDK_PCI_DRIVER_REGISTER defined for your device? This ensu= res the driver is properly registered with DPDK so that associated devices = are configured correctly. If not, lib/env_dpdk/ioat.c provides a suitable = example. This enables a unified mmio approach for SPDK. -Jim =EF=BB=BFOn 9/17/20, 12:17 AM, "oscar.huang(a)microchip.com" wrote: Hi, Gugus, = I have a simple SPDK application, which maps a device BAR, and write so= me data onto the device with spdk_mmio_write_8 function. The code flow is l= ike this: ... spdk_pci_device_map_bar(dev, bir, &virBarAddr, &phys, &size); addrToWrite =3D virBarAddr + offset; //offset is where I'd like to wr= ite data in the device memory spdk_mmio_write_8(addrToWrite, data); ... The code has been working with uio_pci_generic. But recently when I swi= tched to vfio-pci (iommu enabled), I got a segmentation fault the program w= as executing that spdk_mmio_write_8 function. = If I do the following, the program can run: ... spdk_pci_device_map_bar(dev, bir, &virBarAddr, &phys, &size); physAddr =3D phys +offset; int fd =3D open("/dev/mem", O_RDWR | O_SYNC); void *map_base =3D mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED= , fd, physAddr & ~MAP_MASK); addrToWrite =3D (uint64_t)map_base + (physAddr & MAP_MASK); spdk_mmio_write_8(addrToWrite, data); ... I don't understand why it is so. Basically I need a routine to map devi= ce physical address to process virtual address, and then call spdk_mmio_wri= te_x functions. It looks like the virtual address from spdk_pci_device_map_= bar cannot be used. I noticed the virtual address from spdk_pci_device_map_= bar was 0x2010008000, but the one by mmap was 0x7ffff7fef000, very differen= t. = Is there a unified mmio approach that works for both uio_pci_generic an= d vfio_pci? _______________________________________________ SPDK mailing list -- spdk(a)lists.01.org To unsubscribe send an email to spdk-leave(a)lists.01.org --===============0669264421007815091==--