* [PATCH/RFC] clocksource/drivers/ostm: Use unique device name instead of ostm
@ 2017-10-11 12:31 Geert Uytterhoeven
2017-10-11 13:05 ` [PATCH v2] " Jacopo Mondi
0 siblings, 1 reply; 5+ messages in thread
From: Geert Uytterhoeven @ 2017-10-11 12:31 UTC (permalink / raw)
To: Chris Brandt, Jacopo Mondi; +Cc: linux-renesas-soc, Geert Uytterhoeven
Currently all OSTM devices are called "ostm", also in kernel messages.
As there can be multiple instances in an SoC, this can confuse the user.
Hence construct a unique name from the DT node name, like is done for
platform devices.
On GR-Peach, the boot log changes like:
-clocksource: ostm: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 57352151442 ns
+clocksource: ostm timer@fcfec000: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 57352151442 ns
sched_clock: 32 bits at 33MHz, resolution 30ns, wraps every 64440619504ns
-ostm: used for clocksource
-ostm: used for clock events
+ostm timer@fcfec000: used for clocksource
+ostm timer@fcfec400: used for clock events
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Untested due to lack of hardware (I even made up the boot log ;-), hence
sent to a limited audience.
---
drivers/clocksource/renesas-ostm.c | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/drivers/clocksource/renesas-ostm.c b/drivers/clocksource/renesas-ostm.c
index 6cffd7c6001a6961..f9080de0a63c5f60 100644
--- a/drivers/clocksource/renesas-ostm.c
+++ b/drivers/clocksource/renesas-ostm.c
@@ -37,6 +37,7 @@ struct ostm_device {
void __iomem *base;
unsigned long ticks_per_jiffy;
struct clock_event_device ced;
+ char name[0];
};
static void __iomem *system_clock; /* For sched_clock() */
@@ -88,9 +89,8 @@ static int __init ostm_init_clksrc(struct ostm_device *ostm, unsigned long rate)
writeb(CTL_FREERUN, ostm->base + OSTM_CTL);
writeb(TS, ostm->base + OSTM_TS);
- return clocksource_mmio_init(ostm->base + OSTM_CNT,
- "ostm", rate,
- 300, 32, clocksource_mmio_readl_up);
+ return clocksource_mmio_init(ostm->base + OSTM_CNT, ostm->name, rate,
+ 300, 32, clocksource_mmio_readl_up);
}
static u64 notrace ostm_read_sched_clock(void)
@@ -170,15 +170,14 @@ static int __init ostm_init_clkevt(struct ostm_device *ostm, int irq,
struct clock_event_device *ced = &ostm->ced;
int ret = -ENXIO;
- ret = request_irq(irq, ostm_timer_interrupt,
- IRQF_TIMER | IRQF_IRQPOLL,
- "ostm", ostm);
+ ret = request_irq(irq, ostm_timer_interrupt, IRQF_TIMER | IRQF_IRQPOLL,
+ ostm->name, ostm);
if (ret) {
- pr_err("ostm: failed to request irq\n");
+ pr_err("%s: failed to request irq\n", ostm->name);
return ret;
}
- ced->name = "ostm";
+ ced->name = ostm->name;
ced->features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERIODIC;
ced->set_state_shutdown = ostm_shutdown;
ced->set_state_periodic = ostm_set_periodic;
@@ -194,38 +193,41 @@ static int __init ostm_init_clkevt(struct ostm_device *ostm, int irq,
static int __init ostm_init(struct device_node *np)
{
+ unsigned int n = sizeof("ostm ") + strlen(np->name);
struct ostm_device *ostm;
int ret = -EFAULT;
struct clk *ostm_clk = NULL;
int irq;
unsigned long rate;
- ostm = kzalloc(sizeof(*ostm), GFP_KERNEL);
+ ostm = kzalloc(sizeof(*ostm) + n, GFP_KERNEL);
if (!ostm)
return -ENOMEM;
+ snprintf(ostm->name, n, "ostm %s", np->name);
+
ostm->base = of_iomap(np, 0);
if (!ostm->base) {
- pr_err("ostm: failed to remap I/O memory\n");
+ pr_err("%s: failed to remap I/O memory\n", ostm->name);
goto err;
}
irq = irq_of_parse_and_map(np, 0);
if (irq < 0) {
- pr_err("ostm: Failed to get irq\n");
+ pr_err("%s: Failed to get irq\n", ostm->name);
goto err;
}
ostm_clk = of_clk_get(np, 0);
if (IS_ERR(ostm_clk)) {
- pr_err("ostm: Failed to get clock\n");
+ pr_err("%s: Failed to get clock\n", ostm->name);
ostm_clk = NULL;
goto err;
}
ret = clk_prepare_enable(ostm_clk);
if (ret) {
- pr_err("ostm: Failed to enable clock\n");
+ pr_err("%s: Failed to enable clock\n", ostm->name);
goto err;
}
@@ -241,14 +243,14 @@ static int __init ostm_init(struct device_node *np)
if (!ret) {
ostm_init_sched_clock(ostm, rate);
- pr_info("ostm: used for clocksource\n");
+ pr_info("%s: used for clocksource\n", ostm->name);
}
} else {
ret = ostm_init_clkevt(ostm, irq, rate);
if (!ret)
- pr_info("ostm: used for clock events\n");
+ pr_info("%s: used for clock events\n", ostm->name);
}
err:
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2] clocksource/drivers/ostm: Use unique device name instead of ostm
2017-10-11 12:31 [PATCH/RFC] clocksource/drivers/ostm: Use unique device name instead of ostm Geert Uytterhoeven
@ 2017-10-11 13:05 ` Jacopo Mondi
2017-10-11 13:26 ` Geert Uytterhoeven
2017-10-11 13:30 ` Chris Brandt
0 siblings, 2 replies; 5+ messages in thread
From: Jacopo Mondi @ 2017-10-11 13:05 UTC (permalink / raw)
To: geert+renesas, chris.brandt; +Cc: linux-renesas-soc, Jacopo Mondi
From: Geert Uytterhoeven <geert+renesas@glider.be>
Currently all OSTM devices are called "ostm", also in kernel messages.
As there can be multiple instances in an SoC, this can confuse the user.
Hence construct a unique name from the DT node name, like is done for
platform devices.
On GR-Peach, the boot log changes like:
-clocksource: ostm: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 57352151442 ns
+clocksource: ostm /timer@fcfec000: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 57352151442 ns
sched_clock: 32 bits at 33MHz, resolution 30ns, wraps every 64440619504ns
-ostm: used for clocksource
-ostm: used for clock events
+ostm /timer@fcfec000: used for clocksource
+ostm /timer@fcfec400: used for clock events
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
Hi Geert,
with your original patch boot log looks like:
clocksource: ostm timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 57339246898 ns
ostm timer: used for clocksource
ostm timer: used for clock events
clocksource: Switched to clocksource ostm timer
Using "np->name" to sprintf the ostm name is not that useful as all ostm
instances will appear as "ostm timer".
With this v2 I am using "np->full_name" and custom print modifier "%pOF" to
sprintf the node name, and now boot log looks like what I have reported in the
change log (*)
Thanks
j
(*) Using %pOF results in "/timer@fcfec000" with the "/" at beginning of
timer name. I used %pOF as it has been recently introduced, but if you
feel like it's better to get rid of the "/" I can fall back to
("%s", np->full_name)
---
drivers/clocksource/renesas-ostm.c | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/drivers/clocksource/renesas-ostm.c b/drivers/clocksource/renesas-ostm.c
index 6cffd7c..0db75de 100644
--- a/drivers/clocksource/renesas-ostm.c
+++ b/drivers/clocksource/renesas-ostm.c
@@ -37,6 +37,7 @@ struct ostm_device {
void __iomem *base;
unsigned long ticks_per_jiffy;
struct clock_event_device ced;
+ char name[0];
};
static void __iomem *system_clock; /* For sched_clock() */
@@ -88,9 +89,8 @@ static int __init ostm_init_clksrc(struct ostm_device *ostm, unsigned long rate)
writeb(CTL_FREERUN, ostm->base + OSTM_CTL);
writeb(TS, ostm->base + OSTM_TS);
- return clocksource_mmio_init(ostm->base + OSTM_CNT,
- "ostm", rate,
- 300, 32, clocksource_mmio_readl_up);
+ return clocksource_mmio_init(ostm->base + OSTM_CNT, ostm->name, rate,
+ 300, 32, clocksource_mmio_readl_up);
}
static u64 notrace ostm_read_sched_clock(void)
@@ -170,15 +170,14 @@ static int __init ostm_init_clkevt(struct ostm_device *ostm, int irq,
struct clock_event_device *ced = &ostm->ced;
int ret = -ENXIO;
- ret = request_irq(irq, ostm_timer_interrupt,
- IRQF_TIMER | IRQF_IRQPOLL,
- "ostm", ostm);
+ ret = request_irq(irq, ostm_timer_interrupt, IRQF_TIMER | IRQF_IRQPOLL,
+ ostm->name, ostm);
if (ret) {
- pr_err("ostm: failed to request irq\n");
+ pr_err("%s: failed to request irq\n", ostm->name);
return ret;
}
- ced->name = "ostm";
+ ced->name = ostm->name;
ced->features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERIODIC;
ced->set_state_shutdown = ostm_shutdown;
ced->set_state_periodic = ostm_set_periodic;
@@ -194,38 +193,41 @@ static int __init ostm_init_clkevt(struct ostm_device *ostm, int irq,
static int __init ostm_init(struct device_node *np)
{
+ unsigned int n = sizeof("ostm ") + strlen(np->full_name);
struct ostm_device *ostm;
int ret = -EFAULT;
struct clk *ostm_clk = NULL;
int irq;
unsigned long rate;
- ostm = kzalloc(sizeof(*ostm), GFP_KERNEL);
+ ostm = kzalloc(sizeof(*ostm) + n, GFP_KERNEL);
if (!ostm)
return -ENOMEM;
+ snprintf(ostm->name, n, "ostm %pOF", np);
+
ostm->base = of_iomap(np, 0);
if (!ostm->base) {
- pr_err("ostm: failed to remap I/O memory\n");
+ pr_err("%s: failed to remap I/O memory\n", ostm->name);
goto err;
}
irq = irq_of_parse_and_map(np, 0);
if (irq < 0) {
- pr_err("ostm: Failed to get irq\n");
+ pr_err("%s: Failed to get irq\n", ostm->name);
goto err;
}
ostm_clk = of_clk_get(np, 0);
if (IS_ERR(ostm_clk)) {
- pr_err("ostm: Failed to get clock\n");
+ pr_err("%s: Failed to get clock\n", ostm->name);
ostm_clk = NULL;
goto err;
}
ret = clk_prepare_enable(ostm_clk);
if (ret) {
- pr_err("ostm: Failed to enable clock\n");
+ pr_err("%s: Failed to enable clock\n", ostm->name);
goto err;
}
@@ -241,14 +243,14 @@ static int __init ostm_init(struct device_node *np)
if (!ret) {
ostm_init_sched_clock(ostm, rate);
- pr_info("ostm: used for clocksource\n");
+ pr_info("%s: used for clocksource\n", ostm->name);
}
} else {
ret = ostm_init_clkevt(ostm, irq, rate);
if (!ret)
- pr_info("ostm: used for clock events\n");
+ pr_info("%s: used for clock events\n", ostm->name);
}
err:
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] clocksource/drivers/ostm: Use unique device name instead of ostm
2017-10-11 13:05 ` [PATCH v2] " Jacopo Mondi
@ 2017-10-11 13:26 ` Geert Uytterhoeven
2017-10-11 13:30 ` Chris Brandt
1 sibling, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2017-10-11 13:26 UTC (permalink / raw)
To: Jacopo Mondi; +Cc: Geert Uytterhoeven, Chris Brandt, Linux-Renesas
Hi Jacopo,
On Wed, Oct 11, 2017 at 3:05 PM, Jacopo Mondi <jacopo+renesas@jmondi.org> wrote:
> From: Geert Uytterhoeven <geert+renesas@glider.be>
>
> Currently all OSTM devices are called "ostm", also in kernel messages.
>
> As there can be multiple instances in an SoC, this can confuse the user.
> Hence construct a unique name from the DT node name, like is done for
> platform devices.
>
> On GR-Peach, the boot log changes like:
>
> -clocksource: ostm: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 57352151442 ns
> +clocksource: ostm /timer@fcfec000: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 57352151442 ns
> sched_clock: 32 bits at 33MHz, resolution 30ns, wraps every 64440619504ns
> -ostm: used for clocksource
> -ostm: used for clock events
> +ostm /timer@fcfec000: used for clocksource
> +ostm /timer@fcfec400: used for clock events
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Thanks for testing!
> ---
> Hi Geert,
> with your original patch boot log looks like:
>
> clocksource: ostm timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 57339246898 ns
> ostm timer: used for clocksource
> ostm timer: used for clock events
> clocksource: Switched to clocksource ostm timer
>
> Using "np->name" to sprintf the ostm name is not that useful as all ostm
> instances will appear as "ostm timer".
>
> With this v2 I am using "np->full_name" and custom print modifier "%pOF" to
> sprintf the node name, and now boot log looks like what I have reported in the
> change log (*)
>
> Thanks
> j
>
> (*) Using %pOF results in "/timer@fcfec000" with the "/" at beginning of
> timer name. I used %pOF as it has been recently introduced, but if you
> feel like it's better to get rid of the "/" I can fall back to
> ("%s", np->full_name)
Right, I forgot the unit address is not included.
What I really intended was to print "fcfec000.timer", cfr.
of_device_make_bus_id()
for platform devices.
IMHO the full name is a bit long.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH v2] clocksource/drivers/ostm: Use unique device name instead of ostm
2017-10-11 13:05 ` [PATCH v2] " Jacopo Mondi
2017-10-11 13:26 ` Geert Uytterhoeven
@ 2017-10-11 13:30 ` Chris Brandt
2018-01-04 16:06 ` Chris Brandt
1 sibling, 1 reply; 5+ messages in thread
From: Chris Brandt @ 2017-10-11 13:30 UTC (permalink / raw)
To: Jacopo Mondi, geert+renesas; +Cc: linux-renesas-soc
On Wednesday, October 11, 2017, Jacopo Mondi wrote:
> From: Geert Uytterhoeven <geert+renesas@glider.be>
>
> Currently all OSTM devices are called "ostm", also in kernel messages.
>
> As there can be multiple instances in an SoC, this can confuse the user.
> Hence construct a unique name from the DT node name, like is done for
> platform devices.
>
> On GR-Peach, the boot log changes like:
>
> -clocksource: ostm: mask: 0xffffffff max_cycles: 0xffffffff,
> max_idle_ns: 57352151442 ns
> +clocksource: ostm /timer@fcfec000: mask: 0xffffffff max_cycles:
> 0xffffffff, max_idle_ns: 57352151442 ns
> sched_clock: 32 bits at 33MHz, resolution 30ns, wraps every
> 64440619504ns
> -ostm: used for clocksource
> -ostm: used for clock events
> +ostm /timer@fcfec000: used for clocksource
> +ostm /timer@fcfec400: used for clock events
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> ---
My results on the RZ/A1H RSK board:
$ dmesg | grep timer
[ 0.000000] clocksource: ostm /timer@fcfec000: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 57352151442 ns
[ 0.008267] ostm /timer@fcfec000: used for clocksource
[ 0.014085] ostm /timer@fcfec400: used for clock events
[ 0.452022] sh_mtu2 fcff0000.timer: ch0: used for clock events
[ 0.475358] sh_mtu2 fcff0000.timer: PM domain cpg_clocks will not be powered off
[ 0.486528] clocksource: Switched to clocksource ostm /timer@fcfec000
$ cat /proc/interrupts | grep timer
17: 18721 GIC-0 135 Edge ostm /timer@fcfec400
40: 0 GIC-0 139 Level fcff0000.timer
Chris
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH v2] clocksource/drivers/ostm: Use unique device name instead of ostm
2017-10-11 13:30 ` Chris Brandt
@ 2018-01-04 16:06 ` Chris Brandt
0 siblings, 0 replies; 5+ messages in thread
From: Chris Brandt @ 2018-01-04 16:06 UTC (permalink / raw)
To: Jacopo Mondi, geert+renesas; +Cc: linux-renesas-soc
On Wednesday, October 11, 2017, Chris Brandt wrote:
> On Wednesday, October 11, 2017, Jacopo Mondi wrote:
> > From: Geert Uytterhoeven <geert+renesas@glider.be>
> >
> > Currently all OSTM devices are called "ostm", also in kernel messages.
> >
> > As there can be multiple instances in an SoC, this can confuse the user.
> > Hence construct a unique name from the DT node name, like is done for
> > platform devices.
> >
> > On GR-Peach, the boot log changes like:
> >
> > -clocksource: ostm: mask: 0xffffffff max_cycles: 0xffffffff,
> > max_idle_ns: 57352151442 ns
> > +clocksource: ostm /timer@fcfec000: mask: 0xffffffff max_cycles:
> > 0xffffffff, max_idle_ns: 57352151442 ns
> > sched_clock: 32 bits at 33MHz, resolution 30ns, wraps every
> > 64440619504ns
> > -ostm: used for clocksource
> > -ostm: used for clock events
> > +ostm /timer@fcfec000: used for clocksource
> > +ostm /timer@fcfec400: used for clock events
> >
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> > Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> > ---
>
>
> My results on the RZ/A1H RSK board:
>
> $ dmesg | grep timer
> [ 0.000000] clocksource: ostm /timer@fcfec000: mask: 0xffffffff
> max_cycles: 0xffffffff, max_idle_ns: 57352151442 ns
> [ 0.008267] ostm /timer@fcfec000: used for clocksource
> [ 0.014085] ostm /timer@fcfec400: used for clock events
> [ 0.452022] sh_mtu2 fcff0000.timer: ch0: used for clock events
> [ 0.475358] sh_mtu2 fcff0000.timer: PM domain cpg_clocks will not be
> powered off
> [ 0.486528] clocksource: Switched to clocksource ostm /timer@fcfec000
>
>
> $ cat /proc/interrupts | grep timer
> 17: 18721 GIC-0 135 Edge ostm /timer@fcfec400
> 40: 0 GIC-0 139 Level fcff0000.timer
>
>
> Chris
Out of curiosity, what ever happened to this patch???
Chris
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-01-04 16:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-11 12:31 [PATCH/RFC] clocksource/drivers/ostm: Use unique device name instead of ostm Geert Uytterhoeven
2017-10-11 13:05 ` [PATCH v2] " Jacopo Mondi
2017-10-11 13:26 ` Geert Uytterhoeven
2017-10-11 13:30 ` Chris Brandt
2018-01-04 16:06 ` Chris Brandt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.