Skip to content

Commit 3290fa1

Browse files
author
CKI KWF Bot
committed
Merge: scsi: qla2xxx: update to latest upstream
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/896 JIRA: https://issues.redhat.com/browse/RHEL-90558 Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git Testing: Perform basic sanity tests for FCP and FC-NVMe Nilesh Javali (6): scsi: qla2xxx: Fix abort in bsg timeout scsi: qla2xxx: Move FCE Trace buffer allocation to user control scsi: qla2xxx: Remove check req_sg_cnt should be equal to rsp_sg_cnt scsi: qla2xxx: Fix NVMe and NPIV connect issue scsi: qla2xxx: Supported speed displayed incorrectly for VPorts scsi: qla2xxx: Update version to 10.02.09.400-k drivers/scsi/qla2xxx/qla_attr.c | 1 + drivers/scsi/qla2xxx/qla_bsg.c | 124 +++++++++++++++++++++-------- drivers/scsi/qla2xxx/qla_def.h | 2 + drivers/scsi/qla2xxx/qla_dfs.c | 124 ++++++++++++++++++++++++----- drivers/scsi/qla2xxx/qla_gbl.h | 3 + drivers/scsi/qla2xxx/qla_init.c | 28 ++++--- drivers/scsi/qla2xxx/qla_mid.c | 1 + drivers/scsi/qla2xxx/qla_version.h | 4 +- 8 files changed, 222 insertions(+), 65 deletions(-) Signed-off-by: Nilesh Javali <njavali@redhat.com> Approved-by: John Meneghini <jmeneghi@redhat.com> Approved-by: Chris Leech <cleech@redhat.com> Approved-by: Ewan D. Milne <emilne@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents 519a5f7 + 706125b commit 3290fa1

File tree

8 files changed

+222
-65
lines changed

8 files changed

+222
-65
lines changed

