From nobody Wed Sep 10 05:43:46 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 9BA482EDD76; Fri, 5 Sep 2025 13:24:37 +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=1757078681; cv=none; b=lZKT0dVYPyDEucIaIc6pcM5uOUcRa1FvSDSDpswtbalH7JWX7oVT+xxTJY5O3BehZobpd+Ds/0pe/ubagjIbkwN0GWHTvuRkVx9a2O/0qeH7iXOR+I0XYcnRxalOkhgQvu2sJlLb15lYFTZE0AbXj89EhRT43EVrBR6wKdtl3Ys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757078681; c=relaxed/simple; bh=S4Ko70ZJJHD/wWUnApfc4oXk2ctDto//kNXhxHN/5HA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PzW+d1jtHp/hGMrO5AVytyPlqc79aruK7VOXBpXKMFSnJH3IEtxqDouo/srxUdc0fOdy09j1eXFlhbdi39fJAfdsJpHikv+6PgFNXQXb/vuJUz7146WYMNaqemM4fc1u0vRikE+lJDnl58o6+LaDZDCPDkRxNDnHFiaj7Ab84bY= 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: a92db2a88a5b11f0b29709d653e92f7d-20250905 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:db943cde-bbe0-429d-b0bf-a43728169e5f,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:daa3cd9fa204e6c6d28bd15663a324ed,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: a92db2a88a5b11f0b29709d653e92f7d-20250905 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 1872443980; Fri, 05 Sep 2025 21:24:33 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 0113AE008FA3; Fri, 5 Sep 2025 21:24:33 +0800 (CST) X-ns-mid: postfix-68BAE490-8197312 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id 1F7DBE008FA4; Fri, 5 Sep 2025 21:24:29 +0800 (CST) From: Zihuan Zhang To: "Rafael J . wysocki" , Viresh Kumar , Jonathan Cameron , 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 v5 1/6] arm64: topology: Use scope-based cleanup helper Date: Fri, 5 Sep 2025 21:24:08 +0800 Message-Id: <20250905132413.1376220-2-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250905132413.1376220-1-zhangzihuan@kylinos.cn> References: <20250905132413.1376220-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 | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index 5d07ee85bdae..07e2f5b5ade0 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -307,30 +307,27 @@ 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(info->opp_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) { /* Prevent verifying same CPU twice */ ref_cpu =3D nr_cpu_ids; - break; + return -EAGAIN; } if (!idle_cpu(ref_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 Wed Sep 10 05:43:46 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 4BC3911713; Fri, 5 Sep 2025 13:24:39 +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=1757078684; cv=none; b=FkutlmagxpW9d49SjUynB3j8zTurQea910Df6VTvgNs762/ijdBaKNf/mqv05mEc8DVjoynWtpy88QLM3HYeKj2QDCMoE03b85etjhf0LZ8YWaMU0a42vAQwpMm/RKWtywqn3pSH6DMLoC0dfuNiXTCwzVVvO4WK9pUyEAkERtA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757078684; c=relaxed/simple; bh=IsD8LXlpLSq+O9Fi54i0sMVBUxYprbw8gjn6uSjWZAY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tfSXHHSBsWuyeZDw2h5eyqTDPNBZTdZhv/J/T+zzR/o/avwj7HZe7YjekhjoUpFSxzwpApaA8uNhddoOcH8c4X14P4P7hXC/N5GbVSV+QkAc0Mp9ZZ3B16+hWHwc183juSx1WQZnpdPkggpS0fmdH7r8dnzNY/ywbVo7MYAhOOo= 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: ab7f0e948a5b11f0b29709d653e92f7d-20250905 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:4b2060ab-e5d6-4d05-9c5f-b1ce0c1d23cf,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:1052e2a43a89a6a3ff62207c016cfdeb,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: ab7f0e948a5b11f0b29709d653e92f7d-20250905 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 659114040; Fri, 05 Sep 2025 21:24:37 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id D9FE4E008FA3; Fri, 5 Sep 2025 21:24:36 +0800 (CST) X-ns-mid: postfix-68BAE494-7144943 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id 0A8E7E008FA7; Fri, 5 Sep 2025 21:24:32 +0800 (CST) From: Zihuan Zhang To: "Rafael J . wysocki" , Viresh Kumar , Jonathan Cameron , 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 v5 2/6] ACPI: processor: thermal: Use scope-based cleanup helper Date: Fri, 5 Sep 2025 21:24:09 +0800 Message-Id: <20250905132413.1376220-3-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250905132413.1376220-1-zhangzihuan@kylinos.cn> References: <20250905132413.1376220-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 | 52 +++++++++++++++++--------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_ther= mal.c index 1219adb11ab9..460713d1414a 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; - if (!acpi_processor_cpufreq_init) return 0; =20 - policy =3D cpufreq_cpu_get(cpu); - if (policy) { - cpufreq_cpu_put(policy); - return 1; - } - return 0; + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D cpufreq_cpu_= get(cpu); + + return policy !=3D NULL; } =20 static int cpufreq_get_max_state(unsigned int cpu) @@ -93,12 +88,31 @@ static int cpufreq_get_cur_state(unsigned int cpu) return reduction_step(cpu); } =20 +static bool cpufreq_update_thermal_limit(unsigned int cpu, struct acpi_pro= cessor *pr) +{ + unsigned long max_freq; + int ret; + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D cpufreq_cpu_= get(cpu); + + if (!policy) + return false; + + max_freq =3D (policy->cpuinfo.max_freq * + (100 - reduction_step(cpu) * cpufreq_thermal_reduction_pctg)) / 100; + + ret =3D freq_qos_update_request(&pr->thermal_req, max_freq); + if (ret < 0) { + pr_warn("Failed to update thermal freq constraint: CPU%d (%d)\n", + pr->id, ret); + } + + return true; +} + 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; + int i; =20 if (!cpu_has_cpufreq(cpu)) return 0; @@ -120,20 +134,8 @@ static int cpufreq_set_cur_state(unsigned int cpu, int= state) if (unlikely(!freq_qos_request_active(&pr->thermal_req))) continue; =20 - policy =3D cpufreq_cpu_get(i); - if (!policy) + if (!cpufreq_update_thermal_limit(i, pr)) return -EINVAL; - - max_freq =3D (policy->cpuinfo.max_freq * - (100 - reduction_step(i) * cpufreq_thermal_reduction_pctg)) / 100; - - cpufreq_cpu_put(policy); - - ret =3D freq_qos_update_request(&pr->thermal_req, max_freq); - if (ret < 0) { - pr_warn("Failed to update thermal freq constraint: CPU%d (%d)\n", - pr->id, ret); - } } return 0; } --=20 2.25.1 From nobody Wed Sep 10 05:43:46 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 A102E346A0D; Fri, 5 Sep 2025 13:24:44 +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=1757078687; cv=none; b=Gk/WvckHmhtbqQyGtiQ+mQUGEUG56DPLhexw7wBoqL0wY7PgRh7i7mMBCJn8Ix447jVebcy78vzTD8W8Fwr5MvvmdVYqpyrVxb3ltnZU2Wo4XxMS2uGay2hCfkGqaxay8z0P3KMyA78ncU29IbzIilGAua0Y0BgZND5P5fQKHUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757078687; c=relaxed/simple; bh=1BB+rsMu9WyJ0YV0eXRG8M3+zAR9J06CCeewMPU/1Eg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=U9jpQb6mj+jCXNmehkHKsBFuKgE1wwjIPAdd5qdc/0vNwReq2rPZy2BbQvb1961XKS3RJMe2HRrkEDzqc4B5dngG33IE8vGbP84HxDJwUnEFb4iwsDWRMFUK3biUsIguPhSL6bI9TcXBtLVNCspnuPfVGN7aPRhVBb1T+aYMezM= 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: ae0311428a5b11f0b29709d653e92f7d-20250905 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:8aa5386c-c9f5-4430-8500-bcee34bb0354,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:b78993f22d836f36a02cb4d46fb2af39,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: ae0311428a5b11f0b29709d653e92f7d-20250905 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 604134888; Fri, 05 Sep 2025 21:24:41 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 14B58E008FA3; Fri, 5 Sep 2025 21:24:41 +0800 (CST) X-ns-mid: postfix-68BAE498-6193824 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id E5F06E008FA4; Fri, 5 Sep 2025 21:24:36 +0800 (CST) From: Zihuan Zhang To: "Rafael J . wysocki" , Viresh Kumar , Jonathan Cameron , 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 v5 3/6] cpufreq: intel_pstate: Use scope-based cleanup helper Date: Fri, 5 Sep 2025 21:24:10 +0800 Message-Id: <20250905132413.1376220-4-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250905132413.1376220-1-zhangzihuan@kylinos.cn> References: <20250905132413.1376220-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 | 59 +++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index f366d35c5840..0b54e08f9447 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -1502,9 +1502,8 @@ static void __intel_pstate_update_max_freq(struct cpu= freq_policy *policy, =20 static bool intel_pstate_update_max_freq(struct cpudata *cpudata) { - struct cpufreq_policy *policy __free(put_cpufreq_policy); + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D cpufreq_cpu_= get(cpudata->cpu); =20 - policy =3D cpufreq_cpu_get(cpudata->cpu); if (!policy) return false; =20 @@ -1695,41 +1694,49 @@ static ssize_t store_no_turbo(struct kobject *a, st= ruct kobj_attribute *b, return count; } =20 -static void update_qos_request(enum freq_qos_req_type type) +static bool intel_pstate_cpufreq_update_limits(int cpu, enum freq_qos_req_= type type) { struct freq_qos_request *req; - struct cpufreq_policy *policy; - int i; + unsigned int freq, perf_pct; + struct cpudata *data =3D all_cpu_data[cpu]; + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D cpufreq_cpu_= get(cpu); =20 - for_each_possible_cpu(i) { - struct cpudata *cpu =3D all_cpu_data[i]; - unsigned int freq, perf_pct; + if (!policy) + return false; =20 - policy =3D cpufreq_cpu_get(i); - if (!policy) - continue; + req =3D policy->driver_data; =20 - req =3D policy->driver_data; - cpufreq_cpu_put(policy); + if (!req) + return false; =20 - if (!req) - continue; + if (hwp_active) + intel_pstate_get_hwp_cap(data); =20 - if (hwp_active) - intel_pstate_get_hwp_cap(cpu); + if (type =3D=3D FREQ_QOS_MIN) { + perf_pct =3D global.min_perf_pct; + } else { + req++; + perf_pct =3D global.max_perf_pct; + } =20 - if (type =3D=3D FREQ_QOS_MIN) { - perf_pct =3D global.min_perf_pct; - } else { - req++; - perf_pct =3D global.max_perf_pct; - } + freq =3D DIV_ROUND_UP(data->pstate.turbo_freq * perf_pct, 100); =20 - freq =3D DIV_ROUND_UP(cpu->pstate.turbo_freq * perf_pct, 100); + if (freq_qos_update_request(req, freq) < 0) + pr_warn("Failed to update freq constraint: CPU%d\n", cpu); =20 - if (freq_qos_update_request(req, freq) < 0) - pr_warn("Failed to update freq constraint: CPU%d\n", i); + return true; +} + + +static void update_qos_request(enum freq_qos_req_type type) +{ + int i; + + for_each_possible_cpu(i) { + if (!intel_pstate_cpufreq_update_limits(i, type)) + continue; } + } =20 static ssize_t store_max_perf_pct(struct kobject *a, struct kobj_attribute= *b, --=20 2.25.1 From nobody Wed Sep 10 05:43:46 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 AB2EB1D7995; Fri, 5 Sep 2025 13:24:57 +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=1757078700; cv=none; b=uKsfY6wSQjYa07WpmgeXEvaXuKthXsoGFkyGV5U0P2FcFy9PnIOGC5EU0Riz149HrpIkLDugCyLzRnxeG2VO9k0EZZ8t2Be7d6xQKwo/5iZ4UJ4lSMZvwiqHBgtbE/l3s9TNhhav3U7O7jdc2lUP2MJmttDvvawzCAhpdeF3G8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757078700; c=relaxed/simple; bh=zI8LSVUIEAXBAXevXKLvocIGcksp4e+H6QqZHmOJ4mw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=epmJ+TMSvftpH0q8MsmB8TzvHvWoaSuvoN7wtTdW+DoGs4x4KSAF2pVCpHSETh7VpFghcWh8pMOKUsY95EMyWe6Y+xvhNhAHSPwFCY7kJ/OaeaqPY5dsupyVgM/eS52nQpLGZcycon0y0M6SxYT9hbfFWxLZrl7u2KzjB5+cNHQ= 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: b44a3dfa8a5b11f0b29709d653e92f7d-20250905 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:b8a8a8e9-2660-4e89-a43a-f9d5a297e17a,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:d547413c6b29f7a2761f5c65158ef560,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: b44a3dfa8a5b11f0b29709d653e92f7d-20250905 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 342664798; Fri, 05 Sep 2025 21:24:51 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 716AAE008FA3; Fri, 5 Sep 2025 21:24:51 +0800 (CST) X-ns-mid: postfix-68BAE4A1-8445755 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id 1F509E008FA4; Fri, 5 Sep 2025 21:24:41 +0800 (CST) From: Zihuan Zhang To: "Rafael J . wysocki" , Viresh Kumar , Jonathan Cameron , 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 v5 4/6] PM / devfreq: Use scope-based cleanup helper Date: Fri, 5 Sep 2025 21:24:11 +0800 Message-Id: <20250905132413.1376220-5-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250905132413.1376220-1-zhangzihuan@kylinos.cn> References: <20250905132413.1376220-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 | 60 +++++++++++------------------- 1 file changed, 22 insertions(+), 38 deletions(-) diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_= passive.c index 953cf9a1e9f7..5afaea39377e 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; @@ -255,8 +252,6 @@ static int cpufreq_passive_register_notifier(struct dev= freq *devfreq) =3D (struct devfreq_passive_data *)devfreq->data; 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,37 +268,34 @@ static int cpufreq_passive_register_notifier(struct d= evfreq *devfreq) } =20 for_each_possible_cpu(cpu) { - policy =3D cpufreq_cpu_get(cpu); - if (!policy) { - ret =3D -EPROBE_DEFER; - goto err; - } + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D + cpufreq_cpu_get(cpu); =20 - parent_cpu_data =3D get_parent_cpu_data(p_data, policy); - if (parent_cpu_data) { - cpufreq_cpu_put(policy); + if (!policy) + return -EPROBE_DEFER; + + struct devfreq_cpu_data *initial_parent_cpu_data =3D + get_parent_cpu_data(p_data, policy); + + if (initial_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; - } + struct devfreq_cpu_data *parent_cpu_data __free(kfree) =3D + kzalloc(sizeof(*parent_cpu_data), GFP_KERNEL); + + if (!parent_cpu_data) + return -ENOMEM; =20 cpu_dev =3D get_cpu_device(cpu); if (!cpu_dev) { dev_err(dev, "failed to get cpu device\n"); - ret =3D -ENODEV; - goto err_free_cpu_data; + return -ENODEV; } =20 opp_table =3D dev_pm_opp_get_opp_table(cpu_dev); if (IS_ERR(opp_table)) { dev_err(dev, "failed to get opp_table of cpu%d\n", cpu); - ret =3D PTR_ERR(opp_table); - goto err_free_cpu_data; + return PTR_ERR(opp_table); } =20 parent_cpu_data->dev =3D cpu_dev; @@ -313,8 +305,8 @@ static int cpufreq_passive_register_notifier(struct dev= freq *devfreq) parent_cpu_data->min_freq =3D policy->cpuinfo.min_freq; 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); + list_add_tail(&(no_free_ptr(parent_cpu_data)->node, + &p_data->cpu_data_list); } =20 mutex_lock(&devfreq->lock); @@ -324,14 +316,6 @@ static int cpufreq_passive_register_notifier(struct de= vfreq *devfreq) dev_err(dev, "failed to update the frequency\n"); =20 return ret; - -err_free_cpu_data: - kfree(parent_cpu_data); -err_put_policy: - cpufreq_cpu_put(policy); -err: - - return ret; } =20 static int devfreq_passive_notifier_call(struct notifier_block *nb, --=20 2.25.1 From nobody Wed Sep 10 05:43:46 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 3C820353344; Fri, 5 Sep 2025 13:25:02 +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=1757078705; cv=none; b=kt+k/yJqU2YXzYMDGeJSh/esKBBaVku79fHZcbyFtg/vbCXucbFexCXrgj/xeBhB6InRO1vUBxsE/81LCEtnV31Y7rMmz0LO+HbAKrnpCYk9H1BYEtF4lzy0V8bEuIUPYz28GPdPxORR6O3kK4EG+CKADsxaNkYmktL0MmxSf6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757078705; c=relaxed/simple; bh=6gVVnC1YkH8ZoWy5/0k7WKJEKCXa4X/6uXXQ9d6a62Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jhnoMOt6UMduNKXC/OZQpFVn8yDmPkW10sEucQQ2E2qHw0jkoS411eI7YHMtuJt5JaX/UDKKniM3po12IoK5EjkEWPn/Zooz4bGAMm1ILVp2W2dJ3lBDL7uK5ymV3akbi7E2EWcxXmeJVhrH1CmnKWnyzoesBgtmMZGQX/O3GTs= 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: b687c5d88a5b11f0b29709d653e92f7d-20250905 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:2f63b8d2-1ead-4757-b66c-86b8c1049e1d,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:3fcc3bb2746cc7389702de1a6e732580,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: b687c5d88a5b11f0b29709d653e92f7d-20250905 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 2010186639; Fri, 05 Sep 2025 21:24:55 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 6372FE008FA3; Fri, 5 Sep 2025 21:24:55 +0800 (CST) X-ns-mid: postfix-68BAE4A7-2095376 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id 7B73DE008FA4; Fri, 5 Sep 2025 21:24:51 +0800 (CST) From: Zihuan Zhang To: "Rafael J . wysocki" , Viresh Kumar , Jonathan Cameron , 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 v5 5/6] drm/i915: Use scope-based cleanup helper Date: Fri, 5 Sep 2025 21:24:12 +0800 Message-Id: <20250905132413.1376220-6-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250905132413.1376220-1-zhangzihuan@kylinos.cn> References: <20250905132413.1376220-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 Wed Sep 10 05:43:46 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 16F2D35337A; Fri, 5 Sep 2025 13:25:06 +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=1757078709; cv=none; b=EhWpgQXD4V1z+dtypBpchHSRWb3RM0xQzKQDnO6mtb/YYy2JE8wa9v/JzwbUiex1l2O0ixEAg3jq8dQ3wW0bnimCTYdG1MmB+aiQgOAGwTMkgy1PjUq8p5xbcrn+/Ah7ldEzG3+BZiNsgE/ZbqsPQ0+MXcbnfpNo8XOx77TI83o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757078709; c=relaxed/simple; bh=vpnK+wgxPDyyGBiNRyOVaIAlcPF3ONZ70dk/Vdt+kro=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rody1JRDeRk/msd/i2NYZIr/PMFj21jCY4VB4ZexsxDKt4SvtViJqNi5xDmflG6Qd5ZE1lnfIioA/XN1AWUXYQJwUBwO+rh79HB+yn4EwfF/o+b2Z4LceMVTaIcERqN7stvOw1SkWlAf6Ltbsi3ZW1nRDakq61IFL6Ve2iZkYQs= 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: b8db92f68a5b11f0b29709d653e92f7d-20250905 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:646670e5-e5c7-40b1-b28a-3ee5e8c5af3a,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:f6a8c23197cabdb3bff5558c69d77a16,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: b8db92f68a5b11f0b29709d653e92f7d-20250905 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 530252194; Fri, 05 Sep 2025 21:24:59 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 4D67FE008FA3; Fri, 5 Sep 2025 21:24:59 +0800 (CST) X-ns-mid: postfix-68BAE4AB-1181537 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id 70239E008FA7; Fri, 5 Sep 2025 21:24:55 +0800 (CST) From: Zihuan Zhang To: "Rafael J . wysocki" , Viresh Kumar , Jonathan Cameron , 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 v5 6/6] PM: EM: Use scope-based cleanup helper Date: Fri, 5 Sep 2025 21:24:13 +0800 Message-Id: <20250905132413.1376220-7-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250905132413.1376220-1-zhangzihuan@kylinos.cn> References: <20250905132413.1376220-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 | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c index ea7995a25780..5ec63b3e7d85 100644 --- a/kernel/power/energy_model.c +++ b/kernel/power/energy_model.c @@ -451,7 +451,6 @@ 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; int found =3D 0; int i, cpu; =20 @@ -465,7 +464,7 @@ em_cpufreq_update_efficiencies(struct device *dev, stru= ct em_perf_state *table) return; } =20 - policy =3D cpufreq_cpu_get(cpu); + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D cpufreq_cpu_= get(cpu); if (!policy) { dev_warn(dev, "EM: Access to CPUFreq policy failed\n"); return; @@ -479,8 +478,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,21 +784,19 @@ 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 em_perf_domain *pd; struct device *dev; =20 if (cpumask_test_cpu(cpu, cpu_done_mask)) continue; =20 - policy =3D cpufreq_cpu_get(cpu); + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D cpufreq_cpu= _get(cpu); if (!policy) { pr_debug("Accessing cpu%d policy failed\n", cpu); schedule_delayed_work(&em_update_work, 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