linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Samsung/S3C6410/Mini6410: how to handle NAND's "clock off"
@ 2014-11-11 18:10 Juergen Borleis
  2014-11-11 18:42 ` Uwe Kleine-König
  0 siblings, 1 reply; 4+ messages in thread
From: Juergen Borleis @ 2014-11-11 18:10 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

the S3C2410 NAND driver [1] can still be used for NANDs attached to an S3C6410
SoC. But this driver has a "nice" feature called "clock off" to save some
power while not in use. I tried it here on my Mini6410 platform and it freezes
the system.

The clock tree is somehow:

[...]
  hclk                      4            4   133000000          0 0
     hclk_mfc               0            0   133000000          0 0
     hclk_mem0              2            2   133000000          0 0
        mem0_srom           0            0   133000000          0 0
        mem0_nfcon          1            1   133000000          0 0
        mem0_onenand0       0            0   133000000          0 0
        mem0_onenand1       0            0   133000000          0 0
        mem0_cfcon          0            0   133000000          0 0
[...]

On the Mini6410 the "mem0_nfcon" clock is the only single user of the
"hclk_mem0". And this clock is required to keep the access to the external
network device enabled. When the NAND driver disables its clock "mem0_nfcon",
the "hclk_mem0" gets also disabled because there is no consumer anymore. The
next time the network driver tries to access its device, the SoC freezes.

How to prevent this? Can we keep the "hclk_mem0" enabled without an active
consumer? Or do we need a dummy consumer? Or do we need to request for
"hclk_mem0" when at least one external device is attached? Or should we remove
the "clock stop" feature for at least the S3C6410 SoC?

With the patch below I was able to reproduce the behavior:

Author: Juergen Borleis <juergen@kreuzholzen.de>
Date:   Mon Nov 10 23:35:06 2014 +0100

    ARM/S3C6410/NAND: add clock alias to keep an old driver alive
    
    This change enables the existing S3c2410.c driver for the S3C6410.
    
    But keep in mind to disable the CONFIG_MTD_NAND_S3C2410_CLKSTOP when using
    this driver!
    
    Why? The access to external devices depends on a running "hclk_mem0" clock.
    As the NAND controller was the only single user of it, it disables it, when
    it disables its owm clock to save power. This locks the system. m(
    
    Signed-off-by: Juergen Borleis <juergen@kreuzholzen.de>

diff --git a/drivers/clk/samsung/clk-s3c64xx.c b/drivers/clk/samsung/clk-s3c64xx.c
index 0f590e5..f7d2d57 100644
--- a/drivers/clk/samsung/clk-s3c64xx.c
+++ b/drivers/clk/samsung/clk-s3c64xx.c
@@ -404,6 +404,7 @@ static struct samsung_clock_alias s3c64xx_clock_aliases[] = {
 	ALIAS(PCLK_IIS0, "samsung-i2s.0", "iis"),
 	ALIAS(PCLK_AC97, "samsung-ac97", "ac97"),
 	ALIAS(PCLK_TSADC, "s3c64xx-adc", "adc"),
+	ALIAS(MEM0_NFCON, NULL, "nand"),
 	ALIAS(PCLK_KEYPAD, "samsung-keypad", "keypad"),
 	ALIAS(PCLK_PCM1, "samsung-pcm.1", "pcm"),
 	ALIAS(PCLK_PCM0, "samsung-pcm.0", "pcm"),

jbe

[1] drivers/mtd/nand/s3c2410.c

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

* Samsung/S3C6410/Mini6410: how to handle NAND's "clock off"
  2014-11-11 18:10 Samsung/S3C6410/Mini6410: how to handle NAND's "clock off" Juergen Borleis
@ 2014-11-11 18:42 ` Uwe Kleine-König
  2014-11-12  9:14   ` Uwe Kleine-König
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2014-11-11 18:42 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Nov 11, 2014 at 07:10:33PM +0100, Juergen Borleis wrote:
> Hi,
> 
> the S3C2410 NAND driver [1] can still be used for NANDs attached to an S3C6410
> SoC. But this driver has a "nice" feature called "clock off" to save some
> power while not in use. I tried it here on my Mini6410 platform and it freezes
> the system.
> 
> The clock tree is somehow:
> 
> [...]
>   hclk                      4            4   133000000          0 0
>      hclk_mfc               0            0   133000000          0 0
>      hclk_mem0              2            2   133000000          0 0
>         mem0_srom           0            0   133000000          0 0
>         mem0_nfcon          1            1   133000000          0 0
>         mem0_onenand0       0            0   133000000          0 0
>         mem0_onenand1       0            0   133000000          0 0
>         mem0_cfcon          0            0   133000000          0 0
> [...]
> 
> On the Mini6410 the "mem0_nfcon" clock is the only single user of the
> "hclk_mem0". And this clock is required to keep the access to the external
> network device enabled. When the NAND driver disables its clock "mem0_nfcon",
> the "hclk_mem0" gets also disabled because there is no consumer anymore. The
> next time the network driver tries to access its device, the SoC freezes.
Sounds like the network driver should hold a reference to hclk_mem0. I
assume the system uses a device tree? This is the dm9000 driver? It
doesn't seem to use clk stuff, but it should be possible to add an
optional clk entry.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Samsung/S3C6410/Mini6410: how to handle NAND's "clock off"
  2014-11-11 18:42 ` Uwe Kleine-König
