2 * linux/drivers/scsi/esas2r/esas2r_io.c
3 * For use with ATTO ExpressSAS R6xx SAS/SATA RAID controllers
5 * Copyright (c) 2001-2013 ATTO Technology, Inc.
6 * (mailto:linuxdrivers@attotech.com)mpt3sas/mpt3sas_trigger_diag.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
19 * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
20 * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
21 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
22 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
23 * solely responsible for determining the appropriateness of using and
24 * distributing the Program and assumes all risks associated with its
25 * exercise of rights under this Agreement, including but not limited to
26 * the risks and costs of program errors, damage to or loss of data,
27 * programs or equipment, and unavailability or interruption of operations.
29 * DISCLAIMER OF LIABILITY
30 * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
31 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
33 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
34 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
35 * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
36 * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
38 * You should have received a copy of the GNU General Public License
39 * along with this program; if not, write to the Free Software
40 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
46 void esas2r_start_request(struct esas2r_adapter
*a
, struct esas2r_request
*rq
)
48 struct esas2r_target
*t
= NULL
;
49 struct esas2r_request
*startrq
= rq
;
52 if (unlikely(a
->flags
& (AF_DEGRADED_MODE
| AF_POWER_DOWN
))) {
53 if (rq
->vrq
->scsi
.function
== VDA_FUNC_SCSI
)
54 rq
->req_stat
= RS_SEL2
;
56 rq
->req_stat
= RS_DEGRADED
;
57 } else if (likely(rq
->vrq
->scsi
.function
== VDA_FUNC_SCSI
)) {
58 t
= a
->targetdb
+ rq
->target_id
;
60 if (unlikely(t
>= a
->targetdb_end
61 || !(t
->flags
& TF_USED
))) {
62 rq
->req_stat
= RS_SEL
;
64 /* copy in the target ID. */
65 rq
->vrq
->scsi
.target_id
= cpu_to_le16(t
->virt_targ_id
);
68 * Test if we want to report RS_SEL for missing target.
69 * Note that if AF_DISC_PENDING is set than this will
70 * go on the defer queue.
72 if (unlikely(t
->target_state
!= TS_PRESENT
73 && !(a
->flags
& AF_DISC_PENDING
)))
74 rq
->req_stat
= RS_SEL
;
78 if (unlikely(rq
->req_stat
!= RS_PENDING
)) {
79 esas2r_complete_request(a
, rq
);
83 esas2r_trace("rq=%p", rq
);
84 esas2r_trace("rq->vrq->scsi.handle=%x", rq
->vrq
->scsi
.handle
);
86 if (rq
->vrq
->scsi
.function
== VDA_FUNC_SCSI
) {
87 esas2r_trace("rq->target_id=%d", rq
->target_id
);
88 esas2r_trace("rq->vrq->scsi.flags=%x", rq
->vrq
->scsi
.flags
);
91 spin_lock_irqsave(&a
->queue_lock
, flags
);
93 if (likely(list_empty(&a
->defer_list
) &&
95 (AF_CHPRST_PENDING
| AF_FLASHING
| AF_DISC_PENDING
))))
96 esas2r_local_start_request(a
, startrq
);
98 list_add_tail(&startrq
->req_list
, &a
->defer_list
);
100 spin_unlock_irqrestore(&a
->queue_lock
, flags
);
104 * Starts the specified request. all requests have RS_PENDING set when this
105 * routine is called. The caller is usually esas2r_start_request, but
106 * esas2r_do_deferred_processes will start request that are deferred.
108 * The caller must ensure that requests can be started.
110 * esas2r_start_request will defer a request if there are already requests
111 * waiting or there is a chip reset pending. once the reset condition clears,
112 * esas2r_do_deferred_processes will call this function to start the request.
114 * When a request is started, it is placed on the active list and queued to
117 void esas2r_local_start_request(struct esas2r_adapter
*a
,
118 struct esas2r_request
*rq
)
120 esas2r_trace_enter();
121 esas2r_trace("rq=%p", rq
);
122 esas2r_trace("rq->vrq:%p", rq
->vrq
);
123 esas2r_trace("rq->vrq_md->phys_addr:%x", rq
->vrq_md
->phys_addr
);
125 if (unlikely(rq
->vrq
->scsi
.function
== VDA_FUNC_FLASH
126 && rq
->vrq
->flash
.sub_func
== VDA_FLASH_COMMIT
))
127 esas2r_lock_set_flags(&a
->flags
, AF_FLASHING
);
129 list_add_tail(&rq
->req_list
, &a
->active_list
);
130 esas2r_start_vda_request(a
, rq
);
135 void esas2r_start_vda_request(struct esas2r_adapter
*a
,
136 struct esas2r_request
*rq
)
138 struct esas2r_inbound_list_source_entry
*element
;
141 rq
->req_stat
= RS_STARTED
;
143 * Calculate the inbound list entry location and the current state of
147 if (a
->last_write
>= a
->list_size
) {
149 /* update the toggle bit */
150 if (a
->flags
& AF_COMM_LIST_TOGGLE
)
151 esas2r_lock_clear_flags(&a
->flags
,
152 AF_COMM_LIST_TOGGLE
);
154 esas2r_lock_set_flags(&a
->flags
, AF_COMM_LIST_TOGGLE
);
158 (struct esas2r_inbound_list_source_entry
*)a
->inbound_list_md
.
162 /* Set the VDA request size if it was never modified */
163 if (rq
->vda_req_sz
== RQ_SIZE_DEFAULT
)
164 rq
->vda_req_sz
= (u16
)(a
->max_vdareq_size
/ sizeof(u32
));
166 element
->address
= cpu_to_le64(rq
->vrq_md
->phys_addr
);
167 element
->length
= cpu_to_le32(rq
->vda_req_sz
);
169 /* Update the write pointer */
172 if (a
->flags
& AF_COMM_LIST_TOGGLE
)
175 esas2r_trace("rq->vrq->scsi.handle:%x", rq
->vrq
->scsi
.handle
);
176 esas2r_trace("dw:%x", dw
);
177 esas2r_trace("rq->vda_req_sz:%x", rq
->vda_req_sz
);
178 esas2r_write_register_dword(a
, MU_IN_LIST_WRITE
, dw
);
182 * Build the scatter/gather list for an I/O request according to the
183 * specifications placed in the s/g context. The caller must initialize
184 * context prior to the initial call by calling esas2r_sgc_init().
186 bool esas2r_build_sg_list_sge(struct esas2r_adapter
*a
,
187 struct esas2r_sg_context
*sgc
)
189 struct esas2r_request
*rq
= sgc
->first_req
;
190 union atto_vda_req
*vrq
= rq
->vrq
;
192 while (sgc
->length
) {
197 len
= (*sgc
->get_phys_addr
)(sgc
, &addr
);
199 if (unlikely(len
== 0))
202 /* if current length is more than what's left, stop there */
203 if (unlikely(len
> sgc
->length
))
207 /* limit to a round number less than the maximum length */
208 if (len
> SGE_LEN_MAX
) {
210 * Save the remainder of the split. Whenever we limit
211 * an entry we come back around to build entries out
212 * of the leftover. We do this to prevent multiple
213 * calls to the get_phys_addr() function for an SGE
216 rem
= len
- SGE_LEN_MAX
;
220 /* See if we need to allocate a new SGL */
221 if (unlikely(sgc
->sge
.a64
.curr
> sgc
->sge
.a64
.limit
)) {
223 struct esas2r_mem_desc
*sgl
;
226 * If no SGls are available, return failure. The
227 * caller can call us later with the current context
230 sgl
= esas2r_alloc_sgl(a
);
232 if (unlikely(sgl
== NULL
))
235 /* Calculate the length of the last SGE filled in */
236 sgelen
= (u8
)((u8
*)sgc
->sge
.a64
.curr
237 - (u8
*)sgc
->sge
.a64
.last
);
240 * Copy the last SGE filled in to the first entry of
241 * the new SGL to make room for the chain entry.
243 memcpy(sgl
->virt_addr
, sgc
->sge
.a64
.last
, sgelen
);
245 /* Figure out the new curr pointer in the new segment */
247 (struct atto_vda_sge
*)((u8
*)sgl
->virt_addr
+
250 /* Set the limit pointer and build the chain entry */
252 (struct atto_vda_sge
*)((u8
*)sgl
->virt_addr
256 sgc
->sge
.a64
.last
->length
= cpu_to_le32(
257 SGE_CHAIN
| SGE_ADDR_64
);
258 sgc
->sge
.a64
.last
->address
=
259 cpu_to_le64(sgl
->phys_addr
);
262 * Now, if there was a previous chain entry, then
263 * update it to contain the length of this segment
264 * and size of this chain. otherwise this is the
265 * first SGL, so set the chain_offset in the request.
267 if (sgc
->sge
.a64
.chain
) {
268 sgc
->sge
.a64
.chain
->length
|=
270 ((u8
*)(sgc
->sge
.a64
.
272 - (u8
*)rq
->sg_table
->
274 + sizeof(struct atto_vda_sge
) *
275 LOBIT(SGE_CHAIN_SZ
));
277 vrq
->scsi
.chain_offset
= (u8
)
283 * This is the first SGL, so set the
284 * chain_offset and the VDA request size in
288 (vrq
->scsi
.chain_offset
+
289 sizeof(struct atto_vda_sge
) +
295 * Remember this so when we get a new SGL filled in we
296 * can update the length of this chain entry.
298 sgc
->sge
.a64
.chain
= sgc
->sge
.a64
.last
;
300 /* Now link the new SGL onto the primary request. */
301 list_add(&sgl
->next_desc
, &rq
->sg_table_head
);
304 /* Update last one filled in */
305 sgc
->sge
.a64
.last
= sgc
->sge
.a64
.curr
;
307 /* Build the new SGE and update the S/G context */
308 sgc
->sge
.a64
.curr
->length
= cpu_to_le32(SGE_ADDR_64
| len
);
309 sgc
->sge
.a64
.curr
->address
= cpu_to_le32(addr
);
311 sgc
->cur_offset
+= len
;
315 * Check if we previously split an entry. If so we have to
316 * pick up where we left off.
326 /* Mark the end of the SGL */
327 sgc
->sge
.a64
.last
->length
|= cpu_to_le32(SGE_LAST
);
330 * If there was a previous chain entry, update the length to indicate
331 * the length of this last segment.
333 if (sgc
->sge
.a64
.chain
) {
334 sgc
->sge
.a64
.chain
->length
|= cpu_to_le32(
335 ((u8
*)(sgc
->sge
.a64
.curr
) -
336 (u8
*)rq
->sg_table
->virt_addr
));
341 * The entire VDA request was not used so lets
342 * set the size of the VDA request to be DMA'd
345 ((u16
)((u8
*)sgc
->sge
.a64
.last
- (u8
*)vrq
)
346 + sizeof(struct atto_vda_sge
) + 3) / sizeof(u32
);
349 * Only update the request size if it is bigger than what is
350 * already there. We can come in here twice for some management
353 if (reqsize
> rq
->vda_req_sz
)
354 rq
->vda_req_sz
= reqsize
;
361 * Create PRD list for each I-block consumed by the command. This routine
362 * determines how much data is required from each I-block being consumed
363 * by the command. The first and last I-blocks can be partials and all of
364 * the I-blocks in between are for a full I-block of data.
366 * The interleave size is used to determine the number of bytes in the 1st
367 * I-block and the remaining I-blocks are what remeains.
369 static bool esas2r_build_prd_iblk(struct esas2r_adapter
*a
,
370 struct esas2r_sg_context
*sgc
)
372 struct esas2r_request
*rq
= sgc
->first_req
;
375 struct esas2r_mem_desc
*sgl
;
379 while (sgc
->length
) {
380 /* Get the next address/length pair */
382 len
= (*sgc
->get_phys_addr
)(sgc
, &addr
);
384 if (unlikely(len
== 0))
387 /* If current length is more than what's left, stop there */
389 if (unlikely(len
> sgc
->length
))
393 /* Limit to a round number less than the maximum length */
395 if (len
> PRD_LEN_MAX
) {
397 * Save the remainder of the split. whenever we limit
398 * an entry we come back around to build entries out
399 * of the leftover. We do this to prevent multiple
400 * calls to the get_phys_addr() function for an SGE
403 rem
= len
- PRD_LEN_MAX
;
407 /* See if we need to allocate a new SGL */
408 if (sgc
->sge
.prd
.sge_cnt
== 0) {
409 if (len
== sgc
->length
) {
411 * We only have 1 PRD entry left.
412 * It can be placed where the chain
413 * entry would have gone
416 /* Build the simple SGE */
417 sgc
->sge
.prd
.curr
->ctl_len
= cpu_to_le32(
419 sgc
->sge
.prd
.curr
->address
= cpu_to_le64(addr
);
421 /* Adjust length related fields */
422 sgc
->cur_offset
+= len
;
425 /* We use the reserved chain entry for data */
431 if (sgc
->sge
.prd
.chain
) {
433 * Fill # of entries of current SGL in previous
434 * chain the length of this current SGL may not
438 sgc
->sge
.prd
.chain
->ctl_len
|= cpu_to_le32(
439 sgc
->sge
.prd
.sgl_max_cnt
);
443 * If no SGls are available, return failure. The
444 * caller can call us later with the current context
448 sgl
= esas2r_alloc_sgl(a
);
450 if (unlikely(sgl
== NULL
))
454 * Link the new SGL onto the chain
455 * They are in reverse order
457 list_add(&sgl
->next_desc
, &rq
->sg_table_head
);
460 * An SGL was just filled in and we are starting
461 * a new SGL. Prime the chain of the ending SGL with
462 * info that points to the new SGL. The length gets
463 * filled in when the new SGL is filled or ended
466 sgc
->sge
.prd
.chain
= sgc
->sge
.prd
.curr
;
468 sgc
->sge
.prd
.chain
->ctl_len
= cpu_to_le32(PRD_CHAIN
);
469 sgc
->sge
.prd
.chain
->address
=
470 cpu_to_le64(sgl
->phys_addr
);
473 * Start a new segment.
474 * Take one away and save for chain SGE
478 (struct atto_physical_region_description
*)sgl
481 sgc
->sge
.prd
.sge_cnt
= sgc
->sge
.prd
.sgl_max_cnt
- 1;
484 sgc
->sge
.prd
.sge_cnt
--;
485 /* Build the simple SGE */
486 sgc
->sge
.prd
.curr
->ctl_len
= cpu_to_le32(PRD_DATA
| len
);
487 sgc
->sge
.prd
.curr
->address
= cpu_to_le64(addr
);
489 /* Used another element. Point to the next one */
493 /* Adjust length related fields */
495 sgc
->cur_offset
+= len
;
499 * Check if we previously split an entry. If so we have to
500 * pick up where we left off.
511 if (!list_empty(&rq
->sg_table_head
)) {
512 if (sgc
->sge
.prd
.chain
) {
513 sgc
->sge
.prd
.chain
->ctl_len
|=
514 cpu_to_le32(sgc
->sge
.prd
.sgl_max_cnt
515 - sgc
->sge
.prd
.sge_cnt
523 bool esas2r_build_sg_list_prd(struct esas2r_adapter
*a
,
524 struct esas2r_sg_context
*sgc
)
526 struct esas2r_request
*rq
= sgc
->first_req
;
527 u32 len
= sgc
->length
;
528 struct esas2r_target
*t
= a
->targetdb
+ rq
->target_id
;
531 struct atto_physical_region_description
*curr_iblk_chn
;
532 u8
*cdb
= (u8
*)&rq
->vrq
->scsi
.cdb
[0];
535 * extract LBA from command so we can determine
536 * the I-Block boundary
539 if (rq
->vrq
->scsi
.function
== VDA_FUNC_SCSI
540 && t
->target_state
== TS_PRESENT
541 && !(t
->flags
& TF_PASS_THRU
)) {
544 switch (rq
->vrq
->scsi
.cdb
[0]) {
549 MAKEDWORD(MAKEWORD(cdb
[9],
563 MAKEDWORD(MAKEWORD(cdb
[5],
575 MAKEDWORD(MAKEWORD(cdb
[3],
577 MAKEWORD(cdb
[1] & 0x1F,
590 rq
->vrq
->scsi
.iblk_cnt_prd
= 0;
592 /* Determine size of 1st I-block PRD list */
593 startlba
= t
->inter_block
- (lbalo
& (t
->inter_block
-
595 sgc
->length
= startlba
* t
->block_size
;
597 /* Chk if the 1st iblk chain starts at base of Iblock */
598 if ((lbalo
& (t
->inter_block
- 1)) == 0)
599 rq
->flags
|= RF_1ST_IBLK_BASE
;
601 if (sgc
->length
> len
)
610 /* get our starting chain address */
613 (struct atto_physical_region_description
*)sgc
->sge
.a64
.curr
;
615 sgc
->sge
.prd
.sgl_max_cnt
= sgl_page_size
/
617 atto_physical_region_description
);
619 /* create all of the I-block PRD lists */
622 sgc
->sge
.prd
.sge_cnt
= 0;
623 sgc
->sge
.prd
.chain
= NULL
;
624 sgc
->sge
.prd
.curr
= curr_iblk_chn
;
626 /* increment to next I-Block */
630 /* go build the next I-Block PRD list */
632 if (unlikely(!esas2r_build_prd_iblk(a
, sgc
)))
638 rq
->vrq
->scsi
.iblk_cnt_prd
++;
640 if (len
> t
->inter_byte
)
641 sgc
->length
= t
->inter_byte
;
647 /* figure out the size used of the VDA request */
649 reqsize
= ((u16
)((u8
*)curr_iblk_chn
- (u8
*)rq
->vrq
))
653 * only update the request size if it is bigger than what is
654 * already there. we can come in here twice for some management
658 if (reqsize
> rq
->vda_req_sz
)
659 rq
->vda_req_sz
= reqsize
;
664 static void esas2r_handle_pending_reset(struct esas2r_adapter
*a
, u32 currtime
)
666 u32 delta
= currtime
- a
->chip_init_time
;
668 if (delta
<= ESAS2R_CHPRST_WAIT_TIME
) {
669 /* Wait before accessing registers */
670 } else if (delta
>= ESAS2R_CHPRST_TIME
) {
672 * The last reset failed so try again. Reset
673 * processing will give up after three tries.
675 esas2r_local_reset_adapter(a
);
677 /* We can now see if the firmware is ready */
680 doorbell
= esas2r_read_register_dword(a
, MU_DOORBELL_OUT
);
681 if (doorbell
== 0xFFFFFFFF || !(doorbell
& DRBL_FORCE_INT
)) {
682 esas2r_force_interrupt(a
);
684 u32 ver
= (doorbell
& DRBL_FW_VER_MSK
);
686 /* Driver supports API version 0 and 1 */
687 esas2r_write_register_dword(a
, MU_DOORBELL_OUT
,
689 if (ver
== DRBL_FW_VER_0
) {
690 esas2r_lock_set_flags(&a
->flags
,
692 esas2r_lock_set_flags(&a
->flags
,
695 a
->max_vdareq_size
= 128;
696 a
->build_sgl
= esas2r_build_sg_list_sge
;
697 } else if (ver
== DRBL_FW_VER_1
) {
698 esas2r_lock_set_flags(&a
->flags
,
700 esas2r_lock_clear_flags(&a
->flags
,
703 a
->max_vdareq_size
= 1024;
704 a
->build_sgl
= esas2r_build_sg_list_prd
;
706 esas2r_local_reset_adapter(a
);
713 /* This function must be called once per timer tick */
714 void esas2r_timer_tick(struct esas2r_adapter
*a
)
716 u32 currtime
= jiffies_to_msecs(jiffies
);
717 u32 deltatime
= currtime
- a
->last_tick_time
;
719 a
->last_tick_time
= currtime
;
721 /* count down the uptime */
723 && !(a
->flags
& (AF_CHPRST_PENDING
| AF_DISC_PENDING
))) {
724 if (deltatime
>= a
->chip_uptime
)
727 a
->chip_uptime
-= deltatime
;
730 if (a
->flags
& AF_CHPRST_PENDING
) {
731 if (!(a
->flags
& AF_CHPRST_NEEDED
)
732 && !(a
->flags
& AF_CHPRST_DETECTED
))
733 esas2r_handle_pending_reset(a
, currtime
);
735 if (a
->flags
& AF_DISC_PENDING
)
736 esas2r_disc_check_complete(a
);
738 if (a
->flags
& AF_HEARTBEAT_ENB
) {
739 if (a
->flags
& AF_HEARTBEAT
) {
740 if ((currtime
- a
->heartbeat_time
) >=
741 ESAS2R_HEARTBEAT_TIME
) {
742 esas2r_lock_clear_flags(&a
->flags
,
744 esas2r_hdebug("heartbeat failed");
745 esas2r_log(ESAS2R_LOG_CRIT
,
748 esas2r_local_reset_adapter(a
);
751 esas2r_lock_set_flags(&a
->flags
, AF_HEARTBEAT
);
752 a
->heartbeat_time
= currtime
;
753 esas2r_force_interrupt(a
);
758 if (atomic_read(&a
->disable_cnt
) == 0)
759 esas2r_do_deferred_processes(a
);
763 * Send the specified task management function to the target and LUN
764 * specified in rqaux. in addition, immediately abort any commands that
765 * are queued but not sent to the device according to the rules specified
766 * by the task management function.
768 bool esas2r_send_task_mgmt(struct esas2r_adapter
*a
,
769 struct esas2r_request
*rqaux
, u8 task_mgt_func
)
771 u16 targetid
= rqaux
->target_id
;
772 u8 lun
= (u8
)le32_to_cpu(rqaux
->vrq
->scsi
.flags
);
774 struct esas2r_request
*rq
;
775 struct list_head
*next
, *element
;
778 LIST_HEAD(comp_list
);
780 esas2r_trace_enter();
781 esas2r_trace("rqaux:%p", rqaux
);
782 esas2r_trace("task_mgt_func:%x", task_mgt_func
);
783 spin_lock_irqsave(&a
->queue_lock
, flags
);
785 /* search the defer queue looking for requests for the device */
786 list_for_each_safe(element
, next
, &a
->defer_list
) {
787 rq
= list_entry(element
, struct esas2r_request
, req_list
);
789 if (rq
->vrq
->scsi
.function
== VDA_FUNC_SCSI
790 && rq
->target_id
== targetid
791 && (((u8
)le32_to_cpu(rq
->vrq
->scsi
.flags
)) == lun
792 || task_mgt_func
== 0x20)) { /* target reset */
793 /* Found a request affected by the task management */
794 if (rq
->req_stat
== RS_PENDING
) {
796 * The request is pending or waiting. We can
797 * safelycomplete the request now.
799 if (esas2r_ioreq_aborted(a
, rq
, RS_ABORTED
))
800 list_add_tail(&rq
->comp_list
,
806 /* Send the task management request to the firmware */
807 rqaux
->sense_len
= 0;
808 rqaux
->vrq
->scsi
.length
= 0;
809 rqaux
->target_id
= targetid
;
810 rqaux
->vrq
->scsi
.flags
|= cpu_to_le32(lun
);
811 memset(rqaux
->vrq
->scsi
.cdb
, 0, sizeof(rqaux
->vrq
->scsi
.cdb
));
812 rqaux
->vrq
->scsi
.flags
|=
813 cpu_to_le16(task_mgt_func
* LOBIT(FCP_CMND_TM_MASK
));
815 if (a
->flags
& AF_FLASHING
) {
816 /* Assume success. if there are active requests, return busy */
817 rqaux
->req_stat
= RS_SUCCESS
;
819 list_for_each_safe(element
, next
, &a
->active_list
) {
820 rq
= list_entry(element
, struct esas2r_request
,
822 if (rq
->vrq
->scsi
.function
== VDA_FUNC_SCSI
823 && rq
->target_id
== targetid
824 && (((u8
)le32_to_cpu(rq
->vrq
->scsi
.flags
)) == lun
825 || task_mgt_func
== 0x20)) /* target reset */
826 rqaux
->req_stat
= RS_BUSY
;
832 spin_unlock_irqrestore(&a
->queue_lock
, flags
);
834 if (!(a
->flags
& AF_FLASHING
))
835 esas2r_start_request(a
, rqaux
);
837 esas2r_comp_list_drain(a
, &comp_list
);
839 if (atomic_read(&a
->disable_cnt
) == 0)
840 esas2r_do_deferred_processes(a
);
847 void esas2r_reset_bus(struct esas2r_adapter
*a
)
849 esas2r_log(ESAS2R_LOG_INFO
, "performing a bus reset");
851 if (!(a
->flags
& AF_DEGRADED_MODE
)
852 && !(a
->flags
& (AF_CHPRST_PENDING
| AF_DISC_PENDING
))) {
853 esas2r_lock_set_flags(&a
->flags
, AF_BUSRST_NEEDED
);
854 esas2r_lock_set_flags(&a
->flags
, AF_BUSRST_PENDING
);
855 esas2r_lock_set_flags(&a
->flags
, AF_OS_RESET
);
857 esas2r_schedule_tasklet(a
);
861 bool esas2r_ioreq_aborted(struct esas2r_adapter
*a
, struct esas2r_request
*rq
,
864 esas2r_trace_enter();
865 esas2r_trace("rq:%p", rq
);
866 list_del_init(&rq
->req_list
);
867 if (rq
->timeout
> RQ_MAX_TIMEOUT
) {
869 * The request timed out, but we could not abort it because a
870 * chip reset occurred. Return busy status.
872 rq
->req_stat
= RS_BUSY
;
877 rq
->req_stat
= status
;