Lines Matching full:console
7 #include <linux/console.h>
27 * Printk console printing implementation for consoles which does not depend
30 * The state of the console is maintained in the "nbcon_state" atomic
33 * The console is locked when:
36 * console. Only higher priority contexts are allowed to take over the
37 * lock. A value of 0 (NBCON_PRIO_NONE) means the console is not locked.
39 * - The 'cpu' field denotes on which CPU the console is locked. It is used
51 * - The 'unsafe' field allows to take over the console in a safe way in the
53 * shared resources or when the console device is manipulated. It can be
54 * cleared, for example, after emitting one character when the console
58 * console in an unsafe state. The console will stay in the unsafe state
63 * 1) Direct acquire when the console is not owned or is owned by a lower
67 * when the current owner has lower priority and the console is in an
75 * console.
82 * console state.
84 * b) Gives up console ownership by clearing the 'prio' field.
87 * console is an unsafe state. It is used only in panic() by the final
96 * All operations on @console::nbcon_state are atomic cmpxchg based to
107 * - Whether to spin-wait if there is already an owner and the console is
126 * nbcon_state_set - Helper function to set the console state
127 * @con: Console to update
130 * Only to be used when the console is not yet or no longer visible in the
133 static inline void nbcon_state_set(struct console *con, struct nbcon_state *new) in nbcon_state_set()
139 * nbcon_state_read - Helper function to read the console state
140 * @con: Console to read
143 static inline void nbcon_state_read(struct console *con, struct nbcon_state *state) in nbcon_state_read()
149 * nbcon_state_try_cmpxchg() - Helper function for atomic_try_cmpxchg() on console state
150 * @con: Console to update
156 static inline bool nbcon_state_try_cmpxchg(struct console *con, struct nbcon_state *cur, in nbcon_state_try_cmpxchg()
163 * nbcon_seq_read - Read the current console sequence
164 * @con: Console to read the sequence of
168 u64 nbcon_seq_read(struct console *con) in nbcon_seq_read()
176 * nbcon_seq_force - Force console sequence to a specific value
177 * @con: Console to work on
183 void nbcon_seq_force(struct console *con, u64 seq) in nbcon_seq_force()
197 * nbcon_seq_try_update - Try to update the console sequence number
205 * console. In the later case, it will stop printing anyway.
210 struct console *con = ctxt->console; in nbcon_seq_try_update()
223 * @cur: The current console state
226 * Acquire the console when it is released. Also acquire the console when
227 * the current owner has a lower priority and the console is in a safe state.
239 * -EBUSY: The current owner has a lower priority but the console
247 struct console *con = ctxt->console; in nbcon_context_try_acquire_direct()
252 * Panic does not imply that the console is owned. However, in nbcon_context_try_acquire_direct()
254 * is safer to have them avoid gaining console ownership. in nbcon_context_try_acquire_direct()
260 * a direct acquire in panic. This gives console drivers an in nbcon_context_try_acquire_direct()
277 * The console should never be safe for a direct acquire in nbcon_context_try_acquire_direct()
318 * Event #3 occurs when panic() has flushed the console. in nbcon_waiter_matches()
331 * @cur: The current console state
334 * It is called when the console is in an unsafe state. The current
335 * owner will release the console on exit from the unsafe region.
337 * Return: 0 on success and @cur is updated to the new console state.
345 * -EBUSY: The console is still locked. The caller should
355 struct console *con = ctxt->console; in nbcon_context_try_acquire_requested()
394 /* Handover success. This context now owns the console. */ in nbcon_context_try_acquire_requested()
401 * @cur: The current console state
404 * than the current owner and the console is in an unsafe state.
408 * the request. Then it waits until the current owner releases the console,
412 * region and releases the console. It does not touch the "req_prio" field
413 * so that the console stays reserved for the waiter.
422 * console or the handover request.
426 * willing to wait (zero timeout). Or the console does
438 struct console *con = ctxt->console; in nbcon_context_try_acquire_handover()
451 * Panic does not imply that the console is owned. However, it in nbcon_context_try_acquire_handover()
465 * Console stays unsafe after an unsafe takeover until re-initialized. in nbcon_context_try_acquire_handover()
477 * the console directly when the current state has been modified. in nbcon_context_try_acquire_handover()
486 /* Wait until there is no owner and then acquire the console. */ in nbcon_context_try_acquire_handover()
511 * the console or the handover request. in nbcon_context_try_acquire_handover()
541 * @cur: The current console state
543 * Acquire the console even in the unsafe state.
554 struct console *con = ctxt->console; in nbcon_context_try_acquire_hostile()
586 * nbcon_context_try_acquire - Try to acquire nbcon console
591 * Return: True if the console was acquired. False otherwise.
594 * caller should check the current console state to see if it is
596 * the console is not in an unsafe state.
600 struct console *con = ctxt->console; in nbcon_context_try_acquire()
630 ctxt->seq = nbcon_seq_read(ctxt->console); in nbcon_context_try_acquire()
659 * 4. [Task A] gets running on [CPU X] and sees that the console is in nbcon_owner_matches()
674 * nbcon_context_release - Release the console
680 struct console *con = ctxt->console; in nbcon_context_release()
707 * @cur: The current console state
709 * Return: True if this context still owns the console. False if
717 * It can be called inside an unsafe section when the console is just
726 * the console and is no longer allowed to go forward. In this case it must
734 /* Make sure this context still owns the console. */ in nbcon_context_can_proceed()
738 /* The console owner can proceed if there is no waiter. */ in nbcon_context_can_proceed()
743 * A console owner within an unsafe region is always allowed to in nbcon_context_can_proceed()
764 * outermost callsite must make the final decision whether console in nbcon_context_can_proceed()
768 * The calling context no longer owns the console so go back all the in nbcon_context_can_proceed()
779 * Return: True if this context still owns the console. False if
786 * It can be called inside an unsafe section when the console is just
794 * the console and is no longer allowed to go forward. In this case it must
801 struct console *con = ctxt->console; in nbcon_can_proceed()
819 * owns the console. Otherwise false if ownership was handed
822 * This function allows console owners to modify the unsafe status of the
823 * console.
826 * the console and is no longer allowed to go forward. In this case it must
834 struct console *con = ctxt->console; in __nbcon_context_update_unsafe()
864 struct console *con = ctxt->console; in nbcon_write_context_set_buf()
877 * Return: True if this context still owns the console. False if
881 * the console and is no longer allowed to go forward. In this case it must
901 * Return: True if this context still owns the console. False if
905 * the console and is no longer allowed to go forward. In this case it must
922 * nbcon_reacquire_nobuf - Reacquire a console after losing ownership
968 * Return: True if this context still owns the console. False if
972 * the console and is no longer allowed to go forward. In this case it must
975 * wants to do more it must reacquire the console first.
983 struct console *con = ctxt->console; in nbcon_emit_next_record()
1089 * dropped count for the console. in nbcon_emit_next_record()
1113 * nbcon_emit_one - Print one record for an nbcon console using the
1121 * False, when there is no pending record, or when the console
1126 * This is an internal helper to handle the locking of the console before
1132 struct console *con = ctxt->console; in nbcon_emit_one()
1150 * nbcon_emit_next_record() returns false when the console was in nbcon_emit_one()
1171 * @con: Console to operate on
1174 * Return: True if the thread should shutdown or if the console is
1180 static bool nbcon_kthread_should_wakeup(struct console *con, struct nbcon_context *ctxt) in nbcon_kthread_should_wakeup()
1193 * where the context with a higher priority takes over the nbcon console in nbcon_kthread_should_wakeup()
1216 * @__console: Console to operate on
1222 struct console *con = __console; in nbcon_kthread_func()
1224 .ctxt.console = con, in nbcon_kthread_func()
1283 * nbcon_irq_work - irq work to wake console printer thread
1288 struct console *con = container_of(irq_work, struct console, irq_work); in nbcon_irq_work()
1315 struct console *con; in nbcon_kthreads_wake()
1322 * It is not allowed to call this function when console irq_work in nbcon_kthreads_wake()
1345 * nbcon_kthread_stop - Stop a console printer thread
1346 * @con: Console to operate on
1348 void nbcon_kthread_stop(struct console *con) in nbcon_kthread_stop()
1360 * nbcon_kthread_create - Create a console printer thread
1361 * @con: Console to operate on
1369 * be fatal for console registration.
1375 bool nbcon_kthread_create(struct console *con) in nbcon_kthread_create()
1393 * It is important that console printing threads are scheduled in nbcon_kthread_create()
1435 * Return: The nbcon_prio to use for acquiring an nbcon console in this
1457 * Track if it is allowed to perform unsafe hostile takeovers of console
1458 * ownership. When true, console drivers might perform unsafe actions while
1464 * nbcon_allow_unsafe_takeover - Check if unsafe console takeovers are allowed
1466 * Return: True, when it is permitted to perform unsafe console printing
1477 * nbcon_legacy_emit_next_record - Print one record for an nbcon console
1479 * @con: The console to print on
1497 * False, when there is no pending record, or when the console
1503 * on nbcon consoles from legacy context (printing via console unlocking).
1506 bool nbcon_legacy_emit_next_record(struct console *con, bool *handover, in nbcon_legacy_emit_next_record()
1514 ctxt->console = con; in nbcon_legacy_emit_next_record()
1542 * __nbcon_atomic_flush_pending_con - Flush specified nbcon console using its
1544 * @con: The nbcon console to flush
1552 * -EPERM: Unable to acquire console ownership.
1560 * this context is not allowed to acquire the console. When -ENOENT is
1564 static int __nbcon_atomic_flush_pending_con(struct console *con, u64 stop_seq) in __nbcon_atomic_flush_pending_con()
1570 ctxt->console = con; in __nbcon_atomic_flush_pending_con()
1577 * Atomic flushing does not use console driver synchronization in __nbcon_atomic_flush_pending_con()
1581 * to acquire console ownership. in __nbcon_atomic_flush_pending_con()
1589 * the console was handed over or taken over. in __nbcon_atomic_flush_pending_con()
1610 * nbcon_atomic_flush_pending_con - Flush specified nbcon console using its
1612 * @con: The nbcon console to flush
1620 static void nbcon_atomic_flush_pending_con(struct console *con, u64 stop_seq) in nbcon_atomic_flush_pending_con()
1659 struct console *con; in __nbcon_atomic_flush_pending()
1761 * nbcon_alloc - Allocate and init the nbcon console specific data
1762 * @con: Console to initialize
1764 * Return: True if the console was fully allocated and initialized.
1767 * When allocation and init was successful, the console must be properly
1770 bool nbcon_alloc(struct console *con) in nbcon_alloc()
1798 * Boot console printing is synchronized with legacy console in nbcon_alloc()
1826 * nbcon_free - Free and cleanup the nbcon console specific data
1827 * @con: Console to free/cleanup nbcon data
1831 * is still another nbcon console registered.
1833 void nbcon_free(struct console *con) in nbcon_free()
1843 /* Might be the last nbcon console. in nbcon_free()
1862 * nbcon_device_try_acquire - Try to acquire nbcon console and enter unsafe
1864 * @con: The nbcon console to acquire
1868 * Return: True if the console was acquired. False otherwise.
1870 * Console drivers will usually use their own internal synchronization
1871 * mechasism to synchronize between console printing and non-printing
1872 * activities (such as setting baud rates). However, nbcon console drivers
1877 * This function acquires the nbcon console using priority NBCON_PRIO_NORMAL
1880 bool nbcon_device_try_acquire(struct console *con) in nbcon_device_try_acquire()
1887 ctxt->console = con; in nbcon_device_try_acquire()
1901 * nbcon_device_release - Exit unsafe section and release the nbcon console
1902 * @con: The nbcon console acquired in nbcon_device_try_acquire()
1904 void nbcon_device_release(struct console *con) in nbcon_device_release()
1916 * This context must flush any new records added while the console in nbcon_device_release()
1918 * console_srcu_read_lock must be taken to ensure the console is in nbcon_device_release()
1944 * nbcon_kdb_try_acquire - Try to acquire nbcon console and enter unsafe
1946 * @con: The nbcon console to acquire
1951 * only when the console is usable at the moment.
1953 * Return: True if the console was acquired. False otherwise.
1956 * storing them into the ring buffer. It has to acquire the console
1959 * This function acquires the nbcon console using priority NBCON_PRIO_EMERGENCY
1962 bool nbcon_kdb_try_acquire(struct console *con, in nbcon_kdb_try_acquire()
1968 ctxt->console = con; in nbcon_kdb_try_acquire()
1981 * nbcon_kdb_release - Exit unsafe section and release the nbcon console
1996 * Flush any new printk() messages added when the console was blocked. in nbcon_kdb_release()
1997 * Only the console used by the given write context was blocked. in nbcon_kdb_release()
1998 * The console was locked only when the write_atomic() callback in nbcon_kdb_release()
2001 __nbcon_atomic_flush_pending_con(ctxt->console, prb_next_reserve_seq(prb)); in nbcon_kdb_release()