From patchwork Sat Sep 7 18:48:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13795271 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 D8C84EB64CA for ; Sat, 7 Sep 2024 18:52:31 +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=ASoLCFAFth+L/RYaTTbW4gr5zkHU8LUy6gZz0L/32b0=; b=c8YQMvV1vyimw32G+PXs4eDVT2 rsAeXkjPC/8KwxDuL0HieiCE8zBYFRlLgzW0PeWhOjBtbhkOhqTMsFl50h5mk9I9i0sbIp5AgfWmH Pa4Z7auYxfU1Mc+yE0cb4z8NiKRGfMlTm7/rSSGEf8/9VkCLFbUuEtD1lUHV735bvKlZgvjL0BI8F CebSyyHfFsll2f6gK5KilVV7WMY6+S1XGdxII904so2bO35mYimVCi02xWcL971q32Z2oMukX5+pP g8aXeYHLIK5e8tp/pUXj6pFnXqrxQxhZLJX5Th44tV2YlPDxL4CijM2ESbGX4JRUv2fy4ipu8be29 HTVeHyVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sn0Xn-0000000FUQ4-3LtD; Sat, 07 Sep 2024 18:52:23 +0000 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sn0Tu-0000000FTZd-2JzS for linux-arm-kernel@lists.infradead.org; Sat, 07 Sep 2024 18:48:25 +0000 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2f7502f09fdso17671161fa.1 for ; Sat, 07 Sep 2024 11:48:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725734901; x=1726339701; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ASoLCFAFth+L/RYaTTbW4gr5zkHU8LUy6gZz0L/32b0=; b=bkUQw0ayp/avhMcq6r1IsSTmOBh2n5nerThzBE1D6Z/rUurQ+9CAw7z47RwbrF/qmk UklmYbdnmJv0kQqzrs3CK2RiP3uIw993oif9buuIL2IXZlZsWjCzE2WddonIxMjLESnk lso6f4yewcfucMW+Mvuu3jtXiY37PR1LGrq2PKz8TEaGMGtd95j1slHpyGtltOKGI/mf ghHrasGAp09RZeABzodALEQkyOx5SMwsZD7LIIzYLHJEKLyWS8neVS4sqKVMvY58d7/z oRBqGI8kHGlHL8i9rLKGXMYkQULiDiNU5BIkMXpTGrk+lu6la8/kp0kTQQJa/iF5Ssx9 AMJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725734901; x=1726339701; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ASoLCFAFth+L/RYaTTbW4gr5zkHU8LUy6gZz0L/32b0=; b=f73BbGi4NtgHBgEqR/9f3i4xI/rsjV/WNdpn4ZKF+rH6VtQZU2fDGJZazRA+B1t61Z 9I0ZP46PMuuwSyjjM7Dpj/xn0cNkGrZgXhpOXmpN46gB7pceEN2cLBJuXTJ0riJ8ia5W Wi6vWMguIHSeWrrmHVitTc7ey0ETO3HE7D38sxZrKgItVQ50f/+g2UWdOL4t1uiZRRn4 uTg0Kdn+HyredfcYGrkNpxZ3J7Z9sx5cofHVKKmRtL3u03X+vjx2ygdNmFDqw+Chi96s /8dEz2SLVZP6itdXQ2VRVS7nPGFKSnWK7HJWJKAE9V+/IYOLPrC7Yh/28gJvIvc7Kcs+ nI1Q== X-Forwarded-Encrypted: i=1; AJvYcCVFqkK41PDk9H1uYBHVAKQimkOB8Wib8/TxANLBlj2TE2TW2HInT8g35H0PHYw63XRAD8b0weO/Eku7j5g7laQS@lists.infradead.org X-Gm-Message-State: AOJu0YyfavuAGsDh77jkbPneCOAj9rACipp/urrspmrDtZ2io9jzqknz wECGe/dxQhDb5/fiMSh0IGcGrvnrAhwjUqTAiifSDjZ/EMKCJ1TObkzQU46PagU= X-Google-Smtp-Source: AGHT+IHT9NJuhuG4AamvpeXk9LoAYFX1Rx0Iy7N0kMWiubohIUwXALW2N+6wWLpExdHwsDiK/BRP1g== X-Received: by 2002:a05:651c:19a3:b0:2f7:586d:e5e7 with SMTP id 38308e7fff4ca-2f7586de6f4mr12201981fa.5.1725734899905; Sat, 07 Sep 2024 11:48:19 -0700 (PDT) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2f75c0b1af3sm2271861fa.129.2024.09.07.11.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Sep 2024 11:48:19 -0700 (PDT) From: Dmitry Baryshkov Date: Sat, 07 Sep 2024 21:48:12 +0300 Subject: [PATCH 1/7] iommu/arm-smmu-qcom: apply num_context_bank fixes for SDM630 / SDM660 MIME-Version: 1.0 Message-Id: <20240907-sdm660-wifi-v1-1-e316055142f8@linaro.org> References: <20240907-sdm660-wifi-v1-0-e316055142f8@linaro.org> In-Reply-To: <20240907-sdm660-wifi-v1-0-e316055142f8@linaro.org> To: Rob Clark , Will Deacon , Robin Murphy , Joerg Roedel , AngeloGioacchino Del Regno , Konrad Dybcio , Bjorn Andersson , 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 X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1917; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=4jg/7UcRjOk5Aa8PYPjFu4S06h+6mU5cJuLQp0/H3QE=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBm3J/xHjCopDQPiYASMPf01hRA68yz6IxH2T4eL eC6cfgV0lyJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZtyf8QAKCRCLPIo+Aiko 1Q9uB/0ag1ZGlUF+StHNMO5RSRr8jbA8TML029hF2MBiqykw2lDs8s8+suyKE9WYe4KswcqvVgN 4bLu2KGe0WcbuoHG/wD/0SUKHISGgj5Anq4r23QlfVb2bxp4eyH5lJGlFpX19EANfZl3+VaMWyY 9heRsRGZ3eCyB+Lbo0qZGCWzU7Stf3ugs2tVW/KpgpE+RU64fzV2B+hAZRoqrH/SSzcvZ0qR1tL NzKtpFdruw/1UcKNwMKoQJV9xo58sMiOz6W2+uJB9Md+VVFGfmCFmjQ1uK0VdwVnpwVVxQgT9Jo vCdHx4iMWcz8ZKPEMLUY7mTi4Uw0ad36gbt2aAtXUl6jX6xT X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240907_114823_141867_A502FFA2 X-CRM114-Status: GOOD ( 15.24 ) 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 The Qualcomm SDM630 / SDM660 platform requires the same kind of workaround as MSM8998: some IOMMUs have context banks reserved by firmware / TZ, touching those banks resets the board. Apply the num_context_bank workaround to those two SMMU devices in order to allow them to be used by Linux. Fixes: b812834b5329 ("iommu: arm-smmu-qcom: Add sdm630/msm8998 compatibles for qcom quirks") Signed-off-by: Dmitry Baryshkov Reviewed-by: Bjorn Andersson --- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c index 087fb4f6f4d3..13a3e3585c89 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c @@ -288,6 +288,12 @@ static int qcom_smmu_cfg_probe(struct arm_smmu_device *smmu) */ if (of_device_is_compatible(smmu->dev->of_node, "qcom,msm8998-smmu-v2") && smmu->num_context_banks == 13) smmu->num_context_banks = 12; + else if (of_device_is_compatible(smmu->dev->of_node, "qcom,sdm630-smmu-v2")) { + if (smmu->num_context_banks == 21) /* SDM630 / SDM660 A2NOC SMMU */ + smmu->num_context_banks = 7; + else if (smmu->num_context_banks == 14) /* SDM630 / SDM660 LPASS SMMU */ + smmu->num_context_banks = 13; + } /* * Some platforms support more than the Arm SMMU architected maximum of @@ -350,6 +356,11 @@ static int qcom_adreno_smmuv2_cfg_probe(struct arm_smmu_device *smmu) /* Support for 16K pages is advertised on some SoCs, but it doesn't seem to work */ smmu->features &= ~ARM_SMMU_FEAT_FMT_AARCH64_16K; + /* TZ protects several last context banks, hide them from Linux */ + if (of_device_is_compatible(smmu->dev->of_node, "qcom,sdm630-smmu-v2") && + smmu->num_context_banks == 5) + smmu->num_context_banks = 2; + return 0; }