diff options
Diffstat (limited to 'drivers/scsi/libsas/sas_ata.c')
-rw-r--r-- | drivers/scsi/libsas/sas_ata.c | 91 |
1 files changed, 87 insertions, 4 deletions
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index a59fcdc8fd63..bdb81cda8401 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c | |||
@@ -580,10 +580,7 @@ int sas_ata_init(struct domain_device *found_dev) | |||
580 | struct ata_port *ap; | 580 | struct ata_port *ap; |
581 | int rc; | 581 | int rc; |
582 | 582 | ||
583 | ata_host_init(&found_dev->sata_dev.ata_host, | 583 | ata_host_init(&found_dev->sata_dev.ata_host, ha->dev, &sas_sata_ops); |
584 | ha->dev, | ||
585 | sata_port_info.flags, | ||
586 | &sas_sata_ops); | ||
587 | ap = ata_sas_port_alloc(&found_dev->sata_dev.ata_host, | 584 | ap = ata_sas_port_alloc(&found_dev->sata_dev.ata_host, |
588 | &sata_port_info, | 585 | &sata_port_info, |
589 | shost); | 586 | shost); |
@@ -700,6 +697,92 @@ void sas_probe_sata(struct asd_sas_port *port) | |||
700 | if (ata_dev_disabled(sas_to_ata_dev(dev))) | 697 | if (ata_dev_disabled(sas_to_ata_dev(dev))) |
701 | sas_fail_probe(dev, __func__, -ENODEV); | 698 | sas_fail_probe(dev, __func__, -ENODEV); |
702 | } | 699 | } |
700 | |||
701 | } | ||
702 | |||
703 | static bool sas_ata_flush_pm_eh(struct asd_sas_port *port, const char *func) | ||
704 | { | ||
705 | struct domain_device *dev, *n; | ||
706 | bool retry = false; | ||
707 | |||
708 | list_for_each_entry_safe(dev, n, &port->dev_list, dev_list_node) { | ||
709 | int rc; | ||
710 | |||
711 | if (!dev_is_sata(dev)) | ||
712 | continue; | ||
713 | |||
714 | sas_ata_wait_eh(dev); | ||
715 | rc = dev->sata_dev.pm_result; | ||
716 | if (rc == -EAGAIN) | ||
717 | retry = true; | ||
718 | else if (rc) { | ||
719 | /* since we don't have a | ||
720 | * ->port_{suspend|resume} routine in our | ||
721 | * ata_port ops, and no entanglements with | ||
722 | * acpi, suspend should just be mechanical trip | ||
723 | * through eh, catch cases where these | ||
724 | * assumptions are invalidated | ||
725 | */ | ||
726 | WARN_ONCE(1, "failed %s %s error: %d\n", func, | ||
727 | dev_name(&dev->rphy->dev), rc); | ||
728 | } | ||
729 | |||
730 | /* if libata failed to power manage the device, tear it down */ | ||
731 | if (ata_dev_disabled(sas_to_ata_dev(dev))) | ||
732 | sas_fail_probe(dev, func, -ENODEV); | ||
733 | } | ||
734 | |||
735 | return retry; | ||
736 | } | ||
737 | |||
738 | void sas_suspend_sata(struct asd_sas_port *port) | ||
739 | { | ||
740 | struct domain_device *dev; | ||
741 | |||
742 | retry: | ||
743 | mutex_lock(&port->ha->disco_mutex); | ||
744 | list_for_each_entry(dev, &port->dev_list, dev_list_node) { | ||
745 | struct sata_device *sata; | ||
746 | |||
747 | if (!dev_is_sata(dev)) | ||
748 | continue; | ||
749 | |||
750 | sata = &dev->sata_dev; | ||
751 | if (sata->ap->pm_mesg.event == PM_EVENT_SUSPEND) | ||
752 | continue; | ||
753 | |||
754 | sata->pm_result = -EIO; | ||
755 | ata_sas_port_async_suspend(sata->ap, &sata->pm_result); | ||
756 | } | ||
757 | mutex_unlock(&port->ha->disco_mutex); | ||
758 | |||
759 | if (sas_ata_flush_pm_eh(port, __func__)) | ||
760 | goto retry; | ||
761 | } | ||
762 | |||
763 | void sas_resume_sata(struct asd_sas_port *port) | ||
764 | { | ||
765 | struct domain_device *dev; | ||
766 | |||
767 | retry: | ||
768 | mutex_lock(&port->ha->disco_mutex); | ||
769 | list_for_each_entry(dev, &port->dev_list, dev_list_node) { | ||
770 | struct sata_device *sata; | ||
771 | |||
772 | if (!dev_is_sata(dev)) | ||
773 | continue; | ||
774 | |||
775 | sata = &dev->sata_dev; | ||
776 | if (sata->ap->pm_mesg.event == PM_EVENT_ON) | ||
777 | continue; | ||
778 | |||
779 | sata->pm_result = -EIO; | ||
780 | ata_sas_port_async_resume(sata->ap, &sata->pm_result); | ||
781 | } | ||
782 | mutex_unlock(&port->ha->disco_mutex); | ||
783 | |||
784 | if (sas_ata_flush_pm_eh(port, __func__)) | ||
785 | goto retry; | ||
703 | } | 786 | } |
704 | 787 | ||
705 | /** | 788 | /** |