Subject: [PATCH v16 07/12] OMAP: dmtimer: add timeout to low-level routines

From: [email-masked] (Tony Lindgren)
Date: Wed, 21 Sep 2011 18:00:46 -0700

* Tarun Kanti DebBarma <[email-masked]> [110920 03:57]:
> @@ -254,9 +259,15 @@ int omap_dm_timer_prepare(struct omap_dm_timer *timer);
>  static inline u32 __omap_dm_timer_read(struct omap_dm_timer *timer, u32 reg,
>  						int posted)
>  {
> -	if (posted)
> -		while (__raw_readl(timer->pend) & (reg >> WPSHIFT))
> -			cpu_relax();
> +	int i = 0;
> +
> +	if (posted) {
> +		omap_test_timeout(!(__raw_readl(timer->pend) & (reg >> WPSHIFT))
> +						, MAX_WRITE_PEND_WAIT, i);
> +
> +		if (WARN_ON_ONCE(i == MAX_WRITE_PEND_WAIT))
> +			pr_err("Read timeout!\n");
> +	}
>  
>  	return __raw_readl(timer->func_base + (reg & 0xff));
>  }
> @@ -264,9 +275,15 @@ static inline u32 __omap_dm_timer_read(struct omap_dm_timer *timer, u32 reg,
>  static inline void __omap_dm_timer_write(struct omap_dm_timer *timer,
>  					u32 reg, u32 val, int posted)
>  {
> -	if (posted)
> -		while (__raw_readl(timer->pend) & (reg >> WPSHIFT))
> -			cpu_relax();
> +	int i = 0;
> +
> +	if (posted) {
> +		omap_test_timeout(!(__raw_readl(timer->pend) & (reg >> WPSHIFT))
> +						, MAX_WRITE_PEND_WAIT, i);
> +
> +		if (WARN_ON_ONCE(i == MAX_WRITE_PEND_WAIT))
> +			pr_err("Write timeout!\n");
> +	}
>  
>  	__raw_writel(val, timer->func_base + (reg & 0xff));
>  }

Let's leave out these changes for now, they make the
omap2_gp_timer_set_next_event used for system timer interrupts
huge if you take a look at it with objdump.

Later on we might want to split the posted bit check into a separate
inline function, and then you can implement this for the device
driver where things are more likely to go wrong with more complicated
use scenarios.

Regards,

Tony