Lines Matching +full:long +full:- +full:press +full:- +full:ms

1 // SPDX-License-Identifier: GPL-2.0-or-later
49 void enter_rtas(unsigned long);
51 static inline void do_enter_rtas(unsigned long args) in do_enter_rtas()
53 unsigned long msr; in do_enter_rtas()
82 unsigned long rtas_rmo_buf;
85 * If non-NULL, this gets called when the kernel terminates.
96 static unsigned long lock_rtas(void) in lock_rtas()
98 unsigned long flags; in lock_rtas()
106 static void unlock_rtas(unsigned long flags) in unlock_rtas()
115 * are designed only for very early low-level debugging, which
116 * is why the token is hard-coded to 10.
120 unsigned long s; in call_rtas_display_status()
136 while (width-- > 0) in call_rtas_display_status_delay()
147 if (width--) { in call_rtas_display_status_delay()
192 return -1; in udbg_rtascon_getc_poll()
195 return -1; in udbg_rtascon_getc_poll()
204 while ((c = udbg_rtascon_getc_poll()) == -1) in udbg_rtascon_getc()
239 "ibm,display-line-length", NULL))) in rtas_progress()
242 "ibm,form-feed", NULL))) in rtas_progress()
245 "ibm,display-number-of-lines", NULL))) in rtas_progress()
248 "ibm,display-truncation-length", NULL); in rtas_progress()
251 display_character = rtas_token("display-character"); in rtas_progress()
252 set_indicator = rtas_token("set-indicator"); in rtas_progress()
300 if (current_line > display_lines-1) in rtas_progress()
301 current_line = display_lines-1; in rtas_progress()
306 /* RTAS wants CR-LF, not just LF */ in rtas_progress()
312 /* CR might be used to re-draw a line, so we'll in rtas_progress()
323 width--; in rtas_progress()
357 * Return the firmware-specified size of the error log buffer
359 * This includes 'check-exception' and 'rtas-last-error'.
367 rtas_error_log_max = rtas_token ("rtas-error-log-max"); in rtas_get_error_log_max()
394 if (rtas_last_error_token == -1) in __fetch_rtas_last_error()
444 args->token = cpu_to_be32(token); in va_rtas_call_unlocked()
445 args->nargs = cpu_to_be32(nargs); in va_rtas_call_unlocked()
446 args->nret = cpu_to_be32(nret); in va_rtas_call_unlocked()
447 args->rets = &(args->args[nargs]); in va_rtas_call_unlocked()
450 args->args[i] = cpu_to_be32(va_arg(list, __u32)); in va_rtas_call_unlocked()
453 args->rets[i] = 0; in va_rtas_call_unlocked()
474 unsigned long s; in rtas_call()
480 return -1; in rtas_call()
489 return -1; in rtas_call()
494 return -1; in rtas_call()
506 /* A -1 return code indicates that the last command couldn't in rtas_call()
508 if (be32_to_cpu(rtas_args->rets[0]) == -1) in rtas_call()
512 for (i = 0; i < nret-1; ++i) in rtas_call()
513 outputs[i] = be32_to_cpu(rtas_args->rets[i+1]); in rtas_call()
514 ret = (nret > 0)? be32_to_cpu(rtas_args->rets[0]): 0; in rtas_call()
528 * rtas_busy_delay_time() - From an RTAS status value, calculate the
537 * * 100000 - If @status is 9905.
538 * * 10000 - If @status is 9904.
539 * * 1000 - If @status is 9903.
540 * * 100 - If @status is 9902.
541 * * 10 - If @status is 9901.
542 * * 1 - If @status is either 9900 or -2. This is "wrong" for -2, but
545 * * 0 - If @status is not a busy or extended delay value.
550 unsigned int ms = 0; in rtas_busy_delay_time() local
553 ms = 1; in rtas_busy_delay_time()
556 order = status - RTAS_EXTENDED_DELAY_MIN; in rtas_busy_delay_time()
557 for (ms = 1; order > 0; order--) in rtas_busy_delay_time()
558 ms *= 10; in rtas_busy_delay_time()
561 return ms; in rtas_busy_delay_time()
566 * rtas_busy_delay() - helper for RTAS busy and extended delay statuses
574 * * true - @status is RTAS_BUSY or an extended delay hint. The
580 * * false - @status is not @RTAS_BUSY nor an extended delay hint. The
585 unsigned int ms; in rtas_busy_delay() local
591 ms = rtas_busy_delay_time(status); in rtas_busy_delay()
598 ms = clamp(ms, 1U, 1000U); in rtas_busy_delay()
600 * The delay hint is an order-of-magnitude suggestion, not in rtas_busy_delay()
606 * See Documentation/timers/timers-howto.rst for in rtas_busy_delay()
609 * 9902-9905. in rtas_busy_delay()
611 if (ms <= 20) in rtas_busy_delay()
612 usleep_range(ms * 100, ms * 1000); in rtas_busy_delay()
614 msleep(ms); in rtas_busy_delay()
644 case -1: /* Hardware Error */ in rtas_error_rc()
645 rc = -EIO; in rtas_error_rc()
647 case -3: /* Bad indicator/domain/etc */ in rtas_error_rc()
648 rc = -EINVAL; in rtas_error_rc()
650 case -9000: /* Isolation error */ in rtas_error_rc()
651 rc = -EFAULT; in rtas_error_rc()
653 case -9001: /* Outstanding TCE/PTE */ in rtas_error_rc()
654 rc = -EEXIST; in rtas_error_rc()
656 case -9002: /* No usable slot */ in rtas_error_rc()
657 rc = -ENODEV; in rtas_error_rc()
662 rc = -ERANGE; in rtas_error_rc()
670 int token = rtas_token("get-power-level"); in rtas_get_power_level()
674 return -ENOENT; in rtas_get_power_level()
687 int token = rtas_token("set-power-level"); in rtas_set_power_level()
691 return -ENOENT; in rtas_set_power_level()
705 int token = rtas_token("get-sensor-state"); in rtas_get_sensor()
709 return -ENOENT; in rtas_get_sensor()
723 int token = rtas_token("get-sensor-state"); in rtas_get_sensor_fast()
727 return -ENOENT; in rtas_get_sensor_fast()
746 indicators = of_get_property(rtas.dev, "rtas-indicators", &proplen); in rtas_indicator_present()
766 int token = rtas_token("set-indicator"); in rtas_set_indicator()
770 return -ENOENT; in rtas_set_indicator()
788 int token = rtas_token("set-indicator"); in rtas_set_indicator_fast()
791 return -ENOENT; in rtas_set_indicator_fast()
805 * rtas_ibm_suspend_me() - Call ibm,suspend-me to suspend the LPAR.
821 * 0 - The partition has resumed from suspend, possibly after
823 * -ECANCELED - The operation was aborted.
824 * -EAGAIN - There were other CPUs not in H_JOIN at the time of the call.
825 * -EBUSY - Some other condition prevented the suspend from succeeding.
826 * -EIO - Hardware/platform error.
833 fwrc = rtas_call(rtas_token("ibm,suspend-me"), 0, 1, NULL); in rtas_ibm_suspend_me()
840 ret = -ECANCELED; in rtas_ibm_suspend_me()
843 ret = -EAGAIN; in rtas_ibm_suspend_me()
847 ret = -EBUSY; in rtas_ibm_suspend_me()
849 case -1: in rtas_ibm_suspend_me()
851 ret = -EIO; in rtas_ibm_suspend_me()
865 printk("RTAS system-reboot returned %d\n", in rtas_restart()
866 rtas_call(rtas_token("system-reboot"), 0, 1, NULL)); in rtas_restart()
874 /* allow power on only with power button press */ in rtas_power_off()
875 printk("RTAS power-off returned %d\n", in rtas_power_off()
876 rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1)); in rtas_power_off()
884 /* allow power on only with power button press */ in rtas_halt()
885 printk("RTAS power-off returned %d\n", in rtas_halt()
886 rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1)); in rtas_halt()
898 * Firmware with the ibm,extended-os-term property is guaranteed in rtas_os_term()
899 * to always return from an ibm,os-term call. Earlier versions without in rtas_os_term()
903 if (RTAS_UNKNOWN_SERVICE == rtas_token("ibm,os-term") || in rtas_os_term()
904 RTAS_UNKNOWN_SERVICE == rtas_token("ibm,extended-os-term")) in rtas_os_term()
910 status = rtas_call(rtas_token("ibm,os-term"), 1, 1, NULL, in rtas_os_term()
915 printk(KERN_EMERG "ibm,os-term call failed %d\n", status); in rtas_os_term()
919 * rtas_activate_firmware() - Activate a new version of firmware.
934 token = rtas_token("ibm,activate-firmware"); in rtas_activate_firmware()
936 pr_notice("ibm,activate-firmware method unavailable\n"); in rtas_activate_firmware()
945 pr_err("ibm,activate-firmware failed (%i)\n", fwrc); in rtas_activate_firmware()
949 * get_pseries_errorlog() - Find a specific pseries error log in an RTAS
960 (struct rtas_ext_event_log_v6 *)log->buffer; in get_pseries_errorlog()
973 log_end = log->buffer + ext_log_length; in get_pseries_errorlog()
974 p = ext_log->vendor_log; in get_pseries_errorlog()
1008 /* Indexes into the args buffer, -1 if not used */
1018 { "ibm,activate-firmware", -1, -1, -1, -1, -1 },
1019 { "ibm,configure-connector", -1, 0, -1, 1, -1, 4096 }, /* Special cased */
1020 { "display-character", -1, -1, -1, -1, -1 },
1021 { "ibm,display-message", -1, 0, -1, -1, -1 },
1022 { "ibm,errinjct", -1, 2, -1, -1, -1, 1024 },
1023 { "ibm,close-errinjct", -1, -1, -1, -1, -1 },
1024 { "ibm,open-errinjct", -1, -1, -1, -1, -1 },
1025 { "ibm,get-config-addr-info2", -1, -1, -1, -1, -1 },
1026 { "ibm,get-dynamic-sensor-state", -1, 1, -1, -1, -1 },
1027 { "ibm,get-indices", -1, 2, 3, -1, -1 },
1028 { "get-power-level", -1, -1, -1, -1, -1 },
1029 { "get-sensor-state", -1, -1, -1, -1, -1 },
1030 { "ibm,get-system-parameter", -1, 1, 2, -1, -1 },
1031 { "get-time-of-day", -1, -1, -1, -1, -1 },
1032 { "ibm,get-vpd", -1, 0, -1, 1, 2 },
1033 { "ibm,lpar-perftools", -1, 2, 3, -1, -1 },
1034 { "ibm,platform-dump", -1, 4, 5, -1, -1 }, /* Special cased */
1035 { "ibm,read-slot-reset-state", -1, -1, -1, -1, -1 },
1036 { "ibm,scan-log-dump", -1, 0, 1, -1, -1 },
1037 { "ibm,set-dynamic-indicator", -1, 2, -1, -1, -1 },
1038 { "ibm,set-eeh-option", -1, -1, -1, -1, -1 },
1039 { "set-indicator", -1, -1, -1, -1, -1 },
1040 { "set-power-level", -1, -1, -1, -1, -1 },
1041 { "set-time-for-power-on", -1, -1, -1, -1, -1 },
1042 { "ibm,set-system-parameter", -1, 1, -1, -1, -1 },
1043 { "set-time-of-day", -1, -1, -1, -1, -1 },
1045 { "ibm,suspend-me", -1, -1, -1, -1, -1 },
1046 { "ibm,update-nodes", -1, 0, -1, -1, -1, 4096 },
1047 { "ibm,update-properties", -1, 0, -1, -1, -1, 4096 },
1049 { "ibm,physical-attestation", -1, 0, 1, -1, -1 },
1070 if (token != f->token) in block_rtas_call()
1073 if (f->buf_idx1 != -1) { in block_rtas_call()
1074 base = be32_to_cpu(args->args[f->buf_idx1]); in block_rtas_call()
1075 if (f->size_idx1 != -1) in block_rtas_call()
1076 size = be32_to_cpu(args->args[f->size_idx1]); in block_rtas_call()
1077 else if (f->fixed_size) in block_rtas_call()
1078 size = f->fixed_size; in block_rtas_call()
1082 end = base + size - 1; in block_rtas_call()
1085 * Special case for ibm,platform-dump - NULL buffer in block_rtas_call()
1088 if (!strcmp(f->name, "ibm,platform-dump") && in block_rtas_call()
1096 if (f->buf_idx2 != -1) { in block_rtas_call()
1097 base = be32_to_cpu(args->args[f->buf_idx2]); in block_rtas_call()
1098 if (f->size_idx2 != -1) in block_rtas_call()
1099 size = be32_to_cpu(args->args[f->size_idx2]); in block_rtas_call()
1100 else if (f->fixed_size) in block_rtas_call()
1101 size = f->fixed_size; in block_rtas_call()
1104 end = base + size - 1; in block_rtas_call()
1107 * Special case for ibm,configure-connector where the in block_rtas_call()
1110 if (!strcmp(f->name, "ibm,configure-connector") && in block_rtas_call()
1122 pr_err_ratelimited("sys_rtas: RTAS call blocked - exploit attempt?\n"); in block_rtas_call()
1124 token, nargs, current->comm); in block_rtas_call()
1154 unsigned long flags; in SYSCALL_DEFINE1()
1159 return -EPERM; in SYSCALL_DEFINE1()
1162 return -EINVAL; in SYSCALL_DEFINE1()
1165 return -EFAULT; in SYSCALL_DEFINE1()
1174 return -EINVAL; in SYSCALL_DEFINE1()
1177 if (copy_from_user(args.args, uargs->args, in SYSCALL_DEFINE1()
1179 return -EFAULT; in SYSCALL_DEFINE1()
1182 return -EINVAL; in SYSCALL_DEFINE1()
1188 return -EINVAL; in SYSCALL_DEFINE1()
1199 if (token == rtas_token("ibm,suspend-me")) { in SYSCALL_DEFINE1()
1209 if (rc == -EAGAIN) in SYSCALL_DEFINE1()
1211 else if (rc == -EIO) in SYSCALL_DEFINE1()
1212 args.rets[0] = cpu_to_be32(-1); in SYSCALL_DEFINE1()
1226 /* A -1 return code indicates that the last command couldn't in SYSCALL_DEFINE1()
1228 if (be32_to_cpu(args.rets[0]) == -1) in SYSCALL_DEFINE1()
1241 if (copy_to_user(uargs->args + nargs, in SYSCALL_DEFINE1()
1244 return -EFAULT; in SYSCALL_DEFINE1()
1251 * information from the device-tree and allocate the RMO buffer for userland
1256 unsigned long rtas_region = RTAS_INSTANTIATE_MAX; in rtas_initialize()
1267 no_base = of_property_read_u32(rtas.dev, "linux,rtas-base", &base); in rtas_initialize()
1268 no_size = of_property_read_u32(rtas.dev, "rtas-size", &size); in rtas_initialize()
1277 no_entry = of_property_read_u32(rtas.dev, "linux,rtas-entry", &entry); in rtas_initialize()
1281 * the stop-self token if any in rtas_initialize()
1294 rtas_last_error_token = rtas_token("rtas-last-error"); in rtas_initialize()
1296 ibm_open_errinjct_token = rtas_token("ibm,open-errinjct"); in rtas_initialize()
1301 int __init early_init_dt_scan_rtas(unsigned long node, in early_init_dt_scan_rtas()
1309 basep = of_get_flat_dt_prop(node, "linux,rtas-base", NULL); in early_init_dt_scan_rtas()
1310 entryp = of_get_flat_dt_prop(node, "linux,rtas-entry", NULL); in early_init_dt_scan_rtas()
1311 sizep = of_get_flat_dt_prop(node, "rtas-size", NULL); in early_init_dt_scan_rtas()
1315 if (of_get_flat_dt_prop(node, "ibm,hypertas-functions", NULL)) in early_init_dt_scan_rtas()
1326 basep = of_get_flat_dt_prop(node, "put-term-char", NULL); in early_init_dt_scan_rtas()
1330 basep = of_get_flat_dt_prop(node, "get-term-char", NULL); in early_init_dt_scan_rtas()
1349 unsigned long flags; in rtas_give_timebase()
1354 rtas_call(rtas_token("freeze-time-base"), 0, 1, NULL); in rtas_give_timebase()
1360 rtas_call(rtas_token("thaw-time-base"), 0, 1, NULL); in rtas_give_timebase()