lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20111017113050.GI21648@n2100.arm.linux.org.uk>
Date:	Mon, 17 Oct 2011 12:30:50 +0100
From:	Russell King - ARM Linux <linux@....linux.org.uk>
To:	Sascha Hauer <s.hauer@...gutronix.de>
Cc:	Richard Zhao <richard.zhao@...aro.org>,
	Mark Brown <broonie@...nsource.wolfsonmicro.com>,
	jeremy.kerr@...onical.com, paul@...an.com,
	linaro-dev@...ts.linaro.org, linus.walleij@...ricsson.com,
	patches@...aro.org, shawn.guo@...escale.com, magnus.damm@...il.com,
	linux-kernel@...r.kernel.org, eric.miao@...aro.org,
	grant.likely@...retlab.ca, dsaxena@...aro.org,
	amit.kucheria@...aro.org, skannan@...cinc.com,
	arnd.bergmann@...aro.org, sboyd@...inc.com, tglx@...utronix.de,
	linux-arm-kernel@...ts.infradead.org,
	Mike Turquette <mturquette@...com>
Subject: Re: [PATCH v2 1/7] clk: Add a generic clock infrastructure

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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