Commit 490a8d70 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'hibern_fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev

* 'hibern_fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev:
  SATA PIIX: Blacklist system that spins off disks during ACPI power off
  SATA Sil: Blacklist system that spins off disks during ACPI power off
  SATA AHCI: Blacklist system that spins off disks during ACPI power off
  SATA: Blacklisting of systems that spin off disks during ACPI power off
  DMI: Introduce dmi_first_match to make the interface more flexible
  Hibernation: Introduce system_entering_hibernation
parents 8c022fdd 5f451fe1
...@@ -2548,6 +2548,32 @@ static void ahci_p5wdh_workaround(struct ata_host *host) ...@@ -2548,6 +2548,32 @@ static void ahci_p5wdh_workaround(struct ata_host *host)
} }
} }
static bool ahci_broken_system_poweroff(struct pci_dev *pdev)
{
static const struct dmi_system_id broken_systems[] = {
{
.ident = "HP Compaq nx6310",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6310"),
},
/* PCI slot number of the controller */
.driver_data = (void *)0x1FUL,
},
{ } /* terminate list */
};
const struct dmi_system_id *dmi = dmi_first_match(broken_systems);
if (dmi) {
unsigned long slot = (unsigned long)dmi->driver_data;
/* apply the quirk only to on-board controllers */
return slot == PCI_SLOT(pdev->devfn);
}
return false;
}
static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{ {
static int printed_version; static int printed_version;
...@@ -2647,6 +2673,12 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -2647,6 +2673,12 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
} }
} }
if (ahci_broken_system_poweroff(pdev)) {
pi.flags |= ATA_FLAG_NO_POWEROFF_SPINDOWN;
dev_info(&pdev->dev,
"quirky BIOS, skipping spindown on poweroff\n");
}
/* CAP.NP sometimes indicate the index of the last enabled /* CAP.NP sometimes indicate the index of the last enabled
* port, at other times, that of the last possible port, so * port, at other times, that of the last possible port, so
* determining the maximum port number requires looking at * determining the maximum port number requires looking at
......
...@@ -1387,6 +1387,32 @@ static void piix_iocfg_bit18_quirk(struct ata_host *host) ...@@ -1387,6 +1387,32 @@ static void piix_iocfg_bit18_quirk(struct ata_host *host)
} }
} }
static bool piix_broken_system_poweroff(struct pci_dev *pdev)
{
static const struct dmi_system_id broken_systems[] = {
{
.ident = "HP Compaq 2510p",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 2510p"),
},
/* PCI slot number of the controller */
.driver_data = (void *)0x1FUL,
},
{ } /* terminate list */
};
const struct dmi_system_id *dmi = dmi_first_match(broken_systems);
if (dmi) {
unsigned long slot = (unsigned long)dmi->driver_data;
/* apply the quirk only to on-board controllers */
return slot == PCI_SLOT(pdev->devfn);
}
return false;
}
/** /**
* piix_init_one - Register PIIX ATA PCI device with kernel services * piix_init_one - Register PIIX ATA PCI device with kernel services
* @pdev: PCI device to register * @pdev: PCI device to register
...@@ -1422,6 +1448,14 @@ static int __devinit piix_init_one(struct pci_dev *pdev, ...@@ -1422,6 +1448,14 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
if (!in_module_init) if (!in_module_init)
return -ENODEV; return -ENODEV;
if (piix_broken_system_poweroff(pdev)) {
piix_port_info[ent->driver_data].flags |=
ATA_FLAG_NO_POWEROFF_SPINDOWN |
ATA_FLAG_NO_HIBERNATE_SPINDOWN;
dev_info(&pdev->dev, "quirky BIOS, skipping spindown "
"on poweroff and hibernation\n");
}
port_info[0] = piix_port_info[ent->driver_data]; port_info[0] = piix_port_info[ent->driver_data];
port_info[1] = piix_port_info[ent->driver_data]; port_info[1] = piix_port_info[ent->driver_data];
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include <linux/libata.h> #include <linux/libata.h>
#include <linux/hdreg.h> #include <linux/hdreg.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/suspend.h>
#include "libata.h" #include "libata.h"
...@@ -1303,6 +1304,17 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc) ...@@ -1303,6 +1304,17 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc)
tf->command = ATA_CMD_VERIFY; /* READ VERIFY */ tf->command = ATA_CMD_VERIFY; /* READ VERIFY */
} else { } else {
/* Some odd clown BIOSen issue spindown on power off (ACPI S4
* or S5) causing some drives to spin up and down again.
*/
if ((qc->ap->flags & ATA_FLAG_NO_POWEROFF_SPINDOWN) &&
system_state == SYSTEM_POWER_OFF)
goto skip;
if ((qc->ap->flags & ATA_FLAG_NO_HIBERNATE_SPINDOWN) &&
system_entering_hibernation())
goto skip;
/* XXX: This is for backward compatibility, will be /* XXX: This is for backward compatibility, will be
* removed. Read Documentation/feature-removal-schedule.txt * removed. Read Documentation/feature-removal-schedule.txt
* for more info. * for more info.
...@@ -1326,8 +1338,7 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc) ...@@ -1326,8 +1338,7 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc)
scmd->scsi_done = qc->scsidone; scmd->scsi_done = qc->scsidone;
qc->scsidone = ata_delayed_done; qc->scsidone = ata_delayed_done;
} }
scmd->result = SAM_STAT_GOOD; goto skip;
return 1;
} }
/* Issue ATA STANDBY IMMEDIATE command */ /* Issue ATA STANDBY IMMEDIATE command */
...@@ -1343,10 +1354,13 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc) ...@@ -1343,10 +1354,13 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc)
return 0; return 0;
invalid_fld: invalid_fld:
ata_scsi_set_sense(scmd, ILLEGAL_REQUEST, 0x24, 0x0); ata_scsi_set_sense(scmd, ILLEGAL_REQUEST, 0x24, 0x0);
/* "Invalid field in cbd" */ /* "Invalid field in cbd" */
return 1; return 1;
skip:
scmd->result = SAM_STAT_GOOD;
return 1;
} }
......
...@@ -695,11 +695,38 @@ static void sil_init_controller(struct ata_host *host) ...@@ -695,11 +695,38 @@ static void sil_init_controller(struct ata_host *host)
} }
} }
static bool sil_broken_system_poweroff(struct pci_dev *pdev)
{
static const struct dmi_system_id broken_systems[] = {
{
.ident = "HP Compaq nx6325",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"),
},
/* PCI slot number of the controller */
.driver_data = (void *)0x12UL,
},
{ } /* terminate list */
};
const struct dmi_system_id *dmi = dmi_first_match(broken_systems);
if (dmi) {
unsigned long slot = (unsigned long)dmi->driver_data;
/* apply the quirk only to on-board controllers */
return slot == PCI_SLOT(pdev->devfn);
}
return false;
}
static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{ {
static int printed_version; static int printed_version;
int board_id = ent->driver_data; int board_id = ent->driver_data;
const struct ata_port_info *ppi[] = { &sil_port_info[board_id], NULL }; struct ata_port_info pi = sil_port_info[board_id];
const struct ata_port_info *ppi[] = { &pi, NULL };
struct ata_host *host; struct ata_host *host;
void __iomem *mmio_base; void __iomem *mmio_base;
int n_ports, rc; int n_ports, rc;
...@@ -713,6 +740,13 @@ static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -713,6 +740,13 @@ static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
if (board_id == sil_3114) if (board_id == sil_3114)
n_ports = 4; n_ports = 4;
if (sil_broken_system_poweroff(pdev)) {
pi.flags |= ATA_FLAG_NO_POWEROFF_SPINDOWN |
ATA_FLAG_NO_HIBERNATE_SPINDOWN;
dev_info(&pdev->dev, "quirky BIOS, skipping spindown "
"on poweroff and hibernation\n");
}
host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports); host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
if (!host) if (!host)
return -ENOMEM; return -ENOMEM;
......
...@@ -414,6 +414,29 @@ void __init dmi_scan_machine(void) ...@@ -414,6 +414,29 @@ void __init dmi_scan_machine(void)
dmi_initialized = 1; dmi_initialized = 1;
} }
/**
* dmi_matches - check if dmi_system_id structure matches system DMI data
* @dmi: pointer to the dmi_system_id structure to check
*/
static bool dmi_matches(const struct dmi_system_id *dmi)
{
int i;
WARN(!dmi_initialized, KERN_ERR "dmi check: not initialized yet.\n");
for (i = 0; i < ARRAY_SIZE(dmi->matches); i++) {
int s = dmi->matches[i].slot;
if (s == DMI_NONE)
continue;
if (dmi_ident[s]
&& strstr(dmi_ident[s], dmi->matches[i].substr))
continue;
/* No match */
return false;
}
return true;
}
/** /**
* dmi_check_system - check system DMI data * dmi_check_system - check system DMI data
* @list: array of dmi_system_id structures to match against * @list: array of dmi_system_id structures to match against
...@@ -429,31 +452,44 @@ void __init dmi_scan_machine(void) ...@@ -429,31 +452,44 @@ void __init dmi_scan_machine(void)
*/ */
int dmi_check_system(const struct dmi_system_id *list) int dmi_check_system(const struct dmi_system_id *list)
{ {
int i, count = 0; int count = 0;
const struct dmi_system_id *d = list; const struct dmi_system_id *d;
WARN(!dmi_initialized, KERN_ERR "dmi check: not initialized yet.\n"); for (d = list; d->ident; d++)
if (dmi_matches(d)) {
while (d->ident) {
for (i = 0; i < ARRAY_SIZE(d->matches); i++) {
int s = d->matches[i].slot;
if (s == DMI_NONE)
continue;
if (dmi_ident[s] && strstr(dmi_ident[s], d->matches[i].substr))
continue;
/* No match */
goto fail;
}
count++; count++;
if (d->callback && d->callback(d)) if (d->callback && d->callback(d))
break; break;
fail: d++;
} }
return count; return count;
} }
EXPORT_SYMBOL(dmi_check_system); EXPORT_SYMBOL(dmi_check_system);
/**
* dmi_first_match - find dmi_system_id structure matching system DMI data
* @list: array of dmi_system_id structures to match against
* All non-null elements of the list must match
* their slot's (field index's) data (i.e., each
* list string must be a substring of the specified
* DMI slot's string data) to be considered a
* successful match.
*
* Walk the blacklist table until the first match is found. Return the
* pointer to the matching entry or NULL if there's no match.
*/
const struct dmi_system_id *dmi_first_match(const struct dmi_system_id *list)
{
const struct dmi_system_id *d;
for (d = list; d->ident; d++)
if (dmi_matches(d))
return d;
return NULL;
}
EXPORT_SYMBOL(dmi_first_match);
/** /**
* dmi_get_system_info - return DMI data value * dmi_get_system_info - return DMI data value
* @field: data index (see enum dmi_field) * @field: data index (see enum dmi_field)
......
...@@ -38,6 +38,7 @@ struct dmi_device { ...@@ -38,6 +38,7 @@ struct dmi_device {
#ifdef CONFIG_DMI #ifdef CONFIG_DMI
extern int dmi_check_system(const struct dmi_system_id *list); extern int dmi_check_system(const struct dmi_system_id *list);
const struct dmi_system_id *dmi_first_match(const struct dmi_system_id *list);
extern const char * dmi_get_system_info(int field); extern const char * dmi_get_system_info(int field);
extern const struct dmi_device * dmi_find_device(int type, const char *name, extern const struct dmi_device * dmi_find_device(int type, const char *name,
const struct dmi_device *from); const struct dmi_device *from);
......
...@@ -187,6 +187,8 @@ enum { ...@@ -187,6 +187,8 @@ enum {
ATA_FLAG_PIO_POLLING = (1 << 9), /* use polling PIO if LLD ATA_FLAG_PIO_POLLING = (1 << 9), /* use polling PIO if LLD
* doesn't handle PIO interrupts */ * doesn't handle PIO interrupts */
ATA_FLAG_NCQ = (1 << 10), /* host supports NCQ */ ATA_FLAG_NCQ = (1 << 10), /* host supports NCQ */
ATA_FLAG_NO_POWEROFF_SPINDOWN = (1 << 11), /* don't spindown before poweroff */
ATA_FLAG_NO_HIBERNATE_SPINDOWN = (1 << 12), /* don't spindown before hibernation */
ATA_FLAG_DEBUGMSG = (1 << 13), ATA_FLAG_DEBUGMSG = (1 << 13),
ATA_FLAG_IGN_SIMPLEX = (1 << 15), /* ignore SIMPLEX */ ATA_FLAG_IGN_SIMPLEX = (1 << 15), /* ignore SIMPLEX */
ATA_FLAG_NO_IORDY = (1 << 16), /* controller lacks iordy */ ATA_FLAG_NO_IORDY = (1 << 16), /* controller lacks iordy */
......
...@@ -237,6 +237,7 @@ extern int hibernate_nvs_alloc(void); ...@@ -237,6 +237,7 @@ extern int hibernate_nvs_alloc(void);
extern void hibernate_nvs_free(void); extern void hibernate_nvs_free(void);
extern void hibernate_nvs_save(void); extern void hibernate_nvs_save(void);
extern void hibernate_nvs_restore(void); extern void hibernate_nvs_restore(void);
extern bool system_entering_hibernation(void);
#else /* CONFIG_HIBERNATION */ #else /* CONFIG_HIBERNATION */
static inline int swsusp_page_is_forbidden(struct page *p) { return 0; } static inline int swsusp_page_is_forbidden(struct page *p) { return 0; }
static inline void swsusp_set_page_free(struct page *p) {} static inline void swsusp_set_page_free(struct page *p) {}
...@@ -252,6 +253,7 @@ static inline int hibernate_nvs_alloc(void) { return 0; } ...@@ -252,6 +253,7 @@ static inline int hibernate_nvs_alloc(void) { return 0; }
static inline void hibernate_nvs_free(void) {} static inline void hibernate_nvs_free(void) {}
static inline void hibernate_nvs_save(void) {} static inline void hibernate_nvs_save(void) {}
static inline void hibernate_nvs_restore(void) {} static inline void hibernate_nvs_restore(void) {}
static inline bool system_entering_hibernation(void) { return false; }
#endif /* CONFIG_HIBERNATION */ #endif /* CONFIG_HIBERNATION */
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
......
...@@ -71,6 +71,14 @@ void hibernation_set_ops(struct platform_hibernation_ops *ops) ...@@ -71,6 +71,14 @@ void hibernation_set_ops(struct platform_hibernation_ops *ops)
mutex_unlock(&pm_mutex); mutex_unlock(&pm_mutex);
} }
static bool entering_platform_hibernation;
bool system_entering_hibernation(void)
{
return entering_platform_hibernation;
}
EXPORT_SYMBOL(system_entering_hibernation);
#ifdef CONFIG_PM_DEBUG #ifdef CONFIG_PM_DEBUG
static void hibernation_debug_sleep(void) static void hibernation_debug_sleep(void)
{ {
...@@ -411,6 +419,7 @@ int hibernation_platform_enter(void) ...@@ -411,6 +419,7 @@ int hibernation_platform_enter(void)
if (error) if (error)
goto Close; goto Close;
entering_platform_hibernation = true;
suspend_console(); suspend_console();
error = device_suspend(PMSG_HIBERNATE); error = device_suspend(PMSG_HIBERNATE);
if (error) { if (error) {
...@@ -445,6 +454,7 @@ int hibernation_platform_enter(void) ...@@ -445,6 +454,7 @@ int hibernation_platform_enter(void)
Finish: Finish:
hibernation_ops->finish(); hibernation_ops->finish();
Resume_devices: Resume_devices:
entering_platform_hibernation = false;
device_resume(PMSG_RESTORE); device_resume(PMSG_RESTORE);
resume_console(); resume_console();
Close: Close:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment