Commit 5d4c779c authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Rafael J. Wysocki

powercap: intel_rapl: Replace deprecated CPU-hotplug functions

The functions get_online_cpus() and put_online_cpus() have been
deprecated during the CPU hotplug rework. They map directly to
cpus_read_lock() and cpus_read_unlock().

Replace deprecated CPU-hotplug functions with the official version.
The behavior remains unchanged.
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent c500bee1
...@@ -158,16 +158,16 @@ static int get_energy_counter(struct powercap_zone *power_zone, ...@@ -158,16 +158,16 @@ static int get_energy_counter(struct powercap_zone *power_zone,
/* prevent CPU hotplug, make sure the RAPL domain does not go /* prevent CPU hotplug, make sure the RAPL domain does not go
* away while reading the counter. * away while reading the counter.
*/ */
get_online_cpus(); cpus_read_lock();
rd = power_zone_to_rapl_domain(power_zone); rd = power_zone_to_rapl_domain(power_zone);
if (!rapl_read_data_raw(rd, ENERGY_COUNTER, true, &energy_now)) { if (!rapl_read_data_raw(rd, ENERGY_COUNTER, true, &energy_now)) {
*energy_raw = energy_now; *energy_raw = energy_now;
put_online_cpus(); cpus_read_unlock();
return 0; return 0;
} }
put_online_cpus(); cpus_read_unlock();
return -EIO; return -EIO;
} }
...@@ -216,11 +216,11 @@ static int set_domain_enable(struct powercap_zone *power_zone, bool mode) ...@@ -216,11 +216,11 @@ static int set_domain_enable(struct powercap_zone *power_zone, bool mode)
if (rd->state & DOMAIN_STATE_BIOS_LOCKED) if (rd->state & DOMAIN_STATE_BIOS_LOCKED)
return -EACCES; return -EACCES;
get_online_cpus(); cpus_read_lock();
rapl_write_data_raw(rd, PL1_ENABLE, mode); rapl_write_data_raw(rd, PL1_ENABLE, mode);
if (rapl_defaults->set_floor_freq) if (rapl_defaults->set_floor_freq)
rapl_defaults->set_floor_freq(rd, mode); rapl_defaults->set_floor_freq(rd, mode);
put_online_cpus(); cpus_read_unlock();
return 0; return 0;
} }
...@@ -234,13 +234,13 @@ static int get_domain_enable(struct powercap_zone *power_zone, bool *mode) ...@@ -234,13 +234,13 @@ static int get_domain_enable(struct powercap_zone *power_zone, bool *mode)
*mode = false; *mode = false;
return 0; return 0;
} }
get_online_cpus(); cpus_read_lock();
if (rapl_read_data_raw(rd, PL1_ENABLE, true, &val)) { if (rapl_read_data_raw(rd, PL1_ENABLE, true, &val)) {
put_online_cpus(); cpus_read_unlock();
return -EIO; return -EIO;
} }
*mode = val; *mode = val;
put_online_cpus(); cpus_read_unlock();
return 0; return 0;
} }
...@@ -317,7 +317,7 @@ static int set_power_limit(struct powercap_zone *power_zone, int cid, ...@@ -317,7 +317,7 @@ static int set_power_limit(struct powercap_zone *power_zone, int cid,
int ret = 0; int ret = 0;
int id; int id;
get_online_cpus(); cpus_read_lock();
rd = power_zone_to_rapl_domain(power_zone); rd = power_zone_to_rapl_domain(power_zone);
id = contraint_to_pl(rd, cid); id = contraint_to_pl(rd, cid);
if (id < 0) { if (id < 0) {
...@@ -350,7 +350,7 @@ static int set_power_limit(struct powercap_zone *power_zone, int cid, ...@@ -350,7 +350,7 @@ static int set_power_limit(struct powercap_zone *power_zone, int cid,
if (!ret) if (!ret)
package_power_limit_irq_save(rp); package_power_limit_irq_save(rp);
set_exit: set_exit:
put_online_cpus(); cpus_read_unlock();
return ret; return ret;
} }
...@@ -363,7 +363,7 @@ static int get_current_power_limit(struct powercap_zone *power_zone, int cid, ...@@ -363,7 +363,7 @@ static int get_current_power_limit(struct powercap_zone *power_zone, int cid,
int ret = 0; int ret = 0;
int id; int id;
get_online_cpus(); cpus_read_lock();
rd = power_zone_to_rapl_domain(power_zone); rd = power_zone_to_rapl_domain(power_zone);
id = contraint_to_pl(rd, cid); id = contraint_to_pl(rd, cid);
if (id < 0) { if (id < 0) {
...@@ -382,7 +382,7 @@ static int get_current_power_limit(struct powercap_zone *power_zone, int cid, ...@@ -382,7 +382,7 @@ static int get_current_power_limit(struct powercap_zone *power_zone, int cid,
prim = POWER_LIMIT4; prim = POWER_LIMIT4;
break; break;
default: default:
put_online_cpus(); cpus_read_unlock();
return -EINVAL; return -EINVAL;
} }
if (rapl_read_data_raw(rd, prim, true, &val)) if (rapl_read_data_raw(rd, prim, true, &val))
...@@ -391,7 +391,7 @@ static int get_current_power_limit(struct powercap_zone *power_zone, int cid, ...@@ -391,7 +391,7 @@ static int get_current_power_limit(struct powercap_zone *power_zone, int cid,
*data = val; *data = val;
get_exit: get_exit:
put_online_cpus(); cpus_read_unlock();
return ret; return ret;
} }
...@@ -403,7 +403,7 @@ static int set_time_window(struct powercap_zone *power_zone, int cid, ...@@ -403,7 +403,7 @@ static int set_time_window(struct powercap_zone *power_zone, int cid,
int ret = 0; int ret = 0;
int id; int id;
get_online_cpus(); cpus_read_lock();
rd = power_zone_to_rapl_domain(power_zone); rd = power_zone_to_rapl_domain(power_zone);
id = contraint_to_pl(rd, cid); id = contraint_to_pl(rd, cid);
if (id < 0) { if (id < 0) {
...@@ -423,7 +423,7 @@ static int set_time_window(struct powercap_zone *power_zone, int cid, ...@@ -423,7 +423,7 @@ static int set_time_window(struct powercap_zone *power_zone, int cid,
} }
set_time_exit: set_time_exit:
put_online_cpus(); cpus_read_unlock();
return ret; return ret;
} }
...@@ -435,7 +435,7 @@ static int get_time_window(struct powercap_zone *power_zone, int cid, ...@@ -435,7 +435,7 @@ static int get_time_window(struct powercap_zone *power_zone, int cid,
int ret = 0; int ret = 0;
int id; int id;
get_online_cpus(); cpus_read_lock();
rd = power_zone_to_rapl_domain(power_zone); rd = power_zone_to_rapl_domain(power_zone);
id = contraint_to_pl(rd, cid); id = contraint_to_pl(rd, cid);
if (id < 0) { if (id < 0) {
...@@ -458,14 +458,14 @@ static int get_time_window(struct powercap_zone *power_zone, int cid, ...@@ -458,14 +458,14 @@ static int get_time_window(struct powercap_zone *power_zone, int cid,
val = 0; val = 0;
break; break;
default: default:
put_online_cpus(); cpus_read_unlock();
return -EINVAL; return -EINVAL;
} }
if (!ret) if (!ret)
*data = val; *data = val;
get_time_exit: get_time_exit:
put_online_cpus(); cpus_read_unlock();
return ret; return ret;
} }
...@@ -491,7 +491,7 @@ static int get_max_power(struct powercap_zone *power_zone, int id, u64 *data) ...@@ -491,7 +491,7 @@ static int get_max_power(struct powercap_zone *power_zone, int id, u64 *data)
int prim; int prim;
int ret = 0; int ret = 0;
get_online_cpus(); cpus_read_lock();
rd = power_zone_to_rapl_domain(power_zone); rd = power_zone_to_rapl_domain(power_zone);
switch (rd->rpl[id].prim_id) { switch (rd->rpl[id].prim_id) {
case PL1_ENABLE: case PL1_ENABLE:
...@@ -504,7 +504,7 @@ static int get_max_power(struct powercap_zone *power_zone, int id, u64 *data) ...@@ -504,7 +504,7 @@ static int get_max_power(struct powercap_zone *power_zone, int id, u64 *data)
prim = MAX_POWER; prim = MAX_POWER;
break; break;
default: default:
put_online_cpus(); cpus_read_unlock();
return -EINVAL; return -EINVAL;
} }
if (rapl_read_data_raw(rd, prim, true, &val)) if (rapl_read_data_raw(rd, prim, true, &val))
...@@ -516,7 +516,7 @@ static int get_max_power(struct powercap_zone *power_zone, int id, u64 *data) ...@@ -516,7 +516,7 @@ static int get_max_power(struct powercap_zone *power_zone, int id, u64 *data)
if (rd->rpl[id].prim_id == PL4_ENABLE) if (rd->rpl[id].prim_id == PL4_ENABLE)
*data = *data * 2; *data = *data * 2;
put_online_cpus(); cpus_read_unlock();
return ret; return ret;
} }
...@@ -1358,7 +1358,7 @@ static void power_limit_state_save(void) ...@@ -1358,7 +1358,7 @@ static void power_limit_state_save(void)
struct rapl_domain *rd; struct rapl_domain *rd;
int nr_pl, ret, i; int nr_pl, ret, i;
get_online_cpus(); cpus_read_lock();
list_for_each_entry(rp, &rapl_packages, plist) { list_for_each_entry(rp, &rapl_packages, plist) {
if (!rp->power_zone) if (!rp->power_zone)
continue; continue;
...@@ -1390,7 +1390,7 @@ static void power_limit_state_save(void) ...@@ -1390,7 +1390,7 @@ static void power_limit_state_save(void)
} }
} }
} }
put_online_cpus(); cpus_read_unlock();
} }
static void power_limit_state_restore(void) static void power_limit_state_restore(void)
...@@ -1399,7 +1399,7 @@ static void power_limit_state_restore(void) ...@@ -1399,7 +1399,7 @@ static void power_limit_state_restore(void)
struct rapl_domain *rd; struct rapl_domain *rd;
int nr_pl, i; int nr_pl, i;
get_online_cpus(); cpus_read_lock();
list_for_each_entry(rp, &rapl_packages, plist) { list_for_each_entry(rp, &rapl_packages, plist) {
if (!rp->power_zone) if (!rp->power_zone)
continue; continue;
...@@ -1425,7 +1425,7 @@ static void power_limit_state_restore(void) ...@@ -1425,7 +1425,7 @@ static void power_limit_state_restore(void)
} }
} }
} }
put_online_cpus(); cpus_read_unlock();
} }
static int rapl_pm_callback(struct notifier_block *nb, static int rapl_pm_callback(struct notifier_block *nb,
......
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