From nobody Fri Oct 3 07:43:39 2025 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 ADC282D0637; Wed, 3 Sep 2025 13:18:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905492; cv=none; b=uvQn7CKwbtlI5GGZmqtS3TFYzoLgAt2QM45s/+X++xxdMaTypR9KABSb59hJUkyRKGUWOYbqe8Y76qivV1LJ/5Y5Rs9Usu0GZm4zqXeqq0iDO7XCBZGti5qpakNpS0dw9MpmrLPegO/efNI80cSsvjOMfnyiR9/9/CN5IkMaias= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905492; c=relaxed/simple; bh=/1IyDm7ikrgLLdM2a9a0dQzD1QQmw/Q0CRn1iT02oso=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WWjzwERborK9EjBtYorCtiUlv7J9DxVq3UpF/rtUnTwWMph5boaIMOBSORE06HAY9C/1ubGtQDurIaeUVFAr5mqrpQmiRipuI6yhxKxs8Pa6jGn4RXQD0kgptTtTymxAtiBct7wjZbnYKaLT/JBUiZr4GeE99gIUKA9wt4iZZM0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 692a80c688c811f0b29709d653e92f7d-20250903 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:3ddeb900-f5f4-400e-a2b5-2d2a7352155c,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:6493067,CLOUDID:d13f05546fa3a3e5009a7a2fda0e8af8,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|850,TC:nil,Content:0|50,EDM:-3 ,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV :0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 692a80c688c811f0b29709d653e92f7d-20250903 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 755720587; Wed, 03 Sep 2025 21:17:58 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 4A097E008FA2; Wed, 3 Sep 2025 21:17:58 +0800 (CST) X-ns-mid: postfix-68B84005-4750173 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id DBC83E008FA3; Wed, 3 Sep 2025 21:17:53 +0800 (CST) From: Zihuan Zhang To: "Rafael J . wysocki" , Viresh Kumar , Catalin Marinas , Will Deacon , Borislav Petkov , Dave Hansen , Srinivas Pandruvada , Michael Ellerman , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Jani Nikula , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Daniel Lezcano , Sascha Hauer , Shawn Guo , Eduardo Valentin , Keerthy Cc: Ben Horgan , zhenglifeng , Zhang Rui , Len Brown , Lukasz Luba , Pengutronix Kernel Team , Beata Michalska , Fabio Estevam , Pavel Machek , Sumit Gupta , Prasanna Kumar T S M , Sudeep Holla , Yicong Yang , linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, imx@lists.linux.dev, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Zihuan Zhang Subject: [PATCH v4 01/10] arm64: topology: Use scope-based cleanup helper Date: Wed, 3 Sep 2025 21:17:24 +0800 Message-Id: <20250903131733.57637-2-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250903131733.57637-1-zhangzihuan@kylinos.cn> References: <20250903131733.57637-1-zhangzihuan@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace the manual cpufreq_cpu_put() with __free(put_cpufreq_policy) annotation for policy references. This reduces the risk of reference counting mistakes and aligns the code with the latest kernel style. No functional change intended. Signed-off-by: Zihuan Zhang Reviewed-by: Jonathan Cameron --- arch/arm64/kernel/topology.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index 5d07ee85bdae..0eebd3492669 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -307,17 +307,16 @@ int arch_freq_get_on_cpu(int cpu) */ if (!housekeeping_cpu(cpu, HK_TYPE_TICK) || time_is_before_jiffies(last_update + msecs_to_jiffies(AMU_SAMPLE_EXP= _MS))) { - struct cpufreq_policy *policy =3D cpufreq_cpu_get(cpu); + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D + cpufreq_cpu_get(cpu); int ref_cpu; =20 if (!policy) return -EINVAL; =20 if (!cpumask_intersects(policy->related_cpus, - housekeeping_cpumask(HK_TYPE_TICK))) { - cpufreq_cpu_put(policy); + housekeeping_cpumask(HK_TYPE_TICK))) return -EOPNOTSUPP; - } =20 for_each_cpu_wrap(ref_cpu, policy->cpus, cpu + 1) { if (ref_cpu =3D=3D start_cpu) { @@ -329,8 +328,6 @@ int arch_freq_get_on_cpu(int cpu) break; } =20 - cpufreq_cpu_put(policy); - if (ref_cpu >=3D nr_cpu_ids) /* No alternative to pull info from */ return -EAGAIN; --=20 2.25.1 From nobody Fri Oct 3 07:43:39 2025 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 D09072E8B8A; Wed, 3 Sep 2025 13:18:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905495; cv=none; b=WFEbm37pllJIIz/su1MIKffV7JhSRgNMf//Evhc+mvyvFy+6YDoFVRzpy2X9wNACvuvWf8bVmA/TyzXmLSuHLW0SQuA87NyWSUOAQJTHbUqSyJHRQckcHBEk+OKqG3TvnYFv4tH49hCDojls6fq4Dc878T/pMj1cQJgwCZ7T6lU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905495; c=relaxed/simple; bh=MaEpS/kQ0iq8I+mSuZFPEXaBH8HV11drax5+pE3OzRU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OMuNjBa8DjXSg2L0e1lRxi4XWJU43pSd12+6xPR1k9RULYALghZ3iXCinLD33R9YCsLPbyQYmCiB0fUscP73eXFrpezwDze8B3fcZhu2fX3yJJ4k/Ri448UV2kh2RJiQ+fXZJ66zkSWvz4dHPBNYq61tXEUwUAwadXMiw71Qjrg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 6b6c578888c811f0b29709d653e92f7d-20250903 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:cc21363a-8291-4a3e-bd39-a186506d2f70,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:6493067,CLOUDID:63c205d422a11131bd200bea55a50c60,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|850,TC:nil,Content:0|50,EDM:-3 ,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV :0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 6b6c578888c811f0b29709d653e92f7d-20250903 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 487574624; Wed, 03 Sep 2025 21:18:02 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 1A8C2E008FA2; Wed, 3 Sep 2025 21:18:02 +0800 (CST) X-ns-mid: postfix-68B84009-9033994 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id 57859E008FA4; Wed, 3 Sep 2025 21:17:58 +0800 (CST) From: Zihuan Zhang To: "Rafael J . wysocki" , Viresh Kumar , Catalin Marinas , Will Deacon , Borislav Petkov , Dave Hansen , Srinivas Pandruvada , Michael Ellerman , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Jani Nikula , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Daniel Lezcano , Sascha Hauer , Shawn Guo , Eduardo Valentin , Keerthy Cc: Ben Horgan , zhenglifeng , Zhang Rui , Len Brown , Lukasz Luba , Pengutronix Kernel Team , Beata Michalska , Fabio Estevam , Pavel Machek , Sumit Gupta , Prasanna Kumar T S M , Sudeep Holla , Yicong Yang , linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, imx@lists.linux.dev, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Zihuan Zhang Subject: [PATCH v4 02/10] ACPI: processor: thermal: Use scope-based cleanup helper Date: Wed, 3 Sep 2025 21:17:25 +0800 Message-Id: <20250903131733.57637-3-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250903131733.57637-1-zhangzihuan@kylinos.cn> References: <20250903131733.57637-1-zhangzihuan@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace the manual cpufreq_cpu_put() with __free(put_cpufreq_policy) annotation for policy references. This reduces the risk of reference counting mistakes and aligns the code with the latest kernel style. No functional change intended. Signed-off-by: Zihuan Zhang --- drivers/acpi/processor_thermal.c | 37 ++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_ther= mal.c index 1219adb11ab9..5043f17d27b7 100644 --- a/drivers/acpi/processor_thermal.c +++ b/drivers/acpi/processor_thermal.c @@ -62,19 +62,14 @@ static int phys_package_first_cpu(int cpu) return 0; } =20 -static int cpu_has_cpufreq(unsigned int cpu) +static bool cpu_has_cpufreq(unsigned int cpu) { - struct cpufreq_policy *policy; + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D cpufreq_cpu_= get(cpu); =20 if (!acpi_processor_cpufreq_init) return 0; =20 - policy =3D cpufreq_cpu_get(cpu); - if (policy) { - cpufreq_cpu_put(policy); - return 1; - } - return 0; + return !!policy; } =20 static int cpufreq_get_max_state(unsigned int cpu) @@ -93,9 +88,23 @@ static int cpufreq_get_cur_state(unsigned int cpu) return reduction_step(cpu); } =20 +static long long cpufreq_get_max_freq(unsigned int cpu) +{ + long long max_freq; + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D + cpufreq_cpu_get(cpu); + + if (!policy) + return -EINVAL; + + max_freq =3D (policy->cpuinfo.max_freq * + (100 - reduction_step(cpu) * cpufreq_thermal_reduction_pctg)) / 100; + + return max_freq; +} + static int cpufreq_set_cur_state(unsigned int cpu, int state) { - struct cpufreq_policy *policy; struct acpi_processor *pr; unsigned long max_freq; int i, ret; @@ -120,14 +129,10 @@ static int cpufreq_set_cur_state(unsigned int cpu, in= t state) if (unlikely(!freq_qos_request_active(&pr->thermal_req))) continue; =20 - policy =3D cpufreq_cpu_get(i); - if (!policy) - return -EINVAL; - - max_freq =3D (policy->cpuinfo.max_freq * - (100 - reduction_step(i) * cpufreq_thermal_reduction_pctg)) / 100; + max_freq =3D cpufreq_get_max_freq(cpu); =20 - cpufreq_cpu_put(policy); + if (max_freq =3D=3D -EINVAL) + return -EINVAL; =20 ret =3D freq_qos_update_request(&pr->thermal_req, max_freq); if (ret < 0) { --=20 2.25.1 From nobody Fri Oct 3 07:43:39 2025 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 420D32FFDD4; Wed, 3 Sep 2025 13:18:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905496; cv=none; b=TgsJdv7OIklZ8BFgGRrKxx8ufD3G49JHtXTw15BMy3susJfRl2tLQuP7YihhKkaHOGoHXsbvkDX09UIbMY2tWcdkWligugbxbK2zIo0wpSPoi1WVnw3zAIGFBkEmaTZpZ4jtYHkbz+7aMW/xQQxNGV/m12uU/X0riyC5BE+55DA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905496; c=relaxed/simple; bh=Ri+HnsehT5qmnrFfhsWPu06KH5Cd4uzOm/bRovy4hUE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CtON1wzVNm2wr1n8+TPOLKlw88E8Op5/TJx8WUoMaYHftSwKW7vh+voaW6aPJR0W7vd08z3CauFz2jac2vLYGX2fKDTulhXgAseeh5k0taDFT9tun0kzuHNa8RlmMdzTFgkqhSaKIUHqUJXUJ5Iv3daib//hX65mZdeRQMILMNs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 6d9ec34288c811f0b29709d653e92f7d-20250903 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:ac5747f3-9e1d-490b-8e6c-f666a217ea55,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:6493067,CLOUDID:9b0da8ae305601572ea3b633d2580e0b,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|850,TC:nil,Content:0|50,EDM:-3 ,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV :0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 6d9ec34288c811f0b29709d653e92f7d-20250903 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 386945722; Wed, 03 Sep 2025 21:18:06 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id D7260E008FA2; Wed, 3 Sep 2025 21:18:05 +0800 (CST) X-ns-mid: postfix-68B8400D-6807325 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id 25471E008FA3; Wed, 3 Sep 2025 21:18:02 +0800 (CST) From: Zihuan Zhang To: "Rafael J . wysocki" , Viresh Kumar , Catalin Marinas , Will Deacon , Borislav Petkov , Dave Hansen , Srinivas Pandruvada , Michael Ellerman , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Jani Nikula , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Daniel Lezcano , Sascha Hauer , Shawn Guo , Eduardo Valentin , Keerthy Cc: Ben Horgan , zhenglifeng , Zhang Rui , Len Brown , Lukasz Luba , Pengutronix Kernel Team , Beata Michalska , Fabio Estevam , Pavel Machek , Sumit Gupta , Prasanna Kumar T S M , Sudeep Holla , Yicong Yang , linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, imx@lists.linux.dev, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Zihuan Zhang Subject: [PATCH v4 03/10] cpufreq: intel_pstate: Use scope-based cleanup helper Date: Wed, 3 Sep 2025 21:17:26 +0800 Message-Id: <20250903131733.57637-4-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250903131733.57637-1-zhangzihuan@kylinos.cn> References: <20250903131733.57637-1-zhangzihuan@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace the manual cpufreq_cpu_put() with __free(put_cpufreq_policy) annotation for policy references. This reduces the risk of reference counting mistakes and aligns the code with the latest kernel style. No functional change intended. Signed-off-by: Zihuan Zhang Reviewed-by: Jonathan Cameron --- drivers/cpufreq/intel_pstate.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index f366d35c5840..925efb1e65be 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -1209,6 +1209,17 @@ static bool hybrid_clear_max_perf_cpu(void) return ret; } =20 +static struct freq_qos_request *intel_pstate_cpufreq_get_req(int cpu) +{ + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D + cpufreq_cpu_get(cpu); + + if (!policy) + return NULL; + + return policy->driver_data; +} + static void __intel_pstate_get_hwp_cap(struct cpudata *cpu) { u64 cap; @@ -1698,19 +1709,13 @@ static ssize_t store_no_turbo(struct kobject *a, st= ruct kobj_attribute *b, static void update_qos_request(enum freq_qos_req_type type) { struct freq_qos_request *req; - struct cpufreq_policy *policy; int i; =20 for_each_possible_cpu(i) { struct cpudata *cpu =3D all_cpu_data[i]; unsigned int freq, perf_pct; =20 - policy =3D cpufreq_cpu_get(i); - if (!policy) - continue; - - req =3D policy->driver_data; - cpufreq_cpu_put(policy); + req =3D intel_pstate_cpufreq_get_req(i); =20 if (!req) continue; --=20 2.25.1 From nobody Fri Oct 3 07:43:39 2025 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 A476B302774; Wed, 3 Sep 2025 13:18:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905500; cv=none; b=FOVC00v2tv236tbTVjZ1nZHLVhGfrfR5SndfKLeT9mrDneovmRh5fgHoZ5waEfkrlEz9Qf5xhi55CfN3+oUsOO9RreS4UjWUPJMY92un2sQf3uHAHC2V1u5yjjqLGj3/3gzUOk1yDvZ6iSiE7Ob+mVkFF63IZwUyPmeXeKup18E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905500; c=relaxed/simple; bh=25xihmgNFYPtSP4uZbH8/sjypxcxoQ7omwmmQUSgg98=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ikn23Kys/d/fvSZlLrRjewuMM3wfskKhEDFQATdyOARpfxa72XIGml24w1B2Uy3QXJsc2TzGwnKyLB6NvXm/ENxwInrsGvY4Diq6q4xu0DHdli57An4/z38VnPQnh35z/hjZ4WpbCbPXaABYvZg2zNo8MuhUG6g6Uq0QoXMzzgc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 6fdb27e088c811f0b29709d653e92f7d-20250903 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:12ed8bd1-e772-4e2f-b7a0-b366cc106c8e,IP:0,U RL:0,TC:0,Content:38,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:38 X-CID-META: VersionHash:6493067,CLOUDID:c7bcb509d5c742570f4125e3bd0d306b,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|850,TC:nil,Content:4|50,EDM:-3 ,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV :0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 6fdb27e088c811f0b29709d653e92f7d-20250903 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 1513682554; Wed, 03 Sep 2025 21:18:09 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id A2980E008FA2; Wed, 3 Sep 2025 21:18:09 +0800 (CST) X-ns-mid: postfix-68B84011-4806846 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id E3EF1E008FA4; Wed, 3 Sep 2025 21:18:05 +0800 (CST) From: Zihuan Zhang To: "Rafael J . wysocki" , Viresh Kumar , Catalin Marinas , Will Deacon , Borislav Petkov , Dave Hansen , Srinivas Pandruvada , Michael Ellerman , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Jani Nikula , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Daniel Lezcano , Sascha Hauer , Shawn Guo , Eduardo Valentin , Keerthy Cc: Ben Horgan , zhenglifeng , Zhang Rui , Len Brown , Lukasz Luba , Pengutronix Kernel Team , Beata Michalska , Fabio Estevam , Pavel Machek , Sumit Gupta , Prasanna Kumar T S M , Sudeep Holla , Yicong Yang , linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, imx@lists.linux.dev, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Zihuan Zhang Subject: [PATCH v4 04/10] cpufreq: powernv: Use scope-based cleanup helper Date: Wed, 3 Sep 2025 21:17:27 +0800 Message-Id: <20250903131733.57637-5-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250903131733.57637-1-zhangzihuan@kylinos.cn> References: <20250903131733.57637-1-zhangzihuan@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace the manual cpufreq_cpu_put() with __free(put_cpufreq_policy) annotation for policy references. This reduces the risk of reference counting mistakes and aligns the code with the latest kernel style. No functional change intended. Signed-off-by: Zihuan Zhang --- drivers/cpufreq/powernv-cpufreq.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cp= ufreq.c index 7d9a5f656de8..811fdbf398fa 100644 --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c @@ -892,15 +892,15 @@ static int powernv_cpufreq_reboot_notifier(struct not= ifier_block *nb, unsigned long action, void *unused) { int cpu; - struct cpufreq_policy *cpu_policy; =20 rebooting =3D true; for_each_online_cpu(cpu) { - cpu_policy =3D cpufreq_cpu_get(cpu); + struct cpufreq_policy *cpu_policy __free(put_cpufreq_policy) =3D + cpufreq_cpu_get(cpu); + if (!cpu_policy) continue; powernv_cpufreq_target_index(cpu_policy, get_nominal_index()); - cpufreq_cpu_put(cpu_policy); } =20 return NOTIFY_DONE; @@ -913,7 +913,6 @@ static struct notifier_block powernv_cpufreq_reboot_nb = =3D { static void powernv_cpufreq_work_fn(struct work_struct *work) { struct chip *chip =3D container_of(work, struct chip, throttle); - struct cpufreq_policy *policy; unsigned int cpu; cpumask_t mask; =20 @@ -928,14 +927,14 @@ static void powernv_cpufreq_work_fn(struct work_struc= t *work) chip->restore =3D false; for_each_cpu(cpu, &mask) { int index; + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D + cpufreq_cpu_get(cpu); =20 - policy =3D cpufreq_cpu_get(cpu); if (!policy) continue; index =3D cpufreq_table_find_index_c(policy, policy->cur, false); powernv_cpufreq_target_index(policy, index); cpumask_andnot(&mask, &mask, policy->cpus); - cpufreq_cpu_put(policy); } out: cpus_read_unlock(); --=20 2.25.1 From nobody Fri Oct 3 07:43:39 2025 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 4D434303C87; Wed, 3 Sep 2025 13:18:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905503; cv=none; b=H+kMNeg/VwLSf5+7pAlDxeGdKXFnqtqOiyBRlWhUdiq2SUs102UT/Bbj6cCjJeAwauHcOyfKKwqnYhI8ejBC5nFUnfFg8uWLzTN5plmbu7Bw4r9bi/Znu9fX/0N/YUYAgkZBIYkOcsbW6tt81YDAAxhuaWJOtpvnPOP0de4uHO4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905503; c=relaxed/simple; bh=6PsNSJA12rQtQ1XvZDJQx6WZz6bBmX6iNEjUN6S7Ojw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HfxeKixD2oy1X9frdjijw1budDaK6pwgRhGjONnO2wlVnUtwO7l8gEOCRJf24aCFPaKlTaKoWvSg4B0PCK8UvZvjAQE13H8BqOVHu7yqHmpL9srJ7Jyfb4zKB/glMcYr91pe3m91RPVzh9NNu+fmYhA2nH6WQMb8S4NuQQdKZf0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 7225f52a88c811f0b29709d653e92f7d-20250903 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:03d6cce6-2064-47c3-bebb-0dae30991a82,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:6493067,CLOUDID:ff7be0c6729f0e3faf64acb4b4023c94,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|850,TC:nil,Content:0|50,EDM:-3 ,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV :0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 7225f52a88c811f0b29709d653e92f7d-20250903 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 1862006784; Wed, 03 Sep 2025 21:18:13 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 791F1E008FA2; Wed, 3 Sep 2025 21:18:13 +0800 (CST) X-ns-mid: postfix-68B84015-3074077 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id AF321E008FA3; Wed, 3 Sep 2025 21:18:09 +0800 (CST) From: Zihuan Zhang To: "Rafael J . wysocki" , Viresh Kumar , Catalin Marinas , Will Deacon , Borislav Petkov , Dave Hansen , Srinivas Pandruvada , Michael Ellerman , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Jani Nikula , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Daniel Lezcano , Sascha Hauer , Shawn Guo , Eduardo Valentin , Keerthy Cc: Ben Horgan , zhenglifeng , Zhang Rui , Len Brown , Lukasz Luba , Pengutronix Kernel Team , Beata Michalska , Fabio Estevam , Pavel Machek , Sumit Gupta , Prasanna Kumar T S M , Sudeep Holla , Yicong Yang , linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, imx@lists.linux.dev, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Zihuan Zhang Subject: [PATCH v4 05/10] PM / devfreq: Use scope-based cleanup helper Date: Wed, 3 Sep 2025 21:17:28 +0800 Message-Id: <20250903131733.57637-6-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250903131733.57637-1-zhangzihuan@kylinos.cn> References: <20250903131733.57637-1-zhangzihuan@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace the manual cpufreq_cpu_put() with __free(put_cpufreq_policy) annotation for policy references. This reduces the risk of reference counting mistakes and aligns the code with the latest kernel style. No functional change intended. Signed-off-by: Zihuan Zhang --- drivers/devfreq/governor_passive.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_= passive.c index 953cf9a1e9f7..a035cf44bdb8 100644 --- a/drivers/devfreq/governor_passive.c +++ b/drivers/devfreq/governor_passive.c @@ -80,24 +80,23 @@ static int get_target_freq_with_cpufreq(struct devfreq = *devfreq, struct devfreq_passive_data *p_data =3D (struct devfreq_passive_data *)devfreq->data; struct devfreq_cpu_data *parent_cpu_data; - struct cpufreq_policy *policy; unsigned long cpu, cpu_cur, cpu_min, cpu_max, cpu_percent; unsigned long dev_min, dev_max; unsigned long freq =3D 0; int ret =3D 0; =20 for_each_online_cpu(cpu) { - policy =3D cpufreq_cpu_get(cpu); + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D + cpufreq_cpu_get(cpu); + if (!policy) { ret =3D -EINVAL; continue; } =20 parent_cpu_data =3D get_parent_cpu_data(p_data, policy); - if (!parent_cpu_data) { - cpufreq_cpu_put(policy); + if (!parent_cpu_data) continue; - } =20 /* Get target freq via required opps */ cpu_cur =3D parent_cpu_data->cur_freq * HZ_PER_KHZ; @@ -106,7 +105,6 @@ static int get_target_freq_with_cpufreq(struct devfreq = *devfreq, devfreq->opp_table, &cpu_cur); if (freq) { *target_freq =3D max(freq, *target_freq); - cpufreq_cpu_put(policy); continue; } =20 @@ -121,7 +119,6 @@ static int get_target_freq_with_cpufreq(struct devfreq = *devfreq, freq =3D dev_min + mult_frac(dev_max - dev_min, cpu_percent, 100); =20 *target_freq =3D max(freq, *target_freq); - cpufreq_cpu_put(policy); } =20 return ret; @@ -256,7 +253,6 @@ static int cpufreq_passive_register_notifier(struct dev= freq *devfreq) struct device *dev =3D devfreq->dev.parent; struct opp_table *opp_table =3D NULL; struct devfreq_cpu_data *parent_cpu_data; - struct cpufreq_policy *policy; struct device *cpu_dev; unsigned int cpu; int ret; @@ -273,23 +269,23 @@ static int cpufreq_passive_register_notifier(struct d= evfreq *devfreq) } =20 for_each_possible_cpu(cpu) { - policy =3D cpufreq_cpu_get(cpu); + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D + cpufreq_cpu_get(cpu); + if (!policy) { ret =3D -EPROBE_DEFER; goto err; } =20 parent_cpu_data =3D get_parent_cpu_data(p_data, policy); - if (parent_cpu_data) { - cpufreq_cpu_put(policy); + if (parent_cpu_data) continue; - } =20 parent_cpu_data =3D kzalloc(sizeof(*parent_cpu_data), GFP_KERNEL); if (!parent_cpu_data) { ret =3D -ENOMEM; - goto err_put_policy; + goto err; } =20 cpu_dev =3D get_cpu_device(cpu); @@ -314,7 +310,6 @@ static int cpufreq_passive_register_notifier(struct dev= freq *devfreq) parent_cpu_data->max_freq =3D policy->cpuinfo.max_freq; =20 list_add_tail(&parent_cpu_data->node, &p_data->cpu_data_list); - cpufreq_cpu_put(policy); } =20 mutex_lock(&devfreq->lock); @@ -327,8 +322,6 @@ static int cpufreq_passive_register_notifier(struct dev= freq *devfreq) =20 err_free_cpu_data: kfree(parent_cpu_data); -err_put_policy: - cpufreq_cpu_put(policy); err: =20 return ret; --=20 2.25.1 From nobody Fri Oct 3 07:43:39 2025 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 5466F302759; Wed, 3 Sep 2025 13:18:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905505; cv=none; b=NFBxxklfGdwo5m9hrqXfdWdC0ndx/ZRPOE9EPIg8LMi78UMPeEsjCPBGUZ7pTWU3ybBcBF3gYc8LBkCv+pUnIAtujecQ08HlG7vNbWLokJEBfisEjACLvXFQjpbxqHvWkRKTdRLfc057NIGFqeoRldxGP9uYatHE7qsT/eqF67A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905505; c=relaxed/simple; bh=nL9uXlexQDC6CbrMTnH0B+Ysx+pDvLQ1rB8sOE0bEcY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=f5pcrIlG/qrY02AjaLk8SzlP/SsiFwM++gmHc0MsBC/FzjepYbDnnm2Q/scy4tvJx3jPvqtGzthL6TE47UfF9NB1UxeStiFubMATDeWTr4tvvaGiMsJnLkfbcq3k2pt3LtyaNhtXX/UIm8072XGgz6IFdEcphEJg0+KsRpZYVFI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 749e0a6888c811f0b29709d653e92f7d-20250903 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:592335fb-43af-471c-81cf-7d21aa6b3165,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:6493067,CLOUDID:4fe2850b774750f8430f4353e4afc535,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|850,TC:nil,Content:0|50,EDM:-3 ,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV :0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 749e0a6888c811f0b29709d653e92f7d-20250903 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 1123542880; Wed, 03 Sep 2025 21:18:17 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 990A1E008FA2; Wed, 3 Sep 2025 21:18:17 +0800 (CST) X-ns-mid: postfix-68B84019-866748 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id 854FDE008FA3; Wed, 3 Sep 2025 21:18:13 +0800 (CST) From: Zihuan Zhang To: "Rafael J . wysocki" , Viresh Kumar , Catalin Marinas , Will Deacon , Borislav Petkov , Dave Hansen , Srinivas Pandruvada , Michael Ellerman , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Jani Nikula , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Daniel Lezcano , Sascha Hauer , Shawn Guo , Eduardo Valentin , Keerthy Cc: Ben Horgan , zhenglifeng , Zhang Rui , Len Brown , Lukasz Luba , Pengutronix Kernel Team , Beata Michalska , Fabio Estevam , Pavel Machek , Sumit Gupta , Prasanna Kumar T S M , Sudeep Holla , Yicong Yang , linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, imx@lists.linux.dev, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Zihuan Zhang Subject: [PATCH v4 06/10] drm/i915: Use scope-based cleanup helper Date: Wed, 3 Sep 2025 21:17:29 +0800 Message-Id: <20250903131733.57637-7-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250903131733.57637-1-zhangzihuan@kylinos.cn> References: <20250903131733.57637-1-zhangzihuan@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace the manual cpufreq_cpu_put() with __free(put_cpufreq_policy) annotation for policy references. This reduces the risk of reference counting mistakes and aligns the code with the latest kernel style. No functional change intended. Signed-off-by: Zihuan Zhang Reviewed-by: Jonathan Cameron --- drivers/gpu/drm/i915/gt/intel_llc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/intel_llc.c b/drivers/gpu/drm/i915/gt/= intel_llc.c index 1d19c073ba2e..f15e4c0fa54b 100644 --- a/drivers/gpu/drm/i915/gt/intel_llc.c +++ b/drivers/gpu/drm/i915/gt/intel_llc.c @@ -29,13 +29,11 @@ static struct intel_gt *llc_to_gt(struct intel_llc *llc) =20 static unsigned int cpu_max_MHz(void) { - struct cpufreq_policy *policy; + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D cpufreq_cpu_= get(0); unsigned int max_khz; =20 - policy =3D cpufreq_cpu_get(0); if (policy) { max_khz =3D policy->cpuinfo.max_freq; - cpufreq_cpu_put(policy); } else { /* * Default to measured freq if none found, PCU will ensure we --=20 2.25.1 From nobody Fri Oct 3 07:43:39 2025 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 7D2112FF67E; Wed, 3 Sep 2025 13:18:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905515; cv=none; b=Yc5GBtGy8WWOAYZsMUzAJ+65yamZybMHI/7k8KfvZiC3f6xGXECPdvT1qyZJnDnxIKzNgTvXfdo7DExXRqfAgMuQG9qD4I0dsKWjhpbQBVptH6W8fJt+G8EG7qx1pIxEWnzA5MGFG4y7LBA0+p0MFGXrr7JhxBFroGHswcqHP50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905515; c=relaxed/simple; bh=lBV/LXcmoSKW35TD8fJIFkXy7y0QDiiHa2xN0x50KdQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fXzlZORYH3q9fPDtHClMR3AfSLzmCjhWLdj1fbQXyAcrK0g5f7LRupJVf95UYVf2Kh36NYXvi9tCrmMZUy9FH13sCmcG57BlL1Cwqtw68WLs+zBQIFxj2aT8xTS7yjNrwyBlSMk0H/efd095pycmJV0iZQMOyMDDmRRpXB+wVwA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 770bae1888c811f0b29709d653e92f7d-20250903 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:0168c3e0-98fe-406d-85b1-48da848a7ccc,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:6493067,CLOUDID:2c9e1e9e5c5ada8eb7e570a730afb71d,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|850,TC:nil,Content:0|50,EDM:-3 ,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV :0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 770bae1888c811f0b29709d653e92f7d-20250903 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 1452110782; Wed, 03 Sep 2025 21:18:22 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 65C56E008FA2; Wed, 3 Sep 2025 21:18:21 +0800 (CST) X-ns-mid: postfix-68B8401D-2351769 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id A519FE008FA4; Wed, 3 Sep 2025 21:18:17 +0800 (CST) From: Zihuan Zhang To: "Rafael J . wysocki" , Viresh Kumar , Catalin Marinas , Will Deacon , Borislav Petkov , Dave Hansen , Srinivas Pandruvada , Michael Ellerman , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Jani Nikula , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Daniel Lezcano , Sascha Hauer , Shawn Guo , Eduardo Valentin , Keerthy Cc: Ben Horgan , zhenglifeng , Zhang Rui , Len Brown , Lukasz Luba , Pengutronix Kernel Team , Beata Michalska , Fabio Estevam , Pavel Machek , Sumit Gupta , Prasanna Kumar T S M , Sudeep Holla , Yicong Yang , linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, imx@lists.linux.dev, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Zihuan Zhang Subject: [PATCH v4 07/10] powercap: dtpm_cpu: Use scope-based cleanup helper Date: Wed, 3 Sep 2025 21:17:30 +0800 Message-Id: <20250903131733.57637-8-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250903131733.57637-1-zhangzihuan@kylinos.cn> References: <20250903131733.57637-1-zhangzihuan@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace the manual cpufreq_cpu_put() with __free(put_cpufreq_policy) annotation for policy references. This reduces the risk of reference counting mistakes and aligns the code with the latest kernel style. No functional change intended. Signed-off-by: Zihuan Zhang --- drivers/powercap/dtpm_cpu.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/drivers/powercap/dtpm_cpu.c b/drivers/powercap/dtpm_cpu.c index 99390ec1481f..f76594185fa2 100644 --- a/drivers/powercap/dtpm_cpu.c +++ b/drivers/powercap/dtpm_cpu.c @@ -144,19 +144,17 @@ static int update_pd_power_uw(struct dtpm *dtpm) static void pd_release(struct dtpm *dtpm) { struct dtpm_cpu *dtpm_cpu =3D to_dtpm_cpu(dtpm); - struct cpufreq_policy *policy; =20 if (freq_qos_request_active(&dtpm_cpu->qos_req)) freq_qos_remove_request(&dtpm_cpu->qos_req); =20 - policy =3D cpufreq_cpu_get(dtpm_cpu->cpu); - if (policy) { + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D + cpufreq_cpu_get(dtpm_cpu->cpu); + + if (policy) for_each_cpu(dtpm_cpu->cpu, policy->related_cpus) per_cpu(dtpm_per_cpu, dtpm_cpu->cpu) =3D NULL; =20 - cpufreq_cpu_put(policy); - } - kfree(dtpm_cpu); } =20 @@ -192,7 +190,6 @@ static int cpuhp_dtpm_cpu_online(unsigned int cpu) static int __dtpm_cpu_setup(int cpu, struct dtpm *parent) { struct dtpm_cpu *dtpm_cpu; - struct cpufreq_policy *policy; struct em_perf_state *table; struct em_perf_domain *pd; char name[CPUFREQ_NAME_LEN]; @@ -202,21 +199,19 @@ static int __dtpm_cpu_setup(int cpu, struct dtpm *par= ent) if (dtpm_cpu) return 0; =20 - policy =3D cpufreq_cpu_get(cpu); + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D + cpufreq_cpu_get(cpu); + if (!policy) return 0; =20 pd =3D em_cpu_get(cpu); - if (!pd || em_is_artificial(pd)) { - ret =3D -EINVAL; - goto release_policy; - } + if (!pd || em_is_artificial(pd)) + return -EINVAL; =20 dtpm_cpu =3D kzalloc(sizeof(*dtpm_cpu), GFP_KERNEL); - if (!dtpm_cpu) { - ret =3D -ENOMEM; - goto release_policy; - } + if (!dtpm_cpu) + return -ENOMEM; =20 dtpm_init(&dtpm_cpu->dtpm, &dtpm_ops); dtpm_cpu->cpu =3D cpu; @@ -239,7 +234,6 @@ static int __dtpm_cpu_setup(int cpu, struct dtpm *paren= t) if (ret < 0) goto out_dtpm_unregister; =20 - cpufreq_cpu_put(policy); return 0; =20 out_dtpm_unregister: @@ -251,8 +245,6 @@ static int __dtpm_cpu_setup(int cpu, struct dtpm *paren= t) per_cpu(dtpm_per_cpu, cpu) =3D NULL; kfree(dtpm_cpu); =20 -release_policy: - cpufreq_cpu_put(policy); return ret; } =20 --=20 2.25.1 From nobody Fri Oct 3 07:43:39 2025 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 717A12FF64B; Wed, 3 Sep 2025 13:18:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905514; cv=none; b=dDE4RGYZH3R288ktMIIKE2NicLHgJBnkWzsbeHh+ipMiY2QrfYuZjV7ixq6kAarF1PCwZmL5nFuhhX6DHuyOZ744moCoQFC8G/eft6g4oCibpTWnwdCs9ftYdLXMfx/23TlsV6jTI/Yns/UAKwtjj2II8E8cY6ZVztKAQtWnukU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905514; c=relaxed/simple; bh=SOEaaZpmJn7sGF2g0MQZ6wZ+Z37bA8pyb8CmHglSgm0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=obpB/GlqlsksIDJ+YvmXKk/jPYi/GydZrmKW8OJ2MS82UcMrKX+P5vx+BPuwgljzaCRRHQ2MkaNGoGmKKt0msLSkfg68dSfX9lN2I/sF0tYTBte8lKDiPZWnP/dTkrzpgXMGodAQKct7MGYhKctdO2XNLJ8ls86Q6dmcf8QFtJc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 7923175488c811f0b29709d653e92f7d-20250903 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:404860c2-a1e1-4a57-af4d-479ddd31998b,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:6493067,CLOUDID:8ae0b0763886d87a9cf94141ec49b745,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|850,TC:nil,Content:0|50,EDM:-3 ,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV :0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 7923175488c811f0b29709d653e92f7d-20250903 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 1572167497; Wed, 03 Sep 2025 21:18:25 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 328D9E008FA2; Wed, 3 Sep 2025 21:18:25 +0800 (CST) X-ns-mid: postfix-68B84021-1150110 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id 717CBE008FA3; Wed, 3 Sep 2025 21:18:21 +0800 (CST) From: Zihuan Zhang To: "Rafael J . wysocki" , Viresh Kumar , Catalin Marinas , Will Deacon , Borislav Petkov , Dave Hansen , Srinivas Pandruvada , Michael Ellerman , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Jani Nikula , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Daniel Lezcano , Sascha Hauer , Shawn Guo , Eduardo Valentin , Keerthy Cc: Ben Horgan , zhenglifeng , Zhang Rui , Len Brown , Lukasz Luba , Pengutronix Kernel Team , Beata Michalska , Fabio Estevam , Pavel Machek , Sumit Gupta , Prasanna Kumar T S M , Sudeep Holla , Yicong Yang , linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, imx@lists.linux.dev, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Zihuan Zhang Subject: [PATCH v4 08/10] thermal: imx: Use scope-based cleanup helper Date: Wed, 3 Sep 2025 21:17:31 +0800 Message-Id: <20250903131733.57637-9-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250903131733.57637-1-zhangzihuan@kylinos.cn> References: <20250903131733.57637-1-zhangzihuan@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace the manual cpufreq_cpu_put() with __free(put_cpufreq_policy) annotation for policy references. This reduces the risk of reference counting mistakes and aligns the code with the latest kernel style. No functional change intended. Signed-off-by: Zihuan Zhang --- drivers/thermal/imx_thermal.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 38c993d1bcb3..cd1d9d419275 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -201,7 +201,6 @@ static struct thermal_soc_data thermal_imx7d_data =3D { =20 struct imx_thermal_data { struct device *dev; - struct cpufreq_policy *policy; struct thermal_zone_device *tz; struct thermal_cooling_device *cdev; struct regmap *tempmon; @@ -541,22 +540,20 @@ MODULE_DEVICE_TABLE(of, of_imx_thermal_match); static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *da= ta) { struct device_node *np; + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D cpufreq_cpu_= get(0); int ret =3D 0; =20 - data->policy =3D cpufreq_cpu_get(0); - if (!data->policy) { + if (!policy) { pr_debug("%s: CPUFreq policy not found\n", __func__); return -EPROBE_DEFER; } =20 - np =3D of_get_cpu_node(data->policy->cpu, NULL); + np =3D of_get_cpu_node(policy->cpu, NULL); =20 if (!np || !of_property_present(np, "#cooling-cells")) { - data->cdev =3D cpufreq_cooling_register(data->policy); - if (IS_ERR(data->cdev)) { + data->cdev =3D cpufreq_cooling_register(policy); + if (IS_ERR(data->cdev)) ret =3D PTR_ERR(data->cdev); - cpufreq_cpu_put(data->policy); - } } =20 of_node_put(np); @@ -567,7 +564,6 @@ static int imx_thermal_register_legacy_cooling(struct i= mx_thermal_data *data) static void imx_thermal_unregister_legacy_cooling(struct imx_thermal_data = *data) { cpufreq_cooling_unregister(data->cdev); - cpufreq_cpu_put(data->policy); } =20 #else --=20 2.25.1 From nobody Fri Oct 3 07:43:39 2025 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 B7223307481; Wed, 3 Sep 2025 13:18:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905518; cv=none; b=ZH6cV8trFxtqhCuNR8RDFTgzLCgD9qzgOKgFenuzELsh5x2LhFs0dVXxeumELLt/d4yoB2MgouFyt8Fdr4c9UN+FR3lDyqOnn9pX6yqTVLXnfPXoZvia6xWue89bwWOQhcA3g50+t3597Q0T+2WgopASlMbnsu1Pox/7hmcWTN8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905518; c=relaxed/simple; bh=mMkykB+5FeWYu30WtxVsDKEqZr9ON+7axCeJ12PaHQg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BFlSpYLZaIHHynMZgIg1eMmA+cmACZM1gQX5rl4WUqLfXsS42KqoXcW6cyK443ISguB19q3WB4gLw/4uy2CBU9R2CtR+8k1F0wsToqOobp5xQkTpk2YCYnIeFFgn6whs7/UrOt+QyqqjJGjc4413JFr9FVcOh7ako6j3isFbMN8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 7bf29db088c811f0b29709d653e92f7d-20250903 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:47b9b184-7915-4981-84d2-da5939ebd09f,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:6493067,CLOUDID:4de4532331db31d4079350c98637262e,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|850,TC:nil,Content:0|50,EDM:-3 ,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV :0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 7bf29db088c811f0b29709d653e92f7d-20250903 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 251707506; Wed, 03 Sep 2025 21:18:30 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 09D93E008FA2; Wed, 3 Sep 2025 21:18:29 +0800 (CST) X-ns-mid: postfix-68B84024-80687311 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id 3F46FE008FA3; Wed, 3 Sep 2025 21:18:25 +0800 (CST) From: Zihuan Zhang To: "Rafael J . wysocki" , Viresh Kumar , Catalin Marinas , Will Deacon , Borislav Petkov , Dave Hansen , Srinivas Pandruvada , Michael Ellerman , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Jani Nikula , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Daniel Lezcano , Sascha Hauer , Shawn Guo , Eduardo Valentin , Keerthy Cc: Ben Horgan , zhenglifeng , Zhang Rui , Len Brown , Lukasz Luba , Pengutronix Kernel Team , Beata Michalska , Fabio Estevam , Pavel Machek , Sumit Gupta , Prasanna Kumar T S M , Sudeep Holla , Yicong Yang , linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, imx@lists.linux.dev, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Zihuan Zhang Subject: [PATCH v4 09/10] thermal/drivers/ti-soc-thermal: Use scope-based cleanup helper Date: Wed, 3 Sep 2025 21:17:32 +0800 Message-Id: <20250903131733.57637-10-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250903131733.57637-1-zhangzihuan@kylinos.cn> References: <20250903131733.57637-1-zhangzihuan@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace the manual cpufreq_cpu_put() with __free(put_cpufreq_policy) annotation for policy references. This reduces the risk of reference counting mistakes and aligns the code with the latest kernel style. No functional change intended. Signed-off-by: Zihuan Zhang --- drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/t= hermal/ti-soc-thermal/ti-thermal-common.c index 0cf0826b805a..37d06468913a 100644 --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c @@ -27,7 +27,6 @@ =20 /* common data structures */ struct ti_thermal_data { - struct cpufreq_policy *policy; struct thermal_zone_device *ti_thermal; struct thermal_zone_device *pcb_tz; struct thermal_cooling_device *cool_dev; @@ -218,6 +217,7 @@ int ti_thermal_register_cpu_cooling(struct ti_bandgap *= bgp, int id) { struct ti_thermal_data *data; struct device_node *np =3D bgp->dev->of_node; + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D cpufreq_cpu_= get(0); =20 /* * We are assuming here that if one deploys the zone @@ -234,19 +234,17 @@ int ti_thermal_register_cpu_cooling(struct ti_bandgap= *bgp, int id) if (!data) return -EINVAL; =20 - data->policy =3D cpufreq_cpu_get(0); - if (!data->policy) { + if (!policy) { pr_debug("%s: CPUFreq policy not found\n", __func__); return -EPROBE_DEFER; } =20 /* Register cooling device */ - data->cool_dev =3D cpufreq_cooling_register(data->policy); + data->cool_dev =3D cpufreq_cooling_register(policy); if (IS_ERR(data->cool_dev)) { int ret =3D PTR_ERR(data->cool_dev); dev_err(bgp->dev, "Failed to register cpu cooling device %d\n", ret); - cpufreq_cpu_put(data->policy); =20 return ret; } @@ -261,11 +259,8 @@ int ti_thermal_unregister_cpu_cooling(struct ti_bandga= p *bgp, int id) =20 data =3D ti_bandgap_get_sensor_data(bgp, id); =20 - if (!IS_ERR_OR_NULL(data)) { + if (!IS_ERR_OR_NULL(data)) cpufreq_cooling_unregister(data->cool_dev); - if (data->policy) - cpufreq_cpu_put(data->policy); - } =20 return 0; } --=20 2.25.1 From nobody Fri Oct 3 07:43:39 2025 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 98FB1307AE4; Wed, 3 Sep 2025 13:18:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905521; cv=none; b=mbBXtNNgUYZUdTsKMOrEDtNt5NveBHAaEO/mQ3bRWsCqPCIzKyj4pWYt8cGdsfQ/IUy2+vwMmhZh0yLEIJHACVxxIl6JBS0/aS8Wiiq840mu6/DsJ73h3uX8AAS9Mh0D9BGRiBGgLG5PelEIrhw84G8fUiPJxJF7CWEjUF6OEdQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756905521; c=relaxed/simple; bh=fBao4LDrH9xBp2D7IbGTgxizvkgLdt++Jefm+pPe6/g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DTcOygEZAqOw5/sv+S8n6qmxMltpqEjh+OLXCx29DQiTulLf7I1DMTpM9kV0nG23mxjr21rtwUrbG2wnDy8sAI52JMatFZpRSy+6fMcZ4nSYmpxmtwPE4hwj2qVKNe17OGlyzYmcd/YwAklEw2G0boHl4zO5lGsBDrmtGcKyi4c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 7da87c9c88c811f0b29709d653e92f7d-20250903 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:2ff8d2a4-2ba3-43cb-a1ff-0465a59439e3,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:6493067,CLOUDID:ee6b8f0128955488e4eb76d27f0f3de0,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|850,TC:nil,Content:0|50,EDM:-3 ,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV :0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 7da87c9c88c811f0b29709d653e92f7d-20250903 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 363581621; Wed, 03 Sep 2025 21:18:33 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id C4D2EE008FA2; Wed, 3 Sep 2025 21:18:32 +0800 (CST) X-ns-mid: postfix-68B84028-62733312 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id 164D5E008FA4; Wed, 3 Sep 2025 21:18:29 +0800 (CST) From: Zihuan Zhang To: "Rafael J . wysocki" , Viresh Kumar , Catalin Marinas , Will Deacon , Borislav Petkov , Dave Hansen , Srinivas Pandruvada , Michael Ellerman , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Jani Nikula , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Daniel Lezcano , Sascha Hauer , Shawn Guo , Eduardo Valentin , Keerthy Cc: Ben Horgan , zhenglifeng , Zhang Rui , Len Brown , Lukasz Luba , Pengutronix Kernel Team , Beata Michalska , Fabio Estevam , Pavel Machek , Sumit Gupta , Prasanna Kumar T S M , Sudeep Holla , Yicong Yang , linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, imx@lists.linux.dev, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Zihuan Zhang Subject: [PATCH v4 10/10] PM: EM: Use scope-based cleanup helper Date: Wed, 3 Sep 2025 21:17:33 +0800 Message-Id: <20250903131733.57637-11-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250903131733.57637-1-zhangzihuan@kylinos.cn> References: <20250903131733.57637-1-zhangzihuan@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace the manual cpufreq_cpu_put() with __free(put_cpufreq_policy) annotation for policy references. This reduces the risk of reference counting mistakes and aligns the code with the latest kernel style. No functional change intended. Signed-off-by: Zihuan Zhang --- kernel/power/energy_model.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c index ea7995a25780..99401678e809 100644 --- a/kernel/power/energy_model.c +++ b/kernel/power/energy_model.c @@ -451,7 +451,7 @@ static void em_cpufreq_update_efficiencies(struct device *dev, struct em_perf_state *t= able) { struct em_perf_domain *pd =3D dev->em_pd; - struct cpufreq_policy *policy; + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D NULL; int found =3D 0; int i, cpu; =20 @@ -479,8 +479,6 @@ em_cpufreq_update_efficiencies(struct device *dev, stru= ct em_perf_state *table) found++; } =20 - cpufreq_cpu_put(policy); - if (!found) return; =20 @@ -787,7 +785,7 @@ static void em_check_capacity_update(void) =20 /* Check if CPUs capacity has changed than update EM */ for_each_possible_cpu(cpu) { - struct cpufreq_policy *policy; + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D NULL; struct em_perf_domain *pd; struct device *dev; =20 @@ -801,7 +799,6 @@ static void em_check_capacity_update(void) msecs_to_jiffies(1000)); break; } - cpufreq_cpu_put(policy); =20 dev =3D get_cpu_device(cpu); pd =3D em_pd_get(dev); --=20 2.25.1