@@ -782,8 +782,8 @@ void rtas_progress(char *s, unsigned short hex)
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,7 +937,6 @@ static void __init init_error_log_max(void)
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
@@ -947,16 +946,17 @@ static int rtas_last_error_token;
947
946
*/
948
947
static char * __fetch_rtas_last_error (char * altbuf )
949
948
{
949
+ const s32 token = rtas_function_token (RTAS_FN_RTAS_LAST_ERROR );
950
950
struct rtas_args err_args , save_args ;
951
951
u32 bufsz ;
952
952
char * buf = NULL ;
953
953
954
- if (rtas_last_error_token == -1 )
954
+ if (token == -1 )
955
955
return NULL ;
956
956
957
957
bufsz = rtas_get_error_log_max ();
958
958
959
- err_args .token = cpu_to_be32 (rtas_last_error_token );
959
+ err_args .token = cpu_to_be32 (token );
960
960
err_args .nargs = cpu_to_be32 (2 );
961
961
err_args .nret = cpu_to_be32 (1 );
962
962
err_args .args [0 ] = cpu_to_be32 (__pa (rtas_err_buf ));
@@ -1025,8 +1025,11 @@ void rtas_call_unlocked(struct rtas_args *args, int token, int nargs, int nret,
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.
@@ -1098,7 +1101,7 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)
1098
1101
if (!rtas .entry || token == RTAS_UNKNOWN_SERVICE )
1099
1102
return -1 ;
1100
1103
1101
- if (token == ibm_open_errinjct_token || token == ibm_errinjct_token ) {
1104
+ if (token_is_restricted_errinjct ( token ) ) {
1102
1105
/*
1103
1106
* It would be nicer to not discard the error value
1104
1107
* from security_locked_down(), but callers expect an
@@ -1330,7 +1333,7 @@ static int rtas_error_rc(int rtas_rc)
1330
1333
1331
1334
int rtas_get_power_level (int powerdomain , int * level )
1332
1335
{
1333
- int token = rtas_token ( "get-power-level" );
1336
+ int token = rtas_function_token ( RTAS_FN_GET_POWER_LEVEL );
1334
1337
int rc ;
1335
1338
1336
1339
if (token == RTAS_UNKNOWN_SERVICE )
@@ -1347,7 +1350,7 @@ EXPORT_SYMBOL_GPL(rtas_get_power_level);
1347
1350
1348
1351
int rtas_set_power_level (int powerdomain , int level , int * setlevel )
1349
1352
{
1350
- int token = rtas_token ( "set-power-level" );
1353
+ int token = rtas_function_token ( RTAS_FN_SET_POWER_LEVEL );
1351
1354
int rc ;
1352
1355
1353
1356
if (token == RTAS_UNKNOWN_SERVICE )
@@ -1365,7 +1368,7 @@ EXPORT_SYMBOL_GPL(rtas_set_power_level);
1365
1368
1366
1369
int rtas_get_sensor (int sensor , int index , int * state )
1367
1370
{
1368
- int token = rtas_token ( "get-sensor-state" );
1371
+ int token = rtas_function_token ( RTAS_FN_GET_SENSOR_STATE );
1369
1372
int rc ;
1370
1373
1371
1374
if (token == RTAS_UNKNOWN_SERVICE )
@@ -1383,7 +1386,7 @@ EXPORT_SYMBOL_GPL(rtas_get_sensor);
1383
1386
1384
1387
int rtas_get_sensor_fast (int sensor , int index , int * state )
1385
1388
{
1386
- int token = rtas_token ( "get-sensor-state" );
1389
+ int token = rtas_function_token ( RTAS_FN_GET_SENSOR_STATE );
1387
1390
int rc ;
1388
1391
1389
1392
if (token == RTAS_UNKNOWN_SERVICE )
@@ -1425,7 +1428,7 @@ bool rtas_indicator_present(int token, int *maxindex)
1425
1428
1426
1429
int rtas_set_indicator (int indicator , int index , int new_value )
1427
1430
{
1428
- int token = rtas_token ( "set-indicator" );
1431
+ int token = rtas_function_token ( RTAS_FN_SET_INDICATOR );
1429
1432
int rc ;
1430
1433
1431
1434
if (token == RTAS_UNKNOWN_SERVICE )
@@ -1446,8 +1449,8 @@ EXPORT_SYMBOL_GPL(rtas_set_indicator);
1446
1449
*/
1447
1450
int rtas_set_indicator_fast (int indicator , int index , int new_value )
1448
1451
{
1452
+ int token = rtas_function_token (RTAS_FN_SET_INDICATOR );
1449
1453
int rc ;
1450
- int token = rtas_token ("set-indicator" );
1451
1454
1452
1455
if (token == RTAS_UNKNOWN_SERVICE )
1453
1456
return - ENOENT ;
@@ -1489,10 +1492,11 @@ int rtas_set_indicator_fast(int indicator, int index, int new_value)
1489
1492
*/
1490
1493
int rtas_ibm_suspend_me (int * fw_status )
1491
1494
{
1495
+ int token = rtas_function_token (RTAS_FN_IBM_SUSPEND_ME );
1492
1496
int fwrc ;
1493
1497
int ret ;
1494
1498
1495
- fwrc = rtas_call (rtas_token ( "ibm,suspend-me" ) , 0 , 1 , NULL );
1499
+ fwrc = rtas_call (token , 0 , 1 , NULL );
1496
1500
1497
1501
switch (fwrc ) {
1498
1502
case 0 :
@@ -1525,7 +1529,7 @@ void __noreturn rtas_restart(char *cmd)
1525
1529
if (rtas_flash_term_hook )
1526
1530
rtas_flash_term_hook (SYS_RESTART );
1527
1531
pr_emerg ("system-reboot returned %d\n" ,
1528
- rtas_call (rtas_token ( "system-reboot" ), 0 , 1 , NULL ));
1532
+ rtas_call (rtas_function_token ( RTAS_FN_SYSTEM_REBOOT ), 0 , 1 , NULL ));
1529
1533
for (;;);
1530
1534
}
1531
1535
@@ -1535,7 +1539,7 @@ void rtas_power_off(void)
1535
1539
rtas_flash_term_hook (SYS_POWER_OFF );
1536
1540
/* allow power on only with power button press */
1537
1541
pr_emerg ("power-off returned %d\n" ,
1538
- rtas_call (rtas_token ( "power-off" ), 2 , 1 , NULL , -1 , -1 ));
1542
+ rtas_call (rtas_function_token ( RTAS_FN_POWER_OFF ), 2 , 1 , NULL , -1 , -1 ));
1539
1543
for (;;);
1540
1544
}
1541
1545
@@ -1545,16 +1549,17 @@ void __noreturn rtas_halt(void)
1545
1549
rtas_flash_term_hook (SYS_HALT );
1546
1550
/* allow power on only with power button press */
1547
1551
pr_emerg ("power-off returned %d\n" ,
1548
- rtas_call (rtas_token ( "power-off" ), 2 , 1 , NULL , -1 , -1 ));
1552
+ rtas_call (rtas_function_token ( RTAS_FN_POWER_OFF ), 2 , 1 , NULL , -1 , -1 ));
1549
1553
for (;;);
1550
1554
}
1551
1555
1552
1556
/* Must be in the RMO region, so we place it here */
1553
1557
static char rtas_os_term_buf [2048 ];
1554
- static s32 ibm_os_term_token = RTAS_UNKNOWN_SERVICE ;
1558
+ static bool ibm_extended_os_term ;
1555
1559
1556
1560
void rtas_os_term (char * str )
1557
1561
{
1562
+ s32 token = rtas_function_token (RTAS_FN_IBM_OS_TERM );
1558
1563
int status ;
1559
1564
1560
1565
/*
@@ -1563,7 +1568,8 @@ void rtas_os_term(char *str)
1563
1568
* this property may terminate the partition which we want to avoid
1564
1569
* since it interferes with panic_timeout.
1565
1570
*/
1566
- if (ibm_os_term_token == RTAS_UNKNOWN_SERVICE )
1571
+
1572
+ if (token == RTAS_UNKNOWN_SERVICE || !ibm_extended_os_term )
1567
1573
return ;
1568
1574
1569
1575
snprintf (rtas_os_term_buf , 2048 , "OS panic: %s" , str );
@@ -1574,8 +1580,7 @@ void rtas_os_term(char *str)
1574
1580
* schedules.
1575
1581
*/
1576
1582
do {
1577
- status = rtas_call (ibm_os_term_token , 1 , 1 , NULL ,
1578
- __pa (rtas_os_term_buf ));
1583
+ status = rtas_call (token , 1 , 1 , NULL , __pa (rtas_os_term_buf ));
1579
1584
} while (rtas_busy_delay_time (status ));
1580
1585
1581
1586
if (status != 0 )
@@ -1595,10 +1600,9 @@ void rtas_os_term(char *str)
1595
1600
*/
1596
1601
void rtas_activate_firmware (void )
1597
1602
{
1598
- int token ;
1603
+ int token = rtas_function_token ( RTAS_FN_IBM_ACTIVATE_FIRMWARE ) ;
1599
1604
int fwrc ;
1600
1605
1601
- token = rtas_token ("ibm,activate-firmware" );
1602
1606
if (token == RTAS_UNKNOWN_SERVICE ) {
1603
1607
pr_notice ("ibm,activate-firmware method unavailable\n" );
1604
1608
return ;
@@ -1684,6 +1688,8 @@ static bool block_rtas_call(int token, int nargs,
1684
1688
{
1685
1689
const struct rtas_function * func ;
1686
1690
const struct rtas_filter * f ;
1691
+ const bool is_platform_dump = token == rtas_function_token (RTAS_FN_IBM_PLATFORM_DUMP );
1692
+ const bool is_config_conn = token == rtas_function_token (RTAS_FN_IBM_CONFIGURE_CONNECTOR );
1687
1693
u32 base , size , end ;
1688
1694
1689
1695
/*
@@ -1720,8 +1726,7 @@ static bool block_rtas_call(int token, int nargs,
1720
1726
* Special case for ibm,platform-dump - NULL buffer
1721
1727
* address is used to indicate end of dump processing
1722
1728
*/
1723
- if (!strcmp (func -> name , "ibm,platform-dump" ) &&
1724
- base == 0 )
1729
+ if (is_platform_dump && base == 0 )
1725
1730
return false;
1726
1731
1727
1732
if (!in_rmo_buf (base , end ))
@@ -1742,8 +1747,7 @@ static bool block_rtas_call(int token, int nargs,
1742
1747
* Special case for ibm,configure-connector where the
1743
1748
* address can be 0
1744
1749
*/
1745
- if (!strcmp (func -> name , "ibm,configure-connector" ) &&
1746
- base == 0 )
1750
+ if (is_config_conn && base == 0 )
1747
1751
return false;
1748
1752
1749
1753
if (!in_rmo_buf (base , end ))
@@ -1798,7 +1802,7 @@ SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs)
1798
1802
if (block_rtas_call (token , nargs , & args ))
1799
1803
return - EINVAL ;
1800
1804
1801
- if (token == ibm_open_errinjct_token || token == ibm_errinjct_token ) {
1805
+ if (token_is_restricted_errinjct ( token ) ) {
1802
1806
int err ;
1803
1807
1804
1808
err = security_locked_down (LOCKDOWN_RTAS_ERROR_INJECTION );
@@ -1807,7 +1811,7 @@ SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs)
1807
1811
}
1808
1812
1809
1813
/* Need to handle ibm,suspend_me call specially */
1810
- if (token == rtas_token ( "ibm,suspend-me" )) {
1814
+ if (token == rtas_function_token ( RTAS_FN_IBM_SUSPEND_ME )) {
1811
1815
1812
1816
/*
1813
1817
* rtas_ibm_suspend_me assumes the streamid handle is in cpu
@@ -1942,11 +1946,10 @@ void __init rtas_initialize(void)
1942
1946
rtas_function_table_init ();
1943
1947
1944
1948
/*
1945
- * Discover these now to avoid device tree lookups in the
1949
+ * Discover this now to avoid a device tree lookup in the
1946
1950
* panic path.
1947
1951
*/
1948
- if (of_property_read_bool (rtas .dev , "ibm,extended-os-term" ))
1949
- ibm_os_term_token = rtas_token ("ibm,os-term" );
1952
+ ibm_extended_os_term = of_property_read_bool (rtas .dev , "ibm,extended-os-term" );
1950
1953
1951
1954
/* If RTAS was found, allocate the RMO buffer for it and look for
1952
1955
* the stop-self token if any
@@ -1961,12 +1964,6 @@ void __init rtas_initialize(void)
1961
1964
panic ("ERROR: RTAS: Failed to allocate %lx bytes below %pa\n" ,
1962
1965
PAGE_SIZE , & rtas_region );
1963
1966
1964
- #ifdef CONFIG_RTAS_ERROR_LOGGING
1965
- rtas_last_error_token = rtas_token ("rtas-last-error" );
1966
- #endif
1967
- ibm_open_errinjct_token = rtas_token ("ibm,open-errinjct" );
1968
- ibm_errinjct_token = rtas_token ("ibm,errinjct" );
1969
-
1970
1967
rtas_work_area_reserve_arena (rtas_region );
1971
1968
}
1972
1969
@@ -2022,13 +2019,13 @@ void rtas_give_timebase(void)
2022
2019
2023
2020
raw_spin_lock_irqsave (& timebase_lock , flags );
2024
2021
hard_irq_disable ();
2025
- rtas_call (rtas_token ( "freeze-time-base" ), 0 , 1 , NULL );
2022
+ rtas_call (rtas_function_token ( RTAS_FN_FREEZE_TIME_BASE ), 0 , 1 , NULL );
2026
2023
timebase = get_tb ();
2027
2024
raw_spin_unlock (& timebase_lock );
2028
2025
2029
2026
while (timebase )
2030
2027
barrier ();
2031
- rtas_call (rtas_token ( "thaw-time-base" ), 0 , 1 , NULL );
2028
+ rtas_call (rtas_function_token ( RTAS_FN_THAW_TIME_BASE ), 0 , 1 , NULL );
2032
2029
local_irq_restore (flags );
2033
2030
}
2034
2031
0 commit comments