drivers/scsi/qla2xxx/qla_attr.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3304,6 +3304,7 @@ struct fc_function_template qla2xxx_transport_vport_functions = {
33043304
.show_host_node_name = 1,
33053305
.show_host_port_name = 1,
33063306
.show_host_supported_classes = 1,
3307+
.show_host_supported_speeds = 1,
33073308

33083309
.get_host_port_id = qla2x00_get_host_port_id,
33093310
.show_host_port_id = 1,

drivers/scsi/qla2xxx/qla_bsg.c

Lines changed: 92 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ void qla2x00_bsg_job_done(srb_t *sp, int res)
2424
{
2525
struct bsg_job *bsg_job = sp->u.bsg_job;
2626
struct fc_bsg_reply *bsg_reply = bsg_job->reply;
27+
struct completion *comp = sp->comp;
2728

2829
ql_dbg(ql_dbg_user, sp->vha, 0x7009,
2930
"%s: sp hdl %x, result=%x bsg ptr %p\n",
@@ -35,6 +36,9 @@ void qla2x00_bsg_job_done(srb_t *sp, int res)
3536
bsg_reply->result = res;
3637
bsg_job_done(bsg_job, bsg_reply->result,
3738
bsg_reply->reply_payload_rcv_len);
39+
40+
if (comp)
41+
complete(comp);
3842
}
3943

4044
void qla2x00_bsg_sp_free(srb_t *sp)
@@ -490,16 +494,6 @@ qla2x00_process_ct(struct bsg_job *bsg_job)
490494
goto done;
491495
}
492496

493-
if ((req_sg_cnt != bsg_job->request_payload.sg_cnt) ||
494-
(rsp_sg_cnt != bsg_job->reply_payload.sg_cnt)) {
495-
ql_log(ql_log_warn, vha, 0x7011,
496-
"request_sg_cnt: %x dma_request_sg_cnt: %x reply_sg_cnt:%x "
497-
"dma_reply_sg_cnt: %x\n", bsg_job->request_payload.sg_cnt,
498-
req_sg_cnt, bsg_job->reply_payload.sg_cnt, rsp_sg_cnt);
499-
rval = -EAGAIN;
500-
goto done_unmap_sg;
501-
}
502-
503497
if (!vha->flags.online) {
504498
ql_log(ql_log_warn, vha, 0x7012,
505499
"Host is not online.\n");
@@ -3061,14 +3055,19 @@ qla24xx_bsg_request(struct bsg_job *bsg_job)
30613055

30623056
static bool qla_bsg_found(struct qla_qpair *qpair, struct bsg_job *bsg_job)
30633057
{
3064-
bool found = false;
3058+
bool found, do_bsg_done;
30653059
struct fc_bsg_reply *bsg_reply = bsg_job->reply;
30663060
scsi_qla_host_t *vha = shost_priv(fc_bsg_to_shost(bsg_job));
30673061
struct qla_hw_data *ha = vha->hw;
30683062
srb_t *sp = NULL;
30693063
int cnt;
30703064
unsigned long flags;
30713065
struct req_que *req;
3066+
int rval;
3067+
DECLARE_COMPLETION_ONSTACK(comp);
3068+
uint32_t ratov_j;
3069+
3070+
found = do_bsg_done = false;
30723071

30733072
spin_lock_irqsave(qpair->qp_lock_ptr, flags);
30743073
req = qpair->req;
@@ -3080,42 +3079,104 @@ static bool qla_bsg_found(struct qla_qpair *qpair, struct bsg_job *bsg_job)
30803079
sp->type == SRB_ELS_CMD_HST ||
30813080
sp->type == SRB_ELS_CMD_HST_NOLOGIN) &&
30823081
sp->u.bsg_job == bsg_job) {
3083-
req->outstanding_cmds[cnt] = NULL;
3084-
spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
3085-
3086-
if (!ha->flags.eeh_busy && ha->isp_ops->abort_command(sp)) {
3087-
ql_log(ql_log_warn, vha, 0x7089,
3088-
"mbx abort_command failed.\n");
3089-
bsg_reply->result = -EIO;
3090-
} else {
3091-
ql_dbg(ql_dbg_user, vha, 0x708a,
3092-
"mbx abort_command success.\n");
3093-
bsg_reply->result = 0;
3094-
}
3095-
/* ref: INIT */
3096-
kref_put(&sp->cmd_kref, qla2x00_sp_release);
30973082

30983083
found = true;
3099-
goto done;
3084+
sp->comp = &comp;
3085+
break;
31003086
}
31013087
}
31023088
spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
31033089

