Re: [RFC,PATCH 1/2] Add a common struct clk

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Ben Dooks
Date: Thursday, June 10, 2010 - 9:20 pm

On Fri, Jun 04, 2010 at 03:30:08PM +0800, Jeremy Kerr wrote:

Whilst I agree that this is a useful thing to do, I'd like to ensure
we get a good base for our work before we get another reason for Linus
to complain about churn.
 

What do people think of just changing everyone who is currently using
clk support to using this new implementation?
 

I'm a little worried about the size of struct clk if all of them
have a mutex in them. If i'm right, this is 40 bytes of data each
clock has to take on board.

Doing the following:

find arch/arm -type f -name "*.c" | xargs grep -c -E "struct.*clk.*=.*{" | grep -v ":0" | awk 'BEGIN { count=0; FS=":" }
count += $2; END { print count }'

indicates that there's approximately 2241 clocks under arch/arm at the
moment. That's about 87KiB of mutexes if all are being compiled at
once.

~> };
still think that not passing an bool as a second argument is silly.

~>        unsigned long   (*get_rate)(struct clk *);
~~~~> 

how about defining a nice kerneldoc for this.


how about doing the mutex initinitialisation at registration
time, will save a pile of non-zero code in the image to mess up
the compression.

~> +struct clk_ops {

should each clock carry a parent field and the this is returned by
the get parent call.~~


So we're leaving the enable parent code now to each implementation?

I think this is a really bad decision, it leaves so much open to bad
code repetition, as well as something the core should really be doing
if it had a parent clock field.

~> +static inline void clk_disable(struct clk *clk)

so if we've no enable call we ignore disable too?

also, we don't keep an enable count if this fields are in use,
could people rely on this being correct even if the clock has
no enable/disable fields.

Would much rather see the enable_count being kept up-to-date
no matter what, given it may be watched by other parts of the
implementation, useful for debug info, and possibly useful if
later in the start sequence the clk_ops get changed to have this
field.~


I'm beginging to wonder if we don't just have a set of default ops
that get set into the clk+ops at registration time if these do
not have an implementation.
~

We have an interesting problem here which I belive should be dealt
with, what happens when the clock's parent is changed with respect
to the enable count of the parent.

With the following instance:

	we have clocks a, b, c;
	a and b are possible parents for c;
	c starts off with a as parent

then the driver comes along:

	1) gets clocks a, b, c;
	2) clk_enable(c);
	3) clk_set_parent(c, b);
	
now we have the following:

	A) clk a now has an enable count of non-zero
	B) clk b may not be enabled
	C) even though clk a may now be unused, it is still running
	D) even though clk c was enabled, it isn't running since step3

this means that either any driver that is using a multi-parent clock
has to deal with the proper enable/disable of the parents (this is
is going to lead to code repetition, and I bet people will get it
badly wrong).

I belive the core of the clock code should deal with this, since
otherwise we end up with the situation of the same code being
repeated throughout the kernel.

~> - * the clock producer.  (IOW, @id may be identical strings, but
~~> + */

-- 
Ben (ben@fluff.org, http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC,PATCH 1/2] Add a common struct clk, Jeremy Kerr, (Fri Jun 4, 12:30 am)
Re: [RFC,PATCH 1/2] Add a common struct clk, Ben Dooks, (Thu Jun 10, 9:20 pm)
Re: [RFC,PATCH 1/2] Add a common struct clk, Benjamin Herrenschmidt, (Thu Jun 10, 11:50 pm)
Re: [RFC,PATCH 1/2] Add a common struct clk, Jeremy Kerr, (Fri Jun 11, 12:57 am)
Re: [RFC,PATCH 1/2] Add a common struct clk, Lothar Waßmann, (Fri Jun 11, 1:14 am)
Re: [RFC,PATCH 1/2] Add a common struct clk, Jeremy Kerr, (Fri Jun 11, 2:18 am)
Re: [RFC,PATCH 1/2] Add a common struct clk, Lothar Waßmann, (Fri Jun 11, 2:23 am)
Re: [RFC,PATCH 1/2] Add a common struct clk, Uwe Kleine-König, (Fri Jun 11, 2:58 am)
Re: [RFC,PATCH 1/2] Add a common struct clk, Lothar Waßmann, (Fri Jun 11, 3:08 am)
Re: [RFC,PATCH 1/2] Add a common struct clk, Jeremy Kerr, (Fri Jun 11, 3:50 am)
Re: [RFC,PATCH 1/2] Add a common struct clk, Uwe Kleine-König, (Fri Jun 11, 7:11 am)
Re: [RFC,PATCH 1/2] Add a common struct clk, Benjamin Herrenschmidt, (Fri Jun 11, 10:10 pm)
Re: [RFC,PATCH 1/2] Add a common struct clk, Benjamin Herrenschmidt, (Fri Jun 11, 10:12 pm)
Re: [RFC,PATCH 1/2] Add a common struct clk, Benjamin Herrenschmidt, (Fri Jun 11, 10:14 pm)
Re: [RFC,PATCH 1/2] Add a common struct clk, Ben Dooks, (Sun Jun 13, 3:23 pm)
Re: [RFC,PATCH 1/2] Add a common struct clk, Ben Dooks, (Sun Jun 13, 3:25 pm)
Re: [RFC,PATCH 1/2] Add a common struct clk, Ben Dooks, (Sun Jun 13, 3:27 pm)
Re: [RFC,PATCH 1/2] Add a common struct clk, Jeremy Kerr, (Sun Jun 13, 8:10 pm)
Re: [RFC,PATCH 1/2] Add a common struct clk, Lothar Waßmann, (Sun Jun 13, 11:39 pm)
Re: [RFC,PATCH 1/2] Add a common struct clk, Uwe Kleine-König, (Sun Jun 13, 11:40 pm)
Re: [RFC,PATCH 1/2] Add a common struct clk, Lothar Waßmann, (Sun Jun 13, 11:52 pm)
Re: [RFC,PATCH 1/2] Add a common struct clk, Benjamin Herrenschmidt, (Mon Jun 14, 2:22 am)
Re: [RFC,PATCH 1/2] Add a common struct clk, Lothar Waßmann, (Mon Jun 14, 2:30 am)
Re: [RFC,PATCH 1/2] Add a common struct clk, Uwe Kleine-König, (Mon Jun 14, 2:34 am)
Re: [RFC,PATCH 1/2] Add a common struct clk, Uwe Kleine-König, (Mon Jun 14, 2:43 am)
Re: [RFC,PATCH 1/2] Add a common struct clk, Jeremy Kerr, (Mon Jun 14, 3:18 am)
Re: [RFC,PATCH 1/2] Add a common struct clk, Ben Dooks, (Wed Jun 16, 2:13 pm)
Re: [RFC,PATCH 1/2] Add a common struct clk, Ben Dooks, (Wed Jun 16, 2:14 pm)
Re: [RFC,PATCH 1/2] Add a common struct clk, Ben Dooks, (Wed Jun 16, 2:16 pm)
Re: [RFC,PATCH 1/2] Add a common struct clk, Benjamin Herrenschmidt, (Wed Jun 16, 4:33 pm)
Re: [RFC,PATCH 1/2] Add a common struct clk, Jeremy Kerr, (Thu Sep 9, 7:10 pm)