From: Greg Kurz <groug@kaod.org>
To: Jason Wang <jasowang@redhat.com>
Cc: qemu-devel@nongnu.org, mst@redhat.com, peterx@redhat.com,
vkaplans@redhat.com, wexu@redhat.com, cornelia.huck@de.ibm.com,
pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH V3 06/10] virtio-pci: address space translation service (ATS) support
Date: Tue, 8 Nov 2016 13:25:08 +0100 [thread overview]
Message-ID: <20161108132508.3abe2336@bahia> (raw)
In-Reply-To: <1478502595-8484-7-git-send-email-jasowang@redhat.com>
On Mon, 7 Nov 2016 15:09:51 +0800
Jason Wang <jasowang@redhat.com> wrote:
> 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 required by vhost device IOTLB API
> implementation for intel IOMMU.
>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
> hw/pci/pcie.c | 16 ++++++++++++++++
> hw/virtio/virtio-pci.c | 7 +++++++
> hw/virtio/virtio-pci.h | 4 ++++
> include/hw/pci/pcie.h | 4 ++++
> include/standard-headers/linux/pci_regs.h | 1 +
> 5 files changed, 32 insertions(+)
>
> diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
> index 99cfb45..02195d9 100644
> --- a/hw/pci/pcie.c
> +++ b/hw/pci/pcie.c
> @@ -717,3 +717,19 @@ void pcie_dev_ser_num_init(PCIDevice *dev, uint16_t offset, uint64_t ser_num)
> PCI_EXT_CAP_DSN_SIZEOF);
> pci_set_quad(dev->config + offset + pci_dsn_cap, ser_num);
> }
> +
> +void pcie_ats_init(PCIDevice *dev, uint16_t offset)
> +{
> + pcie_add_capability(dev, PCI_EXT_CAP_ID_ATS, 0x1,
> + offset, PCI_EXT_CAP_ATS_SIZEOF);
> +
> + dev->exp.ats_cap = offset;
> +
> + /* Invalidate Queue Depth 0, Page Aligned Request 0 */
> + pci_set_word(dev->config + offset + PCI_ATS_CAP, 0);
> + /* STU 0, Disabled by default */
> + pci_set_word(dev->config + offset + PCI_ATS_CTRL, 0);
> +
> + pci_set_word(dev->wmask + dev->exp.ats_cap + PCI_ATS_CTRL, 0x800f);
> +}
> +
The extra blank line makes git am unhappy:
Applying: virtio-pci: address space translation service (ATS) support
/home/greg/Work/qemu/qemu-master/.git/rebase-apply/patch:32: new blank line at EOF.
> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> index 6ceb43e..e357bdf 100644
> --- a/hw/virtio/virtio-pci.c
> +++ b/hw/virtio/virtio-pci.c
> @@ -1838,6 +1838,11 @@ 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_ats_init(pci_dev, 256);
> + }
> +
> } else {
> /*
> * make future invocations of pci_is_express() return false
> @@ -1889,6 +1894,8 @@ static Property virtio_pci_properties[] = {
> VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT, false),
> DEFINE_PROP_BIT("page-per-vq", VirtIOPCIProxy, flags,
> VIRTIO_PCI_FLAG_PAGE_PER_VQ_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 b4edea6..057d49d 100644
> --- a/hw/virtio/virtio-pci.h
> +++ b/hw/virtio/virtio-pci.h
> @@ -69,6 +69,7 @@ enum {
> VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT,
> VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT,
> VIRTIO_PCI_FLAG_PAGE_PER_VQ_BIT,
> + VIRTIO_PCI_FLAG_ATS_BIT,
> };
>
> /* Need to activate work-arounds for buggy guests at vmstate load. */
> @@ -93,6 +94,9 @@ enum {
> #define VIRTIO_PCI_FLAG_PAGE_PER_VQ \
> (1 << VIRTIO_PCI_FLAG_PAGE_PER_VQ_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/hw/pci/pcie.h b/include/hw/pci/pcie.h
> index 056d25e..b08451d 100644
> --- a/include/hw/pci/pcie.h
> +++ b/include/hw/pci/pcie.h
> @@ -74,6 +74,9 @@ struct PCIExpressDevice {
> /* AER */
> uint16_t aer_cap;
> PCIEAERLog aer_log;
> +
> + /* Offset of ATS capability in config space */
> + uint16_t ats_cap;
> };
>
> #define COMPAT_PROP_PCP "power_controller_present"
> @@ -120,6 +123,7 @@ void pcie_add_capability(PCIDevice *dev,
>
> void pcie_ari_init(PCIDevice *dev, uint16_t offset, uint16_t nextfn);
> void pcie_dev_ser_num_init(PCIDevice *dev, uint16_t offset, uint64_t ser_num);
> +void pcie_ats_init(PCIDevice *dev, uint16_t offset);
>
> extern const VMStateDescription vmstate_pcie_device;
>
> diff --git a/include/standard-headers/linux/pci_regs.h b/include/standard-headers/linux/pci_regs.h
> index 4040951..ac426a0 100644
> --- a/include/standard-headers/linux/pci_regs.h
> +++ b/include/standard-headers/linux/pci_regs.h
> @@ -674,6 +674,7 @@
> #define PCI_EXT_CAP_ID_MAX PCI_EXT_CAP_ID_DPC
>
> #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 */
next prev parent reply other threads:[~2016-11-08 12:25 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-07 7:09 [Qemu-devel] [PATCH V3 00/10] vhost device IOTLB support Jason Wang
2016-11-07 7:09 ` [Qemu-devel] [PATCH V3 01/10] virtio: convert to use DMA api Jason Wang
2016-11-07 7:09 ` [Qemu-devel] [PATCH V3 02/10] intel_iommu: name vtd address space with devfn Jason Wang
2016-12-16 2:53 ` Peter Xu
2016-12-16 3:53 ` Jason Wang
2016-12-30 8:19 ` Jason Wang
2016-12-30 9:22 ` Peter Xu
2016-12-30 10:06 ` Jason Wang
2016-11-07 7:09 ` [Qemu-devel] [PATCH V3 03/10] intel_iommu: allocate new key when creating new address space Jason Wang
2016-11-07 7:09 ` [Qemu-devel] [PATCH V3 04/10] exec: introduce address_space_get_iotlb_entry() Jason Wang
2016-11-07 17:07 ` Paolo Bonzini
2016-11-07 7:09 ` [Qemu-devel] [PATCH V3 05/10] intel_iommu: support device iotlb descriptor Jason Wang
2016-11-07 23:35 ` Peter Xu
2016-11-08 6:54 ` Jason Wang
2016-11-08 20:31 ` Michael S. Tsirkin
2016-11-07 7:09 ` [Qemu-devel] [PATCH V3 06/10] virtio-pci: address space translation service (ATS) support Jason Wang
2016-11-08 12:25 ` Greg Kurz [this message]
2016-11-07 7:09 ` [Qemu-devel] [PATCH V3 07/10] acpi: add ATSR for q35 Jason Wang
2016-11-07 7:09 ` [Qemu-devel] [PATCH V3 08/10] memory: handle alias for iommu notifier Jason Wang
2016-11-07 23:41 ` Peter Xu
2016-11-07 7:09 ` [Qemu-devel] [PATCH V3 09/10] memory: handle alias in memory_region_is_iommu() Jason Wang
2016-11-07 23:42 ` Peter Xu
2016-11-07 7:09 ` [Qemu-devel] [PATCH V3 10/10] 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=20161108132508.3abe2336@bahia \
--to=groug@kaod.org \
--cc=cornelia.huck@de.ibm.com \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vkaplans@redhat.com \
--cc=wexu@redhat.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).