Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <bigeasy@linutronix.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Sebastian Andrzej Siewior and committed by
Rafael J. Wysocki
5d4c779c c500bee1

+25 -25
+25 -25
drivers/powercap/intel_rapl_common.c
··· 158 158 /* prevent CPU hotplug, make sure the RAPL domain does not go 159 159 * away while reading the counter. 160 160 */ 161 - get_online_cpus(); 161 + cpus_read_lock(); 162 162 rd = power_zone_to_rapl_domain(power_zone); 163 163 164 164 if (!rapl_read_data_raw(rd, ENERGY_COUNTER, true, &energy_now)) { 165 165 *energy_raw = energy_now; 166 - put_online_cpus(); 166 + cpus_read_unlock(); 167 167 168 168 return 0; 169 169 } 170 - put_online_cpus(); 170 + cpus_read_unlock(); 171 171 172 172 return -EIO; 173 173 } ··· 216 216 if (rd->state & DOMAIN_STATE_BIOS_LOCKED) 217 217 return -EACCES; 218 218 219 - get_online_cpus(); 219 + cpus_read_lock(); 220 220 rapl_write_data_raw(rd, PL1_ENABLE, mode); 221 221 if (rapl_defaults->set_floor_freq) 222 222 rapl_defaults->set_floor_freq(rd, mode); 223 - put_online_cpus(); 223 + cpus_read_unlock(); 224 224 225 225 return 0; 226 226 } ··· 234 234 *mode = false; 235 235 return 0; 236 236 } 237 - get_online_cpus(); 237 + cpus_read_lock(); 238 238 if (rapl_read_data_raw(rd, PL1_ENABLE, true, &val)) { 239 - put_online_cpus(); 239 + cpus_read_unlock(); 240 240 return -EIO; 241 241 } 242 242 *mode = val; 243 - put_online_cpus(); 243 + cpus_read_unlock(); 244 244 245 245 return 0; 246 246 } ··· 317 317 int ret = 0; 318 318 int id; 319 319 320 - get_online_cpus(); 320 + cpus_read_lock(); 321 321 rd = power_zone_to_rapl_domain(power_zone); 322 322 id = contraint_to_pl(rd, cid); 323 323 if (id < 0) { ··· 350 350 if (!ret) 351 351 package_power_limit_irq_save(rp); 352 352 set_exit: 353 - put_online_cpus(); 353 + cpus_read_unlock(); 354 354 return ret; 355 355 } 356 356 ··· 363 363 int ret = 0; 364 364 int id; 365 365 366 - get_online_cpus(); 366 + cpus_read_lock(); 367 367 rd = power_zone_to_rapl_domain(power_zone); 368 368 id = contraint_to_pl(rd, cid); 369 369 if (id < 0) { ··· 382 382 prim = POWER_LIMIT4; 383 383 break; 384 384 default: 385 - put_online_cpus(); 385 + cpus_read_unlock(); 386 386 return -EINVAL; 387 387 } 388 388 if (rapl_read_data_raw(rd, prim, true, &val)) ··· 391 391 *data = val; 392 392 393 393 get_exit: 394 - put_online_cpus(); 394 + cpus_read_unlock(); 395 395 396 396 return ret; 397 397 } ··· 403 403 int ret = 0; 404 404 int id; 405 405 406 - get_online_cpus(); 406 + cpus_read_lock(); 407 407 rd = power_zone_to_rapl_domain(power_zone); 408 408 id = contraint_to_pl(rd, cid); 409 409 if (id < 0) { ··· 423 423 } 424 424 425 425 set_time_exit: 426 - put_online_cpus(); 426 + cpus_read_unlock(); 427 427 return ret; 428 428 } 429 429 ··· 435 435 int ret = 0; 436 436 int id; 437 437 438 - get_online_cpus(); 438 + cpus_read_lock(); 439 439 rd = power_zone_to_rapl_domain(power_zone); 440 440 id = contraint_to_pl(rd, cid); 441 441 if (id < 0) { ··· 458 458 val = 0; 459 459 break; 460 460 default: 461 - put_online_cpus(); 461 + cpus_read_unlock(); 462 462 return -EINVAL; 463 463 } 464 464 if (!ret) 465 465 *data = val; 466 466 467 467 get_time_exit: 468 - put_online_cpus(); 468 + cpus_read_unlock(); 469 469 470 470 return ret; 471 471 } ··· 491 491 int prim; 492 492 int ret = 0; 493 493 494 - get_online_cpus(); 494 + cpus_read_lock(); 495 495 rd = power_zone_to_rapl_domain(power_zone); 496 496 switch (rd->rpl[id].prim_id) { 497 497 case PL1_ENABLE: ··· 504 504 prim = MAX_POWER; 505 505 break; 506 506 default: 507 - put_online_cpus(); 507 + cpus_read_unlock(); 508 508 return -EINVAL; 509 509 } 510 510 if (rapl_read_data_raw(rd, prim, true, &val)) ··· 516 516 if (rd->rpl[id].prim_id == PL4_ENABLE) 517 517 *data = *data * 2; 518 518 519 - put_online_cpus(); 519 + cpus_read_unlock(); 520 520 521 521 return ret; 522 522 } ··· 1358 1358 struct rapl_domain *rd; 1359 1359 int nr_pl, ret, i; 1360 1360 1361 - get_online_cpus(); 1361 + cpus_read_lock(); 1362 1362 list_for_each_entry(rp, &rapl_packages, plist) { 1363 1363 if (!rp->power_zone) 1364 1364 continue; ··· 1390 1390 } 1391 1391 } 1392 1392 } 1393 - put_online_cpus(); 1393 + cpus_read_unlock(); 1394 1394 } 1395 1395 1396 1396 static void power_limit_state_restore(void) ··· 1399 1399 struct rapl_domain *rd; 1400 1400 int nr_pl, i; 1401 1401 1402 - get_online_cpus(); 1402 + cpus_read_lock(); 1403 1403 list_for_each_entry(rp, &rapl_packages, plist) { 1404 1404 if (!rp->power_zone) 1405 1405 continue; ··· 1425 1425 } 1426 1426 } 1427 1427 } 1428 - put_online_cpus(); 1428 + cpus_read_unlock(); 1429 1429 } 1430 1430 1431 1431 static int rapl_pm_callback(struct notifier_block *nb,