blob: 0eb5c7330face66193ffc53956517362291a2638 [file] [log] [blame]
Dan Williams6f231dd2011-07-02 22:56:22 -07001/*
2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
4 *
5 * GPL LICENSE SUMMARY
6 *
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * BSD LICENSE
25 *
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
28 *
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
32 *
33 * * Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * * Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in
37 * the documentation and/or other materials provided with the
38 * distribution.
39 * * Neither the name of Intel Corporation nor the names of its
40 * contributors may be used to endorse or promote products derived
41 * from this software without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 */
55
56#include "isci.h"
57#include "scic_io_request.h"
58#include "scic_remote_device.h"
59#include "scic_phy.h"
60#include "scic_port.h"
61#include "port.h"
62#include "remote_device.h"
63#include "request.h"
64#include "task.h"
65
66
67
68/**
69 * isci_remote_device_deconstruct() - This function frees an isci_remote_device.
70 * @isci_host: This parameter specifies the isci host object.
71 * @isci_device: This parameter specifies the remote device to be freed.
72 *
73 */
74static void isci_remote_device_deconstruct(
75 struct isci_host *isci_host,
76 struct isci_remote_device *isci_device)
77{
78 dev_dbg(&isci_host->pdev->dev,
79 "%s: isci_device = %p\n", __func__, isci_device);
80
81 /* There should not be any outstanding io's. All paths to
82 * here should go through isci_remote_device_nuke_requests.
83 * If we hit this condition, we will need a way to complete
84 * io requests in process */
85 while (!list_empty(&isci_device->reqs_in_process)) {
86
87 dev_err(&isci_host->pdev->dev,
88 "%s: ** request list not empty! **\n", __func__);
89 BUG();
90 }
91
92 /* Remove all related references to this device and free
93 * the cache object.
94 */
Dan Williams3a97eec2011-03-04 11:51:43 -080095 scic_remote_device_destruct(to_sci_dev(isci_device));
Dan Williams6f231dd2011-07-02 22:56:22 -070096 isci_device->domain_dev->lldd_dev = NULL;
97 list_del(&isci_device->node);
98 kmem_cache_free(isci_kmem_cache, isci_device);
99}
100
101
102/**
103 * isci_remote_device_construct() - This function calls the scic remote device
104 * construct and start functions, it waits on the remote device start
105 * completion.
106 * @port: This parameter specifies the isci port with the remote device.
107 * @isci_device: This parameter specifies the isci remote device
108 *
109 * status from the scic calls, the caller to this function should clean up
110 * resources as appropriate.
111 */
112static enum sci_status isci_remote_device_construct(
113 struct isci_port *port,
114 struct isci_remote_device *isci_device)
115{
116 enum sci_status status = SCI_SUCCESS;
117
118 /* let the core do it's common constuction. */
119 scic_remote_device_construct(port->sci_port_handle,
Dan Williams3a97eec2011-03-04 11:51:43 -0800120 to_sci_dev(isci_device));
Dan Williams6f231dd2011-07-02 22:56:22 -0700121
122 /* let the core do it's device specific constuction. */
123 if (isci_device->domain_dev->parent &&
124 (isci_device->domain_dev->parent->dev_type == EDGE_DEV)) {
125 int i;
126
127 /* struct smp_response_discover discover_response; */
128 struct discover_resp discover_response;
129 struct domain_device *parent =
130 isci_device->domain_dev->parent;
131
132 struct expander_device *parent_ex = &parent->ex_dev;
133
134 for (i = 0; i < parent_ex->num_phys; i++) {
135
136 struct ex_phy *phy = &parent_ex->ex_phy[i];
137
138 if ((phy->phy_state == PHY_VACANT) ||
139 (phy->phy_state == PHY_NOT_PRESENT))
140 continue;
141
142 if (SAS_ADDR(phy->attached_sas_addr)
143 == SAS_ADDR(isci_device->domain_dev->sas_addr)) {
144
145 discover_response.attached_dev_type
146 = phy->attached_dev_type;
147 discover_response.linkrate
148 = phy->linkrate;
149 discover_response.attached_sata_host
150 = phy->attached_sata_host;
151 discover_response.attached_sata_dev
152 = phy->attached_sata_dev;
153 discover_response.attached_sata_ps
154 = phy->attached_sata_ps;
155 discover_response.iproto
156 = phy->attached_iproto >> 1;
157 discover_response.tproto
158 = phy->attached_tproto >> 1;
159 memcpy(
160 discover_response.attached_sas_addr,
161 phy->attached_sas_addr,
162 SAS_ADDR_SIZE
163 );
164 discover_response.attached_phy_id
165 = phy->attached_phy_id;
166 discover_response.change_count
167 = phy->phy_change_count;
168 discover_response.routing_attr
169 = phy->routing_attr;
170 discover_response.hmin_linkrate
171 = phy->phy->minimum_linkrate_hw;
172 discover_response.hmax_linkrate
173 = phy->phy->maximum_linkrate_hw;
174 discover_response.pmin_linkrate
175 = phy->phy->minimum_linkrate;
176 discover_response.pmax_linkrate
177 = phy->phy->maximum_linkrate;
178 }
179 }
180
181
182 dev_dbg(&port->isci_host->pdev->dev,
183 "%s: parent->dev_type = EDGE_DEV\n",
184 __func__);
185
Dan Williams3a97eec2011-03-04 11:51:43 -0800186 status = scic_remote_device_ea_construct(to_sci_dev(isci_device),
187 (struct smp_response_discover *)&discover_response);
Dan Williams6f231dd2011-07-02 22:56:22 -0700188
189 } else
Dan Williams3a97eec2011-03-04 11:51:43 -0800190 status = scic_remote_device_da_construct(to_sci_dev(isci_device));
Dan Williams6f231dd2011-07-02 22:56:22 -0700191
192
193 if (status != SCI_SUCCESS) {
194 dev_dbg(&port->isci_host->pdev->dev,
195 "%s: scic_remote_device_da_construct failed - "
196 "isci_device = %p\n",
197 __func__,
198 isci_device);
199
200 return status;
201 }
202
Dan Williams3a97eec2011-03-04 11:51:43 -0800203 sci_object_set_association(to_sci_dev(isci_device), isci_device);
Dan Williams6f231dd2011-07-02 22:56:22 -0700204
205 BUG_ON(port->isci_host == NULL);
206
207 /* start the device. */
Dan Williams3a97eec2011-03-04 11:51:43 -0800208 status = scic_remote_device_start(to_sci_dev(isci_device),
209 ISCI_REMOTE_DEVICE_START_TIMEOUT);
Dan Williams6f231dd2011-07-02 22:56:22 -0700210
211 if (status != SCI_SUCCESS) {
212 dev_warn(&port->isci_host->pdev->dev,
213 "%s: scic_remote_device_start failed\n",
214 __func__);
215 return status;
216 }
217
218 return status;
219}
220
221
222/**
223 * isci_remote_device_nuke_requests() - This function terminates all requests
224 * for a given remote device.
225 * @isci_device: This parameter specifies the remote device
226 *
227 */
228void isci_remote_device_nuke_requests(
229 struct isci_remote_device *isci_device)
230{
231 DECLARE_COMPLETION_ONSTACK(aborted_task_completion);
232 struct isci_host *isci_host;
233
234 isci_host = isci_device->isci_port->isci_host;
235
236 dev_dbg(&isci_host->pdev->dev,
237 "%s: isci_device = %p\n", __func__, isci_device);
238
239 /* Cleanup all requests pending for this device. */
240 isci_terminate_pending_requests(isci_host, isci_device, terminating);
241
242 dev_dbg(&isci_host->pdev->dev,
243 "%s: isci_device = %p, done\n", __func__, isci_device);
244}
245
246
247
248/**
249 * This function builds the isci_remote_device when a libsas dev_found message
250 * is received.
251 * @isci_host: This parameter specifies the isci host object.
252 * @port: This parameter specifies the isci_port conected to this device.
253 *
254 * pointer to new isci_remote_device.
255 */
256static struct isci_remote_device *
257isci_remote_device_alloc(struct isci_host *isci_host, struct isci_port *port)
258{
259 struct isci_remote_device *isci_device;
Dan Williams6f231dd2011-07-02 22:56:22 -0700260
261 isci_device = kmem_cache_zalloc(isci_kmem_cache, GFP_KERNEL);
262
263 if (!isci_device) {
264 dev_warn(&isci_host->pdev->dev, "%s: failed\n", __func__);
265 return NULL;
266 }
267
Dan Williams6f231dd2011-07-02 22:56:22 -0700268 INIT_LIST_HEAD(&isci_device->reqs_in_process);
269 INIT_LIST_HEAD(&isci_device->node);
270 isci_device->host_quiesce = false;
271
272 spin_lock_init(&isci_device->state_lock);
273 spin_lock_init(&isci_device->host_quiesce_lock);
274 isci_remote_device_change_state(isci_device, isci_freed);
275
276 return isci_device;
277
278}
279/**
280 * isci_device_set_host_quiesce_lock_state() - This function sets the host I/O
281 * quiesce lock state for the remote_device object.
282 * @isci_device,: This parameter points to the isci_remote_device object
283 * @isci_device: This parameter specifies the new quiesce state.
284 *
285 */
286void isci_device_set_host_quiesce_lock_state(
287 struct isci_remote_device *isci_device,
288 bool lock_state)
289{
290 unsigned long flags;
291
292 dev_dbg(&isci_device->isci_port->isci_host->pdev->dev,
293 "%s: isci_device=%p, lock_state=%d\n",
294 __func__, isci_device, lock_state);
295
296 spin_lock_irqsave(&isci_device->host_quiesce_lock, flags);
297 isci_device->host_quiesce = lock_state;
298 spin_unlock_irqrestore(&isci_device->host_quiesce_lock, flags);
299}
300
301/**
302 * isci_remote_device_ready() - This function is called by the scic when the
303 * remote device is ready. We mark the isci device as ready and signal the
304 * waiting proccess.
305 * @isci_host: This parameter specifies the isci host object.
306 * @isci_device: This parameter specifies the remote device
307 *
308 */
309void isci_remote_device_ready(struct isci_remote_device *isci_device)
310{
311 unsigned long flags;
312
313 dev_dbg(&isci_device->isci_port->isci_host->pdev->dev,
314 "%s: isci_device = %p\n", __func__, isci_device);
315
316 /* device ready is actually a "ready for io" state. */
317 if ((isci_starting == isci_remote_device_get_state(isci_device)) ||
318 (isci_ready == isci_remote_device_get_state(isci_device))) {
319 spin_lock_irqsave(&isci_device->isci_port->remote_device_lock,
320 flags);
321 isci_remote_device_change_state(isci_device, isci_ready_for_io);
322 if (isci_device->completion)
323 complete(isci_device->completion);
324 spin_unlock_irqrestore(
325 &isci_device->isci_port->remote_device_lock,
326 flags);
327 }
328
329}
330
331/**
332 * isci_remote_device_not_ready() - This function is called by the scic when
333 * the remote device is not ready. We mark the isci device as ready (not
334 * "ready_for_io") and signal the waiting proccess.
335 * @isci_host: This parameter specifies the isci host object.
336 * @isci_device: This parameter specifies the remote device
337 *
338 */
339void isci_remote_device_not_ready(
340 struct isci_remote_device *isci_device,
341 u32 reason_code)
342{
343 dev_dbg(&isci_device->isci_port->isci_host->pdev->dev,
344 "%s: isci_device = %p\n", __func__, isci_device);
345
346 if (reason_code == SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED)
347 isci_remote_device_change_state(isci_device, isci_stopping);
348 else
349 /* device ready is actually a "not ready for io" state. */
350 isci_remote_device_change_state(isci_device, isci_ready);
351}
352
353/**
354 * isci_remote_device_stop_complete() - This function is called by the scic
355 * when the remote device stop has completed. We mark the isci device as not
356 * ready and remove the isci remote device.
357 * @isci_host: This parameter specifies the isci host object.
358 * @isci_device: This parameter specifies the remote device.
359 * @status: This parameter specifies status of the completion.
360 *
361 */
362void isci_remote_device_stop_complete(
363 struct isci_host *isci_host,
364 struct isci_remote_device *isci_device,
365 enum sci_status status)
366{
367 struct completion *completion = isci_device->completion;
368
369 dev_dbg(&isci_host->pdev->dev,
370 "%s: complete isci_device = %p, status = 0x%x\n",
371 __func__,
372 isci_device,
373 status);
374
375 isci_remote_device_change_state(isci_device, isci_stopped);
376
377 /* after stop, we can tear down resources. */
378 isci_remote_device_deconstruct(isci_host, isci_device);
379
380 /* notify interested parties. */
381 if (completion)
382 complete(completion);
383}
384
385/**
386 * isci_remote_device_start_complete() - This function is called by the scic
387 * when the remote device start has completed
388 * @isci_host: This parameter specifies the isci host object.
389 * @isci_device: This parameter specifies the remote device.
390 * @status: This parameter specifies status of the completion.
391 *
392 */
393void isci_remote_device_start_complete(
394 struct isci_host *isci_host,
395 struct isci_remote_device *isci_device,
396 enum sci_status status)
397{
398
399
400}
401
402
403/**
404 * isci_remote_device_stop() - This function is called internally to stop the
405 * remote device.
406 * @isci_host: This parameter specifies the isci host object.
407 * @isci_device: This parameter specifies the remote device.
408 *
409 * The status of the scic request to stop.
410 */
411enum sci_status isci_remote_device_stop(
412 struct isci_remote_device *isci_device)
413{
414 enum sci_status status;
415 unsigned long flags;
416
417 DECLARE_COMPLETION_ONSTACK(completion);
418
419 dev_dbg(&isci_device->isci_port->isci_host->pdev->dev,
420 "%s: isci_device = %p\n", __func__, isci_device);
421
422 isci_remote_device_change_state(isci_device, isci_stopping);
423
424 /* We need comfirmation that stop completed. */
425 isci_device->completion = &completion;
426
427 BUG_ON(isci_device->isci_port == NULL);
428 BUG_ON(isci_device->isci_port->isci_host == NULL);
429
430 spin_lock_irqsave(&isci_device->isci_port->isci_host->scic_lock, flags);
431
Dan Williams3a97eec2011-03-04 11:51:43 -0800432 status = scic_remote_device_stop(to_sci_dev(isci_device), 50);
Dan Williams6f231dd2011-07-02 22:56:22 -0700433
434 spin_unlock_irqrestore(&isci_device->isci_port->isci_host->scic_lock, flags);
435
436 /* Wait for the stop complete callback. */
437 if (status == SCI_SUCCESS)
438 wait_for_completion(&completion);
439
440 dev_dbg(&isci_device->isci_port->isci_host->pdev->dev,
441 "%s: isci_device = %p - after completion wait\n",
442 __func__, isci_device);
443
444 isci_device->completion = NULL;
445 return status;
446}
447
448/**
449 * isci_remote_device_gone() - This function is called by libsas when a domain
450 * device is removed.
451 * @domain_device: This parameter specifies the libsas domain device.
452 *
453 */
454void isci_remote_device_gone(
455 struct domain_device *domain_dev)
456{
457 struct isci_remote_device *isci_device = isci_dev_from_domain_dev(
458 domain_dev);
459
Dave Jiangd7628d02011-03-02 13:10:45 -0800460 dev_dbg(&isci_device->isci_port->isci_host->pdev->dev,
Dan Williams6f231dd2011-07-02 22:56:22 -0700461 "%s: domain_device = %p, isci_device = %p, isci_port = %p\n",
462 __func__, domain_dev, isci_device, isci_device->isci_port);
463
464 if (isci_device != NULL)
465 isci_remote_device_stop(isci_device);
466}
467
468
469/**
470 * isci_remote_device_found() - This function is called by libsas when a remote
471 * device is discovered. A remote device object is created and started. the
472 * function then sleeps until the sci core device started message is
473 * received.
474 * @domain_device: This parameter specifies the libsas domain device.
475 *
476 * status, zero indicates success.
477 */
478int isci_remote_device_found(struct domain_device *domain_dev)
479{
480 unsigned long flags;
481 struct isci_host *isci_host;
482 struct isci_port *isci_port;
483 struct isci_phy *isci_phy;
484 struct asd_sas_port *sas_port;
485 struct asd_sas_phy *sas_phy;
486 struct isci_remote_device *isci_device;
487 enum sci_status status;
488 DECLARE_COMPLETION_ONSTACK(completion);
489
490 isci_host = isci_host_from_sas_ha(domain_dev->port->ha);
491
492 dev_dbg(&isci_host->pdev->dev,
493 "%s: domain_device = %p\n", __func__, domain_dev);
494
Dan Williams0cf89d12011-02-18 09:25:07 -0800495 wait_for_start(isci_host);
496
Dan Williams6f231dd2011-07-02 22:56:22 -0700497 sas_port = domain_dev->port;
498 sas_phy = list_first_entry(&sas_port->phy_list, struct asd_sas_phy,
499 port_phy_el);
500 isci_phy = to_isci_phy(sas_phy);
501 isci_port = isci_phy->isci_port;
502
503 /* we are being called for a device on this port,
504 * so it has to come up eventually
505 */
506 wait_for_completion(&isci_port->start_complete);
507
508 if ((isci_stopping == isci_port_get_state(isci_port)) ||
509 (isci_stopped == isci_port_get_state(isci_port)))
510 return -ENODEV;
511
512 isci_device = isci_remote_device_alloc(isci_host, isci_port);
513
514 INIT_LIST_HEAD(&isci_device->node);
515 domain_dev->lldd_dev = isci_device;
516 isci_device->domain_dev = domain_dev;
517 isci_device->isci_port = isci_port;
518 isci_remote_device_change_state(isci_device, isci_starting);
519
520
521 spin_lock_irqsave(&isci_port->remote_device_lock, flags);
522 list_add_tail(&isci_device->node, &isci_port->remote_dev_list);
523
524 /* for the device ready event. */
525 isci_device->completion = &completion;
526
527 status = isci_remote_device_construct(isci_port, isci_device);
528
529 spin_unlock_irqrestore(&isci_port->remote_device_lock, flags);
530
531 /* wait for the device ready callback. */
532 wait_for_completion(isci_device->completion);
533 isci_device->completion = NULL;
534
535 dev_dbg(&isci_host->pdev->dev,
536 "%s: isci_device = %p\n",
537 __func__, isci_device);
538
539 if (status != SCI_SUCCESS) {
540
541 spin_lock_irqsave(&isci_port->remote_device_lock, flags);
542 isci_remote_device_deconstruct(
543 isci_host,
544 isci_device
545 );
546 spin_unlock_irqrestore(&isci_port->remote_device_lock, flags);
547 return -ENODEV;
548 }
549
Dan Williams6f231dd2011-07-02 22:56:22 -0700550 return 0;
551}
552/**
553 * isci_device_is_reset_pending() - This function will check if there is any
554 * pending reset condition on the device.
555 * @request: This parameter is the isci_device object.
556 *
557 * true if there is a reset pending for the device.
558 */
559bool isci_device_is_reset_pending(
560 struct isci_host *isci_host,
561 struct isci_remote_device *isci_device)
562{
563 struct isci_request *isci_request;
564 struct isci_request *tmp_req;
565 bool reset_is_pending = false;
566 unsigned long flags;
567
568 dev_dbg(&isci_host->pdev->dev,
569 "%s: isci_device = %p\n", __func__, isci_device);
570
571 spin_lock_irqsave(&isci_host->scic_lock, flags);
572
573 /* Check for reset on all pending requests. */
574 list_for_each_entry_safe(isci_request, tmp_req,
575 &isci_device->reqs_in_process, dev_node) {
576 dev_dbg(&isci_host->pdev->dev,
577 "%s: isci_device = %p request = %p\n",
578 __func__, isci_device, isci_request);
579
580 if (isci_request->ttype == io_task) {
581
582 unsigned long flags;
583 struct sas_task *task = isci_request_access_task(
584 isci_request);
585
586 spin_lock_irqsave(&task->task_state_lock, flags);
587 if (task->task_state_flags & SAS_TASK_NEED_DEV_RESET)
588 reset_is_pending = true;
589 spin_unlock_irqrestore(&task->task_state_lock, flags);
590 }
591 }
592
593 spin_unlock_irqrestore(&isci_host->scic_lock, flags);
594
595 dev_dbg(&isci_host->pdev->dev,
596 "%s: isci_device = %p reset_is_pending = %d\n",
597 __func__, isci_device, reset_is_pending);
598
599 return reset_is_pending;
600}
601
602/**
603 * isci_device_clear_reset_pending() - This function will clear if any pending
604 * reset condition flags on the device.
605 * @request: This parameter is the isci_device object.
606 *
607 * true if there is a reset pending for the device.
608 */
609void isci_device_clear_reset_pending(struct isci_remote_device *isci_device)
610{
611 struct isci_request *isci_request;
612 struct isci_request *tmp_req;
613 struct isci_host *isci_host = NULL;
614 unsigned long flags = 0;
615
616 /* FIXME more port gone confusion, and this time it makes the
617 * locking "fun"
618 */
619 if (isci_device->isci_port != NULL)
620 isci_host = isci_device->isci_port->isci_host;
621
622 /*
623 * FIXME when the isci_host gets sorted out
624 * use dev_dbg()
625 */
626 pr_debug("%s: isci_device=%p, isci_host=%p\n",
627 __func__, isci_device, isci_host);
628
629 if (isci_host != NULL)
630 spin_lock_irqsave(&isci_host->scic_lock, flags);
631 else
632 pr_err("%s: isci_device %p; isci_host == NULL!\n",
633 __func__, isci_device);
634
635 /* Clear reset pending on all pending requests. */
636 list_for_each_entry_safe(isci_request, tmp_req,
637 &isci_device->reqs_in_process, dev_node) {
638 /*
639 * FIXME when the conditional spinlock is gone
640 * change to dev_dbg()
641 */
642 pr_debug("%s: isci_device = %p request = %p\n",
643 __func__, isci_device, isci_request);
644
645 if (isci_request->ttype == io_task) {
646
647 unsigned long flags2;
648 struct sas_task *task = isci_request_access_task(
649 isci_request);
650
651 spin_lock_irqsave(&task->task_state_lock, flags2);
652 task->task_state_flags &= ~SAS_TASK_NEED_DEV_RESET;
653 spin_unlock_irqrestore(&task->task_state_lock, flags2);
654 }
655 }
656
657 if (isci_host != NULL)
658 spin_unlock_irqrestore(&isci_host->scic_lock, flags);
659}
660
661/**
662 * isci_remote_device_change_state() - This function gets the status of the
663 * remote_device object.
664 * @isci_device: This parameter points to the isci_remote_device object
665 *
666 * status of the object as a isci_status enum.
667 */
668void isci_remote_device_change_state(
669 struct isci_remote_device *isci_device,
670 enum isci_status status)
671{
672 unsigned long flags;
673
Dan Williams6f231dd2011-07-02 22:56:22 -0700674 spin_lock_irqsave(&isci_device->state_lock, flags);
675 isci_device->status = status;
676 spin_unlock_irqrestore(&isci_device->state_lock, flags);
677}