1 From: Matthew Garrett <mjg59@coreos.com>
2 Date: Sat, 18 Apr 2015 08:26:34 -0700
3 Subject: [PATCH 1/3] libata: Stash initial power management configuration
5 The initial configuration for power management settings may be a result of
6 the firmware using its knowledge of the installed hardware to program
7 reasonable defaults. Stash as much of it as possible for later use.
9 Signed-off-by: Matthew Garrett <mjg59@srcf.ucam.org>
11 drivers/ata/acard-ahci.c | 3 +++
12 drivers/ata/ahci.c | 3 +++
13 drivers/ata/ahci.h | 7 +++++++
14 drivers/ata/libahci.c | 46 +++++++++++++++++++++++++++++++++++-------
15 drivers/ata/libahci_platform.c | 4 ++++
16 drivers/ata/libata-core.c | 19 ++++++++++-------
17 drivers/ata/libata-pmp.c | 2 +-
18 drivers/ata/libata.h | 2 +-
19 drivers/ata/sata_highbank.c | 4 ++++
20 include/linux/libata.h | 3 +++
21 10 files changed, 77 insertions(+), 16 deletions(-)
23 diff --git a/drivers/ata/acard-ahci.c b/drivers/ata/acard-ahci.c
24 index 12489ce..0029229 100644
25 --- a/drivers/ata/acard-ahci.c
26 +++ b/drivers/ata/acard-ahci.c
27 @@ -476,6 +476,9 @@ static int acard_ahci_init_one(struct pci_dev *pdev, const struct pci_device_id
28 ata_port_pbar_desc(ap, AHCI_PCI_BAR,
29 0x100 + ap->port_no * 0x80, "port");
31 + rc = ahci_setup_port_privdata(ap);
34 /* set initial link pm policy */
36 ap->pm_policy = NOT_AVAILABLE;
37 diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
38 index c7a92a7..0f875e2 100644
39 --- a/drivers/ata/ahci.c
40 +++ b/drivers/ata/ahci.c
41 @@ -1436,6 +1436,9 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
42 if (ap->flags & ATA_FLAG_EM)
43 ap->em_message_type = hpriv->em_msg_type;
45 + rc = ahci_setup_port_privdata(ap);
49 /* disabled/not-implemented port */
50 if (!(hpriv->port_map & (1 << i)))
51 diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
52 index 71262e0..c1a4b6a 100644
53 --- a/drivers/ata/ahci.h
54 +++ b/drivers/ata/ahci.h
55 @@ -313,6 +313,12 @@ struct ahci_port_priv {
56 /* enclosure management info per PM slot */
57 struct ahci_em_priv em_priv[EM_MAX_SLOTS];
58 char *irq_desc; /* desc in /proc/interrupts */
59 + bool init_alpe; /* alpe enabled by default */
60 + bool init_asp; /* asp enabled by default */
61 + bool init_devslp; /* devslp enabled by default */
62 + u32 init_dito; /* initial dito configuration */
63 + u32 init_deto; /* initial deto configuration */
64 + u32 init_mdat; /* initial mdat configuration */
67 struct ahci_host_priv {
68 @@ -371,6 +377,7 @@ extern struct ata_port_operations ahci_platform_ops;
69 extern struct ata_port_operations ahci_pmp_retry_srst_ops;
71 unsigned int ahci_dev_classify(struct ata_port *ap);
72 +int ahci_setup_port_privdata(struct ata_port *ap);
73 void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag,
75 void ahci_save_initial_config(struct device *dev,
76 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
77 index 61a9c07..f0c7120 100644
78 --- a/drivers/ata/libahci.c
79 +++ b/drivers/ata/libahci.c
80 @@ -2212,19 +2212,53 @@ static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg)
85 + * Allocate port privdata and read back initial power management configuration
87 +int ahci_setup_port_privdata(struct ata_port *ap)
89 + struct ahci_port_priv *pp;
91 + void __iomem *port_mmio = ahci_port_base(ap);
93 + pp = kzalloc(sizeof(*pp), GFP_KERNEL);
97 + ap->private_data = pp;
99 + cmd = readl(port_mmio + PORT_CMD);
101 + if (cmd & PORT_CMD_ALPE)
102 + pp->init_alpe = true;
104 + if (cmd & PORT_CMD_ASP)
105 + pp->init_asp = true;
107 + devslp = readl(port_mmio + PORT_DEVSLP);
109 + /* devslp unsupported or disabled */
110 + if (!(devslp & PORT_DEVSLP_DSP) || !(devslp & PORT_DEVSLP_ADSE))
113 + pp->init_devslp = true;
114 + pp->init_dito = (devslp >> PORT_DEVSLP_DITO_OFFSET) & 0x3ff;
115 + pp->init_deto = (devslp >> PORT_DEVSLP_DETO_OFFSET) & 0xff;
116 + pp->init_mdat = (devslp >> PORT_DEVSLP_MDAT_OFFSET) & 0x1f;
120 +EXPORT_SYMBOL_GPL(ahci_setup_port_privdata);
122 static int ahci_port_start(struct ata_port *ap)
124 struct ahci_host_priv *hpriv = ap->host->private_data;
125 + struct ahci_port_priv *pp = ap->private_data;
126 struct device *dev = ap->host->dev;
127 - struct ahci_port_priv *pp;
130 size_t dma_sz, rx_fis_sz;
132 - pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
136 if (ap->host->n_ports > 1) {
137 pp->irq_desc = devm_kzalloc(dev, 8, GFP_KERNEL);
139 @@ -2303,8 +2337,6 @@ static int ahci_port_start(struct ata_port *ap)
140 ap->lock = &pp->lock;
143 - ap->private_data = pp;
145 /* engage engines, captain */
146 return ahci_port_resume(ap);
148 diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c
149 index d89305d..39946d4 100644
150 --- a/drivers/ata/libahci_platform.c
151 +++ b/drivers/ata/libahci_platform.c
152 @@ -563,6 +563,10 @@ int ahci_platform_init_host(struct platform_device *pdev,
153 if (ap->flags & ATA_FLAG_EM)
154 ap->em_message_type = hpriv->em_msg_type;
156 + rc = ahci_setup_port_privdata(ap);
160 /* disabled/not-implemented port */
161 if (!(hpriv->port_map & (1 << i)))
162 ap->ops = &ata_dummy_port_ops;
163 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
164 index f6cb1f1..c037f33 100644
165 --- a/drivers/ata/libata-core.c
166 +++ b/drivers/ata/libata-core.c
167 @@ -2024,6 +2024,9 @@ retry:
171 + if (id[79] & SATA_DIPM)
172 + dev->init_dipm = true;
177 @@ -5583,11 +5586,11 @@ void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp)
181 - * sata_link_init_spd - Initialize link->sata_spd_limit
182 - * @link: Link to configure sata_spd_limit for
183 + * sata_link_init_config - Initialize link->sata_spd_limit and init_lpm
184 + * @link: Link to configure sata_spd_limit and init_lpm for
186 - * Initialize @link->[hw_]sata_spd_limit to the currently
187 - * configured value.
188 + * Initialize @link->[hw_]sata_spd_limit and @link->init_lpm to the
189 + * currently configured value.
192 * Kernel thread context (may sleep).
193 @@ -5595,7 +5598,7 @@ void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp)
195 * 0 on success, -errno on failure.
197 -int sata_link_init_spd(struct ata_link *link)
198 +int sata_link_init_config(struct ata_link *link)
202 @@ -5612,6 +5615,8 @@ int sata_link_init_spd(struct ata_link *link)
204 link->sata_spd_limit = link->hw_sata_spd_limit;
206 + link->init_lpm = (link->saved_scontrol >> 8) & 0x7;
211 @@ -6161,9 +6166,9 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
212 ap->cbl = ATA_CBL_SATA;
214 /* init sata_spd_limit to the current value */
215 - sata_link_init_spd(&ap->link);
216 + sata_link_init_config(&ap->link);
218 - sata_link_init_spd(ap->slave_link);
219 + sata_link_init_config(ap->slave_link);
221 /* print per-port info to dmesg */
222 xfer_mask = ata_pack_xfermask(ap->pio_mask, ap->mwdma_mask,
223 diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
224 index 7ccc084..b9f7ce8 100644
225 --- a/drivers/ata/libata-pmp.c
226 +++ b/drivers/ata/libata-pmp.c
227 @@ -531,7 +531,7 @@ int sata_pmp_attach(struct ata_device *dev)
228 ap->ops->pmp_attach(ap);
230 ata_for_each_link(tlink, ap, EDGE)
231 - sata_link_init_spd(tlink);
232 + sata_link_init_config(tlink);
236 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
237 index a998a17..35016d6 100644
238 --- a/drivers/ata/libata.h
239 +++ b/drivers/ata/libata.h
240 @@ -99,7 +99,7 @@ extern bool ata_phys_link_online(struct ata_link *link);
241 extern bool ata_phys_link_offline(struct ata_link *link);
242 extern void ata_dev_init(struct ata_device *dev);
243 extern void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp);
244 -extern int sata_link_init_spd(struct ata_link *link);
245 +extern int sata_link_init_config(struct ata_link *link);
246 extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg);
247 extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg);
248 extern struct ata_port *ata_port_alloc(struct ata_host *host);
249 diff --git a/drivers/ata/sata_highbank.c b/drivers/ata/sata_highbank.c
250 index 24e311f..a2adf3f 100644
251 --- a/drivers/ata/sata_highbank.c
252 +++ b/drivers/ata/sata_highbank.c
253 @@ -556,6 +556,10 @@ static int ahci_highbank_probe(struct platform_device *pdev)
254 if (ap->flags & ATA_FLAG_EM)
255 ap->em_message_type = hpriv->em_msg_type;
257 + rc = ahci_setup_port_privdata(ap);
261 /* disabled/not-implemented port */
262 if (!(hpriv->port_map & (1 << i)))
263 ap->ops = &ata_dummy_port_ops;
264 diff --git a/include/linux/libata.h b/include/linux/libata.h
265 index 8dad4a3..31c149b 100644
266 --- a/include/linux/libata.h
267 +++ b/include/linux/libata.h
268 @@ -719,6 +719,8 @@ struct ata_device {
270 /* ering is CLEAR_END, read comment above CLEAR_END */
271 struct ata_ering ering;
272 + /* Initial DIPM configuration */
276 /* Fields between ATA_DEVICE_CLEAR_BEGIN and ATA_DEVICE_CLEAR_END are
277 @@ -800,6 +800,7 @@ struct ata_link {
278 struct ata_device device[ATA_MAX_DEVICES];
280 unsigned long last_lpm_change; /* when last LPM change happened */
281 + u8 init_lpm; /* initial lpm configuration */
283 #define ATA_LINK_CLEAR_BEGIN offsetof(struct ata_link, active_tag)
284 #define ATA_LINK_CLEAR_END offsetof(struct ata_link, device[0])
289 To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
290 the body of a message to majordomo@vger.kernel.org
291 More majordomo info at http://vger.kernel.org/majordomo-info.html
292 Please read the FAQ at http://www.tux.org/lkml/
293 From: Matthew Garrett <mjg59@coreos.com>
294 Date: Sat, 18 Apr 2015 08:26:35 -0700
295 Subject: [PATCH 2/3] libata: Add firmware_default LPM policy
297 System vendors may configure SATA link power management appropriately for
298 their systems in firmware, based on their knowledge of the hardware
299 installed. Add an additional LPM policy designed to inherit the
300 configuration provided by the firmware.
302 Signed-off-by: Matthew Garrett <mjg59@coreos.com>
304 .../scsi/link_power_management_policy.txt | 5 +-
305 drivers/ata/libahci.c | 62 +++++++++++++++-------
306 drivers/ata/libata-core.c | 7 ++-
307 drivers/ata/libata-eh.c | 15 +++---
308 drivers/ata/libata-scsi.c | 1 +
309 include/linux/libata.h | 1 +
310 6 files changed, 63 insertions(+), 28 deletions(-)
312 diff --git a/Documentation/scsi/link_power_management_policy.txt b/Documentation/scsi/link_power_management_policy.txt
313 index d18993d..0285601 100644
314 --- a/Documentation/scsi/link_power_management_policy.txt
315 +++ b/Documentation/scsi/link_power_management_policy.txt
317 This parameter allows the user to set the link (interface) power management.
318 -There are 3 possible options:
319 +There are 4 possible options:
322 ----------------------------------------------------------------------------
323 +firmware_defaults Inherit configuration from the state programmed by
324 + the firmware during system init.
326 min_power Tell the controller to try to make the link use the
327 least possible power when possible. This may
328 sacrifice some performance due to increased latency
329 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
330 index f0c7120..fabcff4 100644
331 --- a/drivers/ata/libahci.c
332 +++ b/drivers/ata/libahci.c
333 @@ -684,6 +684,7 @@ static int ahci_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
335 struct ata_port *ap = link->ap;
336 struct ahci_host_priv *hpriv = ap->host->private_data;
337 + struct ahci_port_priv *ppriv = ap->private_data;
338 struct ahci_port_priv *pp = ap->private_data;
339 void __iomem *port_mmio = ahci_port_base(ap);
341 @@ -701,9 +702,9 @@ static int ahci_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
343 if (hpriv->cap & HOST_CAP_ALPM) {
344 u32 cmd = readl(port_mmio + PORT_CMD);
345 + cmd &= ~(PORT_CMD_ASP | PORT_CMD_ALPE);
347 if (policy == ATA_LPM_MAX_POWER || !(hints & ATA_LPM_HIPM)) {
348 - cmd &= ~(PORT_CMD_ASP | PORT_CMD_ALPE);
349 cmd |= PORT_CMD_ICC_ACTIVE;
351 writel(cmd, port_mmio + PORT_CMD);
352 @@ -711,6 +712,13 @@ static int ahci_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
354 /* wait 10ms to be sure we've come out of LPM state */
356 + } else if (policy == ATA_LPM_FIRMWARE_DEFAULTS) {
357 + if (ppriv->init_alpe)
358 + cmd |= PORT_CMD_ALPE;
359 + if (ppriv->init_asp)
360 + cmd |= PORT_CMD_ASP;
362 + writel(cmd, port_mmio + PORT_CMD);
364 cmd |= PORT_CMD_ALPE;
365 if (policy == ATA_LPM_MIN_POWER)
366 @@ -725,10 +733,17 @@ static int ahci_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
367 if ((hpriv->cap2 & HOST_CAP2_SDS) &&
368 (hpriv->cap2 & HOST_CAP2_SADM) &&
369 (link->device->flags & ATA_DFLAG_DEVSLP)) {
370 - if (policy == ATA_LPM_MIN_POWER)
372 + case ATA_LPM_MIN_POWER:
373 ahci_set_aggressive_devslp(ap, true);
376 + case ATA_LPM_FIRMWARE_DEFAULTS:
377 + ahci_set_aggressive_devslp(ap, ppriv->init_devslp);
380 ahci_set_aggressive_devslp(ap, false);
385 if (policy == ATA_LPM_MAX_POWER) {
386 @@ -1995,6 +2010,7 @@ static void ahci_post_internal_cmd(struct ata_queued_cmd *qc)
387 static void ahci_set_aggressive_devslp(struct ata_port *ap, bool sleep)
389 struct ahci_host_priv *hpriv = ap->host->private_data;
390 + struct ahci_port_priv *ppriv = ap->private_data;
391 void __iomem *port_mmio = ahci_port_base(ap);
392 struct ata_device *dev = ap->link.device;
393 u32 devslp, dm, dito, mdat, deto;
394 @@ -2030,26 +2046,32 @@ static void ahci_set_aggressive_devslp(struct ata_port *ap, bool sleep)
398 - dm = (devslp & PORT_DEVSLP_DM_MASK) >> PORT_DEVSLP_DM_OFFSET;
399 - dito = devslp_idle_timeout / (dm + 1);
402 + if (ppriv->init_devslp) {
403 + dito = ppriv->init_dito;
404 + deto = ppriv->init_deto;
405 + mdat = ppriv->init_mdat;
407 + dm = (devslp & PORT_DEVSLP_DM_MASK) >> PORT_DEVSLP_DM_OFFSET;
408 + dito = devslp_idle_timeout / (dm + 1);
412 - /* Use the nominal value 10 ms if the read MDAT is zero,
413 - * the nominal value of DETO is 20 ms.
415 - if (dev->devslp_timing[ATA_LOG_DEVSLP_VALID] &
416 - ATA_LOG_DEVSLP_VALID_MASK) {
417 - mdat = dev->devslp_timing[ATA_LOG_DEVSLP_MDAT] &
418 - ATA_LOG_DEVSLP_MDAT_MASK;
420 + /* Use the nominal value 10 ms if the read MDAT is zero,
421 + * the nominal value of DETO is 20 ms.
423 + if (dev->devslp_timing[ATA_LOG_DEVSLP_VALID] &
424 + ATA_LOG_DEVSLP_VALID_MASK) {
425 + mdat = dev->devslp_timing[ATA_LOG_DEVSLP_MDAT] &
426 + ATA_LOG_DEVSLP_MDAT_MASK;
429 + deto = dev->devslp_timing[ATA_LOG_DEVSLP_DETO];
434 - deto = dev->devslp_timing[ATA_LOG_DEVSLP_DETO];
443 devslp |= ((dito << PORT_DEVSLP_DITO_OFFSET) |
444 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
445 index c037f33..0a78f01 100644
446 --- a/drivers/ata/libata-core.c
447 +++ b/drivers/ata/libata-core.c
448 @@ -2024,7 +2024,7 @@ retry:
452 - if (id[79] & SATA_DIPM)
453 + if (id[79] & (1 << SATA_DIPM))
454 dev->init_dipm = true;
457 @@ -3672,6 +3672,11 @@ int sata_link_scr_lpm(struct ata_link *link, enum ata_lpm_policy policy,
461 + case ATA_LPM_FIRMWARE_DEFAULTS:
462 + /* use the values we read at probe */
463 + scontrol &= ~(0x7 << 8);
464 + scontrol |= (link->init_lpm << 8);
466 case ATA_LPM_MAX_POWER:
467 /* disable all LPM transitions */
468 scontrol |= (0x7 << 8);
469 diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
470 index 07f41be..c36fa56 100644
471 --- a/drivers/ata/libata-eh.c
472 +++ b/drivers/ata/libata-eh.c
473 @@ -3519,9 +3519,9 @@ static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
477 - * DIPM is enabled only for MIN_POWER as some devices
478 - * misbehave when the host NACKs transition to SLUMBER. Order
479 - * device and link configurations such that the host always
480 + * DIPM is enabled only for MIN_POWER and FIRMWARE_DEFAULT as some
481 + * devices misbehave when the host NACKs transition to SLUMBER.
482 + * Order device and link configurations such that the host always
483 * allows DIPM requests.
485 ata_for_each_dev(dev, link, ENABLED) {
486 @@ -3581,10 +3581,13 @@ static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
487 if (ap && ap->slave_link)
488 ap->slave_link->lpm_policy = policy;
490 - /* host config updated, enable DIPM if transitioning to MIN_POWER */
491 + /* host config updated, enable DIPM if transitioning to MIN_POWER or
492 + * FIRMWARE_DEFAULT when enabled by firmware
494 ata_for_each_dev(dev, link, ENABLED) {
495 - if (policy == ATA_LPM_MIN_POWER && !no_dipm &&
496 - ata_id_has_dipm(dev->id)) {
497 + if ((policy == ATA_LPM_MIN_POWER && !no_dipm &&
498 + ata_id_has_dipm(dev->id)) ||
499 + (policy == ATA_LPM_FIRMWARE_DEFAULTS && dev->init_dipm)) {
500 err_mask = ata_dev_set_feature(dev,
501 SETFEATURES_SATA_ENABLE, SATA_DIPM);
502 if (err_mask && err_mask != AC_ERR_DEV) {
503 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
504 index 3131adc..f1ea052 100644
505 --- a/drivers/ata/libata-scsi.c
506 +++ b/drivers/ata/libata-scsi.c
507 @@ -107,6 +107,7 @@ static const u8 def_control_mpage[CONTROL_MPAGE_LEN] = {
508 static const char *ata_lpm_policy_names[] = {
509 [ATA_LPM_UNKNOWN] = "max_performance",
510 [ATA_LPM_MAX_POWER] = "max_performance",
511 + [ATA_LPM_FIRMWARE_DEFAULTS] = "firmware_defaults",
512 [ATA_LPM_MED_POWER] = "medium_power",
513 [ATA_LPM_MIN_POWER] = "min_power",
515 diff --git a/include/linux/libata.h b/include/linux/libata.h
516 index 31c149b..57b465d 100644
517 --- a/include/linux/libata.h
518 +++ b/include/linux/libata.h
519 @@ -507,6 +507,7 @@ enum ata_completion_errors {
520 enum ata_lpm_policy {
523 + ATA_LPM_FIRMWARE_DEFAULTS,
531 To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
532 the body of a message to majordomo@vger.kernel.org
533 More majordomo info at http://vger.kernel.org/majordomo-info.html
534 Please read the FAQ at http://www.tux.org/lkml/
535 From: Matthew Garrett <mjg59@coreos.com>
536 Date: Sat, 18 Apr 2015 08:26:36 -0700
537 Subject: [PATCH 3/3] libata: Change medium_power LPM policy to match Intel recommendations
539 Intel publish a document on designing energy efficient SATA devices at
540 http://www.intel.com/content/dam/doc/reference-guide/sata-devices-implementation-recommendations.pdf
541 which recommends that ALPE be set, ASPE be cleared and that DIPM be enabled
542 on the device. Right now we have no policy that matches that - medium_power
543 does not enable DIPM and min_power sets ASPE. Change medium_power to
544 implement these recommendations, with the addition of devslp state being
545 inherited from the initial configuration. With luck this will provide
546 reasonable power savings without causing the device breakages we
547 occasionally see with the min_power policy.
549 Signed-off-by: Matthew Garrett <mjg59@coreos.com>
551 drivers/ata/libahci.c | 1 +
552 drivers/ata/libata-core.c | 4 ----
553 drivers/ata/libata-eh.c | 10 ++++------
554 3 files changed, 5 insertions(+), 10 deletions(-)
556 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
557 index fabcff4..8efacb9 100644
558 --- a/drivers/ata/libahci.c
559 +++ b/drivers/ata/libahci.c
560 @@ -738,6 +738,7 @@ static int ahci_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
561 ahci_set_aggressive_devslp(ap, true);
563 case ATA_LPM_FIRMWARE_DEFAULTS:
564 + case ATA_LPM_MED_POWER:
565 ahci_set_aggressive_devslp(ap, ppriv->init_devslp);
568 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
569 index 0a78f01..99a7b8f 100644
570 --- a/drivers/ata/libata-core.c
571 +++ b/drivers/ata/libata-core.c
572 @@ -3687,10 +3687,6 @@ int sata_link_scr_lpm(struct ata_link *link, enum ata_lpm_policy policy,
575 case ATA_LPM_MED_POWER:
576 - /* allow LPM to PARTIAL */
577 - scontrol &= ~(0x1 << 8);
578 - scontrol |= (0x6 << 8);
580 case ATA_LPM_MIN_POWER:
581 if (ata_link_nr_enabled(link) > 0)
582 /* no restrictions on LPM transitions */
583 diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
584 index c36fa56..25d5f37 100644
585 --- a/drivers/ata/libata-eh.c
586 +++ b/drivers/ata/libata-eh.c
587 @@ -3519,8 +3519,6 @@ static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
591 - * DIPM is enabled only for MIN_POWER and FIRMWARE_DEFAULT as some
592 - * devices misbehave when the host NACKs transition to SLUMBER.
593 * Order device and link configurations such that the host always
594 * allows DIPM requests.
596 @@ -3540,7 +3538,7 @@ static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
597 hints &= ~ATA_LPM_HIPM;
599 /* disable DIPM before changing link config */
600 - if (policy != ATA_LPM_MIN_POWER && dipm) {
601 + if (policy < ATA_LPM_MED_POWER && dipm) {
602 err_mask = ata_dev_set_feature(dev,
603 SETFEATURES_SATA_DISABLE, SATA_DIPM);
604 if (err_mask && err_mask != AC_ERR_DEV) {
605 @@ -3581,11 +3579,11 @@ static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
606 if (ap && ap->slave_link)
607 ap->slave_link->lpm_policy = policy;
609 - /* host config updated, enable DIPM if transitioning to MIN_POWER or
610 - * FIRMWARE_DEFAULT when enabled by firmware
611 + /* host config updated, enable DIPM if transitioning to MED_POWER,
612 + * MIN_POWER or FIRMWARE_DEFAULT when enabled by firmware
614 ata_for_each_dev(dev, link, ENABLED) {
615 - if ((policy == ATA_LPM_MIN_POWER && !no_dipm &&
616 + if ((policy >= ATA_LPM_MED_POWER && !no_dipm &&
617 ata_id_has_dipm(dev->id)) ||
618 (policy == ATA_LPM_FIRMWARE_DEFAULTS && dev->init_dipm)) {
619 err_mask = ata_dev_set_feature(dev,
624 To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
625 the body of a message to majordomo@vger.kernel.org
626 More majordomo info at http://vger.kernel.org/majordomo-info.html
627 Please read the FAQ at http://www.tux.org/lkml/