Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1416368

[PATCH v10 9/9] genirq/msi: use the MSI doorbell's IOVA when requested

From Eric Auger <eric.auger@redhat.com>
Newsgroups linux.kernel
Subject [PATCH v10 9/9] genirq/msi: use the MSI doorbell's IOVA when requested
Date 2016-06-07 18:10 +0200
Message-ID <rHrJM-4Rf-51@gated-at.bofh.it> (permalink)
References <rHrJL-4Rf-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On MSI message composition we now use the MSI doorbell's IOVA in
place of the doorbell's PA in case the device is upstream to an
IOMMU that requires MSI addresses to be mapped. The doorbell's
allocation and mapping happened on an early stage (pci_enable_msi).

Signed-off-by: Eric Auger <eric.auger@redhat.com>

---
v8 -> v9:
- Braces on both sides of the 'else' in msi_compose

v7 -> v8:
- use iommu_msi_msg_pa_to_va
- add WARN_ON

v6 -> v7:
- allocation/mapping is done at an earlier stage. We now just perform
  the iova lookup. So it is safe now to be called in a code that cannot
  sleep. iommu_msi_set_doorbell_iova is moved in the dma-reserved-iommu
  API: I think it cleans things up with respect to various #ifdef CONFIGS.

v5:
- use macros to increase the readability
- add comments
- fix a typo that caused a compilation error if CONFIG_IOMMU_API
  is not set
---
 kernel/irq/msi.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
index a78db5f..e731949 100644
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -63,10 +63,18 @@ static int msi_compose(struct irq_data *irq_data,
 {
 	int ret = 0;
 
-	if (erase)
+	if (erase) {
 		memset(msg, 0, sizeof(*msg));
-	else
+	} else {
+		struct device *dev;
+
 		ret = irq_chip_compose_msi_msg(irq_data, msg);
+		if (ret)
+			return ret;
+
+		dev = msi_desc_to_dev(irq_data_get_msi_desc(irq_data));
+		WARN_ON(iommu_msi_msg_pa_to_va(dev, msg));
+	}
 
 	return ret;
 }
-- 
1.9.1

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v10 0/9] KVM PCIe/MSI passthrough on ARM/ARM64: kernel part 2/3: msi changes Eric Auger <eric.auger@redhat.com> - 2016-06-07 18:10 +0200
  [PATCH v10 5/9] genirq/msi-doorbell: msi_doorbell_safe Eric Auger <eric.auger@redhat.com> - 2016-06-07 18:10 +0200
  [PATCH v10 3/9] genirq/msi-doorbell: creation Eric Auger <eric.auger@redhat.com> - 2016-06-07 18:10 +0200
  [PATCH v10 2/9] genirq/msi: msi_compose wrapper Eric Auger <eric.auger@redhat.com> - 2016-06-07 18:10 +0200
  [PATCH v10 1/9] genirq/msi: export msi_get_domain_info Eric Auger <eric.auger@redhat.com> - 2016-06-07 18:10 +0200
  [PATCH v10 7/9] irqchip/gicv3-its: register the MSI global doorbell Eric Auger <eric.auger@redhat.com> - 2016-06-07 18:10 +0200
  [PATCH v10 6/9] irqchip/gicv2m: register the MSI global doorbell Eric Auger <eric.auger@redhat.com> - 2016-06-07 18:10 +0200
  [PATCH v10 8/9] genirq/msi: map/unmap the MSI doorbells on msi_domain_alloc/free_irqs Eric Auger <eric.auger@redhat.com> - 2016-06-07 18:10 +0200
  [PATCH v10 4/9] genirq/msi-doorbell: msi_doorbell_pages Eric Auger <eric.auger@redhat.com> - 2016-06-07 18:10 +0200
  [PATCH v10 9/9] genirq/msi: use the MSI doorbell's IOVA when requested Eric Auger <eric.auger@redhat.com> - 2016-06-07 18:10 +0200

csiph-web