powerpc/rtas: arch-wide function token lookup conversions
authorNathan Lynch <nathanl@linux.ibm.com>
Fri, 10 Feb 2023 18:42:08 +0000 (12:42 -0600)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 13 Feb 2023 11:35:03 +0000 (22:35 +1100)
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
28 files changed:
arch/powerpc/kernel/rtas-proc.c
arch/powerpc/kernel/rtas-rtc.c
arch/powerpc/kernel/rtas.c
arch/powerpc/kernel/rtas_flash.c
arch/powerpc/kernel/rtas_pci.c
arch/powerpc/kernel/rtasd.c
arch/powerpc/platforms/52xx/efika.c
arch/powerpc/platforms/cell/ras.c
arch/powerpc/platforms/cell/smp.c
arch/powerpc/platforms/chrp/nvram.c
arch/powerpc/platforms/chrp/pci.c
arch/powerpc/platforms/chrp/setup.c
arch/powerpc/platforms/maple/setup.c
arch/powerpc/platforms/pseries/dlpar.c
arch/powerpc/platforms/pseries/eeh_pseries.c
arch/powerpc/platforms/pseries/hotplug-cpu.c
arch/powerpc/platforms/pseries/io_event_irq.c
arch/powerpc/platforms/pseries/mobility.c
arch/powerpc/platforms/pseries/msi.c
arch/powerpc/platforms/pseries/nvram.c
arch/powerpc/platforms/pseries/papr-sysparm.c
arch/powerpc/platforms/pseries/pci.c
arch/powerpc/platforms/pseries/ras.c
arch/powerpc/platforms/pseries/rtas-work-area.c
arch/powerpc/platforms/pseries/setup.c
arch/powerpc/platforms/pseries/smp.c
arch/powerpc/sysdev/xics/ics-rtas.c
arch/powerpc/xmon/xmon.c

