qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: mst@redhat.com, qemu-devel@nongnu.org
Cc: cornelia.huck@de.ibm.com, pbonzini@redhat.com,
	Jason Wang <jasowang@redhat.com>,
	peterx@redhat.com
Subject: [Qemu-devel] [RFC PATCH 5/8] virtio-pci: address space translation service (ATS) support
Date: Fri, 25 Mar 2016 10:13:26 +0800	[thread overview]
Message-ID: <1458872009-13342-6-git-send-email-jasowang@redhat.com> (raw)
In-Reply-To: <1458872009-13342-1-git-send-email-jasowang@redhat.com>

This patches enable the Address Translation Service support for virtio
pci devices. This is needed for a guest visible Device IOTLB
implementation and will be used by vhost device IOTLB API.

Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/virtio/virtio-pci.c                    | 14 ++++++++++++--
 hw/virtio/virtio-pci.h                    |  4 ++++
 include/standard-headers/linux/pci_regs.h |  1 +
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 5508b1c..0c4212c 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1821,8 +1821,10 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
 
     address_space_init(&proxy->modern_as, &proxy->modern_cfg, "virtio-pci-cfg-as");
 
-    if (pci_is_express(pci_dev) && pci_bus_is_express(pci_dev->bus) &&
-        !pci_bus_is_root(pci_dev->bus)) {
+    if (pci_is_express(pci_dev) && pci_bus_is_express(pci_dev->bus)) {
+        /* FIXME:
+         * &&!pci_bus_is_root(pci_dev->bus)) {
+         */
         int pos;
 
         pos = pcie_endpoint_cap_init(pci_dev, 0);
@@ -1836,6 +1838,12 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
          * PCI Power Management Interface Specification.
          */
         pci_set_word(pci_dev->config + pos + PCI_PM_PMC, 0x3);
+
+        if (proxy->flags & VIRTIO_PCI_FLAG_ATS) {
+            pcie_add_capability(pci_dev, PCI_EXT_CAP_ID_ATS, 0x1,
+                                256, PCI_EXT_CAP_ATS_SIZEOF);
+        }
+
     } else {
         /*
          * make future invocations of pci_is_express() return false
@@ -1886,6 +1894,8 @@ static Property virtio_pci_properties[] = {
                     VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT, false),
     DEFINE_PROP_BIT("x-disable-pcie", VirtIOPCIProxy, flags,
                     VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT, false),
+    DEFINE_PROP_BIT("ats", VirtIOPCIProxy, flags,
+                    VIRTIO_PCI_FLAG_ATS_BIT, false),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
index e4548c2..f3b93a0 100644
--- a/hw/virtio/virtio-pci.h
+++ b/hw/virtio/virtio-pci.h
@@ -66,6 +66,7 @@ enum {
     VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT,
     VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT,
     VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT,
+    VIRTIO_PCI_FLAG_ATS_BIT,
 };
 
 /* Need to activate work-arounds for buggy guests at vmstate load. */
@@ -88,6 +89,9 @@ enum {
 #define VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY \
     (1 << VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT)
 
+/* address space translation service */
+#define VIRTIO_PCI_FLAG_ATS (1 << VIRTIO_PCI_FLAG_ATS_BIT)
+
 typedef struct {
     MSIMessage msg;
     int virq;
diff --git a/include/standard-headers/linux/pci_regs.h b/include/standard-headers/linux/pci_regs.h
index 1becea8..cfb798a 100644
--- a/include/standard-headers/linux/pci_regs.h
+++ b/include/standard-headers/linux/pci_regs.h
@@ -673,6 +673,7 @@
 #define PCI_EXT_CAP_ID_MAX	PCI_EXT_CAP_ID_PASID
 
 #define PCI_EXT_CAP_DSN_SIZEOF	12
+#define PCI_EXT_CAP_ATS_SIZEOF	8
 #define PCI_EXT_CAP_MCAST_ENDPOINT_SIZEOF 40
 
 /* Advanced Error Reporting */
-- 
2.5.0

  parent reply	other threads:[~2016-03-25  2:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-25  2:13 [Qemu-devel] [RFC PATCH 0/8] virtio/vhost DMAR support Jason Wang
2016-03-25  2:13 ` [Qemu-devel] [RFC PATCH 1/8] virtio: convert to use DMA api Jason Wang
2016-04-19 13:37   ` Michael S. Tsirkin
2016-03-25  2:13 ` [Qemu-devel] [RFC PATCH 2/8] intel_iommu: name vtd address space with devfn Jason Wang
2016-03-28  2:02   ` Peter Xu
2016-03-30  1:12     ` Jason Wang
2016-03-30 11:12       ` Michael S. Tsirkin
2016-03-25  2:13 ` [Qemu-devel] [RFC PATCH 3/8] intel_iommu: allocate new key when creating new address space Jason Wang
2016-03-28  2:07   ` Peter Xu
2016-03-25  2:13 ` [Qemu-devel] [RFC PATCH 4/8] exec: introduce address_space_get_iotlb_entry() Jason Wang
2016-03-28  2:18   ` Peter Xu
2016-03-30  1:13     ` Jason Wang
2016-03-25  2:13 ` Jason Wang [this message]
2016-03-25  2:13 ` [Qemu-devel] [RFC PATCH 6/8] intel_iommu: support device iotlb descriptor Jason Wang
2016-03-28  3:37   ` Peter Xu
2016-03-30  5:08     ` Jason Wang
2016-03-30  5:21       ` Peter Xu
2016-03-25  2:13 ` [Qemu-devel] [RFC PATCH 7/8] memory: handle alias for iommu notifier Jason Wang
2016-03-25  2:13 ` [Qemu-devel] [RFC PATCH 8/8] vhost_net: device IOTLB support Jason Wang

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=1458872009-13342-6-git-send-email-jasowang@redhat.com \
    --to=jasowang@redhat.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).