From 6f231dda68080759f1aed3769896e94c73099f0f Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Sat, 2 Jul 2011 22:56:22 -0700 Subject: isci: Intel(R) C600 Series Chipset Storage Control Unit Driver Support for the up to 2x4-port 6Gb/s SAS controllers embedded in the chipset. This is a snapshot of the first publicly available version of the driver, commit 4c1db2d0 in the 'historical' branch. git://git.kernel.org/pub/scm/linux/kernel/git/djbw/isci.git historical Signed-off-by: Maciej Trela Signed-off-by: Dave Jiang Signed-off-by: Edmund Nadolski Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 429 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 429 insertions(+) create mode 100644 drivers/scsi/isci/request.h (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h new file mode 100644 index 000000000000..5079d4a7c41b --- /dev/null +++ b/drivers/scsi/isci/request.h @@ -0,0 +1,429 @@ +/* + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * BSD LICENSE + * + * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#if !defined(_ISCI_REQUEST_H_) +#define _ISCI_REQUEST_H_ + +#include "isci.h" + +/** + * struct isci_request_status - This enum defines the possible states of an I/O + * request. + * + * + */ +enum isci_request_status { + unallocated = 0x00, + allocated = 0x01, + started = 0x02, + completed = 0x03, + aborting = 0x04, + aborted = 0x05, + terminating = 0x06 +}; + +enum task_type { + io_task = 0, + tmf_task = 1 +}; + +/** + * struct isci_request - This class represents the request object used to track + * IO, smp and TMF request internal. It wraps the SCIC request object. + * + * + */ +struct isci_request { + + struct scic_sds_request *sci_request_handle; + + enum isci_request_status status; + enum task_type ttype; + unsigned short io_tag; + bool complete_in_target; + + union ttype_ptr_union { + struct sas_task *io_task_ptr; /* When ttype==io_task */ + struct isci_tmf *tmf_task_ptr; /* When ttype==tmf_task */ + } ttype_ptr; + struct isci_host *isci_host; + struct isci_remote_device *isci_device; + /* For use in the requests_to_{complete|abort} lists: */ + struct list_head completed_node; + /* For use in the reqs_in_process list: */ + struct list_head dev_node; + void *sci_request_mem_ptr; + spinlock_t state_lock; + dma_addr_t request_daddr; + dma_addr_t zero_scatter_daddr; + + unsigned int num_sg_entries; /* returned by pci_alloc_sg */ + unsigned int request_alloc_size; /* size of block from dma_pool_alloc */ + + /** Note: "io_request_completion" is completed in two different ways + * depending on whether this is a TMF or regular request. + * - TMF requests are completed in the thread that started them; + * - regular requests are completed in the request completion callback + * function. + * This difference in operation allows the aborter of a TMF request + * to be sure that once the TMF request completes, the I/O that the + * TMF was aborting is guaranteed to have completed. + */ + struct completion *io_request_completion; +}; + +/** + * This function gets the status of the request object. + * @request: This parameter points to the isci_request object + * + * status of the object as a isci_request_status enum. + */ +static inline +enum isci_request_status isci_request_get_state( + struct isci_request *isci_request) +{ + BUG_ON(isci_request == NULL); + + /*probably a bad sign... */ + if (isci_request->status == unallocated) + dev_warn(&isci_request->isci_host->pdev->dev, + "%s: isci_request->status == unallocated\n", + __func__); + + return isci_request->status; +} + + +/** + * isci_request_change_state() - This function sets the status of the request + * object. + * @request: This parameter points to the isci_request object + * @status: This Parameter is the new status of the object + * + */ +static inline enum isci_request_status isci_request_change_state( + struct isci_request *isci_request, + enum isci_request_status status) +{ + enum isci_request_status old_state; + unsigned long flags; + + dev_dbg(&isci_request->isci_host->pdev->dev, + "%s: isci_request = %p, state = 0x%x\n", + __func__, + isci_request, + status); + + BUG_ON(isci_request == NULL); + + spin_lock_irqsave(&isci_request->state_lock, flags); + old_state = isci_request->status; + isci_request->status = status; + spin_unlock_irqrestore(&isci_request->state_lock, flags); + + return old_state; +} + +/** + * isci_request_change_started_to_newstate() - This function sets the status of + * the request object. + * @request: This parameter points to the isci_request object + * @status: This Parameter is the new status of the object + * + * state previous to any change. + */ +static inline enum isci_request_status isci_request_change_started_to_newstate( + struct isci_request *isci_request, + struct completion *completion_ptr, + enum isci_request_status newstate) +{ + enum isci_request_status old_state; + unsigned long flags; + + BUG_ON(isci_request == NULL); + + spin_lock_irqsave(&isci_request->state_lock, flags); + + old_state = isci_request->status; + + if (old_state == started) { + BUG_ON(isci_request->io_request_completion != NULL); + + isci_request->io_request_completion = completion_ptr; + isci_request->status = newstate; + } + spin_unlock_irqrestore(&isci_request->state_lock, flags); + + dev_dbg(&isci_request->isci_host->pdev->dev, + "%s: isci_request = %p, old_state = 0x%x\n", + __func__, + isci_request, + old_state); + + return old_state; +} + +/** + * isci_request_change_started_to_aborted() - This function sets the status of + * the request object. + * @request: This parameter points to the isci_request object + * @completion_ptr: This parameter is saved as the kernel completion structure + * signalled when the old request completes. + * + * state previous to any change. + */ +static inline enum isci_request_status isci_request_change_started_to_aborted( + struct isci_request *isci_request, + struct completion *completion_ptr) +{ + return isci_request_change_started_to_newstate( + isci_request, completion_ptr, aborted + ); +} +/** + * isci_request_free() - This function frees the request object. + * @isci_host: This parameter specifies the ISCI host object + * @isci_request: This parameter points to the isci_request object + * + */ +static inline void isci_request_free( + struct isci_host *isci_host, + struct isci_request *isci_request) +{ + BUG_ON(isci_request == NULL); + + /* release the dma memory if we fail. */ + dma_pool_free(isci_host->dma_pool, isci_request, + isci_request->request_daddr); +} + + +/* #define ISCI_REQUEST_VALIDATE_ACCESS + */ + +#ifdef ISCI_REQUEST_VALIDATE_ACCESS + +static inline +struct sas_task *isci_request_access_task(struct isci_request *isci_request) +{ + BUG_ON(isci_request->ttype != io_task); + return isci_request->ttype_ptr.io_task_ptr; +} + +static inline +struct isci_tmf *isci_request_access_tmf(struct isci_request *isci_request) +{ + BUG_ON(isci_request->ttype != tmf_task); + return isci_request->ttype_ptr.tmf_task_ptr; +} + +#else /* not ISCI_REQUEST_VALIDATE_ACCESS */ + +#define isci_request_access_task(RequestPtr) \ + ((RequestPtr)->ttype_ptr.io_task_ptr) + +#define isci_request_access_tmf(RequestPtr) \ + ((RequestPtr)->ttype_ptr.tmf_task_ptr) + +#endif /* not ISCI_REQUEST_VALIDATE_ACCESS */ + + +int isci_request_alloc_tmf( + struct isci_host *isci_host, + struct isci_tmf *isci_tmf, + struct isci_request **isci_request, + struct isci_remote_device *isci_device, + gfp_t gfp_flags); + + +int isci_request_execute( + struct isci_host *isci_host, + struct sas_task *task, + struct isci_request **request, + gfp_t gfp_flags); + +/** + * isci_request_unmap_sgl() - This function unmaps the DMA address of a given + * sgl + * @request: This parameter points to the isci_request object + * @*pdev: This Parameter is the pci_device struct for the controller + * + */ +static inline void isci_request_unmap_sgl( + struct isci_request *request, + struct pci_dev *pdev) +{ + struct sas_task *task = isci_request_access_task(request); + + dev_dbg(&request->isci_host->pdev->dev, + "%s: request = %p, task = %p,\n" + "task->data_dir = %d, is_sata = %d\n ", + __func__, + request, + task, + task->data_dir, + sas_protocol_ata(task->task_proto)); + + if ((task->data_dir != PCI_DMA_NONE) && + !sas_protocol_ata(task->task_proto)) { + if (task->num_scatter == 0) + /* 0 indicates a single dma address */ + dma_unmap_single( + &pdev->dev, + request->zero_scatter_daddr, + task->total_xfer_len, + task->data_dir + ); + + else /* unmap the sgl dma addresses */ + dma_unmap_sg( + &pdev->dev, + task->scatter, + request->num_sg_entries, + task->data_dir + ); + } +} + + +void isci_request_io_request_complete( + struct isci_host *isci_host, + struct isci_request *request, + enum sci_io_status completion_status); + +u32 isci_request_io_request_get_transfer_length( + struct isci_request *request); + +SCI_IO_REQUEST_DATA_DIRECTION isci_request_io_request_get_data_direction( + struct isci_request *request); + +/** + * isci_request_io_request_get_next_sge() - This function is called by the sci + * core to retrieve the next sge for a given request. + * @request: This parameter is the isci_request object. + * @current_sge_address: This parameter is the last sge retrieved by the sci + * core for this request. + * + * pointer to the next sge for specified request. + */ +static inline void *isci_request_io_request_get_next_sge( + struct isci_request *request, + void *current_sge_address) +{ + struct sas_task *task = isci_request_access_task(request); + void *ret = NULL; + + dev_dbg(&request->isci_host->pdev->dev, + "%s: request = %p, " + "current_sge_address = %p, " + "num_scatter = %d\n", + __func__, + request, + current_sge_address, + task->num_scatter); + + if (!current_sge_address) /* First time through.. */ + ret = task->scatter; /* always task->scatter */ + else if (task->num_scatter == 0) /* Next element, if num_scatter == 0 */ + ret = NULL; /* there is only one element. */ + else + ret = sg_next(current_sge_address); /* sg_next returns NULL + * for the last element + */ + + dev_dbg(&request->isci_host->pdev->dev, + "%s: next sge address = %p\n", + __func__, + ret); + + return ret; +} + +dma_addr_t isci_request_sge_get_address_field( + struct isci_request *request, + void *sge_address); + +u32 isci_request_sge_get_length_field( + struct isci_request *request, + void *sge_address); + +void *isci_request_ssp_io_request_get_cdb_address( + struct isci_request *request); + +u32 isci_request_ssp_io_request_get_cdb_length( + struct isci_request *request); + +u32 isci_request_ssp_io_request_get_lun( + struct isci_request *request); + +u32 isci_request_ssp_io_request_get_task_attribute( + struct isci_request *request); + +u32 isci_request_ssp_io_request_get_command_priority( + struct isci_request *request); + + + + + +void isci_terminate_pending_requests( + struct isci_host *isci_host, + struct isci_remote_device *isci_device, + enum isci_request_status new_request_state); + + + + +#endif /* !defined(_ISCI_REQUEST_H_) */ -- cgit v1.2.3 From 82d29928c1c1c6a6605895f8240a9943394244d7 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 8 Feb 2011 17:53:10 -0800 Subject: isci: kill SCI_IO_REQUEST_DATA_DIRECTION It's an unnecessary typedef that mirrors the kernel's enum dma_data_direction. Also cleanup some long variable names along the way. Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 5079d4a7c41b..166295ee8cfd 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -346,8 +346,7 @@ void isci_request_io_request_complete( u32 isci_request_io_request_get_transfer_length( struct isci_request *request); -SCI_IO_REQUEST_DATA_DIRECTION isci_request_io_request_get_data_direction( - struct isci_request *request); +enum dma_data_direction isci_request_io_request_get_data_direction(struct isci_request *req); /** * isci_request_io_request_get_next_sge() - This function is called by the sci -- cgit v1.2.3 From 4dc043c41037fc6e369270daaa626465a8766565 Mon Sep 17 00:00:00 2001 From: Jeff Skirvin Date: Fri, 4 Mar 2011 14:06:52 -0800 Subject: isci: Termination handling cleanup, added termination timeouts. Added a request "dead" state for use when a termination wait times-out. isci_terminate_pending_requests now detaches the device's pending list and terminates each entry on the detached list. Signed-off-by: Jeff Skirvin Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 166295ee8cfd..b45c0f1f057f 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -71,7 +71,8 @@ enum isci_request_status { completed = 0x03, aborting = 0x04, aborted = 0x05, - terminating = 0x06 + terminating = 0x06, + dead = 0x07 }; enum task_type { -- cgit v1.2.3 From 35173d579a08c0d145b3020039d3ba33fbf2c184 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Sat, 26 Mar 2011 16:43:01 -0700 Subject: isci: namespacecheck cleanups * mark needlessly global routines static * delete unused functions * move kernel-doc blocks from header files to source * reorder some functions to delete declarations * more default handler cleanups phy Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index b45c0f1f057f..4a63bb6de44e 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -391,13 +391,7 @@ static inline void *isci_request_io_request_get_next_sge( return ret; } -dma_addr_t isci_request_sge_get_address_field( - struct isci_request *request, - void *sge_address); -u32 isci_request_sge_get_length_field( - struct isci_request *request, - void *sge_address); void *isci_request_ssp_io_request_get_cdb_address( struct isci_request *request); -- cgit v1.2.3 From f219f010a355487638bf2fff4724a420e7158fd2 Mon Sep 17 00:00:00 2001 From: Jeff Skirvin Date: Thu, 31 Mar 2011 13:10:34 -0700 Subject: isci: Properly handle requests in the "aborting" state. When a TMF times-out, the request is set back to "aborting". Requests in the "aborting" state must be terminated when LUN and device resets occur. Signed-off-by: Jeff Skirvin Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 4a63bb6de44e..0c08da6bcd8a 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -199,7 +199,7 @@ static inline enum isci_request_status isci_request_change_started_to_newstate( old_state = isci_request->status; - if (old_state == started) { + if (old_state == started || old_state == aborting) { BUG_ON(isci_request->io_request_completion != NULL); isci_request->io_request_completion = completion_ptr; -- cgit v1.2.3 From 6cb4d6b382be6345c2d0c4b1b90dfdf9af32da7e Mon Sep 17 00:00:00 2001 From: Bartosz Barcinski Date: Tue, 12 Apr 2011 17:28:43 -0700 Subject: isci: audit usage of BUG_ON macro in isci driver Removes unnecessary usage of BUG_ON macro, excluding core directory. In some cases macro is unnecesary, check is done in caller function. In other cases macro is replaced by if construction with appropriate warning. Signed-off-by: Maciej Patelczyk [changed some survivable bug conditions to WARN_ONCE] Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 0c08da6bcd8a..642b21166fc6 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -193,8 +193,6 @@ static inline enum isci_request_status isci_request_change_started_to_newstate( enum isci_request_status old_state; unsigned long flags; - BUG_ON(isci_request == NULL); - spin_lock_irqsave(&isci_request->state_lock, flags); old_state = isci_request->status; @@ -243,7 +241,8 @@ static inline void isci_request_free( struct isci_host *isci_host, struct isci_request *isci_request) { - BUG_ON(isci_request == NULL); + if (!isci_request) + return; /* release the dma memory if we fail. */ dma_pool_free(isci_host->dma_pool, isci_request, -- cgit v1.2.3 From 9286a1959ce7f3df3c1a8e33eb9b210078318dc8 Mon Sep 17 00:00:00 2001 From: Dave Jiang Date: Fri, 6 May 2011 02:17:37 +0000 Subject: isci: Removing unnecessary functions in request.c No need for wrappers, just access sas_task directly. Signed-off-by: Dave Jiang Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 642b21166fc6..9c97715e54d8 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -343,11 +343,6 @@ void isci_request_io_request_complete( struct isci_request *request, enum sci_io_status completion_status); -u32 isci_request_io_request_get_transfer_length( - struct isci_request *request); - -enum dma_data_direction isci_request_io_request_get_data_direction(struct isci_request *req); - /** * isci_request_io_request_get_next_sge() - This function is called by the sci * core to retrieve the next sge for a given request. @@ -391,26 +386,6 @@ static inline void *isci_request_io_request_get_next_sge( } - -void *isci_request_ssp_io_request_get_cdb_address( - struct isci_request *request); - -u32 isci_request_ssp_io_request_get_cdb_length( - struct isci_request *request); - -u32 isci_request_ssp_io_request_get_lun( - struct isci_request *request); - -u32 isci_request_ssp_io_request_get_task_attribute( - struct isci_request *request); - -u32 isci_request_ssp_io_request_get_command_priority( - struct isci_request *request); - - - - - void isci_terminate_pending_requests( struct isci_host *isci_host, struct isci_remote_device *isci_device, -- cgit v1.2.3 From 0d84366fbef557f92ef82ac9a224c57ffb3318bc Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Sun, 8 May 2011 01:56:57 -0700 Subject: isci: make sgl explicit/aligned request object member Towards unifying request objects we need all members to be defined in the object and not carved out of anonymous buffer space. Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 9c97715e54d8..ddfbf71c97e5 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -53,10 +53,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if !defined(_ISCI_REQUEST_H_) +#ifndef _ISCI_REQUEST_H_ #define _ISCI_REQUEST_H_ #include "isci.h" +#include "scic_sds_request.h" /** * struct isci_request_status - This enum defines the possible states of an I/O @@ -80,16 +81,8 @@ enum task_type { tmf_task = 1 }; -/** - * struct isci_request - This class represents the request object used to track - * IO, smp and TMF request internal. It wraps the SCIC request object. - * - * - */ struct isci_request { - struct scic_sds_request *sci_request_handle; - enum isci_request_status status; enum task_type ttype; unsigned short io_tag; @@ -105,7 +98,6 @@ struct isci_request { struct list_head completed_node; /* For use in the reqs_in_process list: */ struct list_head dev_node; - void *sci_request_mem_ptr; spinlock_t state_lock; dma_addr_t request_daddr; dma_addr_t zero_scatter_daddr; @@ -123,6 +115,7 @@ struct isci_request { * TMF was aborting is guaranteed to have completed. */ struct completion *io_request_completion; + struct scic_sds_request sci_req[0] ____cacheline_aligned; }; /** -- cgit v1.2.3 From 67ea838d17acdad3331aeae848683c768df96aaa Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Sun, 8 May 2011 11:47:15 -0700 Subject: isci: unify request data structures Make scic_sds_request a proper member of isci_request. Also let's us get rid of the dma pool object size tracking since we now know that all requests are sizeof(isci_request). While cleaning up the construct routine incidentally replaced SCI_FIELD_OFFSET with offsetof. Reported-by: Christoph Hellwig Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index ddfbf71c97e5..89d8b0a27dfe 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -82,11 +82,11 @@ enum task_type { }; struct isci_request { - struct scic_sds_request *sci_request_handle; enum isci_request_status status; enum task_type ttype; unsigned short io_tag; bool complete_in_target; + bool terminated; union ttype_ptr_union { struct sas_task *io_task_ptr; /* When ttype==io_task */ @@ -103,7 +103,6 @@ struct isci_request { dma_addr_t zero_scatter_daddr; unsigned int num_sg_entries; /* returned by pci_alloc_sg */ - unsigned int request_alloc_size; /* size of block from dma_pool_alloc */ /** Note: "io_request_completion" is completed in two different ways * depending on whether this is a TMF or regular request. @@ -115,9 +114,16 @@ struct isci_request { * TMF was aborting is guaranteed to have completed. */ struct completion *io_request_completion; - struct scic_sds_request sci_req[0] ____cacheline_aligned; + struct scic_sds_request sci; }; +static inline struct isci_request *sci_req_to_ireq(struct scic_sds_request *sci_req) +{ + struct isci_request *ireq = container_of(sci_req, typeof(*ireq), sci); + + return ireq; +} + /** * This function gets the status of the request object. * @request: This parameter points to the isci_request object -- cgit v1.2.3 From ce2b3261b6765c3b80fda95426c73e8d3bb1b035 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Sun, 8 May 2011 15:49:15 -0700 Subject: isci: unify constants cross driver constants are spread out over multiple header files, consolidate them into isci.h, and push some includes out to the source files that need them. TODO: remove SCI_MODE_SIZE infrastructure. TODO: task.h is full of inlines that are too large Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 89d8b0a27dfe..06786ece9bb2 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -57,6 +57,7 @@ #define _ISCI_REQUEST_H_ #include "isci.h" +#include "host.h" #include "scic_sds_request.h" /** -- cgit v1.2.3 From f1f52e75939b56c40b3d153ae99faf2720250242 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 10 May 2011 02:28:45 -0700 Subject: isci: uplevel request infrastructure * Consolidate tiny header files * Move files out of core/ (drop core/scic_sds_ prefix) * Merge core/scic_sds_request.[ch] into request.[ch] * Cleanup request.c namespace (clean forward declarations and global namespace pollution) Reported-by: Christoph Hellwig Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 442 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 426 insertions(+), 16 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 06786ece9bb2..932ea767c8c2 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -58,7 +58,8 @@ #include "isci.h" #include "host.h" -#include "scic_sds_request.h" +#include "scu_task_context.h" +#include "stp_request.h" /** * struct isci_request_status - This enum defines the possible states of an I/O @@ -82,6 +83,151 @@ enum task_type { tmf_task = 1 }; +enum sci_request_protocol { + SCIC_NO_PROTOCOL, + SCIC_SMP_PROTOCOL, + SCIC_SSP_PROTOCOL, + SCIC_STP_PROTOCOL +}; /* XXX remove me, use sas_task.dev instead */; + +struct scic_sds_request { + /** + * This field contains the information for the base request state machine. + */ + struct sci_base_state_machine state_machine; + + /** + * This field simply points to the controller to which this IO request + * is associated. + */ + struct scic_sds_controller *owning_controller; + + /** + * This field simply points to the remote device to which this IO request + * is associated. + */ + struct scic_sds_remote_device *target_device; + + /** + * This field is utilized to determine if the SCI user is managing + * the IO tag for this request or if the core is managing it. + */ + bool was_tag_assigned_by_user; + + /** + * This field indicates the IO tag for this request. The IO tag is + * comprised of the task_index and a sequence count. The sequence count + * is utilized to help identify tasks from one life to another. + */ + u16 io_tag; + + /** + * This field specifies the protocol being utilized for this + * IO request. + */ + enum sci_request_protocol protocol; + + /** + * This field indicates the completion status taken from the SCUs + * completion code. It indicates the completion result for the SCU hardware. + */ + u32 scu_status; + + /** + * This field indicates the completion status returned to the SCI user. It + * indicates the users view of the io request completion. + */ + u32 sci_status; + + /** + * This field contains the value to be utilized when posting (e.g. Post_TC, + * Post_TC_Abort) this request to the silicon. + */ + u32 post_context; + + struct scu_task_context *task_context_buffer; + struct scu_task_context tc ____cacheline_aligned; + + /* could be larger with sg chaining */ + #define SCU_SGL_SIZE ((SCU_IO_REQUEST_SGE_COUNT + 1) / 2) + struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32))); + + /** + * This field indicates if this request is a task management request or + * normal IO request. + */ + bool is_task_management_request; + + /** + * This field indicates that this request contains an initialized started + * substate machine. + */ + bool has_started_substate_machine; + + /** + * This field is a pointer to the stored rx frame data. It is used in STP + * internal requests and SMP response frames. If this field is non-NULL the + * saved frame must be released on IO request completion. + * + * @todo In the future do we want to keep a list of RX frame buffers? + */ + u32 saved_rx_frame_index; + + /** + * This field specifies the data necessary to manage the sub-state + * machine executed while in the SCI_BASE_REQUEST_STATE_STARTED state. + */ + struct sci_base_state_machine started_substate_machine; + + /** + * This field specifies the current state handlers in place for this + * IO Request object. This field is updated each time the request + * changes state. + */ + const struct scic_sds_io_request_state_handler *state_handlers; + + /** + * This field in the recorded device sequence for the io request. This is + * recorded during the build operation and is compared in the start + * operation. If the sequence is different then there was a change of + * devices from the build to start operations. + */ + u8 device_sequence; + + union { + struct { + union { + struct ssp_cmd_iu cmd; + struct ssp_task_iu tmf; + }; + union { + struct ssp_response_iu rsp; + u8 rsp_buf[SSP_RESP_IU_MAX_SIZE]; + }; + } ssp; + + struct { + struct smp_req cmd; + struct smp_resp rsp; + } smp; + + struct { + struct scic_sds_stp_request req; + struct host_to_dev_fis cmd; + struct dev_to_host_fis rsp; + } stp; + }; + +}; + +static inline struct scic_sds_request *to_sci_req(struct scic_sds_stp_request *stp_req) +{ + struct scic_sds_request *sci_req; + + sci_req = container_of(stp_req, typeof(*sci_req), stp.req); + return sci_req; +} + struct isci_request { enum isci_request_status status; enum task_type ttype; @@ -125,6 +271,273 @@ static inline struct isci_request *sci_req_to_ireq(struct scic_sds_request *sci_ return ireq; } +/** + * enum sci_base_request_states - This enumeration depicts all the states for + * the common request state machine. + * + * + */ +enum sci_base_request_states { + /** + * Simply the initial state for the base request state machine. + */ + SCI_BASE_REQUEST_STATE_INITIAL, + + /** + * This state indicates that the request has been constructed. This state + * is entered from the INITIAL state. + */ + SCI_BASE_REQUEST_STATE_CONSTRUCTED, + + /** + * This state indicates that the request has been started. This state is + * entered from the CONSTRUCTED state. + */ + SCI_BASE_REQUEST_STATE_STARTED, + + /** + * This state indicates that the request has completed. + * This state is entered from the STARTED state. This state is entered from + * the ABORTING state. + */ + SCI_BASE_REQUEST_STATE_COMPLETED, + + /** + * This state indicates that the request is in the process of being + * terminated/aborted. + * This state is entered from the CONSTRUCTED state. + * This state is entered from the STARTED state. + */ + SCI_BASE_REQUEST_STATE_ABORTING, + + /** + * Simply the final state for the base request state machine. + */ + SCI_BASE_REQUEST_STATE_FINAL, +}; + +typedef enum sci_status (*scic_sds_io_request_handler_t) + (struct scic_sds_request *request); +typedef enum sci_status (*scic_sds_io_request_frame_handler_t) + (struct scic_sds_request *req, u32 frame); +typedef enum sci_status (*scic_sds_io_request_event_handler_t) + (struct scic_sds_request *req, u32 event); +typedef enum sci_status (*scic_sds_io_request_task_completion_handler_t) + (struct scic_sds_request *req, u32 completion_code); + +/** + * struct scic_sds_io_request_state_handler - This is the SDS core definition + * of the state handlers. + * + * + */ +struct scic_sds_io_request_state_handler { + /** + * The start_handler specifies the method invoked when a user attempts to + * start a request. + */ + scic_sds_io_request_handler_t start_handler; + + /** + * The abort_handler specifies the method invoked when a user attempts to + * abort a request. + */ + scic_sds_io_request_handler_t abort_handler; + + /** + * The complete_handler specifies the method invoked when a user attempts to + * complete a request. + */ + scic_sds_io_request_handler_t complete_handler; + + scic_sds_io_request_task_completion_handler_t tc_completion_handler; + scic_sds_io_request_event_handler_t event_handler; + scic_sds_io_request_frame_handler_t frame_handler; + +}; + +extern const struct sci_base_state scic_sds_io_request_started_task_mgmt_substate_table[]; + +/** + * scic_sds_request_get_controller() - + * + * This macro will return the controller for this io request object + */ +#define scic_sds_request_get_controller(sci_req) \ + ((sci_req)->owning_controller) + +/** + * scic_sds_request_get_device() - + * + * This macro will return the device for this io request object + */ +#define scic_sds_request_get_device(sci_req) \ + ((sci_req)->target_device) + +/** + * scic_sds_request_get_port() - + * + * This macro will return the port for this io request object + */ +#define scic_sds_request_get_port(sci_req) \ + scic_sds_remote_device_get_port(scic_sds_request_get_device(sci_req)) + +/** + * scic_sds_request_get_post_context() - + * + * This macro returns the constructed post context result for the io request. + */ +#define scic_sds_request_get_post_context(sci_req) \ + ((sci_req)->post_context) + +/** + * scic_sds_request_get_task_context() - + * + * This is a helper macro to return the os handle for this request object. + */ +#define scic_sds_request_get_task_context(request) \ + ((request)->task_context_buffer) + +/** + * scic_sds_request_set_status() - + * + * This macro will set the scu hardware status and sci request completion + * status for an io request. + */ +#define scic_sds_request_set_status(request, scu_status_code, sci_status_code) \ + { \ + (request)->scu_status = (scu_status_code); \ + (request)->sci_status = (sci_status_code); \ + } + +#define scic_sds_request_complete(a_request) \ + ((a_request)->state_handlers->complete_handler(a_request)) + + +extern enum sci_status +scic_sds_io_request_tc_completion(struct scic_sds_request *request, u32 completion_code); + +/** + * SCU_SGL_ZERO() - + * + * This macro zeros the hardware SGL element data + */ +#define SCU_SGL_ZERO(scu_sge) \ + { \ + (scu_sge).length = 0; \ + (scu_sge).address_lower = 0; \ + (scu_sge).address_upper = 0; \ + (scu_sge).address_modifier = 0; \ + } + +/** + * SCU_SGL_COPY() - + * + * This macro copys the SGL Element data from the host os to the hardware SGL + * elment data + */ +#define SCU_SGL_COPY(scu_sge, os_sge) \ + { \ + (scu_sge).length = sg_dma_len(sg); \ + (scu_sge).address_upper = \ + upper_32_bits(sg_dma_address(sg)); \ + (scu_sge).address_lower = \ + lower_32_bits(sg_dma_address(sg)); \ + (scu_sge).address_modifier = 0; \ + } + +void scic_sds_request_build_sgl(struct scic_sds_request *sci_req); +void scic_sds_stp_request_assign_buffers(struct scic_sds_request *sci_req); +void scic_sds_smp_request_assign_buffers(struct scic_sds_request *sci_req); +enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req); +enum sci_status scic_sds_io_request_terminate(struct scic_sds_request *sci_req); +void scic_sds_io_request_copy_response(struct scic_sds_request *sci_req); +enum sci_status scic_sds_io_request_event_handler(struct scic_sds_request *sci_req, + u32 event_code); +enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req, + u32 frame_index); +enum sci_status scic_sds_task_request_terminate(struct scic_sds_request *sci_req); +enum sci_status scic_sds_request_started_state_abort_handler(struct scic_sds_request *sci_req); + +/** + * enum _scic_sds_io_request_started_task_mgmt_substates - This enumeration + * depicts all of the substates for a task management request to be + * performed in the STARTED super-state. + * + * + */ +enum scic_sds_raw_request_started_task_mgmt_substates { + /** + * The AWAIT_TC_COMPLETION sub-state indicates that the started raw + * task management request is waiting for the transmission of the + * initial frame (i.e. command, task, etc.). + */ + SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION, + + /** + * This sub-state indicates that the started task management request + * is waiting for the reception of an unsolicited frame + * (i.e. response IU). + */ + SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE, +}; + + +/** + * enum _scic_sds_smp_request_started_substates - This enumeration depicts all + * of the substates for a SMP request to be performed in the STARTED + * super-state. + * + * + */ +enum scic_sds_smp_request_started_substates { + /** + * This sub-state indicates that the started task management request + * is waiting for the reception of an unsolicited frame + * (i.e. response IU). + */ + SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE, + + /** + * The AWAIT_TC_COMPLETION sub-state indicates that the started SMP request is + * waiting for the transmission of the initial frame (i.e. command, task, etc.). + */ + SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION, +}; + + + +/* XXX open code in caller */ +static inline void *scic_request_get_virt_addr(struct scic_sds_request *sci_req, + dma_addr_t phys_addr) +{ + struct isci_request *ireq = sci_req_to_ireq(sci_req); + dma_addr_t offset; + + BUG_ON(phys_addr < ireq->request_daddr); + + offset = phys_addr - ireq->request_daddr; + + BUG_ON(offset >= sizeof(*ireq)); + + return (char *)ireq + offset; +} + +/* XXX open code in caller */ +static inline dma_addr_t scic_io_request_get_dma_addr(struct scic_sds_request *sci_req, + void *virt_addr) +{ + struct isci_request *ireq = sci_req_to_ireq(sci_req); + + char *requested_addr = (char *)virt_addr; + char *base_addr = (char *)ireq; + + BUG_ON(requested_addr < base_addr); + BUG_ON((requested_addr - base_addr) >= sizeof(*ireq)); + + return ireq->request_daddr + (requested_addr - base_addr); +} + /** * This function gets the status of the request object. * @request: This parameter points to the isci_request object @@ -337,12 +750,6 @@ static inline void isci_request_unmap_sgl( } } - -void isci_request_io_request_complete( - struct isci_host *isci_host, - struct isci_request *request, - enum sci_io_status completion_status); - /** * isci_request_io_request_get_next_sge() - This function is called by the sci * core to retrieve the next sge for a given request. @@ -385,13 +792,16 @@ static inline void *isci_request_io_request_get_next_sge( return ret; } - -void isci_terminate_pending_requests( - struct isci_host *isci_host, - struct isci_remote_device *isci_device, - enum isci_request_status new_request_state); - - - - +void isci_terminate_pending_requests(struct isci_host *isci_host, + struct isci_remote_device *isci_device, + enum isci_request_status new_request_state); +enum sci_status scic_task_request_construct(struct scic_sds_controller *scic, + struct scic_sds_remote_device *sci_dev, + u16 io_tag, + struct scic_sds_request *sci_req); +enum sci_status scic_task_request_construct_ssp(struct scic_sds_request *sci_req); +enum sci_status scic_task_request_construct_sata(struct scic_sds_request *sci_req); +enum sci_status scic_io_request_construct_smp(struct scic_sds_request *sci_req); +void scic_stp_io_request_set_ncq_tag(struct scic_sds_request *sci_req, u16 ncq_tag); +void scic_sds_smp_request_copy_response(struct scic_sds_request *sci_req); #endif /* !defined(_ISCI_REQUEST_H_) */ -- cgit v1.2.3 From f139303d17c47eff4c5b5407dee0a6d43e8fd146 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 10 May 2011 02:28:47 -0700 Subject: isci: merge ssp task management substates into primary state machine Remove usage of the request substate machine for ssp task management requests identified by: ireq->ttype == tmf_task && dev->dev_type == SAS_END_DEV; The only routine that checks the base 'started' state is scic_sds_io_request_tc_completion which calls the substate machine handler if we are not in the 'started' state or we are 'started' and no substate machine is defined. This routine requires no conversion because we have transitioned out of 'started' and the substate routine will be called naturally as a result. There are also no side effects of this conversion on exiting the 'started', state because it only stops the substate machine, which is no longer relevant for this transaction type. Reported-by: Christoph Hellwig Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 932ea767c8c2..b5c5b063a369 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -295,6 +295,20 @@ enum sci_base_request_states { */ SCI_BASE_REQUEST_STATE_STARTED, + /** + * The AWAIT_TC_COMPLETION sub-state indicates that the started raw + * task management request is waiting for the transmission of the + * initial frame (i.e. command, task, etc.). + */ + SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION, + + /** + * This sub-state indicates that the started task management request + * is waiting for the reception of an unsolicited frame + * (i.e. response IU). + */ + SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE, + /** * This state indicates that the request has completed. * This state is entered from the STARTED state. This state is entered from @@ -451,7 +465,6 @@ void scic_sds_stp_request_assign_buffers(struct scic_sds_request *sci_req); void scic_sds_smp_request_assign_buffers(struct scic_sds_request *sci_req); enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req); enum sci_status scic_sds_io_request_terminate(struct scic_sds_request *sci_req); -void scic_sds_io_request_copy_response(struct scic_sds_request *sci_req); enum sci_status scic_sds_io_request_event_handler(struct scic_sds_request *sci_req, u32 event_code); enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req, @@ -459,29 +472,6 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r enum sci_status scic_sds_task_request_terminate(struct scic_sds_request *sci_req); enum sci_status scic_sds_request_started_state_abort_handler(struct scic_sds_request *sci_req); -/** - * enum _scic_sds_io_request_started_task_mgmt_substates - This enumeration - * depicts all of the substates for a task management request to be - * performed in the STARTED super-state. - * - * - */ -enum scic_sds_raw_request_started_task_mgmt_substates { - /** - * The AWAIT_TC_COMPLETION sub-state indicates that the started raw - * task management request is waiting for the transmission of the - * initial frame (i.e. command, task, etc.). - */ - SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION, - - /** - * This sub-state indicates that the started task management request - * is waiting for the reception of an unsolicited frame - * (i.e. response IU). - */ - SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE, -}; - /** * enum _scic_sds_smp_request_started_substates - This enumeration depicts all -- cgit v1.2.3 From c72086e3c2897eaca5b99c005dd9844fdc784981 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 10 May 2011 02:28:48 -0700 Subject: isci: merge smp request substates into primary state machine Remove usage of the request substate machine for smp requests identified by: task->task_proto == SAS_PROTOCOL_SMP While merging over the smp_request infrastructure noticed that all the assign buffer implementations are now equal, so moved it to scic_sds_general_request_construct. Reported-by: Christoph Hellwig Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index b5c5b063a369..d090cb1a14d6 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -88,7 +88,7 @@ enum sci_request_protocol { SCIC_SMP_PROTOCOL, SCIC_SSP_PROTOCOL, SCIC_STP_PROTOCOL -}; /* XXX remove me, use sas_task.dev instead */; +}; /* XXX remove me, use sas_task.{dev|task_proto} instead */; struct scic_sds_request { /** @@ -309,6 +309,19 @@ enum sci_base_request_states { */ SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE, + /** + * This sub-state indicates that the started task management request + * is waiting for the reception of an unsolicited frame + * (i.e. response IU). + */ + SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE, + + /** + * The AWAIT_TC_COMPLETION sub-state indicates that the started SMP request is + * waiting for the transmission of the initial frame (i.e. command, task, etc.). + */ + SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION, + /** * This state indicates that the request has completed. * This state is entered from the STARTED state. This state is entered from @@ -461,8 +474,6 @@ scic_sds_io_request_tc_completion(struct scic_sds_request *request, u32 completi } void scic_sds_request_build_sgl(struct scic_sds_request *sci_req); -void scic_sds_stp_request_assign_buffers(struct scic_sds_request *sci_req); -void scic_sds_smp_request_assign_buffers(struct scic_sds_request *sci_req); enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req); enum sci_status scic_sds_io_request_terminate(struct scic_sds_request *sci_req); enum sci_status scic_sds_io_request_event_handler(struct scic_sds_request *sci_req, @@ -473,30 +484,6 @@ enum sci_status scic_sds_task_request_terminate(struct scic_sds_request *sci_req enum sci_status scic_sds_request_started_state_abort_handler(struct scic_sds_request *sci_req); -/** - * enum _scic_sds_smp_request_started_substates - This enumeration depicts all - * of the substates for a SMP request to be performed in the STARTED - * super-state. - * - * - */ -enum scic_sds_smp_request_started_substates { - /** - * This sub-state indicates that the started task management request - * is waiting for the reception of an unsolicited frame - * (i.e. response IU). - */ - SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE, - - /** - * The AWAIT_TC_COMPLETION sub-state indicates that the started SMP request is - * waiting for the transmission of the initial frame (i.e. command, task, etc.). - */ - SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION, -}; - - - /* XXX open code in caller */ static inline void *scic_request_get_virt_addr(struct scic_sds_request *sci_req, dma_addr_t phys_addr) @@ -791,7 +778,6 @@ enum sci_status scic_task_request_construct(struct scic_sds_controller *scic, struct scic_sds_request *sci_req); enum sci_status scic_task_request_construct_ssp(struct scic_sds_request *sci_req); enum sci_status scic_task_request_construct_sata(struct scic_sds_request *sci_req); -enum sci_status scic_io_request_construct_smp(struct scic_sds_request *sci_req); void scic_stp_io_request_set_ncq_tag(struct scic_sds_request *sci_req, u16 ncq_tag); void scic_sds_smp_request_copy_response(struct scic_sds_request *sci_req); #endif /* !defined(_ISCI_REQUEST_H_) */ -- cgit v1.2.3 From 5dec6f4e41340196d223caf922578c44dfe2295a Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 10 May 2011 02:28:49 -0700 Subject: isci: merge stp request substates into primary state machine Remove usage of the request substate machine for stp requests, and kill the request substate infrastructure. Similar to the previous conversions this adds the substates to the primary state machine and arranges for the 'started' state to transition to the proper stp substate. Reported-by: Christoph Hellwig Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 113 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 95 insertions(+), 18 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index d090cb1a14d6..95b65891fc41 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -59,7 +59,6 @@ #include "isci.h" #include "host.h" #include "scu_task_context.h" -#include "stp_request.h" /** * struct isci_request_status - This enum defines the possible states of an I/O @@ -90,6 +89,63 @@ enum sci_request_protocol { SCIC_STP_PROTOCOL }; /* XXX remove me, use sas_task.{dev|task_proto} instead */; +struct scic_sds_stp_request { + union { + u32 ncq; + + u32 udma; + + struct scic_sds_stp_pio_request { + /** + * Total transfer for the entire PIO request recorded at request constuction + * time. + * + * @todo Should we just decrement this value for each byte of data transitted + * or received to elemenate the current_transfer_bytes field? + */ + u32 total_transfer_bytes; + + /** + * Total number of bytes received/transmitted in data frames since the start + * of the IO request. At the end of the IO request this should equal the + * total_transfer_bytes. + */ + u32 current_transfer_bytes; + + /** + * The number of bytes requested in the in the PIO setup. + */ + u32 pio_transfer_bytes; + + /** + * PIO Setup ending status value to tell us if we need to wait for another FIS + * or if the transfer is complete. On the receipt of a D2H FIS this will be + * the status field of that FIS. + */ + u8 ending_status; + + /** + * On receipt of a D2H FIS this will be the ending error field if the + * ending_status has the SATA_STATUS_ERR bit set. + */ + u8 ending_error; + + struct scic_sds_request_pio_sgl { + struct scu_sgl_element_pair *sgl_pair; + u8 sgl_set; + u32 sgl_offset; + } request_current; + } pio; + + struct { + /** + * The number of bytes requested in the PIO setup before CDB data frame. + */ + u32 device_preferred_cdb_length; + } packet; + } type; +}; + struct scic_sds_request { /** * This field contains the information for the base request state machine. @@ -158,12 +214,6 @@ struct scic_sds_request { */ bool is_task_management_request; - /** - * This field indicates that this request contains an initialized started - * substate machine. - */ - bool has_started_substate_machine; - /** * This field is a pointer to the stored rx frame data. It is used in STP * internal requests and SMP response frames. If this field is non-NULL the @@ -173,12 +223,6 @@ struct scic_sds_request { */ u32 saved_rx_frame_index; - /** - * This field specifies the data necessary to manage the sub-state - * machine executed while in the SCI_BASE_REQUEST_STATE_STARTED state. - */ - struct sci_base_state_machine started_substate_machine; - /** * This field specifies the current state handlers in place for this * IO Request object. This field is updated each time the request @@ -295,6 +339,41 @@ enum sci_base_request_states { */ SCI_BASE_REQUEST_STATE_STARTED, + SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE, + SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE, + + SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE, + SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE, + + SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE, + SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE, + SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE, + + /** + * While in this state the IO request object is waiting for the TC completion + * notification for the H2D Register FIS + */ + SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE, + + /** + * While in this state the IO request object is waiting for either a PIO Setup + * FIS or a D2H register FIS. The type of frame received is based on the + * result of the prior frame and line conditions. + */ + SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE, + + /** + * While in this state the IO request object is waiting for a DATA frame from + * the device. + */ + SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE, + + /** + * While in this state the IO request object is waiting to transmit the next data + * frame to the device. + */ + SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE, + /** * The AWAIT_TC_COMPLETION sub-state indicates that the started raw * task management request is waiting for the transmission of the @@ -383,8 +462,6 @@ struct scic_sds_io_request_state_handler { }; -extern const struct sci_base_state scic_sds_io_request_started_task_mgmt_substate_table[]; - /** * scic_sds_request_get_controller() - * @@ -473,7 +550,6 @@ scic_sds_io_request_tc_completion(struct scic_sds_request *request, u32 completi (scu_sge).address_modifier = 0; \ } -void scic_sds_request_build_sgl(struct scic_sds_request *sci_req); enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req); enum sci_status scic_sds_io_request_terminate(struct scic_sds_request *sci_req); enum sci_status scic_sds_io_request_event_handler(struct scic_sds_request *sci_req, @@ -481,8 +557,6 @@ enum sci_status scic_sds_io_request_event_handler(struct scic_sds_request *sci_r enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req, u32 frame_index); enum sci_status scic_sds_task_request_terminate(struct scic_sds_request *sci_req); -enum sci_status scic_sds_request_started_state_abort_handler(struct scic_sds_request *sci_req); - /* XXX open code in caller */ static inline void *scic_request_get_virt_addr(struct scic_sds_request *sci_req, @@ -778,6 +852,9 @@ enum sci_status scic_task_request_construct(struct scic_sds_controller *scic, struct scic_sds_request *sci_req); enum sci_status scic_task_request_construct_ssp(struct scic_sds_request *sci_req); enum sci_status scic_task_request_construct_sata(struct scic_sds_request *sci_req); +enum sci_status scic_sds_stp_udma_request_construct(struct scic_sds_request *sci_req, + u32 transfer_length, + enum dma_data_direction dir); void scic_stp_io_request_set_ncq_tag(struct scic_sds_request *sci_req, u16 ncq_tag); void scic_sds_smp_request_copy_response(struct scic_sds_request *sci_req); #endif /* !defined(_ISCI_REQUEST_H_) */ -- cgit v1.2.3 From f00e6ba4996a34f098fe50c78077f0568fd838ec Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 10 May 2011 02:39:11 -0700 Subject: isci: unify request abort handlers Unify the implementation in scic_sds_io_request_terminate and kill the state handler. Reported-by: Christoph Hellwig Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 95b65891fc41..b17336952314 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -444,12 +444,6 @@ struct scic_sds_io_request_state_handler { */ scic_sds_io_request_handler_t start_handler; - /** - * The abort_handler specifies the method invoked when a user attempts to - * abort a request. - */ - scic_sds_io_request_handler_t abort_handler; - /** * The complete_handler specifies the method invoked when a user attempts to * complete a request. @@ -459,7 +453,6 @@ struct scic_sds_io_request_state_handler { scic_sds_io_request_task_completion_handler_t tc_completion_handler; scic_sds_io_request_event_handler_t event_handler; scic_sds_io_request_frame_handler_t frame_handler; - }; /** -- cgit v1.2.3 From f4636a7b2ab8288466b83a8459d47c43143a70dc Mon Sep 17 00:00:00 2001 From: Piotr Sawicki Date: Tue, 10 May 2011 23:50:32 +0000 Subject: isci: unify request start handlers Unify the implementation in scic_sds_request_start and kill the state handler. Reported-by: Christoph Hellwig Signed-off-by: Piotr Sawicki [remove scic_sds_request_constructed_state_start_handler] Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index b17336952314..bf8ac1860850 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -438,12 +438,6 @@ typedef enum sci_status (*scic_sds_io_request_task_completion_handler_t) * */ struct scic_sds_io_request_state_handler { - /** - * The start_handler specifies the method invoked when a user attempts to - * start a request. - */ - scic_sds_io_request_handler_t start_handler; - /** * The complete_handler specifies the method invoked when a user attempts to * complete a request. -- cgit v1.2.3 From d1c637c35b33ddd2b405956e04b50939bb10ed2a Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 11 May 2011 08:27:47 -0700 Subject: isci: unify request frame handlers Unify the implementation in scic_sds_io_request_frame_handler and kill the state handler. Reported-by: Christoph Hellwig Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index bf8ac1860850..c9070e708948 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -424,8 +424,6 @@ enum sci_base_request_states { typedef enum sci_status (*scic_sds_io_request_handler_t) (struct scic_sds_request *request); -typedef enum sci_status (*scic_sds_io_request_frame_handler_t) - (struct scic_sds_request *req, u32 frame); typedef enum sci_status (*scic_sds_io_request_event_handler_t) (struct scic_sds_request *req, u32 event); typedef enum sci_status (*scic_sds_io_request_task_completion_handler_t) @@ -446,7 +444,6 @@ struct scic_sds_io_request_state_handler { scic_sds_io_request_task_completion_handler_t tc_completion_handler; scic_sds_io_request_event_handler_t event_handler; - scic_sds_io_request_frame_handler_t frame_handler; }; /** @@ -839,9 +836,6 @@ enum sci_status scic_task_request_construct(struct scic_sds_controller *scic, struct scic_sds_request *sci_req); enum sci_status scic_task_request_construct_ssp(struct scic_sds_request *sci_req); enum sci_status scic_task_request_construct_sata(struct scic_sds_request *sci_req); -enum sci_status scic_sds_stp_udma_request_construct(struct scic_sds_request *sci_req, - u32 transfer_length, - enum dma_data_direction dir); void scic_stp_io_request_set_ncq_tag(struct scic_sds_request *sci_req, u16 ncq_tag); void scic_sds_smp_request_copy_response(struct scic_sds_request *sci_req); #endif /* !defined(_ISCI_REQUEST_H_) */ -- cgit v1.2.3 From a7e255a34220ba57eeeb75637c911974e54c08e7 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 11 May 2011 08:27:47 -0700 Subject: isci: remove request task context completion state handler Unlike the other conversions this only updates scic_sds_io_request_tc_completion() to call the old state handlers directly (with less verbose names). This was done for future patch readability, the implementations have only minor differences for different completion codes. Without a reference to the function name it would be difficult to dicern which state is being updated. Considered changing the order to look up the completion code before the state but that was not a clean conversion either. Reported-by: Christoph Hellwig Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index c9070e708948..e13ca3f7c8d7 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -426,8 +426,6 @@ typedef enum sci_status (*scic_sds_io_request_handler_t) (struct scic_sds_request *request); typedef enum sci_status (*scic_sds_io_request_event_handler_t) (struct scic_sds_request *req, u32 event); -typedef enum sci_status (*scic_sds_io_request_task_completion_handler_t) - (struct scic_sds_request *req, u32 completion_code); /** * struct scic_sds_io_request_state_handler - This is the SDS core definition @@ -442,7 +440,6 @@ struct scic_sds_io_request_state_handler { */ scic_sds_io_request_handler_t complete_handler; - scic_sds_io_request_task_completion_handler_t tc_completion_handler; scic_sds_io_request_event_handler_t event_handler; }; -- cgit v1.2.3 From 79e2b6b27699c916e3c7cda18a26d47fea6017fb Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 11 May 2011 08:29:56 -0700 Subject: isci: remove the completion and event state handlers With these handlers gone the rest of the state handler infrastructure is removed. Added some WARN_ONCEs where previously we would cause NULL pointer dereferences or silently run handlers from a previous state. Reported-by: Christoph Hellwig Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index e13ca3f7c8d7..31d6d5717473 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -223,13 +223,6 @@ struct scic_sds_request { */ u32 saved_rx_frame_index; - /** - * This field specifies the current state handlers in place for this - * IO Request object. This field is updated each time the request - * changes state. - */ - const struct scic_sds_io_request_state_handler *state_handlers; - /** * This field in the recorded device sequence for the io request. This is * recorded during the build operation and is compared in the start @@ -422,27 +415,6 @@ enum sci_base_request_states { SCI_BASE_REQUEST_STATE_FINAL, }; -typedef enum sci_status (*scic_sds_io_request_handler_t) - (struct scic_sds_request *request); -typedef enum sci_status (*scic_sds_io_request_event_handler_t) - (struct scic_sds_request *req, u32 event); - -/** - * struct scic_sds_io_request_state_handler - This is the SDS core definition - * of the state handlers. - * - * - */ -struct scic_sds_io_request_state_handler { - /** - * The complete_handler specifies the method invoked when a user attempts to - * complete a request. - */ - scic_sds_io_request_handler_t complete_handler; - - scic_sds_io_request_event_handler_t event_handler; -}; - /** * scic_sds_request_get_controller() - * @@ -495,13 +467,6 @@ struct scic_sds_io_request_state_handler { (request)->sci_status = (sci_status_code); \ } -#define scic_sds_request_complete(a_request) \ - ((a_request)->state_handlers->complete_handler(a_request)) - - -extern enum sci_status -scic_sds_io_request_tc_completion(struct scic_sds_request *request, u32 completion_code); - /** * SCU_SGL_ZERO() - * @@ -538,6 +503,8 @@ enum sci_status scic_sds_io_request_event_handler(struct scic_sds_request *sci_r enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req, u32 frame_index); enum sci_status scic_sds_task_request_terminate(struct scic_sds_request *sci_req); +extern enum sci_status scic_sds_request_complete(struct scic_sds_request *sci_req); +extern enum sci_status scic_sds_io_request_tc_completion(struct scic_sds_request *sci_req, u32 code); /* XXX open code in caller */ static inline void *scic_request_get_virt_addr(struct scic_sds_request *sci_req, -- cgit v1.2.3 From e301370ac553a9a0ac0d1d25e769b86cf60395b3 Mon Sep 17 00:00:00 2001 From: Edmund Nadolski Date: Thu, 2 Jun 2011 00:10:43 +0000 Subject: isci: state machine cleanup This cleans up several areas of the state machine mechanism: o Rename sci_base_state_machine_change_state to sci_change_state o Remove sci_base_state_machine_get_state function o Rename 'state_machine' struct member to 'sm' in client structs o Shorten the name of request states o Shorten state machine state names as follows: SCI_BASE_CONTROLLER_STATE_xxx to SCIC_xxx SCI_BASE_PHY_STATE_xxx to SCI_PHY_xxx SCIC_SDS_PHY_STARTING_SUBSTATE_xxx to SCI_PHY_SUB_xxx SCI_BASE_PORT_STATE_xxx to SCI_PORT_xxx and SCIC_SDS_PORT_READY_SUBSTATE_xxx to SCI_PORT_SUB_xxx SCI_BASE_REMOTE_DEVICE_STATE_xxx to SCI_DEV_xxx SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_xxx to SCI_STP_DEV_xxx SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_xxx to SCI_SMP_DEV_xxx SCIC_SDS_REMOTE_NODE_CONTEXT_xxx_STATE to SCI_RNC_xxx Signed-off-by: Edmund Nadolski Signed-off-by: Dave Jiang Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 357 +++++++++++++++++++++----------------------- 1 file changed, 173 insertions(+), 184 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 31d6d5717473..757cd99ae2ed 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -96,37 +96,42 @@ struct scic_sds_stp_request { u32 udma; struct scic_sds_stp_pio_request { - /** - * Total transfer for the entire PIO request recorded at request constuction - * time. + /* + * Total transfer for the entire PIO request recorded + * at request constuction time. * - * @todo Should we just decrement this value for each byte of data transitted - * or received to elemenate the current_transfer_bytes field? + * @todo Should we just decrement this value for each + * byte of data transitted or received to elemenate + * the current_transfer_bytes field? */ u32 total_transfer_bytes; - /** - * Total number of bytes received/transmitted in data frames since the start - * of the IO request. At the end of the IO request this should equal the + /* + * Total number of bytes received/transmitted in data + * frames since the start of the IO request. At the + * end of the IO request this should equal the * total_transfer_bytes. */ u32 current_transfer_bytes; - /** - * The number of bytes requested in the in the PIO setup. + /* + * The number of bytes requested in the in the PIO + * setup. */ u32 pio_transfer_bytes; - /** - * PIO Setup ending status value to tell us if we need to wait for another FIS - * or if the transfer is complete. On the receipt of a D2H FIS this will be + /* + * PIO Setup ending status value to tell us if we need + * to wait for another FIS or if the transfer is + * complete. On the receipt of a D2H FIS this will be * the status field of that FIS. */ u8 ending_status; - /** - * On receipt of a D2H FIS this will be the ending error field if the - * ending_status has the SATA_STATUS_ERR bit set. + /* + * On receipt of a D2H FIS this will be the ending + * error field if the ending_status has the + * SATA_STATUS_ERR bit set. */ u8 ending_error; @@ -138,8 +143,9 @@ struct scic_sds_stp_request { } pio; struct { - /** - * The number of bytes requested in the PIO setup before CDB data frame. + /* + * The number of bytes requested in the PIO setup + * before CDB data frame. */ u32 device_preferred_cdb_length; } packet; @@ -147,57 +153,59 @@ struct scic_sds_stp_request { }; struct scic_sds_request { - /** - * This field contains the information for the base request state machine. + /* + * This field contains the information for the base request state + * machine. */ - struct sci_base_state_machine state_machine; + struct sci_base_state_machine sm; - /** + /* * This field simply points to the controller to which this IO request * is associated. */ struct scic_sds_controller *owning_controller; - /** - * This field simply points to the remote device to which this IO request - * is associated. + /* + * This field simply points to the remote device to which this IO + * request is associated. */ struct scic_sds_remote_device *target_device; - /** + /* * This field is utilized to determine if the SCI user is managing * the IO tag for this request or if the core is managing it. */ bool was_tag_assigned_by_user; - /** + /* * This field indicates the IO tag for this request. The IO tag is * comprised of the task_index and a sequence count. The sequence count * is utilized to help identify tasks from one life to another. */ u16 io_tag; - /** + /* * This field specifies the protocol being utilized for this * IO request. */ enum sci_request_protocol protocol; - /** + /* * This field indicates the completion status taken from the SCUs - * completion code. It indicates the completion result for the SCU hardware. + * completion code. It indicates the completion result for the SCU + * hardware. */ u32 scu_status; - /** - * This field indicates the completion status returned to the SCI user. It - * indicates the users view of the io request completion. + /* + * This field indicates the completion status returned to the SCI user. + * It indicates the users view of the io request completion. */ u32 sci_status; - /** - * This field contains the value to be utilized when posting (e.g. Post_TC, - * Post_TC_Abort) this request to the silicon. + /* + * This field contains the value to be utilized when posting + * (e.g. Post_TC, * Post_TC_Abort) this request to the silicon. */ u32 post_context; @@ -208,26 +216,26 @@ struct scic_sds_request { #define SCU_SGL_SIZE ((SCU_IO_REQUEST_SGE_COUNT + 1) / 2) struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32))); - /** + /* * This field indicates if this request is a task management request or * normal IO request. */ bool is_task_management_request; - /** - * This field is a pointer to the stored rx frame data. It is used in STP - * internal requests and SMP response frames. If this field is non-NULL the - * saved frame must be released on IO request completion. + /* + * This field is a pointer to the stored rx frame data. It is used in + * STP internal requests and SMP response frames. If this field is + * non-NULL the saved frame must be released on IO request completion. * * @todo In the future do we want to keep a list of RX frame buffers? */ u32 saved_rx_frame_index; - /** - * This field in the recorded device sequence for the io request. This is - * recorded during the build operation and is compared in the start - * operation. If the sequence is different then there was a change of - * devices from the build to start operations. + /* + * This field in the recorded device sequence for the io request. + * This is recorded during the build operation and is compared in the + * start operation. If the sequence is different then there was a + * change of devices from the build to start operations. */ u8 device_sequence; @@ -286,7 +294,7 @@ struct isci_request { dma_addr_t request_daddr; dma_addr_t zero_scatter_daddr; - unsigned int num_sg_entries; /* returned by pci_alloc_sg */ + unsigned int num_sg_entries; /* returned by pci_alloc_sg */ /** Note: "io_request_completion" is completed in two different ways * depending on whether this is a TMF or regular request. @@ -315,104 +323,105 @@ static inline struct isci_request *sci_req_to_ireq(struct scic_sds_request *sci_ * */ enum sci_base_request_states { - /** + /* * Simply the initial state for the base request state machine. */ - SCI_BASE_REQUEST_STATE_INITIAL, + SCI_REQ_INIT, - /** - * This state indicates that the request has been constructed. This state - * is entered from the INITIAL state. + /* + * This state indicates that the request has been constructed. + * This state is entered from the INITIAL state. */ - SCI_BASE_REQUEST_STATE_CONSTRUCTED, + SCI_REQ_CONSTRUCTED, - /** - * This state indicates that the request has been started. This state is - * entered from the CONSTRUCTED state. + /* + * This state indicates that the request has been started. This state + * is entered from the CONSTRUCTED state. */ - SCI_BASE_REQUEST_STATE_STARTED, + SCI_REQ_STARTED, - SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE, - SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE, + SCI_REQ_STP_UDMA_WAIT_TC_COMP, + SCI_REQ_STP_UDMA_WAIT_D2H, - SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE, - SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE, + SCI_REQ_STP_NON_DATA_WAIT_H2D, + SCI_REQ_STP_NON_DATA_WAIT_D2H, - SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE, - SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE, - SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE, + SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED, + SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG, + SCI_REQ_STP_SOFT_RESET_WAIT_D2H, - /** - * While in this state the IO request object is waiting for the TC completion - * notification for the H2D Register FIS + /* + * While in this state the IO request object is waiting for the TC + * completion notification for the H2D Register FIS */ - SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE, + SCI_REQ_STP_PIO_WAIT_H2D, - /** - * While in this state the IO request object is waiting for either a PIO Setup - * FIS or a D2H register FIS. The type of frame received is based on the - * result of the prior frame and line conditions. + /* + * While in this state the IO request object is waiting for either a + * PIO Setup FIS or a D2H register FIS. The type of frame received is + * based on the result of the prior frame and line conditions. */ - SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE, + SCI_REQ_STP_PIO_WAIT_FRAME, - /** - * While in this state the IO request object is waiting for a DATA frame from - * the device. + /* + * While in this state the IO request object is waiting for a DATA + * frame from the device. */ - SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE, + SCI_REQ_STP_PIO_DATA_IN, - /** - * While in this state the IO request object is waiting to transmit the next data - * frame to the device. + /* + * While in this state the IO request object is waiting to transmit + * the next data frame to the device. */ - SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE, + SCI_REQ_STP_PIO_DATA_OUT, - /** + /* * The AWAIT_TC_COMPLETION sub-state indicates that the started raw * task management request is waiting for the transmission of the * initial frame (i.e. command, task, etc.). */ - SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION, + SCI_REQ_TASK_WAIT_TC_COMP, - /** + /* * This sub-state indicates that the started task management request * is waiting for the reception of an unsolicited frame * (i.e. response IU). */ - SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE, + SCI_REQ_TASK_WAIT_TC_RESP, - /** + /* * This sub-state indicates that the started task management request * is waiting for the reception of an unsolicited frame * (i.e. response IU). */ - SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE, + SCI_REQ_SMP_WAIT_RESP, - /** - * The AWAIT_TC_COMPLETION sub-state indicates that the started SMP request is - * waiting for the transmission of the initial frame (i.e. command, task, etc.). + /* + * The AWAIT_TC_COMPLETION sub-state indicates that the started SMP + * request is waiting for the transmission of the initial frame + * (i.e. command, task, etc.). */ - SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION, + SCI_REQ_SMP_WAIT_TC_COMP, - /** + /* * This state indicates that the request has completed. - * This state is entered from the STARTED state. This state is entered from - * the ABORTING state. + * This state is entered from the STARTED state. This state is entered + * from the ABORTING state. */ - SCI_BASE_REQUEST_STATE_COMPLETED, + SCI_REQ_COMPLETED, - /** + /* * This state indicates that the request is in the process of being * terminated/aborted. * This state is entered from the CONSTRUCTED state. * This state is entered from the STARTED state. */ - SCI_BASE_REQUEST_STATE_ABORTING, + SCI_REQ_ABORTING, - /** + /* * Simply the final state for the base request state machine. */ - SCI_BASE_REQUEST_STATE_FINAL, + SCI_REQ_FINAL, }; /** @@ -498,13 +507,18 @@ enum sci_base_request_states { enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req); enum sci_status scic_sds_io_request_terminate(struct scic_sds_request *sci_req); -enum sci_status scic_sds_io_request_event_handler(struct scic_sds_request *sci_req, - u32 event_code); -enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req, - u32 frame_index); -enum sci_status scic_sds_task_request_terminate(struct scic_sds_request *sci_req); -extern enum sci_status scic_sds_request_complete(struct scic_sds_request *sci_req); -extern enum sci_status scic_sds_io_request_tc_completion(struct scic_sds_request *sci_req, u32 code); +enum sci_status +scic_sds_io_request_event_handler(struct scic_sds_request *sci_req, + u32 event_code); +enum sci_status +scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req, + u32 frame_index); +enum sci_status +scic_sds_task_request_terminate(struct scic_sds_request *sci_req); +extern enum sci_status +scic_sds_request_complete(struct scic_sds_request *sci_req); +extern enum sci_status +scic_sds_io_request_tc_completion(struct scic_sds_request *sci_req, u32 code); /* XXX open code in caller */ static inline void *scic_request_get_virt_addr(struct scic_sds_request *sci_req, @@ -523,8 +537,8 @@ static inline void *scic_request_get_virt_addr(struct scic_sds_request *sci_req, } /* XXX open code in caller */ -static inline dma_addr_t scic_io_request_get_dma_addr(struct scic_sds_request *sci_req, - void *virt_addr) +static inline dma_addr_t +scic_io_request_get_dma_addr(struct scic_sds_request *sci_req, void *virt_addr) { struct isci_request *ireq = sci_req_to_ireq(sci_req); @@ -543,9 +557,8 @@ static inline dma_addr_t scic_io_request_get_dma_addr(struct scic_sds_request *s * * status of the object as a isci_request_status enum. */ -static inline -enum isci_request_status isci_request_get_state( - struct isci_request *isci_request) +static inline enum isci_request_status +isci_request_get_state(struct isci_request *isci_request) { BUG_ON(isci_request == NULL); @@ -566,9 +579,9 @@ enum isci_request_status isci_request_get_state( * @status: This Parameter is the new status of the object * */ -static inline enum isci_request_status isci_request_change_state( - struct isci_request *isci_request, - enum isci_request_status status) +static inline enum isci_request_status +isci_request_change_state(struct isci_request *isci_request, + enum isci_request_status status) { enum isci_request_status old_state; unsigned long flags; @@ -597,10 +610,10 @@ static inline enum isci_request_status isci_request_change_state( * * state previous to any change. */ -static inline enum isci_request_status isci_request_change_started_to_newstate( - struct isci_request *isci_request, - struct completion *completion_ptr, - enum isci_request_status newstate) +static inline enum isci_request_status +isci_request_change_started_to_newstate(struct isci_request *isci_request, + struct completion *completion_ptr, + enum isci_request_status newstate) { enum isci_request_status old_state; unsigned long flags; @@ -615,6 +628,7 @@ static inline enum isci_request_status isci_request_change_started_to_newstate( isci_request->io_request_completion = completion_ptr; isci_request->status = newstate; } + spin_unlock_irqrestore(&isci_request->state_lock, flags); dev_dbg(&isci_request->isci_host->pdev->dev, @@ -635,13 +649,13 @@ static inline enum isci_request_status isci_request_change_started_to_newstate( * * state previous to any change. */ -static inline enum isci_request_status isci_request_change_started_to_aborted( - struct isci_request *isci_request, - struct completion *completion_ptr) +static inline enum isci_request_status +isci_request_change_started_to_aborted(struct isci_request *isci_request, + struct completion *completion_ptr) { - return isci_request_change_started_to_newstate( - isci_request, completion_ptr, aborted - ); + return isci_request_change_started_to_newstate(isci_request, + completion_ptr, + aborted); } /** * isci_request_free() - This function frees the request object. @@ -649,62 +663,33 @@ static inline enum isci_request_status isci_request_change_started_to_aborted( * @isci_request: This parameter points to the isci_request object * */ -static inline void isci_request_free( - struct isci_host *isci_host, - struct isci_request *isci_request) +static inline void isci_request_free(struct isci_host *isci_host, + struct isci_request *isci_request) { if (!isci_request) return; /* release the dma memory if we fail. */ - dma_pool_free(isci_host->dma_pool, isci_request, + dma_pool_free(isci_host->dma_pool, + isci_request, isci_request->request_daddr); } +#define isci_request_access_task(req) ((req)->ttype_ptr.io_task_ptr) -/* #define ISCI_REQUEST_VALIDATE_ACCESS - */ - -#ifdef ISCI_REQUEST_VALIDATE_ACCESS - -static inline -struct sas_task *isci_request_access_task(struct isci_request *isci_request) -{ - BUG_ON(isci_request->ttype != io_task); - return isci_request->ttype_ptr.io_task_ptr; -} - -static inline -struct isci_tmf *isci_request_access_tmf(struct isci_request *isci_request) -{ - BUG_ON(isci_request->ttype != tmf_task); - return isci_request->ttype_ptr.tmf_task_ptr; -} - -#else /* not ISCI_REQUEST_VALIDATE_ACCESS */ - -#define isci_request_access_task(RequestPtr) \ - ((RequestPtr)->ttype_ptr.io_task_ptr) - -#define isci_request_access_tmf(RequestPtr) \ - ((RequestPtr)->ttype_ptr.tmf_task_ptr) - -#endif /* not ISCI_REQUEST_VALIDATE_ACCESS */ - +#define isci_request_access_tmf(req) ((req)->ttype_ptr.tmf_task_ptr) -int isci_request_alloc_tmf( - struct isci_host *isci_host, - struct isci_tmf *isci_tmf, - struct isci_request **isci_request, - struct isci_remote_device *isci_device, - gfp_t gfp_flags); +int isci_request_alloc_tmf(struct isci_host *isci_host, + struct isci_tmf *isci_tmf, + struct isci_request **isci_request, + struct isci_remote_device *isci_device, + gfp_t gfp_flags); -int isci_request_execute( - struct isci_host *isci_host, - struct sas_task *task, - struct isci_request **request, - gfp_t gfp_flags); +int isci_request_execute(struct isci_host *isci_host, + struct sas_task *task, + struct isci_request **request, + gfp_t gfp_flags); /** * isci_request_unmap_sgl() - This function unmaps the DMA address of a given @@ -713,9 +698,8 @@ int isci_request_execute( * @*pdev: This Parameter is the pci_device struct for the controller * */ -static inline void isci_request_unmap_sgl( - struct isci_request *request, - struct pci_dev *pdev) +static inline void +isci_request_unmap_sgl(struct isci_request *request, struct pci_dev *pdev) { struct sas_task *task = isci_request_access_task(request); @@ -758,9 +742,9 @@ static inline void isci_request_unmap_sgl( * * pointer to the next sge for specified request. */ -static inline void *isci_request_io_request_get_next_sge( - struct isci_request *request, - void *current_sge_address) +static inline void * +isci_request_io_request_get_next_sge(struct isci_request *request, + void *current_sge_address) { struct sas_task *task = isci_request_access_task(request); void *ret = NULL; @@ -791,15 +775,20 @@ static inline void *isci_request_io_request_get_next_sge( return ret; } -void isci_terminate_pending_requests(struct isci_host *isci_host, - struct isci_remote_device *isci_device, - enum isci_request_status new_request_state); -enum sci_status scic_task_request_construct(struct scic_sds_controller *scic, - struct scic_sds_remote_device *sci_dev, - u16 io_tag, - struct scic_sds_request *sci_req); -enum sci_status scic_task_request_construct_ssp(struct scic_sds_request *sci_req); -enum sci_status scic_task_request_construct_sata(struct scic_sds_request *sci_req); -void scic_stp_io_request_set_ncq_tag(struct scic_sds_request *sci_req, u16 ncq_tag); +void +isci_terminate_pending_requests(struct isci_host *isci_host, + struct isci_remote_device *isci_device, + enum isci_request_status new_request_state); +enum sci_status +scic_task_request_construct(struct scic_sds_controller *scic, + struct scic_sds_remote_device *sci_dev, + u16 io_tag, + struct scic_sds_request *sci_req); +enum sci_status +scic_task_request_construct_ssp(struct scic_sds_request *sci_req); +enum sci_status +scic_task_request_construct_sata(struct scic_sds_request *sci_req); +void +scic_stp_io_request_set_ncq_tag(struct scic_sds_request *sci_req, u16 ncq_tag); void scic_sds_smp_request_copy_response(struct scic_sds_request *sci_req); #endif /* !defined(_ISCI_REQUEST_H_) */ -- cgit v1.2.3 From 7c78da3175177c905a75c54b5830029c778494ea Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 1 Jun 2011 16:00:01 -0700 Subject: isci: remove 'min memory' infrastructure The old 'core' had aspirations of running in severely memory constrained environments like bios option-rom, it's not needed for Linux and gets in the way of other cleanups (like unifying/reducing the number of structure members in scic_sds_controller/isci_host). This also fixes a theoretical bug in that the driver would blindly override the silicon advertised limits for number of ports, task contexts, and remote node contexts. Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 757cd99ae2ed..547c35cbe459 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -213,7 +213,7 @@ struct scic_sds_request { struct scu_task_context tc ____cacheline_aligned; /* could be larger with sg chaining */ - #define SCU_SGL_SIZE ((SCU_IO_REQUEST_SGE_COUNT + 1) / 2) + #define SCU_SGL_SIZE ((SCI_MAX_SCATTER_GATHER_ELEMENTS + 1) / 2) struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32))); /* -- cgit v1.2.3 From 980d3aeb3828b0fdf2a0b2e893d238130b014575 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 20 Jun 2011 15:11:22 -0700 Subject: isci: fix isci_terminate_pending() list management Walk through the list of pending requests being careful to consider that multiple requests can be terminated when the lock is dropped (i.e. invalidating the 'next' reference established by list_for_each_entry_safe). Also noticed that all callers to isci_terminate_pending_requests() specifying terminating, so just drop the parameter. Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 547c35cbe459..ac9368c5a6b5 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -776,9 +776,8 @@ isci_request_io_request_get_next_sge(struct isci_request *request, } void -isci_terminate_pending_requests(struct isci_host *isci_host, - struct isci_remote_device *isci_device, - enum isci_request_status new_request_state); +isci_terminate_pending_requests(struct isci_host *ihost, + struct isci_remote_device *idev); enum sci_status scic_task_request_construct(struct scic_sds_controller *scic, struct scic_sds_remote_device *sci_dev, -- cgit v1.2.3 From 0d0cf14c9bd2943ed5afd15df459f564d85eacde Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 13 Jun 2011 00:51:30 -0700 Subject: isci: cleanup request allocation Rather than return an error code and update a pointer that was passed by reference just return the request object directly (or null if allocation failed). Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index ac9368c5a6b5..8de2542f081f 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -679,16 +679,13 @@ static inline void isci_request_free(struct isci_host *isci_host, #define isci_request_access_tmf(req) ((req)->ttype_ptr.tmf_task_ptr) -int isci_request_alloc_tmf(struct isci_host *isci_host, - struct isci_tmf *isci_tmf, - struct isci_request **isci_request, - struct isci_remote_device *isci_device, - gfp_t gfp_flags); - +struct isci_request *isci_request_alloc_tmf(struct isci_host *ihost, + struct isci_tmf *isci_tmf, + struct isci_remote_device *idev, + gfp_t gfp_flags); int isci_request_execute(struct isci_host *isci_host, struct sas_task *task, - struct isci_request **request, gfp_t gfp_flags); /** -- cgit v1.2.3 From 209fae14fabfd48525e5630bebbbd4ca15090c60 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 13 Jun 2011 17:39:44 -0700 Subject: isci: atomic device lookup and reference counting We have unsafe references to remote devices that are notified to disappear at lldd_dev_gone. In order to clean this up we need a single canonical source for device lookups and stable references once a lookup succeeds. Towards that end guarantee that domain_device.lldd_dev is NULL as soon as we start the process of stopping a device. Any code path that wants to safely lookup a remote device must do so through task->dev->lldd_dev (isci_lookup_device()). For in-flight references outside of scic_lock we need reference counting to ensure that the device is not recycled before we are done with it. Simplify device back references to just scic_sds_request.target_device which is now the only permissible internal reference that is maintained relative to the reference count. There were two occasions where we wanted new i/o's to be treated as SAS_TASK_UNDELIVERED but where the domain_dev->lldd_dev link is still intact. Introduce a 'gone' flag to prevent i/o while waiting for libsas to take action on the port down event. One 'core' leftover is that we currently call scic_remote_device_destruct() from isci_remote_device_deconstruct() which is called when the 'core' says the device is stopped. It would be more natural for the final put to trigger isci_remote_device_deconstruct() but this implementation is deferred as it requires other changes. Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 8de2542f081f..9bb7c36257f3 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -285,7 +285,6 @@ struct isci_request { struct isci_tmf *tmf_task_ptr; /* When ttype==tmf_task */ } ttype_ptr; struct isci_host *isci_host; - struct isci_remote_device *isci_device; /* For use in the requests_to_{complete|abort} lists: */ struct list_head completed_node; /* For use in the reqs_in_process list: */ @@ -681,12 +680,10 @@ static inline void isci_request_free(struct isci_host *isci_host, struct isci_request *isci_request_alloc_tmf(struct isci_host *ihost, struct isci_tmf *isci_tmf, - struct isci_remote_device *idev, gfp_t gfp_flags); -int isci_request_execute(struct isci_host *isci_host, - struct sas_task *task, - gfp_t gfp_flags); +int isci_request_execute(struct isci_host *ihost, struct isci_remote_device *idev, + struct sas_task *task, gfp_t gfp_flags); /** * isci_request_unmap_sgl() - This function unmaps the DMA address of a given -- cgit v1.2.3 From ff60639dc9a461883db9192d2da0674a00339f12 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 17 Jun 2011 13:34:43 -0700 Subject: isci: kill device_sequence Now that we have upleveled device reassignment protection to the isci_remote_device reference count we no longer need this level of self-defense. Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 9 --------- 1 file changed, 9 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 9bb7c36257f3..a91d1d6060ce 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -231,14 +231,6 @@ struct scic_sds_request { */ u32 saved_rx_frame_index; - /* - * This field in the recorded device sequence for the io request. - * This is recorded during the build operation and is compared in the - * start operation. If the sequence is different then there was a - * change of devices from the build to start operations. - */ - u8 device_sequence; - union { struct { union { @@ -262,7 +254,6 @@ struct scic_sds_request { struct dev_to_host_fis rsp; } stp; }; - }; static inline struct scic_sds_request *to_sci_req(struct scic_sds_stp_request *stp_req) -- cgit v1.2.3 From ddcc7e347a891937be65358b43f40b7f81185f8f Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 17 Jun 2011 10:40:43 -0700 Subject: isci: fix dma_unmap_sg usage One bug and a cleanup: 1/ Fix cases where we were unmapping invalid addresses (smp requests were being unmapped) [ 604.662770] ------------[ cut here ]------------ [ 604.668026] WARNING: at lib/dma-debug.c:800 check_unmap+0x418/0x740() [ 604.675315] Hardware name: SandyBridge Platform [ 604.680465] isci 0000:03:00.0: DMA-API: device driver tries to free an invalid DMA memory address 2/ The unmap routine is too large to be an inline function, and isci_request_io_request_get_next_sge is unused. Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 91 +-------------------------------------------- 1 file changed, 2 insertions(+), 89 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index a91d1d6060ce..324fb7b3ab42 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -672,97 +672,10 @@ static inline void isci_request_free(struct isci_host *isci_host, struct isci_request *isci_request_alloc_tmf(struct isci_host *ihost, struct isci_tmf *isci_tmf, gfp_t gfp_flags); - int isci_request_execute(struct isci_host *ihost, struct isci_remote_device *idev, struct sas_task *task, gfp_t gfp_flags); - -/** - * isci_request_unmap_sgl() - This function unmaps the DMA address of a given - * sgl - * @request: This parameter points to the isci_request object - * @*pdev: This Parameter is the pci_device struct for the controller - * - */ -static inline void -isci_request_unmap_sgl(struct isci_request *request, struct pci_dev *pdev) -{ - struct sas_task *task = isci_request_access_task(request); - - dev_dbg(&request->isci_host->pdev->dev, - "%s: request = %p, task = %p,\n" - "task->data_dir = %d, is_sata = %d\n ", - __func__, - request, - task, - task->data_dir, - sas_protocol_ata(task->task_proto)); - - if ((task->data_dir != PCI_DMA_NONE) && - !sas_protocol_ata(task->task_proto)) { - if (task->num_scatter == 0) - /* 0 indicates a single dma address */ - dma_unmap_single( - &pdev->dev, - request->zero_scatter_daddr, - task->total_xfer_len, - task->data_dir - ); - - else /* unmap the sgl dma addresses */ - dma_unmap_sg( - &pdev->dev, - task->scatter, - request->num_sg_entries, - task->data_dir - ); - } -} - -/** - * isci_request_io_request_get_next_sge() - This function is called by the sci - * core to retrieve the next sge for a given request. - * @request: This parameter is the isci_request object. - * @current_sge_address: This parameter is the last sge retrieved by the sci - * core for this request. - * - * pointer to the next sge for specified request. - */ -static inline void * -isci_request_io_request_get_next_sge(struct isci_request *request, - void *current_sge_address) -{ - struct sas_task *task = isci_request_access_task(request); - void *ret = NULL; - - dev_dbg(&request->isci_host->pdev->dev, - "%s: request = %p, " - "current_sge_address = %p, " - "num_scatter = %d\n", - __func__, - request, - current_sge_address, - task->num_scatter); - - if (!current_sge_address) /* First time through.. */ - ret = task->scatter; /* always task->scatter */ - else if (task->num_scatter == 0) /* Next element, if num_scatter == 0 */ - ret = NULL; /* there is only one element. */ - else - ret = sg_next(current_sge_address); /* sg_next returns NULL - * for the last element - */ - - dev_dbg(&request->isci_host->pdev->dev, - "%s: next sge address = %p\n", - __func__, - ret); - - return ret; -} - -void -isci_terminate_pending_requests(struct isci_host *ihost, - struct isci_remote_device *idev); +void isci_terminate_pending_requests(struct isci_host *ihost, + struct isci_remote_device *idev); enum sci_status scic_task_request_construct(struct scic_sds_controller *scic, struct scic_sds_remote_device *sci_dev, -- cgit v1.2.3 From e9bf709564e90abea25ca7aeae8c3de5cc6468d7 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 16 Jun 2011 16:59:56 -0700 Subject: isci: fix support for arbitrarily large smp requests Instead of duplicating the smp request buffer reuse the one provided by libsas. This future proofs the driver to support arbitrarily large smp requests, and shrinks the request structure size by ~700 bytes. Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 324fb7b3ab42..7c8b59a7c02c 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -244,7 +244,6 @@ struct scic_sds_request { } ssp; struct { - struct smp_req cmd; struct smp_resp rsp; } smp; -- cgit v1.2.3 From 9274f45ea551421cd3bf329de9dd8d1e6208285a Mon Sep 17 00:00:00 2001 From: Jeff Skirvin Date: Thu, 23 Jun 2011 17:09:02 -0700 Subject: isci: Terminate dev requests on FIS err bit rx in NCQ When the remote device transitions to a not-ready state because of an NCQ error condition, all outstanding requests to that device are terminated and completed to libsas on the normal path. The device then waits for a READ LOG EXT command to issue on the task management path. Signed-off-by: Jeff Skirvin Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 7c8b59a7c02c..9130f22a63b8 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -687,4 +687,13 @@ scic_task_request_construct_sata(struct scic_sds_request *sci_req); void scic_stp_io_request_set_ncq_tag(struct scic_sds_request *sci_req, u16 ncq_tag); void scic_sds_smp_request_copy_response(struct scic_sds_request *sci_req); + +static inline int isci_task_is_ncq_recovery(struct sas_task *task) +{ + return (sas_protocol_ata(task->task_proto) && + task->ata_task.fis.command == ATA_CMD_READ_LOG_EXT && + task->ata_task.fis.lbal == ATA_LOG_SATA_NCQ); + +} + #endif /* !defined(_ISCI_REQUEST_H_) */ -- cgit v1.2.3 From 312e0c2455c18716cf640d4336dcb1e9e5053818 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 28 Jun 2011 13:47:09 -0700 Subject: isci: unify can_queue tracking on the tci_pool, uplevel tag assignment The tci_pool tracks our outstanding command slots which are also the 'index' portion of our tags. Grabbing the tag early in ->lldd_execute_task let's us drop the isci_host_can_queue() and ->was_tag_assigned_by_user infrastructure. ->was_tag_assigned_by_user required the task context to be duplicated in request-local buffer. With the tci established early we can build the task_context directly into its final location and skip a memcpy. With the task context buffer at a known address at request construction we have the opportunity/obligation to also fix sgl handling. This rework feels like it belongs in another patch but the sgl handling and task_context are too intertwined. 1/ fix the 'ab' pair embedded in the task context to point to the 'cd' pair in the task context (previously we were prematurely linking to the staging buffer). 2/ fix the broken iteration of pio sgls that assumes all sgls are relative to the request, and does a dangerous looking reverse lookup of physical address to virtual address. Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 58 +++------------------------------------------ 1 file changed, 3 insertions(+), 55 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 9130f22a63b8..8c77c4cbe04a 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -136,7 +136,7 @@ struct scic_sds_stp_request { u8 ending_error; struct scic_sds_request_pio_sgl { - struct scu_sgl_element_pair *sgl_pair; + int sgl_index; u8 sgl_set; u32 sgl_offset; } request_current; @@ -171,12 +171,6 @@ struct scic_sds_request { */ struct scic_sds_remote_device *target_device; - /* - * This field is utilized to determine if the SCI user is managing - * the IO tag for this request or if the core is managing it. - */ - bool was_tag_assigned_by_user; - /* * This field indicates the IO tag for this request. The IO tag is * comprised of the task_index and a sequence count. The sequence count @@ -209,8 +203,7 @@ struct scic_sds_request { */ u32 post_context; - struct scu_task_context *task_context_buffer; - struct scu_task_context tc ____cacheline_aligned; + struct scu_task_context *tc; /* could be larger with sg chaining */ #define SCU_SGL_SIZE ((SCI_MAX_SCATTER_GATHER_ELEMENTS + 1) / 2) @@ -465,35 +458,6 @@ enum sci_base_request_states { (request)->sci_status = (sci_status_code); \ } -/** - * SCU_SGL_ZERO() - - * - * This macro zeros the hardware SGL element data - */ -#define SCU_SGL_ZERO(scu_sge) \ - { \ - (scu_sge).length = 0; \ - (scu_sge).address_lower = 0; \ - (scu_sge).address_upper = 0; \ - (scu_sge).address_modifier = 0; \ - } - -/** - * SCU_SGL_COPY() - - * - * This macro copys the SGL Element data from the host os to the hardware SGL - * elment data - */ -#define SCU_SGL_COPY(scu_sge, os_sge) \ - { \ - (scu_sge).length = sg_dma_len(sg); \ - (scu_sge).address_upper = \ - upper_32_bits(sg_dma_address(sg)); \ - (scu_sge).address_lower = \ - lower_32_bits(sg_dma_address(sg)); \ - (scu_sge).address_modifier = 0; \ - } - enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req); enum sci_status scic_sds_io_request_terminate(struct scic_sds_request *sci_req); enum sci_status @@ -509,22 +473,6 @@ scic_sds_request_complete(struct scic_sds_request *sci_req); extern enum sci_status scic_sds_io_request_tc_completion(struct scic_sds_request *sci_req, u32 code); -/* XXX open code in caller */ -static inline void *scic_request_get_virt_addr(struct scic_sds_request *sci_req, - dma_addr_t phys_addr) -{ - struct isci_request *ireq = sci_req_to_ireq(sci_req); - dma_addr_t offset; - - BUG_ON(phys_addr < ireq->request_daddr); - - offset = phys_addr - ireq->request_daddr; - - BUG_ON(offset >= sizeof(*ireq)); - - return (char *)ireq + offset; -} - /* XXX open code in caller */ static inline dma_addr_t scic_io_request_get_dma_addr(struct scic_sds_request *sci_req, void *virt_addr) @@ -672,7 +620,7 @@ struct isci_request *isci_request_alloc_tmf(struct isci_host *ihost, struct isci_tmf *isci_tmf, gfp_t gfp_flags); int isci_request_execute(struct isci_host *ihost, struct isci_remote_device *idev, - struct sas_task *task, gfp_t gfp_flags); + struct sas_task *task, u16 tag, gfp_t gfp_flags); void isci_terminate_pending_requests(struct isci_host *ihost, struct isci_remote_device *idev); enum sci_status -- cgit v1.2.3 From 38d8879baeb61b6946052739e7c03fa79b3a57f0 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 23 Jun 2011 14:33:48 -0700 Subject: isci: combine request flags Combine three bools into one unsigned long 'flags'. Doesn't increase the request size due to packing. (to do: optimize the structure layout). Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 8c77c4cbe04a..f440e421ea0e 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -209,12 +209,6 @@ struct scic_sds_request { #define SCU_SGL_SIZE ((SCI_MAX_SCATTER_GATHER_ELEMENTS + 1) / 2) struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32))); - /* - * This field indicates if this request is a task management request or - * normal IO request. - */ - bool is_task_management_request; - /* * This field is a pointer to the stored rx frame data. It is used in * STP internal requests and SMP response frames. If this field is @@ -260,8 +254,10 @@ struct isci_request { enum isci_request_status status; enum task_type ttype; unsigned short io_tag; - bool complete_in_target; - bool terminated; + #define IREQ_COMPLETE_IN_TARGET 0 + #define IREQ_TERMINATED 1 + #define IREQ_TMF 2 + unsigned long flags; union ttype_ptr_union { struct sas_task *io_task_ptr; /* When ttype==io_task */ -- cgit v1.2.3 From db0562509800a2d4cb5cb14a66413c30484f165c Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 17 Jun 2011 14:18:39 -0700 Subject: isci: preallocate requests the dma_pool interface is optimized for object_size << page_size which is not the case with isci_request objects and the dma_pool routines show up in the top of the profile. The old io_request_table which tracked whether tci slots were in-flight or not is replaced with an IREQ_ACTIVE flag per request. Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index f440e421ea0e..7628decbd535 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -257,6 +257,7 @@ struct isci_request { #define IREQ_COMPLETE_IN_TARGET 0 #define IREQ_TERMINATED 1 #define IREQ_TMF 2 + #define IREQ_ACTIVE 3 unsigned long flags; union ttype_ptr_union { @@ -590,33 +591,16 @@ isci_request_change_started_to_aborted(struct isci_request *isci_request, completion_ptr, aborted); } -/** - * isci_request_free() - This function frees the request object. - * @isci_host: This parameter specifies the ISCI host object - * @isci_request: This parameter points to the isci_request object - * - */ -static inline void isci_request_free(struct isci_host *isci_host, - struct isci_request *isci_request) -{ - if (!isci_request) - return; - - /* release the dma memory if we fail. */ - dma_pool_free(isci_host->dma_pool, - isci_request, - isci_request->request_daddr); -} #define isci_request_access_task(req) ((req)->ttype_ptr.io_task_ptr) #define isci_request_access_tmf(req) ((req)->ttype_ptr.tmf_task_ptr) -struct isci_request *isci_request_alloc_tmf(struct isci_host *ihost, - struct isci_tmf *isci_tmf, - gfp_t gfp_flags); +struct isci_request *isci_tmf_request_from_tag(struct isci_host *ihost, + struct isci_tmf *isci_tmf, + u16 tag); int isci_request_execute(struct isci_host *ihost, struct isci_remote_device *idev, - struct sas_task *task, u16 tag, gfp_t gfp_flags); + struct sas_task *task, u16 tag); void isci_terminate_pending_requests(struct isci_host *ihost, struct isci_remote_device *idev); enum sci_status -- cgit v1.2.3 From ba7cb22342a66505a831bb7e4541fef90e0193c9 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 27 Jun 2011 11:56:41 -0700 Subject: isci: rename / clean up scic_sds_stp_request * Rename scic_sds_stp_request to isci_stp_request * Remove the unused fields and union indirection Reported-by: Christoph Hellwig Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 84 ++++++++++++--------------------------------- 1 file changed, 21 insertions(+), 63 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 7628decbd535..7fd98531d1f2 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -89,67 +89,25 @@ enum sci_request_protocol { SCIC_STP_PROTOCOL }; /* XXX remove me, use sas_task.{dev|task_proto} instead */; -struct scic_sds_stp_request { - union { - u32 ncq; - - u32 udma; - - struct scic_sds_stp_pio_request { - /* - * Total transfer for the entire PIO request recorded - * at request constuction time. - * - * @todo Should we just decrement this value for each - * byte of data transitted or received to elemenate - * the current_transfer_bytes field? - */ - u32 total_transfer_bytes; - - /* - * Total number of bytes received/transmitted in data - * frames since the start of the IO request. At the - * end of the IO request this should equal the - * total_transfer_bytes. - */ - u32 current_transfer_bytes; - - /* - * The number of bytes requested in the in the PIO - * setup. - */ - u32 pio_transfer_bytes; - - /* - * PIO Setup ending status value to tell us if we need - * to wait for another FIS or if the transfer is - * complete. On the receipt of a D2H FIS this will be - * the status field of that FIS. - */ - u8 ending_status; - - /* - * On receipt of a D2H FIS this will be the ending - * error field if the ending_status has the - * SATA_STATUS_ERR bit set. - */ - u8 ending_error; - - struct scic_sds_request_pio_sgl { - int sgl_index; - u8 sgl_set; - u32 sgl_offset; - } request_current; - } pio; - - struct { - /* - * The number of bytes requested in the PIO setup - * before CDB data frame. - */ - u32 device_preferred_cdb_length; - } packet; - } type; +/** + * isci_stp_request - extra request infrastructure to handle pio/atapi protocol + * @pio_len - number of bytes requested at PIO setup + * @status - pio setup ending status value to tell us if we need + * to wait for another fis or if the transfer is complete. Upon + * receipt of a d2h fis this will be the status field of that fis. + * @sgl - track pio transfer progress as we iterate through the sgl + * @device_cdb_len - atapi device advertises it's transfer constraints at setup + */ +struct isci_stp_request { + u32 pio_len; + u8 status; + + struct isci_stp_pio_sgl { + int index; + u8 set; + u32 offset; + } sgl; + u32 device_cdb_len; }; struct scic_sds_request { @@ -235,14 +193,14 @@ struct scic_sds_request { } smp; struct { - struct scic_sds_stp_request req; + struct isci_stp_request req; struct host_to_dev_fis cmd; struct dev_to_host_fis rsp; } stp; }; }; -static inline struct scic_sds_request *to_sci_req(struct scic_sds_stp_request *stp_req) +static inline struct scic_sds_request *to_sci_req(struct isci_stp_request *stp_req) { struct scic_sds_request *sci_req; -- cgit v1.2.3 From 5076a1a97e2fa61c847a5fdd4b1991faf7716da6 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 27 Jun 2011 14:57:03 -0700 Subject: isci: unify isci_request and scic_sds_request They are one in the same object so remove the distinction. The near duplicate fields (owning_controller, and isci_host) will be cleaned up after the scic_sds_contoller isci_host unification. Reported-by: Christoph Hellwig Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 184 +++++++++++++++----------------------------- 1 file changed, 61 insertions(+), 123 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 7fd98531d1f2..68d8a27357eb 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -93,7 +93,7 @@ enum sci_request_protocol { * isci_stp_request - extra request infrastructure to handle pio/atapi protocol * @pio_len - number of bytes requested at PIO setup * @status - pio setup ending status value to tell us if we need - * to wait for another fis or if the transfer is complete. Upon + * to wait for another fis or if the transfer is complete. Upon * receipt of a d2h fis this will be the status field of that fis. * @sgl - track pio transfer progress as we iterate through the sgl * @device_cdb_len - atapi device advertises it's transfer constraints at setup @@ -110,69 +110,55 @@ struct isci_stp_request { u32 device_cdb_len; }; -struct scic_sds_request { - /* - * This field contains the information for the base request state - * machine. +struct isci_request { + enum isci_request_status status; + #define IREQ_COMPLETE_IN_TARGET 0 + #define IREQ_TERMINATED 1 + #define IREQ_TMF 2 + #define IREQ_ACTIVE 3 + unsigned long flags; + /* XXX kill ttype and ttype_ptr, allocate full sas_task */ + enum task_type ttype; + union ttype_ptr_union { + struct sas_task *io_task_ptr; /* When ttype==io_task */ + struct isci_tmf *tmf_task_ptr; /* When ttype==tmf_task */ + } ttype_ptr; + struct isci_host *isci_host; + /* For use in the requests_to_{complete|abort} lists: */ + struct list_head completed_node; + /* For use in the reqs_in_process list: */ + struct list_head dev_node; + spinlock_t state_lock; + dma_addr_t request_daddr; + dma_addr_t zero_scatter_daddr; + unsigned int num_sg_entries; + /* Note: "io_request_completion" is completed in two different ways + * depending on whether this is a TMF or regular request. + * - TMF requests are completed in the thread that started them; + * - regular requests are completed in the request completion callback + * function. + * This difference in operation allows the aborter of a TMF request + * to be sure that once the TMF request completes, the I/O that the + * TMF was aborting is guaranteed to have completed. + * + * XXX kill io_request_completion */ + struct completion *io_request_completion; struct sci_base_state_machine sm; - - /* - * This field simply points to the controller to which this IO request - * is associated. - */ struct scic_sds_controller *owning_controller; - - /* - * This field simply points to the remote device to which this IO - * request is associated. - */ struct scic_sds_remote_device *target_device; - - /* - * This field indicates the IO tag for this request. The IO tag is - * comprised of the task_index and a sequence count. The sequence count - * is utilized to help identify tasks from one life to another. - */ u16 io_tag; - - /* - * This field specifies the protocol being utilized for this - * IO request. - */ enum sci_request_protocol protocol; - - /* - * This field indicates the completion status taken from the SCUs - * completion code. It indicates the completion result for the SCU - * hardware. - */ - u32 scu_status; - - /* - * This field indicates the completion status returned to the SCI user. - * It indicates the users view of the io request completion. - */ - u32 sci_status; - - /* - * This field contains the value to be utilized when posting - * (e.g. Post_TC, * Post_TC_Abort) this request to the silicon. - */ + u32 scu_status; /* hardware result */ + u32 sci_status; /* upper layer disposition */ u32 post_context; - struct scu_task_context *tc; - /* could be larger with sg chaining */ #define SCU_SGL_SIZE ((SCI_MAX_SCATTER_GATHER_ELEMENTS + 1) / 2) struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32))); - - /* - * This field is a pointer to the stored rx frame data. It is used in + /* This field is a pointer to the stored rx frame data. It is used in * STP internal requests and SMP response frames. If this field is * non-NULL the saved frame must be released on IO request completion. - * - * @todo In the future do we want to keep a list of RX frame buffers? */ u32 saved_rx_frame_index; @@ -187,11 +173,9 @@ struct scic_sds_request { u8 rsp_buf[SSP_RESP_IU_MAX_SIZE]; }; } ssp; - struct { struct smp_resp rsp; } smp; - struct { struct isci_stp_request req; struct host_to_dev_fis cmd; @@ -200,56 +184,11 @@ struct scic_sds_request { }; }; -static inline struct scic_sds_request *to_sci_req(struct isci_stp_request *stp_req) -{ - struct scic_sds_request *sci_req; - - sci_req = container_of(stp_req, typeof(*sci_req), stp.req); - return sci_req; -} - -struct isci_request { - enum isci_request_status status; - enum task_type ttype; - unsigned short io_tag; - #define IREQ_COMPLETE_IN_TARGET 0 - #define IREQ_TERMINATED 1 - #define IREQ_TMF 2 - #define IREQ_ACTIVE 3 - unsigned long flags; - - union ttype_ptr_union { - struct sas_task *io_task_ptr; /* When ttype==io_task */ - struct isci_tmf *tmf_task_ptr; /* When ttype==tmf_task */ - } ttype_ptr; - struct isci_host *isci_host; - /* For use in the requests_to_{complete|abort} lists: */ - struct list_head completed_node; - /* For use in the reqs_in_process list: */ - struct list_head dev_node; - spinlock_t state_lock; - dma_addr_t request_daddr; - dma_addr_t zero_scatter_daddr; - - unsigned int num_sg_entries; /* returned by pci_alloc_sg */ - - /** Note: "io_request_completion" is completed in two different ways - * depending on whether this is a TMF or regular request. - * - TMF requests are completed in the thread that started them; - * - regular requests are completed in the request completion callback - * function. - * This difference in operation allows the aborter of a TMF request - * to be sure that once the TMF request completes, the I/O that the - * TMF was aborting is guaranteed to have completed. - */ - struct completion *io_request_completion; - struct scic_sds_request sci; -}; - -static inline struct isci_request *sci_req_to_ireq(struct scic_sds_request *sci_req) +static inline struct isci_request *to_ireq(struct isci_stp_request *stp_req) { - struct isci_request *ireq = container_of(sci_req, typeof(*ireq), sci); + struct isci_request *ireq; + ireq = container_of(stp_req, typeof(*ireq), stp.req); return ireq; } @@ -366,32 +305,32 @@ enum sci_base_request_states { * * This macro will return the controller for this io request object */ -#define scic_sds_request_get_controller(sci_req) \ - ((sci_req)->owning_controller) +#define scic_sds_request_get_controller(ireq) \ + ((ireq)->owning_controller) /** * scic_sds_request_get_device() - * * This macro will return the device for this io request object */ -#define scic_sds_request_get_device(sci_req) \ - ((sci_req)->target_device) +#define scic_sds_request_get_device(ireq) \ + ((ireq)->target_device) /** * scic_sds_request_get_port() - * * This macro will return the port for this io request object */ -#define scic_sds_request_get_port(sci_req) \ - scic_sds_remote_device_get_port(scic_sds_request_get_device(sci_req)) +#define scic_sds_request_get_port(ireq) \ + scic_sds_remote_device_get_port(scic_sds_request_get_device(ireq)) /** * scic_sds_request_get_post_context() - * * This macro returns the constructed post context result for the io request. */ -#define scic_sds_request_get_post_context(sci_req) \ - ((sci_req)->post_context) +#define scic_sds_request_get_post_context(ireq) \ + ((ireq)->post_context) /** * scic_sds_request_get_task_context() - @@ -413,26 +352,25 @@ enum sci_base_request_states { (request)->sci_status = (sci_status_code); \ } -enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req); -enum sci_status scic_sds_io_request_terminate(struct scic_sds_request *sci_req); +enum sci_status scic_sds_request_start(struct isci_request *ireq); +enum sci_status scic_sds_io_request_terminate(struct isci_request *ireq); enum sci_status -scic_sds_io_request_event_handler(struct scic_sds_request *sci_req, +scic_sds_io_request_event_handler(struct isci_request *ireq, u32 event_code); enum sci_status -scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req, +scic_sds_io_request_frame_handler(struct isci_request *ireq, u32 frame_index); enum sci_status -scic_sds_task_request_terminate(struct scic_sds_request *sci_req); +scic_sds_task_request_terminate(struct isci_request *ireq); extern enum sci_status -scic_sds_request_complete(struct scic_sds_request *sci_req); +scic_sds_request_complete(struct isci_request *ireq); extern enum sci_status -scic_sds_io_request_tc_completion(struct scic_sds_request *sci_req, u32 code); +scic_sds_io_request_tc_completion(struct isci_request *ireq, u32 code); /* XXX open code in caller */ static inline dma_addr_t -scic_io_request_get_dma_addr(struct scic_sds_request *sci_req, void *virt_addr) +scic_io_request_get_dma_addr(struct isci_request *ireq, void *virt_addr) { - struct isci_request *ireq = sci_req_to_ireq(sci_req); char *requested_addr = (char *)virt_addr; char *base_addr = (char *)ireq; @@ -565,14 +503,14 @@ enum sci_status scic_task_request_construct(struct scic_sds_controller *scic, struct scic_sds_remote_device *sci_dev, u16 io_tag, - struct scic_sds_request *sci_req); + struct isci_request *ireq); enum sci_status -scic_task_request_construct_ssp(struct scic_sds_request *sci_req); +scic_task_request_construct_ssp(struct isci_request *ireq); enum sci_status -scic_task_request_construct_sata(struct scic_sds_request *sci_req); +scic_task_request_construct_sata(struct isci_request *ireq); void -scic_stp_io_request_set_ncq_tag(struct scic_sds_request *sci_req, u16 ncq_tag); -void scic_sds_smp_request_copy_response(struct scic_sds_request *sci_req); +scic_stp_io_request_set_ncq_tag(struct isci_request *ireq, u16 ncq_tag); +void scic_sds_smp_request_copy_response(struct isci_request *ireq); static inline int isci_task_is_ncq_recovery(struct sas_task *task) { -- cgit v1.2.3 From 78a6f06e0e82125787d7aa308fe28c2c8381540c Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 30 Jun 2011 16:31:37 -0700 Subject: isci: unify isci_remote_device and scic_sds_remote_device Remove the distinction between these two implementations and unify on isci_remote_device (local instances named idev). Reported-by: Christoph Hellwig Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 68d8a27357eb..ca64ea207ac8 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -146,7 +146,7 @@ struct isci_request { struct completion *io_request_completion; struct sci_base_state_machine sm; struct scic_sds_controller *owning_controller; - struct scic_sds_remote_device *target_device; + struct isci_remote_device *target_device; u16 io_tag; enum sci_request_protocol protocol; u32 scu_status; /* hardware result */ @@ -501,7 +501,7 @@ void isci_terminate_pending_requests(struct isci_host *ihost, struct isci_remote_device *idev); enum sci_status scic_task_request_construct(struct scic_sds_controller *scic, - struct scic_sds_remote_device *sci_dev, + struct isci_remote_device *idev, u16 io_tag, struct isci_request *ireq); enum sci_status -- cgit v1.2.3 From d9dcb4ba791de2a06b19ac47cd61601cf3d4e208 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 30 Jun 2011 17:38:32 -0700 Subject: isci: unify isci_host and scic_sds_controller Remove the distinction between these two implementations and unify on isci_host (local instances named ihost). Hmmm, we had two 'oem_parameters' instances, one was unused... nice. Reported-by: Christoph Hellwig Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index ca64ea207ac8..0cafcead7a01 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -145,7 +145,7 @@ struct isci_request { */ struct completion *io_request_completion; struct sci_base_state_machine sm; - struct scic_sds_controller *owning_controller; + struct isci_host *owning_controller; struct isci_remote_device *target_device; u16 io_tag; enum sci_request_protocol protocol; @@ -500,7 +500,7 @@ int isci_request_execute(struct isci_host *ihost, struct isci_remote_device *ide void isci_terminate_pending_requests(struct isci_host *ihost, struct isci_remote_device *idev); enum sci_status -scic_task_request_construct(struct scic_sds_controller *scic, +scic_task_request_construct(struct isci_host *ihost, struct isci_remote_device *idev, u16 io_tag, struct isci_request *ireq); -- cgit v1.2.3 From 89a7301f21fb00e753089671eb9e4132aab8ea08 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 30 Jun 2011 19:14:33 -0700 Subject: isci: retire scic_sds_ and scic_ prefixes The distinction between scic_sds_ scic_ and sci_ are no longer relevant so just unify the prefixes on sci_. The distinction between isci_ and sci_ is historically significant, and useful for comparing the old 'core' to the current Linux driver. 'sci_' represents the former core as well as the routines that are closer to the hardware and protocol than their 'isci_' brethren. sci == sas controller interface. Also unwind the 'sds1' out of the parameter structs. Reported-by: Christoph Hellwig Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 52 ++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 0cafcead7a01..08fcf98e70f4 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -301,75 +301,75 @@ enum sci_base_request_states { }; /** - * scic_sds_request_get_controller() - + * sci_request_get_controller() - * * This macro will return the controller for this io request object */ -#define scic_sds_request_get_controller(ireq) \ +#define sci_request_get_controller(ireq) \ ((ireq)->owning_controller) /** - * scic_sds_request_get_device() - + * sci_request_get_device() - * * This macro will return the device for this io request object */ -#define scic_sds_request_get_device(ireq) \ +#define sci_request_get_device(ireq) \ ((ireq)->target_device) /** - * scic_sds_request_get_port() - + * sci_request_get_port() - * * This macro will return the port for this io request object */ -#define scic_sds_request_get_port(ireq) \ - scic_sds_remote_device_get_port(scic_sds_request_get_device(ireq)) +#define sci_request_get_port(ireq) \ + sci_remote_device_get_port(sci_request_get_device(ireq)) /** - * scic_sds_request_get_post_context() - + * sci_request_get_post_context() - * * This macro returns the constructed post context result for the io request. */ -#define scic_sds_request_get_post_context(ireq) \ +#define sci_request_get_post_context(ireq) \ ((ireq)->post_context) /** - * scic_sds_request_get_task_context() - + * sci_request_get_task_context() - * * This is a helper macro to return the os handle for this request object. */ -#define scic_sds_request_get_task_context(request) \ +#define sci_request_get_task_context(request) \ ((request)->task_context_buffer) /** - * scic_sds_request_set_status() - + * sci_request_set_status() - * * This macro will set the scu hardware status and sci request completion * status for an io request. */ -#define scic_sds_request_set_status(request, scu_status_code, sci_status_code) \ +#define sci_request_set_status(request, scu_status_code, sci_status_code) \ { \ (request)->scu_status = (scu_status_code); \ (request)->sci_status = (sci_status_code); \ } -enum sci_status scic_sds_request_start(struct isci_request *ireq); -enum sci_status scic_sds_io_request_terminate(struct isci_request *ireq); +enum sci_status sci_request_start(struct isci_request *ireq); +enum sci_status sci_io_request_terminate(struct isci_request *ireq); enum sci_status -scic_sds_io_request_event_handler(struct isci_request *ireq, +sci_io_request_event_handler(struct isci_request *ireq, u32 event_code); enum sci_status -scic_sds_io_request_frame_handler(struct isci_request *ireq, +sci_io_request_frame_handler(struct isci_request *ireq, u32 frame_index); enum sci_status -scic_sds_task_request_terminate(struct isci_request *ireq); +sci_task_request_terminate(struct isci_request *ireq); extern enum sci_status -scic_sds_request_complete(struct isci_request *ireq); +sci_request_complete(struct isci_request *ireq); extern enum sci_status -scic_sds_io_request_tc_completion(struct isci_request *ireq, u32 code); +sci_io_request_tc_completion(struct isci_request *ireq, u32 code); /* XXX open code in caller */ static inline dma_addr_t -scic_io_request_get_dma_addr(struct isci_request *ireq, void *virt_addr) +sci_io_request_get_dma_addr(struct isci_request *ireq, void *virt_addr) { char *requested_addr = (char *)virt_addr; @@ -500,17 +500,17 @@ int isci_request_execute(struct isci_host *ihost, struct isci_remote_device *ide void isci_terminate_pending_requests(struct isci_host *ihost, struct isci_remote_device *idev); enum sci_status -scic_task_request_construct(struct isci_host *ihost, +sci_task_request_construct(struct isci_host *ihost, struct isci_remote_device *idev, u16 io_tag, struct isci_request *ireq); enum sci_status -scic_task_request_construct_ssp(struct isci_request *ireq); +sci_task_request_construct_ssp(struct isci_request *ireq); enum sci_status -scic_task_request_construct_sata(struct isci_request *ireq); +sci_task_request_construct_sata(struct isci_request *ireq); void -scic_stp_io_request_set_ncq_tag(struct isci_request *ireq, u16 ncq_tag); -void scic_sds_smp_request_copy_response(struct isci_request *ireq); +sci_stp_io_request_set_ncq_tag(struct isci_request *ireq, u16 ncq_tag); +void sci_smp_request_copy_response(struct isci_request *ireq); static inline int isci_task_is_ncq_recovery(struct sas_task *task) { -- cgit v1.2.3 From 34a991587a5cc9f78960c2c9beea217866458c41 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 1 Jul 2011 02:25:15 -0700 Subject: isci: kill 'get/set' macros Most of these simple dereference macros are longer than their open coded equivalent. Deleting enum sci_controller_mode is thrown in for good measure. Reported-by: Christoph Hellwig Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 73 --------------------------------------------- 1 file changed, 73 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 08fcf98e70f4..597084027819 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -300,58 +300,6 @@ enum sci_base_request_states { SCI_REQ_FINAL, }; -/** - * sci_request_get_controller() - - * - * This macro will return the controller for this io request object - */ -#define sci_request_get_controller(ireq) \ - ((ireq)->owning_controller) - -/** - * sci_request_get_device() - - * - * This macro will return the device for this io request object - */ -#define sci_request_get_device(ireq) \ - ((ireq)->target_device) - -/** - * sci_request_get_port() - - * - * This macro will return the port for this io request object - */ -#define sci_request_get_port(ireq) \ - sci_remote_device_get_port(sci_request_get_device(ireq)) - -/** - * sci_request_get_post_context() - - * - * This macro returns the constructed post context result for the io request. - */ -#define sci_request_get_post_context(ireq) \ - ((ireq)->post_context) - -/** - * sci_request_get_task_context() - - * - * This is a helper macro to return the os handle for this request object. - */ -#define sci_request_get_task_context(request) \ - ((request)->task_context_buffer) - -/** - * sci_request_set_status() - - * - * This macro will set the scu hardware status and sci request completion - * status for an io request. - */ -#define sci_request_set_status(request, scu_status_code, sci_status_code) \ - { \ - (request)->scu_status = (scu_status_code); \ - (request)->sci_status = (sci_status_code); \ - } - enum sci_status sci_request_start(struct isci_request *ireq); enum sci_status sci_io_request_terminate(struct isci_request *ireq); enum sci_status @@ -381,27 +329,6 @@ sci_io_request_get_dma_addr(struct isci_request *ireq, void *virt_addr) return ireq->request_daddr + (requested_addr - base_addr); } -/** - * This function gets the status of the request object. - * @request: This parameter points to the isci_request object - * - * status of the object as a isci_request_status enum. - */ -static inline enum isci_request_status -isci_request_get_state(struct isci_request *isci_request) -{ - BUG_ON(isci_request == NULL); - - /*probably a bad sign... */ - if (isci_request->status == unallocated) - dev_warn(&isci_request->isci_host->pdev->dev, - "%s: isci_request->status == unallocated\n", - __func__); - - return isci_request->status; -} - - /** * isci_request_change_state() - This function sets the status of the request * object. -- cgit v1.2.3 From 16ba77091b44af28b3ff3318b4a2aa4fbf7d4c24 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 1 Jul 2011 10:52:55 -0700 Subject: isci: merge sata.[ch] into request.c Undo some needless separation. Signed-off-by: Dan Williams --- drivers/scsi/isci/request.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/scsi/isci/request.h') 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 sci_task_request_construct_ssp(struct isci_request *ireq); enum sci_status sci_task_request_construct_sata(struct isci_request *ireq); -void -sci_stp_io_request_set_ncq_tag(struct isci_request *ireq, u16 ncq_tag); void sci_smp_request_copy_response(struct isci_request *ireq); static inline int isci_task_is_ncq_recovery(struct sas_task *task) -- cgit v1.2.3 From a5ec7f86dc5432c44d8407a144e7617ec65da770 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Sun, 3 Jul 2011 14:14:45 -0500 Subject: [SCSI] isci: fix checkpatch errors Signed-off-by: James Bottomley --- drivers/scsi/isci/request.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/scsi/isci/request.h') diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 11bc279457aa..7a1d5a9778eb 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h @@ -440,8 +440,8 @@ void sci_smp_request_copy_response(struct isci_request *ireq); static inline int isci_task_is_ncq_recovery(struct sas_task *task) { return (sas_protocol_ata(task->task_proto) && - task->ata_task.fis.command == ATA_CMD_READ_LOG_EXT && - task->ata_task.fis.lbal == ATA_LOG_SATA_NCQ); + task->ata_task.fis.command == ATA_CMD_READ_LOG_EXT && + task->ata_task.fis.lbal == ATA_LOG_SATA_NCQ); } -- cgit v1.2.3