From 179b29d17d4d9b8904ab20e73bb30c5499d5cc70 Mon Sep 17 00:00:00 2001 From: Nuno Sa Date: Wed, 24 Jan 2024 16:26:20 +0100 Subject: [PATCH] spi: spi-axi-spi-engine: setup the timer before IRQ enable The watchdog timer was being activated after enabling the interrupts and that could actually lead for the message to be transferred before we get to call mod_timer() which would lead to a spurious soft interrupt. In extreme cases (like playing with overlays to load + unload devices) this could lead to a panic splat as the timer callback would be called with the spi engine device gone already. Fixes: fde5597b0ddd ("spi: axi-spi-engine: Add watchdog timer") Signed-off-by: Nuno Sa --- drivers/spi/spi-axi-spi-engine.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c index 050096874afe9b..47449760b252ec 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -628,6 +628,8 @@ static int spi_engine_transfer_one_message(struct spi_master *master, return -ENOMEM; spi_engine_compile_message(spi_engine, msg, false, p); + mod_timer(&spi_engine->watchdog_timer, jiffies + 5 * HZ); + spin_lock_irqsave(&spi_engine->lock, flags); spi_engine->sync_id = (spi_engine->sync_id + 1) & 0xff; spi_engine_program_add_cmd(p, false, @@ -656,8 +658,6 @@ static int spi_engine_transfer_one_message(struct spi_master *master, spi_engine->int_enable = int_enable; spin_unlock_irqrestore(&spi_engine->lock, flags); - mod_timer(&spi_engine->watchdog_timer, jiffies + 5*HZ); - return 0; }