From: Yongji Xie <xyjxie@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org, alex.williamson@redhat.com
Cc: nikunj@linux.vnet.ibm.com, zhong@linux.vnet.ibm.com,
aik@ozlabs.ru, paulus@samba.org, mpe@ellerman.id.au,
warrier@linux.vnet.ibm.com,
Yongji Xie <xyjxie@linux.vnet.ibm.com>
Subject: [Qemu-devel] [RFC PATCH 3/3] vfio/pci: Add support for mmapping MSI-X table
Date: Fri, 11 Dec 2015 17:05:18 +0800 [thread overview]
Message-ID: <1449824719-3407-4-git-send-email-xyjxie@linux.vnet.ibm.com> (raw)
In-Reply-To: <1449824719-3407-1-git-send-email-xyjxie@linux.vnet.ibm.com>
The VFIO-PCI ioctl VFIO_DEVICE_FLAGS_PCI_MSIX_MMAP flag indicate that
platform support mmapping MSI-X table.
With this flag set, we skip some MSI-X table check so that QEMU can
mmap MSI-X table successfully. And we also raise the priority of mmap
memory region in case of overlap with MSI-X/PBA memory region which
is added in msix_init().
Signed-off-by: Yongji Xie <xyjxie@linux.vnet.ibm.com>
---
hw/vfio/pci.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index a7c6171..bec301c 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1339,7 +1339,8 @@ static void vfio_mmap_set_enabled(VFIOPCIDevice *vdev, bool enabled)
}
memory_region_set_enabled(&bar->region.mmap_mem, enabled);
- if (vdev->msix && vdev->msix->table_bar == i) {
+ if (vdev->msix && vdev->msix->table_bar == i &&
+ !(vdev->vbasedev.flags & VFIO_DEVICE_FLAGS_PCI_MSIX_MMAP)) {
memory_region_set_enabled(&vdev->msix->mmap_mem, enabled);
}
}
@@ -1357,7 +1358,8 @@ static void vfio_unregister_bar(VFIOPCIDevice *vdev, int nr)
memory_region_del_subregion(&bar->region.mem, &bar->region.mmap_mem);
- if (vdev->msix && vdev->msix->table_bar == nr) {
+ if (vdev->msix && vdev->msix->table_bar == nr &&
+ !(vdev->vbasedev.flags & VFIO_DEVICE_FLAGS_PCI_MSIX_MMAP)) {
memory_region_del_subregion(&bar->region.mem, &vdev->msix->mmap_mem);
}
}
@@ -1374,7 +1376,8 @@ static void vfio_unmap_bar(VFIOPCIDevice *vdev, int nr)
munmap(bar->region.mmap, memory_region_size(&bar->region.mmap_mem));
- if (vdev->msix && vdev->msix->table_bar == nr) {
+ if (vdev->msix && vdev->msix->table_bar == nr &&
+ !(vdev->vbasedev.flags & VFIO_DEVICE_FLAGS_PCI_MSIX_MMAP)) {
munmap(vdev->msix->mmap, memory_region_size(&vdev->msix->mmap_mem));
}
}
@@ -1420,7 +1423,8 @@ static void vfio_map_bar(VFIOPCIDevice *vdev, int nr)
* We can't mmap areas overlapping the MSIX vector table, so we
* potentially insert a direct-mapped subregion before and after it.
*/
- if (vdev->msix && vdev->msix->table_bar == nr) {
+ if (vdev->msix && vdev->msix->table_bar == nr &&
+ !(vdev->vbasedev.flags & VFIO_DEVICE_FLAGS_PCI_MSIX_MMAP)) {
size = vdev->msix->table_offset & qemu_real_host_page_mask;
}
@@ -1429,9 +1433,14 @@ static void vfio_map_bar(VFIOPCIDevice *vdev, int nr)
&bar->region.mmap_mem, &bar->region.mmap,
size, 0, name)) {
error_report("%s unsupported. Performance may be slow", name);
+ } else if (vdev->vbasedev.flags & VFIO_DEVICE_FLAGS_PCI_MSIX_MMAP) {
+ memory_region_del_subregion(&bar->region.mem, &bar->region.mmap_mem);
+ memory_region_add_subregion_overlap(&bar->region.mem, 0,
+ &bar->region.mmap_mem, 1);
}
- if (vdev->msix && vdev->msix->table_bar == nr) {
+ if (vdev->msix && vdev->msix->table_bar == nr &&
+ !(vdev->vbasedev.flags & VFIO_DEVICE_FLAGS_PCI_MSIX_MMAP)) {
uint64_t start;
start = REAL_HOST_PAGE_ALIGN((uint64_t)vdev->msix->table_offset +
--
1.7.9.5
prev parent reply other threads:[~2015-12-11 9:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-11 9:05 [Qemu-devel] [RFC PATCH 0/3] vfio/pci: Add support for mmapping sub-page MMIO BARs and MSI-X table Yongji Xie
2015-12-11 9:05 ` [Qemu-devel] [RFC PATCH 1/3] linux-headers: Update VFIO headers from linux-next tag ToBeFilled Yongji Xie
2015-12-11 9:05 ` [Qemu-devel] [RFC PATCH 2/3] vfio/pci: Add support for mmapped sub-page MMIO BARs Yongji Xie
2015-12-11 9:05 ` Yongji Xie [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1449824719-3407-4-git-send-email-xyjxie@linux.vnet.ibm.com \
--to=xyjxie@linux.vnet.ibm.com \
--cc=aik@ozlabs.ru \
--cc=alex.williamson@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=nikunj@linux.vnet.ibm.com \
--cc=paulus@samba.org \
--cc=qemu-devel@nongnu.org \
--cc=warrier@linux.vnet.ibm.com \
--cc=zhong@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).