Skip to contentSkip to conversation

serial: ifx6x60: add_timer is not safe in the mrdy_assert function

PATCH In review Jun Chen 2 participants 2 messages Oct 22, 2012 TTY layer and serial drivers

lore
Share & tools
lore

Jun Chen

author
#0 lore raw

PATCH 1/1 serial: ifx6x60: add_timer is not safe in the mrdy_assert function

This patch make use of mod_timer instead of add_timer in the mrdy_assert function. Because the srdy interrupter can go high when we are running function mrdy_assert and mrdy_assert can be called by multi-entry. In our medfield platform, spi stress test can encounter this error logs triggered by the BUG_ON of add_timer function.This patch had been tested on our medfield platform.

the scenario:

      CPU0							CPU1
mrdy_assert
set_bit(IFX_SPI_STATE_TIMER_PENDING)
								ifx_spi_handle_srdy
								...
								clear_bit(IFX_SPI_STATE_TIMER_PENDING)
								...
								mrdy_assert
								set_bit(IFX_SPI_STATE_TIMER_PENDING)
								...
								add_timer

...
add_timer

cc liu chuansheng <[email protected]>
cc Bi Chao <[email protected]>
---
 drivers/tty/serial/ifx6x60.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/tty/serial/ifx6x60.c +1 -3
index 769396a..e56ed33 100644
@@ -190,9 +190,7 @@ static void mrdy_assert(struct ifx_spi_device *ifx_dev)
 	if (!val) {
 		if (!test_and_set_bit(IFX_SPI_STATE_TIMER_PENDING,
 				      &ifx_dev->flags)) {
-			ifx_dev->spi_timer.expires =
-				jiffies + IFX_SPI_TIMEOUT_SEC*HZ;
-			add_timer(&ifx_dev->spi_timer);
+			mod_timer(&ifx_dev->spi_timer,jiffies + IFX_SPI_TIMEOUT_SEC*HZ);
 
 		}
 	}
Signature · 1 line
1.7.4.1
Acked-by on v1 1/1
#1 lore raw
Quoted 19 lines · On Mon, 22 Oct 2012 10:23:07 -0400 Jun Chen <[email protected]> wrote:

This patch make use of mod_timer instead of add_timer in the mrdy_assert function. Because the srdy interrupter can go high when we are running function mrdy_assert and mrdy_assert can be called by multi-entry. In our medfield platform, spi stress test can encounter this error logs triggered by the BUG_ON of add_timer function.This patch had been tested on our medfield platform.

the scenario:

      CPU0							CPU1
mrdy_assert
set_bit(IFX_SPI_STATE_TIMER_PENDING)
								ifx_spi_handle_srdy
								...
								clear_bit(IFX_SPI_STATE_TIMER_PENDING)
								...
								mrdy_assert
								set_bit(IFX_SPI_STATE_TIMER_PENDING)
								...
								add_timer
Quoted 6 lines

...
add_timer

cc liu chuansheng <[email protected]>
cc Bi Chao <[email protected]>