diff mbox

ARM: shmobile: compile drivers/sh for CONFIG_ARCH_SHMOBILE_MULTI

Message ID 1389707776-23306-2-git-send-email-ben.dooks@codethink.co.uk (mailing list archive)
State Deferred
Headers show

Commit Message

Ben Dooks Jan. 14, 2014, 1:56 p.m. UTC
If the kernel is built to support multi-arm configurmation with shmobile
support built in, then the drivers/sh is not built. This contains drivers
that are essential to devices support by that configuration, including the
PM runtime code in drivers/sh/pm_runtime.c (which implicitly enables the
bus clocks for all devices).

If CONFIG_ARCH_SHMOBILE_MULTI then build the drivers/sh directory,
but ensure that bits that may conflict (drivers/sh/clk if the common
clock framework is not enabled) are built.

The ARCH_SHMOBILE_MULTI was added by efacfce5f8a ("ARM: shmobile: Introduce
ARCH_SHMOBILE_MULTI") but this has only just recently been found due to
changes currently only in Simon Horman's tree. This patch is a partial
revert of bf98c1eac1d4a6b ("ARM: Rename ARCH_SHMOBILE to ARCH_SHMOBILE_LEGACY")
to address the issue of drivers not being built.

It is also possible the drivers/sh/intc will also need to be built
however the lack of intc is not causing a number of drivers to fail
to properly manage their clocks. This is left as an future patch for
someone who understands that part of the code.

Cc: Linus SH list <linux-sh@vger.kernel.org>
Cc: laurent.pinchart+renesas@ideasonboard.com
Cc: Simon Horman <horms@verge.net.au>
Cc: Magnus Damm <magnus.damm@gmail.com>
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 drivers/Makefile    | 2 +-
 drivers/sh/Makefile | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

Comments

Simon Horman Jan. 14, 2014, 11:55 p.m. UTC | #1
On Tue, Jan 14, 2014 at 01:56:16PM +0000, Ben Dooks wrote:
> If the kernel is built to support multi-arm configurmation with shmobile
> support built in, then the drivers/sh is not built. This contains drivers
> that are essential to devices support by that configuration, including the
> PM runtime code in drivers/sh/pm_runtime.c (which implicitly enables the
> bus clocks for all devices).
> 
> If CONFIG_ARCH_SHMOBILE_MULTI then build the drivers/sh directory,
> but ensure that bits that may conflict (drivers/sh/clk if the common
> clock framework is not enabled) are built.
> 
> The ARCH_SHMOBILE_MULTI was added by efacfce5f8a ("ARM: shmobile: Introduce
> ARCH_SHMOBILE_MULTI") but this has only just recently been found due to
> changes currently only in Simon Horman's tree. This patch is a partial
> revert of bf98c1eac1d4a6b ("ARM: Rename ARCH_SHMOBILE to ARCH_SHMOBILE_LEGACY")
> to address the issue of drivers not being built.
> 
> It is also possible the drivers/sh/intc will also need to be built
> however the lack of intc is not causing a number of drivers to fail
> to properly manage their clocks. This is left as an future patch for
>that is perfectly fine. someone who understands that part of the code.

Laurent, what are you feelings on this?

> Cc: Linus SH list <linux-sh@vger.kernel.org>
> Cc: laurent.pinchart+renesas@ideasonboard.com
> Cc: Simon Horman <horms@verge.net.au>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
>  drivers/Makefile    | 2 +-
>  drivers/sh/Makefile | 3 +++
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/Makefile b/drivers/Makefile
> index 8e3b8b0..3cc8214 100644
> --- a/drivers/Makefile
> +++ b/drivers/Makefile
> @@ -118,7 +118,7 @@ obj-$(CONFIG_SGI_SN)		+= sn/
>  obj-y				+= firmware/
>  obj-$(CONFIG_CRYPTO)		+= crypto/
>  obj-$(CONFIG_SUPERH)		+= sh/
> -obj-$(CONFIG_ARCH_SHMOBILE_LEGACY)	+= sh/
> +obj-$(CONFIG_ARCH_SHMOBILE)	+= sh/
>  ifndef CONFIG_ARCH_USES_GETTIMEOFFSET
>  obj-y				+= clocksource/
>  endif
> diff --git a/drivers/sh/Makefile b/drivers/sh/Makefile
> index fc67f56..b4d588c 100644
> --- a/drivers/sh/Makefile
> +++ b/drivers/sh/Makefile
> @@ -3,7 +3,10 @@
>  #
>  obj-y	:= intc/
>  
> +ifneq ($(CONFIG_COMMON_CLK),y)
>  obj-$(CONFIG_HAVE_CLK)		+= clk/
> +endif
> +
>  obj-$(CONFIG_MAPLE)		+= maple/
>  obj-$(CONFIG_SUPERHYWAY)	+= superhyway/
>  
> -- 
> 1.8.5.2
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Laurent Pinchart Jan. 15, 2014, 7:46 p.m. UTC | #2
Hi Simon,

On Wednesday 15 January 2014 08:55:05 Simon Horman wrote:
> On Tue, Jan 14, 2014 at 01:56:16PM +0000, Ben Dooks wrote:
> > If the kernel is built to support multi-arm configurmation with shmobile
> > support built in, then the drivers/sh is not built. This contains drivers
> > that are essential to devices support by that configuration, including the
> > PM runtime code in drivers/sh/pm_runtime.c (which implicitly enables the
> > bus clocks for all devices).
> > 
> > If CONFIG_ARCH_SHMOBILE_MULTI then build the drivers/sh directory,
> > but ensure that bits that may conflict (drivers/sh/clk if the common
> > clock framework is not enabled) are built.
> > 
> > The ARCH_SHMOBILE_MULTI was added by efacfce5f8a ("ARM: shmobile:
> > Introduce ARCH_SHMOBILE_MULTI") but this has only just recently been found
> > due to changes currently only in Simon Horman's tree. This patch is a
> > partial revert of bf98c1eac1d4a6b ("ARM: Rename ARCH_SHMOBILE to
> > ARCH_SHMOBILE_LEGACY") to address the issue of drivers not being built.
> > 
> > It is also possible the drivers/sh/intc will also need to be built
> > however the lack of intc is not causing a number of drivers to fail
> > to properly manage their clocks. This is left as an future patch for
> >that is perfectly fine. someone who understands that part of the code.
> 
> Laurent, what are you feelings on this?

If we end up needing an interrupt controller supported by drivers/sh/intc for 
a multiplatform kernel I would rather like to port the driver to 
drivers/irqchip instead of compiling drivers/sh/intc for the platform.

Regarding drivers/sh/pm_runtime.c, compiling it for ARCH_SHMOBILE_MULTI will 
cause multiplatform kernels running on non-Renesas platforms to add a pm clock 
notifier. We need to at least add a runtime check.

> > Cc: Linus SH list <linux-sh@vger.kernel.org>
> > Cc: laurent.pinchart+renesas@ideasonboard.com
> > Cc: Simon Horman <horms@verge.net.au>
> > Cc: Magnus Damm <magnus.damm@gmail.com>
> > Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> > ---
> > 
> >  drivers/Makefile    | 2 +-
> >  drivers/sh/Makefile | 3 +++
> >  2 files changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/Makefile b/drivers/Makefile
> > index 8e3b8b0..3cc8214 100644
> > --- a/drivers/Makefile
> > +++ b/drivers/Makefile
> > @@ -118,7 +118,7 @@ obj-$(CONFIG_SGI_SN)		+= sn/
> >  obj-y				+= firmware/
> >  obj-$(CONFIG_CRYPTO)		+= crypto/
> >  obj-$(CONFIG_SUPERH)		+= sh/
> > -obj-$(CONFIG_ARCH_SHMOBILE_LEGACY)	+= sh/
> > +obj-$(CONFIG_ARCH_SHMOBILE)	+= sh/
> >  ifndef CONFIG_ARCH_USES_GETTIMEOFFSET
> >  obj-y				+= clocksource/
> >  endif
> > diff --git a/drivers/sh/Makefile b/drivers/sh/Makefile
> > index fc67f56..b4d588c 100644
> > --- a/drivers/sh/Makefile
> > +++ b/drivers/sh/Makefile
> > @@ -3,7 +3,10 @@
> >  #
> >  obj-y	:= intc/
> > 
> > +ifneq ($(CONFIG_COMMON_CLK),y)
> >  obj-$(CONFIG_HAVE_CLK)		+= clk/
> > +endif
> > +
> >  obj-$(CONFIG_MAPLE)		+= maple/
> >  obj-$(CONFIG_SUPERHYWAY)	+= superhyway/
Ben Dooks Jan. 16, 2014, 10:38 a.m. UTC | #3
On 15/01/14 19:46, Laurent Pinchart wrote:
> Hi Simon,
>
> On Wednesday 15 January 2014 08:55:05 Simon Horman wrote:
>> On Tue, Jan 14, 2014 at 01:56:16PM +0000, Ben Dooks wrote:
>>> If the kernel is built to support multi-arm configurmation with shmobile
>>> support built in, then the drivers/sh is not built. This contains drivers
>>> that are essential to devices support by that configuration, including the
>>> PM runtime code in drivers/sh/pm_runtime.c (which implicitly enables the
>>> bus clocks for all devices).
>>>
>>> If CONFIG_ARCH_SHMOBILE_MULTI then build the drivers/sh directory,
>>> but ensure that bits that may conflict (drivers/sh/clk if the common
>>> clock framework is not enabled) are built.
>>>
>>> The ARCH_SHMOBILE_MULTI was added by efacfce5f8a ("ARM: shmobile:
>>> Introduce ARCH_SHMOBILE_MULTI") but this has only just recently been found
>>> due to changes currently only in Simon Horman's tree. This patch is a
>>> partial revert of bf98c1eac1d4a6b ("ARM: Rename ARCH_SHMOBILE to
>>> ARCH_SHMOBILE_LEGACY") to address the issue of drivers not being built.
>>>
>>> It is also possible the drivers/sh/intc will also need to be built
>>> however the lack of intc is not causing a number of drivers to fail
>>> to properly manage their clocks. This is left as an future patch for
>>> that is perfectly fine. someone who understands that part of the code.
>>
>> Laurent, what are you feelings on this?
>
> If we end up needing an interrupt controller supported by drivers/sh/intc for
> a multiplatform kernel I would rather like to port the driver to
> drivers/irqchip instead of compiling drivers/sh/intc for the platform.
>
> Regarding drivers/sh/pm_runtime.c, compiling it for ARCH_SHMOBILE_MULTI will
> cause multiplatform kernels running on non-Renesas platforms to add a pm clock
> notifier. We need to at least add a runtime check.

Hmm, could we move that to the mstp code or add bindings to the
specific architectures that need it?
Ben Dooks Jan. 16, 2014, 5:25 p.m. UTC | #4
On 16/01/14 10:38, Ben Dooks wrote:
> On 15/01/14 19:46, Laurent Pinchart wrote:
>> Hi Simon,
>>
>> On Wednesday 15 January 2014 08:55:05 Simon Horman wrote:
>>> On Tue, Jan 14, 2014 at 01:56:16PM +0000, Ben Dooks wrote:
>>>> If the kernel is built to support multi-arm configurmation with
>>>> shmobile
>>>> support built in, then the drivers/sh is not built. This contains
>>>> drivers
>>>> that are essential to devices support by that configuration,
>>>> including the
>>>> PM runtime code in drivers/sh/pm_runtime.c (which implicitly enables
>>>> the
>>>> bus clocks for all devices).
>>>>
>>>> If CONFIG_ARCH_SHMOBILE_MULTI then build the drivers/sh directory,
>>>> but ensure that bits that may conflict (drivers/sh/clk if the common
>>>> clock framework is not enabled) are built.
>>>>
>>>> The ARCH_SHMOBILE_MULTI was added by efacfce5f8a ("ARM: shmobile:
>>>> Introduce ARCH_SHMOBILE_MULTI") but this has only just recently been
>>>> found
>>>> due to changes currently only in Simon Horman's tree. This patch is a
>>>> partial revert of bf98c1eac1d4a6b ("ARM: Rename ARCH_SHMOBILE to
>>>> ARCH_SHMOBILE_LEGACY") to address the issue of drivers not being built.
>>>>
>>>> It is also possible the drivers/sh/intc will also need to be built
>>>> however the lack of intc is not causing a number of drivers to fail
>>>> to properly manage their clocks. This is left as an future patch for
>>>> that is perfectly fine. someone who understands that part of the code.
>>>
>>> Laurent, what are you feelings on this?
>>
>> If we end up needing an interrupt controller supported by
>> drivers/sh/intc for
>> a multiplatform kernel I would rather like to port the driver to
>> drivers/irqchip instead of compiling drivers/sh/intc for the platform.
>>
>> Regarding drivers/sh/pm_runtime.c, compiling it for
>> ARCH_SHMOBILE_MULTI will
>> cause multiplatform kernels running on non-Renesas platforms to add a
>> pm clock
>> notifier. We need to at least add a runtime check.
>
> Hmm, could we move that to the mstp code or add bindings to the
> specific architectures that need it?

I was having a think, and how about adding the following to each
driver that expects clock management to happen for it, such as the
following in the probe sequence:

	pm_runtime_manage_clock(dev);


This would mean the following:

- People would know a driver had its clock managed elsewhere
- You couldn't build a system with the clock_ops disabled.
- A system where a mix of drivers where used would work fine
- drivers/sh/pm_runtime.c could be deleted too.
Laurent Pinchart Jan. 19, 2014, 9:44 p.m. UTC | #5
Hi Ben,

On Thursday 16 January 2014 17:25:09 Ben Dooks wrote:
> On 16/01/14 10:38, Ben Dooks wrote:
> > On 15/01/14 19:46, Laurent Pinchart wrote:
> >> On Wednesday 15 January 2014 08:55:05 Simon Horman wrote:
> >>> On Tue, Jan 14, 2014 at 01:56:16PM +0000, Ben Dooks wrote:
> >>>> If the kernel is built to support multi-arm configurmation with
> >>>> shmobile support built in, then the drivers/sh is not built. This
> >>>> contains drivers that are essential to devices support by that
> >>>> configuration, including the PM runtime code in drivers/sh/pm_runtime.c
> >>>> (which implicitly enables the bus clocks for all devices).
> >>>> 
> >>>> If CONFIG_ARCH_SHMOBILE_MULTI then build the drivers/sh directory,
> >>>> but ensure that bits that may conflict (drivers/sh/clk if the common
> >>>> clock framework is not enabled) are built.
> >>>> 
> >>>> The ARCH_SHMOBILE_MULTI was added by efacfce5f8a ("ARM: shmobile:
> >>>> Introduce ARCH_SHMOBILE_MULTI") but this has only just recently been
> >>>> found due to changes currently only in Simon Horman's tree. This patch
> >>>> is a partial revert of bf98c1eac1d4a6b ("ARM: Rename ARCH_SHMOBILE to
> >>>> ARCH_SHMOBILE_LEGACY") to address the issue of drivers not being built.
> >>>> 
> >>>> It is also possible the drivers/sh/intc will also need to be built
> >>>> however the lack of intc is not causing a number of drivers to fail
> >>>> to properly manage their clocks. This is left as an future patch for
> >>>> that is perfectly fine. someone who understands that part of the code.
> >>> 
> >>> Laurent, what are you feelings on this?
> >> 
> >> If we end up needing an interrupt controller supported by
> >> drivers/sh/intc for a multiplatform kernel I would rather like to port
> >> the driver to drivers/irqchip instead of compiling drivers/sh/intc for
> >> the platform.
> >> 
> >> Regarding drivers/sh/pm_runtime.c, compiling it for ARCH_SHMOBILE_MULTI
> >> will cause multiplatform kernels running on non-Renesas platforms to add
> >> a pm clock notifier. We need to at least add a runtime check.
> > 
> > Hmm, could we move that to the mstp code or add bindings to the
> > specific architectures that need it?
> 
> I was having a think, and how about adding the following to each
> driver that expects clock management to happen for it, such as the
> following in the probe sequence:
> 
> 	pm_runtime_manage_clock(dev);
> 
> This would mean the following:
> 
> - People would know a driver had its clock managed elsewhere
> - You couldn't build a system with the clock_ops disabled.
> - A system where a mix of drivers where used would work fine
> - drivers/sh/pm_runtime.c could be deleted too.

That sounds like a good idea to me. I like how drivers will be responsible for 
explicitly delegating clock handling to generic code. This combines simplicity 
with flexibility, and doesn't hide clock handling.

Mark, Rafael, any opinion ?
Mark Brown Jan. 20, 2014, 11:47 a.m. UTC | #6
On Sun, Jan 19, 2014 at 10:44:53PM +0100, Laurent Pinchart wrote:
> On Thursday 16 January 2014 17:25:09 Ben Dooks wrote:

> > I was having a think, and how about adding the following to each
> > driver that expects clock management to happen for it, such as the
> > following in the probe sequence:

> > 	pm_runtime_manage_clock(dev);

> > This would mean the following:

> > - People would know a driver had its clock managed elsewhere
> > - You couldn't build a system with the clock_ops disabled.
> > - A system where a mix of drivers where used would work fine
> > - drivers/sh/pm_runtime.c could be deleted too.

> That sounds like a good idea to me. I like how drivers will be responsible for 
> explicitly delegating clock handling to generic code. This combines simplicity 
> with flexibility, and doesn't hide clock handling.

> Mark, Rafael, any opinion ?

I think that just makes things more complicated and isn't adding
anything over pm_runtime_enable(), it's just boilerplate code.  In
theory essentially every driver running on platforms which don't have
explicit management of core IP clocks ought to be calling this since
potentially the IP might be deployed on another platform which does have
clock management (this does actually happen with things like the
DesignWare IPs) and it doesn't do anything like say which clocks are
expected to be managed in this way which is another thing that can come
up when moving devices between platforms.

I'm also struggling to see how it provides any sort of build time
protection, it would allow the generation of a warning at runtime at
best.

As far as I can tell the problem that Ben has seen here is that the
platform really, really needs the code for its power domains running to
be functional (this doesn't seem unreasonable and may not be related to
clocks, this may be required to have the IPs powered up at all).  I'd
expect this is something for the platform to sort out rather than
something for individual drivers to have to carry code for.

If it was going to be drivers carrying code for this I would expect it
to be something like providing a list of clocks to be managed along with
runtime PM - this would also make the code more widely applicable since
it's quite common for the runtime PM callbacks to do nothing more than
just enable and disable clocks.
Ben Dooks Jan. 20, 2014, 12:01 p.m. UTC | #7
On 20/01/14 11:47, Mark Brown wrote:
> On Sun, Jan 19, 2014 at 10:44:53PM +0100, Laurent Pinchart wrote:
>> On Thursday 16 January 2014 17:25:09 Ben Dooks wrote:
>
>>> I was having a think, and how about adding the following to each
>>> driver that expects clock management to happen for it, such as the
>>> following in the probe sequence:
>
>>> 	pm_runtime_manage_clock(dev);
>
>>> This would mean the following:
>
>>> - People would know a driver had its clock managed elsewhere
>>> - You couldn't build a system with the clock_ops disabled.
>>> - A system where a mix of drivers where used would work fine
>>> - drivers/sh/pm_runtime.c could be deleted too.
>
>> That sounds like a good idea to me. I like how drivers will be responsible for
>> explicitly delegating clock handling to generic code. This combines simplicity
>> with flexibility, and doesn't hide clock handling.
>
>> Mark, Rafael, any opinion ?
>
> I think that just makes things more complicated and isn't adding
> anything over pm_runtime_enable(), it's just boilerplate code.  In
> theory essentially every driver running on platforms which don't have
> explicit management of core IP clocks ought to be calling this since
> potentially the IP might be deployed on another platform which does have
> clock management (this does actually happen with things like the
> DesignWare IPs) and it doesn't do anything like say which clocks are
> expected to be managed in this way which is another thing that can come
> up when moving devices between platforms.

That sounds like a real headache where you have two sets of code
looking at possibly the same clocks, and behaving differently between
different platforms.

> I'm also struggling to see how it provides any sort of build time
> protection, it would allow the generation of a warning at runtime at
> best.

If you don't have the code it WILL NOT LINK. At the moment it is
entirely possible to link a kernel which will produce a set of confusing
errors as drivers fail to initialise at startup.

We've already had other people run into the issue where they do not
know why a driver is failing to work (rcar-thermal is one) as the code
that was managing the clock for it magically vanished during the
development cycle.

> As far as I can tell the problem that Ben has seen here is that the
> platform really, really needs the code for its power domains running to
> be functional (this doesn't seem unreasonable and may not be related to
> clocks, this may be required to have the IPs powered up at all).  I'd
> expect this is something for the platform to sort out rather than
> something for individual drivers to have to carry code for.

What's power domains got to do with this? You keep bringing this up
but the error is purely to do with clock management. The code happens
to be sitting in the drivers/base/pm directory, but could easily sit
elsewhere.

> If it was going to be drivers carrying code for this I would expect it
> to be something like providing a list of clocks to be managed along with
> runtime PM - this would also make the code more widely applicable since
> it's quite common for the runtime PM callbacks to do nothing more than
> just enable and disable clocks.

If we are really saying that bus clocks should not be managed
by the drivers, then we should just enable this across the whole
kernel and remove the management from any extant drivers (or make
it so that any drivers that must manage their bus clocks have a
call to do so).
Mark Brown Jan. 20, 2014, 12:54 p.m. UTC | #8
On Mon, Jan 20, 2014 at 12:01:00PM +0000, Ben Dooks wrote:
> On 20/01/14 11:47, Mark Brown wrote:

> >I think that just makes things more complicated and isn't adding
> >anything over pm_runtime_enable(), it's just boilerplate code.  In
> >theory essentially every driver running on platforms which don't have
> >explicit management of core IP clocks ought to be calling this since
> >potentially the IP might be deployed on another platform which does have
> >clock management (this does actually happen with things like the
> >DesignWare IPs) and it doesn't do anything like say which clocks are
> >expected to be managed in this way which is another thing that can come
> >up when moving devices between platforms.

> That sounds like a real headache where you have two sets of code
> looking at possibly the same clocks, and behaving differently between
> different platforms.

Yup, it's usually only one set of code on the client side but it's
annoying that platform integrations aren't done consistently in hardware
and that this flows through into software.

> >I'm also struggling to see how it provides any sort of build time
> >protection, it would allow the generation of a warning at runtime at
> >best.

> If you don't have the code it WILL NOT LINK. At the moment it is
> entirely possible to link a kernel which will produce a set of confusing
> errors as drivers fail to initialise at startup.

How will this prevent the code linking?  I would expect the "manage the
clocks via runtime PM" call to be a bit of core code, I wouldn't expect
it to be provided by a specific platform otherwise we're in for fail in
a multiplatform environment.  Besides, if it fails to link there's some
missing Kconfig anyway since randconfig is supposed to work.

> We've already had other people run into the issue where they do not
> know why a driver is failing to work (rcar-thermal is one) as the code
> that was managing the clock for it magically vanished during the
> development cycle.

I agree there's a usability problem here, I just don't think that this
is the best fix for it, I think it's breaking abstractions.

> >As far as I can tell the problem that Ben has seen here is that the
> >platform really, really needs the code for its power domains running to
> >be functional (this doesn't seem unreasonable and may not be related to
> >clocks, this may be required to have the IPs powered up at all).  I'd
> >expect this is something for the platform to sort out rather than
> >something for individual drivers to have to carry code for.

> What's power domains got to do with this? You keep bringing this up
> but the error is purely to do with clock management. The code happens
> to be sitting in the drivers/base/pm directory, but could easily sit
> elsewhere.

What these platforms are saying is esssentially that the clocks are part
of the power domain - they're a fundamental part of getting the IP
available for use so there is no point in managing them separately.
This is where I think the abstraction problem is coming, to me it seems
like the platform isn't successfully ensuring that the code to manage
the power domain is there.  The fact that part of what's missing is the
clocks shouldn't matter to the drivers, in doing things like this the
platform is trying to abstract that detail away from the drivers.

> >If it was going to be drivers carrying code for this I would expect it
> >to be something like providing a list of clocks to be managed along with
> >runtime PM - this would also make the code more widely applicable since
> >it's quite common for the runtime PM callbacks to do nothing more than
> >just enable and disable clocks.

> If we are really saying that bus clocks should not be managed
> by the drivers, then we should just enable this across the whole
> kernel and remove the management from any extant drivers (or make
> it so that any drivers that must manage their bus clocks have a
> call to do so).

Yes, I think that would be a useful way to go since it would factor out
some common code patterns that keep cropping up (as I suggested to you
previously).  It may not just be the main IP clocks that the drivers are
managing like this (some drivers end up managing other clocks at the
same time even if they could be more flexible) so if it was something
drivers could make use of themselves that'd be good.
Ben Dooks Jan. 20, 2014, 1:19 p.m. UTC | #9
I've added linux-arm-kernel to the list to get a wider view from
people who actively use the clock subsystem.

On 20/01/14 12:54, Mark Brown wrote:
> On Mon, Jan 20, 2014 at 12:01:00PM +0000, Ben Dooks wrote:
>> On 20/01/14 11:47, Mark Brown wrote:
>
>>> I think that just makes things more complicated and isn't adding
>>> anything over pm_runtime_enable(), it's just boilerplate code.  In
>>> theory essentially every driver running on platforms which don't have
>>> explicit management of core IP clocks ought to be calling this since
>>> potentially the IP might be deployed on another platform which does have
>>> clock management (this does actually happen with things like the
>>> DesignWare IPs) and it doesn't do anything like say which clocks are
>>> expected to be managed in this way which is another thing that can come
>>> up when moving devices between platforms.
>
>> That sounds like a real headache where you have two sets of code
>> looking at possibly the same clocks, and behaving differently between
>> different platforms.
>
> Yup, it's usually only one set of code on the client side but it's
> annoying that platform integrations aren't done consistently in hardware
> and that this flows through into software.
>
>>> I'm also struggling to see how it provides any sort of build time
>>> protection, it would allow the generation of a warning at runtime at
>>> best.
>
>> If you don't have the code it WILL NOT LINK. At the moment it is
>> entirely possible to link a kernel which will produce a set of confusing
>> errors as drivers fail to initialise at startup.
>
> How will this prevent the code linking?  I would expect the "manage the
> clocks via runtime PM" call to be a bit of core code, I wouldn't expect
> it to be provided by a specific platform otherwise we're in for fail in
> a multiplatform environment.  Besides, if it fails to link there's some
> missing Kconfig anyway since randconfig is supposed to work.
>
>> We've already had other people run into the issue where they do not
>> know why a driver is failing to work (rcar-thermal is one) as the code
>> that was managing the clock for it magically vanished during the
>> development cycle.
>
> I agree there's a usability problem here, I just don't think that this
> is the best fix for it, I think it's breaking abstractions.
>
>>> As far as I can tell the problem that Ben has seen here is that the
>>> platform really, really needs the code for its power domains running to
>>> be functional (this doesn't seem unreasonable and may not be related to
>>> clocks, this may be required to have the IPs powered up at all).  I'd
>>> expect this is something for the platform to sort out rather than
>>> something for individual drivers to have to carry code for.
>
>> What's power domains got to do with this? You keep bringing this up
>> but the error is purely to do with clock management. The code happens
>> to be sitting in the drivers/base/pm directory, but could easily sit
>> elsewhere.
>
> What these platforms are saying is esssentially that the clocks are part
> of the power domain - they're a fundamental part of getting the IP
> available for use so there is no point in managing them separately.
> This is where I think the abstraction problem is coming, to me it seems
> like the platform isn't successfully ensuring that the code to manage
> the power domain is there.  The fact that part of what's missing is the
> clocks shouldn't matter to the drivers, in doing things like this the
> platform is trying to abstract that detail away from the drivers.
>
>>> If it was going to be drivers carrying code for this I would expect it
>>> to be something like providing a list of clocks to be managed along with
>>> runtime PM - this would also make the code more widely applicable since
>>> it's quite common for the runtime PM callbacks to do nothing more than
>>> just enable and disable clocks.
>
>> If we are really saying that bus clocks should not be managed
>> by the drivers, then we should just enable this across the whole
>> kernel and remove the management from any extant drivers (or make
>> it so that any drivers that must manage their bus clocks have a
>> call to do so).
>
> Yes, I think that would be a useful way to go since it would factor out
> some common code patterns that keep cropping up (as I suggested to you
> previously).  It may not just be the main IP clocks that the drivers are
> managing like this (some drivers end up managing other clocks at the
> same time even if they could be more flexible) so if it was something
> drivers could make use of themselves that'd be good.

At the moment, the code to actually use the support is sitting in
drivers/sh and gets initialised if it is built. This is the source
of the original confusions.

I think it would be ok if drivers could /opt out/ if the bus clock
handling was done like this for all platforms and we simply noted
that the pm code is doing it. At that point it would be nice just
to build the code in drivers/base/power unconditionally.

At the moment we could quite easily enable this code for all the
ARM platforms as the clk framework should deal nicely with properly
balanced clk_enable() and clk_disable() calls.

Enabling it across the board would also remove any issues with
changes in platform behaviour and find any bugs sooner rather than
later.
Laurent Pinchart Jan. 20, 2014, 3:48 p.m. UTC | #10
On Monday 20 January 2014 13:19:07 Ben Dooks wrote:
> I've added linux-arm-kernel to the list to get a wider view from
> people who actively use the clock subsystem.
> 
> On 20/01/14 12:54, Mark Brown wrote:
> > On Mon, Jan 20, 2014 at 12:01:00PM +0000, Ben Dooks wrote:
> >> On 20/01/14 11:47, Mark Brown wrote:
> >>> I think that just makes things more complicated and isn't adding
> >>> anything over pm_runtime_enable(), it's just boilerplate code.  In
> >>> theory essentially every driver running on platforms which don't have
> >>> explicit management of core IP clocks ought to be calling this since
> >>> potentially the IP might be deployed on another platform which does have
> >>> clock management (this does actually happen with things like the
> >>> DesignWare IPs) and it doesn't do anything like say which clocks are
> >>> expected to be managed in this way which is another thing that can come
> >>> up when moving devices between platforms.
> >> 
> >> That sounds like a real headache where you have two sets of code
> >> looking at possibly the same clocks, and behaving differently between
> >> different platforms.
> > 
> > Yup, it's usually only one set of code on the client side but it's
> > annoying that platform integrations aren't done consistently in hardware
> > and that this flows through into software.
> > 
> >>> I'm also struggling to see how it provides any sort of build time
> >>> protection, it would allow the generation of a warning at runtime at
> >>> best.
> >> 
> >> If you don't have the code it WILL NOT LINK. At the moment it is
> >> entirely possible to link a kernel which will produce a set of confusing
> >> errors as drivers fail to initialise at startup.
> > 
> > How will this prevent the code linking?  I would expect the "manage the
> > clocks via runtime PM" call to be a bit of core code, I wouldn't expect
> > it to be provided by a specific platform otherwise we're in for fail in
> > a multiplatform environment.  Besides, if it fails to link there's some
> > missing Kconfig anyway since randconfig is supposed to work.
> > 
> >> We've already had other people run into the issue where they do not
> >> know why a driver is failing to work (rcar-thermal is one) as the code
> >> that was managing the clock for it magically vanished during the
> >> development cycle.
> > 
> > I agree there's a usability problem here, I just don't think that this
> > is the best fix for it, I think it's breaking abstractions.
> > 
> >>> As far as I can tell the problem that Ben has seen here is that the
> >>> platform really, really needs the code for its power domains running to
> >>> be functional (this doesn't seem unreasonable and may not be related to
> >>> clocks, this may be required to have the IPs powered up at all).  I'd
> >>> expect this is something for the platform to sort out rather than
> >>> something for individual drivers to have to carry code for.
> >> 
> >> What's power domains got to do with this? You keep bringing this up
> >> but the error is purely to do with clock management. The code happens
> >> to be sitting in the drivers/base/pm directory, but could easily sit
> >> elsewhere.
> > 
> > What these platforms are saying is esssentially that the clocks are part
> > of the power domain - they're a fundamental part of getting the IP
> > available for use so there is no point in managing them separately.
> > This is where I think the abstraction problem is coming, to me it seems
> > like the platform isn't successfully ensuring that the code to manage
> > the power domain is there.  The fact that part of what's missing is the
> > clocks shouldn't matter to the drivers, in doing things like this the
> > platform is trying to abstract that detail away from the drivers.
> > 
> >>> If it was going to be drivers carrying code for this I would expect it
> >>> to be something like providing a list of clocks to be managed along with
> >>> runtime PM - this would also make the code more widely applicable since
> >>> it's quite common for the runtime PM callbacks to do nothing more than
> >>> just enable and disable clocks.
> >> 
> >> If we are really saying that bus clocks should not be managed
> >> by the drivers, then we should just enable this across the whole
> >> kernel and remove the management from any extant drivers (or make
> >> it so that any drivers that must manage their bus clocks have a
> >> call to do so).
> > 
> > Yes, I think that would be a useful way to go since it would factor out
> > some common code patterns that keep cropping up (as I suggested to you
> > previously).  It may not just be the main IP clocks that the drivers are
> > managing like this (some drivers end up managing other clocks at the
> > same time even if they could be more flexible) so if it was something
> > drivers could make use of themselves that'd be good.
> 
> At the moment, the code to actually use the support is sitting in
> drivers/sh and gets initialised if it is built. This is the source
> of the original confusions.
> 
> I think it would be ok if drivers could /opt out/

Most drivers have a single functional clock (if any) and only need it to be 
enabled/disabled in sync with runtime PM. As this requirements is common, 
making it the default sounds reasonable. Other drivers need to manage their 
clocks, or at least part of their clocks, manually. There are good and bad 
reasons for this, and some bad reasons come from driver code that should be 
fixed, but we can't ignore the problems for now.

The simplest implementation would be a way to let a driver opt-out completely. 
Unless a driver opts out, the runtime PM core will get the default clock for 
the device (with a NULL con ID) and manage it automatically. I'm not sure what 
to do when the runtime PM core fails to get the clock, as this can be caused 
by various problems or non-problems.

One particular problem that needs to be considered is deferred probing. An 
option would be to have all non-SoC devices opt-out from automatic clock 
management, but that will make the opt-out case the most common one. We also 
need to consider IP cores that can be present on-SoC or off-SoC in discrete 
chips.

The problem isn't as simple as it seems, and more advanced implementations 
that would allow listing clocks that should be managed automatically (or the 
other way around) would also add another level of complexity. The required 
information is platform-dependent, but we currently don't express it as such 
in DT.

> if the bus clock handling was done like this for all platforms and we simply
> noted that the pm code is doing it. At that point it would be nice just to
> build the code in drivers/base/power unconditionally.
> 
> At the moment we could quite easily enable this code for all the ARM
> platforms as the clk framework should deal nicely with properly balanced
> clk_enable() and clk_disable() calls.
> 
> Enabling it across the board would also remove any issues with changes in
> platform behaviour and find any bugs sooner rather than later.
Mark Brown Jan. 20, 2014, 3:56 p.m. UTC | #11
On Mon, Jan 20, 2014 at 04:48:10PM +0100, Laurent Pinchart wrote:

> The problem isn't as simple as it seems, and more advanced implementations 
> that would allow listing clocks that should be managed automatically (or the 
> other way around) would also add another level of complexity. The required 
> information is platform-dependent, but we currently don't express it as such 
> in DT.

Well, the set of clocks an IP requires will tend to be the same - it's
normally just that integrators may have done things like tie them
together or decide to spread confusion by renaming them.
Laurent Pinchart Jan. 20, 2014, 10:52 p.m. UTC | #12
Hi Mark,

On Monday 20 January 2014 15:56:43 Mark Brown wrote:
> On Mon, Jan 20, 2014 at 04:48:10PM +0100, Laurent Pinchart wrote:
> > The problem isn't as simple as it seems, and more advanced implementations
> > that would allow listing clocks that should be managed automatically (or
> > the other way around) would also add another level of complexity. The
> > required information is platform-dependent, but we currently don't
> > express it as such in DT.
> 
> Well, the set of clocks an IP requires will tend to be the same - it's
> normally just that integrators may have done things like tie them together
> or decide to spread confusion by renaming them.

That's the problem :-) How should the runtime PM core be given the list of 
clocks it needs to manage ? That information needs to come from somewhere.
Geert Uytterhoeven March 11, 2014, 7:15 p.m. UTC | #13
Hi Laurent,

On Mon, Jan 20, 2014 at 11:52 PM, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> On Monday 20 January 2014 15:56:43 Mark Brown wrote:
>> On Mon, Jan 20, 2014 at 04:48:10PM +0100, Laurent Pinchart wrote:
>> > The problem isn't as simple as it seems, and more advanced implementations
>> > that would allow listing clocks that should be managed automatically (or
>> > the other way around) would also add another level of complexity. The
>> > required information is platform-dependent, but we currently don't
>> > express it as such in DT.
>>
>> Well, the set of clocks an IP requires will tend to be the same - it's
>> normally just that integrators may have done things like tie them together
>> or decide to spread confusion by renaming them.
>
> That's the problem :-) How should the runtime PM core be given the list of
> clocks it needs to manage ? That information needs to come from somewhere.

Stirring the pot again...

Which clocks a device needs is expressed in DT with CCF.
In the simple case, the runtime PM core can just control them based on
device use.
In the complex case, the driver can regain control using its own pm
callbacks, right?

Probably I'm still missing something, as I haven't had enough exposure to
runtime PM and CCF ;-)

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Laurent Pinchart March 12, 2014, 2:18 p.m. UTC | #14
Hi Geert,

On Tuesday 11 March 2014 20:15:04 Geert Uytterhoeven wrote:
> On Mon, Jan 20, 2014 at 11:52 PM, Laurent Pinchart wrote:
> > On Monday 20 January 2014 15:56:43 Mark Brown wrote:
> >> On Mon, Jan 20, 2014 at 04:48:10PM +0100, Laurent Pinchart wrote:
> >> > The problem isn't as simple as it seems, and more advanced
> >> > implementations that would allow listing clocks that should be managed
> >> > automatically (or the other way around) would also add another level of
> >> > complexity. The required information is platform-dependent, but we
> >> > currently don't express it as such in DT.
> >> 
> >> Well, the set of clocks an IP requires will tend to be the same - it's
> >> normally just that integrators may have done things like tie them
> >> together or decide to spread confusion by renaming them.
> > 
> > That's the problem :-) How should the runtime PM core be given the list of
> > clocks it needs to manage ? That information needs to come from somewhere.
> 
> Stirring the pot again...
> 
> Which clocks a device needs is expressed in DT with CCF.
> In the simple case, the runtime PM core can just control them based on
> device use.
> In the complex case, the driver can regain control using its own pm
> callbacks, right?

Sure, the driver can of course control the clocks manually in its PM callbacks 
if it needs to. The point, however, is to control the clocks from core code 
whenever possible. We thus need to define exact semantics to make sure each 
side knows what tasks to perform, and what to expect from the other side. For 
instance, in the DT case, the runtime PM core can easily get the list of the 
clocks used by the device from its DT node, but how can it know which clock(s) 
it should manage automatically and which clock(s) it should leave for the 
driver to control ?

> Probably I'm still missing something, as I haven't had enough exposure to
> runtime PM and CCF ;-)
Laurent Pinchart March 12, 2014, 3:28 p.m. UTC | #15
Hi Geert,

On Wednesday 12 March 2014 15:18:46 Laurent Pinchart wrote:
> On Tuesday 11 March 2014 20:15:04 Geert Uytterhoeven wrote:
> > On Mon, Jan 20, 2014 at 11:52 PM, Laurent Pinchart wrote:
> > > On Monday 20 January 2014 15:56:43 Mark Brown wrote:
> > >> On Mon, Jan 20, 2014 at 04:48:10PM +0100, Laurent Pinchart wrote:
> > >> > The problem isn't as simple as it seems, and more advanced
> > >> > implementations that would allow listing clocks that should be
> > >> > managed automatically (or the other way around) would also add
> > >> > another level of complexity. The required information is platform-
> > >> > dependent, but we currently don't express it as such in DT.
> > >> 
> > >> Well, the set of clocks an IP requires will tend to be the same - it's
> > >> normally just that integrators may have done things like tie them
> > >> together or decide to spread confusion by renaming them.
> > > 
> > > That's the problem :-) How should the runtime PM core be given the list
> > > of clocks it needs to manage ? That information needs to come from
> > > somewhere.
> > 
> > Stirring the pot again...
> > 
> > Which clocks a device needs is expressed in DT with CCF.
> > In the simple case, the runtime PM core can just control them based on
> > device use.
> > In the complex case, the driver can regain control using its own pm
> > callbacks, right?
> 
> Sure, the driver can of course control the clocks manually in its PM
> callbacks if it needs to. The point, however, is to control the clocks from
> core code whenever possible. We thus need to define exact semantics to make
> sure each side knows what tasks to perform, and what to expect from the
> other side. For instance, in the DT case, the runtime PM core can easily
> get the list of the clocks used by the device from its DT node, but how can
> it know which clock(s) it should manage automatically and which clock(s) it
> should leave for the driver to control ?
> 
> > Probably I'm still missing something, as I haven't had enough exposure to
> > runtime PM and CCF ;-)

If you haven't seen it already, https://lkml.org/lkml/2014/1/31/290 
("[RFC/PATCH] base: platform: add generic clock handling for platform-bus") 
might be related.
diff mbox

Patch

diff --git a/drivers/Makefile b/drivers/Makefile
index 8e3b8b0..3cc8214 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -118,7 +118,7 @@  obj-$(CONFIG_SGI_SN)		+= sn/
 obj-y				+= firmware/
 obj-$(CONFIG_CRYPTO)		+= crypto/
 obj-$(CONFIG_SUPERH)		+= sh/
-obj-$(CONFIG_ARCH_SHMOBILE_LEGACY)	+= sh/
+obj-$(CONFIG_ARCH_SHMOBILE)	+= sh/
 ifndef CONFIG_ARCH_USES_GETTIMEOFFSET
 obj-y				+= clocksource/
 endif
diff --git a/drivers/sh/Makefile b/drivers/sh/Makefile
index fc67f56..b4d588c 100644
--- a/drivers/sh/Makefile
+++ b/drivers/sh/Makefile
@@ -3,7 +3,10 @@ 
 #
 obj-y	:= intc/
 
+ifneq ($(CONFIG_COMMON_CLK),y)
 obj-$(CONFIG_HAVE_CLK)		+= clk/
+endif
+
 obj-$(CONFIG_MAPLE)		+= maple/
 obj-$(CONFIG_SUPERHYWAY)	+= superhyway/