mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [Patch 0/3] Pending AMD IOMMU patches
@ 2011-12-22 14:01 Joerg Roedel
  2011-12-22 14:01 ` [PATCH 1/3] iommu/amd: Remove unnecessary cache flushes in amd_iommu_resume Joerg Roedel
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Joerg Roedel @ 2011-12-22 14:01 UTC (permalink / raw)
  To: iommu; +Cc: linux-kernel

Hi,

here are 3 pending patches from my AMD IOMMU queue. No real bug-fixes in
there.  The patches just increase consistency and robustnes of the AMD
IOMMU driver.


	Joerg

Diffstat:

 drivers/iommu/amd_iommu.c       |    2 ++
 drivers/iommu/amd_iommu_init.c  |   20 +++++++++++++-------
 drivers/iommu/amd_iommu_types.h |   10 ++++++++++
 3 files changed, 25 insertions(+), 7 deletions(-)



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

* [PATCH 1/3] iommu/amd: Remove unnecessary cache flushes in amd_iommu_resume
  2011-12-22 14:01 [Patch 0/3] Pending AMD IOMMU patches Joerg Roedel
@ 2011-12-22 14:01 ` Joerg Roedel
  2011-12-22 14:01 ` [PATCH 2/3] iommu/amd: Init stats for iommu=pt Joerg Roedel
  2011-12-22 14:01 ` [PATCH 3/3] iommu/amd: Set IOTLB invalidation timeout Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2011-12-22 14:01 UTC (permalink / raw)
  To: iommu; +Cc: linux-kernel, Joerg Roedel

The caches are already flushed in enable_iommus(), so this
flush is not necessary.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 drivers/iommu/amd_iommu_init.c |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index c7a5d7e..38784733 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -1396,13 +1396,6 @@ static void amd_iommu_resume(void)
 
 	/* re-load the hardware */
 	enable_iommus();
-
-	/*
-	 * we have to flush after the IOMMUs are enabled because a
-	 * disabled IOMMU will never execute the commands we send
-	 */
-	for_each_iommu(iommu)
-		iommu_flush_all_caches(iommu);
 }
 
 static int amd_iommu_suspend(void)
-- 
1.7.5.4



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

* [PATCH 2/3] iommu/amd: Init stats for iommu=pt
  2011-12-22 14:01 [Patch 0/3] Pending AMD IOMMU patches Joerg Roedel
  2011-12-22 14:01 ` [PATCH 1/3] iommu/amd: Remove unnecessary cache flushes in amd_iommu_resume Joerg Roedel
@ 2011-12-22 14:01 ` Joerg Roedel
  2011-12-22 14:01 ` [PATCH 3/3] iommu/amd: Set IOTLB invalidation timeout Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2011-12-22 14:01 UTC (permalink / raw)
  To: iommu; +Cc: linux-kernel, Joerg Roedel

The IOMMUv2 driver added a few statistic counter which are
interesting in the iommu=pt mode too. So initialize the
statistic counter for that mode too.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 drivers/iommu/amd_iommu.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index cfcc524..30e895d 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -3222,6 +3222,8 @@ int __init amd_iommu_init_passthrough(void)
 		attach_device(&dev->dev, pt_domain);
 	}
 
+	amd_iommu_stats_init();
+
 	pr_info("AMD-Vi: Initialized for Passthrough Mode\n");
 
 	return 0;
-- 
1.7.5.4



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

* [PATCH 3/3] iommu/amd: Set IOTLB invalidation timeout
  2011-12-22 14:01 [Patch 0/3] Pending AMD IOMMU patches Joerg Roedel
  2011-12-22 14:01 ` [PATCH 1/3] iommu/amd: Remove unnecessary cache flushes in amd_iommu_resume Joerg Roedel
  2011-12-22 14:01 ` [PATCH 2/3] iommu/amd: Init stats for iommu=pt Joerg Roedel
@ 2011-12-22 14:01 ` Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2011-12-22 14:01 UTC (permalink / raw)
  To: iommu; +Cc: linux-kernel, Joerg Roedel

To protect the command buffer from hanging when a device
does not respond to an IOTLB invalidation, set a timeout of
1s for outstanding IOTLB invalidations.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 drivers/iommu/amd_iommu_init.c  |   13 +++++++++++++
 drivers/iommu/amd_iommu_types.h |   10 ++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 38784733..bdea288 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -306,6 +306,16 @@ static void iommu_feature_disable(struct amd_iommu *iommu, u8 bit)
 	writel(ctrl, iommu->mmio_base + MMIO_CONTROL_OFFSET);
 }
 
+static void iommu_set_inv_tlb_timeout(struct amd_iommu *iommu, int timeout)
+{
+	u32 ctrl;
+
+	ctrl = readl(iommu->mmio_base + MMIO_CONTROL_OFFSET);
+	ctrl &= ~CTRL_INV_TO_MASK;
+	ctrl |= (timeout << CONTROL_INV_TIMEOUT) & CTRL_INV_TO_MASK;
+	writel(ctrl, iommu->mmio_base + MMIO_CONTROL_OFFSET);
+}
+
 /* Function to enable the hardware */
 static void iommu_enable(struct amd_iommu *iommu)
 {
@@ -1300,6 +1310,9 @@ static void iommu_init_flags(struct amd_iommu *iommu)
 	 * make IOMMU memory accesses cache coherent
 	 */
 	iommu_feature_enable(iommu, CONTROL_COHERENT_EN);
+
+	/* Set IOTLB invalidation timeout to 1s */
+	iommu_set_inv_tlb_timeout(iommu, CTRL_INV_TO_1S);
 }
 
 static void iommu_apply_resume_quirks(struct amd_iommu *iommu)
diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h
index 6ad8b10..2452f3b 100644
--- a/drivers/iommu/amd_iommu_types.h
+++ b/drivers/iommu/amd_iommu_types.h
@@ -127,6 +127,7 @@
 #define CONTROL_EVT_LOG_EN      0x02ULL
 #define CONTROL_EVT_INT_EN      0x03ULL
 #define CONTROL_COMWAIT_EN      0x04ULL
+#define CONTROL_INV_TIMEOUT	0x05ULL
 #define CONTROL_PASSPW_EN       0x08ULL
 #define CONTROL_RESPASSPW_EN    0x09ULL
 #define CONTROL_COHERENT_EN     0x0aULL
@@ -137,6 +138,15 @@
 #define CONTROL_PPR_EN          0x0fULL
 #define CONTROL_GT_EN           0x10ULL
 
+#define CTRL_INV_TO_MASK	(7 << CONTROL_INV_TIMEOUT)
+#define CTRL_INV_TO_NONE	0
+#define CTRL_INV_TO_1MS		1
+#define CTRL_INV_TO_10MS	2
+#define CTRL_INV_TO_100MS	3
+#define CTRL_INV_TO_1S		4
+#define CTRL_INV_TO_10S		5
+#define CTRL_INV_TO_100S	6
+
 /* command specific defines */
 #define CMD_COMPL_WAIT          0x01
 #define CMD_INV_DEV_ENTRY       0x02
-- 
1.7.5.4



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

end of thread, other threads:[~2011-12-22 14:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-22 14:01 [Patch 0/3] Pending AMD IOMMU patches Joerg Roedel
2011-12-22 14:01 ` [PATCH 1/3] iommu/amd: Remove unnecessary cache flushes in amd_iommu_resume Joerg Roedel
2011-12-22 14:01 ` [PATCH 2/3] iommu/amd: Init stats for iommu=pt Joerg Roedel
2011-12-22 14:01 ` [PATCH 3/3] iommu/amd: Set IOTLB invalidation timeout Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®