From mboxrd@z Thu Jan 1 00:00:00 1970 From: tony@atomide.com (Tony Lindgren) Date: Wed, 21 Sep 2011 18:00:46 -0700 Subject: [PATCH v16 07/12] OMAP: dmtimer: add timeout to low-level routines In-Reply-To: <1316518227-28116-8-git-send-email-tarun.kanti@ti.com> References: <1316518227-28116-1-git-send-email-tarun.kanti@ti.com> <1316518227-28116-8-git-send-email-tarun.kanti@ti.com> Message-ID: <20110922010046.GS2937@atomide.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org * Tarun Kanti DebBarma [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