Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1068962pxb; Thu, 28 Jan 2021 07:21:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwN2z6XtxGO2dZNJVmS+shPqcoNutH/MbO9o9lIPURjsTPiqpnWRwtrHap5nSgxMknkSLG9 X-Received: by 2002:aa7:cf8d:: with SMTP id z13mr14314597edx.119.1611847261681; Thu, 28 Jan 2021 07:21:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611847261; cv=none; d=google.com; s=arc-20160816; b=YJTbU7kmnh1eaxbavaP/q8jOMRAHF4RzPa8QMa047s6iHT0f/ZnhGCRNlCzuQ5CJEE E7e0C5G3TggSnoudt8QVTLk5xc5kLQzdx3jR2TAW9XC2WX1y0voP3h0eHsF6UPj28HyS 7lnD1CozUl9ufXOzgB/y3qXFdxnLVunKZF7UaulKHdyiHOnzzvmdwhqLj7xIpk0sfQW8 /9R76nPzUeZAUcdY98M5TAa4yawx4gfqVOUprxM1DYIh9SbXANLHRFbC0hBJxj7Emj3i uQTjFqWwOjFflyS/KnoGEmk57Yiom6RZBNn63B3dtA51TtCertY5R1ezwS/TBabLl0iE knmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=u25qROiI/8Ghu+Qm58q+Gy4wFGlQNp6e0ilqThdbI4E=; b=eVuiIyrah2EoOEyqJ17yiKfxYRsWyLSSBnWgxTFdvBEcY0tsxiJ9RCDBw/vaRFMgdp +o4oykcO9PXQ4mbnkH/4nnjZ5RTJny2PQULqXz6SsvsZQM0CXeNHpetvoULCzCEjkF4k yfjqqG2m7cxgb3hAGvlNrHKR4z8aPb5Jtnv7ky42C84Ero4FM1eOcIka6tpbX+0F0AoP TpZ63ig+JmfswZ3P0LekhSweCDraLd7IP7AXNafCW9LmSLhe+LQMM+0Q+Tmcup+Ht5Uf L5vezDD4YivTMBTCStJdUBsfjOffuEO6HlufsyTvpmii+ZsrmIGrzl9p5CvTIZ6fSjku qqxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w17si2860251ejb.223.2021.01.28.07.20.35; Thu, 28 Jan 2021 07:21:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231782AbhA1PTF (ORCPT + 99 others); Thu, 28 Jan 2021 10:19:05 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:11462 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231204AbhA1PSw (ORCPT ); Thu, 28 Jan 2021 10:18:52 -0500 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DRPG93c68zjDPv; Thu, 28 Jan 2021 23:17:05 +0800 (CST) Received: from DESKTOP-5IS4806.china.huawei.com (10.174.184.42) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.498.0; Thu, 28 Jan 2021 23:17:56 +0800 From: Keqian Zhu To: , , , , , Will Deacon , "Alex Williamson" , Marc Zyngier , Catalin Marinas CC: Kirti Wankhede , Cornelia Huck , Mark Rutland , James Morse , "Robin Murphy" , Suzuki K Poulose , , , , Subject: [RFC PATCH 03/11] iommu/arm-smmu-v3: Add feature detection for BBML Date: Thu, 28 Jan 2021 23:17:34 +0800 Message-ID: <20210128151742.18840-4-zhukeqian1@huawei.com> X-Mailer: git-send-email 2.8.4.windows.1 In-Reply-To: <20210128151742.18840-1-zhukeqian1@huawei.com> References: <20210128151742.18840-1-zhukeqian1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.184.42] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: jiangkunkun When altering a translation table descriptor of some specific reasons, we require break-before-make procedure. But it might cause problems when the TTD is alive. The I/O streams might not tolerate translation faults. If the SMMU supports BBML level 1 or BBML level 2, we can change the block size without using break-before-make. This adds feature detection for BBML, none functional change. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 24 ++++++++++++++++++++- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 6 ++++++ include/linux/io-pgtable.h | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index 8cc9d7536b08..9208881a571c 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -1947,7 +1947,7 @@ static int arm_smmu_domain_finalise_s2(struct arm_smmu_domain *smmu_domain, static int arm_smmu_domain_finalise(struct iommu_domain *domain, struct arm_smmu_master *master) { - int ret; + int ret, bbml; unsigned long ias, oas; enum io_pgtable_fmt fmt; struct io_pgtable_cfg pgtbl_cfg; @@ -1988,12 +1988,20 @@ static int arm_smmu_domain_finalise(struct iommu_domain *domain, return -EINVAL; } + if (smmu->features & ARM_SMMU_FEAT_BBML2) + bbml = 2; + else if (smmu->features & ARM_SMMU_FEAT_BBML1) + bbml = 1; + else + bbml = 0; + pgtbl_cfg = (struct io_pgtable_cfg) { .pgsize_bitmap = smmu->pgsize_bitmap, .ias = ias, .oas = oas, .httu_hd = smmu->features & ARM_SMMU_FEAT_HTTU_HD, .coherent_walk = smmu->features & ARM_SMMU_FEAT_COHERENCY, + .bbml = bbml, .tlb = &arm_smmu_flush_ops, .iommu_dev = smmu->dev, }; @@ -3328,6 +3336,20 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu) /* IDR3 */ reg = readl_relaxed(smmu->base + ARM_SMMU_IDR3); + switch (FIELD_GET(IDR3_BBML, reg)) { + case IDR3_BBML0: + break; + case IDR3_BBML1: + smmu->features |= ARM_SMMU_FEAT_BBML1; + break; + case IDR3_BBML2: + smmu->features |= ARM_SMMU_FEAT_BBML2; + break; + default: + dev_err(smmu->dev, "unknown/unsupported BBM behavior level\n"); + return -ENXIO; + } + if (FIELD_GET(IDR3_RIL, reg)) smmu->features |= ARM_SMMU_FEAT_RANGE_INV; diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h index e91bea44519e..11e526ab7239 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -55,6 +55,10 @@ #define IDR1_SIDSIZE GENMASK(5, 0) #define ARM_SMMU_IDR3 0xc +#define IDR3_BBML GENMASK(12, 11) +#define IDR3_BBML0 0 +#define IDR3_BBML1 1 +#define IDR3_BBML2 2 #define IDR3_RIL (1 << 10) #define ARM_SMMU_IDR5 0x14 @@ -612,6 +616,8 @@ struct arm_smmu_device { #define ARM_SMMU_FEAT_SVA (1 << 17) #define ARM_SMMU_FEAT_HTTU_HA (1 << 18) #define ARM_SMMU_FEAT_HTTU_HD (1 << 19) +#define ARM_SMMU_FEAT_BBML1 (1 << 20) +#define ARM_SMMU_FEAT_BBML2 (1 << 21) u32 features; #define ARM_SMMU_OPT_SKIP_PREFETCH (1 << 0) diff --git a/include/linux/io-pgtable.h b/include/linux/io-pgtable.h index 1a00ea8562c7..26583beeb5d9 100644 --- a/include/linux/io-pgtable.h +++ b/include/linux/io-pgtable.h @@ -99,6 +99,7 @@ struct io_pgtable_cfg { unsigned int oas; bool httu_hd; bool coherent_walk; + int bbml; const struct iommu_flush_ops *tlb; struct device *iommu_dev; -- 2.19.1