linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: thommyj@gmail.com (Thommy Jakobsson)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 2/2] arm-smmu: Add possibillity to mask streamIDs
Date: Thu,  9 Jun 2016 12:43:21 +0200	[thread overview]
Message-ID: <1465469001-2352-3-git-send-email-thommyj@gmail.com> (raw)
In-Reply-To: <1465469001-2352-1-git-send-email-thommyj@gmail.com>

Use upper half word in StreamID cell from DT as a StreamID mask. This is
useful for reducing number of SMRs used for a master with many StreamIDs.
For example the ZynqMPSoC mirrors 6bits from the AXI ID into the StreamID
for FPGA blocks, but only allows 48 register groups for stream matching.

Signed-off-by: Thommy Jakobsson <thommyj@gmail.com>
---
 drivers/iommu/arm-smmu.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 9345a3f..ffedd96 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -305,6 +305,7 @@ struct arm_smmu_smr {
 struct arm_smmu_master_cfg {
 	int				num_streamids;
 	u16				streamids[MAX_MASTER_STREAMIDS];
+	u16				streammasks[MAX_MASTER_STREAMIDS];
 	struct arm_smmu_smr		*smrs;
 };
 
@@ -347,6 +348,7 @@ struct arm_smmu_device {
 
 	u32				num_mapping_groups;
 	DECLARE_BITMAP(smr_map, ARM_SMMU_MAX_SMRS);
+	u16				supported_mask;
 
 	unsigned long			va_size;
 	unsigned long			ipa_size;
@@ -540,7 +542,10 @@ static int register_smmu_master(struct arm_smmu_device *smmu,
 	master->cfg.num_streamids	= masterspec->args_count;
 
 	for (i = 0; i < master->cfg.num_streamids; ++i) {
-		u16 streamid = masterspec->args[i];
+		u16 streamid = (masterspec->args[i] >> SMR_ID_SHIFT) &
+				SMR_ID_MASK;
+		u16 mask     = (masterspec->args[i] >> SMR_MASK_SHIFT) &
+				SMR_MASK_MASK;
 
 		if (!(smmu->features & ARM_SMMU_FEAT_STREAM_MATCH) &&
 		     (streamid >= smmu->num_mapping_groups)) {
@@ -550,6 +555,14 @@ static int register_smmu_master(struct arm_smmu_device *smmu,
 			return -ERANGE;
 		}
 		master->cfg.streamids[i] = streamid;
+
+		if ((smmu->supported_mask | mask) != smmu->supported_mask) {
+			dev_err(dev,
+				"unsupported mask, 0x%04x used for master device %s\n",
+				mask, masterspec->np->name);
+			return -ERANGE;
+		}
+		master->cfg.streammasks[i] = mask;
 	}
 	return insert_smmu_master(smmu, master);
 }
@@ -1106,7 +1119,7 @@ static int arm_smmu_master_configure_smrs(struct arm_smmu_device *smmu,
 
 		smrs[i] = (struct arm_smmu_smr) {
 			.idx	= idx,
-			.mask	= 0, /* We don't currently share SMRs */
+			.mask	= cfg->streammasks[i],
 			.id	= cfg->streamids[i],
 		};
 	}
@@ -1735,6 +1748,7 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)
 				mask, sid);
 			return -ENODEV;
 		}
+		smmu->supported_mask = mask;
 
 		dev_notice(smmu->dev,
 			   "\tstream matching with %u register groups, mask 0x%x",
-- 
1.9.1

      parent reply	other threads:[~2016-06-09 10:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-30 20:40 [PATCH 0/2] arm-smmu: add master mask Thommy Jakobsson
2016-05-30 20:40 ` [PATCH 1/2] arm-smmu: doc: add binding for stream ID mask Thommy Jakobsson
2016-05-30 20:40 ` [PATCH 2/2] arm-smmu: Add possibillity to mask streamIDs Thommy Jakobsson
2016-06-02 13:35   ` Nipun Gupta
2016-06-03  9:02     ` Thommy Jakobsson
2016-06-03  9:41       ` Nipun Gupta
2016-06-03 18:32         ` Thommy Jakobsson
2016-06-03 12:19     ` [PATCH v2 0/2] arm-smmu: add master mask Thommy Jakobsson
2016-06-03 12:19       ` [PATCH v2 1/2] arm-smmu: doc: add binding for stream ID mask Thommy Jakobsson
2016-06-03 12:19       ` [PATCH v2 2/2] arm-smmu: Add possibillity to mask streamIDs Thommy Jakobsson
2016-06-06 12:47   ` [PATCH " Robin Murphy
2016-06-08  7:47     ` Thommy Jakobsson
2016-06-08 11:11       ` Robin Murphy
     [not found]         ` <CALRxmdCVshj_g1tHht9ni3tq5hrKjcv_aZEW0gunA9n3Nt7RXA@mail.gmail.com>
2016-06-08 19:25           ` Stuart Yoder
2016-06-09 10:42         ` Thommy Jakobsson
2016-06-09 10:43         ` [PATCH v3 0/2] " Thommy Jakobsson
2016-06-09 10:43           ` [PATCH v3 1/2] arm-smmu: doc: add SMMU mask documentation Thommy Jakobsson
2016-06-14 16:01             ` Will Deacon
2016-06-09 10:43           ` Thommy Jakobsson [this message]

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=1465469001-2352-3-git-send-email-thommyj@gmail.com \
    --to=thommyj@gmail.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).