From patchwork Thu Jun 22 09:27:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 13288883 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1BCEAEB64DB for ; Thu, 22 Jun 2023 09:28:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NU9+81brYa2AYmn3qxK9oVnzr3UmrpKEwqRmLgevvPc=; b=YifYlpPrP5qziC p1yRfIpTtA8vtXzLg/G3Of1L3snBDgma+j5vwQvQ8t/0ZbZemU4pedD9lAoQ9cGq+xLzNPBQ/hNWA 8MjpISV0dzrq+bv3NIJcGRxHOOamiQ3KZt9sO66GL61huqns533CXuP5kB/15ERigYbXxwkLZ3i6Z oBxV4xLUuJ4MA7zwIHTTsxHghLllzFsqb/V/ZLaGwnGkpo9m5P5hFHKt3E/3wdo2f14rFAiXtUAwV sxUtL4pErxc01jSZdrDU19tCYcvhTNG0Rr7HOwDgQDK2DZF7G9ye8q+5xpPKrCM/uL7gjWKM2IaT1 i33+c/+xCJv48xxcgKGw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qCGbp-00Hb24-0Z; Thu, 22 Jun 2023 09:28:09 +0000 Received: from madras.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e5ab]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qCGbh-00HavE-0G for linux-arm-kernel@lists.infradead.org; Thu, 22 Jun 2023 09:28:02 +0000 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 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 , 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230622_022801_251081_B3CAA0AA X-CRM114-Status: UNSURE ( 8.35 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Konrad Dybcio --- 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 |