Subsystems (2)
Subject: [PATCH v2 0/4] clk: st: New clock domain
v1 => v2:
- Turned the ST specific driver into a generic one
Hardware can have a bunch of clocks which must not be turned off. If drivers a) fail to obtain a reference to any of these or b) give up a previously obtained reference during suspend, the common clk framework will attempt to turn them off and the hardware will subsequently die. The only way to recover from this failure is to restart.
To avoid either of these two scenarios from catastrophically disabling the running system we have implemented a clock domain where clocks are consumed and references are taken, thus preventing them from being shut down by the framework.
Lee Jones (4):
ARM: sti: stih407-family: Supply defines for CLOCKGEN A0
ARM: sti: stih407-family: Provide Clock Domain information
clk: Provide an always-on clock domain framework
clk: dt: Introduce always-on clock domain documentation
.../devicetree/bindings/clock/clk-domain.txt | 35 ++++++++++++ arch/arm/boot/dts/stih407-family.dtsi | 13 +++++ drivers/clk/Makefile | 1 + drivers/clk/clkdomain.c | 63 ++++++++++++++++++++++ include/dt-bindings/clock/stih407-clks.h | 4 ++ 5 files changed, 116 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/clk-domain.txt create mode 100644 drivers/clk/clkdomain.c
Signature · 1 line
1.9.1
PATCH v2 1/4 ARM: sti: stih407-family: Supply defines for CLOCKGEN A0
There are 2 LMI clocks generated by CLOCKGEN A0. We wish to control them individually and need to use these indexes to do so.
--- include/dt-bindings/clock/stih407-clks.h | 4 ++++ 1 file changed, 4 insertions(+)
include/dt-bindings/clock/stih407-clks.h +4 -0
@@ -5,6 +5,10 @@#ifndef _DT_BINDINGS_CLK_STIH407#define _DT_BINDINGS_CLK_STIH407 +/* CLOCKGEN A0 */ +#define CLK_IC_LMI0 0 +#define CLK_IC_LMI1 1 +/* CLOCKGEN C0 */ #define CLK_ICN_GPU 0#define CLK_FDMA 1
Signature · 1 line
1.9.1
PATCH v2 2/4 ARM: sti: stih407-family: Provide Clock Domain information
In reply to Lee JonesCertain clocks should not be turned of by clk_disable_unused. Until now we have been using the kernel command-line of the same name to prevent common clk from turning off all clocks without a reference, as this would ensure hardware lockup. This patch lists each clock which need to stay on to prevent the aforementioned issue from arising.
--- arch/arm/boot/dts/stih407-family.dtsi | 13 +++++++++++++ 1 file changed, 13 insertions(+)
arch/arm/boot/dts/stih407-family.dtsi +13 -0
@@ -34,6 +34,19 @@ reg = <0x08761000 0x1000>, <0x08760100 0x100>; }; + clk-domain { + compatible = "always-on-clk-domain"; + clocks = <&clk_s_c0_flexgen CLK_EXT2F_A9>, + <&clk_s_c0_flexgen CLK_COMPO_DVP>, + <&clk_s_c0_flexgen CLK_MMC_1>, + <&clk_s_c0_flexgen CLK_ICN_SBC>, + <&clk_s_c0_flexgen CLK_ICN_LMI>, + <&clk_s_c0_flexgen CLK_ICN_CPU>, + <&clk_s_c0_flexgen CLK_TX_ICN_DMU>, + <&clk_s_a0_flexgen CLK_IC_LMI0>, + <&clk_m_a9>; + }; + scu at 08760000 { compatible = "arm,cortex-a9-scu"; reg = <0x08760000 0x1000>;
Signature · 1 line
1.9.1
PATCH v2 3/4 clk: Provide an always-on clock domain framework
In reply to Lee JonesMuch h/w contain clocks which if turned off would prove fatal. The only way to recover is to restart the board(s). This driver takes references to clocks which are required to be always-on in order to prevent the common clk framework from trying to turn them off during the clk_disabled_unused() procedure.
--- drivers/clk/Makefile | 1 + drivers/clk/clkdomain.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 drivers/clk/clkdomain.c
drivers/clk/Makefile +1 -0
@@ -3,6 +3,7 @@ obj-$(CONFIG_HAVE_CLK) += clk-devres.o obj-$(CONFIG_CLKDEV_LOOKUP) += clkdev.o obj-$(CONFIG_COMMON_CLK) += clk.o obj-$(CONFIG_COMMON_CLK) += clk-divider.o +obj-$(CONFIG_COMMON_CLK) += clkdomain.o obj-$(CONFIG_COMMON_CLK) += clk-fixed-factor.o obj-$(CONFIG_COMMON_CLK) += clk-fixed-rate.o obj-$(CONFIG_COMMON_CLK) += clk-gate.o
drivers/clk/clkdomain.c new file +63 -0
63 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [STLinux Kernel] [PATCH v2 3/4] clk: Provide an always-on clock domain framework
Hi Lee,
Quoted 2 lines · Lee Jones
+/*
+ * ST Clock Domain
minor nit, as v2 is a generic driver, comment needs updating.
regards,
Peter.
Re: [PATCH v2 3/4] clk: Provide an always-on clock domain framework
In reply to Lee JonesQuoting Lee Jones (2015-02-18 08:15:00)
drivers/clk/clkdomain.c
Quoted 30 lines
Much h/w contain clocks which if turned off would prove fatal. The only way to recover is to restart the board(s). This driver takes references to clocks which are required to be always-on in order to prevent the common clk framework from trying to turn them off during the
clk_disabled_unused()procedure.Signed-off-by Lee Jones <[email protected]>--- drivers/clk/Makefile | 1 + drivers/clk/clkdomain.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 drivers/clk/clkdomain.cdrivers/clk/Makefile +1
-0@@ -3,6 +3,7 @@ obj-$(CONFIG_HAVE_CLK) += clk-devres.o obj-$(CONFIG_CLKDEV_LOOKUP) += clkdev.o obj-$(CONFIG_COMMON_CLK) += clk.o obj-$(CONFIG_COMMON_CLK) += clk-divider.o +obj-$(CONFIG_COMMON_CLK) += clkdomain.o obj-$(CONFIG_COMMON_CLK) += clk-fixed-factor.o obj-$(CONFIG_COMMON_CLK) += clk-fixed-rate.o obj-$(CONFIG_COMMON_CLK) += clk-gate.odrivers/clk/clkdomain.c new file +0
-0
Naming is hard. I'm not sure clkdomain.c is the best expression. Maybe clk-alwon.c? I see ALWON used alot amongst hardware people who live in a world of eight-character naming limitations.
Quoted 5 lines
drivers/clk/clkdomain.c new file +4
-0@@ -0,0 +1,63 @@ +/* +* ST Clock Domain +* +* Copyright (C) 2015 STMicroelectronics ? All Rights Reserved
drivers/clk/clkdomain.c line 14
Quoted 10 lines
drivers/clk/clkdomain.c new file +10
-0+* +* Author: Lee Jones <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ + +#include <linux/clk-private.h>
If this header still existed I would berate you mercilessly. Luckily for you it no longer exists and only causes a compile error ;-)
Quoted 19 lines
drivers/clk/clkdomain.c new file +19
-0+#include <linux/clk-provider.h> +#include <linux/of_address.h> +#include <linux/of.h> +#include <linux/platform_device.h> + +static void ao_clock_domain_hog_clock (struct platform_device *pdev,int index) +{ +struct device_node *np = pdev->dev.of_node; +struct clk *clk; +int ret; + + clk =of_clk_get (np, index); +if (IS_ERR (clk)) { +dev_warn (&pdev->dev,"Failed get clock %s[%d]: %li\n" , + np->full_name, index,PTR_ERR (clk)); +return ; + } + + ret =clk_prepare_enable (clk);
drivers/clk/clkdomain.c line 43
Quoted 10 lines
drivers/clk/clkdomain.c new file +10
-0+if (ret) +dev_warn (&pdev->dev,"Failed to enable clock: %s\n" , clk->name); +} + +static int ao_clock_domain_probe (struct platform_device *pdev) +{ +struct device_node *np = pdev->dev.of_node; +int nclks, i; + + nclks =of_count_phandle_with_args (np,"clocks" ,"#clock-cells" );
Minor nitpick: please use of_clk_get_parent_count. I spent a solid 5 minutes writing that function and I need people to use it so I can get a return on my investment.
Otherwise the patch looks good. I believe that this method is targeting always-on clock in a production environment, which is different from the CLK_IGNORE_UNUSED stuff which typically is helpful while bringing up new hardware or dealing with a platform that has incomplete driver support.
I wonder if there is a clever way for existing clock providers (expressed in DT) to use this without having to create a separate node of clocks with the "always-on-clk-domain" flag. Possibly the common clock binding could declare some always-on flag that is standardized? Then the framework core could use this code easily. Not sure if that is a good idea though...
Regards,
Mike
Quoted 23 lines
drivers/clk/clkdomain.c new file +20
-0+ +for (i =0 ; i < nclks; i++) +ao_clock_domain_hog_clock (pdev, i); + +return 0 ; +} + +static const struct of_device_id ao_clock_domain_match[] = { + { .compatible ="always-on-clk-domain" }, + { }, +}; + +static struct platform_driver ao_clock_domain_driver = { + .probe = ao_clock_domain_probe, + .driver = { + .name ="always-on-clk-domain" , + .of_match_table = ao_clock_domain_match, + }, +}; +module_platform_driver (ao_clock_domain_driver);Signature · 1 line
1.9.1
Re: [PATCH v2 3/4] clk: Provide an always-on clock domain framework
Quoted 27 lines · Mike Turquette
Quoting Lee Jones (2015-02-18 08:15:00)
Quoted 26 lines
Much h/w contain clocks which if turned off would prove fatal. The only way to recover is to restart the board(s). This driver takes references to clocks which are required to be always-on in order to prevent the common clk framework from trying to turn them off during the
clk_disabled_unused()procedure.Signed-off-by Lee Jones <[email protected]>--- drivers/clk/Makefile | 1 + drivers/clk/clkdomain.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 drivers/clk/clkdomain.cdrivers/clk/Makefile +1
-0@@ -3,6 +3,7 @@ obj-$(CONFIG_HAVE_CLK) += clk-devres.o obj-$(CONFIG_CLKDEV_LOOKUP) += clkdev.o obj-$(CONFIG_COMMON_CLK) += clk.o obj-$(CONFIG_COMMON_CLK) += clk-divider.o +obj-$(CONFIG_COMMON_CLK) += clkdomain.o obj-$(CONFIG_COMMON_CLK) += clk-fixed-factor.o obj-$(CONFIG_COMMON_CLK) += clk-fixed-rate.o obj-$(CONFIG_COMMON_CLK) += clk-gate.odrivers/clk/clkdomain.c +0
-0
Quoted 8 lines
drivers/clk/clkdomain.c
Quoted 4 lines
new file mode 100644
index 0000000..8c83f99drivers/clk/clkdomain.c new file +0
-0Naming is hard. I'm not sure
clkdomain.cis the best expression. Maybeclk-alwon.c? I see ALWON used alot amongst hardware people who live in a world of eight-character naming limitations.
If you can have clk-fractional-divider.c in your subsystem, I'm sure clk-always-on.c will be suitable.
Quoted 3 lines
drivers/clk/clkdomain.c line 2
Quoted 3 lines
drivers/clk/clkdomain.c new file +2
-0@@ -0,0 +1,63 @@ +/* +* Always on Clock Domain
=;-)
Quoted 6 lines
Quoted 6 lines
drivers/clk/clkdomain.c new file +6
-0+* Copyright (C) 2015 STMicroelectronics ? All Rights Reserved +* +* Author: Lee Jones <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by
Quoted 8 lines
drivers/clk/clkdomain.c line 14
Quoted 5 lines
drivers/clk/clkdomain.c new file +5
-0+* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ + +#include <linux/clk-private.h> If this header still existed I would berate you mercilessly. Luckily for you it no longer exists and only causes a compile error ;-)
Noted.
You may wish to update: Documentation/clk.txt accordingly.
Quoted 25 lines
Quoted 25 lines
drivers/clk/clkdomain.c new file +25
-0+#include <linux/clk-provider.h> +#include <linux/of_address.h> +#include <linux/of.h> +#include <linux/platform_device.h> + +static void ao_clock_domain_hog_clock (struct platform_device *pdev,int index) +{ +struct device_node *np = pdev->dev.of_node; +struct clk *clk; +int ret; + + clk =of_clk_get (np, index); +if (IS_ERR (clk)) { +dev_warn (&pdev->dev,"Failed get clock %s[%d]: %li\n" , + np->full_name, index,PTR_ERR (clk)); +return ; + } + + ret =clk_prepare_enable (clk); +if (ret) +dev_warn (&pdev->dev,"Failed to enable clock: %s\n" , clk->name); +} + +static int ao_clock_domain_probe (struct platform_device *pdev) +{
Quoted 8 lines
drivers/clk/clkdomain.c line 43
Quoted 4 lines
drivers/clk/clkdomain.c new file +4
-0+struct device_node *np = pdev->dev.of_node; +int nclks, i; + + nclks =of_count_phandle_with_args (np,"clocks" ,"#clock-cells" );Minor nitpick: please use
of_clk_get_parent_count. I spent a solid 5 minutes writing that function and I need people to use it so I can get a return on my investment.
My middle name is RoI. I'm on it.
Quoted 11 lines
Otherwise the patch looks good. I believe that this method is targeting always-on clock in a production environment, which is different from the
CLK_IGNORE_UNUSEDstuff which typically is helpful while bringing up new hardware or dealing with a platform that has incomplete driver support.I wonder if there is a clever way for existing clock providers (expressed in DT) to use this without having to create a separate node of clocks with the "always-on-clk-domain" flag. Possibly the common clock binding could declare some always-on flag that is standardized? Then the framework core could use this code easily. Not sure if that is a good idea though...
I think having both would be a good idea. If all clocks supplied by a provider should be left on, then a property inside the provider node could be a good way to describe that. In our case only some of them are required, so I consider this concept to be better.
Quoted 20 lines
Quoted 20 lines
drivers/clk/clkdomain.c new file +20
-0+ +for (i =0 ; i < nclks; i++) +ao_clock_domain_hog_clock (pdev, i); + +return 0 ; +} + +static const struct of_device_id ao_clock_domain_match[] = { + { .compatible ="always-on-clk-domain" }, + { }, +}; + +static struct platform_driver ao_clock_domain_driver = { + .probe = ao_clock_domain_probe, + .driver = { + .name ="always-on-clk-domain" , + .of_match_table = ao_clock_domain_match, + }, +}; +module_platform_driver (ao_clock_domain_driver);
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v2 3/4] clk: Provide an always-on clock domain framework
In reply to Mike TurquetteQuoted 6 lines · Mike Turquette
Quoting Lee Jones (2015-02-18 08:15:00)
Quoted 5 lines
Much h/w contain clocks which if turned off would prove fatal. The only way to recover is to restart the board(s). This driver takes references to clocks which are required to be always-on in order to prevent the common clk framework from trying to turn them off during the
clk_disabled_unused()procedure.
[...]
Quoted 11 lines
drivers/clk/clkdomain.c line 43
Quoted 6 lines
drivers/clk/clkdomain.c new file +6
-0+static int ao_clock_domain_probe (struct platform_device *pdev) +{ +struct device_node *np = pdev->dev.of_node; +int nclks, i; + + nclks =of_count_phandle_with_args (np,"clocks" ,"#clock-cells" );Minor nitpick: please use
of_clk_get_parent_count. I spent a solid 5 minutes writing that function and I need people to use it so I can get a return on my investment.
Quoted 4 lines
Otherwise the patch looks good. I believe that this method is targeting always-on clock in a production environment, which is different from the
CLK_IGNORE_UNUSEDstuff which typically is helpful while bringing up new hardware or dealing with a platform that has incomplete driver support.
There is also the usecase of keep clocks on until I load a module that properly handles my hardware (e.g simplefb). We have a simplefb node with clocks and the simplefb driver jumps thru some hoops to hand-off clocks to the real driver. I don't really like it and don't want to see more examples. And there is the case of I thought I would never manage this clock, but kernel subsystems evolve and now I want to manage a clock. This should not require a DT update to do so.
Neither of these may be Lee's usecase, but I want to see them covered by the binding.
Quoted 6 lines
I wonder if there is a clever way for existing clock providers (expressed in DT) to use this without having to create a separate node of clocks with the "always-on-clk-domain" flag. Possibly the common clock binding could declare some always-on flag that is standardized? Then the framework core could use this code easily. Not sure if that is a good idea though...
I would prefer to see the always on clocks just listed within the clock controller's node rather than creating made up nodes with clock properties. This should be always-on until claimed IMO, but that aspect is the OS's problem, not a DT problem.
Rob
Re: [PATCH v2 3/4] clk: Provide an always-on clock domain framework
Quoted 44 lines · Rob Herring
Quoted 6 lines · Mike Turquette
Quoting Lee Jones (2015-02-18 08:15:00)
Quoted 5 lines
Much h/w contain clocks which if turned off would prove fatal. The only way to recover is to restart the board(s). This driver takes references to clocks which are required to be always-on in order to prevent the common clk framework from trying to turn them off during the
clk_disabled_unused()procedure.[...]
Quoted 11 lines
drivers/clk/clkdomain.c line 43
Quoted 6 lines
drivers/clk/clkdomain.c new file +6
-0+static int ao_clock_domain_probe (struct platform_device *pdev) +{ +struct device_node *np = pdev->dev.of_node; +int nclks, i; + + nclks =of_count_phandle_with_args (np,"clocks" ,"#clock-cells" );Minor nitpick: please use
of_clk_get_parent_count. I spent a solid 5 minutes writing that function and I need people to use it so I can get a return on my investment.Quoted 4 lines
Otherwise the patch looks good. I believe that this method is targeting always-on clock in a production environment, which is different from the
CLK_IGNORE_UNUSEDstuff which typically is helpful while bringing up new hardware or dealing with a platform that has incomplete driver support.There is also the usecase of keep clocks on until I load a module that properly handles my hardware (e.g simplefb). We have a simplefb node with clocks and the simplefb driver jumps thru some hoops to hand-off clocks to the real driver. I don't really like it and don't want to see more examples. And there is the case of I thought I would never manage this clock, but kernel subsystems evolve and now I want to manage a clock. This should not require a DT update to do so.
Neither of these may be Lee's usecase, but I want to see them covered by the binding.
Quoted 6 lines
I wonder if there is a clever way for existing clock providers (expressed in DT) to use this without having to create a separate node of clocks with the "always-on-clk-domain" flag. Possibly the common clock binding could declare some always-on flag that is standardized? Then the framework core could use this code easily. Not sure if that is a good idea though...
Quoted 6 lines
I would prefer to see the always on clocks just listed within the clock controller's node rather than creating made up nodes with clock properties.
This should be always-on until claimed IMO, but that aspect is the OS's problem, not a DT problem.
I disagree with this point. There are likely to be many unclaimed, but perfectly gateable clocks in a system, which will consume power unnecessarily. The clk framework does the right thing by turning all unclaimed clocks off IMHO. This only leaves a small use-case where we need to artificially claim some which must not be gated.
The other way to do is, as you mentioned is list the clocks which must stay on in the clock source node, but this will still require a binding. It will also require a much more complicated framework driver.
clkprovider at xxxxxxxx {
always-on-clks = <1, 2, 4, 5, 7>;
};Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v2 3/4] clk: Provide an always-on clock domain framework
Quoting Lee Jones (2015-02-25 07:48:08)
Quoted 50 lines · Rob Herring
Quoted 48 lines · Mike Turquette
Quoted 6 lines
Quoting Lee Jones (2015-02-18 08:15:00)
Quoted 5 lines
Much h/w contain clocks which if turned off would prove fatal. The only way to recover is to restart the board(s). This driver takes references to clocks which are required to be always-on in order to prevent the common clk framework from trying to turn them off during the
clk_disabled_unused()procedure.[...]
Quoted 11 lines
drivers/clk/clkdomain.c line 43
Quoted 6 lines
drivers/clk/clkdomain.c new file +6
-0+static int ao_clock_domain_probe (struct platform_device *pdev) +{ +struct device_node *np = pdev->dev.of_node; +int nclks, i; + + nclks =of_count_phandle_with_args (np,"clocks" ,"#clock-cells" );Minor nitpick: please use
of_clk_get_parent_count. I spent a solid 5 minutes writing that function and I need people to use it so I can get a return on my investment.Quoted 4 lines
Otherwise the patch looks good. I believe that this method is targeting always-on clock in a production environment, which is different from the
CLK_IGNORE_UNUSEDstuff which typically is helpful while bringing up new hardware or dealing with a platform that has incomplete driver support.There is also the usecase of keep clocks on until I load a module that properly handles my hardware (e.g simplefb). We have a simplefb node with clocks and the simplefb driver jumps thru some hoops to hand-off clocks to the real driver. I don't really like it and don't want to see more examples. And there is the case of I thought I would never manage this clock, but kernel subsystems evolve and now I want to manage a clock. This should not require a DT update to do so.
Neither of these may be Lee's usecase, but I want to see them covered by the binding.
Quoted 6 lines
I wonder if there is a clever way for existing clock providers (expressed in DT) to use this without having to create a separate node of clocks with the "always-on-clk-domain" flag. Possibly the common clock binding could declare some always-on flag that is standardized? Then the framework core could use this code easily. Not sure if that is a good idea though...
I would prefer to see the always on clocks just listed within the clock controller's node rather than creating made up nodes with clock properties.
Quoted 8 lines
Quoted 2 lines
This should be always-on until claimed IMO, but that aspect is the OS's problem, not a DT problem.
I disagree with this point. There are likely to be many unclaimed, but perfectly gateable clocks in a system, which will consume power unnecessarily. The clk framework does the right thing by turning all unclaimed clocks off IMHO. This only leaves a small use-case where we need to artificially claim some which must not be gated.
I might have misread both of your mails, but I think you two are actually in agreement. You both support a common property which lists the always-on clocks inside of the common clock binding, no?
Quoted 9 lines
The other way to do is, as you mentioned is list the clocks which must stay on in the clock source node, but this will still require a binding. It will also require a much more complicated framework driver.
clkprovider at xxxxxxxx { always-on-clks = <1, 2, 4, 5, 7>; };
This should pose no burden on the driver. Since always-on-clks is in the common clock binding it should be handled by the framework core. At clk_register-time we can check for always-on-clks, walk the list and see if we have a match. It's ugly O(n^2) but it works.
Thoughts?
Mike
Quoted 5 lines
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH v2 3/4 clk: Provide an always-on clock domain framework
In reply to Rob HerringQuoting Rob Herring (2015-02-25 07:24:43)
Quoted 26 lines · Mike Turquette
Quoted 6 lines
Quoting Lee Jones (2015-02-18 08:15:00)
Quoted 5 lines
Much h/w contain clocks which if turned off would prove fatal. The only way to recover is to restart the board(s). This driver takes references to clocks which are required to be always-on in order to prevent the common clk framework from trying to turn them off during the
clk_disabled_unused()procedure.[...]
Quoted 11 lines
drivers/clk/clkdomain.c line 43
Quoted 6 lines
drivers/clk/clkdomain.c new file +6
-0+static int ao_clock_domain_probe (struct platform_device *pdev) +{ +struct device_node *np = pdev->dev.of_node; +int nclks, i; + + nclks =of_count_phandle_with_args (np,"clocks" ,"#clock-cells" );Minor nitpick: please use
of_clk_get_parent_count. I spent a solid 5 minutes writing that function and I need people to use it so I can get a return on my investment.Quoted 4 lines
Otherwise the patch looks good. I believe that this method is targeting always-on clock in a production environment, which is different from the
CLK_IGNORE_UNUSEDstuff which typically is helpful while bringing up new hardware or dealing with a platform that has incomplete driver support.
Quoted 7 lines
There is also the usecase of keep clocks on until I load a module that properly handles my hardware (e.g simplefb). We have a simplefb node with clocks and the simplefb driver jumps thru some hoops to hand-off clocks to the real driver. I don't really like it and don't want to see more examples. And there is the case of I thought I would never manage this clock, but kernel subsystems evolve and now I want to manage a clock. This should not require a DT update to do so.
Regarding the latter case, this is a violation of the intent of always-on clocks. I think a firmly worded sentence in the binding should suffice.
Quoted 11 lines
Neither of these may be Lee's usecase, but I want to see them covered by the binding.
Quoted 6 lines
I wonder if there is a clever way for existing clock providers (expressed in DT) to use this without having to create a separate node of clocks with the "always-on-clk-domain" flag. Possibly the common clock binding could declare some always-on flag that is standardized? Then the framework core could use this code easily. Not sure if that is a good idea though...
Quoted 4 lines
I would prefer to see the always on clocks just listed within the clock controller's node rather than creating made up nodes with clock properties. This should be always-on until claimed IMO, but that aspect is the OS's problem, not a DT problem.
So the common clock binding could have a new always-on list added to it, but the clock can still be claimed and gated by drivers? I'll think on it a bit but always-on is not the right name in that case. It is a more general solution however (since it could still cover the sub-case of clocks always remaining on since a driver never claims them).
Regards,
Mike
Quoted 2 lines
Rob
PATCH v2 4/4 clk: dt: Introduce always-on clock domain documentation
In reply to Lee Jones--- .../devicetree/bindings/clock/clk-domain.txt | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/clk-domain.txt
Documentation/devicetree/bindings/clock/clk-domain.txt new file +35 -0
@@ -0,0 +1,35 @@ +Always-on Clock Domain + +Some hardware is contains bunches of clocks which must never be +turned off. If drivers a) fail to obtain a reference to any of +these or b) give up a previously obtained reference during suspend, +the common clk framework will attempt to disable them and the +hardware can fail irrecoverably. Usually, the only way to recover +from these failures is to restart. + +To avoid either of these two scenarios from catastrophically +disabling an otherwise perfectly healthy running system, we have +implemented a clock domain where clocks are consumed and references +are taken, thus preventing them from being shut down by the +framework. + +We use the generic clock bindings found in: + Documentation/devicetree/bindings/clock/clock-bindings.txt + +Required properties: +- compatible : Must be "always-on-clk-domain" + +Example: + +clk-domain { + compatible = "always-on-clk-domain"; + clocks = <&clk_s_c0_flexgen CLK_EXT2F_A9>, + <&clk_s_c0_flexgen CLK_COMPO_DVP>, + <&clk_s_c0_flexgen CLK_MMC_1>, + <&clk_s_c0_flexgen CLK_ICN_SBC>, + <&clk_s_c0_flexgen CLK_ICN_LMI>, + <&clk_s_c0_flexgen CLK_ICN_CPU>, + <&clk_s_c0_flexgen CLK_TX_ICN_DMU>, + <&clk_s_a0_flexgen CLK_IC_LMI0>, + <&clk_m_a9>; +};
Signature · 1 line
1.9.1
Re: [PATCH v2 4/4] clk: dt: Introduce always-on clock domain documentation
Quoted 12 lines · Lee Jones
Signed-off-by Lee Jones <[email protected]>--- .../devicetree/bindings/clock/clk-domain.txt | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/clk-domain.txtDocumentation/devicetree/bindings/clock/clk-domain.txt new file +0
-0
Documentation/devicetree/bindings/clock/clk-domain.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/clock/clk-domain.txt new file +8
-0@@ -0,0 +1,35 @@ +Always-on Clock Domain + +Some hardware is contains bunches of clocks which must never be +turned off. If drivers a) fail to obtain a reference to any of +these or b) give up a previously obtained reference during suspend, +the common clk framework will attempt to disable them and the +hardware can fail irrecoverably. Usually, the only way to recover +from these failures is to restart.
How is (b) not a bug?
While I think we need something here, I worry that this will be abused to be a list of clocks you have not gotten around to managing. We cannot be changing the DT every time the kernel starts managing a clock. I think this should operate more as always on until claimed. But then you get into drivers having to be aware that the clock started enabled.
Also, I feel like we are using DT to work around kernel policy (of turning off clocks). If the policy was to leave on clocks, then we would be trying to put a list of clocks to disable in DT.
Rob
Quoted 35 lines
Documentation/devicetree/bindings/clock/clk-domain.txt new file +27
-1+ +To avoid either of these two scenarios from catastrophically +disabling an otherwise perfectly healthy running system, we have +implemented a clock domain where clocks are consumed and references +are taken, thus preventing them from being shut down by the +framework. + +We use the generic clock bindings found in: + Documentation/devicetree/bindings/clock/clock-bindings.txt + +Required properties: +- compatible : Must be "always-on-clk-domain" + +Example: + +clk-domain { + compatible = "always-on-clk-domain"; + clocks = <&clk_s_c0_flexgen CLK_EXT2F_A9>, + <&clk_s_c0_flexgen CLK_COMPO_DVP>, + <&clk_s_c0_flexgen CLK_MMC_1>, + <&clk_s_c0_flexgen CLK_ICN_SBC>, + <&clk_s_c0_flexgen CLK_ICN_LMI>, + <&clk_s_c0_flexgen CLK_ICN_CPU>, + <&clk_s_c0_flexgen CLK_TX_ICN_DMU>, + <&clk_s_a0_flexgen CLK_IC_LMI0>, + <&clk_m_a9>; +}; --1.9.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 4/4] clk: dt: Introduce always-on clock domain documentation
Quoted 7 lines · Rob Herring
Quoted 6 lines · Lee Jones
Signed-off-by Lee Jones <[email protected]>--- .../devicetree/bindings/clock/clk-domain.txt | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/clk-domain.txt
Quoted 16 lines
Quoted 6 lines
Documentation/devicetree/bindings/clock/clk-domain.txt new file +0
-0Documentation/devicetree/bindings/clock/clk-domain.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/clock/clk-domain.txt new file +8
-0@@ -0,0 +1,35 @@ +Always-on Clock Domain + +Some hardware is contains bunches of clocks which must never be +turned off. If drivers a) fail to obtain a reference to any of +these or b) give up a previously obtained reference during suspend, +the common clk framework will attempt to disable them and the +hardware can fail irrecoverably. Usually, the only way to recover +from these failures is to restart.How is (b) not a bug?
Clocks are normally disabled during suspend. When clocks are disabled they give up their reference. If references reach 0, the clock is gated. If one of these clocks is gated, the system will never come out of suspend.
How is it a bug?
Quoted 2 lines
While I think we need something here, I worry that this will be abused to be a list of clocks you have not gotten around to managing. We
You can say that about any framework. It's our responsibility to ask the right questions and to disallow it from being abused. The clocks I use in the (real-world) example in this set are _really_ always-on. If any of them are turned off the system will cease to perform in any meaningful way.
Quoted 2 lines
cannot be changing the DT every time the kernel starts managing a clock. I think this should operate more as always on until claimed.
The point of this is that even when these clocks are claimed, there is an issue that when unclaimed (i.e. during suspend) the clk framework will attempt to gate them, and when they do *boom*.
Quoted 2 lines
But then you get into drivers having to be aware that the clock started enabled.
This has nothing to do with the initial state of the clock. It's whether the clock is integral (i.e. is part of a vital interconnect) that's important. For instance, ST's bootloader turns on lots of clocks which can be safely gated if unused. The clocks we're registering with this always-on framework cannot.
Quoted 3 lines
Also, I feel like we are using DT to work around kernel policy (of turning off clocks). If the policy was to leave on clocks, then we would be trying to put a list of clocks to disable in DT.
I'm not sure I understand your point. The current policy is correct if it's power that you care about, which is invariably the point of disabling clocks in the first place, right? Also, this has nothing to do with DT per say. It's just another framework driver.
Quoted 32 lines
Quoted 32 lines
Documentation/devicetree/bindings/clock/clk-domain.txt new file +26
-0+To avoid either of these two scenarios from catastrophically +disabling an otherwise perfectly healthy running system, we have +implemented a clock domain where clocks are consumed and references +are taken, thus preventing them from being shut down by the +framework. + +We use the generic clock bindings found in: + Documentation/devicetree/bindings/clock/clock-bindings.txt + +Required properties: +- compatible : Must be "always-on-clk-domain" + +Example: + +clk-domain { + compatible = "always-on-clk-domain"; + clocks = <&clk_s_c0_flexgen CLK_EXT2F_A9>, + <&clk_s_c0_flexgen CLK_COMPO_DVP>, + <&clk_s_c0_flexgen CLK_MMC_1>, + <&clk_s_c0_flexgen CLK_ICN_SBC>, + <&clk_s_c0_flexgen CLK_ICN_LMI>, + <&clk_s_c0_flexgen CLK_ICN_CPU>, + <&clk_s_c0_flexgen CLK_TX_ICN_DMU>, + <&clk_s_a0_flexgen CLK_IC_LMI0>, + <&clk_m_a9>; +};_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v2 4/4] clk: dt: Introduce always-on clock domain documentation
Quoted 26 lines · Lee Jones
Quoted 7 lines · Rob Herring
Quoted 6 lines · Lee Jones
Signed-off-by Lee Jones <[email protected]>--- .../devicetree/bindings/clock/clk-domain.txt | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/clk-domain.txtQuoted 16 lines
Quoted 6 lines
Documentation/devicetree/bindings/clock/clk-domain.txt new file +0
-0Documentation/devicetree/bindings/clock/clk-domain.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/clock/clk-domain.txt new file +8
-0@@ -0,0 +1,35 @@ +Always-on Clock Domain + +Some hardware is contains bunches of clocks which must never be +turned off. If drivers a) fail to obtain a reference to any of +these or b) give up a previously obtained reference during suspend, +the common clk framework will attempt to disable them and the +hardware can fail irrecoverably. Usually, the only way to recover +from these failures is to restart.How is (b) not a bug?
Quoted 6 lines
Clocks are normally disabled during suspend. When clocks are disabled they give up their reference. If references reach 0, the clock is gated. If one of these clocks is gated, the system will never come out of suspend.
How is it a bug?
It a clock needs to be enabled during suspend, then the driver using it should not disable it. Anyway, suspend is a bit orthogonal to this issue.
Quoted 8 lines
Quoted 2 lines
While I think we need something here, I worry that this will be abused to be a list of clocks you have not gotten around to managing. We
You can say that about any framework. It's our responsibility to ask the right questions and to disallow it from being abused. The clocks I use in the (real-world) example in this set are _really_ always-on. If any of them are turned off the system will cease to perform in any meaningful way.
You cannot tell here up front whether clocks are really always-on. A reviewer is not going to know, and the submitter may not even have all the documentation and know the answer. Getting it wrong here means you have to change the dtb to fix it. Granted, it doesn't really break things in this case.
Quoted 7 lines
Quoted 2 lines
cannot be changing the DT every time the kernel starts managing a clock. I think this should operate more as always on until claimed.
The point of this is that even when these clocks are claimed, there is an issue that when unclaimed (i.e. during suspend) the clk framework will attempt to gate them, and when they do *boom*.
Quoted 8 lines
Quoted 2 lines
But then you get into drivers having to be aware that the clock started enabled.
This has nothing to do with the initial state of the clock. It's whether the clock is integral (i.e. is part of a vital interconnect) that's important. For instance, ST's bootloader turns on lots of clocks which can be safely gated if unused. The clocks we're registering with this always-on framework cannot.
It does because you have to assume either the initial state is wrong and you need to disable it, or that the initial state is correct and you need to leave the clock enabled.
There are also other usecases such as simplefb where you want to leave clocks on until the real fb driver takes over. Consoles have a similar issue.
Perhaps you need to model your buses more completely? Does simple-pm-bus help you?
Quoted 8 lines
Quoted 3 lines
Also, I feel like we are using DT to work around kernel policy (of turning off clocks). If the policy was to leave on clocks, then we would be trying to put a list of clocks to disable in DT.
I'm not sure I understand your point. The current policy is correct if it's power that you care about, which is invariably the point of disabling clocks in the first place, right? Also, this has nothing to do with DT per say. It's just another framework driver.
It does have something to do with DT because you are designing a binding around what the kernel does. Should the kernel assume it can disable clocks safely? Another OS may do the opposite and assume it cannot turn-off unused clocks. Then you would have a list of clocks safe to disable in DT.
This is also completely solvable within the framework driver by claiming those clocks in the clock controller driver.
Rob
Re: [PATCH v2 4/4] clk: dt: Introduce always-on clock domain documentation
Quoted 32 lines · Rob Herring
Quoted 31 lines · Lee Jones
Quoted 7 lines · Rob Herring
Quoted 6 lines · Lee Jones
Signed-off-by Lee Jones <[email protected]>--- .../devicetree/bindings/clock/clk-domain.txt | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/clk-domain.txtQuoted 16 lines
Quoted 6 lines
Documentation/devicetree/bindings/clock/clk-domain.txt new file +0
-0Documentation/devicetree/bindings/clock/clk-domain.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/clock/clk-domain.txt new file +8
-0@@ -0,0 +1,35 @@ +Always-on Clock Domain + +Some hardware is contains bunches of clocks which must never be +turned off. If drivers a) fail to obtain a reference to any of +these or b) give up a previously obtained reference during suspend, +the common clk framework will attempt to disable them and the +hardware can fail irrecoverably. Usually, the only way to recover +from these failures is to restart.How is (b) not a bug?
Clocks are normally disabled during suspend. When clocks are disabled they give up their reference. If references reach 0, the clock is gated. If one of these clocks is gated, the system will never come out of suspend.
Quoted 5 lines
Quoted 1 line
How is it a bug?
It a clock needs to be enabled during suspend, then the driver using it should not disable it. Anyway, suspend is a bit orthogonal to this issue.
IMO, it's not the driver's responsibility to know which clock they are using and whether it's a critical clock or not.
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
While I think we need something here, I worry that this will be abused to be a list of clocks you have not gotten around to managing. We
You can say that about any framework. It's our responsibility to ask the right questions and to disallow it from being abused. The clocks I use in the (real-world) example in this set are _really_ always-on. If any of them are turned off the system will cease to perform in any meaningful way.
Quoted 5 lines
You cannot tell here up front whether clocks are really always-on. A reviewer is not going to know, and the submitter may not even have all the documentation and know the answer. Getting it wrong here means you have to change the dtb to fix it. Granted, it doesn't really break things in this case.
We should make it clear in the documentation that this framework should only be used if the clock is a critical "if it's turned off it will cripple the system" one.
Quoted 16 lines
Quoted 7 lines
Quoted 2 lines
cannot be changing the DT every time the kernel starts managing a clock. I think this should operate more as always on until claimed.
The point of this is that even when these clocks are claimed, there is an issue that when unclaimed (i.e. during suspend) the clk framework will attempt to gate them, and when they do *boom*.
Quoted 8 lines
Quoted 2 lines
But then you get into drivers having to be aware that the clock started enabled.
This has nothing to do with the initial state of the clock. It's whether the clock is integral (i.e. is part of a vital interconnect) that's important. For instance, ST's bootloader turns on lots of clocks which can be safely gated if unused. The clocks we're registering with this always-on framework cannot.
Quoted 3 lines
It does because you have to assume either the initial state is wrong and you need to disable it, or that the initial state is correct and you need to leave the clock enabled.
I think the kernel's policy is a good one i.e. wait until all devices are probed and have had the opportunity to take the clocks they need, at which point we can usually safely gate the remainder. These types of clocks are the exception however; hence the need for this driver. There are other vendors which have similar issues with their h/w. These are currently using bespoke versions of this implementation, but IMO a generic solution would be better.
Quoted 3 lines
There are also other usecases such as simplefb where you want to leave clocks on until the real fb driver takes over. Consoles have a similar issue.
Why wouldn't these devices have taken references by the time clk_disable_unused() is called?
Quoted 1 line
Perhaps you need to model your buses more completely?
Would you mind explaining this a little more please?
Quoted 1 line
Does simple-pm-bus help you?
I have no idea what this is, and I'm struggling to grep for it too?
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Also, I feel like we are using DT to work around kernel policy (of turning off clocks). If the policy was to leave on clocks, then we would be trying to put a list of clocks to disable in DT.
Quoted 8 lines
Quoted 4 lines
I'm not sure I understand your point. The current policy is correct if it's power that you care about, which is invariably the point of disabling clocks in the first place, right? Also, this has nothing to do with DT per say. It's just another framework driver.
It does have something to do with DT because you are designing a binding around what the kernel does. Should the kernel assume it can disable clocks safely?
I guess it depends on what you're trying to achieve. Personally I think the kernel's policy is a good one, especually with regards to power saving. What are you suggesting? A new policy?
Quoted 3 lines
Another OS may do the opposite and assume it
cannot turn-off unused clocks. Then you would have a list of clocks safe to disable in DT.
Sounds bananas. What's good about that kind of policy? It wouldn't matter anyway, both of these implementations can live harmoniously in the same tree.
Quoted 2 lines
This is also completely solvable within the framework driver by claiming those clocks in the clock controller driver.
This conversation has now gone full circle. This was an earlier suggestion, but it was considered hacky, and I'm inclined to agree. An always-on power domain was deemed to be a much more elegant solution.
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v2 4/4] clk: dt: Introduce always-on clock domain documentation
Quoted 34 lines · Lee Jones
Quoted 32 lines · Rob Herring
Quoted 31 lines · Lee Jones
Quoted 7 lines · Rob Herring
Quoted 6 lines · Lee Jones
Signed-off-by Lee Jones <[email protected]>--- .../devicetree/bindings/clock/clk-domain.txt | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/clk-domain.txtQuoted 16 lines
Quoted 6 lines
Documentation/devicetree/bindings/clock/clk-domain.txt new file +0
-0Documentation/devicetree/bindings/clock/clk-domain.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/clock/clk-domain.txt new file +8
-0@@ -0,0 +1,35 @@ +Always-on Clock Domain + +Some hardware is contains bunches of clocks which must never be +turned off. If drivers a) fail to obtain a reference to any of +these or b) give up a previously obtained reference during suspend, +the common clk framework will attempt to disable them and the +hardware can fail irrecoverably. Usually, the only way to recover +from these failures is to restart.How is (b) not a bug?
Clocks are normally disabled during suspend. When clocks are disabled they give up their reference. If references reach 0, the clock is gated. If one of these clocks is gated, the system will never come out of suspend.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
How is it a bug?
It a clock needs to be enabled during suspend, then the driver using it should not disable it. Anyway, suspend is a bit orthogonal to this issue.
IMO, it's not the driver's responsibility to know which clock they are using and whether it's a critical clock or not.
Certainly drivers should not know about clocks outside of their h/w block, but they absolutely should know if a clock is needed for wake-up.
Quoted 47 lines
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
While I think we need something here, I worry that this will be abused to be a list of clocks you have not gotten around to managing. We
You can say that about any framework. It's our responsibility to ask the right questions and to disallow it from being abused. The clocks I use in the (real-world) example in this set are _really_ always-on. If any of them are turned off the system will cease to perform in any meaningful way.
Quoted 5 lines
You cannot tell here up front whether clocks are really always-on. A reviewer is not going to know, and the submitter may not even have all the documentation and know the answer. Getting it wrong here means you have to change the dtb to fix it. Granted, it doesn't really break things in this case.
We should make it clear in the documentation that this framework should only be used if the clock is a critical "if it's turned off it will cripple the system" one.
Quoted 16 lines
Quoted 7 lines
Quoted 2 lines
cannot be changing the DT every time the kernel starts managing a clock. I think this should operate more as always on until claimed.
The point of this is that even when these clocks are claimed, there is an issue that when unclaimed (i.e. during suspend) the clk framework will attempt to gate them, and when they do *boom*.
Quoted 8 lines
Quoted 2 lines
But then you get into drivers having to be aware that the clock started enabled.
This has nothing to do with the initial state of the clock. It's whether the clock is integral (i.e. is part of a vital interconnect) that's important. For instance, ST's bootloader turns on lots of clocks which can be safely gated if unused. The clocks we're registering with this always-on framework cannot.
Quoted 3 lines
It does because you have to assume either the initial state is wrong and you need to disable it, or that the initial state is correct and you need to leave the clock enabled.
I think the kernel's policy is a good one i.e. wait until all devices are probed and have had the opportunity to take the clocks they need, at which point we can usually safely gate the remainder. These types of clocks are the exception however; hence the need for this driver. There are other vendors which have similar issues with their h/w. These are currently using bespoke versions of this implementation, but IMO a generic solution would be better.
Quoted 6 lines
Quoted 3 lines
There are also other usecases such as simplefb where you want to leave clocks on until the real fb driver takes over. Consoles have a similar issue.
Why wouldn't these devices have taken references by the time
clk_disable_unused()is called?
Not if the drivers are modules.
Quoted 7 lines
Quoted 1 line
Perhaps you need to model your buses more completely?
Would you mind explaining this a little more please?
Quoted 1 line
Does simple-pm-bus help you?
I have no idea what this is, and I'm struggling to grep for it too?
http://lwn.net/Articles/632058/
I'm not saying this works as-is for you, but people are starting to add bus properties to buses.
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
Also, I feel like we are using DT to work around kernel policy (of turning off clocks). If the policy was to leave on clocks, then we would be trying to put a list of clocks to disable in DT.
I'm not sure I understand your point. The current policy is correct if it's power that you care about, which is invariably the point of disabling clocks in the first place, right? Also, this has nothing to do with DT per say. It's just another framework driver.
Quoted 7 lines
Quoted 3 lines
It does have something to do with DT because you are designing a binding around what the kernel does. Should the kernel assume it can disable clocks safely?
I guess it depends on what you're trying to achieve. Personally I think the kernel's policy is a good one, especually with regards to power saving. What are you suggesting? A new policy?
No. The binding just has to work no matter what the OS policy.
Quoted 7 lines
Quoted 3 lines
Another OS may do the opposite and assume it
cannot turn-off unused clocks. Then you would have a list of clocks safe to disable in DT.Sounds bananas. What's good about that kind of policy? It wouldn't matter anyway, both of these implementations can live harmoniously in the same tree.
Your systems won't go *boom*.
Quoted 5 lines
Quoted 2 lines
This is also completely solvable within the framework driver by claiming those clocks in the clock controller driver.
This conversation has now gone full circle. This was an earlier suggestion, but it was considered hacky, and I'm inclined to agree.
The clock maintainer doesn't want hacks in the clock framework and the DT maintainer doesn't want them in DT... We should put them in MFD. ;)
Quoted 2 lines
An always-on power domain was deemed to be a much more elegant solution.
Now you are mixing in power domains?
I'm not saying we can't put something in DT. I'm okay with that, but it needs to handle the case of the clocks do get claimed either after boot (e.g. by a module) or in later kernels without a dtb change.
Rob
Re: [PATCH v2 4/4] clk: dt: Introduce always-on clock domain documentation
Quoted 95 lines · Rob Herring
Quoted 34 lines · Lee Jones
Quoted 32 lines · Rob Herring
Quoted 31 lines · Lee Jones
Quoted 7 lines · Rob Herring
Quoted 6 lines · Lee Jones
Signed-off-by Lee Jones <[email protected]>--- .../devicetree/bindings/clock/clk-domain.txt | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/clk-domain.txtQuoted 16 lines
Quoted 6 lines
Documentation/devicetree/bindings/clock/clk-domain.txt new file +0
-0Documentation/devicetree/bindings/clock/clk-domain.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/clock/clk-domain.txt new file +8
-0@@ -0,0 +1,35 @@ +Always-on Clock Domain + +Some hardware is contains bunches of clocks which must never be +turned off. If drivers a) fail to obtain a reference to any of +these or b) give up a previously obtained reference during suspend, +the common clk framework will attempt to disable them and the +hardware can fail irrecoverably. Usually, the only way to recover +from these failures is to restart.How is (b) not a bug?
Clocks are normally disabled during suspend. When clocks are disabled they give up their reference. If references reach 0, the clock is gated. If one of these clocks is gated, the system will never come out of suspend.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
How is it a bug?
It a clock needs to be enabled during suspend, then the driver using it should not disable it. Anyway, suspend is a bit orthogonal to this issue.
IMO, it's not the driver's responsibility to know which clock they are using and whether it's a critical clock or not.
Certainly drivers should not know about clocks outside of their h/w block, but they absolutely should know if a clock is needed for wake-up.
Quoted 47 lines
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
While I think we need something here, I worry that this will be abused to be a list of clocks you have not gotten around to managing. We
You can say that about any framework. It's our responsibility to ask the right questions and to disallow it from being abused. The clocks I use in the (real-world) example in this set are _really_ always-on. If any of them are turned off the system will cease to perform in any meaningful way.
Quoted 5 lines
You cannot tell here up front whether clocks are really always-on. A reviewer is not going to know, and the submitter may not even have all the documentation and know the answer. Getting it wrong here means you have to change the dtb to fix it. Granted, it doesn't really break things in this case.
We should make it clear in the documentation that this framework should only be used if the clock is a critical "if it's turned off it will cripple the system" one.
Quoted 16 lines
Quoted 7 lines
Quoted 2 lines
cannot be changing the DT every time the kernel starts managing a clock. I think this should operate more as always on until claimed.
The point of this is that even when these clocks are claimed, there is an issue that when unclaimed (i.e. during suspend) the clk framework will attempt to gate them, and when they do *boom*.
Quoted 8 lines
Quoted 2 lines
But then you get into drivers having to be aware that the clock started enabled.
This has nothing to do with the initial state of the clock. It's whether the clock is integral (i.e. is part of a vital interconnect) that's important. For instance, ST's bootloader turns on lots of clocks which can be safely gated if unused. The clocks we're registering with this always-on framework cannot.
Quoted 3 lines
It does because you have to assume either the initial state is wrong and you need to disable it, or that the initial state is correct and you need to leave the clock enabled.
I think the kernel's policy is a good one i.e. wait until all devices are probed and have had the opportunity to take the clocks they need, at which point we can usually safely gate the remainder. These types of clocks are the exception however; hence the need for this driver. There are other vendors which have similar issues with their h/w. These are currently using bespoke versions of this implementation, but IMO a generic solution would be better.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
There are also other usecases such as simplefb where you want to leave clocks on until the real fb driver takes over. Consoles have a similar issue.
Why wouldn't these devices have taken references by the time
clk_disable_unused()is called?Not if the drivers are modules.
Can you rightfully compile the drivers for your monitor and serial console as modules and expect them to work until you load them?
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Perhaps you need to model your buses more completely?
Would you mind explaining this a little more please?
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Does simple-pm-bus help you?
I have no idea what this is, and I'm struggling to grep for it too?
http://lwn.net/Articles/632058/
I'm not saying this works as-is for you, but people are starting to add bus properties to buses.
I'm struggling to see how this might help. Which node would you probe as simple-pm-bus? It sounds like a very bloated and convoluted way of saying "don't gate these clocks". Besides, isn't this the opposite what what we're trying to achieve? We don't want to enable any PM on these clocks, let along runtime PM. FYI, I also looked into genpd, but came to the same set of conclusions.
Quoted 48 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
Also, I feel like we are using DT to work around kernel policy (of turning off clocks). If the policy was to leave on clocks, then we would be trying to put a list of clocks to disable in DT.
I'm not sure I understand your point. The current policy is correct if it's power that you care about, which is invariably the point of disabling clocks in the first place, right? Also, this has nothing to do with DT per say. It's just another framework driver.
Quoted 7 lines
Quoted 3 lines
It does have something to do with DT because you are designing a binding around what the kernel does. Should the kernel assume it can disable clocks safely?
I guess it depends on what you're trying to achieve. Personally I think the kernel's policy is a good one, especually with regards to power saving. What are you suggesting? A new policy?
No. The binding just has to work no matter what the OS policy.
Quoted 7 lines
Quoted 3 lines
Another OS may do the opposite and assume it
cannot turn-off unused clocks. Then you would have a list of clocks safe to disable in DT.Sounds bananas. What's good about that kind of policy? It wouldn't matter anyway, both of these implementations can live harmoniously in the same tree.
Your systems won't go *boom*.
Quoted 5 lines
Quoted 2 lines
This is also completely solvable within the framework driver by claiming those clocks in the clock controller driver.
This conversation has now gone full circle. This was an earlier suggestion, but it was considered hacky, and I'm inclined to agree.
The clock maintainer doesn't want hacks in the clock framework and the DT maintainer doesn't want them in DT... We should put them in MFD. ;)
Quoted 2 lines
An always-on power domain was deemed to be a much more elegant solution.
Now you are mixing in power domains?
I'm not saying we can't put something in DT. I'm okay with that, but it needs to handle the case of the clocks do get claimed either after boot (e.g. by a module) or in later kernels without a dtb change.
Rob
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v2 4/4] clk: dt: Introduce always-on clock domain documentation
In reply to Lee JonesHi Lee,
Quoted 14 lines · Lee Jones
Quoted 14 lines
Quoted 14 lines
Quoted 8 lines
Documentation/devicetree/bindings/clock/clk-domain.txt line 8
Quoted 6 lines
Documentation/devicetree/bindings/clock/clk-domain.txt new file +6
-0+Some hardware is contains bunches of clocks which must never be +turned off. If drivers a) fail to obtain a reference to any of +these or b) give up a previously obtained reference during suspend, +the common clk framework will attempt to disable them and the +hardware can fail irrecoverably. Usually, the only way to recover +from these failures is to restart.How is (b) not a bug?
Clocks are normally disabled during suspend. When clocks are disabled they give up their reference. If references reach 0, the clock is gated. If one of these clocks is gated, the system will never come out of suspend.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
How is it a bug?
It a clock needs to be enabled during suspend, then the driver using it should not disable it. Anyway, suspend is a bit orthogonal to this issue.
IMO, it's not the driver's responsibility to know which clock they are using and whether it's a critical clock or not.
So it's (partly) a platform/bus issue.
Quoted 18 lines
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
While I think we need something here, I worry that this will be abused to be a list of clocks you have not gotten around to managing. We
You can say that about any framework. It's our responsibility to ask the right questions and to disallow it from being abused. The clocks I use in the (real-world) example in this set are _really_ always-on. If any of them are turned off the system will cease to perform in any meaningful way.
Quoted 5 lines
You cannot tell here up front whether clocks are really always-on. A reviewer is not going to know, and the submitter may not even have all the documentation and know the answer. Getting it wrong here means you have to change the dtb to fix it. Granted, it doesn't really break things in this case.
We should make it clear in the documentation that this framework should only be used if the clock is a critical "if it's turned off it will cripple the system" one.
[...]
Quoted 7 lines
I think the kernel's policy is a good one i.e. wait until all devices are probed and have had the opportunity to take the clocks they need, at which point we can usually safely gate the remainder. These types of clocks are the exception however; hence the need for this driver. There are other vendors which have similar issues with their h/w. These are currently using bespoke versions of this implementation, but IMO a generic solution would be better.
What kind of clocks are these? What do they control? Memory controllers? Bus controllers?
They must control some device(s), so there should be one or more device nodes in DT that reference these clocks.
As soon as that information is in DT, support can be added to Linux to make sure the "critical" clocks stay enabled, either through a real driver, or through platform code.
Quoted 3 lines
Quoted 1 line
Does simple-pm-bus help you?
I have no idea what this is, and I'm struggling to grep for it too?
Rob already provided a pointer.
If you have more questions, feel free to ask!
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at 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
Re: [PATCH v2 4/4] clk: dt: Introduce always-on clock domain documentation
Quoted 55 lines · Geert Uytterhoeven
Quoted 14 lines · Lee Jones
Quoted 14 lines
Quoted 14 lines
Quoted 8 lines
Documentation/devicetree/bindings/clock/clk-domain.txt line 8
Quoted 6 lines
Documentation/devicetree/bindings/clock/clk-domain.txt new file +6
-0+Some hardware is contains bunches of clocks which must never be +turned off. If drivers a) fail to obtain a reference to any of +these or b) give up a previously obtained reference during suspend, +the common clk framework will attempt to disable them and the +hardware can fail irrecoverably. Usually, the only way to recover +from these failures is to restart.How is (b) not a bug?
Clocks are normally disabled during suspend. When clocks are disabled they give up their reference. If references reach 0, the clock is gated. If one of these clocks is gated, the system will never come out of suspend.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
How is it a bug?
It a clock needs to be enabled during suspend, then the driver using it should not disable it. Anyway, suspend is a bit orthogonal to this issue.
IMO, it's not the driver's responsibility to know which clock they are using and whether it's a critical clock or not.
So it's (partly) a platform/bus issue.
Quoted 18 lines
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
While I think we need something here, I worry that this will be abused to be a list of clocks you have not gotten around to managing. We
You can say that about any framework. It's our responsibility to ask the right questions and to disallow it from being abused. The clocks I use in the (real-world) example in this set are _really_ always-on. If any of them are turned off the system will cease to perform in any meaningful way.
Quoted 5 lines
You cannot tell here up front whether clocks are really always-on. A reviewer is not going to know, and the submitter may not even have all the documentation and know the answer. Getting it wrong here means you have to change the dtb to fix it. Granted, it doesn't really break things in this case.
We should make it clear in the documentation that this framework should only be used if the clock is a critical "if it's turned off it will cripple the system" one.
[...]
Quoted 7 lines
I think the kernel's policy is a good one i.e. wait until all devices are probed and have had the opportunity to take the clocks they need, at which point we can usually safely gate the remainder. These types of clocks are the exception however; hence the need for this driver. There are other vendors which have similar issues with their h/w. These are currently using bespoke versions of this implementation, but IMO a generic solution would be better.
Quoted 8 lines
What kind of clocks are these? What do they control? Memory controllers? Bus controllers?
They must control some device(s), so there should be one or more device nodes in DT that reference these clocks.
As soon as that information is in DT, support can be added to Linux to make sure the "critical" clocks stay enabled, either through a real driver, or through platform code.
Some do, some don't. For instance, we have one clock which controls SPI and I2C that must not be turned off. We discovered this then when a suspend was attempted and the board refused to resume. This clock also runs one of the critical interconnects that runs from the a9. It would be wrong to remove the clk_disable() attempt from the SPI/I2C drivers because the same IP on another board might be controlled by a different clock which is able to be gated.
There are also clocks which control other interconnects that are not connected to any device drivers. If we fail to take references for them before clk_disable_unused() is called, again the board hangs. We even lose JTAG support.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Does simple-pm-bus help you?
I have no idea what this is, and I'm struggling to grep for it too?
Rob already provided a pointer.
If you have more questions, feel free to ask!
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v2 4/4] clk: dt: Introduce always-on clock domain documentation
Hi Lee,
Quoted 17 lines · Lee Jones
Quoted 8 lines
What kind of clocks are these? What do they control? Memory controllers? Bus controllers?
They must control some device(s), so there should be one or more device nodes in DT that reference these clocks.
As soon as that information is in DT, support can be added to Linux to make sure the "critical" clocks stay enabled, either through a real driver, or through platform code.Some do, some don't. For instance, we have one clock which controls SPI and I2C that must not be turned off. We discovered this then when a suspend was attempted and the board refused to resume. This clock also runs one of the critical interconnects that runs from the a9. It would be wrong to remove the
clk_disable()attempt from the SPI/I2C drivers because the same IP on another board might be controlled by a different clock which is able to be gated.
Quoted 4 lines
There are also clocks which control other interconnects that are not connected to any device drivers. If we fail to take references for them before
clk_disable_unused()is called, again the board hangs. We even lose JTAG support.
Interconnects are buses. Can't you represent those buses in the DT hierarchy, and give them clocks properties?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at 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
Re: [PATCH v2 4/4] clk: dt: Introduce always-on clock domain documentation
Quoted 20 lines · Geert Uytterhoeven
Hi Lee,
Quoted 17 lines · Lee Jones
Quoted 8 lines
What kind of clocks are these? What do they control? Memory controllers? Bus controllers?
They must control some device(s), so there should be one or more device nodes in DT that reference these clocks.
As soon as that information is in DT, support can be added to Linux to make sure the "critical" clocks stay enabled, either through a real driver, or through platform code.Some do, some don't. For instance, we have one clock which controls SPI and I2C that must not be turned off. We discovered this then when a suspend was attempted and the board refused to resume. This clock also runs one of the critical interconnects that runs from the a9. It would be wrong to remove the
clk_disable()attempt from the SPI/I2C drivers because the same IP on another board might be controlled by a different clock which is able to be gated.
Quoted 7 lines
Quoted 4 lines
There are also clocks which control other interconnects that are not connected to any device drivers. If we fail to take references for them before
clk_disable_unused()is called, again the board hangs. We even lose JTAG support.Interconnects are buses. Can't you represent those buses in the DT hierarchy, and give them clocks properties?
So instead of this nice succinct, simple, cover all bases (interconnects was just an example, there are bound to be others), generic framework, you are suggesting to write drivers for devices which other than "don't turn my clocks off", Linux can't actually see or control?
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v2 4/4] clk: dt: Introduce always-on clock domain documentation
Hi Lee,
Quoted 24 lines · Lee Jones
Quoted 23 lines · Geert Uytterhoeven
Quoted 21 lines · Lee Jones
Quoted 8 lines
What kind of clocks are these? What do they control? Memory controllers? Bus controllers?
They must control some device(s), so there should be one or more device nodes in DT that reference these clocks.
As soon as that information is in DT, support can be added to Linux to make sure the "critical" clocks stay enabled, either through a real driver, or through platform code.Some do, some don't. For instance, we have one clock which controls SPI and I2C that must not be turned off. We discovered this then when a suspend was attempted and the board refused to resume. This clock also runs one of the critical interconnects that runs from the a9. It would be wrong to remove the
clk_disable()attempt from the SPI/I2C drivers because the same IP on another board might be controlled by a different clock which is able to be gated.There are also clocks which control other interconnects that are not connected to any device drivers. If we fail to take references for them before
clk_disable_unused()is called, again the board hangs. We even lose JTAG support.
Quoted 8 lines
Quoted 2 lines
Interconnects are buses. Can't you represent those buses in the DT hierarchy, and give them clocks properties?
So instead of this nice succinct, simple, cover all bases (interconnects was just an example, there are bound to be others), generic framework, you are suggesting to write drivers for devices which other than "don't turn my clocks off", Linux can't actually see or control?
DT describes the hardware, not behavior.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at 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
Re: [PATCH v2 4/4] clk: dt: Introduce always-on clock domain documentation
Quoted 30 lines · Geert Uytterhoeven
Hi Lee,
Quoted 27 lines · Lee Jones
Quoted 25 lines · Geert Uytterhoeven
Quoted 17 lines · Lee Jones
Quoted 8 lines
What kind of clocks are these? What do they control? Memory controllers? Bus controllers?
They must control some device(s), so there should be one or more device nodes in DT that reference these clocks.
As soon as that information is in DT, support can be added to Linux to make sure the "critical" clocks stay enabled, either through a real driver, or through platform code.Some do, some don't. For instance, we have one clock which controls SPI and I2C that must not be turned off. We discovered this then when a suspend was attempted and the board refused to resume. This clock also runs one of the critical interconnects that runs from the a9. It would be wrong to remove the
clk_disable()attempt from the SPI/I2C drivers because the same IP on another board might be controlled by a different clock which is able to be gated.Quoted 4 lines
There are also clocks which control other interconnects that are not connected to any device drivers. If we fail to take references for them before
clk_disable_unused()is called, again the board hangs. We even lose JTAG support.Interconnects are buses. Can't you represent those buses in the DT hierarchy, and give them clocks properties?
Quoted 7 lines
Quoted 5 lines
So instead of this nice succinct, simple, cover all bases (interconnects was just an example, there are bound to be others), generic framework, you are suggesting to write drivers for devices which other than "don't turn my clocks off", Linux can't actually see or control?
DT describes the hardware, not behavior.
Okay so ...
/*
* ICNs are not visible/controllable in Linux, but references to their
* clocks must be obtained and retained or the platform will become
* irrecoverably unresponsive.
*/
interconnects at 0 {
compatible = "always-on-clk-domain";
clocks = <&clk_s_c0_flexgen CLK_ICN_SBC>,
<&clk_s_c0_flexgen CLK_ICN_LMI>,
<&clk_s_c0_flexgen CLK_ICN_CPU>,
<&clk_s_c0_flexgen CLK_TX_ICN_DMU>;
};Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v2 4/4] clk: dt: Introduce always-on clock domain documentation
Hi Lee,
Quoted 39 lines · Lee Jones
Quoted 28 lines · Geert Uytterhoeven
Quoted 27 lines · Lee Jones
Quoted 25 lines · Geert Uytterhoeven
Quoted 17 lines · Lee Jones
Quoted 8 lines
What kind of clocks are these? What do they control? Memory controllers? Bus controllers?
They must control some device(s), so there should be one or more device nodes in DT that reference these clocks.
As soon as that information is in DT, support can be added to Linux to make sure the "critical" clocks stay enabled, either through a real driver, or through platform code.Some do, some don't. For instance, we have one clock which controls SPI and I2C that must not be turned off. We discovered this then when a suspend was attempted and the board refused to resume. This clock also runs one of the critical interconnects that runs from the a9. It would be wrong to remove the
clk_disable()attempt from the SPI/I2C drivers because the same IP on another board might be controlled by a different clock which is able to be gated.Quoted 4 lines
There are also clocks which control other interconnects that are not connected to any device drivers. If we fail to take references for them before
clk_disable_unused()is called, again the board hangs. We even lose JTAG support.Interconnects are buses. Can't you represent those buses in the DT hierarchy, and give them clocks properties?
Quoted 7 lines
Quoted 5 lines
So instead of this nice succinct, simple, cover all bases (interconnects was just an example, there are bound to be others), generic framework, you are suggesting to write drivers for devices which other than "don't turn my clocks off", Linux can't actually see or control?
DT describes the hardware, not behavior.
Okay so ...
Quoted 7 lines
/*
* ICNs are not visible/controllable in Linux, but references to their
* clocks must be obtained and retained or the platform will become
* irrecoverably unresponsive.
*/interconnects at 0 { compatible = "always-on-clk-domain";
st,...flexgen...
Quoted 5 lines
clocks = <&clk_s_c0_flexgen CLK_ICN_SBC>,
<&clk_s_c0_flexgen CLK_ICN_LMI>,
<&clk_s_c0_flexgen CLK_ICN_CPU>,
<&clk_s_c0_flexgen CLK_TX_ICN_DMU>;
};And then you can have platform code that binds against st,...flexgen..., and enables all referenced clocks.
Alternatively, if you have power domains, you can add a reference to the power domain, and let the power domain driver handle it.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at 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
Re: [PATCH v2 4/4] clk: dt: Introduce always-on clock domain documentation
Quoted 52 lines · Geert Uytterhoeven
Hi Lee,
Quoted 39 lines · Lee Jones
Quoted 28 lines · Geert Uytterhoeven
Quoted 27 lines · Lee Jones
Quoted 25 lines · Geert Uytterhoeven
Quoted 17 lines · Lee Jones
Quoted 8 lines
What kind of clocks are these? What do they control? Memory controllers? Bus controllers?
They must control some device(s), so there should be one or more device nodes in DT that reference these clocks.
As soon as that information is in DT, support can be added to Linux to make sure the "critical" clocks stay enabled, either through a real driver, or through platform code.Some do, some don't. For instance, we have one clock which controls SPI and I2C that must not be turned off. We discovered this then when a suspend was attempted and the board refused to resume. This clock also runs one of the critical interconnects that runs from the a9. It would be wrong to remove the
clk_disable()attempt from the SPI/I2C drivers because the same IP on another board might be controlled by a different clock which is able to be gated.Quoted 4 lines
There are also clocks which control other interconnects that are not connected to any device drivers. If we fail to take references for them before
clk_disable_unused()is called, again the board hangs. We even lose JTAG support.Interconnects are buses. Can't you represent those buses in the DT hierarchy, and give them clocks properties?
Quoted 7 lines
Quoted 5 lines
So instead of this nice succinct, simple, cover all bases (interconnects was just an example, there are bound to be others), generic framework, you are suggesting to write drivers for devices which other than "don't turn my clocks off", Linux can't actually see or control?
DT describes the hardware, not behavior.
Okay so ...
Quoted 7 lines
/*
* ICNs are not visible/controllable in Linux, but references to their
* clocks must be obtained and retained or the platform will become
* irrecoverably unresponsive.
*/interconnects at 0 { compatible = "always-on-clk-domain";st,...flexgen...
Quoted 8 lines
Quoted 5 lines
clocks = <&clk_s_c0_flexgen CLK_ICN_SBC>, <&clk_s_c0_flexgen CLK_ICN_LMI>, <&clk_s_c0_flexgen CLK_ICN_CPU>, <&clk_s_c0_flexgen CLK_TX_ICN_DMU>; };And then you can have platform code that binds against st,...flexgen..., and enables all referenced clocks.
Flexgen isn't a device, it's a clk source. a) writing a device driver for a clk source seems wrong b) what if on another platform a different clock source supplied the clock? Write another driver? And what if the ICNs are connected to different clock sources? More drivers? c) all of these drivers will only do one thing -- pull a reference and keep hold of it. You want 50 drivers (across all platforms) doing only that? Or, more sanely, do you want this one generic framework driver doing that?
Quoted 2 lines
Alternatively, if you have power domains, you can add a reference to the power domain, and let the power domain driver handle it.
I'm not sure what a power domain driver will do? We need a driver to _not_ give up references, that is all. :)
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v2 4/4] clk: dt: Introduce always-on clock domain documentation
Hi Lee,
Quoted 57 lines · Lee Jones
Quoted 56 lines · Geert Uytterhoeven
Quoted 39 lines · Lee Jones
Quoted 28 lines · Geert Uytterhoeven
Quoted 27 lines · Lee Jones
Quoted 25 lines · Geert Uytterhoeven
Quoted 17 lines · Lee Jones
Quoted 8 lines
What kind of clocks are these? What do they control? Memory controllers? Bus controllers?
They must control some device(s), so there should be one or more device nodes in DT that reference these clocks.
As soon as that information is in DT, support can be added to Linux to make sure the "critical" clocks stay enabled, either through a real driver, or through platform code.Some do, some don't. For instance, we have one clock which controls SPI and I2C that must not be turned off. We discovered this then when a suspend was attempted and the board refused to resume. This clock also runs one of the critical interconnects that runs from the a9. It would be wrong to remove the
clk_disable()attempt from the SPI/I2C drivers because the same IP on another board might be controlled by a different clock which is able to be gated.Quoted 4 lines
There are also clocks which control other interconnects that are not connected to any device drivers. If we fail to take references for them before
clk_disable_unused()is called, again the board hangs. We even lose JTAG support.Interconnects are buses. Can't you represent those buses in the DT hierarchy, and give them clocks properties?
Quoted 7 lines
Quoted 5 lines
So instead of this nice succinct, simple, cover all bases (interconnects was just an example, there are bound to be others), generic framework, you are suggesting to write drivers for devices which other than "don't turn my clocks off", Linux can't actually see or control?
DT describes the hardware, not behavior.
Okay so ...
Quoted 7 lines
/*
* ICNs are not visible/controllable in Linux, but references to their
* clocks must be obtained and retained or the platform will become
* irrecoverably unresponsive.
*/interconnects at 0 { compatible = "always-on-clk-domain";st,...flexgen...
Quoted 5 lines
clocks = <&clk_s_c0_flexgen CLK_ICN_SBC>, <&clk_s_c0_flexgen CLK_ICN_LMI>, <&clk_s_c0_flexgen CLK_ICN_CPU>, <&clk_s_c0_flexgen CLK_TX_ICN_DMU>; };
Quoted 4 lines
Quoted 2 lines
And then you can have platform code that binds against st,...flexgen..., and enables all referenced clocks.
Flexgen isn't a device, it's a clk source. a) writing a device driver
Sorry, I'm not familiar with ST nomenclature. So that should become the name of the interconnect/bus.
Quoted 8 lines
for a clk source seems wrong b) what if on another platform a different clock source supplied the clock? Write another driver? And what if the ICNs are connected to different clock sources? More drivers? c) all of these drivers will only do one thing -- pull a reference and keep hold of it. You want 50 drivers (across all platforms) doing only that? Or, more sanely, do you want this one generic framework driver doing that?
Quoted 5 lines
Quoted 2 lines
Alternatively, if you have power domains, you can add a reference to the power domain, and let the power domain driver handle it.
I'm not sure what a power domain driver will do? We need a driver to _not_ give up references, that is all. :)
A power domain driver can do anything it wants.
That includes enabling your interconnect clocks, and keeping them enabled.
Now, if flexgen is the name of the clock source, then all devices connected to flexgen are part of the flexgen clock domain, which can be represented in Linux using the generic PM domain. Do all devices connected to flexgen need to be handled similarly w.r.t. clocks? If yes, the genpd may be the place to implement that.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at 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
Re: [PATCH v2 4/4] clk: dt: Introduce always-on clock domain documentation
Quoted 58 lines · Geert Uytterhoeven
Quoted 57 lines · Lee Jones
Quoted 56 lines · Geert Uytterhoeven
Quoted 39 lines · Lee Jones
Quoted 28 lines · Geert Uytterhoeven
Quoted 27 lines · Lee Jones
Quoted 25 lines · Geert Uytterhoeven
Quoted 17 lines · Lee Jones
Quoted 8 lines
What kind of clocks are these? What do they control? Memory controllers? Bus controllers?
They must control some device(s), so there should be one or more device nodes in DT that reference these clocks.
As soon as that information is in DT, support can be added to Linux to make sure the "critical" clocks stay enabled, either through a real driver, or through platform code.Some do, some don't. For instance, we have one clock which controls SPI and I2C that must not be turned off. We discovered this then when a suspend was attempted and the board refused to resume. This clock also runs one of the critical interconnects that runs from the a9. It would be wrong to remove the
clk_disable()attempt from the SPI/I2C drivers because the same IP on another board might be controlled by a different clock which is able to be gated.Quoted 4 lines
There are also clocks which control other interconnects that are not connected to any device drivers. If we fail to take references for them before
clk_disable_unused()is called, again the board hangs. We even lose JTAG support.Interconnects are buses. Can't you represent those buses in the DT hierarchy, and give them clocks properties?
Quoted 7 lines
Quoted 5 lines
So instead of this nice succinct, simple, cover all bases (interconnects was just an example, there are bound to be others), generic framework, you are suggesting to write drivers for devices which other than "don't turn my clocks off", Linux can't actually see or control?
DT describes the hardware, not behavior.
Okay so ...
Quoted 7 lines
/*
* ICNs are not visible/controllable in Linux, but references to their
* clocks must be obtained and retained or the platform will become
* irrecoverably unresponsive.
*/interconnects at 0 { compatible = "always-on-clk-domain";st,...flexgen...
Quoted 5 lines
clocks = <&clk_s_c0_flexgen CLK_ICN_SBC>, <&clk_s_c0_flexgen CLK_ICN_LMI>, <&clk_s_c0_flexgen CLK_ICN_CPU>, <&clk_s_c0_flexgen CLK_TX_ICN_DMU>; };
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
And then you can have platform code that binds against st,...flexgen..., and enables all referenced clocks.
Flexgen isn't a device, it's a clk source. a) writing a device driver
Sorry, I'm not familiar with ST nomenclature. So that should become the name of the interconnect/bus.
You're still talking about writing function-less drivers for multiple pieces of h/w. We would have a few for ST alone, then multiply that by the number of silicon vendors with similar issues -- which is likely to be most of them.
I can understand Rob's "DT has to match h/w" point, but to insist we write lots of empty drivers just to stop some clocks from being gated is barking mad.
Quoted 14 lines
Quoted 8 lines
for a clk source seems wrong b) what if on another platform a different clock source supplied the clock? Write another driver? And what if the ICNs are connected to different clock sources? More drivers? c) all of these drivers will only do one thing -- pull a reference and keep hold of it. You want 50 drivers (across all platforms) doing only that? Or, more sanely, do you want this one generic framework driver doing that?
Quoted 5 lines
Quoted 2 lines
Alternatively, if you have power domains, you can add a reference to the power domain, and let the power domain driver handle it.
I'm not sure what a power domain driver will do? We need a driver to _not_ give up references, that is all. :)
Quoted 8 lines
A power domain driver can do anything it wants.
That includes enabling your interconnect clocks, and keeping them enabled.Now, if flexgen is the name of the clock source, then all devices connected to flexgen are part of the flexgen clock domain, which can be represented in Linux using the generic PM domain. Do all devices connected to flexgen need to be handled similarly w.r.t. clocks? If yes, the genpd may be the place to implement that.
Most of the FLEXGEN clocks are fully gateable. It's only a select few which are critical to the running of the system.
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v2 4/4] clk: dt: Introduce always-on clock domain documentation
Quoted 107 lines · Lee Jones
Quoted 58 lines · Geert Uytterhoeven
Quoted 57 lines · Lee Jones
Quoted 56 lines · Geert Uytterhoeven
Quoted 39 lines · Lee Jones
Quoted 28 lines · Geert Uytterhoeven
Quoted 27 lines · Lee Jones
Quoted 25 lines · Geert Uytterhoeven
Quoted 17 lines · Lee Jones
Quoted 8 lines
What kind of clocks are these? What do they control? Memory controllers? Bus controllers?
They must control some device(s), so there should be one or more device nodes in DT that reference these clocks.
As soon as that information is in DT, support can be added to Linux to make sure the "critical" clocks stay enabled, either through a real driver, or through platform code.Some do, some don't. For instance, we have one clock which controls SPI and I2C that must not be turned off. We discovered this then when a suspend was attempted and the board refused to resume. This clock also runs one of the critical interconnects that runs from the a9. It would be wrong to remove the
clk_disable()attempt from the SPI/I2C drivers because the same IP on another board might be controlled by a different clock which is able to be gated.Quoted 4 lines
There are also clocks which control other interconnects that are not connected to any device drivers. If we fail to take references for them before
clk_disable_unused()is called, again the board hangs. We even lose JTAG support.Interconnects are buses. Can't you represent those buses in the DT hierarchy, and give them clocks properties?
Quoted 7 lines
Quoted 5 lines
So instead of this nice succinct, simple, cover all bases (interconnects was just an example, there are bound to be others), generic framework, you are suggesting to write drivers for devices which other than "don't turn my clocks off", Linux can't actually see or control?
DT describes the hardware, not behavior.
Okay so ...
Quoted 7 lines
/*
* ICNs are not visible/controllable in Linux, but references to their
* clocks must be obtained and retained or the platform will become
* irrecoverably unresponsive.
*/interconnects@0 { compatible = "always-on-clk-domain";st,...flexgen...
Quoted 5 lines
clocks = <&clk_s_c0_flexgen CLK_ICN_SBC>, <&clk_s_c0_flexgen CLK_ICN_LMI>, <&clk_s_c0_flexgen CLK_ICN_CPU>, <&clk_s_c0_flexgen CLK_TX_ICN_DMU>; };Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
And then you can have platform code that binds against st,...flexgen..., and enables all referenced clocks.
Flexgen isn't a device, it's a clk source. a) writing a device driver
Sorry, I'm not familiar with ST nomenclature. So that should become the name of the interconnect/bus.
You're still talking about writing function-less drivers for multiple pieces of h/w. We would have a few for ST alone, then multiply that by the number of silicon vendors with similar issues -- which is likely to be most of them.
I can understand Rob's "DT has to match h/w" point, but to insist we write lots of empty drivers just to stop some clocks from being gated is barking mad.
Quoted 14 lines
Quoted 8 lines
for a clk source seems wrong b) what if on another platform a different clock source supplied the clock? Write another driver? And what if the ICNs are connected to different clock sources? More drivers? c) all of these drivers will only do one thing -- pull a reference and keep hold of it. You want 50 drivers (across all platforms) doing only that? Or, more sanely, do you want this one generic framework driver doing that?
Quoted 5 lines
Quoted 2 lines
Alternatively, if you have power domains, you can add a reference to the power domain, and let the power domain driver handle it.
I'm not sure what a power domain driver will do? We need a driver to _not_ give up references, that is all. :)
Quoted 8 lines
A power domain driver can do anything it wants.
That includes enabling your interconnect clocks, and keeping them enabled.Now, if flexgen is the name of the clock source, then all devices connected to flexgen are part of the flexgen clock domain, which can be represented in Linux using the generic PM domain. Do all devices connected to flexgen need to be handled similarly w.r.t. clocks? If yes, the genpd may be the place to implement that.
Most of the FLEXGEN clocks are fully gateable. It's only a select few which are critical to the running of the system.
--
Lee Jones
Linaro STMicroelectronics Landing Team LeadLinaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog