All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Richard Zhao <richard.zhao@linaro.org>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	jeremy.kerr@canonical.com, paul@pwsan.com,
	linaro-dev@lists.linaro.org, linus.walleij@stericsson.com,
	patches@linaro.org, shawn.guo@freescale.com,
	magnus.damm@gmail.com, linux-kernel@vger.kernel.org,
	eric.miao@linaro.org, grant.likely@secretlab.ca,
	dsaxena@linaro.org, amit.kucheria@linaro.org,
	skannan@quicinc.com, arnd.bergmann@linaro.org, sboyd@quiinc.com,
	tglx@linutronix.de, linux-arm-kernel@lists.infradead.org,
	Mike Turquette <mturquette@ti.com>
Subject: Re: [PATCH v2 1/7] clk: Add a generic clock infrastructure
Date: Mon, 17 Oct 2011 12:30:50 +0100	[thread overview]
Message-ID: <20111017113050.GI21648@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20111017110539.GB18141@pengutronix.de>

On Mon, Oct 17, 2011 at 01:05:39PM +0200, Sascha Hauer wrote:
> It's not a problem to associate multiple clocks to a device, we can do
> this now already. What a driver can't do now is give-me-all-clocks-I-need(dev),
> but this problem should not be solved at clock core level but at the
> clkdev level.

I don't think it even needs solving at the clkdev level.

In order to get all clocks for a specific device, we'd need variable
length arrays to store the individual struct clk pointers, which isn't
going to be all that nice.  We'd need clk_get_alldev() and
clk_put_alldev() to deal with these variable length arrays - and as
far as the driver is concerned that's an opaque object - it can't know
anything about any particular individual struct clk in the array.

Then we'd need operations to operate on the array itself, which means
much more API baggage.

Also, if it did need to know about one particular struct clk, then
there's problems with avoiding that struct clk in the alldev() versions
(or we'll see drivers doing clk_get() followed by clk_disable() to
work-around any enabling done via the array versions.)

> The fact is that the different clocks for a device are really different
> clocks. A dumb driver may want to request/enable all relevant clocks at
> once while a more sophisticated driver may want to enable the clock for
> accessing registers in the probe function and a baud clock on device
> open time.

I don't think you can get away from drivers having to know about their
individual clocks in some form or other - and I don't think a dumb
driver should be a justification for creating an API.  If a dumb driver
wants to get the clocks for a device it has to behave as if it were
a smart driver and request each one (maybe having an array itself)
such as this:

static const char *con_ids[NR_CLKS] = {
	"foo",
	"bar",
};

struct driver_priv {
	struct clk *clk[NR_CLKS];
};

	
	for (err = i = 0; i < NR_CLKS; i++) {
		priv->clk[i] = clk_get(dev, con_ids[i];
		if (IS_ERR(priv->clk[i])) {
			err = PTR_ERR(priv->clk[i]);
			break;
		}
	}

	if (err) {
		for (i = 0; i < NR_CLKS && !IS_ERR(priv->clk[i]); i++)
			clk_put(priv->clk[i]);
		return err;
	}

This approach also has the advantage that we know what order the clocks
will be in the array, and so we can sensibly index the array to obtain
a particular clock.

However, going back to the bus fabric case, a driver probably doesn't
have the knowledge - it's a platform topology thing - one which can't
be represented by a clock tree.

It might help if we represented our busses closer to reality - like PCI
does - rather than a flattened set of platform devices.  Couple that with
runtime PM and a driver for the bus fabric, and it should fall out
fairly naturally from the infrastructure we already have.

WARNING: multiple messages have this Message-ID (diff)
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/7] clk: Add a generic clock infrastructure
Date: Mon, 17 Oct 2011 12:30:50 +0100	[thread overview]
Message-ID: <20111017113050.GI21648@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20111017110539.GB18141@pengutronix.de>

On Mon, Oct 17, 2011 at 01:05:39PM +0200, Sascha Hauer wrote:
> It's not a problem to associate multiple clocks to a device, we can do
> this now already. What a driver can't do now is give-me-all-clocks-I-need(dev),
> but this problem should not be solved at clock core level but at the
> clkdev level.

I don't think it even needs solving at the clkdev level.

In order to get all clocks for a specific device, we'd need variable
length arrays to store the individual struct clk pointers, which isn't
going to be all that nice.  We'd need clk_get_alldev() and
clk_put_alldev() to deal with these variable length arrays - and as
far as the driver is concerned that's an opaque object - it can't know
anything about any particular individual struct clk in the array.

Then we'd need operations to operate on the array itself, which means
much more API baggage.

Also, if it did need to know about one particular struct clk, then
there's problems with avoiding that struct clk in the alldev() versions
(or we'll see drivers doing clk_get() followed by clk_disable() to
work-around any enabling done via the array versions.)

> The fact is that the different clocks for a device are really different
> clocks. A dumb driver may want to request/enable all relevant clocks at
> once while a more sophisticated driver may want to enable the clock for
> accessing registers in the probe function and a baud clock on device
> open time.

