From: Eric Auger <eric.auger@redhat.com>
To: eric.auger.pro@gmail.com, eric.auger@redhat.com,
iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
joro@8bytes.org, alex.williamson@redhat.com,
jacob.jun.pan@linux.intel.com, yi.l.liu@intel.com,
jean-philippe.brucker@arm.com, will.deacon@arm.com,
robin.murphy@arm.com
Cc: marc.zyngier@arm.com
Subject: [PATCH v10 10/11] vfio/pci: Register and allow DMA FAULT IRQ signaling
Date: Fri, 20 Mar 2020 17:19:10 +0100 [thread overview]
Message-ID: <20200320161911.27494-11-eric.auger@redhat.com> (raw)
In-Reply-To: <20200320161911.27494-1-eric.auger@redhat.com>
Register the VFIO_IRQ_TYPE_NESTED/VFIO_IRQ_SUBTYPE_DMA_FAULT
IRQ that allows to signal a nested mode DMA fault.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
drivers/vfio/pci/vfio_pci.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index ca13067e4718..70e3a31da9f0 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -346,7 +346,7 @@ int vfio_pci_iommu_dev_fault_handler(struct iommu_fault *fault, void *data)
struct iommu_fault *new =
(struct iommu_fault *)(vdev->fault_pages + reg->offset +
reg->head * reg->entry_size);
- int head, tail, size;
+ int head, tail, size, ext_irq_index;
int ret = 0;
if (fault->type != IOMMU_FAULT_DMA_UNRECOV)
@@ -367,7 +367,19 @@ int vfio_pci_iommu_dev_fault_handler(struct iommu_fault *fault, void *data)
reg->head = (head + 1) % size;
unlock:
mutex_unlock(&vdev->fault_queue_lock);
- return ret;
+ if (ret)
+ return ret;
+
+ ext_irq_index = vfio_pci_get_ext_irq_index(vdev, VFIO_IRQ_TYPE_NESTED,
+ VFIO_IRQ_SUBTYPE_DMA_FAULT);
+ if (ext_irq_index < 0)
+ return -EINVAL;
+
+ mutex_lock(&vdev->igate);
+ if (vdev->ext_irqs[ext_irq_index].trigger)
+ eventfd_signal(vdev->ext_irqs[ext_irq_index].trigger, 1);
+ mutex_unlock(&vdev->igate);
+ return 0;
}
#define DMA_FAULT_RING_LENGTH 512
@@ -520,6 +532,12 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
if (ret)
goto disable_exit;
+ ret = vfio_pci_register_irq(vdev, VFIO_IRQ_TYPE_NESTED,
+ VFIO_IRQ_SUBTYPE_DMA_FAULT,
+ VFIO_IRQ_INFO_EVENTFD);
+ if (ret)
+ goto disable_exit;
+
vfio_pci_probe_mmaps(vdev);
return 0;
--
2.20.1
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
next prev parent reply other threads:[~2020-03-20 16:21 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-20 16:19 [PATCH v10 00/11] SMMUv3 Nested Stage Setup (VFIO part) Eric Auger
2020-03-20 16:19 ` [PATCH v10 01/11] vfio: VFIO_IOMMU_SET_PASID_TABLE Eric Auger
2020-03-21 5:18 ` kbuild test robot
2020-09-23 11:27 ` Zenghui Yu
2020-09-23 11:47 ` Auger Eric
2020-10-27 12:20 ` Shameerali Kolothum Thodi
2020-10-27 13:04 ` Auger Eric
2020-03-20 16:19 ` [PATCH v10 02/11] vfio: VFIO_IOMMU_CACHE_INVALIDATE Eric Auger
2020-03-20 16:19 ` [PATCH v10 03/11] vfio: VFIO_IOMMU_SET_MSI_BINDING Eric Auger
2020-03-20 16:19 ` [PATCH v10 04/11] vfio/pci: Add VFIO_REGION_TYPE_NESTED region type Eric Auger
2020-04-01 13:18 ` Liu, Yi L
2020-04-01 13:31 ` Auger Eric
2020-04-06 6:29 ` Liu, Yi L
2020-09-24 8:23 ` Zenghui Yu
2020-11-13 16:12 ` Auger Eric
2020-03-20 16:19 ` [PATCH v10 05/11] vfio/pci: Register an iommu fault handler Eric Auger
2020-09-24 8:49 ` Zenghui Yu
2020-11-13 16:11 ` Auger Eric
2020-03-20 16:19 ` [PATCH v10 06/11] vfio/pci: Allow to mmap the fault queue Eric Auger
2020-03-20 16:19 ` [PATCH v10 07/11] vfio: Use capability chains to handle device specific irq Eric Auger
2020-03-20 16:19 ` [PATCH v10 08/11] vfio: Add new IRQ for DMA fault reporting Eric Auger
2020-03-20 16:19 ` [PATCH v10 09/11] vfio/pci: Add framework for custom interrupt indices Eric Auger
2020-03-20 16:19 ` Eric Auger [this message]
2020-03-20 16:19 ` [PATCH v10 11/11] vfio: Document nested stage control Eric Auger
2020-09-24 13:42 ` Zenghui Yu
2020-10-06 15:29 ` Auger Eric
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=20200320161911.27494-11-eric.auger@redhat.com \
--to=eric.auger@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=eric.auger.pro@gmail.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jean-philippe.brucker@arm.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=robin.murphy@arm.com \
--cc=will.deacon@arm.com \
--cc=yi.l.liu@intel.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).