diff options
| author | Thomas Gleixner <[email protected]> | 2022-07-28 12:36:35 +0200 | 
|---|---|---|
| committer | Thomas Gleixner <[email protected]> | 2022-07-28 12:36:35 +0200 | 
| commit | 779fda86bdeb86bad6daa4f0ecf37788dfc26f6c (patch) | |
| tree | 6445c0ba43c460765b27e62d9d3bec13c2cde674 /kernel/printk/printk_safe.c | |
| parent | ac165aab469895de059a4a191a2e04ddb5421d0e (diff) | |
| parent | 2bd1753e8c431fc7475c04ac8d14a4e9930f47f6 (diff) | |
Merge tag 'irqchip-5.20' of git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms into irq/core
Pull irqchip/genirq updates from Marc Zyngier:
 * Core code update:
  - Non-SMP IRQ affinity fixes, allowing UP kernel to behave similarly
    to SMP ones for the purpose of interrupt affinity
  - Let irq_set_chip_handler_name_locked() take a const struct irq_chip *
  - Tidy-up the NOMAP irqdomain API variant
  - Teach action_show() to use for_each_action_of_desc()
  - Make irq_chip_request_resources_parent() allow the parent callback
    to be optional
  - Remove dynamic allocations from populate_parent_alloc_arg()
 * New drivers:
  - Merge the long awaited IRQ support for the LoongArch architecture,
    with the provisional ACPICA update (to be reverted once the official
    support lands)
  - New Renesas RZ/G2L IRQC driver, equipped with its companion GPIO
    driver
 * Driver updates
  - Optimise the hot path operations for the SiFive PLIC, trading the
    locking for per-CPU priority masking masking operations which are
    apparently faster
  - Work around broken PLIC implementations that deal pretty badly with
    edge-triggered interrupts. Flag two implementations as affected.
  - Simplify the irq-stm32-exti driver, particularly the table that
    remaps the interrupts from exti to the GIC, reducing the memory usage
  - Convert the ocelot irq_chip to being immutable
  - Check ioremap() return value in the MIPS GIC driver
  - Move MMP driver init function declarations into the common .h
  - The obligatory typo fixes
Link: https://lore.kernel.org/all/[email protected]
Diffstat (limited to 'kernel/printk/printk_safe.c')
| -rw-r--r-- | kernel/printk/printk_safe.c | 32 | 
1 files changed, 32 insertions, 0 deletions
| diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c index ef0f9a2044da..caac4de1ea59 100644 --- a/kernel/printk/printk_safe.c +++ b/kernel/printk/printk_safe.c @@ -8,7 +8,9 @@  #include <linux/smp.h>  #include <linux/cpumask.h>  #include <linux/printk.h> +#include <linux/console.h>  #include <linux/kprobes.h> +#include <linux/delay.h>  #include "internal.h" @@ -50,3 +52,33 @@ asmlinkage int vprintk(const char *fmt, va_list args)  	return vprintk_default(fmt, args);  }  EXPORT_SYMBOL(vprintk); + +/** + * try_block_console_kthreads() - Try to block console kthreads and + *	make the global console_lock() avaialble + * + * @timeout_ms:        The maximum time (in ms) to wait. + * + * Prevent console kthreads from starting processing new messages. Wait + * until the global console_lock() become available. + * + * Context: Can be called in any context. + */ +void try_block_console_kthreads(int timeout_ms) +{ +	block_console_kthreads = true; + +	/* Do not wait when the console lock could not be safely taken. */ +	if (this_cpu_read(printk_context) || in_nmi()) +		return; + +	while (timeout_ms > 0) { +		if (console_trylock()) { +			console_unlock(); +			return; +		} + +		udelay(1000); +		timeout_ms -= 1; +	} +} |