linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] clocksource/drivers/ostm: Miscellaneous improvements
@ 2019-08-07  8:46 Geert Uytterhoeven
  2019-08-07  8:46 ` [PATCH v3 1/3] clocksource/drivers/renesas-ostm: Use DIV_ROUND_CLOSEST() helper Geert Uytterhoeven
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Geert Uytterhoeven @ 2019-08-07  8:46 UTC (permalink / raw)
  To: Daniel Lezcano, Thomas Gleixner
  Cc: Jacopo Mondi, Chris Brandt, linux-renesas-soc, linux-kernel,
	Geert Uytterhoeven

	Hi all,

This patch series contains various improvements for the Renesas OSTM
timer driver, as used on the RZ/A1 and RZ/A2 SoCs.

The last patch is v3 of a patch that was sent before to a limited
audience:
  - https://lore.kernel.org/linux-renesas-soc/1507727130-17641-1-git-send-email-jacopo+renesas@jmondi.org/
  - https://lore.kernel.org/linux-renesas-soc/1507725113-18070-1-git-send-email-geert+renesas@glider.be/

Thanks!

Geert Uytterhoeven (3):
  clocksource/drivers/renesas-ostm: Use DIV_ROUND_CLOSEST() helper
  clocksource/drivers/renesas-ostm: Fix probe error path
  clocksource/drivers/ostm: Use unique device name instead of ostm

 drivers/clocksource/renesas-ostm.c | 95 ++++++++++++++++++------------
 1 file changed, 57 insertions(+), 38 deletions(-)

-- 
2.17.1

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] 13+ messages in thread

* [PATCH v3 1/3] clocksource/drivers/renesas-ostm: Use DIV_ROUND_CLOSEST() helper
  2019-08-07  8:46 [PATCH v3 0/3] clocksource/drivers/ostm: Miscellaneous improvements Geert Uytterhoeven
@ 2019-08-07  8:46 ` Geert Uytterhoeven
  2019-08-16 12:58   ` Simon Horman
  2019-08-07  8:46 ` [PATCH v3 2/3] clocksource/drivers/renesas-ostm: Fix probe error path Geert Uytterhoeven
  2019-08-07  8:46 ` [PATCH v3 3/3] clocksource/drivers/ostm: Use unique device name instead of ostm Geert Uytterhoeven
  2 siblings, 1 reply; 13+ messages in thread
From: Geert Uytterhoeven @ 2019-08-07  8:46 UTC (permalink / raw)
  To: Daniel Lezcano, Thomas Gleixner
  Cc: Jacopo Mondi, Chris Brandt, linux-renesas-soc, linux-kernel,
	Geert Uytterhoeven

Use the DIV_ROUND_CLOSEST() helper instead of open-coding the same
operation.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v3:
  - New.
---
 drivers/clocksource/renesas-ostm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/renesas-ostm.c b/drivers/clocksource/renesas-ostm.c
index 61d5f3b539ce23df..37c39b901bb12b38 100644
--- a/drivers/clocksource/renesas-ostm.c
+++ b/drivers/clocksource/renesas-ostm.c
@@ -221,7 +221,7 @@ static int __init ostm_init(struct device_node *np)
 	}
 
 	rate = clk_get_rate(ostm_clk);
-	ostm->ticks_per_jiffy = (rate + HZ / 2) / HZ;
+	ostm->ticks_per_jiffy = DIV_ROUND_CLOSEST(rate, HZ);
 
 	/*
 	 * First probed device will be used as system clocksource. Any
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 2/3] clocksource/drivers/renesas-ostm: Fix probe error path
  2019-08-07  8:46 [PATCH v3 0/3] clocksource/drivers/ostm: Miscellaneous improvements Geert Uytterhoeven
  2019-08-07  8:46 ` [PATCH v3 1/3] clocksource/drivers/renesas-ostm: Use DIV_ROUND_CLOSEST() helper Geert Uytterhoeven
