Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is provided under a dual BSD/GPLv2 license. When using or |
| 3 | * redistributing this file, you may do so under either license. |
| 4 | * |
| 5 | * GPL LICENSE SUMMARY |
| 6 | * |
| 7 | * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of version 2 of the GNU General Public License as |
| 11 | * published by the Free Software Foundation. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, but |
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | * The full GNU General Public License is included in this distribution |
| 22 | * in the file called LICENSE.GPL. |
| 23 | * |
| 24 | * BSD LICENSE |
| 25 | * |
| 26 | * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. |
| 27 | * All rights reserved. |
| 28 | * |
| 29 | * Redistribution and use in source and binary forms, with or without |
| 30 | * modification, are permitted provided that the following conditions |
| 31 | * are met: |
| 32 | * |
| 33 | * * Redistributions of source code must retain the above copyright |
| 34 | * notice, this list of conditions and the following disclaimer. |
| 35 | * * Redistributions in binary form must reproduce the above copyright |
| 36 | * notice, this list of conditions and the following disclaimer in |
| 37 | * the documentation and/or other materials provided with the |
| 38 | * distribution. |
| 39 | * * Neither the name of Intel Corporation nor the names of its |
| 40 | * contributors may be used to endorse or promote products derived |
| 41 | * from this software without specific prior written permission. |
| 42 | * |
| 43 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 44 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 45 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 46 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 47 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 48 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 49 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 50 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 51 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 52 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 53 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 54 | */ |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 55 | #include "intel_sas.h" |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 56 | #include "intel_ata.h" |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 57 | #include "isci.h" |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 58 | #include "port.h" |
| 59 | #include "remote_device.h" |
| 60 | #include "request.h" |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 61 | #include "scic_controller.h" |
| 62 | #include "scic_io_request.h" |
| 63 | #include "scic_phy.h" |
| 64 | #include "scic_port.h" |
| 65 | #include "scic_sds_controller.h" |
| 66 | #include "scic_sds_phy.h" |
| 67 | #include "scic_sds_port.h" |
| 68 | #include "remote_node_context.h" |
| 69 | #include "scic_sds_request.h" |
| 70 | #include "sci_environment.h" |
| 71 | #include "sci_util.h" |
| 72 | #include "scu_event_codes.h" |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 73 | #include "task.h" |
| 74 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 75 | /** |
| 76 | * isci_remote_device_change_state() - This function gets the status of the |
| 77 | * remote_device object. |
| 78 | * @isci_device: This parameter points to the isci_remote_device object |
| 79 | * |
| 80 | * status of the object as a isci_status enum. |
| 81 | */ |
| 82 | void isci_remote_device_change_state( |
| 83 | struct isci_remote_device *isci_device, |
| 84 | enum isci_status status) |
| 85 | { |
| 86 | unsigned long flags; |
| 87 | |
| 88 | spin_lock_irqsave(&isci_device->state_lock, flags); |
| 89 | isci_device->status = status; |
| 90 | spin_unlock_irqrestore(&isci_device->state_lock, flags); |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * isci_remote_device_not_ready() - This function is called by the scic when |
| 95 | * the remote device is not ready. We mark the isci device as ready (not |
| 96 | * "ready_for_io") and signal the waiting proccess. |
| 97 | * @isci_host: This parameter specifies the isci host object. |
| 98 | * @isci_device: This parameter specifies the remote device |
| 99 | * |
| 100 | */ |
| 101 | static void isci_remote_device_not_ready(struct isci_host *ihost, |
| 102 | struct isci_remote_device *idev, u32 reason) |
| 103 | { |
| 104 | dev_dbg(&ihost->pdev->dev, |
| 105 | "%s: isci_device = %p\n", __func__, idev); |
| 106 | |
| 107 | if (reason == SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED) |
| 108 | isci_remote_device_change_state(idev, isci_stopping); |
| 109 | else |
| 110 | /* device ready is actually a "not ready for io" state. */ |
| 111 | isci_remote_device_change_state(idev, isci_ready); |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * isci_remote_device_ready() - This function is called by the scic when the |
| 116 | * remote device is ready. We mark the isci device as ready and signal the |
| 117 | * waiting proccess. |
| 118 | * @ihost: our valid isci_host |
| 119 | * @idev: remote device |
| 120 | * |
| 121 | */ |
| 122 | static void isci_remote_device_ready(struct isci_host *ihost, struct isci_remote_device *idev) |
| 123 | { |
| 124 | dev_dbg(&ihost->pdev->dev, |
| 125 | "%s: idev = %p\n", __func__, idev); |
| 126 | |
| 127 | isci_remote_device_change_state(idev, isci_ready_for_io); |
| 128 | if (test_and_clear_bit(IDEV_START_PENDING, &idev->flags)) |
| 129 | wake_up(&ihost->eventq); |
| 130 | } |
| 131 | |
Dan Williams | ec57566 | 2011-05-01 14:19:25 -0700 | [diff] [blame] | 132 | /* called once the remote node context is ready to be freed. |
| 133 | * The remote device can now report that its stop operation is complete. none |
| 134 | */ |
| 135 | static void rnc_destruct_done(void *_dev) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 136 | { |
Dan Williams | ec57566 | 2011-05-01 14:19:25 -0700 | [diff] [blame] | 137 | struct scic_sds_remote_device *sci_dev = _dev; |
| 138 | |
| 139 | BUG_ON(sci_dev->started_request_count != 0); |
| 140 | sci_base_state_machine_change_state(&sci_dev->state_machine, |
| 141 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED); |
| 142 | } |
| 143 | |
| 144 | static enum sci_status scic_sds_remote_device_terminate_requests(struct scic_sds_remote_device *sci_dev) |
| 145 | { |
| 146 | struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller; |
| 147 | u32 i, request_count = sci_dev->started_request_count; |
| 148 | enum sci_status status = SCI_SUCCESS; |
| 149 | |
| 150 | for (i = 0; i < SCI_MAX_IO_REQUESTS && i < request_count; i++) { |
| 151 | struct scic_sds_request *sci_req; |
| 152 | enum sci_status s; |
| 153 | |
| 154 | sci_req = scic->io_request_table[i]; |
| 155 | if (!sci_req || sci_req->target_device != sci_dev) |
| 156 | continue; |
| 157 | s = scic_controller_terminate_request(scic, sci_dev, sci_req); |
| 158 | if (s != SCI_SUCCESS) |
| 159 | status = s; |
| 160 | } |
| 161 | |
| 162 | return status; |
| 163 | } |
| 164 | |
| 165 | enum sci_status scic_remote_device_stop(struct scic_sds_remote_device *sci_dev, |
| 166 | u32 timeout) |
| 167 | { |
| 168 | struct sci_base_state_machine *sm = &sci_dev->state_machine; |
| 169 | enum scic_sds_remote_device_states state = sm->current_state_id; |
| 170 | |
| 171 | switch (state) { |
| 172 | case SCI_BASE_REMOTE_DEVICE_STATE_INITIAL: |
| 173 | case SCI_BASE_REMOTE_DEVICE_STATE_FAILED: |
| 174 | case SCI_BASE_REMOTE_DEVICE_STATE_FINAL: |
| 175 | default: |
| 176 | dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", |
| 177 | __func__, state); |
| 178 | return SCI_FAILURE_INVALID_STATE; |
| 179 | case SCI_BASE_REMOTE_DEVICE_STATE_STOPPED: |
| 180 | return SCI_SUCCESS; |
| 181 | case SCI_BASE_REMOTE_DEVICE_STATE_STARTING: |
| 182 | /* device not started so there had better be no requests */ |
| 183 | BUG_ON(sci_dev->started_request_count != 0); |
| 184 | scic_sds_remote_node_context_destruct(&sci_dev->rnc, |
| 185 | rnc_destruct_done, sci_dev); |
| 186 | /* Transition to the stopping state and wait for the |
| 187 | * remote node to complete being posted and invalidated. |
| 188 | */ |
| 189 | sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_STOPPING); |
| 190 | return SCI_SUCCESS; |
| 191 | case SCI_BASE_REMOTE_DEVICE_STATE_READY: |
| 192 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: |
| 193 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: |
| 194 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: |
| 195 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: |
| 196 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: |
| 197 | case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: |
| 198 | case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: |
| 199 | sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_STOPPING); |
| 200 | if (sci_dev->started_request_count == 0) { |
| 201 | scic_sds_remote_node_context_destruct(&sci_dev->rnc, |
| 202 | rnc_destruct_done, sci_dev); |
| 203 | return SCI_SUCCESS; |
| 204 | } else |
| 205 | return scic_sds_remote_device_terminate_requests(sci_dev); |
| 206 | break; |
| 207 | case SCI_BASE_REMOTE_DEVICE_STATE_STOPPING: |
| 208 | /* All requests should have been terminated, but if there is an |
| 209 | * attempt to stop a device already in the stopping state, then |
| 210 | * try again to terminate. |
| 211 | */ |
| 212 | return scic_sds_remote_device_terminate_requests(sci_dev); |
| 213 | case SCI_BASE_REMOTE_DEVICE_STATE_RESETTING: |
| 214 | sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_STOPPING); |
| 215 | return SCI_SUCCESS; |
| 216 | } |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 217 | } |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 218 | |
Dan Williams | 4fd0d2e | 2011-05-01 14:48:54 -0700 | [diff] [blame] | 219 | enum sci_status scic_remote_device_reset(struct scic_sds_remote_device *sci_dev) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 220 | { |
Dan Williams | 4fd0d2e | 2011-05-01 14:48:54 -0700 | [diff] [blame] | 221 | struct sci_base_state_machine *sm = &sci_dev->state_machine; |
| 222 | enum scic_sds_remote_device_states state = sm->current_state_id; |
| 223 | |
| 224 | switch (state) { |
| 225 | case SCI_BASE_REMOTE_DEVICE_STATE_INITIAL: |
| 226 | case SCI_BASE_REMOTE_DEVICE_STATE_STOPPED: |
| 227 | case SCI_BASE_REMOTE_DEVICE_STATE_STARTING: |
| 228 | case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: |
| 229 | case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: |
| 230 | case SCI_BASE_REMOTE_DEVICE_STATE_STOPPING: |
| 231 | case SCI_BASE_REMOTE_DEVICE_STATE_FAILED: |
| 232 | case SCI_BASE_REMOTE_DEVICE_STATE_RESETTING: |
| 233 | case SCI_BASE_REMOTE_DEVICE_STATE_FINAL: |
| 234 | default: |
| 235 | dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", |
| 236 | __func__, state); |
| 237 | return SCI_FAILURE_INVALID_STATE; |
| 238 | case SCI_BASE_REMOTE_DEVICE_STATE_READY: |
| 239 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: |
| 240 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: |
| 241 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: |
| 242 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: |
| 243 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: |
| 244 | sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_RESETTING); |
| 245 | return SCI_SUCCESS; |
| 246 | } |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 247 | } |
| 248 | |
Dan Williams | 8151518 | 2011-05-01 14:53:00 -0700 | [diff] [blame] | 249 | enum sci_status scic_remote_device_reset_complete(struct scic_sds_remote_device *sci_dev) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 250 | { |
Dan Williams | 8151518 | 2011-05-01 14:53:00 -0700 | [diff] [blame] | 251 | struct sci_base_state_machine *sm = &sci_dev->state_machine; |
| 252 | enum scic_sds_remote_device_states state = sm->current_state_id; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 253 | |
Dan Williams | 8151518 | 2011-05-01 14:53:00 -0700 | [diff] [blame] | 254 | if (state != SCI_BASE_REMOTE_DEVICE_STATE_RESETTING) { |
| 255 | dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", |
| 256 | __func__, state); |
| 257 | return SCI_FAILURE_INVALID_STATE; |
| 258 | } |
| 259 | |
| 260 | sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_READY); |
| 261 | return SCI_SUCCESS; |
| 262 | } |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 263 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 264 | /** |
| 265 | * |
| 266 | * @sci_dev: The remote device for which the suspend is being requested. |
| 267 | * |
| 268 | * This method invokes the remote device suspend state handler. enum sci_status |
| 269 | */ |
| 270 | enum sci_status scic_sds_remote_device_suspend( |
| 271 | struct scic_sds_remote_device *sci_dev, |
| 272 | u32 suspend_type) |
| 273 | { |
| 274 | return sci_dev->state_handlers->suspend_handler(sci_dev, suspend_type); |
| 275 | } |
| 276 | |
| 277 | /** |
| 278 | * |
| 279 | * @sci_dev: The remote device for which the event handling is being |
| 280 | * requested. |
| 281 | * @frame_index: This is the frame index that is being processed. |
| 282 | * |
| 283 | * This method invokes the frame handler for the remote device state machine |
| 284 | * enum sci_status |
| 285 | */ |
| 286 | enum sci_status scic_sds_remote_device_frame_handler( |
| 287 | struct scic_sds_remote_device *sci_dev, |
| 288 | u32 frame_index) |
| 289 | { |
| 290 | return sci_dev->state_handlers->frame_handler(sci_dev, frame_index); |
| 291 | } |
| 292 | |
| 293 | /** |
| 294 | * |
| 295 | * @sci_dev: The remote device for which the event handling is being |
| 296 | * requested. |
| 297 | * @event_code: This is the event code that is to be processed. |
| 298 | * |
| 299 | * This method invokes the remote device event handler. enum sci_status |
| 300 | */ |
| 301 | enum sci_status scic_sds_remote_device_event_handler( |
| 302 | struct scic_sds_remote_device *sci_dev, |
| 303 | u32 event_code) |
| 304 | { |
| 305 | return sci_dev->state_handlers->event_handler(sci_dev, event_code); |
| 306 | } |
| 307 | |
Dan Williams | 1860655 | 2011-05-01 14:57:11 -0700 | [diff] [blame] | 308 | static void scic_sds_remote_device_start_request(struct scic_sds_remote_device *sci_dev, |
| 309 | struct scic_sds_request *sci_req, |
| 310 | enum sci_status status) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 311 | { |
Dan Williams | 1860655 | 2011-05-01 14:57:11 -0700 | [diff] [blame] | 312 | struct scic_sds_port *sci_port = sci_dev->owning_port; |
| 313 | |
| 314 | /* cleanup requests that failed after starting on the port */ |
| 315 | if (status != SCI_SUCCESS) |
| 316 | scic_sds_port_complete_io(sci_port, sci_dev, sci_req); |
| 317 | else |
| 318 | scic_sds_remote_device_increment_request_count(sci_dev); |
| 319 | } |
| 320 | |
| 321 | enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic, |
| 322 | struct scic_sds_remote_device *sci_dev, |
| 323 | struct scic_sds_request *sci_req) |
| 324 | { |
| 325 | struct sci_base_state_machine *sm = &sci_dev->state_machine; |
| 326 | enum scic_sds_remote_device_states state = sm->current_state_id; |
| 327 | struct scic_sds_port *sci_port = sci_dev->owning_port; |
| 328 | enum sci_status status; |
| 329 | |
| 330 | switch (state) { |
| 331 | case SCI_BASE_REMOTE_DEVICE_STATE_INITIAL: |
| 332 | case SCI_BASE_REMOTE_DEVICE_STATE_STOPPED: |
| 333 | case SCI_BASE_REMOTE_DEVICE_STATE_STARTING: |
| 334 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: |
| 335 | case SCI_BASE_REMOTE_DEVICE_STATE_STOPPING: |
| 336 | case SCI_BASE_REMOTE_DEVICE_STATE_FAILED: |
| 337 | case SCI_BASE_REMOTE_DEVICE_STATE_RESETTING: |
| 338 | case SCI_BASE_REMOTE_DEVICE_STATE_FINAL: |
| 339 | default: |
| 340 | dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", |
| 341 | __func__, state); |
| 342 | return SCI_FAILURE_INVALID_STATE; |
| 343 | case SCI_BASE_REMOTE_DEVICE_STATE_READY: |
| 344 | /* attempt to start an io request for this device object. The remote |
| 345 | * device object will issue the start request for the io and if |
| 346 | * successful it will start the request for the port object then |
| 347 | * increment its own request count. |
| 348 | */ |
| 349 | status = scic_sds_port_start_io(sci_port, sci_dev, sci_req); |
| 350 | if (status != SCI_SUCCESS) |
| 351 | return status; |
| 352 | |
| 353 | status = scic_sds_remote_node_context_start_io(&sci_dev->rnc, sci_req); |
| 354 | if (status != SCI_SUCCESS) |
| 355 | break; |
| 356 | |
| 357 | status = scic_sds_request_start(sci_req); |
| 358 | break; |
| 359 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: { |
| 360 | /* handle the start io operation for a sata device that is in |
| 361 | * the command idle state. - Evalute the type of IO request to |
| 362 | * be started - If its an NCQ request change to NCQ substate - |
| 363 | * If its any other command change to the CMD substate |
| 364 | * |
| 365 | * If this is a softreset we may want to have a different |
| 366 | * substate. |
| 367 | */ |
| 368 | enum scic_sds_remote_device_states new_state; |
| 369 | |
| 370 | status = scic_sds_port_start_io(sci_port, sci_dev, sci_req); |
| 371 | if (status != SCI_SUCCESS) |
| 372 | return status; |
| 373 | |
| 374 | status = scic_sds_remote_node_context_start_io(&sci_dev->rnc, sci_req); |
| 375 | if (status != SCI_SUCCESS) |
| 376 | break; |
| 377 | |
| 378 | status = sci_req->state_handlers->start_handler(sci_req); |
| 379 | if (status != SCI_SUCCESS) |
| 380 | break; |
| 381 | |
| 382 | if (isci_sata_get_sat_protocol(sci_req->ireq) == SAT_PROTOCOL_FPDMA) |
| 383 | new_state = SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ; |
| 384 | else { |
| 385 | sci_dev->working_request = sci_req; |
| 386 | new_state = SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD; |
| 387 | } |
| 388 | sci_base_state_machine_change_state(sm, new_state); |
| 389 | break; |
| 390 | } |
| 391 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: |
| 392 | if (isci_sata_get_sat_protocol(sci_req->ireq) == SAT_PROTOCOL_FPDMA) { |
| 393 | status = scic_sds_port_start_io(sci_port, sci_dev, sci_req); |
| 394 | if (status != SCI_SUCCESS) |
| 395 | return status; |
| 396 | |
| 397 | status = scic_sds_remote_node_context_start_io(&sci_dev->rnc, sci_req); |
| 398 | if (status != SCI_SUCCESS) |
| 399 | break; |
| 400 | |
| 401 | status = sci_req->state_handlers->start_handler(sci_req); |
| 402 | } else |
| 403 | return SCI_FAILURE_INVALID_STATE; |
| 404 | break; |
| 405 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: |
| 406 | return SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED; |
| 407 | case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: |
| 408 | status = scic_sds_port_start_io(sci_port, sci_dev, sci_req); |
| 409 | if (status != SCI_SUCCESS) |
| 410 | return status; |
| 411 | |
| 412 | status = scic_sds_remote_node_context_start_io(&sci_dev->rnc, sci_req); |
| 413 | if (status != SCI_SUCCESS) |
| 414 | break; |
| 415 | |
| 416 | status = scic_sds_request_start(sci_req); |
| 417 | if (status != SCI_SUCCESS) |
| 418 | break; |
| 419 | |
| 420 | sci_dev->working_request = sci_req; |
| 421 | sci_base_state_machine_change_state(&sci_dev->state_machine, |
| 422 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD); |
| 423 | break; |
| 424 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: |
| 425 | case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: |
| 426 | /* device is already handling a command it can not accept new commands |
| 427 | * until this one is complete. |
| 428 | */ |
| 429 | return SCI_FAILURE_INVALID_STATE; |
| 430 | } |
| 431 | |
| 432 | scic_sds_remote_device_start_request(sci_dev, sci_req, status); |
| 433 | return status; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 434 | } |
| 435 | |
Dan Williams | 10a09e6 | 2011-05-01 15:33:43 -0700 | [diff] [blame] | 436 | static enum sci_status common_complete_io(struct scic_sds_port *sci_port, |
| 437 | struct scic_sds_remote_device *sci_dev, |
| 438 | struct scic_sds_request *sci_req) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 439 | { |
Dan Williams | 10a09e6 | 2011-05-01 15:33:43 -0700 | [diff] [blame] | 440 | enum sci_status status; |
| 441 | |
| 442 | status = scic_sds_request_complete(sci_req); |
| 443 | if (status != SCI_SUCCESS) |
| 444 | return status; |
| 445 | |
| 446 | status = scic_sds_port_complete_io(sci_port, sci_dev, sci_req); |
| 447 | if (status != SCI_SUCCESS) |
| 448 | return status; |
| 449 | |
| 450 | scic_sds_remote_device_decrement_request_count(sci_dev); |
| 451 | return status; |
| 452 | } |
| 453 | |
| 454 | enum sci_status scic_sds_remote_device_complete_io(struct scic_sds_controller *scic, |
| 455 | struct scic_sds_remote_device *sci_dev, |
| 456 | struct scic_sds_request *sci_req) |
| 457 | { |
| 458 | struct sci_base_state_machine *sm = &sci_dev->state_machine; |
| 459 | enum scic_sds_remote_device_states state = sm->current_state_id; |
| 460 | struct scic_sds_port *sci_port = sci_dev->owning_port; |
| 461 | enum sci_status status; |
| 462 | |
| 463 | switch (state) { |
| 464 | case SCI_BASE_REMOTE_DEVICE_STATE_INITIAL: |
| 465 | case SCI_BASE_REMOTE_DEVICE_STATE_STOPPED: |
| 466 | case SCI_BASE_REMOTE_DEVICE_STATE_STARTING: |
| 467 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: |
| 468 | case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: |
| 469 | case SCI_BASE_REMOTE_DEVICE_STATE_FAILED: |
| 470 | case SCI_BASE_REMOTE_DEVICE_STATE_FINAL: |
| 471 | default: |
| 472 | dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", |
| 473 | __func__, state); |
| 474 | return SCI_FAILURE_INVALID_STATE; |
| 475 | case SCI_BASE_REMOTE_DEVICE_STATE_READY: |
| 476 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: |
| 477 | case SCI_BASE_REMOTE_DEVICE_STATE_RESETTING: |
| 478 | status = common_complete_io(sci_port, sci_dev, sci_req); |
| 479 | break; |
| 480 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: |
| 481 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: |
| 482 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: |
| 483 | status = common_complete_io(sci_port, sci_dev, sci_req); |
| 484 | if (status != SCI_SUCCESS) |
| 485 | break; |
| 486 | |
| 487 | if (sci_req->sci_status == SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) { |
| 488 | /* This request causes hardware error, device needs to be Lun Reset. |
| 489 | * So here we force the state machine to IDLE state so the rest IOs |
| 490 | * can reach RNC state handler, these IOs will be completed by RNC with |
| 491 | * status of "DEVICE_RESET_REQUIRED", instead of "INVALID STATE". |
| 492 | */ |
| 493 | sci_base_state_machine_change_state(sm, SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET); |
| 494 | } else if (scic_sds_remote_device_get_request_count(sci_dev) == 0) |
| 495 | sci_base_state_machine_change_state(sm, SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); |
| 496 | break; |
| 497 | case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: |
| 498 | status = common_complete_io(sci_port, sci_dev, sci_req); |
| 499 | if (status != SCI_SUCCESS) |
| 500 | break; |
| 501 | sci_base_state_machine_change_state(sm, SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); |
| 502 | break; |
| 503 | case SCI_BASE_REMOTE_DEVICE_STATE_STOPPING: |
| 504 | status = common_complete_io(sci_port, sci_dev, sci_req); |
| 505 | if (status != SCI_SUCCESS) |
| 506 | break; |
| 507 | |
| 508 | if (scic_sds_remote_device_get_request_count(sci_dev) == 0) |
| 509 | scic_sds_remote_node_context_destruct(&sci_dev->rnc, |
| 510 | rnc_destruct_done, |
| 511 | sci_dev); |
| 512 | break; |
| 513 | } |
| 514 | |
| 515 | if (status != SCI_SUCCESS) |
| 516 | dev_err(scirdev_to_dev(sci_dev), |
| 517 | "%s: Port:0x%p Device:0x%p Request:0x%p Status:0x%x " |
| 518 | "could not complete\n", __func__, sci_port, |
| 519 | sci_dev, sci_req, status); |
| 520 | |
| 521 | return status; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 522 | } |
| 523 | |
Dan Williams | 84b9b02 | 2011-05-01 15:53:25 -0700 | [diff] [blame^] | 524 | static void scic_sds_remote_device_continue_request(void *dev) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 525 | { |
Dan Williams | 84b9b02 | 2011-05-01 15:53:25 -0700 | [diff] [blame^] | 526 | struct scic_sds_remote_device *sci_dev = dev; |
| 527 | |
| 528 | /* we need to check if this request is still valid to continue. */ |
| 529 | if (sci_dev->working_request) |
| 530 | scic_controller_continue_io(sci_dev->working_request); |
| 531 | } |
| 532 | |
| 533 | enum sci_status scic_sds_remote_device_start_task(struct scic_sds_controller *scic, |
| 534 | struct scic_sds_remote_device *sci_dev, |
| 535 | struct scic_sds_request *sci_req) |
| 536 | { |
| 537 | struct sci_base_state_machine *sm = &sci_dev->state_machine; |
| 538 | enum scic_sds_remote_device_states state = sm->current_state_id; |
| 539 | struct scic_sds_port *sci_port = sci_dev->owning_port; |
| 540 | enum sci_status status; |
| 541 | |
| 542 | switch (state) { |
| 543 | case SCI_BASE_REMOTE_DEVICE_STATE_INITIAL: |
| 544 | case SCI_BASE_REMOTE_DEVICE_STATE_STOPPED: |
| 545 | case SCI_BASE_REMOTE_DEVICE_STATE_STARTING: |
| 546 | case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: |
| 547 | case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: |
| 548 | case SCI_BASE_REMOTE_DEVICE_STATE_STOPPING: |
| 549 | case SCI_BASE_REMOTE_DEVICE_STATE_FAILED: |
| 550 | case SCI_BASE_REMOTE_DEVICE_STATE_RESETTING: |
| 551 | case SCI_BASE_REMOTE_DEVICE_STATE_FINAL: |
| 552 | default: |
| 553 | dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", |
| 554 | __func__, state); |
| 555 | return SCI_FAILURE_INVALID_STATE; |
| 556 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: |
| 557 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: |
| 558 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: |
| 559 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: |
| 560 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: |
| 561 | status = scic_sds_port_start_io(sci_port, sci_dev, sci_req); |
| 562 | if (status != SCI_SUCCESS) |
| 563 | return status; |
| 564 | |
| 565 | status = scic_sds_remote_node_context_start_task(&sci_dev->rnc, sci_req); |
| 566 | if (status != SCI_SUCCESS) |
| 567 | goto out; |
| 568 | |
| 569 | status = sci_req->state_handlers->start_handler(sci_req); |
| 570 | if (status != SCI_SUCCESS) |
| 571 | goto out; |
| 572 | |
| 573 | /* Note: If the remote device state is not IDLE this will |
| 574 | * replace the request that probably resulted in the task |
| 575 | * management request. |
| 576 | */ |
| 577 | sci_dev->working_request = sci_req; |
| 578 | sci_base_state_machine_change_state(sm, SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD); |
| 579 | |
| 580 | /* The remote node context must cleanup the TCi to NCQ mapping |
| 581 | * table. The only way to do this correctly is to either write |
| 582 | * to the TLCR register or to invalidate and repost the RNC. In |
| 583 | * either case the remote node context state machine will take |
| 584 | * the correct action when the remote node context is suspended |
| 585 | * and later resumed. |
| 586 | */ |
| 587 | scic_sds_remote_node_context_suspend(&sci_dev->rnc, |
| 588 | SCI_SOFTWARE_SUSPENSION, NULL, NULL); |
| 589 | scic_sds_remote_node_context_resume(&sci_dev->rnc, |
| 590 | scic_sds_remote_device_continue_request, |
| 591 | sci_dev); |
| 592 | |
| 593 | out: |
| 594 | scic_sds_remote_device_start_request(sci_dev, sci_req, status); |
| 595 | /* We need to let the controller start request handler know that |
| 596 | * it can't post TC yet. We will provide a callback function to |
| 597 | * post TC when RNC gets resumed. |
| 598 | */ |
| 599 | return SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS; |
| 600 | case SCI_BASE_REMOTE_DEVICE_STATE_READY: |
| 601 | status = scic_sds_port_start_io(sci_port, sci_dev, sci_req); |
| 602 | if (status != SCI_SUCCESS) |
| 603 | return status; |
| 604 | |
| 605 | status = scic_sds_remote_node_context_start_task(&sci_dev->rnc, sci_req); |
| 606 | if (status != SCI_SUCCESS) |
| 607 | break; |
| 608 | |
| 609 | status = scic_sds_request_start(sci_req); |
| 610 | break; |
| 611 | } |
| 612 | scic_sds_remote_device_start_request(sci_dev, sci_req, status); |
| 613 | |
| 614 | return status; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 615 | } |
| 616 | |
| 617 | /** |
| 618 | * |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 619 | * @sci_dev: |
| 620 | * @request: |
| 621 | * |
| 622 | * This method takes the request and bulids an appropriate SCU context for the |
| 623 | * request and then requests the controller to post the request. none |
| 624 | */ |
| 625 | void scic_sds_remote_device_post_request( |
| 626 | struct scic_sds_remote_device *sci_dev, |
| 627 | u32 request) |
| 628 | { |
| 629 | u32 context; |
| 630 | |
| 631 | context = scic_sds_remote_device_build_command_context(sci_dev, request); |
| 632 | |
| 633 | scic_sds_controller_post_request( |
| 634 | scic_sds_remote_device_get_controller(sci_dev), |
| 635 | context |
| 636 | ); |
| 637 | } |
| 638 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 639 | /* called once the remote node context has transisitioned to a |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 640 | * ready state. This is the indication that the remote device object can also |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 641 | * transition to ready. |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 642 | */ |
Dan Williams | eb22967 | 2011-05-01 14:05:57 -0700 | [diff] [blame] | 643 | static void remote_device_resume_done(void *_dev) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 644 | { |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 645 | struct scic_sds_remote_device *sci_dev = _dev; |
| 646 | enum scic_sds_remote_device_states state; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 647 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 648 | state = sci_dev->state_machine.current_state_id; |
| 649 | switch (state) { |
| 650 | case SCI_BASE_REMOTE_DEVICE_STATE_READY: |
| 651 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: |
| 652 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: |
| 653 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: |
| 654 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: |
| 655 | case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: |
| 656 | case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: |
| 657 | case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: |
| 658 | break; |
| 659 | default: |
| 660 | /* go 'ready' if we are not already in a ready state */ |
| 661 | sci_base_state_machine_change_state(&sci_dev->state_machine, |
| 662 | SCI_BASE_REMOTE_DEVICE_STATE_READY); |
| 663 | break; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 664 | } |
| 665 | } |
| 666 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 667 | static enum sci_status |
| 668 | default_device_handler(struct scic_sds_remote_device *sci_dev, |
| 669 | const char *func) |
| 670 | { |
| 671 | dev_warn(scirdev_to_dev(sci_dev), |
| 672 | "%s: in wrong state: %d\n", func, |
| 673 | sci_base_state_machine_get_state(&sci_dev->state_machine)); |
| 674 | return SCI_FAILURE_INVALID_STATE; |
| 675 | } |
| 676 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 677 | static enum sci_status scic_sds_remote_device_default_suspend_handler( |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 678 | struct scic_sds_remote_device *sci_dev, u32 suspend_type) |
| 679 | { |
| 680 | return default_device_handler(sci_dev, __func__); |
| 681 | } |
| 682 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 683 | static enum sci_status scic_sds_remote_device_default_resume_handler( |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 684 | struct scic_sds_remote_device *sci_dev) |
| 685 | { |
| 686 | return default_device_handler(sci_dev, __func__); |
| 687 | } |
| 688 | |
| 689 | /** |
| 690 | * |
| 691 | * @device: The struct scic_sds_remote_device which is then cast into a |
| 692 | * struct scic_sds_remote_device. |
| 693 | * @event_code: The event code that the struct scic_sds_controller wants the device |
| 694 | * object to process. |
| 695 | * |
| 696 | * This method is the default event handler. It will call the RNC state |
| 697 | * machine handler for any RNC events otherwise it will log a warning and |
| 698 | * returns a failure. enum sci_status SCI_FAILURE_INVALID_STATE |
| 699 | */ |
| 700 | static enum sci_status scic_sds_remote_device_core_event_handler( |
| 701 | struct scic_sds_remote_device *sci_dev, |
| 702 | u32 event_code, |
| 703 | bool is_ready_state) |
| 704 | { |
| 705 | enum sci_status status; |
| 706 | |
| 707 | switch (scu_get_event_type(event_code)) { |
| 708 | case SCU_EVENT_TYPE_RNC_OPS_MISC: |
| 709 | case SCU_EVENT_TYPE_RNC_SUSPEND_TX: |
| 710 | case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX: |
| 711 | status = scic_sds_remote_node_context_event_handler(&sci_dev->rnc, event_code); |
| 712 | break; |
| 713 | case SCU_EVENT_TYPE_PTX_SCHEDULE_EVENT: |
| 714 | |
| 715 | if (scu_get_event_code(event_code) == SCU_EVENT_IT_NEXUS_TIMEOUT) { |
| 716 | status = SCI_SUCCESS; |
| 717 | |
| 718 | /* Suspend the associated RNC */ |
| 719 | scic_sds_remote_node_context_suspend(&sci_dev->rnc, |
| 720 | SCI_SOFTWARE_SUSPENSION, |
| 721 | NULL, NULL); |
| 722 | |
| 723 | dev_dbg(scirdev_to_dev(sci_dev), |
| 724 | "%s: device: %p event code: %x: %s\n", |
| 725 | __func__, sci_dev, event_code, |
| 726 | (is_ready_state) |
| 727 | ? "I_T_Nexus_Timeout event" |
| 728 | : "I_T_Nexus_Timeout event in wrong state"); |
| 729 | |
| 730 | break; |
| 731 | } |
| 732 | /* Else, fall through and treat as unhandled... */ |
| 733 | |
| 734 | default: |
| 735 | dev_dbg(scirdev_to_dev(sci_dev), |
| 736 | "%s: device: %p event code: %x: %s\n", |
| 737 | __func__, sci_dev, event_code, |
| 738 | (is_ready_state) |
| 739 | ? "unexpected event" |
| 740 | : "unexpected event in wrong state"); |
| 741 | status = SCI_FAILURE_INVALID_STATE; |
| 742 | break; |
| 743 | } |
| 744 | |
| 745 | return status; |
| 746 | } |
| 747 | /** |
| 748 | * |
| 749 | * @device: The struct scic_sds_remote_device which is then cast into a |
| 750 | * struct scic_sds_remote_device. |
| 751 | * @event_code: The event code that the struct scic_sds_controller wants the device |
| 752 | * object to process. |
| 753 | * |
| 754 | * This method is the default event handler. It will call the RNC state |
| 755 | * machine handler for any RNC events otherwise it will log a warning and |
| 756 | * returns a failure. enum sci_status SCI_FAILURE_INVALID_STATE |
| 757 | */ |
| 758 | static enum sci_status scic_sds_remote_device_default_event_handler( |
| 759 | struct scic_sds_remote_device *sci_dev, |
| 760 | u32 event_code) |
| 761 | { |
| 762 | return scic_sds_remote_device_core_event_handler(sci_dev, |
| 763 | event_code, |
| 764 | false); |
| 765 | } |
| 766 | |
| 767 | /** |
| 768 | * |
| 769 | * @device: The struct scic_sds_remote_device which is then cast into a |
| 770 | * struct scic_sds_remote_device. |
| 771 | * @frame_index: The frame index for which the struct scic_sds_controller wants this |
| 772 | * device object to process. |
| 773 | * |
| 774 | * This method is the default unsolicited frame handler. It logs a warning, |
| 775 | * releases the frame and returns a failure. enum sci_status |
| 776 | * SCI_FAILURE_INVALID_STATE |
| 777 | */ |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 778 | static enum sci_status scic_sds_remote_device_default_frame_handler( |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 779 | struct scic_sds_remote_device *sci_dev, |
| 780 | u32 frame_index) |
| 781 | { |
| 782 | dev_warn(scirdev_to_dev(sci_dev), |
| 783 | "%s: SCIC Remote Device requested to handle frame %x " |
| 784 | "while in wrong state %d\n", |
| 785 | __func__, |
| 786 | frame_index, |
| 787 | sci_base_state_machine_get_state( |
| 788 | &sci_dev->state_machine)); |
| 789 | |
| 790 | /* Return the frame back to the controller */ |
| 791 | scic_sds_controller_release_frame( |
| 792 | scic_sds_remote_device_get_controller(sci_dev), frame_index |
| 793 | ); |
| 794 | |
| 795 | return SCI_FAILURE_INVALID_STATE; |
| 796 | } |
| 797 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 798 | static enum sci_status scic_sds_remote_device_default_complete_request_handler( |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 799 | struct scic_sds_remote_device *sci_dev, |
| 800 | struct scic_sds_request *request) |
| 801 | { |
| 802 | return default_device_handler(sci_dev, __func__); |
| 803 | } |
| 804 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 805 | /** |
| 806 | * |
| 807 | * @device: The struct scic_sds_remote_device which is then cast into a |
| 808 | * struct scic_sds_remote_device. |
| 809 | * @frame_index: The frame index for which the struct scic_sds_controller wants this |
| 810 | * device object to process. |
| 811 | * |
| 812 | * This method is a general ssp frame handler. In most cases the device object |
| 813 | * needs to route the unsolicited frame processing to the io request object. |
| 814 | * This method decodes the tag for the io request object and routes the |
| 815 | * unsolicited frame to that object. enum sci_status SCI_FAILURE_INVALID_STATE |
| 816 | */ |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 817 | static enum sci_status scic_sds_remote_device_general_frame_handler( |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 818 | struct scic_sds_remote_device *sci_dev, |
| 819 | u32 frame_index) |
| 820 | { |
| 821 | enum sci_status result; |
| 822 | struct sci_ssp_frame_header *frame_header; |
| 823 | struct scic_sds_request *io_request; |
| 824 | |
| 825 | result = scic_sds_unsolicited_frame_control_get_header( |
| 826 | &(scic_sds_remote_device_get_controller(sci_dev)->uf_control), |
| 827 | frame_index, |
| 828 | (void **)&frame_header |
| 829 | ); |
| 830 | |
| 831 | if (SCI_SUCCESS == result) { |
| 832 | io_request = scic_sds_controller_get_io_request_from_tag( |
| 833 | scic_sds_remote_device_get_controller(sci_dev), frame_header->tag); |
| 834 | |
| 835 | if ((io_request == NULL) |
| 836 | || (io_request->target_device != sci_dev)) { |
| 837 | /* |
| 838 | * We could not map this tag to a valid IO request |
| 839 | * Just toss the frame and continue */ |
| 840 | scic_sds_controller_release_frame( |
| 841 | scic_sds_remote_device_get_controller(sci_dev), frame_index |
| 842 | ); |
| 843 | } else { |
| 844 | /* The IO request is now in charge of releasing the frame */ |
| 845 | result = io_request->state_handlers->frame_handler( |
| 846 | io_request, frame_index); |
| 847 | } |
| 848 | } |
| 849 | |
| 850 | return result; |
| 851 | } |
| 852 | |
| 853 | /** |
| 854 | * |
| 855 | * @[in]: sci_dev This is the device object that is receiving the event. |
| 856 | * @[in]: event_code The event code to process. |
| 857 | * |
| 858 | * This is a common method for handling events reported to the remote device |
| 859 | * from the controller object. enum sci_status |
| 860 | */ |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 861 | static enum sci_status scic_sds_remote_device_general_event_handler( |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 862 | struct scic_sds_remote_device *sci_dev, |
| 863 | u32 event_code) |
| 864 | { |
| 865 | return scic_sds_remote_device_core_event_handler(sci_dev, |
| 866 | event_code, |
| 867 | true); |
| 868 | } |
| 869 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 870 | /* |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 871 | * This method will complete the request for the remote device object. The |
| 872 | * method will call the completion handler for the request object and if |
| 873 | * successful it will complete the request on the port object then decrement |
| 874 | * its own started_request_count. enum sci_status |
| 875 | */ |
| 876 | static enum sci_status scic_sds_remote_device_ready_state_complete_request_handler( |
| 877 | struct scic_sds_remote_device *sci_dev, |
| 878 | struct scic_sds_request *request) |
| 879 | { |
| 880 | enum sci_status result; |
| 881 | |
| 882 | result = scic_sds_request_complete(request); |
| 883 | |
| 884 | if (result != SCI_SUCCESS) |
| 885 | return result; |
| 886 | |
| 887 | /* See if the port is in a state |
| 888 | * where we can start the IO request */ |
| 889 | result = scic_sds_port_complete_io( |
| 890 | scic_sds_remote_device_get_port(sci_dev), |
| 891 | sci_dev, request); |
| 892 | |
| 893 | if (result == SCI_SUCCESS) |
| 894 | scic_sds_remote_device_decrement_request_count(sci_dev); |
| 895 | |
| 896 | return result; |
| 897 | } |
| 898 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 899 | /** |
| 900 | * |
| 901 | * @device: The device object for which the request is completing. |
| 902 | * @request: The task request that is being completed. |
| 903 | * |
| 904 | * This method completes requests for this struct scic_sds_remote_device while it is |
| 905 | * in the SCI_BASE_REMOTE_DEVICE_STATE_STOPPING state. This method calls the |
| 906 | * complete method for the request object and if that is successful the port |
| 907 | * object is called to complete the task request. Then the device object itself |
| 908 | * completes the task request. If struct scic_sds_remote_device started_request_count |
| 909 | * goes to 0 and the invalidate RNC request has completed the device object can |
| 910 | * transition to the SCI_BASE_REMOTE_DEVICE_STATE_STOPPED. enum sci_status |
| 911 | */ |
| 912 | static enum sci_status scic_sds_remote_device_stopping_state_complete_request_handler( |
| 913 | struct scic_sds_remote_device *sci_dev, |
| 914 | struct scic_sds_request *request) |
| 915 | { |
| 916 | enum sci_status status = SCI_SUCCESS; |
| 917 | |
| 918 | status = scic_sds_request_complete(request); |
| 919 | |
| 920 | if (status != SCI_SUCCESS) |
| 921 | return status; |
| 922 | |
| 923 | status = scic_sds_port_complete_io(scic_sds_remote_device_get_port(sci_dev), |
| 924 | sci_dev, request); |
| 925 | if (status != SCI_SUCCESS) |
| 926 | return status; |
| 927 | |
| 928 | scic_sds_remote_device_decrement_request_count(sci_dev); |
| 929 | |
| 930 | if (scic_sds_remote_device_get_request_count(sci_dev) == 0) |
| 931 | scic_sds_remote_node_context_destruct(&sci_dev->rnc, |
Dan Williams | ec57566 | 2011-05-01 14:19:25 -0700 | [diff] [blame] | 932 | rnc_destruct_done, sci_dev); |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 933 | return SCI_SUCCESS; |
| 934 | } |
| 935 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 936 | /* complete requests for this device while it is in the |
| 937 | * SCI_BASE_REMOTE_DEVICE_STATE_RESETTING state. This method calls the complete |
| 938 | * method for the request object and if that is successful the port object is |
| 939 | * called to complete the task request. Then the device object itself completes |
| 940 | * the task request. enum sci_status |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 941 | */ |
| 942 | static enum sci_status scic_sds_remote_device_resetting_state_complete_request_handler( |
| 943 | struct scic_sds_remote_device *sci_dev, |
| 944 | struct scic_sds_request *request) |
| 945 | { |
| 946 | enum sci_status status = SCI_SUCCESS; |
| 947 | |
| 948 | status = scic_sds_request_complete(request); |
| 949 | |
| 950 | if (status == SCI_SUCCESS) { |
| 951 | status = scic_sds_port_complete_io( |
| 952 | scic_sds_remote_device_get_port(sci_dev), |
| 953 | sci_dev, request); |
| 954 | |
| 955 | if (status == SCI_SUCCESS) { |
| 956 | scic_sds_remote_device_decrement_request_count(sci_dev); |
| 957 | } |
| 958 | } |
| 959 | |
| 960 | return status; |
| 961 | } |
| 962 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 963 | static enum sci_status scic_sds_stp_remote_device_complete_request(struct scic_sds_remote_device *sci_dev, |
| 964 | struct scic_sds_request *sci_req) |
| 965 | { |
| 966 | enum sci_status status; |
| 967 | |
| 968 | status = scic_sds_io_request_complete(sci_req); |
| 969 | if (status != SCI_SUCCESS) |
| 970 | goto out; |
| 971 | |
| 972 | status = scic_sds_port_complete_io(sci_dev->owning_port, sci_dev, sci_req); |
| 973 | if (status != SCI_SUCCESS) |
| 974 | goto out; |
| 975 | |
| 976 | scic_sds_remote_device_decrement_request_count(sci_dev); |
| 977 | if (sci_req->sci_status == SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) { |
| 978 | /* This request causes hardware error, device needs to be Lun Reset. |
| 979 | * So here we force the state machine to IDLE state so the rest IOs |
| 980 | * can reach RNC state handler, these IOs will be completed by RNC with |
| 981 | * status of "DEVICE_RESET_REQUIRED", instead of "INVALID STATE". |
| 982 | */ |
| 983 | sci_base_state_machine_change_state(&sci_dev->state_machine, |
| 984 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET); |
| 985 | } else if (scic_sds_remote_device_get_request_count(sci_dev) == 0) |
| 986 | sci_base_state_machine_change_state(&sci_dev->state_machine, |
| 987 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); |
| 988 | |
| 989 | |
| 990 | out: |
| 991 | if (status != SCI_SUCCESS) |
| 992 | dev_err(scirdev_to_dev(sci_dev), |
| 993 | "%s: Port:0x%p Device:0x%p Request:0x%p Status:0x%x " |
| 994 | "could not complete\n", __func__, sci_dev->owning_port, |
| 995 | sci_dev, sci_req, status); |
| 996 | |
| 997 | return status; |
| 998 | } |
| 999 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1000 | static enum sci_status scic_sds_stp_remote_device_ready_idle_substate_event_handler( |
| 1001 | struct scic_sds_remote_device *sci_dev, |
| 1002 | u32 event_code) |
| 1003 | { |
| 1004 | enum sci_status status; |
| 1005 | |
| 1006 | status = scic_sds_remote_device_general_event_handler(sci_dev, event_code); |
| 1007 | if (status != SCI_SUCCESS) |
| 1008 | return status; |
| 1009 | |
| 1010 | /* We pick up suspension events to handle specifically to this state. We |
| 1011 | * resume the RNC right away. enum sci_status |
| 1012 | */ |
| 1013 | if (scu_get_event_type(event_code) == SCU_EVENT_TYPE_RNC_SUSPEND_TX || |
| 1014 | scu_get_event_type(event_code) == SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX) |
| 1015 | status = scic_sds_remote_node_context_resume(&sci_dev->rnc, NULL, NULL); |
| 1016 | |
| 1017 | return status; |
| 1018 | } |
| 1019 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1020 | static enum sci_status scic_sds_stp_remote_device_ready_ncq_substate_frame_handler(struct scic_sds_remote_device *sci_dev, |
| 1021 | u32 frame_index) |
| 1022 | { |
| 1023 | enum sci_status status; |
| 1024 | struct sata_fis_header *frame_header; |
| 1025 | struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller; |
| 1026 | |
| 1027 | status = scic_sds_unsolicited_frame_control_get_header(&scic->uf_control, |
| 1028 | frame_index, |
| 1029 | (void **)&frame_header); |
| 1030 | if (status != SCI_SUCCESS) |
| 1031 | return status; |
| 1032 | |
| 1033 | if (frame_header->fis_type == SATA_FIS_TYPE_SETDEVBITS && |
| 1034 | (frame_header->status & ATA_STATUS_REG_ERROR_BIT)) { |
| 1035 | sci_dev->not_ready_reason = SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED; |
| 1036 | |
| 1037 | /* TODO Check sactive and complete associated IO if any. */ |
| 1038 | |
| 1039 | sci_base_state_machine_change_state(&sci_dev->state_machine, |
| 1040 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR); |
| 1041 | } else if (frame_header->fis_type == SATA_FIS_TYPE_REGD2H && |
| 1042 | (frame_header->status & ATA_STATUS_REG_ERROR_BIT)) { |
| 1043 | /* |
| 1044 | * Some devices return D2H FIS when an NCQ error is detected. |
| 1045 | * Treat this like an SDB error FIS ready reason. |
| 1046 | */ |
| 1047 | sci_dev->not_ready_reason = SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED; |
| 1048 | |
| 1049 | sci_base_state_machine_change_state(&sci_dev->state_machine, |
| 1050 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR); |
| 1051 | } else |
| 1052 | status = SCI_FAILURE; |
| 1053 | |
| 1054 | scic_sds_controller_release_frame(scic, frame_index); |
| 1055 | |
| 1056 | return status; |
| 1057 | } |
| 1058 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1059 | static enum sci_status scic_sds_stp_remote_device_ready_cmd_substate_suspend_handler( |
| 1060 | struct scic_sds_remote_device *sci_dev, |
| 1061 | u32 suspend_type) |
| 1062 | { |
| 1063 | enum sci_status status; |
| 1064 | |
| 1065 | status = scic_sds_remote_node_context_suspend(&sci_dev->rnc, |
| 1066 | suspend_type, NULL, NULL); |
| 1067 | |
| 1068 | return status; |
| 1069 | } |
| 1070 | |
| 1071 | static enum sci_status scic_sds_stp_remote_device_ready_cmd_substate_frame_handler( |
| 1072 | struct scic_sds_remote_device *sci_dev, |
| 1073 | u32 frame_index) |
| 1074 | { |
| 1075 | /* The device doe not process any UF received from the hardware while |
| 1076 | * in this state. All unsolicited frames are forwarded to the io |
| 1077 | * request object. |
| 1078 | */ |
| 1079 | return scic_sds_io_request_frame_handler(sci_dev->working_request, |
| 1080 | frame_index); |
| 1081 | } |
| 1082 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1083 | static void scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handler(void *_dev) |
| 1084 | { |
| 1085 | struct scic_sds_remote_device *sci_dev = _dev; |
| 1086 | struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); |
| 1087 | struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller; |
| 1088 | |
| 1089 | /* For NCQ operation we do not issue a isci_remote_device_not_ready(). |
| 1090 | * As a result, avoid sending the ready notification. |
| 1091 | */ |
| 1092 | if (sci_dev->state_machine.previous_state_id != SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ) |
| 1093 | isci_remote_device_ready(scic->ihost, idev); |
| 1094 | } |
| 1095 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1096 | static enum sci_status scic_sds_smp_remote_device_ready_cmd_substate_frame_handler( |
| 1097 | struct scic_sds_remote_device *sci_dev, |
| 1098 | u32 frame_index) |
| 1099 | { |
| 1100 | enum sci_status status; |
| 1101 | |
| 1102 | /* The device does not process any UF received from the hardware while |
| 1103 | * in this state. All unsolicited frames are forwarded to the io request |
| 1104 | * object. |
| 1105 | */ |
| 1106 | status = scic_sds_io_request_frame_handler( |
| 1107 | sci_dev->working_request, |
| 1108 | frame_index |
| 1109 | ); |
| 1110 | |
| 1111 | return status; |
| 1112 | } |
| 1113 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1114 | static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_state_handler_table[] = { |
| 1115 | [SCI_BASE_REMOTE_DEVICE_STATE_INITIAL] = { |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1116 | .complete_task_handler = scic_sds_remote_device_default_complete_request_handler, |
| 1117 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, |
| 1118 | .resume_handler = scic_sds_remote_device_default_resume_handler, |
| 1119 | .event_handler = scic_sds_remote_device_default_event_handler, |
| 1120 | .frame_handler = scic_sds_remote_device_default_frame_handler |
| 1121 | }, |
| 1122 | [SCI_BASE_REMOTE_DEVICE_STATE_STOPPED] = { |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1123 | .complete_task_handler = scic_sds_remote_device_default_complete_request_handler, |
| 1124 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, |
| 1125 | .resume_handler = scic_sds_remote_device_default_resume_handler, |
| 1126 | .event_handler = scic_sds_remote_device_default_event_handler, |
| 1127 | .frame_handler = scic_sds_remote_device_default_frame_handler |
| 1128 | }, |
| 1129 | [SCI_BASE_REMOTE_DEVICE_STATE_STARTING] = { |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1130 | .complete_task_handler = scic_sds_remote_device_default_complete_request_handler, |
| 1131 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, |
| 1132 | .resume_handler = scic_sds_remote_device_default_resume_handler, |
| 1133 | .event_handler = scic_sds_remote_device_general_event_handler, |
| 1134 | .frame_handler = scic_sds_remote_device_default_frame_handler |
| 1135 | }, |
| 1136 | [SCI_BASE_REMOTE_DEVICE_STATE_READY] = { |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1137 | .complete_task_handler = scic_sds_remote_device_ready_state_complete_request_handler, |
| 1138 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, |
| 1139 | .resume_handler = scic_sds_remote_device_default_resume_handler, |
| 1140 | .event_handler = scic_sds_remote_device_general_event_handler, |
| 1141 | .frame_handler = scic_sds_remote_device_general_frame_handler, |
| 1142 | }, |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1143 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = { |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1144 | .complete_task_handler = scic_sds_remote_device_default_complete_request_handler, |
| 1145 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, |
| 1146 | .resume_handler = scic_sds_remote_device_default_resume_handler, |
| 1147 | .event_handler = scic_sds_stp_remote_device_ready_idle_substate_event_handler, |
| 1148 | .frame_handler = scic_sds_remote_device_default_frame_handler |
| 1149 | }, |
| 1150 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD] = { |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1151 | .complete_task_handler = scic_sds_stp_remote_device_complete_request, |
| 1152 | .suspend_handler = scic_sds_stp_remote_device_ready_cmd_substate_suspend_handler, |
| 1153 | .resume_handler = scic_sds_remote_device_default_resume_handler, |
| 1154 | .event_handler = scic_sds_remote_device_general_event_handler, |
| 1155 | .frame_handler = scic_sds_stp_remote_device_ready_cmd_substate_frame_handler |
| 1156 | }, |
| 1157 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ] = { |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1158 | .complete_task_handler = scic_sds_stp_remote_device_complete_request, |
| 1159 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, |
| 1160 | .resume_handler = scic_sds_remote_device_default_resume_handler, |
| 1161 | .event_handler = scic_sds_remote_device_general_event_handler, |
| 1162 | .frame_handler = scic_sds_stp_remote_device_ready_ncq_substate_frame_handler |
| 1163 | }, |
| 1164 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR] = { |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1165 | .complete_task_handler = scic_sds_stp_remote_device_complete_request, |
| 1166 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, |
| 1167 | .resume_handler = scic_sds_remote_device_default_resume_handler, |
| 1168 | .event_handler = scic_sds_remote_device_general_event_handler, |
| 1169 | .frame_handler = scic_sds_remote_device_general_frame_handler |
| 1170 | }, |
| 1171 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET] = { |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1172 | .complete_task_handler = scic_sds_stp_remote_device_complete_request, |
| 1173 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, |
| 1174 | .resume_handler = scic_sds_remote_device_default_resume_handler, |
| 1175 | .event_handler = scic_sds_remote_device_general_event_handler, |
| 1176 | .frame_handler = scic_sds_remote_device_general_frame_handler |
| 1177 | }, |
| 1178 | [SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = { |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1179 | .complete_task_handler = scic_sds_remote_device_default_complete_request_handler, |
| 1180 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, |
| 1181 | .resume_handler = scic_sds_remote_device_default_resume_handler, |
| 1182 | .event_handler = scic_sds_remote_device_general_event_handler, |
| 1183 | .frame_handler = scic_sds_remote_device_default_frame_handler |
| 1184 | }, |
| 1185 | [SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD] = { |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1186 | .complete_task_handler = scic_sds_remote_device_default_complete_request_handler, |
| 1187 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, |
| 1188 | .resume_handler = scic_sds_remote_device_default_resume_handler, |
| 1189 | .event_handler = scic_sds_remote_device_general_event_handler, |
| 1190 | .frame_handler = scic_sds_smp_remote_device_ready_cmd_substate_frame_handler |
| 1191 | }, |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1192 | [SCI_BASE_REMOTE_DEVICE_STATE_STOPPING] = { |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1193 | .complete_task_handler = scic_sds_remote_device_stopping_state_complete_request_handler, |
| 1194 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, |
| 1195 | .resume_handler = scic_sds_remote_device_default_resume_handler, |
| 1196 | .event_handler = scic_sds_remote_device_general_event_handler, |
| 1197 | .frame_handler = scic_sds_remote_device_general_frame_handler |
| 1198 | }, |
| 1199 | [SCI_BASE_REMOTE_DEVICE_STATE_FAILED] = { |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1200 | .complete_task_handler = scic_sds_remote_device_default_complete_request_handler, |
| 1201 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, |
| 1202 | .resume_handler = scic_sds_remote_device_default_resume_handler, |
| 1203 | .event_handler = scic_sds_remote_device_default_event_handler, |
| 1204 | .frame_handler = scic_sds_remote_device_general_frame_handler |
| 1205 | }, |
| 1206 | [SCI_BASE_REMOTE_DEVICE_STATE_RESETTING] = { |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1207 | .complete_task_handler = scic_sds_remote_device_resetting_state_complete_request_handler, |
| 1208 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, |
| 1209 | .resume_handler = scic_sds_remote_device_default_resume_handler, |
| 1210 | .event_handler = scic_sds_remote_device_default_event_handler, |
| 1211 | .frame_handler = scic_sds_remote_device_general_frame_handler |
| 1212 | }, |
| 1213 | [SCI_BASE_REMOTE_DEVICE_STATE_FINAL] = { |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1214 | .complete_task_handler = scic_sds_remote_device_default_complete_request_handler, |
| 1215 | .suspend_handler = scic_sds_remote_device_default_suspend_handler, |
| 1216 | .resume_handler = scic_sds_remote_device_default_resume_handler, |
| 1217 | .event_handler = scic_sds_remote_device_default_event_handler, |
| 1218 | .frame_handler = scic_sds_remote_device_default_frame_handler |
| 1219 | } |
| 1220 | }; |
| 1221 | |
Maciej Patelczyk | 9a0fff7 | 2011-04-28 22:06:01 +0000 | [diff] [blame] | 1222 | static void scic_sds_remote_device_initial_state_enter(void *object) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1223 | { |
Maciej Patelczyk | 5d937e9 | 2011-04-28 22:06:21 +0000 | [diff] [blame] | 1224 | struct scic_sds_remote_device *sci_dev = object; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1225 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1226 | SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table, |
| 1227 | SCI_BASE_REMOTE_DEVICE_STATE_INITIAL); |
| 1228 | |
| 1229 | /* Initial state is a transitional state to the stopped state */ |
| 1230 | sci_base_state_machine_change_state(&sci_dev->state_machine, |
| 1231 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED); |
| 1232 | } |
| 1233 | |
| 1234 | /** |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1235 | * scic_remote_device_destruct() - free remote node context and destruct |
| 1236 | * @remote_device: This parameter specifies the remote device to be destructed. |
| 1237 | * |
| 1238 | * Remote device objects are a limited resource. As such, they must be |
| 1239 | * protected. Thus calls to construct and destruct are mutually exclusive and |
| 1240 | * non-reentrant. The return value shall indicate if the device was |
| 1241 | * successfully destructed or if some failure occurred. enum sci_status This value |
| 1242 | * is returned if the device is successfully destructed. |
| 1243 | * SCI_FAILURE_INVALID_REMOTE_DEVICE This value is returned if the supplied |
| 1244 | * device isn't valid (e.g. it's already been destoryed, the handle isn't |
| 1245 | * valid, etc.). |
| 1246 | */ |
| 1247 | static enum sci_status scic_remote_device_destruct(struct scic_sds_remote_device *sci_dev) |
| 1248 | { |
Dan Williams | b8d82f6 | 2011-05-01 14:38:26 -0700 | [diff] [blame] | 1249 | struct sci_base_state_machine *sm = &sci_dev->state_machine; |
| 1250 | enum scic_sds_remote_device_states state = sm->current_state_id; |
| 1251 | struct scic_sds_controller *scic; |
| 1252 | |
| 1253 | if (state != SCI_BASE_REMOTE_DEVICE_STATE_STOPPED) { |
| 1254 | dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", |
| 1255 | __func__, state); |
| 1256 | return SCI_FAILURE_INVALID_STATE; |
| 1257 | } |
| 1258 | |
| 1259 | scic = sci_dev->owning_port->owning_controller; |
| 1260 | scic_sds_controller_free_remote_node_context(scic, sci_dev, |
| 1261 | sci_dev->rnc.remote_node_index); |
| 1262 | sci_dev->rnc.remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX; |
| 1263 | sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_FINAL); |
| 1264 | |
| 1265 | return SCI_SUCCESS; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1266 | } |
| 1267 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1268 | /** |
| 1269 | * isci_remote_device_deconstruct() - This function frees an isci_remote_device. |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 1270 | * @ihost: This parameter specifies the isci host object. |
| 1271 | * @idev: This parameter specifies the remote device to be freed. |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1272 | * |
| 1273 | */ |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 1274 | static void isci_remote_device_deconstruct(struct isci_host *ihost, struct isci_remote_device *idev) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1275 | { |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 1276 | dev_dbg(&ihost->pdev->dev, |
| 1277 | "%s: isci_device = %p\n", __func__, idev); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1278 | |
| 1279 | /* There should not be any outstanding io's. All paths to |
| 1280 | * here should go through isci_remote_device_nuke_requests. |
| 1281 | * If we hit this condition, we will need a way to complete |
| 1282 | * io requests in process */ |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 1283 | while (!list_empty(&idev->reqs_in_process)) { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1284 | |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 1285 | dev_err(&ihost->pdev->dev, |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1286 | "%s: ** request list not empty! **\n", __func__); |
| 1287 | BUG(); |
| 1288 | } |
| 1289 | |
Dan Williams | 57f20f4 | 2011-04-21 18:14:45 -0700 | [diff] [blame] | 1290 | scic_remote_device_destruct(&idev->sci); |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 1291 | idev->domain_dev->lldd_dev = NULL; |
| 1292 | idev->domain_dev = NULL; |
| 1293 | idev->isci_port = NULL; |
| 1294 | list_del_init(&idev->node); |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 1295 | |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 1296 | clear_bit(IDEV_START_PENDING, &idev->flags); |
| 1297 | clear_bit(IDEV_STOP_PENDING, &idev->flags); |
| 1298 | wake_up(&ihost->eventq); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1299 | } |
| 1300 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1301 | /** |
| 1302 | * isci_remote_device_stop_complete() - This function is called by the scic |
| 1303 | * when the remote device stop has completed. We mark the isci device as not |
| 1304 | * ready and remove the isci remote device. |
| 1305 | * @ihost: This parameter specifies the isci host object. |
| 1306 | * @idev: This parameter specifies the remote device. |
| 1307 | * @status: This parameter specifies status of the completion. |
| 1308 | * |
| 1309 | */ |
| 1310 | static void isci_remote_device_stop_complete(struct isci_host *ihost, |
| 1311 | struct isci_remote_device *idev) |
| 1312 | { |
| 1313 | dev_dbg(&ihost->pdev->dev, "%s: complete idev = %p\n", __func__, idev); |
| 1314 | |
| 1315 | isci_remote_device_change_state(idev, isci_stopped); |
| 1316 | |
| 1317 | /* after stop, we can tear down resources. */ |
| 1318 | isci_remote_device_deconstruct(ihost, idev); |
| 1319 | } |
| 1320 | |
Maciej Patelczyk | 9a0fff7 | 2011-04-28 22:06:01 +0000 | [diff] [blame] | 1321 | static void scic_sds_remote_device_stopped_state_enter(void *object) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1322 | { |
Maciej Patelczyk | 5d937e9 | 2011-04-28 22:06:21 +0000 | [diff] [blame] | 1323 | struct scic_sds_remote_device *sci_dev = object; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1324 | struct scic_sds_controller *scic; |
| 1325 | struct isci_remote_device *idev; |
| 1326 | struct isci_host *ihost; |
| 1327 | u32 prev_state; |
| 1328 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1329 | scic = scic_sds_remote_device_get_controller(sci_dev); |
Maciej Patelczyk | d3757c3 | 2011-04-28 22:06:06 +0000 | [diff] [blame] | 1330 | ihost = scic->ihost; |
Maciej Patelczyk | 5d937e9 | 2011-04-28 22:06:21 +0000 | [diff] [blame] | 1331 | idev = sci_dev_to_idev(sci_dev); |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1332 | |
| 1333 | SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table, |
| 1334 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED); |
| 1335 | |
| 1336 | /* If we are entering from the stopping state let the SCI User know that |
| 1337 | * the stop operation has completed. |
| 1338 | */ |
| 1339 | prev_state = sci_dev->state_machine.previous_state_id; |
| 1340 | if (prev_state == SCI_BASE_REMOTE_DEVICE_STATE_STOPPING) |
| 1341 | isci_remote_device_stop_complete(ihost, idev); |
| 1342 | |
| 1343 | scic_sds_controller_remote_device_stopped(scic, sci_dev); |
| 1344 | } |
| 1345 | |
Maciej Patelczyk | 9a0fff7 | 2011-04-28 22:06:01 +0000 | [diff] [blame] | 1346 | static void scic_sds_remote_device_starting_state_enter(void *object) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1347 | { |
Maciej Patelczyk | 5d937e9 | 2011-04-28 22:06:21 +0000 | [diff] [blame] | 1348 | struct scic_sds_remote_device *sci_dev = object; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1349 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); |
Maciej Patelczyk | d3757c3 | 2011-04-28 22:06:06 +0000 | [diff] [blame] | 1350 | struct isci_host *ihost = scic->ihost; |
Maciej Patelczyk | 5d937e9 | 2011-04-28 22:06:21 +0000 | [diff] [blame] | 1351 | struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1352 | |
| 1353 | SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table, |
| 1354 | SCI_BASE_REMOTE_DEVICE_STATE_STARTING); |
| 1355 | |
| 1356 | isci_remote_device_not_ready(ihost, idev, |
| 1357 | SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED); |
| 1358 | } |
| 1359 | |
Maciej Patelczyk | 9a0fff7 | 2011-04-28 22:06:01 +0000 | [diff] [blame] | 1360 | static void scic_sds_remote_device_ready_state_enter(void *object) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1361 | { |
Maciej Patelczyk | 5d937e9 | 2011-04-28 22:06:21 +0000 | [diff] [blame] | 1362 | struct scic_sds_remote_device *sci_dev = object; |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1363 | struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller; |
| 1364 | struct domain_device *dev = sci_dev_to_domain(sci_dev); |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1365 | |
| 1366 | SET_STATE_HANDLER(sci_dev, |
| 1367 | scic_sds_remote_device_state_handler_table, |
| 1368 | SCI_BASE_REMOTE_DEVICE_STATE_READY); |
| 1369 | |
| 1370 | scic->remote_device_sequence[sci_dev->rnc.remote_node_index]++; |
| 1371 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1372 | if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_SATA)) { |
| 1373 | sci_base_state_machine_change_state(&sci_dev->state_machine, |
| 1374 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); |
| 1375 | } else if (dev_is_expander(dev)) { |
| 1376 | sci_base_state_machine_change_state(&sci_dev->state_machine, |
| 1377 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); |
| 1378 | } else |
| 1379 | isci_remote_device_ready(scic->ihost, sci_dev_to_idev(sci_dev)); |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1380 | } |
| 1381 | |
Maciej Patelczyk | 9a0fff7 | 2011-04-28 22:06:01 +0000 | [diff] [blame] | 1382 | static void scic_sds_remote_device_ready_state_exit(void *object) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1383 | { |
Maciej Patelczyk | 5d937e9 | 2011-04-28 22:06:21 +0000 | [diff] [blame] | 1384 | struct scic_sds_remote_device *sci_dev = object; |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1385 | struct domain_device *dev = sci_dev_to_domain(sci_dev); |
| 1386 | |
| 1387 | if (dev->dev_type == SAS_END_DEV) { |
| 1388 | struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller; |
Maciej Patelczyk | 5d937e9 | 2011-04-28 22:06:21 +0000 | [diff] [blame] | 1389 | struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1390 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1391 | isci_remote_device_not_ready(scic->ihost, idev, |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1392 | SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED); |
| 1393 | } |
| 1394 | } |
| 1395 | |
Maciej Patelczyk | 9a0fff7 | 2011-04-28 22:06:01 +0000 | [diff] [blame] | 1396 | static void scic_sds_remote_device_stopping_state_enter(void *object) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1397 | { |
Maciej Patelczyk | 5d937e9 | 2011-04-28 22:06:21 +0000 | [diff] [blame] | 1398 | struct scic_sds_remote_device *sci_dev = object; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1399 | |
| 1400 | SET_STATE_HANDLER( |
| 1401 | sci_dev, |
| 1402 | scic_sds_remote_device_state_handler_table, |
| 1403 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING |
| 1404 | ); |
| 1405 | } |
| 1406 | |
Maciej Patelczyk | 9a0fff7 | 2011-04-28 22:06:01 +0000 | [diff] [blame] | 1407 | static void scic_sds_remote_device_failed_state_enter(void *object) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1408 | { |
Maciej Patelczyk | 5d937e9 | 2011-04-28 22:06:21 +0000 | [diff] [blame] | 1409 | struct scic_sds_remote_device *sci_dev = object; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1410 | |
| 1411 | SET_STATE_HANDLER( |
| 1412 | sci_dev, |
| 1413 | scic_sds_remote_device_state_handler_table, |
| 1414 | SCI_BASE_REMOTE_DEVICE_STATE_FAILED |
| 1415 | ); |
| 1416 | } |
| 1417 | |
Maciej Patelczyk | 9a0fff7 | 2011-04-28 22:06:01 +0000 | [diff] [blame] | 1418 | static void scic_sds_remote_device_resetting_state_enter(void *object) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1419 | { |
Maciej Patelczyk | 5d937e9 | 2011-04-28 22:06:21 +0000 | [diff] [blame] | 1420 | struct scic_sds_remote_device *sci_dev = object; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1421 | |
| 1422 | SET_STATE_HANDLER( |
| 1423 | sci_dev, |
| 1424 | scic_sds_remote_device_state_handler_table, |
| 1425 | SCI_BASE_REMOTE_DEVICE_STATE_RESETTING |
| 1426 | ); |
| 1427 | |
| 1428 | scic_sds_remote_node_context_suspend( |
| 1429 | &sci_dev->rnc, SCI_SOFTWARE_SUSPENSION, NULL, NULL); |
| 1430 | } |
| 1431 | |
Maciej Patelczyk | 9a0fff7 | 2011-04-28 22:06:01 +0000 | [diff] [blame] | 1432 | static void scic_sds_remote_device_resetting_state_exit(void *object) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1433 | { |
Maciej Patelczyk | 5d937e9 | 2011-04-28 22:06:21 +0000 | [diff] [blame] | 1434 | struct scic_sds_remote_device *sci_dev = object; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1435 | |
| 1436 | scic_sds_remote_node_context_resume(&sci_dev->rnc, NULL, NULL); |
| 1437 | } |
| 1438 | |
Maciej Patelczyk | 9a0fff7 | 2011-04-28 22:06:01 +0000 | [diff] [blame] | 1439 | static void scic_sds_remote_device_final_state_enter(void *object) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1440 | { |
Maciej Patelczyk | 5d937e9 | 2011-04-28 22:06:21 +0000 | [diff] [blame] | 1441 | struct scic_sds_remote_device *sci_dev = object; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1442 | |
| 1443 | SET_STATE_HANDLER( |
| 1444 | sci_dev, |
| 1445 | scic_sds_remote_device_state_handler_table, |
| 1446 | SCI_BASE_REMOTE_DEVICE_STATE_FINAL |
| 1447 | ); |
| 1448 | } |
| 1449 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1450 | static void scic_sds_stp_remote_device_ready_idle_substate_enter(void *object) |
| 1451 | { |
| 1452 | struct scic_sds_remote_device *sci_dev = object; |
| 1453 | |
| 1454 | SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table, |
| 1455 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); |
| 1456 | |
| 1457 | sci_dev->working_request = NULL; |
| 1458 | if (scic_sds_remote_node_context_is_ready(&sci_dev->rnc)) { |
| 1459 | /* |
| 1460 | * Since the RNC is ready, it's alright to finish completion |
| 1461 | * processing (e.g. signal the remote device is ready). */ |
| 1462 | scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handler(sci_dev); |
| 1463 | } else { |
| 1464 | scic_sds_remote_node_context_resume(&sci_dev->rnc, |
| 1465 | scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handler, |
| 1466 | sci_dev); |
| 1467 | } |
| 1468 | } |
| 1469 | |
| 1470 | static void scic_sds_stp_remote_device_ready_cmd_substate_enter(void *object) |
| 1471 | { |
| 1472 | struct scic_sds_remote_device *sci_dev = object; |
| 1473 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); |
| 1474 | |
| 1475 | BUG_ON(sci_dev->working_request == NULL); |
| 1476 | |
| 1477 | SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table, |
| 1478 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD); |
| 1479 | |
| 1480 | isci_remote_device_not_ready(scic->ihost, sci_dev_to_idev(sci_dev), |
| 1481 | SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED); |
| 1482 | } |
| 1483 | |
| 1484 | static void scic_sds_stp_remote_device_ready_ncq_substate_enter(void *object) |
| 1485 | { |
| 1486 | struct scic_sds_remote_device *sci_dev = object; |
| 1487 | |
| 1488 | SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table, |
| 1489 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ); |
| 1490 | } |
| 1491 | |
| 1492 | static void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(void *object) |
| 1493 | { |
| 1494 | struct scic_sds_remote_device *sci_dev = object; |
| 1495 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); |
| 1496 | struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); |
| 1497 | |
| 1498 | SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table, |
| 1499 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR); |
| 1500 | |
| 1501 | if (sci_dev->not_ready_reason == SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED) |
| 1502 | isci_remote_device_not_ready(scic->ihost, idev, |
| 1503 | sci_dev->not_ready_reason); |
| 1504 | } |
| 1505 | |
| 1506 | static void scic_sds_stp_remote_device_ready_await_reset_substate_enter(void *object) |
| 1507 | { |
| 1508 | struct scic_sds_remote_device *sci_dev = object; |
| 1509 | |
| 1510 | SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table, |
| 1511 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET); |
| 1512 | } |
| 1513 | |
| 1514 | static void scic_sds_smp_remote_device_ready_idle_substate_enter(void *object) |
| 1515 | { |
| 1516 | struct scic_sds_remote_device *sci_dev = object; |
| 1517 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); |
| 1518 | |
| 1519 | SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table, |
| 1520 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); |
| 1521 | |
| 1522 | isci_remote_device_ready(scic->ihost, sci_dev_to_idev(sci_dev)); |
| 1523 | } |
| 1524 | |
| 1525 | static void scic_sds_smp_remote_device_ready_cmd_substate_enter(void *object) |
| 1526 | { |
| 1527 | struct scic_sds_remote_device *sci_dev = object; |
| 1528 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); |
| 1529 | |
| 1530 | BUG_ON(sci_dev->working_request == NULL); |
| 1531 | |
| 1532 | SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table, |
| 1533 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD); |
| 1534 | |
| 1535 | isci_remote_device_not_ready(scic->ihost, sci_dev_to_idev(sci_dev), |
| 1536 | SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED); |
| 1537 | } |
| 1538 | |
| 1539 | static void scic_sds_smp_remote_device_ready_cmd_substate_exit(void *object) |
| 1540 | { |
| 1541 | struct scic_sds_remote_device *sci_dev = object; |
| 1542 | |
| 1543 | sci_dev->working_request = NULL; |
| 1544 | } |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1545 | |
| 1546 | static const struct sci_base_state scic_sds_remote_device_state_table[] = { |
| 1547 | [SCI_BASE_REMOTE_DEVICE_STATE_INITIAL] = { |
| 1548 | .enter_state = scic_sds_remote_device_initial_state_enter, |
| 1549 | }, |
| 1550 | [SCI_BASE_REMOTE_DEVICE_STATE_STOPPED] = { |
| 1551 | .enter_state = scic_sds_remote_device_stopped_state_enter, |
| 1552 | }, |
| 1553 | [SCI_BASE_REMOTE_DEVICE_STATE_STARTING] = { |
| 1554 | .enter_state = scic_sds_remote_device_starting_state_enter, |
| 1555 | }, |
| 1556 | [SCI_BASE_REMOTE_DEVICE_STATE_READY] = { |
| 1557 | .enter_state = scic_sds_remote_device_ready_state_enter, |
| 1558 | .exit_state = scic_sds_remote_device_ready_state_exit |
| 1559 | }, |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1560 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = { |
| 1561 | .enter_state = scic_sds_stp_remote_device_ready_idle_substate_enter, |
| 1562 | }, |
| 1563 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD] = { |
| 1564 | .enter_state = scic_sds_stp_remote_device_ready_cmd_substate_enter, |
| 1565 | }, |
| 1566 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ] = { |
| 1567 | .enter_state = scic_sds_stp_remote_device_ready_ncq_substate_enter, |
| 1568 | }, |
| 1569 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR] = { |
| 1570 | .enter_state = scic_sds_stp_remote_device_ready_ncq_error_substate_enter, |
| 1571 | }, |
| 1572 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET] = { |
| 1573 | .enter_state = scic_sds_stp_remote_device_ready_await_reset_substate_enter, |
| 1574 | }, |
| 1575 | [SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = { |
| 1576 | .enter_state = scic_sds_smp_remote_device_ready_idle_substate_enter, |
| 1577 | }, |
| 1578 | [SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD] = { |
| 1579 | .enter_state = scic_sds_smp_remote_device_ready_cmd_substate_enter, |
| 1580 | .exit_state = scic_sds_smp_remote_device_ready_cmd_substate_exit, |
| 1581 | }, |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1582 | [SCI_BASE_REMOTE_DEVICE_STATE_STOPPING] = { |
| 1583 | .enter_state = scic_sds_remote_device_stopping_state_enter, |
| 1584 | }, |
| 1585 | [SCI_BASE_REMOTE_DEVICE_STATE_FAILED] = { |
| 1586 | .enter_state = scic_sds_remote_device_failed_state_enter, |
| 1587 | }, |
| 1588 | [SCI_BASE_REMOTE_DEVICE_STATE_RESETTING] = { |
| 1589 | .enter_state = scic_sds_remote_device_resetting_state_enter, |
| 1590 | .exit_state = scic_sds_remote_device_resetting_state_exit |
| 1591 | }, |
| 1592 | [SCI_BASE_REMOTE_DEVICE_STATE_FINAL] = { |
| 1593 | .enter_state = scic_sds_remote_device_final_state_enter, |
| 1594 | }, |
| 1595 | }; |
| 1596 | |
| 1597 | /** |
Dan Williams | b87ee30 | 2011-04-25 11:48:29 -0700 | [diff] [blame] | 1598 | * scic_remote_device_construct() - common construction |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1599 | * @sci_port: SAS/SATA port through which this device is accessed. |
| 1600 | * @sci_dev: remote device to construct |
| 1601 | * |
Dan Williams | b87ee30 | 2011-04-25 11:48:29 -0700 | [diff] [blame] | 1602 | * This routine just performs benign initialization and does not |
| 1603 | * allocate the remote_node_context which is left to |
| 1604 | * scic_remote_device_[de]a_construct(). scic_remote_device_destruct() |
| 1605 | * frees the remote_node_context(s) for the device. |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1606 | */ |
| 1607 | static void scic_remote_device_construct(struct scic_sds_port *sci_port, |
| 1608 | struct scic_sds_remote_device *sci_dev) |
| 1609 | { |
| 1610 | sci_dev->owning_port = sci_port; |
| 1611 | sci_dev->started_request_count = 0; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1612 | |
| 1613 | sci_base_state_machine_construct( |
| 1614 | &sci_dev->state_machine, |
Maciej Patelczyk | 5d937e9 | 2011-04-28 22:06:21 +0000 | [diff] [blame] | 1615 | sci_dev, |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1616 | scic_sds_remote_device_state_table, |
| 1617 | SCI_BASE_REMOTE_DEVICE_STATE_INITIAL |
| 1618 | ); |
| 1619 | |
| 1620 | sci_base_state_machine_start( |
| 1621 | &sci_dev->state_machine |
| 1622 | ); |
| 1623 | |
| 1624 | scic_sds_remote_node_context_construct(&sci_dev->rnc, |
| 1625 | SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX); |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1626 | } |
| 1627 | |
| 1628 | /** |
Dan Williams | b87ee30 | 2011-04-25 11:48:29 -0700 | [diff] [blame] | 1629 | * scic_remote_device_da_construct() - construct direct attached device. |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1630 | * |
Dan Williams | b87ee30 | 2011-04-25 11:48:29 -0700 | [diff] [blame] | 1631 | * The information (e.g. IAF, Signature FIS, etc.) necessary to build |
| 1632 | * the device is known to the SCI Core since it is contained in the |
| 1633 | * scic_phy object. Remote node context(s) is/are a global resource |
| 1634 | * allocated by this routine, freed by scic_remote_device_destruct(). |
| 1635 | * |
| 1636 | * Returns: |
| 1637 | * SCI_FAILURE_DEVICE_EXISTS - device has already been constructed. |
| 1638 | * SCI_FAILURE_UNSUPPORTED_PROTOCOL - e.g. sas device attached to |
| 1639 | * sata-only controller instance. |
| 1640 | * SCI_FAILURE_INSUFFICIENT_RESOURCES - remote node contexts exhausted. |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1641 | */ |
Dan Williams | b87ee30 | 2011-04-25 11:48:29 -0700 | [diff] [blame] | 1642 | static enum sci_status scic_remote_device_da_construct(struct scic_sds_port *sci_port, |
| 1643 | struct scic_sds_remote_device *sci_dev) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1644 | { |
| 1645 | enum sci_status status; |
Dan Williams | a1a113b | 2011-04-21 18:44:45 -0700 | [diff] [blame] | 1646 | struct domain_device *dev = sci_dev_to_domain(sci_dev); |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1647 | |
Dan Williams | b87ee30 | 2011-04-25 11:48:29 -0700 | [diff] [blame] | 1648 | scic_remote_device_construct(sci_port, sci_dev); |
| 1649 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1650 | /* |
| 1651 | * This information is request to determine how many remote node context |
| 1652 | * entries will be needed to store the remote node. |
| 1653 | */ |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1654 | sci_dev->is_direct_attached = true; |
Dan Williams | a1a113b | 2011-04-21 18:44:45 -0700 | [diff] [blame] | 1655 | status = scic_sds_controller_allocate_remote_node_context(sci_port->owning_controller, |
| 1656 | sci_dev, |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1657 | &sci_dev->rnc.remote_node_index); |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1658 | |
Dan Williams | a1a113b | 2011-04-21 18:44:45 -0700 | [diff] [blame] | 1659 | if (status != SCI_SUCCESS) |
| 1660 | return status; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1661 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1662 | if (dev->dev_type == SAS_END_DEV || dev->dev_type == SATA_DEV || |
| 1663 | (dev->tproto & SAS_PROTOCOL_STP) || dev_is_expander(dev)) |
| 1664 | /* pass */; |
| 1665 | else |
Dan Williams | a1a113b | 2011-04-21 18:44:45 -0700 | [diff] [blame] | 1666 | return SCI_FAILURE_UNSUPPORTED_PROTOCOL; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1667 | |
Dan Williams | a1a113b | 2011-04-21 18:44:45 -0700 | [diff] [blame] | 1668 | sci_dev->connection_rate = scic_sds_port_get_max_allowed_speed(sci_port); |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1669 | |
Dan Williams | a1a113b | 2011-04-21 18:44:45 -0700 | [diff] [blame] | 1670 | /* / @todo Should I assign the port width by reading all of the phys on the port? */ |
| 1671 | sci_dev->device_port_width = 1; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1672 | |
Dan Williams | a1a113b | 2011-04-21 18:44:45 -0700 | [diff] [blame] | 1673 | return SCI_SUCCESS; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1674 | } |
| 1675 | |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1676 | /** |
Dan Williams | b87ee30 | 2011-04-25 11:48:29 -0700 | [diff] [blame] | 1677 | * scic_remote_device_ea_construct() - construct expander attached device |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1678 | * |
Dan Williams | b87ee30 | 2011-04-25 11:48:29 -0700 | [diff] [blame] | 1679 | * Remote node context(s) is/are a global resource allocated by this |
| 1680 | * routine, freed by scic_remote_device_destruct(). |
| 1681 | * |
| 1682 | * Returns: |
| 1683 | * SCI_FAILURE_DEVICE_EXISTS - device has already been constructed. |
| 1684 | * SCI_FAILURE_UNSUPPORTED_PROTOCOL - e.g. sas device attached to |
| 1685 | * sata-only controller instance. |
| 1686 | * SCI_FAILURE_INSUFFICIENT_RESOURCES - remote node contexts exhausted. |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1687 | */ |
Dan Williams | b87ee30 | 2011-04-25 11:48:29 -0700 | [diff] [blame] | 1688 | static enum sci_status scic_remote_device_ea_construct(struct scic_sds_port *sci_port, |
Dan Williams | 00d680e | 2011-04-25 14:29:29 -0700 | [diff] [blame] | 1689 | struct scic_sds_remote_device *sci_dev) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1690 | { |
Dan Williams | a1a113b | 2011-04-21 18:44:45 -0700 | [diff] [blame] | 1691 | struct domain_device *dev = sci_dev_to_domain(sci_dev); |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1692 | enum sci_status status; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1693 | |
Dan Williams | b87ee30 | 2011-04-25 11:48:29 -0700 | [diff] [blame] | 1694 | scic_remote_device_construct(sci_port, sci_dev); |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1695 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1696 | status = scic_sds_controller_allocate_remote_node_context(sci_port->owning_controller, |
| 1697 | sci_dev, |
| 1698 | &sci_dev->rnc.remote_node_index); |
Dan Williams | a1a113b | 2011-04-21 18:44:45 -0700 | [diff] [blame] | 1699 | if (status != SCI_SUCCESS) |
| 1700 | return status; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1701 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1702 | if (dev->dev_type == SAS_END_DEV || dev->dev_type == SATA_DEV || |
| 1703 | (dev->tproto & SAS_PROTOCOL_STP) || dev_is_expander(dev)) |
| 1704 | /* pass */; |
| 1705 | else |
| 1706 | return SCI_FAILURE_UNSUPPORTED_PROTOCOL; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1707 | |
Dan Williams | a1a113b | 2011-04-21 18:44:45 -0700 | [diff] [blame] | 1708 | /* |
| 1709 | * For SAS-2 the physical link rate is actually a logical link |
| 1710 | * rate that incorporates multiplexing. The SCU doesn't |
| 1711 | * incorporate multiplexing and for the purposes of the |
| 1712 | * connection the logical link rate is that same as the |
| 1713 | * physical. Furthermore, the SAS-2 and SAS-1.1 fields overlay |
| 1714 | * one another, so this code works for both situations. */ |
| 1715 | sci_dev->connection_rate = min_t(u16, scic_sds_port_get_max_allowed_speed(sci_port), |
Dan Williams | 00d680e | 2011-04-25 14:29:29 -0700 | [diff] [blame] | 1716 | dev->linkrate); |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1717 | |
Dan Williams | a1a113b | 2011-04-21 18:44:45 -0700 | [diff] [blame] | 1718 | /* / @todo Should I assign the port width by reading all of the phys on the port? */ |
| 1719 | sci_dev->device_port_width = 1; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1720 | |
Dan Williams | ab2e8f7 | 2011-04-27 16:32:45 -0700 | [diff] [blame] | 1721 | return SCI_SUCCESS; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1722 | } |
| 1723 | |
| 1724 | /** |
| 1725 | * scic_remote_device_start() - This method will start the supplied remote |
| 1726 | * device. This method enables normal IO requests to flow through to the |
| 1727 | * remote device. |
| 1728 | * @remote_device: This parameter specifies the device to be started. |
| 1729 | * @timeout: This parameter specifies the number of milliseconds in which the |
| 1730 | * start operation should complete. |
| 1731 | * |
| 1732 | * An indication of whether the device was successfully started. SCI_SUCCESS |
| 1733 | * This value is returned if the device was successfully started. |
| 1734 | * SCI_FAILURE_INVALID_PHY This value is returned if the user attempts to start |
| 1735 | * the device when there have been no phys added to it. |
| 1736 | */ |
| 1737 | static enum sci_status scic_remote_device_start(struct scic_sds_remote_device *sci_dev, |
Dan Williams | eb22967 | 2011-05-01 14:05:57 -0700 | [diff] [blame] | 1738 | u32 timeout) |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1739 | { |
Dan Williams | eb22967 | 2011-05-01 14:05:57 -0700 | [diff] [blame] | 1740 | struct sci_base_state_machine *sm = &sci_dev->state_machine; |
| 1741 | enum scic_sds_remote_device_states state = sm->current_state_id; |
| 1742 | enum sci_status status; |
| 1743 | |
| 1744 | if (state != SCI_BASE_REMOTE_DEVICE_STATE_STOPPED) { |
| 1745 | dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", |
| 1746 | __func__, state); |
| 1747 | return SCI_FAILURE_INVALID_STATE; |
| 1748 | } |
| 1749 | |
| 1750 | status = scic_sds_remote_node_context_resume(&sci_dev->rnc, |
| 1751 | remote_device_resume_done, |
| 1752 | sci_dev); |
| 1753 | if (status != SCI_SUCCESS) |
| 1754 | return status; |
| 1755 | |
| 1756 | sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_STARTING); |
| 1757 | |
| 1758 | return SCI_SUCCESS; |
Dan Williams | 88f3b62 | 2011-04-22 19:18:03 -0700 | [diff] [blame] | 1759 | } |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1760 | |
Dan Williams | 00d680e | 2011-04-25 14:29:29 -0700 | [diff] [blame] | 1761 | static enum sci_status isci_remote_device_construct(struct isci_port *iport, |
| 1762 | struct isci_remote_device *idev) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1763 | { |
Dan Williams | 00d680e | 2011-04-25 14:29:29 -0700 | [diff] [blame] | 1764 | struct scic_sds_port *sci_port = iport->sci_port_handle; |
| 1765 | struct isci_host *ihost = iport->isci_host; |
| 1766 | struct domain_device *dev = idev->domain_dev; |
| 1767 | enum sci_status status; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1768 | |
Dan Williams | 00d680e | 2011-04-25 14:29:29 -0700 | [diff] [blame] | 1769 | if (dev->parent && dev_is_expander(dev->parent)) |
| 1770 | status = scic_remote_device_ea_construct(sci_port, &idev->sci); |
| 1771 | else |
| 1772 | status = scic_remote_device_da_construct(sci_port, &idev->sci); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1773 | |
| 1774 | if (status != SCI_SUCCESS) { |
Dan Williams | 00d680e | 2011-04-25 14:29:29 -0700 | [diff] [blame] | 1775 | dev_dbg(&ihost->pdev->dev, "%s: construct failed: %d\n", |
| 1776 | __func__, status); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1777 | |
| 1778 | return status; |
| 1779 | } |
| 1780 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1781 | /* start the device. */ |
Dan Williams | 00d680e | 2011-04-25 14:29:29 -0700 | [diff] [blame] | 1782 | status = scic_remote_device_start(&idev->sci, ISCI_REMOTE_DEVICE_START_TIMEOUT); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1783 | |
Dan Williams | 00d680e | 2011-04-25 14:29:29 -0700 | [diff] [blame] | 1784 | if (status != SCI_SUCCESS) |
| 1785 | dev_warn(&ihost->pdev->dev, "remote device start failed: %d\n", |
| 1786 | status); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1787 | |
| 1788 | return status; |
| 1789 | } |
| 1790 | |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 1791 | void isci_remote_device_nuke_requests(struct isci_host *ihost, struct isci_remote_device *idev) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1792 | { |
| 1793 | DECLARE_COMPLETION_ONSTACK(aborted_task_completion); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1794 | |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 1795 | dev_dbg(&ihost->pdev->dev, |
| 1796 | "%s: idev = %p\n", __func__, idev); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1797 | |
| 1798 | /* Cleanup all requests pending for this device. */ |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 1799 | isci_terminate_pending_requests(ihost, idev, terminating); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1800 | |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 1801 | dev_dbg(&ihost->pdev->dev, |
| 1802 | "%s: idev = %p, done\n", __func__, idev); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1803 | } |
| 1804 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1805 | /** |
| 1806 | * This function builds the isci_remote_device when a libsas dev_found message |
| 1807 | * is received. |
| 1808 | * @isci_host: This parameter specifies the isci host object. |
| 1809 | * @port: This parameter specifies the isci_port conected to this device. |
| 1810 | * |
| 1811 | * pointer to new isci_remote_device. |
| 1812 | */ |
| 1813 | static struct isci_remote_device * |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 1814 | isci_remote_device_alloc(struct isci_host *ihost, struct isci_port *iport) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1815 | { |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 1816 | struct isci_remote_device *idev; |
| 1817 | int i; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1818 | |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 1819 | for (i = 0; i < SCI_MAX_REMOTE_DEVICES; i++) { |
Dan Williams | 57f20f4 | 2011-04-21 18:14:45 -0700 | [diff] [blame] | 1820 | idev = &ihost->devices[i]; |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 1821 | if (!test_and_set_bit(IDEV_ALLOCATED, &idev->flags)) |
| 1822 | break; |
| 1823 | } |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1824 | |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 1825 | if (i >= SCI_MAX_REMOTE_DEVICES) { |
| 1826 | dev_warn(&ihost->pdev->dev, "%s: failed\n", __func__); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1827 | return NULL; |
| 1828 | } |
| 1829 | |
Bartosz Barcinski | 6cb4d6b | 2011-04-12 17:28:43 -0700 | [diff] [blame] | 1830 | if (WARN_ONCE(!list_empty(&idev->reqs_in_process), "found requests in process\n")) |
| 1831 | return NULL; |
| 1832 | |
| 1833 | if (WARN_ONCE(!list_empty(&idev->node), "found non-idle remote device\n")) |
| 1834 | return NULL; |
| 1835 | |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 1836 | isci_remote_device_change_state(idev, isci_freed); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1837 | |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 1838 | return idev; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1839 | } |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1840 | |
| 1841 | /** |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1842 | * isci_remote_device_stop() - This function is called internally to stop the |
| 1843 | * remote device. |
| 1844 | * @isci_host: This parameter specifies the isci host object. |
| 1845 | * @isci_device: This parameter specifies the remote device. |
| 1846 | * |
| 1847 | * The status of the scic request to stop. |
| 1848 | */ |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 1849 | enum sci_status isci_remote_device_stop(struct isci_host *ihost, struct isci_remote_device *idev) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1850 | { |
| 1851 | enum sci_status status; |
| 1852 | unsigned long flags; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1853 | |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 1854 | dev_dbg(&ihost->pdev->dev, |
| 1855 | "%s: isci_device = %p\n", __func__, idev); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1856 | |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 1857 | isci_remote_device_change_state(idev, isci_stopping); |
Jeff Skirvin | 6e2802a | 2011-03-08 20:32:16 -0700 | [diff] [blame] | 1858 | |
| 1859 | /* Kill all outstanding requests. */ |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 1860 | isci_remote_device_nuke_requests(ihost, idev); |
Jeff Skirvin | 6e2802a | 2011-03-08 20:32:16 -0700 | [diff] [blame] | 1861 | |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 1862 | set_bit(IDEV_STOP_PENDING, &idev->flags); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1863 | |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 1864 | spin_lock_irqsave(&ihost->scic_lock, flags); |
Dan Williams | 57f20f4 | 2011-04-21 18:14:45 -0700 | [diff] [blame] | 1865 | status = scic_remote_device_stop(&idev->sci, 50); |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 1866 | spin_unlock_irqrestore(&ihost->scic_lock, flags); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1867 | |
| 1868 | /* Wait for the stop complete callback. */ |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 1869 | if (status == SCI_SUCCESS) { |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 1870 | wait_for_device_stop(ihost, idev); |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 1871 | clear_bit(IDEV_ALLOCATED, &idev->flags); |
| 1872 | } |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1873 | |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 1874 | dev_dbg(&ihost->pdev->dev, |
| 1875 | "%s: idev = %p - after completion wait\n", |
| 1876 | __func__, idev); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1877 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1878 | return status; |
| 1879 | } |
| 1880 | |
| 1881 | /** |
| 1882 | * isci_remote_device_gone() - This function is called by libsas when a domain |
| 1883 | * device is removed. |
| 1884 | * @domain_device: This parameter specifies the libsas domain device. |
| 1885 | * |
| 1886 | */ |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 1887 | void isci_remote_device_gone(struct domain_device *dev) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1888 | { |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 1889 | struct isci_host *ihost = dev_to_ihost(dev); |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 1890 | struct isci_remote_device *idev = dev->lldd_dev; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1891 | |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 1892 | dev_dbg(&ihost->pdev->dev, |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1893 | "%s: domain_device = %p, isci_device = %p, isci_port = %p\n", |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 1894 | __func__, dev, idev, idev->isci_port); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1895 | |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 1896 | isci_remote_device_stop(ihost, idev); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1897 | } |
| 1898 | |
| 1899 | |
| 1900 | /** |
| 1901 | * isci_remote_device_found() - This function is called by libsas when a remote |
| 1902 | * device is discovered. A remote device object is created and started. the |
| 1903 | * function then sleeps until the sci core device started message is |
| 1904 | * received. |
| 1905 | * @domain_device: This parameter specifies the libsas domain device. |
| 1906 | * |
| 1907 | * status, zero indicates success. |
| 1908 | */ |
| 1909 | int isci_remote_device_found(struct domain_device *domain_dev) |
| 1910 | { |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 1911 | struct isci_host *isci_host = dev_to_ihost(domain_dev); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1912 | struct isci_port *isci_port; |
| 1913 | struct isci_phy *isci_phy; |
| 1914 | struct asd_sas_port *sas_port; |
| 1915 | struct asd_sas_phy *sas_phy; |
| 1916 | struct isci_remote_device *isci_device; |
| 1917 | enum sci_status status; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1918 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1919 | dev_dbg(&isci_host->pdev->dev, |
| 1920 | "%s: domain_device = %p\n", __func__, domain_dev); |
| 1921 | |
Dan Williams | 0cf89d1 | 2011-02-18 09:25:07 -0800 | [diff] [blame] | 1922 | wait_for_start(isci_host); |
| 1923 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1924 | sas_port = domain_dev->port; |
| 1925 | sas_phy = list_first_entry(&sas_port->phy_list, struct asd_sas_phy, |
| 1926 | port_phy_el); |
| 1927 | isci_phy = to_isci_phy(sas_phy); |
| 1928 | isci_port = isci_phy->isci_port; |
| 1929 | |
| 1930 | /* we are being called for a device on this port, |
| 1931 | * so it has to come up eventually |
| 1932 | */ |
| 1933 | wait_for_completion(&isci_port->start_complete); |
| 1934 | |
| 1935 | if ((isci_stopping == isci_port_get_state(isci_port)) || |
| 1936 | (isci_stopped == isci_port_get_state(isci_port))) |
| 1937 | return -ENODEV; |
| 1938 | |
| 1939 | isci_device = isci_remote_device_alloc(isci_host, isci_port); |
Dan Williams | d9c3739 | 2011-03-03 17:59:32 -0800 | [diff] [blame] | 1940 | if (!isci_device) |
| 1941 | return -ENODEV; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1942 | |
| 1943 | INIT_LIST_HEAD(&isci_device->node); |
| 1944 | domain_dev->lldd_dev = isci_device; |
| 1945 | isci_device->domain_dev = domain_dev; |
| 1946 | isci_device->isci_port = isci_port; |
| 1947 | isci_remote_device_change_state(isci_device, isci_starting); |
| 1948 | |
| 1949 | |
Dan Williams | 1a38045 | 2011-03-03 18:01:43 -0800 | [diff] [blame] | 1950 | spin_lock_irq(&isci_host->scic_lock); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1951 | list_add_tail(&isci_device->node, &isci_port->remote_dev_list); |
| 1952 | |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 1953 | set_bit(IDEV_START_PENDING, &isci_device->flags); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1954 | status = isci_remote_device_construct(isci_port, isci_device); |
Dan Williams | 1a38045 | 2011-03-03 18:01:43 -0800 | [diff] [blame] | 1955 | spin_unlock_irq(&isci_host->scic_lock); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1956 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1957 | dev_dbg(&isci_host->pdev->dev, |
| 1958 | "%s: isci_device = %p\n", |
| 1959 | __func__, isci_device); |
| 1960 | |
| 1961 | if (status != SCI_SUCCESS) { |
| 1962 | |
Dan Williams | 1a38045 | 2011-03-03 18:01:43 -0800 | [diff] [blame] | 1963 | spin_lock_irq(&isci_host->scic_lock); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1964 | isci_remote_device_deconstruct( |
| 1965 | isci_host, |
| 1966 | isci_device |
| 1967 | ); |
Dan Williams | 1a38045 | 2011-03-03 18:01:43 -0800 | [diff] [blame] | 1968 | spin_unlock_irq(&isci_host->scic_lock); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1969 | return -ENODEV; |
| 1970 | } |
| 1971 | |
Dan Williams | 6ad31fe | 2011-03-04 12:10:29 -0800 | [diff] [blame] | 1972 | /* wait for the device ready callback. */ |
| 1973 | wait_for_device_start(isci_host, isci_device); |
| 1974 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1975 | return 0; |
| 1976 | } |
| 1977 | /** |
| 1978 | * isci_device_is_reset_pending() - This function will check if there is any |
| 1979 | * pending reset condition on the device. |
| 1980 | * @request: This parameter is the isci_device object. |
| 1981 | * |
| 1982 | * true if there is a reset pending for the device. |
| 1983 | */ |
| 1984 | bool isci_device_is_reset_pending( |
| 1985 | struct isci_host *isci_host, |
| 1986 | struct isci_remote_device *isci_device) |
| 1987 | { |
| 1988 | struct isci_request *isci_request; |
| 1989 | struct isci_request *tmp_req; |
| 1990 | bool reset_is_pending = false; |
| 1991 | unsigned long flags; |
| 1992 | |
| 1993 | dev_dbg(&isci_host->pdev->dev, |
| 1994 | "%s: isci_device = %p\n", __func__, isci_device); |
| 1995 | |
| 1996 | spin_lock_irqsave(&isci_host->scic_lock, flags); |
| 1997 | |
| 1998 | /* Check for reset on all pending requests. */ |
| 1999 | list_for_each_entry_safe(isci_request, tmp_req, |
| 2000 | &isci_device->reqs_in_process, dev_node) { |
| 2001 | dev_dbg(&isci_host->pdev->dev, |
| 2002 | "%s: isci_device = %p request = %p\n", |
| 2003 | __func__, isci_device, isci_request); |
| 2004 | |
| 2005 | if (isci_request->ttype == io_task) { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 2006 | struct sas_task *task = isci_request_access_task( |
| 2007 | isci_request); |
| 2008 | |
Bartosz Barcinski | 467e855 | 2011-04-12 17:28:41 -0700 | [diff] [blame] | 2009 | spin_lock(&task->task_state_lock); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 2010 | if (task->task_state_flags & SAS_TASK_NEED_DEV_RESET) |
| 2011 | reset_is_pending = true; |
Bartosz Barcinski | 467e855 | 2011-04-12 17:28:41 -0700 | [diff] [blame] | 2012 | spin_unlock(&task->task_state_lock); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 2013 | } |
| 2014 | } |
| 2015 | |
| 2016 | spin_unlock_irqrestore(&isci_host->scic_lock, flags); |
| 2017 | |
| 2018 | dev_dbg(&isci_host->pdev->dev, |
| 2019 | "%s: isci_device = %p reset_is_pending = %d\n", |
| 2020 | __func__, isci_device, reset_is_pending); |
| 2021 | |
| 2022 | return reset_is_pending; |
| 2023 | } |
| 2024 | |
| 2025 | /** |
| 2026 | * isci_device_clear_reset_pending() - This function will clear if any pending |
| 2027 | * reset condition flags on the device. |
| 2028 | * @request: This parameter is the isci_device object. |
| 2029 | * |
| 2030 | * true if there is a reset pending for the device. |
| 2031 | */ |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 2032 | void isci_device_clear_reset_pending(struct isci_host *ihost, struct isci_remote_device *idev) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 2033 | { |
| 2034 | struct isci_request *isci_request; |
| 2035 | struct isci_request *tmp_req; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 2036 | unsigned long flags = 0; |
| 2037 | |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 2038 | dev_dbg(&ihost->pdev->dev, "%s: idev=%p, ihost=%p\n", |
| 2039 | __func__, idev, ihost); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 2040 | |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 2041 | spin_lock_irqsave(&ihost->scic_lock, flags); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 2042 | |
| 2043 | /* Clear reset pending on all pending requests. */ |
| 2044 | list_for_each_entry_safe(isci_request, tmp_req, |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 2045 | &idev->reqs_in_process, dev_node) { |
| 2046 | dev_dbg(&ihost->pdev->dev, "%s: idev = %p request = %p\n", |
| 2047 | __func__, idev, isci_request); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 2048 | |
| 2049 | if (isci_request->ttype == io_task) { |
| 2050 | |
| 2051 | unsigned long flags2; |
| 2052 | struct sas_task *task = isci_request_access_task( |
| 2053 | isci_request); |
| 2054 | |
| 2055 | spin_lock_irqsave(&task->task_state_lock, flags2); |
| 2056 | task->task_state_flags &= ~SAS_TASK_NEED_DEV_RESET; |
| 2057 | spin_unlock_irqrestore(&task->task_state_lock, flags2); |
| 2058 | } |
| 2059 | } |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 2060 | spin_unlock_irqrestore(&ihost->scic_lock, flags); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 2061 | } |