Re: [PATCH v4 1/2] iopoll: Introduce memory-mapped IO polling macros

2014-10-10 Thread Mitchel Humpherys
On Wed, Oct 08 2014 at 06:40:46 AM, Arnd Bergmann a...@arndb.de wrote: On Tuesday 07 October 2014 18:47:59 Mitchel Humpherys wrote: On Wed, Oct 01 2014 at 01:25:33 AM, Arnd Bergmann a...@arndb.de wrote: On Tuesday 30 September 2014 18:28:12 Mitchel Humpherys wrote: + */ +#define

Re: [PATCH v4 1/2] iopoll: Introduce memory-mapped IO polling macros

2014-10-10 Thread Arnd Bergmann
On Friday 10 October 2014 12:44:45 Mitchel Humpherys wrote: Regarding the division, for the overwhelmingly common case where the user of the API passes in a constant for sleep_us the compiler optimizes out this calculation altogether and just sticks the final result in (I verified this

Re: [PATCH v4 1/2] iopoll: Introduce memory-mapped IO polling macros

2014-10-09 Thread Mitchel Humpherys
On Tue, Oct 07 2014 at 06:47:59 PM, Mitchel Humpherys mitch...@codeaurora.org wrote: +#define readl_poll_timeout_atomic(addr, val, cond, max_reads, time_between_us) \ +({ \ + int count; \ + for (count = (max_reads); count 0; count--) { \ + (val) = readl(addr); \

Re: [PATCH v4 1/2] iopoll: Introduce memory-mapped IO polling macros

2014-10-08 Thread Arnd Bergmann
On Tuesday 07 October 2014 18:47:59 Mitchel Humpherys wrote: On Wed, Oct 01 2014 at 01:25:33 AM, Arnd Bergmann a...@arndb.de wrote: On Tuesday 30 September 2014 18:28:12 Mitchel Humpherys wrote: + */ +#define readl_poll_timeout(addr, val, cond, sleep_us, timeout_us) \ +({ \ +

Re: [PATCH v4 1/2] iopoll: Introduce memory-mapped IO polling macros

2014-10-07 Thread Mitchel Humpherys
On Wed, Oct 01 2014 at 01:25:33 AM, Arnd Bergmann a...@arndb.de wrote: On Tuesday 30 September 2014 18:28:12 Mitchel Humpherys wrote: + */ +#define readl_poll_timeout(addr, val, cond, sleep_us, timeout_us) \ +({ \ + ktime_t timeout = ktime_add_us(ktime_get(), timeout_us); \ +

Re: [PATCH v4 1/2] iopoll: Introduce memory-mapped IO polling macros

2014-10-01 Thread Arnd Bergmann
On Tuesday 30 September 2014 18:28:12 Mitchel Humpherys wrote: + */ +#define readl_poll_timeout(addr, val, cond, sleep_us, timeout_us) \ +({ \ + ktime_t timeout = ktime_add_us(ktime_get(), timeout_us); \ + might_sleep_if(timeout_us); \ Does it make sense to call this with

[PATCH v4 1/2] iopoll: Introduce memory-mapped IO polling macros

2014-09-30 Thread Mitchel Humpherys
From: Matt Wagantall ma...@codeaurora.org It is sometimes necessary to poll a memory-mapped register until its value satisfies some condition. Introduce a family of convenience macros that do this. Tight-looping, sleeping, and timing out can all be accomplished using these macros. Cc: Thierry