From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C2B138F25C for ; Wed, 22 Apr 2026 17:43:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776879799; cv=none; b=jpJN4pxMyJWpPbAPQiZEjYw/qJo9UCqbeq1j8L74yWD9c9tlT1Z5bN+StdGd2kdi1AAp7XgetEAe/3L2bOj9aqt082T3bWQQt8HvAn1iVGMjVSdfBFKF0drWGcLZKMxSFIraC9fSr41G/Jd1GCC/0k6f/+43sbDs1wIZWuAkXow= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776879799; c=relaxed/simple; bh=zWS8PuwEBAA/aKTsS1W5V1wcu3h80TjX0hW2zjl2YyY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TWj43QLYA2ST9w387cyJQbsFO8F8UvRvARkNMM+HNmdNviPnshf4NuQL9XVdesR3tm8OvLR9ar+S9C7alj2PBrXOuxuR4OWdzA9tPoR5Cjq9iC2Rpszl1ngbBPjGUUkpCxIS5rbE2AB+R++7fuU0jnMoqufDsNzjPJR7acyBdMs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=HSSKvqma; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=K33xB6Ph; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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.b="HSSKvqma"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="K33xB6Ph" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63MG3ebb1230127 for ; Wed, 22 Apr 2026 17:43:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=YAVmnQsYcnQ YdpKJBDYnCqGDQ8o6FQwjhG98mPvL/qc=; b=HSSKvqma7woJ8Qi+alo+1LO+g3F APsb5flzPPCga7UTDbNJ9FADQ/PDuMLPilBhhyDDq7LMVGdXJzoRLxdIBgDCdYfS +mcJsC89mfQZ/Xe4T1LaLzO1XjWRfysO/gziDYQKYsIuKBP+8iYt8hZgXuhLIEky NVsYRhZA1LrLi2Jfgc/GF074nfLcZrNS/nL0bN0/wmo6w5vAHIwlyVgyCJzIaldB ID/t7fB5pU7fyiJf03J4m0DOXmnW8WY/TN7gn5hiB0bAImJbOqR/7xjDyyiAnOkc Nu9qTnlH3eVeNbkTEngP7ksBI+gXGnQfXOpAY05RfqwLkjIRF9SJCwOKXUw== Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dq1h68bra-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 22 Apr 2026 17:43:17 +0000 (GMT) Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-50f13da9684so41125041cf.3 for ; Wed, 22 Apr 2026 10:43:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1776879796; x=1777484596; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YAVmnQsYcnQYdpKJBDYnCqGDQ8o6FQwjhG98mPvL/qc=; b=K33xB6PhqHeIFi/UMMSq9mYTMTqCy2gjPgfva+ROpCitvOiRiPDxjW48lrHbFBhcZE JDwK/udiY4F/KQpajSE+S9t6PbVhDGgmtJmx2S6B6lvBn5+RYLAXdfP0XrnuzAt1Nx2Y jtNTamZ7RtNlMWE/8GLNqAApC8JBgu8gN4knTchgBs5l1wZgik+vMfDsjIfI4JhzgnSR fLEQkwuzfuovUFvf+wkLCNiUmlvFYfux7mW8J3OoiKx7mPmYSSN8EAYQmUrpc8C911Uc 5L9sSHPk3pfurYHvxK0PxBT/8yEPQXbDHLQH+hfuG2A9ctVChRQBNcCagUR6AuIppQeg ktuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776879796; x=1777484596; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=YAVmnQsYcnQYdpKJBDYnCqGDQ8o6FQwjhG98mPvL/qc=; b=krtydru54A4sev8A8PSjqHegdWjqhssy6KihgHZc+I1mwxQGcV+KRP2xkHz4efwLPv g1JhWXXpP5NQLQBJXXj9yjKx3lBqXhBSN0frAn0t9LEBeqYNHGcQ09LXEM+JHPeahOUr SbisQBrqreJBNFa2JNYpR4TyOqTfPNgFbJEK8OvS/gzyktw9mDThDgKrj6tdkTYHwW8v iCRcEvcMxihRICruo3Cp6oWwFsSkE+diSlB6EWqTT4qlICh8m2Ab4bJ9/ZFYu2UdodXt uKpXvsCX5YesVCyGJa/DYkJ7O2Mr6BveNPGI4K+7bJyl2n21xIIjuhL5kPM1SE5D2tF6 H+pg== X-Forwarded-Encrypted: i=1; AFNElJ+FK4nMJ6mPUwe218StQDFKtWSRx5YuCzfUpP+X8yleYLtW1ThTAZnZNy12+e5SAiT5DwVtXDD0jwG7PPw=@vger.kernel.org X-Gm-Message-State: AOJu0YzR1MP5/wMTDvSzAk1McCM+lqo3XSJeHA9IxDyEJt1PmzWKiXqy afXfZ7R3oHH9Td8mpKnSCjs2fusLOdCj1Ew977zdWagy/R0u0JByHeNLNnV0iYORMPTZfc1ZtmI h7hJMoUWzWzHDa7PoIbQjB5/aEr31yniu5Bs8TnIdXpu+630IrJlXjKiCndgZy+NFeus= X-Gm-Gg: AeBDievb03TEUUsEDFFzlDb3KdDz1lDO+zeA5UGxO1GZSFW54XtLGJ3H2wojVq1rYwh 6KHCGm50owfKJjdMsgkZHQ8xOcOfcvcwOnBOTChJ8hv+hCqkZggs5PrjA7zNEnDek2gh7wljNAW r75LwdDGhC7crXEOgK2eNP1VUJbCi1pUa7P1/nbz3/e61VUrreq89Tt7h6Tcnb1IqrSLymgwpok O928+wjqz0dRLvPPZhbbIz1V/5RIbrUPU4WYD+7aJB77JuncjWnaS34Z+cp48/b19MoA37Bdiu2 8mQ8LFp7P3xbS6rlH8YYA+by9zOpR14bfZV2Vr2RK/cJchoh8fmojuGuPsT/gKHpF/OalKfaiXe yUGbIXY3cEFNmskmkQEN8cYHRB3E6CbqcIR/kGkxopg+ZpHrWJF3nxkRyXPec X-Received: by 2002:a05:622a:5516:b0:50f:b904:457 with SMTP id d75a77b69052e-50fb9040613mr96316391cf.25.1776879796191; Wed, 22 Apr 2026 10:43:16 -0700 (PDT) X-Received: by 2002:a05:622a:5516:b0:50f:b904:457 with SMTP id d75a77b69052e-50fb9040613mr96315451cf.25.1776879795605; Wed, 22 Apr 2026 10:43:15 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:ae20:597c:99b8:d161]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488fb7a051dsm142511965e9.18.2026.04.22.10.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2026 10:43:12 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@kernel.org Cc: gaurav.kohli@oss.qualcomm.com, Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lucas Stach , Russell King , Christian Gmeiner , David Airlie , Simona Vetter , Guenter Roeck , Joel Stanley , Andrew Jeffery , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Benson Leung , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Heiko Stuebner , Thierry Reding , Jonathan Hunter , Bjorn Andersson , Konrad Dybcio , Amit Daniel Kachhap , Viresh Kumar , Neil Armstrong , Amit Kucheria , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, "Jiri Slaby (SUSE)" , Mikko Perttunen , Svyatoslav Ryhel , Thomas Gleixner , linux-tegra@vger.kernel.org (open list:TEGRA ARCHITECTURE SUPPORT) Subject: [PATCH v2 01/12] thermal/driver/tegra/soctherm: Use devm_ variant when registering a cooling device Date: Wed, 22 Apr 2026 19:42:50 +0200 Message-ID: <20260422174305.2899095-2-daniel.lezcano@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260422174305.2899095-1-daniel.lezcano@oss.qualcomm.com> References: <20260422174305.2899095-1-daniel.lezcano@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authority-Analysis: v=2.4 cv=f4Z4wuyM c=1 sm=1 tr=0 ts=69e908b5 cx=c_pps a=mPf7EqFMSY9/WdsSgAYMbA==:117 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=oPkgDEUO7JvNfMSusBkA:9 a=dawVfQjAaf238kedN5IG:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDIyMDE3MSBTYWx0ZWRfXw5RZvar9dEgd XuBa6XbFnlDfMftYZiQ1DHHOdXo422oQVsqZGK5VQJItP/32p+b9t5XRRJuLyvHABL5eR+kObVX iE6Y2Hwl8RISfHgfH1a6mxM5nmqff5RfvthQ/ZJDLIlQwJaOBsl4X5DVdT0EnYtes9qByhaz38L rdNGMCTLZzmNCYVOorTTxvuNYNMGgwBZeOYcgJ7ratZ34Dq7cxZwRyrU6sTrI3i4+vx9TL+60Ha 4X/g7HSwC/8q5LH98aAlM06Ff0aRS2xTaEd11gmEyWPxn7+4mEugn1BJVcUH8lGEOazLU2cUxgC vUE2ixunvqRnfkZXPuiligb1cByAG0GH4bMOjdJueOhZMC/MxIGyYiFdjyrMAcL1NEBGoxkVWxT YJpiLaMJKk8168barnngjt9OOUJjOMR4hAhrzzakKOlPrDnqE4Qv0+j3o8sV+yUvyKQ5UBhMOiQ 4lqs8cr2goll/rYPXRQ== X-Proofpoint-GUID: K9SKzjRxCVz45bzckQIkmnzlwUu1cxrr X-Proofpoint-ORIG-GUID: K9SKzjRxCVz45bzckQIkmnzlwUu1cxrr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-22_02,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 bulkscore=0 malwarescore=0 clxscore=1015 spamscore=0 suspectscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604220171 The driver invokes thermal_of_cooling_device_register() at probe time but without unregistering it at remove time. As we have a devm_ variant, use it and the cooling device should be automatically removed. While this prevents the cooling device from leaking, the unregistration is now deferred until devres_release_all() runs (after probe() returns an error or remove() completes). A bug can be subtly introduced by this change because the driver still manually disables the hardware clocks during the probe error path and in tegra_soctherm_remove(). This creates a window where the cooling device remains registered and exposed to the thermal core and sysfs while the underlying hardware is powered down. In order to prevent this potential issue, use the devm_ variant for the clk. Compiled-tested only. Signed-off-by: Daniel Lezcano --- drivers/thermal/tegra/soctherm.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index 5d26b52beaba..790c4c96a9b5 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -1700,9 +1700,9 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev) stc->init = true; } else { - tcd = thermal_of_cooling_device_register(np_stcc, - (char *)name, ts, - &throt_cooling_ops); + tcd = devm_thermal_of_cooling_device_register(dev, np_stcc, + (char *)name, ts, + &throt_cooling_ops); if (IS_ERR_OR_NULL(tcd)) { dev_err(dev, "throttle-cfg: %s: failed to register cooling device\n", @@ -2133,13 +2133,13 @@ static int tegra_soctherm_probe(struct platform_device *pdev) return PTR_ERR(tegra->reset); } - tegra->clock_tsensor = devm_clk_get(&pdev->dev, "tsensor"); + tegra->clock_tsensor = devm_clk_get_enabled(&pdev->dev, "tsensor"); if (IS_ERR(tegra->clock_tsensor)) { dev_err(&pdev->dev, "can't get tsensor clock\n"); return PTR_ERR(tegra->clock_tsensor); } - tegra->clock_soctherm = devm_clk_get(&pdev->dev, "soctherm"); + tegra->clock_soctherm = devm_clk_get_enabled(&pdev->dev, "soctherm"); if (IS_ERR(tegra->clock_soctherm)) { dev_err(&pdev->dev, "can't get soctherm clock\n"); return PTR_ERR(tegra->clock_soctherm); @@ -2171,10 +2171,6 @@ static int tegra_soctherm_probe(struct platform_device *pdev) if (!tegra->thermctl_tzs) return -ENOMEM; - err = soctherm_clk_enable(pdev, true); - if (err) - return err; - soctherm_thermtrips_parse(pdev); soctherm_init_hw_throt_cdev(pdev); @@ -2184,10 +2180,8 @@ static int tegra_soctherm_probe(struct platform_device *pdev) for (i = 0; i < soc->num_ttgs; ++i) { struct tegra_thermctl_zone *zone = devm_kzalloc(&pdev->dev, sizeof(*zone), GFP_KERNEL); - if (!zone) { - err = -ENOMEM; - goto disable_clocks; - } + if (!zone) + return -ENOMEM; zone->reg = tegra->regs + soc->ttgs[i]->sensor_temp_offset; zone->dev = &pdev->dev; @@ -2201,7 +2195,7 @@ static int tegra_soctherm_probe(struct platform_device *pdev) err = PTR_ERR(z); dev_err(&pdev->dev, "failed to register sensor: %d\n", err); - goto disable_clocks; + return err; } zone->tz = z; @@ -2210,7 +2204,7 @@ static int tegra_soctherm_probe(struct platform_device *pdev) /* Configure hw trip points */ err = tegra_soctherm_set_hwtrips(&pdev->dev, soc->ttgs[i], z); if (err) - goto disable_clocks; + return err; } err = soctherm_interrupts_init(pdev, tegra); @@ -2218,11 +2212,6 @@ static int tegra_soctherm_probe(struct platform_device *pdev) soctherm_debug_init(pdev); return 0; - -disable_clocks: - soctherm_clk_enable(pdev, false); - - return err; } static void tegra_soctherm_remove(struct platform_device *pdev) -- 2.43.0