@ 2014-11-12  9:14   ` Uwe Kleine-König
  2014-11-12 12:00     ` Juergen Borleis
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2014-11-12  9:14 UTC (permalink / raw)
  To: linux-arm-kernel

Hello again,

[extending audience a bit]

On Tue, Nov 11, 2014 at 07:42:26PM +0100, Uwe Kleine-K?nig wrote:
> On Tue, Nov 11, 2014 at 07:10:33PM +0100, Juergen Borleis wrote:
> > Hi,
> > 
> > the S3C2410 NAND driver [1] can still be used for NANDs attached to an S3C6410
> > SoC. But this driver has a "nice" feature called "clock off" to save some
> > power while not in use. I tried it here on my Mini6410 platform and it freezes
> > the system.
> > 
> > The clock tree is somehow:
> > 
> > [...]
> >   hclk                      4            4   133000000          0 0
> >      hclk_mfc               0            0   133000000          0 0
> >      hclk_mem0              2            2   133000000          0 0
> >         mem0_srom           0            0   133000000          0 0
> >         mem0_nfcon          1            1   133000000          0 0
> >         mem0_onenand0       0            0   133000000          0 0
> >         mem0_onenand1       0            0   133000000          0 0
> >         mem0_cfcon          0            0   133000000          0 0
> > [...]
> > 
> > On the Mini6410 the "mem0_nfcon" clock is the only single user of the
> > "hclk_mem0". And this clock is required to keep the access to the external
> > network device enabled. When the NAND driver disables its clock "mem0_nfcon",
> > the "hclk_mem0" gets also disabled because there is no consumer anymore. The
> > next time the network driver tries to access its device, the SoC freezes.
> Sounds like the network driver should hold a reference to hclk_mem0.
After talking to J?rgen by phone, the solution that the dm9000 driver
should handle the clock sounds wrong. The clk in question is needed by
the SoC to operate the bus the dm9000 is connected to. So I think the
right approach would include

