Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1241602 > unrolled thread
| Started by | Mans Rullgard <mans@mansr.com> |
|---|---|
| First post | 2015-10-07 17:40 +0200 |
| Last post | 2015-10-10 02:10 +0200 |
| Articles | 15 — 5 participants |
Back to article view | Back to linux.kernel
[PATCH v2 1/2] devicetree: add binding for generic mmio clocksource Mans Rullgard <mans@mansr.com> - 2015-10-07 17:40 +0200
[PATCH v2 2/2] clocksource: mmio: add devicetree support Mans Rullgard <mans@mansr.com> - 2015-10-07 17:40 +0200
Re: [PATCH v2 1/2] devicetree: add binding for generic mmio clocksource Mark Rutland <mark.rutland@arm.com> - 2015-10-07 17:50 +0200
Re: [PATCH v2 1/2] devicetree: add binding for generic mmio clocksource Måns Rullgård <mans@mansr.com> - 2015-10-07 18:50 +0200
Re: [PATCH v2 1/2] devicetree: add binding for generic mmio clocksource Mark Rutland <mark.rutland@arm.com> - 2015-10-07 19:10 +0200
Re: [PATCH v2 1/2] devicetree: add binding for generic mmio clocksource Måns Rullgård <mans@mansr.com> - 2015-10-08 11:20 +0200
Re: [PATCH v2 1/2] devicetree: add binding for generic mmio clocksource Rob Herring <robherring2@gmail.com> - 2015-10-07 21:50 +0200
Re: [PATCH v2 1/2] devicetree: add binding for generic mmio clocksource Måns Rullgård <mans@mansr.com> - 2015-10-08 11:30 +0200
Re: [PATCH v2 1/2] devicetree: add binding for generic mmio clocksource Måns Rullgård <mans@mansr.com> - 2015-10-09 18:20 +0200
Re: [PATCH v2 1/2] devicetree: add binding for generic mmio clocksource Rob Herring <robherring2@gmail.com> - 2015-10-09 20:00 +0200
Re: [PATCH v2 1/2] devicetree: add binding for generic mmio clocksource Stephen Boyd <sboyd@codeaurora.org> - 2015-10-09 20:50 +0200
Re: [PATCH v2 1/2] devicetree: add binding for generic mmio clocksource Måns Rullgård <mans@mansr.com> - 2015-10-09 21:50 +0200
Re: [PATCH v2 1/2] devicetree: add binding for generic mmio clocksource Stephen Boyd <sboyd@codeaurora.org> - 2015-10-10 02:10 +0200
Re: [PATCH v2 1/2] devicetree: add binding for generic mmio clocksource Måns Rullgård <mans@mansr.com> - 2015-10-10 00:00 +0200
Re: [PATCH v2 1/2] devicetree: add binding for generic mmio clocksource Stephen Boyd <sboyd@codeaurora.org> - 2015-10-10 02:10 +0200
| From | Mans Rullgard <mans@mansr.com> |
|---|---|
| Date | 2015-10-07 17:40 +0200 |
| Subject | [PATCH v2 1/2] devicetree: add binding for generic mmio clocksource |
| Message-ID | <qgYYW-wa-5@gated-at.bofh.it> |
This adds a DT binding for a generic mmio clocksource as implemented
by clocksource_mmio_init().
Signed-off-by: Mans Rullgard <mans@mansr.com>
---
Changed in v2:
- added sched_clock support
---
.../devicetree/bindings/timer/clocksource-mmio.txt | 28 ++++++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100644 Documentation/devicetree/bindings/timer/clocksource-mmio.txt
diff --git a/Documentation/devicetree/bindings/timer/clocksource-mmio.txt b/Documentation/devicetree/bindings/timer/clocksource-mmio.txt
new file mode 100644
index 0000000..cfb3601
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/clocksource-mmio.txt
@@ -0,0 +1,28 @@
+Generic MMIO clocksource
+
+Required properties:
+
+- compatible: should be "clocksource-mmio"
+- reg: the physical address of the counter register
+- reg-io-width: size of counter register in bytes, should be 2 or 4
+- clocks: phandle to the source clock
+- clocksource-bits: number of valid bits
+- clocksource-rating: rating of the clocksource
+
+Optional properties:
+
+- clocksource-counts-down: indicates that counter counts down
+- label: name of the clocksource
+- linux,sched-clock: boolean, register clocksource as sched_clock
+
+Example:
+
+clocksource {
+ compatible = "clocksource-mmio";
+ reg = <0x10000 4>;
+ reg-io-width = <4>;
+ clocksource-bits = <32>;
+ clocksource-rating = <300>;
+ clocks = <&clk>;
+ linux,sched_clock;
+}
--
2.5.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Mans Rullgard <mans@mansr.com> |
|---|---|
| Date | 2015-10-07 17:40 +0200 |
| Subject | [PATCH v2 2/2] clocksource: mmio: add devicetree support |
| Message-ID | <qgYYX-wa-29@gated-at.bofh.it> |
| In reply to | #1241602 |
This implements the "clocksource-mmio" devicetree binding. It is
useful for devices that have a free-running counter requiring no
setup.
Signed-off-by: Mans Rullgard <mans@mansr.com>
---
Changed in v2:
- added sched_clock support
---
drivers/clocksource/mmio.c | 123 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 123 insertions(+)
diff --git a/drivers/clocksource/mmio.c b/drivers/clocksource/mmio.c
index 1593ade..b2cb3cc 100644
--- a/drivers/clocksource/mmio.c
+++ b/drivers/clocksource/mmio.c
@@ -5,9 +5,12 @@
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
+#include <linux/clk.h>
#include <linux/clocksource.h>
#include <linux/errno.h>
#include <linux/init.h>
+#include <linux/of_address.h>
+#include <linux/sched_clock.h>
#include <linux/slab.h>
struct clocksource_mmio {
@@ -71,3 +74,123 @@ int __init clocksource_mmio_init(void __iomem *base, const char *name,
return clocksource_register_hz(&cs->clksrc, hz);
}
+
+#ifdef CONFIG_OF
+static void __iomem *sched_clock_mmio_reg;
+
+static u64 notrace sched_clock_mmio_readl_up(void)
+{
+ return (u64)readl_relaxed(sched_clock_mmio_reg);
+}
+
+static u64 notrace sched_clock_mmio_readl_down(void)
+{
+ return ~(u64)readl_relaxed(sched_clock_mmio_reg);
+}
+
+static u64 notrace sched_clock_mmio_readw_up(void)
+{
+ return (u64)readw_relaxed(sched_clock_mmio_reg);
+}
+
+static u64 notrace sched_clock_mmio_readw_down(void)
+{
+ return ~(u64)readw_relaxed(sched_clock_mmio_reg);
+}
+
+static void __init clocksource_mmio_of_setup(struct device_node *node)
+{
+ cycle_t (*csrc_read)(struct clocksource *);
+ u64 (*sched_read)(void);
+ void __iomem *reg;
+ struct clk *clk;
+ const char *name;
+ unsigned long rate;
+ bool count_down;
+ u32 rating;
+ u32 width;
+ u32 bits;
+ int err;
+
+ if (of_property_read_u32(node, "reg-io-width", &width)) {
+ pr_err("clocksource-mmio: register width not specified\n");
+ return;
+ }
+
+ if (of_property_read_u32(node, "clocksource-bits", &bits)) {
+ pr_err("clocksource-mmio: bits not specified\n");
+ return;
+ }
+
+ if (of_property_read_u32(node, "clocksource-rating", &rating)) {
+ pr_err("clocksource-mmio: rating not specified\n");
+ return;
+ }
+
+ count_down = of_property_read_bool(node, "clocksource-counts-down");
+
+ if (width == 2) {
+ if (count_down) {
+ csrc_read = clocksource_mmio_readw_down;
+ sched_read = sched_clock_mmio_readw_down;
+ } else {
+ csrc_read = clocksource_mmio_readw_up;
+ sched_read = sched_clock_mmio_readw_up;
+ }
+ } else if (width == 4) {
+ if (count_down) {
+ csrc_read = clocksource_mmio_readl_down;
+ sched_read = sched_clock_mmio_readl_down;
+ } else {
+ csrc_read = clocksource_mmio_readl_up;
+ sched_read = sched_clock_mmio_readl_up;
+ }
+ } else {
+ pr_err("clocksource-mmio: reg-io-width must be 2 or 4\n");
+ return;
+ }
+
+ clk = of_clk_get(node, 0);
+ if (IS_ERR(clk)) {
+ pr_err("clocksource-mmio: failed to get clock\n");
+ return;
+ }
+
+ if (clk_prepare_enable(clk)) {
+ pr_err("clocksource-mmio: failed to enable clock\n");
+ return;
+ }
+
+ rate = clk_get_rate(clk);
+ if (!rate) {
+ pr_err("clocksource-mmio: clock rate is zero\n");
+ clk_disable_unprepare(clk);
+ return;
+ }
+
+ reg = of_iomap(node, 0);
+ if (!reg) {
+ pr_err("clocksource-mmio: iomap failed\n");
+ clk_disable_unprepare(clk);
+ return;
+ }
+
+ if (of_property_read_string(node, "label", &name))
+ name = node->name;
+
+ err = clocksource_mmio_init(reg, name, rate, rating, bits, csrc_read);
+ if (err) {
+ pr_err("clocksource-mmio: failed to register clock source\n");
+ clk_disable_unprepare(clk);
+ iounmap(reg);
+ return;
+ }
+
+ if (of_property_read_bool(node, "linux,sched-clock")) {
+ sched_clock_mmio_reg = reg;
+ sched_clock_register(sched_read, bits, rate);
+ }
+}
+CLOCKSOURCE_OF_DECLARE(clocksource_mmio, "clocksource-mmio",
+ clocksource_mmio_of_setup);
+#endif
--
2.5.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Mark Rutland <mark.rutland@arm.com> |
|---|---|
| Date | 2015-10-07 17:50 +0200 |
| Subject | Re: [PATCH v2 1/2] devicetree: add binding for generic mmio clocksource |
| Message-ID | <qgZ8B-Hx-5@gated-at.bofh.it> |
| In reply to | #1241602 |
On Wed, Oct 07, 2015 at 04:37:13PM +0100, Mans Rullgard wrote:
> This adds a DT binding for a generic mmio clocksource as implemented
> by clocksource_mmio_init().
>
> Signed-off-by: Mans Rullgard <mans@mansr.com>
> ---
> Changed in v2:
> - added sched_clock support
> ---
> .../devicetree/bindings/timer/clocksource-mmio.txt | 28 ++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/timer/clocksource-mmio.txt
>
> diff --git a/Documentation/devicetree/bindings/timer/clocksource-mmio.txt b/Documentation/devicetree/bindings/timer/clocksource-mmio.txt
> new file mode 100644
> index 0000000..cfb3601
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/timer/clocksource-mmio.txt
> @@ -0,0 +1,28 @@
> +Generic MMIO clocksource
> +
> +Required properties:
> +
> +- compatible: should be "clocksource-mmio"
> +- reg: the physical address of the counter register
> +- reg-io-width: size of counter register in bytes, should be 2 or 4
Can this not be inferred from the reg?
What about 8 byte counters?
> +- clocks: phandle to the source clock
Is the frequency expected to be exactly the source clock frequency? I
imagine it's possible for there to be a divisor.
We can add properties for that later, but we should be explcit as to
what we currently expect the relationship between the clock and the
clocksource to be.
> +- clocksource-bits: number of valid bits
> +- clocksource-rating: rating of the clocksource
NAK. This has no meaning w.r.t. the hardware. This should not be in the
DT. If there are criteria that bias this (e.g. frequency, latency), they
should eitehr be describedi nteh DT or determined dynamically.
> +Optional properties:
> +
> +- clocksource-counts-down: indicates that counter counts down
> +- label: name of the clocksource
> +- linux,sched-clock: boolean, register clocksource as sched_clock
Likewise, this property doesn't belong in the DT for the same reasons as
clocksource-rating.
Mark.
> +
> +Example:
> +
> +clocksource {
> + compatible = "clocksource-mmio";
> + reg = <0x10000 4>;
> + reg-io-width = <4>;
> + clocksource-bits = <32>;
> + clocksource-rating = <300>;
> + clocks = <&clk>;
> + linux,sched_clock;
> +}
> --
> 2.5.3
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Måns Rullgård <mans@mansr.com> |
|---|---|
| Date | 2015-10-07 18:50 +0200 |
| Message-ID | <qh04G-25n-9@gated-at.bofh.it> |
| In reply to | #1241608 |
Mark Rutland <mark.rutland@arm.com> writes: > On Wed, Oct 07, 2015 at 04:37:13PM +0100, Mans Rullgard wrote: >> This adds a DT binding for a generic mmio clocksource as implemented >> by clocksource_mmio_init(). >> >> Signed-off-by: Mans Rullgard <mans@mansr.com> >> --- >> Changed in v2: >> - added sched_clock support >> --- >> .../devicetree/bindings/timer/clocksource-mmio.txt | 28 ++++++++++++++++++++++ >> 1 file changed, 28 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/timer/clocksource-mmio.txt >> >> diff --git a/Documentation/devicetree/bindings/timer/clocksource-mmio.txt b/Documentation/devicetree/bindings/timer/clocksource-mmio.txt >> new file mode 100644 >> index 0000000..cfb3601 >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/timer/clocksource-mmio.txt >> @@ -0,0 +1,28 @@ >> +Generic MMIO clocksource >> + >> +Required properties: >> + >> +- compatible: should be "clocksource-mmio" >> +- reg: the physical address of the counter register >> +- reg-io-width: size of counter register in bytes, should be 2 or 4 > > Can this not be inferred from the reg? You're right, it can. > What about 8 byte counters? The existing code only supports 2 or 4, but that of course doesn't matter here. >> +- clocks: phandle to the source clock > > Is the frequency expected to be exactly the source clock frequency? I > imagine it's possible for there to be a divisor. There could of course be, though there isn't in the hardware I'm dealing with. Is specifying it here preferable using a fixed-factor-clock? > We can add properties for that later, but we should be explcit as to > what we currently expect the relationship between the clock and the > clocksource to be. > >> +- clocksource-bits: number of valid bits >> +- clocksource-rating: rating of the clocksource > > NAK. This has no meaning w.r.t. the hardware. This should not be in the > DT. If there are criteria that bias this (e.g. frequency, latency), they > should either be described in the DT or determined dynamically. I had a bad feeling about this. How would you suggest determining a suitable value from actual hardware parameters? >> +- linux,sched-clock: boolean, register clocksource as sched_clock > > Likewise, this property doesn't belong in the DT for the same reasons as > clocksource-rating. What would be a proper way to select a sched_clock source? I realise it's a Linux-specific thing and DT is supposed to be generic, but the information must be provided somehow. -- Måns Rullgård mans@mansr.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Mark Rutland <mark.rutland@arm.com> |
|---|---|
| Date | 2015-10-07 19:10 +0200 |
| Subject | Re: [PATCH v2 1/2] devicetree: add binding for generic mmio clocksource |
| Message-ID | <qh0o2-2H0-13@gated-at.bofh.it> |
| In reply to | #1241681 |
On Wed, Oct 07, 2015 at 05:47:12PM +0100, Måns Rullgård wrote: > Mark Rutland <mark.rutland@arm.com> writes: > > > On Wed, Oct 07, 2015 at 04:37:13PM +0100, Mans Rullgard wrote: > >> This adds a DT binding for a generic mmio clocksource as implemented > >> by clocksource_mmio_init(). > >> > >> Signed-off-by: Mans Rullgard <mans@mansr.com> > >> --- > >> Changed in v2: > >> - added sched_clock support > >> --- > >> .../devicetree/bindings/timer/clocksource-mmio.txt | 28 ++++++++++++++++++++++ > >> 1 file changed, 28 insertions(+) > >> create mode 100644 Documentation/devicetree/bindings/timer/clocksource-mmio.txt > >> > >> diff --git a/Documentation/devicetree/bindings/timer/clocksource-mmio.txt b/Documentation/devicetree/bindings/timer/clocksource-mmio.txt > >> new file mode 100644 > >> index 0000000..cfb3601 > >> --- /dev/null > >> +++ b/Documentation/devicetree/bindings/timer/clocksource-mmio.txt > >> @@ -0,0 +1,28 @@ > >> +Generic MMIO clocksource > >> + > >> +Required properties: > >> + > >> +- compatible: should be "clocksource-mmio" > >> +- reg: the physical address of the counter register > >> +- reg-io-width: size of counter register in bytes, should be 2 or 4 > > > > Can this not be inferred from the reg? > > You're right, it can. > > > What about 8 byte counters? > > The existing code only supports 2 or 4, but that of course doesn't > matter here. > > >> +- clocks: phandle to the source clock > > > > Is the frequency expected to be exactly the source clock frequency? I > > imagine it's possible for there to be a divisor. > > There could of course be, though there isn't in the hardware I'm dealing > with. Is specifying it here preferable using a fixed-factor-clock? I'm not actually sure; I guess it would be ok to do so. For now we should just explicitly state that the clocksource is assumed to tick at the rate of the clock. > > We can add properties for that later, but we should be explcit as to > > what we currently expect the relationship between the clock and the > > clocksource to be. > > > >> +- clocksource-bits: number of valid bits > >> +- clocksource-rating: rating of the clocksource > > > > NAK. This has no meaning w.r.t. the hardware. This should not be in the > > DT. If there are criteria that bias this (e.g. frequency, latency), they > > should either be described in the DT or determined dynamically. > > I had a bad feeling about this. How would you suggest determining a > suitable value from actual hardware parameters? I don't have a good answer to that given the rating is semi-arbitrary, but that's also the reason I don't want to see it in the DT. Can we not just choose a fixed number in the driver for now? Likely something lower than the architected timers (400 currently). > >> +- linux,sched-clock: boolean, register clocksource as sched_clock > > > > Likewise, this property doesn't belong in the DT for the same reasons as > > clocksource-rating. > > What would be a proper way to select a sched_clock source? I realise > it's a Linux-specific thing and DT is supposed to be generic, but the > information must be provided somehow. I think that any source above a certain rate and below a certain latency, which does not lose state, should be registered (and the best gets chosen dynamically). Come to think of it, what's the expected behaviour of this source w.r.t. power management? I expect that the kernel needs to leave the clock enabled at all times for this to possibly work. Mark. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Måns Rullgård <mans@mansr.com> |
|---|---|
| Date | 2015-10-08 11:20 +0200 |
| Message-ID | <qhfwJ-7zW-17@gated-at.bofh.it> |
| In reply to | #1241690 |
Mark Rutland <mark.rutland@arm.com> writes: >> >> +- clocks: phandle to the source clock >> > >> > Is the frequency expected to be exactly the source clock frequency? I >> > imagine it's possible for there to be a divisor. >> >> There could of course be, though there isn't in the hardware I'm dealing >> with. Is specifying it here preferable using a fixed-factor-clock? > > I'm not actually sure; I guess it would be ok to do so. > > For now we should just explicitly state that the clocksource is assumed > to tick at the rate of the clock. OK, I'll come up with a clearer wording. >> > We can add properties for that later, but we should be explcit as to >> > what we currently expect the relationship between the clock and the >> > clocksource to be. >> > >> >> +- clocksource-bits: number of valid bits >> >> +- clocksource-rating: rating of the clocksource >> > >> > NAK. This has no meaning w.r.t. the hardware. This should not be in the >> > DT. If there are criteria that bias this (e.g. frequency, latency), they >> > should either be described in the DT or determined dynamically. >> >> I had a bad feeling about this. How would you suggest determining a >> suitable value from actual hardware parameters? > > I don't have a good answer to that given the rating is semi-arbitrary, > but that's also the reason I don't want to see it in the DT. > > Can we not just choose a fixed number in the driver for now? Likely > something lower than the architected timers (400 currently). Fine with me. >> >> +- linux,sched-clock: boolean, register clocksource as sched_clock >> > >> > Likewise, this property doesn't belong in the DT for the same reasons as >> > clocksource-rating. >> >> What would be a proper way to select a sched_clock source? I realise >> it's a Linux-specific thing and DT is supposed to be generic, but the >> information must be provided somehow. > > I think that any source above a certain rate and below a certain > latency, which does not lose state, should be registered (and the best > gets chosen dynamically). > > Come to think of it, what's the expected behaviour of this source w.r.t. > power management? I expect that the kernel needs to leave the clock > enabled at all times for this to possibly work. The platform I'm dealing with has a 32-bit register counting cycles of the external clock input which never stops. It also has a few counters with a configurable clock source, and those might indeed stop so should probably not be used for this. -- Måns Rullgård mans@mansr.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Rob Herring <robherring2@gmail.com> |
|---|---|
| Date | 2015-10-07 21:50 +0200 |
| Message-ID | <qh2SR-68H-15@gated-at.bofh.it> |
| In reply to | #1241681 |
On Wed, Oct 7, 2015 at 11:47 AM, Måns Rullgård <mans@mansr.com> wrote: > Mark Rutland <mark.rutland@arm.com> writes: > >> On Wed, Oct 07, 2015 at 04:37:13PM +0100, Mans Rullgard wrote: >>> This adds a DT binding for a generic mmio clocksource as implemented >>> by clocksource_mmio_init(). >>> >>> Signed-off-by: Mans Rullgard <mans@mansr.com> >>> --- >>> Changed in v2: >>> - added sched_clock support >>> --- >>> .../devicetree/bindings/timer/clocksource-mmio.txt | 28 ++++++++++++++++++++++ >>> 1 file changed, 28 insertions(+) >>> create mode 100644 Documentation/devicetree/bindings/timer/clocksource-mmio.txt >>> >>> diff --git a/Documentation/devicetree/bindings/timer/clocksource-mmio.txt b/Documentation/devicetree/bindings/timer/clocksource-mmio.txt >>> new file mode 100644 >>> index 0000000..cfb3601 >>> --- /dev/null >>> +++ b/Documentation/devicetree/bindings/timer/clocksource-mmio.txt >>> @@ -0,0 +1,28 @@ >>> +Generic MMIO clocksource >>> + >>> +Required properties: >>> + >>> +- compatible: should be "clocksource-mmio" I'm doubtful this matches any h/w. This would assume there is no other control like enabling, reset, clock dividers, etc. Who is your user of this? >>> +- reg: the physical address of the counter register >>> +- reg-io-width: size of counter register in bytes, should be 2 or 4 >> >> Can this not be inferred from the reg? > > You're right, it can. > >> What about 8 byte counters? > > The existing code only supports 2 or 4, but that of course doesn't > matter here. > >>> +- clocks: phandle to the source clock >> >> Is the frequency expected to be exactly the source clock frequency? I >> imagine it's possible for there to be a divisor. > > There could of course be, though there isn't in the hardware I'm dealing > with. Is specifying it here preferable using a fixed-factor-clock? > >> We can add properties for that later, but we should be explcit as to >> what we currently expect the relationship between the clock and the >> clocksource to be. >> >>> +- clocksource-bits: number of valid bits >>> +- clocksource-rating: rating of the clocksource >> >> NAK. This has no meaning w.r.t. the hardware. This should not be in the >> DT. If there are criteria that bias this (e.g. frequency, latency), they >> should either be described in the DT or determined dynamically. > > I had a bad feeling about this. How would you suggest determining a > suitable value from actual hardware parameters? I wouldn't. I think there is general agreement that rating is broken. This has come up a few times before in context of given a pile of timer h/w how do you select one. Chosen properties have been one example (I think that actually went in on Integrator, but we since removed it). Think about what the properties of a timer are and then you can decide based on properties for those. OMAP timers are a good example. > >>> +- linux,sched-clock: boolean, register clocksource as sched_clock >> >> Likewise, this property doesn't belong in the DT for the same reasons as >> clocksource-rating. > > What would be a proper way to select a sched_clock source? I realise > it's a Linux-specific thing and DT is supposed to be generic, but the > information must be provided somehow. The kernel already has some logic to do this. Most number of bits followed by highest frequency will be the winning sched_clock. You might also want to look at things like always on or not. Rob > > -- > Måns Rullgård > mans@mansr.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Måns Rullgård <mans@mansr.com> |
|---|---|
| Date | 2015-10-08 11:30 +0200 |
| Message-ID | <qhfGq-7Lv-21@gated-at.bofh.it> |
| In reply to | #1241756 |
Rob Herring <robherring2@gmail.com> writes: > On Wed, Oct 7, 2015 at 11:47 AM, Måns Rullgård <mans@mansr.com> wrote: >> Mark Rutland <mark.rutland@arm.com> writes: >> >>> On Wed, Oct 07, 2015 at 04:37:13PM +0100, Mans Rullgard wrote: >>>> This adds a DT binding for a generic mmio clocksource as implemented >>>> by clocksource_mmio_init(). >>>> >>>> Signed-off-by: Mans Rullgard <mans@mansr.com> >>>> --- >>>> Changed in v2: >>>> - added sched_clock support >>>> --- >>>> .../devicetree/bindings/timer/clocksource-mmio.txt | 28 ++++++++++++++++++++++ >>>> 1 file changed, 28 insertions(+) >>>> create mode 100644 Documentation/devicetree/bindings/timer/clocksource-mmio.txt >>>> >>>> diff --git a/Documentation/devicetree/bindings/timer/clocksource-mmio.txt b/Documentation/devicetree/bindings/timer/clocksource-mmio.txt >>>> new file mode 100644 >>>> index 0000000..cfb3601 >>>> --- /dev/null >>>> +++ b/Documentation/devicetree/bindings/timer/clocksource-mmio.txt >>>> @@ -0,0 +1,28 @@ >>>> +Generic MMIO clocksource >>>> + >>>> +Required properties: >>>> + >>>> +- compatible: should be "clocksource-mmio" > > I'm doubtful this matches any h/w. This would assume there is no other > control like enabling, reset, clock dividers, etc. I know it matches real hardware. > Who is your user of this? Various Sigma Designs chips have such counters. I figured others might as well, and it seemed silly to tie such generic functionality to a specific chip family. >> I had a bad feeling about this. How would you suggest determining a >> suitable value from actual hardware parameters? > > I wouldn't. I think there is general agreement that rating is broken. So hardcoding something like 300 would be OK? >>>> +- linux,sched-clock: boolean, register clocksource as sched_clock >>> >>> Likewise, this property doesn't belong in the DT for the same reasons as >>> clocksource-rating. >> >> What would be a proper way to select a sched_clock source? I realise >> it's a Linux-specific thing and DT is supposed to be generic, but the >> information must be provided somehow. > > The kernel already has some logic to do this. Most number of bits > followed by highest frequency will be the winning sched_clock. You > might also want to look at things like always on or not. The problem is that sched_clock_register() doesn't take a pointer to be passed back to the read_sched_clock callback like most interfaces of this type do. This means the callback must use global variables set up before the register call, but at that time there's no way of knowing which one will be used. If there were a way of getting a pointer to the callback, it would be a simple matter of registering all instances and letting the kernel choose which to use. -- Måns Rullgård mans@mansr.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Måns Rullgård <mans@mansr.com> |
|---|---|
| Date | 2015-10-09 18:20 +0200 |
| Message-ID | <qhIyK-7ea-7@gated-at.bofh.it> |
| In reply to | #1242109 |
Måns Rullgård <mans@mansr.com> writes: > Rob Herring <robherring2@gmail.com> writes: > >> On Wed, Oct 7, 2015 at 11:47 AM, Måns Rullgård <mans@mansr.com> wrote: >>> What would be a proper way to select a sched_clock source? I realise >>> it's a Linux-specific thing and DT is supposed to be generic, but the >>> information must be provided somehow. >> >> The kernel already has some logic to do this. Most number of bits >> followed by highest frequency will be the winning sched_clock. You >> might also want to look at things like always on or not. > > The problem is that sched_clock_register() doesn't take a pointer to be > passed back to the read_sched_clock callback like most interfaces of > this type do. This means the callback must use global variables set up > before the register call, but at that time there's no way of knowing > which one will be used. If there were a way of getting a pointer to the > callback, it would be a simple matter of registering all instances and > letting the kernel choose which to use. Anyone got a comment on this? Do I have to send a patch adding this before anyone will tell me why it's a bad idea? (That method almost always works.) -- Måns Rullgård mans@mansr.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Rob Herring <robherring2@gmail.com> |
|---|---|
| Date | 2015-10-09 20:00 +0200 |
| Message-ID | <qhK7v-Tp-17@gated-at.bofh.it> |
| In reply to | #1243510 |
+Stephen who has worked on this code. On Fri, Oct 9, 2015 at 11:19 AM, Måns Rullgård <mans@mansr.com> wrote: > Måns Rullgård <mans@mansr.com> writes: > >> Rob Herring <robherring2@gmail.com> writes: >> >>> On Wed, Oct 7, 2015 at 11:47 AM, Måns Rullgård <mans@mansr.com> wrote: >>>> What would be a proper way to select a sched_clock source? I realise >>>> it's a Linux-specific thing and DT is supposed to be generic, but the >>>> information must be provided somehow. >>> >>> The kernel already has some logic to do this. Most number of bits >>> followed by highest frequency will be the winning sched_clock. You >>> might also want to look at things like always on or not. >> >> The problem is that sched_clock_register() doesn't take a pointer to be >> passed back to the read_sched_clock callback like most interfaces of >> this type do. This means the callback must use global variables set up >> before the register call, but at that time there's no way of knowing >> which one will be used. If there were a way of getting a pointer to the >> callback, it would be a simple matter of registering all instances and >> letting the kernel choose which to use. > > Anyone got a comment on this? Do I have to send a patch adding this > before anyone will tell me why it's a bad idea? (That method almost > always works.) Adding a ptr to the callback seems fine to me. Rob -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Stephen Boyd <sboyd@codeaurora.org> |
|---|---|
| Date | 2015-10-09 20:50 +0200 |
| Subject | Re: [PATCH v2 1/2] devicetree: add binding for generic mmio clocksource |
| Message-ID | <qhKTT-231-9@gated-at.bofh.it> |
| In reply to | #1243568 |
On 10/09, Rob Herring wrote: > +Stephen who has worked on this code. > > On Fri, Oct 9, 2015 at 11:19 AM, Måns Rullgård <mans@mansr.com> wrote: > > Måns Rullgård <mans@mansr.com> writes: > > > >> Rob Herring <robherring2@gmail.com> writes: > >> > >>> On Wed, Oct 7, 2015 at 11:47 AM, Måns Rullgård <mans@mansr.com> wrote: > >>>> What would be a proper way to select a sched_clock source? I realise > >>>> it's a Linux-specific thing and DT is supposed to be generic, but the > >>>> information must be provided somehow. > >>> > >>> The kernel already has some logic to do this. Most number of bits > >>> followed by highest frequency will be the winning sched_clock. You > >>> might also want to look at things like always on or not. > >> > >> The problem is that sched_clock_register() doesn't take a pointer to be > >> passed back to the read_sched_clock callback like most interfaces of > >> this type do. This means the callback must use global variables set up > >> before the register call, but at that time there's no way of knowing > >> which one will be used. If there were a way of getting a pointer to the > >> callback, it would be a simple matter of registering all instances and > >> letting the kernel choose which to use. > > > > Anyone got a comment on this? Do I have to send a patch adding this > > before anyone will tell me why it's a bad idea? (That method almost > > always works.) > > Adding a ptr to the callback seems fine to me. > Does that mean a flag day? Urgh. Pain. I'm not opposed to adding a pointer, in fact it might be better for performance so that we don't take a cache miss in read() functions that need to load some pointer. We were talking about that problem a few months ago, but nothing came of it. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Måns Rullgård <mans@mansr.com> |
|---|---|
| Date | 2015-10-09 21:50 +0200 |
| Message-ID | <qhLPX-3oh-1@gated-at.bofh.it> |
| In reply to | #1243601 |
Stephen Boyd <sboyd@codeaurora.org> writes: > On 10/09, Rob Herring wrote: >> +Stephen who has worked on this code. >> >> On Fri, Oct 9, 2015 at 11:19 AM, Måns Rullgård <mans@mansr.com> wrote: >> > Måns Rullgård <mans@mansr.com> writes: >> > >> >> Rob Herring <robherring2@gmail.com> writes: >> >> >> >>> On Wed, Oct 7, 2015 at 11:47 AM, Måns Rullgård <mans@mansr.com> wrote: >> >>>> What would be a proper way to select a sched_clock source? I realise >> >>>> it's a Linux-specific thing and DT is supposed to be generic, but the >> >>>> information must be provided somehow. >> >>> >> >>> The kernel already has some logic to do this. Most number of bits >> >>> followed by highest frequency will be the winning sched_clock. You >> >>> might also want to look at things like always on or not. >> >> >> >> The problem is that sched_clock_register() doesn't take a pointer to be >> >> passed back to the read_sched_clock callback like most interfaces of >> >> this type do. This means the callback must use global variables set up >> >> before the register call, but at that time there's no way of knowing >> >> which one will be used. If there were a way of getting a pointer to the >> >> callback, it would be a simple matter of registering all instances and >> >> letting the kernel choose which to use. >> > >> > Anyone got a comment on this? Do I have to send a patch adding this >> > before anyone will tell me why it's a bad idea? (That method almost >> > always works.) >> >> Adding a ptr to the callback seems fine to me. >> > > Does that mean a flag day? Urgh. Pain. I'm not opposed to adding > a pointer, in fact it might be better for performance so that we > don't take a cache miss in read() functions that need to load > some pointer. We were talking about that problem a few months > ago, but nothing came of it. Flag day in what sense? There aren't all that many users of the interface (56, to be precise), and sched_clock_register() isn't exported. Verifying the change will be a minor pain, but I don't see why it should have any major consequences. Obviously I'd just set the pointer to null for existing users and leave it for the respective maintainers to make proper use of it where sensible. -- Måns Rullgård mans@mansr.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Stephen Boyd <sboyd@codeaurora.org> |
|---|---|
| Date | 2015-10-10 02:10 +0200 |
| Subject | Re: [PATCH v2 1/2] devicetree: add binding for generic mmio clocksource |
| Message-ID | <qhPTz-VK-9@gated-at.bofh.it> |
| In reply to | #1243625 |
On 10/09, Måns Rullgård wrote: > Stephen Boyd <sboyd@codeaurora.org> writes: > > > On 10/09, Rob Herring wrote: > >> > >> Adding a ptr to the callback seems fine to me. > >> > > > > Does that mean a flag day? Urgh. Pain. I'm not opposed to adding > > a pointer, in fact it might be better for performance so that we > > don't take a cache miss in read() functions that need to load > > some pointer. We were talking about that problem a few months > > ago, but nothing came of it. > > Flag day in what sense? There aren't all that many users of the > interface (56, to be precise), and sched_clock_register() isn't > exported. That's exactly what a flag day is. Lots of coordination, lots of acks, etc. Last time when I changed the registration API I made a new registration API, moved every caller over one by one, and then deleted the old registration API. That's how you manage a flag day. We could probably do the same thing again with two different types of registration APIs so that we move over users one by one. The old registration API would be wrapped with a sched_clock local function that doesn't pass the pointer it gets called with, while the new registration API would fill in the function pointer that we call directly from the core code. The double function call is probably bad for performance, so I guess we should get rid of it and always pass the pointer to the callback. But this is at least a method to convert everything gradually without breaking users that may be going through different trees. > Verifying the change will be a minor pain, but I don't see > why it should have any major consequences. Obviously I'd just set the > pointer to null for existing users and leave it for the respective > maintainers to make proper use of it where sensible. > Sure. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Måns Rullgård <mans@mansr.com> |
|---|---|
| Date | 2015-10-10 00:00 +0200 |
| Message-ID | <qhNRN-6gk-9@gated-at.bofh.it> |
| In reply to | #1243601 |
Stephen Boyd <sboyd@codeaurora.org> writes: > On 10/09, Rob Herring wrote: >> +Stephen who has worked on this code. >> >> On Fri, Oct 9, 2015 at 11:19 AM, Måns Rullgård <mans@mansr.com> wrote: >> > Måns Rullgård <mans@mansr.com> writes: >> > >> >> Rob Herring <robherring2@gmail.com> writes: >> >> >> >>> On Wed, Oct 7, 2015 at 11:47 AM, Måns Rullgård <mans@mansr.com> wrote: >> >>>> What would be a proper way to select a sched_clock source? I realise >> >>>> it's a Linux-specific thing and DT is supposed to be generic, but the >> >>>> information must be provided somehow. >> >>> >> >>> The kernel already has some logic to do this. Most number of bits >> >>> followed by highest frequency will be the winning sched_clock. You >> >>> might also want to look at things like always on or not. >> >> >> >> The problem is that sched_clock_register() doesn't take a pointer to be >> >> passed back to the read_sched_clock callback like most interfaces of >> >> this type do. This means the callback must use global variables set up >> >> before the register call, but at that time there's no way of knowing >> >> which one will be used. If there were a way of getting a pointer to the >> >> callback, it would be a simple matter of registering all instances and >> >> letting the kernel choose which to use. >> > >> > Anyone got a comment on this? Do I have to send a patch adding this >> > before anyone will tell me why it's a bad idea? (That method almost >> > always works.) >> >> Adding a ptr to the callback seems fine to me. >> > > Does that mean a flag day? Urgh. Pain. I'm not opposed to adding > a pointer, in fact it might be better for performance so that we > don't take a cache miss in read() functions that need to load > some pointer. We were talking about that problem a few months > ago, but nothing came of it. I've sent a patch. Let the flames begin. -- Måns Rullgård mans@mansr.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Stephen Boyd <sboyd@codeaurora.org> |
|---|---|
| Date | 2015-10-10 02:10 +0200 |
| Subject | Re: [PATCH v2 1/2] devicetree: add binding for generic mmio clocksource |
| Message-ID | <qhPTz-VK-7@gated-at.bofh.it> |
| In reply to | #1243684 |
On 10/09, Måns Rullgård wrote: > Stephen Boyd <sboyd@codeaurora.org> writes: > > > > Does that mean a flag day? Urgh. Pain. I'm not opposed to adding > > a pointer, in fact it might be better for performance so that we > > don't take a cache miss in read() functions that need to load > > some pointer. We were talking about that problem a few months > > ago, but nothing came of it. > > I've sent a patch. Let the flames begin. > I never got it. Was I Cced? -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web