From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796139136; b=B3Tz/sY934PGCQEqhqt7jRitKkydC8QfcO6Xx5Y6Owv4+Jkby/kDSe1h9jSHdW2lpsXb Td7ws0i6DBO27RgZLEWf29Lzo66KMKhIA9wU0y02FqQqJ/4t06mreXGDuoFOZSwNtHsY9 Yjom9vJxKRvAZWYDjTldod1u+U+7s8W9kr7xs4AyZSWra16PMmUo1WjgMzEbZzn+WrHon SlDPy3lvW4qB+i0lkIBEHorL72iDZKlF+vDsD7JO546Tjpr3c/tJ/OnRGW/HL56jLv2V4 naKOFVS2D1kcwNc1dCPgQ1bbkLLf5zPz0D/vb83B95O5UU8Spc1zXb1jB+7vi+SASKg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796139136; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:From:Date: Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Authority-Analysis: X-Proofpoint-GUID:X-Proofpoint-ORIG-GUID:X-Proofpoint-Spam-Info: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=2+g7kL3xKmlqvPXmJRacZqOIcB3wvmTRiaY0M3rL7KQ=; b=MTTW/yTBow5Qo2T37rqZtv/7Hvl+K9PAdyUZ3gKFMM0P9IVv+l8a45J12XJWBKJxqArz vAwMMsaKdz4eFmpZSrJ6L3w0p8oKtZu9DVwYxt0QD29OFHLepzgmPRNgQPbUr1cMVFutl tPzsOMEgluC6mMK+vVNMwfAvas7Sr1Lw09Aq532cHavlnkGkX2BxXVvEGXH+Xy7vfY+OC fJ4fn02EkCRvtdMclihflGUO79Xc5DBukDZFGIc1NJpjpQL4Rz58KK9AnZ08z6qeeRcQr pVTse63KCudDYe8M7tiTmQZcfdJwYpyBZWS+yXJCwaIc4Z8qK/seYy1qx0SWHddG4oQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=l7dtzCRq; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=jwLnXDuL; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 670F0606A327 for ; Tue, 1 Dec 2026 15:32:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 670F0606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=l7dtzCRq; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=jwLnXDuL Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B1F6mZT1575219 for ; Tue, 1 Dec 2026 15:32:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 2+g7kL3xKmlqvPXmJRacZqOIcB3wvmTRiaY0M3rL7KQ=; b=l7dtzCRqNgXHWxoF 4hNqfRvnKeXPVDVJrOWsEoblyvBXYi+u5jqje8wo+vLdcfvD0ojBGrFErHE0WwZ+ QmGUubPZO5o4mjUkWoNGJmMwrC0Dcior9i1VKp+D7/71+YZ3nqI3Z0x7bpF35J1z TnxO+/zGTge0ddHpWzV73dcq34jTyZCSEiY1dS024Wsr7d/f2aB+HSAssGl6SJcG WcELvNf+BeTOzDIX5OnsAIgVVUX9ACC/NB/QhmHYNaSfgm15okSj0J/UhE056LGE 3+zp+26LVSxvICG67cjWPRV119/U2ZxOKtYuh4KDfOymYSxlz4Vj3y0NIahMLU3L LRaRvg== Received: from mail-dy1-f198.google.com (mail-dy1-f198.google.com [74.125.82.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j9sa2240q-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 01 Dec 2026 15:32:14 +0000 (GMT) Received: by mail-dy1-f198.google.com with SMTP id 5a478bee46e88-3846d5f54c1so12915428eec.1 for ; Tue, 01 Dec 2026 07:32:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796139133; x=1796743933; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=2+g7kL3xKmlqvPXmJRacZqOIcB3wvmTRiaY0M3rL7KQ=; b=jwLnXDuLG+sUluUTqO/GgB00Gg7OalOLLk7rMs7K448M/7J8zw6lnKWzSM9UBYGPRZ /MvI3lgjgx3J+AfdLIexukL8/UsIzxFHPYOMf5bI0IaPSVMgp0xa2CbktZiMsJtGk2AA UCWKlMMobDCvJc6i4ZujpEL7W/kd1soAD7Aq//BD5Se1rRdGG9C7Wpm3OPGAdSS5HXN9 /aD6fF/qtco2tbdPboVuzRIEmABXDI3CxT+sPk7B2348PwltiIF6zDQivAVgyNHrlgyX A6DAs+w3ifkGRv1OtuH+yEeRpKNaMNHSt/DMJyOgCp1mqo+3SLLVoKaEBcvwi1cS2NPg biMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796139133; x=1796743933; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=2+g7kL3xKmlqvPXmJRacZqOIcB3wvmTRiaY0M3rL7KQ=; b=TcUP0ycvsnjkTCIohrH+LJhwL9cW3JlixEg60SBh4JSrqAI0j2vv8waWdzu8LXN30b yf1GN1C9HLJqjNN1n/XZn565vGZE9WyR8sIXgtyQNb0jI3eGhOHilerWW2M5ASi+4uUx e79Xs7mxZtEV74BfGI3gBtD/xlKcv8dvp38vhwjxQtvxDEvfDDng4YqwevHAfpecMRZW C5UJEKSInZ3C4GMUtGH9a3xh28LQLmmb+8JEulGg9oL+Jk6zYELV+HdW0nKdH+u08jw1 tkyM3iAAi7t6kJxmB+kKMuzXMXMqo0qScWA1Vp7W4TflfHDhsEgqv7qKTm6p8EqBSfxF RXOQ== X-Forwarded-Encrypted: i=1; AL+hErEga+d60xC21TFALZXZLKhilc/jVtuCAztY/MLpxuDqeONcGqXfD3qNBrLVg5X4T5vHf4hV0ViiLK+QSJE=@vger.kernel.org X-Gm-Message-State: APuU4Z9Y/aLkUDLlZds/YrUxv0K2m5lX2QA7N+83CfRudSNBhZq/46+c hKdmjl4zEgqpujhgRZ53FUTkJyq/+l2pbYJl56JQhTb4HhiEQtwPSNn0035oS5niyKbRzx3q9ji cDatzx2QcDO2Q3otrg8NQjsznYYUnZI5RNGSejcQnjRn0v7P0AAzl8SMVtbwJFpxlYE6+CzM2Tq w= X-Gm-Gg: AZFdTZe84XZNHDh4QcFwreMvCjUo+giIQ3Z0O0E2m5Mg6ful0Vvcmr6d9lJ+kYAb82o DMsPbHntnEaZ7I6IDS87xlw4K9tzOQzLZQi8LSLqPzFr8ZmSidgDocFropQbjgD1nYMhmdi2zOz HQIEjf26vjG0QXvCox7CMBOiSEiJkntXqHXyQWmX8UlOn8j9OK1K13niDErTf143unt9R/7g/ra 5+nNDMAoltgpwc3XgAdFsfJTSDtClhMKomKRFWiNyglDzPDI/OTwxbhycjSIQh/C7PYgu4Auh5W ZHXuLM/5nA6+I4fIV9as2owSwBH+WOlO220dnpkP+FbDb6zKTY8NT8Ke6IAjeJRVOwbwJqT+/Fe Q1ZW0CIpmlQqIHOoKu+As8hCdqppg3wrisT63wq/N/5OmC+v4rH32k4P7qQtOj2F8PiyAaZ7Ucz I/aRrd X-Received: by 2002:a05:7301:714:b0:386:ff69:eb0a with SMTP id 5a478bee46e88-386ff69ef8bmr9942029eec.34.1796139132620; Tue, 01 Dec 2026 07:32:12 -0800 (PST) X-Received: by 2002:a05:7301:714:b0:386:ff69:eb0a with SMTP id 5a478bee46e88-386ff69ef8bmr9941890eec.34.1796139129473; Tue, 01 Dec 2026 07:32:09 -0800 (PST) Received: from hu-bibekkum-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385646633d0sm188496439eec.3.2026.12.01.07.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 07:32:08 -0800 (PST) From: Bibek Kumar Patro Date: Tue, 01 Dec 2026 21:01:32 +0530 Subject: [PATCH v5 02/21] iommu/arm-smmu: Add interconnect bandwidth voting support X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20261201-smmu_interconnect_addition-v5-2-4d22c4b85e30@oss.qualcomm.com> References: <20261201-smmu_interconnect_addition-v5-0-4d22c4b85e30@oss.qualcomm.com> In-Reply-To: <20261201-smmu_interconnect_addition-v5-0-4d22c4b85e30@oss.qualcomm.com> To: Will Deacon , Robin Murphy , "Joerg Roedel (AMD)" , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rob Clark , Bjorn Andersson , Konrad Dybcio , Abel Vesa Cc: linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Bibek Kumar Patro , Val Packett X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796139108; l=12525; i=bibek.patro@oss.qualcomm.com; s=20260617; h=from:subject:message-id; bh=adCwqiptJjNZs/laYZ5Jf08uJM2mSCznAtEFpu8vmNI=; b=Q/p7tKVfvs43yf02oya8bbAWjjuuYHLR/ZUMee469pHfM/ZSNPkkKGhK38N76Ib8apmi4V0r8 Le61bWsXeKkCKHNSc4Bqa06FAlmJnI1DMq16DzCQkt2PqFW+1I/24Jb X-Developer-Key: i=bibek.patro@oss.qualcomm.com; a=ed25519; pk=DkrbE5dhskZJmBAKR5LygWRsAydEOSN+T0/YxNYxDLM= X-Authority-Analysis: v=2.4 cv=A8/5rKWG c=1 sm=1 tr=0 ts=6b0ee87e cx=c_pps a=wEP8DlPgTf/vqF+yE6f9lg==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=EUspDBNiAAAA:8 a=XHcSWrAp5dBF00xDRBcA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=bBxd6f-gb0O0v-kibOvt:22 X-Proofpoint-GUID: jhVOh7HMJNMpBbFlWYHVzlV-UqnVo9df X-Proofpoint-ORIG-GUID: jhVOh7HMJNMpBbFlWYHVzlV-UqnVo9df X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAxMDA2MSBTYWx0ZWRfX/v50zTGkr9XV Jlta+QHfm1j2JLn6RFJHCehQGUDRaOZC6Hd757R7vz/khGaD4Mmt74J+gW0FMzkCalHYrtBr32q tnnQ/2LbBnTGwZR3oDnB54qvPRxa5WI= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAxMDA2MSBTYWx0ZWRfX75s2JghSmpdJ vWHsqj6IFXis1C2w+Rz6BomIjzOBpUbNu2IWZcsnBPRvsRumaEnXSYTzTt2ppGK2fEc9Ch51YsZ sudD4ztt8fwNXuH6TdqT6aRcU506Afw/He2P4sW7pHQco905k2v8VEtas9/B9Csq/hF4+Zk4sac Njyjsx7aqWiKW7ocrDQoTbYh3AA5qNAIYbBv8C8Nr3Okl3gqHufmnLev1LO+IYZOuIBN/kDBEYD wxY97LdN9CsFujgpX1SeHlzAd9k1ktBe4LVB33jLRs4UEgEVMAnfAf+JlyIZpbu830+eTB/KyGt 5x3ygdmFyVkSm3tAG9mbXR2+A/p8D+NAfYfdfqC9itppBzFznwWQbYd6We7YUVGx3h493Gl9k48 WVWInjOaQ7jJIuUEFKfUflNk4o36xjOk2Z4SHgjtemcXfk/UJlgq7XG3ZLT+kUSm9enzZKpkWmz M5xd+4Ci+9o7WIdh+6A== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-01_03,2026-12-01_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 priorityscore=1501 bulkscore=0 spamscore=0 malwarescore=0 clxscore=1015 adultscore=0 lowpriorityscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612010061 On Qualcomm SoCs using the ARM MMU-500 as the adreno SMMU, the GPU TCU sits on GEM_NOC as an independent AXI master and requires an active interconnect bandwidth vote for its registers to be accessible. While other clients typically satisfy this requirement implicitly, certain corner cases (e.g. during sleep/wakeup transitions) can leave the SMMU without a vote, causing intermittent register access failures. Add support for an optional interconnect path to the arm-smmu driver and vote for bandwidth while the SMMU is active. The path is acquired from DT if present and ignored otherwise. The bandwidth vote is enabled before accessing SMMU registers during probe and runtime resume, and released during runtime suspend and on error paths. Generally, from an architectural perspective, GEM_NOC and DDR are expected to have an active vote whenever the adreno_smmu block is powered on. In most common use cases, this requirement is implicitly satisfied because other GPU-related clients (for example, the GMU device) already hold a GEM_NOC vote when adreno_smmu is enabled. However, there are certain corner cases, such as during sleep/wakeup transitions, where the GEM_NOC vote can be removed before adreno_smmu is powered down. If adreno_smmu is then accessed while the interconnect vote is missing, it can lead to the observed failures. Because of the precise ordering involved, this scenario is difficult to reproduce consistently. Additionally, GDSC power state transitions in adreno use cases can independently drop the interconnect vote, further contributing to this race. The design difference between QSMMU (SMMU-v2) and SMMU-500 explains why an explicit ICC vote is needed only for the latter: QSMMU (SMMU-v2) — SM6250 / SDM845 era: The TCU is NOT a separate hardware master. It is integrated INSIDE the SMMU-v2 block itself. GPU SS +----------------------------------+ | QSMMU (SMMU-v2 @ 0x5040000) | | +----------------------------+ | | | TCU (integrated, no | | | | separate AXI master port) | | | +------------+---------------+ | | | page table walk | | | issued on same | | | AXI port as GPU | +---------------+------------------+ | | qxm_gpu0 / qxm_gpu1 | (GPU data + TCU walks share same NOC master) v GEM_NOC -> LLCC -> MC -> DDR On SMMU-v2 platforms the TCU never needs an independent vote because it physically cannot be active without the GPU data path also being active. SMMU-500 — SM8150+ / SA8775P / SC7280 etc.: The TCU is a SEPARATE hardware block with its OWN AXI master. GPU SS +----------------------------------+ | +-------------+ +-----------+ | | | GPU Core | | GPU TCU | | <- distinct HW block | | (rendering)| | + DVM | | | +------+------+ +-----+-----+ | +---------+---------------+--------+ | | qnm_gpu0/1 alm_gpu_tcu <- separate NOC master port | | +-------+-------+ v GEM_NOC -> LLCC -> MC -> DDR On SMMU-500 the TCU has its own master port — it can be active (e.g. page table walks during wakeup) while the GPU data path is idle, leaving GEM_NOC without any other voter. Hence the explicit MASTER_GPU_TCU -> SLAVE_EBI1 vote is required. Signed-off-by: Bibek Kumar Patro Tested-by: Val Packett # sm7325-motorola-dubai --- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 50 ++++++++++++++++++++++++ drivers/iommu/arm/arm-smmu/arm-smmu-qcom.h | 4 ++ drivers/iommu/arm/arm-smmu/arm-smmu.c | 61 ++++++++++++++++++++++++------ drivers/iommu/arm/arm-smmu/arm-smmu.h | 2 + 4 files changed, 106 insertions(+), 11 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c index 795e8ec7e8fa..eee20811eede 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -608,6 +609,45 @@ static int qcom_sdm845_smmu500_reset(struct arm_smmu_device *smmu) return ret; } +static int qcom_adreno_smmu_icc_init(struct arm_smmu_device *smmu) +{ + struct qcom_smmu *qsmmu = container_of(smmu, struct qcom_smmu, smmu); + int err; + + qsmmu->icc_path = devm_of_icc_get(smmu->dev, NULL); + if (!IS_ERR(qsmmu->icc_path)) + return 0; + + err = PTR_ERR(qsmmu->icc_path); + + if (err == -ENODEV) { + qsmmu->icc_path = NULL; + return 0; + } + return dev_err_probe(smmu->dev, err, + "failed to get interconnect path\n"); +} + +static int qcom_adreno_smmu_runtime_resume(struct arm_smmu_device *smmu) +{ + struct qcom_smmu *qsmmu = container_of(smmu, struct qcom_smmu, smmu); + int ret; + + ret = icc_set_bw(qsmmu->icc_path, 0, 1); + WARN_ON_ONCE(ret); + return ret; +} + +static int qcom_adreno_smmu_runtime_suspend(struct arm_smmu_device *smmu) +{ + struct qcom_smmu *qsmmu = container_of(smmu, struct qcom_smmu, smmu); + int ret; + + ret = icc_set_bw(qsmmu->icc_path, 0, 0); + WARN_ON_ONCE(ret); + return ret; +} + static const struct arm_smmu_impl qcom_smmu_v2_impl = { .init_context = qcom_smmu_init_context, .cfg_probe = qcom_smmu_cfg_probe, @@ -659,6 +699,8 @@ static const struct arm_smmu_impl qcom_adreno_smmu_500_impl = { .alloc_context_bank = qcom_adreno_smmu_alloc_context_bank, .write_sctlr = qcom_adreno_smmu_write_sctlr, .tlb_sync = qcom_smmu_tlb_sync, + .runtime_resume = qcom_adreno_smmu_runtime_resume, + .runtime_suspend = qcom_adreno_smmu_runtime_suspend, .context_fault_needs_threaded_irq = true, }; @@ -668,6 +710,7 @@ static struct arm_smmu_device *qcom_smmu_create(struct arm_smmu_device *smmu, const struct device_node *np = smmu->dev->of_node; const struct arm_smmu_impl *impl; struct qcom_smmu *qsmmu; + int ret; if (!data) return ERR_PTR(-EINVAL); @@ -692,6 +735,12 @@ static struct arm_smmu_device *qcom_smmu_create(struct arm_smmu_device *smmu, qsmmu->smmu.impl = impl; qsmmu->data = data; + if (data->icc_init) { + ret = data->icc_init(&qsmmu->smmu); + if (ret) + return ERR_PTR(ret); + } + return &qsmmu->smmu; } @@ -734,6 +783,7 @@ static const struct qcom_smmu_match_data qcom_smmu_500_impl0_data = { .adreno_impl = &qcom_adreno_smmu_500_impl, .cfg = &qcom_smmu_impl0_cfg, .client_match = qcom_smmu_actlr_client_of_match, + .icc_init = qcom_adreno_smmu_icc_init, }; /* diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.h b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.h index 8addd453f5f1..12c3eda780dc 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.h +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.h @@ -6,12 +6,15 @@ #ifndef _ARM_SMMU_QCOM_H #define _ARM_SMMU_QCOM_H +struct icc_path; + struct qcom_smmu { struct arm_smmu_device smmu; const struct qcom_smmu_match_data *data; bool bypass_quirk; u8 bypass_cbndx; u32 stall_enabled; + struct icc_path *icc_path; }; enum qcom_smmu_impl_reg_offset { @@ -29,6 +32,7 @@ struct qcom_smmu_match_data { const struct arm_smmu_impl *impl; const struct arm_smmu_impl *adreno_impl; const struct of_device_id * const client_match; + int (*icc_init)(struct arm_smmu_device *smmu); }; irqreturn_t qcom_smmu_context_fault(int irq, void *dev); diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index 798ab2ed5369..4d365c16bb26 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -2180,16 +2180,25 @@ static int arm_smmu_device_probe(struct platform_device *pdev) if (err) return err; + if (smmu->impl && smmu->impl->runtime_resume) { + err = smmu->impl->runtime_resume(smmu); + if (err) { + clk_bulk_disable_unprepare(smmu->num_clks, smmu->clks); + return err; + } + } + err = arm_smmu_device_cfg_probe(smmu); if (err) - return err; + goto err_impl_suspend; if (smmu->version == ARM_SMMU_V2) { if (smmu->num_context_banks > smmu->num_context_irqs) { dev_err(dev, "found only %d context irq(s) but %d required\n", smmu->num_context_irqs, smmu->num_context_banks); - return -ENODEV; + err = -ENODEV; + goto err_impl_suspend; } /* Ignore superfluous interrupts */ @@ -2204,13 +2213,15 @@ static int arm_smmu_device_probe(struct platform_device *pdev) for (i = 0; i < global_irqs; i++) { int irq = platform_get_irq(pdev, i); - if (irq < 0) - return irq; + if (irq < 0) { + err = irq; + goto err_impl_suspend; + } err = devm_request_irq(dev, irq, global_fault, IRQF_SHARED, "arm-smmu global fault", smmu); if (err) - return err; + goto err_impl_suspend; } platform_set_drvdata(pdev, smmu); @@ -2223,14 +2234,17 @@ static int arm_smmu_device_probe(struct platform_device *pdev) err = iommu_device_sysfs_add(&smmu->iommu, smmu->dev, NULL, "smmu.%pa", &smmu->ioaddr); - if (err) - return dev_err_probe(dev, err, "Failed to register iommu in sysfs\n"); + if (err) { + dev_err_probe(dev, err, "Failed to register iommu in sysfs\n"); + goto err_impl_suspend; + } err = iommu_device_register(&smmu->iommu, &arm_smmu_ops, using_legacy_binding ? NULL : dev); if (err) { iommu_device_sysfs_remove(&smmu->iommu); - return dev_err_probe(dev, err, "Failed to register iommu\n"); + dev_err_probe(dev, err, "Failed to register iommu\n"); + goto err_impl_suspend; } /* @@ -2246,6 +2260,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev) } return 0; + +err_impl_suspend: + if (smmu->impl && smmu->impl->runtime_suspend) + smmu->impl->runtime_suspend(smmu); + clk_bulk_disable_unprepare(smmu->num_clks, smmu->clks); + return err; } static void arm_smmu_device_shutdown(struct platform_device *pdev) @@ -2260,10 +2280,13 @@ static void arm_smmu_device_shutdown(struct platform_device *pdev) arm_smmu_gr0_write(smmu, ARM_SMMU_GR0_sCR0, ARM_SMMU_sCR0_CLIENTPD); arm_smmu_rpm_put(smmu); - if (pm_runtime_enabled(smmu->dev)) + if (pm_runtime_enabled(smmu->dev)) { pm_runtime_force_suspend(smmu->dev); - else + } else { + if (smmu->impl && smmu->impl->runtime_suspend) + smmu->impl->runtime_suspend(smmu); clk_bulk_disable(smmu->num_clks, smmu->clks); + } clk_bulk_unprepare(smmu->num_clks, smmu->clks); } @@ -2283,9 +2306,18 @@ static int __maybe_unused arm_smmu_runtime_resume(struct device *dev) struct arm_smmu_device *smmu = dev_get_drvdata(dev); int ret; + if (smmu->impl && smmu->impl->runtime_resume) { + ret = smmu->impl->runtime_resume(smmu); + if (ret) + return ret; + } + ret = clk_bulk_enable(smmu->num_clks, smmu->clks); - if (ret) + if (ret) { + if (smmu->impl && smmu->impl->runtime_suspend) + smmu->impl->runtime_suspend(smmu); return ret; + } arm_smmu_device_reset(smmu); @@ -2295,6 +2327,13 @@ static int __maybe_unused arm_smmu_runtime_resume(struct device *dev) static int __maybe_unused arm_smmu_runtime_suspend(struct device *dev) { struct arm_smmu_device *smmu = dev_get_drvdata(dev); + int ret; + + if (smmu->impl && smmu->impl->runtime_suspend) { + ret = smmu->impl->runtime_suspend(smmu); + if (ret) + return ret; + } clk_bulk_disable(smmu->num_clks, smmu->clks); diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.h b/drivers/iommu/arm/arm-smmu/arm-smmu.h index 26d2e33cd328..ed08f86cf99d 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.h +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.h @@ -455,6 +455,8 @@ struct arm_smmu_impl { void (*write_s2cr)(struct arm_smmu_device *smmu, int idx); void (*write_sctlr)(struct arm_smmu_device *smmu, int idx, u32 reg); void (*probe_finalize)(struct arm_smmu_device *smmu, struct device *dev); + int (*runtime_resume)(struct arm_smmu_device *smmu); + int (*runtime_suspend)(struct arm_smmu_device *smmu); }; #define INVALID_SMENDX -1 -- 2.34.1