Re: [RFC][PATCH 1/2] cpufreq: intel_pstate: Expose global sysfs attributes upfront

From: Srinivas Pandruvada
Date: Tue Jan 10 2017 - 15:49:04 EST


On Thu, 2017-01-05 at 02:51 +0100, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
>
> Expose the intel_pstate's global sysfs attributes before registering
> the driver to prepare for the addition of an attribute that also will
> have to work if the driver is not registered.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
> ---
>

[...]

> Â#ifdef CONFIG_ACPI
> @@ -1055,12 +1058,22 @@ static ssize_t show_turbo_pct(struct kob
> Â int total, no_turbo, turbo_pct;
> Â uint32_t turbo_fp;
> Â
> + mutex_lock(&intel_pstate_driver_lock);
> +
> + if (!driver_registered) {
> + mutex_unlock(&intel_pstate_limits_lock);
It should be
        mutex_unlock(&intel_pstate_driver_lock);

> + return -EAGAIN;
> + }
> +
> Â cpu = all_cpu_data[0];
> Â
>
[...]

> @@ -1070,8 +1083,18 @@ static ssize_t show_num_pstates(struct k
> Â struct cpudata *cpu;
> Â int total;
> Â
> + mutex_lock(&intel_pstate_driver_lock);
> +
> + if (!driver_registered) {
> + mutex_unlock(&intel_pstate_limits_lock);
Change to
        mutex_unlock(&intel_pstate_driver_lock);

> + return -EAGAIN;
> + }
> +
> Â cpu = all_cpu_data[0];
> Â total = cpu->pstate.turbo_pstate - cpu->pstate.min_pstate +
> 1;
> +
> + mutex_unlock(&intel_pstate_driver_lock);
> +
> Â return sprintf(buf, "%u\n", total);
> Â}
> Â
> @@ -1080,12 +1103,21 @@ static ssize_t show_no_turbo(struct kobj
> Â{
> Â ssize_t ret;
> Â
> + mutex_lock(&intel_pstate_driver_lock);
> +
> + if (!driver_registered) {
> + mutex_unlock(&intel_pstate_limits_lock);
Same here
        mutex_unlock(&intel_pstate_driver_lock);

> + return -EAGAIN;
> + }
> +
> Â update_turbo_state();
> Â if (limits->turbo_disabled)
> Â ret = sprintf(buf, "%u\n", limits->turbo_disabled);
> Â else
> Â ret = sprintf(buf, "%u\n", limits->no_turbo);
> Â
> + mutex_unlock(&intel_pstate_driver_lock);
> +
> Â return ret;
> Â}
> Â
> @@ -1099,6 +1131,13 @@ static ssize_t store_no_turbo(struct kob
> Â if (ret != 1)
> Â return -EINVAL;
> Â
> + mutex_lock(&intel_pstate_driver_lock);
> +
> + if (!driver_registered) {
> + mutex_unlock(&intel_pstate_driver_lock);
> + return -EAGAIN;
> + }
> +
> Â mutex_lock(&intel_pstate_limits_lock);ÂÂÂÂÂÂÂif (limits-
> >turbo_disabled) {
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂpr_warn("Turbo disabled by BIOS or unavailable on
> processor\n");
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂmutex_unlock(&intel_pstate_limits_lock);
Also
mutex_unlock(&intel_pstate_driver_lock);>Â

> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂreturn -EPERM;
> ÂÂÂÂÂÂÂÂ}
> Â
> Â update_turbo_state();
> @@ -1114,6 +1153,8 @@ static ssize_t store_no_turbo(struct kob
> Â
> Â intel_pstate_update_policies();
> Â
> + mutex_unlock(&intel_pstate_driver_lock);
> +
> Â return count;
> Â}
>

Thanks,
Srinivas