From patchwork Tue Mar 7 18:26:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 9609615 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C39E36016C for ; Tue, 7 Mar 2017 18:27:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9ACB20564 for ; Tue, 7 Mar 2017 18:27:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE63D23F88; Tue, 7 Mar 2017 18:27:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1346E20564 for ; Tue, 7 Mar 2017 18:27:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=s08iqmqtDawIn+3ALw+xHKYxAIlbUehm9egMAmV5tBs=; b=fXk rZbx7ftF+lepwUzBpWxNCCHw0mH+9XIVCiqtl3rGtRnai9TOpYGqqQ8WGOPn+t0hZ0ZhRZpXaVtBS r6XkSRvq0UrcUwo/MuEdgEzdoefE1LDAWLkMahgK/swxcjdxAHdOgj0KtH/6V6/Ym5+i9+IYevPqy k+2S4ziK6DCVVDwk/Hb/7VgkQnQYoFEonCBzZICpRQR5pdSbM5sgoYwKrO33fcToR4lVMeFkjFsNK +kg6nSnnXWdQCC1KOYvBDS/cGa5iHWz51VYIVgH0zbCDIr/HqQz2g9ZOxgo/3aCTq7N7bX5IbV6Ha zEs5w31RfjDuotyj5ljCUZQYlPl05Lw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1clJpI-0001zG-7E; Tue, 07 Mar 2017 18:27:12 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1clJpD-0001yK-Vb for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2017 18:27:10 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DF9F81424; Tue, 7 Mar 2017 10:26:45 -0800 (PST) Received: from e110467-lin.cambridge.arm.com (e110467-lin.cambridge.arm.com [10.1.210.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9F3C93F220; Tue, 7 Mar 2017 10:26:44 -0800 (PST) From: Robin Murphy To: will.deacon@arm.com Subject: [PATCH] iommu/arm-smmu: Add global SMR masking property Date: Tue, 7 Mar 2017 18:26:28 +0000 Message-Id: X-Mailer: git-send-email 2.11.0.dirty X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170307_102708_078578_C2DE454C X-CRM114-Status: GOOD ( 12.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, iommu@lists.linux-foundation.org, robh+dt@kernel.org, nipun.gupta@nxp.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The current SMR masking support using a 2-cell iommu-specifier is primarily intended to handle individual masters with large and/or complex Stream ID assignments; it quickly gets a bit clunky in other SMR use-cases where we just want to consistently mask out the same part of every Stream ID (e.g. for MMU-500 configurations where the appended TBU number gets in the way unnecessarily). Let's add a new property to allow a single global mask value to better fit the latter situation. Tested-by: Nipun Gupta Signed-off-by: Robin Murphy --- Time to rekindle the discussion about whether an architecture-level concept with a rather specific name needs a vendor prefix ;) Robin. Documentation/devicetree/bindings/iommu/arm,smmu.txt | 10 ++++++++++ drivers/iommu/arm-smmu.c | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iommu/arm,smmu.txt b/Documentation/devicetree/bindings/iommu/arm,smmu.txt index 6cdf32d037fc..d66f355e174f 100644 --- a/Documentation/devicetree/bindings/iommu/arm,smmu.txt +++ b/Documentation/devicetree/bindings/iommu/arm,smmu.txt @@ -60,6 +60,16 @@ conditions. aliases of secure registers have to be used during SMMU configuration. +- stream-match-mask : Specifies a fixed SMR mask value to combine with + the Stream ID value from every iommu-specifier. This + may be used instead of an "#iommu-cells" value of 2 + when there is no need for per-master SMR masks, but + it is still desired to mask some portion of every + Stream ID (e.g. for certain MMU-500 configurations + given globally unique external IDs). This property is + not valid for SMMUs using stream indexing, and may be + ignored if stream matching is not supported. + ** Deprecated properties: - mmu-masters (deprecated in favour of the generic "iommus" binding) : diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index abf6496843a6..e394d55146a6 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -1590,13 +1590,15 @@ static int arm_smmu_domain_set_attr(struct iommu_domain *domain, static int arm_smmu_of_xlate(struct device *dev, struct of_phandle_args *args) { - u32 fwid = 0; + u32 mask, fwid = 0; if (args->args_count > 0) fwid |= (u16)args->args[0]; if (args->args_count > 1) fwid |= (u16)args->args[1] << SMR_MASK_SHIFT; + else if (!of_property_read_u32(args->np, "stream-match-mask", &mask)) + fwid |= (u16)mask << SMR_MASK_SHIFT; return iommu_fwspec_add_ids(dev, &fwid, 1); }