Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6471132ybi; Mon, 8 Jul 2019 03:36:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfnEy8ccV3zJv5prLCJSVInyYxZec+jak19HF7IUowLyIMmATX/QRRJ33VYdo/QAIQUpdz X-Received: by 2002:a63:db4b:: with SMTP id x11mr22475488pgi.254.1562582174908; Mon, 08 Jul 2019 03:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562582174; cv=none; d=google.com; s=arc-20160816; b=Gr1c4PWkS5nck7g7nTA8qtEuTTQOW79Cqsd91SM+MNWaHSSqD46+ts42LODZb3pYC7 v6g3Nl6xmrB+0xN0alT8vucFQ73IRSLcwBj8oPD3qnuZQzN7uBursiXW4lhMrBILFe5+ 6reG7Lf1bL6nmbKTJ4+PjUlrSO4GsAOpWMn3Ellxvh1AS8nSDu8DTlY528NjF54NUIsS NS4HGexyNQd2jqjK/oQSmFkjIsbsh6ZgtLRPJETBZRn+UPtruvSSM1o0gKAANYdXROC0 TKbki+KS6ffq5opQ3GT89h7aaFeNjYmTyz9fCai6LsPOOwnWgJpLFp8clWrk1wncb44+ GACw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=15+6j1AmlbWbWYeOzcD2hrhDQy/hCPrFeUYYBQGcbY0=; b=xegd4WB2ok9mASJZZY4P9LIJy4GW/5yDl/StGkXanqDigeWM2+Xgm8QcsxRJmiV5Jb uaM3zxVBObOIswR0gf8JTQGfh0DUgJFu3VIGF9cdwQ713SIFzpaW3+pLWyydo4vmQOAN epx+cDfYjhzHBtgzJtA/WUYPhiypQJ0ewJSswDpeV3c5gpGy2Ym3L9vAG0Q+JSN3fj0V 5WnGT/Eyq8SEpzVVHxCI3lXckWWGLoTay1y13WV8kLhz+kea0PhpH7zTqwX/V/62zhvx 8lS5G4D87D1QI6dQiRZk1drsz2cro3ITLa8Gm6qrxjfbNirEg5oIOKVDW0YN2fXTKxc3 6XvA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i36si18012593pgl.491.2019.07.08.03.35.58; Mon, 08 Jul 2019 03:36:14 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728114AbfGHH61 (ORCPT + 99 others); Mon, 8 Jul 2019 03:58:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54996 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725836AbfGHH60 (ORCPT ); Mon, 8 Jul 2019 03:58:26 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 349E35AFE3; Mon, 8 Jul 2019 07:58:26 +0000 (UTC) Received: from [10.36.116.46] (ovpn-116-46.ams2.redhat.com [10.36.116.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 936D818ACB; Mon, 8 Jul 2019 07:58:23 +0000 (UTC) Subject: Re: [PATCH 3/8] iommu/arm-smmu-v3: Support platform SSID To: Jean-Philippe Brucker , will.deacon@arm.com 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 References: <20190610184714.6786-1-jean-philippe.brucker@arm.com> <20190610184714.6786-4-jean-philippe.brucker@arm.com> From: Auger Eric Message-ID: <63d4a71a-8e3f-f663-34bc-6647971b7e4b@redhat.com> Date: Mon, 8 Jul 2019 09:58:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190610184714.6786-4-jean-philippe.brucker@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 08 Jul 2019 07:58:26 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jean, On 6/10/19 8:47 PM, 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. The commit message may give the impression the master's ssid_bits field only is used for platform devices. > > 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); In case the device is a PCI device, what is the value taken by 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 ctx_desc is 26B so 11bits would be OK > + */ > + if (!(smmu->features & ARM_SMMU_FEAT_2_LVL_CDTAB)) > + master->ssid_bits = min(master->ssid_bits, 10U); > + > 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); > + } > > /* > * Two success conditions can be represented by non-negative err here: > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index 519e40fb23ce..b91df613385f 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -536,6 +536,7 @@ struct iommu_fwspec { > struct fwnode_handle *iommu_fwnode; > void *iommu_priv; > u32 flags; > + u32 num_pasid_bits; > unsigned int num_ids; > u32 ids[1]; > }; > Thanks Eric