2009-04-18 10:50:59

by Bruno Prémont

[permalink] [raw]
Subject: [PATCH 0/2] Stop disks on reboot for laptop which cuts power

Hi,

During shutdown (power off) the disks are stopped gracefully thus the
stopping is skipped for reboot case.

On my Acer Travelmate 660 reboot is more like power-off as it cuts all
power during reboot which currently causes the disk to emergency-park
its head (noisy and shortens disk life).

This patch series adds a DMI-based check to ide-gd and sd to still
stop the disks for affected laptop during reboot.

Has been compile an run-tested with libata and just compile-tested for
ide.

Bruno Prémont


2009-04-18 10:56:06

by Bruno Prémont

[permalink] [raw]
Subject: [PATCH 2/2] sd: Stop disks on reboot for laptop which cuts power

My laptop (Acer Travelmate 660) always cuts the power when rebooting
which causes the disk to emergency-park it's head.

Add a dmi check to stop disk as for shutdown on this laptop.

Signed-off-by: Bruno Prémont <[email protected]>
---
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 3fcb64b..fdad8bc 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -50,6 +50,7 @@
#include <linux/string_helpers.h>
#include <linux/async.h>
#include <asm/uaccess.h>
+#include <linux/dmi.h>

#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
@@ -2127,6 +2128,20 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
return res;
}

+static const struct dmi_system_id sd_coldreboot_table[] = {
+ {
+ /* Acer TravelMate 66x cuts power during reboot */
+ .ident = "Acer TravelMate 660",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 660"),
+ },
+ },
+
+ { } /* terminate list */
+};
+
+
/*
* Send a SYNCHRONIZE CACHE instruction down to the device through
* the normal SCSI command structure. Wait for the command to
@@ -2144,7 +2159,9 @@ 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 &&
+ (system_state != SYSTEM_RESTART ||
+ dmi_check_system(sd_coldreboot_table))) {
sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
sd_start_stop_device(sdkp, 0);
}

2009-04-18 10:56:28

by Bruno Prémont

[permalink] [raw]
Subject: [PATCH 1/2] ide: Stop disks on reboot for laptop which cuts power

My laptop (Acer Travelmate 660) always cuts the power when rebooting
which causes the disk to emergency-park it's head.

Add a dmi check to stop disk as for shutdown on this laptop.

Signed-off-by: Bruno Prémont <[email protected]>
---
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
index 1aebdf1..4b6b71e 100644
--- a/drivers/ide/ide-gd.c
+++ b/drivers/ide/ide-gd.c
@@ -7,6 +7,7 @@
#include <linux/mutex.h>
#include <linux/ide.h>
#include <linux/hdreg.h>
+#include <linux/dmi.h>

#if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT)
#define IDE_DISK_MINORS (1 << PARTN_BITS)
@@ -99,6 +100,19 @@ static void ide_gd_resume(ide_drive_t *drive)
(void)drive->disk_ops->get_capacity(drive);
}

+static const struct dmi_system_id ide_coldreboot_table[] = {
+ {
+ /* Acer TravelMate 66x cuts power during reboot */
+ .ident = "Acer TravelMate 660",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 660"),
+ },
+ },
+
+ { } /* terminate list */
+};
+
static void ide_gd_shutdown(ide_drive_t *drive)
{
#ifdef CONFIG_ALPHA
@@ -115,7 +129,8 @@ static void ide_gd_shutdown(ide_drive_t *drive)
the disk to expire its write cache. */
if (system_state != SYSTEM_POWER_OFF) {
#else
- if (system_state == SYSTEM_RESTART) {
+ if (system_state == SYSTEM_RESTART &&
+ !dmi_check_system(ide_coldreboot_table)) {
#endif
drive->disk_ops->flush(drive);
return;

2009-04-20 07:52:25

by Tejun Heo

[permalink] [raw]
Subject: Re: [PATCH 1/2] ide: Stop disks on reboot for laptop which cuts power

Bruno Prémont wrote:
> My laptop (Acer Travelmate 660) always cuts the power when rebooting
> which causes the disk to emergency-park it's head.
>
> Add a dmi check to stop disk as for shutdown on this laptop.

Hmm... yeah, I also noticed this behavior on several machines I have
here. Most were beta BIOSen.

Maybe it's worth to shutdown drives on reboot on all machines?

Thanks.

--
tejun

2009-04-20 08:36:01

by Tejun Heo

[permalink] [raw]
Subject: Re: [PATCH 1/2] ide: Stop disks on reboot for laptop which cuts power

Hello,

Bruno Prémont wrote:
> Possibly it depends very much how the power is connected,
> e.g. desktop boxes with ATX power-supply probably never tell the
> power-supply to cut the power but laptop may behave differently with
> regard to their built-in DC-DC converters (disks connected to
> mainboard versus disks directly connected to power supply).

I've seen several desktop motherboards which fully power cycle disks
on reboot. Dunno where the difference comes from tho. IIRC, some
intel boards seem to do things that way.

> What I was also wondering whether the list of machines to which to
> apply the quirk should be moved to a common location so it exists
> only once for ide and scsi/ata instead of once on each side. Having
> the list exactly once avoids the risk for content to drift between
> ide and scsi/ata.

Hmmm....

Thanks.

--
tejun

2009-04-20 08:37:30

by Bruno Prémont

[permalink] [raw]
Subject: Re: [PATCH 1/2] ide: Stop disks on reboot for laptop which cuts power

On Mon, 20 Apr 2009 16:51:57 Tejun Heo <[email protected]> wrote:
> Bruno Prémont wrote:
> > My laptop (Acer Travelmate 660) always cuts the power when rebooting
> > which causes the disk to emergency-park it's head.
> >
> > Add a dmi check to stop disk as for shutdown on this laptop.
>
> Hmm... yeah, I also noticed this behavior on several machines I have
> here. Most were beta BIOSen.
>
> Maybe it's worth to shutdown drives on reboot on all machines?
>
> Thanks.

I will check how my other machines behave but I don't remember such a
power-down behavior.
Except for a spin-down - spin-up cycle a generalization should not
cause troubles though. (I vaguely remember seeing different reboot
modes in kernel code - as in colder or hotter reboots - these might
also change BIOS behavior where the different modes are implemented
and thus cause disk stopping to be needed)

Possibly it depends very much how the power is connected, e.g. desktop
boxes with ATX power-supply probably never tell the power-supply to cut
the power but laptop may behave differently with regard to their
built-in DC-DC converters (disks connected to mainboard versus disks
directly connected to power supply).

What I was also wondering whether the list of machines to which
to apply the quirk should be moved to a common location so it exists
only once for ide and scsi/ata instead of once on each side.
Having the list exactly once avoids the risk for content to drift
between ide and scsi/ata.

Bruno

Subject: Re: [PATCH 1/2] ide: Stop disks on reboot for laptop which cuts power

On Saturday 18 April 2009 12:45:58 Bruno Prémont wrote:
> My laptop (Acer Travelmate 660) always cuts the power when rebooting
> which causes the disk to emergency-park it's head.
>
> Add a dmi check to stop disk as for shutdown on this laptop.
>
> Signed-off-by: Bruno Prémont <[email protected]>

applied