Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1389853
| From | Eric Auger <eric.auger@linaro.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v8 6/8] iommu/msi-iommu: iommu_msi_domain |
| Date | 2016-04-28 10:20 +0200 |
| Message-ID | <rsPl1-8pu-39@gated-at.bofh.it> (permalink) |
| References | <rsPl0-8pu-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
This function checks whether
- the device belongs to a non default iommu domain
- this iommu domain requires the MSI address to be mapped.
If those conditions are met, the function returns the iommu domain
to be used for mapping the MSI doorbell; else it returns NULL.
Signed-off-by: Eric Auger <eric.auger@linaro.org>
---
v7 -> v8:
- renamed iommu_msi_mapping_desc_to_domain to iommu_msi_domain
- the function now takes a struct device *
- use DOMAIN_ATTR_MSI_GEOMETRY attribute
---
drivers/iommu/msi-iommu.c | 17 +++++++++++++++++
include/linux/msi-iommu.h | 14 ++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/drivers/iommu/msi-iommu.c b/drivers/iommu/msi-iommu.c
index 203e86e..023ff17 100644
--- a/drivers/iommu/msi-iommu.c
+++ b/drivers/iommu/msi-iommu.c
@@ -243,3 +243,20 @@ unlock:
}
}
EXPORT_SYMBOL_GPL(iommu_msi_put_doorbell_iova);
+
+struct iommu_domain *iommu_msi_domain(struct device *dev)
+{
+ struct iommu_domain *d = iommu_get_domain_for_dev(dev);
+ struct iommu_domain_msi_geometry msi_geometry;
+
+ if (!d || (d->type == IOMMU_DOMAIN_DMA))
+ return NULL;
+
+ iommu_domain_get_attr(d, DOMAIN_ATTR_MSI_GEOMETRY, &msi_geometry);
+ if (!msi_geometry.programmable)
+ return NULL;
+
+ return d;
+}
+EXPORT_SYMBOL_GPL(iommu_msi_domain);
+
diff --git a/include/linux/msi-iommu.h b/include/linux/msi-iommu.h
index 1cd115f..114bd69 100644
--- a/include/linux/msi-iommu.h
+++ b/include/linux/msi-iommu.h
@@ -81,6 +81,15 @@ int iommu_msi_get_doorbell_iova(struct iommu_domain *domain,
*/
void iommu_msi_put_doorbell_iova(struct iommu_domain *domain, phys_addr_t addr);
+/**
+ * iommu_msi_domain: in case the device is upstream to an IOMMU and this IOMMU
+ * translates the MSI transaction, returns the iommu domain the MSI doorbell
+ * address must be mapped in; else returns NULL.
+ *
+ * @dev: device handle
+ */
+struct iommu_domain *iommu_msi_domain(struct device *dev);
+
#else
static inline int
@@ -100,5 +109,10 @@ static inline int iommu_msi_get_doorbell_iova(struct iommu_domain *domain,
static inline void iommu_msi_put_doorbell_iova(struct iommu_domain *domain,
phys_addr_t addr) {}
+static inline struct iommu_domain *iommu_msi_domain(struct device *dev)
+{
+ return NULL;
+}
+
#endif /* CONFIG_IOMMU_MSI */
#endif /* __MSI_IOMMU_H */
--
1.9.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v8 0/8] KVM PCIe/MSI passthrough on ARM/ARM64: kernel part 1/3: iommu changes Eric Auger <eric.auger@linaro.org> - 2016-04-28 10:20 +0200
[PATCH v8 2/8] iommu/arm-smmu: sets the MSI geometry to programmable Eric Auger <eric.auger@linaro.org> - 2016-04-28 10:20 +0200
[PATCH v8 3/8] iommu: introduce an msi cookie Eric Auger <eric.auger@linaro.org> - 2016-04-28 10:20 +0200
[PATCH v8 7/8] iommu/msi-iommu: iommu_msi_msg_pa_to_va Eric Auger <eric.auger@linaro.org> - 2016-04-28 10:20 +0200
[PATCH v8 5/8] iommu/msi-iommu: iommu_msi_[get,put]_doorbell_iova Eric Auger <eric.auger@linaro.org> - 2016-04-28 10:20 +0200
[PATCH v8 8/8] iommu/arm-smmu: get/put the msi cookie Eric Auger <eric.auger@linaro.org> - 2016-04-28 10:20 +0200
[PATCH v8 6/8] iommu/msi-iommu: iommu_msi_domain Eric Auger <eric.auger@linaro.org> - 2016-04-28 10:20 +0200
Re: [PATCH v8 6/8] iommu/msi-iommu: iommu_msi_domain Alex Williamson <alex.williamson@redhat.com> - 2016-04-29 00:30 +0200
Re: [PATCH v8 6/8] iommu/msi-iommu: iommu_msi_domain Eric Auger <eric.auger@linaro.org> - 2016-05-02 17:50 +0200
Re: [PATCH v8 6/8] iommu/msi-iommu: iommu_msi_domain Alex Williamson <alex.williamson@redhat.com> - 2016-05-02 22:30 +0200
Re: [PATCH v8 6/8] iommu/msi-iommu: iommu_msi_domain Eric Auger <eric.auger@linaro.org> - 2016-05-03 14:30 +0200
[PATCH v8 4/8] iommu/msi-iommu: initialization Eric Auger <eric.auger@linaro.org> - 2016-04-28 10:20 +0200
[PATCH v8 1/8] iommu: Add iommu_domain_msi_geometry and DOMAIN_ATTR_MSI_GEOMETRY Eric Auger <eric.auger@linaro.org> - 2016-04-28 10:20 +0200
csiph-web