hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/scsi/qla2xxx/qla_iocb.c
....@@ -601,7 +601,8 @@
601601 put_unaligned_le32(COMMAND_TYPE_6, &cmd_pkt->entry_type);
602602
603603 /* No data transfer */
604
- if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
604
+ if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE ||
605
+ tot_dsds == 0) {
605606 cmd_pkt->byte_count = cpu_to_le32(0);
606607 return 0;
607608 }
....@@ -1643,8 +1644,14 @@
16431644 goto queuing_error;
16441645
16451646 if (req->cnt < (req_cnt + 2)) {
1646
- cnt = IS_SHADOW_REG_CAPABLE(ha) ? *req->out_ptr :
1647
- rd_reg_dword_relaxed(req->req_q_out);
1647
+ if (IS_SHADOW_REG_CAPABLE(ha)) {
1648
+ cnt = *req->out_ptr;
1649
+ } else {
1650
+ cnt = rd_reg_dword_relaxed(req->req_q_out);
1651
+ if (qla2x00_check_reg16_for_disconnect(vha, cnt))
1652
+ goto queuing_error;
1653
+ }
1654
+
16481655 if (req->ring_index < cnt)
16491656 req->cnt = cnt - req->ring_index;
16501657 else
....@@ -1835,8 +1842,13 @@
18351842 goto queuing_error;
18361843
18371844 if (req->cnt < (req_cnt + 2)) {
1838
- cnt = IS_SHADOW_REG_CAPABLE(ha) ? *req->out_ptr :
1839
- rd_reg_dword_relaxed(req->req_q_out);
1845
+ if (IS_SHADOW_REG_CAPABLE(ha)) {
1846
+ cnt = *req->out_ptr;
1847
+ } else {
1848
+ cnt = rd_reg_dword_relaxed(req->req_q_out);
1849
+ if (qla2x00_check_reg16_for_disconnect(vha, cnt))
1850
+ goto queuing_error;
1851
+ }
18401852 if (req->ring_index < cnt)
18411853 req->cnt = cnt - req->ring_index;
18421854 else
....@@ -1910,6 +1922,7 @@
19101922
19111923 qla_put_iocbs(sp->qpair, &sp->iores);
19121924 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1925
+
19131926 return QLA_FUNCTION_FAILED;
19141927 }
19151928
....@@ -1977,8 +1990,14 @@
19771990 goto queuing_error;
19781991
19791992 if (req->cnt < (req_cnt + 2)) {
1980
- cnt = IS_SHADOW_REG_CAPABLE(ha) ? *req->out_ptr :
1981
- rd_reg_dword_relaxed(req->req_q_out);
1993
+ if (IS_SHADOW_REG_CAPABLE(ha)) {
1994
+ cnt = *req->out_ptr;
1995
+ } else {
1996
+ cnt = rd_reg_dword_relaxed(req->req_q_out);
1997
+ if (qla2x00_check_reg16_for_disconnect(vha, cnt))
1998
+ goto queuing_error;
1999
+ }
2000
+
19822001 if (req->ring_index < cnt)
19832002 req->cnt = cnt - req->ring_index;
19842003 else
....@@ -2184,8 +2203,14 @@
21842203 goto queuing_error;
21852204
21862205 if (req->cnt < (req_cnt + 2)) {
2187
- cnt = IS_SHADOW_REG_CAPABLE(ha) ? *req->out_ptr :
2188
- rd_reg_dword_relaxed(req->req_q_out);
2206
+ if (IS_SHADOW_REG_CAPABLE(ha)) {
2207
+ cnt = *req->out_ptr;
2208
+ } else {
2209
+ cnt = rd_reg_dword_relaxed(req->req_q_out);
2210
+ if (qla2x00_check_reg16_for_disconnect(vha, cnt))
2211
+ goto queuing_error;
2212
+ }
2213
+
21892214 if (req->ring_index < cnt)
21902215 req->cnt = cnt - req->ring_index;
21912216 else
....@@ -2262,6 +2287,7 @@
22622287
22632288 qla_put_iocbs(sp->qpair, &sp->iores);
22642289 spin_unlock_irqrestore(&qpair->qp_lock, flags);
2290
+
22652291 return QLA_FUNCTION_FAILED;
22662292 }
22672293
....@@ -2305,6 +2331,11 @@
23052331 else
23062332 cnt = qla2x00_debounce_register(
23072333 ISP_REQ_Q_OUT(ha, &reg->isp));
2334
+
2335
+ if (!qpair->use_shadow_reg && cnt == ISP_REG16_DISCONNECT) {
2336
+ qla_schedule_eeh_work(vha);
2337
+ return NULL;
2338
+ }
23082339
23092340 if (req->ring_index < cnt)
23102341 req->cnt = cnt - req->ring_index;
....@@ -3710,10 +3741,13 @@
37103741 void *pkt;
37113742 unsigned long flags;
37123743
3744
+ if (vha->hw->flags.eeh_busy)
3745
+ return -EIO;
3746
+
37133747 spin_lock_irqsave(qp->qp_lock_ptr, flags);
37143748 pkt = __qla2x00_alloc_iocbs(sp->qpair, sp);
37153749 if (!pkt) {
3716
- rval = EAGAIN;
3750
+ rval = -EAGAIN;
37173751 ql_log(ql_log_warn, vha, 0x700c,
37183752 "qla2x00_alloc_iocbs failed.\n");
37193753 goto done;
....@@ -3927,8 +3961,14 @@
39273961
39283962 /* Check for room on request queue. */
39293963 if (req->cnt < req_cnt + 2) {
3930
- cnt = IS_SHADOW_REG_CAPABLE(ha) ? *req->out_ptr :
3931
- rd_reg_dword_relaxed(req->req_q_out);
3964
+ if (IS_SHADOW_REG_CAPABLE(ha)) {
3965
+ cnt = *req->out_ptr;
3966
+ } else {
3967
+ cnt = rd_reg_dword_relaxed(req->req_q_out);
3968
+ if (qla2x00_check_reg16_for_disconnect(vha, cnt))
3969
+ goto queuing_error;
3970
+ }
3971
+
39323972 if (req->ring_index < cnt)
39333973 req->cnt = cnt - req->ring_index;
39343974 else
....@@ -3967,5 +4007,6 @@
39674007 qla2x00_start_iocbs(vha, req);
39684008 queuing_error:
39694009 spin_unlock_irqrestore(&ha->hardware_lock, flags);
4010
+
39704011 return rval;
39714012 }