Cubietruck, u-boot-2014.10, SATA drive power cut during boot

147 views
Skip to first unread message

Bruno Prémont

unread,
Nov 8, 2014, 2:35:01 PM11/8/14
to linux...@googlegroups.com, Ian Campbell
Hi,

Since updating my cubietruck to u-boot-2014.10 the SATA hard drive
connected to it performs emergency head parking around the time
uboot hands over control to kernel (or kernel is booting).

The same issue also exists during reboot.

Looking at the changes in u-boot-2014.10 SATA support has been added.

It looks like u-boot is setting up SATA then kernel is doing the same,
killing SATA power while reconfiguring the AHCI or SATApower GPIO.

Could u-boot put SATA drive into standby (or at least ask it to sync
and park its heads) prior to handing control over to kernel?

On the other hand it would be nice if SATApower could be preserved
along the different steps of boot process.



On kernel side I'm using the following patch to protect the SATA drive
during reboot:

Author: Bruno Prémont <bon...@linux-vserver.org>
Date: Wed Jul 9 22:50:43 2014 +0200

sd: Stop disks on reboot

Some systems (e.g. Acer Travelmate 66x laptop, Cubietruck) to
power-reset on reboot and thus make disks age more quickly due to
emergency head parking & stop.

Do not prevent stopping disk on reboot even if it might slow down
following boot process.
---
drivers/scsi/sd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 2c2041c..e5ff75f 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3158,7 +3158,7 @@ static void sd_shutdown(struct device *dev)
sd_sync_cache(sdkp);
}

