linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/arm-smmu-v3: Invalidate ATC when detaching a device
@ 2019-07-03 11:19 Jean-Philippe Brucker
  2019-07-03 16:57 ` Will Deacon
  2019-07-04  8:07 ` Joerg Roedel
  0 siblings, 2 replies; 3+ messages in thread
From: Jean-Philippe Brucker @ 2019-07-03 11:19 UTC (permalink / raw)
  To: will; +Cc: joro, robin.murphy, iommu, linux-arm-kernel

We make the invalid assumption in arm_smmu_detach_dev() that the ATC is
clear after calling pci_disable_ats(). For one thing, only enabling the
PCIe ATS capability constitutes an implicit invalidation event, so the
comment was wrong. More importantly, the ATS capability isn't necessarily
disabled by pci_disable_ats() in a PF, if the associated VFs have ATS
enabled. Explicitly invalidate all ATC entries in arm_smmu_detach_dev().
The endpoint cannot form new ATC entries because STE.EATS is clear.

Fixes: 9ce27afc0830 ("iommu/arm-smmu-v3: Add support for PCI ATS")
Reported-by: Manoj Kumar <Manoj.Kumar3@arm.com>
Reported-by: Robin Murphy <Robin.Murphy@arm.com>
Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
---
 drivers/iommu/arm-smmu-v3.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index 4d5a694f02c2..0fee8f7957ec 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -1884,9 +1884,13 @@ static int arm_smmu_enable_ats(struct arm_smmu_master *master)
 
 static void arm_smmu_disable_ats(struct arm_smmu_master *master)
 {
+	struct arm_smmu_cmdq_ent cmd;
+
 	if (!master->ats_enabled || !dev_is_pci(master->dev))
 		return;
 
+	arm_smmu_atc_inv_to_cmd(0, 0, 0, &cmd);
+	arm_smmu_atc_inv_master(master, &cmd);
 	pci_disable_ats(to_pci_dev(master->dev));
 	master->ats_enabled = false;
 }
@@ -1906,7 +1910,6 @@ static void arm_smmu_detach_dev(struct arm_smmu_master *master)
 	master->domain = NULL;
 	arm_smmu_install_ste_for_dev(master);
 
-	/* Disabling ATS invalidates all ATC entries */
 	arm_smmu_disable_ats(master);
 }
 
-- 
2.21.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iommu/arm-smmu-v3: Invalidate ATC when detaching a device
  2019-07-03 11:19 [PATCH] iommu/arm-smmu-v3: Invalidate ATC when detaching a device Jean-Philippe Brucker
@ 2019-07-03 16:57 ` Will Deacon
  2019-07-04  8:07 ` Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Will Deacon @ 2019-07-03 16:57 UTC (permalink / raw)
  To: Jean-Philippe Brucker, joro; +Cc: iommu, robin.murphy, linux-arm-kernel

On Wed, Jul 03, 2019 at 12:19:20PM +0100, Jean-Philippe Brucker wrote:
> We make the invalid assumption in arm_smmu_detach_dev() that the ATC is
> clear after calling pci_disable_ats(). For one thing, only enabling the
> PCIe ATS capability constitutes an implicit invalidation event, so the
> comment was wrong. More importantly, the ATS capability isn't necessarily
> disabled by pci_disable_ats() in a PF, if the associated VFs have ATS
> enabled. Explicitly invalidate all ATC entries in arm_smmu_detach_dev().
> The endpoint cannot form new ATC entries because STE.EATS is clear.
> 
> Fixes: 9ce27afc0830 ("iommu/arm-smmu-v3: Add support for PCI ATS")
> Reported-by: Manoj Kumar <Manoj.Kumar3@arm.com>
> Reported-by: Robin Murphy <Robin.Murphy@arm.com>
> Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
> ---
>  drivers/iommu/arm-smmu-v3.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Acked-by: Will Deacon <will@kernel.org>

Hopefully Joerg can add this to his queue for 5.3.

Thanks,

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iommu/arm-smmu-v3: Invalidate ATC when detaching a device
  2019-07-03 11:19 [PATCH] iommu/arm-smmu-v3: Invalidate ATC when detaching a device Jean-Philippe Brucker
  2019-07-03 16:57 ` Will Deacon
@ 2019-07-04  8:07 ` Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2019-07-04  8:07 UTC (permalink / raw)
  To: Jean-Philippe Brucker; +Cc: robin.murphy, iommu, will, linux-arm-kernel

On Wed, Jul 03, 2019 at 12:19:20PM +0100, Jean-Philippe Brucker wrote:
>  drivers/iommu/arm-smmu-v3.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Applied, thanks.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-04  8:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-03 11:19 [PATCH] iommu/arm-smmu-v3: Invalidate ATC when detaching a device Jean-Philippe Brucker
2019-07-03 16:57 ` Will Deacon
2019-07-04  8:07 ` 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).