From patchwork Wed Aug 14 13:59:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Gonzalez X-Patchwork-Id: 13763538 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 F1C57C52D7B for ; Wed, 14 Aug 2024 14:01:16 +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: Content-Transfer-Encoding:Content-Type:MIME-Version:Message-Id:Date:Subject: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=bkjIBA/SFJvz3N2qUFygxZTnm0f+s7G0Z41C74QR7+c=; b=M9c2/PekhDAvij UR4FjOQIdfvbDG1BenLLB+QJ1xo5exBzIWTtVfZhWV89Lmc4ifwzGerH4RifXk3G2PQpDfbv21LBT 5XcWHQYgyHqTGpPfHrB5cZOalxWMZJj+f0Oz3B6KOHvqDHzQ154BN7GiSn0RvalH3WqTMzPdnfq/Y J18H4NciyiKYssSVoHT7gwm6pZ5tZspGOQ6TAtZrBBXND6WPlzQNIU5qJ+8xsRa9PBogN/MY0sBdy 0gfIVyHHudOfKPgK1uGiUkJil/TON8vw2z7NVgOapnhsSkrgez8JlQDxRGsl2RCpPqqk0IgFCM3V7 OJA7JGe7vQubmimDKZsA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seEYd-00000007BkW-12A8; Wed, 14 Aug 2024 14:00:59 +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-00000007BXq-2Xhv 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 D1FE520990; 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 BDAD920988; Wed, 14 Aug 2024 16:00:09 +0200 (CEST) From: Marc Gonzalez Subject: [PATCH 0/2] Work around reserved SMMU context bank on msm8998 Date: Wed, 14 Aug 2024 15:59:54 +0200 Message-Id: <20240814-smmu-v1-0-3d6c27027d5b@freebox.fr> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAFq4vGYC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIxMDC0MT3eLc3FLdFFNzo2TDREOzxMRkJaDSgqLUtMwKsDHRsbW1ACh0KDJ WAAAA 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_941783_83CE47B2 X-CRM114-Status: UNSURE ( 6.93 ) 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. This patch series: 1) introduces a DT prop "qcom,last-ctx-bank-reserved" to indicate that FW reserves the last context bank of a given SMMU. 2) tweaks the driver to "hide" the last context bank from Linux. For reference, the lpass_q6_smmu node looks like this: lpass_q6_smmu: iommu@5100000 { compatible = "qcom,msm8998-smmu-v2", "qcom,smmu-v2"; reg = <0x05100000 0x40000>; clocks = <&gcc HLOS1_VOTE_LPASS_ADSP_SMMU_CLK>; clock-names = "iface"; #global-interrupts = <0>; #iommu-cells = <1>; interrupts = , , , , , , , , , , , , ; power-domains = <&gcc LPASS_ADSP_GDSC>; status = "disabled"; }; --- Marc Gonzalez (2): dt-bindings: arm-smmu: Add qcom,last-ctx-bank-reserved iommu/arm-smmu-qcom: hide last context bank from linux Documentation/devicetree/bindings/iommu/arm,smmu.yaml | 6 ++++++ drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 5 +++++ 2 files changed, 11 insertions(+) --- base-commit: c934f6908ad1f210c1d1e289934d1182a6e7cb62 change-id: 20240814-smmu-d572c1a16aac Best regards,