Skip to contentSkip to conversation

serial: pic32_uart: don't enable clock with interrupts disabled

PATCH New Hyunjung Ko 2 participants 2 messages Nov 18

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: pic32_uart: don't enable clock with interrupts disabled

pic32_uart_startup() calls clk_prepare_enable() with interrupts disabled via local_irq_save(). clk_prepare() calls might_sleep() unconditionally, so this can sleep in atomic context.

Interrupts are only disabled to serialize the UART register initialization that follows; the clock must be enabled before those registers can be accessed anyway. Enable the clock before disabling interrupts.

Fixes 157b9394709e ("serial: pic32_uart: Add PIC32 UART driver")
---
 drivers/tty/serial/pic32_uart.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/tty/serial/pic32_uart.c +3 -5
index 8407f85776c0..a8010d6b65ba 100644
@@ -455,13 +455,11 @@ static int pic32_uart_startup(struct uart_port *port)
 	unsigned long flags;
 	int ret;
 
-	local_irq_save(flags);
-
 	ret = clk_prepare_enable(sport->clk);
-	if (ret) {
-		local_irq_restore(flags);
+	if (ret)
 		goto out_done;
-	}
+
+	local_irq_save(flags);
 
 	/* clear status and mode registers */
 	pic32_uart_writel(sport, PIC32_UART_MODE, 0);
Signature · 1 line
2.43.0
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 4 lines

pic32_uart_startup() calls clk_prepare_enable() with interrupts disabled via local_irq_save(). clk_prepare() calls might_sleep() unconditionally, so this can sleep in atomic context.

Quoted 8 lines

Interrupts are only disabled to serialize the UART register initialization that follows; the clock must be enabled before those registers can be accessed anyway. Enable the clock before disabling interrupts.

Fixes 157b9394709e ("serial: pic32_uart: Add PIC32 UART driver")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1