Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4065886ybi; Tue, 18 Jun 2019 11:09:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcFqmWz/g1au6sA8krrzwoaqZjMdpHq1lcUoVm4vpqfqe2sx/Gevp1mh6QDQOxciBEeVe7 X-Received: by 2002:a17:902:b592:: with SMTP id a18mr90467195pls.278.1560881358967; Tue, 18 Jun 2019 11:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560881358; cv=none; d=google.com; s=arc-20160816; b=pZhY9RNERw+zM38B/mYSQplAcCyHtWCTOMf1jkFz3CwPjTTF68QdAo3U6N2QLgkSp0 KRBmmSecqMjH8i1jkP000PexAmGA+4GIIxNB8FoTH+IF+elY6kq+LtPOyb64tKYRZbnp wQb/saZK5KORQC3kbJcGyx5kUIK68kfJR2m+2/YaES/rHSFAcanezlCwP3yz3BY03U1H W4espL0cC9BK4+zRw3w11bMmT3CyfUbilhZ8Ia/vHaev2ZKqWRQQ4XWCBrCGWal/euIP OirfwSvrGYTWqhSH7P+JrveoxQy4+9SX/E0K+jpQJ9ubQQNDRt5wZFn4CjW5pG1LUk8U bWJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=nrqJwjf85vRerFIAz8DfDXecHX/bE4lDHoSeaLlqoNU=; b=JxdxtBds+VT+ToP6xARwT6jcVmM4Y2ak3mgZu2D+Mk1MvhvBzyh/GRnDypB+sNlfJW mlmgz5N8gfRq72TiHkwvgGnYJsBXIs75yeTOQZEGGjluuQWAJ7gyhVQIj0+eAn0q3OFL BdR01BjXU5Wh0nSZQB1k4RjbE6aXnwxBVTDNO5hCX99cnEfxzu+1SvCG+kcExICsBBLs OhLETrEb/oEaUJV8Y221wxb+vVd50+2VuGrgCdC0ekx7nJRkepKotfbXjUiB//c+txx/ zwhGqVpxjbHVUXW0huY3RoBSRnwvrzj+DzQ7LNsj+juTHPROjPimjZH3/ObO8ibiOcNe cIWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t6si12804455plr.245.2019.06.18.11.09.03; Tue, 18 Jun 2019 11:09:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730163AbfFRSIz (ORCPT + 99 others); Tue, 18 Jun 2019 14:08:55 -0400 Received: from foss.arm.com ([217.140.110.172]:53354 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729337AbfFRSIz (ORCPT ); Tue, 18 Jun 2019 14:08:55 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 91FB9344; Tue, 18 Jun 2019 11:08:54 -0700 (PDT) Received: from fuggles.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2194F3F738; Tue, 18 Jun 2019 11:08:53 -0700 (PDT) Date: Tue, 18 Jun 2019 19:08:51 +0100 From: Will Deacon To: Jean-Philippe Brucker Cc: joro@8bytes.org, robh+dt@kernel.org, mark.rutland@arm.com, robin.murphy@arm.com, jacob.jun.pan@linux.intel.com, iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, eric.auger@redhat.com Subject: Re: [PATCH 3/8] iommu/arm-smmu-v3: Support platform SSID Message-ID: <20190618180851.GK4270@fuggles.cambridge.arm.com> References: <20190610184714.6786-1-jean-philippe.brucker@arm.com> <20190610184714.6786-4-jean-philippe.brucker@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190610184714.6786-4-jean-philippe.brucker@arm.com> User-Agent: Mutt/1.11.1+86 (6f28e57d73f2) () Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 10, 2019 at 07:47:09PM +0100, Jean-Philippe Brucker wrote: > For platform devices that support SubstreamID (SSID), firmware provides > the number of supported SSID bits. Restrict it to what the SMMU supports > and cache it into master->ssid_bits. > > Signed-off-by: Jean-Philippe Brucker > --- > drivers/iommu/arm-smmu-v3.c | 11 +++++++++++ > drivers/iommu/of_iommu.c | 6 +++++- > include/linux/iommu.h | 1 + > 3 files changed, 17 insertions(+), 1 deletion(-) > > diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c > index 4d5a694f02c2..3254f473e681 100644 > --- a/drivers/iommu/arm-smmu-v3.c > +++ b/drivers/iommu/arm-smmu-v3.c > @@ -604,6 +604,7 @@ struct arm_smmu_master { > struct list_head domain_head; > u32 *sids; > unsigned int num_sids; > + unsigned int ssid_bits; > bool ats_enabled :1; > }; > > @@ -2097,6 +2098,16 @@ static int arm_smmu_add_device(struct device *dev) > } > } > > + master->ssid_bits = min(smmu->ssid_bits, fwspec->num_pasid_bits); > + > + /* > + * If the SMMU doesn't support 2-stage CD, limit the linear > + * tables to a reasonable number of contexts, let's say > + * 64kB / sizeof(ctx_desc) = 1024 = 2^10 > + */ > + if (!(smmu->features & ARM_SMMU_FEAT_2_LVL_CDTAB)) > + master->ssid_bits = min(master->ssid_bits, 10U); Please introduce a #define for the 10, so that it is computed in the way you describe in the comment (a bit like we do for things like queue sizes). > + > group = iommu_group_get_for_dev(dev); > if (!IS_ERR(group)) { > iommu_group_put(group); > diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c > index f04a6df65eb8..04f4f6b95d82 100644 > --- a/drivers/iommu/of_iommu.c > +++ b/drivers/iommu/of_iommu.c > @@ -206,8 +206,12 @@ const struct iommu_ops *of_iommu_configure(struct device *dev, > if (err) > break; > } > - } > > + fwspec = dev_iommu_fwspec_get(dev); > + if (!err && fwspec) > + of_property_read_u32(master_np, "pasid-num-bits", > + &fwspec->num_pasid_bits); > + } Hmm. Do you know if there's anything in ACPI for this? Otherwise, patch looks fine. Thanks. Will