@ 2019-08-07  8:46 ` Geert Uytterhoeven
  2019-08-07 18:13   ` Daniel Lezcano
  2019-08-07  8:46 ` [PATCH v3 3/3] clocksource/drivers/ostm: Use unique device name instead of ostm Geert Uytterhoeven
  2 siblings, 1 reply; 13+ messages in thread
From: Geert Uytterhoeven @ 2019-08-07  8:46 UTC (permalink / raw)
  To: Daniel Lezcano, Thomas Gleixner
  Cc: Jacopo Mondi, Chris Brandt, linux-renesas-soc, linux-kernel,
	Geert Uytterhoeven

Fix various issues in the error path of ostm_init():
  1. Drop error message printing on of_iomap() failure, as the memory
     allocation core already takes of that,
  2. Handle irq_of_parse_and_map() failures correctly: it returns
     unsigned int, hence make irq unsigned int, and zero is an error,
  3. Propagate/return appropriate error codes instead of -EFAULT.
  4. Add a missing clk_put(),
  5. Split the single cleanup block in separate phases, to avoid
     clk_put() calling WARN() when passed an error pointer.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v3:
  - New.
---
 drivers/clocksource/renesas-ostm.c | 54 ++++++++++++++++--------------
 1 file changed, 29 insertions(+), 25 deletions(-)

diff --git a/drivers/clocksource/renesas-ostm.c b/drivers/clocksource/renesas-ostm.c
index 37c39b901bb12b38..1e22e54d7b0df40d 100644
--- a/drivers/clocksource/renesas-ostm.c
+++ b/drivers/clocksource/renesas-ostm.c
@@ -155,7 +155,7 @@ static irqreturn_t ostm_timer_interrupt(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
-static int __init ostm_init_clkevt(struct ostm_device *ostm, int irq,
+static int __init ostm_init_clkevt(struct ostm_device *ostm, unsigned int irq,
 			unsigned long rate)
 {
 	struct clock_event_device *ced = &ostm->ced;
@@ -185,11 +185,11 @@ static int __init ostm_init_clkevt(struct ostm_device *ostm, int irq,
 
 static int __init ostm_init(struct device_node *np)
 {
-	struct ostm_device *ostm;
-	int ret = -EFAULT;
 	struct clk *ostm_clk = NULL;
-	int irq;
+	struct ostm_device *ostm;
 	unsigned long rate;
+	unsigned int irq;
+	int ret;
 
 	ostm = kzalloc(sizeof(*ostm), GFP_KERNEL);
 	if (!ostm)
@@ -197,27 +197,29 @@ static int __init ostm_init(struct device_node *np)
 
 	ostm->base = of_iomap(np, 0);
 	if (!ostm->base) {
-		pr_err("ostm: failed to remap I/O memory\n");
-		goto err;
+		ret = -ENOMEM;
+		goto err_free;
 	}
 
 	irq = irq_of_parse_and_map(np, 0);
-	if (irq < 0) {
+	if (!irq) {
 		pr_err("ostm: Failed to get irq\n");
-		goto err;
+		ret = -EINVAL;
+		goto err_unmap;
 	}
 
 	ostm_clk = of_clk_get(np, 0);
 	if (IS_ERR(ostm_clk)) {
 		pr_err("ostm: Failed to get clock\n");
 		ostm_clk = NULL;
-		goto err;
+		ret = PTR_ERR(ostm_clk);
+		goto err_unmap;
 	}
 
 	ret = clk_prepare_enable(ostm_clk);
 	if (ret) {
 		pr_err("ostm: Failed to enable clock\n");
-		goto err;
+		goto err_clk_put;
 	}
 
 	rate = clk_get_rate(ostm_clk);
@@ -229,28 +231,30 @@ static int __init ostm_init(struct device_node *np)
 	 */
 	if (!system_clock) {
 		ret = ostm_init_clksrc(ostm, rate);
+		if (ret)
+			goto err_clk_disable;
 
-		if (!ret) {
-			ostm_init_sched_clock(ostm, rate);
-			pr_info("ostm: used for clocksource\n");
-		}
-
+		ostm_init_sched_clock(ostm, rate);
+		pr_info("ostm: used for clocksource\n");
 	} else {
 		ret = ostm_init_clkevt(ostm, irq, rate);
+		if (ret)
+			goto err_clk_disable;
 
-		if (!ret)
-			pr_info("ostm: used for clock events\n");
-	}
-
-err:
-	if (ret) {
-		clk_disable_unprepare(ostm_clk);
-		iounmap(ostm->base);
-		kfree(ostm);
-		return ret;
+		pr_info("ostm: used for clock events\n");
 	}
 
 	return 0;
+
+err_clk_disable:
+	clk_disable_unprepare(ostm_clk);
+err_clk_put:
+	clk_put(ostm_clk);
+err_unmap:
+	iounmap(ostm->base);
+err_free:
+	kfree(ostm);
+	return ret;
 }
 
 TIMER_OF_DECLARE(ostm, "renesas,ostm", ostm_init);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 3/3] clocksource/drivers/ostm: Use unique device name instead of ostm
  2019-08-07  8:46 [PATCH v3 0/3] clocksource/drivers/ostm: Miscellaneous improvements Geert Uytterhoeven
  2019-08-07  8:46 ` [PATCH v3 1/3] clocksource/drivers/renesas-ostm: Use DIV_ROUND_CLOSEST() helper Geert Uytterhoeven
  2019-08-07  8:46 ` [PATCH v3 2/3] clocksource/drivers/renesas-ostm: Fix probe error path Geert Uytterhoeven
@ 2019-08-07  8:46 ` Geert Uytterhoeven
  2019-08-16 13:11   ` Simon Horman
  2 siblings, 1 reply; 13+ messages in thread
From: Geert Uytterhoeven @ 2019-08-07  8:46 UTC (permalink / raw)
  To: Daniel Lezcano, Thomas Gleixner
  Cc: Jacopo Mondi, Chris Brandt, linux-renesas-soc, linux-kernel,
	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 RSK+RZA1, the boot log changes like:

    -clocksource: ostm: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 57352151442 ns
    +clocksource: ostm fcfec000.timer: 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 fcfec000.timer: used for clocksource
    +ostm fcfec400.timer: used for clock events

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v3:
  - Make the name format similar to the one used for platform devices,
  - Use kasprintf() instead of buffer size guessing,
  - Use a real example from rskrza1.

v2 (by Jacopo):
  - Use np->full_name.
---
 drivers/clocksource/renesas-ostm.c | 45 ++++++++++++++++++++----------
 1 file changed, 30 insertions(+), 15 deletions(-)

diff --git a/drivers/clocksource/renesas-ostm.c b/drivers/clocksource/renesas-ostm.c
index 1e22e54d7b0df40d..659e3ec7b86714e3 100644
--- a/drivers/clocksource/renesas-ostm.c
+++ b/drivers/clocksource/renesas-ostm.c
@@ -25,6 +25,7 @@
  */
 
 struct ostm_device {
+	const char *name;
 	void __iomem *base;
 	unsigned long ticks_per_jiffy;
 	struct clock_event_device ced;
@@ -79,9 +80,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)
@@ -161,15 +161,14 @@ static int __init ostm_init_clkevt(struct ostm_device *ostm, unsigned 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;
@@ -187,6 +186,7 @@ static int __init ostm_init(struct device_node *np)
 {
 	struct clk *ostm_clk = NULL;
 	struct ostm_device *ostm;
+	struct resource res;
 	unsigned long rate;
 	unsigned int irq;
 	int ret;
@@ -195,22 +195,35 @@ static int __init ostm_init(struct device_node *np)
 	if (!ostm)
 		return -ENOMEM;
 
-	ostm->base = of_iomap(np, 0);
-	if (!ostm->base) {
+	ret = of_address_to_resource(np, 0, &res);
+	if (ret) {
+		pr_err("ostm: Failed to obtain I/O memory\n");
+		goto err_free;
+	}
+
+	ostm->name = kasprintf(GFP_KERNEL, "ostm %llx.%s",
+			       (unsigned long long)res.start, np->name);
+	if (!ostm->name) {
 		ret = -ENOMEM;
 		goto err_free;
 	}
 
+	ostm->base = ioremap(res.start, resource_size(&res));
+	if (!ostm->base) {
+		ret = -ENOMEM;
+		goto err_free_name;
+	}
+
 	irq = irq_of_parse_and_map(np, 0);
 	if (!irq) {
-		pr_err("ostm: Failed to get irq\n");
+		pr_err("%s: Failed to get irq\n", ostm->name);
 		ret = -EINVAL;
 		goto err_unmap;
 	}
 
 	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;
 		ret = PTR_ERR(ostm_clk);
 		goto err_unmap;
@@ -218,7 +231,7 @@ static int __init ostm_init(struct device_node *np)
 
 	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_clk_put;
 	}
 
@@ -235,13 +248,13 @@ static int __init ostm_init(struct device_node *np)
 			goto err_clk_disable;
 
 		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)
 			goto err_clk_disable;
 
-		pr_info("ostm: used for clock events\n");
+		pr_info("%s: used for clock events\n", ostm->name);
 	}
 
 	return 0;
@@ -252,6 +265,8 @@ static int __init ostm_init(struct device_node *np)
 	clk_put(ostm_clk);
 err_unmap:
 	iounmap(ostm->base);
+err_free_name:
+	kfree(ostm->name);
 err_free:
 	kfree(ostm);
 	return ret;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 2/3] clocksource/drivers/renesas-ostm: Fix probe error path
  2019-08-07  8:46 ` [PATCH v3 2/3] clocksource/drivers/renesas-ostm: Fix probe error path Geert Uytterhoeven
