From: eric.auger@redhat.com (Eric Auger)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v14 06/16] iommu/arm-smmu: Implement domain_get_attr for DOMAIN_ATTR_MSI_RESV
Date: Wed, 12 Oct 2016 13:22:14 +0000 [thread overview]
Message-ID: <1476278544-3397-7-git-send-email-eric.auger@redhat.com> (raw)
In-Reply-To: <1476278544-3397-1-git-send-email-eric.auger@redhat.com>
ARM smmu and smmu-v3 translate MSI transactions so their driver
are must implement domain_get_attr for DOMAIN_ATTR_MSI_RESV.
This allows to retrieve the size and alignment requirements of
the MSI reserved IOVA window.
Also IOMMU_DMA gets selected since it exposes the API to map the
MSIs.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
drivers/iommu/Kconfig | 4 ++--
drivers/iommu/arm-smmu-v3.c | 7 +++++++
drivers/iommu/arm-smmu.c | 7 +++++++
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
index 8ee54d7..f5e5e4b 100644
--- a/drivers/iommu/Kconfig
+++ b/drivers/iommu/Kconfig
@@ -297,7 +297,7 @@ config SPAPR_TCE_IOMMU
config ARM_SMMU
bool "ARM Ltd. System MMU (SMMU) Support"
depends on (ARM64 || ARM) && MMU
- select IOMMU_API
+ select IOMMU_DMA
select IOMMU_IO_PGTABLE_LPAE
select ARM_DMA_USE_IOMMU if ARM
help
@@ -310,7 +310,7 @@ config ARM_SMMU
config ARM_SMMU_V3
bool "ARM Ltd. System MMU Version 3 (SMMUv3) Support"
depends on ARM64
- select IOMMU_API
+ select IOMMU_DMA
select IOMMU_IO_PGTABLE_LPAE
select GENERIC_MSI_IRQ_DOMAIN
help
diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index 15c01c3..572cad8 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -1559,6 +1559,9 @@ static int arm_smmu_domain_finalise(struct iommu_domain *domain)
if (ret < 0)
free_io_pgtable_ops(pgtbl_ops);
+ if (domain->type == IOMMU_DOMAIN_UNMANAGED)
+ iommu_calc_msi_resv(domain);
+
return ret;
}
@@ -1840,6 +1843,10 @@ static int arm_smmu_domain_get_attr(struct iommu_domain *domain,
case DOMAIN_ATTR_NESTING:
*(int *)data = (smmu_domain->stage == ARM_SMMU_DOMAIN_NESTED);
return 0;
+ case DOMAIN_ATTR_MSI_RESV:
+ *(struct iommu_domain_msi_resv *)data =
+ smmu_domain->domain.msi_resv;
+ return 0;
default:
return -ENODEV;
}
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index ac4aab9..ae20b9c 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -943,6 +943,9 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
domain->geometry.aperture_end = (1UL << ias) - 1;
domain->geometry.force_aperture = true;
+ if (domain->type == IOMMU_DOMAIN_UNMANAGED)
+ iommu_calc_msi_resv(domain);
+
/* Initialise the context bank with our page table cfg */
arm_smmu_init_context_bank(smmu_domain, &pgtbl_cfg);
@@ -1486,6 +1489,10 @@ static int arm_smmu_domain_get_attr(struct iommu_domain *domain,
case DOMAIN_ATTR_NESTING:
*(int *)data = (smmu_domain->stage == ARM_SMMU_DOMAIN_NESTED);
return 0;
+ case DOMAIN_ATTR_MSI_RESV:
+ *(struct iommu_domain_msi_resv *)data =
+ smmu_domain->domain.msi_resv;
+ return 0;
default:
return -ENODEV;
}
--
1.9.1
next prev parent reply other threads:[~2016-10-12 13:22 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-12 13:22 [PATCH v14 00/16] KVM PCIe/MSI passthrough on ARM/ARM64 Eric Auger
2016-10-12 13:22 ` [PATCH v14 01/16] iommu/iova: fix __alloc_and_insert_iova_range Eric Auger
2016-10-12 13:22 ` [PATCH v14 02/16] iommu: Introduce DOMAIN_ATTR_MSI_RESV Eric Auger
2016-10-12 13:22 ` [PATCH v14 03/16] iommu/dma: Allow MSI-only cookies Eric Auger
2016-10-12 13:22 ` [PATCH v14 04/16] iommu/dma: MSI doorbell alloc/free Eric Auger
2016-10-14 11:25 ` Punit Agrawal
2016-10-17 14:25 ` Auger Eric
2016-10-12 13:22 ` [PATCH v14 05/16] iommu/dma: Introduce iommu_calc_msi_resv Eric Auger
2016-10-12 13:22 ` Eric Auger [this message]
2016-10-12 13:22 ` [PATCH v14 07/16] irqchip/gic-v2m: Register the MSI doorbell Eric Auger
2016-10-12 13:22 ` [PATCH v14 08/16] irqchip/gicv3-its: " Eric Auger
2016-10-12 13:22 ` [PATCH v14 09/16] vfio: Introduce a vfio_dma type field Eric Auger
2016-10-12 13:22 ` [PATCH v14 10/16] vfio/type1: vfio_find_dma accepting a type argument Eric Auger
2016-10-12 13:22 ` [PATCH v14 11/16] vfio/type1: Implement recursive vfio_find_dma_from_node Eric Auger
2016-10-12 13:22 ` [PATCH v14 12/16] vfio/type1: Handle unmap/unpin and replay for VFIO_IOVA_RESERVED slots Eric Auger
2016-10-12 13:22 ` [PATCH v14 13/16] vfio: Allow reserved msi iova registration Eric Auger
2016-10-12 13:22 ` [PATCH v14 14/16] vfio/type1: Check doorbell safety Eric Auger
2016-11-03 13:45 ` Diana Madalina Craciun
2016-11-03 14:14 ` Auger Eric
2016-10-12 13:22 ` [PATCH v14 15/16] iommu/arm-smmu: Do not advertise IOMMU_CAP_INTR_REMAP Eric Auger
2016-10-12 13:22 ` [PATCH v14 16/16] vfio/type1: Introduce MSI_RESV capability Eric Auger
2016-10-14 11:24 ` [PATCH v14 00/16] KVM PCIe/MSI passthrough on ARM/ARM64 Punit Agrawal
2016-10-17 14:19 ` Auger Eric
2016-10-17 15:08 ` Punit Agrawal
2016-10-20 17:32 ` Will Deacon
2016-10-21 9:26 ` Auger Eric
2016-10-24 19:39 ` Robin Murphy
2016-11-02 16:15 ` 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=1476278544-3397-7-git-send-email-eric.auger@redhat.com \
--to=eric.auger@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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).