Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Russell King - ARM Linux
On Wed, Mar 27, 2013 at 12:09:43AM -0700, Mike Turquette wrote: > + /* set context for any reentrant calls */ > + atomic_set(_context, (int) get_current()); ... > + if (mutex_is_locked(_lock)) > + if ((void *) atomic_read(_context) == get_current()) > +

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Thomas Gleixner
On Wed, 27 Mar 2013, Mike Turquette wrote: > Quoting Laurent Pinchart (2013-03-27 02:08:15) > > I wonder if it would make sense to abstract these operations in a generic > > recursive mutex. Given that it would delay this patch past v3.10 I won't > > push > > for that. > > > > Having a nice

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Thomas Gleixner
On Wed, 27 Mar 2013, Mike Turquette wrote: > Thanks for the review Thomas. I will steal your code and call it my own > in the next version. Sure. > In particular getting rid of the atomics makes things much nicer. I'd say using the helper functions and not having all these conditionals makes

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Mike Turquette
Quoting Thomas Gleixner (2013-03-27 04:09:17) > On Wed, 27 Mar 2013, Ulf Hansson wrote: > > On 27 March 2013 10:55, Viresh Kumar wrote: > > > On 27 March 2013 15:10, Thomas Gleixner wrote: > > >> On Wed, 27 Mar 2013, Mike Turquette wrote: > > >> > > >>> Reentrancy into the clock framework from

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Thomas Gleixner
On Wed, 27 Mar 2013, Mike Turquette wrote: > +/*** locking & reentrancy ***/ > + > +static void clk_fwk_lock(void) This function name sucks as much as the whole implementation does. > +{ > + /* hold the framework-wide lock, context == NULL */ > + mutex_lock(_lock); > + > + /* set

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Thomas Gleixner
On Wed, 27 Mar 2013, Ulf Hansson wrote: > On 27 March 2013 10:55, Viresh Kumar wrote: > > On 27 March 2013 15:10, Thomas Gleixner wrote: > >> On Wed, 27 Mar 2013, Mike Turquette wrote: > >> > >>> Reentrancy into the clock framework from the clk.h api is necessary > >>> for clocks that are

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Ulf Hansson
On 27 March 2013 10:55, Viresh Kumar wrote: > On 27 March 2013 15:10, Thomas Gleixner wrote: >> On Wed, 27 Mar 2013, Mike Turquette wrote: >> >>> Reentrancy into the clock framework from the clk.h api is necessary >>> for clocks that are prepared and unprepared via i2c_transfer (which >>>

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Laurent Pinchart
Hi Thomas, On Wednesday 27 March 2013 10:40:28 Thomas Gleixner wrote: > On Wed, 27 Mar 2013, Mike Turquette wrote: > > Reentrancy into the clock framework from the clk.h api is necessary > > for clocks that are prepared and unprepared via i2c_transfer (which > > includes many PMICs and discrete

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Viresh Kumar
On 27 March 2013 15:10, Thomas Gleixner wrote: > On Wed, 27 Mar 2013, Mike Turquette wrote: > >> Reentrancy into the clock framework from the clk.h api is necessary >> for clocks that are prepared and unprepared via i2c_transfer (which >> includes many PMICs and discrete audio chips) as well as

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Thomas Gleixner
On Wed, 27 Mar 2013, Mike Turquette wrote: > Reentrancy into the clock framework from the clk.h api is necessary > for clocks that are prepared and unprepared via i2c_transfer (which > includes many PMICs and discrete audio chips) as well as for several > other use cases. That explanation sucks.

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Laurent Pinchart
Hi Mike, Thanks for the patch. Please see below for a couple of comments. On Wednesday 27 March 2013 00:09:43 Mike Turquette wrote: > Reentrancy into the clock framework from the clk.h api is necessary for > clocks that are prepared and unprepared via i2c_transfer (which includes > many PMICs

[PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Mike Turquette
Reentrancy into the clock framework from the clk.h api is necessary for clocks that are prepared and unprepared via i2c_transfer (which includes many PMICs and discrete audio chips) as well as for several other use cases. This patch implements reentrancy by adding two global atomic_t's which

[PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Mike Turquette
Reentrancy into the clock framework from the clk.h api is necessary for clocks that are prepared and unprepared via i2c_transfer (which includes many PMICs and discrete audio chips) as well as for several other use cases. This patch implements reentrancy by adding two global atomic_t's which

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Laurent Pinchart
Hi Mike, Thanks for the patch. Please see below for a couple of comments. On Wednesday 27 March 2013 00:09:43 Mike Turquette wrote: Reentrancy into the clock framework from the clk.h api is necessary for clocks that are prepared and unprepared via i2c_transfer (which includes many PMICs and

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Thomas Gleixner
On Wed, 27 Mar 2013, Mike Turquette wrote: Reentrancy into the clock framework from the clk.h api is necessary for clocks that are prepared and unprepared via i2c_transfer (which includes many PMICs and discrete audio chips) as well as for several other use cases. That explanation sucks.

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Viresh Kumar
On 27 March 2013 15:10, Thomas Gleixner t...@linutronix.de wrote: On Wed, 27 Mar 2013, Mike Turquette wrote: Reentrancy into the clock framework from the clk.h api is necessary for clocks that are prepared and unprepared via i2c_transfer (which includes many PMICs and discrete audio chips) as

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Laurent Pinchart
Hi Thomas, On Wednesday 27 March 2013 10:40:28 Thomas Gleixner wrote: On Wed, 27 Mar 2013, Mike Turquette wrote: Reentrancy into the clock framework from the clk.h api is necessary for clocks that are prepared and unprepared via i2c_transfer (which includes many PMICs and discrete audio

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Ulf Hansson
On 27 March 2013 10:55, Viresh Kumar viresh.ku...@linaro.org wrote: On 27 March 2013 15:10, Thomas Gleixner t...@linutronix.de wrote: On Wed, 27 Mar 2013, Mike Turquette wrote: Reentrancy into the clock framework from the clk.h api is necessary for clocks that are prepared and unprepared via

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Thomas Gleixner
On Wed, 27 Mar 2013, Ulf Hansson wrote: On 27 March 2013 10:55, Viresh Kumar viresh.ku...@linaro.org wrote: On 27 March 2013 15:10, Thomas Gleixner t...@linutronix.de wrote: On Wed, 27 Mar 2013, Mike Turquette wrote: Reentrancy into the clock framework from the clk.h api is necessary

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Thomas Gleixner
On Wed, 27 Mar 2013, Mike Turquette wrote: +/*** locking reentrancy ***/ + +static void clk_fwk_lock(void) This function name sucks as much as the whole implementation does. +{ + /* hold the framework-wide lock, context == NULL */ + mutex_lock(prepare_lock); + + /* set

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Mike Turquette
Quoting Thomas Gleixner (2013-03-27 04:09:17) On Wed, 27 Mar 2013, Ulf Hansson wrote: On 27 March 2013 10:55, Viresh Kumar viresh.ku...@linaro.org wrote: On 27 March 2013 15:10, Thomas Gleixner t...@linutronix.de wrote: On Wed, 27 Mar 2013, Mike Turquette wrote: Reentrancy into the

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Thomas Gleixner
On Wed, 27 Mar 2013, Mike Turquette wrote: Thanks for the review Thomas. I will steal your code and call it my own in the next version. Sure. In particular getting rid of the atomics makes things much nicer. I'd say using the helper functions and not having all these conditionals makes it

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Thomas Gleixner
On Wed, 27 Mar 2013, Mike Turquette wrote: Quoting Laurent Pinchart (2013-03-27 02:08:15) I wonder if it would make sense to abstract these operations in a generic recursive mutex. Given that it would delay this patch past v3.10 I won't push for that. Having a nice implementation

Re: [PATCH v4] clk: allow reentrant calls into the clk framework

2013-03-27 Thread Russell King - ARM Linux
On Wed, Mar 27, 2013 at 12:09:43AM -0700, Mike Turquette wrote: + /* set context for any reentrant calls */ + atomic_set(prepare_context, (int) get_current()); ... + if (mutex_is_locked(prepare_lock)) + if ((void *) atomic_read(prepare_context) == get_current()) +