@ 2019-08-07 18:13   ` Daniel Lezcano
  2019-08-07 18:56     ` Geert Uytterhoeven
  2019-08-16 13:19     ` Simon Horman
  0 siblings, 2 replies; 13+ messages in thread
From: Daniel Lezcano @ 2019-08-07 18:13 UTC (permalink / raw)
  To: Geert Uytterhoeven, Thomas Gleixner
  Cc: Jacopo Mondi, Chris Brandt, linux-renesas-soc, linux-kernel

On 07/08/2019 10:46, Geert Uytterhoeven wrote:
> Fix various issues in the error path of ostm_init():
>   1. Drop error message printing on of_iomap() failure, as the memory
>      allocation core already takes of that,
>   2. Handle irq_of_parse_and_map() failures correctly: it returns
>      unsigned int, hence make irq unsigned int, and zero is an error,
>   3. Propagate/return appropriate error codes instead of -EFAULT.
>   4. Add a missing clk_put(),
>   5. Split the single cleanup block in separate phases, to avoid
>      clk_put() calling WARN() when passed an error pointer.

Does it make sense to convert to timer-of API?

> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> v3:
>   - New.
> ---
>  drivers/clocksource/renesas-ostm.c | 54 ++++++++++++++++--------------
>  1 file changed, 29 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/clocksource/renesas-ostm.c b/drivers/clocksource/renesas-ostm.c
> index 37c39b901bb12b38..1e22e54d7b0df40d 100644
> --- a/drivers/clocksource/renesas-ostm.c
> +++ b/drivers/clocksource/renesas-ostm.c
> @@ -155,7 +155,7 @@ static irqreturn_t ostm_timer_interrupt(int irq, void *dev_id)
>  	return IRQ_HANDLED;
>  }
>  
> -static int __init ostm_init_clkevt(struct ostm_device *ostm, int irq,
> +static int __init ostm_init_clkevt(struct ostm_device *ostm, unsigned int irq,
>  			unsigned long rate)
>  {
>  	struct clock_event_device *ced = &ostm->ced;
> @@ -185,11 +185,11 @@ static int __init ostm_init_clkevt(struct ostm_device *ostm, int irq,
>  
>  static int __init ostm_init(struct device_node *np)
>  {
> -	struct ostm_device *ostm;
> -	int ret = -EFAULT;
>  	struct clk *ostm_clk = NULL;
> -	int irq;
> +	struct ostm_device *ostm;
>  	unsigned long rate;
> +	unsigned int irq;
> +	int ret;
>  
>  	ostm = kzalloc(sizeof(*ostm), GFP_KERNEL);
>  	if (!ostm)
> @@ -197,27 +197,29 @@ static int __init ostm_init(struct device_node *np)
>  
>  	ostm->base = of_iomap(np, 0);
>  	if (!ostm->base) {
> -		pr_err("ostm: failed to remap I/O memory\n");
> -		goto err;
> +		ret = -ENOMEM;
> +		goto err_free;
>  	}
>  
>  	irq = irq_of_parse_and_map(np, 0);
> -	if (irq < 0) {
> +	if (!irq) {
>  		pr_err("ostm: Failed to get irq\n");
> -		goto err;
> +		ret = -EINVAL;
> +		goto err_unmap;
>  	}
>  
>  	ostm_clk = of_clk_get(np, 0);
>  	if (IS_ERR(ostm_clk)) {
>  		pr_err("ostm: Failed to get clock\n");
>  		ostm_clk = NULL;
> -		goto err;
> +		ret = PTR_ERR(ostm_clk);
> +		goto err_unmap;
>  	}
>  
>  	ret = clk_prepare_enable(ostm_clk);
>  	if (ret) {
>  		pr_err("ostm: Failed to enable clock\n");
> -		goto err;
> +		goto err_clk_put;
>  	}
>  
>  	rate = clk_get_rate(ostm_clk);
> @@ -229,28 +231,30 @@ static int __init ostm_init(struct device_node *np)
>  	 */
>  	if (!system_clock) {
>  		ret = ostm_init_clksrc(ostm, rate);
> +		if (ret)
> +			goto err_clk_disable;
>  
> -		if (!ret) {
> -			ostm_init_sched_clock(ostm, rate);
> -			pr_info("ostm: used for clocksource\n");
> -		}
> -
> +		ostm_init_sched_clock(ostm, rate);
> +		pr_info("ostm: used for clocksource\n");
>  	} else {
>  		ret = ostm_init_clkevt(ostm, irq, rate);
> +		if (ret)
> +			goto err_clk_disable;
>  
> -		if (!ret)
> -			pr_info("ostm: used for clock events\n");
> -	}
> -
> -err:
> -	if (ret) {
> -		clk_disable_unprepare(ostm_clk);
> -		iounmap(ostm->base);
> -		kfree(ostm);
> -		return ret;
> +		pr_info("ostm: used for clock events\n");
>  	}
>  
>  	return 0;
> +
> +err_clk_disable:
> +	clk_disable_unprepare(ostm_clk);
> +err_clk_put:
> +	clk_put(ostm_clk);
> +err_unmap:
> +	iounmap(ostm->base);
> +err_free:
> +	kfree(ostm);
> +	return ret;
>  }
>  
>  TIMER_OF_DECLARE(ostm, "renesas,ostm", ostm_init);
> 


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 2/3] clocksource/drivers/renesas-ostm: Fix probe error path
  2019-08-07 18:13   ` Daniel Lezcano
