Commit 6174bac8 authored by Vaidyanathan Srinivasan's avatar Vaidyanathan Srinivasan Committed by Benjamin Herrenschmidt

powerpc/cpufreq: Add pr_warn() on OPAL firmware failures

Cpufreq depends on platform firmware to implement PStates.  In case of
platform firmware failure, cpufreq should not panic host kernel with
BUG_ON().  Less severe pr_warn() will suffice.

Add firmware_has_feature(FW_FEATURE_OPALv3) check to
skip probing for device-tree on non-powernv platforms.
Signed-off-by: default avatarVaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
Acked-by: default avatarGautham R. Shenoy <ego@linux.vnet.ibm.com>
CC: <stable@vger.kernel.org>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent b00fc6ec
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/of.h> #include <linux/of.h>
#include <asm/cputhreads.h> #include <asm/cputhreads.h>
#include <asm/firmware.h>
#include <asm/reg.h> #include <asm/reg.h>
#include <asm/smp.h> /* Required for cpu_sibling_mask() in UP configs */ #include <asm/smp.h> /* Required for cpu_sibling_mask() in UP configs */
...@@ -98,7 +99,11 @@ static int init_powernv_pstates(void) ...@@ -98,7 +99,11 @@ static int init_powernv_pstates(void)
return -ENODEV; return -ENODEV;
} }
WARN_ON(len_ids != len_freqs); if (len_ids != len_freqs) {
pr_warn("Entries in ibm,pstate-ids and "
"ibm,pstate-frequencies-mhz does not match\n");
}
nr_pstates = min(len_ids, len_freqs) / sizeof(u32); nr_pstates = min(len_ids, len_freqs) / sizeof(u32);
if (!nr_pstates) { if (!nr_pstates) {
pr_warn("No PStates found\n"); pr_warn("No PStates found\n");
...@@ -131,7 +136,12 @@ static unsigned int pstate_id_to_freq(int pstate_id) ...@@ -131,7 +136,12 @@ static unsigned int pstate_id_to_freq(int pstate_id)
int i; int i;
i = powernv_pstate_info.max - pstate_id; i = powernv_pstate_info.max - pstate_id;
BUG_ON(i >= powernv_pstate_info.nr_pstates || i < 0); if (i >= powernv_pstate_info.nr_pstates || i < 0) {
pr_warn("PState id %d outside of PState table, "
"reporting nominal id %d instead\n",
pstate_id, powernv_pstate_info.nominal);
i = powernv_pstate_info.max - powernv_pstate_info.nominal;
}
return powernv_freqs[i].frequency; return powernv_freqs[i].frequency;
} }
...@@ -321,6 +331,10 @@ static int __init powernv_cpufreq_init(void) ...@@ -321,6 +331,10 @@ static int __init powernv_cpufreq_init(void)
{ {
int rc = 0; int rc = 0;
/* Don't probe on pseries (guest) platforms */
if (!firmware_has_feature(FW_FEATURE_OPALv3))
return -ENODEV;
/* Discover pstates from device tree and init */ /* Discover pstates from device tree and init */
rc = init_powernv_pstates(); rc = init_powernv_pstates();
if (rc) { if (rc) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment