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

powerpc/rtas: arch-wide function token lookup conversions

With the tokens for all implemented RTAS functions now available via
rtas_function_token(), which is optimal and safe for arbitrary
contexts, there is no need to use rtas_token() or cache its result.

Most conversions are trivial, but a few are worth describing in more
detail:

* Error injection token comparisons for lockdown purposes are
consolidated into a simple predicate: token_is_restricted_errinjct().

* A couple of special cases in block_rtas_call() do not use
rtas_token() but perform string comparisons against names in the
function table. These are converted to compare against token values
instead, which is logically equivalent but less expensive.

* The lookup for the ibm,os-term token can be deferred until needed,
instead of caching it at boot to avoid device tree traversal during
panic.

* Since rtas_function_token() accesses a read-only data structure
without taking any locks, xmon's lookup of set-indicator can be
performed as needed instead of cached at startup.

Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20230125-b4-powerpc-rtas-queue-v3-20-26929c8cce78@linux.ibm.com

authored by

Nathan Lynch and committed by
Michael Ellerman
08273c9f 716bfc97

+123 -137
+12 -12
arch/powerpc/kernel/rtas-proc.c
··· 287 287 288 288 rtc_time64_to_tm(nowtime, &tm); 289 289 290 - error = rtas_call(rtas_token("set-time-for-power-on"), 7, 1, NULL, 291 - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, 292 - tm.tm_hour, tm.tm_min, tm.tm_sec, 0 /* nano */); 290 + error = rtas_call(rtas_function_token(RTAS_FN_SET_TIME_FOR_POWER_ON), 7, 1, NULL, 291 + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, 292 + tm.tm_hour, tm.tm_min, tm.tm_sec, 0 /* nano */); 293 293 if (error) 294 294 printk(KERN_WARNING "error: setting poweron time returned: %s\n", 295 295 ppc_rtas_process_error(error)); ··· 350 350 return error; 351 351 352 352 rtc_time64_to_tm(nowtime, &tm); 353 - error = rtas_call(rtas_token("set-time-of-day"), 7, 1, NULL, 354 - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, 355 - tm.tm_hour, tm.tm_min, tm.tm_sec, 0); 353 + error = rtas_call(rtas_function_token(RTAS_FN_SET_TIME_OF_DAY), 7, 1, NULL, 354 + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, 355 + tm.tm_hour, tm.tm_min, tm.tm_sec, 0); 356 356 if (error) 357 357 printk(KERN_WARNING "error: setting the clock returned: %s\n", 358 358 ppc_rtas_process_error(error)); ··· 362 362 static int ppc_rtas_clock_show(struct seq_file *m, void *v) 363 363 { 364 364 int ret[8]; 365 - int error = rtas_call(rtas_token("get-time-of-day"), 0, 8, ret); 365 + int error = rtas_call(rtas_function_token(RTAS_FN_GET_TIME_OF_DAY), 0, 8, ret); 366 366 367 367 if (error) { 368 368 printk(KERN_WARNING "error: reading the clock returned: %s\n", ··· 385 385 { 386 386 int i,j; 387 387 int state, error; 388 - int get_sensor_state = rtas_token("get-sensor-state"); 388 + int get_sensor_state = rtas_function_token(RTAS_FN_GET_SENSOR_STATE); 389 389 390 390 seq_printf(m, "RTAS (RunTime Abstraction Services) Sensor Information\n"); 391 391 seq_printf(m, "Sensor\t\tValue\t\tCondition\tLocation\n"); ··· 708 708 return error; 709 709 710 710 rtas_tone_frequency = freq; /* save it for later */ 711 - error = rtas_call(rtas_token("set-indicator"), 3, 1, NULL, 712 - TONE_FREQUENCY, 0, freq); 711 + error = rtas_call(rtas_function_token(RTAS_FN_SET_INDICATOR), 3, 1, NULL, 712 + TONE_FREQUENCY, 0, freq); 713 713 if (error) 714 714 printk(KERN_WARNING "error: setting tone frequency returned: %s\n", 715 715 ppc_rtas_process_error(error)); ··· 736 736 volume = 100; 737 737 738 738 rtas_tone_volume = volume; /* save it for later */ 739 - error = rtas_call(rtas_token("set-indicator"), 3, 1, NULL, 740 - TONE_VOLUME, 0, volume); 739 + error = rtas_call(rtas_function_token(RTAS_FN_SET_INDICATOR), 3, 1, NULL, 740 + TONE_VOLUME, 0, volume); 741 741 if (error) 742 742 printk(KERN_WARNING "error: setting tone volume returned: %s\n", 743 743 ppc_rtas_process_error(error));
+3 -3
arch/powerpc/kernel/rtas-rtc.c
··· 21 21 22 22 max_wait_tb = get_tb() + tb_ticks_per_usec * 1000 * MAX_RTC_WAIT; 23 23 do { 24 - error = rtas_call(rtas_token("get-time-of-day"), 0, 8, ret); 24 + error = rtas_call(rtas_function_token(RTAS_FN_GET_TIME_OF_DAY), 0, 8, ret); 25 25 26 26 wait_time = rtas_busy_delay_time(error); 27 27 if (wait_time) { ··· 53 53 54 54 max_wait_tb = get_tb() + tb_ticks_per_usec * 1000 * MAX_RTC_WAIT; 55 55 do { 56 - error = rtas_call(rtas_token("get-time-of-day"), 0, 8, ret); 56 + error = rtas_call(rtas_function_token(RTAS_FN_GET_TIME_OF_DAY), 0, 8, ret); 57 57 58 58 wait_time = rtas_busy_delay_time(error); 59 59 if (wait_time) { ··· 90 90 91 91 max_wait_tb = get_tb() + tb_ticks_per_usec * 1000 * MAX_RTC_WAIT; 92 92 do { 93 - error = rtas_call(rtas_token("set-time-of-day"), 7, 1, NULL, 93 + error = rtas_call(rtas_function_token(RTAS_FN_SET_TIME_OF_DAY), 7, 1, NULL, 94 94 tm->tm_year + 1900, tm->tm_mon + 1, 95 95 tm->tm_mday, tm->tm_hour, tm->tm_min, 96 96 tm->tm_sec, 0);
+38 -41
arch/powerpc/kernel/rtas.c
··· 782 782 "ibm,display-truncation-length", NULL); 783 783 of_node_put(root); 784 784 } 785 - display_character = rtas_token("display-character"); 786 - set_indicator = rtas_token("set-indicator"); 785 + display_character = rtas_function_token(RTAS_FN_DISPLAY_CHARACTER); 786 + set_indicator = rtas_function_token(RTAS_FN_SET_INDICATOR); 787 787 } 788 788 789 789 if (display_character == RTAS_UNKNOWN_SERVICE) { ··· 937 937 938 938 939 939 static char rtas_err_buf[RTAS_ERROR_LOG_MAX]; 940 - static int rtas_last_error_token; 941 940 942 941 /** Return a copy of the detailed error text associated with the 943 942 * most recent failed call to rtas. Because the error text ··· 946 947 */ 947 948 static char *__fetch_rtas_last_error(char *altbuf) 948 949 { 950 + const s32 token = rtas_function_token(RTAS_FN_RTAS_LAST_ERROR); 949 951 struct rtas_args err_args, save_args; 950 952 u32 bufsz; 951 953 char *buf = NULL; 952 954 953 - if (rtas_last_error_token == -1) 955 + if (token == -1) 954 956 return NULL; 955 957 956 958 bufsz = rtas_get_error_log_max(); 957 959 958 - err_args.token = cpu_to_be32(rtas_last_error_token); 960 + err_args.token = cpu_to_be32(token); 959 961 err_args.nargs = cpu_to_be32(2); 960 962 err_args.nret = cpu_to_be32(1); 961 963 err_args.args[0] = cpu_to_be32(__pa(rtas_err_buf)); ··· 1025 1025 va_end(list); 1026 1026 } 1027 1027 1028 - static int ibm_open_errinjct_token; 1029 - static int ibm_errinjct_token; 1028 + static bool token_is_restricted_errinjct(s32 token) 1029 + { 1030 + return token == rtas_function_token(RTAS_FN_IBM_OPEN_ERRINJCT) || 1031 + token == rtas_function_token(RTAS_FN_IBM_ERRINJCT); 1032 + } 1030 1033 1031 1034 /** 1032 1035 * rtas_call() - Invoke an RTAS firmware function. ··· 1101 1098 if (!rtas.entry || token == RTAS_UNKNOWN_SERVICE) 1102 1099 return -1; 1103 1100 1104 - if (token == ibm_open_errinjct_token || token == ibm_errinjct_token) { 1101 + if (token_is_restricted_errinjct(token)) { 1105 1102 /* 1106 1103 * It would be nicer to not discard the error value 1107 1104 * from security_locked_down(), but callers expect an ··· 1333 1330 1334 1331 int rtas_get_power_level(int powerdomain, int *level) 1335 1332 { 1336 - int token = rtas_token("get-power-level"); 1333 + int token = rtas_function_token(RTAS_FN_GET_POWER_LEVEL); 1337 1334 int rc; 1338 1335 1339 1336 if (token == RTAS_UNKNOWN_SERVICE) ··· 1350 1347 1351 1348 int rtas_set_power_level(int powerdomain, int level, int *setlevel) 1352 1349 { 1353 - int token = rtas_token("set-power-level"); 1350 + int token = rtas_function_token(RTAS_FN_SET_POWER_LEVEL); 1354 1351 int rc; 1355 1352 1356 1353 if (token == RTAS_UNKNOWN_SERVICE) ··· 1368 1365 1369 1366 int rtas_get_sensor(int sensor, int index, int *state) 1370 1367 { 1371 - int token = rtas_token("get-sensor-state"); 1368 + int token = rtas_function_token(RTAS_FN_GET_SENSOR_STATE); 1372 1369 int rc; 1373 1370 1374 1371 if (token == RTAS_UNKNOWN_SERVICE) ··· 1386 1383 1387 1384 int rtas_get_sensor_fast(int sensor, int index, int *state) 1388 1385 { 1389 - int token = rtas_token("get-sensor-state"); 1386 + int token = rtas_function_token(RTAS_FN_GET_SENSOR_STATE); 1390 1387 int rc; 1391 1388 1392 1389 if (token == RTAS_UNKNOWN_SERVICE) ··· 1428 1425 1429 1426 int rtas_set_indicator(int indicator, int index, int new_value) 1430 1427 { 1431 - int token = rtas_token("set-indicator"); 1428 + int token = rtas_function_token(RTAS_FN_SET_INDICATOR); 1432 1429 int rc; 1433 1430 1434 1431 if (token == RTAS_UNKNOWN_SERVICE) ··· 1449 1446 */ 1450 1447 int rtas_set_indicator_fast(int indicator, int index, int new_value) 1451 1448 { 1449 + int token = rtas_function_token(RTAS_FN_SET_INDICATOR); 1452 1450 int rc; 1453 - int token = rtas_token("set-indicator"); 1454 1451 1455 1452 if (token == RTAS_UNKNOWN_SERVICE) 1456 1453 return -ENOENT; ··· 1492 1489 */ 1493 1490 int rtas_ibm_suspend_me(int *fw_status) 1494 1491 { 1492 + int token = rtas_function_token(RTAS_FN_IBM_SUSPEND_ME); 1495 1493 int fwrc; 1496 1494 int ret; 1497 1495 1498 - fwrc = rtas_call(rtas_token("ibm,suspend-me"), 0, 1, NULL); 1496 + fwrc = rtas_call(token, 0, 1, NULL); 1499 1497 1500 1498 switch (fwrc) { 1501 1499 case 0: ··· 1529 1525 if (rtas_flash_term_hook) 1530 1526 rtas_flash_term_hook(SYS_RESTART); 1531 1527 pr_emerg("system-reboot returned %d\n", 1532 - rtas_call(rtas_token("system-reboot"), 0, 1, NULL)); 1528 + rtas_call(rtas_function_token(RTAS_FN_SYSTEM_REBOOT), 0, 1, NULL)); 1533 1529 for (;;); 1534 1530 } 1535 1531 ··· 1539 1535 rtas_flash_term_hook(SYS_POWER_OFF); 1540 1536 /* allow power on only with power button press */ 1541 1537 pr_emerg("power-off returned %d\n", 1542 - rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1)); 1538 + rtas_call(rtas_function_token(RTAS_FN_POWER_OFF), 2, 1, NULL, -1, -1)); 1543 1539 for (;;); 1544 1540 } 1545 1541 ··· 1549 1545 rtas_flash_term_hook(SYS_HALT); 1550 1546 /* allow power on only with power button press */ 1551 1547 pr_emerg("power-off returned %d\n", 1552 - rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1)); 1548 + rtas_call(rtas_function_token(RTAS_FN_POWER_OFF), 2, 1, NULL, -1, -1)); 1553 1549 for (;;); 1554 1550 } 1555 1551 1556 1552 /* Must be in the RMO region, so we place it here */ 1557 1553 static char rtas_os_term_buf[2048]; 1558 - static s32 ibm_os_term_token = RTAS_UNKNOWN_SERVICE; 1554 + static bool ibm_extended_os_term; 1559 1555 1560 1556 void rtas_os_term(char *str) 1561 1557 { 1558 + s32 token = rtas_function_token(RTAS_FN_IBM_OS_TERM); 1562 1559 int status; 1563 1560 1564 1561 /* ··· 1568 1563 * this property may terminate the partition which we want to avoid 1569 1564 * since it interferes with panic_timeout. 1570 1565 */ 1571 - if (ibm_os_term_token == RTAS_UNKNOWN_SERVICE) 1566 + 1567 + if (token == RTAS_UNKNOWN_SERVICE || !ibm_extended_os_term) 1572 1568 return; 1573 1569 1574 1570 snprintf(rtas_os_term_buf, 2048, "OS panic: %s", str); ··· 1580 1574 * schedules. 1581 1575 */ 1582 1576 do { 1583 - status = rtas_call(ibm_os_term_token, 1, 1, NULL, 1584 - __pa(rtas_os_term_buf)); 1577 + status = rtas_call(token, 1, 1, NULL, __pa(rtas_os_term_buf)); 1585 1578 } while (rtas_busy_delay_time(status)); 1586 1579 1587 1580 if (status != 0) ··· 1600 1595 */ 1601 1596 void rtas_activate_firmware(void) 1602 1597 { 1603 - int token; 1598 + int token = rtas_function_token(RTAS_FN_IBM_ACTIVATE_FIRMWARE); 1604 1599 int fwrc; 1605 1600 1606 - token = rtas_token("ibm,activate-firmware"); 1607 1601 if (token == RTAS_UNKNOWN_SERVICE) { 1608 1602 pr_notice("ibm,activate-firmware method unavailable\n"); 1609 1603 return; ··· 1688 1684 { 1689 1685 const struct rtas_function *func; 1690 1686 const struct rtas_filter *f; 1687 + const bool is_platform_dump = token == rtas_function_token(RTAS_FN_IBM_PLATFORM_DUMP); 1688 + const bool is_config_conn = token == rtas_function_token(RTAS_FN_IBM_CONFIGURE_CONNECTOR); 1691 1689 u32 base, size, end; 1692 1690 1693 1691 /* ··· 1726 1720 * Special case for ibm,platform-dump - NULL buffer 1727 1721 * address is used to indicate end of dump processing 1728 1722 */ 1729 - if (!strcmp(func->name, "ibm,platform-dump") && 1730 - base == 0) 1723 + if (is_platform_dump && base == 0) 1731 1724 return false; 1732 1725 1733 1726 if (!in_rmo_buf(base, end)) ··· 1747 1742 * Special case for ibm,configure-connector where the 1748 1743 * address can be 0 1749 1744 */ 1750 - if (!strcmp(func->name, "ibm,configure-connector") && 1751 - base == 0) 1745 + if (is_config_conn && base == 0) 1752 1746 return false; 1753 1747 1754 1748 if (!in_rmo_buf(base, end)) ··· 1802 1798 if (block_rtas_call(token, nargs, &args)) 1803 1799 return -EINVAL; 1804 1800 1805 - if (token == ibm_open_errinjct_token || token == ibm_errinjct_token) { 1801 + if (token_is_restricted_errinjct(token)) { 1806 1802 int err; 1807 1803 1808 1804 err = security_locked_down(LOCKDOWN_RTAS_ERROR_INJECTION); ··· 1811 1807 } 1812 1808 1813 1809 /* Need to handle ibm,suspend_me call specially */ 1814 - if (token == rtas_token("ibm,suspend-me")) { 1810 + if (token == rtas_function_token(RTAS_FN_IBM_SUSPEND_ME)) { 1815 1811 1816 1812 /* 1817 1813 * rtas_ibm_suspend_me assumes the streamid handle is in cpu ··· 1946 1942 rtas_function_table_init(); 1947 1943 1948 1944 /* 1949 - * Discover these now to avoid device tree lookups in the 1945 + * Discover this now to avoid a device tree lookup in the 1950 1946 * panic path. 1951 1947 */ 1952 - if (of_property_read_bool(rtas.dev, "ibm,extended-os-term")) 1953 - ibm_os_term_token = rtas_token("ibm,os-term"); 1948 + ibm_extended_os_term = of_property_read_bool(rtas.dev, "ibm,extended-os-term"); 1954 1949 1955 1950 /* If RTAS was found, allocate the RMO buffer for it and look for 1956 1951 * the stop-self token if any ··· 1963 1960 if (!rtas_rmo_buf) 1964 1961 panic("ERROR: RTAS: Failed to allocate %lx bytes below %pa\n", 1965 1962 PAGE_SIZE, &rtas_region); 1966 - 1967 - #ifdef CONFIG_RTAS_ERROR_LOGGING 1968 - rtas_last_error_token = rtas_token("rtas-last-error"); 1969 - #endif 1970 - ibm_open_errinjct_token = rtas_token("ibm,open-errinjct"); 1971 - ibm_errinjct_token = rtas_token("ibm,errinjct"); 1972 1963 1973 1964 rtas_work_area_reserve_arena(rtas_region); 1974 1965 } ··· 2019 2022 2020 2023 raw_spin_lock_irqsave(&timebase_lock, flags); 2021 2024 hard_irq_disable(); 2022 - rtas_call(rtas_token("freeze-time-base"), 0, 1, NULL); 2025 + rtas_call(rtas_function_token(RTAS_FN_FREEZE_TIME_BASE), 0, 1, NULL); 2023 2026 timebase = get_tb(); 2024 2027 raw_spin_unlock(&timebase_lock); 2025 2028 2026 2029 while (timebase) 2027 2030 barrier(); 2028 - rtas_call(rtas_token("thaw-time-base"), 0, 1, NULL); 2031 + rtas_call(rtas_function_token(RTAS_FN_THAW_TIME_BASE), 0, 1, NULL); 2029 2032 local_irq_restore(flags); 2030 2033 } 2031 2034
+10 -11
arch/powerpc/kernel/rtas_flash.c
··· 376 376 s32 rc; 377 377 378 378 do { 379 - rc = rtas_call(rtas_token("ibm,manage-flash-image"), 1, 1, 379 + rc = rtas_call(rtas_function_token(RTAS_FN_IBM_MANAGE_FLASH_IMAGE), 1, 1, 380 380 NULL, op); 381 381 } while (rtas_busy_delay(rc)); 382 382 ··· 444 444 */ 445 445 static void validate_flash(struct rtas_validate_flash_t *args_buf) 446 446 { 447 - int token = rtas_token("ibm,validate-flash-image"); 447 + int token = rtas_function_token(RTAS_FN_IBM_VALIDATE_FLASH_IMAGE); 448 448 int update_results; 449 449 s32 rc; 450 450 ··· 570 570 return; 571 571 } 572 572 573 - update_token = rtas_token("ibm,update-flash-64-and-reboot"); 573 + update_token = rtas_function_token(RTAS_FN_IBM_UPDATE_FLASH_64_AND_REBOOT); 574 574 if (update_token == RTAS_UNKNOWN_SERVICE) { 575 575 printk(KERN_ALERT "FLASH: ibm,update-flash-64-and-reboot " 576 576 "is not available -- not a service partition?\n"); ··· 653 653 */ 654 654 struct rtas_flash_file { 655 655 const char *filename; 656 - const char *rtas_call_name; 656 + const rtas_fn_handle_t handle; 657 657 int *status; 658 658 const struct proc_ops ops; 659 659 }; ··· 661 661 static const struct rtas_flash_file rtas_flash_files[] = { 662 662 { 663 663 .filename = "powerpc/rtas/" FIRMWARE_FLASH_NAME, 664 - .rtas_call_name = "ibm,update-flash-64-and-reboot", 664 + .handle = RTAS_FN_IBM_UPDATE_FLASH_64_AND_REBOOT, 665 665 .status = &rtas_update_flash_data.status, 666 666 .ops.proc_read = rtas_flash_read_msg, 667 667 .ops.proc_write = rtas_flash_write, ··· 670 670 }, 671 671 { 672 672 .filename = "powerpc/rtas/" FIRMWARE_UPDATE_NAME, 673 - .rtas_call_name = "ibm,update-flash-64-and-reboot", 673 + .handle = RTAS_FN_IBM_UPDATE_FLASH_64_AND_REBOOT, 674 674 .status = &rtas_update_flash_data.status, 675 675 .ops.proc_read = rtas_flash_read_num, 676 676 .ops.proc_write = rtas_flash_write, ··· 679 679 }, 680 680 { 681 681 .filename = "powerpc/rtas/" VALIDATE_FLASH_NAME, 682 - .rtas_call_name = "ibm,validate-flash-image", 682 + .handle = RTAS_FN_IBM_VALIDATE_FLASH_IMAGE, 683 683 .status = &rtas_validate_flash_data.status, 684 684 .ops.proc_read = validate_flash_read, 685 685 .ops.proc_write = validate_flash_write, ··· 688 688 }, 689 689 { 690 690 .filename = "powerpc/rtas/" MANAGE_FLASH_NAME, 691 - .rtas_call_name = "ibm,manage-flash-image", 691 + .handle = RTAS_FN_IBM_MANAGE_FLASH_IMAGE, 692 692 .status = &rtas_manage_flash_data.status, 693 693 .ops.proc_read = manage_flash_read, 694 694 .ops.proc_write = manage_flash_write, ··· 700 700 { 701 701 int i; 702 702 703 - if (rtas_token("ibm,update-flash-64-and-reboot") == 704 - RTAS_UNKNOWN_SERVICE) { 703 + if (rtas_function_token(RTAS_FN_IBM_UPDATE_FLASH_64_AND_REBOOT) == RTAS_UNKNOWN_SERVICE) { 705 704 pr_info("rtas_flash: no firmware flash support\n"); 706 705 return -EINVAL; 707 706 } ··· 729 730 * This code assumes that the status int is the first member of the 730 731 * struct 731 732 */ 732 - token = rtas_token(f->rtas_call_name); 733 + token = rtas_function_token(f->handle); 733 734 if (token == RTAS_UNKNOWN_SERVICE) 734 735 *f->status = FLASH_AUTH; 735 736 else
+4 -4
arch/powerpc/kernel/rtas_pci.c
··· 191 191 192 192 void __init init_pci_config_tokens(void) 193 193 { 194 - read_pci_config = rtas_token("read-pci-config"); 195 - write_pci_config = rtas_token("write-pci-config"); 196 - ibm_read_pci_config = rtas_token("ibm,read-pci-config"); 197 - ibm_write_pci_config = rtas_token("ibm,write-pci-config"); 194 + read_pci_config = rtas_function_token(RTAS_FN_READ_PCI_CONFIG); 195 + write_pci_config = rtas_function_token(RTAS_FN_WRITE_PCI_CONFIG); 196 + ibm_read_pci_config = rtas_function_token(RTAS_FN_IBM_READ_PCI_CONFIG); 197 + ibm_write_pci_config = rtas_function_token(RTAS_FN_IBM_WRITE_PCI_CONFIG); 198 198 } 199 199 200 200 unsigned long get_phb_buid(struct device_node *phb)
+1 -1
arch/powerpc/kernel/rtasd.c
··· 506 506 return 0; 507 507 508 508 /* No RTAS */ 509 - event_scan = rtas_token("event-scan"); 509 + event_scan = rtas_function_token(RTAS_FN_EVENT_SCAN); 510 510 if (event_scan == RTAS_UNKNOWN_SERVICE) { 511 511 printk(KERN_INFO "rtasd: No event-scan on system\n"); 512 512 return -ENODEV;
+2 -2
arch/powerpc/platforms/52xx/efika.c
··· 41 41 int ret = -1; 42 42 int rval; 43 43 44 - rval = rtas_call(rtas_token("read-pci-config"), 2, 2, &ret, addr, len); 44 + rval = rtas_call(rtas_function_token(RTAS_FN_READ_PCI_CONFIG), 2, 2, &ret, addr, len); 45 45 *val = ret; 46 46 return rval ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL; 47 47 } ··· 55 55 | (hose->global_number << 24); 56 56 int rval; 57 57 58 - rval = rtas_call(rtas_token("write-pci-config"), 3, 1, NULL, 58 + rval = rtas_call(rtas_function_token(RTAS_FN_WRITE_PCI_CONFIG), 3, 1, NULL, 59 59 addr, len, val); 60 60 return rval ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL; 61 61 }
+2 -2
arch/powerpc/platforms/cell/ras.c
··· 297 297 static int __init cbe_ptcal_init(void) 298 298 { 299 299 int ret; 300 - ptcal_start_tok = rtas_token("ibm,cbe-start-ptcal"); 301 - ptcal_stop_tok = rtas_token("ibm,cbe-stop-ptcal"); 300 + ptcal_start_tok = rtas_function_token(RTAS_FN_IBM_CBE_START_PTCAL); 301 + ptcal_stop_tok = rtas_function_token(RTAS_FN_IBM_CBE_STOP_PTCAL); 302 302 303 303 if (ptcal_start_tok == RTAS_UNKNOWN_SERVICE 304 304 || ptcal_stop_tok == RTAS_UNKNOWN_SERVICE)
+2 -2
arch/powerpc/platforms/cell/smp.c
··· 81 81 * If the RTAS start-cpu token does not exist then presume the 82 82 * cpu is already spinning. 83 83 */ 84 - start_cpu = rtas_token("start-cpu"); 84 + start_cpu = rtas_function_token(RTAS_FN_START_CPU); 85 85 if (start_cpu == RTAS_UNKNOWN_SERVICE) 86 86 return 1; 87 87 ··· 152 152 cpumask_clear_cpu(boot_cpuid, &of_spin_map); 153 153 154 154 /* Non-lpar has additional take/give timebase */ 155 - if (rtas_token("freeze-time-base") != RTAS_UNKNOWN_SERVICE) { 155 + if (rtas_function_token(RTAS_FN_FREEZE_TIME_BASE) != RTAS_UNKNOWN_SERVICE) { 156 156 smp_ops->give_timebase = rtas_give_timebase; 157 157 smp_ops->take_timebase = rtas_take_timebase; 158 158 }
+2 -2
arch/powerpc/platforms/chrp/nvram.c
··· 31 31 return 0xff; 32 32 } 33 33 spin_lock_irqsave(&nvram_lock, flags); 34 - if ((rtas_call(rtas_token("nvram-fetch"), 3, 2, &done, addr, 34 + if ((rtas_call(rtas_function_token(RTAS_FN_NVRAM_FETCH), 3, 2, &done, addr, 35 35 __pa(nvram_buf), 1) != 0) || 1 != done) 36 36 ret = 0xff; 37 37 else ··· 53 53 } 54 54 spin_lock_irqsave(&nvram_lock, flags); 55 55 nvram_buf[0] = val; 56 - if ((rtas_call(rtas_token("nvram-store"), 3, 2, &done, addr, 56 + if ((rtas_call(rtas_function_token(RTAS_FN_NVRAM_STORE), 3, 2, &done, addr, 57 57 __pa(nvram_buf), 1) != 0) || 1 != done) 58 58 printk(KERN_DEBUG "rtas IO error storing 0x%02x at %d", val, addr); 59 59 spin_unlock_irqrestore(&nvram_lock, flags);
+2 -2
arch/powerpc/platforms/chrp/pci.c
··· 104 104 int ret = -1; 105 105 int rval; 106 106 107 - rval = rtas_call(rtas_token("read-pci-config"), 2, 2, &ret, addr, len); 107 + rval = rtas_call(rtas_function_token(RTAS_FN_READ_PCI_CONFIG), 2, 2, &ret, addr, len); 108 108 *val = ret; 109 109 return rval? PCIBIOS_DEVICE_NOT_FOUND: PCIBIOS_SUCCESSFUL; 110 110 } ··· 118 118 | (hose->global_number << 24); 119 119 int rval; 120 120 121 - rval = rtas_call(rtas_token("write-pci-config"), 3, 1, NULL, 121 + rval = rtas_call(rtas_function_token(RTAS_FN_WRITE_PCI_CONFIG), 3, 1, NULL, 122 122 addr, len, val); 123 123 return rval? PCIBIOS_DEVICE_NOT_FOUND: PCIBIOS_SUCCESSFUL; 124 124 }
+2 -2
arch/powerpc/platforms/chrp/setup.c
··· 323 323 printk("chrp type = %x [%s]\n", _chrp_type, chrp_names[_chrp_type]); 324 324 325 325 rtas_initialize(); 326 - if (rtas_token("display-character") >= 0) 326 + if (rtas_function_token(RTAS_FN_DISPLAY_CHARACTER) >= 0) 327 327 ppc_md.progress = rtas_progress; 328 328 329 329 /* use RTAS time-of-day routines if available */ 330 - if (rtas_token("get-time-of-day") != RTAS_UNKNOWN_SERVICE) { 330 + if (rtas_function_token(RTAS_FN_GET_TIME_OF_DAY) != RTAS_UNKNOWN_SERVICE) { 331 331 ppc_md.get_boot_time = rtas_get_boot_time; 332 332 ppc_md.get_rtc_time = rtas_get_rtc_time; 333 333 ppc_md.set_rtc_time = rtas_set_rtc_time;
+2 -2
arch/powerpc/platforms/maple/setup.c
··· 162 162 163 163 static void __init maple_use_rtas_reboot_and_halt_if_present(void) 164 164 { 165 - if (rtas_service_present("system-reboot") && 166 - rtas_service_present("power-off")) { 165 + if (rtas_function_implemented(RTAS_FN_SYSTEM_REBOOT) && 166 + rtas_function_implemented(RTAS_FN_POWER_OFF)) { 167 167 ppc_md.restart = rtas_restart; 168 168 pm_power_off = rtas_power_off; 169 169 ppc_md.halt = rtas_halt;
+1 -1
arch/powerpc/platforms/pseries/dlpar.c
··· 143 143 int cc_token; 144 144 int rc = -1; 145 145 146 - cc_token = rtas_token("ibm,configure-connector"); 146 + cc_token = rtas_function_token(RTAS_FN_IBM_CONFIGURE_CONNECTOR); 147 147 if (cc_token == RTAS_UNKNOWN_SERVICE) 148 148 return NULL; 149 149
+11 -11
arch/powerpc/platforms/pseries/eeh_pseries.c
··· 699 699 static int pseries_send_allow_unfreeze(struct pci_dn *pdn, u16 *vf_pe_array, int cur_vfs) 700 700 { 701 701 int rc; 702 - int ibm_allow_unfreeze = rtas_token("ibm,open-sriov-allow-unfreeze"); 702 + int ibm_allow_unfreeze = rtas_function_token(RTAS_FN_IBM_OPEN_SRIOV_ALLOW_UNFREEZE); 703 703 unsigned long buid, addr; 704 704 705 705 addr = rtas_config_addr(pdn->busno, pdn->devfn, 0); ··· 774 774 if (!edev) 775 775 return -EEXIST; 776 776 777 - if (rtas_token("ibm,open-sriov-allow-unfreeze") == RTAS_UNKNOWN_SERVICE) 777 + if (rtas_function_token(RTAS_FN_IBM_OPEN_SRIOV_ALLOW_UNFREEZE) == RTAS_UNKNOWN_SERVICE) 778 778 return -EINVAL; 779 779 780 780 if (edev->pdev->is_physfn || edev->pdev->is_virtfn) ··· 815 815 int ret, config_addr; 816 816 817 817 /* figure out EEH RTAS function call tokens */ 818 - ibm_set_eeh_option = rtas_token("ibm,set-eeh-option"); 819 - ibm_set_slot_reset = rtas_token("ibm,set-slot-reset"); 820 - ibm_read_slot_reset_state2 = rtas_token("ibm,read-slot-reset-state2"); 821 - ibm_read_slot_reset_state = rtas_token("ibm,read-slot-reset-state"); 822 - ibm_slot_error_detail = rtas_token("ibm,slot-error-detail"); 823 - ibm_get_config_addr_info2 = rtas_token("ibm,get-config-addr-info2"); 824 - ibm_get_config_addr_info = rtas_token("ibm,get-config-addr-info"); 825 - ibm_configure_pe = rtas_token("ibm,configure-pe"); 818 + ibm_set_eeh_option = rtas_function_token(RTAS_FN_IBM_SET_EEH_OPTION); 819 + ibm_set_slot_reset = rtas_function_token(RTAS_FN_IBM_SET_SLOT_RESET); 820 + ibm_read_slot_reset_state2 = rtas_function_token(RTAS_FN_IBM_READ_SLOT_RESET_STATE2); 821 + ibm_read_slot_reset_state = rtas_function_token(RTAS_FN_IBM_READ_SLOT_RESET_STATE); 822 + ibm_slot_error_detail = rtas_function_token(RTAS_FN_IBM_SLOT_ERROR_DETAIL); 823 + ibm_get_config_addr_info2 = rtas_function_token(RTAS_FN_IBM_GET_CONFIG_ADDR_INFO2); 824 + ibm_get_config_addr_info = rtas_function_token(RTAS_FN_IBM_GET_CONFIG_ADDR_INFO); 825 + ibm_configure_pe = rtas_function_token(RTAS_FN_IBM_CONFIGURE_PE); 826 826 827 827 /* 828 828 * ibm,configure-pe and ibm,configure-bridge have the same semantics, ··· 830 830 * ibm,configure-pe then fall back to using ibm,configure-bridge. 831 831 */ 832 832 if (ibm_configure_pe == RTAS_UNKNOWN_SERVICE) 833 - ibm_configure_pe = rtas_token("ibm,configure-bridge"); 833 + ibm_configure_pe = rtas_function_token(RTAS_FN_IBM_CONFIGURE_BRIDGE); 834 834 835 835 /* 836 836 * Necessary sanity check. We needn't check "get-config-addr-info"
+2 -2
arch/powerpc/platforms/pseries/hotplug-cpu.c
··· 855 855 ppc_md.cpu_release = dlpar_cpu_release; 856 856 #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ 857 857 858 - rtas_stop_self_token = rtas_token("stop-self"); 859 - qcss_tok = rtas_token("query-cpu-stopped-state"); 858 + rtas_stop_self_token = rtas_function_token(RTAS_FN_STOP_SELF); 859 + qcss_tok = rtas_function_token(RTAS_FN_QUERY_CPU_STOPPED_STATE); 860 860 861 861 if (rtas_stop_self_token == RTAS_UNKNOWN_SERVICE || 862 862 qcss_tok == RTAS_UNKNOWN_SERVICE) {
+1 -1
arch/powerpc/platforms/pseries/io_event_irq.c
··· 143 143 { 144 144 struct device_node *np; 145 145 146 - ioei_check_exception_token = rtas_token("check-exception"); 146 + ioei_check_exception_token = rtas_function_token(RTAS_FN_CHECK_EXCEPTION); 147 147 if (ioei_check_exception_token == RTAS_UNKNOWN_SERVICE) 148 148 return -ENODEV; 149 149
+2 -2
arch/powerpc/platforms/pseries/mobility.c
··· 195 195 u32 nprops; 196 196 u32 vd; 197 197 198 - update_properties_token = rtas_token("ibm,update-properties"); 198 + update_properties_token = rtas_function_token(RTAS_FN_IBM_UPDATE_PROPERTIES); 199 199 if (update_properties_token == RTAS_UNKNOWN_SERVICE) 200 200 return -EINVAL; 201 201 ··· 306 306 int update_nodes_token; 307 307 int rc; 308 308 309 - update_nodes_token = rtas_token("ibm,update-nodes"); 309 + update_nodes_token = rtas_function_token(RTAS_FN_IBM_UPDATE_NODES); 310 310 if (update_nodes_token == RTAS_UNKNOWN_SERVICE) 311 311 return 0; 312 312
+2 -2
arch/powerpc/platforms/pseries/msi.c
··· 679 679 680 680 static int rtas_msi_init(void) 681 681 { 682 - query_token = rtas_token("ibm,query-interrupt-source-number"); 683 - change_token = rtas_token("ibm,change-msi"); 682 + query_token = rtas_function_token(RTAS_FN_IBM_QUERY_INTERRUPT_SOURCE_NUMBER); 683 + change_token = rtas_function_token(RTAS_FN_IBM_CHANGE_MSI); 684 684 685 685 if ((query_token == RTAS_UNKNOWN_SERVICE) || 686 686 (change_token == RTAS_UNKNOWN_SERVICE)) {
+2 -2
arch/powerpc/platforms/pseries/nvram.c
··· 227 227 228 228 nvram_size = be32_to_cpup(nbytes_p); 229 229 230 - nvram_fetch = rtas_token("nvram-fetch"); 231 - nvram_store = rtas_token("nvram-store"); 230 + nvram_fetch = rtas_function_token(RTAS_FN_NVRAM_FETCH); 231 + nvram_store = rtas_function_token(RTAS_FN_NVRAM_STORE); 232 232 printk(KERN_INFO "PPC64 nvram contains %d bytes\n", nvram_size); 233 233 of_node_put(nvram); 234 234
+2 -2
arch/powerpc/platforms/pseries/papr-sysparm.c
··· 50 50 51 51 int papr_sysparm_get(papr_sysparm_t param, struct papr_sysparm_buf *buf) 52 52 { 53 - const s32 token = rtas_token("ibm,get-system-parameter"); 53 + const s32 token = rtas_function_token(RTAS_FN_IBM_GET_SYSTEM_PARAMETER); 54 54 struct rtas_work_area *work_area; 55 55 s32 fwrc; 56 56 int ret; ··· 102 102 103 103 int papr_sysparm_set(papr_sysparm_t param, const struct papr_sysparm_buf *buf) 104 104 { 105 - const s32 token = rtas_token("ibm,set-system-parameter"); 105 + const s32 token = rtas_function_token(RTAS_FN_IBM_SET_SYSTEM_PARAMETER); 106 106 struct rtas_work_area *work_area; 107 107 s32 fwrc; 108 108 int ret;
+1 -1
arch/powerpc/platforms/pseries/pci.c
··· 60 60 struct pci_dn *pdn; 61 61 int rc; 62 62 unsigned long buid, addr; 63 - int ibm_map_pes = rtas_token("ibm,open-sriov-map-pe-number"); 63 + int ibm_map_pes = rtas_function_token(RTAS_FN_IBM_OPEN_SRIOV_MAP_PE_NUMBER); 64 64 65 65 if (ibm_map_pes == RTAS_UNKNOWN_SERVICE) 66 66 return -EINVAL;
+1 -1
arch/powerpc/platforms/pseries/ras.c
··· 155 155 { 156 156 struct device_node *np; 157 157 158 - ras_check_exception_token = rtas_token("check-exception"); 158 + ras_check_exception_token = rtas_function_token(RTAS_FN_CHECK_EXCEPTION); 159 159 160 160 /* Internal Errors */ 161 161 np = of_find_node_by_path("/event-sources/internal-errors");
+2 -2
arch/powerpc/platforms/pseries/rtas-work-area.c
··· 203 203 * So set up the arena if we find that, with a fallback to 204 204 * ibm,configure-connector, just in case. 205 205 */ 206 - if (rtas_service_present("ibm,get-system-parameter") || 207 - rtas_service_present("ibm,configure-connector")) 206 + if (rtas_function_implemented(RTAS_FN_IBM_GET_SYSTEM_PARAMETER) || 207 + rtas_function_implemented(RTAS_FN_IBM_CONFIGURE_CONNECTOR)) 208 208 rwa_state.arena = memblock_alloc_try_nid(size, align, min, limit, nid); 209 209 }
+4 -4
arch/powerpc/platforms/pseries/setup.c
··· 136 136 #endif 137 137 int ibm_nmi_register_token; 138 138 139 - ibm_nmi_register_token = rtas_token("ibm,nmi-register"); 139 + ibm_nmi_register_token = rtas_function_token(RTAS_FN_IBM_NMI_REGISTER); 140 140 if (ibm_nmi_register_token == RTAS_UNKNOWN_SERVICE) 141 141 return; 142 142 143 - ibm_nmi_interlock_token = rtas_token("ibm,nmi-interlock"); 143 + ibm_nmi_interlock_token = rtas_function_token(RTAS_FN_IBM_NMI_INTERLOCK); 144 144 if (WARN_ON(ibm_nmi_interlock_token == RTAS_UNKNOWN_SERVICE)) 145 145 return; 146 146 ··· 1071 1071 static void pseries_power_off(void) 1072 1072 { 1073 1073 int rc; 1074 - int rtas_poweroff_ups_token = rtas_token("ibm,power-off-ups"); 1074 + int rtas_poweroff_ups_token = rtas_function_token(RTAS_FN_IBM_POWER_OFF_UPS); 1075 1075 1076 1076 if (rtas_flash_term_hook) 1077 1077 rtas_flash_term_hook(SYS_POWER_OFF); 1078 1078 1079 1079 if (rtas_poweron_auto == 0 || 1080 1080 rtas_poweroff_ups_token == RTAS_UNKNOWN_SERVICE) { 1081 - rc = rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1); 1081 + rc = rtas_call(rtas_function_token(RTAS_FN_POWER_OFF), 2, 1, NULL, -1, -1); 1082 1082 printk(KERN_INFO "RTAS power-off returned %d\n", rc); 1083 1083 } else { 1084 1084 rc = rtas_call(rtas_poweroff_ups_token, 0, 1, NULL);
+3 -3
arch/powerpc/platforms/pseries/smp.c
··· 55 55 int smp_query_cpu_stopped(unsigned int pcpu) 56 56 { 57 57 int cpu_status, status; 58 - int qcss_tok = rtas_token("query-cpu-stopped-state"); 58 + int qcss_tok = rtas_function_token(RTAS_FN_QUERY_CPU_STOPPED_STATE); 59 59 60 60 if (qcss_tok == RTAS_UNKNOWN_SERVICE) { 61 61 printk_once(KERN_INFO ··· 108 108 * If the RTAS start-cpu token does not exist then presume the 109 109 * cpu is already spinning. 110 110 */ 111 - start_cpu = rtas_token("start-cpu"); 111 + start_cpu = rtas_function_token(RTAS_FN_START_CPU); 112 112 if (start_cpu == RTAS_UNKNOWN_SERVICE) 113 113 return 1; 114 114 ··· 266 266 * We know prom_init will not have started them if RTAS supports 267 267 * query-cpu-stopped-state. 268 268 */ 269 - if (rtas_token("query-cpu-stopped-state") == RTAS_UNKNOWN_SERVICE) { 269 + if (rtas_function_token(RTAS_FN_QUERY_CPU_STOPPED_STATE) == RTAS_UNKNOWN_SERVICE) { 270 270 if (cpu_has_feature(CPU_FTR_SMT)) { 271 271 for_each_present_cpu(i) { 272 272 if (cpu_thread_in_core(i) == 0)
+4 -4
arch/powerpc/sysdev/xics/ics-rtas.c
··· 200 200 201 201 __init int ics_rtas_init(void) 202 202 { 203 - ibm_get_xive = rtas_token("ibm,get-xive"); 204 - ibm_set_xive = rtas_token("ibm,set-xive"); 205 - ibm_int_on = rtas_token("ibm,int-on"); 206 - ibm_int_off = rtas_token("ibm,int-off"); 203 + ibm_get_xive = rtas_function_token(RTAS_FN_IBM_GET_XIVE); 204 + ibm_set_xive = rtas_function_token(RTAS_FN_IBM_SET_XIVE); 205 + ibm_int_on = rtas_function_token(RTAS_FN_IBM_INT_ON); 206 + ibm_int_off = rtas_function_token(RTAS_FN_IBM_INT_OFF); 207 207 208 208 /* We enable the RTAS "ICS" if RTAS is present with the 209 209 * appropriate tokens
+3 -13
arch/powerpc/xmon/xmon.c
··· 76 76 #define xmon_owner 0 77 77 #endif /* CONFIG_SMP */ 78 78 79 - #ifdef CONFIG_PPC_PSERIES 80 - static int set_indicator_token = RTAS_UNKNOWN_SERVICE; 81 - #endif 82 79 static unsigned long in_xmon __read_mostly = 0; 83 80 static int xmon_on = IS_ENABLED(CONFIG_XMON_DEFAULT); 84 81 static bool xmon_is_ro = IS_ENABLED(CONFIG_XMON_DEFAULT_RO_MODE); ··· 395 398 #ifdef CONFIG_PPC_PSERIES 396 399 /* Since this can't be a module, args should end up below 4GB. */ 397 400 static struct rtas_args args; 401 + const s32 token = rtas_function_token(RTAS_FN_SET_INDICATOR); 398 402 399 403 /* 400 404 * At this point we have got all the cpus we can into ··· 404 406 * If we did try to take rtas.lock there would be a 405 407 * real possibility of deadlock. 406 408 */ 407 - if (set_indicator_token == RTAS_UNKNOWN_SERVICE) 409 + if (token == RTAS_UNKNOWN_SERVICE) 408 410 return; 409 411 410 - rtas_call_unlocked(&args, set_indicator_token, 3, 1, NULL, 412 + rtas_call_unlocked(&args, token, 3, 1, NULL, 411 413 SURVEILLANCE_TOKEN, 0, 0); 412 414 413 415 #endif /* CONFIG_PPC_PSERIES */ ··· 3974 3976 __debugger_iabr_match = xmon_iabr_match; 3975 3977 __debugger_break_match = xmon_break_match; 3976 3978 __debugger_fault_handler = xmon_fault_handler; 3977 - 3978 - #ifdef CONFIG_PPC_PSERIES 3979 - /* 3980 - * Get the token here to avoid trying to get a lock 3981 - * during the crash, causing a deadlock. 3982 - */ 3983 - set_indicator_token = rtas_token("set-indicator"); 3984 - #endif 3985 3979 } else { 3986 3980 __debugger = NULL; 3987 3981 __debugger_ipi = NULL;