@ 2019-08-07 18:56     ` Geert Uytterhoeven
  2019-08-16 13:19     ` Simon Horman
  1 sibling, 0 replies; 13+ messages in thread
From: Geert Uytterhoeven @ 2019-08-07 18:56 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Geert Uytterhoeven, Thomas Gleixner, Jacopo Mondi, Chris Brandt,
	Linux-Renesas, Linux Kernel Mailing List

Hi Daniel,

On Wed, Aug 7, 2019 at 8:13 PM Daniel Lezcano <daniel.lezcano@linaro.org> wrote:
> On 07/08/2019 10:46, Geert Uytterhoeven wrote:
> > Fix various issues in the error path of ostm_init():
> >   1. Drop error message printing on of_iomap() failure, as the memory
> >      allocation core already takes of that,
> >   2. Handle irq_of_parse_and_map() failures correctly: it returns
> >      unsigned int, hence make irq unsigned int, and zero is an error,
> >   3. Propagate/return appropriate error codes instead of -EFAULT.
> >   4. Add a missing clk_put(),
> >   5. Split the single cleanup block in separate phases, to avoid
> >      clk_put() calling WARN() when passed an error pointer.
>
> Does it make sense to convert to timer-of API?

I don't know. Will have a look...

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] 13+ messages in thread

