Skip to content

Commit

Permalink
spi: spi-axi-spi-engine: setup the timer before IRQ enable
Browse files Browse the repository at this point in the history
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: fde5597 ("spi: axi-spi-engine: Add watchdog timer")
Signed-off-by: Nuno Sa <[email protected]>
  • Loading branch information
nunojsa committed Jan 26, 2024
1 parent e1517be commit a2949a1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/spi/spi-axi-spi-engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit a2949a1

Please sign in to comment.