linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/arm-smmu-v3: limit use of 2-level stream tables
@ 2016-07-11 18:00 Nate Watterson
  2016-07-12  9:36 ` Robin Murphy
  2016-07-12 18:19 ` [PATCH v2] " Nate Watterson
  0 siblings, 2 replies; 7+ messages in thread
From: Nate Watterson @ 2016-07-11 18:00 UTC (permalink / raw)
  To: linux-arm-kernel

In the current arm-smmu-v3 driver, all smmus that support 2-level
stream tables are being forced to use them. This is suboptimal for
smmus that support fewer stream id bits than would fill in a single
second level table. This patch limits the use of 2-level tables to
smmus that both support the feature and whose first level table can
possibly contain more than a single entry.

Signed-off-by: Nate Watterson <nwatters@codeaurora.org>
---
 drivers/iommu/arm-smmu-v3.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index 5f6b3bc..742254c 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -2531,6 +2531,17 @@ static int arm_smmu_device_probe(struct arm_smmu_device *smmu)
 	smmu->ssid_bits = reg >> IDR1_SSID_SHIFT & IDR1_SSID_MASK;
 	smmu->sid_bits = reg >> IDR1_SID_SHIFT & IDR1_SID_MASK;
 
+	/*
+	 * If the SMMU supports fewer bits than would fill a single L2 stream
+	 * table, use a linear table instead.
+	 */
+	if (smmu->sid_bits <= STRTAB_SPLIT &&
+	    smmu->features & ARM_SMMU_FEAT_2_LVL_STRTAB) {
+		smmu->features &= ~ARM_SMMU_FEAT_2_LVL_STRTAB;
+		dev_info(smmu->dev, "SIDSIZE (%d) <= STRTAB_SPLIT (%d) : disabling 2-level stream tables\n",
+			 smmu->sid_bits, STRTAB_SPLIT);
+	}
+
 	/* IDR5 */
 	reg = readl_relaxed(smmu->base + ARM_SMMU_IDR5);
 
-- 
Qualcomm Technologies, Inc. on behalf
of the Qualcomm Innovation Center, Inc.  The Qualcomm Innovation Center, Inc. 
is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.

^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH] iommu/arm-smmu-v3: avoid over allocating for l2 stream tables
@ 2016-12-20 10:22 Will Deacon
  2017-01-10 19:47 ` [PATCH] iommu/arm-smmu-v3: limit use of 2-level " Nate Watterson
  0 siblings, 1 reply; 7+ messages in thread
From: Will Deacon @ 2016-12-20 10:22 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Nate,

On Mon, Dec 19, 2016 at 03:26:40PM -0500, Nate Watterson wrote:
> Currently, all l2 stream tables are being allocated with space for
> (1<<split) stes without regard to the number of sid bits the smmu
> physically supports. To avoid allocating memory for inaccessible
> stes, this patch limits the span of an l2 table to be no larger
> than the sid size of the smmu to which it belongs.
> 
> Signed-off-by: Nate Watterson <nwatters@codeaurora.org>
> ---
>  drivers/iommu/arm-smmu-v3.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)

I can't help but think you'd be better off using a linear stream table
in this scenario. If we hack the feature check for
ARM_SMMU_FEAT_2_LVL_STRTAB so that it doesn't report support for 2 level
tables if the number of sids is less than that covered by a single l2
entry, would that solve your problem?

Will

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

end of thread, other threads:[~2017-01-12 17:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-11 18:00 [PATCH] iommu/arm-smmu-v3: limit use of 2-level stream tables Nate Watterson
2016-07-12  9:36 ` Robin Murphy
2016-07-12 18:19 ` [PATCH v2] " Nate Watterson
2016-07-14 13:31   ` Will Deacon
2016-07-14 17:33     ` nwatters at codeaurora.org
2016-12-20 10:22 [PATCH] iommu/arm-smmu-v3: avoid over allocating for l2 " Will Deacon
2017-01-10 19:47 ` [PATCH] iommu/arm-smmu-v3: limit use of 2-level " Nate Watterson
2017-01-12 17:20   ` Will Deacon

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).