* Re: [PATCH v3 1/3] clocksource/drivers/renesas-ostm: Use DIV_ROUND_CLOSEST() helper
  2019-08-07  8:46 ` [PATCH v3 1/3] clocksource/drivers/renesas-ostm: Use DIV_ROUND_CLOSEST() helper Geert Uytterhoeven
@ 2019-08-16 12:58   ` Simon Horman
  2019-08-16 13:00     ` Daniel Lezcano
  0 siblings, 1 reply; 13+ messages in thread
From: Simon Horman @ 2019-08-16 12:58 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Daniel Lezcano, Thomas Gleixner, Jacopo Mondi, Chris Brandt,
	linux-renesas-soc, linux-kernel

On Wed, Aug 07, 2019 at 10:46:33AM +0200, Geert Uytterhoeven wrote:
> Use the DIV_ROUND_CLOSEST() helper instead of open-coding the same
> operation.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> ---
> v3:
>   - New.
> ---
>  drivers/clocksource/renesas-ostm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clocksource/renesas-ostm.c b/drivers/clocksource/renesas-ostm.c
> index 61d5f3b539ce23df..37c39b901bb12b38 100644
> --- a/drivers/clocksource/renesas-ostm.c
> +++ b/drivers/clocksource/renesas-ostm.c
> @@ -221,7 +221,7 @@ static int __init ostm_init(struct device_node *np)
>  	}
>  
>  	rate = clk_get_rate(ostm_clk);
> -	ostm->ticks_per_jiffy = (rate + HZ / 2) / HZ;
> +	ostm->ticks_per_jiffy = DIV_ROUND_CLOSEST(rate, HZ);
>  
>  	/*
>  	 * First probed device will be used as system clocksource. Any
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 1/3] clocksource/drivers/renesas-ostm: Use DIV_ROUND_CLOSEST() helper
  2019-08-16 12:58   ` Simon Horman
@ 2019-08-16 13:00     ` Daniel Lezcano
  0 siblings, 0 replies; 13+ messages in thread
From: Daniel Lezcano @ 2019-08-16 13:00 UTC (permalink / raw)
  To: Simon Horman, Geert Uytterhoeven
  Cc: Thomas Gleixner, Jacopo Mondi, Chris Brandt, linux-renesas-soc,
	linux-kernel

On 16/08/2019 14:58, Simon Horman wrote:
> On Wed, Aug 07, 2019 at 10:46:33AM +0200, Geert Uytterhoeven wrote:
>> Use the DIV_ROUND_CLOSEST() helper instead of open-coding the same
>> operation.
>>
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> 
> Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

Applied this one, thanks

I'm waiting Geert feedbacks for 2/3 and 3/3.


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 3/3] clocksource/drivers/ostm: Use unique device name instead of ostm
  2019-08-07  8:46 ` [PATCH v3 3/3] clocksource/drivers/ostm: Use unique device name instead of ostm Geert Uytterhoeven
@ 2019-08-16 13:11   ` Simon Horman
  2019-08-16 13:12     ` Simon Horman
  2019-08-16 13:18     ` Geert Uytterhoeven
  0 siblings, 2 replies; 13+ messages in thread
From: Simon Horman @ 2019-08-16 13:11 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Daniel Lezcano, Thomas Gleixner, Jacopo Mondi, Chris Brandt,
	linux-renesas-soc, linux-kernel

On Wed, Aug 07, 2019 at 10:46:35AM +0200, Geert Uytterhoeven wrote:
> 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 RSK+RZA1, the boot log changes like:
> 
>     -clocksource: ostm: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 57352151442 ns
>     +clocksource: ostm fcfec000.timer: 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 fcfec000.timer: used for clocksource
>     +ostm fcfec400.timer: used for clock events
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> v3:
>   - Make the name format similar to the one used for platform devices,
>   - Use kasprintf() instead of buffer size guessing,
>   - Use a real example from rskrza1.
> 
> v2 (by Jacopo):
>   - Use np->full_name.
> ---
>  drivers/clocksource/renesas-ostm.c | 45 ++++++++++++++++++++----------
>  1 file changed, 30 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/clocksource/renesas-ostm.c b/drivers/clocksource/renesas-ostm.c
> index 1e22e54d7b0df40d..659e3ec7b86714e3 100644
> --- a/drivers/clocksource/renesas-ostm.c
> +++ b/drivers/clocksource/renesas-ostm.c
> @@ -25,6 +25,7 @@
>   */
>  
>  struct ostm_device {
> +	const char *name;
>  	void __iomem *base;
>  	unsigned long ticks_per_jiffy;
>  	struct clock_event_device ced;
> @@ -79,9 +80,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)
> @@ -161,15 +161,14 @@ static int __init ostm_init_clkevt(struct ostm_device *ostm, unsigned 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;
> @@ -187,6 +186,7 @@ static int __init ostm_init(struct device_node *np)
>  {
>  	struct clk *ostm_clk = NULL;
>  	struct ostm_device *ostm;
> +	struct resource res;
>  	unsigned long rate;
>  	unsigned int irq;
>  	int ret;
> @@ -195,22 +195,35 @@ static int __init ostm_init(struct device_node *np)
>  	if (!ostm)
>  		return -ENOMEM;
>  
> -	ostm->base = of_iomap(np, 0);
> -	if (!ostm->base) {
> +	ret = of_address_to_resource(np, 0, &res);
> +	if (ret) {
> +		pr_err("ostm: Failed to obtain I/O memory\n");
> +		goto err_free;
> +	}
> +
> +	ostm->name = kasprintf(GFP_KERNEL, "ostm %llx.%s",
> +			       (unsigned long long)res.start, np->name);

I'm not sure, but looking at printk-formats.rst it seems that
%pa[p] as a format specifier for resource_size_t. If so it may
allow dropping the cast above.

> +	if (!ostm->name) {
>  		ret = -ENOMEM;
>  		goto err_free;
>  	}
>  
> +	ostm->base = ioremap(res.start, resource_size(&res));
> +	if (!ostm->base) {
> +		ret = -ENOMEM;
> +		goto err_free_name;
> +	}
> +
>  	irq = irq_of_parse_and_map(np, 0);
>  	if (!irq) {
> -		pr_err("ostm: Failed to get irq\n");
> +		pr_err("%s: Failed to get irq\n", ostm->name);
>  		ret = -EINVAL;
>  		goto err_unmap;
>  	}
>  
>  	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;
>  		ret = PTR_ERR(ostm_clk);
>  		goto err_unmap;
> @@ -218,7 +231,7 @@ static int __init ostm_init(struct device_node *np)
>  
>  	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_clk_put;
>  	}
>  
> @@ -235,13 +248,13 @@ static int __init ostm_init(struct device_node *np)
>  			goto err_clk_disable;
>  
>  		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)
>  			goto err_clk_disable;
>  
> -		pr_info("ostm: used for clock events\n");
> +		pr_info("%s: used for clock events\n", ostm->name);
>  	}
>  
>  	return 0;
> @@ -252,6 +265,8 @@ static int __init ostm_init(struct device_node *np)
>  	clk_put(ostm_clk);
>  err_unmap:
>  	iounmap(ostm->base);
> +err_free_name:
> +	kfree(ostm->name);
>  err_free:
>  	kfree(ostm);
>  	return ret;
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 3/3] clocksource/drivers/ostm: Use unique device name instead of ostm
  2019-08-16 13:11   ` Simon Horman
