From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ajHG0-0005Id-NU for qemu-devel@nongnu.org; Thu, 24 Mar 2016 22:13:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ajHFz-0008E6-Nt for qemu-devel@nongnu.org; Thu, 24 Mar 2016 22:13:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58284) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ajHFz-0008Dv-HT for qemu-devel@nongnu.org; Thu, 24 Mar 2016 22:13:47 -0400 From: Jason Wang Date: Fri, 25 Mar 2016 10:13:26 +0800 Message-Id: <1458872009-13342-6-git-send-email-jasowang@redhat.com> In-Reply-To: <1458872009-13342-1-git-send-email-jasowang@redhat.com> References: <1458872009-13342-1-git-send-email-jasowang@redhat.com> Subject: [Qemu-devel] [RFC PATCH 5/8] virtio-pci: address space translation service (ATS) support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: mst@redhat.com, qemu-devel@nongnu.org Cc: cornelia.huck@de.ibm.com, pbonzini@redhat.com, Jason Wang , peterx@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 Signed-off-by: Jason Wang --- 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