Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.179 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796128728; b=5S7xS5ppMvUEINHv471g1RrBkA5V+kP5g6Y0P72PkbokkXMNgrzAw9NjQVxAenMYCRBY rMJcowiWTI4HrcaLHUjmXr7dPsJJzHhRT/tr9qAXMGZVRj++fjVjrgJ+j+wZcAJopsGNH 6cl0psmbVAXOgt3527p+5FcQhS1s0mqtAVZurv6hPkQlbrqPav7sDdU9gEj3pt8x140OG Doa+SLtb/c52JZMoNR0nsZbaKMsjkX0IE/ZZobtunRpGhAflQtNILK2AxgOhoBt+p/akX K1Ryfe4WJq8MNbf1Bd/Zrqao5U7aW7i7pInELHuujjLiHmrf+EQ1xLIWGa6HlVsDVBw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796128728; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg: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; bh=zYwsA6fELlUOLKSWE0Cigfr8Is+/vOEX5UpPIHSB48M=; b=HyFTp8maU0ckKQxm5jb6f2sfN7RcCA+GKzdMY8C20Zbf6QKq4JkNT6RTNYtsceZhgQw4 1Ap/S60BeigRGuPhJHE1D1sZXcSwV0HJ5t7sOin8WOdY/MNQBHcYYyZ39TS9/hMG0H+Be HEpSBH4iwBv+lka9NegzxzfzDybIi9CVTYitDHZtlfESJM8PLlmAklfaQP9p8zaKEr8Ur MrU3LqTTavs4H2VXfv8Ld4Meu51bHdG1gHEI62RxgqaaMGWp5rxkCDoXMFK4T+WfSsfC5 b6TBDKhEVXv6Q8hgghLytb2kqPIqT+AGFLfGZU9jnTwKis9hclYh8s6rEJ25bqw+aoQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=UY6GsI3l; arc=none smtp.remote-ip=74.125.82.179 Received: from mail-dy1-f179.google.com (mail-dy1-f179.google.com [74.125.82.179]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A422606A31A for ; Tue, 1 Dec 2026 12:38:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4A422606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=UY6GsI3l Received: by mail-dy1-f179.google.com with SMTP id 5a478bee46e88-38190551625so21942200eec.1 for ; Tue, 01 Dec 2026 04:38:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796128726; x=1796733526; 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=zYwsA6fELlUOLKSWE0Cigfr8Is+/vOEX5UpPIHSB48M=; b=UY6GsI3l8/Qym+CX8QLKP4sR/SwNqCCIvvmecCDYWpOFGbsbMKGGrkaPNEZysdwPwv h8GEQqK0Fgk+SVrQqUsJFqDs/eNPEkmRlI7aTmozAdz30QGzNT9fVEE8GySzi6VnWCAl TYRANbHbP0Vl5v5XUAiTb9TM5xcBbXrS88eDnxZKgwFAT0sRtQ1pMTBK4JmmkiqlOg19 eCHp9Na3geaxsWmrLKnHC/3bvBCrGFOLDTv7Cyy2aJ5Y3QNSHhWTnqKVNJ38pqI+xioZ 3CH1ihD0eaWW47F86u+9WHOKWaueIQx4dzPQa2xLlGEzXUpsiZT975FpIg6wPfiRVd7B Kwaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796128726; x=1796733526; 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=zYwsA6fELlUOLKSWE0Cigfr8Is+/vOEX5UpPIHSB48M=; b=09r3Rs+IXHziWgkiHFns7E949+LDq9ZDwhTLUTdRF6HD9N/JUo5Ud00M/MGotXp11a NycKqY3ACHOuR8pmZMUMSCGGvDre57mphY6LvCfd7j8bI11q6eWionNjDTAQYyMdrPsM WqRSYWz9+Stuu4U1pt1MBAsI9iNg9AQY7Vvv0jtewL3+xnXaS0NBdRomcSCxKMHyrieI IBMjMM4zDUMcB6WWQ4vFx+OprK0gqEMZIwQS6z/oI7L3HkxEzOs+WM2jHRm9ZRTRj79L BrAjQ9hmwDWQhzhywj0qz9tDv48OR023/GDTx3eEBans9+Ocnw1+gfdIJUti0xj+ELb/ A2NA== X-Gm-Message-State: APuU4Z/pNZAugOa7HrVVdA3w8fmQsxqcYUyYnxSBXsXEJyrTPs6+HCRr zCSVrJthg/aJnaZxIpCEWlO7LwRungxAIUy38qpJjDeP8jv0ACWVdfhd X-Gm-Gg: AZFdTZeyixSD/a4nz6F3wviAvn35r5Y/dGUiUiT88da3eh+G/wo5ZT0G7ZaSp38SbTV Z83nplJcBCr8Y5AQmsjCq6OFHeGv0MmmcXYnko2PRXb520rr2lC02or52ri6j3E2DSelY+ptdy4 LbCqcMPfyQBsGkfjFk9sPssEI7w5TZD7eypa5SEXzb8wd80O1gqyNGCmvaxPCVGWC2AAMmr2nH1 LINt1MYhIgtGGaLeu9ndhjfxbSDdDWJIqGRZpRM5zvBpS6YuXvJz3kMrBytHjPBCVi/ctKEwPNU aZ/3te/gtX78NnvV577vGVCzoG+zZs7gFe0OTsD4iy3WcWzJtSygt0wGvLYlYgRRCW9ILykeXd8 ngtWaquh/kA6JhSQYCJ9kTxW3xwCQrnOI15mmNfqNzs6LOknjX94RrIQZ+JRvYnQi3lylDrWMal nTEW7+KgF3r0HgIDSUS8AC6GjAKmJ6SgF6T8wx7JpDgCvHqBBORejZZtco+pBIVzdOdsl71UN5W klXAbi0FNQ0qgmizjCRHKxLNHUwJGlkOQs1p1eBxcF4T2o2BSBZPm06nLyvmGDr46m+CWga27So /1PfN6PS6wSeerY8BHSA0M/wgu3xu43uUYWClpCY+T9BcoZYHzzUNO4IqrVB1Si3r4v0hJMHfLo FMGCatZhyWyzRgWAxAKkwC3wGT1Eq X-Received: by 2002:a05:7301:6192:10b0:386:a7f2:88e2 with SMTP id 5a478bee46e88-386a7f28967mr28896245eec.23.1796128726418; Tue, 01 Dec 2026 04:38:46 -0800 (PST) Received: from Sobhana.localdomain ([157.51.214.229]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-38567abb870sm91419865eec.25.2026.12.01.04.38.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 04:38:45 -0800 (PST) From: Sreeshankar K Date: Tue, 01 Dec 2026 12:37:55 +0000 Subject: [PATCH v16 3/8] thermal/qcom/lmh: Switch to match data for SoC CPU-to-node mappings X-Mailing-List: linux-arm-msm@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: 7bit Message-Id: <20261201-sm7250-v16-3-ff2a373e16d3@gmail.com> References: <20261201-sm7250-v16-0-ff2a373e16d3@gmail.com> In-Reply-To: <20261201-sm7250-v16-0-ff2a373e16d3@gmail.com> To: Bjorn Andersson , Abel Vesa , Stephen Boyd , Brian Masney , Jerome Brunet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Taniya Das , Amit Kucheria , Thara Gopinath , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Konrad Dybcio , Robert Marko , Guru Das Srinagesh , Viresh Kumar , Manivannan Sadhasivam Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Sreeshankar K X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796128685; l=4222; i=sreeshankar0910@gmail.com; s=20261029; h=from:subject:message-id; bh=D9Zi/v3kI5W5G/fthcWJLknUlwztbMGcE2KwtySxJuU=; b=XOjlaID/Cp/WJXR2kpuHq0tuKZhbXKnt6mOR1EGf1WPtHrx6KmbQsm8QY3FNQiPqiMP0VyUMe 11Yq4bOy7OFASYwRZ/ZeUTY9P6s6omT5PqHKC11h6AnDI3A3tUgg3LM X-Developer-Key: i=sreeshankar0910@gmail.com; a=ed25519; pk=CGSHduvtn2hwLCNRXRc9s/fh6X8PH/zNdp08zC8hOuQ= lmh_probe() hardcodes the mapping of logical CPU IDs to LMh hardware cluster node IDs: CPU 0 maps to LMH_CLUSTER0_NODE_ID, and CPU 4 maps to LMH_CLUSTER1_NODE_ID. This assumption only holds true for 4+4 big.LITTLE architectures like SDM845 and SM8150. On platforms with asymmetric cluster layouts, such as the 6+2 topology on SM7250 where the big cluster starts at CPU 6, lmh_probe() fails with -EINVAL. Consequently, the second LMh node does not register its interrupt domain, which in turn causes dependent drivers like qcom-cpufreq-hw to fail or indefinitely defer probing via fw_devlink. Address this by introducing an SoC descriptor structure (struct lmh_soc_data) and an explicit mapping table (struct lmh_soc_map) associated with of_device_id match data. This encapsulates both the algorithm enable flags and the CPU-to-node mappings per compatible string. Signed-off-by: Sreeshankar K --- drivers/thermal/qcom/lmh.c | 63 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/drivers/thermal/qcom/lmh.c b/drivers/thermal/qcom/lmh.c index 6bfe25021..d796fbeae 100644 --- a/drivers/thermal/qcom/lmh.c +++ b/drivers/thermal/qcom/lmh.c @@ -94,19 +94,53 @@ static const struct irq_domain_ops lmh_irq_ops = { .xlate = irq_domain_xlate_onecell, }; +struct lmh_cluster_map { + int cpu_id; + u32 node_id; +}; + +struct lmh_soc_data { + unsigned int flags; + const struct lmh_cluster_map *map; + size_t num_nodes; +}; + +static const struct lmh_cluster_map cluster_cpu04_map[] = { + { .cpu_id = 0, .node_id = LMH_CLUSTER0_NODE_ID }, + { .cpu_id = 4, .node_id = LMH_CLUSTER1_NODE_ID }, +}; + +static const struct lmh_soc_data sdm845_data = { + .map = cluster_cpu04_map, + .num_nodes = ARRAY_SIZE(cluster_cpu04_map), + .flags = LMH_ENABLE_ALGOS, +}; + +static const struct lmh_soc_data sm8150_data = { + .map = cluster_cpu04_map, + .num_nodes = ARRAY_SIZE(cluster_cpu04_map), +}; + static int lmh_probe(struct platform_device *pdev) { + const struct lmh_soc_data *soc_data; struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; struct device_node *cpu_node; struct lmh_hw_data *lmh_data; int temp_low, temp_high, temp_arm, cpu_id, ret; unsigned int enable_alg; + bool found = false; u32 node_id; + int i; if (!qcom_scm_is_available()) return -EPROBE_DEFER; + soc_data = of_device_get_match_data(dev); + if (!soc_data) + return -EINVAL; + lmh_data = devm_kzalloc_obj(dev, *lmh_data); if (!lmh_data) return -ENOMEM; @@ -139,24 +173,23 @@ static int lmh_probe(struct platform_device *pdev) return ret; } - /* - * Only sdm845 has lmh hardware currently enabled from hlos. If this is needed - * for other platforms, revisit this to check if the should be part - * of a dt match table. - */ - if (cpu_id == 0) { - node_id = LMH_CLUSTER0_NODE_ID; - } else if (cpu_id == 4) { - node_id = LMH_CLUSTER1_NODE_ID; - } else { - dev_err(dev, "Wrong CPU id associated with LMh node\n"); + for (i = 0; i < soc_data->num_nodes; i++) { + if (cpu_id == soc_data->map[i].cpu_id) { + node_id = soc_data->map[i].node_id; + found = true; + break; + } + } + + if (!found) { + dev_err(dev, "Wrong CPU id %d associated with LMh node\n", cpu_id); return -EINVAL; } if (!qcom_scm_lmh_dcvsh_available()) return -EINVAL; - enable_alg = (uintptr_t)of_device_get_match_data(dev); + enable_alg = soc_data->flags; if (enable_alg) { ret = qcom_scm_lmh_dcvsh(LMH_SUB_FN_CRNT, LMH_ALGO_MODE_ENABLE, 1, @@ -231,9 +264,9 @@ static int lmh_probe(struct platform_device *pdev) } static const struct of_device_id lmh_table[] = { - { .compatible = "qcom,sc8180x-lmh", }, - { .compatible = "qcom,sdm845-lmh", .data = (void *)LMH_ENABLE_ALGOS}, - { .compatible = "qcom,sm8150-lmh", }, + { .compatible = "qcom,sc8180x-lmh", .data = &sm8150_data }, + { .compatible = "qcom,sdm845-lmh", .data = &sdm845_data }, + { .compatible = "qcom,sm8150-lmh", .data = &sm8150_data }, {} }; MODULE_DEVICE_TABLE(of, lmh_table); -- 2.43.0