25 #include <linux/slab.h>
27 #include <linux/export.h>
34 #include <scsi/scsi.h>
37 #include "../scsi_sas_internal.h"
38 #include "../scsi_transport_api.h"
119 goto qc_already_gone;
127 spin_unlock_irqrestore(ap->lock,
flags);
129 goto qc_already_gone;
144 if (!
link->sactive) {
147 link->eh_info.err_mask |= ac_err_mask(dev->
sata_dev.fis[2]);
152 ac = sas_to_ata_err(stat);
157 if (!
link->sactive) {
171 spin_unlock_irqrestore(ap->lock,
flags);
174 list_del_init(&task->
list);
184 unsigned int si, xfer = 0;
195 spin_unlock(ap->
lock);
216 if (ata_is_atapi(qc->
tf.protocol)) {
225 task->num_scatter = si;
232 qc->lldd_task = task;
236 task->ata_task.use_ncq = 1;
240 task->ata_task.dma_xfer = 1;
254 SAS_DPRINTK(
"lldd_execute_task returned: %d\n", ret);
281 static void sas_get_ata_command_set(
struct domain_device *dev);
299 SAS_DPRINTK(
"report phy sata to %016llx:0x%x returned "
307 sas_get_ata_command_set(dev);
340 sas_put_local_phy(phy);
355 return sas_ata_clear_pending(dev, ex_phy);
361 static int local_ata_check_ready(
struct ata_link *link)
367 if (i->
dft->lldd_ata_check_ready)
368 return i->
dft->lldd_ata_check_ready(dev);
379 const char *
fmt, ...)
392 r =
printk(
"%ssas: ata%u: %s: %pV",
393 level, ap->
print_id, dev_name(dev), &vaf);
400 static int sas_ata_hard_reset(
struct ata_link *link,
unsigned int *
class,
401 unsigned long deadline)
410 res = i->
dft->lldd_I_T_nexus_reset(dev);
415 sas_ata_printk(
KERN_DEBUG, dev,
"Unable to reset ata device?\n");
419 check_ready = local_ata_check_ready;
421 check_ready = smp_ata_check_ready;
422 sas_put_local_phy(phy);
425 if (ret && ret != -
EAGAIN)
426 sas_ata_printk(
KERN_ERR, dev,
"reset failed (errno=%d)\n", ret);
432 switch (dev->
sata_dev.command_set) {
449 static void sas_ata_internal_abort(
struct sas_task *task)
459 SAS_DPRINTK(
"%s: Task %p already finished.\n", __func__,
466 res = si->
dft->lldd_abort_task(task);
480 SAS_DPRINTK(
"%s: Task %p leaked.\n", __func__, task);
488 list_del_init(&task->
list);
512 sas_ata_internal_abort(task);
522 if (i->
dft->lldd_ata_set_dmamode)
523 i->
dft->lldd_ata_set_dmamode(dev);
526 static void sas_ata_sched_eh(
struct ata_port *ap)
536 spin_unlock_irqrestore(&ha->
lock, flags);
548 spin_unlock_irqrestore(&ha->
lock, flags);
553 .hardreset = sas_ata_hard_reset,
556 .post_internal_cmd = sas_ata_post_internal,
559 .qc_issue = sas_ata_qc_issue,
560 .qc_fill_rtf = sas_ata_qc_fill_rtf,
563 .set_dmamode = sas_ata_set_dmamode,
564 .sched_eh = sas_ata_sched_eh,
573 .port_ops = &sas_sata_ops
617 spin_unlock_irqrestore(q->queue_lock, flags);
629 static void sas_get_ata_command_set(
struct domain_device *dev)
647 (fis->
device & ~0x10) == 0))
655 (fis->
device & ~0x10) == 0))
669 (fis->
device & ~0x10) == 0))
681 if (!dev_is_sata(dev))
689 if (!dev_is_sata(dev))
697 if (ata_dev_disabled(sas_to_ata_dev(dev)))
698 sas_fail_probe(dev, __func__, -
ENODEV);
711 if (!dev_is_sata(dev))
726 WARN_ONCE(1,
"failed %s %s error: %d\n", func,
727 dev_name(&dev->
rphy->dev), rc);
731 if (ata_dev_disabled(sas_to_ata_dev(dev)))
732 sas_fail_probe(dev, func, -
ENODEV);
747 if (!dev_is_sata(dev))
755 ata_sas_port_async_suspend(sata->
ap, &sata->
pm_result);
759 if (sas_ata_flush_pm_eh(port, __func__))
772 if (!dev_is_sata(dev))
780 ata_sas_port_async_resume(sata->
ap, &sata->
pm_result);
784 if (sas_ata_flush_pm_eh(port, __func__))
803 sas_get_ata_command_set(dev);
804 sas_fill_in_rphy(dev, dev->
rphy);
820 sas_ata_printk(
KERN_DEBUG, dev,
"dev error handler\n");
842 for (i = 0; i < sas_ha->
num_phys; i++) {
848 if (!dev_is_sata(dev))
855 kref_get(&dev->
kref);
883 if (eh_dev && eh_dev != ddev)
889 if (!list_empty(&sata_q)) {
892 sas_ata_printk(
KERN_DEBUG, eh_dev,
"cmd error handler\n");
905 while (!list_empty(&sata_q))
906 list_del_init(sata_q.next);
917 if (!dev_is_sata(dev))
921 ehi = &ap->
link.eh_info;
927 spin_unlock_irqrestore(ap->
lock, flags);
935 if (!dev_is_sata(dev))