index 081b2b7..9454b83 100644 (file)
@@ -287,9 +287,9 @@ static ssize_t ppc_rtas_poweron_write(struct file *file,
 
        rtc_time64_to_tm(nowtime, &tm);
 
-       error = rtas_call(rtas_token("set-time-for-power-on"), 7, 1, NULL, 
-                       tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
-                       tm.tm_hour, tm.tm_min, tm.tm_sec, 0 /* nano */);
+       error = rtas_call(rtas_function_token(RTAS_FN_SET_TIME_FOR_POWER_ON), 7, 1, NULL,
+                         tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+                         tm.tm_hour, tm.tm_min, tm.tm_sec, 0 /* nano */);
        if (error)
                printk(KERN_WARNING "error: setting poweron time returned: %s\n", 
                                ppc_rtas_process_error(error));
@@ -350,9 +350,9 @@ static ssize_t ppc_rtas_clock_write(struct file *file,
                return error;
 
        rtc_time64_to_tm(nowtime, &tm);
-       error = rtas_call(rtas_token("set-time-of-day"), 7, 1, NULL, 
-                       tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
-                       tm.tm_hour, tm.tm_min, tm.tm_sec, 0);
+       error = rtas_call(rtas_function_token(RTAS_FN_SET_TIME_OF_DAY), 7, 1, NULL,
+                         tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+                         tm.tm_hour, tm.tm_min, tm.tm_sec, 0);
        if (error)
                printk(KERN_WARNING "error: setting the clock returned: %s\n", 
                                ppc_rtas_process_error(error));
@@ -362,7 +362,7 @@ static ssize_t ppc_rtas_clock_write(struct file *file,
 static int ppc_rtas_clock_show(struct seq_file *m, void *v)
 {
        int ret[8];
-       int error = rtas_call(rtas_token("get-time-of-day"), 0, 8, ret);
+       int error = rtas_call(rtas_function_token(RTAS_FN_GET_TIME_OF_DAY), 0, 8, ret);
 
        if (error) {
                printk(KERN_WARNING "error: reading the clock returned: %s\n", 
@@ -385,7 +385,7 @@ static int ppc_rtas_sensors_show(struct seq_file *m, void *v)
 {
        int i,j;
        int state, error;
-       int get_sensor_state = rtas_token("get-sensor-state");
+       int get_sensor_state = rtas_function_token(RTAS_FN_GET_SENSOR_STATE);
 
        seq_printf(m, "RTAS (RunTime Abstraction Services) Sensor Information\n");
        seq_printf(m, "Sensor\t\tValue\t\tCondition\tLocation\n");
@@ -708,8 +708,8 @@ static ssize_t ppc_rtas_tone_freq_write(struct file *file,
                return error;
 
        rtas_tone_frequency = freq; /* save it for later */
-       error = rtas_call(rtas_token("set-indicator"), 3, 1, NULL,
-                       TONE_FREQUENCY, 0, freq);
+       error = rtas_call(rtas_function_token(RTAS_FN_SET_INDICATOR), 3, 1, NULL,
+                         TONE_FREQUENCY, 0, freq);
        if (error)
                printk(KERN_WARNING "error: setting tone frequency returned: %s\n", 
                                ppc_rtas_process_error(error));
@@ -736,8 +736,8 @@ static ssize_t ppc_rtas_tone_volume_write(struct file *file,
                volume = 100;
        
         rtas_tone_volume = volume; /* save it for later */
-       error = rtas_call(rtas_token("set-indicator"), 3, 1, NULL,
-                       TONE_VOLUME, 0, volume);
+       error = rtas_call(rtas_function_token(RTAS_FN_SET_INDICATOR), 3, 1, NULL,
+                         TONE_VOLUME, 0, volume);
        if (error)
                printk(KERN_WARNING "error: setting tone volume returned: %s\n", 
                                ppc_rtas_process_error(error));
index 5a31d18..6996214 100644 (file)
@@ -21,7 +21,7 @@ time64_t __init rtas_get_boot_time(void)
 
        max_wait_tb = get_tb() + tb_ticks_per_usec * 1000 * MAX_RTC_WAIT;
        do {
-               error = rtas_call(rtas_token("get-time-of-day"), 0, 8, ret);
+               error = rtas_call(rtas_function_token(RTAS_FN_GET_TIME_OF_DAY), 0, 8, ret);
 
                wait_time = rtas_busy_delay_time(error);
                if (wait_time) {
@@ -53,7 +53,7 @@ void rtas_get_rtc_time(struct rtc_time *rtc_tm)
 
        max_wait_tb = get_tb() + tb_ticks_per_usec * 1000 * MAX_RTC_WAIT;
        do {
-               error = rtas_call(rtas_token("get-time-of-day"), 0, 8, ret);
+               error = rtas_call(rtas_function_token(RTAS_FN_GET_TIME_OF_DAY), 0, 8, ret);
 
                wait_time = rtas_busy_delay_time(error);
                if (wait_time) {
@@ -90,7 +90,7 @@ int rtas_set_rtc_time(struct rtc_time *tm)
 
        max_wait_tb = get_tb() + tb_ticks_per_usec * 1000 * MAX_RTC_WAIT;
        do {
-               error = rtas_call(rtas_token("set-time-of-day"), 7, 1, NULL,
+               error = rtas_call(rtas_function_token(RTAS_FN_SET_TIME_OF_DAY), 7, 1, NULL,
                                  tm->tm_year + 1900, tm->tm_mon + 1,
                                  tm->tm_mday, tm->tm_hour, tm->tm_min,
                                  tm->tm_sec, 0);
index bb6f537..31175b3 100644 (file)
@@ -782,8 +782,8 @@ void rtas_progress(char *s, unsigned short hex)
                                        "ibm,display-truncation-length", NULL);
                        of_node_put(root);
                }
-               display_character = rtas_token("display-character");
-               set_indicator = rtas_token("set-indicator");
+               display_character = rtas_function_token(RTAS_FN_DISPLAY_CHARACTER);
+               set_indicator = rtas_function_token(RTAS_FN_SET_INDICATOR);
        }
 
        if (display_character == RTAS_UNKNOWN_SERVICE) {
@@ -937,7 +937,6 @@ static void __init init_error_log_max(void)
 
 
 static char rtas_err_buf[RTAS_ERROR_LOG_MAX];
-static int rtas_last_error_token;
 
 /** Return a copy of the detailed error text associated with the
  *  most recent failed call to rtas.  Because the error text
@@ -947,16 +946,17 @@ static int rtas_last_error_token;
  */
 static char *__fetch_rtas_last_error(char *altbuf)
 {
+       const s32 token = rtas_function_token(RTAS_FN_RTAS_LAST_ERROR);
        struct rtas_args err_args, save_args;
        u32 bufsz;
        char *buf = NULL;
 
-       if (rtas_last_error_token == -1)
+       if (token == -1)
                return NULL;
 
        bufsz = rtas_get_error_log_max();
 
-       err_args.token = cpu_to_be32(rtas_last_error_token);
+       err_args.token = cpu_to_be32(token);
        err_args.nargs = cpu_to_be32(2);
        err_args.nret = cpu_to_be32(1);
        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,
        va_end(list);
 }
 
-static int ibm_open_errinjct_token;
-static int ibm_errinjct_token;
+static bool token_is_restricted_errinjct(s32 token)
+{
+       return token == rtas_function_token(RTAS_FN_IBM_OPEN_ERRINJCT) ||
+              token == rtas_function_token(RTAS_FN_IBM_ERRINJCT);
+}
 
 /**
  * rtas_call() - Invoke an RTAS firmware function.
@@ -1098,7 +1101,7 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)
        if (!rtas.entry || token == RTAS_UNKNOWN_SERVICE)
                return -1;
 
-       if (token == ibm_open_errinjct_token || token == ibm_errinjct_token) {
+       if (token_is_restricted_errinjct(token)) {
                /*
                 * It would be nicer to not discard the error value
                 * from security_locked_down(), but callers expect an
@@ -1330,7 +1333,7 @@ static int rtas_error_rc(int rtas_rc)
 
 int rtas_get_power_level(int powerdomain, int *level)
 {
-       int token = rtas_token("get-power-level");
+       int token = rtas_function_token(RTAS_FN_GET_POWER_LEVEL);
        int rc;
 
        if (token == RTAS_UNKNOWN_SERVICE)
@@ -1347,7 +1350,7 @@ EXPORT_SYMBOL_GPL(rtas_get_power_level);
 
 int rtas_set_power_level(int powerdomain, int level, int *setlevel)
 {
-       int token = rtas_token("set-power-level");
+       int token = rtas_function_token(RTAS_FN_SET_POWER_LEVEL);
        int rc;
 
        if (token == RTAS_UNKNOWN_SERVICE)
@@ -1365,7 +1368,7 @@ EXPORT_SYMBOL_GPL(rtas_set_power_level);
 
 int rtas_get_sensor(int sensor, int index, int *state)
 {
-       int token = rtas_token("get-sensor-state");
+       int token = rtas_function_token(RTAS_FN_GET_SENSOR_STATE);
        int rc;
 
        if (token == RTAS_UNKNOWN_SERVICE)
@@ -1383,7 +1386,7 @@ EXPORT_SYMBOL_GPL(rtas_get_sensor);
 
 int rtas_get_sensor_fast(int sensor, int index, int *state)
 {
-       int token = rtas_token("get-sensor-state");
+       int token = rtas_function_token(RTAS_FN_GET_SENSOR_STATE);
        int rc;
 
        if (token == RTAS_UNKNOWN_SERVICE)
@@ -1425,7 +1428,7 @@ bool rtas_indicator_present(int token, int *maxindex)
 
 int rtas_set_indicator(int indicator, int index, int new_value)
 {
-       int token = rtas_token("set-indicator");
+       int token = rtas_function_token(RTAS_FN_SET_INDICATOR);
        int rc;
 
        if (token == RTAS_UNKNOWN_SERVICE)
@@ -1446,8 +1449,8 @@ EXPORT_SYMBOL_GPL(rtas_set_indicator);
  */
 int rtas_set_indicator_fast(int indicator, int index, int new_value)
 {
+       int token = rtas_function_token(RTAS_FN_SET_INDICATOR);
        int rc;
-       int token = rtas_token("set-indicator");
 
        if (token == RTAS_UNKNOWN_SERVICE)
                return -ENOENT;
@@ -1489,10 +1492,11 @@ int rtas_set_indicator_fast(int indicator, int index, int new_value)
  */
 int rtas_ibm_suspend_me(int *fw_status)
 {
+       int token = rtas_function_token(RTAS_FN_IBM_SUSPEND_ME);
        int fwrc;
        int ret;
 
-       fwrc = rtas_call(rtas_token("ibm,suspend-me"), 0, 1, NULL);
+       fwrc = rtas_call(token, 0, 1, NULL);
 
        switch (fwrc) {
        case 0:
@@ -1525,7 +1529,7 @@ void __noreturn rtas_restart(char *cmd)
        if (rtas_flash_term_hook)
                rtas_flash_term_hook(SYS_RESTART);
        pr_emerg("system-reboot returned %d\n",
-                rtas_call(rtas_token("system-reboot"), 0, 1, NULL));
+                rtas_call(rtas_function_token(RTAS_FN_SYSTEM_REBOOT), 0, 1, NULL));
        for (;;);
 }
 
@@ -1535,7 +1539,7 @@ void rtas_power_off(void)
                rtas_flash_term_hook(SYS_POWER_OFF);
        /* allow power on only with power button press */
        pr_emerg("power-off returned %d\n",
-                rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1));
+                rtas_call(rtas_function_token(RTAS_FN_POWER_OFF), 2, 1, NULL, -1, -1));
        for (;;);
 }
 
@@ -1545,16 +1549,17 @@ void __noreturn rtas_halt(void)
                rtas_flash_term_hook(SYS_HALT);
        /* allow power on only with power button press */
        pr_emerg("power-off returned %d\n",
-                rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1));
+                rtas_call(rtas_function_token(RTAS_FN_POWER_OFF), 2, 1, NULL, -1, -1));
        for (;;);
 }
 
 /* Must be in the RMO region, so we place it here */
 static char rtas_os_term_buf[2048];
-static s32 ibm_os_term_token = RTAS_UNKNOWN_SERVICE;
+static bool ibm_extended_os_term;
 
 void rtas_os_term(char *str)
 {
+       s32 token = rtas_function_token(RTAS_FN_IBM_OS_TERM);
        int status;
 
        /*
@@ -1563,7 +1568,8 @@ void rtas_os_term(char *str)
         * this property may terminate the partition which we want to avoid
         * since it interferes with panic_timeout.
         */
-       if (ibm_os_term_token == RTAS_UNKNOWN_SERVICE)
+
+       if (token == RTAS_UNKNOWN_SERVICE || !ibm_extended_os_term)
                return;
 
        snprintf(rtas_os_term_buf, 2048, "OS panic: %s", str);
@@ -1574,8 +1580,7 @@ void rtas_os_term(char *str)
         * schedules.
         */
        do {
-               status = rtas_call(ibm_os_term_token, 1, 1, NULL,
-                                  __pa(rtas_os_term_buf));
+               status = rtas_call(token, 1, 1, NULL, __pa(rtas_os_term_buf));
        } while (rtas_busy_delay_time(status));
 
        if (status != 0)
@@ -1595,10 +1600,9 @@ void rtas_os_term(char *str)
  */
 void rtas_activate_firmware(void)
 {
-       int token;
+       int token = rtas_function_token(RTAS_FN_IBM_ACTIVATE_FIRMWARE);
        int fwrc;
 
-       token = rtas_token("ibm,activate-firmware");
        if (token == RTAS_UNKNOWN_SERVICE) {
                pr_notice("ibm,activate-firmware method unavailable\n");
                return;
@@ -1684,6 +1688,8 @@ static bool block_rtas_call(int token, int nargs,
 {
        const struct rtas_function *func;
        const struct rtas_filter *f;
+       const bool is_platform_dump = token == rtas_function_token(RTAS_FN_IBM_PLATFORM_DUMP);
+       const bool is_config_conn = token == rtas_function_token(RTAS_FN_IBM_CONFIGURE_CONNECTOR);
        u32 base, size, end;
 
        /*
@@ -1720,8 +1726,7 @@ static bool block_rtas_call(int token, int nargs,
                 * Special case for ibm,platform-dump - NULL buffer
                 * address is used to indicate end of dump processing
                 */
-               if (!strcmp(func->name, "ibm,platform-dump") &&
-                   base == 0)
+               if (is_platform_dump && base == 0)
                        return false;
 
                if (!in_rmo_buf(base, end))
@@ -1742,8 +1747,7 @@ static bool block_rtas_call(int token, int nargs,
                 * Special case for ibm,configure-connector where the
                 * address can be 0
                 */
-               if (!strcmp(func->name, "ibm,configure-connector") &&
-                   base == 0)
+               if (is_config_conn && base == 0)
                        return false;
 
                if (!in_rmo_buf(base, end))
@@ -1798,7 +1802,7 @@ SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs)
        if (block_rtas_call(token, nargs, &args))
                return -EINVAL;
 
-       if (token == ibm_open_errinjct_token || token == ibm_errinjct_token) {
+       if (token_is_restricted_errinjct(token)) {
                int err;
 
                err = security_locked_down(LOCKDOWN_RTAS_ERROR_INJECTION);
@@ -1807,7 +1811,7 @@ SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs)
        }
 
        /* Need to handle ibm,suspend_me call specially */
-       if (token == rtas_token("ibm,suspend-me")) {
+       if (token == rtas_function_token(RTAS_FN_IBM_SUSPEND_ME)) {
 
                /*
                 * rtas_ibm_suspend_me assumes the streamid handle is in cpu
@@ -1942,11 +1946,10 @@ void __init rtas_initialize(void)
        rtas_function_table_init();
 
        /*
-        * Discover these now to avoid device tree lookups in the
+        * Discover this now to avoid a device tree lookup in the
         * panic path.
         */
-       if (of_property_read_bool(rtas.dev, "ibm,extended-os-term"))
-               ibm_os_term_token = rtas_token("ibm,os-term");
+       ibm_extended_os_term = of_property_read_bool(rtas.dev, "ibm,extended-os-term");
 
        /* If RTAS was found, allocate the RMO buffer for it and look for
         * the stop-self token if any
@@ -1961,12 +1964,6 @@ void __init rtas_initialize(void)
                panic("ERROR: RTAS: Failed to allocate %lx bytes below %pa\n",
                      PAGE_SIZE, &rtas_region);
 
-#ifdef CONFIG_RTAS_ERROR_LOGGING
-       rtas_last_error_token = rtas_token("rtas-last-error");
-#endif
-       ibm_open_errinjct_token = rtas_token("ibm,open-errinjct");
-       ibm_errinjct_token = rtas_token("ibm,errinjct");
-
        rtas_work_area_reserve_arena(rtas_region);
 }
 
@@ -2022,13 +2019,13 @@ void rtas_give_timebase(void)
 
        raw_spin_lock_irqsave(&timebase_lock, flags);
        hard_irq_disable();
-       rtas_call(rtas_token("freeze-time-base"), 0, 1, NULL);
+       rtas_call(rtas_function_token(RTAS_FN_FREEZE_TIME_BASE), 0, 1, NULL);
        timebase = get_tb();
        raw_spin_unlock(&timebase_lock);
 
        while (timebase)
                barrier();
-       rtas_call(rtas_token("thaw-time-base"), 0, 1, NULL);
+       rtas_call(rtas_function_token(RTAS_FN_THAW_TIME_BASE), 0, 1, NULL);
        local_irq_restore(flags);
 }
 
index bc817a5..4caf5e3 100644 (file)
@@ -376,7 +376,7 @@ static void manage_flash(struct rtas_manage_flash_t *args_buf, unsigned int op)
        s32 rc;
 
        do {
-               rc = rtas_call(rtas_token("ibm,manage-flash-image"), 1, 1,
+               rc = rtas_call(rtas_function_token(RTAS_FN_IBM_MANAGE_FLASH_IMAGE), 1, 1,
                               NULL, op);
        } while (rtas_busy_delay(rc));
 
@@ -444,7 +444,7 @@ error:
  */
 static void validate_flash(struct rtas_validate_flash_t *args_buf)
 {
-       int token = rtas_token("ibm,validate-flash-image");
+       int token = rtas_function_token(RTAS_FN_IBM_VALIDATE_FLASH_IMAGE);
        int update_results;
        s32 rc; 
 
@@ -570,7 +570,7 @@ static void rtas_flash_firmware(int reboot_type)
                return;
        }
 
-       update_token = rtas_token("ibm,update-flash-64-and-reboot");
+       update_token = rtas_function_token(RTAS_FN_IBM_UPDATE_FLASH_64_AND_REBOOT);
        if (update_token == RTAS_UNKNOWN_SERVICE) {
                printk(KERN_ALERT "FLASH: ibm,update-flash-64-and-reboot "
                       "is not available -- not a service partition?\n");
@@ -653,7 +653,7 @@ static void rtas_flash_firmware(int reboot_type)
  */
 struct rtas_flash_file {
        const char *filename;
-       const char *rtas_call_name;
+       const rtas_fn_handle_t handle;
        int *status;
        const struct proc_ops ops;
 };
@@ -661,7 +661,7 @@ struct rtas_flash_file {
 static const struct rtas_flash_file rtas_flash_files[] = {
        {
                .filename       = "powerpc/rtas/" FIRMWARE_FLASH_NAME,
-               .rtas_call_name = "ibm,update-flash-64-and-reboot",
+               .handle         = RTAS_FN_IBM_UPDATE_FLASH_64_AND_REBOOT,
                .status         = &rtas_update_flash_data.status,
                .ops.proc_read  = rtas_flash_read_msg,
                .ops.proc_write = rtas_flash_write,
@@ -670,7 +670,7 @@ static const struct rtas_flash_file rtas_flash_files[] = {
        },
        {
                .filename       = "powerpc/rtas/" FIRMWARE_UPDATE_NAME,
-               .rtas_call_name = "ibm,update-flash-64-and-reboot",
+               .handle         = RTAS_FN_IBM_UPDATE_FLASH_64_AND_REBOOT,
                .status         = &rtas_update_flash_data.status,
                .ops.proc_read  = rtas_flash_read_num,
                .ops.proc_write = rtas_flash_write,
@@ -679,7 +679,7 @@ static const struct rtas_flash_file rtas_flash_files[] = {
        },
        {
                .filename       = "powerpc/rtas/" VALIDATE_FLASH_NAME,
-               .rtas_call_name = "ibm,validate-flash-image",
+               .handle         = RTAS_FN_IBM_VALIDATE_FLASH_IMAGE,
                .status         = &rtas_validate_flash_data.status,
                .ops.proc_read  = validate_flash_read,
                .ops.proc_write = validate_flash_write,
@@ -688,7 +688,7 @@ static const struct rtas_flash_file rtas_flash_files[] = {
        },
        {
                .filename       = "powerpc/rtas/" MANAGE_FLASH_NAME,
-               .rtas_call_name = "ibm,manage-flash-image",
+               .handle         = RTAS_FN_IBM_MANAGE_FLASH_IMAGE,
                .status         = &rtas_manage_flash_data.status,
                .ops.proc_read  = manage_flash_read,
                .ops.proc_write = manage_flash_write,
@@ -700,8 +700,7 @@ static int __init rtas_flash_init(void)
 {
        int i;
 
-       if (rtas_token("ibm,update-flash-64-and-reboot") ==
-                      RTAS_UNKNOWN_SERVICE) {
+       if (rtas_function_token(RTAS_FN_IBM_UPDATE_FLASH_64_AND_REBOOT) == RTAS_UNKNOWN_SERVICE) {
                pr_info("rtas_flash: no firmware flash support\n");
                return -EINVAL;
        }
@@ -730,7 +729,7 @@ static int __init rtas_flash_init(void)
                 * This code assumes that the status int is the first member of the
                 * struct
                 */
-               token = rtas_token(f->rtas_call_name);
+               token = rtas_function_token(f->handle);
                if (token == RTAS_UNKNOWN_SERVICE)
                        *f->status = FLASH_AUTH;
                else
index 5a2f5ea..e1fdc74 100644 (file)
@@ -191,10 +191,10 @@ static void python_countermeasures(struct device_node *dev)
 
 void __init init_pci_config_tokens(void)
 {
-       read_pci_config = rtas_token("read-pci-config");
-       write_pci_config = rtas_token("write-pci-config");
-       ibm_read_pci_config = rtas_token("ibm,read-pci-config");
-       ibm_write_pci_config = rtas_token("ibm,write-pci-config");
+       read_pci_config = rtas_function_token(RTAS_FN_READ_PCI_CONFIG);
+       write_pci_config = rtas_function_token(RTAS_FN_WRITE_PCI_CONFIG);
+       ibm_read_pci_config = rtas_function_token(RTAS_FN_IBM_READ_PCI_CONFIG);
+       ibm_write_pci_config = rtas_function_token(RTAS_FN_IBM_WRITE_PCI_CONFIG);
 }
 
 unsigned long get_phb_buid(struct device_node *phb)
index cc56ac6..9bba469 100644 (file)
@@ -506,7 +506,7 @@ static int __init rtas_event_scan_init(void)
                return 0;
 
        /* No RTAS */
-       event_scan = rtas_token("event-scan");
+       event_scan = rtas_function_token(RTAS_FN_EVENT_SCAN);
        if (event_scan == RTAS_UNKNOWN_SERVICE) {
                printk(KERN_INFO "rtasd: No event-scan on system\n");
                return -ENODEV;
index e064772..61dfec7 100644 (file)
@@ -41,7 +41,7 @@ static int rtas_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
        int ret = -1;
        int rval;
 
-       rval = rtas_call(rtas_token("read-pci-config"), 2, 2, &ret, addr, len);
+       rval = rtas_call(rtas_function_token(RTAS_FN_READ_PCI_CONFIG), 2, 2, &ret, addr, len);
        *val = ret;
        return rval ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
 }
@@ -55,7 +55,7 @@ static int rtas_write_config(struct pci_bus *bus, unsigned int devfn,
            | (hose->global_number << 24);
        int rval;
 
-       rval = rtas_call(rtas_token("write-pci-config"), 3, 1, NULL,
+       rval = rtas_call(rtas_function_token(RTAS_FN_WRITE_PCI_CONFIG), 3, 1, NULL,
                         addr, len, val);
        return rval ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
 }
index 8d934ea..98db63b 100644 (file)
@@ -297,8 +297,8 @@ int cbe_sysreset_hack(void)
 static int __init cbe_ptcal_init(void)
 {
        int ret;
-       ptcal_start_tok = rtas_token("ibm,cbe-start-ptcal");
-       ptcal_stop_tok = rtas_token("ibm,cbe-stop-ptcal");
+       ptcal_start_tok = rtas_function_token(RTAS_FN_IBM_CBE_START_PTCAL);
+       ptcal_stop_tok = rtas_function_token(RTAS_FN_IBM_CBE_STOP_PTCAL);
 
        if (ptcal_start_tok == RTAS_UNKNOWN_SERVICE
                        || ptcal_stop_tok == RTAS_UNKNOWN_SERVICE)
index 31ce00b..30394c6 100644 (file)
@@ -81,7 +81,7 @@ static inline int smp_startup_cpu(unsigned int lcpu)
         * If the RTAS start-cpu token does not exist then presume the
         * cpu is already spinning.
         */
-       start_cpu = rtas_token("start-cpu");
+       start_cpu = rtas_function_token(RTAS_FN_START_CPU);
        if (start_cpu == RTAS_UNKNOWN_SERVICE)
                return 1;
 
@@ -152,7 +152,7 @@ void __init smp_init_cell(void)
        cpumask_clear_cpu(boot_cpuid, &of_spin_map);
 
        /* Non-lpar has additional take/give timebase */
-       if (rtas_token("freeze-time-base") != RTAS_UNKNOWN_SERVICE) {
+       if (rtas_function_token(RTAS_FN_FREEZE_TIME_BASE) != RTAS_UNKNOWN_SERVICE) {
                smp_ops->give_timebase = rtas_give_timebase;
                smp_ops->take_timebase = rtas_take_timebase;
        }
index dab7807..0eedae9 100644 (file)
@@ -31,7 +31,7 @@ static unsigned char chrp_nvram_read_val(int addr)
                return 0xff;
        }
        spin_lock_irqsave(&nvram_lock, flags);
-       if ((rtas_call(rtas_token("nvram-fetch"), 3, 2, &done, addr,
+       if ((rtas_call(rtas_function_token(RTAS_FN_NVRAM_FETCH), 3, 2, &done, addr,
                       __pa(nvram_buf), 1) != 0) || 1 != done)
                ret = 0xff;
        else
@@ -53,7 +53,7 @@ static void chrp_nvram_write_val(int addr, unsigned char val)
        }
        spin_lock_irqsave(&nvram_lock, flags);
        nvram_buf[0] = val;
-       if ((rtas_call(rtas_token("nvram-store"), 3, 2, &done, addr,
+       if ((rtas_call(rtas_function_token(RTAS_FN_NVRAM_STORE), 3, 2, &done, addr,
                       __pa(nvram_buf), 1) != 0) || 1 != done)
                printk(KERN_DEBUG "rtas IO error storing 0x%02x at %d", val, addr);
        spin_unlock_irqrestore(&nvram_lock, flags);
index 6f6598e..428fd2a 100644 (file)
@@ -104,7 +104,7 @@ static int rtas_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
         int ret = -1;
        int rval;
 
-       rval = rtas_call(rtas_token("read-pci-config"), 2, 2, &ret, addr, len);
+       rval = rtas_call(rtas_function_token(RTAS_FN_READ_PCI_CONFIG), 2, 2, &ret, addr, len);
        *val = ret;
        return rval? PCIBIOS_DEVICE_NOT_FOUND: PCIBIOS_SUCCESSFUL;
 }
@@ -118,7 +118,7 @@ static int rtas_write_config(struct pci_bus *bus, unsigned int devfn, int offset
                | (hose->global_number << 24);
        int rval;
 
-       rval = rtas_call(rtas_token("write-pci-config"), 3, 1, NULL,
+       rval = rtas_call(rtas_function_token(RTAS_FN_WRITE_PCI_CONFIG), 3, 1, NULL,
                         addr, len, val);
        return rval? PCIBIOS_DEVICE_NOT_FOUND: PCIBIOS_SUCCESSFUL;
 }
index ec63c05..d9049ce 100644 (file)
@@ -323,11 +323,11 @@ static void __init chrp_setup_arch(void)
        printk("chrp type = %x [%s]\n", _chrp_type, chrp_names[_chrp_type]);
 
        rtas_initialize();
-       if (rtas_token("display-character") >= 0)
+       if (rtas_function_token(RTAS_FN_DISPLAY_CHARACTER) >= 0)
                ppc_md.progress = rtas_progress;
 
        /* use RTAS time-of-day routines if available */
-       if (rtas_token("get-time-of-day") != RTAS_UNKNOWN_SERVICE) {
+       if (rtas_function_token(RTAS_FN_GET_TIME_OF_DAY) != RTAS_UNKNOWN_SERVICE) {
                ppc_md.get_boot_time    = rtas_get_boot_time;
                ppc_md.get_rtc_time     = rtas_get_rtc_time;
                ppc_md.set_rtc_time     = rtas_set_rtc_time;
index c26c379..98c8e36 100644 (file)
@@ -162,8 +162,8 @@ static struct smp_ops_t maple_smp_ops = {
 
 static void __init maple_use_rtas_reboot_and_halt_if_present(void)
 {
-       if (rtas_service_present("system-reboot") &&
-           rtas_service_present("power-off")) {
+       if (rtas_function_implemented(RTAS_FN_SYSTEM_REBOOT) &&
+           rtas_function_implemented(RTAS_FN_POWER_OFF)) {
                ppc_md.restart = rtas_restart;
                pm_power_off = rtas_power_off;
                ppc_md.halt = rtas_halt;
index 9b65b50..75ffdbc 100644 (file)
@@ -143,7 +143,7 @@ struct device_node *dlpar_configure_connector(__be32 drc_index,
        int cc_token;
        int rc = -1;
 
-       cc_token = rtas_token("ibm,configure-connector");
+       cc_token = rtas_function_token(RTAS_FN_IBM_CONFIGURE_CONNECTOR);
        if (cc_token == RTAS_UNKNOWN_SERVICE)
                return NULL;
 
index 6b507b6..def184d 100644 (file)
@@ -699,7 +699,7 @@ static int pseries_eeh_write_config(struct eeh_dev *edev, int where, int size, u
 static int pseries_send_allow_unfreeze(struct pci_dn *pdn, u16 *vf_pe_array, int cur_vfs)
 {
        int rc;
-       int ibm_allow_unfreeze = rtas_token("ibm,open-sriov-allow-unfreeze");
+       int ibm_allow_unfreeze = rtas_function_token(RTAS_FN_IBM_OPEN_SRIOV_ALLOW_UNFREEZE);
        unsigned long buid, addr;
 
        addr = rtas_config_addr(pdn->busno, pdn->devfn, 0);
@@ -774,7 +774,7 @@ static int pseries_notify_resume(struct eeh_dev *edev)
        if (!edev)
                return -EEXIST;
 
-       if (rtas_token("ibm,open-sriov-allow-unfreeze") == RTAS_UNKNOWN_SERVICE)
+       if (rtas_function_token(RTAS_FN_IBM_OPEN_SRIOV_ALLOW_UNFREEZE) == RTAS_UNKNOWN_SERVICE)
                return -EINVAL;
 
        if (edev->pdev->is_physfn || edev->pdev->is_virtfn)
@@ -815,14 +815,14 @@ static int __init eeh_pseries_init(void)
        int ret, config_addr;
 
        /* figure out EEH RTAS function call tokens */
-       ibm_set_eeh_option              = rtas_token("ibm,set-eeh-option");
-       ibm_set_slot_reset              = rtas_token("ibm,set-slot-reset");
-       ibm_read_slot_reset_state2      = rtas_token("ibm,read-slot-reset-state2");
-       ibm_read_slot_reset_state       = rtas_token("ibm,read-slot-reset-state");
-       ibm_slot_error_detail           = rtas_token("ibm,slot-error-detail");
-       ibm_get_config_addr_info2       = rtas_token("ibm,get-config-addr-info2");
-       ibm_get_config_addr_info        = rtas_token("ibm,get-config-addr-info");
-       ibm_configure_pe                = rtas_token("ibm,configure-pe");
+       ibm_set_eeh_option              = rtas_function_token(RTAS_FN_IBM_SET_EEH_OPTION);
+       ibm_set_slot_reset              = rtas_function_token(RTAS_FN_IBM_SET_SLOT_RESET);
+       ibm_read_slot_reset_state2      = rtas_function_token(RTAS_FN_IBM_READ_SLOT_RESET_STATE2);
+       ibm_read_slot_reset_state       = rtas_function_token(RTAS_FN_IBM_READ_SLOT_RESET_STATE);
+       ibm_slot_error_detail           = rtas_function_token(RTAS_FN_IBM_SLOT_ERROR_DETAIL);
+       ibm_get_config_addr_info2       = rtas_function_token(RTAS_FN_IBM_GET_CONFIG_ADDR_INFO2);
+       ibm_get_config_addr_info        = rtas_function_token(RTAS_FN_IBM_GET_CONFIG_ADDR_INFO);
+       ibm_configure_pe                = rtas_function_token(RTAS_FN_IBM_CONFIGURE_PE);
 
        /*
         * ibm,configure-pe and ibm,configure-bridge have the same semantics,
@@ -830,7 +830,7 @@ static int __init eeh_pseries_init(void)
         * ibm,configure-pe then fall back to using ibm,configure-bridge.
         */
        if (ibm_configure_pe == RTAS_UNKNOWN_SERVICE)
-               ibm_configure_pe        = rtas_token("ibm,configure-bridge");
+               ibm_configure_pe        = rtas_function_token(RTAS_FN_IBM_CONFIGURE_BRIDGE);
 
        /*
         * Necessary sanity check. We needn't check "get-config-addr-info"
index 090ae5a..982e5e4 100644 (file)
@@ -855,8 +855,8 @@ static int __init pseries_cpu_hotplug_init(void)
        ppc_md.cpu_release = dlpar_cpu_release;
 #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */
 
-       rtas_stop_self_token = rtas_token("stop-self");
-       qcss_tok = rtas_token("query-cpu-stopped-state");
+       rtas_stop_self_token = rtas_function_token(RTAS_FN_STOP_SELF);
+       qcss_tok = rtas_function_token(RTAS_FN_QUERY_CPU_STOPPED_STATE);
 
        if (rtas_stop_self_token == RTAS_UNKNOWN_SERVICE ||
                        qcss_tok == RTAS_UNKNOWN_SERVICE) {
index 7b74d4d..f411d4f 100644 (file)
@@ -143,7 +143,7 @@ static int __init ioei_init(void)
 {
        struct device_node *np;
 
-       ioei_check_exception_token = rtas_token("check-exception");
+       ioei_check_exception_token = rtas_function_token(RTAS_FN_CHECK_EXCEPTION);
        if (ioei_check_exception_token == RTAS_UNKNOWN_SERVICE)
                return -ENODEV;
 
index 4cea71a..643d309 100644 (file)
@@ -195,7 +195,7 @@ static int update_dt_node(struct device_node *dn, s32 scope)
        u32 nprops;
        u32 vd;
 
-       update_properties_token = rtas_token("ibm,update-properties");
+       update_properties_token = rtas_function_token(RTAS_FN_IBM_UPDATE_PROPERTIES);
        if (update_properties_token == RTAS_UNKNOWN_SERVICE)
                return -EINVAL;
 
@@ -306,7 +306,7 @@ static int pseries_devicetree_update(s32 scope)
        int update_nodes_token;
        int rc;
 
-       update_nodes_token = rtas_token("ibm,update-nodes");
+       update_nodes_token = rtas_function_token(RTAS_FN_IBM_UPDATE_NODES);
        if (update_nodes_token == RTAS_UNKNOWN_SERVICE)
                return 0;
 
index 3f05507..423ee1d 100644 (file)
@@ -679,8 +679,8 @@ static void rtas_msi_pci_irq_fixup(struct pci_dev *pdev)
 
 static int rtas_msi_init(void)
 {
-       query_token  = rtas_token("ibm,query-interrupt-source-number");
-       change_token = rtas_token("ibm,change-msi");
+       query_token  = rtas_function_token(RTAS_FN_IBM_QUERY_INTERRUPT_SOURCE_NUMBER);
+       change_token = rtas_function_token(RTAS_FN_IBM_CHANGE_MSI);
 
        if ((query_token == RTAS_UNKNOWN_SERVICE) ||
                        (change_token == RTAS_UNKNOWN_SERVICE)) {
index cbf1720..8130c37 100644 (file)
@@ -227,8 +227,8 @@ int __init pSeries_nvram_init(void)
 
        nvram_size = be32_to_cpup(nbytes_p);
 
-       nvram_fetch = rtas_token("nvram-fetch");
-       nvram_store = rtas_token("nvram-store");
+       nvram_fetch = rtas_function_token(RTAS_FN_NVRAM_FETCH);
+       nvram_store = rtas_function_token(RTAS_FN_NVRAM_STORE);
        printk(KERN_INFO "PPC64 nvram contains %d bytes\n", nvram_size);
        of_node_put(nvram);
 
index 2bb5c81..fedc615 100644 (file)
@@ -50,7 +50,7 @@ void papr_sysparm_buf_free(struct papr_sysparm_buf *buf)
 
 int papr_sysparm_get(papr_sysparm_t param, struct papr_sysparm_buf *buf)
 {
-       const s32 token = rtas_token("ibm,get-system-parameter");
+       const s32 token = rtas_function_token(RTAS_FN_IBM_GET_SYSTEM_PARAMETER);
        struct rtas_work_area *work_area;
        s32 fwrc;
        int ret;
@@ -102,7 +102,7 @@ int papr_sysparm_get(papr_sysparm_t param, struct papr_sysparm_buf *buf)
 
 int papr_sysparm_set(papr_sysparm_t param, const struct papr_sysparm_buf *buf)
 {
-       const s32 token = rtas_token("ibm,set-system-parameter");
+       const s32 token = rtas_function_token(RTAS_FN_IBM_SET_SYSTEM_PARAMETER);
        struct rtas_work_area *work_area;
        s32 fwrc;
        int ret;
index 6e671c3..60e0a58 100644 (file)
@@ -60,7 +60,7 @@ static int pseries_send_map_pe(struct pci_dev *pdev, u16 num_vfs,
        struct pci_dn *pdn;
        int rc;
        unsigned long buid, addr;
-       int ibm_map_pes = rtas_token("ibm,open-sriov-map-pe-number");
+       int ibm_map_pes = rtas_function_token(RTAS_FN_IBM_OPEN_SRIOV_MAP_PE_NUMBER);
 
        if (ibm_map_pes == RTAS_UNKNOWN_SERVICE)
                return -EINVAL;
index f12516c..adafd59 100644 (file)
@@ -155,7 +155,7 @@ static int __init init_ras_IRQ(void)
 {
        struct device_node *np;
 
-       ras_check_exception_token = rtas_token("check-exception");
+       ras_check_exception_token = rtas_function_token(RTAS_FN_CHECK_EXCEPTION);
 
        /* Internal Errors */
        np = of_find_node_by_path("/event-sources/internal-errors");
index 1ee6333..b37d52f 100644 (file)
@@ -203,7 +203,7 @@ void __init rtas_work_area_reserve_arena(const phys_addr_t limit)
         * So set up the arena if we find that, with a fallback to
         * ibm,configure-connector, just in case.
         */
-       if (rtas_service_present("ibm,get-system-parameter") ||
-           rtas_service_present("ibm,configure-connector"))
+       if (rtas_function_implemented(RTAS_FN_IBM_GET_SYSTEM_PARAMETER) ||
+           rtas_function_implemented(RTAS_FN_IBM_CONFIGURE_CONNECTOR))
                rwa_state.arena = memblock_alloc_try_nid(size, align, min, limit, nid);
 }
index 420a2fa..4a0cec8 100644 (file)
@@ -136,11 +136,11 @@ static void __init fwnmi_init(void)
 #endif
        int ibm_nmi_register_token;
 
-       ibm_nmi_register_token = rtas_token("ibm,nmi-register");
+       ibm_nmi_register_token = rtas_function_token(RTAS_FN_IBM_NMI_REGISTER);
        if (ibm_nmi_register_token == RTAS_UNKNOWN_SERVICE)
                return;
 
-       ibm_nmi_interlock_token = rtas_token("ibm,nmi-interlock");
+       ibm_nmi_interlock_token = rtas_function_token(RTAS_FN_IBM_NMI_INTERLOCK);
        if (WARN_ON(ibm_nmi_interlock_token == RTAS_UNKNOWN_SERVICE))
                return;
 
@@ -1071,14 +1071,14 @@ static void __init pseries_init(void)
 static void pseries_power_off(void)
 {
        int rc;
-       int rtas_poweroff_ups_token = rtas_token("ibm,power-off-ups");
+       int rtas_poweroff_ups_token = rtas_function_token(RTAS_FN_IBM_POWER_OFF_UPS);
 
        if (rtas_flash_term_hook)
                rtas_flash_term_hook(SYS_POWER_OFF);
 
        if (rtas_poweron_auto == 0 ||
                rtas_poweroff_ups_token == RTAS_UNKNOWN_SERVICE) {
-               rc = rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1);
+               rc = rtas_call(rtas_function_token(RTAS_FN_POWER_OFF), 2, 1, NULL, -1, -1);
                printk(KERN_INFO "RTAS power-off returned %d\n", rc);
        } else {
                rc = rtas_call(rtas_poweroff_ups_token, 0, 1, NULL);
index 2bcfee8..c597711 100644 (file)
@@ -55,7 +55,7 @@ static cpumask_var_t of_spin_mask;
 int smp_query_cpu_stopped(unsigned int pcpu)
 {
        int cpu_status, status;
-       int qcss_tok = rtas_token("query-cpu-stopped-state");
+       int qcss_tok = rtas_function_token(RTAS_FN_QUERY_CPU_STOPPED_STATE);
 
        if (qcss_tok == RTAS_UNKNOWN_SERVICE) {
                printk_once(KERN_INFO
@@ -108,7 +108,7 @@ static inline int smp_startup_cpu(unsigned int lcpu)
         * If the RTAS start-cpu token does not exist then presume the
         * cpu is already spinning.
         */
-       start_cpu = rtas_token("start-cpu");
+       start_cpu = rtas_function_token(RTAS_FN_START_CPU);
        if (start_cpu == RTAS_UNKNOWN_SERVICE)
                return 1;
 
@@ -266,7 +266,7 @@ void __init smp_init_pseries(void)
         * We know prom_init will not have started them if RTAS supports
         * query-cpu-stopped-state.
         */
-       if (rtas_token("query-cpu-stopped-state") == RTAS_UNKNOWN_SERVICE) {
+       if (rtas_function_token(RTAS_FN_QUERY_CPU_STOPPED_STATE) == RTAS_UNKNOWN_SERVICE) {
                if (cpu_has_feature(CPU_FTR_SMT)) {
                        for_each_present_cpu(i) {
                                if (cpu_thread_in_core(i) == 0)
index f8320f8..b772a83 100644 (file)
@@ -200,10 +200,10 @@ static struct ics ics_rtas = {
 
 __init int ics_rtas_init(void)
 {
-       ibm_get_xive = rtas_token("ibm,get-xive");
-       ibm_set_xive = rtas_token("ibm,set-xive");
-       ibm_int_on  = rtas_token("ibm,int-on");
-       ibm_int_off = rtas_token("ibm,int-off");
+       ibm_get_xive = rtas_function_token(RTAS_FN_IBM_GET_XIVE);
+       ibm_set_xive = rtas_function_token(RTAS_FN_IBM_SET_XIVE);
+       ibm_int_on  = rtas_function_token(RTAS_FN_IBM_INT_ON);
+       ibm_int_off = rtas_function_token(RTAS_FN_IBM_INT_OFF);
 
        /* We enable the RTAS "ICS" if RTAS is present with the
         * appropriate tokens
index 0da66bc..73c620c 100644 (file)
@@ -76,9 +76,6 @@ static cpumask_t xmon_batch_cpus = CPU_MASK_NONE;
 #define xmon_owner 0
 #endif /* CONFIG_SMP */
 
-#ifdef CONFIG_PPC_PSERIES
-static int set_indicator_token = RTAS_UNKNOWN_SERVICE;
-#endif
 static unsigned long in_xmon __read_mostly = 0;
 static int xmon_on = IS_ENABLED(CONFIG_XMON_DEFAULT);
 static bool xmon_is_ro = IS_ENABLED(CONFIG_XMON_DEFAULT_RO_MODE);
@@ -398,6 +395,7 @@ static inline void disable_surveillance(void)
 #ifdef CONFIG_PPC_PSERIES
        /* Since this can't be a module, args should end up below 4GB. */
        static struct rtas_args args;
+       const s32 token = rtas_function_token(RTAS_FN_SET_INDICATOR);
 
        /*
         * At this point we have got all the cpus we can into
@@ -406,10 +404,10 @@ static inline void disable_surveillance(void)
         * If we did try to take rtas.lock there would be a
         * real possibility of deadlock.
         */
-       if (set_indicator_token == RTAS_UNKNOWN_SERVICE)
+       if (token == RTAS_UNKNOWN_SERVICE)
                return;
 
-       rtas_call_unlocked(&args, set_indicator_token, 3, 1, NULL,
+       rtas_call_unlocked(&args, token, 3, 1, NULL,
                           SURVEILLANCE_TOKEN, 0, 0);
 
 #endif /* CONFIG_PPC_PSERIES */
@@ -3976,14 +3974,6 @@ static void xmon_init(int enable)
                __debugger_iabr_match = xmon_iabr_match;
                __debugger_break_match = xmon_break_match;
                __debugger_fault_handler = xmon_fault_handler;
-
-#ifdef CONFIG_PPC_PSERIES
-               /*
-                * Get the token here to avoid trying to get a lock
-                * during the crash, causing a deadlock.
-                */
-               set_indicator_token = rtas_token("set-indicator");
-#endif
        } else {
                __debugger = NULL;
                __debugger_ipi = NULL;