From patchwork Mon Jul 29 08:37:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 13744554 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 4F661C3DA4A for ; Mon, 29 Jul 2024 08:38:36 +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: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:In-Reply-To:References:List-Owner; bh=1eybL2ZZo9lG8pme1RIyF5W9jhwDzFz2CalxOdKI+BQ=; b=kAfQA/ehKlgUDDG5oikjb1zQzz oVJZe4xSr9rU+gcUPHqLOmgX/Jb0TBSzf6d/Kfg1Wn/iZSmUCLeXMbxsEHw/V7yTq+OkOsX4qmbCi +26XsXOH7/43Tl2eW//7TWrniva6XCfei72++iZkvqRLdOmj41BcFPOkyP677P0v+foo0Y9cZ7C4/ 8X0qesuuoU5FugDEl+USkK4Ri20O/YRmNzfR5fiu7hr/zxnGc+1g6PsGQiXAfOflKaIkkBnvePGld OpUc1peDZE2JvcvznNiBshLP6v1kBbIKhoQ3h6a2lINIaaNGJtOzAJvOJbcpEPdGL5/dmAqxzhTxg bp33AIVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYLth-0000000AZaE-0tLa; Mon, 29 Jul 2024 08:38:25 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYLtG-0000000AZSL-3Slu for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2024 08:38:00 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id A6ADBCE0959; Mon, 29 Jul 2024 08:37:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DFB0C32786; Mon, 29 Jul 2024 08:37:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722242276; bh=V9wFi+MX2139fI/I1jgkjhCzse15vxUwsNcBTc5sszY=; h=From:Date:Subject:To:Cc:From; b=IyZzHb2vH+E0LTpNKmwOtI8sgfUgguJwCTeV4822DeBWr4CbUrjTG5SC8J5ZFvpEc TEvSLqKME1VRrCbO+syepVH2Xkmon0CPp/bYSQFFHRAqaGjhN7E3it70evYv+2wGMO u7wPFcvYoD/OzWnG1W3G6vr+hvCv0+UW3/t16rG9HExpH8yxq2WlLKgVbhViMQZ0Gg 0pgL2cXiw3vzFOA58XRr5q2LksCMp092sdfLxGzQUNcDIPPfOsQyC9/VoZP/mwK27q ql6zVEBL8dLi61HyVykxhhh+YOKynyy/JnJFEqp2rc8+BpZdtUirGmOOTS0BUlSiDU odE1ktcY5KaOw== From: Konrad Dybcio Date: Mon, 29 Jul 2024 10:37:48 +0200 Subject: [PATCH] iommu/arm-smmu-qcom: Work around SDM845 Adreno SMMU w/ 16K pages MIME-Version: 1.0 Message-Id: <20240729-topic-845_gpu_smmu-v1-1-8e372abbde41@kernel.org> X-B4-Tracking: v=1; b=H4sIANtUp2YC/x3MQQqAIBBA0avIrBPMLKOrRITZWLOoRDOC6O5Jy 7f4/4GIgTBCxx4IeFGkY88oCwZ2NfuCnOZskEIqoWXDz8OT5a2qx8WnMW5b4mbSVeu0EWVlIYc +oKP7n/bD+360dp+KZAAAAA== To: Bjorn Andersson , Rob Clark , Will Deacon , Robin Murphy , Joerg Roedel Cc: Marijn Suijten , iommu@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Konrad Dybcio , Sumit Semwal X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722242271; l=2469; i=konradybcio@kernel.org; s=20230215; h=from:subject:message-id; bh=2WVG4OVq/a0X1nt/OAVRPPSlDahdsoGHbN6xyxn5/YE=; b=hGjcIevB0Wn7lOG4ywLtp4lmqnr4qxzsOJxqCNiUIqZyUhcghFBYu93Rj0DFKYBbHubGFVdV1 +URYCL6jDIQCy6PVA0crNynhwSa+8s061yIQ2CyNJ2CeSxTik1wPU/H X-Developer-Key: i=konradybcio@kernel.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_013759_249471_90CF6062 X-CRM114-Status: GOOD ( 12.85 ) 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 From: Konrad Dybcio SDM845's Adreno SMMU is unique in that it actually advertizes support for 16K (and 32M) pages, which doesn't hold for newer SoCs. This however, seems either broken in the hardware implementation, the hypervisor middleware that abstracts the SMMU, or there's a bug in the Linux kernel somewhere down the line that nobody managed to track down. Booting SDM845 with 16K page sizes and drm/msm results in: *** gpu fault: ttbr0=0000000000000000 iova=000100000000c000 dir=READ type=TRANSLATION source=CP (0,0,0,0) right after loading the firmware. The GPU then starts spitting out illegal intstruction errors, as it's quite obvious that it got a bogus pointer. Hide 16K support on SDM845's Adreno SMMU to work around this. Reported-by: Sumit Semwal Signed-off-by: Konrad Dybcio --- There's a mismatch in sender/committer addresses but that's "fine": https://lore.kernel.org/linux-usb/2024072734-scenic-unwilling-71ea@gregkh/ --- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- base-commit: 931a3b3bccc96e7708c82b30b2b5fa82dfd04890 change-id: 20240726-topic-845_gpu_smmu-ab738f7a013c Best regards, diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c index 36c6b36ad4ff..d25825c05817 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c @@ -338,6 +338,15 @@ static int qcom_smmu_cfg_probe(struct arm_smmu_device *smmu) return 0; } +static int qcom_adreno_smmuv2_cfg_probe(struct arm_smmu_device *smmu) +{ + /* SDM845 Adreno SMMU advertizes 16K pages support, but something is broken */ + if (of_device_is_compatible(smmu->dev->of_node, "qcom,sdm845-smmu-v2")) + smmu->features &= ~ARM_SMMU_FEAT_FMT_AARCH64_16K; + + return 0; +} + static void qcom_smmu_write_s2cr(struct arm_smmu_device *smmu, int idx) { struct arm_smmu_s2cr *s2cr = smmu->s2crs + idx; @@ -436,6 +445,7 @@ static const struct arm_smmu_impl sdm845_smmu_500_impl = { static const struct arm_smmu_impl qcom_adreno_smmu_v2_impl = { .init_context = qcom_adreno_smmu_init_context, + .cfg_probe = qcom_adreno_smmuv2_cfg_probe, .def_domain_type = qcom_smmu_def_domain_type, .alloc_context_bank = qcom_adreno_smmu_alloc_context_bank, .write_sctlr = qcom_adreno_smmu_write_sctlr,