From patchwork Fri Jul 16 08:34:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 478371 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp1146629jao; Fri, 16 Jul 2021 01:35:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFMdS5acAdU7y/mC0rXHGLSAIvwQZOuuic0F0yTigCA4lIzvEZA6908U+I+77tmtaccdGZ X-Received: by 2002:a17:906:3948:: with SMTP id g8mr10396753eje.282.1626424544550; Fri, 16 Jul 2021 01:35:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626424544; cv=none; d=google.com; s=arc-20160816; b=oJpRhU6IWn8X9lZP5NTQRh4NIIRryejRagtRzU867rVebZs1ZOiclWvkeIWI1DdWIN UoWBdvLaoVBnT18k4PFzzcdgVcr4u8RVjy04yM0VOvH73cUyMbz4Sjn8jgIyP7UZ4cC5 a3HXR5mD5axrKqpJUP7Yolp0f4t6E2hqmYcTQSalgBt9KiZm+iFtOPFhTLcd2snUq053 RkouNlThjqOoP0EvEhNIwwBUZCjGXmYmjOOWwK9aLpP03FrDzOUql8yuVz5eRffHC7vX DLykeqNKQooFtwy2EtZi2BTGAti75Crb/pAk5/smE5+LaZ7Gvuz2p/S0y0jCEioA9ZR/ zwVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=e74H04M5RAXHPukqdYgNCH/LNiTSkM7YH5DGKoP2BUA=; b=DbYgq2Z7O6cNtdBmmxdJiGFSfjMtG9ZyvQ2uZ62c3LrFW7A4DYo7V6G/M/Ct976LzU pxcUfBfEJ6S88L75FcKEYOlCb87pJEbQkT+24oAd7byTayleX3B2/K7GMU1O6SFIZQO/ 54gsXuDgrQGw4asyQ2s7byURS4AKN3FEGSKZvacF7fWU4CXXn+3HqbY9H4vczYVVRlfl mJKCcAoRu26A0VH9xAVnrZO33l4VR/rAikJdO4U9h3Ix5/uDUsgGtraou8jbDoMviZvY EaKVaKy57pEhzqAG1erO/1UvlRxqiHRLB7e3iIhB4ZtcO6DOep8CmSOMDtWjWSysyy21 sHyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd21si2610993edb.514.2021.07.16.01.35.44; Fri, 16 Jul 2021 01:35:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-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-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237801AbhGPIii (ORCPT + 4 others); Fri, 16 Jul 2021 04:38:38 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3423 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237055AbhGPIih (ORCPT ); Fri, 16 Jul 2021 04:38:37 -0400 Received: from fraeml708-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4GR42F05Bjz6D8n1; Fri, 16 Jul 2021 16:21:09 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml708-chm.china.huawei.com (10.206.15.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 16 Jul 2021 10:35:40 +0200 Received: from A2006125610.china.huawei.com (10.47.80.222) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 16 Jul 2021 09:35:33 +0100 From: Shameer Kolothum To: , , CC: , , , , , , , , , , Subject: [PATCH v6 6/9] =?utf-8?q?iommu/arm-smmu-v3=3A_Refactor=C2=A0arm?= =?utf-8?q?=5Fsmmu=5Finit=5Fbypass=5Fstes=28=29_to_force_bypass?= Date: Fri, 16 Jul 2021 09:34:39 +0100 Message-ID: <20210716083442.1708-7-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20210716083442.1708-1-shameerali.kolothum.thodi@huawei.com> References: <20210716083442.1708-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.80.222] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org By default, disable_bypass flag is set and any dev without an iommu domain installs STE with CFG_ABORT during arm_smmu_init_bypass_stes(). Introduce a "force" flag and move the STE update logic to arm_smmu_init_bypass_stes() so that we can force it to install CFG_BYPASS STE for specific SIDs. This will be useful in follow-up patch to install bypass for IORT RMR SIDs. Signed-off-by: Shameer Kolothum --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) -- 2.17.1 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 33f5556aefeb..34f84641dc6a 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -1356,12 +1356,21 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_master *master, u32 sid, arm_smmu_cmdq_issue_cmd(smmu, &prefetch_cmd); } -static void arm_smmu_init_bypass_stes(__le64 *strtab, unsigned int nent) +static void arm_smmu_init_bypass_stes(__le64 *strtab, unsigned int nent, bool force) { unsigned int i; + u64 val = STRTAB_STE_0_V; + + if (disable_bypass && !force) + val |= FIELD_PREP(STRTAB_STE_0_CFG, STRTAB_STE_0_CFG_ABORT); + else + val |= FIELD_PREP(STRTAB_STE_0_CFG, STRTAB_STE_0_CFG_BYPASS); for (i = 0; i < nent; ++i) { - arm_smmu_write_strtab_ent(NULL, -1, strtab); + strtab[0] = cpu_to_le64(val); + strtab[1] = cpu_to_le64(FIELD_PREP(STRTAB_STE_1_SHCFG, + STRTAB_STE_1_SHCFG_INCOMING)); + strtab[2] = 0; strtab += STRTAB_STE_DWORDS; } } @@ -1389,7 +1398,7 @@ static int arm_smmu_init_l2_strtab(struct arm_smmu_device *smmu, u32 sid) return -ENOMEM; } - arm_smmu_init_bypass_stes(desc->l2ptr, 1 << STRTAB_SPLIT); + arm_smmu_init_bypass_stes(desc->l2ptr, 1 << STRTAB_SPLIT, false); arm_smmu_write_strtab_l1_desc(strtab, desc); return 0; } @@ -3041,7 +3050,7 @@ static int arm_smmu_init_strtab_linear(struct arm_smmu_device *smmu) reg |= FIELD_PREP(STRTAB_BASE_CFG_LOG2SIZE, smmu->sid_bits); cfg->strtab_base_cfg = reg; - arm_smmu_init_bypass_stes(strtab, cfg->num_l1_ents); + arm_smmu_init_bypass_stes(strtab, cfg->num_l1_ents, false); return 0; }