3104-
done:
3105-
return found;
3090+
if (!found)
3091+
return false;
3092+
3093+
if (ha->flags.eeh_busy) {
3094+
/* skip over abort. EEH handling will return the bsg. Wait for it */
3095+
rval = QLA_SUCCESS;
3096+
ql_dbg(ql_dbg_user, vha, 0x802c,
3097+
"eeh encounter. bsg %p sp=%p handle=%x \n",
3098+
bsg_job, sp, sp->handle);
3099+
} else {
3100+
rval = ha->isp_ops->abort_command(sp);
3101+
ql_dbg(ql_dbg_user, vha, 0x802c,
3102+
"Aborting bsg %p sp=%p handle=%x rval=%x\n",
3103+
bsg_job, sp, sp->handle, rval);
3104+
}
3105+
3106+
switch (rval) {
3107+
case QLA_SUCCESS:
3108+
/* Wait for the command completion. */
3109+
ratov_j = ha->r_a_tov / 10 * 4 * 1000;
3110+
ratov_j = msecs_to_jiffies(ratov_j);
3111+
3112+
if (!wait_for_completion_timeout(&comp, ratov_j)) {
3113+
ql_log(ql_log_info, vha, 0x7089,
3114+
"bsg abort timeout. bsg=%p sp=%p handle %#x .\n",
3115+
bsg_job, sp, sp->handle);
3116+
3117+
do_bsg_done = true;
3118+
} else {
3119+
/* fw had returned the bsg */
3120+
ql_dbg(ql_dbg_user, vha, 0x708a,
3121+
"bsg abort success. bsg %p sp=%p handle=%#x\n",
3122+
bsg_job, sp, sp->handle);
3123+
do_bsg_done = false;
3124+
}
3125+
break;
3126+
default:
3127+
ql_log(ql_log_info, vha, 0x704f,
3128+
"bsg abort fail. bsg=%p sp=%p rval=%x.\n",
3129+
bsg_job, sp, rval);
3130+
3131+
do_bsg_done = true;
3132+
break;
3133+
}
3134+
3135+
if (!do_bsg_done)
3136+
return true;
3137+
3138+
spin_lock_irqsave(qpair->qp_lock_ptr, flags);
3139+
/*
3140+
* recheck to make sure it's still the same bsg_job due to
3141+
* qp_lock_ptr was released earlier.
3142+
*/
3143+
if (req->outstanding_cmds[cnt] &&
3144+
req->outstanding_cmds[cnt]->u.bsg_job != bsg_job) {
3145+
/* fw had returned the bsg */
3146+
spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
3147+
return true;
3148+
}
3149+
req->outstanding_cmds[cnt] = NULL;
3150+
spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
3151+
3152+
/* ref: INIT */
3153+
sp->comp = NULL;
3154+
kref_put(&sp->cmd_kref, qla2x00_sp_release);
3155+
bsg_reply->result = -ENXIO;
3156+
bsg_reply->reply_payload_rcv_len = 0;
3157+
3158+
ql_dbg(ql_dbg_user, vha, 0x7051,
3159+
"%s bsg_job_done : bsg %p result %#x sp %p.\n",
3160+
__func__, bsg_job, bsg_reply->result, sp);
3161+
3162+
bsg_job_done(bsg_job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);
3163+
3164+
return true;
31063165
}
31073166

