Lines Matching +full:fis +full:- +full:index +full:- +full:block
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.
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 = 0; 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()
221 idev = ireq->target_device; in scu_ssp_request_construct_task_context()
222 iport = idev->owning_port; in scu_ssp_request_construct_task_context()
225 task_context->abort = 0; in scu_ssp_request_construct_task_context()
226 task_context->priority = 0; in scu_ssp_request_construct_task_context()
227 task_context->initiator_request = 1; in scu_ssp_request_construct_task_context()
228 task_context->connection_rate = idev->connection_rate; in scu_ssp_request_construct_task_context()
229 task_context->protocol_engine_index = ISCI_PEG; in scu_ssp_request_construct_task_context()
230 task_context->logical_port_index = iport->physical_port_index; in scu_ssp_request_construct_task_context()
231 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SSP; in scu_ssp_request_construct_task_context()
232 task_context->valid = SCU_TASK_CONTEXT_VALID; in scu_ssp_request_construct_task_context()
233 task_context->context_type = SCU_TASK_CONTEXT_TYPE; in scu_ssp_request_construct_task_context()
235 task_context->remote_node_index = idev->rnc.remote_node_index; in scu_ssp_request_construct_task_context()
236 task_context->command_code = 0; in scu_ssp_request_construct_task_context()
238 task_context->link_layer_control = 0; in scu_ssp_request_construct_task_context()
239 task_context->do_not_dma_ssp_good_response = 1; in scu_ssp_request_construct_task_context()
240 task_context->strict_ordering = 0; in scu_ssp_request_construct_task_context()
241 task_context->control_frame = 0; in scu_ssp_request_construct_task_context()
242 task_context->timeout_enable = 0; in scu_ssp_request_construct_task_context()
243 task_context->block_guard_enable = 0; in scu_ssp_request_construct_task_context()
245 task_context->address_modifier = 0; in scu_ssp_request_construct_task_context()
247 /* task_context->type.ssp.tag = ireq->io_tag; */ in scu_ssp_request_construct_task_context()
248 task_context->task_phase = 0x01; in scu_ssp_request_construct_task_context()
250 ireq->post_context = (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | in scu_ssp_request_construct_task_context()
252 (iport->physical_port_index << in scu_ssp_request_construct_task_context()
254 ISCI_TAG_TCI(ireq->io_tag)); in scu_ssp_request_construct_task_context()
260 dma_addr = sci_io_request_get_dma_addr(ireq, &ireq->ssp.cmd); in scu_ssp_request_construct_task_context()
262 task_context->command_iu_upper = upper_32_bits(dma_addr); in scu_ssp_request_construct_task_context()
263 task_context->command_iu_lower = lower_32_bits(dma_addr); in scu_ssp_request_construct_task_context()
269 dma_addr = sci_io_request_get_dma_addr(ireq, &ireq->ssp.rsp); in scu_ssp_request_construct_task_context()
271 task_context->response_iu_upper = upper_32_bits(dma_addr); in scu_ssp_request_construct_task_context()
272 task_context->response_iu_lower = lower_32_bits(dma_addr); in scu_ssp_request_construct_task_context()
277 switch (sdp->sector_size) { in scu_bg_blk_size()
296 struct scu_task_context *tc = ireq->tc; in scu_ssp_ireq_dif_insert()
297 struct scsi_cmnd *scmd = ireq->ttype_ptr.io_task_ptr->uldd_task; in scu_ssp_ireq_dif_insert()
298 u8 blk_sz = scu_bg_blk_size(scmd->device); in scu_ssp_ireq_dif_insert()
300 tc->block_guard_enable = 1; in scu_ssp_ireq_dif_insert()
301 tc->blk_prot_en = 1; in scu_ssp_ireq_dif_insert()
302 tc->blk_sz = blk_sz; in scu_ssp_ireq_dif_insert()
304 tc->blk_prot_func = 0x2; in scu_ssp_ireq_dif_insert()
306 tc->transfer_length_bytes += scu_dif_bytes(tc->transfer_length_bytes, in scu_ssp_ireq_dif_insert()
307 scmd->device->sector_size); in scu_ssp_ireq_dif_insert()
310 tc->interm_crc_val = 0; in scu_ssp_ireq_dif_insert()
312 tc->init_crc_seed = 0; in scu_ssp_ireq_dif_insert()
313 tc->app_tag_verify = 0; in scu_ssp_ireq_dif_insert()
314 tc->app_tag_gen = 0; in scu_ssp_ireq_dif_insert()
315 tc->ref_tag_seed_verify = 0; in scu_ssp_ireq_dif_insert()
318 tc->UD_bytes_immed_val = scmd->device->sector_size; in scu_ssp_ireq_dif_insert()
320 tc->reserved_DC_0 = 0; in scu_ssp_ireq_dif_insert()
323 tc->DIF_bytes_immed_val = 8; in scu_ssp_ireq_dif_insert()
325 tc->reserved_DC_1 = 0; in scu_ssp_ireq_dif_insert()
326 tc->bgc_blk_sz = scmd->device->sector_size; in scu_ssp_ireq_dif_insert()
327 tc->reserved_E0_0 = 0; in scu_ssp_ireq_dif_insert()
328 tc->app_tag_gen_mask = 0; in scu_ssp_ireq_dif_insert()
330 /** setup block guard control **/ in scu_ssp_ireq_dif_insert()
331 tc->bgctl = 0; in scu_ssp_ireq_dif_insert()
334 tc->bgctl_f.op = 0x2; in scu_ssp_ireq_dif_insert()
336 tc->app_tag_verify_mask = 0; in scu_ssp_ireq_dif_insert()
339 tc->blk_guard_err = 0; in scu_ssp_ireq_dif_insert()
341 tc->reserved_E8_0 = 0; in scu_ssp_ireq_dif_insert()
344 tc->ref_tag_seed_gen = scsi_prot_ref_tag(scmd); in scu_ssp_ireq_dif_insert()
346 tc->ref_tag_seed_gen = 0; in scu_ssp_ireq_dif_insert()
351 struct scu_task_context *tc = ireq->tc; in scu_ssp_ireq_dif_strip()
352 struct scsi_cmnd *scmd = ireq->ttype_ptr.io_task_ptr->uldd_task; in scu_ssp_ireq_dif_strip()
353 u8 blk_sz = scu_bg_blk_size(scmd->device); in scu_ssp_ireq_dif_strip()
355 tc->block_guard_enable = 1; in scu_ssp_ireq_dif_strip()
356 tc->blk_prot_en = 1; in scu_ssp_ireq_dif_strip()
357 tc->blk_sz = blk_sz; in scu_ssp_ireq_dif_strip()
359 tc->blk_prot_func = 0x1; in scu_ssp_ireq_dif_strip()
361 tc->transfer_length_bytes += scu_dif_bytes(tc->transfer_length_bytes, in scu_ssp_ireq_dif_strip()
362 scmd->device->sector_size); in scu_ssp_ireq_dif_strip()
365 tc->interm_crc_val = 0; in scu_ssp_ireq_dif_strip()
367 tc->init_crc_seed = 0; in scu_ssp_ireq_dif_strip()
368 tc->app_tag_verify = 0; in scu_ssp_ireq_dif_strip()
369 tc->app_tag_gen = 0; in scu_ssp_ireq_dif_strip()
372 tc->ref_tag_seed_verify = scsi_prot_ref_tag(scmd); in scu_ssp_ireq_dif_strip()
374 tc->ref_tag_seed_verify = 0; in scu_ssp_ireq_dif_strip()
377 tc->UD_bytes_immed_val = scmd->device->sector_size; in scu_ssp_ireq_dif_strip()
379 tc->reserved_DC_0 = 0; in scu_ssp_ireq_dif_strip()
382 tc->DIF_bytes_immed_val = 8; in scu_ssp_ireq_dif_strip()
384 tc->reserved_DC_1 = 0; in scu_ssp_ireq_dif_strip()
385 tc->bgc_blk_sz = scmd->device->sector_size; in scu_ssp_ireq_dif_strip()
386 tc->reserved_E0_0 = 0; in scu_ssp_ireq_dif_strip()
387 tc->app_tag_gen_mask = 0; in scu_ssp_ireq_dif_strip()
389 /** setup block guard control **/ in scu_ssp_ireq_dif_strip()
390 tc->bgctl = 0; in scu_ssp_ireq_dif_strip()
393 tc->bgctl_f.crc_verify = 1; in scu_ssp_ireq_dif_strip()
394 tc->bgctl_f.op = 0x1; in scu_ssp_ireq_dif_strip()
396 tc->bgctl_f.ref_tag_chk = 1; in scu_ssp_ireq_dif_strip()
397 tc->bgctl_f.app_f_detect = 1; in scu_ssp_ireq_dif_strip()
399 tc->bgctl_f.app_ref_f_detect = 1; in scu_ssp_ireq_dif_strip()
401 tc->app_tag_verify_mask = 0; in scu_ssp_ireq_dif_strip()
404 tc->blk_guard_err = 0; in scu_ssp_ireq_dif_strip()
406 tc->reserved_E8_0 = 0; in scu_ssp_ireq_dif_strip()
407 tc->ref_tag_seed_gen = 0; in scu_ssp_ireq_dif_strip()
417 struct scu_task_context *task_context = ireq->tc; in scu_ssp_io_request_construct_task_context()
418 struct sas_task *sas_task = ireq->ttype_ptr.io_task_ptr; in scu_ssp_io_request_construct_task_context()
419 struct scsi_cmnd *scmd = sas_task->uldd_task; in scu_ssp_io_request_construct_task_context()
425 task_context->ssp_command_iu_length = in scu_ssp_io_request_construct_task_context()
427 task_context->type.ssp.frame_type = SSP_COMMAND; in scu_ssp_io_request_construct_task_context()
433 task_context->task_type = SCU_TASK_TYPE_IOREAD; in scu_ssp_io_request_construct_task_context()
436 task_context->task_type = SCU_TASK_TYPE_IOWRITE; in scu_ssp_io_request_construct_task_context()
440 task_context->transfer_length_bytes = len; in scu_ssp_io_request_construct_task_context()
442 if (task_context->transfer_length_bytes > 0) in scu_ssp_io_request_construct_task_context()
454 * scu_ssp_task_request_construct_task_context() - This method will fill in
456 * settings are utilized: -# priority == SCU_TASK_PRIORITY_HIGH. This
458 * for the same Remote Node. -# task_type == SCU_TASK_TYPE_IOREAD. This
459 * simply indicates that a normal request type (i.e. non-raw frame) is
460 * being utilized to perform task management. -#control_frame == 1. This
467 struct scu_task_context *task_context = ireq->tc; in scu_ssp_task_request_construct_task_context()
471 task_context->control_frame = 1; in scu_ssp_task_request_construct_task_context()
472 task_context->priority = SCU_TASK_PRIORITY_HIGH; in scu_ssp_task_request_construct_task_context()
473 task_context->task_type = SCU_TASK_TYPE_RAW_FRAME; in scu_ssp_task_request_construct_task_context()
474 task_context->transfer_length_bytes = 0; in scu_ssp_task_request_construct_task_context()
475 task_context->type.ssp.frame_type = SSP_TASK; in scu_ssp_task_request_construct_task_context()
476 task_context->ssp_command_iu_length = in scu_ssp_task_request_construct_task_context()
501 idev = ireq->target_device; in scu_sata_request_construct_task_context()
502 iport = idev->owning_port; in scu_sata_request_construct_task_context()
505 task_context->abort = 0; in scu_sata_request_construct_task_context()
506 task_context->priority = SCU_TASK_PRIORITY_NORMAL; in scu_sata_request_construct_task_context()
507 task_context->initiator_request = 1; in scu_sata_request_construct_task_context()
508 task_context->connection_rate = idev->connection_rate; in scu_sata_request_construct_task_context()
509 task_context->protocol_engine_index = ISCI_PEG; in scu_sata_request_construct_task_context()
510 task_context->logical_port_index = iport->physical_port_index; in scu_sata_request_construct_task_context()
511 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_STP; in scu_sata_request_construct_task_context()
512 task_context->valid = SCU_TASK_CONTEXT_VALID; in scu_sata_request_construct_task_context()
513 task_context->context_type = SCU_TASK_CONTEXT_TYPE; in scu_sata_request_construct_task_context()
515 task_context->remote_node_index = idev->rnc.remote_node_index; in scu_sata_request_construct_task_context()
516 task_context->command_code = 0; in scu_sata_request_construct_task_context()
518 task_context->link_layer_control = 0; in scu_sata_request_construct_task_context()
519 task_context->do_not_dma_ssp_good_response = 1; in scu_sata_request_construct_task_context()
520 task_context->strict_ordering = 0; in scu_sata_request_construct_task_context()
521 task_context->control_frame = 0; in scu_sata_request_construct_task_context()
522 task_context->timeout_enable = 0; in scu_sata_request_construct_task_context()
523 task_context->block_guard_enable = 0; in scu_sata_request_construct_task_context()
525 task_context->address_modifier = 0; in scu_sata_request_construct_task_context()
526 task_context->task_phase = 0x01; in scu_sata_request_construct_task_context()
528 task_context->ssp_command_iu_length = in scu_sata_request_construct_task_context()
529 (sizeof(struct host_to_dev_fis) - sizeof(u32)) / sizeof(u32); in scu_sata_request_construct_task_context()
531 /* Set the first word of the H2D REG FIS */ in scu_sata_request_construct_task_context()
532 task_context->type.words[0] = *(u32 *)&ireq->stp.cmd; in scu_sata_request_construct_task_context()
534 ireq->post_context = (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | in scu_sata_request_construct_task_context()
536 (iport->physical_port_index << in scu_sata_request_construct_task_context()
538 ISCI_TAG_TCI(ireq->io_tag)); in scu_sata_request_construct_task_context()
545 ((char *) &ireq->stp.cmd) + in scu_sata_request_construct_task_context()
548 task_context->command_iu_upper = upper_32_bits(dma_addr); in scu_sata_request_construct_task_context()
549 task_context->command_iu_lower = lower_32_bits(dma_addr); in scu_sata_request_construct_task_context()
552 task_context->response_iu_upper = 0; in scu_sata_request_construct_task_context()
553 task_context->response_iu_lower = 0; in scu_sata_request_construct_task_context()
558 struct scu_task_context *task_context = ireq->tc; in scu_stp_raw_request_construct_task_context()
562 task_context->control_frame = 0; in scu_stp_raw_request_construct_task_context()
563 task_context->priority = SCU_TASK_PRIORITY_NORMAL; in scu_stp_raw_request_construct_task_context()
564 task_context->task_type = SCU_TASK_TYPE_SATA_RAW_FRAME; in scu_stp_raw_request_construct_task_context()
565 task_context->type.stp.fis_type = FIS_REGH2D; in scu_stp_raw_request_construct_task_context()
566 task_context->transfer_length_bytes = sizeof(struct host_to_dev_fis) - sizeof(u32); in scu_stp_raw_request_construct_task_context()
572 struct isci_stp_request *stp_req = &ireq->stp.req; in sci_stp_pio_request_construct()
576 stp_req->status = 0; in sci_stp_pio_request_construct()
577 stp_req->sgl.offset = 0; in sci_stp_pio_request_construct()
578 stp_req->sgl.set = SCU_SGL_ELEMENT_PAIR_A; in sci_stp_pio_request_construct()
582 stp_req->sgl.index = 0; in sci_stp_pio_request_construct()
585 stp_req->sgl.index = -1; in sci_stp_pio_request_construct()
596 * an UDMA request or a NCQ request. - A value of 0 indicates UDMA. - A
608 struct scu_task_context *task_context = ireq->tc; in sci_stp_optimized_request_construct()
617 task_context->transfer_length_bytes = len; in sci_stp_optimized_request_construct()
626 task_context->task_type = optimized_task_type + (SCU_TASK_TYPE_DMA_OUT in sci_stp_optimized_request_construct()
627 - SCU_TASK_TYPE_DMA_IN); in sci_stp_optimized_request_construct()
632 task_context->task_type = optimized_task_type; in sci_stp_optimized_request_construct()
638 struct host_to_dev_fis *h2d_fis = &ireq->stp.cmd; in sci_atapi_construct()
646 h2d_fis->features |= ATAPI_PKT_DMA; in sci_atapi_construct()
651 if (task->data_dir == DMA_NONE) in sci_atapi_construct()
652 task->total_xfer_len = 0; in sci_atapi_construct()
655 * unsolicited h2d fis in sci_atapi_construct()
657 ireq->stp.rsp.fis_type = 0; in sci_atapi_construct()
668 struct domain_device *dev = ireq->target_device->domain_dev; in sci_io_request_construct_sata()
671 if (test_bit(IREQ_TMF, &ireq->flags)) { in sci_io_request_construct_sata()
674 dev_err(&ireq->owning_controller->pdev->dev, in sci_io_request_construct_sata()
675 "%s: Request 0x%p received un-handled SAT " in sci_io_request_construct_sata()
677 __func__, ireq, tmf->tmf_code); in sci_io_request_construct_sata()
682 if (!sas_protocol_ata(task->task_proto)) { in sci_io_request_construct_sata()
683 dev_err(&ireq->owning_controller->pdev->dev, in sci_io_request_construct_sata()
684 "%s: Non-ATA protocol in SATA path: 0x%x\n", in sci_io_request_construct_sata()
686 task->task_proto); in sci_io_request_construct_sata()
692 if (dev->sata_dev.class == ATA_DEV_ATAPI && in sci_io_request_construct_sata()
693 task->ata_task.fis.command == ATA_CMD_PACKET) { in sci_io_request_construct_sata()
699 if (task->data_dir == DMA_NONE) { in sci_io_request_construct_sata()
705 if (task->ata_task.use_ncq) { in sci_io_request_construct_sata()
713 if (task->ata_task.dma_xfer) { in sci_io_request_construct_sata()
728 ireq->protocol = SAS_PROTOCOL_SSP; in sci_io_request_construct_basic_ssp()
731 task->data_dir, in sci_io_request_construct_basic_ssp()
732 task->total_xfer_len); in sci_io_request_construct_basic_ssp()
736 sci_change_state(&ireq->sm, SCI_REQ_CONSTRUCTED); in sci_io_request_construct_basic_ssp()
749 sci_change_state(&ireq->sm, SCI_REQ_CONSTRUCTED); in sci_task_request_construct_ssp()
758 ireq->protocol = SAS_PROTOCOL_STP; in sci_io_request_construct_basic_sata()
760 copy = (task->data_dir == DMA_NONE) ? false : true; in sci_io_request_construct_basic_sata()
763 task->total_xfer_len, in sci_io_request_construct_basic_sata()
764 task->data_dir, in sci_io_request_construct_basic_sata()
768 sci_change_state(&ireq->sm, SCI_REQ_CONSTRUCTED); in sci_io_request_construct_basic_sata()
775 * sci_req_tx_bytes - bytes transferred when reply underruns request
780 struct isci_host *ihost = ireq->owning_controller; in sci_req_tx_bytes()
783 if (readl(&ihost->smu_registers->address_modifier) == 0) { in sci_req_tx_bytes()
784 void __iomem *scu_reg_base = ihost->scu_registers; in sci_req_tx_bytes()
794 ((sizeof(struct scu_task_context)) * ISCI_TAG_TCI(ireq->io_tag))); in sci_req_tx_bytes()
803 struct scu_task_context *tc = ireq->tc; in sci_request_start()
804 struct isci_host *ihost = ireq->owning_controller; in sci_request_start()
806 state = ireq->sm.current_state_id; in sci_request_start()
808 dev_warn(&ihost->pdev->dev, in sci_request_start()
814 tc->task_index = ISCI_TAG_TCI(ireq->io_tag); in sci_request_start()
816 switch (tc->protocol_type) { in sci_request_start()
820 tc->type.ssp.tag = ireq->io_tag; in sci_request_start()
821 tc->type.ssp.target_port_transfer_tag = 0xFFFF; in sci_request_start()
826 * tc->type.stp.ncq_tag = ireq->ncq_tag; in sci_request_start()
841 ireq->post_context |= ISCI_TAG_TCI(ireq->io_tag); in sci_request_start()
844 sci_change_state(&ireq->sm, SCI_REQ_STARTED); in sci_request_start()
854 state = ireq->sm.current_state_id; in sci_io_request_terminate()
859 set_bit(IREQ_TC_ABORT_POSTED, &ireq->flags); in sci_io_request_terminate()
860 ireq->scu_status = SCU_TASK_DONE_TASK_ABORT; in sci_io_request_terminate()
861 ireq->sci_status = SCI_FAILURE_IO_TERMINATED; in sci_io_request_terminate()
862 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_terminate()
888 sci_change_state(&ireq->sm, SCI_REQ_ABORTING); in sci_io_request_terminate()
891 if (!isci_remote_device_is_safe_to_abort(ireq->target_device)) in sci_io_request_terminate()
892 set_bit(IREQ_PENDING_ABORT, &ireq->flags); in sci_io_request_terminate()
894 clear_bit(IREQ_PENDING_ABORT, &ireq->flags); in sci_io_request_terminate()
901 dev_warn(&ireq->owning_controller->pdev->dev, in sci_io_request_terminate()
903 "state %d\n", __func__, ireq->sm.current_state_id); in sci_io_request_terminate()
913 struct isci_host *ihost = ireq->owning_controller; in sci_request_complete()
915 state = ireq->sm.current_state_id; in sci_request_complete()
921 if (ireq->saved_rx_frame_index != SCU_INVALID_FRAME_INDEX) in sci_request_complete()
923 ireq->saved_rx_frame_index); in sci_request_complete()
926 sci_change_state(&ireq->sm, SCI_REQ_FINAL); in sci_request_complete()
934 struct isci_host *ihost = ireq->owning_controller; in sci_io_request_event_handler()
936 state = ireq->sm.current_state_id; in sci_io_request_event_handler()
939 dev_warn(&ihost->pdev->dev, "%s: (%x) in wrong state %s\n", in sci_io_request_event_handler()
948 * Go back to waiting for the D2H Register FIS in sci_io_request_event_handler()
950 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); in sci_io_request_event_handler()
953 dev_err(&ihost->pdev->dev, in sci_io_request_event_handler()
977 ssp_response = &ireq->ssp.rsp; in sci_io_request_copy_response()
979 resp_buf = &isci_tmf->resp.resp_iu; in sci_io_request_copy_response()
983 be32_to_cpu(ssp_response->response_data_len)); in sci_io_request_copy_response()
985 memcpy(resp_buf, ssp_response->resp_data, len); in sci_io_request_copy_response()
1000 ireq->scu_status = SCU_TASK_DONE_GOOD; in request_started_state_tc_event()
1001 ireq->sci_status = SCI_SUCCESS; in request_started_state_tc_event()
1011 struct ssp_response_iu *resp = &ireq->ssp.rsp; in request_started_state_tc_event()
1014 sci_swab32_cpy(&ireq->ssp.rsp, in request_started_state_tc_event()
1015 &ireq->ssp.rsp, in request_started_state_tc_event()
1018 if (resp->status == 0) { in request_started_state_tc_event()
1019 ireq->scu_status = SCU_TASK_DONE_GOOD; in request_started_state_tc_event()
1020 ireq->sci_status = SCI_SUCCESS_IO_DONE_EARLY; in request_started_state_tc_event()
1022 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in request_started_state_tc_event()
1023 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in request_started_state_tc_event()
1030 sci_swab32_cpy(&ireq->ssp.rsp, in request_started_state_tc_event()
1031 &ireq->ssp.rsp, in request_started_state_tc_event()
1034 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in request_started_state_tc_event()
1035 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in request_started_state_tc_event()
1044 resp_iu = &ireq->ssp.rsp; in request_started_state_tc_event()
1045 datapres = resp_iu->datapres; in request_started_state_tc_event()
1049 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in request_started_state_tc_event()
1050 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in request_started_state_tc_event()
1052 ireq->scu_status = SCU_TASK_DONE_GOOD; in request_started_state_tc_event()
1053 ireq->sci_status = SCI_SUCCESS; in request_started_state_tc_event()
1068 if (ireq->protocol == SAS_PROTOCOL_STP) { in request_started_state_tc_event()
1069 ireq->scu_status = SCU_GET_COMPLETION_TL_STATUS(completion_code) >> in request_started_state_tc_event()
1071 ireq->sci_status = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED; in request_started_state_tc_event()
1073 ireq->scu_status = SCU_GET_COMPLETION_TL_STATUS(completion_code) >> in request_started_state_tc_event()
1075 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in request_started_state_tc_event()
1090 ireq->scu_status = SCU_GET_COMPLETION_TL_STATUS(completion_code) >> in request_started_state_tc_event()
1092 ireq->sci_status = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED; in request_started_state_tc_event()
1112 ireq->scu_status = SCU_GET_COMPLETION_TL_STATUS(completion_code) >> in request_started_state_tc_event()
1114 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in request_started_state_tc_event()
1123 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in request_started_state_tc_event()
1134 ireq->scu_status = SCU_TASK_DONE_TASK_ABORT; in request_aborting_state_tc_event()
1135 ireq->sci_status = SCI_FAILURE_IO_TERMINATED; in request_aborting_state_tc_event()
1136 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in request_aborting_state_tc_event()
1154 ireq->scu_status = SCU_TASK_DONE_GOOD; in ssp_task_request_await_tc_event()
1155 ireq->sci_status = SCI_SUCCESS; in ssp_task_request_await_tc_event()
1156 sci_change_state(&ireq->sm, SCI_REQ_TASK_WAIT_TC_RESP); in ssp_task_request_await_tc_event()
1164 dev_warn(&ireq->owning_controller->pdev->dev, in ssp_task_request_await_tc_event()
1165 "%s: TaskRequest:0x%p CompletionCode:%x - " in ssp_task_request_await_tc_event()
1169 sci_change_state(&ireq->sm, SCI_REQ_TASK_WAIT_TC_RESP); in ssp_task_request_await_tc_event()
1177 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in ssp_task_request_await_tc_event()
1178 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in ssp_task_request_await_tc_event()
1179 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in ssp_task_request_await_tc_event()
1196 ireq->scu_status = SCU_TASK_DONE_GOOD; in smp_request_await_response_tc_event()
1197 ireq->sci_status = SCI_SUCCESS; in smp_request_await_response_tc_event()
1198 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in smp_request_await_response_tc_event()
1211 ireq->scu_status = SCU_TASK_DONE_SMP_RESP_TO_ERR; in smp_request_await_response_tc_event()
1212 ireq->sci_status = SCI_FAILURE_RETRY_REQUIRED; in smp_request_await_response_tc_event()
1213 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in smp_request_await_response_tc_event()
1219 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in smp_request_await_response_tc_event()
1220 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in smp_request_await_response_tc_event()
1221 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in smp_request_await_response_tc_event()
1234 ireq->scu_status = SCU_TASK_DONE_GOOD; in smp_request_await_tc_event()
1235 ireq->sci_status = SCI_SUCCESS; in smp_request_await_tc_event()
1236 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in smp_request_await_tc_event()
1243 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in smp_request_await_tc_event()
1244 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in smp_request_await_tc_event()
1245 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in smp_request_await_tc_event()
1257 struct isci_stp_pio_sgl *pio_sgl = &stp_req->sgl; in pio_sgl_next()
1259 sgl_pair = to_sgl_element_pair(ireq, pio_sgl->index); in pio_sgl_next()
1262 else if (pio_sgl->set == SCU_SGL_ELEMENT_PAIR_A) { in pio_sgl_next()
1263 if (sgl_pair->B.address_lower == 0 && in pio_sgl_next()
1264 sgl_pair->B.address_upper == 0) { in pio_sgl_next()
1267 pio_sgl->set = SCU_SGL_ELEMENT_PAIR_B; in pio_sgl_next()
1268 sgl = &sgl_pair->B; in pio_sgl_next()
1271 if (sgl_pair->next_pair_lower == 0 && in pio_sgl_next()
1272 sgl_pair->next_pair_upper == 0) { in pio_sgl_next()
1275 pio_sgl->index++; in pio_sgl_next()
1276 pio_sgl->set = SCU_SGL_ELEMENT_PAIR_A; in pio_sgl_next()
1277 sgl_pair = to_sgl_element_pair(ireq, pio_sgl->index); in pio_sgl_next()
1278 sgl = &sgl_pair->A; in pio_sgl_next()
1291 ireq->scu_status = SCU_TASK_DONE_GOOD; in stp_request_non_data_await_h2d_tc_event()
1292 ireq->sci_status = SCI_SUCCESS; in stp_request_non_data_await_h2d_tc_event()
1293 sci_change_state(&ireq->sm, SCI_REQ_STP_NON_DATA_WAIT_D2H); in stp_request_non_data_await_h2d_tc_event()
1301 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in stp_request_non_data_await_h2d_tc_event()
1302 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in stp_request_non_data_await_h2d_tc_event()
1303 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in stp_request_non_data_await_h2d_tc_event()
1319 struct isci_stp_request *stp_req = &ireq->stp.req; in sci_stp_request_pio_data_out_trasmit_data_frame()
1320 struct scu_task_context *task_context = ireq->tc; in sci_stp_request_pio_data_out_trasmit_data_frame()
1324 /* Recycle the TC and reconstruct it for sending out DATA FIS containing in sci_stp_request_pio_data_out_trasmit_data_frame()
1327 sgl_pair = to_sgl_element_pair(ireq, stp_req->sgl.index); in sci_stp_request_pio_data_out_trasmit_data_frame()
1328 if (stp_req->sgl.set == SCU_SGL_ELEMENT_PAIR_A) in sci_stp_request_pio_data_out_trasmit_data_frame()
1329 current_sgl = &sgl_pair->A; in sci_stp_request_pio_data_out_trasmit_data_frame()
1331 current_sgl = &sgl_pair->B; in sci_stp_request_pio_data_out_trasmit_data_frame()
1334 task_context->command_iu_upper = current_sgl->address_upper; in sci_stp_request_pio_data_out_trasmit_data_frame()
1335 task_context->command_iu_lower = current_sgl->address_lower; in sci_stp_request_pio_data_out_trasmit_data_frame()
1336 task_context->transfer_length_bytes = length; in sci_stp_request_pio_data_out_trasmit_data_frame()
1337 task_context->type.stp.fis_type = FIS_DATA; in sci_stp_request_pio_data_out_trasmit_data_frame()
1345 struct isci_stp_request *stp_req = &ireq->stp.req; in sci_stp_request_pio_data_out_transmit_data()
1352 offset = stp_req->sgl.offset; in sci_stp_request_pio_data_out_transmit_data()
1353 sgl_pair = to_sgl_element_pair(ireq, stp_req->sgl.index); in sci_stp_request_pio_data_out_transmit_data()
1357 if (stp_req->sgl.set == SCU_SGL_ELEMENT_PAIR_A) { in sci_stp_request_pio_data_out_transmit_data()
1358 sgl = &sgl_pair->A; in sci_stp_request_pio_data_out_transmit_data()
1359 len = sgl_pair->A.length - offset; in sci_stp_request_pio_data_out_transmit_data()
1361 sgl = &sgl_pair->B; in sci_stp_request_pio_data_out_transmit_data()
1362 len = sgl_pair->B.length - offset; in sci_stp_request_pio_data_out_transmit_data()
1365 if (stp_req->pio_len == 0) in sci_stp_request_pio_data_out_transmit_data()
1368 if (stp_req->pio_len >= len) { in sci_stp_request_pio_data_out_transmit_data()
1372 stp_req->pio_len -= len; in sci_stp_request_pio_data_out_transmit_data()
1377 } else if (stp_req->pio_len < len) { in sci_stp_request_pio_data_out_transmit_data()
1378 sci_stp_request_pio_data_out_trasmit_data_frame(ireq, stp_req->pio_len); in sci_stp_request_pio_data_out_transmit_data()
1381 offset += stp_req->pio_len; in sci_stp_request_pio_data_out_transmit_data()
1382 sgl->address_lower += stp_req->pio_len; in sci_stp_request_pio_data_out_transmit_data()
1383 stp_req->pio_len = 0; in sci_stp_request_pio_data_out_transmit_data()
1386 stp_req->sgl.offset = offset; in sci_stp_request_pio_data_out_transmit_data()
1416 if (task->num_scatter > 0) { in sci_stp_request_pio_data_in_copy_data_buffer()
1417 sg = task->scatter; in sci_stp_request_pio_data_in_copy_data_buffer()
1424 memcpy(kaddr + sg->offset, src_addr, copy_len); in sci_stp_request_pio_data_in_copy_data_buffer()
1426 total_len -= copy_len; in sci_stp_request_pio_data_in_copy_data_buffer()
1431 BUG_ON(task->total_xfer_len < total_len); in sci_stp_request_pio_data_in_copy_data_buffer()
1432 memcpy(task->scatter, src_addr, total_len); in sci_stp_request_pio_data_in_copy_data_buffer()
1454 if (stp_req->pio_len < SCU_MAX_FRAME_BUFFER_SIZE) { in sci_stp_request_pio_data_in_copy_data()
1456 stp_req, data_buffer, stp_req->pio_len); in sci_stp_request_pio_data_in_copy_data()
1459 stp_req->pio_len = 0; in sci_stp_request_pio_data_in_copy_data()
1466 stp_req->pio_len -= SCU_MAX_FRAME_BUFFER_SIZE; in sci_stp_request_pio_data_in_copy_data()
1478 ireq->scu_status = SCU_TASK_DONE_GOOD; in stp_request_pio_await_h2d_completion_tc_event()
1479 ireq->sci_status = SCI_SUCCESS; in stp_request_pio_await_h2d_completion_tc_event()
1480 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); in stp_request_pio_await_h2d_completion_tc_event()
1488 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in stp_request_pio_await_h2d_completion_tc_event()
1489 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in stp_request_pio_await_h2d_completion_tc_event()
1490 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in stp_request_pio_await_h2d_completion_tc_event()
1503 struct isci_stp_request *stp_req = &ireq->stp.req; in pio_data_out_tx_done_tc_event()
1508 if (stp_req->pio_len != 0) { in pio_data_out_tx_done_tc_event()
1511 if (stp_req->pio_len == 0) in pio_data_out_tx_done_tc_event()
1514 } else if (stp_req->pio_len == 0) { in pio_data_out_tx_done_tc_event()
1517 * first time after the pio setup fis is received in pio_data_out_tx_done_tc_event()
1526 * and wait for PIO_SETUP fis / or D2H REg fis. */ in pio_data_out_tx_done_tc_event()
1527 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); in pio_data_out_tx_done_tc_event()
1537 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in pio_data_out_tx_done_tc_event()
1538 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in pio_data_out_tx_done_tc_event()
1539 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in pio_data_out_tx_done_tc_event()
1549 struct isci_host *ihost = ireq->owning_controller; in sci_stp_request_udma_general_frame_handler()
1554 status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, in sci_stp_request_udma_general_frame_handler()
1559 (frame_header->fis_type == FIS_REGD2H)) { in sci_stp_request_udma_general_frame_handler()
1560 sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, in sci_stp_request_udma_general_frame_handler()
1564 sci_controller_copy_sata_response(&ireq->stp.rsp, in sci_stp_request_udma_general_frame_handler()
1577 struct isci_host *ihost = ireq->owning_controller; in process_unsolicited_fis()
1582 status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, in process_unsolicited_fis()
1589 if (frame_header->fis_type != FIS_REGD2H) { in process_unsolicited_fis()
1590 dev_err(&ireq->isci_host->pdev->dev, in process_unsolicited_fis()
1591 "%s ERROR: invalid fis type 0x%X\n", in process_unsolicited_fis()
1592 __func__, frame_header->fis_type); in process_unsolicited_fis()
1596 sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, in process_unsolicited_fis()
1600 sci_controller_copy_sata_response(&ireq->stp.rsp, in process_unsolicited_fis()
1619 if (ireq->stp.rsp.status & ATA_ERR) in atapi_d2h_reg_frame_handler()
1626 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in atapi_d2h_reg_frame_handler()
1627 ireq->sci_status = status; in atapi_d2h_reg_frame_handler()
1629 ireq->scu_status = SCU_TASK_DONE_GOOD; in atapi_d2h_reg_frame_handler()
1630 ireq->sci_status = SCI_SUCCESS; in atapi_d2h_reg_frame_handler()
1633 /* the d2h ufi is the end of non-data commands */ in atapi_d2h_reg_frame_handler()
1634 if (task->data_dir == DMA_NONE) in atapi_d2h_reg_frame_handler()
1635 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in atapi_d2h_reg_frame_handler()
1642 struct ata_device *dev = sas_to_ata_dev(ireq->target_device->domain_dev); in scu_atapi_reconstruct_raw_frame_task_context()
1643 void *atapi_cdb = ireq->ttype_ptr.io_task_ptr->ata_task.atapi_packet; in scu_atapi_reconstruct_raw_frame_task_context()
1644 struct scu_task_context *task_context = ireq->tc; in scu_atapi_reconstruct_raw_frame_task_context()
1646 /* fill in the SCU Task Context for a DATA fis containing CDB in Raw Frame in scu_atapi_reconstruct_raw_frame_task_context()
1647 * type. The TC for previous Packet fis was already there, we only need to in scu_atapi_reconstruct_raw_frame_task_context()
1648 * change the H2D fis content. in scu_atapi_reconstruct_raw_frame_task_context()
1650 memset(&ireq->stp.cmd, 0, sizeof(struct host_to_dev_fis)); in scu_atapi_reconstruct_raw_frame_task_context()
1651 memcpy(((u8 *)&ireq->stp.cmd + sizeof(u32)), atapi_cdb, ATAPI_CDB_LEN); in scu_atapi_reconstruct_raw_frame_task_context()
1652 memset(&(task_context->type.stp), 0, sizeof(struct stp_task_context)); in scu_atapi_reconstruct_raw_frame_task_context()
1653 task_context->type.stp.fis_type = FIS_DATA; in scu_atapi_reconstruct_raw_frame_task_context()
1654 task_context->transfer_length_bytes = dev->cdb_len; in scu_atapi_reconstruct_raw_frame_task_context()
1659 struct ata_device *dev = sas_to_ata_dev(ireq->target_device->domain_dev); in scu_atapi_construct_task_context()
1661 struct scu_task_context *task_context = ireq->tc; in scu_atapi_construct_task_context()
1662 int cdb_len = dev->cdb_len; in scu_atapi_construct_task_context()
1667 if (task->data_dir == DMA_TO_DEVICE) { in scu_atapi_construct_task_context()
1668 task_context->task_type = SCU_TASK_TYPE_PACKET_DMA_OUT; in scu_atapi_construct_task_context()
1669 task_context->sata_direction = 0; in scu_atapi_construct_task_context()
1672 task_context->task_type = SCU_TASK_TYPE_PACKET_DMA_IN; in scu_atapi_construct_task_context()
1673 task_context->sata_direction = 1; in scu_atapi_construct_task_context()
1676 memset(&task_context->type.stp, 0, sizeof(task_context->type.stp)); in scu_atapi_construct_task_context()
1677 task_context->type.stp.fis_type = FIS_DATA; in scu_atapi_construct_task_context()
1679 memset(&ireq->stp.cmd, 0, sizeof(ireq->stp.cmd)); in scu_atapi_construct_task_context()
1680 memcpy(&ireq->stp.cmd.lbal, task->ata_task.atapi_packet, cdb_len); in scu_atapi_construct_task_context()
1681 task_context->ssp_command_iu_length = cdb_len / sizeof(u32); in scu_atapi_construct_task_context()
1684 task_context->task_phase = 0x1; in scu_atapi_construct_task_context()
1687 task_context->stp_retry_count = 0; in scu_atapi_construct_task_context()
1690 task_context->transfer_length_bytes = task->total_xfer_len; in scu_atapi_construct_task_context()
1700 struct isci_host *ihost = ireq->owning_controller; in sci_io_request_frame_handler()
1701 struct isci_stp_request *stp_req = &ireq->stp.req; in sci_io_request_frame_handler()
1706 state = ireq->sm.current_state_id; in sci_io_request_frame_handler()
1712 sci_unsolicited_frame_control_get_header(&ihost->uf_control, in sci_io_request_frame_handler()
1723 sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, in sci_io_request_frame_handler()
1727 sci_swab32_cpy(&ireq->ssp.rsp, resp_iu, word_cnt); in sci_io_request_frame_handler()
1729 resp_iu = &ireq->ssp.rsp; in sci_io_request_frame_handler()
1731 if (resp_iu->datapres == SAS_DATAPRES_RESPONSE_DATA || in sci_io_request_frame_handler()
1732 resp_iu->datapres == SAS_DATAPRES_SENSE_DATA) { in sci_io_request_frame_handler()
1733 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in sci_io_request_frame_handler()
1734 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in sci_io_request_frame_handler()
1736 ireq->scu_status = SCU_TASK_DONE_GOOD; in sci_io_request_frame_handler()
1737 ireq->sci_status = SCI_SUCCESS; in sci_io_request_frame_handler()
1741 dev_err(&ihost->pdev->dev, in sci_io_request_frame_handler()
1758 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
1764 struct scatterlist *sg = &task->smp_task.smp_resp; in sci_io_request_frame_handler()
1768 sci_unsolicited_frame_control_get_header(&ihost->uf_control, in sci_io_request_frame_handler()
1772 rsp = kaddr + sg->offset; in sci_io_request_frame_handler()
1778 sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, in sci_io_request_frame_handler()
1782 word_cnt = (sg->length/4)-1; in sci_io_request_frame_handler()
1788 ireq->scu_status = SCU_TASK_DONE_GOOD; in sci_io_request_frame_handler()
1789 ireq->sci_status = SCI_SUCCESS; in sci_io_request_frame_handler()
1790 sci_change_state(&ireq->sm, SCI_REQ_SMP_WAIT_TC_COMP); in sci_io_request_frame_handler()
1796 dev_err(&ihost->pdev->dev, in sci_io_request_frame_handler()
1804 ireq->scu_status = SCU_TASK_DONE_SMP_FRM_TYPE_ERR; in sci_io_request_frame_handler()
1805 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in sci_io_request_frame_handler()
1806 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
1826 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in sci_io_request_frame_handler()
1827 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in sci_io_request_frame_handler()
1828 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
1835 status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, in sci_io_request_frame_handler()
1840 dev_err(&ihost->pdev->dev, in sci_io_request_frame_handler()
1842 "header for frame index %d, status %x\n", in sci_io_request_frame_handler()
1851 switch (frame_header->fis_type) { in sci_io_request_frame_handler()
1853 sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, in sci_io_request_frame_handler()
1857 sci_controller_copy_sata_response(&ireq->stp.rsp, in sci_io_request_frame_handler()
1862 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in sci_io_request_frame_handler()
1863 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in sci_io_request_frame_handler()
1867 dev_warn(&ihost->pdev->dev, in sci_io_request_frame_handler()
1872 ireq->scu_status = SCU_TASK_DONE_UNEXP_FIS; in sci_io_request_frame_handler()
1873 ireq->sci_status = SCI_FAILURE_PROTOCOL_VIOLATION; in sci_io_request_frame_handler()
1877 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
1890 status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, in sci_io_request_frame_handler()
1895 dev_err(&ihost->pdev->dev, in sci_io_request_frame_handler()
1897 "header for frame index %d, status %x\n", in sci_io_request_frame_handler()
1902 switch (frame_header->fis_type) { in sci_io_request_frame_handler()
1905 sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, in sci_io_request_frame_handler()
1916 stp_req->pio_len = frame_buffer[3] & 0xffff; in sci_io_request_frame_handler()
1919 stp_req->status = (frame_buffer[2] >> 24) & 0xff; in sci_io_request_frame_handler()
1921 sci_controller_copy_sata_response(&ireq->stp.rsp, in sci_io_request_frame_handler()
1925 ireq->stp.rsp.status = stp_req->status; in sci_io_request_frame_handler()
1928 * request was PIO Data-in or Data out in sci_io_request_frame_handler()
1930 if (task->data_dir == DMA_FROM_DEVICE) { in sci_io_request_frame_handler()
1931 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_DATA_IN); in sci_io_request_frame_handler()
1932 } else if (task->data_dir == DMA_TO_DEVICE) { in sci_io_request_frame_handler()
1937 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_DATA_OUT); in sci_io_request_frame_handler()
1942 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); in sci_io_request_frame_handler()
1946 if (frame_header->status & ATA_BUSY) { in sci_io_request_frame_handler()
1949 * FIS when it is still busy? Do nothing since in sci_io_request_frame_handler()
1952 dev_dbg(&ihost->pdev->dev, in sci_io_request_frame_handler()
1954 "D2H Register FIS with BSY status " in sci_io_request_frame_handler()
1958 frame_header->status); in sci_io_request_frame_handler()
1962 sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, in sci_io_request_frame_handler()
1966 sci_controller_copy_sata_response(&ireq->stp.rsp, in sci_io_request_frame_handler()
1970 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in sci_io_request_frame_handler()
1971 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in sci_io_request_frame_handler()
1972 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
1990 status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, in sci_io_request_frame_handler()
1995 dev_err(&ihost->pdev->dev, in sci_io_request_frame_handler()
1997 "header for frame index %d, status %x\n", in sci_io_request_frame_handler()
2005 if (frame_header->fis_type != FIS_DATA) { in sci_io_request_frame_handler()
2006 dev_err(&ihost->pdev->dev, in sci_io_request_frame_handler()
2008 "with fis type 0x%02x when expecting a data " in sci_io_request_frame_handler()
2009 "fis.\n", in sci_io_request_frame_handler()
2013 frame_header->fis_type); in sci_io_request_frame_handler()
2015 ireq->scu_status = SCU_TASK_DONE_GOOD; in sci_io_request_frame_handler()
2016 ireq->sci_status = SCI_FAILURE_IO_REQUIRES_SCSI_ABORT; in sci_io_request_frame_handler()
2017 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
2024 if (stp_req->sgl.index < 0) { in sci_io_request_frame_handler()
2025 ireq->saved_rx_frame_index = frame_index; in sci_io_request_frame_handler()
2026 stp_req->pio_len = 0; in sci_io_request_frame_handler()
2028 sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, in sci_io_request_frame_handler()
2042 if (status != SCI_SUCCESS || stp_req->pio_len != 0) in sci_io_request_frame_handler()
2045 if ((stp_req->status & ATA_BUSY) == 0) { in sci_io_request_frame_handler()
2046 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in sci_io_request_frame_handler()
2047 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in sci_io_request_frame_handler()
2048 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
2050 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); in sci_io_request_frame_handler()
2059 ireq->target_device->working_request = ireq; in sci_io_request_frame_handler()
2060 if (task->data_dir == DMA_NONE) { in sci_io_request_frame_handler()
2061 sci_change_state(&ireq->sm, SCI_REQ_ATAPI_WAIT_TC_COMP); in sci_io_request_frame_handler()
2064 sci_change_state(&ireq->sm, SCI_REQ_ATAPI_WAIT_D2H); in sci_io_request_frame_handler()
2082 dev_warn(&ihost->pdev->dev, in sci_io_request_frame_handler()
2099 ireq->scu_status = SCU_TASK_DONE_GOOD; in stp_request_udma_await_tc_event()
2100 ireq->sci_status = SCI_SUCCESS; in stp_request_udma_await_tc_event()
2101 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in stp_request_udma_await_tc_event()
2106 * Register FIS was received before we got the TC in stp_request_udma_await_tc_event()
2109 if (ireq->stp.rsp.fis_type == FIS_REGD2H) { in stp_request_udma_await_tc_event()
2110 sci_remote_device_suspend(ireq->target_device, in stp_request_udma_await_tc_event()
2113 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in stp_request_udma_await_tc_event()
2114 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in stp_request_udma_await_tc_event()
2115 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in stp_request_udma_await_tc_event()
2118 * TC then we can expect a D2H register FIS from in stp_request_udma_await_tc_event()
2122 sci_change_state(&ireq->sm, SCI_REQ_STP_UDMA_WAIT_D2H); in stp_request_udma_await_tc_event()
2127 * wait for the device to host register fis. in stp_request_udma_await_tc_event()
2130 * - this comes only for B0 in stp_request_udma_await_tc_event()
2134 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in stp_request_udma_await_tc_event()
2135 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in stp_request_udma_await_tc_event()
2136 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in stp_request_udma_await_tc_event()
2148 ireq->scu_status = SCU_TASK_DONE_GOOD; in atapi_raw_completion()
2149 ireq->sci_status = SCI_SUCCESS; in atapi_raw_completion()
2150 sci_change_state(&ireq->sm, next); in atapi_raw_completion()
2157 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in atapi_raw_completion()
2158 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in atapi_raw_completion()
2160 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in atapi_raw_completion()
2170 struct isci_remote_device *idev = ireq->target_device; in atapi_data_tc_completion_handler()
2171 struct dev_to_host_fis *d2h = &ireq->stp.rsp; in atapi_data_tc_completion_handler()
2176 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in atapi_data_tc_completion_handler()
2182 /* likely non-error data underrun, workaround missing in atapi_data_tc_completion_handler()
2185 if (d2h->fis_type != FIS_REGD2H) { in atapi_data_tc_completion_handler()
2186 d2h->fis_type = FIS_REGD2H; in atapi_data_tc_completion_handler()
2187 d2h->flags = (1 << 6); in atapi_data_tc_completion_handler()
2188 d2h->status = 0x50; in atapi_data_tc_completion_handler()
2189 d2h->error = 0; in atapi_data_tc_completion_handler()
2190 d2h->lbal = 0; in atapi_data_tc_completion_handler()
2191 d2h->byte_count_low = len & 0xff; in atapi_data_tc_completion_handler()
2192 d2h->byte_count_high = len >> 8; in atapi_data_tc_completion_handler()
2193 d2h->device = 0xa0; in atapi_data_tc_completion_handler()
2194 d2h->lbal_exp = 0; in atapi_data_tc_completion_handler()
2195 d2h->lbam_exp = 0; in atapi_data_tc_completion_handler()
2196 d2h->lbah_exp = 0; in atapi_data_tc_completion_handler()
2197 d2h->_r_a = 0; in atapi_data_tc_completion_handler()
2198 d2h->sector_count = 0x3; in atapi_data_tc_completion_handler()
2199 d2h->sector_count_exp = 0; in atapi_data_tc_completion_handler()
2200 d2h->_r_b = 0; in atapi_data_tc_completion_handler()
2201 d2h->_r_c = 0; in atapi_data_tc_completion_handler()
2202 d2h->_r_d = 0; in atapi_data_tc_completion_handler()
2205 ireq->scu_status = SCU_TASK_DONE_GOOD; in atapi_data_tc_completion_handler()
2206 ireq->sci_status = SCI_SUCCESS_IO_DONE_EARLY; in atapi_data_tc_completion_handler()
2207 status = ireq->sci_status; in atapi_data_tc_completion_handler()
2212 sci_change_state(&idev->sm, SCI_STP_DEV_ATAPI_ERROR); in atapi_data_tc_completion_handler()
2219 ireq->scu_status = SCU_TASK_DONE_GOOD; in atapi_data_tc_completion_handler()
2220 ireq->sci_status = SCI_SUCCESS; in atapi_data_tc_completion_handler()
2221 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in atapi_data_tc_completion_handler()
2225 if (d2h->fis_type == FIS_REGD2H) { in atapi_data_tc_completion_handler()
2227 status = ireq->sci_status; in atapi_data_tc_completion_handler()
2228 sci_change_state(&idev->sm, SCI_STP_DEV_ATAPI_ERROR); in atapi_data_tc_completion_handler()
2230 /* If receiving any non-success TC status, no UF in atapi_data_tc_completion_handler()
2231 * received yet, then an UF for the status fis in atapi_data_tc_completion_handler()
2236 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in atapi_data_tc_completion_handler()
2237 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in atapi_data_tc_completion_handler()
2239 sci_change_state(&ireq->sm, SCI_REQ_ATAPI_WAIT_D2H); in atapi_data_tc_completion_handler()
2342 switch (ireq->protocol) { in sci_request_handle_suspending_completions()
2363 dev_warn(&ireq->isci_host->pdev->dev, in sci_request_handle_suspending_completions()
2372 &ireq->target_device->rnc, in sci_request_handle_suspending_completions()
2384 struct isci_host *ihost = ireq->owning_controller; in sci_io_request_tc_completion()
2386 state = ireq->sm.current_state_id; in sci_io_request_tc_completion()
2438 dev_warn(&ihost->pdev->dev, "%s: %x in wrong state %s\n", in sci_io_request_tc_completion()
2445 * isci_request_process_response_iu() - This function sets the status and
2461 "resp_iu->status = 0x%x,\nresp_iu->datapres = %d " in isci_request_process_response_iu()
2462 "resp_iu->response_data_len = %x, " in isci_request_process_response_iu()
2463 "resp_iu->sense_data_len = %x\nresponse data: ", in isci_request_process_response_iu()
2466 resp_iu->status, in isci_request_process_response_iu()
2467 resp_iu->datapres, in isci_request_process_response_iu()
2468 resp_iu->response_data_len, in isci_request_process_response_iu()
2469 resp_iu->sense_data_len); in isci_request_process_response_iu()
2471 task->task_status.stat = resp_iu->status; in isci_request_process_response_iu()
2478 * isci_request_set_open_reject_status() - This function prepares the I/O
2485 * abandon-class reject.
2497 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_set_open_reject_status()
2500 task->task_status.open_rej_reason = open_rej_reason; in isci_request_set_open_reject_status()
2504 * isci_request_handle_controller_specific_errors() - This function decodes
2505 * controller-specific I/O completion error conditions.
2523 cstatus = request->scu_status; in isci_request_handle_controller_specific_errors()
2525 dev_dbg(&request->isci_host->pdev->dev, in isci_request_handle_controller_specific_errors()
2527 "- controller status = 0x%x\n", in isci_request_handle_controller_specific_errors()
2530 /* Decode the controller-specific errors; most in isci_request_handle_controller_specific_errors()
2538 * a controller-specific completion code; these are left in isci_request_handle_controller_specific_errors()
2546 if (task->task_proto == SAS_PROTOCOL_SMP) { in isci_request_handle_controller_specific_errors()
2559 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_handle_controller_specific_errors()
2569 clear_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_handle_controller_specific_errors()
2579 case SCU_TASK_DONE_VIIT_ENTRY_NV: /* TODO - conditions? */ in isci_request_handle_controller_specific_errors()
2580 case SCU_TASK_DONE_IIT_ENTRY_NV: /* TODO - conditions? */ in isci_request_handle_controller_specific_errors()
2581 case SCU_TASK_DONE_RNCNV_OUTBOUND: /* TODO - conditions? */ in isci_request_handle_controller_specific_errors()
2597 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_handle_controller_specific_errors()
2602 * abandon-class codes; all others are automatically retried in the SCU. in isci_request_handle_controller_specific_errors()
2613 /* Note - the return of AB0 will change when in isci_request_handle_controller_specific_errors()
2699 if (task->task_proto == SAS_PROTOCOL_SMP) in isci_request_handle_controller_specific_errors()
2700 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_handle_controller_specific_errors()
2702 clear_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_handle_controller_specific_errors()
2707 static void isci_process_stp_response(struct sas_task *task, struct dev_to_host_fis *fis) in isci_process_stp_response() argument
2709 struct task_status_struct *ts = &task->task_status; in isci_process_stp_response()
2710 struct ata_task_resp *resp = (void *)&ts->buf[0]; in isci_process_stp_response()
2712 resp->frame_len = sizeof(*fis); in isci_process_stp_response()
2713 memcpy(resp->ending_fis, fis, sizeof(*fis)); in isci_process_stp_response()
2714 ts->buf_valid_size = sizeof(*resp); in isci_process_stp_response()
2716 /* If an error is flagged let libata decode the fis */ in isci_process_stp_response()
2717 if (ac_err_mask(fis->status)) in isci_process_stp_response()
2718 ts->stat = SAS_PROTO_RESPONSE; in isci_process_stp_response()
2720 ts->stat = SAS_SAM_STAT_GOOD; in isci_process_stp_response()
2722 ts->resp = SAS_TASK_COMPLETE; in isci_process_stp_response()
2732 struct isci_remote_device *idev = request->target_device; in isci_request_io_request_complete()
2736 dev_dbg(&ihost->pdev->dev, in isci_request_io_request_complete()
2738 "task->data_dir = %d completion_status = 0x%x\n", in isci_request_io_request_complete()
2739 __func__, request, task, task->data_dir, completion_status); in isci_request_io_request_complete()
2747 dev_dbg(&ihost->pdev->dev, in isci_request_io_request_complete()
2751 if (sas_protocol_ata(task->task_proto)) { in isci_request_io_request_complete()
2752 isci_process_stp_response(task, &request->stp.rsp); in isci_request_io_request_complete()
2753 } else if (SAS_PROTOCOL_SSP == task->task_proto) { in isci_request_io_request_complete()
2756 resp_iu = &request->ssp.rsp; in isci_request_io_request_complete()
2758 &ihost->pdev->dev); in isci_request_io_request_complete()
2760 } else if (SAS_PROTOCOL_SMP == task->task_proto) { in isci_request_io_request_complete()
2762 dev_err(&ihost->pdev->dev, in isci_request_io_request_complete()
2768 dev_err(&ihost->pdev->dev, in isci_request_io_request_complete()
2774 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_io_request_complete()
2775 response = task->task_status.resp; in isci_request_io_request_complete()
2776 status = task->task_status.stat; in isci_request_io_request_complete()
2784 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_io_request_complete()
2794 task->task_status.residual in isci_request_io_request_complete()
2795 = task->total_xfer_len - transferred_length; in isci_request_io_request_complete()
2800 if (task->task_status.residual != 0) in isci_request_io_request_complete()
2803 dev_dbg(&ihost->pdev->dev, in isci_request_io_request_complete()
2808 dev_dbg(&ihost->pdev->dev, "%s: SCI_IO_SUCCESS\n", in isci_request_io_request_complete()
2814 dev_dbg(&ihost->pdev->dev, in isci_request_io_request_complete()
2819 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_io_request_complete()
2847 spin_lock_irqsave(&task->task_state_lock, task_flags); in isci_request_io_request_complete()
2848 task->task_state_flags |= SAS_TASK_NEED_DEV_RESET; in isci_request_io_request_complete()
2849 spin_unlock_irqrestore(&task->task_state_lock, task_flags); in isci_request_io_request_complete()
2855 clear_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_io_request_complete()
2867 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_io_request_complete()
2873 dev_dbg(&ihost->pdev->dev, in isci_request_io_request_complete()
2874 "%s: invalid completion code: 0x%x - " in isci_request_io_request_complete()
2889 if (SAS_PROTOCOL_SMP == task->task_proto) in isci_request_io_request_complete()
2890 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_io_request_complete()
2892 clear_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); in isci_request_io_request_complete()
2896 switch (task->task_proto) { in isci_request_io_request_complete()
2898 if (task->data_dir == DMA_NONE) in isci_request_io_request_complete()
2900 if (task->num_scatter == 0) in isci_request_io_request_complete()
2902 dma_unmap_single(&ihost->pdev->dev, in isci_request_io_request_complete()
2903 request->zero_scatter_daddr, in isci_request_io_request_complete()
2904 task->total_xfer_len, task->data_dir); in isci_request_io_request_complete()
2906 dma_unmap_sg(&ihost->pdev->dev, task->scatter, in isci_request_io_request_complete()
2907 request->num_sg_entries, task->data_dir); in isci_request_io_request_complete()
2910 struct scatterlist *sg = &task->smp_task.smp_req; in isci_request_io_request_complete()
2914 dma_unmap_sg(&ihost->pdev->dev, sg, 1, DMA_TO_DEVICE); in isci_request_io_request_complete()
2916 /* need to swab it back in case the command buffer is re-used */ in isci_request_io_request_complete()
2918 smp_req = kaddr + sg->offset; in isci_request_io_request_complete()
2919 sci_swab32_cpy(smp_req, smp_req, sg->length / sizeof(u32)); in isci_request_io_request_complete()
2927 spin_lock_irqsave(&task->task_state_lock, task_flags); in isci_request_io_request_complete()
2929 task->task_status.resp = response; in isci_request_io_request_complete()
2930 task->task_status.stat = status; in isci_request_io_request_complete()
2932 if (test_bit(IREQ_COMPLETE_IN_TARGET, &request->flags)) { in isci_request_io_request_complete()
2934 task->task_state_flags |= SAS_TASK_STATE_DONE; in isci_request_io_request_complete()
2935 task->task_state_flags &= ~SAS_TASK_STATE_PENDING; in isci_request_io_request_complete()
2937 spin_unlock_irqrestore(&task->task_state_lock, task_flags); in isci_request_io_request_complete()
2940 sci_controller_complete_io(ihost, request->target_device, request); in isci_request_io_request_complete()
2946 set_bit(IREQ_TERMINATED, &request->flags); in isci_request_io_request_complete()
2954 struct domain_device *dev = ireq->target_device->domain_dev; in sci_request_started_state_enter()
2961 task = (test_bit(IREQ_TMF, &ireq->flags)) ? NULL : isci_request_access_task(ireq); in sci_request_started_state_enter()
2966 if (!task && dev->dev_type == SAS_END_DEVICE) { in sci_request_started_state_enter()
2968 } else if (task && task->task_proto == SAS_PROTOCOL_SMP) { in sci_request_started_state_enter()
2970 } else if (task && sas_protocol_ata(task->task_proto) && in sci_request_started_state_enter()
2971 !task->ata_task.use_ncq) { in sci_request_started_state_enter()
2972 if (dev->sata_dev.class == ATA_DEV_ATAPI && in sci_request_started_state_enter()
2973 task->ata_task.fis.command == ATA_CMD_PACKET) { in sci_request_started_state_enter()
2975 } else if (task->data_dir == DMA_NONE) { in sci_request_started_state_enter()
2977 } else if (task->ata_task.dma_xfer) { in sci_request_started_state_enter()
2992 struct isci_host *ihost = ireq->owning_controller; in sci_request_completed_state_enter()
2995 if (!test_bit(IREQ_TMF, &ireq->flags)) in sci_request_completed_state_enter()
2997 ireq->sci_status); in sci_request_completed_state_enter()
2999 isci_task_request_complete(ihost, ireq, ireq->sci_status); in sci_request_completed_state_enter()
3007 ireq->tc->abort = 1; in sci_request_aborting_state_enter()
3014 ireq->target_device->working_request = ireq; in sci_stp_request_started_non_data_await_h2d_completion_enter()
3021 ireq->target_device->working_request = ireq; in sci_stp_request_started_pio_await_h2d_completion_enter()
3064 sci_init_sm(&ireq->sm, sci_request_state_table, SCI_REQ_INIT); in sci_general_request_construct()
3066 ireq->target_device = idev; in sci_general_request_construct()
3067 ireq->protocol = SAS_PROTOCOL_NONE; in sci_general_request_construct()
3068 ireq->saved_rx_frame_index = SCU_INVALID_FRAME_INDEX; in sci_general_request_construct()
3070 ireq->sci_status = SCI_SUCCESS; in sci_general_request_construct()
3071 ireq->scu_status = 0; in sci_general_request_construct()
3072 ireq->post_context = 0xFFFFFFFF; in sci_general_request_construct()
3080 struct domain_device *dev = idev->domain_dev; in sci_io_request_construct()
3086 if (idev->rnc.remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) in sci_io_request_construct()
3089 if (dev->dev_type == SAS_END_DEVICE) in sci_io_request_construct()
3092 memset(&ireq->stp.cmd, 0, sizeof(ireq->stp.cmd)); in sci_io_request_construct()
3093 else if (dev_is_expander(dev->dev_type)) in sci_io_request_construct()
3098 memset(ireq->tc, 0, offsetof(struct scu_task_context, sgl_pair_ab)); in sci_io_request_construct()
3107 struct domain_device *dev = idev->domain_dev; in sci_task_request_construct()
3113 if (dev->dev_type == SAS_END_DEVICE || dev_is_sata(dev)) { in sci_task_request_construct()
3114 set_bit(IREQ_TMF, &ireq->flags); in sci_task_request_construct()
3115 memset(ireq->tc, 0, sizeof(struct scu_task_context)); in sci_task_request_construct()
3119 ireq->protocol = SAS_PROTOCOL_STP; in sci_task_request_construct()
3121 ireq->protocol = SAS_PROTOCOL_SSP; in sci_task_request_construct()
3133 dev_dbg(&request->isci_host->pdev->dev, in isci_request_ssp_request_construct()
3144 struct host_to_dev_fis *fis = &ireq->stp.cmd; in isci_request_stp_request_construct() local
3145 struct ata_queued_cmd *qc = task->uldd_task; in isci_request_stp_request_construct()
3148 dev_dbg(&ireq->isci_host->pdev->dev, in isci_request_stp_request_construct()
3153 memcpy(fis, &task->ata_task.fis, sizeof(struct host_to_dev_fis)); in isci_request_stp_request_construct()
3154 if (!task->ata_task.device_control_reg_update) in isci_request_stp_request_construct()
3155 fis->flags |= 0x80; in isci_request_stp_request_construct()
3156 fis->flags &= 0xF0; in isci_request_stp_request_construct()
3160 if (qc && (qc->tf.command == ATA_CMD_FPDMA_WRITE || in isci_request_stp_request_construct()
3161 qc->tf.command == ATA_CMD_FPDMA_READ || in isci_request_stp_request_construct()
3162 qc->tf.command == ATA_CMD_FPDMA_RECV || in isci_request_stp_request_construct()
3163 qc->tf.command == ATA_CMD_FPDMA_SEND || in isci_request_stp_request_construct()
3164 qc->tf.command == ATA_CMD_NCQ_NON_DATA)) { in isci_request_stp_request_construct()
3165 fis->sector_count = qc->tag << 3; in isci_request_stp_request_construct()
3166 ireq->tc->type.stp.ncq_tag = qc->tag; in isci_request_stp_request_construct()
3177 struct scatterlist *sg = &task->smp_task.smp_req; in sci_io_request_construct_smp()
3187 smp_req = kaddr + sg->offset; in sci_io_request_construct_smp()
3191 * a non-zero default length. in sci_io_request_construct_smp()
3193 if (smp_req->req_len == 0) { in sci_io_request_construct_smp()
3194 switch (smp_req->func) { in sci_io_request_construct_smp()
3199 smp_req->req_len = 2; in sci_io_request_construct_smp()
3204 smp_req->req_len = 9; in sci_io_request_construct_smp()
3206 /* Default - zero is a valid default for 2.0. */ in sci_io_request_construct_smp()
3209 req_len = smp_req->req_len; in sci_io_request_construct_smp()
3210 sci_swab32_cpy(smp_req, smp_req, sg->length / sizeof(u32)); in sci_io_request_construct_smp()
3217 ireq->protocol = SAS_PROTOCOL_SMP; in sci_io_request_construct_smp()
3221 task_context = ireq->tc; in sci_io_request_construct_smp()
3223 idev = ireq->target_device; in sci_io_request_construct_smp()
3224 iport = idev->owning_port; in sci_io_request_construct_smp()
3230 task_context->priority = 0; in sci_io_request_construct_smp()
3231 task_context->initiator_request = 1; in sci_io_request_construct_smp()
3232 task_context->connection_rate = idev->connection_rate; in sci_io_request_construct_smp()
3233 task_context->protocol_engine_index = ISCI_PEG; in sci_io_request_construct_smp()
3234 task_context->logical_port_index = iport->physical_port_index; in sci_io_request_construct_smp()
3235 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SMP; in sci_io_request_construct_smp()
3236 task_context->abort = 0; in sci_io_request_construct_smp()
3237 task_context->valid = SCU_TASK_CONTEXT_VALID; in sci_io_request_construct_smp()
3238 task_context->context_type = SCU_TASK_CONTEXT_TYPE; in sci_io_request_construct_smp()
3241 task_context->remote_node_index = idev->rnc.remote_node_index; in sci_io_request_construct_smp()
3242 task_context->command_code = 0; in sci_io_request_construct_smp()
3243 task_context->task_type = SCU_TASK_TYPE_SMP_REQUEST; in sci_io_request_construct_smp()
3246 task_context->link_layer_control = 0; in sci_io_request_construct_smp()
3247 task_context->do_not_dma_ssp_good_response = 1; in sci_io_request_construct_smp()
3248 task_context->strict_ordering = 0; in sci_io_request_construct_smp()
3249 task_context->control_frame = 1; in sci_io_request_construct_smp()
3250 task_context->timeout_enable = 0; in sci_io_request_construct_smp()
3251 task_context->block_guard_enable = 0; in sci_io_request_construct_smp()
3254 task_context->address_modifier = 0; in sci_io_request_construct_smp()
3257 task_context->ssp_command_iu_length = req_len; in sci_io_request_construct_smp()
3260 task_context->transfer_length_bytes = 0; in sci_io_request_construct_smp()
3266 memcpy(&task_context->type.smp, &cmd, sizeof(u32)); in sci_io_request_construct_smp()
3271 * so that done code will be consistent." - Venki in sci_io_request_construct_smp()
3273 task_context->task_phase = 0; in sci_io_request_construct_smp()
3275 ireq->post_context = (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | in sci_io_request_construct_smp()
3277 (iport->physical_port_index << in sci_io_request_construct_smp()
3279 ISCI_TAG_TCI(ireq->io_tag)); in sci_io_request_construct_smp()
3284 task_context->command_iu_upper = upper_32_bits(sg_dma_address(sg)); in sci_io_request_construct_smp()
3285 task_context->command_iu_lower = lower_32_bits(sg_dma_address(sg) + sizeof(u32)); in sci_io_request_construct_smp()
3288 task_context->response_iu_upper = 0; in sci_io_request_construct_smp()
3289 task_context->response_iu_lower = 0; in sci_io_request_construct_smp()
3291 sci_change_state(&ireq->sm, SCI_REQ_CONSTRUCTED); in sci_io_request_construct_smp()
3297 * isci_smp_request_build() - This function builds the smp request.
3306 struct device *dev = &ireq->isci_host->pdev->dev; in isci_smp_request_build()
3311 dev_dbg(&ireq->isci_host->pdev->dev, in isci_smp_request_build()
3320 * isci_io_request_build() - This function builds the io request object.
3336 dev_dbg(&ihost->pdev->dev, in isci_io_request_build()
3342 task->num_scatter); in isci_io_request_build()
3348 if (task->num_scatter && in isci_io_request_build()
3349 !sas_protocol_ata(task->task_proto) && in isci_io_request_build()
3350 !(SAS_PROTOCOL_SMP & task->task_proto)) { in isci_io_request_build()
3352 request->num_sg_entries = dma_map_sg( in isci_io_request_build()
3353 &ihost->pdev->dev, in isci_io_request_build()
3354 task->scatter, in isci_io_request_build()
3355 task->num_scatter, in isci_io_request_build()
3356 task->data_dir in isci_io_request_build()
3359 if (request->num_sg_entries == 0) in isci_io_request_build()
3366 dev_dbg(&ihost->pdev->dev, in isci_io_request_build()
3372 switch (task->task_proto) { in isci_io_request_build()
3385 dev_dbg(&ihost->pdev->dev, in isci_io_request_build()
3397 ireq = ihost->reqs[ISCI_TAG_TCI(tag)]; in isci_request_from_tag()
3398 ireq->io_tag = tag; in isci_request_from_tag()
3399 ireq->io_request_completion = NULL; in isci_request_from_tag()
3400 ireq->flags = 0; in isci_request_from_tag()
3401 ireq->num_sg_entries = 0; in isci_request_from_tag()
3413 ireq->ttype_ptr.io_task_ptr = task; in isci_io_request_from_tag()
3414 clear_bit(IREQ_TMF, &ireq->flags); in isci_io_request_from_tag()
3415 task->lldd_task = ireq; in isci_io_request_from_tag()
3427 ireq->ttype_ptr.tmf_task_ptr = isci_tmf; in isci_tmf_request_from_tag()
3428 set_bit(IREQ_TMF, &ireq->flags); in isci_tmf_request_from_tag()
3442 dev_dbg(&ihost->pdev->dev, in isci_request_execute()
3443 "%s: request_construct failed - status = 0x%x\n", in isci_request_execute()
3449 spin_lock_irqsave(&ihost->scic_lock, flags); in isci_request_execute()
3451 if (test_bit(IDEV_IO_NCQERROR, &idev->flags)) { in isci_request_execute()
3459 * ireq->is_task_management_request is false). in isci_request_execute()
3475 dev_dbg(&ihost->pdev->dev, in isci_request_execute()
3478 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_request_execute()
3489 set_bit(IREQ_TERMINATED, &ireq->flags); in isci_request_execute()
3491 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_request_execute()
3499 spin_lock_irqsave(&task->task_state_lock, flags); in isci_request_execute()
3500 task->task_state_flags |= SAS_TASK_NEED_DEV_RESET; in isci_request_execute()
3501 spin_unlock_irqrestore(&task->task_state_lock, flags); in isci_request_execute()