diff --git a/arch/arm/boot/dts/s3c6410-mini6410.dts b/arch/arm/boot/dts/s3c6410-mini6410.dts
index 57e00f9bce99..b5067e631216 100644
--- a/arch/arm/boot/dts/s3c6410-mini6410.dts
+++ b/arch/arm/boot/dts/s3c6410-mini6410.dts
@@ -55,9 +55,11 @@
 	srom-cs1 at 18000000 {
 		compatible = "simple-bus";
 		#address-cells = <1>;
 		#size-cells = <1>;
+		clock-names = "hclk-whatever";
+		clocks = <&no_idea_which_device MEM0_SROM>;
 		reg = <0x18000000 0x8000000>;
 		ranges;
 
 		ethernet at 18000000 {
 			compatible = "davicom,dm9000";

I don't think the simple bus has clock handling, and I'm not sure if
simple bus is intended to be too simple to handle that. Anyhow, it would
describe the hardware.
The next thing that will pop up once simple-bus (or a dedicated
whatever-bus) has clk-handling is power management. Does the bus notice
when all it's devices are suspended such that the bus driver can turn
off its clock?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Samsung/S3C6410/Mini6410: how to handle NAND's "clock off"
  2014-11-12  9:14   ` Uwe Kleine-König
@ 2014-11-12 12:00     ` Juergen Borleis
  0 siblings, 0 replies; 4+ messages in thread
From: Juergen Borleis @ 2014-11-12 12:00 UTC (permalink / raw)
  To: linux-arm-kernel


On Wednesday 12 November 2014 10:14:58 Uwe Kleine-K?nig wrote:
> Hello again,
>
> [extending audience a bit]
>
> On Tue, Nov 11, 2014 at 07:42:26PM +0100, Uwe Kleine-K?nig wrote:
> > On Tue, Nov 11, 2014 at 07:10:33PM +0100, Juergen Borleis wrote:
> > > Hi,
> > >
> > > the S3C2410 NAND driver [1] can still be used for NANDs attached to an
> > > S3C6410 SoC. But this driver has a "nice" feature called "clock off" to
> > > save some power while not in use. I tried it here on my Mini6410
> > > platform and it freezes the system.
> > >
> > > The clock tree is somehow:
> > >
> > > [...]
> > >   hclk                      4            4   133000000          0 0
> > >      hclk_mfc               0            0   133000000          0 0
> > >      hclk_mem0              2            2   133000000          0 0
> > >         mem0_srom           0            0   133000000          0 0
> > >         mem0_nfcon          1            1   133000000          0 0
> > >         mem0_onenand0       0            0   133000000          0 0
> > >         mem0_onenand1       0            0   133000000          0 0
> > >         mem0_cfcon          0            0   133000000          0 0
> > > [...]
> > >
> > > On the Mini6410 the "mem0_nfcon" clock is the only single user of the
> > > "hclk_mem0". And this clock is required to keep the access to the
> > > external network device enabled. When the NAND driver disables its
> > > clock "mem0_nfcon", the "hclk_mem0" gets also disabled because there is
> > > no consumer anymore. The next time the network driver tries to access
> > > its device, the SoC freezes.
> >
> > Sounds like the network driver should hold a reference to hclk_mem0.
>
> After talking to J?rgen by phone, the solution that the dm9000 driver
> should handle the clock sounds wrong. The clk in question is needed by
> the SoC to operate the bus the dm9000 is connected to. So I think the
> right approach would include

I think we need the same here for the S3C6410 SoC, like the imx-weim driver is 
for i.MX SoCs.

jbe

-- 
Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| Juergen Borleis ? ? ? ? ? ? |
Industrial Linux Solutions               ? ? ?| Phone: +49-5121-206917-5128 |
Peiner Str. 6-8, 31137 Hildesheim, Germany ? ?| Fax: ? +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 ? ? ? ? ? ? ?| http://www.pengutronix.de/ ?|

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

end of thread, other threads:[~2014-11-12 12:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-11 18:10 Samsung/S3C6410/Mini6410: how to handle NAND's "clock off" Juergen Borleis
2014-11-11 18:42 ` Uwe Kleine-König
2014-11-12  9:14   ` Uwe Kleine-König
2014-11-12 12:00     ` Juergen Borleis

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).