libata-eh.c (8990c1bc4be46473ad19bf2fa612ca57286f3df4) libata-eh.c (e5005b15c91f3362036067bde5210d5c78af2f0d)
1/*
2 * libata-eh.c - libata error handling
3 *
4 * Maintained by: Jeff Garzik <jgarzik@pobox.com>
5 * Please ALWAYS copy linux-ide@vger.kernel.org
6 * on emails.
7 *
8 * Copyright 2006 Tejun Heo <htejun@gmail.com>

--- 3261 unchanged lines hidden (view full) ---

3270 * 0 on success, -errno on failure.
3271 */
3272static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
3273 struct ata_device **r_failed_dev)
3274{
3275 struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL;
3276 struct ata_eh_context *ehc = &link->eh_context;
3277 struct ata_device *dev, *link_dev = NULL, *lpm_dev = NULL;
1/*
2 * libata-eh.c - libata error handling
3 *
4 * Maintained by: Jeff Garzik <jgarzik@pobox.com>
5 * Please ALWAYS copy linux-ide@vger.kernel.org
6 * on emails.
7 *
8 * Copyright 2006 Tejun Heo <htejun@gmail.com>

--- 3261 unchanged lines hidden (view full) ---

3270 * 0 on success, -errno on failure.
3271 */
3272static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
3273 struct ata_device **r_failed_dev)
3274{
3275 struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL;
3276 struct ata_eh_context *ehc = &link->eh_context;
3277 struct ata_device *dev, *link_dev = NULL, *lpm_dev = NULL;
3278 enum ata_lpm_policy old_policy = link->lpm_policy;
3278 unsigned int hints = ATA_LPM_EMPTY | ATA_LPM_HIPM;
3279 unsigned int err_mask;
3280 int rc;
3281
3282 /* if the link or host doesn't do LPM, noop */
3283 if ((link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm))
3284 return 0;
3285

--- 47 unchanged lines hidden (view full) ---

3333 if (rc == -EOPNOTSUPP) {
3334 link->flags |= ATA_LFLAG_NO_LPM;
3335 return 0;
3336 }
3337 dev = lpm_dev ? lpm_dev : link_dev;
3338 goto fail;
3339 }
3340
3279 unsigned int hints = ATA_LPM_EMPTY | ATA_LPM_HIPM;
3280 unsigned int err_mask;
3281 int rc;
3282
3283 /* if the link or host doesn't do LPM, noop */
3284 if ((link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm))
3285 return 0;
3286

--- 47 unchanged lines hidden (view full) ---

3334 if (rc == -EOPNOTSUPP) {
3335 link->flags |= ATA_LFLAG_NO_LPM;
3336 return 0;
3337 }
3338 dev = lpm_dev ? lpm_dev : link_dev;
3339 goto fail;
3340 }
3341
3342 /*
3343 * Low level driver acked the transition. Issue DIPM command
3344 * with the new policy set.
3345 */
3346 link->lpm_policy = policy;
3347 if (ap && ap->slave_link)
3348 ap->slave_link->lpm_policy = policy;
3349
3341 /* host config updated, enable DIPM if transitioning to MIN_POWER */
3342 ata_for_each_dev(dev, link, ENABLED) {
3343 if (policy == ATA_LPM_MIN_POWER && ata_id_has_dipm(dev->id)) {
3344 err_mask = ata_dev_set_feature(dev,
3345 SETFEATURES_SATA_ENABLE, SATA_DIPM);
3346 if (err_mask && err_mask != AC_ERR_DEV) {
3347 ata_dev_printk(dev, KERN_WARNING,
3348 "failed to enable DIPM, Emask 0x%x\n",
3349 err_mask);
3350 rc = -EIO;
3351 goto fail;
3352 }
3353 }
3354 }
3355
3350 /* host config updated, enable DIPM if transitioning to MIN_POWER */
3351 ata_for_each_dev(dev, link, ENABLED) {
3352 if (policy == ATA_LPM_MIN_POWER && ata_id_has_dipm(dev->id)) {
3353 err_mask = ata_dev_set_feature(dev,
3354 SETFEATURES_SATA_ENABLE, SATA_DIPM);
3355 if (err_mask && err_mask != AC_ERR_DEV) {
3356 ata_dev_printk(dev, KERN_WARNING,
3357 "failed to enable DIPM, Emask 0x%x\n",
3358 err_mask);
3359 rc = -EIO;
3360 goto fail;
3361 }
3362 }
3363 }
3364
3356 link->lpm_policy = policy;
3357 if (ap && ap->slave_link)
3358 ap->slave_link->lpm_policy = policy;
3359 return 0;
3360
3361fail:
3365 return 0;
3366
3367fail:
3368 /* restore the old policy */
3369 link->lpm_policy = old_policy;
3370 if (ap && ap->slave_link)
3371 ap->slave_link->lpm_policy = old_policy;
3372
3362 /* if no device or only one more chance is left, disable LPM */
3363 if (!dev || ehc->tries[dev->devno] <= 2) {
3364 ata_link_printk(link, KERN_WARNING,
3365 "disabling LPM on the link\n");
3366 link->flags |= ATA_LFLAG_NO_LPM;
3367 }
3368 if (r_failed_dev)
3369 *r_failed_dev = dev;

--- 626 unchanged lines hidden ---
3373 /* if no device or only one more chance is left, disable LPM */
3374 if (!dev || ehc->tries[dev->devno] <= 2) {
3375 ata_link_printk(link, KERN_WARNING,
3376 "disabling LPM on the link\n");
3377 link->flags |= ATA_LFLAG_NO_LPM;
3378 }
3379 if (r_failed_dev)
3380 *r_failed_dev = dev;

--- 626 unchanged lines hidden ---