diff mbox series

ARM: topology: Allow missing CPU clock-frequency device-tree property

Message ID 20240929181936.644910-1-paulk@sys-base.io (mailing list archive)
State New, archived
Headers show
Series ARM: topology: Allow missing CPU clock-frequency device-tree property | expand

Commit Message

Paul Kocialkowski Sept. 29, 2024, 6:19 p.m. UTC
From: Paul Kocialkowski <contact@paulk.fr>

When no capacity-dmips-mhz property is provided, the ARM topology code
implements a fallback mechanism that uses the clock-frequency
device-tree property as an indication of the maximum frequency
achievable by the CPU.

When the property is missing, the fallback mechanism gives up and
prints out a nasty error message that has been haunting generations
of ARMv7 Linux users. This is uncalled for since the property is
optional (and now deprecated too).

Allow the fallback mechanism to continue by assuming the same nominal
frequency for all CPU cores, while still benefiting from the static
coefficient provided by the compatible-driven table entries.
This is similar to what is done in the common arch topology code when
it fails to find a clock to get the frequency from.

The ranging mechanism (using the middle capacity) is unaffected by
the use of a unit frequency and still returns values in the requested
range.

Also add a comment to clarify what is going on.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
---
 arch/arm/kernel/topology.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

Comments

Paul Kocialkowski Nov. 1, 2024, 11:07 a.m. UTC | #1
Hi!

Le Sun 29 Sep 24, 20:19, Paul Kocialkowski a écrit :
> Allow the fallback mechanism to continue by assuming the same nominal
> frequency for all CPU cores, while still benefiting from the static
> coefficient provided by the compatible-driven table entries.
> This is similar to what is done in the common arch topology code when
> it fails to find a clock to get the frequency from.

Any thoughts about this patch?

Thanks!

Paul

> The ranging mechanism (using the middle capacity) is unaffected by
> the use of a unit frequency and still returns values in the requested
> range.
> 
> Also add a comment to clarify what is going on.
> 
> Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
> ---
>  arch/arm/kernel/topology.c | 22 ++++++++++++++++------
>  1 file changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
> index 2336ee2aa44a..0eb743c65166 100644
> --- a/arch/arm/kernel/topology.c
> +++ b/arch/arm/kernel/topology.c
> @@ -119,13 +119,23 @@ static void __init parse_dt_topology(void)
>  		if (cpu_eff->compatible == NULL)
>  			continue;
>  
> +		/*
> +		 * Use the legacy clock-frequency property (representing the
> +		 * maximum achievable clock frequency) as an efficiency
> +		 * coefficient (divided by 2^20, roughly 1 MHz) to the table
> +		 * value. If no such property is available, use the table value
> +		 * directly and assume all CPUs are running at the same
> +		 * nominal frequency.
> +		 *
> +		 * It is assumed that clock-frequency is either provided for all
> +		 * CPUs or for none of them.
> +		 */
>  		rate = of_get_property(cn, "clock-frequency", &len);
> -		if (!rate || len != 4) {
> -			pr_err("%pOF missing clock-frequency property\n", cn);
> -			continue;
> -		}
> -
> -		capacity = ((be32_to_cpup(rate)) >> 20) * cpu_eff->efficiency;
> +		if (rate && len == 4)
> +			capacity = ((be32_to_cpup(rate)) >> 20) *
> +				   cpu_eff->efficiency;
> +		else
> +			capacity = cpu_eff->efficiency;
>  
>  		/* Save min capacity of the system */
>  		if (capacity < min_capacity)
> -- 
> 2.46.2
> 
>
diff mbox series

Patch

diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
index 2336ee2aa44a..0eb743c65166 100644
--- a/arch/arm/kernel/topology.c
+++ b/arch/arm/kernel/topology.c
@@ -119,13 +119,23 @@  static void __init parse_dt_topology(void)
 		if (cpu_eff->compatible == NULL)
 			continue;
 
+		/*
+		 * Use the legacy clock-frequency property (representing the
+		 * maximum achievable clock frequency) as an efficiency
+		 * coefficient (divided by 2^20, roughly 1 MHz) to the table
+		 * value. If no such property is available, use the table value
+		 * directly and assume all CPUs are running at the same
+		 * nominal frequency.
+		 *
+		 * It is assumed that clock-frequency is either provided for all
+		 * CPUs or for none of them.
+		 */
 		rate = of_get_property(cn, "clock-frequency", &len);
-		if (!rate || len != 4) {
-			pr_err("%pOF missing clock-frequency property\n", cn);
-			continue;
-		}
-
-		capacity = ((be32_to_cpup(rate)) >> 20) * cpu_eff->efficiency;
+		if (rate && len == 4)
+			capacity = ((be32_to_cpup(rate)) >> 20) *
+				   cpu_eff->efficiency;
+		else
+			capacity = cpu_eff->efficiency;
 
 		/* Save min capacity of the system */
 		if (capacity < min_capacity)