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

1 // SPDX-License-Identifier: GPL-2.0-or-later
40 #include <asm/rtas-work-area.h>
47 /* Indexes into the args buffer, -1 if not used */
60 * struct rtas_function - Descriptor for RTAS functions.
64 * @filter: If non-NULL, invoking this function via the rtas syscall is
83 .name = "check-exception",
86 .name = "display-character",
88 .buf_idx1 = -1, .size_idx1 = -1,
89 .buf_idx2 = -1, .size_idx2 = -1,
93 .name = "event-scan",
96 .name = "freeze-time-base",
99 .name = "get-power-level",
101 .buf_idx1 = -1, .size_idx1 = -1,
102 .buf_idx2 = -1, .size_idx2 = -1,
106 .name = "get-sensor-state",
108 .buf_idx1 = -1, .size_idx1 = -1,
109 .buf_idx2 = -1, .size_idx2 = -1,
113 .name = "get-term-char",
116 .name = "get-time-of-day",
118 .buf_idx1 = -1, .size_idx1 = -1,
119 .buf_idx2 = -1, .size_idx2 = -1,
123 .name = "ibm,activate-firmware",
125 .buf_idx1 = -1, .size_idx1 = -1,
126 .buf_idx2 = -1, .size_idx2 = -1,
130 .name = "ibm,cbe-start-ptcal",
133 .name = "ibm,cbe-stop-ptcal",
136 .name = "ibm,change-msi",
139 .name = "ibm,close-errinjct",
141 .buf_idx1 = -1, .size_idx1 = -1,
142 .buf_idx2 = -1, .size_idx2 = -1,
146 .name = "ibm,configure-bridge",
149 .name = "ibm,configure-connector",
151 .buf_idx1 = 0, .size_idx1 = -1,
152 .buf_idx2 = 1, .size_idx2 = -1,
157 .name = "ibm,configure-kernel-dump",
160 .name = "ibm,configure-pe",
163 .name = "ibm,create-pe-dma-window",
166 .name = "ibm,display-message",
168 .buf_idx1 = 0, .size_idx1 = -1,
169 .buf_idx2 = -1, .size_idx2 = -1,
175 .buf_idx1 = 2, .size_idx1 = -1,
176 .buf_idx2 = -1, .size_idx2 = -1,
184 .name = "ibm,get-config-addr-info",
187 .name = "ibm,get-config-addr-info2",
189 .buf_idx1 = -1, .size_idx1 = -1,
190 .buf_idx2 = -1, .size_idx2 = -1,
194 .name = "ibm,get-dynamic-sensor-state",
196 .buf_idx1 = 1, .size_idx1 = -1,
197 .buf_idx2 = -1, .size_idx2 = -1,
201 .name = "ibm,get-indices",
204 .buf_idx2 = -1, .size_idx2 = -1,
208 .name = "ibm,get-rio-topology",
211 .name = "ibm,get-system-parameter",
214 .buf_idx2 = -1, .size_idx2 = -1,
218 .name = "ibm,get-vpd",
220 .buf_idx1 = 0, .size_idx1 = -1,
225 .name = "ibm,get-xive",
228 .name = "ibm,int-off",
231 .name = "ibm,int-on",
234 .name = "ibm,io-quiesce-ack",
237 .name = "ibm,lpar-perftools",
240 .buf_idx2 = -1, .size_idx2 = -1,
244 .name = "ibm,manage-flash-image",
247 .name = "ibm,manage-storage-preservation",
250 .name = "ibm,nmi-interlock",
253 .name = "ibm,nmi-register",
256 .name = "ibm,open-errinjct",
258 .buf_idx1 = -1, .size_idx1 = -1,
259 .buf_idx2 = -1, .size_idx2 = -1,
263 .name = "ibm,open-sriov-allow-unfreeze",
266 .name = "ibm,open-sriov-map-pe-number",
269 .name = "ibm,os-term",
272 .name = "ibm,partner-control",
275 .name = "ibm,physical-attestation",
278 .buf_idx2 = -1, .size_idx2 = -1,
282 .name = "ibm,platform-dump",
285 .buf_idx2 = -1, .size_idx2 = -1,
289 .name = "ibm,power-off-ups",
292 .name = "ibm,query-interrupt-source-number",
295 .name = "ibm,query-pe-dma-window",
298 .name = "ibm,read-pci-config",
301 .name = "ibm,read-slot-reset-state",
303 .buf_idx1 = -1, .size_idx1 = -1,
304 .buf_idx2 = -1, .size_idx2 = -1,
308 .name = "ibm,read-slot-reset-state2",
311 .name = "ibm,remove-pe-dma-window",
316 * "ibm,reset-pe-dma-windows" (plural), but RTAS
319 .name = "ibm,reset-pe-dma-window",
322 .name = "ibm,scan-log-dump",
325 .buf_idx2 = -1, .size_idx2 = -1,
329 .name = "ibm,set-dynamic-indicator",
331 .buf_idx1 = 2, .size_idx1 = -1,
332 .buf_idx2 = -1, .size_idx2 = -1,
336 .name = "ibm,set-eeh-option",
338 .buf_idx1 = -1, .size_idx1 = -1,
339 .buf_idx2 = -1, .size_idx2 = -1,
343 .name = "ibm,set-slot-reset",
346 .name = "ibm,set-system-parameter",
348 .buf_idx1 = 1, .size_idx1 = -1,
349 .buf_idx2 = -1, .size_idx2 = -1,
353 .name = "ibm,set-xive",
356 .name = "ibm,slot-error-detail",
359 .name = "ibm,suspend-me",
362 .buf_idx1 = -1, .size_idx1 = -1,
363 .buf_idx2 = -1, .size_idx2 = -1,
367 .name = "ibm,tune-dma-parms",
370 .name = "ibm,update-flash-64-and-reboot",
373 .name = "ibm,update-nodes",
376 .buf_idx1 = 0, .size_idx1 = -1,
377 .buf_idx2 = -1, .size_idx2 = -1,
382 .name = "ibm,update-properties",
385 .buf_idx1 = 0, .size_idx1 = -1,
386 .buf_idx2 = -1, .size_idx2 = -1,
391 .name = "ibm,validate-flash-image",
394 .name = "ibm,write-pci-config",
397 .name = "nvram-fetch",
400 .name = "nvram-store",
403 .name = "power-off",
406 .name = "put-term-char",
409 .name = "query-cpu-stopped-state",
412 .name = "read-pci-config",
415 .name = "rtas-last-error",
418 .name = "set-indicator",
420 .buf_idx1 = -1, .size_idx1 = -1,
421 .buf_idx2 = -1, .size_idx2 = -1,
425 .name = "set-power-level",
427 .buf_idx1 = -1, .size_idx1 = -1,
428 .buf_idx2 = -1, .size_idx2 = -1,
432 .name = "set-time-for-power-on",
434 .buf_idx1 = -1, .size_idx1 = -1,
435 .buf_idx2 = -1, .size_idx2 = -1,
439 .name = "set-time-of-day",
441 .buf_idx1 = -1, .size_idx1 = -1,
442 .buf_idx2 = -1, .size_idx2 = -1,
446 .name = "start-cpu",
449 .name = "stop-self",
452 .name = "system-reboot",
455 .name = "thaw-time-base",
458 .name = "write-pci-config",
466 * Exceptions to the RTAS serialization requirement (e.g. stop-self)
473 * rtas_function_token() - RTAS function token lookup.
488 * Various drivers attempt token lookups on non-RTAS in rtas_function_token()
503 return strcmp(f1->name, f2->name); in rtas_function_cmp()
507 * Boot-time initialization of the function table needs the lookup to
508 * return a non-const-qualified object. Use rtas_name_to_function()
537 const s32 token = func->token; in rtas_token_to_function_xarray_init()
563 * known-good token value in contexts where the former is not already
583 void enter_rtas(unsigned long);
602 const s32 token = be32_to_cpu(args->token); in __do_enter_rtas_trace()
605 name = func->name; in __do_enter_rtas_trace()
619 const unsigned long msr = mfmsr(); in do_enter_rtas()
625 * i.e. we're about to call stop-self. The tracepoints' in do_enter_rtas()
630 * 2. In real mode, as when invoking ibm,nmi-interlock from in do_enter_rtas()
635 const unsigned long mask = MSR_IR | MSR_DR; in do_enter_rtas()
662 unsigned long rtas_rmo_buf;
665 * If non-NULL, this gets called when the kernel terminates.
673 * are designed only for very early low-level debugging, which
674 * is why the token is hard-coded to 10.
678 unsigned long flags; in call_rtas_display_status()
694 while (width-- > 0) in call_rtas_display_status_delay()
705 if (width--) { in call_rtas_display_status_delay()
750 return -1; in udbg_rtascon_getc_poll()
753 return -1; in udbg_rtascon_getc_poll()
762 while ((c = udbg_rtascon_getc_poll()) == -1) in udbg_rtascon_getc()
797 "ibm,display-line-length", NULL))) in rtas_progress()
800 "ibm,form-feed", NULL))) in rtas_progress()
803 "ibm,display-number-of-lines", NULL))) in rtas_progress()
806 "ibm,display-truncation-length", NULL); in rtas_progress()
858 if (current_line > display_lines-1) in rtas_progress()
859 current_line = display_lines-1; in rtas_progress()
864 /* RTAS wants CR-LF, not just LF */ in rtas_progress()
870 /* CR might be used to re-draw a line, so we'll in rtas_progress()
881 width--; in rtas_progress()
907 return func->token; in rtas_token()
912 * access non-function properties of the /rtas node. Warn and in rtas_token()
933 * Return the firmware-specified size of the error log buffer
935 * This includes 'check-exception' and 'rtas-last-error'.
944 static const char propname[] __initconst = "rtas-error-log-max"; in init_error_log_max()
980 if (token == -1) in __fetch_rtas_last_error()
1031 args->token = cpu_to_be32(token); in va_rtas_call_unlocked()
1032 args->nargs = cpu_to_be32(nargs); in va_rtas_call_unlocked()
1033 args->nret = cpu_to_be32(nret); in va_rtas_call_unlocked()
1034 args->rets = &(args->args[nargs]); in va_rtas_call_unlocked()
1037 args->args[i] = cpu_to_be32(va_arg(list, __u32)); in va_rtas_call_unlocked()
1040 args->rets[i] = 0; in va_rtas_call_unlocked()
1046 * rtas_call_unlocked() - Invoke an RTAS firmware function without synchronization.
1060 * time. Examples include stop-self and ibm,nmi-interlock.
1078 * rtas_call() - Invoke an RTAS firmware function.
1094 * -2 or 990x should use rtas_busy_delay() to correctly handle those
1105 * * 0 - RTAS function call succeeded.
1106 * * -1 - RTAS function encountered a hardware or
1109 * * -2 - Specs say "A necessary hardware device was busy,
1119 * * -3 - Parameter error.
1120 * * -7 - Unexpected state change.
1121 * * 9000...9899 - Vendor-specific success codes.
1122 * * 9900...9905 - Advisory extended delay. Caller should try
1123 * again after ~10^x ms has elapsed, where x is
1124 * the last digit of the status [0-5]. Again going
1126 * contention for RTAS-internal resources. Other
1130 * * -9000 - Multi-level isolation error.
1131 * * -9999...-9004 - Vendor-specific error codes.
1132 * * Additional negative values - Function-specific error.
1133 * * Additional positive values - Function-specific success.
1140 unsigned long flags; in rtas_call()
1146 return -1; in rtas_call()
1155 return -1; in rtas_call()
1160 return -1; in rtas_call()
1173 /* A -1 return code indicates that the last command couldn't in rtas_call()
1175 if (be32_to_cpu(args->rets[0]) == -1) in rtas_call()
1179 for (i = 0; i < nret-1; ++i) in rtas_call()
1180 outputs[i] = be32_to_cpu(args->rets[i + 1]); in rtas_call()
1181 ret = (nret > 0) ? be32_to_cpu(args->rets[0]) : 0; in rtas_call()
1196 * rtas_busy_delay_time() - From an RTAS status value, calculate the
1205 * * 100000 - If @status is 9905.
1206 * * 10000 - If @status is 9904.
1207 * * 1000 - If @status is 9903.
1208 * * 100 - If @status is 9902.
1209 * * 10 - If @status is 9901.
1210 * * 1 - If @status is either 9900 or -2. This is "wrong" for -2, but
1213 * * 0 - If @status is not a busy or extended delay value.
1218 unsigned int ms = 0; in rtas_busy_delay_time() local
1221 ms = 1; in rtas_busy_delay_time()
1224 order = status - RTAS_EXTENDED_DELAY_MIN; in rtas_busy_delay_time()
1225 for (ms = 1; order > 0; order--) in rtas_busy_delay_time()
1226 ms *= 10; in rtas_busy_delay_time()
1229 return ms; in rtas_busy_delay_time()
1274 * rtas_busy_delay() - helper for RTAS busy and extended delay statuses
1282 * * true - @status is RTAS_BUSY or an extended delay hint. The
1288 * * false - @status is not @RTAS_BUSY nor an extended delay hint. The
1293 unsigned int ms; in rtas_busy_delay() local
1305 ms = rtas_busy_delay_time(status); in rtas_busy_delay()
1312 ms = clamp(ms, 1U, 1000U); in rtas_busy_delay()
1314 * The delay hint is an order-of-magnitude suggestion, not in rtas_busy_delay()
1320 * See Documentation/timers/timers-howto.rst for in rtas_busy_delay()
1323 * 9902-9905. in rtas_busy_delay()
1325 if (ms <= 20) in rtas_busy_delay()
1326 usleep_range(ms * 100, ms * 1000); in rtas_busy_delay()
1328 msleep(ms); in rtas_busy_delay()
1359 rc = -EIO; in rtas_error_rc()
1362 rc = -EINVAL; in rtas_error_rc()
1364 case -9000: /* Isolation error */ in rtas_error_rc()
1365 rc = -EFAULT; in rtas_error_rc()
1367 case -9001: /* Outstanding TCE/PTE */ in rtas_error_rc()
1368 rc = -EEXIST; in rtas_error_rc()
1370 case -9002: /* No usable slot */ in rtas_error_rc()
1371 rc = -ENODEV; in rtas_error_rc()
1375 rc = -ERANGE; in rtas_error_rc()
1388 return -ENOENT; in rtas_get_power_level()
1405 return -ENOENT; in rtas_set_power_level()
1423 return -ENOENT; in rtas_get_sensor()
1441 return -ENOENT; in rtas_get_sensor_fast()
1460 indicators = of_get_property(rtas.dev, "rtas-indicators", &proplen); in rtas_indicator_present()
1483 return -ENOENT; in rtas_set_indicator()
1504 return -ENOENT; in rtas_set_indicator_fast()
1518 * rtas_ibm_suspend_me() - Call ibm,suspend-me to suspend the LPAR.
1534 * 0 - The partition has resumed from suspend, possibly after
1536 * -ECANCELED - The operation was aborted.
1537 * -EAGAIN - There were other CPUs not in H_JOIN at the time of the call.
1538 * -EBUSY - Some other condition prevented the suspend from succeeding.
1539 * -EIO - Hardware/platform error.
1554 ret = -ECANCELED; in rtas_ibm_suspend_me()
1557 ret = -EAGAIN; in rtas_ibm_suspend_me()
1561 ret = -EBUSY; in rtas_ibm_suspend_me()
1563 case -1: in rtas_ibm_suspend_me()
1565 ret = -EIO; in rtas_ibm_suspend_me()
1579 pr_emerg("system-reboot returned %d\n", in rtas_restart()
1588 /* allow power on only with power button press */ in rtas_power_off()
1589 pr_emerg("power-off returned %d\n", in rtas_power_off()
1590 rtas_call(rtas_function_token(RTAS_FN_POWER_OFF), 2, 1, NULL, -1, -1)); in rtas_power_off()
1598 /* allow power on only with power button press */ in rtas_halt()
1599 pr_emerg("power-off returned %d\n", in rtas_halt()
1600 rtas_call(rtas_function_token(RTAS_FN_POWER_OFF), 2, 1, NULL, -1, -1)); in rtas_halt()
1615 * Firmware with the ibm,extended-os-term property is guaranteed in rtas_os_term()
1616 * to always return from an ibm,os-term call. Earlier versions without in rtas_os_term()
1627 * Keep calling as long as RTAS returns a "try again" status, in rtas_os_term()
1637 pr_emerg("ibm,os-term call failed %d\n", status); in rtas_os_term()
1641 * rtas_activate_firmware() - Activate a new version of firmware.
1657 pr_notice("ibm,activate-firmware method unavailable\n"); in rtas_activate_firmware()
1666 pr_err("ibm,activate-firmware failed (%i)\n", fwrc); in rtas_activate_firmware()
1670 * get_pseries_errorlog() - Find a specific pseries error log in an RTAS
1681 (struct rtas_ext_event_log_v6 *)log->buffer; in get_pseries_errorlog()
1694 log_end = log->buffer + ext_log_length; in get_pseries_errorlog()
1695 p = ext_log->vendor_log; in get_pseries_errorlog()
1755 f = func->filter; in block_rtas_call()
1761 if (IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN) && func->banned_for_syscall_on_le) in block_rtas_call()
1764 if (f->buf_idx1 != -1) { in block_rtas_call()
1765 base = be32_to_cpu(args->args[f->buf_idx1]); in block_rtas_call()
1766 if (f->size_idx1 != -1) in block_rtas_call()
1767 size = be32_to_cpu(args->args[f->size_idx1]); in block_rtas_call()
1768 else if (f->fixed_size) in block_rtas_call()
1769 size = f->fixed_size; in block_rtas_call()
1773 end = base + size - 1; in block_rtas_call()
1776 * Special case for ibm,platform-dump - NULL buffer in block_rtas_call()
1786 if (f->buf_idx2 != -1) { in block_rtas_call()
1787 base = be32_to_cpu(args->args[f->buf_idx2]); in block_rtas_call()
1788 if (f->size_idx2 != -1) in block_rtas_call()
1789 size = be32_to_cpu(args->args[f->size_idx2]); in block_rtas_call()
1790 else if (f->fixed_size) in block_rtas_call()
1791 size = f->fixed_size; in block_rtas_call()
1794 end = base + size - 1; in block_rtas_call()
1797 * Special case for ibm,configure-connector where the in block_rtas_call()
1809 pr_err_ratelimited("sys_rtas: RTAS call blocked - exploit attempt?\n"); in block_rtas_call()
1811 token, nargs, current->comm); in block_rtas_call()
1820 unsigned long flags; in SYSCALL_DEFINE1()
1825 return -EPERM; in SYSCALL_DEFINE1()
1828 return -EINVAL; in SYSCALL_DEFINE1()
1831 return -EFAULT; in SYSCALL_DEFINE1()
1840 return -EINVAL; in SYSCALL_DEFINE1()
1843 if (copy_from_user(args.args, uargs->args, in SYSCALL_DEFINE1()
1845 return -EFAULT; in SYSCALL_DEFINE1()
1848 return -EINVAL; in SYSCALL_DEFINE1()
1854 return -EINVAL; in SYSCALL_DEFINE1()
1875 if (rc == -EAGAIN) in SYSCALL_DEFINE1()
1877 else if (rc == -EIO) in SYSCALL_DEFINE1()
1878 args.rets[0] = cpu_to_be32(-1); in SYSCALL_DEFINE1()
1893 /* A -1 return code indicates that the last command couldn't in SYSCALL_DEFINE1()
1895 if (be32_to_cpu(args.rets[0]) == -1) in SYSCALL_DEFINE1()
1909 if (copy_to_user(uargs->args + nargs, in SYSCALL_DEFINE1()
1912 return -EFAULT; in SYSCALL_DEFINE1()
1926 curr->token = RTAS_UNKNOWN_SERVICE; in rtas_function_table_init()
1934 prior = &rtas_function_table[i - 1]; in rtas_function_table_init()
1936 cmp = strcmp(prior->name, curr->name); in rtas_function_table_init()
1942 curr->name); in rtas_function_table_init()
1945 prior->name, curr->name); in rtas_function_table_init()
1952 if (prop->length != sizeof(u32)) in rtas_function_table_init()
1955 func = __rtas_name_to_function(prop->name); in rtas_function_table_init()
1959 func->token = be32_to_cpup((__be32 *)prop->value); in rtas_function_table_init()
1961 pr_debug("function %s has token %u\n", func->name, func->token); in rtas_function_table_init()
1967 * information from the device-tree and allocate the RMO buffer for userland
1972 unsigned long rtas_region = RTAS_INSTANTIATE_MAX; in rtas_initialize()
1983 no_base = of_property_read_u32(rtas.dev, "linux,rtas-base", &base); in rtas_initialize()
1984 no_size = of_property_read_u32(rtas.dev, "rtas-size", &size); in rtas_initialize()
1993 no_entry = of_property_read_u32(rtas.dev, "linux,rtas-entry", &entry); in rtas_initialize()
2005 ibm_extended_os_term = of_property_read_bool(rtas.dev, "ibm,extended-os-term"); in rtas_initialize()
2008 * the stop-self token if any in rtas_initialize()
2023 int __init early_init_dt_scan_rtas(unsigned long node, in early_init_dt_scan_rtas()
2031 basep = of_get_flat_dt_prop(node, "linux,rtas-base", NULL); in early_init_dt_scan_rtas()
2032 entryp = of_get_flat_dt_prop(node, "linux,rtas-entry", NULL); in early_init_dt_scan_rtas()
2033 sizep = of_get_flat_dt_prop(node, "rtas-size", NULL); in early_init_dt_scan_rtas()
2037 if (of_get_flat_dt_prop(node, "ibm,hypertas-functions", NULL)) in early_init_dt_scan_rtas()
2048 basep = of_get_flat_dt_prop(node, "put-term-char", NULL); in early_init_dt_scan_rtas()
2052 basep = of_get_flat_dt_prop(node, "get-term-char", NULL); in early_init_dt_scan_rtas()
2071 unsigned long flags; in rtas_give_timebase()