From patchwork Wed Aug 14 13:59:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Gonzalez X-Patchwork-Id: 13763539 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 CDC75C3DA4A for ; Wed, 14 Aug 2024 14:01:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HzPXz1vNKZSloc7wkj7KgQvkL7JG0jfNp4YKJXxXFSE=; b=fRSyyPvwwscF0j457/XvBgPptS npIawzJeJhxUujHwxdvdAtOeqAkJ9QYOrsz2JAeZiGp4H+vJfge8+Swg2NQ8NWcWkacsdZnHyzM1l YLoeYftGTpyDKwqFqZIjL7cPhoWXJLNMMyEtDz+zvtNOhWdsvVtbEI55HNovRSNkvziECK7aHsWe3 vGJugTW8q8b9SaXVTD7qPTJd5tW6xV4MCPi6gjP4ZwDkGaelitYUEdomnhxLokuTc4QBdWgpPt3gs VvzjSEYeHbYOUOr7egxE3aOl1uKSnDuzMaHAFj/mtO/lqjUZdMi0EDVY1SHEXuUI0FWAe2o88f9V5 vII1H9/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seEZF-00000007Bxt-0PLc; Wed, 14 Aug 2024 14:01:37 +0000 Received: from ns.iliad.fr ([212.27.33.1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seEXw-00000007BXr-1urL for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 14:00:19 +0000 Received: from ns.iliad.fr (localhost [127.0.0.1]) by ns.iliad.fr (Postfix) with ESMTP id D8CC220998; Wed, 14 Aug 2024 16:00:09 +0200 (CEST) Received: from [127.0.1.1] (freebox.vlq16.iliad.fr [213.36.7.13]) by ns.iliad.fr (Postfix) with ESMTP id C755720989; Wed, 14 Aug 2024 16:00:09 +0200 (CEST) From: Marc Gonzalez Date: Wed, 14 Aug 2024 15:59:55 +0200 Subject: [PATCH 1/2] dt-bindings: arm-smmu: Add qcom,last-ctx-bank-reserved MIME-Version: 1.0 Message-Id: <20240814-smmu-v1-1-3d6c27027d5b@freebox.fr> References: <20240814-smmu-v1-0-3d6c27027d5b@freebox.fr> In-Reply-To: <20240814-smmu-v1-0-3d6c27027d5b@freebox.fr> To: Rob Clark , Will Deacon , Robin Murphy , Joerg Roedel , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: iommu@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Bjorn Andersson , Konrad Dybcio , Arnaud Vrac , Pierre-Hugues Husson , Marijn Suijten , Marc Gonzalez X-Mailer: b4 0.13.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_070016_714894_0B3E3F2E X-CRM114-Status: UNSURE ( 8.28 ) 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 On qcom msm8998, writing to the last context bank of lpass_q6_smmu (base address 0x05100000) produces a system freeze & reboot. Specifically, here: qsmmu->bypass_cbndx = smmu->num_context_banks - 1; arm_smmu_cb_write(smmu, qsmmu->bypass_cbndx, ARM_SMMU_CB_SCTLR, 0); and here: arm_smmu_write_context_bank(smmu, i); arm_smmu_cb_write(smmu, i, ARM_SMMU_CB_FSR, ARM_SMMU_CB_FSR_FAULT); It is likely that FW reserves the last context bank for its own use, thus a simple work-around would be: DON'T USE IT in Linux. Signed-off-by: Marc Gonzalez --- Documentation/devicetree/bindings/iommu/arm,smmu.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/iommu/arm,smmu.yaml b/Documentation/devicetree/bindings/iommu/arm,smmu.yaml index 280b4e49f2191..f9b23aef351b0 100644 --- a/Documentation/devicetree/bindings/iommu/arm,smmu.yaml +++ b/Documentation/devicetree/bindings/iommu/arm,smmu.yaml @@ -204,6 +204,12 @@ properties: access to SMMU configuration registers. In this case non-secure aliases of secure registers have to be used during SMMU configuration. + qcom,last-ctx-bank-reserved: + type: boolean + description: + FW reserves the last context bank of this SMMU for its own use. + If Linux tries to use it, Linux gets nuked. + stream-match-mask: $ref: /schemas/types.yaml#/definitions/uint32 description: | From patchwork Wed Aug 14 13:59:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Gonzalez X-Patchwork-Id: 13763540 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 175CBC3DA4A for ; Wed, 14 Aug 2024 14:02:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=lQ1TdXUXle3KO7rbQc3Q3cjX7vatqrMMTS9KCK8tsfo=; b=e/wPkVxOXBZOfcyW0hsXYaGAeu iW/jmZcYcpMRNTq3RvIeFI/G+9JQFF4B0CrOYYE2SLqtqo82cvOKBk1Xc/qP4ZI+2u0UlleZH9R7z 49Z3yka8x4bcQpvhwySHUcPm1CRl79ENwx5UQ7Nu98klbfBR78KUDaF/ff8SaJDj7WbzriQtp0HUr wqqC9Op1jvCF3km2PP0eJNT4H6TFs4GmeT/m2zhpq1GVy4JHxzRKfG/OSLGnEq+mXz4wJulFeePRt GL+k5SqwGu91OwyoJxqQtm/hHTzF7azhl08YW3QeaoSJXoNbU9t8A1YFhJqHNyY/jF8snQVqBiOS4 FwR0C2mA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seEZq-00000007C9G-1MKW; Wed, 14 Aug 2024 14:02:14 +0000 Received: from ns.iliad.fr ([212.27.33.1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seEXw-00000007BXp-2nFs for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 14:00:20 +0000 Received: from ns.iliad.fr (localhost [127.0.0.1]) by ns.iliad.fr (Postfix) with ESMTP id DE9D42099D; Wed, 14 Aug 2024 16:00:09 +0200 (CEST) Received: from [127.0.1.1] (freebox.vlq16.iliad.fr [213.36.7.13]) by ns.iliad.fr (Postfix) with ESMTP id CE1972098C; Wed, 14 Aug 2024 16:00:09 +0200 (CEST) From: Marc Gonzalez Date: Wed, 14 Aug 2024 15:59:56 +0200 Subject: [PATCH 2/2] iommu/arm-smmu-qcom: hide last context bank from linux MIME-Version: 1.0 Message-Id: <20240814-smmu-v1-2-3d6c27027d5b@freebox.fr> References: <20240814-smmu-v1-0-3d6c27027d5b@freebox.fr> In-Reply-To: <20240814-smmu-v1-0-3d6c27027d5b@freebox.fr> To: Rob Clark , Will Deacon , Robin Murphy , Joerg Roedel , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: iommu@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Bjorn Andersson , Konrad Dybcio , Arnaud Vrac , Pierre-Hugues Husson , Marijn Suijten , Marc Gonzalez X-Mailer: b4 0.13.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_070016_929003_0149876F X-CRM114-Status: UNSURE ( 9.73 ) 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 On qcom msm8998, writing to the last context bank of lpass_q6_smmu (base address 0x05100000) produces a system freeze & reboot. Specifically, here: qsmmu->bypass_cbndx = smmu->num_context_banks - 1; arm_smmu_cb_write(smmu, qsmmu->bypass_cbndx, ARM_SMMU_CB_SCTLR, 0); and here: arm_smmu_write_context_bank(smmu, i); arm_smmu_cb_write(smmu, i, ARM_SMMU_CB_FSR, ARM_SMMU_CB_FSR_FAULT); It is likely that FW reserves the last context bank for its own use, thus a simple work-around would be: DON'T USE IT in Linux. If we decrease the number of context banks, last one will be "hidden". Signed-off-by: Marc Gonzalez --- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c index 7e65189ca7b8c..e2e1fd9e2452b 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c @@ -282,6 +282,11 @@ static int qcom_smmu_cfg_probe(struct arm_smmu_device *smmu) u32 smr; int i; + if (of_property_read_bool(smmu->dev->of_node, "qcom,last-ctx-bank-reserved")) { + dev_warn(smmu->dev, "hiding last ctx bank from linux"); + --smmu->num_context_banks; + } + /* * Some platforms support more than the Arm SMMU architected maximum of * 128 stream matching groups. For unknown reasons, the additional