* [PATCH 00/48] ARM: at91: rework Atmel TCB drivers
@ 2016-06-10 22:03 Alexandre Belloni
2016-06-10 22:03 ` [PATCH 01/48] clk: at91: replace usleep() by udelay() calls Alexandre Belloni
0 siblings, 1 reply; 9+ messages in thread
From: Alexandre Belloni @ 2016-06-10 22:03 UTC (permalink / raw)
To: Nicolas Ferre
Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
linux-arm-kernel, linux-kernel, Alexandre Belloni, Antoine Aubert,
Daniel Lezcano, devicetree, Douglas Gilbert, Fabio Porcedda,
Gregory CLEMENT, Gregory Hermant, Joachim Eastwood, linux-clk,
linux-pwm, Marek Vasut, Martin Reimann, Rob Herring,
Rodolfo Giometti, Sergio Tanzilli, Stephen Boyd, Thierry Reding,
Thomas Gleixner, Tim Schendekehl
Hi,
This series reworks the Atmel Timer counter Block drivers. Those blocks
each have 3 counters with 2 channels each and can be used for
multiple functions:
- timers
- PWMs
- Quadrature decoders
- Stepper motor counters
Up until now, each TCB was fully used by each driver, possibly wasting
counters/channels.
There is a second issue motivating that rework. Until now, the PIT is
still used to boot then later in the boot sequence, the clocksource is
switched to the TCB. This ends up not working well with preempt-rt
because on some SoCs, the PIT interrupt is shared with the DBGU uart.
When using preempt-rt the interrupt flags for the PIT and the DBGU end
up being incompatible.
The whole rework doesn't break the DT ABI for the clocksource as the old
driver is kept anyway for AVR32. However, I still took the time to
switch all the upstreamed board dts to the new bindings.
However, there is no other choice than breaking the mainly unused
pwm-atmel-tcb binding. Only the kizbox is actually using it.
I hope we could quickly come to an agreement on the new DT bindings and
include those changes in 4.8.
Regarding the tcbclksrc driver, I'm not completely happy with the
request_irq/free_irq thing but there is not much choice unless we want
to pass in the clksrc handler even when using the clkevt driver as they
may share the same interrupt.
Cc: Antoine Aubert <a.aubert@overkiz.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: devicetree@vger.kernel.org
Cc: Douglas Gilbert <dgilbert@interlog.com>
Cc: Fabio Porcedda <fabio.porcedda@gmail.com>
Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>
Cc: Gregory Hermant <gregory.hermant@calao-systems.com>
Cc: Joachim Eastwood <manabian@gmail.com>
Cc: linux-clk@vger.kernel.org
Cc: linux-pwm@vger.kernel.org
Cc: Marek Vasut <marex@denx.de>
Cc: Martin Reimann <martin.reimann@egnite.de>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Rodolfo Giometti <giometti@linux.it>
Cc: Sergio Tanzilli <tanzilli@acmesystems.it>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tim Schendekehl <tim.schendekehl@egnite.de>
Alexandre Belloni (47):
ARM: at91: Document new TCB bindings
ARM: dts: at91: at91rm9200: TC blocks are also simple-mfd and syscon
devices
ARM: dts: at91: at91rm9200ek; use TCB0 as clocksource
ARM: dts: at91: mpa1600; use TCB0 as clocksource
ARM: dts: at91: at91sam9260: TC blocks are also simple-mfd and syscon
devices
ARM: dts: at91: ethernut5: use TCB0 as clocksource
ARM: dts: at91: foxg20: use TCB0 as clocksource
ARM: dts: at91: animeo_ip: use TCB0 as clocksource
ARM: dts: at91: kizbox: use TCB0 as clocksource
ARM: dts: at91: at91sam9g20ek: use TCB0 as clocksource
ARM: dts: at91: ge863-pro3: use TCB0 as clocksource
ARM: dts: at91: at91sam9261: TC blocks are also simple-mfd and syscon
devices
ARM: dts: at91: at91sam9261ek: use TCB0 as clocksource
ARM: dts: at91: at91sam9263: TC blocks are also simple-mfd and syscon
devices
ARM: dts: at91: at91sam9263ek: use TCB0 as clocksource
ARM: dts: at91: calao: use TCB0 as clocksource
ARM: dts: at91: at91sam9g45: TC blocks are also simple-mfd and syscon
devices
ARM: dts: at91: at91sam9m10g45ek: use TCB0 as clocksource
ARM: dts: at91: pm9g45: use TCB0 as clocksource
ARM: dts: at91: at91sam9rl: TC blocks are also simple-mfd and syscon
devices
ARM: dts: at91: at91sam9rlek: use TCB0 as clocksource
ARM: dts: at91: at91sam9n12: TC blocks are also simple-mfd and syscon
devices
ARM: dts: at91: at91sam9n12ek: use TCB0 as clocksource
ARM: dts: at91: at91sam9x5: TC blocks are also simple-mfd and syscon
devices
ARM: dts: at91: at91sam9x5cm: use TCB0 as clocksource
ARM: dts: at91: acme/g25: use TCB0 as clocksource
ARM: dts: at91: cosino: use TCB0 as clocksource
ARM: dts: at91: kizboxmini: use TCB0 as clocksource
ARM: dts: at91: sama5d3: TC blocks are also simple-mfd and syscon
devices
ARM: dts: at91: sama5d3xek; use TCB0 as clocksource
ARM: dts: at91: sama5d3 Xplained: use TCB0 as clocksource
ARM: dts: at91: kizbox2: use TCB0 as clocksource
ARM: dts: at91: sama5d4: TC blocks are also simple-mfd and syscon
devices
ARM: dts: at91: sama5d4: Add TCB2
ARM: dts: at91: sama5d4ek: use TCB2 as clocksource
ARM: dts: at91: sama5d4 Xplained: use TCB2 as clocksource
ARM: dts: at91: ma5d4: use TCB2 as clocksource
ARM: dts: at91: vinco: use TCB2 as clocksource
ARM: dts: at91: sama5d2: TC blocks are also simple-mfd and syscon
devices
ARM: dts: at91: sama5d2 Xplained: use TCB0 as clocksource
clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
clocksource/drivers: Add a clockevent driver for Atmel TC blocks
clocksource: atmel-pit: allow unselecting ATMEL_PIT
ARM: at91/defconfig: sama5: unselect ATMEL_PIT
ARM: at91/defconfig: at91_dt unselect ATMEL_PIT
PWM: atmel-tcb: switch to new binding
ARM: dts: at91: kizbox: switch to new pwm-atmel-tcb binding
Cyrille Pitchen (1):
clk: at91: replace usleep() by udelay() calls
.../devicetree/bindings/arm/atmel-at91.txt | 32 ---
.../devicetree/bindings/mfd/atmel-tcb.txt | 62 +++++
.../devicetree/bindings/pwm/atmel-tcb-pwm.txt | 12 +-
arch/arm/boot/dts/animeo_ip.dts | 12 +
arch/arm/boot/dts/at91-ariag25.dts | 12 +
arch/arm/boot/dts/at91-ariettag25.dts | 12 +
arch/arm/boot/dts/at91-cosino.dtsi | 12 +
arch/arm/boot/dts/at91-foxg20.dts | 12 +
arch/arm/boot/dts/at91-kizbox.dts | 54 +++-
arch/arm/boot/dts/at91-kizbox2.dts | 12 +
arch/arm/boot/dts/at91-kizboxmini.dts | 12 +
arch/arm/boot/dts/at91-qil_a9260.dts | 12 +
arch/arm/boot/dts/at91-sama5d2_xplained.dts | 12 +
arch/arm/boot/dts/at91-sama5d3_xplained.dts | 12 +
arch/arm/boot/dts/at91-sama5d4_ma5d4.dtsi | 12 +
arch/arm/boot/dts/at91-sama5d4_xplained.dts | 12 +
arch/arm/boot/dts/at91-sama5d4ek.dts | 12 +
arch/arm/boot/dts/at91-vinco.dts | 12 +
arch/arm/boot/dts/at91rm9200.dtsi | 8 +-
arch/arm/boot/dts/at91rm9200ek.dts | 12 +
arch/arm/boot/dts/at91sam9260.dtsi | 8 +-
arch/arm/boot/dts/at91sam9261.dtsi | 4 +-
arch/arm/boot/dts/at91sam9261ek.dts | 12 +
arch/arm/boot/dts/at91sam9263.dtsi | 4 +-
arch/arm/boot/dts/at91sam9263ek.dts | 12 +
arch/arm/boot/dts/at91sam9g20ek_common.dtsi | 12 +
arch/arm/boot/dts/at91sam9g45.dtsi | 8 +-
arch/arm/boot/dts/at91sam9m10g45ek.dts | 12 +
arch/arm/boot/dts/at91sam9n12.dtsi | 8 +-
arch/arm/boot/dts/at91sam9n12ek.dts | 12 +
arch/arm/boot/dts/at91sam9rl.dtsi | 4 +-
arch/arm/boot/dts/at91sam9rlek.dts | 12 +
arch/arm/boot/dts/at91sam9x5.dtsi | 8 +-
arch/arm/boot/dts/at91sam9x5cm.dtsi | 12 +
arch/arm/boot/dts/ethernut5.dts | 12 +
arch/arm/boot/dts/ge863-pro3.dtsi | 12 +
arch/arm/boot/dts/mpa1600.dts | 12 +
arch/arm/boot/dts/pm9g45.dts | 12 +
arch/arm/boot/dts/sama5d2.dtsi | 8 +-
arch/arm/boot/dts/sama5d3.dtsi | 4 +-
arch/arm/boot/dts/sama5d3_tcb1.dtsi | 4 +-
arch/arm/boot/dts/sama5d3xcm.dtsi | 12 +
arch/arm/boot/dts/sama5d4.dtsi | 18 +-
arch/arm/boot/dts/tny_a9260_common.dtsi | 12 +
arch/arm/boot/dts/tny_a9263.dts | 12 +
arch/arm/boot/dts/usb_a9260_common.dtsi | 12 +
arch/arm/boot/dts/usb_a9263.dts | 12 +
arch/arm/configs/at91_dt_defconfig | 1 +
arch/arm/configs/sama5_defconfig | 1 +
drivers/clk/at91/clk-main.c | 2 +-
drivers/clk/at91/clk-slow.c | 6 +-
drivers/clocksource/Kconfig | 32 ++-
drivers/clocksource/Makefile | 4 +-
drivers/clocksource/timer-atmel-tcbclkevt.c | 220 +++++++++++++++
drivers/clocksource/timer-atmel-tcbclksrc.c | 305 +++++++++++++++++++++
drivers/pwm/Kconfig | 3 +-
drivers/pwm/pwm-atmel-tcb.c | 219 ++++++++-------
include/soc/at91/atmel_tcb.h | 220 +++++++++++++++
58 files changed, 1452 insertions(+), 179 deletions(-)
create mode 100644 Documentation/devicetree/bindings/mfd/atmel-tcb.txt
create mode 100644 drivers/clocksource/timer-atmel-tcbclkevt.c
create mode 100644 drivers/clocksource/timer-atmel-tcbclksrc.c
create mode 100644 include/soc/at91/atmel_tcb.h
--
2.8.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 01/48] clk: at91: replace usleep() by udelay() calls
2016-06-10 22:03 [PATCH 00/48] ARM: at91: rework Atmel TCB drivers Alexandre Belloni
@ 2016-06-10 22:03 ` Alexandre Belloni
2016-06-10 22:30 ` Arnd Bergmann
2016-06-11 7:49 ` Boris Brezillon
0 siblings, 2 replies; 9+ messages in thread
From: Alexandre Belloni @ 2016-06-10 22:03 UTC (permalink / raw)
To: Nicolas Ferre
Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
linux-arm-kernel, linux-kernel, Cyrille Pitchen, Stephen Boyd,
linux-clk, Alexandre Belloni
From: Cyrille Pitchen <cyrille.pitchen@atmel.com>
Fix the main and slow clock .prepare() implementations which used to call
usleep() when the scheduler wasn't ready yet.
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: linux-clk@vger.kernel.org
Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/clk/at91/clk-main.c | 2 +-
drivers/clk/at91/clk-slow.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c
index 58b5baca670c..12c5062aeb92 100644
--- a/drivers/clk/at91/clk-main.c
+++ b/drivers/clk/at91/clk-main.c
@@ -342,7 +342,7 @@ static int clk_main_probe_frequency(struct regmap *regmap)
regmap_read(regmap, AT91_CKGR_MCFR, &mcfr);
if (mcfr & AT91_PMC_MAINRDY)
return 0;
- usleep_range(MAINF_LOOP_MIN_WAIT, MAINF_LOOP_MAX_WAIT);
+ udelay(MAINF_LOOP_MIN_WAIT);
} while (time_before(prep_time, timeout));
return -ETIMEDOUT;
diff --git a/drivers/clk/at91/clk-slow.c b/drivers/clk/at91/clk-slow.c
index 61090b1146cf..612e893ce994 100644
--- a/drivers/clk/at91/clk-slow.c
+++ b/drivers/clk/at91/clk-slow.c
@@ -76,7 +76,7 @@ static int clk_slow_osc_prepare(struct clk_hw *hw)
writel(tmp | AT91_SCKC_OSC32EN, sckcr);
- usleep_range(osc->startup_usec, osc->startup_usec + 1);
+ udelay(osc->startup_usec);
return 0;
}
@@ -195,7 +195,7 @@ static int clk_slow_rc_osc_prepare(struct clk_hw *hw)
writel(readl(sckcr) | AT91_SCKC_RCEN, sckcr);
- usleep_range(osc->startup_usec, osc->startup_usec + 1);
+ udelay(osc->startup_usec);
return 0;
}
@@ -304,7 +304,7 @@ static int clk_sam9x5_slow_set_parent(struct clk_hw *hw, u8 index)
writel(tmp, sckcr);
- usleep_range(SLOWCK_SW_TIME_USEC, SLOWCK_SW_TIME_USEC + 1);
+ udelay(SLOWCK_SW_TIME_USEC);
return 0;
}
--
2.8.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 01/48] clk: at91: replace usleep() by udelay() calls
2016-06-10 22:03 ` [PATCH 01/48] clk: at91: replace usleep() by udelay() calls Alexandre Belloni
@ 2016-06-10 22:30 ` Arnd Bergmann
2016-06-10 22:37 ` Alexandre Belloni
2016-06-13 15:24 ` Alexandre Belloni
2016-06-11 7:49 ` Boris Brezillon
1 sibling, 2 replies; 9+ messages in thread
From: Arnd Bergmann @ 2016-06-10 22:30 UTC (permalink / raw)
To: linux-arm-kernel
Cc: Alexandre Belloni, Nicolas Ferre, Boris Brezillon, Stephen Boyd,
linux-kernel, Cyrille Pitchen, Jean-Christophe Plagniol-Villard,
linux-clk
On Saturday, June 11, 2016 12:03:04 AM CEST Alexandre Belloni wrote:
> From: Cyrille Pitchen <cyrille.pitchen@atmel.com>
>
> Fix the main and slow clock .prepare() implementations which used to call
> usleep() when the scheduler wasn't ready yet.
>
Does this have to be called that early? It seems wasteful to always
call udelay() here, when these are functions that are normally
allowed to sleep.
Arnd
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 01/48] clk: at91: replace usleep() by udelay() calls
2016-06-10 22:30 ` Arnd Bergmann
@ 2016-06-10 22:37 ` Alexandre Belloni
2016-06-13 15:24 ` Alexandre Belloni
1 sibling, 0 replies; 9+ messages in thread
From: Alexandre Belloni @ 2016-06-10 22:37 UTC (permalink / raw)
To: Arnd Bergmann
Cc: linux-arm-kernel, Nicolas Ferre, Boris Brezillon, Stephen Boyd,
linux-kernel, Cyrille Pitchen, Jean-Christophe Plagniol-Villard,
linux-clk
On 11/06/2016 at 00:30:36 +0200, Arnd Bergmann wrote :
> On Saturday, June 11, 2016 12:03:04 AM CEST Alexandre Belloni wrote:
> > From: Cyrille Pitchen <cyrille.pitchen@atmel.com>
> >
> > Fix the main and slow clock .prepare() implementations which used to call
> > usleep() when the scheduler wasn't ready yet.
> >
>
> Does this have to be called that early? It seems wasteful to always
> call udelay() here, when these are functions that are normally
> allowed to sleep.
>
Well, the main issue here is that we want to be able to prepare_enable
the slow clock before we are allowed to sleep.
Thinking about it when writing that, I realize that when I reworked my
series, I removed the dependency between the clocksource TCB and the
slow_clock. But I guess we still have one on the main clock. I'll check
whether this is still necessary.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 01/48] clk: at91: replace usleep() by udelay() calls
2016-06-10 22:03 ` [PATCH 01/48] clk: at91: replace usleep() by udelay() calls Alexandre Belloni
2016-06-10 22:30 ` Arnd Bergmann
@ 2016-06-11 7:49 ` Boris Brezillon
1 sibling, 0 replies; 9+ messages in thread
From: Boris Brezillon @ 2016-06-11 7:49 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Nicolas Ferre, Jean-Christophe Plagniol-Villard, linux-arm-kernel,
linux-kernel, Cyrille Pitchen, Stephen Boyd, linux-clk
On Sat, 11 Jun 2016 00:03:04 +0200
Alexandre Belloni <alexandre.belloni@free-electrons.com> wrote:
> From: Cyrille Pitchen <cyrille.pitchen@atmel.com>
>
> Fix the main and slow clock .prepare() implementations which used to call
> usleep() when the scheduler wasn't ready yet.
>
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Cc: linux-clk@vger.kernel.org
> Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> drivers/clk/at91/clk-main.c | 2 +-
> drivers/clk/at91/clk-slow.c | 6 +++---
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c
> index 58b5baca670c..12c5062aeb92 100644
> --- a/drivers/clk/at91/clk-main.c
> +++ b/drivers/clk/at91/clk-main.c
> @@ -342,7 +342,7 @@ static int clk_main_probe_frequency(struct regmap *regmap)
> regmap_read(regmap, AT91_CKGR_MCFR, &mcfr);
> if (mcfr & AT91_PMC_MAINRDY)
> return 0;
> - usleep_range(MAINF_LOOP_MIN_WAIT, MAINF_LOOP_MAX_WAIT);
> + udelay(MAINF_LOOP_MIN_WAIT);
> } while (time_before(prep_time, timeout));
>
> return -ETIMEDOUT;
> diff --git a/drivers/clk/at91/clk-slow.c b/drivers/clk/at91/clk-slow.c
> index 61090b1146cf..612e893ce994 100644
> --- a/drivers/clk/at91/clk-slow.c
> +++ b/drivers/clk/at91/clk-slow.c
> @@ -76,7 +76,7 @@ static int clk_slow_osc_prepare(struct clk_hw *hw)
>
> writel(tmp | AT91_SCKC_OSC32EN, sckcr);
>
> - usleep_range(osc->startup_usec, osc->startup_usec + 1);
> + udelay(osc->startup_usec);
If you're using udelay() you should probably move the code in
->prepare() into ->enable(). The same goes for the following changes.
>
> return 0;
> }
> @@ -195,7 +195,7 @@ static int clk_slow_rc_osc_prepare(struct clk_hw *hw)
>
> writel(readl(sckcr) | AT91_SCKC_RCEN, sckcr);
>
> - usleep_range(osc->startup_usec, osc->startup_usec + 1);
> + udelay(osc->startup_usec);
>
> return 0;
> }
> @@ -304,7 +304,7 @@ static int clk_sam9x5_slow_set_parent(struct clk_hw *hw, u8 index)
>
> writel(tmp, sckcr);
>
> - usleep_range(SLOWCK_SW_TIME_USEC, SLOWCK_SW_TIME_USEC + 1);
> + udelay(SLOWCK_SW_TIME_USEC);
>
> return 0;
> }
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 01/48] clk: at91: replace usleep() by udelay() calls
2016-06-10 22:30 ` Arnd Bergmann
2016-06-10 22:37 ` Alexandre Belloni
@ 2016-06-13 15:24 ` Alexandre Belloni
2016-06-13 19:26 ` Arnd Bergmann
2016-06-14 16:05 ` Afzal Mohammed
1 sibling, 2 replies; 9+ messages in thread
From: Alexandre Belloni @ 2016-06-13 15:24 UTC (permalink / raw)
To: Arnd Bergmann
Cc: linux-arm-kernel, Nicolas Ferre, Boris Brezillon, Stephen Boyd,
linux-kernel, Cyrille Pitchen, Jean-Christophe Plagniol-Villard,
linux-clk
On 11/06/2016 at 00:30:36 +0200, Arnd Bergmann wrote :
> On Saturday, June 11, 2016 12:03:04 AM CEST Alexandre Belloni wrote:
> > From: Cyrille Pitchen <cyrille.pitchen@atmel.com>
> >
> > Fix the main and slow clock .prepare() implementations which used to call
> > usleep() when the scheduler wasn't ready yet.
> >
>
> Does this have to be called that early? It seems wasteful to always
> call udelay() here, when these are functions that are normally
> allowed to sleep.
>
So I've tested it and something like that would work:
if (system_state < SYSTEM_RUNNING)
udelay(osc->startup_usec);
else
usleep_range(osc->startup_usec, osc->startup_usec + 1);
But I'm afraid it would be the first driver to actually do something
like that (however, it is already the only driver trying to sleep).
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 01/48] clk: at91: replace usleep() by udelay() calls
2016-06-13 15:24 ` Alexandre Belloni
@ 2016-06-13 19:26 ` Arnd Bergmann
2016-06-14 16:05 ` Afzal Mohammed
1 sibling, 0 replies; 9+ messages in thread
From: Arnd Bergmann @ 2016-06-13 19:26 UTC (permalink / raw)
To: Alexandre Belloni
Cc: linux-arm-kernel, Nicolas Ferre, Boris Brezillon, Stephen Boyd,
linux-kernel, Cyrille Pitchen, Jean-Christophe Plagniol-Villard,
linux-clk
On Monday, June 13, 2016 5:24:09 PM CEST Alexandre Belloni wrote:
> On 11/06/2016 at 00:30:36 +0200, Arnd Bergmann wrote :
> > On Saturday, June 11, 2016 12:03:04 AM CEST Alexandre Belloni wrote:
> > > From: Cyrille Pitchen <cyrille.pitchen@atmel.com>
> > >
> > > Fix the main and slow clock .prepare() implementations which used to call
> > > usleep() when the scheduler wasn't ready yet.
> > >
> >
> > Does this have to be called that early? It seems wasteful to always
> > call udelay() here, when these are functions that are normally
> > allowed to sleep.
> >
>
> So I've tested it and something like that would work:
>
> if (system_state < SYSTEM_RUNNING)
> udelay(osc->startup_usec);
> else
> usleep_range(osc->startup_usec, osc->startup_usec + 1);
I think that's reasonable in this case.
> But I'm afraid it would be the first driver to actually do something
> like that (however, it is already the only driver trying to sleep).
We have a lot of drivers that call potentially sleeping function from
the .prepare callback, e.g. when they go to an i2c controller.
Arnd
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 01/48] clk: at91: replace usleep() by udelay() calls
2016-06-13 15:24 ` Alexandre Belloni
2016-06-13 19:26 ` Arnd Bergmann
@ 2016-06-14 16:05 ` Afzal Mohammed
2016-06-14 16:18 ` Boris Brezillon
1 sibling, 1 reply; 9+ messages in thread
From: Afzal Mohammed @ 2016-06-14 16:05 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Arnd Bergmann, Boris Brezillon, Stephen Boyd, Nicolas Ferre,
linux-kernel, Cyrille Pitchen, Jean-Christophe Plagniol-Villard,
linux-clk, linux-arm-kernel
Hi,
On Mon, Jun 13, 2016 at 05:24:09PM +0200, Alexandre Belloni wrote:
> On 11/06/2016 at 00:30:36 +0200, Arnd Bergmann wrote :
> > Does this have to be called that early? It seems wasteful to always
> > call udelay() here, when these are functions that are normally
> > allowed to sleep.
> So I've tested it and something like that would work:
>
> if (system_state < SYSTEM_RUNNING)
> udelay(osc->startup_usec);
> else
> usleep_range(osc->startup_usec, osc->startup_usec + 1);
>
> But I'm afraid it would be the first driver to actually do something
> like that (however, it is already the only driver trying to sleep).
tglx has suggested to modify clock core to handle a somewhat similar
kind of scenario (probably should work here too) and avoid driver
changes,
http://lkml.kernel.org/r/alpine.DEB.2.11.1606061448010.28031@nanos
Regards
afzal
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 01/48] clk: at91: replace usleep() by udelay() calls
2016-06-14 16:05 ` Afzal Mohammed
@ 2016-06-14 16:18 ` Boris Brezillon
0 siblings, 0 replies; 9+ messages in thread
From: Boris Brezillon @ 2016-06-14 16:18 UTC (permalink / raw)
To: Afzal Mohammed
Cc: Alexandre Belloni, Arnd Bergmann, Stephen Boyd, Nicolas Ferre,
linux-kernel, Cyrille Pitchen, Jean-Christophe Plagniol-Villard,
linux-clk, linux-arm-kernel
On Tue, 14 Jun 2016 21:35:17 +0530
Afzal Mohammed <afzal.mohd.ma@gmail.com> wrote:
> Hi,
>
> On Mon, Jun 13, 2016 at 05:24:09PM +0200, Alexandre Belloni wrote:
> > On 11/06/2016 at 00:30:36 +0200, Arnd Bergmann wrote :
>
> > > Does this have to be called that early? It seems wasteful to always
> > > call udelay() here, when these are functions that are normally
> > > allowed to sleep.
>
> > So I've tested it and something like that would work:
> >
> > if (system_state < SYSTEM_RUNNING)
> > udelay(osc->startup_usec);
> > else
> > usleep_range(osc->startup_usec, osc->startup_usec + 1);
> >
> > But I'm afraid it would be the first driver to actually do something
> > like that (however, it is already the only driver trying to sleep).
>
> tglx has suggested to modify clock core to handle a somewhat similar
> kind of scenario (probably should work here too) and avoid driver
> changes,
>
> http://lkml.kernel.org/r/alpine.DEB.2.11.1606061448010.28031@nanos
Oh, interesting. Definitely a better solution than this custom check.
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-06-14 16:18 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-10 22:03 [PATCH 00/48] ARM: at91: rework Atmel TCB drivers Alexandre Belloni
2016-06-10 22:03 ` [PATCH 01/48] clk: at91: replace usleep() by udelay() calls Alexandre Belloni
2016-06-10 22:30 ` Arnd Bergmann
2016-06-10 22:37 ` Alexandre Belloni
2016-06-13 15:24 ` Alexandre Belloni
2016-06-13 19:26 ` Arnd Bergmann
2016-06-14 16:05 ` Afzal Mohammed
2016-06-14 16:18 ` Boris Brezillon
2016-06-11 7:49 ` Boris Brezillon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox