Skip to content

Commit 191e2f7

Browse files
jsmart-ghmartinkpetersen
authored andcommitted
scsi: lpfc: Correct errors accessing fw log
This patch corrects two issues: - An oops would occur if reading based on a non-zero offset. Offset calculation was incorrect. - Updates to ras config (logging level) were ignored if change was made while fw logging was enabled. Revise to dynamically update. Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com> Signed-off-by: James Smart <jsmart2021@gmail.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 5cca2ab commit 191e2f7

File tree

1 file changed

+25
-39
lines changed

1 file changed

+25
-39
lines changed

drivers/scsi/lpfc/lpfc_bsg.c

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5416,7 +5416,7 @@ lpfc_bsg_set_ras_config(struct bsg_job *job)
54165416
struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog;
54175417
struct fc_bsg_reply *bsg_reply = job->reply;
54185418
uint8_t action = 0, log_level = 0;
5419-
int rc = 0;
5419+
int rc = 0, action_status = 0;
54205420

54215421
if (job->request_len <
54225422
sizeof(struct fc_bsg_request) +
@@ -5449,16 +5449,25 @@ lpfc_bsg_set_ras_config(struct bsg_job *job)
54495449
lpfc_ras_stop_fwlog(phba);
54505450
} else {
54515451
/*action = LPFC_RASACTION_START_LOGGING*/
5452-
if (ras_fwlog->ras_active == true) {
5453-
rc = -EINPROGRESS;
5454-
goto ras_job_error;
5455-
}
5452+
5453+
/* Even though FW-logging is active re-initialize
5454+
* FW-logging with new log-level. Return status
5455+
* "Logging already Running" to caller.
5456+
**/
5457+
if (ras_fwlog->ras_active)
5458+
action_status = -EINPROGRESS;
54565459

54575460
/* Enable logging */
54585461
rc = lpfc_sli4_ras_fwlog_init(phba, log_level,
54595462
LPFC_RAS_ENABLE_LOGGING);
5460-
if (rc)
5463+
if (rc) {
54615464
rc = -EINVAL;
5465+
goto ras_job_error;
5466+
}
5467+
5468+
/* Check if FW-logging is re-initialized */
5469+
if (action_status == -EINPROGRESS)
5470+
rc = action_status;
54625471
}
54635472
ras_job_error:
54645473
/* make error code available to userspace */
@@ -5487,8 +5496,7 @@ lpfc_bsg_get_ras_lwpd(struct bsg_job *job)
54875496
struct lpfc_hba *phba = vport->phba;
54885497
struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog;
54895498
struct fc_bsg_reply *bsg_reply = job->reply;
5490-
uint32_t lwpd_offset = 0;
5491-
uint64_t wrap_value = 0;
5499+
u32 *lwpd_ptr = NULL;
54925500
int rc = 0;
54935501

54945502
rc = lpfc_check_fwlog_support(phba);
@@ -5508,11 +5516,12 @@ lpfc_bsg_get_ras_lwpd(struct bsg_job *job)
55085516
ras_reply = (struct lpfc_bsg_get_ras_lwpd *)
55095517
bsg_reply->reply_data.vendor_reply.vendor_rsp;
55105518

5511-
lwpd_offset = *((uint32_t *)ras_fwlog->lwpd.virt) & 0xffffffff;
5512-
ras_reply->offset = be32_to_cpu(lwpd_offset);
5519+
/* Get lwpd offset */
5520+
lwpd_ptr = (uint32_t *)(ras_fwlog->lwpd.virt);
5521+
ras_reply->offset = be32_to_cpu(*lwpd_ptr & 0xffffffff);
55135522

5514-
wrap_value = *((uint64_t *)ras_fwlog->lwpd.virt);
5515-
ras_reply->wrap_count = be32_to_cpu((wrap_value >> 32) & 0xffffffff);
5523+
/* Get wrap count */
5524+
ras_reply->wrap_count = be32_to_cpu(*(++lwpd_ptr) & 0xffffffff);
55165525

55175526
ras_job_error:
55185527
/* make error code available to userspace */
@@ -5539,9 +5548,8 @@ lpfc_bsg_get_ras_fwlog(struct bsg_job *job)
55395548
struct fc_bsg_request *bsg_request = job->request;
55405549
struct fc_bsg_reply *bsg_reply = job->reply;
55415550
struct lpfc_bsg_get_fwlog_req *ras_req;
5542-
uint32_t rd_offset, rd_index, offset, pending_wlen;
5543-
uint32_t boundary = 0, align_len = 0, write_len = 0;
5544-
void *dest, *src, *fwlog_buff;
5551+
u32 rd_offset, rd_index, offset;
5552+
void *src, *fwlog_buff;
55455553
struct lpfc_ras_fwlog *ras_fwlog = NULL;
55465554
struct lpfc_dmabuf *dmabuf, *next;
55475555
int rc = 0;
@@ -5581,38 +5589,16 @@ lpfc_bsg_get_ras_fwlog(struct bsg_job *job)
55815589

55825590
rd_index = (rd_offset / LPFC_RAS_MAX_ENTRY_SIZE);
55835591
offset = (rd_offset % LPFC_RAS_MAX_ENTRY_SIZE);
5584-
pending_wlen = ras_req->read_size;
5585-
dest = fwlog_buff;
55865592

55875593
list_for_each_entry_safe(dmabuf, next,
55885594
&ras_fwlog->fwlog_buff_list, list) {
55895595

55905596
if (dmabuf->buffer_tag < rd_index)
55915597
continue;
55925598

5593-
/* Align read to buffer size */
5594-
if (offset) {
5595-
boundary = ((dmabuf->buffer_tag + 1) *
5596-
LPFC_RAS_MAX_ENTRY_SIZE);
5597-
5598-
align_len = (boundary - offset);
5599-
write_len = min_t(u32, align_len,
5600-
LPFC_RAS_MAX_ENTRY_SIZE);
5601-
} else {
5602-
write_len = min_t(u32, pending_wlen,
5603-
LPFC_RAS_MAX_ENTRY_SIZE);
5604-
align_len = 0;
5605-
boundary = 0;
5606-
}
56075599
src = dmabuf->virt + offset;
5608-
memcpy(dest, src, write_len);
5609-
5610-
pending_wlen -= write_len;
5611-
if (!pending_wlen)
5612-
break;
5613-
5614-
dest += write_len;
5615-
offset = (offset + write_len) % LPFC_RAS_MAX_ENTRY_SIZE;
5600+
memcpy(fwlog_buff, src, ras_req->read_size);
5601+
break;
56165602
}
56175603

56185604
bsg_reply->reply_payload_rcv_len =

0 commit comments

Comments
 (0)