Lines Matching +full:retain +full:- +full:state +full:- +full:suspended
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
33 * * Redistributions of source code must retain the above copyright
66 const char *req_state_name(enum sci_base_request_states state) in req_state_name() argument
70 return strings[state]; in req_state_name()
78 return &ireq->tc->sgl_pair_ab; in to_sgl_element_pair()
80 return &ireq->tc->sgl_pair_cd; in to_sgl_element_pair()
84 return &ireq->sg_table[idx - 2]; in to_sgl_element_pair()
93 offset = (void *) &ireq->tc->sgl_pair_ab - in to_sgl_element_pair_dma()
94 (void *) &ihost->task_context_table[0]; in to_sgl_element_pair_dma()
95 return ihost->tc_dma + offset; in to_sgl_element_pair_dma()
97 offset = (void *) &ireq->tc->sgl_pair_cd - in to_sgl_element_pair_dma()
98 (void *) &ihost->task_context_table[0]; in to_sgl_element_pair_dma()
99 return ihost->tc_dma + offset; in to_sgl_element_pair_dma()
102 return sci_io_request_get_dma_addr(ireq, &ireq->sg_table[idx - 2]); in to_sgl_element_pair_dma()
107 e->length = sg_dma_len(sg); in init_sgl_element()
108 e->address_upper = upper_32_bits(sg_dma_address(sg)); in init_sgl_element()
109 e->address_lower = lower_32_bits(sg_dma_address(sg)); in init_sgl_element()
110 e->address_modifier = 0; in init_sgl_element()
115 struct isci_host *ihost = ireq->isci_host; in sci_request_build_sgl()
123 if (task->num_scatter > 0) { in sci_request_build_sgl()
124 sg = task->scatter; in sci_request_build_sgl()
128 init_sgl_element(&scu_sg->A, sg); in sci_request_build_sgl()
131 init_sgl_element(&scu_sg->B, sg); in sci_request_build_sgl()
134 memset(&scu_sg->B, 0, sizeof(scu_sg->B)); in sci_request_build_sgl()
141 prev_sg->next_pair_upper = in sci_request_build_sgl()
143 prev_sg->next_pair_lower = in sci_request_build_sgl()
153 dma_addr = dma_map_single(&ihost->pdev->dev, in sci_request_build_sgl()
154 task->scatter, in sci_request_build_sgl()
155 task->total_xfer_len, in sci_request_build_sgl()
156 task->data_dir); in sci_request_build_sgl()
158 ireq->zero_scatter_daddr = dma_addr; in sci_request_build_sgl()
160 scu_sg->A.length = task->total_xfer_len; in sci_request_build_sgl()
161 scu_sg->A.address_upper = upper_32_bits(dma_addr); in sci_request_build_sgl()
162 scu_sg->A.address_lower = lower_32_bits(dma_addr); in sci_request_build_sgl()
166 scu_sg->next_pair_upper = 0; in sci_request_build_sgl()
167 scu_sg->next_pair_lower = 0; in sci_request_build_sgl()
176 cmd_iu = &ireq->ssp.cmd; in sci_io_request_build_ssp_command_iu()
178 memcpy(cmd_iu->LUN, task->ssp_task.LUN, 8); in sci_io_request_build_ssp_command_iu()
179 cmd_iu->add_cdb_len = 0; in sci_io_request_build_ssp_command_iu()
180 cmd_iu->_r_a = 0; in sci_io_request_build_ssp_command_iu()
181 cmd_iu->_r_b = 0; in sci_io_request_build_ssp_command_iu()
182 cmd_iu->en_fburst = 0; /* unsupported */ in sci_io_request_build_ssp_command_iu()
183 cmd_iu->task_prio = task->ssp_task.task_prio; in sci_io_request_build_ssp_command_iu()
184 cmd_iu->task_attr = task->ssp_task.task_attr; in sci_io_request_build_ssp_command_iu()
185 cmd_iu->_r_c = 0; in sci_io_request_build_ssp_command_iu()
187 sci_swab32_cpy(&cmd_iu->cdb, task->ssp_task.cmd->cmnd, in sci_io_request_build_ssp_command_iu()
188 (task->ssp_task.cmd->cmd_len+3) / sizeof(u32)); in sci_io_request_build_ssp_command_iu()
197 task_iu = &ireq->ssp.tmf; in sci_task_request_build_ssp_task_iu()
201 memcpy(task_iu->LUN, task->ssp_task.LUN, 8); in sci_task_request_build_ssp_task_iu()
203 task_iu->task_func = isci_tmf->tmf_code; in sci_task_request_build_ssp_task_iu()
204 task_iu->task_tag = in sci_task_request_build_ssp_task_iu()
205 (test_bit(IREQ_TMF, &ireq->flags)) ? in sci_task_request_build_ssp_task_iu()
206 isci_tmf->io_tag : in sci_task_request_build_ssp_task_iu()
224 idev = ireq->target_device; in scu_ssp_request_construct_task_context()
225 iport = idev->owning_port; in scu_ssp_request_construct_task_context()
228 task_context->abort = 0; in scu_ssp_request_construct_task_context()
229 task_context->priority = 0; in scu_ssp_request_construct_task_context()
230 task_context->initiator_request = 1; in scu_ssp_request_construct_task_context()
231 task_context->connection_rate = idev->connection_rate; in scu_ssp_request_construct_task_context()
232 task_context->protocol_engine_index = ISCI_PEG; in scu_ssp_request_construct_task_context()
233 task_context->logical_port_index = iport->physical_port_index; in scu_ssp_request_construct_task_context()
234 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SSP; in scu_ssp_request_construct_task_context()
235 task_context->valid = SCU_TASK_CONTEXT_VALID; in scu_ssp_request_construct_task_context()
236 task_context->context_type = SCU_TASK_CONTEXT_TYPE; in scu_ssp_request_construct_task_context()
238 task_context->remote_node_index = idev->rnc.remote_node_index; in scu_ssp_request_construct_task_context()
239 task_context->command_code = 0; in scu_ssp_request_construct_task_context()
241 task_context->link_layer_control = 0; in scu_ssp_request_construct_task_context()
242 task_context->do_not_dma_ssp_good_response = 1; in scu_ssp_request_construct_task_context()
243 task_context->strict_ordering = 0; in scu_ssp_request_construct_task_context()
244 task_context->control_frame = 0; in scu_ssp_request_construct_task_context()
245 task_context->timeout_enable = 0; in scu_ssp_request_construct_task_context()
246 task_context->block_guard_enable = 0; in scu_ssp_request_construct_task_context()
248 task_context->address_modifier = 0; in scu_ssp_request_construct_task_context()
250 /* task_context->type.ssp.tag = ireq->io_tag; */ in scu_ssp_request_construct_task_context()
251 task_context->task_phase = 0x01; in scu_ssp_request_construct_task_context()
253 ireq->post_context = (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | in scu_ssp_request_construct_task_context()
255 (iport->physical_port_index << in scu_ssp_request_construct_task_context()
257 ISCI_TAG_TCI(ireq->io_tag)); in scu_ssp_request_construct_task_context()
263 dma_addr = sci_io_request_get_dma_addr(ireq, &ireq->ssp.cmd); in scu_ssp_request_construct_task_context()
265 task_context->command_iu_upper = upper_32_bits(dma_addr); in scu_ssp_request_construct_task_context()
266 task_context->command_iu_lower = lower_32_bits(dma_addr); in scu_ssp_request_construct_task_context()
272 dma_addr = sci_io_request_get_dma_addr(ireq, &ireq->ssp.rsp); in scu_ssp_request_construct_task_context()
274 task_context->response_iu_upper = upper_32_bits(dma_addr); in scu_ssp_request_construct_task_context()
275 task_context->response_iu_lower = lower_32_bits(dma_addr); in scu_ssp_request_construct_task_context()
280 switch (sdp->sector_size) { in scu_bg_blk_size()
299 struct scu_task_context *tc = ireq->tc; in scu_ssp_ireq_dif_insert()
300 struct scsi_cmnd *scmd = ireq->ttype_ptr.io_task_ptr->uldd_task; in scu_ssp_ireq_dif_insert()
301 u8 blk_sz = scu_bg_blk_size(scmd->device); in scu_ssp_ireq_dif_insert()
303 tc->block_guard_enable = 1; in scu_ssp_ireq_dif_insert()
304 tc->blk_prot_en = 1; in scu_ssp_ireq_dif_insert()
305 tc->blk_sz = blk_sz; in scu_ssp_ireq_dif_insert()
307 tc->blk_prot_func = 0x2; in scu_ssp_ireq_dif_insert()
309 tc->transfer_length_bytes += scu_dif_bytes(tc->transfer_length_bytes, in scu_ssp_ireq_dif_insert()
310 scmd->device->sector_size); in scu_ssp_ireq_dif_insert()
313 tc->interm_crc_val = 0; in scu_ssp_ireq_dif_insert()
315 tc->init_crc_seed = 0; in scu_ssp_ireq_dif_insert()
316 tc->app_tag_verify = 0; in scu_ssp_ireq_dif_insert()
317 tc->app_tag_gen = 0; in scu_ssp_ireq_dif_insert()
318 tc->ref_tag_seed_verify = 0; in scu_ssp_ireq_dif_insert()
321 tc->UD_bytes_immed_val = scmd->device->sector_size; in scu_ssp_ireq_dif_insert()
323 tc->reserved_DC_0 = 0; in scu_ssp_ireq_dif_insert()
326 tc->DIF_bytes_immed_val = 8; in scu_ssp_ireq_dif_insert()
328 tc->reserved_DC_1 = 0; in scu_ssp_ireq_dif_insert()
329 tc->bgc_blk_sz = scmd->device->sector_size; in scu_ssp_ireq_dif_insert()
330 tc->reserved_E0_0 = 0; in scu_ssp_ireq_dif_insert()
331 tc->app_tag_gen_mask = 0; in scu_ssp_ireq_dif_insert()
334 tc->bgctl = 0; in scu_ssp_ireq_dif_insert()
337 tc->bgctl_f.op = 0x2; in scu_ssp_ireq_dif_insert()
339 tc->app_tag_verify_mask = 0; in scu_ssp_ireq_dif_insert()
342 tc->blk_guard_err = 0; in scu_ssp_ireq_dif_insert()
344 tc->reserved_E8_0 = 0; in scu_ssp_ireq_dif_insert()
347 tc->ref_tag_seed_gen = scsi_get_lba(scmd) & 0xffffffff; in scu_ssp_ireq_dif_insert()
349 tc->ref_tag_seed_gen = 0; in scu_ssp_ireq_dif_insert()
354 struct scu_task_context *tc = ireq->tc; in scu_ssp_ireq_dif_strip()
355 struct scsi_cmnd *scmd = ireq->ttype_ptr.io_task_ptr->uldd_task; in scu_ssp_ireq_dif_strip()
356 u8 blk_sz = scu_bg_blk_size(scmd->device); in scu_ssp_ireq_dif_strip()
358 tc->block_guard_enable = 1; in scu_ssp_ireq_dif_strip()
359 tc->blk_prot_en = 1; in scu_ssp_ireq_dif_strip()
360 tc->blk_sz = blk_sz; in scu_ssp_ireq_dif_strip()
362 tc->blk_prot_func = 0x1; in scu_ssp_ireq_dif_strip()
364 tc->transfer_length_bytes += scu_dif_bytes(tc->transfer_length_bytes, in scu_ssp_ireq_dif_strip()
365 scmd->device->sector_size); in scu_ssp_ireq_dif_strip()
368 tc->interm_crc_val = 0; in scu_ssp_ireq_dif_strip()
370 tc->init_crc_seed = 0; in scu_ssp_ireq_dif_strip()
371 tc->app_tag_verify = 0; in scu_ssp_ireq_dif_strip()
372 tc->app_tag_gen = 0; in scu_ssp_ireq_dif_strip()
375 tc->ref_tag_seed_verify = scsi_get_lba(scmd) & 0xffffffff; in scu_ssp_ireq_dif_strip()
377 tc->ref_tag_seed_verify = 0; in scu_ssp_ireq_dif_strip()
380 tc->UD_bytes_immed_val = scmd->device->sector_size; in scu_ssp_ireq_dif_strip()
382 tc->reserved_DC_0 = 0; in scu_ssp_ireq_dif_strip()
385 tc->DIF_bytes_immed_val = 8; in scu_ssp_ireq_dif_strip()
387 tc->reserved_DC_1 = 0; in scu_ssp_ireq_dif_strip()
388 tc->bgc_blk_sz = scmd->device->sector_size; in scu_ssp_ireq_dif_strip()
389 tc->reserved_E0_0 = 0; in scu_ssp_ireq_dif_strip()
390 tc->app_tag_gen_mask = 0; in scu_ssp_ireq_dif_strip()
393 tc->bgctl = 0; in scu_ssp_ireq_dif_strip()
396 tc->bgctl_f.crc_verify = 1; in scu_ssp_ireq_dif_strip()
397 tc->bgctl_f.op = 0x1; in scu_ssp_ireq_dif_strip()
399 tc->bgctl_f.ref_tag_chk = 1; in scu_ssp_ireq_dif_strip()
400 tc->bgctl_f.app_f_detect = 1; in scu_ssp_ireq_dif_strip()
402 tc->bgctl_f.app_ref_f_detect = 1; in scu_ssp_ireq_dif_strip()
404 tc->app_tag_verify_mask = 0; in scu_ssp_ireq_dif_strip()
407 tc->blk_guard_err = 0; in scu_ssp_ireq_dif_strip()
409 tc->reserved_E8_0 = 0; in scu_ssp_ireq_dif_strip()
410 tc->ref_tag_seed_gen = 0; in scu_ssp_ireq_dif_strip()
422 struct scu_task_context *task_context = ireq->tc; in scu_ssp_io_request_construct_task_context()
423 struct sas_task *sas_task = ireq->ttype_ptr.io_task_ptr; in scu_ssp_io_request_construct_task_context()
424 struct scsi_cmnd *scmd = sas_task->uldd_task; in scu_ssp_io_request_construct_task_context()
430 task_context->ssp_command_iu_length = in scu_ssp_io_request_construct_task_context()
432 task_context->type.ssp.frame_type = SSP_COMMAND; in scu_ssp_io_request_construct_task_context()
438 task_context->task_type = SCU_TASK_TYPE_IOREAD; in scu_ssp_io_request_construct_task_context()
441 task_context->task_type = SCU_TASK_TYPE_IOWRITE; in scu_ssp_io_request_construct_task_context()
445 task_context->transfer_length_bytes = len; in scu_ssp_io_request_construct_task_context()
447 if (task_context->transfer_length_bytes > 0) in scu_ssp_io_request_construct_task_context()
460 * following important settings are utilized: -# priority ==
462 * ahead of other task destined for the same Remote Node. -# task_type ==
464 * (i.e. non-raw frame) is being utilized to perform task management. -#
473 struct scu_task_context *task_context = ireq->tc; in scu_ssp_task_request_construct_task_context()
477 task_context->control_frame = 1; in scu_ssp_task_request_construct_task_context()
478 task_context->priority = SCU_TASK_PRIORITY_HIGH; in scu_ssp_task_request_construct_task_context()
479 task_context->task_type = SCU_TASK_TYPE_RAW_FRAME; in scu_ssp_task_request_construct_task_context()
480 task_context->transfer_length_bytes = 0; in scu_ssp_task_request_construct_task_context()
481 task_context->type.ssp.frame_type = SSP_TASK; in scu_ssp_task_request_construct_task_context()
482 task_context->ssp_command_iu_length = in scu_ssp_task_request_construct_task_context()
506 idev = ireq->target_device; in scu_sata_request_construct_task_context()
507 iport = idev->owning_port; in scu_sata_request_construct_task_context()
510 task_context->abort = 0; in scu_sata_request_construct_task_context()
511 task_context->priority = SCU_TASK_PRIORITY_NORMAL; in scu_sata_request_construct_task_context()
512 task_context->initiator_request = 1; in scu_sata_request_construct_task_context()
513 task_context->connection_rate = idev->connection_rate; in scu_sata_request_construct_task_context()
514 task_context->protocol_engine_index = ISCI_PEG; in scu_sata_request_construct_task_context()
515 task_context->logical_port_index = iport->physical_port_index; in scu_sata_request_construct_task_context()
516 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_STP; in scu_sata_request_construct_task_context()
517 task_context->valid = SCU_TASK_CONTEXT_VALID; in scu_sata_request_construct_task_context()
518 task_context->context_type = SCU_TASK_CONTEXT_TYPE; in scu_sata_request_construct_task_context()
520 task_context->remote_node_index = idev->rnc.remote_node_index; in scu_sata_request_construct_task_context()
521 task_context->command_code = 0; in scu_sata_request_construct_task_context()
523 task_context->link_layer_control = 0; in scu_sata_request_construct_task_context()
524 task_context->do_not_dma_ssp_good_response = 1; in scu_sata_request_construct_task_context()
525 task_context->strict_ordering = 0; in scu_sata_request_construct_task_context()
526 task_context->control_frame = 0; in scu_sata_request_construct_task_context()
527 task_context->timeout_enable = 0; in scu_sata_request_construct_task_context()
528 task_context->block_guard_enable = 0; in scu_sata_request_construct_task_context()
530 task_context->address_modifier = 0; in scu_sata_request_construct_task_context()
531 task_context->task_phase = 0x01; in scu_sata_request_construct_task_context()
533 task_context->ssp_command_iu_length = in scu_sata_request_construct_task_context()
534 (sizeof(struct host_to_dev_fis) - sizeof(u32)) / sizeof(u32); in scu_sata_request_construct_task_context()
537 task_context->type.words[0] = *(u32 *)&ireq->stp.cmd; in scu_sata_request_construct_task_context()
539 ireq->post_context = (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | in scu_sata_request_construct_task_context()
541 (iport->physical_port_index << in scu_sata_request_construct_task_context()
543 ISCI_TAG_TCI(ireq->io_tag)); in scu_sata_request_construct_task_context()
550 ((char *) &ireq->stp.cmd) + in scu_sata_request_construct_task_context()
553 task_context->command_iu_upper = upper_32_bits(dma_addr); in scu_sata_request_construct_task_context()
554 task_context->command_iu_lower = lower_32_bits(dma_addr); in scu_sata_request_construct_task_context()
557 task_context->response_iu_upper = 0; in scu_sata_request_construct_task_context()
558 task_context->response_iu_lower = 0; in scu_sata_request_construct_task_context()
563 struct scu_task_context *task_context = ireq->tc; in scu_stp_raw_request_construct_task_context()
567 task_context->control_frame = 0; in scu_stp_raw_request_construct_task_context()
568 task_context->priority = SCU_TASK_PRIORITY_NORMAL; in scu_stp_raw_request_construct_task_context()
569 task_context->task_type = SCU_TASK_TYPE_SATA_RAW_FRAME; in scu_stp_raw_request_construct_task_context()
570 task_context->type.stp.fis_type = FIS_REGH2D; in scu_stp_raw_request_construct_task_context()
571 task_context->transfer_length_bytes = sizeof(struct host_to_dev_fis) - sizeof(u32); in scu_stp_raw_request_construct_task_context()
577 struct isci_stp_request *stp_req = &ireq->stp.req; in sci_stp_pio_request_construct()
581 stp_req->status = 0; in sci_stp_pio_request_construct()
582 stp_req->sgl.offset = 0; in sci_stp_pio_request_construct()
583 stp_req->sgl.set = SCU_SGL_ELEMENT_PAIR_A; in sci_stp_pio_request_construct()
587 stp_req->sgl.index = 0; in sci_stp_pio_request_construct()
590 stp_req->sgl.index = -1; in sci_stp_pio_request_construct()
601 * an UDMA request or a NCQ request. - A value of 0 indicates UDMA. - A
613 struct scu_task_context *task_context = ireq->tc; in sci_stp_optimized_request_construct()
622 task_context->transfer_length_bytes = len; in sci_stp_optimized_request_construct()
631 task_context->task_type = optimized_task_type + (SCU_TASK_TYPE_DMA_OUT in sci_stp_optimized_request_construct()
632 - SCU_TASK_TYPE_DMA_IN); in sci_stp_optimized_request_construct()
637 task_context->task_type = optimized_task_type; in sci_stp_optimized_request_construct()
643 struct host_to_dev_fis *h2d_fis = &ireq->stp.cmd; in sci_atapi_construct()
651 h2d_fis->features |= ATAPI_PKT_DMA; in sci_atapi_construct()
656 if (task->data_dir == DMA_NONE) in sci_atapi_construct()
657 task->total_xfer_len = 0; in sci_atapi_construct()
662 ireq->stp.rsp.fis_type = 0; in sci_atapi_construct()
673 struct domain_device *dev = ireq->target_device->domain_dev; in sci_io_request_construct_sata()
676 if (test_bit(IREQ_TMF, &ireq->flags)) { in sci_io_request_construct_sata()
679 dev_err(&ireq->owning_controller->pdev->dev, in sci_io_request_construct_sata()
680 "%s: Request 0x%p received un-handled SAT " in sci_io_request_construct_sata()
682 __func__, ireq, tmf->tmf_code); in sci_io_request_construct_sata()
687 if (!sas_protocol_ata(task->task_proto)) { in sci_io_request_construct_sata()
688 dev_err(&ireq->owning_controller->pdev->dev, in sci_io_request_construct_sata()
689 "%s: Non-ATA protocol in SATA path: 0x%x\n", in sci_io_request_construct_sata()
691 task->task_proto); in sci_io_request_construct_sata()
697 if (dev->sata_dev.class == ATA_DEV_ATAPI && in sci_io_request_construct_sata()
698 task->ata_task.fis.command == ATA_CMD_PACKET) { in sci_io_request_construct_sata()
704 if (task->data_dir == DMA_NONE) { in sci_io_request_construct_sata()
710 if (task->ata_task.use_ncq) { in sci_io_request_construct_sata()
718 if (task->ata_task.dma_xfer) { in sci_io_request_construct_sata()
733 ireq->protocol = SAS_PROTOCOL_SSP; in sci_io_request_construct_basic_ssp()
736 task->data_dir, in sci_io_request_construct_basic_ssp()
737 task->total_xfer_len); in sci_io_request_construct_basic_ssp()
741 sci_change_state(&ireq->sm, SCI_REQ_CONSTRUCTED); in sci_io_request_construct_basic_ssp()
755 sci_change_state(&ireq->sm, SCI_REQ_CONSTRUCTED); in sci_task_request_construct_ssp()
766 ireq->protocol = SAS_PROTOCOL_STP; in sci_io_request_construct_basic_sata()
768 copy = (task->data_dir == DMA_NONE) ? false : true; in sci_io_request_construct_basic_sata()
771 task->total_xfer_len, in sci_io_request_construct_basic_sata()
772 task->data_dir, in sci_io_request_construct_basic_sata()
776 sci_change_state(&ireq->sm, SCI_REQ_CONSTRUCTED); in sci_io_request_construct_basic_sata()
782 * sci_req_tx_bytes - bytes transferred when reply underruns request
788 struct isci_host *ihost = ireq->owning_controller; in sci_req_tx_bytes()
791 if (readl(&ihost->smu_registers->address_modifier) == 0) { in sci_req_tx_bytes()
792 void __iomem *scu_reg_base = ihost->scu_registers; in sci_req_tx_bytes()
802 ((sizeof(struct scu_task_context)) * ISCI_TAG_TCI(ireq->io_tag))); in sci_req_tx_bytes()
810 enum sci_base_request_states state; in sci_request_start() local
811 struct scu_task_context *tc = ireq->tc; in sci_request_start()
812 struct isci_host *ihost = ireq->owning_controller; in sci_request_start()
814 state = ireq->sm.current_state_id; in sci_request_start()
815 if (state != SCI_REQ_CONSTRUCTED) { in sci_request_start()
816 dev_warn(&ihost->pdev->dev, in sci_request_start()
818 "state %d\n", __func__, state); in sci_request_start()
822 tc->task_index = ISCI_TAG_TCI(ireq->io_tag); in sci_request_start()
824 switch (tc->protocol_type) { in sci_request_start()
828 tc->type.ssp.tag = ireq->io_tag; in sci_request_start()
829 tc->type.ssp.target_port_transfer_tag = 0xFFFF; in sci_request_start()
834 * tc->type.stp.ncq_tag = ireq->ncq_tag; in sci_request_start()
849 ireq->post_context |= ISCI_TAG_TCI(ireq->io_tag); in sci_request_start()
851 /* Everything is good go ahead and change state */ in sci_request_start()
852 sci_change_state(&ireq->sm, SCI_REQ_STARTED); in sci_request_start()
860 enum sci_base_request_states state; in sci_io_request_terminate() local
862 state = ireq->sm.current_state_id; in sci_io_request_terminate()
864 switch (state) { in sci_io_request_terminate()
867 set_bit(IREQ_TC_ABORT_POSTED, &ireq->flags); in sci_io_request_terminate()
868 ireq->scu_status = SCU_TASK_DONE_TASK_ABORT; in sci_io_request_terminate()
869 ireq->sci_status = SCI_FAILURE_IO_TERMINATED; in sci_io_request_terminate()
870 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_terminate()
888 /* Fall through and change state to ABORTING... */ in sci_io_request_terminate()
891 * sent by the SCU HW. Since the state machine is in sci_io_request_terminate()
896 sci_change_state(&ireq->sm, SCI_REQ_ABORTING); in sci_io_request_terminate()
899 if (!isci_remote_device_is_safe_to_abort(ireq->target_device)) in sci_io_request_terminate()
900 set_bit(IREQ_PENDING_ABORT, &ireq->flags); in sci_io_request_terminate()
902 clear_bit(IREQ_PENDING_ABORT, &ireq->flags); in sci_io_request_terminate()
909 dev_warn(&ireq->owning_controller->pdev->dev, in sci_io_request_terminate()
911 "state %d\n", __func__, ireq->sm.current_state_id); in sci_io_request_terminate()
920 enum sci_base_request_states state; in sci_request_complete() local
921 struct isci_host *ihost = ireq->owning_controller; in sci_request_complete()
923 state = ireq->sm.current_state_id; in sci_request_complete()
924 if (WARN_ONCE(state != SCI_REQ_COMPLETED, in sci_request_complete()
925 "isci: request completion from wrong state (%s)\n", in sci_request_complete()
926 req_state_name(state))) in sci_request_complete()
929 if (ireq->saved_rx_frame_index != SCU_INVALID_FRAME_INDEX) in sci_request_complete()
931 ireq->saved_rx_frame_index); in sci_request_complete()
933 /* XXX can we just stop the machine and remove the 'final' state? */ in sci_request_complete()
934 sci_change_state(&ireq->sm, SCI_REQ_FINAL); in sci_request_complete()
941 enum sci_base_request_states state; in sci_io_request_event_handler() local
942 struct isci_host *ihost = ireq->owning_controller; in sci_io_request_event_handler()
944 state = ireq->sm.current_state_id; in sci_io_request_event_handler()
946 if (state != SCI_REQ_STP_PIO_DATA_IN) { in sci_io_request_event_handler()
947 dev_warn(&ihost->pdev->dev, "%s: (%x) in wrong state %s\n", in sci_io_request_event_handler()
948 __func__, event_code, req_state_name(state)); in sci_io_request_event_handler()
958 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); in sci_io_request_event_handler()
961 dev_err(&ihost->pdev->dev, in sci_io_request_event_handler()
985 ssp_response = &ireq->ssp.rsp; in sci_io_request_copy_response()
987 resp_buf = &isci_tmf->resp.resp_iu; in sci_io_request_copy_response()
991 be32_to_cpu(ssp_response->response_data_len)); in sci_io_request_copy_response()
993 memcpy(resp_buf, ssp_response->resp_data, len); in sci_io_request_copy_response()
1008 ireq->scu_status = SCU_TASK_DONE_GOOD; in request_started_state_tc_event()
1009 ireq->sci_status = SCI_SUCCESS; in request_started_state_tc_event()
1019 struct ssp_response_iu *resp = &ireq->ssp.rsp; in request_started_state_tc_event()
1022 sci_swab32_cpy(&ireq->ssp.rsp, in request_started_state_tc_event()
1023 &ireq->ssp.rsp, in request_started_state_tc_event()
1026 if (resp->status == 0) { in request_started_state_tc_event()
1027 ireq->scu_status = SCU_TASK_DONE_GOOD; in request_started_state_tc_event()
1028 ireq->sci_status = SCI_SUCCESS_IO_DONE_EARLY; in request_started_state_tc_event()
1030 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in request_started_state_tc_event()
1031 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in request_started_state_tc_event()
1038 sci_swab32_cpy(&ireq->ssp.rsp, in request_started_state_tc_event()
1039 &ireq->ssp.rsp, in request_started_state_tc_event()
1042 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in request_started_state_tc_event()
1043 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in request_started_state_tc_event()
1052 resp_iu = &ireq->ssp.rsp; in request_started_state_tc_event()
1053 datapres = resp_iu->datapres; in request_started_state_tc_event()
1056 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in request_started_state_tc_event()
1057 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in request_started_state_tc_event()
1059 ireq->scu_status = SCU_TASK_DONE_GOOD; in request_started_state_tc_event()
1060 ireq->sci_status = SCI_SUCCESS; in request_started_state_tc_event()
1063 /* only stp device gets suspended. */ in request_started_state_tc_event()
1075 if (ireq->protocol == SAS_PROTOCOL_STP) { in request_started_state_tc_event()
1076 ireq->scu_status = SCU_GET_COMPLETION_TL_STATUS(completion_code) >> in request_started_state_tc_event()
1078 ireq->sci_status = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED; in request_started_state_tc_event()
1080 ireq->scu_status = SCU_GET_COMPLETION_TL_STATUS(completion_code) >> in request_started_state_tc_event()
1082 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in request_started_state_tc_event()
1086 /* both stp/ssp device gets suspended */ in request_started_state_tc_event()
1097 ireq->scu_status = SCU_GET_COMPLETION_TL_STATUS(completion_code) >> in request_started_state_tc_event()
1099 ireq->sci_status = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED; in request_started_state_tc_event()
1102 /* neither ssp nor stp gets suspended. */ in request_started_state_tc_event()
1119 ireq->scu_status = SCU_GET_COMPLETION_TL_STATUS(completion_code) >> in request_started_state_tc_event()
1121 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in request_started_state_tc_event()
1130 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in request_started_state_tc_event()
1141 ireq->scu_status = SCU_TASK_DONE_TASK_ABORT; in request_aborting_state_tc_event()
1142 ireq->sci_status = SCI_FAILURE_IO_TERMINATED; in request_aborting_state_tc_event()
1143 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in request_aborting_state_tc_event()
1148 * TODO: Should there be a state change for this completion? in request_aborting_state_tc_event()
1161 ireq->scu_status = SCU_TASK_DONE_GOOD; in ssp_task_request_await_tc_event()
1162 ireq->sci_status = SCI_SUCCESS; in ssp_task_request_await_tc_event()
1163 sci_change_state(&ireq->sm, SCI_REQ_TASK_WAIT_TC_RESP); in ssp_task_request_await_tc_event()
1171 dev_warn(&ireq->owning_controller->pdev->dev, in ssp_task_request_await_tc_event()
1172 "%s: TaskRequest:0x%p CompletionCode:%x - " in ssp_task_request_await_tc_event()
1176 sci_change_state(&ireq->sm, SCI_REQ_TASK_WAIT_TC_RESP); in ssp_task_request_await_tc_event()
1184 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in ssp_task_request_await_tc_event()
1185 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in ssp_task_request_await_tc_event()
1186 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in ssp_task_request_await_tc_event()
1199 /* In the AWAIT RESPONSE state, any TC completion is in smp_request_await_response_tc_event()
1203 ireq->scu_status = SCU_TASK_DONE_GOOD; in smp_request_await_response_tc_event()
1204 ireq->sci_status = SCI_SUCCESS; in smp_request_await_response_tc_event()
1205 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in smp_request_await_response_tc_event()
1218 ireq->scu_status = SCU_TASK_DONE_SMP_RESP_TO_ERR; in smp_request_await_response_tc_event()
1219 ireq->sci_status = SCI_FAILURE_RETRY_REQUIRED; in smp_request_await_response_tc_event()
1220 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in smp_request_await_response_tc_event()
1226 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in smp_request_await_response_tc_event()
1227 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in smp_request_await_response_tc_event()
1228 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in smp_request_await_response_tc_event()
1241 ireq->scu_status = SCU_TASK_DONE_GOOD; in smp_request_await_tc_event()
1242 ireq->sci_status = SCI_SUCCESS; in smp_request_await_tc_event()
1243 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in smp_request_await_tc_event()
1250 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in smp_request_await_tc_event()
1251 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in smp_request_await_tc_event()
1252 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in smp_request_await_tc_event()
1264 struct isci_stp_pio_sgl *pio_sgl = &stp_req->sgl; in pio_sgl_next()
1266 sgl_pair = to_sgl_element_pair(ireq, pio_sgl->index); in pio_sgl_next()
1269 else if (pio_sgl->set == SCU_SGL_ELEMENT_PAIR_A) { in pio_sgl_next()
1270 if (sgl_pair->B.address_lower == 0 && in pio_sgl_next()
1271 sgl_pair->B.address_upper == 0) { in pio_sgl_next()
1274 pio_sgl->set = SCU_SGL_ELEMENT_PAIR_B; in pio_sgl_next()
1275 sgl = &sgl_pair->B; in pio_sgl_next()
1278 if (sgl_pair->next_pair_lower == 0 && in pio_sgl_next()
1279 sgl_pair->next_pair_upper == 0) { in pio_sgl_next()
1282 pio_sgl->index++; in pio_sgl_next()
1283 pio_sgl->set = SCU_SGL_ELEMENT_PAIR_A; in pio_sgl_next()
1284 sgl_pair = to_sgl_element_pair(ireq, pio_sgl->index); in pio_sgl_next()
1285 sgl = &sgl_pair->A; in pio_sgl_next()
1298 ireq->scu_status = SCU_TASK_DONE_GOOD; in stp_request_non_data_await_h2d_tc_event()
1299 ireq->sci_status = SCI_SUCCESS; in stp_request_non_data_await_h2d_tc_event()
1300 sci_change_state(&ireq->sm, SCI_REQ_STP_NON_DATA_WAIT_D2H); in stp_request_non_data_await_h2d_tc_event()
1308 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in stp_request_non_data_await_h2d_tc_event()
1309 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in stp_request_non_data_await_h2d_tc_event()
1310 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in stp_request_non_data_await_h2d_tc_event()
1326 struct isci_stp_request *stp_req = &ireq->stp.req; in sci_stp_request_pio_data_out_trasmit_data_frame()
1327 struct scu_task_context *task_context = ireq->tc; in sci_stp_request_pio_data_out_trasmit_data_frame()
1334 sgl_pair = to_sgl_element_pair(ireq, stp_req->sgl.index); in sci_stp_request_pio_data_out_trasmit_data_frame()
1335 if (stp_req->sgl.set == SCU_SGL_ELEMENT_PAIR_A) in sci_stp_request_pio_data_out_trasmit_data_frame()
1336 current_sgl = &sgl_pair->A; in sci_stp_request_pio_data_out_trasmit_data_frame()
1338 current_sgl = &sgl_pair->B; in sci_stp_request_pio_data_out_trasmit_data_frame()
1341 task_context->command_iu_upper = current_sgl->address_upper; in sci_stp_request_pio_data_out_trasmit_data_frame()
1342 task_context->command_iu_lower = current_sgl->address_lower; in sci_stp_request_pio_data_out_trasmit_data_frame()
1343 task_context->transfer_length_bytes = length; in sci_stp_request_pio_data_out_trasmit_data_frame()
1344 task_context->type.stp.fis_type = FIS_DATA; in sci_stp_request_pio_data_out_trasmit_data_frame()
1352 struct isci_stp_request *stp_req = &ireq->stp.req; in sci_stp_request_pio_data_out_transmit_data()
1359 offset = stp_req->sgl.offset; in sci_stp_request_pio_data_out_transmit_data()
1360 sgl_pair = to_sgl_element_pair(ireq, stp_req->sgl.index); in sci_stp_request_pio_data_out_transmit_data()
1364 if (stp_req->sgl.set == SCU_SGL_ELEMENT_PAIR_A) { in sci_stp_request_pio_data_out_transmit_data()
1365 sgl = &sgl_pair->A; in sci_stp_request_pio_data_out_transmit_data()
1366 len = sgl_pair->A.length - offset; in sci_stp_request_pio_data_out_transmit_data()
1368 sgl = &sgl_pair->B; in sci_stp_request_pio_data_out_transmit_data()
1369 len = sgl_pair->B.length - offset; in sci_stp_request_pio_data_out_transmit_data()
1372 if (stp_req->pio_len == 0) in sci_stp_request_pio_data_out_transmit_data()
1375 if (stp_req->pio_len >= len) { in sci_stp_request_pio_data_out_transmit_data()
1379 stp_req->pio_len -= len; in sci_stp_request_pio_data_out_transmit_data()
1384 } else if (stp_req->pio_len < len) { in sci_stp_request_pio_data_out_transmit_data()
1385 sci_stp_request_pio_data_out_trasmit_data_frame(ireq, stp_req->pio_len); in sci_stp_request_pio_data_out_transmit_data()
1388 offset += stp_req->pio_len; in sci_stp_request_pio_data_out_transmit_data()
1389 sgl->address_lower += stp_req->pio_len; in sci_stp_request_pio_data_out_transmit_data()
1390 stp_req->pio_len = 0; in sci_stp_request_pio_data_out_transmit_data()
1393 stp_req->sgl.offset = offset; in sci_stp_request_pio_data_out_transmit_data()
1423 if (task->num_scatter > 0) { in sci_stp_request_pio_data_in_copy_data_buffer()
1424 sg = task->scatter; in sci_stp_request_pio_data_in_copy_data_buffer()
1431 memcpy(kaddr + sg->offset, src_addr, copy_len); in sci_stp_request_pio_data_in_copy_data_buffer()
1433 total_len -= copy_len; in sci_stp_request_pio_data_in_copy_data_buffer()
1438 BUG_ON(task->total_xfer_len < total_len); in sci_stp_request_pio_data_in_copy_data_buffer()
1439 memcpy(task->scatter, src_addr, total_len); in sci_stp_request_pio_data_in_copy_data_buffer()
1461 if (stp_req->pio_len < SCU_MAX_FRAME_BUFFER_SIZE) { in sci_stp_request_pio_data_in_copy_data()
1463 stp_req, data_buffer, stp_req->pio_len); in sci_stp_request_pio_data_in_copy_data()
1466 stp_req->pio_len = 0; in sci_stp_request_pio_data_in_copy_data()
1473 stp_req->pio_len -= SCU_MAX_FRAME_BUFFER_SIZE; in sci_stp_request_pio_data_in_copy_data()
1487 ireq->scu_status = SCU_TASK_DONE_GOOD; in stp_request_pio_await_h2d_completion_tc_event()
1488 ireq->sci_status = SCI_SUCCESS; in stp_request_pio_await_h2d_completion_tc_event()
1489 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); in stp_request_pio_await_h2d_completion_tc_event()
1497 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in stp_request_pio_await_h2d_completion_tc_event()
1498 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in stp_request_pio_await_h2d_completion_tc_event()
1499 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in stp_request_pio_await_h2d_completion_tc_event()
1512 struct isci_stp_request *stp_req = &ireq->stp.req; in pio_data_out_tx_done_tc_event()
1517 if (stp_req->pio_len != 0) { in pio_data_out_tx_done_tc_event()
1520 if (stp_req->pio_len == 0) in pio_data_out_tx_done_tc_event()
1523 } else if (stp_req->pio_len == 0) { in pio_data_out_tx_done_tc_event()
1534 * Change the state to SCI_REQ_STP_PIO_DATA_IN in pio_data_out_tx_done_tc_event()
1536 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); in pio_data_out_tx_done_tc_event()
1546 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in pio_data_out_tx_done_tc_event()
1547 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in pio_data_out_tx_done_tc_event()
1548 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in pio_data_out_tx_done_tc_event()
1558 struct isci_host *ihost = ireq->owning_controller; in sci_stp_request_udma_general_frame_handler()
1563 status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, in sci_stp_request_udma_general_frame_handler()
1568 (frame_header->fis_type == FIS_REGD2H)) { in sci_stp_request_udma_general_frame_handler()
1569 sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, in sci_stp_request_udma_general_frame_handler()
1573 sci_controller_copy_sata_response(&ireq->stp.rsp, in sci_stp_request_udma_general_frame_handler()
1586 struct isci_host *ihost = ireq->owning_controller; in process_unsolicited_fis()
1591 status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, in process_unsolicited_fis()
1598 if (frame_header->fis_type != FIS_REGD2H) { in process_unsolicited_fis()
1599 dev_err(&ireq->isci_host->pdev->dev, in process_unsolicited_fis()
1601 __func__, frame_header->fis_type); in process_unsolicited_fis()
1605 sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, in process_unsolicited_fis()
1609 sci_controller_copy_sata_response(&ireq->stp.rsp, in process_unsolicited_fis()
1628 if (ireq->stp.rsp.status & ATA_ERR) in atapi_d2h_reg_frame_handler()
1635 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in atapi_d2h_reg_frame_handler()
1636 ireq->sci_status = status; in atapi_d2h_reg_frame_handler()
1638 ireq->scu_status = SCU_TASK_DONE_GOOD; in atapi_d2h_reg_frame_handler()
1639 ireq->sci_status = SCI_SUCCESS; in atapi_d2h_reg_frame_handler()
1642 /* the d2h ufi is the end of non-data commands */ in atapi_d2h_reg_frame_handler()
1643 if (task->data_dir == DMA_NONE) in atapi_d2h_reg_frame_handler()
1644 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in atapi_d2h_reg_frame_handler()
1651 struct ata_device *dev = sas_to_ata_dev(ireq->target_device->domain_dev); in scu_atapi_reconstruct_raw_frame_task_context()
1652 void *atapi_cdb = ireq->ttype_ptr.io_task_ptr->ata_task.atapi_packet; in scu_atapi_reconstruct_raw_frame_task_context()
1653 struct scu_task_context *task_context = ireq->tc; in scu_atapi_reconstruct_raw_frame_task_context()
1659 memset(&ireq->stp.cmd, 0, sizeof(struct host_to_dev_fis)); in scu_atapi_reconstruct_raw_frame_task_context()
1660 memcpy(((u8 *)&ireq->stp.cmd + sizeof(u32)), atapi_cdb, ATAPI_CDB_LEN); in scu_atapi_reconstruct_raw_frame_task_context()
1661 memset(&(task_context->type.stp), 0, sizeof(struct stp_task_context)); in scu_atapi_reconstruct_raw_frame_task_context()
1662 task_context->type.stp.fis_type = FIS_DATA; in scu_atapi_reconstruct_raw_frame_task_context()
1663 task_context->transfer_length_bytes = dev->cdb_len; in scu_atapi_reconstruct_raw_frame_task_context()
1668 struct ata_device *dev = sas_to_ata_dev(ireq->target_device->domain_dev); in scu_atapi_construct_task_context()
1670 struct scu_task_context *task_context = ireq->tc; in scu_atapi_construct_task_context()
1671 int cdb_len = dev->cdb_len; in scu_atapi_construct_task_context()
1676 if (task->data_dir == DMA_TO_DEVICE) { in scu_atapi_construct_task_context()
1677 task_context->task_type = SCU_TASK_TYPE_PACKET_DMA_OUT; in scu_atapi_construct_task_context()
1678 task_context->sata_direction = 0; in scu_atapi_construct_task_context()
1681 task_context->task_type = SCU_TASK_TYPE_PACKET_DMA_IN; in scu_atapi_construct_task_context()
1682 task_context->sata_direction = 1; in scu_atapi_construct_task_context()
1685 memset(&task_context->type.stp, 0, sizeof(task_context->type.stp)); in scu_atapi_construct_task_context()
1686 task_context->type.stp.fis_type = FIS_DATA; in scu_atapi_construct_task_context()
1688 memset(&ireq->stp.cmd, 0, sizeof(ireq->stp.cmd)); in scu_atapi_construct_task_context()
1689 memcpy(&ireq->stp.cmd.lbal, task->ata_task.atapi_packet, cdb_len); in scu_atapi_construct_task_context()
1690 task_context->ssp_command_iu_length = cdb_len / sizeof(u32); in scu_atapi_construct_task_context()
1693 task_context->task_phase = 0x1; in scu_atapi_construct_task_context()
1696 task_context->stp_retry_count = 0; in scu_atapi_construct_task_context()
1699 task_context->transfer_length_bytes = task->total_xfer_len; in scu_atapi_construct_task_context()
1709 struct isci_host *ihost = ireq->owning_controller; in sci_io_request_frame_handler()
1710 struct isci_stp_request *stp_req = &ireq->stp.req; in sci_io_request_frame_handler()
1711 enum sci_base_request_states state; in sci_io_request_frame_handler() local
1715 state = ireq->sm.current_state_id; in sci_io_request_frame_handler()
1716 switch (state) { in sci_io_request_frame_handler()
1721 sci_unsolicited_frame_control_get_header(&ihost->uf_control, in sci_io_request_frame_handler()
1732 sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, in sci_io_request_frame_handler()
1736 sci_swab32_cpy(&ireq->ssp.rsp, resp_iu, word_cnt); in sci_io_request_frame_handler()
1738 resp_iu = &ireq->ssp.rsp; in sci_io_request_frame_handler()
1740 if (resp_iu->datapres == 0x01 || in sci_io_request_frame_handler()
1741 resp_iu->datapres == 0x02) { in sci_io_request_frame_handler()
1742 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in sci_io_request_frame_handler()
1743 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in sci_io_request_frame_handler()
1745 ireq->scu_status = SCU_TASK_DONE_GOOD; in sci_io_request_frame_handler()
1746 ireq->sci_status = SCI_SUCCESS; in sci_io_request_frame_handler()
1750 dev_err(&ihost->pdev->dev, in sci_io_request_frame_handler()
1767 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
1773 struct scatterlist *sg = &task->smp_task.smp_resp; in sci_io_request_frame_handler()
1777 sci_unsolicited_frame_control_get_header(&ihost->uf_control, in sci_io_request_frame_handler()
1781 rsp = kaddr + sg->offset; in sci_io_request_frame_handler()
1787 sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, in sci_io_request_frame_handler()
1791 word_cnt = (sg->length/4)-1; in sci_io_request_frame_handler()
1797 ireq->scu_status = SCU_TASK_DONE_GOOD; in sci_io_request_frame_handler()
1798 ireq->sci_status = SCI_SUCCESS; in sci_io_request_frame_handler()
1799 sci_change_state(&ireq->sm, SCI_REQ_SMP_WAIT_TC_COMP); in sci_io_request_frame_handler()
1805 dev_err(&ihost->pdev->dev, in sci_io_request_frame_handler()
1813 ireq->scu_status = SCU_TASK_DONE_SMP_FRM_TYPE_ERR; in sci_io_request_frame_handler()
1814 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in sci_io_request_frame_handler()
1815 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
1835 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in sci_io_request_frame_handler()
1836 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in sci_io_request_frame_handler()
1837 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
1844 status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, in sci_io_request_frame_handler()
1849 dev_err(&ihost->pdev->dev, in sci_io_request_frame_handler()
1860 switch (frame_header->fis_type) { in sci_io_request_frame_handler()
1862 sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, in sci_io_request_frame_handler()
1866 sci_controller_copy_sata_response(&ireq->stp.rsp, in sci_io_request_frame_handler()
1871 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in sci_io_request_frame_handler()
1872 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in sci_io_request_frame_handler()
1876 dev_warn(&ihost->pdev->dev, in sci_io_request_frame_handler()
1881 ireq->scu_status = SCU_TASK_DONE_UNEXP_FIS; in sci_io_request_frame_handler()
1882 ireq->sci_status = SCI_FAILURE_PROTOCOL_VIOLATION; in sci_io_request_frame_handler()
1886 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
1899 status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, in sci_io_request_frame_handler()
1904 dev_err(&ihost->pdev->dev, in sci_io_request_frame_handler()
1911 switch (frame_header->fis_type) { in sci_io_request_frame_handler()
1914 sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, in sci_io_request_frame_handler()
1925 stp_req->pio_len = frame_buffer[3] & 0xffff; in sci_io_request_frame_handler()
1928 stp_req->status = (frame_buffer[2] >> 24) & 0xff; in sci_io_request_frame_handler()
1930 sci_controller_copy_sata_response(&ireq->stp.rsp, in sci_io_request_frame_handler()
1934 ireq->stp.rsp.status = stp_req->status; in sci_io_request_frame_handler()
1936 /* The next state is dependent on whether the in sci_io_request_frame_handler()
1937 * request was PIO Data-in or Data out in sci_io_request_frame_handler()
1939 if (task->data_dir == DMA_FROM_DEVICE) { in sci_io_request_frame_handler()
1940 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_DATA_IN); in sci_io_request_frame_handler()
1941 } else if (task->data_dir == DMA_TO_DEVICE) { in sci_io_request_frame_handler()
1946 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_DATA_OUT); in sci_io_request_frame_handler()
1951 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); in sci_io_request_frame_handler()
1955 if (frame_header->status & ATA_BUSY) { in sci_io_request_frame_handler()
1959 * we are still in the right state. in sci_io_request_frame_handler()
1961 dev_dbg(&ihost->pdev->dev, in sci_io_request_frame_handler()
1967 frame_header->status); in sci_io_request_frame_handler()
1971 sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, in sci_io_request_frame_handler()
1975 sci_controller_copy_sata_response(&ireq->stp.rsp, in sci_io_request_frame_handler()
1979 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in sci_io_request_frame_handler()
1980 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in sci_io_request_frame_handler()
1981 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
1999 status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, in sci_io_request_frame_handler()
2004 dev_err(&ihost->pdev->dev, in sci_io_request_frame_handler()
2014 if (frame_header->fis_type != FIS_DATA) { in sci_io_request_frame_handler()
2015 dev_err(&ihost->pdev->dev, in sci_io_request_frame_handler()
2022 frame_header->fis_type); in sci_io_request_frame_handler()
2024 ireq->scu_status = SCU_TASK_DONE_GOOD; in sci_io_request_frame_handler()
2025 ireq->sci_status = SCI_FAILURE_IO_REQUIRES_SCSI_ABORT; in sci_io_request_frame_handler()
2026 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
2033 if (stp_req->sgl.index < 0) { in sci_io_request_frame_handler()
2034 ireq->saved_rx_frame_index = frame_index; in sci_io_request_frame_handler()
2035 stp_req->pio_len = 0; in sci_io_request_frame_handler()
2037 sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, in sci_io_request_frame_handler()
2051 if (status != SCI_SUCCESS || stp_req->pio_len != 0) in sci_io_request_frame_handler()
2054 if ((stp_req->status & ATA_BUSY) == 0) { in sci_io_request_frame_handler()
2055 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in sci_io_request_frame_handler()
2056 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in sci_io_request_frame_handler()
2057 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
2059 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); in sci_io_request_frame_handler()
2068 ireq->target_device->working_request = ireq; in sci_io_request_frame_handler()
2069 if (task->data_dir == DMA_NONE) { in sci_io_request_frame_handler()
2070 sci_change_state(&ireq->sm, SCI_REQ_ATAPI_WAIT_TC_COMP); in sci_io_request_frame_handler()
2073 sci_change_state(&ireq->sm, SCI_REQ_ATAPI_WAIT_D2H); in sci_io_request_frame_handler()
2085 * aborting state? in sci_io_request_frame_handler()
2091 dev_warn(&ihost->pdev->dev, in sci_io_request_frame_handler()
2093 "in state %d\n", in sci_io_request_frame_handler()
2096 state); in sci_io_request_frame_handler()
2110 ireq->scu_status = SCU_TASK_DONE_GOOD; in stp_request_udma_await_tc_event()
2111 ireq->sci_status = SCI_SUCCESS; in stp_request_udma_await_tc_event()
2112 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in stp_request_udma_await_tc_event()
2120 if (ireq->stp.rsp.fis_type == FIS_REGD2H) { in stp_request_udma_await_tc_event()
2121 sci_remote_device_suspend(ireq->target_device, in stp_request_udma_await_tc_event()
2124 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in stp_request_udma_await_tc_event()
2125 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in stp_request_udma_await_tc_event()
2126 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in stp_request_udma_await_tc_event()
2130 * the device so we must change state to wait in stp_request_udma_await_tc_event()
2133 sci_change_state(&ireq->sm, SCI_REQ_STP_UDMA_WAIT_D2H); in stp_request_udma_await_tc_event()
2141 * - this comes only for B0 in stp_request_udma_await_tc_event()
2145 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in stp_request_udma_await_tc_event()
2146 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in stp_request_udma_await_tc_event()
2147 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in stp_request_udma_await_tc_event()
2161 ireq->scu_status = SCU_TASK_DONE_GOOD; in atapi_raw_completion()
2162 ireq->sci_status = SCI_SUCCESS; in atapi_raw_completion()
2163 sci_change_state(&ireq->sm, next); in atapi_raw_completion()
2170 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in atapi_raw_completion()
2171 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in atapi_raw_completion()
2173 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in atapi_raw_completion()
2183 struct isci_remote_device *idev = ireq->target_device; in atapi_data_tc_completion_handler()
2184 struct dev_to_host_fis *d2h = &ireq->stp.rsp; in atapi_data_tc_completion_handler()
2189 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in atapi_data_tc_completion_handler()
2195 /* likely non-error data underrrun, workaround missing in atapi_data_tc_completion_handler()
2198 if (d2h->fis_type != FIS_REGD2H) { in atapi_data_tc_completion_handler()
2199 d2h->fis_type = FIS_REGD2H; in atapi_data_tc_completion_handler()
2200 d2h->flags = (1 << 6); in atapi_data_tc_completion_handler()
2201 d2h->status = 0x50; in atapi_data_tc_completion_handler()
2202 d2h->error = 0; in atapi_data_tc_completion_handler()
2203 d2h->lbal = 0; in atapi_data_tc_completion_handler()
2204 d2h->byte_count_low = len & 0xff; in atapi_data_tc_completion_handler()
2205 d2h->byte_count_high = len >> 8; in atapi_data_tc_completion_handler()
2206 d2h->device = 0xa0; in atapi_data_tc_completion_handler()
2207 d2h->lbal_exp = 0; in atapi_data_tc_completion_handler()
2208 d2h->lbam_exp = 0; in atapi_data_tc_completion_handler()
2209 d2h->lbah_exp = 0; in atapi_data_tc_completion_handler()
2210 d2h->_r_a = 0; in atapi_data_tc_completion_handler()
2211 d2h->sector_count = 0x3; in atapi_data_tc_completion_handler()
2212 d2h->sector_count_exp = 0; in atapi_data_tc_completion_handler()
2213 d2h->_r_b = 0; in atapi_data_tc_completion_handler()
2214 d2h->_r_c = 0; in atapi_data_tc_completion_handler()
2215 d2h->_r_d = 0; in atapi_data_tc_completion_handler()
2218 ireq->scu_status = SCU_TASK_DONE_GOOD; in atapi_data_tc_completion_handler()
2219 ireq->sci_status = SCI_SUCCESS_IO_DONE_EARLY; in atapi_data_tc_completion_handler()
2220 status = ireq->sci_status; in atapi_data_tc_completion_handler()
2222 /* the hw will have suspended the rnc, so complete the in atapi_data_tc_completion_handler()
2225 sci_change_state(&idev->sm, SCI_STP_DEV_ATAPI_ERROR); in atapi_data_tc_completion_handler()
2232 ireq->scu_status = SCU_TASK_DONE_GOOD; in atapi_data_tc_completion_handler()
2233 ireq->sci_status = SCI_SUCCESS; in atapi_data_tc_completion_handler()
2234 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in atapi_data_tc_completion_handler()
2238 if (d2h->fis_type == FIS_REGD2H) { in atapi_data_tc_completion_handler()
2239 /* UF received change the device state to ATAPI_ERROR */ in atapi_data_tc_completion_handler()
2240 status = ireq->sci_status; in atapi_data_tc_completion_handler()
2241 sci_change_state(&idev->sm, SCI_STP_DEV_ATAPI_ERROR); in atapi_data_tc_completion_handler()
2243 /* If receiving any non-success TC status, no UF in atapi_data_tc_completion_handler()
2249 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in atapi_data_tc_completion_handler()
2250 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in atapi_data_tc_completion_handler()
2252 sci_change_state(&ireq->sm, SCI_REQ_ATAPI_WAIT_D2H); in atapi_data_tc_completion_handler()
2355 switch (ireq->protocol) { in sci_request_handle_suspending_completions()
2376 dev_warn(&ireq->isci_host->pdev->dev, in sci_request_handle_suspending_completions()
2385 &ireq->target_device->rnc, in sci_request_handle_suspending_completions()
2396 enum sci_base_request_states state; in sci_io_request_tc_completion() local
2397 struct isci_host *ihost = ireq->owning_controller; in sci_io_request_tc_completion()
2399 state = ireq->sm.current_state_id; in sci_io_request_tc_completion()
2405 switch (state) { in sci_io_request_tc_completion()
2451 dev_warn(&ihost->pdev->dev, "%s: %x in wrong state %s\n", in sci_io_request_tc_completion()
2452 __func__, completion_code, req_state_name(state)); in sci_io_request_tc_completion()
2458 * isci_request_process_response_iu() - This function sets the status and
2474 "resp_iu->status = 0x%x,\nresp_iu->datapres = %d " in isci_request_process_response_iu()
2475 "resp_iu->response_data_len = %x, " in isci_request_process_response_iu()
2476 "resp_iu->sense_data_len = %x\nresponse data: ", in isci_request_process_response_iu()
2479 resp_iu->status, in isci_request_process_response_iu()
2480 resp_iu->datapres, in isci_request_process_response_iu()
2481 resp_iu->response_data_len, in isci_request_process_response_iu()
2482 resp_iu->sense_data_len); in isci_request_process_response_iu()
2484 task->task_status.stat = resp_iu->status; in isci_request_process_response_iu()
2491 * isci_request_set_open_reject_status() - This function prepares the I/O
2497 * abandon-class reject.
2509 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_set_open_reject_status()
2512 task->task_status.open_rej_reason = open_rej_reason; in isci_request_set_open_reject_status()
2516 * isci_request_handle_controller_specific_errors() - This function decodes
2517 * controller-specific I/O completion error conditions.
2533 cstatus = request->scu_status; in isci_request_handle_controller_specific_errors()
2535 dev_dbg(&request->isci_host->pdev->dev, in isci_request_handle_controller_specific_errors()
2537 "- controller status = 0x%x\n", in isci_request_handle_controller_specific_errors()
2540 /* Decode the controller-specific errors; most in isci_request_handle_controller_specific_errors()
2548 * a controller-specific completion code; these are left in isci_request_handle_controller_specific_errors()
2556 if (task->task_proto == SAS_PROTOCOL_SMP) { in isci_request_handle_controller_specific_errors()
2561 * that we ignore the quiesce state, since we are in isci_request_handle_controller_specific_errors()
2562 * concerned about the actual device state. in isci_request_handle_controller_specific_errors()
2569 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_handle_controller_specific_errors()
2579 clear_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_handle_controller_specific_errors()
2589 case SCU_TASK_DONE_VIIT_ENTRY_NV: /* TODO - conditions? */ in isci_request_handle_controller_specific_errors()
2590 case SCU_TASK_DONE_IIT_ENTRY_NV: /* TODO - conditions? */ in isci_request_handle_controller_specific_errors()
2591 case SCU_TASK_DONE_RNCNV_OUTBOUND: /* TODO - conditions? */ in isci_request_handle_controller_specific_errors()
2599 * that we ignore the quiesce state, since we are in isci_request_handle_controller_specific_errors()
2600 * concerned about the actual device state. in isci_request_handle_controller_specific_errors()
2607 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_handle_controller_specific_errors()
2612 * abandon-class codes; all others are automatically retried in the SCU. in isci_request_handle_controller_specific_errors()
2623 /* Note - the return of AB0 will change when in isci_request_handle_controller_specific_errors()
2709 if (task->task_proto == SAS_PROTOCOL_SMP) in isci_request_handle_controller_specific_errors()
2710 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_handle_controller_specific_errors()
2712 clear_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_handle_controller_specific_errors()
2719 struct task_status_struct *ts = &task->task_status; in isci_process_stp_response()
2720 struct ata_task_resp *resp = (void *)&ts->buf[0]; in isci_process_stp_response()
2722 resp->frame_len = sizeof(*fis); in isci_process_stp_response()
2723 memcpy(resp->ending_fis, fis, sizeof(*fis)); in isci_process_stp_response()
2724 ts->buf_valid_size = sizeof(*resp); in isci_process_stp_response()
2727 if (ac_err_mask(fis->status)) in isci_process_stp_response()
2728 ts->stat = SAS_PROTO_RESPONSE; in isci_process_stp_response()
2730 ts->stat = SAM_STAT_GOOD; in isci_process_stp_response()
2732 ts->resp = SAS_TASK_COMPLETE; in isci_process_stp_response()
2742 struct isci_remote_device *idev = request->target_device; in isci_request_io_request_complete()
2746 dev_dbg(&ihost->pdev->dev, in isci_request_io_request_complete()
2748 "task->data_dir = %d completion_status = 0x%x\n", in isci_request_io_request_complete()
2749 __func__, request, task, task->data_dir, completion_status); in isci_request_io_request_complete()
2757 dev_dbg(&ihost->pdev->dev, in isci_request_io_request_complete()
2761 if (sas_protocol_ata(task->task_proto)) { in isci_request_io_request_complete()
2762 isci_process_stp_response(task, &request->stp.rsp); in isci_request_io_request_complete()
2763 } else if (SAS_PROTOCOL_SSP == task->task_proto) { in isci_request_io_request_complete()
2766 resp_iu = &request->ssp.rsp; in isci_request_io_request_complete()
2768 &ihost->pdev->dev); in isci_request_io_request_complete()
2770 } else if (SAS_PROTOCOL_SMP == task->task_proto) { in isci_request_io_request_complete()
2772 dev_err(&ihost->pdev->dev, in isci_request_io_request_complete()
2778 dev_err(&ihost->pdev->dev, in isci_request_io_request_complete()
2784 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_io_request_complete()
2785 response = task->task_status.resp; in isci_request_io_request_complete()
2786 status = task->task_status.stat; in isci_request_io_request_complete()
2794 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_io_request_complete()
2804 task->task_status.residual in isci_request_io_request_complete()
2805 = task->total_xfer_len - transferred_length; in isci_request_io_request_complete()
2810 if (task->task_status.residual != 0) in isci_request_io_request_complete()
2813 dev_dbg(&ihost->pdev->dev, in isci_request_io_request_complete()
2818 dev_dbg(&ihost->pdev->dev, "%s: SCI_IO_SUCCESS\n", in isci_request_io_request_complete()
2824 dev_dbg(&ihost->pdev->dev, in isci_request_io_request_complete()
2829 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_io_request_complete()
2833 * that we ignore the quiesce state, since we are in isci_request_io_request_complete()
2834 * concerned about the actual device state. in isci_request_io_request_complete()
2857 spin_lock_irqsave(&task->task_state_lock, task_flags); in isci_request_io_request_complete()
2858 task->task_state_flags |= SAS_TASK_NEED_DEV_RESET; in isci_request_io_request_complete()
2859 spin_unlock_irqrestore(&task->task_state_lock, task_flags); in isci_request_io_request_complete()
2865 clear_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_io_request_complete()
2877 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_io_request_complete()
2883 dev_dbg(&ihost->pdev->dev, in isci_request_io_request_complete()
2884 "%s: invalid completion code: 0x%x - " in isci_request_io_request_complete()
2891 * that we ignore the quiesce state, since we are in isci_request_io_request_complete()
2892 * concerned about the actual device state. in isci_request_io_request_complete()
2899 if (SAS_PROTOCOL_SMP == task->task_proto) in isci_request_io_request_complete()
2900 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_io_request_complete()
2902 clear_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_io_request_complete()
2906 switch (task->task_proto) { in isci_request_io_request_complete()
2908 if (task->data_dir == DMA_NONE) in isci_request_io_request_complete()
2910 if (task->num_scatter == 0) in isci_request_io_request_complete()
2912 dma_unmap_single(&ihost->pdev->dev, in isci_request_io_request_complete()
2913 request->zero_scatter_daddr, in isci_request_io_request_complete()
2914 task->total_xfer_len, task->data_dir); in isci_request_io_request_complete()
2916 dma_unmap_sg(&ihost->pdev->dev, task->scatter, in isci_request_io_request_complete()
2917 request->num_sg_entries, task->data_dir); in isci_request_io_request_complete()
2920 struct scatterlist *sg = &task->smp_task.smp_req; in isci_request_io_request_complete()
2924 dma_unmap_sg(&ihost->pdev->dev, sg, 1, DMA_TO_DEVICE); in isci_request_io_request_complete()
2926 /* need to swab it back in case the command buffer is re-used */ in isci_request_io_request_complete()
2928 smp_req = kaddr + sg->offset; in isci_request_io_request_complete()
2929 sci_swab32_cpy(smp_req, smp_req, sg->length / sizeof(u32)); in isci_request_io_request_complete()
2937 spin_lock_irqsave(&task->task_state_lock, task_flags); in isci_request_io_request_complete()
2939 task->task_status.resp = response; in isci_request_io_request_complete()
2940 task->task_status.stat = status; in isci_request_io_request_complete()
2942 if (test_bit(IREQ_COMPLETE_IN_TARGET, &request->flags)) { in isci_request_io_request_complete()
2944 task->task_state_flags |= SAS_TASK_STATE_DONE; in isci_request_io_request_complete()
2945 task->task_state_flags &= ~(SAS_TASK_AT_INITIATOR | in isci_request_io_request_complete()
2948 spin_unlock_irqrestore(&task->task_state_lock, task_flags); in isci_request_io_request_complete()
2951 sci_controller_complete_io(ihost, request->target_device, request); in isci_request_io_request_complete()
2957 set_bit(IREQ_TERMINATED, &request->flags); in isci_request_io_request_complete()
2965 struct domain_device *dev = ireq->target_device->domain_dev; in sci_request_started_state_enter()
2966 enum sci_base_request_states state; in sci_request_started_state_enter() local
2972 task = (test_bit(IREQ_TMF, &ireq->flags)) ? NULL : isci_request_access_task(ireq); in sci_request_started_state_enter()
2977 if (!task && dev->dev_type == SAS_END_DEVICE) { in sci_request_started_state_enter()
2978 state = SCI_REQ_TASK_WAIT_TC_COMP; in sci_request_started_state_enter()
2979 } else if (task && task->task_proto == SAS_PROTOCOL_SMP) { in sci_request_started_state_enter()
2980 state = SCI_REQ_SMP_WAIT_RESP; in sci_request_started_state_enter()
2981 } else if (task && sas_protocol_ata(task->task_proto) && in sci_request_started_state_enter()
2982 !task->ata_task.use_ncq) { in sci_request_started_state_enter()
2983 if (dev->sata_dev.class == ATA_DEV_ATAPI && in sci_request_started_state_enter()
2984 task->ata_task.fis.command == ATA_CMD_PACKET) { in sci_request_started_state_enter()
2985 state = SCI_REQ_ATAPI_WAIT_H2D; in sci_request_started_state_enter()
2986 } else if (task->data_dir == DMA_NONE) { in sci_request_started_state_enter()
2987 state = SCI_REQ_STP_NON_DATA_WAIT_H2D; in sci_request_started_state_enter()
2988 } else if (task->ata_task.dma_xfer) { in sci_request_started_state_enter()
2989 state = SCI_REQ_STP_UDMA_WAIT_TC_COMP; in sci_request_started_state_enter()
2991 state = SCI_REQ_STP_PIO_WAIT_H2D; in sci_request_started_state_enter()
2997 sci_change_state(sm, state); in sci_request_started_state_enter()
3003 struct isci_host *ihost = ireq->owning_controller; in sci_request_completed_state_enter()
3006 if (!test_bit(IREQ_TMF, &ireq->flags)) in sci_request_completed_state_enter()
3008 ireq->sci_status); in sci_request_completed_state_enter()
3010 isci_task_request_complete(ihost, ireq, ireq->sci_status); in sci_request_completed_state_enter()
3018 ireq->tc->abort = 1; in sci_request_aborting_state_enter()
3025 ireq->target_device->working_request = ireq; in sci_stp_request_started_non_data_await_h2d_completion_enter()
3032 ireq->target_device->working_request = ireq; in sci_stp_request_started_pio_await_h2d_completion_enter()
3075 sci_init_sm(&ireq->sm, sci_request_state_table, SCI_REQ_INIT); in sci_general_request_construct()
3077 ireq->target_device = idev; in sci_general_request_construct()
3078 ireq->protocol = SAS_PROTOCOL_NONE; in sci_general_request_construct()
3079 ireq->saved_rx_frame_index = SCU_INVALID_FRAME_INDEX; in sci_general_request_construct()
3081 ireq->sci_status = SCI_SUCCESS; in sci_general_request_construct()
3082 ireq->scu_status = 0; in sci_general_request_construct()
3083 ireq->post_context = 0xFFFFFFFF; in sci_general_request_construct()
3091 struct domain_device *dev = idev->domain_dev; in sci_io_request_construct()
3097 if (idev->rnc.remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) in sci_io_request_construct()
3100 if (dev->dev_type == SAS_END_DEVICE) in sci_io_request_construct()
3103 memset(&ireq->stp.cmd, 0, sizeof(ireq->stp.cmd)); in sci_io_request_construct()
3104 else if (dev_is_expander(dev->dev_type)) in sci_io_request_construct()
3109 memset(ireq->tc, 0, offsetof(struct scu_task_context, sgl_pair_ab)); in sci_io_request_construct()
3118 struct domain_device *dev = idev->domain_dev; in sci_task_request_construct()
3124 if (dev->dev_type == SAS_END_DEVICE || dev_is_sata(dev)) { in sci_task_request_construct()
3125 set_bit(IREQ_TMF, &ireq->flags); in sci_task_request_construct()
3126 memset(ireq->tc, 0, sizeof(struct scu_task_context)); in sci_task_request_construct()
3130 ireq->protocol = SAS_PROTOCOL_STP; in sci_task_request_construct()
3132 ireq->protocol = SAS_PROTOCOL_SSP; in sci_task_request_construct()
3144 dev_dbg(&request->isci_host->pdev->dev, in isci_request_ssp_request_construct()
3155 struct host_to_dev_fis *fis = &ireq->stp.cmd; in isci_request_stp_request_construct()
3156 struct ata_queued_cmd *qc = task->uldd_task; in isci_request_stp_request_construct()
3159 dev_dbg(&ireq->isci_host->pdev->dev, in isci_request_stp_request_construct()
3164 memcpy(fis, &task->ata_task.fis, sizeof(struct host_to_dev_fis)); in isci_request_stp_request_construct()
3165 if (!task->ata_task.device_control_reg_update) in isci_request_stp_request_construct()
3166 fis->flags |= 0x80; in isci_request_stp_request_construct()
3167 fis->flags &= 0xF0; in isci_request_stp_request_construct()
3171 if (qc && (qc->tf.command == ATA_CMD_FPDMA_WRITE || in isci_request_stp_request_construct()
3172 qc->tf.command == ATA_CMD_FPDMA_READ || in isci_request_stp_request_construct()
3173 qc->tf.command == ATA_CMD_FPDMA_RECV || in isci_request_stp_request_construct()
3174 qc->tf.command == ATA_CMD_FPDMA_SEND || in isci_request_stp_request_construct()
3175 qc->tf.command == ATA_CMD_NCQ_NON_DATA)) { in isci_request_stp_request_construct()
3176 fis->sector_count = qc->tag << 3; in isci_request_stp_request_construct()
3177 ireq->tc->type.stp.ncq_tag = qc->tag; in isci_request_stp_request_construct()
3188 struct scatterlist *sg = &task->smp_task.smp_req; in sci_io_request_construct_smp()
3198 smp_req = kaddr + sg->offset; in sci_io_request_construct_smp()
3202 * a non-zero default length. in sci_io_request_construct_smp()
3204 if (smp_req->req_len == 0) { in sci_io_request_construct_smp()
3205 switch (smp_req->func) { in sci_io_request_construct_smp()
3210 smp_req->req_len = 2; in sci_io_request_construct_smp()
3215 smp_req->req_len = 9; in sci_io_request_construct_smp()
3217 /* Default - zero is a valid default for 2.0. */ in sci_io_request_construct_smp()
3220 req_len = smp_req->req_len; in sci_io_request_construct_smp()
3221 sci_swab32_cpy(smp_req, smp_req, sg->length / sizeof(u32)); in sci_io_request_construct_smp()
3228 ireq->protocol = SAS_PROTOCOL_SMP; in sci_io_request_construct_smp()
3232 task_context = ireq->tc; in sci_io_request_construct_smp()
3234 idev = ireq->target_device; in sci_io_request_construct_smp()
3235 iport = idev->owning_port; in sci_io_request_construct_smp()
3241 task_context->priority = 0; in sci_io_request_construct_smp()
3242 task_context->initiator_request = 1; in sci_io_request_construct_smp()
3243 task_context->connection_rate = idev->connection_rate; in sci_io_request_construct_smp()
3244 task_context->protocol_engine_index = ISCI_PEG; in sci_io_request_construct_smp()
3245 task_context->logical_port_index = iport->physical_port_index; in sci_io_request_construct_smp()
3246 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SMP; in sci_io_request_construct_smp()
3247 task_context->abort = 0; in sci_io_request_construct_smp()
3248 task_context->valid = SCU_TASK_CONTEXT_VALID; in sci_io_request_construct_smp()
3249 task_context->context_type = SCU_TASK_CONTEXT_TYPE; in sci_io_request_construct_smp()
3252 task_context->remote_node_index = idev->rnc.remote_node_index; in sci_io_request_construct_smp()
3253 task_context->command_code = 0; in sci_io_request_construct_smp()
3254 task_context->task_type = SCU_TASK_TYPE_SMP_REQUEST; in sci_io_request_construct_smp()
3257 task_context->link_layer_control = 0; in sci_io_request_construct_smp()
3258 task_context->do_not_dma_ssp_good_response = 1; in sci_io_request_construct_smp()
3259 task_context->strict_ordering = 0; in sci_io_request_construct_smp()
3260 task_context->control_frame = 1; in sci_io_request_construct_smp()
3261 task_context->timeout_enable = 0; in sci_io_request_construct_smp()
3262 task_context->block_guard_enable = 0; in sci_io_request_construct_smp()
3265 task_context->address_modifier = 0; in sci_io_request_construct_smp()
3268 task_context->ssp_command_iu_length = req_len; in sci_io_request_construct_smp()
3271 task_context->transfer_length_bytes = 0; in sci_io_request_construct_smp()
3277 memcpy(&task_context->type.smp, &cmd, sizeof(u32)); in sci_io_request_construct_smp()
3282 * so that done code will be consistent." - Venki in sci_io_request_construct_smp()
3284 task_context->task_phase = 0; in sci_io_request_construct_smp()
3286 ireq->post_context = (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | in sci_io_request_construct_smp()
3288 (iport->physical_port_index << in sci_io_request_construct_smp()
3290 ISCI_TAG_TCI(ireq->io_tag)); in sci_io_request_construct_smp()
3295 task_context->command_iu_upper = upper_32_bits(sg_dma_address(sg)); in sci_io_request_construct_smp()
3296 task_context->command_iu_lower = lower_32_bits(sg_dma_address(sg) + sizeof(u32)); in sci_io_request_construct_smp()
3299 task_context->response_iu_upper = 0; in sci_io_request_construct_smp()
3300 task_context->response_iu_lower = 0; in sci_io_request_construct_smp()
3302 sci_change_state(&ireq->sm, SCI_REQ_CONSTRUCTED); in sci_io_request_construct_smp()
3308 * isci_smp_request_build() - This function builds the smp request.
3317 struct device *dev = &ireq->isci_host->pdev->dev; in isci_smp_request_build()
3322 dev_dbg(&ireq->isci_host->pdev->dev, in isci_smp_request_build()
3331 * isci_io_request_build() - This function builds the io request object.
3347 dev_dbg(&ihost->pdev->dev, in isci_io_request_build()
3353 task->num_scatter); in isci_io_request_build()
3359 if (task->num_scatter && in isci_io_request_build()
3360 !sas_protocol_ata(task->task_proto) && in isci_io_request_build()
3361 !(SAS_PROTOCOL_SMP & task->task_proto)) { in isci_io_request_build()
3363 request->num_sg_entries = dma_map_sg( in isci_io_request_build()
3364 &ihost->pdev->dev, in isci_io_request_build()
3365 task->scatter, in isci_io_request_build()
3366 task->num_scatter, in isci_io_request_build()
3367 task->data_dir in isci_io_request_build()
3370 if (request->num_sg_entries == 0) in isci_io_request_build()
3377 dev_dbg(&ihost->pdev->dev, in isci_io_request_build()
3383 switch (task->task_proto) { in isci_io_request_build()
3396 dev_dbg(&ihost->pdev->dev, in isci_io_request_build()
3408 ireq = ihost->reqs[ISCI_TAG_TCI(tag)]; in isci_request_from_tag()
3409 ireq->io_tag = tag; in isci_request_from_tag()
3410 ireq->io_request_completion = NULL; in isci_request_from_tag()
3411 ireq->flags = 0; in isci_request_from_tag()
3412 ireq->num_sg_entries = 0; in isci_request_from_tag()
3424 ireq->ttype_ptr.io_task_ptr = task; in isci_io_request_from_tag()
3425 clear_bit(IREQ_TMF, &ireq->flags); in isci_io_request_from_tag()
3426 task->lldd_task = ireq; in isci_io_request_from_tag()
3438 ireq->ttype_ptr.tmf_task_ptr = isci_tmf; in isci_tmf_request_from_tag()
3439 set_bit(IREQ_TMF, &ireq->flags); in isci_tmf_request_from_tag()
3457 dev_dbg(&ihost->pdev->dev, in isci_request_execute()
3458 "%s: request_construct failed - status = 0x%x\n", in isci_request_execute()
3464 spin_lock_irqsave(&ihost->scic_lock, flags); in isci_request_execute()
3466 if (test_bit(IDEV_IO_NCQERROR, &idev->flags)) { in isci_request_execute()
3470 /* The device is in an NCQ recovery state. Issue the in isci_request_execute()
3474 * ireq->is_task_management_request is false). in isci_request_execute()
3490 dev_dbg(&ihost->pdev->dev, in isci_request_execute()
3493 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_request_execute()
3504 set_bit(IREQ_TERMINATED, &ireq->flags); in isci_request_execute()
3506 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_request_execute()
3514 spin_lock_irqsave(&task->task_state_lock, flags); in isci_request_execute()
3515 task->task_state_flags |= SAS_TASK_NEED_DEV_RESET; in isci_request_execute()
3516 spin_unlock_irqrestore(&task->task_state_lock, flags); in isci_request_execute()