@ 2019-08-16 13:12     ` Simon Horman
  2019-08-16 13:18     ` Geert Uytterhoeven
  1 sibling, 0 replies; 13+ messages in thread
From: Simon Horman @ 2019-08-16 13:12 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Daniel Lezcano, Thomas Gleixner, Jacopo Mondi, Chris Brandt,
	linux-renesas-soc, linux-kernel

On Fri, Aug 16, 2019 at 03:11:29PM +0200, Simon Horman wrote:
> On Wed, Aug 07, 2019 at 10:46:35AM +0200, Geert Uytterhoeven wrote:
> > 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 RSK+RZA1, the boot log changes like:
> > 
> >     -clocksource: ostm: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 57352151442 ns
> >     +clocksource: ostm fcfec000.timer: 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 fcfec000.timer: used for clocksource
> >     +ostm fcfec400.timer: used for clock events
> > 
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

The nit in my previous email notwithstanding

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> > ---
> > v3:
> >   - Make the name format similar to the one used for platform devices,
> >   - Use kasprintf() instead of buffer size guessing,
> >   - Use a real example from rskrza1.
> > 
> > v2 (by Jacopo):
> >   - Use np->full_name.
> > ---
> >  drivers/clocksource/renesas-ostm.c | 45 ++++++++++++++++++++----------
> >  1 file changed, 30 insertions(+), 15 deletions(-)
> > 
> > diff --git a/drivers/clocksource/renesas-ostm.c b/drivers/clocksource/renesas-ostm.c
> > index 1e22e54d7b0df40d..659e3ec7b86714e3 100644
> > --- a/drivers/clocksource/renesas-ostm.c
> > +++ b/drivers/clocksource/renesas-ostm.c
> > @@ -25,6 +25,7 @@
> >   */
> >  
> >  struct ostm_device {
> > +	const char *name;
> >  	void __iomem *base;
> >  	unsigned long ticks_per_jiffy;
> >  	struct clock_event_device ced;
> > @@ -79,9 +80,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)
> > @@ -161,15 +161,14 @@ static int __init ostm_init_clkevt(struct ostm_device *ostm, unsigned 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;
> > @@ -187,6 +186,7 @@ static int __init ostm_init(struct device_node *np)
> >  {
> >  	struct clk *ostm_clk = NULL;
> >  	struct ostm_device *ostm;
> > +	struct resource res;
> >  	unsigned long rate;
> >  	unsigned int irq;
> >  	int ret;
> > @@ -195,22 +195,35 @@ static int __init ostm_init(struct device_node *np)
> >  	if (!ostm)
> >  		return -ENOMEM;
> >  
> > -	ostm->base = of_iomap(np, 0);
> > -	if (!ostm->base) {
> > +	ret = of_address_to_resource(np, 0, &res);
> > +	if (ret) {
> > +		pr_err("ostm: Failed to obtain I/O memory\n");
> > +		goto err_free;
> > +	}
> > +
> > +	ostm->name = kasprintf(GFP_KERNEL, "ostm %llx.%s",
> > +			       (unsigned long long)res.start, np->name);
> 
> I'm not sure, but looking at printk-formats.rst it seems that
> %pa[p] as a format specifier for resource_size_t. If so it may
> allow dropping the cast above.
> 
> > +	if (!ostm->name) {
> >  		ret = -ENOMEM;
> >  		goto err_free;
> >  	}
> >  
> > +	ostm->base = ioremap(res.start, resource_size(&res));
> > +	if (!ostm->base) {
> > +		ret = -ENOMEM;
> > +		goto err_free_name;
> > +	}
> > +
> >  	irq = irq_of_parse_and_map(np, 0);
> >  	if (!irq) {
> > -		pr_err("ostm: Failed to get irq\n");
> > +		pr_err("%s: Failed to get irq\n", ostm->name);
> >  		ret = -EINVAL;
> >  		goto err_unmap;
> >  	}
> >  
> >  	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;
> >  		ret = PTR_ERR(ostm_clk);
> >  		goto err_unmap;
> > @@ -218,7 +231,7 @@ static int __init ostm_init(struct device_node *np)
> >  
> >  	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_clk_put;
> >  	}
> >  
> > @@ -235,13 +248,13 @@ static int __init ostm_init(struct device_node *np)
> >  			goto err_clk_disable;
> >  
> >  		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)
> >  			goto err_clk_disable;
> >  
> > -		pr_info("ostm: used for clock events\n");
> > +		pr_info("%s: used for clock events\n", ostm->name);
> >  	}
> >  
> >  	return 0;
> > @@ -252,6 +265,8 @@ static int __init ostm_init(struct device_node *np)
> >  	clk_put(ostm_clk);
> >  err_unmap:
> >  	iounmap(ostm->base);
> > +err_free_name:
> > +	kfree(ostm->name);
> >  err_free:
> >  	kfree(ostm);
> >  	return ret;
> > -- 
> > 2.17.1
> > 
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 3/3] clocksource/drivers/ostm: Use unique device name instead of ostm
  2019-08-16 13:11   ` Simon Horman
  2019-08-16 13:12     ` Simon Horman
