Lines Matching +full:- +full:- +full:retry +full:- +full:delay
1 // SPDX-License-Identifier: GPL-2.0-or-later
14 #include <linux/delay.h>
36 #include <asm/delay.h>
42 #include <asm/rtas-work-area.h>
49 /* Indexes into the args buffer, -1 if not used */
62 * struct rtas_function - Descriptor for RTAS functions.
66 * @filter: If non-NULL, invoking this function via the rtas syscall is
75 * @lock: Pointer to an optional dedicated per-function mutex. This
92 * Per-function locks for sequence-based RTAS functions.
106 .name = "check-exception",
109 .name = "display-character",
111 .buf_idx1 = -1, .size_idx1 = -1,
112 .buf_idx2 = -1, .size_idx2 = -1,
116 .name = "event-scan",
119 .name = "freeze-time-base",
122 .name = "get-power-level",
124 .buf_idx1 = -1, .size_idx1 = -1,
125 .buf_idx2 = -1, .size_idx2 = -1,
129 .name = "get-sensor-state",
131 .buf_idx1 = -1, .size_idx1 = -1,
132 .buf_idx2 = -1, .size_idx2 = -1,
136 .name = "get-term-char",
139 .name = "get-time-of-day",
141 .buf_idx1 = -1, .size_idx1 = -1,
142 .buf_idx2 = -1, .size_idx2 = -1,
146 .name = "ibm,activate-firmware",
148 .buf_idx1 = -1, .size_idx1 = -1,
149 .buf_idx2 = -1, .size_idx2 = -1,
160 .name = "ibm,cbe-start-ptcal",
163 .name = "ibm,cbe-stop-ptcal",
166 .name = "ibm,change-msi",
169 .name = "ibm,close-errinjct",
171 .buf_idx1 = -1, .size_idx1 = -1,
172 .buf_idx2 = -1, .size_idx2 = -1,
176 .name = "ibm,configure-bridge",
179 .name = "ibm,configure-connector",
181 .buf_idx1 = 0, .size_idx1 = -1,
182 .buf_idx2 = 1, .size_idx2 = -1,
187 .name = "ibm,configure-kernel-dump",
190 .name = "ibm,configure-pe",
193 .name = "ibm,create-pe-dma-window",
196 .name = "ibm,display-message",
198 .buf_idx1 = 0, .size_idx1 = -1,
199 .buf_idx2 = -1, .size_idx2 = -1,
205 .buf_idx1 = 2, .size_idx1 = -1,
206 .buf_idx2 = -1, .size_idx2 = -1,
214 .name = "ibm,get-config-addr-info",
217 .name = "ibm,get-config-addr-info2",
219 .buf_idx1 = -1, .size_idx1 = -1,
220 .buf_idx2 = -1, .size_idx2 = -1,
224 .name = "ibm,get-dynamic-sensor-state",
226 .buf_idx1 = 1, .size_idx1 = -1,
227 .buf_idx2 = -1, .size_idx2 = -1,
231 * must not call ibm,get-dynamic-sensor-state with
232 * different inputs until a non-retry status has been
238 .name = "ibm,get-indices",
241 .buf_idx2 = -1, .size_idx2 = -1,
245 * interleave ibm,get-indices call sequences with
251 .name = "ibm,get-rio-topology",
254 .name = "ibm,get-system-parameter",
257 .buf_idx2 = -1, .size_idx2 = -1,
261 .name = "ibm,get-vpd",
263 .buf_idx1 = 0, .size_idx1 = -1,
273 .name = "ibm,get-xive",
276 .name = "ibm,int-off",
279 .name = "ibm,int-on",
282 .name = "ibm,io-quiesce-ack",
285 .name = "ibm,lpar-perftools",
288 .buf_idx2 = -1, .size_idx2 = -1,
297 .name = "ibm,manage-flash-image",
300 .name = "ibm,manage-storage-preservation",
303 .name = "ibm,nmi-interlock",
306 .name = "ibm,nmi-register",
309 .name = "ibm,open-errinjct",
311 .buf_idx1 = -1, .size_idx1 = -1,
312 .buf_idx2 = -1, .size_idx2 = -1,
316 .name = "ibm,open-sriov-allow-unfreeze",
319 .name = "ibm,open-sriov-map-pe-number",
322 .name = "ibm,os-term",
325 .name = "ibm,partner-control",
328 .name = "ibm,physical-attestation",
331 .buf_idx2 = -1, .size_idx2 = -1,
334 * This follows a sequence-based pattern similar to
335 * ibm,get-vpd et al. Since PAPR+ restricts
343 .name = "ibm,platform-dump",
346 .buf_idx2 = -1, .size_idx2 = -1,
350 * sequences of ibm,platform-dump are allowed if they
353 * reconsideration if kernel-internal users appear.
357 .name = "ibm,power-off-ups",
360 .name = "ibm,query-interrupt-source-number",
363 .name = "ibm,query-pe-dma-window",
366 .name = "ibm,read-pci-config",
369 .name = "ibm,read-slot-reset-state",
371 .buf_idx1 = -1, .size_idx1 = -1,
372 .buf_idx2 = -1, .size_idx2 = -1,
376 .name = "ibm,read-slot-reset-state2",
379 .name = "ibm,receive-hvpipe-msg",
382 .buf_idx2 = -1, .size_idx2 = -1,
390 .name = "ibm,remove-pe-dma-window",
395 * "ibm,reset-pe-dma-windows" (plural), but RTAS
398 .name = "ibm,reset-pe-dma-window",
401 .name = "ibm,scan-log-dump",
404 .buf_idx2 = -1, .size_idx2 = -1,
408 .name = "ibm,send-hvpipe-msg",
410 .buf_idx1 = 1, .size_idx1 = -1,
411 .buf_idx2 = -1, .size_idx2 = -1,
419 .name = "ibm,set-dynamic-indicator",
421 .buf_idx1 = 2, .size_idx1 = -1,
422 .buf_idx2 = -1, .size_idx2 = -1,
427 * non-retry status has been returned.
432 .name = "ibm,set-eeh-option",
434 .buf_idx1 = -1, .size_idx1 = -1,
435 .buf_idx2 = -1, .size_idx2 = -1,
439 .name = "ibm,set-slot-reset",
442 .name = "ibm,set-system-parameter",
444 .buf_idx1 = 1, .size_idx1 = -1,
445 .buf_idx2 = -1, .size_idx2 = -1,
449 .name = "ibm,set-xive",
452 .name = "ibm,slot-error-detail",
455 .name = "ibm,suspend-me",
458 .buf_idx1 = -1, .size_idx1 = -1,
459 .buf_idx2 = -1, .size_idx2 = -1,
463 .name = "ibm,tune-dma-parms",
466 .name = "ibm,update-flash-64-and-reboot",
469 .name = "ibm,update-nodes",
472 .buf_idx1 = 0, .size_idx1 = -1,
473 .buf_idx2 = -1, .size_idx2 = -1,
478 .name = "ibm,update-properties",
481 .buf_idx1 = 0, .size_idx1 = -1,
482 .buf_idx2 = -1, .size_idx2 = -1,
487 .name = "ibm,validate-flash-image",
490 .name = "ibm,write-pci-config",
493 .name = "nvram-fetch",
496 .name = "nvram-store",
499 .name = "power-off",
502 .name = "put-term-char",
505 .name = "query-cpu-stopped-state",
508 .name = "read-pci-config",
511 .name = "rtas-last-error",
514 .name = "set-indicator",
516 .buf_idx1 = -1, .size_idx1 = -1,
517 .buf_idx2 = -1, .size_idx2 = -1,
521 .name = "set-power-level",
523 .buf_idx1 = -1, .size_idx1 = -1,
524 .buf_idx2 = -1, .size_idx2 = -1,
528 .name = "set-time-for-power-on",
530 .buf_idx1 = -1, .size_idx1 = -1,
531 .buf_idx2 = -1, .size_idx2 = -1,
535 .name = "set-time-of-day",
537 .buf_idx1 = -1, .size_idx1 = -1,
538 .buf_idx2 = -1, .size_idx2 = -1,
542 .name = "start-cpu",
545 .name = "stop-self",
548 .name = "system-reboot",
551 .name = "thaw-time-base",
554 .name = "write-pci-config",
567 * Exceptions to the RTAS serialization requirement (e.g. stop-self)
574 * rtas_function_token() - RTAS function token lookup.
589 * Various drivers attempt token lookups on non-RTAS in rtas_function_token()
604 return strcmp(f1->name, f2->name); in rtas_function_cmp()
608 * Boot-time initialization of the function table needs the lookup to
609 * return a non-const-qualified object. Use rtas_name_to_function()
638 const s32 token = func->token; in rtas_token_to_function_xarray_init()
664 * known-good token value in contexts where the former is not already
684 if (func->token == token) in rtas_token_to_function()
704 const struct rtas_function *func = rtas_token_to_function(be32_to_cpu(args->token)); in __do_enter_rtas_trace()
707 * If there is a per-function lock, it must be held by the in __do_enter_rtas_trace()
710 if (func->lock) in __do_enter_rtas_trace()
711 lockdep_assert_held(func->lock); in __do_enter_rtas_trace()
716 trace_rtas_input(args, func->name); in __do_enter_rtas_trace()
722 trace_rtas_output(args, func->name); in __do_enter_rtas_trace()
733 * i.e. we're about to call stop-self. The tracepoints' in do_enter_rtas()
738 * 2. In real mode, as when invoking ibm,nmi-interlock from in do_enter_rtas()
773 * If non-NULL, this gets called when the kernel terminates.
781 * are designed only for very early low-level debugging, which
782 * is why the token is hard-coded to 10.
802 while (width-- > 0) in call_rtas_display_status_delay()
813 if (width--) { in call_rtas_display_status_delay()
845 "ibm,display-line-length", NULL))) in rtas_progress()
848 "ibm,form-feed", NULL))) in rtas_progress()
851 "ibm,display-number-of-lines", NULL))) in rtas_progress()
854 "ibm,display-truncation-length", NULL); in rtas_progress()
906 if (current_line > display_lines-1) in rtas_progress()
907 current_line = display_lines-1; in rtas_progress()
912 /* RTAS wants CR-LF, not just LF */ in rtas_progress()
918 /* CR might be used to re-draw a line, so we'll in rtas_progress()
929 width--; in rtas_progress()
955 return func->token; in rtas_token()
960 * access non-function properties of the /rtas node. Warn and in rtas_token()
976 * Return the firmware-specified size of the error log buffer
978 * This includes 'check-exception' and 'rtas-last-error'.
987 static const char propname[] __initconst = "rtas-error-log-max"; in init_error_log_max()
1023 if (token == -1) in __fetch_rtas_last_error()
1074 args->token = cpu_to_be32(token); in va_rtas_call_unlocked()
1075 args->nargs = cpu_to_be32(nargs); in va_rtas_call_unlocked()
1076 args->nret = cpu_to_be32(nret); in va_rtas_call_unlocked()
1077 args->rets = &(args->args[nargs]); in va_rtas_call_unlocked()
1080 args->args[i] = cpu_to_be32(va_arg(list, __u32)); in va_rtas_call_unlocked()
1083 args->rets[i] = 0; in va_rtas_call_unlocked()
1089 * rtas_call_unlocked() - Invoke an RTAS firmware function without synchronization.
1103 * time. Examples include stop-self and ibm,nmi-interlock.
1121 * rtas_call() - Invoke an RTAS firmware function.
1137 * -2 or 990x should use rtas_busy_delay() to correctly handle those
1148 * * 0 - RTAS function call succeeded.
1149 * * -1 - RTAS function encountered a hardware or
1152 * * -2 - Specs say "A necessary hardware device was busy,
1162 * * -3 - Parameter error.
1163 * * -7 - Unexpected state change.
1164 * * 9000...9899 - Vendor-specific success codes.
1165 * * 9900...9905 - Advisory extended delay. Caller should try
1167 * the last digit of the status [0-5]. Again going
1169 * contention for RTAS-internal resources. Other
1173 * * -9000 - Multi-level isolation error.
1174 * * -9999...-9004 - Vendor-specific error codes.
1175 * * Additional negative values - Function-specific error.
1176 * * Additional positive values - Function-specific success.
1189 return -1; in rtas_call()
1198 return -1; in rtas_call()
1203 return -1; in rtas_call()
1216 /* A -1 return code indicates that the last command couldn't in rtas_call()
1218 if (be32_to_cpu(args->rets[0]) == -1) in rtas_call()
1222 for (i = 0; i < nret-1; ++i) in rtas_call()
1223 outputs[i] = be32_to_cpu(args->rets[i + 1]); in rtas_call()
1224 ret = (nret > 0) ? be32_to_cpu(args->rets[0]) : 0; in rtas_call()
1239 * rtas_busy_delay_time() - From an RTAS status value, calculate the
1240 * suggested delay time in milliseconds.
1248 * * 100000 - If @status is 9905.
1249 * * 10000 - If @status is 9904.
1250 * * 1000 - If @status is 9903.
1251 * * 100 - If @status is 9902.
1252 * * 10 - If @status is 9901.
1253 * * 1 - If @status is either 9900 or -2. This is "wrong" for -2, but
1255 * is that they will delay for longer than necessary.
1256 * * 0 - If @status is not a busy or extended delay value.
1267 order = status - RTAS_EXTENDED_DELAY_MIN; in rtas_busy_delay_time()
1268 for (ms = 1; order > 0; order--) in rtas_busy_delay_time()
1281 bool retry; in rtas_busy_delay_early() local
1287 * delay status in early boot, the OS is probably not in rtas_busy_delay_early()
1289 * the condition. Best we can do is delay for a bit in rtas_busy_delay_early()
1291 * seems like we're stuck in a retry loop. in rtas_busy_delay_early()
1294 retry = true; in rtas_busy_delay_early()
1299 retry = false; in rtas_busy_delay_early()
1304 retry = true; in rtas_busy_delay_early()
1308 retry = false; in rtas_busy_delay_early()
1313 return retry; in rtas_busy_delay_early()
1317 * rtas_busy_delay() - helper for RTAS busy and extended delay statuses
1325 * * true - @status is RTAS_BUSY or an extended delay hint. The
1327 * and that an appropriate delay for @status has elapsed.
1331 * * false - @status is not @RTAS_BUSY nor an extended delay hint. The
1350 * The extended delay hint can be as high as 100 seconds. in rtas_busy_delay()
1357 * The delay hint is an order-of-magnitude suggestion, not a in rtas_busy_delay()
1377 * Not a busy or extended delay status; the caller should in rtas_busy_delay()
1395 rc = -EIO; in rtas_error_rc()
1398 rc = -EINVAL; in rtas_error_rc()
1400 case -9000: /* Isolation error */ in rtas_error_rc()
1401 rc = -EFAULT; in rtas_error_rc()
1403 case -9001: /* Outstanding TCE/PTE */ in rtas_error_rc()
1404 rc = -EEXIST; in rtas_error_rc()
1406 case -9002: /* No usable slot */ in rtas_error_rc()
1407 rc = -ENODEV; in rtas_error_rc()
1411 rc = -ERANGE; in rtas_error_rc()
1424 return -ENOENT; in rtas_get_power_level()
1441 return -ENOENT; in rtas_set_power_level()
1459 return -ENOENT; in rtas_get_sensor()
1477 return -ENOENT; in rtas_get_sensor_fast()
1496 indicators = of_get_property(rtas.dev, "rtas-indicators", &proplen); in rtas_indicator_present()
1519 return -ENOENT; in rtas_set_indicator()
1532 * Ignoring RTAS extended delay
1540 return -ENOENT; in rtas_set_indicator_fast()
1554 * rtas_ibm_suspend_me() - Call ibm,suspend-me to suspend the LPAR.
1566 * Callers may choose to retry this call if @fw_status is
1570 * 0 - The partition has resumed from suspend, possibly after
1572 * -ECANCELED - The operation was aborted.
1573 * -EAGAIN - There were other CPUs not in H_JOIN at the time of the call.
1574 * -EBUSY - Some other condition prevented the suspend from succeeding.
1575 * -EIO - Hardware/platform error.
1590 ret = -ECANCELED; in rtas_ibm_suspend_me()
1593 ret = -EAGAIN; in rtas_ibm_suspend_me()
1597 ret = -EBUSY; in rtas_ibm_suspend_me()
1599 case -1: in rtas_ibm_suspend_me()
1601 ret = -EIO; in rtas_ibm_suspend_me()
1615 pr_emerg("system-reboot returned %d\n", in rtas_restart()
1625 pr_emerg("power-off returned %d\n", in rtas_power_off()
1626 rtas_call(rtas_function_token(RTAS_FN_POWER_OFF), 2, 1, NULL, -1, -1)); in rtas_power_off()
1635 pr_emerg("power-off returned %d\n", in rtas_halt()
1636 rtas_call(rtas_function_token(RTAS_FN_POWER_OFF), 2, 1, NULL, -1, -1)); in rtas_halt()
1651 * Firmware with the ibm,extended-os-term property is guaranteed in rtas_os_term()
1652 * to always return from an ibm,os-term call. Earlier versions without in rtas_os_term()
1673 pr_emerg("ibm,os-term call failed %d\n", status); in rtas_os_term()
1677 * rtas_activate_firmware() - Activate a new version of firmware.
1693 pr_notice("ibm,activate-firmware method unavailable\n"); in rtas_activate_firmware()
1706 pr_err("ibm,activate-firmware failed (%i)\n", fwrc); in rtas_activate_firmware()
1710 * get_pseries_errorlog() - Find a specific pseries error log in an RTAS
1721 (struct rtas_ext_event_log_v6 *)log->buffer; in get_pseries_errorlog()
1734 log_end = log->buffer + ext_log_length; in get_pseries_errorlog()
1735 p = ext_log->vendor_log; in get_pseries_errorlog()
1789 f = func->filter; in block_rtas_call()
1795 if (IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN) && func->banned_for_syscall_on_le) in block_rtas_call()
1798 if (f->buf_idx1 != -1) { in block_rtas_call()
1799 base = be32_to_cpu(args->args[f->buf_idx1]); in block_rtas_call()
1800 if (f->size_idx1 != -1) in block_rtas_call()
1801 size = be32_to_cpu(args->args[f->size_idx1]); in block_rtas_call()
1802 else if (f->fixed_size) in block_rtas_call()
1803 size = f->fixed_size; in block_rtas_call()
1807 end = base + size - 1; in block_rtas_call()
1810 * Special case for ibm,platform-dump - NULL buffer in block_rtas_call()
1820 if (f->buf_idx2 != -1) { in block_rtas_call()
1821 base = be32_to_cpu(args->args[f->buf_idx2]); in block_rtas_call()
1822 if (f->size_idx2 != -1) in block_rtas_call()
1823 size = be32_to_cpu(args->args[f->size_idx2]); in block_rtas_call()
1824 else if (f->fixed_size) in block_rtas_call()
1825 size = f->fixed_size; in block_rtas_call()
1828 end = base + size - 1; in block_rtas_call()
1831 * Special case for ibm,configure-connector where the in block_rtas_call()
1843 pr_err_ratelimited("sys_rtas: RTAS call blocked - exploit attempt?\n"); in block_rtas_call()
1845 func->name, nargs, current->comm); in block_rtas_call()
1860 return -EPERM; in SYSCALL_DEFINE1()
1863 return -EINVAL; in SYSCALL_DEFINE1()
1866 return -EFAULT; in SYSCALL_DEFINE1()
1875 return -EINVAL; in SYSCALL_DEFINE1()
1878 nret = array_index_nospec(nret, ARRAY_SIZE(args.args) - nargs); in SYSCALL_DEFINE1()
1881 if (copy_from_user(args.args, uargs->args, in SYSCALL_DEFINE1()
1883 return -EFAULT; in SYSCALL_DEFINE1()
1891 return -EINVAL; in SYSCALL_DEFINE1()
1897 return -EINVAL; in SYSCALL_DEFINE1()
1918 if (rc == -EAGAIN) in SYSCALL_DEFINE1()
1920 else if (rc == -EIO) in SYSCALL_DEFINE1()
1921 args.rets[0] = cpu_to_be32(-1); in SYSCALL_DEFINE1()
1931 * acquire it to avoid interleaving with any kernel-based uses in SYSCALL_DEFINE1()
1932 * of the same function. Kernel-based sequences acquire the in SYSCALL_DEFINE1()
1935 if (func->lock) in SYSCALL_DEFINE1()
1936 mutex_lock(func->lock); in SYSCALL_DEFINE1()
1945 /* A -1 return code indicates that the last command couldn't in SYSCALL_DEFINE1()
1947 if (be32_to_cpu(args.rets[0]) == -1) in SYSCALL_DEFINE1()
1953 if (func->lock) in SYSCALL_DEFINE1()
1954 mutex_unlock(func->lock); in SYSCALL_DEFINE1()
1964 if (copy_to_user(uargs->args + nargs, in SYSCALL_DEFINE1()
1967 return -EFAULT; in SYSCALL_DEFINE1()
1981 curr->token = RTAS_UNKNOWN_SERVICE; in rtas_function_table_init()
1989 prior = &rtas_function_table[i - 1]; in rtas_function_table_init()
1991 cmp = strcmp(prior->name, curr->name); in rtas_function_table_init()
1997 curr->name); in rtas_function_table_init()
2000 prior->name, curr->name); in rtas_function_table_init()
2007 if (prop->length != sizeof(u32)) in rtas_function_table_init()
2010 func = __rtas_name_to_function(prop->name); in rtas_function_table_init()
2014 func->token = be32_to_cpup((__be32 *)prop->value); in rtas_function_table_init()
2016 pr_debug("function %s has token %u\n", func->name, func->token); in rtas_function_table_init()
2022 * information from the device-tree and allocate the RMO buffer for userland
2038 no_base = of_property_read_u32(rtas.dev, "linux,rtas-base", &base); in rtas_initialize()
2039 no_size = of_property_read_u32(rtas.dev, "rtas-size", &size); in rtas_initialize()
2048 no_entry = of_property_read_u32(rtas.dev, "linux,rtas-entry", &entry); in rtas_initialize()
2060 ibm_extended_os_term = of_property_read_bool(rtas.dev, "ibm,extended-os-term"); in rtas_initialize()
2063 * the stop-self token if any in rtas_initialize()
2086 basep = of_get_flat_dt_prop(node, "linux,rtas-base", NULL); in early_init_dt_scan_rtas()
2087 entryp = of_get_flat_dt_prop(node, "linux,rtas-entry", NULL); in early_init_dt_scan_rtas()
2088 sizep = of_get_flat_dt_prop(node, "rtas-size", NULL); in early_init_dt_scan_rtas()
2092 if (of_get_flat_dt_prop(node, "ibm,hypertas-functions", NULL)) in early_init_dt_scan_rtas()