* [PATCH 0/2] iommu/arm-smmu: Fixed for 4.6
@ 2016-04-20 13:53 Will Deacon
[not found] ` <1461160413-15403-1-git-send-email-will.deacon-5wv7dgnIgG8@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Will Deacon @ 2016-04-20 13:53 UTC (permalink / raw)
To: jroedel-l3A5Bk7waGM
Cc: yang.shi-QSEj5FYQhm4dnm+yROfE0A,
eric.auger-QSEj5FYQhm4dnm+yROfE0A, Will Deacon,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Hi Joerg,
Please can you take these two related arm-smmu fixes for 4.6? They
address a regression seem by both Eric and Yang following the partial
support for default domains that we added during the merge window.
I can send a pull request if you prefer, but it doesn't seem necessary
to me.
Thanks!
Will
--->8
Robin Murphy (1):
iommu/arm-smmu: Don't allocate resources for bypass domains
Will Deacon (1):
iommu/arm-smmu: Fix stream-match conflict with IOMMU_DOMAIN_DMA
drivers/iommu/arm-smmu.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
--
2.1.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] iommu/arm-smmu: Fix stream-match conflict with IOMMU_DOMAIN_DMA
[not found] ` <1461160413-15403-1-git-send-email-will.deacon-5wv7dgnIgG8@public.gmane.org>
@ 2016-04-20 13:53 ` Will Deacon
2016-04-20 13:53 ` [PATCH 2/2] iommu/arm-smmu: Don't allocate resources for bypass domains Will Deacon
2016-04-21 14:51 ` [PATCH 0/2] iommu/arm-smmu: Fixed for 4.6 Joerg Roedel
2 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2016-04-20 13:53 UTC (permalink / raw)
To: jroedel-l3A5Bk7waGM
Cc: yang.shi-QSEj5FYQhm4dnm+yROfE0A,
eric.auger-QSEj5FYQhm4dnm+yROfE0A, Will Deacon,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Commit cbf8277ef456 ("iommu/arm-smmu: Treat IOMMU_DOMAIN_DMA as bypass
for now") ignores requests to attach a device to the default domain
since, without IOMMU-basked DMA ops available everywhere, the default
domain will just lead to unexpected transaction faults being reported.
Unfortunately, the way this was implemented on SMMUv2 causes a
regression with VFIO PCI device passthrough under KVM on AMD Seattle.
On this system, the host controller device is associated with both a
pci_dev *and* a platform_device, and can therefore end up with duplicate
SMR entries, resulting in a stream-match conflict at runtime.
This patch amends the original fix so that attaching to IOMMU_DOMAIN_DMA
is rejected even before configuring the SMRs. This restores the old
behaviour for now, but we'll need to look at handing host controllers
specially when we come to supporting the default domain fully.
Reported-by: Eric Auger <eric.auger-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Tested-by: Eric Auger <eric.auger-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Tested-by: Yang Shi <yang.shi-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Signed-off-by: Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>
---
drivers/iommu/arm-smmu.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 2409e3bd3df2..5158febd889d 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1089,18 +1089,20 @@ static int arm_smmu_domain_add_master(struct arm_smmu_domain *smmu_domain,
struct arm_smmu_device *smmu = smmu_domain->smmu;
void __iomem *gr0_base = ARM_SMMU_GR0(smmu);
- /* Devices in an IOMMU group may already be configured */
- ret = arm_smmu_master_configure_smrs(smmu, cfg);
- if (ret)
- return ret == -EEXIST ? 0 : ret;
-
/*
* FIXME: This won't be needed once we have IOMMU-backed DMA ops
- * for all devices behind the SMMU.
+ * for all devices behind the SMMU. Note that we need to take
+ * care configuring SMRs for devices both a platform_device and
+ * and a PCI device (i.e. a PCI host controller)
*/
if (smmu_domain->domain.type == IOMMU_DOMAIN_DMA)
return 0;
+ /* Devices in an IOMMU group may already be configured */
+ ret = arm_smmu_master_configure_smrs(smmu, cfg);
+ if (ret)
+ return ret == -EEXIST ? 0 : ret;
+
for (i = 0; i < cfg->num_streamids; ++i) {
u32 idx, s2cr;
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] iommu/arm-smmu: Don't allocate resources for bypass domains
[not found] ` <1461160413-15403-1-git-send-email-will.deacon-5wv7dgnIgG8@public.gmane.org>
2016-04-20 13:53 ` [PATCH 1/2] iommu/arm-smmu: Fix stream-match conflict with IOMMU_DOMAIN_DMA Will Deacon
@ 2016-04-20 13:53 ` Will Deacon
2016-04-21 14:51 ` [PATCH 0/2] iommu/arm-smmu: Fixed for 4.6 Joerg Roedel
2 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2016-04-20 13:53 UTC (permalink / raw)
To: jroedel-l3A5Bk7waGM
Cc: yang.shi-QSEj5FYQhm4dnm+yROfE0A,
eric.auger-QSEj5FYQhm4dnm+yROfE0A, Will Deacon,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
From: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
Until we get fully plumbed into of_iommu_configure, our default
IOMMU_DOMAIN_DMA domains just bypass translation. Since we achieve that
by leaving the stream table entries set to bypass instead of pointing at
a translation context, the context bank we allocate for the domain is
completely wasted. Context banks are typically a rather limited
resource, so don't hog ones we don't need.
Reported-by: Eric Auger <eric.auger-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Tested-by: Eric Auger <eric.auger-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Signed-off-by: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
Signed-off-by: Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>
---
drivers/iommu/arm-smmu.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 5158febd889d..7c39ac4b9c53 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -826,6 +826,12 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
if (smmu_domain->smmu)
goto out_unlock;
+ /* We're bypassing these SIDs, so don't allocate an actual context */
+ if (domain->type == IOMMU_DOMAIN_DMA) {
+ smmu_domain->smmu = smmu;
+ goto out_unlock;
+ }
+
/*
* Mapping the requested stage onto what we support is surprisingly
* complicated, mainly because the spec allows S1+S2 SMMUs without
@@ -948,7 +954,7 @@ static void arm_smmu_destroy_domain_context(struct iommu_domain *domain)
void __iomem *cb_base;
int irq;
- if (!smmu)
+ if (!smmu || domain->type == IOMMU_DOMAIN_DMA)
return;
/*
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] iommu/arm-smmu: Fixed for 4.6
[not found] ` <1461160413-15403-1-git-send-email-will.deacon-5wv7dgnIgG8@public.gmane.org>
2016-04-20 13:53 ` [PATCH 1/2] iommu/arm-smmu: Fix stream-match conflict with IOMMU_DOMAIN_DMA Will Deacon
2016-04-20 13:53 ` [PATCH 2/2] iommu/arm-smmu: Don't allocate resources for bypass domains Will Deacon
@ 2016-04-21 14:51 ` Joerg Roedel
2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2016-04-21 14:51 UTC (permalink / raw)
To: Will Deacon
Cc: yang.shi-QSEj5FYQhm4dnm+yROfE0A,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
eric.auger-QSEj5FYQhm4dnm+yROfE0A
On Wed, Apr 20, 2016 at 02:53:31PM +0100, Will Deacon wrote:
> Hi Joerg,
>
> Please can you take these two related arm-smmu fixes for 4.6? They
> address a regression seem by both Eric and Yang following the partial
> support for default domains that we added during the merge window.
>
> I can send a pull request if you prefer, but it doesn't seem necessary
> to me.
Sure, applied both. Thanks Will.
Joerg
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-04-21 14:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-20 13:53 [PATCH 0/2] iommu/arm-smmu: Fixed for 4.6 Will Deacon
[not found] ` <1461160413-15403-1-git-send-email-will.deacon-5wv7dgnIgG8@public.gmane.org>
2016-04-20 13:53 ` [PATCH 1/2] iommu/arm-smmu: Fix stream-match conflict with IOMMU_DOMAIN_DMA Will Deacon
2016-04-20 13:53 ` [PATCH 2/2] iommu/arm-smmu: Don't allocate resources for bypass domains Will Deacon
2016-04-21 14:51 ` [PATCH 0/2] iommu/arm-smmu: Fixed for 4.6 Joerg Roedel
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).