16f231ddaSDan Williams /* 26f231ddaSDan Williams * This file is provided under a dual BSD/GPLv2 license. When using or 36f231ddaSDan Williams * redistributing this file, you may do so under either license. 46f231ddaSDan Williams * 56f231ddaSDan Williams * GPL LICENSE SUMMARY 66f231ddaSDan Williams * 76f231ddaSDan Williams * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 86f231ddaSDan Williams * 96f231ddaSDan Williams * This program is free software; you can redistribute it and/or modify 106f231ddaSDan Williams * it under the terms of version 2 of the GNU General Public License as 116f231ddaSDan Williams * published by the Free Software Foundation. 126f231ddaSDan Williams * 136f231ddaSDan Williams * This program is distributed in the hope that it will be useful, but 146f231ddaSDan Williams * WITHOUT ANY WARRANTY; without even the implied warranty of 156f231ddaSDan Williams * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 166f231ddaSDan Williams * General Public License for more details. 176f231ddaSDan Williams * 186f231ddaSDan Williams * You should have received a copy of the GNU General Public License 196f231ddaSDan Williams * along with this program; if not, write to the Free Software 206f231ddaSDan Williams * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 216f231ddaSDan Williams * The full GNU General Public License is included in this distribution 226f231ddaSDan Williams * in the file called LICENSE.GPL. 236f231ddaSDan Williams * 246f231ddaSDan Williams * BSD LICENSE 256f231ddaSDan Williams * 266f231ddaSDan Williams * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 276f231ddaSDan Williams * All rights reserved. 286f231ddaSDan Williams * 296f231ddaSDan Williams * Redistribution and use in source and binary forms, with or without 306f231ddaSDan Williams * modification, are permitted provided that the following conditions 316f231ddaSDan Williams * are met: 326f231ddaSDan Williams * 336f231ddaSDan Williams * * Redistributions of source code must retain the above copyright 346f231ddaSDan Williams * notice, this list of conditions and the following disclaimer. 356f231ddaSDan Williams * * Redistributions in binary form must reproduce the above copyright 366f231ddaSDan Williams * notice, this list of conditions and the following disclaimer in 376f231ddaSDan Williams * the documentation and/or other materials provided with the 386f231ddaSDan Williams * distribution. 396f231ddaSDan Williams * * Neither the name of Intel Corporation nor the names of its 406f231ddaSDan Williams * contributors may be used to endorse or promote products derived 416f231ddaSDan Williams * from this software without specific prior written permission. 426f231ddaSDan Williams * 436f231ddaSDan Williams * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 446f231ddaSDan Williams * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 456f231ddaSDan Williams * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 466f231ddaSDan Williams * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 476f231ddaSDan Williams * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 486f231ddaSDan Williams * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 496f231ddaSDan Williams * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 506f231ddaSDan Williams * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 516f231ddaSDan Williams * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 526f231ddaSDan Williams * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 536f231ddaSDan Williams * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 546f231ddaSDan Williams */ 556f231ddaSDan Williams 560d84366fSDan Williams #ifndef _ISCI_REQUEST_H_ 576f231ddaSDan Williams #define _ISCI_REQUEST_H_ 586f231ddaSDan Williams 596f231ddaSDan Williams #include "isci.h" 60ce2b3261SDan Williams #include "host.h" 61f1f52e75SDan Williams #include "scu_task_context.h" 626f231ddaSDan Williams 636f231ddaSDan Williams /** 646f231ddaSDan Williams * struct isci_request_status - This enum defines the possible states of an I/O 656f231ddaSDan Williams * request. 666f231ddaSDan Williams * 676f231ddaSDan Williams * 686f231ddaSDan Williams */ 696f231ddaSDan Williams enum isci_request_status { 706f231ddaSDan Williams unallocated = 0x00, 716f231ddaSDan Williams allocated = 0x01, 726f231ddaSDan Williams started = 0x02, 736f231ddaSDan Williams completed = 0x03, 746f231ddaSDan Williams aborting = 0x04, 756f231ddaSDan Williams aborted = 0x05, 764dc043c4SJeff Skirvin terminating = 0x06, 774dc043c4SJeff Skirvin dead = 0x07 786f231ddaSDan Williams }; 796f231ddaSDan Williams 80f1f52e75SDan Williams enum sci_request_protocol { 81f1f52e75SDan Williams SCIC_NO_PROTOCOL, 82f1f52e75SDan Williams SCIC_SMP_PROTOCOL, 83f1f52e75SDan Williams SCIC_SSP_PROTOCOL, 84f1f52e75SDan Williams SCIC_STP_PROTOCOL 85c72086e3SDan Williams }; /* XXX remove me, use sas_task.{dev|task_proto} instead */; 86f1f52e75SDan Williams 87ba7cb223SDan Williams /** 88ba7cb223SDan Williams * isci_stp_request - extra request infrastructure to handle pio/atapi protocol 89ba7cb223SDan Williams * @pio_len - number of bytes requested at PIO setup 90ba7cb223SDan Williams * @status - pio setup ending status value to tell us if we need 91ba7cb223SDan Williams * to wait for another fis or if the transfer is complete. Upon 92ba7cb223SDan Williams * receipt of a d2h fis this will be the status field of that fis. 93ba7cb223SDan Williams * @sgl - track pio transfer progress as we iterate through the sgl 945dec6f4eSDan Williams */ 95ba7cb223SDan Williams struct isci_stp_request { 96ba7cb223SDan Williams u32 pio_len; 97ba7cb223SDan Williams u8 status; 985dec6f4eSDan Williams 99ba7cb223SDan Williams struct isci_stp_pio_sgl { 100ba7cb223SDan Williams int index; 101ba7cb223SDan Williams u8 set; 102ba7cb223SDan Williams u32 offset; 103ba7cb223SDan Williams } sgl; 1045dec6f4eSDan Williams }; 1055dec6f4eSDan Williams 1065076a1a9SDan Williams struct isci_request { 1075076a1a9SDan Williams enum isci_request_status status; 1085076a1a9SDan Williams #define IREQ_COMPLETE_IN_TARGET 0 1095076a1a9SDan Williams #define IREQ_TERMINATED 1 1105076a1a9SDan Williams #define IREQ_TMF 2 1115076a1a9SDan Williams #define IREQ_ACTIVE 3 1125076a1a9SDan Williams unsigned long flags; 1135076a1a9SDan Williams /* XXX kill ttype and ttype_ptr, allocate full sas_task */ 1145076a1a9SDan Williams union ttype_ptr_union { 1155076a1a9SDan Williams struct sas_task *io_task_ptr; /* When ttype==io_task */ 1165076a1a9SDan Williams struct isci_tmf *tmf_task_ptr; /* When ttype==tmf_task */ 1175076a1a9SDan Williams } ttype_ptr; 1185076a1a9SDan Williams struct isci_host *isci_host; 1195076a1a9SDan Williams /* For use in the requests_to_{complete|abort} lists: */ 1205076a1a9SDan Williams struct list_head completed_node; 1215076a1a9SDan Williams /* For use in the reqs_in_process list: */ 1225076a1a9SDan Williams struct list_head dev_node; 1235076a1a9SDan Williams spinlock_t state_lock; 1245076a1a9SDan Williams dma_addr_t request_daddr; 1255076a1a9SDan Williams dma_addr_t zero_scatter_daddr; 1265076a1a9SDan Williams unsigned int num_sg_entries; 1275076a1a9SDan Williams /* Note: "io_request_completion" is completed in two different ways 1285076a1a9SDan Williams * depending on whether this is a TMF or regular request. 1295076a1a9SDan Williams * - TMF requests are completed in the thread that started them; 1305076a1a9SDan Williams * - regular requests are completed in the request completion callback 1315076a1a9SDan Williams * function. 1325076a1a9SDan Williams * This difference in operation allows the aborter of a TMF request 1335076a1a9SDan Williams * to be sure that once the TMF request completes, the I/O that the 1345076a1a9SDan Williams * TMF was aborting is guaranteed to have completed. 1355076a1a9SDan Williams * 1365076a1a9SDan Williams * XXX kill io_request_completion 137f1f52e75SDan Williams */ 1385076a1a9SDan Williams struct completion *io_request_completion; 139e301370aSEdmund Nadolski struct sci_base_state_machine sm; 140d9dcb4baSDan Williams struct isci_host *owning_controller; 14178a6f06eSDan Williams struct isci_remote_device *target_device; 142f1f52e75SDan Williams u16 io_tag; 143f1f52e75SDan Williams enum sci_request_protocol protocol; 1445076a1a9SDan Williams u32 scu_status; /* hardware result */ 1455076a1a9SDan Williams u32 sci_status; /* upper layer disposition */ 146f1f52e75SDan Williams u32 post_context; 147312e0c24SDan Williams struct scu_task_context *tc; 148f1f52e75SDan Williams /* could be larger with sg chaining */ 1497c78da31SDan Williams #define SCU_SGL_SIZE ((SCI_MAX_SCATTER_GATHER_ELEMENTS + 1) / 2) 150f1f52e75SDan Williams struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32))); 1515076a1a9SDan Williams /* This field is a pointer to the stored rx frame data. It is used in 152e301370aSEdmund Nadolski * STP internal requests and SMP response frames. If this field is 153e301370aSEdmund Nadolski * non-NULL the saved frame must be released on IO request completion. 154f1f52e75SDan Williams */ 155f1f52e75SDan Williams u32 saved_rx_frame_index; 156f1f52e75SDan Williams 157f1f52e75SDan Williams union { 158f1f52e75SDan Williams struct { 159f1f52e75SDan Williams union { 160f1f52e75SDan Williams struct ssp_cmd_iu cmd; 161f1f52e75SDan Williams struct ssp_task_iu tmf; 162f1f52e75SDan Williams }; 163f1f52e75SDan Williams union { 164f1f52e75SDan Williams struct ssp_response_iu rsp; 165f1f52e75SDan Williams u8 rsp_buf[SSP_RESP_IU_MAX_SIZE]; 166f1f52e75SDan Williams }; 167f1f52e75SDan Williams } ssp; 168f1f52e75SDan Williams struct { 169ba7cb223SDan Williams struct isci_stp_request req; 170f1f52e75SDan Williams struct host_to_dev_fis cmd; 171f1f52e75SDan Williams struct dev_to_host_fis rsp; 172f1f52e75SDan Williams } stp; 173f1f52e75SDan Williams }; 174f1f52e75SDan Williams }; 175f1f52e75SDan Williams 1765076a1a9SDan Williams static inline struct isci_request *to_ireq(struct isci_stp_request *stp_req) 177f1f52e75SDan Williams { 1785076a1a9SDan Williams struct isci_request *ireq; 179f1f52e75SDan Williams 1805076a1a9SDan Williams ireq = container_of(stp_req, typeof(*ireq), stp.req); 18167ea838dSDan Williams return ireq; 18267ea838dSDan Williams } 18367ea838dSDan Williams 1846f231ddaSDan Williams /** 185f1f52e75SDan Williams * enum sci_base_request_states - This enumeration depicts all the states for 186f1f52e75SDan Williams * the common request state machine. 187f1f52e75SDan Williams * 188f1f52e75SDan Williams * 189f1f52e75SDan Williams */ 190f1f52e75SDan Williams enum sci_base_request_states { 191e301370aSEdmund Nadolski /* 192f1f52e75SDan Williams * Simply the initial state for the base request state machine. 193f1f52e75SDan Williams */ 194e301370aSEdmund Nadolski SCI_REQ_INIT, 195f1f52e75SDan Williams 196e301370aSEdmund Nadolski /* 197e301370aSEdmund Nadolski * This state indicates that the request has been constructed. 198e301370aSEdmund Nadolski * This state is entered from the INITIAL state. 199f1f52e75SDan Williams */ 200e301370aSEdmund Nadolski SCI_REQ_CONSTRUCTED, 201f1f52e75SDan Williams 202e301370aSEdmund Nadolski /* 203e301370aSEdmund Nadolski * This state indicates that the request has been started. This state 204e301370aSEdmund Nadolski * is entered from the CONSTRUCTED state. 205f1f52e75SDan Williams */ 206e301370aSEdmund Nadolski SCI_REQ_STARTED, 207f1f52e75SDan Williams 208e301370aSEdmund Nadolski SCI_REQ_STP_UDMA_WAIT_TC_COMP, 209e301370aSEdmund Nadolski SCI_REQ_STP_UDMA_WAIT_D2H, 2105dec6f4eSDan Williams 211e301370aSEdmund Nadolski SCI_REQ_STP_NON_DATA_WAIT_H2D, 212e301370aSEdmund Nadolski SCI_REQ_STP_NON_DATA_WAIT_D2H, 2135dec6f4eSDan Williams 214e301370aSEdmund Nadolski /* 215e301370aSEdmund Nadolski * While in this state the IO request object is waiting for the TC 216e301370aSEdmund Nadolski * completion notification for the H2D Register FIS 2175dec6f4eSDan Williams */ 218e301370aSEdmund Nadolski SCI_REQ_STP_PIO_WAIT_H2D, 2195dec6f4eSDan Williams 220e301370aSEdmund Nadolski /* 221e301370aSEdmund Nadolski * While in this state the IO request object is waiting for either a 222e301370aSEdmund Nadolski * PIO Setup FIS or a D2H register FIS. The type of frame received is 223e301370aSEdmund Nadolski * based on the result of the prior frame and line conditions. 2245dec6f4eSDan Williams */ 225e301370aSEdmund Nadolski SCI_REQ_STP_PIO_WAIT_FRAME, 2265dec6f4eSDan Williams 227e301370aSEdmund Nadolski /* 228e301370aSEdmund Nadolski * While in this state the IO request object is waiting for a DATA 229e301370aSEdmund Nadolski * frame from the device. 2305dec6f4eSDan Williams */ 231e301370aSEdmund Nadolski SCI_REQ_STP_PIO_DATA_IN, 2325dec6f4eSDan Williams 233e301370aSEdmund Nadolski /* 234e301370aSEdmund Nadolski * While in this state the IO request object is waiting to transmit 235e301370aSEdmund Nadolski * the next data frame to the device. 2365dec6f4eSDan Williams */ 237e301370aSEdmund Nadolski SCI_REQ_STP_PIO_DATA_OUT, 2385dec6f4eSDan Williams 239e301370aSEdmund Nadolski /* 240b50102d3SDan Williams * While in this state the IO request object is waiting for the TC 241b50102d3SDan Williams * completion notification for the H2D Register FIS 242b50102d3SDan Williams */ 243b50102d3SDan Williams SCI_REQ_ATAPI_WAIT_H2D, 244b50102d3SDan Williams 245b50102d3SDan Williams /* 246b50102d3SDan Williams * While in this state the IO request object is waiting for either a 247b50102d3SDan Williams * PIO Setup. 248b50102d3SDan Williams */ 249b50102d3SDan Williams SCI_REQ_ATAPI_WAIT_PIO_SETUP, 250b50102d3SDan Williams 251b50102d3SDan Williams /* 252b50102d3SDan Williams * The non-data IO transit to this state in this state after receiving 253b50102d3SDan Williams * TC completion. While in this state IO request object is waiting for 254b50102d3SDan Williams * D2H status frame as UF. 255b50102d3SDan Williams */ 256b50102d3SDan Williams SCI_REQ_ATAPI_WAIT_D2H, 257b50102d3SDan Williams 258b50102d3SDan Williams /* 259b50102d3SDan Williams * When transmitting raw frames hardware reports task context completion 260b50102d3SDan Williams * after every frame submission, so in the non-accelerated case we need 261b50102d3SDan Williams * to expect the completion for the "cdb" frame. 262b50102d3SDan Williams */ 263b50102d3SDan Williams SCI_REQ_ATAPI_WAIT_TC_COMP, 264b50102d3SDan Williams 265b50102d3SDan Williams /* 266f139303dSDan Williams * The AWAIT_TC_COMPLETION sub-state indicates that the started raw 267f139303dSDan Williams * task management request is waiting for the transmission of the 268f139303dSDan Williams * initial frame (i.e. command, task, etc.). 269f139303dSDan Williams */ 270e301370aSEdmund Nadolski SCI_REQ_TASK_WAIT_TC_COMP, 271f139303dSDan Williams 272e301370aSEdmund Nadolski /* 273f139303dSDan Williams * This sub-state indicates that the started task management request 274f139303dSDan Williams * is waiting for the reception of an unsolicited frame 275f139303dSDan Williams * (i.e. response IU). 276f139303dSDan Williams */ 277e301370aSEdmund Nadolski SCI_REQ_TASK_WAIT_TC_RESP, 278f139303dSDan Williams 279e301370aSEdmund Nadolski /* 280c72086e3SDan Williams * This sub-state indicates that the started task management request 281c72086e3SDan Williams * is waiting for the reception of an unsolicited frame 282c72086e3SDan Williams * (i.e. response IU). 283c72086e3SDan Williams */ 284e301370aSEdmund Nadolski SCI_REQ_SMP_WAIT_RESP, 285c72086e3SDan Williams 286e301370aSEdmund Nadolski /* 287e301370aSEdmund Nadolski * The AWAIT_TC_COMPLETION sub-state indicates that the started SMP 288e301370aSEdmund Nadolski * request is waiting for the transmission of the initial frame 289e301370aSEdmund Nadolski * (i.e. command, task, etc.). 290c72086e3SDan Williams */ 291e301370aSEdmund Nadolski SCI_REQ_SMP_WAIT_TC_COMP, 292c72086e3SDan Williams 293e301370aSEdmund Nadolski /* 294f1f52e75SDan Williams * This state indicates that the request has completed. 295e301370aSEdmund Nadolski * This state is entered from the STARTED state. This state is entered 296e301370aSEdmund Nadolski * from the ABORTING state. 297f1f52e75SDan Williams */ 298e301370aSEdmund Nadolski SCI_REQ_COMPLETED, 299f1f52e75SDan Williams 300e301370aSEdmund Nadolski /* 301f1f52e75SDan Williams * This state indicates that the request is in the process of being 302f1f52e75SDan Williams * terminated/aborted. 303f1f52e75SDan Williams * This state is entered from the CONSTRUCTED state. 304f1f52e75SDan Williams * This state is entered from the STARTED state. 305f1f52e75SDan Williams */ 306e301370aSEdmund Nadolski SCI_REQ_ABORTING, 307f1f52e75SDan Williams 308e301370aSEdmund Nadolski /* 309f1f52e75SDan Williams * Simply the final state for the base request state machine. 310f1f52e75SDan Williams */ 311e301370aSEdmund Nadolski SCI_REQ_FINAL, 312f1f52e75SDan Williams }; 313f1f52e75SDan Williams 31489a7301fSDan Williams enum sci_status sci_request_start(struct isci_request *ireq); 31589a7301fSDan Williams enum sci_status sci_io_request_terminate(struct isci_request *ireq); 316e301370aSEdmund Nadolski enum sci_status 31789a7301fSDan Williams sci_io_request_event_handler(struct isci_request *ireq, 318f1f52e75SDan Williams u32 event_code); 319e301370aSEdmund Nadolski enum sci_status 32089a7301fSDan Williams sci_io_request_frame_handler(struct isci_request *ireq, 321f1f52e75SDan Williams u32 frame_index); 322e301370aSEdmund Nadolski enum sci_status 32389a7301fSDan Williams sci_task_request_terminate(struct isci_request *ireq); 324e301370aSEdmund Nadolski extern enum sci_status 32589a7301fSDan Williams sci_request_complete(struct isci_request *ireq); 326e301370aSEdmund Nadolski extern enum sci_status 32789a7301fSDan Williams sci_io_request_tc_completion(struct isci_request *ireq, u32 code); 328f1f52e75SDan Williams 329f1f52e75SDan Williams /* XXX open code in caller */ 330e301370aSEdmund Nadolski static inline dma_addr_t 33189a7301fSDan Williams sci_io_request_get_dma_addr(struct isci_request *ireq, void *virt_addr) 332f1f52e75SDan Williams { 333f1f52e75SDan Williams 334f1f52e75SDan Williams char *requested_addr = (char *)virt_addr; 335f1f52e75SDan Williams char *base_addr = (char *)ireq; 336f1f52e75SDan Williams 337f1f52e75SDan Williams BUG_ON(requested_addr < base_addr); 338f1f52e75SDan Williams BUG_ON((requested_addr - base_addr) >= sizeof(*ireq)); 339f1f52e75SDan Williams 340f1f52e75SDan Williams return ireq->request_daddr + (requested_addr - base_addr); 341f1f52e75SDan Williams } 342f1f52e75SDan Williams 343f1f52e75SDan Williams /** 3446f231ddaSDan Williams * isci_request_change_state() - This function sets the status of the request 3456f231ddaSDan Williams * object. 3466f231ddaSDan Williams * @request: This parameter points to the isci_request object 3476f231ddaSDan Williams * @status: This Parameter is the new status of the object 3486f231ddaSDan Williams * 3496f231ddaSDan Williams */ 350e301370aSEdmund Nadolski static inline enum isci_request_status 351e301370aSEdmund Nadolski isci_request_change_state(struct isci_request *isci_request, 3526f231ddaSDan Williams enum isci_request_status status) 3536f231ddaSDan Williams { 3546f231ddaSDan Williams enum isci_request_status old_state; 3556f231ddaSDan Williams unsigned long flags; 3566f231ddaSDan Williams 3576f231ddaSDan Williams dev_dbg(&isci_request->isci_host->pdev->dev, 3586f231ddaSDan Williams "%s: isci_request = %p, state = 0x%x\n", 3596f231ddaSDan Williams __func__, 3606f231ddaSDan Williams isci_request, 3616f231ddaSDan Williams status); 3626f231ddaSDan Williams 3636f231ddaSDan Williams BUG_ON(isci_request == NULL); 3646f231ddaSDan Williams 3656f231ddaSDan Williams spin_lock_irqsave(&isci_request->state_lock, flags); 3666f231ddaSDan Williams old_state = isci_request->status; 3676f231ddaSDan Williams isci_request->status = status; 3686f231ddaSDan Williams spin_unlock_irqrestore(&isci_request->state_lock, flags); 3696f231ddaSDan Williams 3706f231ddaSDan Williams return old_state; 3716f231ddaSDan Williams } 3726f231ddaSDan Williams 3736f231ddaSDan Williams /** 3746f231ddaSDan Williams * isci_request_change_started_to_newstate() - This function sets the status of 3756f231ddaSDan Williams * the request object. 3766f231ddaSDan Williams * @request: This parameter points to the isci_request object 3776f231ddaSDan Williams * @status: This Parameter is the new status of the object 3786f231ddaSDan Williams * 3796f231ddaSDan Williams * state previous to any change. 3806f231ddaSDan Williams */ 381e301370aSEdmund Nadolski static inline enum isci_request_status 382e301370aSEdmund Nadolski isci_request_change_started_to_newstate(struct isci_request *isci_request, 3836f231ddaSDan Williams struct completion *completion_ptr, 3846f231ddaSDan Williams enum isci_request_status newstate) 3856f231ddaSDan Williams { 3866f231ddaSDan Williams enum isci_request_status old_state; 3876f231ddaSDan Williams unsigned long flags; 3886f231ddaSDan Williams 3896f231ddaSDan Williams spin_lock_irqsave(&isci_request->state_lock, flags); 3906f231ddaSDan Williams 3916f231ddaSDan Williams old_state = isci_request->status; 3926f231ddaSDan Williams 393f219f010SJeff Skirvin if (old_state == started || old_state == aborting) { 3946f231ddaSDan Williams BUG_ON(isci_request->io_request_completion != NULL); 3956f231ddaSDan Williams 3966f231ddaSDan Williams isci_request->io_request_completion = completion_ptr; 3976f231ddaSDan Williams isci_request->status = newstate; 3986f231ddaSDan Williams } 399e301370aSEdmund Nadolski 4006f231ddaSDan Williams spin_unlock_irqrestore(&isci_request->state_lock, flags); 4016f231ddaSDan Williams 4026f231ddaSDan Williams dev_dbg(&isci_request->isci_host->pdev->dev, 4036f231ddaSDan Williams "%s: isci_request = %p, old_state = 0x%x\n", 4046f231ddaSDan Williams __func__, 4056f231ddaSDan Williams isci_request, 4066f231ddaSDan Williams old_state); 4076f231ddaSDan Williams 4086f231ddaSDan Williams return old_state; 4096f231ddaSDan Williams } 4106f231ddaSDan Williams 4116f231ddaSDan Williams /** 4126f231ddaSDan Williams * isci_request_change_started_to_aborted() - This function sets the status of 4136f231ddaSDan Williams * the request object. 4146f231ddaSDan Williams * @request: This parameter points to the isci_request object 4156f231ddaSDan Williams * @completion_ptr: This parameter is saved as the kernel completion structure 4166f231ddaSDan Williams * signalled when the old request completes. 4176f231ddaSDan Williams * 4186f231ddaSDan Williams * state previous to any change. 4196f231ddaSDan Williams */ 420e301370aSEdmund Nadolski static inline enum isci_request_status 421e301370aSEdmund Nadolski isci_request_change_started_to_aborted(struct isci_request *isci_request, 4226f231ddaSDan Williams struct completion *completion_ptr) 4236f231ddaSDan Williams { 424e301370aSEdmund Nadolski return isci_request_change_started_to_newstate(isci_request, 425e301370aSEdmund Nadolski completion_ptr, 426e301370aSEdmund Nadolski aborted); 4276f231ddaSDan Williams } 4286f231ddaSDan Williams 429e301370aSEdmund Nadolski #define isci_request_access_task(req) ((req)->ttype_ptr.io_task_ptr) 4306f231ddaSDan Williams 431e301370aSEdmund Nadolski #define isci_request_access_tmf(req) ((req)->ttype_ptr.tmf_task_ptr) 4326f231ddaSDan Williams 433db056250SDan Williams struct isci_request *isci_tmf_request_from_tag(struct isci_host *ihost, 4346f231ddaSDan Williams struct isci_tmf *isci_tmf, 435db056250SDan Williams u16 tag); 436209fae14SDan Williams int isci_request_execute(struct isci_host *ihost, struct isci_remote_device *idev, 437db056250SDan Williams struct sas_task *task, u16 tag); 438ddcc7e34SDan Williams void isci_terminate_pending_requests(struct isci_host *ihost, 439980d3aebSDan Williams struct isci_remote_device *idev); 440e301370aSEdmund Nadolski enum sci_status 44189a7301fSDan Williams sci_task_request_construct(struct isci_host *ihost, 44278a6f06eSDan Williams struct isci_remote_device *idev, 443f1f52e75SDan Williams u16 io_tag, 4445076a1a9SDan Williams struct isci_request *ireq); 445*43a5ab15SDan Williams enum sci_status sci_task_request_construct_ssp(struct isci_request *ireq); 44689a7301fSDan Williams void sci_smp_request_copy_response(struct isci_request *ireq); 4479274f45eSJeff Skirvin 4489274f45eSJeff Skirvin static inline int isci_task_is_ncq_recovery(struct sas_task *task) 4499274f45eSJeff Skirvin { 4509274f45eSJeff Skirvin return (sas_protocol_ata(task->task_proto) && 4519274f45eSJeff Skirvin task->ata_task.fis.command == ATA_CMD_READ_LOG_EXT && 4529274f45eSJeff Skirvin task->ata_task.fis.lbal == ATA_LOG_SATA_NCQ); 4539274f45eSJeff Skirvin 4549274f45eSJeff Skirvin } 4559274f45eSJeff Skirvin 4566f231ddaSDan Williams #endif /* !defined(_ISCI_REQUEST_H_) */ 457