- if (system_state != SYSTEM_RESTART && sdkp->device->manage_start_stop) {
+ if (sdkp->device->manage_start_stop) {
sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
sd_start_stop_device(sdkp, 0);
}
signature.asc

Ian Campbell

unread,
Nov 9, 2014, 5:20:52 AM11/9/14
to Bruno Prémont, linux...@googlegroups.com
On Sat, 2014-11-08 at 20:34 +0100, Bruno Prémont wrote:
> Since updating my cubietruck to u-boot-2014.10 the SATA hard drive
> connected to it performs emergency head parking around the time
> uboot hands over control to kernel (or kernel is booting).

I think that probably explains the click I've been wondering about.

> Could u-boot put SATA drive into standby (or at least ask it to sync
> and park its heads) prior to handing control over to kernel?

Yes, this would be great, thanks.

> On the other hand it would be nice if SATApower could be preserved
> along the different steps of boot process.

I suppose something is resetting the GPIO controller and therefore the
power GPIO before the SATA drivers come along and configure it. I've no
idea if there exists any infrastructure in the kernel to preserve
initial setup of the GPIO (I expected there is). It would be useful to
investigate.

Cheers,
Ian.

Bruno Prémont

unread,
Nov 9, 2014, 7:49:19 AM11/9/14
to Ian Campbell, linux...@googlegroups.com
On Sun, 09 November 2014 Ian Campbell <i...@hellion.org.uk> wrote:
> On Sat, 2014-11-08 at 20:34 +0100, Bruno Prémont wrote:
> > Since updating my cubietruck to u-boot-2014.10 the SATA hard drive
> > connected to it performs emergency head parking around the time
> > uboot hands over control to kernel (or kernel is booting).
>
> I think that probably explains the click I've been wondering about.

To be more precise, it's in the middle of kernel booting.
Though I had no time to identify more precisely at what time it was,
kernel output on serial console flying by too quickly.

> > Could u-boot put SATA drive into standby (or at least ask it to sync
> > and park its heads) prior to handing control over to kernel?
>
> Yes, this would be great, thanks.

Maybe in addition to stopping the disk(s), delaying SATA initialization
until first use would be helpful as well.

So when booting from SD card without trying to fetch anything from
SATA drive the SATApower could be left untouched/disabled and AHCI
not enabled at all (avoids spinning up the disk to immediately stop it
again).


In any case, if/when u-boot gets support for a power-off command
it would be polite for it to stop the disk before powering off
(and as needed in case of reset/reboot).

> > On the other hand it would be nice if SATApower could be preserved
> > along the different steps of boot process.
>
> I suppose something is resetting the GPIO controller and therefore the
> power GPIO before the SATA drivers come along and configure it. I've no
> idea if there exists any infrastructure in the kernel to preserve
> initial setup of the GPIO (I expected there is). It would be useful to
> investigate.

Thanks,
Bruno
signature.asc

Hans de Goede

unread,
Nov 10, 2014, 8:23:26 AM11/10/14
to linux...@googlegroups.com, Ian Campbell
Hi,

On 11/08/2014 08:34 PM, Bruno Prémont wrote:
> Hi,
>
> Since updating my cubietruck to u-boot-2014.10 the SATA hard drive
> connected to it performs emergency head parking around the time
> uboot hands over control to kernel (or kernel is booting).
>
> The same issue also exists during reboot.

Right, during reboot there unfortunately is nothing we can do to avoid this
afaik. Although there is one thing which you could try, edit:

linux/drivers/ata/libahci_platform.c

Around line 500 you should find the following in there:

static void ahci_host_stop(struct ata_host *host)
{
struct ahci_host_priv *hpriv = host->private_data;

ahci_platform_disable_resources(hpriv);
}

Try commenting out the ahci_platform_disable_resources() call, I'm not sure
if this gets called at reboot / shutdown, but if it does then it could be
the culprit, although I think the real problem is that the SoC at reset
tri-states all its gpio-s.

> Looking at the changes in u-boot-2014.10 SATA support has been added.
>
> It looks like u-boot is setting up SATA then kernel is doing the same,
> killing SATA power while reconfiguring the AHCI or SATApower GPIO.

Hmm, good one, I think we can avoid this from happening with the following
patch:

diff --git a/arch/arm/boot/dts/sunxi-common-regulators.dtsi b/arch/arm/boot/dts/sunxi-common-regulators.dtsi
index c9c5b10..a950671 100644
--- a/arch/arm/boot/dts/sunxi-common-regulators.dtsi
+++ b/arch/arm/boot/dts/sunxi-common-regulators.dtsi
@@ -44,6 +44,7 @@
regulator-name = "ahci-5v";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
+ regulator-boot-on;
enable-active-high;
gpio = <&pio 1 8 0>;
status = "disabled";

Can you try applying this, then do "make dtbs" in your kernel sources
dir and copy the new cubietruck dtb file to your sdcard, and give things
a spin ?

Regards,

Hans

Bruno Prémont

unread,
Nov 10, 2014, 2:49:59 PM11/10/14
to Hans de Goede, linux...@googlegroups.com, Ian Campbell
Hi Hans,

On Mon, 10 November 2014 Hans de Goede wrote:
> On 11/08/2014 08:34 PM, Bruno Prémont wrote:
> > Since updating my cubietruck to u-boot-2014.10 the SATA hard drive
> > connected to it performs emergency head parking around the time
> > uboot hands over control to kernel (or kernel is booting).
> >
> > The same issue also exists during reboot.
>
> Right, during reboot there unfortunately is nothing we can do to avoid this
> afaik. Although there is one thing which you could try, edit:
>
> linux/drivers/ata/libahci_platform.c
>
> Around line 500 you should find the following in there:
>
> static void ahci_host_stop(struct ata_host *host)
> {
> struct ahci_host_priv *hpriv = host->private_data;
>
> ahci_platform_disable_resources(hpriv);
> }
>
> Try commenting out the ahci_platform_disable_resources() call, I'm not sure
> if this gets called at reboot / shutdown, but if it does then it could be
> the culprit, although I think the real problem is that the SoC at reset
> tri-states all its gpio-s.

I don't care too much about the linux shutdown/reboot as the patch I included
does a good job there. (also useful on my x86 Acer TM660 laptop!)

I might retry getting it upstream (a few years ago I sent one with DMI match
for just my laptop, but it was not applied).
With a few devices affected, and that cross-platform, applying it would
make some more sense.

> > Looking at the changes in u-boot-2014.10 SATA support has been added.
> >
> > It looks like u-boot is setting up SATA then kernel is doing the same,
> > killing SATA power while reconfiguring the AHCI or SATApower GPIO.
>
> Hmm, good one, I think we can avoid this from happening with the following
> patch:
>
> diff --git a/arch/arm/boot/dts/sunxi-common-regulators.dtsi b/arch/arm/boot/dts/sunxi-common-regulators.dtsi
> index c9c5b10..a950671 100644
> --- a/arch/arm/boot/dts/sunxi-common-regulators.dtsi
> +++ b/arch/arm/boot/dts/sunxi-common-regulators.dtsi
> @@ -44,6 +44,7 @@
> regulator-name = "ahci-5v";
> regulator-min-microvolt = <5000000>;
> regulator-max-microvolt = <5000000>;
> + regulator-boot-on;
> enable-active-high;
> gpio = <&pio 1 8 0>;
> status = "disabled";
>
> Can you try applying this, then do "make dtbs" in your kernel sources
> dir and copy the new cubietruck dtb file to your sdcard, and give things
> a spin ?

Works like a charm!

Does it have any impact when:
- u-boot does not support SATA/AHCI
- u-boot does not initialize SATA/AHCI
- there is no SATA drive connected?


Reported-and-Tested-by: Bruno Prémont <bon...@linux-vserver.org>


Thanks,
Bruno
Reply all
Reply to author
Forward
0 new messages