Skip to content

Commit 5d4c779

Browse files
Sebastian Andrzej Siewiorrafaeljw
Sebastian Andrzej Siewior
authored andcommitted
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: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent c500bee commit 5d4c779

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

drivers/powercap/intel_rapl_common.c

+25-25
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,16 @@ static int get_energy_counter(struct powercap_zone *power_zone,
158158
/* prevent CPU hotplug, make sure the RAPL domain does not go
159159
* away while reading the counter.
160160
*/
161-
get_online_cpus();
161+
cpus_read_lock();
162162
rd = power_zone_to_rapl_domain(power_zone);
163163

164164
if (!rapl_read_data_raw(rd, ENERGY_COUNTER, true, &energy_now)) {
165165
*energy_raw = energy_now;
166-
put_online_cpus();
166+
cpus_read_unlock();
167167

168168
return 0;
169169
}
170-
put_online_cpus();
170+
cpus_read_unlock();
171171

172172
return -EIO;
173173
}
@@ -216,11 +216,11 @@ static int set_domain_enable(struct powercap_zone *power_zone, bool mode)
216216
if (rd->state & DOMAIN_STATE_BIOS_LOCKED)
217217
return -EACCES;
218218

219-
get_online_cpus();
219+
cpus_read_lock();
220220
rapl_write_data_raw(rd, PL1_ENABLE, mode);
221221
if (rapl_defaults->set_floor_freq)
222222
rapl_defaults->set_floor_freq(rd, mode);
223-
put_online_cpus();
223+
cpus_read_unlock();
224224

225225
return 0;
226226
}
@@ -234,13 +234,13 @@ static int get_domain_enable(struct powercap_zone *power_zone, bool *mode)
234234
*mode = false;
235235
return 0;
236236
}
237-
get_online_cpus();
237+
cpus_read_lock();
238238
if (rapl_read_data_raw(rd, PL1_ENABLE, true, &val)) {
239-
put_online_cpus();
239+
cpus_read_unlock();
240240
return -EIO;
241241
}
242242
*mode = val;
243-
put_online_cpus();
243+
cpus_read_unlock();
244244

245245
return 0;
246246
}
@@ -317,7 +317,7 @@ static int set_power_limit(struct powercap_zone *power_zone, int cid,
317317
int ret = 0;
318318
int id;
319319

320-
get_online_cpus();
320+
cpus_read_lock();
321321
rd = power_zone_to_rapl_domain(power_zone);
322322
id = contraint_to_pl(rd, cid);
323323
if (id < 0) {
@@ -350,7 +350,7 @@ static int set_power_limit(struct powercap_zone *power_zone, int cid,
350350
if (!ret)
351351
package_power_limit_irq_save(rp);
352352
set_exit:
353-
put_online_cpus();
353+
cpus_read_unlock();
354354
return ret;
355355
}
356356

@@ -363,7 +363,7 @@ static int get_current_power_limit(struct powercap_zone *power_zone, int cid,
363363
int ret = 0;
364364
int id;
365365

366-
get_online_cpus();
366+
cpus_read_lock();
367367
rd = power_zone_to_rapl_domain(power_zone);
368368
id = contraint_to_pl(rd, cid);
369369
if (id < 0) {
@@ -382,7 +382,7 @@ static int get_current_power_limit(struct powercap_zone *power_zone, int cid,
382382
prim = POWER_LIMIT4;
383383
break;
384384
default:
385-
put_online_cpus();
385+
cpus_read_unlock();
386386
return -EINVAL;
387387
}
388388
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,
391391
*data = val;
392392

393393
get_exit:
394-
put_online_cpus();
394+
cpus_read_unlock();
395395

396396
return ret;
397397
}
@@ -403,7 +403,7 @@ static int set_time_window(struct powercap_zone *power_zone, int cid,
403403
int ret = 0;
404404
int id;
405405

406-
get_online_cpus();
406+
cpus_read_lock();
407407
rd = power_zone_to_rapl_domain(power_zone);
408408
id = contraint_to_pl(rd, cid);
409409
if (id < 0) {
@@ -423,7 +423,7 @@ static int set_time_window(struct powercap_zone *power_zone, int cid,
423423
}
424424

425425
set_time_exit:
426-
put_online_cpus();
426+
cpus_read_unlock();
427427
return ret;
428428
}
429429

@@ -435,7 +435,7 @@ static int get_time_window(struct powercap_zone *power_zone, int cid,
435435
int ret = 0;
436436
int id;
437437

438-
get_online_cpus();
438+
cpus_read_lock();
439439
rd = power_zone_to_rapl_domain(power_zone);
440440
id = contraint_to_pl(rd, cid);
441441
if (id < 0) {
@@ -458,14 +458,14 @@ static int get_time_window(struct powercap_zone *power_zone, int cid,
458458
val = 0;
459459
break;
460460
default:
461-
put_online_cpus();
461+
cpus_read_unlock();
462462
return -EINVAL;
463463
}
464464
if (!ret)
465465
*data = val;
466466

467467
get_time_exit:
468-
put_online_cpus();
468+
cpus_read_unlock();
469469

470470
return ret;
471471
}
@@ -491,7 +491,7 @@ static int get_max_power(struct powercap_zone *power_zone, int id, u64 *data)
491491
int prim;
492492
int ret = 0;
493493

494-
get_online_cpus();
494+
cpus_read_lock();
495495
rd = power_zone_to_rapl_domain(power_zone);
496496
switch (rd->rpl[id].prim_id) {
497497
case PL1_ENABLE:
@@ -504,7 +504,7 @@ static int get_max_power(struct powercap_zone *power_zone, int id, u64 *data)
504504
prim = MAX_POWER;
505505
break;
506506
default:
507-
put_online_cpus();
507+
cpus_read_unlock();
508508
return -EINVAL;
509509
}
510510
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)
516516
if (rd->rpl[id].prim_id == PL4_ENABLE)
517517
*data = *data * 2;
518518

519-
put_online_cpus();
519+
cpus_read_unlock();
520520

521521
return ret;
522522
}
@@ -1358,7 +1358,7 @@ static void power_limit_state_save(void)
13581358
struct rapl_domain *rd;
13591359
int nr_pl, ret, i;
13601360

1361-
get_online_cpus();
1361+
cpus_read_lock();
13621362
list_for_each_entry(rp, &rapl_packages, plist) {
13631363
if (!rp->power_zone)
13641364
continue;
@@ -1390,7 +1390,7 @@ static void power_limit_state_save(void)
13901390
}
13911391
}
13921392
}
1393-
put_online_cpus();
1393+
cpus_read_unlock();
13941394
}
13951395

13961396
static void power_limit_state_restore(void)
@@ -1399,7 +1399,7 @@ static void power_limit_state_restore(void)
13991399
struct rapl_domain *rd;
14001400
int nr_pl, i;
14011401

1402-
get_online_cpus();
1402+
cpus_read_lock();
14031403
list_for_each_entry(rp, &rapl_packages, plist) {
14041404
if (!rp->power_zone)
14051405
continue;
@@ -1425,7 +1425,7 @@ static void power_limit_state_restore(void)
14251425
}
14261426
}
14271427
}
1428-
put_online_cpus();
1428+
cpus_read_unlock();
14291429
}
14301430

14311431
static int rapl_pm_callback(struct notifier_block *nb,

0 commit comments

Comments
 (0)