31083167
int
31093168
qla24xx_bsg_timeout(struct bsg_job *bsg_job)
31103169
{
3111-
struct fc_bsg_reply *bsg_reply = bsg_job->reply;
3170+
struct fc_bsg_request *bsg_request = bsg_job->request;
31123171
scsi_qla_host_t *vha = shost_priv(fc_bsg_to_shost(bsg_job));
31133172
struct qla_hw_data *ha = vha->hw;
31143173
int i;
31153174
struct qla_qpair *qpair;
31163175

3117-
ql_log(ql_log_info, vha, 0x708b, "%s CMD timeout. bsg ptr %p.\n",
3118-
__func__, bsg_job);
3176+
ql_log(ql_log_info, vha, 0x708b,
3177+
"%s CMD timeout. bsg ptr %p msgcode %x vendor cmd %x\n",
3178+
__func__, bsg_job, bsg_request->msgcode,
3179+
bsg_request->rqst_data.h_vendor.vendor_cmd[0]);
31193180

31203181
if (qla2x00_isp_reg_stat(ha)) {
31213182
ql_log(ql_log_info, vha, 0x9007,
@@ -3136,7 +3197,6 @@ qla24xx_bsg_timeout(struct bsg_job *bsg_job)
31363197
}
31373198

31383199
ql_log(ql_log_info, vha, 0x708b, "SRB not found to abort.\n");
3139-
bsg_reply->result = -ENXIO;
31403200

31413201
done:
31423202
return 0;

drivers/scsi/qla2xxx/qla_def.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4098,6 +4098,8 @@ struct qla_hw_data {
40984098
uint32_t npiv_supported :1;
40994099
uint32_t pci_channel_io_perm_failure :1;
41004100
uint32_t fce_enabled :1;
4101+
uint32_t user_enabled_fce :1;
4102+
uint32_t fce_dump_buf_alloced :1;
41014103
uint32_t fac_supported :1;
41024104

41034105
uint32_t chip_reset_done :1;

drivers/scsi/qla2xxx/qla_dfs.c

Lines changed: 102 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -409,26 +409,31 @@ qla2x00_dfs_fce_show(struct seq_file *s, void *unused)
409409

410410
mutex_lock(&ha->fce_mutex);
411411

412-
seq_puts(s, "FCE Trace Buffer\n");
413-
seq_printf(s, "In Pointer = %llx\n\n", (unsigned long long)ha->fce_wr);
414-
seq_printf(s, "Base = %llx\n\n", (unsigned long long) ha->fce_dma);
415-
seq_puts(s, "FCE Enable Registers\n");
416-
seq_printf(s, "%08x %08x %08x %08x %08x %08x\n",
417-
ha->fce_mb[0], ha->fce_mb[2], ha->fce_mb[3], ha->fce_mb[4],
418-
ha->fce_mb[5], ha->fce_mb[6]);
419-
420-
fce = (uint32_t *) ha->fce;
421-
fce_start = (unsigned long long) ha->fce_dma;
422-
for (cnt = 0; cnt < fce_calc_size(ha->fce_bufs) / 4; cnt++) {
423-
if (cnt % 8 == 0)
424-
seq_printf(s, "\n%llx: ",
425-
(unsigned long long)((cnt * 4) + fce_start));
426-
else
427-
seq_putc(s, ' ');
428-
seq_printf(s, "%08x", *fce++);
429-
}
412+
if (ha->flags.user_enabled_fce) {
413+
seq_puts(s, "FCE Trace Buffer\n");
414+
seq_printf(s, "In Pointer = %llx\n\n", (unsigned long long)ha->fce_wr);
415+
seq_printf(s, "Base = %llx\n\n", (unsigned long long)ha->fce_dma);
416+
seq_puts(s, "FCE Enable Registers\n");
417+
seq_printf(s, "%08x %08x %08x %08x %08x %08x\n",
418+
ha->fce_mb[0], ha->fce_mb[2], ha->fce_mb[3], ha->fce_mb[4],
419+
ha->fce_mb[5], ha->fce_mb[6]);
420+
421+
fce = (uint32_t *)ha->fce;
422+
fce_start = (unsigned long long)ha->fce_dma;
423+
for (cnt = 0; cnt < fce_calc_size(ha->fce_bufs) / 4; cnt++) {
424+
if (cnt % 8 == 0)
425+
seq_printf(s, "\n%llx: ",
426+
(unsigned long long)((cnt * 4) + fce_start));
427+
else
428+
seq_putc(s, ' ');
429+
seq_printf(s, "%08x", *fce++);
430+
}
430431

431-
seq_puts(s, "\nEnd\n");
432+
seq_puts(s, "\nEnd\n");
433+
} else {
434+
seq_puts(s, "FCE Trace is currently not enabled\n");
435+
seq_puts(s, "\techo [ 1 | 0 ] > fce\n");
436+
}
432437

433438
mutex_unlock(&ha->fce_mutex);
434439

@@ -467,7 +472,7 @@ qla2x00_dfs_fce_release(struct inode *inode, struct file *file)
467472
struct qla_hw_data *ha = vha->hw;
468473
int rval;
469474

470-
if (ha->flags.fce_enabled)
475+
if (ha->flags.fce_enabled || !ha->fce)
471476
goto out;
472477

473478
mutex_lock(&ha->fce_mutex);
@@ -488,11 +493,88 @@ qla2x00_dfs_fce_release(struct inode *inode, struct file *file)
488493
return single_release(inode, file);
489494
}
490495

496+
static ssize_t
497+
qla2x00_dfs_fce_write(struct file *file, const char __user *buffer,
498+
size_t count, loff_t *pos)
499+
{
500+
struct seq_file *s = file->private_data;
501+
struct scsi_qla_host *vha = s->private;
502+
struct qla_hw_data *ha = vha->hw;
503+
char *buf;
504+
int rc = 0;
505+
unsigned long enable;
506+
507+
if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha) && !IS_QLA83XX(ha) &&
508+
!IS_QLA27XX(ha) && !IS_QLA28XX(ha)) {
509+
ql_dbg(ql_dbg_user, vha, 0xd034,
510+
"this adapter does not support FCE.");
511+
return -EINVAL;
512+
}
513+
514+
buf = memdup_user_nul(buffer, count);
515+
if (IS_ERR(buf)) {
516+
ql_dbg(ql_dbg_user, vha, 0xd037,
517+
"fail to copy user buffer.");
518+
return PTR_ERR(buf);
519+
}
520+
521+
enable = kstrtoul(buf, 0, 0);
522+
rc = count;
523+
524+
mutex_lock(&ha->fce_mutex);
525+
526+
if (enable) {
527+
if (ha->flags.user_enabled_fce) {
528+
mutex_unlock(&ha->fce_mutex);
529+
goto out_free;
530+
}
531+
ha->flags.user_enabled_fce = 1;
532+
if (!ha->fce) {
533+
rc = qla2x00_alloc_fce_trace(vha);
534+
if (rc) {
535+
ha->flags.user_enabled_fce = 0;
536+
mutex_unlock(&ha->fce_mutex);
537+
goto out_free;
538+
}
539+
540+
/* adjust fw dump buffer to take into account of this feature */
541+
if (!ha->flags.fce_dump_buf_alloced)
542+
qla2x00_alloc_fw_dump(vha);
543+
}
544+
545+
if (!ha->flags.fce_enabled)
546+
qla_enable_fce_trace(vha);
547+
548+
ql_dbg(ql_dbg_user, vha, 0xd045, "User enabled FCE .\n");
549+
} else {
550+
if (!ha->flags.user_enabled_fce) {
551+
mutex_unlock(&ha->fce_mutex);
552+
goto out_free;
553+
}
554+
ha->flags.user_enabled_fce = 0;
555+
if (ha->flags.fce_enabled) {
556+
qla2x00_disable_fce_trace(vha, NULL, NULL);
557+
ha->flags.fce_enabled = 0;
558+
}
559+
560+
qla2x00_free_fce_trace(ha);
561+
/* no need to re-adjust fw dump buffer */
562+
563+
ql_dbg(ql_dbg_user, vha, 0xd04f, "User disabled FCE .\n");
564+
}
565+
566+
mutex_unlock(&ha->fce_mutex);
567+
out_free:
568+
kfree(buf);
569+
return rc;
570+
}
571+
491572
static const struct file_operations dfs_fce_ops = {
492573
.open = qla2x00_dfs_fce_open,
493574
.read = seq_read,
494575
.llseek = seq_lseek,
495576
.release = qla2x00_dfs_fce_release,
577+
.write = qla2x00_dfs_fce_write,
496578
};
497579

498580
static int
@@ -626,8 +708,6 @@ qla2x00_dfs_setup(scsi_qla_host_t *vha)
626708
if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha) && !IS_QLA83XX(ha) &&
627709
!IS_QLA27XX(ha) && !IS_QLA28XX(ha))
628710
goto out;
629-
if (!ha->fce)
630-
goto out;
631711

632712
if (qla2x00_dfs_root)
633713
goto create_dir;

drivers/scsi/qla2xxx/qla_gbl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
/*
1212
* Global Function Prototypes in qla_init.c source file.
1313
*/
14+
int qla2x00_alloc_fce_trace(scsi_qla_host_t *);
15+
void qla2x00_free_fce_trace(struct qla_hw_data *ha);
16+
void qla_enable_fce_trace(scsi_qla_host_t *);
1417
extern int qla2x00_initialize_adapter(scsi_qla_host_t *);
1518
extern int qla24xx_post_prli_work(struct scsi_qla_host *vha, fc_port_t *fcport);
1619

0 commit comments

Comments
 (0)