@ 2019-08-16 13:18     ` Geert Uytterhoeven
  2019-08-21 14:12       ` Simon Horman
  1 sibling, 1 reply; 13+ messages in thread
From: Geert Uytterhoeven @ 2019-08-16 13:18 UTC (permalink / raw)
  To: Simon Horman
  Cc: Geert Uytterhoeven, Daniel Lezcano, Thomas Gleixner,
	Jacopo Mondi, Chris Brandt, Linux-Renesas,
	Linux Kernel Mailing List

Hi Simon,

On Fri, Aug 16, 2019 at 3:11 PM Simon Horman <horms@verge.net.au> wrote:
> On Wed, Aug 07, 2019 at 10:46:35AM +0200, Geert Uytterhoeven wrote:
> > 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 RSK+RZA1, the boot log changes like:
> >
> >     -clocksource: ostm: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 57352151442 ns
> >     +clocksource: ostm fcfec000.timer: 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 fcfec000.timer: used for clocksource
> >     +ostm fcfec400.timer: used for clock events
> >
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > ---
> > v3:
> >   - Make the name format similar to the one used for platform devices,
> >   - Use kasprintf() instead of buffer size guessing,
> >   - Use a real example from rskrza1.
> >
> > v2 (by Jacopo):
> >   - Use np->full_name.
> > ---
> >  drivers/clocksource/renesas-ostm.c | 45 ++++++++++++++++++++----------
> >  1 file changed, 30 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/clocksource/renesas-ostm.c b/drivers/clocksource/renesas-ostm.c
> > index 1e22e54d7b0df40d..659e3ec7b86714e3 100644
> > --- a/drivers/clocksource/renesas-ostm.c
> > +++ b/drivers/clocksource/renesas-ostm.c

> > @@ -195,22 +195,35 @@ static int __init ostm_init(struct device_node *np)
> >       if (!ostm)
> >               return -ENOMEM;
> >
> > -     ostm->base = of_iomap(np, 0);
> > -     if (!ostm->base) {
> > +     ret = of_address_to_resource(np, 0, &res);
> > +     if (ret) {
> > +             pr_err("ostm: Failed to obtain I/O memory\n");
> > +             goto err_free;
> > +     }
> > +
> > +     ostm->name = kasprintf(GFP_KERNEL, "ostm %llx.%s",
> > +                            (unsigned long long)res.start, np->name);
>
> I'm not sure, but looking at printk-formats.rst it seems that
> %pa[p] as a format specifier for resource_size_t. If so it may
> allow dropping the cast above.

Using "%pa" adds a "0x" prefix, which we don't want here.

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] 13+ messages in thread

* Re: [PATCH v3 2/3] clocksource/drivers/renesas-ostm: Fix probe error path
  2019-08-07 18:13   ` Daniel Lezcano
  2019-08-07 18:56     ` Geert Uytterhoeven
