Lines Matching +full:sierra +full:- +full:phy
2 * PMC-Sierra PM8001/8081/8088/8089 SAS/SATA based host adapters driver
4 * Copyright (c) 2008-2009 USI Co., Ltd.
18 * 3. Neither the names of the above-listed copyright holders nor the names
46 * pm8001_find_tag - from sas task to find out tag that belongs to this task
52 if (task->lldd_task) { in pm8001_find_tag()
54 ccb = task->lldd_task; in pm8001_find_tag()
55 *tag = ccb->ccb_tag; in pm8001_find_tag()
62 * pm8001_tag_free - free the no more needed tag
68 void *bitmap = pm8001_ha->rsvd_tags; in pm8001_tag_free()
74 spin_lock_irqsave(&pm8001_ha->bitmap_lock, flags); in pm8001_tag_free()
76 spin_unlock_irqrestore(&pm8001_ha->bitmap_lock, flags); in pm8001_tag_free()
80 * pm8001_tag_alloc - allocate a empty tag for task used.
86 void *bitmap = pm8001_ha->rsvd_tags; in pm8001_tag_alloc()
90 spin_lock_irqsave(&pm8001_ha->bitmap_lock, flags); in pm8001_tag_alloc()
93 spin_unlock_irqrestore(&pm8001_ha->bitmap_lock, flags); in pm8001_tag_alloc()
94 return -SAS_QUEUE_FULL; in pm8001_tag_alloc()
97 spin_unlock_irqrestore(&pm8001_ha->bitmap_lock, flags); in pm8001_tag_alloc()
105 * pm8001_mem_alloc - allocate memory for pm8001.
123 align_offset = (dma_addr_t)align - 1; in pm8001_mem_alloc()
124 mem_virt_alloc = dma_alloc_coherent(&pdev->dev, mem_size + align, in pm8001_mem_alloc()
127 return -ENOMEM; in pm8001_mem_alloc()
130 *virt_addr = (void *)mem_virt_alloc + phys_align - *pphys_addr; in pm8001_mem_alloc()
137 * pm8001_find_ha_by_dev - from domain device which come from sas layer to
144 struct sas_ha_struct *sha = dev->port->ha; in pm8001_find_ha_by_dev()
145 struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; in pm8001_find_ha_by_dev()
150 * pm8001_phy_control - this function should be registered to
152 * control the HBA phy rather than other expander phy if you want control
153 * other phy, you should use SMP command.
154 * @sas_phy: which phy in HBA phys.
161 int rc = 0, phy_id = sas_phy->id; in pm8001_phy_control()
164 struct pm8001_phy *phy; in pm8001_phy_control() local
167 pm8001_ha = sas_phy->ha->lldd_ha; in pm8001_phy_control()
168 phy = &pm8001_ha->phy[phy_id]; in pm8001_phy_control()
170 if (PM8001_CHIP_DISP->fatal_errors(pm8001_ha)) { in pm8001_phy_control()
176 "Phy control failed due to fatal errors\n"); in pm8001_phy_control()
177 return -EFAULT; in pm8001_phy_control()
183 if (rates->minimum_linkrate) { in pm8001_phy_control()
184 pm8001_ha->phy[phy_id].minimum_linkrate = in pm8001_phy_control()
185 rates->minimum_linkrate; in pm8001_phy_control()
187 if (rates->maximum_linkrate) { in pm8001_phy_control()
188 pm8001_ha->phy[phy_id].maximum_linkrate = in pm8001_phy_control()
189 rates->maximum_linkrate; in pm8001_phy_control()
191 if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_DISABLE) { in pm8001_phy_control()
192 pm8001_ha->phy[phy_id].enable_completion = &completion; in pm8001_phy_control()
193 PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id); in pm8001_phy_control()
196 PM8001_CHIP_DISP->phy_ctl_req(pm8001_ha, phy_id, in pm8001_phy_control()
200 if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_DISABLE) { in pm8001_phy_control()
201 pm8001_ha->phy[phy_id].enable_completion = &completion; in pm8001_phy_control()
202 PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id); in pm8001_phy_control()
205 PM8001_CHIP_DISP->phy_ctl_req(pm8001_ha, phy_id, in pm8001_phy_control()
209 if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_DISABLE) { in pm8001_phy_control()
210 pm8001_ha->phy[phy_id].enable_completion = &completion; in pm8001_phy_control()
211 PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id); in pm8001_phy_control()
214 PM8001_CHIP_DISP->phy_ctl_req(pm8001_ha, phy_id, in pm8001_phy_control()
218 PM8001_CHIP_DISP->phy_ctl_req(pm8001_ha, phy_id, in pm8001_phy_control()
222 if (pm8001_ha->chip_id != chip_8001) { in pm8001_phy_control()
223 if (pm8001_ha->phy[phy_id].phy_state == in pm8001_phy_control()
225 sas_phy_disconnected(&phy->sas_phy); in pm8001_phy_control()
226 sas_notify_phy_event(&phy->sas_phy, in pm8001_phy_control()
228 phy->phy_attached = 0; in pm8001_phy_control()
231 if (pm8001_ha->phy[phy_id].phy_state == in pm8001_phy_control()
233 sas_phy_disconnected(&phy->sas_phy); in pm8001_phy_control()
234 sas_notify_phy_event(&phy->sas_phy, in pm8001_phy_control()
236 phy->phy_attached = 0; in pm8001_phy_control()
239 PM8001_CHIP_DISP->phy_stop_req(pm8001_ha, phy_id); in pm8001_phy_control()
242 spin_lock_irqsave(&pm8001_ha->lock, flags); in pm8001_phy_control()
243 if (pm8001_ha->chip_id == chip_8001) { in pm8001_phy_control()
244 if (-1 == pm8001_bar4_shift(pm8001_ha, in pm8001_phy_control()
246 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_phy_control()
247 return -EINVAL; in pm8001_phy_control()
251 struct sas_phy *phy = sas_phy->phy; in pm8001_phy_control() local
252 u32 __iomem *qp = pm8001_ha->io_mem[2].memvirtaddr in pm8001_phy_control()
255 phy->invalid_dword_count = readl(qp); in pm8001_phy_control()
256 phy->running_disparity_error_count = readl(&qp[1]); in pm8001_phy_control()
257 phy->loss_of_dword_sync_count = readl(&qp[3]); in pm8001_phy_control()
258 phy->phy_reset_problem_count = readl(&qp[4]); in pm8001_phy_control()
260 if (pm8001_ha->chip_id == chip_8001) in pm8001_phy_control()
262 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_phy_control()
266 rc = -EOPNOTSUPP; in pm8001_phy_control()
273 * pm8001_scan_start - we should enable all HBA phys by sending the phy_start
283 pm8001_ha = sha->lldd_ha; in pm8001_scan_start()
285 if (pm8001_ha->chip_id == chip_8001) in pm8001_scan_start()
286 PM8001_CHIP_DISP->sas_re_init_req(pm8001_ha); in pm8001_scan_start()
287 for (i = 0; i < pm8001_ha->chip->n_phy; ++i) { in pm8001_scan_start()
288 pm8001_ha->phy[i].enable_completion = &completion; in pm8001_scan_start()
289 PM8001_CHIP_DISP->phy_start_req(pm8001_ha, i); in pm8001_scan_start()
299 /* give the phy enabling interrupt event time to come in (1s in pm8001_scan_finished()
309 * pm8001_task_prep_smp - the dispatcher function, prepare data for smp task
316 return PM8001_CHIP_DISP->smp_req(pm8001_ha, ccb); in pm8001_task_prep_smp()
321 struct ata_queued_cmd *qc = task->uldd_task; in pm8001_get_ncq_tag()
323 if (qc && ata_is_ncq(qc->tf.protocol)) { in pm8001_get_ncq_tag()
324 *tag = qc->tag; in pm8001_get_ncq_tag()
332 * pm8001_task_prep_ata - the dispatcher function, prepare data for sata task
339 return PM8001_CHIP_DISP->sata_req(pm8001_ha, ccb); in pm8001_task_prep_ata()
343 * pm8001_task_prep_internal_abort - the dispatcher function, prepare data
351 return PM8001_CHIP_DISP->task_abort(pm8001_ha, ccb); in pm8001_task_prep_internal_abort()
355 * pm8001_task_prep_ssp_tm - the dispatcher function, prepare task management data
363 return PM8001_CHIP_DISP->ssp_tm_req(pm8001_ha, ccb, tmf); in pm8001_task_prep_ssp_tm()
367 * pm8001_task_prep_ssp - the dispatcher function, prepare ssp data for ssp task
374 return PM8001_CHIP_DISP->ssp_io_req(pm8001_ha, ccb); in pm8001_task_prep_ssp()
380 struct domain_device *pdev = dev->parent; in sas_find_local_port_id()
384 return dev->port->id; in sas_find_local_port_id()
386 struct domain_device *pdev_p = pdev->parent; in sas_find_local_port_id()
388 return pdev->port->id; in sas_find_local_port_id()
389 pdev = pdev->parent; in sas_find_local_port_id()
395 ((!pm8001_dev || (pm8001_dev->dev_type == SAS_PHY_UNUSED)))
401 struct sas_task *task = ccb->task; in pm8001_deliver_command()
402 enum sas_protocol task_proto = task->task_proto; in pm8001_deliver_command()
403 struct sas_tmf_task *tmf = task->tmf; in pm8001_deliver_command()
419 dev_err(pm8001_ha->dev, "unknown sas_task proto: 0x%x\n", in pm8001_deliver_command()
423 return -EINVAL; in pm8001_deliver_command()
427 * pm8001_queue_command - register for upper layer used, all IO commands sent
434 struct task_status_struct *ts = &task->task_status; in pm8001_queue_command()
435 enum sas_protocol task_proto = task->task_proto; in pm8001_queue_command()
436 struct domain_device *dev = task->dev; in pm8001_queue_command()
437 struct pm8001_device *pm8001_dev = dev->lldd_dev; in pm8001_queue_command()
446 if (!internal_abort && !dev->port) { in pm8001_queue_command()
447 ts->resp = SAS_TASK_UNDELIVERED; in pm8001_queue_command()
448 ts->stat = SAS_PHY_DOWN; in pm8001_queue_command()
449 if (dev->dev_type != SAS_SATA_DEV) in pm8001_queue_command()
450 task->task_done(task); in pm8001_queue_command()
455 if (pm8001_ha->controller_fatal_error) { in pm8001_queue_command()
456 ts->resp = SAS_TASK_UNDELIVERED; in pm8001_queue_command()
457 task->task_done(task); in pm8001_queue_command()
463 spin_lock_irqsave(&pm8001_ha->lock, flags); in pm8001_queue_command()
465 pm8001_dev = dev->lldd_dev; in pm8001_queue_command()
466 port = &pm8001_ha->port[sas_find_local_port_id(dev)]; in pm8001_queue_command()
469 (DEV_IS_GONE(pm8001_dev) || !port->port_attached)) { in pm8001_queue_command()
470 ts->resp = SAS_TASK_UNDELIVERED; in pm8001_queue_command()
471 ts->stat = SAS_PHY_DOWN; in pm8001_queue_command()
473 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_queue_command()
474 task->task_done(task); in pm8001_queue_command()
475 spin_lock_irqsave(&pm8001_ha->lock, flags); in pm8001_queue_command()
477 task->task_done(task); in pm8001_queue_command()
479 rc = -ENODEV; in pm8001_queue_command()
485 rc = -SAS_QUEUE_FULL; in pm8001_queue_command()
490 if (task->num_scatter) { in pm8001_queue_command()
491 n_elem = dma_map_sg(pm8001_ha->dev, task->scatter, in pm8001_queue_command()
492 task->num_scatter, task->data_dir); in pm8001_queue_command()
494 rc = -ENOMEM; in pm8001_queue_command()
499 n_elem = task->num_scatter; in pm8001_queue_command()
502 task->lldd_task = ccb; in pm8001_queue_command()
503 ccb->n_elem = n_elem; in pm8001_queue_command()
505 atomic_inc(&pm8001_dev->running_req); in pm8001_queue_command()
509 atomic_dec(&pm8001_dev->running_req); in pm8001_queue_command()
511 dma_unmap_sg(pm8001_ha->dev, task->scatter, in pm8001_queue_command()
512 task->num_scatter, task->data_dir); in pm8001_queue_command()
520 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_queue_command()
526 * pm8001_ccb_task_free - free the sg for ssp and smp command, free the ccb.
533 struct sas_task *task = ccb->task; in pm8001_ccb_task_free()
540 if (!sas_protocol_ata(task->task_proto) && ccb->n_elem) in pm8001_ccb_task_free()
541 dma_unmap_sg(pm8001_ha->dev, task->scatter, in pm8001_ccb_task_free()
542 task->num_scatter, task->data_dir); in pm8001_ccb_task_free()
544 switch (task->task_proto) { in pm8001_ccb_task_free()
546 dma_unmap_sg(pm8001_ha->dev, &task->smp_task.smp_resp, 1, in pm8001_ccb_task_free()
548 dma_unmap_sg(pm8001_ha->dev, &task->smp_task.smp_req, 1, in pm8001_ccb_task_free()
560 if (sas_protocol_ata(task->task_proto)) { in pm8001_ccb_task_free()
562 qc = task->uldd_task; in pm8001_ccb_task_free()
563 pm8001_dev = ccb->device; in pm8001_ccb_task_free()
564 trace_pm80xx_request_complete(pm8001_ha->id, in pm8001_ccb_task_free()
565 pm8001_dev ? pm8001_dev->attached_phy : PM8001_MAX_PHYS, in pm8001_ccb_task_free()
566 ccb->ccb_tag, 0 /* ctlr_opcode not known */, in pm8001_ccb_task_free()
567 qc ? qc->tf.command : 0, // ata opcode in pm8001_ccb_task_free()
568 pm8001_dev ? atomic_read(&pm8001_dev->running_req) : -1); in pm8001_ccb_task_free()
571 task->lldd_task = NULL; in pm8001_ccb_task_free()
576 * pm8001_alloc_dev - find a empty pm8001_device
583 if (pm8001_ha->devices[dev].dev_type == SAS_PHY_UNUSED) { in pm8001_alloc_dev()
584 pm8001_ha->devices[dev].id = dev; in pm8001_alloc_dev()
585 return &pm8001_ha->devices[dev]; in pm8001_alloc_dev()
596 * pm8001_find_dev - find a matching pm8001_device
605 if (pm8001_ha->devices[dev].device_id == device_id) in pm8001_find_dev()
606 return &pm8001_ha->devices[dev]; in pm8001_find_dev()
616 u32 id = pm8001_dev->id; in pm8001_free_dev()
618 pm8001_dev->id = id; in pm8001_free_dev()
619 pm8001_dev->dev_type = SAS_PHY_UNUSED; in pm8001_free_dev()
620 pm8001_dev->device_id = PM8001_MAX_DEVICES; in pm8001_free_dev()
621 pm8001_dev->sas_device = NULL; in pm8001_free_dev()
625 * pm8001_dev_found_notify - libsas notify a device is found.
641 struct domain_device *parent_dev = dev->parent; in pm8001_dev_found_notify()
646 spin_lock_irqsave(&pm8001_ha->lock, flags); in pm8001_dev_found_notify()
650 res = -1; in pm8001_dev_found_notify()
653 pm8001_device->sas_device = dev; in pm8001_dev_found_notify()
654 dev->lldd_dev = pm8001_device; in pm8001_dev_found_notify()
655 pm8001_device->dev_type = dev->dev_type; in pm8001_dev_found_notify()
656 pm8001_device->dcompletion = &completion; in pm8001_dev_found_notify()
657 if (parent_dev && dev_is_expander(parent_dev->dev_type)) { in pm8001_dev_found_notify()
660 phy_id = sas_find_attached_phy_id(&parent_dev->ex_dev, dev); in pm8001_dev_found_notify()
664 SAS_ADDR(dev->sas_addr), in pm8001_dev_found_notify()
665 SAS_ADDR(parent_dev->sas_addr)); in pm8001_dev_found_notify()
668 pm8001_device->attached_phy = phy_id; in pm8001_dev_found_notify()
671 if (dev->dev_type == SAS_SATA_DEV) { in pm8001_dev_found_notify()
672 pm8001_device->attached_phy = in pm8001_dev_found_notify()
673 dev->rphy->identify.phy_identifier; in pm8001_dev_found_notify()
678 PM8001_CHIP_DISP->reg_dev_req(pm8001_ha, pm8001_device, flag); in pm8001_dev_found_notify()
679 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_dev_found_notify()
681 if (dev->dev_type == SAS_END_DEVICE) in pm8001_dev_found_notify()
683 pm8001_ha->flags = PM8001F_RUN_TIME; in pm8001_dev_found_notify()
686 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_dev_found_notify()
698 * pm8001_dev_gone_notify - see the comments for "pm8001_dev_found_notify"
705 struct pm8001_device *pm8001_dev = dev->lldd_dev; in pm8001_dev_gone_notify()
708 spin_lock_irqsave(&pm8001_ha->lock, flags); in pm8001_dev_gone_notify()
710 u32 device_id = pm8001_dev->device_id; in pm8001_dev_gone_notify()
713 pm8001_dev->device_id, pm8001_dev->dev_type); in pm8001_dev_gone_notify()
714 if (atomic_read(&pm8001_dev->running_req)) { in pm8001_dev_gone_notify()
715 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_dev_gone_notify()
717 while (atomic_read(&pm8001_dev->running_req)) in pm8001_dev_gone_notify()
719 spin_lock_irqsave(&pm8001_ha->lock, flags); in pm8001_dev_gone_notify()
721 PM8001_CHIP_DISP->dereg_dev_req(pm8001_ha, device_id); in pm8001_dev_gone_notify()
726 dev->lldd_dev = NULL; in pm8001_dev_gone_notify()
727 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_dev_gone_notify()
747 spin_lock_irqsave(&pm8001_ha->lock, flags); in pm8001_open_reject_retry()
754 struct pm8001_ccb_info *ccb = &pm8001_ha->ccb_info[i]; in pm8001_open_reject_retry()
756 if (ccb->ccb_tag == PM8001_INVALID_TAG) in pm8001_open_reject_retry()
759 pm8001_dev = ccb->device; in pm8001_open_reject_retry()
760 if (!pm8001_dev || (pm8001_dev->dev_type == SAS_PHY_UNUSED)) in pm8001_open_reject_retry()
764 - (uintptr_t)&pm8001_ha->devices; in pm8001_open_reject_retry()
770 task = ccb->task; in pm8001_open_reject_retry()
771 if (!task || !task->task_done) in pm8001_open_reject_retry()
775 ts = &task->task_status; in pm8001_open_reject_retry()
776 ts->resp = SAS_TASK_COMPLETE; in pm8001_open_reject_retry()
778 ts->stat = SAS_OPEN_REJECT; in pm8001_open_reject_retry()
779 ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; in pm8001_open_reject_retry()
781 atomic_dec(&pm8001_dev->running_req); in pm8001_open_reject_retry()
782 spin_lock_irqsave(&task->task_state_lock, flags1); in pm8001_open_reject_retry()
783 task->task_state_flags &= ~SAS_TASK_STATE_PENDING; in pm8001_open_reject_retry()
784 task->task_state_flags |= SAS_TASK_STATE_DONE; in pm8001_open_reject_retry()
785 if (unlikely((task->task_state_flags in pm8001_open_reject_retry()
787 spin_unlock_irqrestore(&task->task_state_lock, in pm8001_open_reject_retry()
791 spin_unlock_irqrestore(&task->task_state_lock, in pm8001_open_reject_retry()
795 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_open_reject_retry()
796 task->task_done(task); in pm8001_open_reject_retry()
797 spin_lock_irqsave(&pm8001_ha->lock, flags); in pm8001_open_reject_retry()
801 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_open_reject_retry()
805 * pm8001_I_T_nexus_reset() - reset the initiator/target connection
816 struct sas_phy *phy; in pm8001_I_T_nexus_reset() local
818 if (!dev || !dev->lldd_dev) in pm8001_I_T_nexus_reset()
819 return -ENODEV; in pm8001_I_T_nexus_reset()
821 pm8001_dev = dev->lldd_dev; in pm8001_I_T_nexus_reset()
823 phy = sas_get_local_phy(dev); in pm8001_I_T_nexus_reset()
826 if (scsi_is_sas_phy_local(phy)) { in pm8001_I_T_nexus_reset()
830 rc = sas_phy_reset(phy, 1); in pm8001_I_T_nexus_reset()
833 "phy reset failed for device %x\n" in pm8001_I_T_nexus_reset()
834 "with rc %d\n", pm8001_dev->device_id, rc); in pm8001_I_T_nexus_reset()
842 "with rc %d\n", pm8001_dev->device_id, rc); in pm8001_I_T_nexus_reset()
846 rc = sas_phy_reset(phy, 1); in pm8001_I_T_nexus_reset()
850 pm8001_dev->device_id, rc); in pm8001_I_T_nexus_reset()
852 sas_put_local_phy(phy); in pm8001_I_T_nexus_reset()
865 struct sas_phy *phy; in pm8001_I_T_nexus_event_handler() local
867 if (!dev || !dev->lldd_dev) in pm8001_I_T_nexus_event_handler()
868 return -1; in pm8001_I_T_nexus_event_handler()
870 pm8001_dev = dev->lldd_dev; in pm8001_I_T_nexus_event_handler()
875 phy = sas_get_local_phy(dev); in pm8001_I_T_nexus_event_handler()
879 if (scsi_is_sas_phy_local(phy)) { in pm8001_I_T_nexus_event_handler()
891 /*send phy reset to hard reset target */ in pm8001_I_T_nexus_event_handler()
892 rc = sas_phy_reset(phy, 1); in pm8001_I_T_nexus_event_handler()
894 pm8001_dev->setds_completion = &completion_setstate; in pm8001_I_T_nexus_event_handler()
906 /*send phy reset to hard reset target */ in pm8001_I_T_nexus_event_handler()
907 rc = sas_phy_reset(phy, 1); in pm8001_I_T_nexus_event_handler()
911 pm8001_dev->device_id, rc); in pm8001_I_T_nexus_event_handler()
913 sas_put_local_phy(phy); in pm8001_I_T_nexus_event_handler()
917 /* mandatory SAM-3, the task reset the specified LUN*/
921 struct pm8001_device *pm8001_dev = dev->lldd_dev; in pm8001_lu_reset()
925 if (PM8001_CHIP_DISP->fatal_errors(pm8001_ha)) { in pm8001_lu_reset()
936 struct sas_phy *phy = sas_get_local_phy(dev); in pm8001_lu_reset() local
938 rc = sas_phy_reset(phy, 1); in pm8001_lu_reset()
939 sas_put_local_phy(phy); in pm8001_lu_reset()
940 pm8001_dev->setds_completion = &completion_setstate; in pm8001_lu_reset()
941 rc = PM8001_CHIP_DISP->set_dev_state_req(pm8001_ha, in pm8001_lu_reset()
947 /* If failed, fall-through I_T_Nexus reset */ in pm8001_lu_reset()
949 pm8001_dev->device_id, rc); in pm8001_lu_reset()
953 /* optional SAM-3 */
958 if (unlikely(!task || !task->lldd_task || !task->dev)) in pm8001_query_task()
961 if (task->task_proto & SAS_PROTOCOL_SSP) { in pm8001_query_task()
962 struct scsi_cmnd *cmnd = task->uldd_task; in pm8001_query_task()
963 struct domain_device *dev = task->dev; in pm8001_query_task()
972 pm8001_dbg(pm8001_ha, EH, "Query:[%16ph]\n", cmnd->cmnd); in pm8001_query_task()
981 /* The task is not in Lun or failed, reset the phy */ in pm8001_query_task()
985 "The task is not in Lun or failed, reset the phy\n"); in pm8001_query_task()
993 /* mandatory SAM-3, still need free task/ccb info, abort the specified task */
996 struct pm8001_ccb_info *ccb = task->lldd_task; in pm8001_abort_task()
1006 if (!task->lldd_task || !task->dev) in pm8001_abort_task()
1009 dev = task->dev; in pm8001_abort_task()
1010 pm8001_dev = dev->lldd_dev; in pm8001_abort_task()
1012 phy_id = pm8001_dev->attached_phy; in pm8001_abort_task()
1014 if (PM8001_CHIP_DISP->fatal_errors(pm8001_ha)) { in pm8001_abort_task()
1025 spin_lock_irqsave(&task->task_state_lock, flags); in pm8001_abort_task()
1026 if (task->task_state_flags & SAS_TASK_STATE_DONE) { in pm8001_abort_task()
1027 spin_unlock_irqrestore(&task->task_state_lock, flags); in pm8001_abort_task()
1030 task->task_state_flags |= SAS_TASK_STATE_ABORTED; in pm8001_abort_task()
1031 if (task->slow_task == NULL) { in pm8001_abort_task()
1033 task->slow_task = &slow_task; in pm8001_abort_task()
1035 spin_unlock_irqrestore(&task->task_state_lock, flags); in pm8001_abort_task()
1036 if (task->task_proto & SAS_PROTOCOL_SSP) { in pm8001_abort_task()
1039 } else if (task->task_proto & SAS_PROTOCOL_SATA || in pm8001_abort_task()
1040 task->task_proto & SAS_PROTOCOL_STP) { in pm8001_abort_task()
1041 if (pm8001_ha->chip_id == chip_8006) { in pm8001_abort_task()
1044 struct pm8001_phy *phy = pm8001_ha->phy + phy_id; in pm8001_abort_task() local
1045 port_id = phy->port->port_id; in pm8001_abort_task()
1048 pm8001_dev->setds_completion = &completion; in pm8001_abort_task()
1049 PM8001_CHIP_DISP->set_dev_state_req(pm8001_ha, in pm8001_abort_task()
1053 /* 2. Send Phy Control Hard Reset */ in pm8001_abort_task()
1055 phy->port_reset_status = PORT_RESET_TMO; in pm8001_abort_task()
1056 phy->reset_success = false; in pm8001_abort_task()
1057 phy->enable_completion = &completion; in pm8001_abort_task()
1058 phy->reset_completion = &completion_reset; in pm8001_abort_task()
1059 ret = PM8001_CHIP_DISP->phy_ctl_req(pm8001_ha, phy_id, in pm8001_abort_task()
1062 phy->enable_completion = NULL; in pm8001_abort_task()
1063 phy->reset_completion = NULL; in pm8001_abort_task()
1076 "Waiting for local phy ctl\n"); in pm8001_abort_task()
1079 if (!ret || !phy->reset_success) { in pm8001_abort_task()
1080 phy->enable_completion = NULL; in pm8001_abort_task()
1081 phy->reset_completion = NULL; in pm8001_abort_task()
1092 phy->reset_completion = NULL; in pm8001_abort_task()
1093 WARN_ON(phy->port_reset_status == in pm8001_abort_task()
1095 if (phy->port_reset_status == PORT_RESET_TMO) { in pm8001_abort_task()
1097 PM8001_CHIP_DISP->hw_event_ack_req( in pm8001_abort_task()
1115 &task->slow_task->completion, in pm8001_abort_task()
1122 pm8001_dev->setds_completion = &completion; in pm8001_abort_task()
1123 PM8001_CHIP_DISP->set_dev_state_req(pm8001_ha, in pm8001_abort_task()
1133 ccb->task = NULL; in pm8001_abort_task()
1137 } else if (task->task_proto & SAS_PROTOCOL_SMP) { in pm8001_abort_task()
1143 spin_lock_irqsave(&task->task_state_lock, flags); in pm8001_abort_task()
1144 if (task->slow_task == &slow_task) in pm8001_abort_task()
1145 task->slow_task = NULL; in pm8001_abort_task()
1146 spin_unlock_irqrestore(&task->task_state_lock, flags); in pm8001_abort_task()
1154 struct pm8001_device *pm8001_dev = dev->lldd_dev; in pm8001_clear_task_set()
1158 pm8001_dev->device_id); in pm8001_clear_task_set()
1164 struct sas_ha_struct *sas_ha = sas_phy->ha; in pm8001_port_formed()
1165 struct pm8001_hba_info *pm8001_ha = sas_ha->lldd_ha; in pm8001_port_formed()
1166 struct pm8001_phy *phy = sas_phy->lldd_phy; in pm8001_port_formed() local
1167 struct asd_sas_port *sas_port = sas_phy->port; in pm8001_port_formed()
1168 struct pm8001_port *port = phy->port; in pm8001_port_formed()
1174 sas_port->lldd_port = port; in pm8001_port_formed()
1180 struct pm8001_device *pm8001_dev = dev->lldd_dev; in pm8001_setds_completion()
1183 if (pm8001_ha->chip_id != chip_8001) { in pm8001_setds_completion()
1184 pm8001_dev->setds_completion = &completion_setstate; in pm8001_setds_completion()
1185 PM8001_CHIP_DISP->set_dev_state_req(pm8001_ha, in pm8001_setds_completion()
1193 struct pm8001_ccb_info *ccb = task->lldd_task; in pm8001_tmf_aborted()
1196 ccb->task = NULL; in pm8001_tmf_aborted()