aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/isci/core/sci_base_controller.h304
-rw-r--r--drivers/scsi/isci/core/sci_controller.h29
-rw-r--r--drivers/scsi/isci/core/scic_sds_controller.c438
-rw-r--r--drivers/scsi/isci/core/scic_sds_controller.h198
-rw-r--r--drivers/scsi/isci/core/scic_sds_remote_device.c9
-rw-r--r--drivers/scsi/isci/core/scic_sds_stp_request.c16
-rw-r--r--drivers/scsi/isci/host.c6
-rw-r--r--drivers/scsi/isci/isci.h2
8 files changed, 364 insertions, 638 deletions
diff --git a/drivers/scsi/isci/core/sci_base_controller.h b/drivers/scsi/isci/core/sci_base_controller.h
deleted file mode 100644
index 8e0c46f8b221..000000000000
--- a/drivers/scsi/isci/core/sci_base_controller.h
+++ /dev/null
@@ -1,304 +0,0 @@
1/*
2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
4 *
5 * GPL LICENSE SUMMARY
6 *
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * BSD LICENSE
25 *
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
28 *
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
32 *
33 * * Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * * Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in
37 * the documentation and/or other materials provided with the
38 * distribution.
39 * * Neither the name of Intel Corporation nor the names of its
40 * contributors may be used to endorse or promote products derived
41 * from this software without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 */
55
56#ifndef _SCI_BASE_CONTROLLER_H_
57#define _SCI_BASE_CONTROLLER_H_
58
59#include "intel_sas.h"
60#include "sci_controller_constants.h"
61#include "sci_base_state.h"
62#include "sci_base_memory_descriptor_list.h"
63#include "sci_base_state_machine.h"
64#include "sci_object.h"
65
66struct sci_base_memory_descriptor_list;
67
68/**
69 * enum sci_base_controller_states - This enumeration depicts all the states
70 * for the common controller state machine.
71 *
72 *
73 */
74enum sci_base_controller_states {
75 /**
76 * Simply the initial state for the base controller state machine.
77 */
78 SCI_BASE_CONTROLLER_STATE_INITIAL = 0,
79
80 /**
81 * This state indicates that the controller is reset. The memory for
82 * the controller is in it's initial state, but the controller requires
83 * initialization.
84 * This state is entered from the INITIAL state.
85 * This state is entered from the RESETTING state.
86 */
87 SCI_BASE_CONTROLLER_STATE_RESET,
88
89 /**
90 * This state is typically an action state that indicates the controller
91 * is in the process of initialization. In this state no new IO operations
92 * are permitted.
93 * This state is entered from the RESET state.
94 */
95 SCI_BASE_CONTROLLER_STATE_INITIALIZING,
96
97 /**
98 * This state indicates that the controller has been successfully
99 * initialized. In this state no new IO operations are permitted.
100 * This state is entered from the INITIALIZING state.
101 */
102 SCI_BASE_CONTROLLER_STATE_INITIALIZED,
103
104 /**
105 * This state indicates the the controller is in the process of becoming
106 * ready (i.e. starting). In this state no new IO operations are permitted.
107 * This state is entered from the INITIALIZED state.
108 */
109 SCI_BASE_CONTROLLER_STATE_STARTING,
110
111 /**
112 * This state indicates the controller is now ready. Thus, the user
113 * is able to perform IO operations on the controller.
114 * This state is entered from the STARTING state.
115 */
116 SCI_BASE_CONTROLLER_STATE_READY,
117
118 /**
119 * This state is typically an action state that indicates the controller
120 * is in the process of resetting. Thus, the user is unable to perform
121 * IO operations on the controller. A reset is considered destructive in
122 * most cases.
123 * This state is entered from the READY state.
124 * This state is entered from the FAILED state.
125 * This state is entered from the STOPPED state.
126 */
127 SCI_BASE_CONTROLLER_STATE_RESETTING,
128
129 /**
130 * This state indicates that the controller is in the process of stopping.
131 * In this state no new IO operations are permitted, but existing IO
132 * operations are allowed to complete.
133 * This state is entered from the READY state.
134 */
135 SCI_BASE_CONTROLLER_STATE_STOPPING,
136
137 /**
138 * This state indicates that the controller has successfully been stopped.
139 * In this state no new IO operations are permitted.
140 * This state is entered from the STOPPING state.
141 */
142 SCI_BASE_CONTROLLER_STATE_STOPPED,
143
144 /**
145 * This state indicates that the controller could not successfully be
146 * initialized. In this state no new IO operations are permitted.
147 * This state is entered from the INITIALIZING state.
148 * This state is entered from the STARTING state.
149 * This state is entered from the STOPPING state.
150 * This state is entered from the RESETTING state.
151 */
152 SCI_BASE_CONTROLLER_STATE_FAILED,
153
154 SCI_BASE_CONTROLLER_MAX_STATES
155
156};
157
158/**
159 * struct sci_base_controller - The base controller object abstracts the fields
160 * common to all SCI controller objects.
161 *
162 *
163 */
164struct sci_base_controller {
165 /**
166 * The field specifies that the parent object for the base controller
167 * is the base object itself.
168 */
169 struct sci_base_object parent;
170
171 /**
172 * This field points to the memory descriptor list associated with this
173 * controller. The MDL indicates the memory requirements necessary for
174 * this controller object.
175 */
176 struct sci_base_memory_descriptor_list mdl;
177
178 /**
179 * This field contains the information for the base controller state
180 * machine.
181 */
182 struct sci_base_state_machine state_machine;
183};
184
185/* Forward declarations */
186struct sci_base_remote_device;
187struct sci_base_request;
188
189typedef enum sci_status
190(*sci_base_controller_handler_t)(struct sci_base_controller *);
191
192typedef enum sci_status
193(*sci_base_controller_timed_handler_t)(struct sci_base_controller *, u32);
194
195typedef enum sci_status
196(*sci_base_controller_request_handler_t)(struct sci_base_controller *,
197 struct sci_base_remote_device *,
198 struct sci_base_request *);
199
200typedef enum sci_status
201(*sci_base_controller_start_request_handler_t)(struct sci_base_controller *,
202 struct sci_base_remote_device *,
203 struct sci_base_request *, u16);
204
205/**
206 * struct sci_base_controller_state_handler - This structure contains all of
207 * the state handler methods common to base controller state machines.
208 * Handler methods provide the ability to change the behavior for user
209 * requests or transitions depending on the state the machine is in.
210 *
211 *
212 */
213struct sci_base_controller_state_handler {
214 /**
215 * The start_handler specifies the method invoked when a user attempts to
216 * start a controller.
217 */
218 sci_base_controller_timed_handler_t start;
219
220 /**
221 * The stop_handler specifies the method invoked when a user attempts to
222 * stop a controller.
223 */
224 sci_base_controller_timed_handler_t stop;
225
226 /**
227 * The reset_handler specifies the method invoked when a user attempts to
228 * reset a controller.
229 */
230 sci_base_controller_handler_t reset;
231
232 /**
233 * The initialize_handler specifies the method invoked when a user
234 * attempts to initialize a controller.
235 */
236 sci_base_controller_handler_t initialize;
237
238 /**
239 * The start_io_handler specifies the method invoked when a user
240 * attempts to start an IO request for a controller.
241 */
242 sci_base_controller_start_request_handler_t start_io;
243
244 /**
245 * The complete_io_handler specifies the method invoked when a user
246 * attempts to complete an IO request for a controller.
247 */
248 sci_base_controller_request_handler_t complete_io;
249
250 /**
251 * The continue_io_handler specifies the method invoked when a user
252 * attempts to continue an IO request for a controller.
253 */
254 sci_base_controller_request_handler_t continue_io;
255
256 /**
257 * The start_task_handler specifies the method invoked when a user
258 * attempts to start a task management request for a controller.
259 */
260 sci_base_controller_start_request_handler_t start_task;
261
262 /**
263 * The complete_task_handler specifies the method invoked when a user
264 * attempts to complete a task management request for a controller.
265 */
266 sci_base_controller_request_handler_t complete_task;
267
268};
269
270/**
271 * sci_base_controller_construct() - Construct the base controller
272 * @this_controller: This parameter specifies the base controller to be
273 * constructed.
274 * @state_table: This parameter specifies the table of state definitions to be
275 * utilized for the controller state machine.
276 * @mde_array: This parameter specifies the array of memory descriptor entries
277 * to be managed by this list.
278 * @mde_array_length: This parameter specifies the size of the array of entries.
279 * @next_mdl: This parameter specifies a subsequent MDL object to be managed by
280 * this MDL object.
281 * @oem_parameters: This parameter specifies the original equipment
282 * manufacturer parameters to be utilized by this controller object.
283 *
284 */
285static inline void sci_base_controller_construct(
286 struct sci_base_controller *scic_base,
287 const struct sci_base_state *state_table,
288 struct sci_physical_memory_descriptor *mdes,
289 u32 mde_count,
290 struct sci_base_memory_descriptor_list *next_mdl)
291{
292 sci_base_state_machine_construct(
293 &scic_base->state_machine,
294 &scic_base->parent,
295 state_table,
296 SCI_BASE_CONTROLLER_STATE_INITIAL
297 );
298
299 sci_base_mdl_construct(&scic_base->mdl, mdes, mde_count, next_mdl);
300
301 sci_base_state_machine_start(&scic_base->state_machine);
302}
303
304#endif /* _SCI_BASE_CONTROLLER_H_ */
diff --git a/drivers/scsi/isci/core/sci_controller.h b/drivers/scsi/isci/core/sci_controller.h
index 5c7774e75ddf..01316b1a8f27 100644
--- a/drivers/scsi/isci/core/sci_controller.h
+++ b/drivers/scsi/isci/core/sci_controller.h
@@ -63,36 +63,7 @@
63 * 63 *
64 */ 64 */
65 65
66
67struct sci_base_memory_descriptor_list;
68struct scic_sds_controller;
69
70#define SCI_CONTROLLER_INVALID_IO_TAG 0xFFFF 66#define SCI_CONTROLLER_INVALID_IO_TAG 0xFFFF
71 67
72/**
73 * sci_controller_get_memory_descriptor_list_handle() - This method simply
74 * returns a handle for the memory descriptor list associated with the
75 * supplied controller. The descriptor list provides DMA safe/capable
76 * memory requirements for this controller.
77 * @controller: This parameter specifies the controller for which to retrieve
78 * the DMA safe memory descriptor list.
79 *
80 * The user must adhere to the alignment requirements specified in memory
81 * descriptor. In situations where the operating environment does not offer
82 * memory allocation utilities supporting alignment, then it is the
83 * responsibility of the user to manually align the memory buffer for SCI.
84 * Thus, the user may have to allocate a larger buffer to meet the alignment.
85 * Additionally, the user will need to remember the actual memory allocation
86 * addresses in order to ensure the memory can be properly freed when necessary
87 * to do so. This method will return a valid handle, but the MDL may not be
88 * accurate until after the user has invoked the associated
89 * sci_controller_initialize() routine. A pointer to a physical memory
90 * descriptor array.
91 */
92struct sci_base_memory_descriptor_list *
93 sci_controller_get_memory_descriptor_list_handle(
94 struct scic_sds_controller *controller);
95
96
97#endif /* _SCI_CONTROLLER_H_ */ 68#endif /* _SCI_CONTROLLER_H_ */
98 69
diff --git a/drivers/scsi/isci/core/scic_sds_controller.c b/drivers/scsi/isci/core/scic_sds_controller.c
index 774c4b3b0dfb..e7790bb7dfdd 100644
--- a/drivers/scsi/isci/core/scic_sds_controller.c
+++ b/drivers/scsi/isci/core/scic_sds_controller.c
@@ -212,12 +212,6 @@ static void scic_sds_controller_power_control_timer_handler(
212 SMU_CQGR_EVENT_CYCLE_BIT \ 212 SMU_CQGR_EVENT_CYCLE_BIT \
213 ) 213 )
214 214
215struct sci_base_memory_descriptor_list *
216sci_controller_get_memory_descriptor_list_handle(struct scic_sds_controller *scic)
217{
218 return &scic->parent.mdl;
219}
220
221static void scic_sds_controller_initialize_power_control(struct scic_sds_controller *scic) 215static void scic_sds_controller_initialize_power_control(struct scic_sds_controller *scic)
222{ 216{
223 struct isci_host *ihost = sci_object_get_association(scic); 217 struct isci_host *ihost = sci_object_get_association(scic);
@@ -688,13 +682,13 @@ static void scic_sds_controller_transition_to_ready(
688{ 682{
689 struct isci_host *ihost = sci_object_get_association(scic); 683 struct isci_host *ihost = sci_object_get_association(scic);
690 684
691 if (scic->parent.state_machine.current_state_id == 685 if (scic->state_machine.current_state_id ==
692 SCI_BASE_CONTROLLER_STATE_STARTING) { 686 SCI_BASE_CONTROLLER_STATE_STARTING) {
693 /* 687 /*
694 * We move into the ready state, because some of the phys/ports 688 * We move into the ready state, because some of the phys/ports
695 * may be up and operational. 689 * may be up and operational.
696 */ 690 */
697 sci_base_state_machine_change_state(&scic->parent.state_machine, 691 sci_base_state_machine_change_state(&scic->state_machine,
698 SCI_BASE_CONTROLLER_STATE_READY); 692 SCI_BASE_CONTROLLER_STATE_READY);
699 693
700 isci_host_start_complete(ihost, status); 694 isci_host_start_complete(ihost, status);
@@ -705,7 +699,7 @@ static void scic_sds_controller_timeout_handler(void *_scic)
705{ 699{
706 struct scic_sds_controller *scic = _scic; 700 struct scic_sds_controller *scic = _scic;
707 struct isci_host *ihost = sci_object_get_association(scic); 701 struct isci_host *ihost = sci_object_get_association(scic);
708 struct sci_base_state_machine *sm = &scic->parent.state_machine; 702 struct sci_base_state_machine *sm = &scic->state_machine;
709 703
710 if (sm->current_state_id == SCI_BASE_CONTROLLER_STATE_STARTING) 704 if (sm->current_state_id == SCI_BASE_CONTROLLER_STATE_STARTING)
711 scic_sds_controller_transition_to_ready(scic, SCI_FAILURE_TIMEOUT); 705 scic_sds_controller_transition_to_ready(scic, SCI_FAILURE_TIMEOUT);
@@ -1549,7 +1543,7 @@ void scic_sds_controller_error_handler(struct scic_sds_controller *scic)
1549 dev_err(scic_to_dev(scic), "%s: status: %#x\n", __func__, 1543 dev_err(scic_to_dev(scic), "%s: status: %#x\n", __func__,
1550 interrupt_status); 1544 interrupt_status);
1551 1545
1552 sci_base_state_machine_change_state(&scic->parent.state_machine, 1546 sci_base_state_machine_change_state(&scic->state_machine,
1553 SCI_BASE_CONTROLLER_STATE_FAILED); 1547 SCI_BASE_CONTROLLER_STATE_FAILED);
1554 1548
1555 return; 1549 return;
@@ -1572,7 +1566,7 @@ void scic_sds_controller_link_up(
1572 scic_sds_controller_phy_handler_t link_up; 1566 scic_sds_controller_phy_handler_t link_up;
1573 u32 state; 1567 u32 state;
1574 1568
1575 state = scic->parent.state_machine.current_state_id; 1569 state = scic->state_machine.current_state_id;
1576 link_up = scic_sds_controller_state_handler_table[state].link_up; 1570 link_up = scic_sds_controller_state_handler_table[state].link_up;
1577 1571
1578 if (link_up) 1572 if (link_up)
@@ -1593,7 +1587,7 @@ void scic_sds_controller_link_down(
1593 u32 state; 1587 u32 state;
1594 scic_sds_controller_phy_handler_t link_down; 1588 scic_sds_controller_phy_handler_t link_down;
1595 1589
1596 state = scic->parent.state_machine.current_state_id; 1590 state = scic->state_machine.current_state_id;
1597 link_down = scic_sds_controller_state_handler_table[state].link_down; 1591 link_down = scic_sds_controller_state_handler_table[state].link_down;
1598 1592
1599 if (link_down) 1593 if (link_down)
@@ -1639,7 +1633,7 @@ void scic_sds_controller_remote_device_stopped(struct scic_sds_controller *scic,
1639 u32 state; 1633 u32 state;
1640 scic_sds_controller_device_handler_t stopped; 1634 scic_sds_controller_device_handler_t stopped;
1641 1635
1642 state = scic->parent.state_machine.current_state_id; 1636 state = scic->state_machine.current_state_id;
1643 stopped = scic_sds_controller_state_handler_table[state].device_stopped; 1637 stopped = scic_sds_controller_state_handler_table[state].device_stopped;
1644 1638
1645 if (stopped) 1639 if (stopped)
@@ -1969,14 +1963,14 @@ enum sci_status scic_controller_initialize(
1969 struct scic_sds_controller *scic) 1963 struct scic_sds_controller *scic)
1970{ 1964{
1971 enum sci_status status = SCI_FAILURE_INVALID_STATE; 1965 enum sci_status status = SCI_FAILURE_INVALID_STATE;
1972 sci_base_controller_handler_t initialize; 1966 scic_sds_controller_handler_t initialize;
1973 u32 state; 1967 u32 state;
1974 1968
1975 state = scic->parent.state_machine.current_state_id; 1969 state = scic->state_machine.current_state_id;
1976 initialize = scic_sds_controller_state_handler_table[state].base.initialize; 1970 initialize = scic_sds_controller_state_handler_table[state].initialize;
1977 1971
1978 if (initialize) 1972 if (initialize)
1979 status = initialize(&scic->parent); 1973 status = initialize(scic);
1980 else 1974 else
1981 dev_warn(scic_to_dev(scic), 1975 dev_warn(scic_to_dev(scic),
1982 "%s: SCIC Controller initialize operation requested " 1976 "%s: SCIC Controller initialize operation requested "
@@ -2050,14 +2044,14 @@ enum sci_status scic_controller_start(
2050 u32 timeout) 2044 u32 timeout)
2051{ 2045{
2052 enum sci_status status = SCI_FAILURE_INVALID_STATE; 2046 enum sci_status status = SCI_FAILURE_INVALID_STATE;
2053 sci_base_controller_timed_handler_t start; 2047 scic_sds_controller_timed_handler_t start;
2054 u32 state; 2048 u32 state;
2055 2049
2056 state = scic->parent.state_machine.current_state_id; 2050 state = scic->state_machine.current_state_id;
2057 start = scic_sds_controller_state_handler_table[state].base.start; 2051 start = scic_sds_controller_state_handler_table[state].start;
2058 2052
2059 if (start) 2053 if (start)
2060 status = start(&scic->parent, timeout); 2054 status = start(scic, timeout);
2061 else 2055 else
2062 dev_warn(scic_to_dev(scic), 2056 dev_warn(scic_to_dev(scic),
2063 "%s: SCIC Controller start operation requested in " 2057 "%s: SCIC Controller start operation requested in "
@@ -2089,14 +2083,14 @@ enum sci_status scic_controller_stop(
2089 u32 timeout) 2083 u32 timeout)
2090{ 2084{
2091 enum sci_status status = SCI_FAILURE_INVALID_STATE; 2085 enum sci_status status = SCI_FAILURE_INVALID_STATE;
2092 sci_base_controller_timed_handler_t stop; 2086 scic_sds_controller_timed_handler_t stop;
2093 u32 state; 2087 u32 state;
2094 2088
2095 state = scic->parent.state_machine.current_state_id; 2089 state = scic->state_machine.current_state_id;
2096 stop = scic_sds_controller_state_handler_table[state].base.stop; 2090 stop = scic_sds_controller_state_handler_table[state].stop;
2097 2091
2098 if (stop) 2092 if (stop)
2099 status = stop(&scic->parent, timeout); 2093 status = stop(scic, timeout);
2100 else 2094 else
2101 dev_warn(scic_to_dev(scic), 2095 dev_warn(scic_to_dev(scic),
2102 "%s: SCIC Controller stop operation requested in " 2096 "%s: SCIC Controller stop operation requested in "
@@ -2121,14 +2115,14 @@ enum sci_status scic_controller_reset(
2121 struct scic_sds_controller *scic) 2115 struct scic_sds_controller *scic)
2122{ 2116{
2123 enum sci_status status = SCI_FAILURE_INVALID_STATE; 2117 enum sci_status status = SCI_FAILURE_INVALID_STATE;
2124 sci_base_controller_handler_t reset; 2118 scic_sds_controller_handler_t reset;
2125 u32 state; 2119 u32 state;
2126 2120
2127 state = scic->parent.state_machine.current_state_id; 2121 state = scic->state_machine.current_state_id;
2128 reset = scic_sds_controller_state_handler_table[state].base.reset; 2122 reset = scic_sds_controller_state_handler_table[state].reset;
2129 2123
2130 if (reset) 2124 if (reset)
2131 status = reset(&scic->parent); 2125 status = reset(scic);
2132 else 2126 else
2133 dev_warn(scic_to_dev(scic), 2127 dev_warn(scic_to_dev(scic),
2134 "%s: SCIC Controller reset operation requested in " 2128 "%s: SCIC Controller reset operation requested in "
@@ -2171,12 +2165,12 @@ enum sci_io_status scic_controller_start_io(
2171 u16 io_tag) 2165 u16 io_tag)
2172{ 2166{
2173 u32 state; 2167 u32 state;
2174 sci_base_controller_start_request_handler_t start_io; 2168 scic_sds_controller_start_request_handler_t start_io;
2175 2169
2176 state = scic->parent.state_machine.current_state_id; 2170 state = scic->state_machine.current_state_id;
2177 start_io = scic_sds_controller_state_handler_table[state].base.start_io; 2171 start_io = scic_sds_controller_state_handler_table[state].start_io;
2178 2172
2179 return start_io(&scic->parent, 2173 return start_io(scic,
2180 (struct sci_base_remote_device *) remote_device, 2174 (struct sci_base_remote_device *) remote_device,
2181 (struct sci_base_request *)io_request, io_tag); 2175 (struct sci_base_request *)io_request, io_tag);
2182} 2176}
@@ -2202,13 +2196,13 @@ enum sci_status scic_controller_terminate_request(
2202 struct scic_sds_remote_device *remote_device, 2196 struct scic_sds_remote_device *remote_device,
2203 struct scic_sds_request *request) 2197 struct scic_sds_request *request)
2204{ 2198{
2205 sci_base_controller_request_handler_t terminate_request; 2199 scic_sds_controller_request_handler_t terminate_request;
2206 u32 state; 2200 u32 state;
2207 2201
2208 state = scic->parent.state_machine.current_state_id; 2202 state = scic->state_machine.current_state_id;
2209 terminate_request = scic_sds_controller_state_handler_table[state].terminate_request; 2203 terminate_request = scic_sds_controller_state_handler_table[state].terminate_request;
2210 2204
2211 return terminate_request(&scic->parent, 2205 return terminate_request(scic,
2212 (struct sci_base_remote_device *)remote_device, 2206 (struct sci_base_remote_device *)remote_device,
2213 (struct sci_base_request *)request); 2207 (struct sci_base_request *)request);
2214} 2208}
@@ -2241,12 +2235,12 @@ enum sci_status scic_controller_complete_io(
2241 struct scic_sds_request *io_request) 2235 struct scic_sds_request *io_request)
2242{ 2236{
2243 u32 state; 2237 u32 state;
2244 sci_base_controller_request_handler_t complete_io; 2238 scic_sds_controller_request_handler_t complete_io;
2245 2239
2246 state = scic->parent.state_machine.current_state_id; 2240 state = scic->state_machine.current_state_id;
2247 complete_io = scic_sds_controller_state_handler_table[state].base.complete_io; 2241 complete_io = scic_sds_controller_state_handler_table[state].complete_io;
2248 2242
2249 return complete_io(&scic->parent, 2243 return complete_io(scic,
2250 (struct sci_base_remote_device *)remote_device, 2244 (struct sci_base_remote_device *)remote_device,
2251 (struct sci_base_request *)io_request); 2245 (struct sci_base_request *)io_request);
2252} 2246}
@@ -2286,14 +2280,14 @@ enum sci_task_status scic_controller_start_task(
2286 u16 task_tag) 2280 u16 task_tag)
2287{ 2281{
2288 u32 state; 2282 u32 state;
2289 sci_base_controller_start_request_handler_t start_task; 2283 scic_sds_controller_start_request_handler_t start_task;
2290 enum sci_task_status status = SCI_TASK_FAILURE_INVALID_STATE; 2284 enum sci_task_status status = SCI_TASK_FAILURE_INVALID_STATE;
2291 2285
2292 state = scic->parent.state_machine.current_state_id; 2286 state = scic->state_machine.current_state_id;
2293 start_task = scic_sds_controller_state_handler_table[state].base.start_task; 2287 start_task = scic_sds_controller_state_handler_table[state].start_task;
2294 2288
2295 if (start_task) 2289 if (start_task)
2296 status = start_task(&scic->parent, 2290 status = start_task(scic,
2297 (struct sci_base_remote_device *)remote_device, 2291 (struct sci_base_remote_device *)remote_device,
2298 (struct sci_base_request *)task_request, 2292 (struct sci_base_request *)task_request,
2299 task_tag); 2293 task_tag);
@@ -2326,14 +2320,14 @@ enum sci_status scic_controller_complete_task(
2326 struct scic_sds_request *task_request) 2320 struct scic_sds_request *task_request)
2327{ 2321{
2328 u32 state; 2322 u32 state;
2329 sci_base_controller_request_handler_t complete_task; 2323 scic_sds_controller_request_handler_t complete_task;
2330 enum sci_status status = SCI_FAILURE_INVALID_STATE; 2324 enum sci_status status = SCI_FAILURE_INVALID_STATE;
2331 2325
2332 state = scic->parent.state_machine.current_state_id; 2326 state = scic->state_machine.current_state_id;
2333 complete_task = scic_sds_controller_state_handler_table[state].base.complete_task; 2327 complete_task = scic_sds_controller_state_handler_table[state].complete_task;
2334 2328
2335 if (complete_task) 2329 if (complete_task)
2336 status = complete_task(&scic->parent, 2330 status = complete_task(scic,
2337 (struct sci_base_remote_device *)remote_device, 2331 (struct sci_base_remote_device *)remote_device,
2338 (struct sci_base_request *)task_request); 2332 (struct sci_base_request *)task_request);
2339 else 2333 else
@@ -2518,9 +2512,9 @@ static enum sci_status scic_controller_set_mode(
2518{ 2512{
2519 enum sci_status status = SCI_SUCCESS; 2513 enum sci_status status = SCI_SUCCESS;
2520 2514
2521 if ((scic->parent.state_machine.current_state_id == 2515 if ((scic->state_machine.current_state_id ==
2522 SCI_BASE_CONTROLLER_STATE_INITIALIZING) || 2516 SCI_BASE_CONTROLLER_STATE_INITIALIZING) ||
2523 (scic->parent.state_machine.current_state_id == 2517 (scic->state_machine.current_state_id ==
2524 SCI_BASE_CONTROLLER_STATE_INITIALIZED)) { 2518 SCI_BASE_CONTROLLER_STATE_INITIALIZED)) {
2525 switch (operating_mode) { 2519 switch (operating_mode) {
2526 case SCI_MODE_SPEED: 2520 case SCI_MODE_SPEED:
@@ -2583,7 +2577,7 @@ enum sci_status scic_user_parameters_set(
2583 struct scic_sds_controller *scic, 2577 struct scic_sds_controller *scic,
2584 union scic_user_parameters *scic_parms) 2578 union scic_user_parameters *scic_parms)
2585{ 2579{
2586 u32 state = scic->parent.state_machine.current_state_id; 2580 u32 state = scic->state_machine.current_state_id;
2587 2581
2588 if (state == SCI_BASE_CONTROLLER_STATE_RESET || 2582 if (state == SCI_BASE_CONTROLLER_STATE_RESET ||
2589 state == SCI_BASE_CONTROLLER_STATE_INITIALIZING || 2583 state == SCI_BASE_CONTROLLER_STATE_INITIALIZING ||
@@ -2637,7 +2631,7 @@ enum sci_status scic_oem_parameters_set(
2637 struct scic_sds_controller *scic, 2631 struct scic_sds_controller *scic,
2638 union scic_oem_parameters *scic_parms) 2632 union scic_oem_parameters *scic_parms)
2639{ 2633{
2640 u32 state = scic->parent.state_machine.current_state_id; 2634 u32 state = scic->state_machine.current_state_id;
2641 2635
2642 if (state == SCI_BASE_CONTROLLER_STATE_RESET || 2636 if (state == SCI_BASE_CONTROLLER_STATE_RESET ||
2643 state == SCI_BASE_CONTROLLER_STATE_INITIALIZING || 2637 state == SCI_BASE_CONTROLLER_STATE_INITIALIZING ||
@@ -2819,54 +2813,52 @@ struct scic_sds_controller *scic_controller_alloc(struct device *dev)
2819 return devm_kzalloc(dev, sizeof(struct scic_sds_controller), GFP_KERNEL); 2813 return devm_kzalloc(dev, sizeof(struct scic_sds_controller), GFP_KERNEL);
2820} 2814}
2821 2815
2822static enum sci_status default_controller_handler(struct sci_base_controller *base_scic, 2816static enum sci_status
2823 const char *func) 2817default_controller_handler(struct scic_sds_controller *scic, const char *func)
2824{ 2818{
2825 struct scic_sds_controller *scic = container_of(base_scic, typeof(*scic), parent); 2819 dev_warn(scic_to_dev(scic), "%s: invalid state %d\n", func,
2826 u32 state = base_scic->state_machine.current_state_id; 2820 scic->state_machine.current_state_id);
2827
2828 dev_warn(scic_to_dev(scic), "%s: invalid state %d\n", func, state);
2829 2821
2830 return SCI_FAILURE_INVALID_STATE; 2822 return SCI_FAILURE_INVALID_STATE;
2831} 2823}
2832 2824
2833static enum sci_status scic_sds_controller_default_start_operation_handler( 2825static enum sci_status scic_sds_controller_default_start_operation_handler(
2834 struct sci_base_controller *base_scic, 2826 struct scic_sds_controller *scic,
2835 struct sci_base_remote_device *remote_device, 2827 struct sci_base_remote_device *remote_device,
2836 struct sci_base_request *io_request, 2828 struct sci_base_request *io_request,
2837 u16 io_tag) 2829 u16 io_tag)
2838{ 2830{
2839 return default_controller_handler(base_scic, __func__); 2831 return default_controller_handler(scic, __func__);
2840} 2832}
2841 2833
2842static enum sci_status scic_sds_controller_default_request_handler( 2834static enum sci_status scic_sds_controller_default_request_handler(
2843 struct sci_base_controller *base_scic, 2835 struct scic_sds_controller *scic,
2844 struct sci_base_remote_device *remote_device, 2836 struct sci_base_remote_device *remote_device,
2845 struct sci_base_request *io_request) 2837 struct sci_base_request *io_request)
2846{ 2838{
2847 return default_controller_handler(base_scic, __func__); 2839 return default_controller_handler(scic, __func__);
2848} 2840}
2849 2841
2850static enum sci_status scic_sds_controller_general_reset_handler(struct sci_base_controller *base_scic) 2842static enum sci_status
2843scic_sds_controller_general_reset_handler(struct scic_sds_controller *scic)
2851{ 2844{
2852 /* The reset operation is not a graceful cleanup just perform the state 2845 /* The reset operation is not a graceful cleanup just perform the state
2853 * transition. 2846 * transition.
2854 */ 2847 */
2855 sci_base_state_machine_change_state(&base_scic->state_machine, 2848 sci_base_state_machine_change_state(&scic->state_machine,
2856 SCI_BASE_CONTROLLER_STATE_RESETTING); 2849 SCI_BASE_CONTROLLER_STATE_RESETTING);
2857 2850
2858 return SCI_SUCCESS; 2851 return SCI_SUCCESS;
2859} 2852}
2860 2853
2861static enum sci_status scic_sds_controller_reset_state_initialize_handler(struct sci_base_controller *base_scic) 2854static enum sci_status
2855scic_sds_controller_reset_state_initialize_handler(struct scic_sds_controller *scic)
2862{ 2856{
2863 struct sci_base_state_machine *sm = &base_scic->state_machine; 2857 struct sci_base_state_machine *sm = &scic->state_machine;
2864 enum sci_status result = SCI_SUCCESS; 2858 enum sci_status result = SCI_SUCCESS;
2865 struct scic_sds_controller *scic;
2866 struct isci_host *ihost; 2859 struct isci_host *ihost;
2867 u32 index, state; 2860 u32 index, state;
2868 2861
2869 scic = container_of(base_scic, typeof(*scic), parent);
2870 ihost = sci_object_get_association(scic); 2862 ihost = sci_object_get_association(scic);
2871 2863
2872 sci_base_state_machine_change_state(sm, SCI_BASE_CONTROLLER_STATE_INITIALIZING); 2864 sci_base_state_machine_change_state(sm, SCI_BASE_CONTROLLER_STATE_INITIALIZING);
@@ -3028,13 +3020,7 @@ static enum sci_status scic_sds_controller_reset_state_initialize_handler(struct
3028 * * INITIALIZED STATE HANDLERS 3020 * * INITIALIZED STATE HANDLERS
3029 * ***************************************************************************** */ 3021 * ***************************************************************************** */
3030 3022
3031/** 3023/*
3032 *
3033 * @controller: This is the struct sci_base_controller object which is cast
3034 * into a struct scic_sds_controller object.
3035 * @timeout: This is the allowed time for the controller object to reach the
3036 * started state.
3037 *
3038 * This function is the struct scic_sds_controller start handler for the 3024 * This function is the struct scic_sds_controller start handler for the
3039 * initialized state. 3025 * initialized state.
3040 * - Validate we have a good memory descriptor table - Initialze the 3026 * - Validate we have a good memory descriptor table - Initialze the
@@ -3049,14 +3035,10 @@ static enum sci_status scic_sds_controller_reset_state_initialize_handler(struct
3049 * descriptor fields is invalid. 3035 * descriptor fields is invalid.
3050 */ 3036 */
3051static enum sci_status scic_sds_controller_initialized_state_start_handler( 3037static enum sci_status scic_sds_controller_initialized_state_start_handler(
3052 struct sci_base_controller *base_scic, 3038 struct scic_sds_controller *scic, u32 timeout)
3053 u32 timeout)
3054{ 3039{
3055 u16 index; 3040 u16 index;
3056 enum sci_status result; 3041 enum sci_status result;
3057 struct scic_sds_controller *scic;
3058
3059 scic = container_of(base_scic, typeof(*scic), parent);
3060 3042
3061 /* 3043 /*
3062 * Make sure that the SCI User filled in the memory descriptor 3044 * Make sure that the SCI User filled in the memory descriptor
@@ -3119,7 +3101,7 @@ static enum sci_status scic_sds_controller_initialized_state_start_handler(
3119 3101
3120 isci_timer_start(scic->timeout_timer, timeout); 3102 isci_timer_start(scic->timeout_timer, timeout);
3121 3103
3122 sci_base_state_machine_change_state(&base_scic->state_machine, 3104 sci_base_state_machine_change_state(&scic->state_machine,
3123 SCI_BASE_CONTROLLER_STATE_STARTING); 3105 SCI_BASE_CONTROLLER_STATE_STARTING);
3124 } 3106 }
3125 3107
@@ -3180,79 +3162,54 @@ static void scic_sds_controller_starting_state_link_down_handler(
3180 /* scic_sds_port_link_down(port, phy); */ 3162 /* scic_sds_port_link_down(port, phy); */
3181} 3163}
3182 3164
3183static enum sci_status scic_sds_controller_ready_state_stop_handler(struct sci_base_controller *base_scic, 3165static enum sci_status scic_sds_controller_ready_state_stop_handler(
3184 u32 timeout) 3166 struct scic_sds_controller *scic,
3167 u32 timeout)
3185{ 3168{
3186 struct scic_sds_controller *scic;
3187
3188 scic = container_of(base_scic, typeof(*scic), parent);
3189 isci_timer_start(scic->timeout_timer, timeout); 3169 isci_timer_start(scic->timeout_timer, timeout);
3190 sci_base_state_machine_change_state(&base_scic->state_machine, 3170 sci_base_state_machine_change_state(&scic->state_machine,
3191 SCI_BASE_CONTROLLER_STATE_STOPPING); 3171 SCI_BASE_CONTROLLER_STATE_STOPPING);
3192
3193 return SCI_SUCCESS; 3172 return SCI_SUCCESS;
3194} 3173}
3195 3174
3196/** 3175/*
3197 *
3198 * @controller: This is struct sci_base_controller object which is cast into a
3199 * struct scic_sds_controller object.
3200 * @remote_device: This is struct sci_base_remote_device which is cast to a
3201 * struct scic_sds_remote_device object.
3202 * @io_request: This is the struct sci_base_request which is cast to a
3203 * SCIC_SDS_IO_REQUEST object.
3204 * @io_tag: This is the IO tag to be assigned to the IO request or
3205 * SCI_CONTROLLER_INVALID_IO_TAG.
3206 *
3207 * This method is called when the struct scic_sds_controller is in the ready state and 3176 * This method is called when the struct scic_sds_controller is in the ready state and
3208 * the start io handler is called. - Start the io request on the remote device 3177 * the start io handler is called. - Start the io request on the remote device
3209 * - if successful - assign the io_request to the io_request_table - post the 3178 * - if successful - assign the io_request to the io_request_table - post the
3210 * request to the hardware enum sci_status SCI_SUCCESS if the start io operation 3179 * request to the hardware enum sci_status SCI_SUCCESS if the start io operation
3211 * succeeds SCI_FAILURE_INSUFFICIENT_RESOURCES if the IO tag could not be 3180 * succeeds SCI_FAILURE_INSUFFICIENT_RESOURCES if the IO tag could not be
3212 * allocated for the io request. SCI_FAILURE_INVALID_STATE if one or more 3181 * allocated for the io request. SCI_FAILURE_INVALID_STATE if one or more
3213 * objects are not in a valid state to accept io requests. How does the io_tag 3182 * objects are not in a valid state to accept io requests.
3214 * parameter get assigned to the io request? 3183 *
3184 * XXX: How does the io_tag parameter get assigned to the io request?
3215 */ 3185 */
3216static enum sci_status scic_sds_controller_ready_state_start_io_handler( 3186static enum sci_status scic_sds_controller_ready_state_start_io_handler(
3217 struct sci_base_controller *controller, 3187 struct scic_sds_controller *controller,
3218 struct sci_base_remote_device *remote_device, 3188 struct sci_base_remote_device *remote_device,
3219 struct sci_base_request *io_request, 3189 struct sci_base_request *io_request,
3220 u16 io_tag) 3190 u16 io_tag)
3221{ 3191{
3222 enum sci_status status; 3192 enum sci_status status;
3223 3193
3224 struct scic_sds_controller *this_controller;
3225 struct scic_sds_request *the_request; 3194 struct scic_sds_request *the_request;
3226 struct scic_sds_remote_device *the_device; 3195 struct scic_sds_remote_device *the_device;
3227 3196
3228 this_controller = (struct scic_sds_controller *)controller;
3229 the_request = (struct scic_sds_request *)io_request; 3197 the_request = (struct scic_sds_request *)io_request;
3230 the_device = (struct scic_sds_remote_device *)remote_device; 3198 the_device = (struct scic_sds_remote_device *)remote_device;
3231 3199
3232 status = scic_sds_remote_device_start_io(this_controller, the_device, the_request); 3200 status = scic_sds_remote_device_start_io(controller, the_device, the_request);
3233
3234 if (status == SCI_SUCCESS) {
3235 this_controller->io_request_table[
3236 scic_sds_io_tag_get_index(the_request->io_tag)] = the_request;
3237 3201
3238 scic_sds_controller_post_request( 3202 if (status != SCI_SUCCESS)
3239 this_controller, 3203 return status;
3240 scic_sds_request_get_post_context(the_request)
3241 );
3242 }
3243 3204
3244 return status; 3205 controller->io_request_table[
3206 scic_sds_io_tag_get_index(the_request->io_tag)] = the_request;
3207 scic_sds_controller_post_request(controller,
3208 scic_sds_request_get_post_context(the_request));
3209 return SCI_SUCCESS;
3245} 3210}
3246 3211
3247/** 3212/*
3248 *
3249 * @controller: This is struct sci_base_controller object which is cast into a
3250 * struct scic_sds_controller object.
3251 * @remote_device: This is struct sci_base_remote_device which is cast to a
3252 * struct scic_sds_remote_device object.
3253 * @io_request: This is the struct sci_base_request which is cast to a
3254 * SCIC_SDS_IO_REQUEST object.
3255 *
3256 * This method is called when the struct scic_sds_controller is in the ready state and 3213 * This method is called when the struct scic_sds_controller is in the ready state and
3257 * the complete io handler is called. - Complete the io request on the remote 3214 * the complete io handler is called. - Complete the io request on the remote
3258 * device - if successful - remove the io_request to the io_request_table 3215 * device - if successful - remove the io_request to the io_request_table
@@ -3261,76 +3218,49 @@ static enum sci_status scic_sds_controller_ready_state_start_io_handler(
3261 * accept io requests. 3218 * accept io requests.
3262 */ 3219 */
3263static enum sci_status scic_sds_controller_ready_state_complete_io_handler( 3220static enum sci_status scic_sds_controller_ready_state_complete_io_handler(
3264 struct sci_base_controller *controller, 3221 struct scic_sds_controller *controller,
3265 struct sci_base_remote_device *remote_device, 3222 struct sci_base_remote_device *remote_device,
3266 struct sci_base_request *io_request) 3223 struct sci_base_request *io_request)
3267{ 3224{
3268 u16 index; 3225 u16 index;
3269 enum sci_status status; 3226 enum sci_status status;
3270 struct scic_sds_controller *this_controller;
3271 struct scic_sds_request *the_request; 3227 struct scic_sds_request *the_request;
3272 struct scic_sds_remote_device *the_device; 3228 struct scic_sds_remote_device *the_device;
3273 3229
3274 this_controller = (struct scic_sds_controller *)controller;
3275 the_request = (struct scic_sds_request *)io_request; 3230 the_request = (struct scic_sds_request *)io_request;
3276 the_device = (struct scic_sds_remote_device *)remote_device; 3231 the_device = (struct scic_sds_remote_device *)remote_device;
3277 3232
3278 status = scic_sds_remote_device_complete_io( 3233 status = scic_sds_remote_device_complete_io(controller, the_device,
3279 this_controller, the_device, the_request); 3234 the_request);
3280 3235 if (status != SCI_SUCCESS)
3281 if (status == SCI_SUCCESS) { 3236 return status;
3282 index = scic_sds_io_tag_get_index(the_request->io_tag);
3283 this_controller->io_request_table[index] = NULL;
3284 }
3285 3237
3286 return status; 3238 index = scic_sds_io_tag_get_index(the_request->io_tag);
3239 controller->io_request_table[index] = NULL;
3240 return SCI_SUCCESS;
3287} 3241}
3288 3242
3289/** 3243/*
3290 *
3291 * @controller: This is struct sci_base_controller object which is cast into a
3292 * struct scic_sds_controller object.
3293 * @remote_device: This is struct sci_base_remote_device which is cast to a
3294 * struct scic_sds_remote_device object.
3295 * @io_request: This is the struct sci_base_request which is cast to a
3296 * SCIC_SDS_IO_REQUEST object.
3297 *
3298 * This method is called when the struct scic_sds_controller is in the ready state and 3244 * This method is called when the struct scic_sds_controller is in the ready state and
3299 * the continue io handler is called. enum sci_status 3245 * the continue io handler is called. enum sci_status
3300 */ 3246 */
3301static enum sci_status scic_sds_controller_ready_state_continue_io_handler( 3247static enum sci_status scic_sds_controller_ready_state_continue_io_handler(
3302 struct sci_base_controller *controller, 3248 struct scic_sds_controller *controller,
3303 struct sci_base_remote_device *remote_device, 3249 struct sci_base_remote_device *remote_device,
3304 struct sci_base_request *io_request) 3250 struct sci_base_request *io_request)
3305{ 3251{
3306 struct scic_sds_controller *this_controller;
3307 struct scic_sds_request *the_request; 3252 struct scic_sds_request *the_request;
3308 3253
3309 the_request = (struct scic_sds_request *)io_request; 3254 the_request = (struct scic_sds_request *)io_request;
3310 this_controller = (struct scic_sds_controller *)controller;
3311 3255
3312 this_controller->io_request_table[ 3256 controller->io_request_table[
3313 scic_sds_io_tag_get_index(the_request->io_tag)] = the_request; 3257 scic_sds_io_tag_get_index(the_request->io_tag)] = the_request;
3314 3258 scic_sds_controller_post_request(controller,
3315 scic_sds_controller_post_request( 3259 scic_sds_request_get_post_context(the_request));
3316 this_controller,
3317 scic_sds_request_get_post_context(the_request)
3318 );
3319
3320 return SCI_SUCCESS; 3260 return SCI_SUCCESS;
3321} 3261}
3322 3262
3323/** 3263/*
3324 *
3325 * @controller: This is struct sci_base_controller object which is cast into a
3326 * struct scic_sds_controller object.
3327 * @remote_device: This is struct sci_base_remote_device which is cast to a
3328 * struct scic_sds_remote_device object.
3329 * @io_request: This is the struct sci_base_request which is cast to a
3330 * SCIC_SDS_IO_REQUEST object.
3331 * @task_tag: This is the task tag to be assigned to the task request or
3332 * SCI_CONTROLLER_INVALID_IO_TAG.
3333 *
3334 * This method is called when the struct scic_sds_controller is in the ready state and 3264 * This method is called when the struct scic_sds_controller is in the ready state and
3335 * the start task handler is called. - The remote device is requested to start 3265 * the start task handler is called. - The remote device is requested to start
3336 * the task request - if successful - assign the task to the io_request_table - 3266 * the task request - if successful - assign the task to the io_request_table -
@@ -3341,33 +3271,28 @@ static enum sci_status scic_sds_controller_ready_state_continue_io_handler(
3341 * tag get assigned in this code path? 3271 * tag get assigned in this code path?
3342 */ 3272 */
3343static enum sci_status scic_sds_controller_ready_state_start_task_handler( 3273static enum sci_status scic_sds_controller_ready_state_start_task_handler(
3344 struct sci_base_controller *controller, 3274 struct scic_sds_controller *controller,
3345 struct sci_base_remote_device *remote_device, 3275 struct sci_base_remote_device *remote_device,
3346 struct sci_base_request *io_request, 3276 struct sci_base_request *io_request,
3347 u16 task_tag) 3277 u16 task_tag)
3348{ 3278{
3349 struct scic_sds_controller *this_controller = (struct scic_sds_controller *)
3350 controller;
3351 struct scic_sds_request *the_request = (struct scic_sds_request *) 3279 struct scic_sds_request *the_request = (struct scic_sds_request *)
3352 io_request; 3280 io_request;
3353 struct scic_sds_remote_device *the_device = (struct scic_sds_remote_device *) 3281 struct scic_sds_remote_device *the_device = (struct scic_sds_remote_device *)
3354 remote_device; 3282 remote_device;
3355 enum sci_status status; 3283 enum sci_status status;
3356 3284
3357 status = scic_sds_remote_device_start_task( 3285 status = scic_sds_remote_device_start_task(controller, the_device,
3358 this_controller, the_device, the_request 3286 the_request);
3359 );
3360 3287
3361 if (status == SCI_SUCCESS) { 3288 if (status == SCI_SUCCESS) {
3362 this_controller->io_request_table[ 3289 controller->io_request_table[
3363 scic_sds_io_tag_get_index(the_request->io_tag)] = the_request; 3290 scic_sds_io_tag_get_index(the_request->io_tag)] = the_request;
3364 3291
3365 scic_sds_controller_post_request( 3292 scic_sds_controller_post_request(controller,
3366 this_controller, 3293 scic_sds_request_get_post_context(the_request));
3367 scic_sds_request_get_post_context(the_request)
3368 );
3369 } else if (status == SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS) { 3294 } else if (status == SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS) {
3370 this_controller->io_request_table[ 3295 controller->io_request_table[
3371 scic_sds_io_tag_get_index(the_request->io_tag)] = the_request; 3296 scic_sds_io_tag_get_index(the_request->io_tag)] = the_request;
3372 3297
3373 /* 3298 /*
@@ -3379,15 +3304,7 @@ static enum sci_status scic_sds_controller_ready_state_start_task_handler(
3379 return status; 3304 return status;
3380} 3305}
3381 3306
3382/** 3307/*
3383 *
3384 * @controller: This is struct sci_base_controller object which is cast into a
3385 * struct scic_sds_controller object.
3386 * @remote_device: This is struct sci_base_remote_device which is cast to a
3387 * struct scic_sds_remote_device object.
3388 * @io_request: This is the struct sci_base_request which is cast to a
3389 * SCIC_SDS_IO_REQUEST object.
3390 *
3391 * This method is called when the struct scic_sds_controller is in the ready state and 3308 * This method is called when the struct scic_sds_controller is in the ready state and
3392 * the terminate request handler is called. - call the io request terminate 3309 * the terminate request handler is called. - call the io request terminate
3393 * function - if successful - post the terminate request to the SCU hardware 3310 * function - if successful - post the terminate request to the SCU hardware
@@ -3396,29 +3313,26 @@ static enum sci_status scic_sds_controller_ready_state_start_task_handler(
3396 * accept io requests. 3313 * accept io requests.
3397 */ 3314 */
3398static enum sci_status scic_sds_controller_ready_state_terminate_request_handler( 3315static enum sci_status scic_sds_controller_ready_state_terminate_request_handler(
3399 struct sci_base_controller *controller, 3316 struct scic_sds_controller *controller,
3400 struct sci_base_remote_device *remote_device, 3317 struct sci_base_remote_device *remote_device,
3401 struct sci_base_request *io_request) 3318 struct sci_base_request *io_request)
3402{ 3319{
3403 struct scic_sds_controller *this_controller = (struct scic_sds_controller *)
3404 controller;
3405 struct scic_sds_request *the_request = (struct scic_sds_request *) 3320 struct scic_sds_request *the_request = (struct scic_sds_request *)
3406 io_request; 3321 io_request;
3407 enum sci_status status; 3322 enum sci_status status;
3408 3323
3409 status = scic_sds_io_request_terminate(the_request); 3324 status = scic_sds_io_request_terminate(the_request);
3410 if (status == SCI_SUCCESS) { 3325 if (status != SCI_SUCCESS)
3411 /* 3326 return status;
3412 * Utilize the original post context command and or in the POST_TC_ABORT
3413 * request sub-type. */
3414 scic_sds_controller_post_request(
3415 this_controller,
3416 scic_sds_request_get_post_context(the_request)
3417 | SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORT
3418 );
3419 }
3420 3327
3421 return status; 3328 /*
3329 * Utilize the original post context command and or in the POST_TC_ABORT
3330 * request sub-type.
3331 */
3332 scic_sds_controller_post_request(controller,
3333 scic_sds_request_get_post_context(the_request) |
3334 SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORT);
3335 return SCI_SUCCESS;
3422} 3336}
3423 3337
3424/** 3338/**
@@ -3470,38 +3384,20 @@ static void scic_sds_controller_ready_state_link_down_handler(
3470 * ***************************************************************************** */ 3384 * ***************************************************************************** */
3471 3385
3472/** 3386/**
3473 *
3474 * @controller: This is struct sci_base_controller object which is cast into a
3475 * struct scic_sds_controller object.
3476 * @remote_device: This is struct sci_base_remote_device which is cast to a
3477 * struct scic_sds_remote_device object.
3478 * @io_request: This is the struct sci_base_request which is cast to a
3479 * SCIC_SDS_IO_REQUEST object.
3480 *
3481 * This method is called when the struct scic_sds_controller is in a stopping state 3387 * This method is called when the struct scic_sds_controller is in a stopping state
3482 * and the complete io handler is called. - This function is not yet 3388 * and the complete io handler is called. - This function is not yet
3483 * implemented enum sci_status SCI_FAILURE 3389 * implemented enum sci_status SCI_FAILURE
3484 */ 3390 */
3485static enum sci_status scic_sds_controller_stopping_state_complete_io_handler( 3391static enum sci_status scic_sds_controller_stopping_state_complete_io_handler(
3486 struct sci_base_controller *controller, 3392 struct scic_sds_controller *controller,
3487 struct sci_base_remote_device *remote_device, 3393 struct sci_base_remote_device *remote_device,
3488 struct sci_base_request *io_request) 3394 struct sci_base_request *io_request)
3489{ 3395{
3490 struct scic_sds_controller *this_controller; 3396 /* XXX: Implement this function */
3491
3492 this_controller = (struct scic_sds_controller *)controller;
3493
3494 /* / @todo Implement this function */
3495 return SCI_FAILURE; 3397 return SCI_FAILURE;
3496} 3398}
3497 3399
3498/** 3400/**
3499 *
3500 * @controller: This is struct sci_base_controller object which is cast into a
3501 * struct scic_sds_controller object.
3502 * @remote_device: This is struct sci_base_remote_device which is cast to a
3503 * struct scic_sds_remote_device object.
3504 *
3505 * This method is called when the struct scic_sds_controller is in a stopping state 3401 * This method is called when the struct scic_sds_controller is in a stopping state
3506 * and the remote device has stopped. 3402 * and the remote device has stopped.
3507 **/ 3403 **/
@@ -3511,8 +3407,7 @@ static void scic_sds_controller_stopping_state_device_stopped_handler(
3511) 3407)
3512{ 3408{
3513 if (!scic_sds_controller_has_remote_devices_stopping(controller)) { 3409 if (!scic_sds_controller_has_remote_devices_stopping(controller)) {
3514 sci_base_state_machine_change_state( 3410 sci_base_state_machine_change_state(&controller->state_machine,
3515 &controller->parent.state_machine,
3516 SCI_BASE_CONTROLLER_STATE_STOPPED 3411 SCI_BASE_CONTROLLER_STATE_STOPPED
3517 ); 3412 );
3518 } 3413 }
@@ -3520,77 +3415,77 @@ static void scic_sds_controller_stopping_state_device_stopped_handler(
3520 3415
3521const struct scic_sds_controller_state_handler scic_sds_controller_state_handler_table[] = { 3416const struct scic_sds_controller_state_handler scic_sds_controller_state_handler_table[] = {
3522 [SCI_BASE_CONTROLLER_STATE_INITIAL] = { 3417 [SCI_BASE_CONTROLLER_STATE_INITIAL] = {
3523 .base.start_io = scic_sds_controller_default_start_operation_handler, 3418 .start_io = scic_sds_controller_default_start_operation_handler,
3524 .base.complete_io = scic_sds_controller_default_request_handler, 3419 .complete_io = scic_sds_controller_default_request_handler,
3525 .base.continue_io = scic_sds_controller_default_request_handler, 3420 .continue_io = scic_sds_controller_default_request_handler,
3526 .terminate_request = scic_sds_controller_default_request_handler, 3421 .terminate_request = scic_sds_controller_default_request_handler,
3527 }, 3422 },
3528 [SCI_BASE_CONTROLLER_STATE_RESET] = { 3423 [SCI_BASE_CONTROLLER_STATE_RESET] = {
3529 .base.reset = scic_sds_controller_general_reset_handler, 3424 .reset = scic_sds_controller_general_reset_handler,
3530 .base.initialize = scic_sds_controller_reset_state_initialize_handler, 3425 .initialize = scic_sds_controller_reset_state_initialize_handler,
3531 .base.start_io = scic_sds_controller_default_start_operation_handler, 3426 .start_io = scic_sds_controller_default_start_operation_handler,
3532 .base.complete_io = scic_sds_controller_default_request_handler, 3427 .complete_io = scic_sds_controller_default_request_handler,
3533 .base.continue_io = scic_sds_controller_default_request_handler, 3428 .continue_io = scic_sds_controller_default_request_handler,
3534 .terminate_request = scic_sds_controller_default_request_handler, 3429 .terminate_request = scic_sds_controller_default_request_handler,
3535 }, 3430 },
3536 [SCI_BASE_CONTROLLER_STATE_INITIALIZING] = { 3431 [SCI_BASE_CONTROLLER_STATE_INITIALIZING] = {
3537 .base.start_io = scic_sds_controller_default_start_operation_handler, 3432 .start_io = scic_sds_controller_default_start_operation_handler,
3538 .base.complete_io = scic_sds_controller_default_request_handler, 3433 .complete_io = scic_sds_controller_default_request_handler,
3539 .base.continue_io = scic_sds_controller_default_request_handler, 3434 .continue_io = scic_sds_controller_default_request_handler,
3540 .terminate_request = scic_sds_controller_default_request_handler, 3435 .terminate_request = scic_sds_controller_default_request_handler,
3541 }, 3436 },
3542 [SCI_BASE_CONTROLLER_STATE_INITIALIZED] = { 3437 [SCI_BASE_CONTROLLER_STATE_INITIALIZED] = {
3543 .base.start = scic_sds_controller_initialized_state_start_handler, 3438 .start = scic_sds_controller_initialized_state_start_handler,
3544 .base.start_io = scic_sds_controller_default_start_operation_handler, 3439 .start_io = scic_sds_controller_default_start_operation_handler,
3545 .base.complete_io = scic_sds_controller_default_request_handler, 3440 .complete_io = scic_sds_controller_default_request_handler,
3546 .base.continue_io = scic_sds_controller_default_request_handler, 3441 .continue_io = scic_sds_controller_default_request_handler,
3547 .terminate_request = scic_sds_controller_default_request_handler, 3442 .terminate_request = scic_sds_controller_default_request_handler,
3548 }, 3443 },
3549 [SCI_BASE_CONTROLLER_STATE_STARTING] = { 3444 [SCI_BASE_CONTROLLER_STATE_STARTING] = {
3550 .base.start_io = scic_sds_controller_default_start_operation_handler, 3445 .start_io = scic_sds_controller_default_start_operation_handler,
3551 .base.complete_io = scic_sds_controller_default_request_handler, 3446 .complete_io = scic_sds_controller_default_request_handler,
3552 .base.continue_io = scic_sds_controller_default_request_handler, 3447 .continue_io = scic_sds_controller_default_request_handler,
3553 .terminate_request = scic_sds_controller_default_request_handler, 3448 .terminate_request = scic_sds_controller_default_request_handler,
3554 .link_up = scic_sds_controller_starting_state_link_up_handler, 3449 .link_up = scic_sds_controller_starting_state_link_up_handler,
3555 .link_down = scic_sds_controller_starting_state_link_down_handler 3450 .link_down = scic_sds_controller_starting_state_link_down_handler
3556 }, 3451 },
3557 [SCI_BASE_CONTROLLER_STATE_READY] = { 3452 [SCI_BASE_CONTROLLER_STATE_READY] = {
3558 .base.stop = scic_sds_controller_ready_state_stop_handler, 3453 .stop = scic_sds_controller_ready_state_stop_handler,
3559 .base.reset = scic_sds_controller_general_reset_handler, 3454 .reset = scic_sds_controller_general_reset_handler,
3560 .base.start_io = scic_sds_controller_ready_state_start_io_handler, 3455 .start_io = scic_sds_controller_ready_state_start_io_handler,
3561 .base.complete_io = scic_sds_controller_ready_state_complete_io_handler, 3456 .complete_io = scic_sds_controller_ready_state_complete_io_handler,
3562 .base.continue_io = scic_sds_controller_ready_state_continue_io_handler, 3457 .continue_io = scic_sds_controller_ready_state_continue_io_handler,
3563 .base.start_task = scic_sds_controller_ready_state_start_task_handler, 3458 .start_task = scic_sds_controller_ready_state_start_task_handler,
3564 .base.complete_task = scic_sds_controller_ready_state_complete_io_handler, 3459 .complete_task = scic_sds_controller_ready_state_complete_io_handler,
3565 .terminate_request = scic_sds_controller_ready_state_terminate_request_handler, 3460 .terminate_request = scic_sds_controller_ready_state_terminate_request_handler,
3566 .link_up = scic_sds_controller_ready_state_link_up_handler, 3461 .link_up = scic_sds_controller_ready_state_link_up_handler,
3567 .link_down = scic_sds_controller_ready_state_link_down_handler 3462 .link_down = scic_sds_controller_ready_state_link_down_handler
3568 }, 3463 },
3569 [SCI_BASE_CONTROLLER_STATE_RESETTING] = { 3464 [SCI_BASE_CONTROLLER_STATE_RESETTING] = {
3570 .base.start_io = scic_sds_controller_default_start_operation_handler, 3465 .start_io = scic_sds_controller_default_start_operation_handler,
3571 .base.complete_io = scic_sds_controller_default_request_handler, 3466 .complete_io = scic_sds_controller_default_request_handler,
3572 .base.continue_io = scic_sds_controller_default_request_handler, 3467 .continue_io = scic_sds_controller_default_request_handler,
3573 .terminate_request = scic_sds_controller_default_request_handler, 3468 .terminate_request = scic_sds_controller_default_request_handler,
3574 }, 3469 },
3575 [SCI_BASE_CONTROLLER_STATE_STOPPING] = { 3470 [SCI_BASE_CONTROLLER_STATE_STOPPING] = {
3576 .base.start_io = scic_sds_controller_default_start_operation_handler, 3471 .start_io = scic_sds_controller_default_start_operation_handler,
3577 .base.complete_io = scic_sds_controller_stopping_state_complete_io_handler, 3472 .complete_io = scic_sds_controller_stopping_state_complete_io_handler,
3578 .base.continue_io = scic_sds_controller_default_request_handler, 3473 .continue_io = scic_sds_controller_default_request_handler,
3579 .terminate_request = scic_sds_controller_default_request_handler, 3474 .terminate_request = scic_sds_controller_default_request_handler,
3580 .device_stopped = scic_sds_controller_stopping_state_device_stopped_handler, 3475 .device_stopped = scic_sds_controller_stopping_state_device_stopped_handler,
3581 }, 3476 },
3582 [SCI_BASE_CONTROLLER_STATE_STOPPED] = { 3477 [SCI_BASE_CONTROLLER_STATE_STOPPED] = {
3583 .base.reset = scic_sds_controller_general_reset_handler, 3478 .reset = scic_sds_controller_general_reset_handler,
3584 .base.start_io = scic_sds_controller_default_start_operation_handler, 3479 .start_io = scic_sds_controller_default_start_operation_handler,
3585 .base.complete_io = scic_sds_controller_default_request_handler, 3480 .complete_io = scic_sds_controller_default_request_handler,
3586 .base.continue_io = scic_sds_controller_default_request_handler, 3481 .continue_io = scic_sds_controller_default_request_handler,
3587 .terminate_request = scic_sds_controller_default_request_handler, 3482 .terminate_request = scic_sds_controller_default_request_handler,
3588 }, 3483 },
3589 [SCI_BASE_CONTROLLER_STATE_FAILED] = { 3484 [SCI_BASE_CONTROLLER_STATE_FAILED] = {
3590 .base.reset = scic_sds_controller_general_reset_handler, 3485 .reset = scic_sds_controller_general_reset_handler,
3591 .base.start_io = scic_sds_controller_default_start_operation_handler, 3486 .start_io = scic_sds_controller_default_start_operation_handler,
3592 .base.complete_io = scic_sds_controller_default_request_handler, 3487 .complete_io = scic_sds_controller_default_request_handler,
3593 .base.continue_io = scic_sds_controller_default_request_handler, 3488 .continue_io = scic_sds_controller_default_request_handler,
3594 .terminate_request = scic_sds_controller_default_request_handler, 3489 .terminate_request = scic_sds_controller_default_request_handler,
3595 }, 3490 },
3596}; 3491};
@@ -3612,8 +3507,8 @@ static void scic_sds_controller_initial_state_enter(
3612 3507
3613 this_controller = (struct scic_sds_controller *)object; 3508 this_controller = (struct scic_sds_controller *)object;
3614 3509
3615 sci_base_state_machine_change_state( 3510 sci_base_state_machine_change_state(&this_controller->state_machine,
3616 &this_controller->parent.state_machine, SCI_BASE_CONTROLLER_STATE_RESET); 3511 SCI_BASE_CONTROLLER_STATE_RESET);
3617} 3512}
3618 3513
3619/** 3514/**
@@ -3718,9 +3613,9 @@ static void scic_sds_controller_resetting_state_enter(struct sci_base_object *ob
3718{ 3613{
3719 struct scic_sds_controller *scic; 3614 struct scic_sds_controller *scic;
3720 3615
3721 scic = container_of(object, typeof(*scic), parent.parent); 3616 scic = container_of(object, typeof(*scic), parent);
3722 scic_sds_controller_reset_hardware(scic); 3617 scic_sds_controller_reset_hardware(scic);
3723 sci_base_state_machine_change_state(&scic->parent.state_machine, 3618 sci_base_state_machine_change_state(&scic->state_machine,
3724 SCI_BASE_CONTROLLER_STATE_RESET); 3619 SCI_BASE_CONTROLLER_STATE_RESET);
3725} 3620}
3726 3621
@@ -3771,10 +3666,13 @@ enum sci_status scic_controller_construct(struct scic_sds_controller *scic,
3771{ 3666{
3772 u8 i; 3667 u8 i;
3773 3668
3774 sci_base_controller_construct(&scic->parent, 3669 sci_base_state_machine_construct(&scic->state_machine,
3775 scic_sds_controller_state_table, 3670 &scic->parent, scic_sds_controller_state_table,
3776 scic->memory_descriptors, 3671 SCI_BASE_CONTROLLER_STATE_INITIAL);
3777 ARRAY_SIZE(scic->memory_descriptors), NULL); 3672
3673 sci_base_mdl_construct(&scic->mdl, scic->memory_descriptors,
3674 ARRAY_SIZE(scic->memory_descriptors), NULL);
3675 sci_base_state_machine_start(&scic->state_machine);
3778 3676
3779 scic->scu_registers = scu_base; 3677 scic->scu_registers = scu_base;
3780 scic->smu_registers = smu_base; 3678 scic->smu_registers = smu_base;
diff --git a/drivers/scsi/isci/core/scic_sds_controller.h b/drivers/scsi/isci/core/scic_sds_controller.h
index baf0b9ededec..f2d7e9c05b17 100644
--- a/drivers/scsi/isci/core/scic_sds_controller.h
+++ b/drivers/scsi/isci/core/scic_sds_controller.h
@@ -69,7 +69,9 @@
69#include "sci_pool.h" 69#include "sci_pool.h"
70#include "sci_controller_constants.h" 70#include "sci_controller_constants.h"
71#include "sci_memory_descriptor_list.h" 71#include "sci_memory_descriptor_list.h"
72#include "sci_base_controller.h" 72#include "sci_base_state.h"
73#include "sci_base_state_machine.h"
74#include "sci_base_memory_descriptor_list.h"
73#include "scic_config_parameters.h" 75#include "scic_config_parameters.h"
74#include "scic_sds_port.h" 76#include "scic_sds_port.h"
75#include "scic_sds_phy.h" 77#include "scic_sds_phy.h"
@@ -82,11 +84,12 @@
82#include "scic_sds_unsolicited_frame_control.h" 84#include "scic_sds_unsolicited_frame_control.h"
83#include "scic_sds_port_configuration_agent.h" 85#include "scic_sds_port_configuration_agent.h"
84 86
87struct sci_base_remote_device;
85struct scic_sds_remote_device; 88struct scic_sds_remote_device;
89struct sci_base_request;
86struct scic_sds_request; 90struct scic_sds_request;
87struct scic_sds_controller; 91struct scic_sds_controller;
88 92
89
90#define SCU_COMPLETION_RAM_ALIGNMENT (64) 93#define SCU_COMPLETION_RAM_ALIGNMENT (64)
91 94
92/** 95/**
@@ -166,10 +169,23 @@ struct scic_power_control {
166 */ 169 */
167struct scic_sds_controller { 170struct scic_sds_controller {
168 /** 171 /**
169 * The struct sci_base_controller is the parent object for the struct scic_sds_controller 172 * The field specifies that the parent object for the base controller
170 * object. 173 * is the base object itself.
174 */
175 struct sci_base_object parent;
176
177 /**
178 * This field points to the memory descriptor list associated with this
179 * controller. The MDL indicates the memory requirements necessary for
180 * this controller object.
181 */
182 struct sci_base_memory_descriptor_list mdl;
183
184 /**
185 * This field contains the information for the base controller state
186 * machine.
171 */ 187 */
172 struct sci_base_controller parent; 188 struct sci_base_state_machine state_machine;
173 189
174 /** 190 /**
175 * This field is the driver timer object handler used to time the controller 191 * This field is the driver timer object handler used to time the controller
@@ -376,24 +392,170 @@ struct scic_sds_controller {
376 392
377}; 393};
378 394
379typedef void (*scic_sds_controller_phy_handler_t)(struct scic_sds_controller *, 395/**
380 struct scic_sds_port *, 396 * enum scic_sds_controller_states - This enumeration depicts all the states
381 struct scic_sds_phy *); 397 * for the common controller state machine.
398 */
399enum scic_sds_controller_states {
400 /**
401 * Simply the initial state for the base controller state machine.
402 */
403 SCI_BASE_CONTROLLER_STATE_INITIAL = 0,
382 404
383typedef void (*scic_sds_controller_device_handler_t)(struct scic_sds_controller *, 405 /**
384 struct scic_sds_remote_device *); 406 * This state indicates that the controller is reset. The memory for
407 * the controller is in it's initial state, but the controller requires
408 * initialization.
409 * This state is entered from the INITIAL state.
410 * This state is entered from the RESETTING state.
411 */
412 SCI_BASE_CONTROLLER_STATE_RESET,
385 413
414 /**
415 * This state is typically an action state that indicates the controller
416 * is in the process of initialization. In this state no new IO operations
417 * are permitted.
418 * This state is entered from the RESET state.
419 */
420 SCI_BASE_CONTROLLER_STATE_INITIALIZING,
421
422 /**
423 * This state indicates that the controller has been successfully
424 * initialized. In this state no new IO operations are permitted.
425 * This state is entered from the INITIALIZING state.
426 */
427 SCI_BASE_CONTROLLER_STATE_INITIALIZED,
428
429 /**
430 * This state indicates the the controller is in the process of becoming
431 * ready (i.e. starting). In this state no new IO operations are permitted.
432 * This state is entered from the INITIALIZED state.
433 */
434 SCI_BASE_CONTROLLER_STATE_STARTING,
435
436 /**
437 * This state indicates the controller is now ready. Thus, the user
438 * is able to perform IO operations on the controller.
439 * This state is entered from the STARTING state.
440 */
441 SCI_BASE_CONTROLLER_STATE_READY,
442
443 /**
444 * This state is typically an action state that indicates the controller
445 * is in the process of resetting. Thus, the user is unable to perform
446 * IO operations on the controller. A reset is considered destructive in
447 * most cases.
448 * This state is entered from the READY state.
449 * This state is entered from the FAILED state.
450 * This state is entered from the STOPPED state.
451 */
452 SCI_BASE_CONTROLLER_STATE_RESETTING,
453
454 /**
455 * This state indicates that the controller is in the process of stopping.
456 * In this state no new IO operations are permitted, but existing IO
457 * operations are allowed to complete.
458 * This state is entered from the READY state.
459 */
460 SCI_BASE_CONTROLLER_STATE_STOPPING,
461
462 /**
463 * This state indicates that the controller has successfully been stopped.
464 * In this state no new IO operations are permitted.
465 * This state is entered from the STOPPING state.
466 */
467 SCI_BASE_CONTROLLER_STATE_STOPPED,
468
469 /**
470 * This state indicates that the controller could not successfully be
471 * initialized. In this state no new IO operations are permitted.
472 * This state is entered from the INITIALIZING state.
473 * This state is entered from the STARTING state.
474 * This state is entered from the STOPPING state.
475 * This state is entered from the RESETTING state.
476 */
477 SCI_BASE_CONTROLLER_STATE_FAILED,
478
479 SCI_BASE_CONTROLLER_MAX_STATES
480
481};
482
483typedef enum sci_status (*scic_sds_controller_handler_t)
484 (struct scic_sds_controller *);
485typedef enum sci_status (*scic_sds_controller_timed_handler_t)
486 (struct scic_sds_controller *, u32);
487typedef enum sci_status (*scic_sds_controller_request_handler_t)
488 (struct scic_sds_controller *,
489 struct sci_base_remote_device *,
490 struct sci_base_request *);
491typedef enum sci_status (*scic_sds_controller_start_request_handler_t)
492 (struct scic_sds_controller *,
493 struct sci_base_remote_device *,
494 struct sci_base_request *, u16);
495typedef void (*scic_sds_controller_phy_handler_t)
496 (struct scic_sds_controller *,
497 struct scic_sds_port *,
498 struct scic_sds_phy *);
499typedef void (*scic_sds_controller_device_handler_t)
500 (struct scic_sds_controller *,
501 struct scic_sds_remote_device *);
386 502
387/**
388 * struct scic_sds_controller_state_handler -
389 *
390 * This structure contains the SDS core specific definition for the state
391 * handlers.
392 */
393struct scic_sds_controller_state_handler { 503struct scic_sds_controller_state_handler {
394 struct sci_base_controller_state_handler base; 504 /**
505 * The start_handler specifies the method invoked when a user attempts to
506 * start a controller.
507 */
508 scic_sds_controller_timed_handler_t start;
509
510 /**
511 * The stop_handler specifies the method invoked when a user attempts to
512 * stop a controller.
513 */
514 scic_sds_controller_timed_handler_t stop;
515
516 /**
517 * The reset_handler specifies the method invoked when a user attempts to
518 * reset a controller.
519 */
520 scic_sds_controller_handler_t reset;
521
522 /**
523 * The initialize_handler specifies the method invoked when a user
524 * attempts to initialize a controller.
525 */
526 scic_sds_controller_handler_t initialize;
527
528 /**
529 * The start_io_handler specifies the method invoked when a user
530 * attempts to start an IO request for a controller.
531 */
532 scic_sds_controller_start_request_handler_t start_io;
533
534 /**
535 * The complete_io_handler specifies the method invoked when a user
536 * attempts to complete an IO request for a controller.
537 */
538 scic_sds_controller_request_handler_t complete_io;
539
540 /**
541 * The continue_io_handler specifies the method invoked when a user
542 * attempts to continue an IO request for a controller.
543 */
544 scic_sds_controller_request_handler_t continue_io;
545
546 /**
547 * The start_task_handler specifies the method invoked when a user
548 * attempts to start a task management request for a controller.
549 */
550 scic_sds_controller_start_request_handler_t start_task;
551
552 /**
553 * The complete_task_handler specifies the method invoked when a user
554 * attempts to complete a task management request for a controller.
555 */
556 scic_sds_controller_request_handler_t complete_task;
395 557
396 sci_base_controller_request_handler_t terminate_request; 558 scic_sds_controller_request_handler_t terminate_request;
397 scic_sds_controller_phy_handler_t link_up; 559 scic_sds_controller_phy_handler_t link_up;
398 scic_sds_controller_phy_handler_t link_down; 560 scic_sds_controller_phy_handler_t link_down;
399 scic_sds_controller_device_handler_t device_stopped; 561 scic_sds_controller_device_handler_t device_stopped;
diff --git a/drivers/scsi/isci/core/scic_sds_remote_device.c b/drivers/scsi/isci/core/scic_sds_remote_device.c
index a6bcaa15fbf4..b4b6be7cdfb9 100644
--- a/drivers/scsi/isci/core/scic_sds_remote_device.c
+++ b/drivers/scsi/isci/core/scic_sds_remote_device.c
@@ -563,12 +563,11 @@ void scic_sds_remote_device_continue_request(void *dev)
563 /* we need to check if this request is still valid to continue. */ 563 /* we need to check if this request is still valid to continue. */
564 if (sci_req) { 564 if (sci_req) {
565 struct scic_sds_controller *scic = sci_req->owning_controller; 565 struct scic_sds_controller *scic = sci_req->owning_controller;
566 u32 state = scic->parent.state_machine.current_state_id; 566 u32 state = scic->state_machine.current_state_id;
567 sci_base_controller_request_handler_t continue_io; 567 scic_sds_controller_request_handler_t continue_io;
568 568
569 continue_io = scic_sds_controller_state_handler_table[state].base.continue_io; 569 continue_io = scic_sds_controller_state_handler_table[state].continue_io;
570 continue_io(&scic->parent, &sci_req->target_device->parent, 570 continue_io(scic, &sci_req->target_device->parent, &sci_req->parent);
571 &sci_req->parent);
572 } 571 }
573} 572}
574 573
diff --git a/drivers/scsi/isci/core/scic_sds_stp_request.c b/drivers/scsi/isci/core/scic_sds_stp_request.c
index 0e961e9cd6eb..5dd4896576d4 100644
--- a/drivers/scsi/isci/core/scic_sds_stp_request.c
+++ b/drivers/scsi/isci/core/scic_sds_stp_request.c
@@ -649,7 +649,7 @@ static enum sci_status scic_sds_stp_request_pio_data_out_trasmit_data_frame(
649 u32 length) 649 u32 length)
650{ 650{
651 struct scic_sds_stp_request *this_sds_stp_request = (struct scic_sds_stp_request *)this_request; 651 struct scic_sds_stp_request *this_sds_stp_request = (struct scic_sds_stp_request *)this_request;
652 sci_base_controller_request_handler_t continue_io; 652 scic_sds_controller_request_handler_t continue_io;
653 struct scu_sgl_element *current_sgl; 653 struct scu_sgl_element *current_sgl;
654 struct scic_sds_controller *scic; 654 struct scic_sds_controller *scic;
655 u32 state; 655 u32 state;
@@ -675,9 +675,9 @@ static enum sci_status scic_sds_stp_request_pio_data_out_trasmit_data_frame(
675 675
676 /* send the new TC out. */ 676 /* send the new TC out. */
677 scic = this_request->owning_controller; 677 scic = this_request->owning_controller;
678 state = scic->parent.state_machine.current_state_id; 678 state = scic->state_machine.current_state_id;
679 continue_io = scic_sds_controller_state_handler_table[state].base.continue_io; 679 continue_io = scic_sds_controller_state_handler_table[state].continue_io;
680 return continue_io(&scic->parent, &this_request->target_device->parent, 680 return continue_io(scic, &this_request->target_device->parent,
681 &this_request->parent); 681 &this_request->parent);
682} 682}
683 683
@@ -1822,7 +1822,7 @@ static void scic_sds_stp_request_started_soft_reset_await_h2d_diagnostic_complet
1822 struct sci_base_object *object) 1822 struct sci_base_object *object)
1823{ 1823{
1824 struct scic_sds_request *this_request = (struct scic_sds_request *)object; 1824 struct scic_sds_request *this_request = (struct scic_sds_request *)object;
1825 sci_base_controller_request_handler_t continue_io; 1825 scic_sds_controller_request_handler_t continue_io;
1826 struct scu_task_context *task_context; 1826 struct scu_task_context *task_context;
1827 struct sata_fis_reg_h2d *h2d_fis; 1827 struct sata_fis_reg_h2d *h2d_fis;
1828 struct scic_sds_controller *scic; 1828 struct scic_sds_controller *scic;
@@ -1839,10 +1839,10 @@ static void scic_sds_stp_request_started_soft_reset_await_h2d_diagnostic_complet
1839 task_context->control_frame = 0; 1839 task_context->control_frame = 0;
1840 1840
1841 scic = this_request->owning_controller; 1841 scic = this_request->owning_controller;
1842 state = scic->parent.state_machine.current_state_id; 1842 state = scic->state_machine.current_state_id;
1843 continue_io = scic_sds_controller_state_handler_table[state].base.continue_io; 1843 continue_io = scic_sds_controller_state_handler_table[state].continue_io;
1844 1844
1845 status = continue_io(&scic->parent, &this_request->target_device->parent, 1845 status = continue_io(scic, &this_request->target_device->parent,
1846 &this_request->parent); 1846 &this_request->parent);
1847 1847
1848 if (status == SCI_SUCCESS) { 1848 if (status == SCI_SUCCESS) {
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c
index 66449593aa8c..adfc2452d216 100644
--- a/drivers/scsi/isci/host.c
+++ b/drivers/scsi/isci/host.c
@@ -62,6 +62,7 @@
62#include "request.h" 62#include "request.h"
63#include "host.h" 63#include "host.h"
64#include "probe_roms.h" 64#include "probe_roms.h"
65#include "core/scic_sds_controller.h"
65 66
66irqreturn_t isci_msix_isr(int vec, void *data) 67irqreturn_t isci_msix_isr(int vec, void *data)
67{ 68{
@@ -231,9 +232,8 @@ static int isci_host_mdl_allocate_coherent(
231 struct coherent_memory_info *mdl_struct; 232 struct coherent_memory_info *mdl_struct;
232 u32 size = 0; 233 u32 size = 0;
233 234
234 struct sci_base_memory_descriptor_list *mdl_handle 235 struct sci_base_memory_descriptor_list *mdl_handle =
235 = sci_controller_get_memory_descriptor_list_handle( 236 &isci_host->core_controller->mdl;
236 isci_host->core_controller);
237 237
238 sci_mdl_first_entry(mdl_handle); 238 sci_mdl_first_entry(mdl_handle);
239 239
diff --git a/drivers/scsi/isci/isci.h b/drivers/scsi/isci/isci.h
index 87643857bade..ac292d2a75de 100644
--- a/drivers/scsi/isci/isci.h
+++ b/drivers/scsi/isci/isci.h
@@ -65,7 +65,7 @@
65#include <scsi/libsas.h> 65#include <scsi/libsas.h>
66#include <scsi/scsi.h> 66#include <scsi/scsi.h>
67 67
68#include "sci_base_controller.h" 68#include "core/sci_object.h"
69#include "scic_controller.h" 69#include "scic_controller.h"
70#include "host.h" 70#include "host.h"
71#include "timers.h" 71#include "timers.h"