|
|
3c6e85 |
From 25f327a459d36581e4c739c17f88007df5371472 Mon Sep 17 00:00:00 2001
|
|
|
3c6e85 |
From: Himanshu Madhani <hmadhani@redhat.com>
|
|
|
3c6e85 |
Date: Thu, 1 Aug 2019 15:55:12 -0400
|
|
|
3c6e85 |
Subject: [PATCH 052/124] [scsi] scsi: qla2xxx: Use mutex protection during
|
|
|
3c6e85 |
qla2x00_sysfs_read_fw_dump()
|
|
|
3c6e85 |
|
|
|
3c6e85 |
Message-id: <20190801155618.12650-53-hmadhani@redhat.com>
|
|
|
3c6e85 |
Patchwork-id: 267830
|
|
|
3c6e85 |
O-Subject: [RHEL 7.8 e-stor PATCH 052/118] scsi: qla2xxx: Use mutex protection during qla2x00_sysfs_read_fw_dump()
|
|
|
3c6e85 |
Bugzilla: 1729270
|
|
|
3c6e85 |
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
|
|
|
3c6e85 |
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
|
|
|
3c6e85 |
|
|
|
3c6e85 |
From: Quinn Tran <quinn.tran@cavium.com>
|
|
|
3c6e85 |
|
|
|
3c6e85 |
Bugzilla 1729270
|
|
|
3c6e85 |
|
|
|
3c6e85 |
Add mutex protection to prevent driver from freeing the FW dump buffer
|
|
|
3c6e85 |
while the extraction is in progress.
|
|
|
3c6e85 |
|
|
|
3c6e85 |
[mkp: commit desc]
|
|
|
3c6e85 |
|
|
|
3c6e85 |
Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
|
|
|
3c6e85 |
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
|
|
|
3c6e85 |
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
|
|
|
3c6e85 |
(cherry picked from commit a6b95d1c71e9adef5ab5ba77c42a50d0b7b409d6)
|
|
|
3c6e85 |
Signed-off-by: Himanshu Madhani <hmadhani@redhat.com>
|
|
|
3c6e85 |
Signed-off-by: Jan Stancek <jstancek@redhat.com>
|
|
|
3c6e85 |
---
|
|
|
3c6e85 |
drivers/scsi/qla2xxx/qla_attr.c | 25 ++++++++++++++-----------
|
|
|
3c6e85 |
drivers/scsi/qla2xxx/qla_init.c | 6 +++++-
|
|
|
3c6e85 |
2 files changed, 19 insertions(+), 12 deletions(-)
|
|
|
3c6e85 |
|
|
|
3c6e85 |
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
|
|
|
3c6e85 |
index 668454d701d0..cd866540c120 100644
|
|
|
3c6e85 |
--- a/drivers/scsi/qla2xxx/qla_attr.c
|
|
|
3c6e85 |
+++ b/drivers/scsi/qla2xxx/qla_attr.c
|
|
|
3c6e85 |
@@ -29,24 +29,27 @@ qla2x00_sysfs_read_fw_dump(struct file *filp, struct kobject *kobj,
|
|
|
3c6e85 |
if (!(ha->fw_dump_reading || ha->mctp_dump_reading))
|
|
|
3c6e85 |
return 0;
|
|
|
3c6e85 |
|
|
|
3c6e85 |
+ mutex_lock(&ha->optrom_mutex);
|
|
|
3c6e85 |
if (IS_P3P_TYPE(ha)) {
|
|
|
3c6e85 |
if (off < ha->md_template_size) {
|
|
|
3c6e85 |
rval = memory_read_from_buffer(buf, count,
|
|
|
3c6e85 |
&off, ha->md_tmplt_hdr, ha->md_template_size);
|
|
|
3c6e85 |
- return rval;
|
|
|
3c6e85 |
+ } else {
|
|
|
3c6e85 |
+ off -= ha->md_template_size;
|
|
|
3c6e85 |
+ rval = memory_read_from_buffer(buf, count,
|
|
|
3c6e85 |
+ &off, ha->md_dump, ha->md_dump_size);
|
|
|
3c6e85 |
}
|
|
|
3c6e85 |
- off -= ha->md_template_size;
|
|
|
3c6e85 |
- rval = memory_read_from_buffer(buf, count,
|
|
|
3c6e85 |
- &off, ha->md_dump, ha->md_dump_size);
|
|
|
3c6e85 |
- return rval;
|
|
|
3c6e85 |
- } else if (ha->mctp_dumped && ha->mctp_dump_reading)
|
|
|
3c6e85 |
- return memory_read_from_buffer(buf, count, &off, ha->mctp_dump,
|
|
|
3c6e85 |
+ } else if (ha->mctp_dumped && ha->mctp_dump_reading) {
|
|
|
3c6e85 |
+ rval = memory_read_from_buffer(buf, count, &off, ha->mctp_dump,
|
|
|
3c6e85 |
MCTP_DUMP_SIZE);
|
|
|
3c6e85 |
- else if (ha->fw_dump_reading)
|
|
|
3c6e85 |
- return memory_read_from_buffer(buf, count, &off, ha->fw_dump,
|
|
|
3c6e85 |
+ } else if (ha->fw_dump_reading) {
|
|
|
3c6e85 |
+ rval = memory_read_from_buffer(buf, count, &off, ha->fw_dump,
|
|
|
3c6e85 |
ha->fw_dump_len);
|
|
|
3c6e85 |
- else
|
|
|
3c6e85 |
- return 0;
|
|
|
3c6e85 |
+ } else {
|
|
|
3c6e85 |
+ rval = 0;
|
|
|
3c6e85 |
+ }
|
|
|
3c6e85 |
+ mutex_unlock(&ha->optrom_mutex);
|
|
|
3c6e85 |
+ return rval;
|
|
|
3c6e85 |
}
|
|
|
3c6e85 |
|
|
|
3c6e85 |
static ssize_t
|
|
|
3c6e85 |
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
|
|
|
3c6e85 |
index 3d06299ef65a..9023e8790785 100644
|
|
|
3c6e85 |
--- a/drivers/scsi/qla2xxx/qla_init.c
|
|
|
3c6e85 |
+++ b/drivers/scsi/qla2xxx/qla_init.c
|
|
|
3c6e85 |
@@ -3234,6 +3234,7 @@ allocate:
|
|
|
3c6e85 |
"Unable to allocate (%d KB) for firmware dump.\n",
|
|
|
3c6e85 |
dump_size / 1024);
|
|
|
3c6e85 |
} else {
|
|
|
3c6e85 |
+ mutex_lock(&ha->optrom_mutex);
|
|
|
3c6e85 |
if (ha->fw_dumped) {
|
|
|
3c6e85 |
memcpy(fw_dump, ha->fw_dump, ha->fw_dump_len);
|
|
|
3c6e85 |
vfree(ha->fw_dump);
|
|
|
3c6e85 |
@@ -3253,8 +3254,10 @@ allocate:
|
|
|
3c6e85 |
"Allocated (%d KB) for firmware dump.\n",
|
|
|
3c6e85 |
dump_size / 1024);
|
|
|
3c6e85 |
|
|
|
3c6e85 |
- if (IS_QLA27XX(ha) || IS_QLA28XX(ha))
|
|
|
3c6e85 |
+ if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
|
|
|
3c6e85 |
+ mutex_unlock(&ha->optrom_mutex);
|
|
|
3c6e85 |
return;
|
|
|
3c6e85 |
+ }
|
|
|
3c6e85 |
|
|
|
3c6e85 |
ha->fw_dump->signature[0] = 'Q';
|
|
|
3c6e85 |
ha->fw_dump->signature[1] = 'L';
|
|
|
3c6e85 |
@@ -3277,6 +3280,7 @@ allocate:
|
|
|
3c6e85 |
htonl(offsetof
|
|
|
3c6e85 |
(struct qla2xxx_fw_dump, isp));
|
|
|
3c6e85 |
}
|
|
|
3c6e85 |
+ mutex_unlock(&ha->optrom_mutex);
|
|
|
3c6e85 |
}
|
|
|
3c6e85 |
}
|
|
|
3c6e85 |
}
|
|
|
3c6e85 |
--
|
|
|
3c6e85 |
2.13.6
|
|
|
3c6e85 |
|