Message ID | 20230622092742.74819-4-angelogioacchino.delregno@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4938625vqr; Thu, 22 Jun 2023 02:36:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4FQfizmjF8LxFjp+ItnxZ/pxPjMvZAaC/iZ5NSQ2Z0GwjAJU4yiDuXOE6OJZDfBxnOQh6V X-Received: by 2002:a9d:6d98:0:b0:6b2:9391:7e74 with SMTP id x24-20020a9d6d98000000b006b293917e74mr13819346otp.23.1687426562727; Thu, 22 Jun 2023 02:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687426562; cv=none; d=google.com; s=arc-20160816; b=QGBK6uaLYesCawOJW9kwOMI9NoNsGligA1NgGgG/qsTRz9AXR5gDPnQ6KH8PX8L+U8 7+HISnkw99ti5I3AZreSRXw/05J7C60x6rtZGiqalaNhAHWrZn0EhXLh2Yh0WW0sys+U wHKNAjZUF+stZL3hM6xsiJVw8RO52ATSydjCBOtU1+B0cCETGNmWnxuO4oqae0UzfO+L Vwtak9ydz2/c1x133YRS6T3hXu/KqZRMvKoDrLn2PsoBwPT0SNyCF0F99vykSezNVHHK rmu4mR9XQ2FtUmTfa7ULKMhaPLrzAHTC7MggqliUoRNiteBEOrMRu0Sz/ka2ox0BFyo+ qjZg== 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 :dkim-signature; bh=pvxfYFpm7NrYQ4wUKk84ULmkrAkuUF5dCRvvJT/alqo=; b=tXU2hZKtSBAKOA1W9C0X7fssZ1xfisfIwylPHsK7GY4lYDeVL7gj4gPK+QYuXsZecX A0cN22UFXI8EqWxIsnGvrWn5vAjXDlwJFmUF6/2RNrJtxDsYxSfQJRCnzcwfanxfMB7/ ZgrrrF+rjjia/l3Rtdrzg3Lj0kX5mz84JYujMrTaWqeVY1kfo5n+i0v6EdqBYB/KRUp5 F0e6amnbktszPgLhANYQTC5qne72HR2zbNZJvaOYy8GecHP3oMTmUlhizThYc8Vzxyj9 3E90RrAm0WmXSsOFdWPDHgGEnngqMNHhyTIxpr1wXbc4gJd4Uxzi5bGQ+ZWPBjWnw7gs WGQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YV5h54SS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e124-20020a636982000000b0053ef95fa919si6149866pgc.458.2023.06.22.02.35.50; Thu, 22 Jun 2023 02:36:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YV5h54SS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232242AbjFVJel (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Thu, 22 Jun 2023 05:34:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232294AbjFVJdn (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 22 Jun 2023 05:33:43 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C9AC269A; Thu, 22 Jun 2023 02:28:01 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (unknown [IPv6:2001:b07:2ed:14ed:c5f8:7372:f042:90a2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id D40B46607076; Thu, 22 Jun 2023 10:27:58 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687426079; bh=6+3tbpupafFXA1rZOX62kA5wZpU6l7nAzHW/LEoVbSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YV5h54SSiaMStnZD8ND7+jqH4UJmBv5qedqLEP4ElMGJuf5tXM9PL1bEg1ZPnWF3N zKIJKRBxV8dY/apgMYDjkZ+tVwscI8IXbd02AEDPrhzHNUblBYQchg8xzWRxcmO6u/ 9MPh5GCiYyrCl7IPgwiM4LZnWL3TyLfV//cqd6ugDQI107ABq/5u/02BguVqu9QXyY PEF8qYu/U1iAhdrf/HKXdLD/CRUTQU1saehIf+OBS3TV7IXNm3TaK7D3F/R2chkQXs 2C7bRmdp3GC6b/M7tqhVagMKDOB8U5nnrehQnSmZ8pVpCHC/hXEt3vv7lTZ4+LRTB3 TBLvvh+LtKe0g== From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> To: agross@kernel.org Cc: andersson@kernel.org, luca@z3ntu.xyz, konrad.dybcio@linaro.org, dmitry.baryshkov@linaro.org, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, robdclark@gmail.com, linux-arm-msm@vger.kernel.org, iommu@lists.linux.dev, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, kernel@collabora.com Subject: [PATCH v5 3/6] iommu/qcom: Disable and reset context bank before programming Date: Thu, 22 Jun 2023 11:27:39 +0200 Message-Id: <20230622092742.74819-4-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230622092742.74819-1-angelogioacchino.delregno@collabora.com> References: <20230622092742.74819-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769394995264268727?= X-GMAIL-MSGID: =?utf-8?q?1769394995264268727?= |
Series |
Add support for Qualcomm's legacy IOMMU v2
|
|
Commit Message
AngeloGioacchino Del Regno
June 22, 2023, 9:27 a.m. UTC
Writing the new TTBRs, TCRs and MAIRs on a previously enabled
context bank may trigger a context fault, resulting in firmware
driven AP resets: change the domain initialization programming
sequence to disable the context bank(s) and to also clear the
related fault address (CB_FAR) and fault status (CB_FSR)
registers before writing new values to TTBR0/1, TCR/TCR2, MAIR0/1.
Fixes: 0ae349a0f33f ("iommu/qcom: Add qcom_iommu")
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
drivers/iommu/arm/arm-smmu/qcom_iommu.c | 7 +++++++
1 file changed, 7 insertions(+)
Comments
On 22.06.2023 11:27, AngeloGioacchino Del Regno wrote: > Writing the new TTBRs, TCRs and MAIRs on a previously enabled > context bank may trigger a context fault, resulting in firmware > driven AP resets: change the domain initialization programming > sequence to disable the context bank(s) and to also clear the > related fault address (CB_FAR) and fault status (CB_FSR) > registers before writing new values to TTBR0/1, TCR/TCR2, MAIR0/1. > > Fixes: 0ae349a0f33f ("iommu/qcom: Add qcom_iommu") > Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> > --- Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org> Konrad > drivers/iommu/arm/arm-smmu/qcom_iommu.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c > index 8face57c4180..f1bd7c035db8 100644 > --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c > +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c > @@ -273,6 +273,13 @@ static int qcom_iommu_init_domain(struct iommu_domain *domain, > ctx->secure_init = true; > } > > + /* Disable context bank before programming */ > + iommu_writel(ctx, ARM_SMMU_CB_SCTLR, 0); > + > + /* Clear context bank fault address fault status registers */ > + iommu_writel(ctx, ARM_SMMU_CB_FAR, 0); > + iommu_writel(ctx, ARM_SMMU_CB_FSR, ARM_SMMU_FSR_FAULT); > + > /* TTBRs */ > iommu_writeq(ctx, ARM_SMMU_CB_TTBR0, > pgtbl_cfg.arm_lpae_s1_cfg.ttbr |
diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c index 8face57c4180..f1bd7c035db8 100644 --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c @@ -273,6 +273,13 @@ static int qcom_iommu_init_domain(struct iommu_domain *domain, ctx->secure_init = true; } + /* Disable context bank before programming */ + iommu_writel(ctx, ARM_SMMU_CB_SCTLR, 0); + + /* Clear context bank fault address fault status registers */ + iommu_writel(ctx, ARM_SMMU_CB_FAR, 0); + iommu_writel(ctx, ARM_SMMU_CB_FSR, ARM_SMMU_FSR_FAULT); + /* TTBRs */ iommu_writeq(ctx, ARM_SMMU_CB_TTBR0, pgtbl_cfg.arm_lpae_s1_cfg.ttbr |