debuggers.hg

changeset 21060:efa827c5bf73

Add cpufreq sanity check

This fixes bug 1585 http://bugzilla.xensource.com/bugzilla/show_bug.cgi?id=3D1585

root cause: with incorrect BIOS info, cpufreq driver may not start. in
this case, if user use xenpm to manipulate cpufreq driver, NULL
pointer will cause xen panic. this patch add the sanity check and
warning info to fix this issue.

Signed-off-by: Yu Ke <ke.yu@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 09 09:59:59 2010 +0000 (2010-03-09)
parents 31ee49f2c4ea
children e6f751ed8e38
files xen/drivers/cpufreq/cpufreq.c xen/drivers/cpufreq/cpufreq_ondemand.c
line diff
     1.1 --- a/xen/drivers/cpufreq/cpufreq.c	Tue Mar 09 09:57:25 2010 +0000
     1.2 +++ b/xen/drivers/cpufreq/cpufreq.c	Tue Mar 09 09:59:59 2010 +0000
     1.3 @@ -177,6 +177,15 @@ int cpufreq_add_cpu(unsigned int cpu)
     1.4              processor_pminfo[firstcpu]->perf.domain_info.coord_type) ||
     1.5              (perf->domain_info.num_processors !=
     1.6              processor_pminfo[firstcpu]->perf.domain_info.num_processors)) {
     1.7 +
     1.8 +            printk(KERN_WARNING "cpufreq fail to add CPU%d:"
     1.9 +                   "incorrect _PSD(%"PRIu64":%"PRIu64"), "
    1.10 +                   "expect(%"PRIu64"/%"PRIu64")\n",
    1.11 +                   cpu, perf->domain_info.coord_type,
    1.12 +                   perf->domain_info.num_processors,
    1.13 +                   processor_pminfo[firstcpu]->perf.domain_info.coord_type,
    1.14 +                   processor_pminfo[firstcpu]->perf.domain_info.num_processors
    1.15 +                );
    1.16              return -EINVAL;
    1.17          }
    1.18      }
    1.19 @@ -193,6 +202,7 @@ int cpufreq_add_cpu(unsigned int cpu)
    1.20          ret = cpufreq_driver->init(policy);
    1.21          if (ret) {
    1.22              xfree(policy);
    1.23 +            cpufreq_cpu_policy[cpu] = NULL;
    1.24              return ret;
    1.25          }
    1.26          printk(KERN_EMERG"CPU %u initialization completed\n", cpu);
     2.1 --- a/xen/drivers/cpufreq/cpufreq_ondemand.c	Tue Mar 09 09:57:25 2010 +0000
     2.2 +++ b/xen/drivers/cpufreq/cpufreq_ondemand.c	Tue Mar 09 09:59:59 2010 +0000
     2.3 @@ -286,6 +286,12 @@ int cpufreq_governor_dbs(struct cpufreq_
     2.4          break;
     2.5  
     2.6      case CPUFREQ_GOV_LIMITS:
     2.7 +        if ( this_dbs_info->cur_policy == NULL )
     2.8 +        {
     2.9 +            printk(KERN_WARNING "CPU%d ondemand governor not started yet,"
    2.10 +                    "unable to GOV_LIMIT\n", cpu);
    2.11 +            return -EINVAL;
    2.12 +        }
    2.13          if (policy->max < this_dbs_info->cur_policy->cur)
    2.14              __cpufreq_driver_target(this_dbs_info->cur_policy,
    2.15                  policy->max, CPUFREQ_RELATION_H);