* [PATCH v3 0/4] clocksource: timer-atmel-pit: driver fix and cleanups
@ 2016-08-23 8:44 Alexandre Belloni
2016-08-23 8:44 ` [PATCH v3 1/4] clocksource: timer-atmel-pit: enable mck Alexandre Belloni
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Alexandre Belloni @ 2016-08-23 8:44 UTC (permalink / raw)
To: Daniel Lezcano
Cc: Thomas Gleixner, Boris Brezillon, Nicolas Ferre,
linux-arm-kernel, linux-kernel, Alexandre Belloni
Hi,
The first patch in the series is a fix that will be needed starting v4.9. The
remaining patches are cleanups.
Changes in v3:
- stop using panic
Changes in v2:
- Rebased on v4.8-rc1
- Collected acks
Alexandre Belloni (4):
clocksource: timer-atmel-pit: enable mck
clocksource: timer-atmel-pit: drop at91sam926x_pit_common_init
clocksource: timer-atmel-pit: remove uselesss WARN_ON_ONCE
clocksource: timer-atmel-pit: simplify IRQ handler
drivers/clocksource/timer-atmel-pit.c | 93 +++++++++++++++--------------------
1 file changed, 41 insertions(+), 52 deletions(-)
--
2.8.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/4] clocksource: timer-atmel-pit: enable mck
2016-08-23 8:44 [PATCH v3 0/4] clocksource: timer-atmel-pit: driver fix and cleanups Alexandre Belloni
@ 2016-08-23 8:44 ` Alexandre Belloni
2016-08-23 13:52 ` Daniel Lezcano
2016-08-23 8:44 ` [PATCH v3 2/4] clocksource: timer-atmel-pit: drop at91sam926x_pit_common_init Alexandre Belloni
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Alexandre Belloni @ 2016-08-23 8:44 UTC (permalink / raw)
To: Daniel Lezcano
Cc: Thomas Gleixner, Boris Brezillon, Nicolas Ferre,
linux-arm-kernel, linux-kernel, Alexandre Belloni
mck is needed to get the PIT working. Explicitly prepare_enable it instead
of assuming it is enabled.
This solves an issue where the system is freezing when the ETM/ETB drivers
are enabled.
Reported-by: Olivier Schonken <olivier.schonken@gmail.com>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/clocksource/timer-atmel-pit.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index 1ffac0cb0cb7..3494bc5a21d5 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -261,6 +261,12 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
return PTR_ERR(data->mck);
}
+ ret = clk_prepare_enable(data->mck);
+ if (ret) {
+ pr_err("Unable to enable mck\n");
+ return ret;
+ }
+
/* Get the interrupts property */
data->irq = irq_of_parse_and_map(node, 0);
if (!data->irq) {
--
2.8.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 2/4] clocksource: timer-atmel-pit: drop at91sam926x_pit_common_init
2016-08-23 8:44 [PATCH v3 0/4] clocksource: timer-atmel-pit: driver fix and cleanups Alexandre Belloni
2016-08-23 8:44 ` [PATCH v3 1/4] clocksource: timer-atmel-pit: enable mck Alexandre Belloni
@ 2016-08-23 8:44 ` Alexandre Belloni
2016-08-23 8:44 ` [PATCH v3 3/4] clocksource: timer-atmel-pit: remove uselesss WARN_ON_ONCE Alexandre Belloni
2016-08-23 8:44 ` [PATCH v3 4/4] clocksource: timer-atmel-pit: simplify IRQ handler Alexandre Belloni
3 siblings, 0 replies; 6+ messages in thread
From: Alexandre Belloni @ 2016-08-23 8:44 UTC (permalink / raw)
To: Daniel Lezcano
Cc: Thomas Gleixner, Boris Brezillon, Nicolas Ferre,
linux-arm-kernel, linux-kernel, Alexandre Belloni
Merge at91sam926x_pit_common_init in at91sam926x_pit_dt_init as this is the
only initialization method now.
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/clocksource/timer-atmel-pit.c | 82 ++++++++++++++++-------------------
1 file changed, 38 insertions(+), 44 deletions(-)
diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index 3494bc5a21d5..67240228fe8e 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -177,11 +177,45 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
/*
* Set up both clocksource and clockevent support.
*/
-static int __init at91sam926x_pit_common_init(struct pit_data *data)
+static int __init at91sam926x_pit_dt_init(struct device_node *node)
{
- unsigned long pit_rate;
- unsigned bits;
- int ret;
+ unsigned long pit_rate;
+ unsigned bits;
+ int ret;
+ struct pit_data *data;
+
+ data = kzalloc(sizeof(*data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
+
+ data->base = of_iomap(node, 0);
+ if (!data->base) {
+ pr_err("Could not map PIT address\n");
+ return -ENXIO;
+ }
+
+ data->mck = of_clk_get(node, 0);
+ if (IS_ERR(data->mck))
+ /* Fallback on clkdev for !CCF-based boards */
+ data->mck = clk_get(NULL, "mck");
+
+ if (IS_ERR(data->mck)) {
+ pr_err("Unable to get mck clk\n");
+ return PTR_ERR(data->mck);
+ }
+
+ ret = clk_prepare_enable(data->mck);
+ if (ret) {
+ pr_err("Unable to enable mck\n");
+ return ret;
+ }
+
+ /* Get the interrupts property */
+ data->irq = irq_of_parse_and_map(node, 0);
+ if (!data->irq) {
+ pr_err("Unable to get IRQ from DT\n");
+ return -EINVAL;
+ }
/*
* Use our actual MCK to figure out how many MCK/16 ticks per
@@ -236,45 +270,5 @@ static int __init at91sam926x_pit_common_init(struct pit_data *data)
return 0;
}
-
-static int __init at91sam926x_pit_dt_init(struct device_node *node)
-{
- struct pit_data *data;
-
- data = kzalloc(sizeof(*data), GFP_KERNEL);
- if (!data)
- return -ENOMEM;
-
- data->base = of_iomap(node, 0);
- if (!data->base) {
- pr_err("Could not map PIT address\n");
- return -ENXIO;
- }
-
- data->mck = of_clk_get(node, 0);
- if (IS_ERR(data->mck))
- /* Fallback on clkdev for !CCF-based boards */
- data->mck = clk_get(NULL, "mck");
-
- if (IS_ERR(data->mck)) {
- pr_err("Unable to get mck clk\n");
- return PTR_ERR(data->mck);
- }
-
- ret = clk_prepare_enable(data->mck);
- if (ret) {
- pr_err("Unable to enable mck\n");
- return ret;
- }
-
- /* Get the interrupts property */
- data->irq = irq_of_parse_and_map(node, 0);
- if (!data->irq) {
- pr_err("Unable to get IRQ from DT\n");
- return -EINVAL;
- }
-
- return at91sam926x_pit_common_init(data);
-}
CLOCKSOURCE_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit",
at91sam926x_pit_dt_init);
--
2.8.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 3/4] clocksource: timer-atmel-pit: remove uselesss WARN_ON_ONCE
2016-08-23 8:44 [PATCH v3 0/4] clocksource: timer-atmel-pit: driver fix and cleanups Alexandre Belloni
2016-08-23 8:44 ` [PATCH v3 1/4] clocksource: timer-atmel-pit: enable mck Alexandre Belloni
2016-08-23 8:44 ` [PATCH v3 2/4] clocksource: timer-atmel-pit: drop at91sam926x_pit_common_init Alexandre Belloni
@ 2016-08-23 8:44 ` Alexandre Belloni
2016-08-23 8:44 ` [PATCH v3 4/4] clocksource: timer-atmel-pit: simplify IRQ handler Alexandre Belloni
3 siblings, 0 replies; 6+ messages in thread
From: Alexandre Belloni @ 2016-08-23 8:44 UTC (permalink / raw)
To: Daniel Lezcano
Cc: Thomas Gleixner, Boris Brezillon, Nicolas Ferre,
linux-arm-kernel, linux-kernel, Alexandre Belloni
IRQ handlers are running with IRQ disabled for a while, remove wrong
comment and useless test.
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/clocksource/timer-atmel-pit.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index 67240228fe8e..633a94429842 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -149,12 +149,6 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
{
struct pit_data *data = dev_id;
- /*
- * irqs should be disabled here, but as the irq is shared they are only
- * guaranteed to be off if the timer irq is registered first.
- */
- WARN_ON_ONCE(!irqs_disabled());
-
/* The PIT interrupt may be disabled, and is shared */
if (clockevent_state_periodic(&data->clkevt) &&
(pit_read(data->base, AT91_PIT_SR) & AT91_PIT_PITS)) {
--
2.8.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 4/4] clocksource: timer-atmel-pit: simplify IRQ handler
2016-08-23 8:44 [PATCH v3 0/4] clocksource: timer-atmel-pit: driver fix and cleanups Alexandre Belloni
` (2 preceding siblings ...)
2016-08-23 8:44 ` [PATCH v3 3/4] clocksource: timer-atmel-pit: remove uselesss WARN_ON_ONCE Alexandre Belloni
@ 2016-08-23 8:44 ` Alexandre Belloni
3 siblings, 0 replies; 6+ messages in thread
From: Alexandre Belloni @ 2016-08-23 8:44 UTC (permalink / raw)
To: Daniel Lezcano
Cc: Thomas Gleixner, Boris Brezillon, Nicolas Ferre,
linux-arm-kernel, linux-kernel, Alexandre Belloni
Because the PIT is also a proper clocksource, the timekeeping code is
already able to handle lost ticks.
Reported-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/clocksource/timer-atmel-pit.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index 633a94429842..2e215e8e6c1d 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -152,15 +152,10 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
/* The PIT interrupt may be disabled, and is shared */
if (clockevent_state_periodic(&data->clkevt) &&
(pit_read(data->base, AT91_PIT_SR) & AT91_PIT_PITS)) {
- unsigned nr_ticks;
-
/* Get number of ticks performed before irq, and ack it */
- nr_ticks = PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR));
- do {
- data->cnt += data->cycle;
- data->clkevt.event_handler(&data->clkevt);
- nr_ticks--;
- } while (nr_ticks);
+ data->cnt += data->cycle * PIT_PICNT(pit_read(data->base,
+ AT91_PIT_PIVR));
+ data->clkevt.event_handler(&data->clkevt);
return IRQ_HANDLED;
}
--
2.8.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/4] clocksource: timer-atmel-pit: enable mck
2016-08-23 8:44 ` [PATCH v3 1/4] clocksource: timer-atmel-pit: enable mck Alexandre Belloni
@ 2016-08-23 13:52 ` Daniel Lezcano
0 siblings, 0 replies; 6+ messages in thread
From: Daniel Lezcano @ 2016-08-23 13:52 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Thomas Gleixner, Boris Brezillon, Nicolas Ferre,
linux-arm-kernel, linux-kernel
On 08/23/2016 10:44 AM, Alexandre Belloni wrote:
> mck is needed to get the PIT working. Explicitly prepare_enable it instead
> of assuming it is enabled.
>
> This solves an issue where the system is freezing when the ETM/ETB drivers
> are enabled.
>
> Reported-by: Olivier Schonken <olivier.schonken@gmail.com>
> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
Applied this one for tip/timers/urgent
Thanks !
-- Daniel
--
<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] 6+ messages in thread
end of thread, other threads:[~2016-08-23 13:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-23 8:44 [PATCH v3 0/4] clocksource: timer-atmel-pit: driver fix and cleanups Alexandre Belloni
2016-08-23 8:44 ` [PATCH v3 1/4] clocksource: timer-atmel-pit: enable mck Alexandre Belloni
2016-08-23 13:52 ` Daniel Lezcano
2016-08-23 8:44 ` [PATCH v3 2/4] clocksource: timer-atmel-pit: drop at91sam926x_pit_common_init Alexandre Belloni
2016-08-23 8:44 ` [PATCH v3 3/4] clocksource: timer-atmel-pit: remove uselesss WARN_ON_ONCE Alexandre Belloni
2016-08-23 8:44 ` [PATCH v3 4/4] clocksource: timer-atmel-pit: simplify IRQ handler Alexandre Belloni
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).