linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpufreq: dt-platdev: Fix creating device on OPPv1 platforms
@ 2025-12-10  5:17 Krzysztof Kozlowski
  2025-12-10  6:30 ` Viresh Kumar
  2025-12-10  9:03 ` Pavel Pisa
  0 siblings, 2 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2025-12-10  5:17 UTC (permalink / raw)
  To: Rafael J. Wysocki, Viresh Kumar, Krzysztof Kozlowski,
	Rob Herring (Arm), AngeloGioacchino Del Regno, linux-pm,
	linux-kernel
  Cc: Krzysztof Kozlowski, Geert Uytterhoeven, Pavel Pisa

Commit 6ea891a6dd37 ("cpufreq: dt-platdev: Simplify with
of_machine_get_match_data()") broke several platforms which did not have
OPPv2 proprety, because it incorrectly checked for device match data
after first matching from "allowlist".  Almost all of "allowlist" match
entries do not have match data and it is expected to create platform
device for them with empty data.

Fix this by first checking if platform is on the allowlist with
of_machine_device_match() and only then taking the match data.  This
duplicates the number of checks (we match against the allowlist twice),
but makes the code here much smaller.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Closes: https://lore.kernel.org/all/CAMuHMdVJD4+J9QpUUs-sX0feKfuPD72CO0dcqN7shvF_UYpZ3Q@mail.gmail.com/
Reported-by: Pavel Pisa <pisa@fel.cvut.cz>
Closes: https://lore.kernel.org/all/6hnk7llbwdezh74h74fhvofbx4t4jihel5kvr6qwx2xuxxbjys@rmwbd7lkhrdz/
Fixes: 6ea891a6dd37 ("cpufreq: dt-platdev: Simplify with of_machine_get_match_data()")
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
 drivers/cpufreq/cpufreq-dt-platdev.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c
index a1d11ecd1ac8..b06a43143d23 100644
--- a/drivers/cpufreq/cpufreq-dt-platdev.c
+++ b/drivers/cpufreq/cpufreq-dt-platdev.c
@@ -219,11 +219,12 @@ static bool __init cpu0_node_has_opp_v2_prop(void)
 
 static int __init cpufreq_dt_platdev_init(void)
 {
-	const void *data;
+	const void *data = NULL;
 
-	data = of_machine_get_match_data(allowlist);
-	if (data)
+	if (of_machine_device_match(allowlist)) {
+		data = of_machine_get_match_data(allowlist);
 		goto create_pdev;
+	}
 
 	if (cpu0_node_has_opp_v2_prop() && !of_machine_device_match(blocklist))
 		goto create_pdev;
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] cpufreq: dt-platdev: Fix creating device on OPPv1 platforms
  2025-12-10  5:17 [PATCH] cpufreq: dt-platdev: Fix creating device on OPPv1 platforms Krzysztof Kozlowski
@ 2025-12-10  6:30 ` Viresh Kumar
  2025-12-11  3:23   ` Rob Herring
  2025-12-10  9:03 ` Pavel Pisa
  1 sibling, 1 reply; 4+ messages in thread
From: Viresh Kumar @ 2025-12-10  6:30 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Pavel Pisa
  Cc: Rafael J. Wysocki, Krzysztof Kozlowski, Rob Herring (Arm),
	AngeloGioacchino Del Regno, linux-pm, linux-kernel,
	Geert Uytterhoeven

On 10-12-25, 06:17, Krzysztof Kozlowski wrote:
> Commit 6ea891a6dd37 ("cpufreq: dt-platdev: Simplify with
> of_machine_get_match_data()") broke several platforms which did not have
> OPPv2 proprety, because it incorrectly checked for device match data
> after first matching from "allowlist".  Almost all of "allowlist" match
> entries do not have match data and it is expected to create platform
> device for them with empty data.
> 
> Fix this by first checking if platform is on the allowlist with
> of_machine_device_match() and only then taking the match data.  This
> duplicates the number of checks (we match against the allowlist twice),
> but makes the code here much smaller.
> 
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Closes: https://lore.kernel.org/all/CAMuHMdVJD4+J9QpUUs-sX0feKfuPD72CO0dcqN7shvF_UYpZ3Q@mail.gmail.com/
> Reported-by: Pavel Pisa <pisa@fel.cvut.cz>
> Closes: https://lore.kernel.org/all/6hnk7llbwdezh74h74fhvofbx4t4jihel5kvr6qwx2xuxxbjys@rmwbd7lkhrdz/
> Fixes: 6ea891a6dd37 ("cpufreq: dt-platdev: Simplify with of_machine_get_match_data()")
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
> ---
>  drivers/cpufreq/cpufreq-dt-platdev.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c
> index a1d11ecd1ac8..b06a43143d23 100644
> --- a/drivers/cpufreq/cpufreq-dt-platdev.c
> +++ b/drivers/cpufreq/cpufreq-dt-platdev.c
> @@ -219,11 +219,12 @@ static bool __init cpu0_node_has_opp_v2_prop(void)
>  
>  static int __init cpufreq_dt_platdev_init(void)
>  {
> -	const void *data;
> +	const void *data = NULL;
>  
> -	data = of_machine_get_match_data(allowlist);
> -	if (data)
> +	if (of_machine_device_match(allowlist)) {
> +		data = of_machine_get_match_data(allowlist);
>  		goto create_pdev;
> +	}
>  
>  	if (cpu0_node_has_opp_v2_prop() && !of_machine_device_match(blocklist))
>  		goto create_pdev;

Pavel, please give this a try as well.

Since the original patch went via your tree, take this one too please:

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cpufreq: dt-platdev: Fix creating device on OPPv1 platforms
  2025-12-10  5:17 [PATCH] cpufreq: dt-platdev: Fix creating device on OPPv1 platforms Krzysztof Kozlowski
  2025-12-10  6:30 ` Viresh Kumar
@ 2025-12-10  9:03 ` Pavel Pisa
  1 sibling, 0 replies; 4+ messages in thread
From: Pavel Pisa @ 2025-12-10  9:03 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Viresh Kumar
  Cc: Rafael J. Wysocki, Krzysztof Kozlowski, Rob Herring (Arm),
	AngeloGioacchino Del Regno, linux-pm, linux-kernel,
	Geert Uytterhoeven

Thanks much for the fast response and fix. I have run checks
successfully without revert 6ea891a6dd37 and this patch applied.

On Wednesday 10 of December 2025 06:17:19 Krzysztof Kozlowski wrote:
> Commit 6ea891a6dd37 ("cpufreq: dt-platdev: Simplify with
> of_machine_get_match_data()") broke several platforms which did not have
> OPPv2 proprety, because it incorrectly checked for device match data
> after first matching from "allowlist".  Almost all of "allowlist" match
> entries do not have match data and it is expected to create platform
> device for them with empty data.
>
> Fix this by first checking if platform is on the allowlist with
> of_machine_device_match() and only then taking the match data.  This
> duplicates the number of checks (we match against the allowlist twice),
> but makes the code here much smaller.
>
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Closes:
> https://lore.kernel.org/all/CAMuHMdVJD4+J9QpUUs-sX0feKfuPD72CO0dcqN7shvF_UY
>pZ3Q@mail.gmail.com/ Reported-by: Pavel Pisa <pisa@fel.cvut.cz>
> Closes:
> https://lore.kernel.org/all/6hnk7llbwdezh74h74fhvofbx4t4jihel5kvr6qwx2xuxxb
>jys@rmwbd7lkhrdz/ Fixes: 6ea891a6dd37 ("cpufreq: dt-platdev: Simplify with
> of_machine_get_match_data()") Signed-off-by: Krzysztof Kozlowski
> <krzysztof.kozlowski@oss.qualcomm.com> ---
>  drivers/cpufreq/cpufreq-dt-platdev.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

Tested-by: Pavel Pisa <pisa@fel.cvut.cz>
on AMD Xilinx Zynq MicroZed xlnx,zynq-7000 platform.

As for the initial report, I have located addresses for CPUfreq
maintainers from the mainline MAINTAINERS file - Rafael J. Wysocki
and Viresh Kumar and PM list, I have added Michal Simek as AMD Xilinx
platform maintainer. I have done quick glimpse into history and have
seen some recent patches but have not time to do bisect so 
I decided start with some maintainers the first to not spam too much
people. Then repeated to the already extended addresses list.

Best wishes,

                Pavel

                Pavel Pisa
    phone:      +420 603531357
    e-mail:     pisa@cmp.felk.cvut.cz
    Department of Control Engineering FEE CVUT
    Karlovo namesti 13, 121 35, Prague 2
    university: http://control.fel.cvut.cz/
    personal:   http://cmp.felk.cvut.cz/~pisa
    social:     https://social.kernel.org/ppisa
    projects:   https://www.openhub.net/accounts/ppisa
    CAN related:http://canbus.pages.fel.cvut.cz/
    RISC-V education: https://comparch.edu.cvut.cz/
    Open Technologies Research Education and Exchange Services
    https://gitlab.fel.cvut.cz/otrees/org/-/wikis/home

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cpufreq: dt-platdev: Fix creating device on OPPv1 platforms
  2025-12-10  6:30 ` Viresh Kumar
@ 2025-12-11  3:23   ` Rob Herring
  0 siblings, 0 replies; 4+ messages in thread
From: Rob Herring @ 2025-12-11  3:23 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Krzysztof Kozlowski, Pavel Pisa, Rafael J. Wysocki,
	Krzysztof Kozlowski, AngeloGioacchino Del Regno, linux-pm,
	linux-kernel, Geert Uytterhoeven

On Wed, Dec 10, 2025 at 12:00:22PM +0530, Viresh Kumar wrote:
> On 10-12-25, 06:17, Krzysztof Kozlowski wrote:
> > Commit 6ea891a6dd37 ("cpufreq: dt-platdev: Simplify with
> > of_machine_get_match_data()") broke several platforms which did not have
> > OPPv2 proprety, because it incorrectly checked for device match data
> > after first matching from "allowlist".  Almost all of "allowlist" match
> > entries do not have match data and it is expected to create platform
> > device for them with empty data.
> > 
> > Fix this by first checking if platform is on the allowlist with
> > of_machine_device_match() and only then taking the match data.  This
> > duplicates the number of checks (we match against the allowlist twice),
> > but makes the code here much smaller.
> > 
> > Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > Closes: https://lore.kernel.org/all/CAMuHMdVJD4+J9QpUUs-sX0feKfuPD72CO0dcqN7shvF_UYpZ3Q@mail.gmail.com/
> > Reported-by: Pavel Pisa <pisa@fel.cvut.cz>
> > Closes: https://lore.kernel.org/all/6hnk7llbwdezh74h74fhvofbx4t4jihel5kvr6qwx2xuxxbjys@rmwbd7lkhrdz/
> > Fixes: 6ea891a6dd37 ("cpufreq: dt-platdev: Simplify with of_machine_get_match_data()")
> > Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
> > ---
> >  drivers/cpufreq/cpufreq-dt-platdev.c | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c
> > index a1d11ecd1ac8..b06a43143d23 100644
> > --- a/drivers/cpufreq/cpufreq-dt-platdev.c
> > +++ b/drivers/cpufreq/cpufreq-dt-platdev.c
> > @@ -219,11 +219,12 @@ static bool __init cpu0_node_has_opp_v2_prop(void)
> >  
> >  static int __init cpufreq_dt_platdev_init(void)
> >  {
> > -	const void *data;
> > +	const void *data = NULL;
> >  
> > -	data = of_machine_get_match_data(allowlist);
> > -	if (data)
> > +	if (of_machine_device_match(allowlist)) {
> > +		data = of_machine_get_match_data(allowlist);
> >  		goto create_pdev;
> > +	}
> >  
> >  	if (cpu0_node_has_opp_v2_prop() && !of_machine_device_match(blocklist))
> >  		goto create_pdev;
> 
> Pavel, please give this a try as well.
> 
> Since the original patch went via your tree, take this one too please:

Applied.

Rob

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-12-11  3:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-10  5:17 [PATCH] cpufreq: dt-platdev: Fix creating device on OPPv1 platforms Krzysztof Kozlowski
2025-12-10  6:30 ` Viresh Kumar
2025-12-11  3:23   ` Rob Herring
2025-12-10  9:03 ` Pavel Pisa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).