Skip to contentSkip to conversation

cpufreq: brcmstb-avs-cpufreq: Couple fixes

PATCH Applied Florian Fainelli 4 participants 7 messages May 22, 2019 – Jun 4, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover cpufreq: brcmstb-avs-cpufreq: Couple fixes

Hi Rafael, Viresh,

These patch series contains two minor fixes for the brcmstb-avs-cpufreq driver.

Florian Fainelli (2):
cpufreq: brcmstb-avs-cpufreq: Fix initial command check
cpufreq: brcmstb-avs-cpufreq: Fix types for voltage/frequency

 drivers/cpufreq/brcmstb-avs-cpufreq.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 cpufreq: brcmstb-avs-cpufreq: Fix initial command check

There is a logical error in brcm_avs_is_firmware_loaded() whereby if the firmware returns -EINVAL, we will be reporting this as an error. The comment is correct, the code was not.

Fixes de322e085995 ("cpufreq: brcmstb-avs-cpufreq: AVS CPUfreq driver for Broadcom STB SoCs")
---
 drivers/cpufreq/brcmstb-avs-cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/brcmstb-avs-cpufreq.c +2 -2
index e6f9cbe5835f..6ed53ca8aa98 100644
@@ -446,8 +446,8 @@ static bool brcm_avs_is_firmware_loaded(struct private_data *priv)
 	rc = brcm_avs_get_pmap(priv, NULL);
 	magic = readl(priv->base + AVS_MBOX_MAGIC);
 
-	return (magic == AVS_FIRMWARE_MAGIC) && (rc != -ENOTSUPP) &&
-		(rc != -EINVAL);
+	return (magic == AVS_FIRMWARE_MAGIC) && ((rc != -ENOTSUPP) ||
+		(rc != -EINVAL));
 }
 
 static unsigned int brcm_avs_cpufreq_get(unsigned int cpu)
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/2 cpufreq: brcmstb-avs-cpufreq: Fix types for voltage/frequency

In reply to Florian Fainelli

What we read back from the register is going to be capped at 32-bits, and cpufreq_freq_table.frequency is an unsigned int. Avoid any possible value truncation by using the appropriate return value.

Fixes de322e085995 ("cpufreq: brcmstb-avs-cpufreq: AVS CPUfreq driver for Broadcom STB SoCs")
---
 drivers/cpufreq/brcmstb-avs-cpufreq.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/cpufreq/brcmstb-avs-cpufreq.c +4 -4
index 6ed53ca8aa98..77b0e5d0fb13 100644
@@ -384,12 +384,12 @@ static int brcm_avs_set_pstate(struct private_data *priv, unsigned int pstate)
 	return __issue_avs_command(priv, AVS_CMD_SET_PSTATE, true, args);
 }
 
-static unsigned long brcm_avs_get_voltage(void __iomem *base)
+static u32 brcm_avs_get_voltage(void __iomem *base)
 {
 	return readl(base + AVS_MBOX_VOLTAGE1);
 }
 
-static unsigned long brcm_avs_get_frequency(void __iomem *base)
+static u32 brcm_avs_get_frequency(void __iomem *base)
 {
 	return readl(base + AVS_MBOX_FREQUENCY) * 1000;	/* in kHz */
 }
@@ -653,14 +653,14 @@ static ssize_t show_brcm_avs_voltage(struct cpufreq_policy *policy, char *buf)
 {
 	struct private_data *priv = policy->driver_data;
 
-	return sprintf(buf, "0x%08lx\n", brcm_avs_get_voltage(priv->base));
+	return sprintf(buf, "0x%08x\n", brcm_avs_get_voltage(priv->base));
 }
 
 static ssize_t show_brcm_avs_frequency(struct cpufreq_policy *policy, char *buf)
 {
 	struct private_data *priv = policy->driver_data;
 
-	return sprintf(buf, "0x%08lx\n", brcm_avs_get_frequency(priv->base));
+	return sprintf(buf, "0x%08x\n", brcm_avs_get_frequency(priv->base));
 }
 
 cpufreq_freq_attr_ro(brcm_avs_pstate);
Signature · 1 line
2.17.1
#3 lore raw
In reply to Florian Fainelli
Quoted 11 lines · CEST Florian Fainelli

Hi Rafael, Viresh,

These patch series contains two minor fixes for the brcmstb-avs-cpufreq driver.

Florian Fainelli (2):
cpufreq: brcmstb-avs-cpufreq: Fix initial command check
cpufreq: brcmstb-avs-cpufreq: Fix types for voltage/frequency

 drivers/cpufreq/brcmstb-avs-cpufreq.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

These look straightforward enough to me, but it would be good to get an ACK from the driver maintainer for them.

#4 lore raw
Quoted 10 lines · Rafael J. Wysocki
Quoted 9 lines · CEST Florian Fainelli

Hi Rafael, Viresh,

These patch series contains two minor fixes for the brcmstb-avs-cpufreq driver.

Florian Fainelli (2):
cpufreq: brcmstb-avs-cpufreq: Fix initial command check
cpufreq: brcmstb-avs-cpufreq: Fix types for voltage/frequency

Quoted 5 lines
Quoted 2 lines
 drivers/cpufreq/brcmstb-avs-cpufreq.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

These look straightforward enough to me, but it would be good to get an ACK from the driver maintainer for them.

Adding Markus' other email address.

Quoted 3 lines
Signature · 1 line
Florian
maintainer Acked-by
#5 lore raw
Quoted 11 lines · Florian Fainelli
Quoted 9 lines · Rafael J. Wysocki
Quoted 8 lines · CEST Florian Fainelli

Hi Rafael, Viresh,

These patch series contains two minor fixes for the brcmstb-avs-cpufreq driver.

Florian Fainelli (2):
cpufreq: brcmstb-avs-cpufreq: Fix initial command check
cpufreq: brcmstb-avs-cpufreq: Fix types for voltage/frequency

To both of these

My apologies for the delay.

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
 drivers/cpufreq/brcmstb-avs-cpufreq.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

These look straightforward enough to me, but it would be good to get an ACK from the driver maintainer for them.

Adding Markus' other email address.
--
Florian

maintainer Applied
#6 lore raw
Quoted 9 lines · Markus Mayer
Quoted 8 lines · Florian Fainelli
Quoted 6 lines · Rafael J. Wysocki
Quoted 5 lines · CEST Florian Fainelli

Hi Rafael, Viresh,

These patch series contains two minor fixes for the brcmstb-avs-cpufreq driver.

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Florian Fainelli (2):
cpufreq: brcmstb-avs-cpufreq: Fix initial command check
cpufreq: brcmstb-avs-cpufreq: Fix types for voltage/frequency

To both of these

Applied. Thanks.

Signature · 1 line
viresh