diff options
| -rw-r--r-- | drivers/scsi/isci/Makefile | 2 | ||||
| -rw-r--r-- | drivers/scsi/isci/request.c | 71 | ||||
| -rw-r--r-- | drivers/scsi/isci/request.h | 2 | ||||
| -rw-r--r-- | drivers/scsi/isci/sata.c | 232 | ||||
| -rw-r--r-- | drivers/scsi/isci/sata.h | 79 | ||||
| -rw-r--r-- | drivers/scsi/isci/task.c | 100 | ||||
| -rw-r--r-- | drivers/scsi/isci/task.h | 12 |
7 files changed, 120 insertions, 378 deletions
diff --git a/drivers/scsi/isci/Makefile b/drivers/scsi/isci/Makefile index 42449701ad9e..3359e10e0d8f 100644 --- a/drivers/scsi/isci/Makefile +++ b/drivers/scsi/isci/Makefile | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | obj-$(CONFIG_SCSI_ISCI) += isci.o | 1 | obj-$(CONFIG_SCSI_ISCI) += isci.o |
| 2 | isci-objs := init.o phy.o request.o sata.o \ | 2 | isci-objs := init.o phy.o request.o \ |
| 3 | remote_device.o port.o \ | 3 | remote_device.o port.o \ |
| 4 | host.o task.o probe_roms.o \ | 4 | host.o task.o probe_roms.o \ |
| 5 | remote_node_context.o \ | 5 | remote_node_context.o \ |
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c index 7c500bb6a8e0..33c8ed1741e6 100644 --- a/drivers/scsi/isci/request.c +++ b/drivers/scsi/isci/request.c | |||
| @@ -56,7 +56,6 @@ | |||
| 56 | #include "isci.h" | 56 | #include "isci.h" |
| 57 | #include "task.h" | 57 | #include "task.h" |
| 58 | #include "request.h" | 58 | #include "request.h" |
| 59 | #include "sata.h" | ||
| 60 | #include "scu_completion_codes.h" | 59 | #include "scu_completion_codes.h" |
| 61 | #include "scu_event_codes.h" | 60 | #include "scu_event_codes.h" |
| 62 | #include "sas.h" | 61 | #include "sas.h" |
| @@ -1092,16 +1091,6 @@ smp_request_await_tc_event(struct isci_request *ireq, | |||
| 1092 | return SCI_SUCCESS; | 1091 | return SCI_SUCCESS; |
| 1093 | } | 1092 | } |
| 1094 | 1093 | ||
| 1095 | void sci_stp_io_request_set_ncq_tag(struct isci_request *ireq, | ||
| 1096 | u16 ncq_tag) | ||
| 1097 | { | ||
| 1098 | /** | ||
| 1099 | * @note This could be made to return an error to the user if the user | ||
| 1100 | * attempts to set the NCQ tag in the wrong state. | ||
| 1101 | */ | ||
| 1102 | ireq->tc->type.stp.ncq_tag = ncq_tag; | ||
| 1103 | } | ||
| 1104 | |||
| 1105 | static struct scu_sgl_element *pio_sgl_next(struct isci_stp_request *stp_req) | 1094 | static struct scu_sgl_element *pio_sgl_next(struct isci_stp_request *stp_req) |
| 1106 | { | 1095 | { |
| 1107 | struct scu_sgl_element *sgl; | 1096 | struct scu_sgl_element *sgl; |
| @@ -2410,6 +2399,29 @@ static void isci_task_save_for_upper_layer_completion( | |||
| 2410 | } | 2399 | } |
| 2411 | } | 2400 | } |
| 2412 | 2401 | ||
| 2402 | static void isci_request_process_stp_response(struct sas_task *task, | ||
| 2403 | void *response_buffer) | ||
| 2404 | { | ||
| 2405 | struct dev_to_host_fis *d2h_reg_fis = response_buffer; | ||
| 2406 | struct task_status_struct *ts = &task->task_status; | ||
| 2407 | struct ata_task_resp *resp = (void *)&ts->buf[0]; | ||
| 2408 | |||
| 2409 | resp->frame_len = le16_to_cpu(*(__le16 *)(response_buffer + 6)); | ||
| 2410 | memcpy(&resp->ending_fis[0], response_buffer + 16, 24); | ||
| 2411 | ts->buf_valid_size = sizeof(*resp); | ||
| 2412 | |||
| 2413 | /** | ||
| 2414 | * If the device fault bit is set in the status register, then | ||
| 2415 | * set the sense data and return. | ||
| 2416 | */ | ||
| 2417 | if (d2h_reg_fis->status & ATA_DF) | ||
| 2418 | ts->stat = SAS_PROTO_RESPONSE; | ||
| 2419 | else | ||
| 2420 | ts->stat = SAM_STAT_GOOD; | ||
| 2421 | |||
| 2422 | ts->resp = SAS_TASK_COMPLETE; | ||
| 2423 | } | ||
| 2424 | |||
| 2413 | static void isci_request_io_request_complete(struct isci_host *ihost, | 2425 | static void isci_request_io_request_complete(struct isci_host *ihost, |
| 2414 | struct isci_request *request, | 2426 | struct isci_request *request, |
| 2415 | enum sci_io_status completion_status) | 2427 | enum sci_io_status completion_status) |
| @@ -2985,34 +2997,29 @@ static enum sci_status isci_request_ssp_request_construct( | |||
| 2985 | return status; | 2997 | return status; |
| 2986 | } | 2998 | } |
| 2987 | 2999 | ||
| 2988 | static enum sci_status isci_request_stp_request_construct( | 3000 | static enum sci_status isci_request_stp_request_construct(struct isci_request *ireq) |
| 2989 | struct isci_request *request) | ||
| 2990 | { | 3001 | { |
| 2991 | struct sas_task *task = isci_request_access_task(request); | 3002 | struct sas_task *task = isci_request_access_task(ireq); |
| 3003 | struct host_to_dev_fis *fis = &ireq->stp.cmd; | ||
| 3004 | struct ata_queued_cmd *qc = task->uldd_task; | ||
| 2992 | enum sci_status status; | 3005 | enum sci_status status; |
| 2993 | struct host_to_dev_fis *register_fis; | ||
| 2994 | 3006 | ||
| 2995 | dev_dbg(&request->isci_host->pdev->dev, | 3007 | dev_dbg(&ireq->isci_host->pdev->dev, |
| 2996 | "%s: request = %p\n", | 3008 | "%s: ireq = %p\n", |
| 2997 | __func__, | 3009 | __func__, |
| 2998 | request); | 3010 | ireq); |
| 2999 | |||
| 3000 | /* Get the host_to_dev_fis from the core and copy | ||
| 3001 | * the fis from the task into it. | ||
| 3002 | */ | ||
| 3003 | register_fis = isci_sata_task_to_fis_copy(task); | ||
| 3004 | 3011 | ||
| 3005 | status = sci_io_request_construct_basic_sata(request); | 3012 | memcpy(fis, &task->ata_task.fis, sizeof(struct host_to_dev_fis)); |
| 3013 | if (!task->ata_task.device_control_reg_update) | ||
| 3014 | fis->flags |= 0x80; | ||
| 3015 | fis->flags &= 0xF0; | ||
| 3006 | 3016 | ||
| 3007 | /* Set the ncq tag in the fis, from the queue | 3017 | status = sci_io_request_construct_basic_sata(ireq); |
| 3008 | * command in the task. | ||
| 3009 | */ | ||
| 3010 | if (isci_sata_is_task_ncq(task)) { | ||
| 3011 | 3018 | ||
| 3012 | isci_sata_set_ncq_tag( | 3019 | if (qc && (qc->tf.command == ATA_CMD_FPDMA_WRITE || |
| 3013 | register_fis, | 3020 | qc->tf.command == ATA_CMD_FPDMA_READ)) { |
| 3014 | task | 3021 | fis->sector_count = qc->tag << 3; |
| 3015 | ); | 3022 | ireq->tc->type.stp.ncq_tag = qc->tag; |
| 3016 | } | 3023 | } |
| 3017 | 3024 | ||
| 3018 | return status; | 3025 | return status; |
diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 597084027819..11bc279457aa 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h | |||
| @@ -435,8 +435,6 @@ enum sci_status | |||
| 435 | sci_task_request_construct_ssp(struct isci_request *ireq); | 435 | sci_task_request_construct_ssp(struct isci_request *ireq); |
| 436 | enum sci_status | 436 | enum sci_status |
| 437 | sci_task_request_construct_sata(struct isci_request *ireq); | 437 | sci_task_request_construct_sata(struct isci_request *ireq); |
| 438 | void | ||
| 439 | sci_stp_io_request_set_ncq_tag(struct isci_request *ireq, u16 ncq_tag); | ||
| 440 | void sci_smp_request_copy_response(struct isci_request *ireq); | 438 | void sci_smp_request_copy_response(struct isci_request *ireq); |
| 441 | 439 | ||
| 442 | static inline int isci_task_is_ncq_recovery(struct sas_task *task) | 440 | static inline int isci_task_is_ncq_recovery(struct sas_task *task) |
diff --git a/drivers/scsi/isci/sata.c b/drivers/scsi/isci/sata.c deleted file mode 100644 index 47b96c21548f..000000000000 --- a/drivers/scsi/isci/sata.c +++ /dev/null | |||
| @@ -1,232 +0,0 @@ | |||
| 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 | */ | ||
| 55 | |||
| 56 | #include <scsi/sas.h> | ||
| 57 | #include "isci.h" | ||
| 58 | #include "remote_device.h" | ||
| 59 | #include "task.h" | ||
| 60 | #include "request.h" | ||
| 61 | #include "sata.h" | ||
| 62 | |||
| 63 | /** | ||
| 64 | * isci_sata_task_to_fis_copy() - This function gets the host_to_dev_fis from | ||
| 65 | * the core and copies the fis from the task into it. | ||
| 66 | * @task: This parameter is a pointer to the task struct from libsas. | ||
| 67 | * | ||
| 68 | * pointer to the host_to_dev_fis from the core request object. | ||
| 69 | */ | ||
| 70 | struct host_to_dev_fis *isci_sata_task_to_fis_copy(struct sas_task *task) | ||
| 71 | { | ||
| 72 | struct isci_request *ireq = task->lldd_task; | ||
| 73 | struct host_to_dev_fis *fis = &ireq->stp.cmd; | ||
| 74 | |||
| 75 | memcpy(fis, &task->ata_task.fis, sizeof(struct host_to_dev_fis)); | ||
| 76 | |||
| 77 | if (!task->ata_task.device_control_reg_update) | ||
| 78 | fis->flags |= 0x80; | ||
| 79 | |||
| 80 | fis->flags &= 0xF0; | ||
| 81 | |||
| 82 | return fis; | ||
| 83 | } | ||
| 84 | |||
| 85 | /** | ||
| 86 | * isci_sata_is_task_ncq() - This function determines if the given stp task is | ||
| 87 | * a ncq request. | ||
| 88 | * @task: This parameter is a pointer to the task struct from libsas. | ||
| 89 | * | ||
| 90 | * true if the task is ncq | ||
| 91 | */ | ||
| 92 | bool isci_sata_is_task_ncq(struct sas_task *task) | ||
| 93 | { | ||
| 94 | struct ata_queued_cmd *qc = task->uldd_task; | ||
| 95 | |||
| 96 | bool ret = (qc && | ||
| 97 | (qc->tf.command == ATA_CMD_FPDMA_WRITE || | ||
| 98 | qc->tf.command == ATA_CMD_FPDMA_READ)); | ||
| 99 | |||
| 100 | return ret; | ||
| 101 | } | ||
| 102 | |||
| 103 | /** | ||
| 104 | * isci_sata_set_ncq_tag() - This function sets the ncq tag field in the | ||
| 105 | * host_to_dev_fis equal to the tag in the queue command in the task. | ||
| 106 | * @task: This parameter is a pointer to the task struct from libsas. | ||
| 107 | * @register_fis: This parameter is a pointer to the host_to_dev_fis from the | ||
| 108 | * core request object. | ||
| 109 | * | ||
| 110 | */ | ||
| 111 | void isci_sata_set_ncq_tag( | ||
| 112 | struct host_to_dev_fis *register_fis, | ||
| 113 | struct sas_task *task) | ||
| 114 | { | ||
| 115 | struct ata_queued_cmd *qc = task->uldd_task; | ||
| 116 | struct isci_request *request = task->lldd_task; | ||
| 117 | |||
| 118 | register_fis->sector_count = qc->tag << 3; | ||
| 119 | sci_stp_io_request_set_ncq_tag(request, qc->tag); | ||
| 120 | } | ||
| 121 | |||
| 122 | /** | ||
| 123 | * isci_request_process_stp_response() - This function sets the status and | ||
| 124 | * response, in the task struct, from the request object for the upper layer | ||
| 125 | * driver. | ||
| 126 | * @sas_task: This parameter is the task struct from the upper layer driver. | ||
| 127 | * @response_buffer: This parameter points to the response of the completed | ||
| 128 | * request. | ||
| 129 | * | ||
| 130 | * none. | ||
| 131 | */ | ||
| 132 | void isci_request_process_stp_response(struct sas_task *task, | ||
| 133 | void *response_buffer) | ||
| 134 | { | ||
| 135 | struct dev_to_host_fis *d2h_reg_fis = response_buffer; | ||
| 136 | struct task_status_struct *ts = &task->task_status; | ||
| 137 | struct ata_task_resp *resp = (void *)&ts->buf[0]; | ||
| 138 | |||
| 139 | resp->frame_len = le16_to_cpu(*(__le16 *)(response_buffer + 6)); | ||
| 140 | memcpy(&resp->ending_fis[0], response_buffer + 16, 24); | ||
| 141 | ts->buf_valid_size = sizeof(*resp); | ||
| 142 | |||
| 143 | /** | ||
| 144 | * If the device fault bit is set in the status register, then | ||
| 145 | * set the sense data and return. | ||
| 146 | */ | ||
| 147 | if (d2h_reg_fis->status & ATA_DF) | ||
| 148 | ts->stat = SAS_PROTO_RESPONSE; | ||
| 149 | else | ||
| 150 | ts->stat = SAM_STAT_GOOD; | ||
| 151 | |||
| 152 | ts->resp = SAS_TASK_COMPLETE; | ||
| 153 | } | ||
| 154 | |||
| 155 | enum sci_status isci_sata_management_task_request_build(struct isci_request *ireq) | ||
| 156 | { | ||
| 157 | struct isci_tmf *isci_tmf; | ||
| 158 | enum sci_status status; | ||
| 159 | |||
| 160 | if (tmf_task != ireq->ttype) | ||
| 161 | return SCI_FAILURE; | ||
| 162 | |||
| 163 | isci_tmf = isci_request_access_tmf(ireq); | ||
| 164 | |||
| 165 | switch (isci_tmf->tmf_code) { | ||
| 166 | |||
| 167 | case isci_tmf_sata_srst_high: | ||
| 168 | case isci_tmf_sata_srst_low: { | ||
| 169 | struct host_to_dev_fis *fis = &ireq->stp.cmd; | ||
| 170 | |||
| 171 | memset(fis, 0, sizeof(*fis)); | ||
| 172 | |||
| 173 | fis->fis_type = 0x27; | ||
| 174 | fis->flags &= ~0x80; | ||
| 175 | fis->flags &= 0xF0; | ||
| 176 | if (isci_tmf->tmf_code == isci_tmf_sata_srst_high) | ||
| 177 | fis->control |= ATA_SRST; | ||
| 178 | else | ||
| 179 | fis->control &= ~ATA_SRST; | ||
| 180 | break; | ||
| 181 | } | ||
| 182 | /* other management commnd go here... */ | ||
| 183 | default: | ||
| 184 | return SCI_FAILURE; | ||
| 185 | } | ||
| 186 | |||
| 187 | /* core builds the protocol specific request | ||
| 188 | * based on the h2d fis. | ||
| 189 | */ | ||
| 190 | status = sci_task_request_construct_sata(ireq); | ||
| 191 | |||
| 192 | return status; | ||
| 193 | } | ||
| 194 | |||
| 195 | /** | ||
| 196 | * isci_task_send_lu_reset_sata() - This function is called by of the SAS | ||
| 197 | * Domain Template functions. This is one of the Task Management functoins | ||
| 198 | * called by libsas, to reset the given SAS lun. Note the assumption that | ||
| 199 | * while this call is executing, no I/O will be sent by the host to the | ||
| 200 | * device. | ||
| 201 | * @lun: This parameter specifies the lun to be reset. | ||
| 202 | * | ||
| 203 | * status, zero indicates success. | ||
| 204 | */ | ||
| 205 | int isci_task_send_lu_reset_sata( | ||
| 206 | struct isci_host *isci_host, | ||
| 207 | struct isci_remote_device *isci_device, | ||
| 208 | u8 *lun) | ||
| 209 | { | ||
| 210 | struct isci_tmf tmf; | ||
| 211 | int ret = TMF_RESP_FUNC_FAILED; | ||
| 212 | |||
| 213 | /* Send the soft reset to the target */ | ||
| 214 | #define ISCI_SRST_TIMEOUT_MS 25000 /* 25 second timeout. */ | ||
| 215 | isci_task_build_tmf(&tmf, isci_tmf_sata_srst_high, NULL, NULL); | ||
| 216 | |||
| 217 | ret = isci_task_execute_tmf(isci_host, isci_device, &tmf, | ||
| 218 | ISCI_SRST_TIMEOUT_MS); | ||
| 219 | |||
| 220 | if (ret != TMF_RESP_FUNC_COMPLETE) { | ||
| 221 | dev_warn(&isci_host->pdev->dev, | ||
| 222 | "%s: Assert SRST failed (%p) = %x", | ||
| 223 | __func__, | ||
| 224 | isci_device, | ||
| 225 | ret); | ||
| 226 | |||
| 227 | /* Return the failure so that the LUN reset is escalated | ||
| 228 | * to a target reset. | ||
| 229 | */ | ||
| 230 | } | ||
| 231 | return ret; | ||
| 232 | } | ||
diff --git a/drivers/scsi/isci/sata.h b/drivers/scsi/isci/sata.h deleted file mode 100644 index 1b89f1f75770..000000000000 --- a/drivers/scsi/isci/sata.h +++ /dev/null | |||
| @@ -1,79 +0,0 @@ | |||
| 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 | */ | ||
| 55 | |||
| 56 | struct host_to_dev_fis *isci_sata_task_to_fis_copy( | ||
| 57 | struct sas_task *task); | ||
| 58 | |||
| 59 | bool isci_sata_is_task_ncq( | ||
| 60 | struct sas_task *task); | ||
| 61 | |||
| 62 | void isci_sata_set_ncq_tag( | ||
| 63 | struct host_to_dev_fis *register_fis, | ||
| 64 | struct sas_task *task); | ||
| 65 | |||
| 66 | void isci_request_process_stp_response( | ||
| 67 | struct sas_task *task, | ||
| 68 | void *response_buffer); | ||
| 69 | |||
| 70 | u8 isci_sata_get_sat_protocol( | ||
| 71 | struct isci_request *isci_request); | ||
| 72 | |||
| 73 | enum sci_status isci_sata_management_task_request_build( | ||
| 74 | struct isci_request *isci_request); | ||
| 75 | |||
| 76 | int isci_task_send_lu_reset_sata( | ||
| 77 | struct isci_host *isci_host, | ||
| 78 | struct isci_remote_device *isci_device, | ||
| 79 | u8 *lun); | ||
diff --git a/drivers/scsi/isci/task.c b/drivers/scsi/isci/task.c index 20112cd5b646..5d962b6b03eb 100644 --- a/drivers/scsi/isci/task.c +++ b/drivers/scsi/isci/task.c | |||
| @@ -61,7 +61,6 @@ | |||
| 61 | #include "remote_node_context.h" | 61 | #include "remote_node_context.h" |
| 62 | #include "isci.h" | 62 | #include "isci.h" |
| 63 | #include "request.h" | 63 | #include "request.h" |
| 64 | #include "sata.h" | ||
| 65 | #include "task.h" | 64 | #include "task.h" |
| 66 | #include "host.h" | 65 | #include "host.h" |
| 67 | 66 | ||
| @@ -238,6 +237,46 @@ int isci_task_execute_task(struct sas_task *task, int num, gfp_t gfp_flags) | |||
| 238 | return 0; | 237 | return 0; |
| 239 | } | 238 | } |
| 240 | 239 | ||
| 240 | static enum sci_status isci_sata_management_task_request_build(struct isci_request *ireq) | ||
| 241 | { | ||
| 242 | struct isci_tmf *isci_tmf; | ||
| 243 | enum sci_status status; | ||
| 244 | |||
| 245 | if (tmf_task != ireq->ttype) | ||
| 246 | return SCI_FAILURE; | ||
| 247 | |||
| 248 | isci_tmf = isci_request_access_tmf(ireq); | ||
| 249 | |||
| 250 | switch (isci_tmf->tmf_code) { | ||
| 251 | |||
| 252 | case isci_tmf_sata_srst_high: | ||
| 253 | case isci_tmf_sata_srst_low: { | ||
| 254 | struct host_to_dev_fis *fis = &ireq->stp.cmd; | ||
| 255 | |||
| 256 | memset(fis, 0, sizeof(*fis)); | ||
| 257 | |||
| 258 | fis->fis_type = 0x27; | ||
| 259 | fis->flags &= ~0x80; | ||
| 260 | fis->flags &= 0xF0; | ||
| 261 | if (isci_tmf->tmf_code == isci_tmf_sata_srst_high) | ||
| 262 | fis->control |= ATA_SRST; | ||
| 263 | else | ||
| 264 | fis->control &= ~ATA_SRST; | ||
| 265 | break; | ||
| 266 | } | ||
| 267 | /* other management commnd go here... */ | ||
| 268 | default: | ||
| 269 | return SCI_FAILURE; | ||
| 270 | } | ||
| 271 | |||
| 272 | /* core builds the protocol specific request | ||
| 273 | * based on the h2d fis. | ||
| 274 | */ | ||
| 275 | status = sci_task_request_construct_sata(ireq); | ||
| 276 | |||
| 277 | return status; | ||
| 278 | } | ||
| 279 | |||
| 241 | static struct isci_request *isci_task_request_build(struct isci_host *ihost, | 280 | static struct isci_request *isci_task_request_build(struct isci_host *ihost, |
| 242 | struct isci_remote_device *idev, | 281 | struct isci_remote_device *idev, |
| 243 | u16 tag, struct isci_tmf *isci_tmf) | 282 | u16 tag, struct isci_tmf *isci_tmf) |
| @@ -287,9 +326,9 @@ static struct isci_request *isci_task_request_build(struct isci_host *ihost, | |||
| 287 | return ireq; | 326 | return ireq; |
| 288 | } | 327 | } |
| 289 | 328 | ||
| 290 | int isci_task_execute_tmf(struct isci_host *ihost, | 329 | static int isci_task_execute_tmf(struct isci_host *ihost, |
| 291 | struct isci_remote_device *idev, | 330 | struct isci_remote_device *idev, |
| 292 | struct isci_tmf *tmf, unsigned long timeout_ms) | 331 | struct isci_tmf *tmf, unsigned long timeout_ms) |
| 293 | { | 332 | { |
| 294 | DECLARE_COMPLETION_ONSTACK(completion); | 333 | DECLARE_COMPLETION_ONSTACK(completion); |
| 295 | enum sci_task_status status = SCI_TASK_FAILURE; | 334 | enum sci_task_status status = SCI_TASK_FAILURE; |
| @@ -401,13 +440,12 @@ int isci_task_execute_tmf(struct isci_host *ihost, | |||
| 401 | return ret; | 440 | return ret; |
| 402 | } | 441 | } |
| 403 | 442 | ||
| 404 | void isci_task_build_tmf( | 443 | static void isci_task_build_tmf(struct isci_tmf *tmf, |
| 405 | struct isci_tmf *tmf, | 444 | enum isci_tmf_function_codes code, |
| 406 | enum isci_tmf_function_codes code, | 445 | void (*tmf_sent_cb)(enum isci_tmf_cb_state, |
| 407 | void (*tmf_sent_cb)(enum isci_tmf_cb_state, | 446 | struct isci_tmf *, |
| 408 | struct isci_tmf *, | 447 | void *), |
| 409 | void *), | 448 | void *cb_data) |
| 410 | void *cb_data) | ||
| 411 | { | 449 | { |
| 412 | memset(tmf, 0, sizeof(*tmf)); | 450 | memset(tmf, 0, sizeof(*tmf)); |
| 413 | 451 | ||
| @@ -416,16 +454,14 @@ void isci_task_build_tmf( | |||
| 416 | tmf->cb_data = cb_data; | 454 | tmf->cb_data = cb_data; |
| 417 | } | 455 | } |
| 418 | 456 | ||
| 419 | static void isci_task_build_abort_task_tmf( | 457 | static void isci_task_build_abort_task_tmf(struct isci_tmf *tmf, |
| 420 | struct isci_tmf *tmf, | 458 | enum isci_tmf_function_codes code, |
| 421 | enum isci_tmf_function_codes code, | 459 | void (*tmf_sent_cb)(enum isci_tmf_cb_state, |
| 422 | void (*tmf_sent_cb)(enum isci_tmf_cb_state, | 460 | struct isci_tmf *, |
| 423 | struct isci_tmf *, | 461 | void *), |
| 424 | void *), | 462 | struct isci_request *old_request) |
| 425 | struct isci_request *old_request) | ||
| 426 | { | 463 | { |
| 427 | isci_task_build_tmf(tmf, code, tmf_sent_cb, | 464 | isci_task_build_tmf(tmf, code, tmf_sent_cb, old_request); |
| 428 | (void *)old_request); | ||
| 429 | tmf->io_tag = old_request->io_tag; | 465 | tmf->io_tag = old_request->io_tag; |
| 430 | } | 466 | } |
| 431 | 467 | ||
| @@ -804,6 +840,30 @@ static int isci_task_send_lu_reset_sas( | |||
| 804 | return ret; | 840 | return ret; |
| 805 | } | 841 | } |
| 806 | 842 | ||
| 843 | static int isci_task_send_lu_reset_sata(struct isci_host *ihost, | ||
| 844 | struct isci_remote_device *idev, u8 *lun) | ||
| 845 | { | ||
| 846 | int ret = TMF_RESP_FUNC_FAILED; | ||
| 847 | struct isci_tmf tmf; | ||
| 848 | |||
| 849 | /* Send the soft reset to the target */ | ||
| 850 | #define ISCI_SRST_TIMEOUT_MS 25000 /* 25 second timeout. */ | ||
| 851 | isci_task_build_tmf(&tmf, isci_tmf_sata_srst_high, NULL, NULL); | ||
| 852 | |||
| 853 | ret = isci_task_execute_tmf(ihost, idev, &tmf, ISCI_SRST_TIMEOUT_MS); | ||
| 854 | |||
| 855 | if (ret != TMF_RESP_FUNC_COMPLETE) { | ||
| 856 | dev_warn(&ihost->pdev->dev, | ||
| 857 | "%s: Assert SRST failed (%p) = %x", | ||
| 858 | __func__, idev, ret); | ||
| 859 | |||
| 860 | /* Return the failure so that the LUN reset is escalated | ||
| 861 | * to a target reset. | ||
| 862 | */ | ||
| 863 | } | ||
| 864 | return ret; | ||
| 865 | } | ||
| 866 | |||
| 807 | /** | 867 | /** |
| 808 | * isci_task_lu_reset() - This function is one of the SAS Domain Template | 868 | * isci_task_lu_reset() - This function is one of the SAS Domain Template |
| 809 | * functions. This is one of the Task Management functoins called by libsas, | 869 | * functions. This is one of the Task Management functoins called by libsas, |
diff --git a/drivers/scsi/isci/task.h b/drivers/scsi/isci/task.h index 42019de23805..4a7fa90287ef 100644 --- a/drivers/scsi/isci/task.h +++ b/drivers/scsi/isci/task.h | |||
| @@ -211,18 +211,6 @@ int isci_queuecommand( | |||
| 211 | 211 | ||
| 212 | int isci_bus_reset_handler(struct scsi_cmnd *cmd); | 212 | int isci_bus_reset_handler(struct scsi_cmnd *cmd); |
| 213 | 213 | ||
| 214 | void isci_task_build_tmf( | ||
| 215 | struct isci_tmf *tmf, | ||
| 216 | enum isci_tmf_function_codes code, | ||
| 217 | void (*tmf_sent_cb)(enum isci_tmf_cb_state, | ||
| 218 | struct isci_tmf *, | ||
| 219 | void *), | ||
| 220 | void *cb_data); | ||
| 221 | |||
| 222 | int isci_task_execute_tmf(struct isci_host *isci_host, | ||
| 223 | struct isci_remote_device *idev, | ||
| 224 | struct isci_tmf *tmf, unsigned long timeout_ms); | ||
| 225 | |||
| 226 | /** | 214 | /** |
| 227 | * enum isci_completion_selection - This enum defines the possible actions to | 215 | * enum isci_completion_selection - This enum defines the possible actions to |
| 228 | * take with respect to a given request's notification back to libsas. | 216 | * take with respect to a given request's notification back to libsas. |