@ 2019-08-16 13:19     ` Simon Horman
  1 sibling, 0 replies; 13+ messages in thread
From: Simon Horman @ 2019-08-16 13:19 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Geert Uytterhoeven, Thomas Gleixner, Jacopo Mondi, Chris Brandt,
	linux-renesas-soc, linux-kernel

On Wed, Aug 07, 2019 at 08:13:27PM +0200, Daniel Lezcano wrote:
> On 07/08/2019 10:46, Geert Uytterhoeven wrote:
> > Fix various issues in the error path of ostm_init():
> >   1. Drop error message printing on of_iomap() failure, as the memory
> >      allocation core already takes of that,
> >   2. Handle irq_of_parse_and_map() failures correctly: it returns
> >      unsigned int, hence make irq unsigned int, and zero is an error,
> >   3. Propagate/return appropriate error codes instead of -EFAULT.
> >   4. Add a missing clk_put(),
> >   5. Split the single cleanup block in separate phases, to avoid
> >      clk_put() calling WARN() when passed an error pointer.
> 
> Does it make sense to convert to timer-of API?

I don't have an opinion on that at this time,
but as an improvement this patch looks good to me.

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 3/3] clocksource/drivers/ostm: Use unique device name instead of ostm
  2019-08-16 13:18     ` Geert Uytterhoeven
@ 2019-08-21 14:12       ` Simon Horman
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Horman @ 2019-08-21 14:12 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Geert Uytterhoeven, Daniel Lezcano, Thomas Gleixner,
	Jacopo Mondi, Chris Brandt, Linux-Renesas,
	Linux Kernel Mailing List

On Fri, Aug 16, 2019 at 03:18:06PM +0200, Geert Uytterhoeven wrote:
> Hi Simon,
> 
> On Fri, Aug 16, 2019 at 3:11 PM Simon Horman <horms@verge.net.au> wrote:
> > On Wed, Aug 07, 2019 at 10:46:35AM +0200, Geert Uytterhoeven wrote:
> > > 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 RSK+RZA1, the boot log changes like:
> > >
> > >     -clocksource: ostm: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 57352151442 ns
> > >     +clocksource: ostm fcfec000.timer: 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 fcfec000.timer: used for clocksource
> > >     +ostm fcfec400.timer: used for clock events
> > >
> > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > > ---
> > > v3:
> > >   - Make the name format similar to the one used for platform devices,
> > >   - Use kasprintf() instead of buffer size guessing,
> > >   - Use a real example from rskrza1.
> > >
> > > v2 (by Jacopo):
> > >   - Use np->full_name.
> > > ---
> > >  drivers/clocksource/renesas-ostm.c | 45 ++++++++++++++++++++----------
> > >  1 file changed, 30 insertions(+), 15 deletions(-)
> > >
> > > diff --git a/drivers/clocksource/renesas-ostm.c b/drivers/clocksource/renesas-ostm.c
> > > index 1e22e54d7b0df40d..659e3ec7b86714e3 100644
> > > --- a/drivers/clocksource/renesas-ostm.c
> > > +++ b/drivers/clocksource/renesas-ostm.c
> 
> > > @@ -195,22 +195,35 @@ static int __init ostm_init(struct device_node *np)
> > >       if (!ostm)
> > >               return -ENOMEM;
> > >
> > > -     ostm->base = of_iomap(np, 0);
> > > -     if (!ostm->base) {
> > > +     ret = of_address_to_resource(np, 0, &res);
> > > +     if (ret) {
> > > +             pr_err("ostm: Failed to obtain I/O memory\n");
> > > +             goto err_free;
> > > +     }
> > > +
> > > +     ostm->name = kasprintf(GFP_KERNEL, "ostm %llx.%s",
> > > +                            (unsigned long long)res.start, np->name);
> >
> > I'm not sure, but looking at printk-formats.rst it seems that
> > %pa[p] as a format specifier for resource_size_t. If so it may
> > allow dropping the cast above.
> 
> Using "%pa" adds a "0x" prefix, which we don't want here.

Thanks, got it.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-08-21 14:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-07  8:46 [PATCH v3 0/3] clocksource/drivers/ostm: Miscellaneous improvements Geert Uytterhoeven
2019-08-07  8:46 ` [PATCH v3 1/3] clocksource/drivers/renesas-ostm: Use DIV_ROUND_CLOSEST() helper Geert Uytterhoeven
2019-08-16 12:58   ` Simon Horman
2019-08-16 13:00     ` Daniel Lezcano
2019-08-07  8:46 ` [PATCH v3 2/3] clocksource/drivers/renesas-ostm: Fix probe error path Geert Uytterhoeven
2019-08-07 18:13   ` Daniel Lezcano
2019-08-07 18:56     ` Geert Uytterhoeven
2019-08-16 13:19     ` Simon Horman
2019-08-07  8:46 ` [PATCH v3 3/3] clocksource/drivers/ostm: Use unique device name instead of ostm Geert Uytterhoeven
2019-08-16 13:11   ` Simon Horman
2019-08-16 13:12     ` Simon Horman
2019-08-16 13:18     ` Geert Uytterhoeven
2019-08-21 14:12       ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).