I don't think you can get away from drivers having to know about their
individual clocks in some form or other - and I don't think a dumb
driver should be a justification for creating an API.  If a dumb driver
wants to get the clocks for a device it has to behave as if it were
a smart driver and request each one (maybe having an array itself)
such as this:

static const char *con_ids[NR_CLKS] = {
	"foo",
	"bar",
};

struct driver_priv {
	struct clk *clk[NR_CLKS];
};

	
	for (err = i = 0; i < NR_CLKS; i++) {
		priv->clk[i] = clk_get(dev, con_ids[i];
		if (IS_ERR(priv->clk[i])) {
			err = PTR_ERR(priv->clk[i]);
			break;
		}
	}

	if (err) {
		for (i = 0; i < NR_CLKS && !IS_ERR(priv->clk[i]); i++)
			clk_put(priv->clk[i]);
		return err;
	}

This approach also has the advantage that we know what order the clocks
will be in the array, and so we can sensibly index the array to obtain
a particular clock.

However, going back to the bus fabric case, a driver probably doesn't
have the knowledge - it's a platform topology thing - one which can't
be represented by a clock tree.

It might help if we represented our busses closer to reality - like PCI
does - rather than a flattened set of platform devices.  Couple that with
runtime PM and a driver for the bus fabric, and it should fall out
fairly naturally from the infrastructure we already have.

  reply	other threads:[~2011-10-17 11:31 UTC|newest]

Thread overview: 144+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-22 22:26 [PATCH v2 0/7] Add a generic struct clk Mike Turquette
2011-09-22 22:26 ` Mike Turquette
2011-09-22 22:26 ` [PATCH v2 1/7] clk: Add a generic clock infrastructure Mike Turquette
2011-09-22 22:26   ` Mike Turquette
2011-09-25  3:55   ` Grant Likely
2011-09-25  3:55     ` Grant Likely
2011-09-25  5:26     ` Turquette, Mike
2011-09-25  5:26       ` Turquette, Mike
2011-10-03 14:17   ` Rob Herring
2011-10-03 14:17     ` Rob Herring
2011-10-03 14:25     ` Mark Brown
2011-10-03 14:25       ` Mark Brown
2011-10-03 15:24       ` Rob Herring
2011-10-03 15:24         ` Rob Herring
2011-10-03 16:31         ` Mark Brown
2011-10-03 16:31           ` Mark Brown
2011-10-03 16:43           ` Russell King - ARM Linux
2011-10-03 16:43             ` Russell King - ARM Linux
2011-10-03 17:05             ` Mark Brown
2011-10-03 17:05               ` Mark Brown
2011-10-04 18:09     ` Grant Likely
2011-10-04 18:09       ` Grant Likely
2011-10-27 11:54     ` Domenico Andreoli
2011-10-27 11:54       ` Domenico Andreoli
2011-10-03 22:02   ` Rob Herring
2011-10-03 22:02     ` Rob Herring
2011-10-03 22:15     ` Turquette, Mike
2011-10-03 22:15       ` Turquette, Mike
2011-10-06  1:17   ` Saravana Kannan
2011-10-06  1:17     ` Saravana Kannan
2011-10-06 16:11     ` Turquette, Mike
2011-10-06 16:11       ` Turquette, Mike
2011-10-11 11:25   ` Richard Zhao
2011-10-11 11:25     ` Richard Zhao
2011-10-13 14:44   ` Russell King - ARM Linux
2011-10-13 14:44     ` Russell King - ARM Linux
2011-10-13 17:16     ` Turquette, Mike
2011-10-13 17:16       ` Turquette, Mike
2011-10-14  8:10   ` Richard Zhao
2011-10-14  8:10     ` Richard Zhao
2011-10-14 10:05     ` Mark Brown
2011-10-14 10:05       ` Mark Brown
2011-10-14 10:32       ` Richard Zhao
2011-10-14 10:32         ` Richard Zhao
2011-10-16 17:55         ` Sascha Hauer
2011-10-16 17:55           ` Sascha Hauer
2011-10-17  8:48           ` Richard Zhao
2011-10-17  8:48             ` Richard Zhao
2011-10-17  9:20             ` Mark Brown
2011-10-17  9:20               ` Mark Brown
2011-10-17 10:53               ` Richard Zhao
2011-10-17 10:53                 ` Richard Zhao
2011-10-17 11:05                 ` Sascha Hauer
2011-10-17 11:05                   ` Sascha Hauer
2011-10-17 11:30                   ` Russell King - ARM Linux [this message]
2011-10-17 11:30                     ` Russell King - ARM Linux
2011-10-14 18:14   ` Turquette, Mike
2011-10-14 18:14     ` Turquette, Mike
2011-10-15  2:24     ` Richard Zhao
2011-10-15  2:24       ` Richard Zhao
2011-10-15  2:34       ` Richard Zhao
2011-10-15  2:34         ` Richard Zhao
2011-10-16 21:17       ` Turquette, Mike
2011-10-16 21:17         ` Turquette, Mike
2011-10-17 11:31         ` Richard Zhao
2011-10-17 11:31           ` Richard Zhao
2011-10-21  9:00   ` Richard Zhao
2011-10-21  9:00     ` Richard Zhao
2011-10-23 12:55   ` Shawn Guo
2011-10-23 12:55     ` Shawn Guo
2011-10-23 16:49     ` Turquette, Mike
2011-10-23 16:49       ` Turquette, Mike
2011-09-22 22:26 ` [PATCH v2 2/7] clk: Implement clk_set_rate Mike Turquette
2011-09-22 22:26   ` Mike Turquette
2011-10-11 11:49   ` Richard Zhao
2011-10-11 11:49     ` Richard Zhao
2011-10-23 14:24   ` Shawn Guo
2011-10-23 14:24     ` Shawn Guo
2011-10-23 16:50     ` Turquette, Mike
2011-10-23 16:50       ` Turquette, Mike
2011-09-22 22:26 ` [PATCH v2 3/7] clk: Add fixed-rate clock Mike Turquette
2011-09-22 22:26   ` Mike Turquette
2011-10-23 14:30   ` Shawn Guo
2011-10-23 14:30     ` Shawn Guo
2011-10-23 16:51     ` Turquette, Mike
2011-10-23 16:51       ` Turquette, Mike
2011-09-22 22:26 ` [PATCH v2 4/7] clk: Add simple gated clock Mike Turquette
2011-09-22 22:26   ` Mike Turquette
2011-09-25  4:02   ` Grant Likely
2011-09-25  4:02     ` Grant Likely
2011-09-25  5:27     ` Turquette, Mike
2011-09-25  5:27       ` Turquette, Mike
2011-09-26 18:33   ` Rob Herring
2011-09-26 18:33     ` Rob Herring
2011-09-26 18:40     ` Jamie Iles
2011-09-26 18:40       ` Jamie Iles
2011-09-26 19:10       ` Rob Herring
2011-09-26 19:10         ` Rob Herring
2011-09-26 19:37         ` Jamie Iles
2011-09-26 19:37           ` Jamie Iles
2011-09-26 22:37           ` Turquette, Mike
2011-09-26 22:37             ` Turquette, Mike
2011-09-26 23:30             ` Rob Herring
2011-09-26 23:30               ` Rob Herring
2011-10-05  1:41               ` Saravana Kannan
2011-10-05  1:41                 ` Saravana Kannan
2011-10-12  6:46   ` Richard Zhao
2011-10-12  6:46     ` Richard Zhao
2011-10-12 14:59     ` Turquette, Mike
2011-10-12 14:59       ` Turquette, Mike
2011-10-16 18:26       ` Sascha Hauer
2011-10-16 18:26         ` Sascha Hauer
2011-10-17  6:42         ` Richard Zhao
2011-10-17  6:42           ` Richard Zhao
2011-10-17 17:46           ` Turquette, Mike
2011-10-17 17:46             ` Turquette, Mike
2011-10-13 14:45   ` Russell King - ARM Linux
2011-10-13 14:45     ` Russell King - ARM Linux
2011-10-13 17:18     ` Turquette, Mike
2011-10-13 17:18       ` Turquette, Mike
2011-09-22 22:27 ` [PATCH v2 5/7] clk: Add Kconfig option to build all generic clk drivers Mike Turquette
2011-09-22 22:27   ` Mike Turquette
2011-09-22 22:27 ` [PATCH v2 6/7] clk: Add initial WM831x clock driver Mike Turquette
2011-09-22 22:27   ` Mike Turquette
2011-09-25  4:08   ` Grant Likely
2011-09-25  4:08     ` Grant Likely
2011-09-25  5:29     ` Turquette, Mike
2011-09-25  5:29       ` Turquette, Mike
2011-09-26  9:38     ` Mark Brown
2011-09-26  9:38       ` Mark Brown
2011-10-04 18:18       ` Grant Likely
2011-10-04 18:18         ` Grant Likely
2011-10-04 20:50         ` Mark Brown
2011-10-04 20:50           ` Mark Brown
2011-10-04 23:22           ` Grant Likely
2011-10-04 23:22             ` Grant Likely
2011-09-22 22:27 ` [PATCH v2 7/7] x86: Enable generic clk API on x86 Mike Turquette
2011-09-22 22:27   ` Mike Turquette
2011-09-22 23:17 ` [PATCH v2 0/7] Add a generic struct clk Turquette, Mike
2011-09-22 23:17   ` Turquette, Mike
2011-09-25  4:10 ` Grant Likely
2011-09-25  4:10   ` Grant Likely
2011-09-29 18:54 ` Mark Brown
2011-09-29 18:54   ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111017113050.GI21648@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=amit.kucheria@linaro.org \
    --cc=arnd.bergmann@linaro.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=dsaxena@linaro.org \
    --cc=eric.miao@linaro.org \
    --cc=grant.likely@secretlab.ca \
    --cc=jeremy.kerr@canonical.com \
    --cc=linaro-dev@lists.linaro.org \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=mturquette@ti.com \
    --cc=patches@linaro.org \
    --cc=paul@pwsan.com \
    --cc=richard.zhao@linaro.org \
    --cc=s.hauer@pengutronix.de \
    --cc=sboyd@quiinc.com \
    --cc=shawn.guo@freescale.com \
    --cc=skannan@quicinc.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.