Lines Matching +full:phy +full:- +full:s
1 // SPDX-License-Identifier: GPL-2.0-or-later
11 ((!dev) || (dev->dev_type == SAS_PHY_UNUSED))
29 switch (qc->tf.protocol) { in hisi_sas_get_ata_protocol_from_tf()
46 struct host_to_dev_fis *fis = &task->ata_task.fis; in hisi_sas_get_ata_protocol()
47 struct ata_queued_cmd *qc = task->uldd_task; in hisi_sas_get_ata_protocol()
48 int direction = task->data_dir; in hisi_sas_get_ata_protocol()
50 switch (fis->command) { in hisi_sas_get_ata_protocol()
103 switch (fis->features) { in hisi_sas_get_ata_protocol()
129 struct task_status_struct *ts = &task->task_status; in hisi_sas_sata_done()
130 struct ata_task_resp *resp = (struct ata_task_resp *)ts->buf; in hisi_sas_sata_done()
133 u8 *iu = &status_buf->iu[0]; in hisi_sas_sata_done()
136 resp->frame_len = sizeof(struct dev_to_host_fis); in hisi_sas_sata_done()
137 memcpy(&resp->ending_fis[0], d2h, sizeof(struct dev_to_host_fis)); in hisi_sas_sata_done()
139 ts->buf_valid_size = sizeof(*resp); in hisi_sas_sata_done()
152 max -= SAS_LINK_RATE_1_5_GBPS; in hisi_sas_get_prog_phy_linkrate_mask()
161 return device->port->ha->lldd_ha; in dev_to_hisi_hba()
174 for (phy_no = 0; phy_no < hisi_hba->n_phy; phy_no++) in hisi_sas_stop_phys()
181 void *bitmap = hisi_hba->slot_index_tags; in hisi_sas_slot_index_clear()
188 if (hisi_hba->hw->slot_index_alloc || in hisi_sas_slot_index_free()
190 spin_lock(&hisi_hba->lock); in hisi_sas_slot_index_free()
192 spin_unlock(&hisi_hba->lock); in hisi_sas_slot_index_free()
198 void *bitmap = hisi_hba->slot_index_tags; in hisi_sas_slot_index_set()
207 void *bitmap = hisi_hba->slot_index_tags; in hisi_sas_slot_index_alloc()
210 return rq->tag + HISI_SAS_RESERVED_IPTT; in hisi_sas_slot_index_alloc()
212 spin_lock(&hisi_hba->lock); in hisi_sas_slot_index_alloc()
214 hisi_hba->last_slot_index + 1); in hisi_sas_slot_index_alloc()
220 spin_unlock(&hisi_hba->lock); in hisi_sas_slot_index_alloc()
221 return -SAS_QUEUE_FULL; in hisi_sas_slot_index_alloc()
225 hisi_hba->last_slot_index = index; in hisi_sas_slot_index_alloc()
226 spin_unlock(&hisi_hba->lock); in hisi_sas_slot_index_alloc()
234 int device_id = slot->device_id; in hisi_sas_slot_task_free()
235 struct hisi_sas_device *sas_dev = &hisi_hba->devices[device_id]; in hisi_sas_slot_task_free()
238 struct device *dev = hisi_hba->dev; in hisi_sas_slot_task_free()
240 if (!task->lldd_task) in hisi_sas_slot_task_free()
243 task->lldd_task = NULL; in hisi_sas_slot_task_free()
245 if (!sas_protocol_ata(task->task_proto)) { in hisi_sas_slot_task_free()
246 if (slot->n_elem) { in hisi_sas_slot_task_free()
247 if (task->task_proto & SAS_PROTOCOL_SSP) in hisi_sas_slot_task_free()
248 dma_unmap_sg(dev, task->scatter, in hisi_sas_slot_task_free()
249 task->num_scatter, in hisi_sas_slot_task_free()
250 task->data_dir); in hisi_sas_slot_task_free()
252 dma_unmap_sg(dev, &task->smp_task.smp_req, in hisi_sas_slot_task_free()
255 if (slot->n_elem_dif) { in hisi_sas_slot_task_free()
256 struct sas_ssp_task *ssp_task = &task->ssp_task; in hisi_sas_slot_task_free()
257 struct scsi_cmnd *scsi_cmnd = ssp_task->cmd; in hisi_sas_slot_task_free()
261 task->data_dir); in hisi_sas_slot_task_free()
267 spin_lock(&sas_dev->lock); in hisi_sas_slot_task_free()
268 list_del_init(&slot->entry); in hisi_sas_slot_task_free()
269 spin_unlock(&sas_dev->lock); in hisi_sas_slot_task_free()
271 list_del_init(&slot->entry); in hisi_sas_slot_task_free()
276 hisi_sas_slot_index_free(hisi_hba, slot->idx); in hisi_sas_slot_task_free()
283 hisi_hba->hw->prep_smp(hisi_hba, slot); in hisi_sas_task_prep_smp()
289 hisi_hba->hw->prep_ssp(hisi_hba, slot); in hisi_sas_task_prep_ssp()
295 hisi_hba->hw->prep_stp(hisi_hba, slot); in hisi_sas_task_prep_ata()
301 hisi_hba->hw->prep_abort(hisi_hba, slot); in hisi_sas_task_prep_abort()
307 struct device *dev = hisi_hba->dev; in hisi_sas_dma_unmap()
309 if (!sas_protocol_ata(task->task_proto) && n_elem) { in hisi_sas_dma_unmap()
310 if (task->num_scatter) { in hisi_sas_dma_unmap()
311 dma_unmap_sg(dev, task->scatter, task->num_scatter, in hisi_sas_dma_unmap()
312 task->data_dir); in hisi_sas_dma_unmap()
313 } else if (task->task_proto & SAS_PROTOCOL_SMP) { in hisi_sas_dma_unmap()
314 dma_unmap_sg(dev, &task->smp_task.smp_req, in hisi_sas_dma_unmap()
323 struct device *dev = hisi_hba->dev; in hisi_sas_dma_map()
326 if (sas_protocol_ata(task->task_proto)) { in hisi_sas_dma_map()
327 *n_elem = task->num_scatter; in hisi_sas_dma_map()
331 if (task->num_scatter) { in hisi_sas_dma_map()
332 *n_elem = dma_map_sg(dev, task->scatter, in hisi_sas_dma_map()
333 task->num_scatter, task->data_dir); in hisi_sas_dma_map()
335 rc = -ENOMEM; in hisi_sas_dma_map()
338 } else if (task->task_proto & SAS_PROTOCOL_SMP) { in hisi_sas_dma_map()
339 *n_elem = dma_map_sg(dev, &task->smp_task.smp_req, in hisi_sas_dma_map()
342 rc = -ENOMEM; in hisi_sas_dma_map()
345 req_len = sg_dma_len(&task->smp_task.smp_req); in hisi_sas_dma_map()
347 rc = -EINVAL; in hisi_sas_dma_map()
356 rc = -EINVAL; in hisi_sas_dma_map()
362 /* It would be better to call dma_unmap_sg() here, but it's messy */ in hisi_sas_dma_map()
371 struct device *dev = hisi_hba->dev; in hisi_sas_dif_dma_unmap()
374 struct sas_ssp_task *ssp_task = &task->ssp_task; in hisi_sas_dif_dma_unmap()
375 struct scsi_cmnd *scsi_cmnd = ssp_task->cmd; in hisi_sas_dif_dma_unmap()
379 task->data_dir); in hisi_sas_dif_dma_unmap()
386 struct device *dev = hisi_hba->dev; in hisi_sas_dif_dma_map()
391 if (task->num_scatter) { in hisi_sas_dif_dma_map()
392 ssp_task = &task->ssp_task; in hisi_sas_dif_dma_map()
393 scsi_cmnd = ssp_task->cmd; in hisi_sas_dif_dma_map()
399 task->data_dir); in hisi_sas_dif_dma_map()
402 return -ENOMEM; in hisi_sas_dif_dma_map()
407 rc = -EINVAL; in hisi_sas_dif_dma_map()
417 scsi_prot_sg_count(scsi_cmnd), task->data_dir); in hisi_sas_dif_dma_map()
429 struct sas_task *task = slot->task; in hisi_sas_task_deliver()
432 spin_lock(&dq->lock); in hisi_sas_task_deliver()
433 wr_q_index = dq->wr_point; in hisi_sas_task_deliver()
434 dq->wr_point = (dq->wr_point + 1) % HISI_SAS_QUEUE_SLOTS; in hisi_sas_task_deliver()
435 list_add_tail(&slot->delivery, &dq->list); in hisi_sas_task_deliver()
436 spin_unlock(&dq->lock); in hisi_sas_task_deliver()
437 spin_lock(&sas_dev->lock); in hisi_sas_task_deliver()
438 list_add_tail(&slot->entry, &sas_dev->list); in hisi_sas_task_deliver()
439 spin_unlock(&sas_dev->lock); in hisi_sas_task_deliver()
441 dlvry_queue = dq->id; in hisi_sas_task_deliver()
444 slot->device_id = sas_dev->device_id; in hisi_sas_task_deliver()
445 slot->dlvry_queue = dlvry_queue; in hisi_sas_task_deliver()
446 slot->dlvry_queue_slot = dlvry_queue_slot; in hisi_sas_task_deliver()
447 cmd_hdr_base = hisi_hba->cmd_hdr[dlvry_queue]; in hisi_sas_task_deliver()
448 slot->cmd_hdr = &cmd_hdr_base[dlvry_queue_slot]; in hisi_sas_task_deliver()
450 task->lldd_task = slot; in hisi_sas_task_deliver()
452 memset(slot->cmd_hdr, 0, sizeof(struct hisi_sas_cmd_hdr)); in hisi_sas_task_deliver()
457 switch (task->task_proto) { in hisi_sas_task_deliver()
478 WRITE_ONCE(slot->ready, 1); in hisi_sas_task_deliver()
480 spin_lock(&dq->lock); in hisi_sas_task_deliver()
481 hisi_hba->hw->start_delivery(dq); in hisi_sas_task_deliver()
482 spin_unlock(&dq->lock); in hisi_sas_task_deliver()
488 struct domain_device *device = task->dev; in hisi_sas_queue_command()
489 struct asd_sas_port *sas_port = device->port; in hisi_sas_queue_command()
490 struct hisi_sas_device *sas_dev = device->lldd_dev; in hisi_sas_queue_command()
501 struct task_status_struct *ts = &task->task_status; in hisi_sas_queue_command()
503 ts->resp = SAS_TASK_UNDELIVERED; in hisi_sas_queue_command()
504 ts->stat = SAS_PHY_DOWN; in hisi_sas_queue_command()
506 * libsas will use dev->port, should in hisi_sas_queue_command()
509 if (device->dev_type != SAS_SATA_DEV && !internal_abort) in hisi_sas_queue_command()
510 task->task_done(task); in hisi_sas_queue_command()
511 return -ECOMM; in hisi_sas_queue_command()
515 dev = hisi_hba->dev; in hisi_sas_queue_command()
517 switch (task->task_proto) { in hisi_sas_queue_command()
523 if (unlikely(test_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags))) { in hisi_sas_queue_command()
525 return -EINVAL; in hisi_sas_queue_command()
527 down(&hisi_hba->sem); in hisi_sas_queue_command()
528 up(&hisi_hba->sem); in hisi_sas_queue_command()
534 sas_dev->device_id); in hisi_sas_queue_command()
537 SAS_ADDR(device->sas_addr)); in hisi_sas_queue_command()
539 return -ECOMM; in hisi_sas_queue_command()
543 if (!port->port_attached) { in hisi_sas_queue_command()
544 dev_info(dev, "task prep: %s port%d not attach device\n", in hisi_sas_queue_command()
546 device->port->id); in hisi_sas_queue_command()
548 return -ECOMM; in hisi_sas_queue_command()
558 dq = &hisi_hba->dq[dq_index]; in hisi_sas_queue_command()
562 if (hisi_hba->iopoll_q_cnt) { in hisi_sas_queue_command()
570 struct Scsi_Host *shost = hisi_hba->shost; in hisi_sas_queue_command()
571 struct blk_mq_queue_map *qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT]; in hisi_sas_queue_command()
573 queue = qmap->mq_map[raw_smp_processor_id()]; in hisi_sas_queue_command()
575 dq = &hisi_hba->dq[queue]; in hisi_sas_queue_command()
579 if (!hisi_hba->hw->prep_abort) in hisi_sas_queue_command()
582 if (test_bit(HISI_SAS_HW_FAULT_BIT, &hisi_hba->flags)) in hisi_sas_queue_command()
583 return -EIO; in hisi_sas_queue_command()
587 if (unlikely(test_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags))) in hisi_sas_queue_command()
588 return -EINVAL; in hisi_sas_queue_command()
591 dq = &hisi_hba->dq[task->abort_task.qid]; in hisi_sas_queue_command()
594 dev_err(hisi_hba->dev, "task prep: unknown/unsupported proto (0x%x)\n", in hisi_sas_queue_command()
595 task->task_proto); in hisi_sas_queue_command()
596 return -EINVAL; in hisi_sas_queue_command()
603 if (!sas_protocol_ata(task->task_proto)) { in hisi_sas_queue_command()
609 if (!internal_abort && hisi_hba->hw->slot_index_alloc) in hisi_sas_queue_command()
610 rc = hisi_hba->hw->slot_index_alloc(hisi_hba, device); in hisi_sas_queue_command()
617 slot = &hisi_hba->slot_info[rc]; in hisi_sas_queue_command()
618 slot->n_elem = n_elem; in hisi_sas_queue_command()
619 slot->n_elem_dif = n_elem_dif; in hisi_sas_queue_command()
620 slot->task = task; in hisi_sas_queue_command()
621 slot->port = port; in hisi_sas_queue_command()
623 slot->tmf = task->tmf; in hisi_sas_queue_command()
624 slot->is_internal = !!task->tmf || internal_abort; in hisi_sas_queue_command()
632 if (!sas_protocol_ata(task->task_proto)) in hisi_sas_queue_command()
644 struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; in hisi_sas_bytes_dmaed() local
645 struct asd_sas_phy *sas_phy = &phy->sas_phy; in hisi_sas_bytes_dmaed()
647 if (!phy->phy_attached) in hisi_sas_bytes_dmaed()
652 if (sas_phy->phy) { in hisi_sas_bytes_dmaed()
653 struct sas_phy *sphy = sas_phy->phy; in hisi_sas_bytes_dmaed()
655 sphy->negotiated_linkrate = sas_phy->linkrate; in hisi_sas_bytes_dmaed()
656 sphy->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS; in hisi_sas_bytes_dmaed()
657 sphy->maximum_linkrate_hw = in hisi_sas_bytes_dmaed()
658 hisi_hba->hw->phy_get_max_linkrate(); in hisi_sas_bytes_dmaed()
659 if (sphy->minimum_linkrate == SAS_LINK_RATE_UNKNOWN) in hisi_sas_bytes_dmaed()
660 sphy->minimum_linkrate = phy->minimum_linkrate; in hisi_sas_bytes_dmaed()
662 if (sphy->maximum_linkrate == SAS_LINK_RATE_UNKNOWN) in hisi_sas_bytes_dmaed()
663 sphy->maximum_linkrate = phy->maximum_linkrate; in hisi_sas_bytes_dmaed()
666 if (phy->phy_type & PORT_TYPE_SAS) { in hisi_sas_bytes_dmaed()
669 id = (struct sas_identify_frame *)phy->frame_rcvd; in hisi_sas_bytes_dmaed()
670 id->dev_type = phy->identify.device_type; in hisi_sas_bytes_dmaed()
671 id->initiator_bits = SAS_PROTOCOL_ALL; in hisi_sas_bytes_dmaed()
672 id->target_bits = phy->identify.target_port_protocols; in hisi_sas_bytes_dmaed()
673 } else if (phy->phy_type & PORT_TYPE_SATA) { in hisi_sas_bytes_dmaed()
677 sas_phy->frame_rcvd_size = phy->frame_rcvd_size; in hisi_sas_bytes_dmaed()
685 int last = hisi_hba->last_dev_id; in hisi_sas_alloc_dev()
686 int first = (hisi_hba->last_dev_id + 1) % HISI_SAS_MAX_DEVICES; in hisi_sas_alloc_dev()
689 spin_lock(&hisi_hba->lock); in hisi_sas_alloc_dev()
691 if (hisi_hba->devices[i].dev_type == SAS_PHY_UNUSED) { in hisi_sas_alloc_dev()
692 int queue = i % hisi_hba->queue_count; in hisi_sas_alloc_dev()
693 struct hisi_sas_dq *dq = &hisi_hba->dq[queue]; in hisi_sas_alloc_dev()
695 hisi_hba->devices[i].device_id = i; in hisi_sas_alloc_dev()
696 sas_dev = &hisi_hba->devices[i]; in hisi_sas_alloc_dev()
697 sas_dev->dev_status = HISI_SAS_DEV_INIT; in hisi_sas_alloc_dev()
698 sas_dev->dev_type = device->dev_type; in hisi_sas_alloc_dev()
699 sas_dev->hisi_hba = hisi_hba; in hisi_sas_alloc_dev()
700 sas_dev->sas_device = device; in hisi_sas_alloc_dev()
701 sas_dev->dq = dq; in hisi_sas_alloc_dev()
702 spin_lock_init(&sas_dev->lock); in hisi_sas_alloc_dev()
703 INIT_LIST_HEAD(&hisi_hba->devices[i].list); in hisi_sas_alloc_dev()
708 hisi_hba->last_dev_id = i; in hisi_sas_alloc_dev()
709 spin_unlock(&hisi_hba->lock); in hisi_sas_alloc_dev()
717 spin_lock(&cq->poll_lock); in hisi_sas_sync_poll_cq()
718 spin_unlock(&cq->poll_lock); in hisi_sas_sync_poll_cq()
723 struct hisi_hba *hisi_hba = cq->hisi_hba; in hisi_sas_queue_is_poll()
725 if (cq->id < hisi_hba->queue_count - hisi_hba->iopoll_q_cnt) in hisi_sas_queue_is_poll()
735 synchronize_irq(cq->irq_no); in hisi_sas_sync_cq()
742 for (i = 0; i < hisi_hba->queue_count; i++) { in hisi_sas_sync_poll_cqs()
743 struct hisi_sas_cq *cq = &hisi_hba->cq[i]; in hisi_sas_sync_poll_cqs()
755 for (i = 0; i < hisi_hba->queue_count; i++) { in hisi_sas_sync_cqs()
756 struct hisi_sas_cq *cq = &hisi_hba->cq[i]; in hisi_sas_sync_cqs()
765 struct hisi_sas_slot *slot = task->lldd_task; in hisi_sas_tmf_aborted()
766 struct domain_device *device = task->dev; in hisi_sas_tmf_aborted()
767 struct hisi_sas_device *sas_dev = device->lldd_dev; in hisi_sas_tmf_aborted()
768 struct hisi_hba *hisi_hba = sas_dev->hisi_hba; in hisi_sas_tmf_aborted()
772 &hisi_hba->cq[slot->dlvry_queue]; in hisi_sas_tmf_aborted()
778 slot->task = NULL; in hisi_sas_tmf_aborted()
790 switch (device->dev_type) { in hisi_sas_init_device()
794 while (retry-- > 0) { in hisi_sas_init_device()
814 * hard reset in sas_probe_sata() -> ata_port_probe(). in hisi_sas_init_device()
819 while (retry-- > 0) { in hisi_sas_init_device()
835 struct hisi_sas_device *sas_dev = ddev->lldd_dev; in hisi_sas_sdev_init()
845 sas_dev->dev_status = HISI_SAS_DEV_NORMAL; in hisi_sas_sdev_init()
853 struct domain_device *parent_dev = device->parent; in hisi_sas_dev_found()
855 struct device *dev = hisi_hba->dev; in hisi_sas_dev_found()
858 if (hisi_hba->hw->alloc_dev) in hisi_sas_dev_found()
859 sas_dev = hisi_hba->hw->alloc_dev(device); in hisi_sas_dev_found()
865 return -EINVAL; in hisi_sas_dev_found()
868 device->lldd_dev = sas_dev; in hisi_sas_dev_found()
869 hisi_hba->hw->setup_itct(hisi_hba, sas_dev); in hisi_sas_dev_found()
871 if (parent_dev && dev_is_expander(parent_dev->dev_type)) { in hisi_sas_dev_found()
874 phy_no = sas_find_attached_phy_id(&parent_dev->ex_dev, device); in hisi_sas_dev_found()
878 SAS_ADDR(device->sas_addr), in hisi_sas_dev_found()
879 SAS_ADDR(parent_dev->sas_addr)); in hisi_sas_dev_found()
886 sas_dev->device_id, sas_dev->dev_type); in hisi_sas_dev_found()
913 hisi_hba->hw->phys_init(hisi_hba); in hisi_sas_scan_start()
920 struct sas_ha_struct *sha = &hisi_hba->sha; in hisi_sas_scan_finished()
922 /* Wait for PHY up interrupt to occur */ in hisi_sas_scan_finished()
934 struct hisi_sas_phy *phy = in hisi_sas_phyup_work_common() local
935 container_of(work, typeof(*phy), works[event]); in hisi_sas_phyup_work_common()
936 struct hisi_hba *hisi_hba = phy->hisi_hba; in hisi_sas_phyup_work_common()
937 struct asd_sas_phy *sas_phy = &phy->sas_phy; in hisi_sas_phyup_work_common()
938 int phy_no = sas_phy->id; in hisi_sas_phyup_work_common()
940 phy->wait_phyup_cnt = 0; in hisi_sas_phyup_work_common()
941 if (phy->identify.target_port_protocols == SAS_PROTOCOL_SSP) in hisi_sas_phyup_work_common()
942 hisi_hba->hw->sl_notify_ssp(hisi_hba, phy_no); in hisi_sas_phyup_work_common()
953 struct hisi_sas_phy *phy = in hisi_sas_linkreset_work() local
954 container_of(work, typeof(*phy), works[HISI_PHYE_LINK_RESET]); in hisi_sas_linkreset_work()
955 struct asd_sas_phy *sas_phy = &phy->sas_phy; in hisi_sas_linkreset_work()
962 struct hisi_sas_phy *phy = in hisi_sas_phyup_pm_work() local
963 container_of(work, typeof(*phy), works[HISI_PHYE_PHY_UP_PM]); in hisi_sas_phyup_pm_work()
964 struct hisi_hba *hisi_hba = phy->hisi_hba; in hisi_sas_phyup_pm_work()
965 struct device *dev = hisi_hba->dev; in hisi_sas_phyup_pm_work()
977 bool hisi_sas_notify_phy_event(struct hisi_sas_phy *phy, in hisi_sas_notify_phy_event() argument
980 struct hisi_hba *hisi_hba = phy->hisi_hba; in hisi_sas_notify_phy_event()
985 return queue_work(hisi_hba->wq, &phy->works[event]); in hisi_sas_notify_phy_event()
991 struct hisi_sas_phy *phy = from_timer(phy, t, timer); in hisi_sas_wait_phyup_timedout() local
992 struct hisi_hba *hisi_hba = phy->hisi_hba; in hisi_sas_wait_phyup_timedout()
993 struct device *dev = hisi_hba->dev; in hisi_sas_wait_phyup_timedout()
994 int phy_no = phy->sas_phy.id; in hisi_sas_wait_phyup_timedout()
996 dev_warn(dev, "phy%d wait phyup timeout, issuing link reset\n", phy_no); in hisi_sas_wait_phyup_timedout()
997 hisi_sas_notify_phy_event(phy, HISI_PHYE_LINK_RESET); in hisi_sas_wait_phyup_timedout()
1004 struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; in hisi_sas_phy_oob_ready() local
1005 struct device *dev = hisi_hba->dev; in hisi_sas_phy_oob_ready()
1008 dev_dbg(dev, "phy%d OOB ready\n", phy_no); in hisi_sas_phy_oob_ready()
1009 spin_lock_irqsave(&phy->lock, flags); in hisi_sas_phy_oob_ready()
1010 if (phy->phy_attached) { in hisi_sas_phy_oob_ready()
1011 spin_unlock_irqrestore(&phy->lock, flags); in hisi_sas_phy_oob_ready()
1015 if (!timer_pending(&phy->timer)) { in hisi_sas_phy_oob_ready()
1016 if (phy->wait_phyup_cnt < HISI_SAS_WAIT_PHYUP_RETRIES) { in hisi_sas_phy_oob_ready()
1017 phy->wait_phyup_cnt++; in hisi_sas_phy_oob_ready()
1018 phy->timer.expires = jiffies + in hisi_sas_phy_oob_ready()
1020 add_timer(&phy->timer); in hisi_sas_phy_oob_ready()
1021 spin_unlock_irqrestore(&phy->lock, flags); in hisi_sas_phy_oob_ready()
1025 dev_warn(dev, "phy%d failed to come up %d times, giving up\n", in hisi_sas_phy_oob_ready()
1026 phy_no, phy->wait_phyup_cnt); in hisi_sas_phy_oob_ready()
1027 phy->wait_phyup_cnt = 0; in hisi_sas_phy_oob_ready()
1029 spin_unlock_irqrestore(&phy->lock, flags); in hisi_sas_phy_oob_ready()
1036 struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; in hisi_sas_phy_init() local
1037 struct asd_sas_phy *sas_phy = &phy->sas_phy; in hisi_sas_phy_init()
1040 phy->hisi_hba = hisi_hba; in hisi_sas_phy_init()
1041 phy->port = NULL; in hisi_sas_phy_init()
1042 phy->minimum_linkrate = SAS_LINK_RATE_1_5_GBPS; in hisi_sas_phy_init()
1043 phy->maximum_linkrate = hisi_hba->hw->phy_get_max_linkrate(); in hisi_sas_phy_init()
1044 sas_phy->enabled = (phy_no < hisi_hba->n_phy) ? 1 : 0; in hisi_sas_phy_init()
1045 sas_phy->iproto = SAS_PROTOCOL_ALL; in hisi_sas_phy_init()
1046 sas_phy->tproto = 0; in hisi_sas_phy_init()
1047 sas_phy->role = PHY_ROLE_INITIATOR; in hisi_sas_phy_init()
1048 sas_phy->oob_mode = OOB_NOT_CONNECTED; in hisi_sas_phy_init()
1049 sas_phy->linkrate = SAS_LINK_RATE_UNKNOWN; in hisi_sas_phy_init()
1050 sas_phy->id = phy_no; in hisi_sas_phy_init()
1051 sas_phy->sas_addr = &hisi_hba->sas_addr[0]; in hisi_sas_phy_init()
1052 sas_phy->frame_rcvd = &phy->frame_rcvd[0]; in hisi_sas_phy_init()
1053 sas_phy->ha = (struct sas_ha_struct *)hisi_hba->shost->hostdata; in hisi_sas_phy_init()
1054 sas_phy->lldd_phy = phy; in hisi_sas_phy_init()
1057 INIT_WORK(&phy->works[i], hisi_sas_phye_fns[i]); in hisi_sas_phy_init()
1059 spin_lock_init(&phy->lock); in hisi_sas_phy_init()
1061 timer_setup(&phy->timer, hisi_sas_wait_phyup_timedout, 0); in hisi_sas_phy_init()
1067 struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; in hisi_sas_phy_enable() local
1068 struct asd_sas_phy *aphy = &phy->sas_phy; in hisi_sas_phy_enable()
1069 struct sas_phy *sphy = aphy->phy; in hisi_sas_phy_enable()
1072 spin_lock_irqsave(&phy->lock, flags); in hisi_sas_phy_enable()
1076 if (!phy->enable) in hisi_sas_phy_enable()
1077 sphy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN; in hisi_sas_phy_enable()
1078 hisi_hba->hw->phy_start(hisi_hba, phy_no); in hisi_sas_phy_enable()
1080 sphy->negotiated_linkrate = SAS_PHY_DISABLED; in hisi_sas_phy_enable()
1081 hisi_hba->hw->phy_disable(hisi_hba, phy_no); in hisi_sas_phy_enable()
1083 phy->enable = enable; in hisi_sas_phy_enable()
1084 spin_unlock_irqrestore(&phy->lock, flags); in hisi_sas_phy_enable()
1090 struct hisi_sas_phy *phy = sas_phy->lldd_phy; in hisi_sas_port_notify_formed() local
1091 struct asd_sas_port *sas_port = sas_phy->port; in hisi_sas_port_notify_formed()
1098 port->port_attached = 1; in hisi_sas_port_notify_formed()
1099 port->id = phy->port_id; in hisi_sas_port_notify_formed()
1100 phy->port = port; in hisi_sas_port_notify_formed()
1101 sas_port->lldd_port = port; in hisi_sas_port_notify_formed()
1111 ts = &task->task_status; in hisi_sas_do_release_task()
1113 ts->resp = SAS_TASK_COMPLETE; in hisi_sas_do_release_task()
1114 ts->stat = SAS_ABORTED_TASK; in hisi_sas_do_release_task()
1115 spin_lock_irqsave(&task->task_state_lock, flags); in hisi_sas_do_release_task()
1116 task->task_state_flags &= ~SAS_TASK_STATE_PENDING; in hisi_sas_do_release_task()
1117 if (!slot->is_internal && task->task_proto != SAS_PROTOCOL_SMP) in hisi_sas_do_release_task()
1118 task->task_state_flags |= SAS_TASK_STATE_DONE; in hisi_sas_do_release_task()
1119 spin_unlock_irqrestore(&task->task_state_lock, flags); in hisi_sas_do_release_task()
1129 struct hisi_sas_device *sas_dev = device->lldd_dev; in hisi_sas_release_task()
1131 spin_lock(&sas_dev->lock); in hisi_sas_release_task()
1132 list_for_each_entry_safe(slot, slot2, &sas_dev->list, entry) in hisi_sas_release_task()
1133 hisi_sas_do_release_task(hisi_hba, slot->task, slot, false); in hisi_sas_release_task()
1135 spin_unlock(&sas_dev->lock); in hisi_sas_release_task()
1145 sas_dev = &hisi_hba->devices[i]; in hisi_sas_release_tasks()
1146 device = sas_dev->sas_device; in hisi_sas_release_tasks()
1148 if ((sas_dev->dev_type == SAS_PHY_UNUSED) || in hisi_sas_release_tasks()
1160 if (hisi_hba->hw->dereg_device) in hisi_sas_dereg_device()
1161 hisi_hba->hw->dereg_device(hisi_hba, device); in hisi_sas_dereg_device()
1169 struct domain_device *device = sas_dev->sas_device; in hisi_sas_internal_task_abort_dev()
1170 struct hisi_hba *hisi_hba = sas_dev->hisi_hba; in hisi_sas_internal_task_abort_dev()
1173 for (i = 0; i < hisi_hba->cq_nvecs; i++) { in hisi_sas_internal_task_abort_dev()
1174 struct hisi_sas_cq *cq = &hisi_hba->cq[i]; in hisi_sas_internal_task_abort_dev()
1175 const struct cpumask *mask = cq->irq_mask; in hisi_sas_internal_task_abort_dev()
1189 struct hisi_sas_device *sas_dev = device->lldd_dev; in hisi_sas_dev_gone()
1191 struct device *dev = hisi_hba->dev; in hisi_sas_dev_gone()
1195 sas_dev->device_id, sas_dev->dev_type); in hisi_sas_dev_gone()
1197 down(&hisi_hba->sem); in hisi_sas_dev_gone()
1198 if (!test_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags)) { in hisi_sas_dev_gone()
1203 ret = hisi_hba->hw->clear_itct(hisi_hba, sas_dev); in hisi_sas_dev_gone()
1204 device->lldd_dev = NULL; in hisi_sas_dev_gone()
1207 if (hisi_hba->hw->free_device) in hisi_sas_dev_gone()
1208 hisi_hba->hw->free_device(sas_dev); in hisi_sas_dev_gone()
1212 sas_dev->dev_type = SAS_PHY_UNUSED; in hisi_sas_dev_gone()
1213 sas_dev->sas_device = NULL; in hisi_sas_dev_gone()
1214 up(&hisi_hba->sem); in hisi_sas_dev_gone()
1222 struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; in hisi_sas_phy_set_linkrate() local
1223 struct asd_sas_phy *sas_phy = &phy->sas_phy; in hisi_sas_phy_set_linkrate()
1226 if (r->minimum_linkrate > SAS_LINK_RATE_1_5_GBPS) in hisi_sas_phy_set_linkrate()
1227 return -EINVAL; in hisi_sas_phy_set_linkrate()
1229 if (r->maximum_linkrate == SAS_LINK_RATE_UNKNOWN) { in hisi_sas_phy_set_linkrate()
1230 max = sas_phy->phy->maximum_linkrate; in hisi_sas_phy_set_linkrate()
1231 min = r->minimum_linkrate; in hisi_sas_phy_set_linkrate()
1232 } else if (r->minimum_linkrate == SAS_LINK_RATE_UNKNOWN) { in hisi_sas_phy_set_linkrate()
1233 max = r->maximum_linkrate; in hisi_sas_phy_set_linkrate()
1234 min = sas_phy->phy->minimum_linkrate; in hisi_sas_phy_set_linkrate()
1236 return -EINVAL; in hisi_sas_phy_set_linkrate()
1241 sas_phy->phy->maximum_linkrate = max; in hisi_sas_phy_set_linkrate()
1242 sas_phy->phy->minimum_linkrate = min; in hisi_sas_phy_set_linkrate()
1246 hisi_hba->hw->phy_set_linkrate(hisi_hba, phy_no, &_r); in hisi_sas_phy_set_linkrate()
1255 struct hisi_sas_phy *phy = container_of(sas_phy, in hisi_sas_control_phy() local
1257 struct sas_ha_struct *sas_ha = sas_phy->ha; in hisi_sas_control_phy()
1258 struct hisi_hba *hisi_hba = sas_ha->lldd_ha; in hisi_sas_control_phy()
1259 struct device *dev = hisi_hba->dev; in hisi_sas_control_phy()
1261 int phy_no = sas_phy->id; in hisi_sas_control_phy()
1262 u8 sts = phy->phy_attached; in hisi_sas_control_phy()
1265 down(&hisi_hba->sem); in hisi_sas_control_phy()
1266 phy->reset_completion = &completion; in hisi_sas_control_phy()
1270 hisi_hba->hw->phy_hard_reset(hisi_hba, phy_no); in hisi_sas_control_phy()
1288 if (hisi_hba->hw->get_events) { in hisi_sas_control_phy()
1289 hisi_hba->hw->get_events(hisi_hba, phy_no); in hisi_sas_control_phy()
1295 ret = -EOPNOTSUPP; in hisi_sas_control_phy()
1301 dev_warn(dev, "phy%d wait phyup timed out for func %d\n", in hisi_sas_control_phy()
1303 if (phy->in_reset) in hisi_sas_control_phy()
1304 ret = -ETIMEDOUT; in hisi_sas_control_phy()
1308 phy->reset_completion = NULL; in hisi_sas_control_phy()
1310 up(&hisi_hba->sem); in hisi_sas_control_phy()
1331 struct ata_port *ap = device->sata_dev.ap; in hisi_sas_softreset_ata_disk()
1335 struct device *dev = hisi_hba->dev; in hisi_sas_softreset_ata_disk()
1340 hisi_sas_fill_ata_reset_cmd(link->device, 1, pmp, fis); in hisi_sas_softreset_ata_disk()
1341 rc = sas_execute_ata_cmd(device, fis, -1); in hisi_sas_softreset_ata_disk()
1351 hisi_sas_fill_ata_reset_cmd(link->device, 0, pmp, fis); in hisi_sas_softreset_ata_disk()
1352 rc = sas_execute_ata_cmd(device, fis, -1); in hisi_sas_softreset_ata_disk()
1354 dev_err(dev, "ata disk %016llx de-reset failed\n", in hisi_sas_softreset_ata_disk()
1355 SAS_ADDR(device->sas_addr)); in hisi_sas_softreset_ata_disk()
1359 SAS_ADDR(device->sas_addr)); in hisi_sas_softreset_ata_disk()
1370 u32 state = hisi_hba->hw->get_phys_state(hisi_hba); in hisi_sas_refresh_port_id()
1374 struct hisi_sas_device *sas_dev = &hisi_hba->devices[i]; in hisi_sas_refresh_port_id()
1375 struct domain_device *device = sas_dev->sas_device; in hisi_sas_refresh_port_id()
1378 struct hisi_sas_phy *phy = NULL; in hisi_sas_refresh_port_id() local
1381 if ((sas_dev->dev_type == SAS_PHY_UNUSED) in hisi_sas_refresh_port_id()
1382 || !device || !device->port) in hisi_sas_refresh_port_id()
1385 sas_port = device->port; in hisi_sas_refresh_port_id()
1388 spin_lock(&sas_port->phy_list_lock); in hisi_sas_refresh_port_id()
1389 list_for_each_entry(sas_phy, &sas_port->phy_list, port_phy_el) in hisi_sas_refresh_port_id()
1390 if (state & BIT(sas_phy->id)) { in hisi_sas_refresh_port_id()
1391 phy = sas_phy->lldd_phy; in hisi_sas_refresh_port_id()
1394 spin_unlock(&sas_port->phy_list_lock); in hisi_sas_refresh_port_id()
1396 if (phy) { in hisi_sas_refresh_port_id()
1397 port->id = phy->port_id; in hisi_sas_refresh_port_id()
1400 if (!device->parent) in hisi_sas_refresh_port_id()
1401 device->linkrate = phy->sas_phy.linkrate; in hisi_sas_refresh_port_id()
1403 hisi_hba->hw->setup_itct(hisi_hba, sas_dev); in hisi_sas_refresh_port_id()
1404 } else if (!port->port_attached) in hisi_sas_refresh_port_id()
1405 port->id = 0xff; in hisi_sas_refresh_port_id()
1411 u32 new_state = hisi_hba->hw->get_phys_state(hisi_hba); in hisi_sas_rescan_topology()
1415 for (phy_no = 0; phy_no < hisi_hba->n_phy; phy_no++) { in hisi_sas_rescan_topology()
1416 struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; in hisi_sas_rescan_topology() local
1417 struct asd_sas_phy *sas_phy = &phy->sas_phy; in hisi_sas_rescan_topology()
1418 struct asd_sas_port *sas_port = sas_phy->port; in hisi_sas_rescan_topology()
1421 if (!sas_phy->phy->enabled) in hisi_sas_rescan_topology()
1424 /* Report PHY state change to libsas */ in hisi_sas_rescan_topology()
1426 if (do_port_check && sas_port && sas_port->port_dev) { in hisi_sas_rescan_topology()
1427 struct domain_device *dev = sas_port->port_dev; in hisi_sas_rescan_topology()
1431 if (dev_is_expander(dev->dev_type)) in hisi_sas_rescan_topology()
1446 hisi_sas_notify_phy_event(phy, in hisi_sas_rescan_topology()
1459 sas_dev = &hisi_hba->devices[i]; in hisi_sas_reset_init_all_devices()
1460 device = sas_dev->sas_device; in hisi_sas_reset_init_all_devices()
1462 if ((sas_dev->dev_type == SAS_PHY_UNUSED) || !device) in hisi_sas_reset_init_all_devices()
1473 struct ata_port *ap = device->sata_dev.ap; in hisi_sas_send_ata_reset_each_phy()
1474 struct device *dev = hisi_hba->dev; in hisi_sas_send_ata_reset_each_phy()
1480 for (i = 0; i < hisi_hba->n_phy; i++) { in hisi_sas_send_ata_reset_each_phy()
1481 if (!(sas_port->phy_mask & BIT(i))) in hisi_sas_send_ata_reset_each_phy()
1487 hisi_sas_fill_ata_reset_cmd(link->device, 1, pmp, fis); in hisi_sas_send_ata_reset_each_phy()
1490 dev_err(dev, "phy%d ata reset failed rc=%d\n", in hisi_sas_send_ata_reset_each_phy()
1500 struct device *dev = hisi_hba->dev; in hisi_sas_terminate_stp_reject()
1504 struct hisi_sas_device *sas_dev = &hisi_hba->devices[i]; in hisi_sas_terminate_stp_reject()
1505 struct domain_device *device = sas_dev->sas_device; in hisi_sas_terminate_stp_reject()
1507 if ((sas_dev->dev_type == SAS_PHY_UNUSED) || !device) in hisi_sas_terminate_stp_reject()
1515 for (port_no = 0; port_no < hisi_hba->n_phy; port_no++) { in hisi_sas_terminate_stp_reject()
1516 struct hisi_sas_port *port = &hisi_hba->port[port_no]; in hisi_sas_terminate_stp_reject()
1517 struct asd_sas_port *sas_port = &port->sas_port; in hisi_sas_terminate_stp_reject()
1518 struct domain_device *port_dev = sas_port->port_dev; in hisi_sas_terminate_stp_reject()
1521 if (!port_dev || !dev_is_expander(port_dev->dev_type)) in hisi_sas_terminate_stp_reject()
1525 list_for_each_entry(device, &sas_port->dev_list, in hisi_sas_terminate_stp_reject()
1539 struct Scsi_Host *shost = hisi_hba->shost; in hisi_sas_controller_reset_prepare()
1541 hisi_hba->phy_state = hisi_hba->hw->get_phys_state(hisi_hba); in hisi_sas_controller_reset_prepare()
1544 hisi_hba->hw->wait_cmds_complete_timeout(hisi_hba, 100, 5000); in hisi_sas_controller_reset_prepare()
1547 * hisi_hba->timer is only used for v1/v2 hw, and check hw->sht in hisi_sas_controller_reset_prepare()
1550 if (hisi_hba->hw->sht) in hisi_sas_controller_reset_prepare()
1551 del_timer_sync(&hisi_hba->timer); in hisi_sas_controller_reset_prepare()
1553 set_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags); in hisi_sas_controller_reset_prepare()
1559 struct hisi_sas_phy *phy = data; in hisi_sas_async_init_wait_phyup() local
1560 struct hisi_hba *hisi_hba = phy->hisi_hba; in hisi_sas_async_init_wait_phyup()
1561 struct device *dev = hisi_hba->dev; in hisi_sas_async_init_wait_phyup()
1563 int phy_no = phy->sas_phy.id; in hisi_sas_async_init_wait_phyup()
1565 phy->reset_completion = &completion; in hisi_sas_async_init_wait_phyup()
1569 dev_warn(dev, "phy%d wait phyup timed out\n", phy_no); in hisi_sas_async_init_wait_phyup()
1571 phy->reset_completion = NULL; in hisi_sas_async_init_wait_phyup()
1576 struct Scsi_Host *shost = hisi_hba->shost; in hisi_sas_controller_reset_done()
1581 for (phy_no = 0; phy_no < hisi_hba->n_phy; phy_no++) { in hisi_sas_controller_reset_done()
1582 struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; in hisi_sas_controller_reset_done() local
1583 struct asd_sas_phy *sas_phy = &phy->sas_phy; in hisi_sas_controller_reset_done()
1585 if (!sas_phy->phy->enabled) in hisi_sas_controller_reset_done()
1588 if (!(hisi_hba->phy_state & BIT(phy_no))) { in hisi_sas_controller_reset_done()
1594 phy, &async); in hisi_sas_controller_reset_done()
1599 clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags); in hisi_sas_controller_reset_done()
1601 if (hisi_hba->reject_stp_links_msk) in hisi_sas_controller_reset_done()
1605 clear_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags); in hisi_sas_controller_reset_done()
1606 up(&hisi_hba->sem); in hisi_sas_controller_reset_done()
1608 hisi_sas_rescan_topology(hisi_hba, hisi_hba->phy_state); in hisi_sas_controller_reset_done()
1614 if (!hisi_hba->hw->soft_reset) in hisi_sas_controller_prereset()
1615 return -ENOENT; in hisi_sas_controller_prereset()
1617 down(&hisi_hba->sem); in hisi_sas_controller_prereset()
1618 if (test_and_set_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags)) { in hisi_sas_controller_prereset()
1619 up(&hisi_hba->sem); in hisi_sas_controller_prereset()
1620 return -EPERM; in hisi_sas_controller_prereset()
1624 hisi_hba->hw->debugfs_snapshot_regs(hisi_hba); in hisi_sas_controller_prereset()
1631 struct device *dev = hisi_hba->dev; in hisi_sas_controller_reset()
1632 struct Scsi_Host *shost = hisi_hba->shost; in hisi_sas_controller_reset()
1638 rc = hisi_hba->hw->soft_reset(hisi_hba); in hisi_sas_controller_reset()
1641 clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags); in hisi_sas_controller_reset()
1642 up(&hisi_hba->sem); in hisi_sas_controller_reset()
1644 clear_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags); in hisi_sas_controller_reset()
1647 clear_bit(HISI_SAS_HW_FAULT_BIT, &hisi_hba->flags); in hisi_sas_controller_reset()
1658 struct domain_device *device = task->dev; in hisi_sas_abort_task()
1659 struct hisi_sas_device *sas_dev = device->lldd_dev; in hisi_sas_abort_task()
1660 struct hisi_sas_slot *slot = task->lldd_task; in hisi_sas_abort_task()
1669 hisi_hba = dev_to_hisi_hba(task->dev); in hisi_sas_abort_task()
1670 dev = hisi_hba->dev; in hisi_sas_abort_task()
1672 spin_lock_irqsave(&task->task_state_lock, flags); in hisi_sas_abort_task()
1673 if (task->task_state_flags & SAS_TASK_STATE_DONE) { in hisi_sas_abort_task()
1681 cq = &hisi_hba->cq[slot->dlvry_queue]; in hisi_sas_abort_task()
1684 spin_unlock_irqrestore(&task->task_state_lock, flags); in hisi_sas_abort_task()
1688 task->task_state_flags |= SAS_TASK_STATE_ABORTED; in hisi_sas_abort_task()
1689 spin_unlock_irqrestore(&task->task_state_lock, flags); in hisi_sas_abort_task()
1694 if (task->task_proto & SAS_PROTOCOL_SSP) { in hisi_sas_abort_task()
1695 u16 tag = slot->idx; in hisi_sas_abort_task()
1700 slot->dlvry_queue, &internal_abort_data); in hisi_sas_abort_task()
1714 if (task->lldd_task) in hisi_sas_abort_task()
1717 } else if (task->task_proto & SAS_PROTOCOL_SATA || in hisi_sas_abort_task()
1718 task->task_proto & SAS_PROTOCOL_STP) { in hisi_sas_abort_task()
1719 if (task->dev->dev_type == SAS_SATA_DEV) { in hisi_sas_abort_task()
1720 struct ata_queued_cmd *qc = task->uldd_task; in hisi_sas_abort_task()
1733 if ((sas_dev->dev_status == HISI_SAS_DEV_NCQ_ERR) && in hisi_sas_abort_task()
1734 qc && qc->scsicmd) { in hisi_sas_abort_task()
1741 } else if (task->task_proto & SAS_PROTOCOL_SMP) { in hisi_sas_abort_task()
1743 u32 tag = slot->idx; in hisi_sas_abort_task()
1744 struct hisi_sas_cq *cq = &hisi_hba->cq[slot->dlvry_queue]; in hisi_sas_abort_task()
1747 tag, slot->dlvry_queue, in hisi_sas_abort_task()
1750 task->lldd_task) { in hisi_sas_abort_task()
1756 slot->task = NULL; in hisi_sas_abort_task()
1768 struct hisi_sas_device *sas_dev = device->lldd_dev; in hisi_sas_abort_task_set()
1770 struct device *dev = hisi_hba->dev; in hisi_sas_abort_task_set()
1790 struct hisi_sas_device *sas_dev = device->lldd_dev; in hisi_sas_debug_I_T_nexus_reset()
1792 struct sas_ha_struct *sas_ha = &hisi_hba->sha; in hisi_sas_debug_I_T_nexus_reset()
1795 if (!local_phy->enabled) { in hisi_sas_debug_I_T_nexus_reset()
1797 return -ENODEV; in hisi_sas_debug_I_T_nexus_reset()
1802 sas_ha->sas_phy[local_phy->number]; in hisi_sas_debug_I_T_nexus_reset()
1803 struct hisi_sas_phy *phy = in hisi_sas_debug_I_T_nexus_reset() local
1807 spin_lock_irqsave(&phy->lock, flags); in hisi_sas_debug_I_T_nexus_reset()
1808 phy->in_reset = 1; in hisi_sas_debug_I_T_nexus_reset()
1809 spin_unlock_irqrestore(&phy->lock, flags); in hisi_sas_debug_I_T_nexus_reset()
1812 reset_type = (sas_dev->dev_status == HISI_SAS_DEV_INIT || in hisi_sas_debug_I_T_nexus_reset()
1820 sas_ha->sas_phy[local_phy->number]; in hisi_sas_debug_I_T_nexus_reset()
1821 struct hisi_sas_phy *phy = in hisi_sas_debug_I_T_nexus_reset() local
1825 spin_lock_irqsave(&phy->lock, flags); in hisi_sas_debug_I_T_nexus_reset()
1826 phy->in_reset = 0; in hisi_sas_debug_I_T_nexus_reset()
1827 spin_unlock_irqrestore(&phy->lock, flags); in hisi_sas_debug_I_T_nexus_reset()
1829 /* report PHY down if timed out */ in hisi_sas_debug_I_T_nexus_reset()
1830 if (rc == -ETIMEDOUT) in hisi_sas_debug_I_T_nexus_reset()
1831 hisi_sas_phy_down(hisi_hba, sas_phy->id, 0, GFP_KERNEL); in hisi_sas_debug_I_T_nexus_reset()
1835 /* Remote phy */ in hisi_sas_debug_I_T_nexus_reset()
1840 struct ata_link *link = &device->sata_dev.ap->link; in hisi_sas_debug_I_T_nexus_reset()
1853 struct hisi_sas_device *sas_dev = device->lldd_dev; in hisi_sas_I_T_nexus_reset()
1855 struct device *dev = hisi_hba->dev; in hisi_sas_I_T_nexus_reset()
1858 if (sas_dev->dev_status == HISI_SAS_DEV_NCQ_ERR) in hisi_sas_I_T_nexus_reset()
1859 sas_dev->dev_status = HISI_SAS_DEV_NORMAL; in hisi_sas_I_T_nexus_reset()
1874 case -ECOMM: in hisi_sas_I_T_nexus_reset()
1875 rc = -ENODEV; in hisi_sas_I_T_nexus_reset()
1878 case -EMSGSIZE: in hisi_sas_I_T_nexus_reset()
1879 case -EIO: in hisi_sas_I_T_nexus_reset()
1883 local_phy->enabled = 0; in hisi_sas_I_T_nexus_reset()
1884 dev_err(dev, "Disabled local phy of ATA disk %016llx due to softreset fail (%d)\n", in hisi_sas_I_T_nexus_reset()
1885 SAS_ADDR(device->sas_addr), rc); in hisi_sas_I_T_nexus_reset()
1886 rc = -ENODEV; in hisi_sas_I_T_nexus_reset()
1895 if ((rc == TMF_RESP_FUNC_COMPLETE) || (rc == -ENODEV)) in hisi_sas_I_T_nexus_reset()
1903 struct hisi_sas_device *sas_dev = device->lldd_dev; in hisi_sas_lu_reset()
1905 struct device *dev = hisi_hba->dev; in hisi_sas_lu_reset()
1917 struct sas_phy *phy; in hisi_sas_lu_reset() local
1919 phy = sas_get_local_phy(device); in hisi_sas_lu_reset()
1921 rc = sas_phy_reset(phy, true); in hisi_sas_lu_reset()
1925 sas_put_local_phy(phy); in hisi_sas_lu_reset()
1934 sas_dev->device_id, rc); in hisi_sas_lu_reset()
1946 dev_info(hisi_hba->dev, "I_T_nexus reset fail for dev:%016llx rc=%d\n", in hisi_sas_async_I_T_nexus_reset()
1947 SAS_ADDR(device->sas_addr), rc); in hisi_sas_async_I_T_nexus_reset()
1952 struct hisi_hba *hisi_hba = sas_ha->lldd_ha; in hisi_sas_clear_nexus_ha()
1957 queue_work(hisi_hba->wq, &r.work); in hisi_sas_clear_nexus_ha()
1963 struct hisi_sas_device *sas_dev = &hisi_hba->devices[i]; in hisi_sas_clear_nexus_ha()
1964 struct domain_device *device = sas_dev->sas_device; in hisi_sas_clear_nexus_ha()
1966 if ((sas_dev->dev_type == SAS_PHY_UNUSED) || !device || in hisi_sas_clear_nexus_ha()
1967 dev_is_expander(device->dev_type)) in hisi_sas_clear_nexus_ha()
1984 if (task->lldd_task && task->task_proto & SAS_PROTOCOL_SSP) { in hisi_sas_query_task()
1985 struct hisi_sas_slot *slot = task->lldd_task; in hisi_sas_query_task()
1986 u32 tag = slot->idx; in hisi_sas_query_task()
1992 /* The task is not in Lun or failed, reset the phy */ in hisi_sas_query_task()
2007 struct domain_device *device = task->dev; in hisi_sas_internal_abort_timeout()
2015 * hisi_sas_dev_gone() -> down() -> ... -> in hisi_sas_internal_abort_timeout()
2016 * hisi_sas_internal_abort_timeout() -> down(). in hisi_sas_internal_abort_timeout()
2018 if (!timeout->rst_ha_timeout) in hisi_sas_internal_abort_timeout()
2019 down(&hisi_hba->sem); in hisi_sas_internal_abort_timeout()
2020 hisi_hba->hw->debugfs_snapshot_regs(hisi_hba); in hisi_sas_internal_abort_timeout()
2021 if (!timeout->rst_ha_timeout) in hisi_sas_internal_abort_timeout()
2022 up(&hisi_hba->sem); in hisi_sas_internal_abort_timeout()
2025 if (task->task_state_flags & SAS_TASK_STATE_DONE) { in hisi_sas_internal_abort_timeout()
2027 SAS_ADDR(device->sas_addr)); in hisi_sas_internal_abort_timeout()
2029 struct hisi_sas_slot *slot = task->lldd_task; in hisi_sas_internal_abort_timeout()
2031 set_bit(HISI_SAS_HW_FAULT_BIT, &hisi_hba->flags); in hisi_sas_internal_abort_timeout()
2035 &hisi_hba->cq[slot->dlvry_queue]; in hisi_sas_internal_abort_timeout()
2041 slot->task = NULL; in hisi_sas_internal_abort_timeout()
2044 if (timeout->rst_ha_timeout) { in hisi_sas_internal_abort_timeout()
2046 SAS_ADDR(device->sas_addr)); in hisi_sas_internal_abort_timeout()
2047 queue_work(hisi_hba->wq, &hisi_hba->rst_work); in hisi_sas_internal_abort_timeout()
2050 SAS_ADDR(device->sas_addr)); in hisi_sas_internal_abort_timeout()
2067 struct hisi_hba *hisi_hba = sha->lldd_ha; in hisi_sas_write_gpio()
2069 if (!hisi_hba->hw->write_gpio) in hisi_sas_write_gpio()
2070 return -EOPNOTSUPP; in hisi_sas_write_gpio()
2072 return hisi_hba->hw->write_gpio(hisi_hba, reg_type, in hisi_sas_write_gpio()
2076 static void hisi_sas_phy_disconnected(struct hisi_sas_phy *phy) in hisi_sas_phy_disconnected() argument
2078 struct asd_sas_phy *sas_phy = &phy->sas_phy; in hisi_sas_phy_disconnected()
2079 struct sas_phy *sphy = sas_phy->phy; in hisi_sas_phy_disconnected()
2082 phy->phy_attached = 0; in hisi_sas_phy_disconnected()
2083 phy->phy_type = 0; in hisi_sas_phy_disconnected()
2084 phy->port = NULL; in hisi_sas_phy_disconnected()
2086 spin_lock_irqsave(&phy->lock, flags); in hisi_sas_phy_disconnected()
2087 if (phy->enable) in hisi_sas_phy_disconnected()
2088 sphy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN; in hisi_sas_phy_disconnected()
2090 sphy->negotiated_linkrate = SAS_PHY_DISABLED; in hisi_sas_phy_disconnected()
2091 spin_unlock_irqrestore(&phy->lock, flags); in hisi_sas_phy_disconnected()
2097 struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; in hisi_sas_phy_down() local
2098 struct asd_sas_phy *sas_phy = &phy->sas_phy; in hisi_sas_phy_down()
2099 struct device *dev = hisi_hba->dev; in hisi_sas_phy_down()
2102 /* Phy down but ready */ in hisi_sas_phy_down()
2106 struct hisi_sas_port *port = phy->port; in hisi_sas_phy_down()
2108 if (test_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags) || in hisi_sas_phy_down()
2109 phy->in_reset) { in hisi_sas_phy_down()
2110 dev_info(dev, "ignore flutter phy%d down\n", phy_no); in hisi_sas_phy_down()
2113 /* Phy down and not ready */ in hisi_sas_phy_down()
2118 if (phy->phy_type & PORT_TYPE_SAS) { in hisi_sas_phy_down()
2119 int port_id = port->id; in hisi_sas_phy_down()
2121 if (!hisi_hba->hw->get_wideport_bitmap(hisi_hba, in hisi_sas_phy_down()
2123 port->port_attached = 0; in hisi_sas_phy_down()
2124 } else if (phy->phy_type & PORT_TYPE_SATA) in hisi_sas_phy_down()
2125 port->port_attached = 0; in hisi_sas_phy_down()
2127 hisi_sas_phy_disconnected(phy); in hisi_sas_phy_down()
2132 void hisi_sas_phy_bcast(struct hisi_sas_phy *phy) in hisi_sas_phy_bcast() argument
2134 struct asd_sas_phy *sas_phy = &phy->sas_phy; in hisi_sas_phy_bcast()
2135 struct hisi_hba *hisi_hba = phy->hisi_hba; in hisi_sas_phy_bcast()
2137 if (test_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags)) in hisi_sas_phy_bcast()
2149 return -EOPNOTSUPP; in hisi_sas_host_reset()
2151 queue_work(hisi_hba->wq, &hisi_hba->rst_work); in hisi_sas_host_reset()
2179 int i, s, j, max_command_entries = HISI_SAS_MAX_COMMANDS; in hisi_sas_init_mem() local
2180 struct hisi_sas_breakpoint *sata_breakpoint = hisi_hba->sata_breakpoint; in hisi_sas_init_mem()
2182 for (i = 0; i < hisi_hba->queue_count; i++) { in hisi_sas_init_mem()
2183 struct hisi_sas_cq *cq = &hisi_hba->cq[i]; in hisi_sas_init_mem()
2184 struct hisi_sas_dq *dq = &hisi_hba->dq[i]; in hisi_sas_init_mem()
2185 struct hisi_sas_cmd_hdr *cmd_hdr = hisi_hba->cmd_hdr[i]; in hisi_sas_init_mem()
2187 s = sizeof(struct hisi_sas_cmd_hdr); in hisi_sas_init_mem()
2189 memset(&cmd_hdr[j], 0, s); in hisi_sas_init_mem()
2191 dq->wr_point = 0; in hisi_sas_init_mem()
2193 s = hisi_hba->hw->complete_hdr_size * HISI_SAS_QUEUE_SLOTS; in hisi_sas_init_mem()
2194 memset(hisi_hba->complete_hdr[i], 0, s); in hisi_sas_init_mem()
2195 cq->rd_point = 0; in hisi_sas_init_mem()
2198 s = sizeof(struct hisi_sas_initial_fis) * hisi_hba->n_phy; in hisi_sas_init_mem()
2199 memset(hisi_hba->initial_fis, 0, s); in hisi_sas_init_mem()
2201 s = max_command_entries * sizeof(struct hisi_sas_iost); in hisi_sas_init_mem()
2202 memset(hisi_hba->iost, 0, s); in hisi_sas_init_mem()
2204 s = max_command_entries * sizeof(struct hisi_sas_breakpoint); in hisi_sas_init_mem()
2205 memset(hisi_hba->breakpoint, 0, s); in hisi_sas_init_mem()
2207 s = sizeof(struct hisi_sas_sata_breakpoint); in hisi_sas_init_mem()
2209 memset(&sata_breakpoint[j], 0, s); in hisi_sas_init_mem()
2215 struct device *dev = hisi_hba->dev; in hisi_sas_alloc()
2216 int i, j, s, max_command_entries = HISI_SAS_MAX_COMMANDS; in hisi_sas_alloc() local
2220 sema_init(&hisi_hba->sem, 1); in hisi_sas_alloc()
2221 spin_lock_init(&hisi_hba->lock); in hisi_sas_alloc()
2222 for (i = 0; i < hisi_hba->n_phy; i++) { in hisi_sas_alloc()
2224 hisi_hba->port[i].port_attached = 0; in hisi_sas_alloc()
2225 hisi_hba->port[i].id = -1; in hisi_sas_alloc()
2229 hisi_hba->devices[i].dev_type = SAS_PHY_UNUSED; in hisi_sas_alloc()
2230 hisi_hba->devices[i].device_id = i; in hisi_sas_alloc()
2231 hisi_hba->devices[i].dev_status = HISI_SAS_DEV_INIT; in hisi_sas_alloc()
2234 for (i = 0; i < hisi_hba->queue_count; i++) { in hisi_sas_alloc()
2235 struct hisi_sas_cq *cq = &hisi_hba->cq[i]; in hisi_sas_alloc()
2236 struct hisi_sas_dq *dq = &hisi_hba->dq[i]; in hisi_sas_alloc()
2239 cq->id = i; in hisi_sas_alloc()
2240 cq->hisi_hba = hisi_hba; in hisi_sas_alloc()
2241 spin_lock_init(&cq->poll_lock); in hisi_sas_alloc()
2244 spin_lock_init(&dq->lock); in hisi_sas_alloc()
2245 INIT_LIST_HEAD(&dq->list); in hisi_sas_alloc()
2246 dq->id = i; in hisi_sas_alloc()
2247 dq->hisi_hba = hisi_hba; in hisi_sas_alloc()
2250 s = sizeof(struct hisi_sas_cmd_hdr) * HISI_SAS_QUEUE_SLOTS; in hisi_sas_alloc()
2251 hisi_hba->cmd_hdr[i] = dmam_alloc_coherent(dev, s, in hisi_sas_alloc()
2252 &hisi_hba->cmd_hdr_dma[i], in hisi_sas_alloc()
2254 if (!hisi_hba->cmd_hdr[i]) in hisi_sas_alloc()
2258 s = hisi_hba->hw->complete_hdr_size * HISI_SAS_QUEUE_SLOTS; in hisi_sas_alloc()
2259 hisi_hba->complete_hdr[i] = dmam_alloc_coherent(dev, s, in hisi_sas_alloc()
2260 &hisi_hba->complete_hdr_dma[i], in hisi_sas_alloc()
2262 if (!hisi_hba->complete_hdr[i]) in hisi_sas_alloc()
2266 s = HISI_SAS_MAX_ITCT_ENTRIES * sizeof(struct hisi_sas_itct); in hisi_sas_alloc()
2267 hisi_hba->itct = dmam_alloc_coherent(dev, s, &hisi_hba->itct_dma, in hisi_sas_alloc()
2269 if (!hisi_hba->itct) in hisi_sas_alloc()
2272 hisi_hba->slot_info = devm_kcalloc(dev, max_command_entries, in hisi_sas_alloc()
2275 if (!hisi_hba->slot_info) in hisi_sas_alloc()
2280 if (hisi_hba->prot_mask & HISI_SAS_DIX_PROT_MASK) in hisi_sas_alloc()
2285 s = max(lcm(max_command_entries_ru, sz_slot_buf_ru), PAGE_SIZE); in hisi_sas_alloc()
2286 blk_cnt = (max_command_entries_ru * sz_slot_buf_ru) / s; in hisi_sas_alloc()
2287 slots_per_blk = s / sz_slot_buf_ru; in hisi_sas_alloc()
2294 buf = dmam_alloc_coherent(dev, s, &buf_dma, in hisi_sas_alloc()
2302 slot = &hisi_hba->slot_info[slot_index]; in hisi_sas_alloc()
2303 slot->buf = buf; in hisi_sas_alloc()
2304 slot->buf_dma = buf_dma; in hisi_sas_alloc()
2305 slot->idx = slot_index; in hisi_sas_alloc()
2312 s = max_command_entries * sizeof(struct hisi_sas_iost); in hisi_sas_alloc()
2313 hisi_hba->iost = dmam_alloc_coherent(dev, s, &hisi_hba->iost_dma, in hisi_sas_alloc()
2315 if (!hisi_hba->iost) in hisi_sas_alloc()
2318 s = max_command_entries * sizeof(struct hisi_sas_breakpoint); in hisi_sas_alloc()
2319 hisi_hba->breakpoint = dmam_alloc_coherent(dev, s, in hisi_sas_alloc()
2320 &hisi_hba->breakpoint_dma, in hisi_sas_alloc()
2322 if (!hisi_hba->breakpoint) in hisi_sas_alloc()
2325 s = hisi_hba->slot_index_count = max_command_entries; in hisi_sas_alloc()
2326 hisi_hba->slot_index_tags = devm_bitmap_zalloc(dev, s, GFP_KERNEL); in hisi_sas_alloc()
2327 if (!hisi_hba->slot_index_tags) in hisi_sas_alloc()
2330 s = sizeof(struct hisi_sas_initial_fis) * HISI_SAS_MAX_PHYS; in hisi_sas_alloc()
2331 hisi_hba->initial_fis = dmam_alloc_coherent(dev, s, in hisi_sas_alloc()
2332 &hisi_hba->initial_fis_dma, in hisi_sas_alloc()
2334 if (!hisi_hba->initial_fis) in hisi_sas_alloc()
2337 s = HISI_SAS_MAX_ITCT_ENTRIES * sizeof(struct hisi_sas_sata_breakpoint); in hisi_sas_alloc()
2338 hisi_hba->sata_breakpoint = dmam_alloc_coherent(dev, s, in hisi_sas_alloc()
2339 &hisi_hba->sata_breakpoint_dma, in hisi_sas_alloc()
2341 if (!hisi_hba->sata_breakpoint) in hisi_sas_alloc()
2344 hisi_hba->last_slot_index = 0; in hisi_sas_alloc()
2346 hisi_hba->wq = in hisi_sas_alloc()
2347 alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, dev_name(dev)); in hisi_sas_alloc()
2348 if (!hisi_hba->wq) { in hisi_sas_alloc()
2355 return -ENOMEM; in hisi_sas_alloc()
2363 for (i = 0; i < hisi_hba->n_phy; i++) { in hisi_sas_free()
2364 struct hisi_sas_phy *phy = &hisi_hba->phy[i]; in hisi_sas_free() local
2366 del_timer_sync(&phy->timer); in hisi_sas_free()
2369 if (hisi_hba->wq) in hisi_sas_free()
2370 destroy_workqueue(hisi_hba->wq); in hisi_sas_free()
2391 if (hisi_sas_controller_prereset(rst->hisi_hba)) in hisi_sas_sync_rst_work_handler()
2394 if (!hisi_sas_controller_reset(rst->hisi_hba)) in hisi_sas_sync_rst_work_handler()
2395 rst->done = true; in hisi_sas_sync_rst_work_handler()
2397 complete(rst->completion); in hisi_sas_sync_rst_work_handler()
2403 struct device *dev = hisi_hba->dev; in hisi_sas_get_fw_info()
2404 struct platform_device *pdev = hisi_hba->platform_dev; in hisi_sas_get_fw_info()
2405 struct device_node *np = pdev ? pdev->dev.of_node : NULL; in hisi_sas_get_fw_info()
2408 if (device_property_read_u8_array(dev, "sas-addr", hisi_hba->sas_addr, in hisi_sas_get_fw_info()
2410 dev_err(dev, "could not get property sas-addr\n"); in hisi_sas_get_fw_info()
2411 return -ENOENT; in hisi_sas_get_fw_info()
2416 * These properties are only required for platform device-based in hisi_sas_get_fw_info()
2419 hisi_hba->ctrl = syscon_regmap_lookup_by_phandle(np, in hisi_sas_get_fw_info()
2420 "hisilicon,sas-syscon"); in hisi_sas_get_fw_info()
2421 if (IS_ERR(hisi_hba->ctrl)) { in hisi_sas_get_fw_info()
2423 return -ENOENT; in hisi_sas_get_fw_info()
2426 if (device_property_read_u32(dev, "ctrl-reset-reg", in hisi_sas_get_fw_info()
2427 &hisi_hba->ctrl_reset_reg)) { in hisi_sas_get_fw_info()
2428 dev_err(dev, "could not get property ctrl-reset-reg\n"); in hisi_sas_get_fw_info()
2429 return -ENOENT; in hisi_sas_get_fw_info()
2432 if (device_property_read_u32(dev, "ctrl-reset-sts-reg", in hisi_sas_get_fw_info()
2433 &hisi_hba->ctrl_reset_sts_reg)) { in hisi_sas_get_fw_info()
2434 dev_err(dev, "could not get property ctrl-reset-sts-reg\n"); in hisi_sas_get_fw_info()
2435 return -ENOENT; in hisi_sas_get_fw_info()
2438 if (device_property_read_u32(dev, "ctrl-clock-ena-reg", in hisi_sas_get_fw_info()
2439 &hisi_hba->ctrl_clock_ena_reg)) { in hisi_sas_get_fw_info()
2440 dev_err(dev, "could not get property ctrl-clock-ena-reg\n"); in hisi_sas_get_fw_info()
2441 return -ENOENT; in hisi_sas_get_fw_info()
2449 hisi_hba->refclk_frequency_mhz = clk_get_rate(refclk) / 1000000; in hisi_sas_get_fw_info()
2451 if (device_property_read_u32(dev, "phy-count", &hisi_hba->n_phy)) { in hisi_sas_get_fw_info()
2452 dev_err(dev, "could not get property phy-count\n"); in hisi_sas_get_fw_info()
2453 return -ENOENT; in hisi_sas_get_fw_info()
2456 if (device_property_read_u32(dev, "queue-count", in hisi_sas_get_fw_info()
2457 &hisi_hba->queue_count)) { in hisi_sas_get_fw_info()
2458 dev_err(dev, "could not get property queue-count\n"); in hisi_sas_get_fw_info()
2459 return -ENOENT; in hisi_sas_get_fw_info()
2472 struct device *dev = &pdev->dev; in hisi_sas_shost_alloc()
2475 shost = scsi_host_alloc(hw->sht, sizeof(*hisi_hba)); in hisi_sas_shost_alloc()
2482 INIT_WORK(&hisi_hba->rst_work, hisi_sas_rst_work_handler); in hisi_sas_shost_alloc()
2483 hisi_hba->hw = hw; in hisi_sas_shost_alloc()
2484 hisi_hba->dev = dev; in hisi_sas_shost_alloc()
2485 hisi_hba->platform_dev = pdev; in hisi_sas_shost_alloc()
2486 hisi_hba->shost = shost; in hisi_sas_shost_alloc()
2487 SHOST_TO_SAS_HA(shost) = &hisi_hba->sha; in hisi_sas_shost_alloc()
2489 timer_setup(&hisi_hba->timer, NULL, 0); in hisi_sas_shost_alloc()
2494 if (hisi_hba->hw->fw_info_check) { in hisi_sas_shost_alloc()
2495 if (hisi_hba->hw->fw_info_check(hisi_hba)) in hisi_sas_shost_alloc()
2505 hisi_hba->regs = devm_platform_ioremap_resource(pdev, 0); in hisi_sas_shost_alloc()
2506 if (IS_ERR(hisi_hba->regs)) in hisi_sas_shost_alloc()
2511 hisi_hba->sgpio_regs = devm_ioremap_resource(dev, res); in hisi_sas_shost_alloc()
2512 if (IS_ERR(hisi_hba->sgpio_regs)) in hisi_sas_shost_alloc()
2530 if (hisi_hba->hw->interrupt_preinit) in hisi_sas_interrupt_preinit()
2531 return hisi_hba->hw->interrupt_preinit(hisi_hba); in hisi_sas_interrupt_preinit()
2540 struct device *dev = &pdev->dev; in hisi_sas_probe()
2548 return -ENOMEM; in hisi_sas_probe()
2554 phy_nr = port_nr = hisi_hba->n_phy; in hisi_sas_probe()
2559 rc = -ENOMEM; in hisi_sas_probe()
2563 sha->sas_phy = arr_phy; in hisi_sas_probe()
2564 sha->sas_port = arr_port; in hisi_sas_probe()
2565 sha->lldd_ha = hisi_hba; in hisi_sas_probe()
2567 shost->transportt = hisi_sas_stt; in hisi_sas_probe()
2568 shost->max_id = HISI_SAS_MAX_DEVICES; in hisi_sas_probe()
2569 shost->max_lun = ~0; in hisi_sas_probe()
2570 shost->max_channel = 1; in hisi_sas_probe()
2571 shost->max_cmd_len = 16; in hisi_sas_probe()
2572 if (hisi_hba->hw->slot_index_alloc) { in hisi_sas_probe()
2573 shost->can_queue = HISI_SAS_MAX_COMMANDS; in hisi_sas_probe()
2574 shost->cmd_per_lun = HISI_SAS_MAX_COMMANDS; in hisi_sas_probe()
2576 shost->can_queue = HISI_SAS_UNRESERVED_IPTT; in hisi_sas_probe()
2577 shost->cmd_per_lun = HISI_SAS_UNRESERVED_IPTT; in hisi_sas_probe()
2580 sha->sas_ha_name = DRV_NAME; in hisi_sas_probe()
2581 sha->dev = hisi_hba->dev; in hisi_sas_probe()
2582 sha->sas_addr = &hisi_hba->sas_addr[0]; in hisi_sas_probe()
2583 sha->num_phys = hisi_hba->n_phy; in hisi_sas_probe()
2584 sha->shost = hisi_hba->shost; in hisi_sas_probe()
2586 for (i = 0; i < hisi_hba->n_phy; i++) { in hisi_sas_probe()
2587 sha->sas_phy[i] = &hisi_hba->phy[i].sas_phy; in hisi_sas_probe()
2588 sha->sas_port[i] = &hisi_hba->port[i].sas_port; in hisi_sas_probe()
2595 rc = scsi_add_host(shost, &pdev->dev); in hisi_sas_probe()
2603 rc = hisi_hba->hw->hw_init(hisi_hba); in hisi_sas_probe()
2625 struct hisi_hba *hisi_hba = sha->lldd_ha; in hisi_sas_remove()
2626 struct Scsi_Host *shost = sha->shost; in hisi_sas_remove()
2628 del_timer_sync(&hisi_hba->timer); in hisi_sas_remove()
2664 return -ENOMEM; in hisi_sas_init()