Kernel
Threads by month
- ----- 2026 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- 10 participants
- 24014 discussions
LeapIO inclusion
category: feature
bugzilla: https://atomgit.com/openeuler/kernel/issues/9539
------------------------------------------
leapraid driver changes from v2.00.01.02 to v2.00.01.05.
This update includes:
- recovery wait and hard reset flow stabilization
- improved timeout diagnostics with per-command context logging
- MSI-X/IRQ CPU affinity fixes
- SAS topology and event bitmap alignment fixes
- transport and task-management error-path cleanup
- config-page stack usage reduction and adapter info cleanup
- ioctl compatibility cleanup
- resource cleanup and failure-path hardening
Signed-off-by: haodongdong <doubled(a)leap-io.com>
---
drivers/scsi/leapraid/leapraid.h | 21 --
drivers/scsi/leapraid/leapraid_app.c | 9 +-
drivers/scsi/leapraid/leapraid_func.c | 344 +++++++++------------
drivers/scsi/leapraid/leapraid_func.h | 18 +-
drivers/scsi/leapraid/leapraid_os.c | 61 ++--
drivers/scsi/leapraid/leapraid_transport.c | 24 +-
6 files changed, 191 insertions(+), 286 deletions(-)
diff --git a/drivers/scsi/leapraid/leapraid.h b/drivers/scsi/leapraid/leapraid.h
index 2a99417143ad..c9f403efb84f 100644
--- a/drivers/scsi/leapraid/leapraid.h
+++ b/drivers/scsi/leapraid/leapraid.h
@@ -27,8 +27,6 @@
/* Maximum number of retries waiting for doorbell to become operational. */
#define LEAPRAID_DB_WAIT_OP_SHORT 10
#define LEAPRAID_DB_WAIT_OP_LONG 200
-/* Sleep interval (in seconds) between doorbell polls. */
-#define LEAPRAID_DB_POLL_INTERVAL_S 1
/* Maximum number of retries waiting for host to end recovery. */
#define LEAPRAID_WAIT_SHOST_RECOVERY 400
@@ -180,7 +178,6 @@
#define LEAPRAID_CFG_PAGE_NUM_DEV0 0x0
/* SAS device page 0 flags. */
-#define LEAPRAID_SAS_DEV_P0_FLG_FP_CAP 0x2000
#define LEAPRAID_SAS_DEV_P0_FLG_SATA_SMART 0x0040
#define LEAPRAID_SAS_DEV_P0_FLG_ENC_LEVEL_VALID 0x0002
#define LEAPRAID_SAS_DEV_P0_FLG_DEV_PRESENT 0x0001
@@ -207,15 +204,9 @@
/* Physical disk page number. */
#define LEAPRAID_CFG_PAGE_NUM_PD0 0x0
-/* Adapter page number. */
-#define LEAPRAID_CFG_PAGE_NUM_ADAPTER1 0x1
-
#define LEAPRAID_CFG_UNIT_SIZE 4
/* Raid volume type and state. */
-#define LEAPRAID_VOL_STATE_MISSING 0x00
-#define LEAPRAID_VOL_STATE_FAILED 0x01
-#define LEAPRAID_VOL_STATE_INITIALIZING 0x02
#define LEAPRAID_VOL_STATE_ONLINE 0x03
#define LEAPRAID_VOL_STATE_DEGRADED 0x04
#define LEAPRAID_VOL_STATE_OPTIMAL 0x05
@@ -231,10 +222,6 @@
#define LEAPRAID_RAIDCFG_P0_EFLG_HOT_SPARE_ELEMENT 0x0002
#define LEAPRAID_RAIDCFG_P0_EFLG_OCE_ELEMENT 0x0003
-/* Raid action. */
-#define LEAPRAID_RAID_ACT_SYSTEM_SHUTDOWN_INITIATED 0x20
-#define LEAPRAID_RAID_ACT_PHYSDISK_HIDDEN 0x24
-
/* SAS negotiated link rates. */
#define LEAPRAID_SAS_NEG_LINK_RATE_MASK_PHYSICAL 0x0F
#define LEAPRAID_SAS_NEG_LINK_RATE_UNKNOWN_LINK_RATE 0x00
@@ -290,8 +277,6 @@
#define LEAPRAID_TM_MSGFLAGS_LINK_RESET 0x00
#define LEAPRAID_TM_RSP_INVALID_FRAME 0x02
-#define LEAPRAID_TM_RSP_TM_SUCCEEDED 0x08
-#define LEAPRAID_TM_RSP_IO_QUEUED_ON_ADAPTER 0x80
/* SCSI enclosure processor request defines. */
#define LEAPRAID_SEP_REQ_ACT_WRITE_STATUS 0x00
@@ -301,8 +286,6 @@
/* The capabilities of the adapter. */
#define LEAPRAID_ADAPTER_FEATURES_CAP_ATOMIC_REQ 0x00080000
-#define LEAPRAID_ADAPTER_FEATURES_CAP_RDPQ_ARRAY_CAPABLE 0x00040000
-#define LEAPRAID_ADAPTER_FEATURES_CAP_EVENT_REPLAY 0x00002000
#define LEAPRAID_ADAPTER_FEATURES_CAP_INTEGRATED_RAID 0x00001000
/* Event code definitions for the firmware. */
@@ -338,10 +321,6 @@
#define LEAPRAID_EVT_SAS_TOPO_RC_TARG_ADDED 0x01
#define LEAPRAID_EVT_SAS_TOPO_RC_TARG_NOT_RESPONDING 0x02
-/* SAS discovery event defines. */
-#define LEAPRAID_EVT_SAS_DISC_RC_STARTED 0x01
-#define LEAPRAID_EVT_SAS_DISC_RC_COMPLETED 0x02
-
/* Enclosure device status change event. */
#define LEAPRAID_EVT_SAS_ENCL_RC_ADDED 0x01
#define LEAPRAID_EVT_SAS_ENCL_RC_NOT_RESPONDING 0x02
diff --git a/drivers/scsi/leapraid/leapraid_app.c b/drivers/scsi/leapraid/leapraid_app.c
index 25ec57c2ce4b..8ee57865adca 100644
--- a/drivers/scsi/leapraid/leapraid_app.c
+++ b/drivers/scsi/leapraid/leapraid_app.c
@@ -388,6 +388,7 @@ static int leapraid_ctl_do_command(struct leapraid_adapter *adapter,
dev_err(&adapter->pdev->dev,
"%s: ctl_cmd timeout, status=0x%x\n",
__func__, adapter->driver_cmds.ctl_cmd.status);
+ leapraid_log_req_context(adapter, taskid, ctl_sp_mpi_req);
}
if ((leap_mpi_req->func == LEAPRAID_FUNC_SMP_PASSTHROUGH ||
@@ -590,7 +591,7 @@ static int leapraid_ctl_ioctl_main(struct file *file, unsigned int cmd,
break;
}
- if (karg.hdr.adapter_id != ioctl_header.adapter_id) {
+ if (karg.hdr.adapter_id != ioctl_header.adapter_id) {
rc = -EINVAL;
break;
}
@@ -621,11 +622,6 @@ static int leapraid_ctl_ioctl_main(struct file *file, unsigned int cmd,
return rc;
}
-static long bad_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
- return -ENOTTY;
-}
-
static long leapraid_ctl_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
@@ -679,7 +675,6 @@ static const struct file_operations leapraid_ctl_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = leapraid_ctl_ioctl,
.mmap = leapraid_fw_mmap,
- .compat_ioctl = bad_ioctl,
};
static struct miscdevice leapraid_ctl_dev = {
diff --git a/drivers/scsi/leapraid/leapraid_func.c b/drivers/scsi/leapraid/leapraid_func.c
index 01096664d122..aa97369a7aca 100644
--- a/drivers/scsi/leapraid/leapraid_func.c
+++ b/drivers/scsi/leapraid/leapraid_func.c
@@ -43,6 +43,17 @@ static bool leapraid_should_skip_poll_work(struct leapraid_adapter *adapter);
static int leapraid_make_adapter_ready(struct leapraid_adapter *adapter,
enum reset_type type);
+static noinline bool leapraid_shost_in_recovery(struct Scsi_Host *shost)
+{
+ enum scsi_host_state state;
+
+ state = READ_ONCE(shost->shost_state);
+ return state == SHOST_RECOVERY ||
+ state == SHOST_CANCEL_RECOVERY ||
+ state == SHOST_DEL_RECOVERY ||
+ shost->tmf_in_progress;
+}
+
static void leapraid_debug_log_info(struct leapraid_adapter *adapter)
{
struct leapraid_reg_base __iomem *iomem_base = adapter->iomem_base;
@@ -77,6 +88,7 @@ static void leapraid_debug_log_info(struct leapraid_adapter *adapter)
debug_log[i + 2],
debug_log[i + 3]);
}
+
static inline bool leapraid_is_end_dev(u32 dev_type)
{
return (dev_type & LEAPRAID_DEVTYP_END_DEV) &&
@@ -167,7 +179,6 @@ static void leapraid_overheat_suspend(struct leapraid_adapter *adapter)
pdev = adapter->pdev;
shost = pci_get_drvdata(pdev);
-
if (!shost) {
dev_warn(&pdev->dev,
"Overheat suspend failed, invalid host or adapter\n");
@@ -1933,7 +1944,7 @@ static const char *leapraid_tm_type_name(u8 task_type)
}
}
-void leapraid_log_req_context(struct leapraid_adapter *adapter,
+void leapraid_log_req_context(struct leapraid_adapter *adapter, u16 smid,
const void *req_data)
{
const struct leapraid_req *req = req_data;
@@ -1946,8 +1957,8 @@ void leapraid_log_req_context(struct leapraid_adapter *adapter,
const struct leapraid_cfg_req *cfg_req = req_data;
dev_err(&adapter->pdev->dev,
- "cfg-req: func=0x%02x(%s) act=0x%02x(%s)\n",
- req->func, leapraid_func_name(req->func),
+ "cfg-req: smid=%u func=0x%02x(%s) action=0x%02x(%s)\n",
+ smid, req->func, leapraid_func_name(req->func),
cfg_req->action,
leapraid_cfg_action_name(cfg_req->action));
dev_err(&adapter->pdev->dev,
@@ -1969,12 +1980,12 @@ void leapraid_log_req_context(struct leapraid_adapter *adapter,
const struct leapraid_scsi_tm_req *tm_req = req_data;
dev_err(&adapter->pdev->dev,
- "scsi_tm: func=0x%02x(%s) task=0x%02x(%s)\n",
- req->func, leapraid_func_name(req->func),
+ "scsi_tm:: smid=%u func=0x%02x(%s) task=0x%02x(%s)\n",
+ smid, req->func, leapraid_func_name(req->func),
tm_req->task_type,
leapraid_tm_type_name(tm_req->task_type));
dev_err(&adapter->pdev->dev,
- "scsi_tm: dev_hdl=0x%04x task_mid=%u\n",
+ "scsi_tm:: dev_hdl=0x%04x task_mid=%u\n",
le16_to_cpu(tm_req->dev_hdl),
le16_to_cpu(tm_req->task_mid));
break;
@@ -1983,8 +1994,8 @@ void leapraid_log_req_context(struct leapraid_adapter *adapter,
const struct leapraid_sep_req *sep_req = req_data;
dev_err(&adapter->pdev->dev,
- "sep: func=0x%02x(%s) act=0x%02x(%s)\n",
- req->func, leapraid_func_name(req->func),
+ "sep: smid=%u func=0x%02x(%s) action=0x%02x(%s)\n",
+ smid, req->func, leapraid_func_name(req->func),
sep_req->act,
leapraid_sep_action_name(sep_req->act));
dev_err(&adapter->pdev->dev,
@@ -1998,11 +2009,11 @@ void leapraid_log_req_context(struct leapraid_adapter *adapter,
const struct leapraid_io_unit_ctrl_req *io_req = req_data;
dev_err(&adapter->pdev->dev,
- "timestamp sync: func=0x%02x(%s) op=0x%02x(%s)\n",
- req->func, leapraid_func_name(req->func),
+ "ctl_cmd: smid=%u func=0x%02x(%s) action=0x%02x(%s)\n",
+ smid, req->func, leapraid_func_name(req->func),
io_req->op, leapraid_sas_op_name(io_req->op));
dev_err(&adapter->pdev->dev,
- "timestamp sync: dev_hdl=0x%04x param=0x%02x(%s)\n",
+ "ctl_cmd: dev_hdl=0x%04x param=0x%02x(%s)\n",
le16_to_cpu(io_req->dev_hdl),
io_req->adapter_para,
leapraid_io_param_name(io_req->adapter_para));
@@ -2012,18 +2023,21 @@ void leapraid_log_req_context(struct leapraid_adapter *adapter,
const struct leapraid_smp_passthrough_req *smp_req = req_data;
dev_err(&adapter->pdev->dev,
- "transport: func=0x%02x(%s) port=%u req_len=%u\n",
- req->func, leapraid_func_name(req->func),
+ "smp_cmd: smid=%u func=0x%02x(%s) action=0x%02x\n",
+ smid, req->func, leapraid_func_name(req->func),
+ smp_req->passthrough_flg);
+ dev_err(&adapter->pdev->dev,
+ "smp_cmd: port=%u req_len=%u\n",
smp_req->physical_port,
le16_to_cpu(smp_req->req_data_len));
- dev_err(&adapter->pdev->dev, "transport: sas_addr=0x%016llx\n",
+ dev_err(&adapter->pdev->dev, "smp_cmd: sas_addr=0x%016llx\n",
(unsigned long long)le64_to_cpu(smp_req->sas_address));
break;
}
default:
dev_err(&adapter->pdev->dev,
- "%s: func=0x%02x(%s)\n",
- __func__, req->func, leapraid_func_name(req->func));
+ "cmd: smid=%u func=0x%02x(%s)\n",
+ smid, req->func, leapraid_func_name(req->func));
break;
}
}
@@ -2034,19 +2048,18 @@ static void leapraid_build_and_fire_cfg_req(
struct leapraid_cfg_rep *leap_mpi_cfgp_rep)
{
struct leapraid_cfg_req *local_leap_cfg_req;
+ u16 smid;
memset(leap_mpi_cfgp_rep, 0, sizeof(struct leapraid_cfg_rep));
memset(&adapter->driver_cmds.cfg_op_cmd.reply, 0,
sizeof(struct leapraid_cfg_rep));
adapter->driver_cmds.cfg_op_cmd.status = LEAPRAID_CMD_PENDING;
- local_leap_cfg_req = leapraid_get_task_desc(
- adapter,
- adapter->driver_cmds.cfg_op_cmd.inter_taskid);
+ smid = adapter->driver_cmds.cfg_op_cmd.inter_taskid;
+ local_leap_cfg_req = leapraid_get_task_desc(adapter, smid);
memcpy(local_leap_cfg_req, leap_mpi_cfgp_req,
sizeof(struct leapraid_cfg_req));
init_completion(&adapter->driver_cmds.cfg_op_cmd.done);
- leapraid_fire_task(adapter,
- adapter->driver_cmds.cfg_op_cmd.inter_taskid);
+ leapraid_fire_task(adapter, smid);
wait_for_completion_timeout(&adapter->driver_cmds.cfg_op_cmd.done,
LEAPRAID_CFG_OP_TIMEOUT * HZ);
}
@@ -2059,11 +2072,13 @@ static int leapraid_req_cfg_func(struct leapraid_adapter *adapter,
{
u32 adapter_status = UINT_MAX;
bool issue_reset = false;
+ u16 smid;
u8 retry_cnt;
int rc;
retry_cnt = 0;
mutex_lock(&adapter->driver_cmds.cfg_op_cmd.mutex);
+ smid = adapter->driver_cmds.cfg_op_cmd.inter_taskid;
retry:
if (retry_cnt) {
if (retry_cnt > LEAPRAID_CFG_REQ_RETRY_TIMES) {
@@ -2100,14 +2115,16 @@ static int leapraid_req_cfg_func(struct leapraid_adapter *adapter,
adapter->access_ctrl.shost_recovering ?
"shost recovery" : "pcie recovery",
adapter->driver_cmds.cfg_op_cmd.status);
- leapraid_log_req_context(adapter, leap_mpi_cfgp_req);
+ leapraid_log_req_context(adapter, smid,
+ leap_mpi_cfgp_req);
issue_reset = false;
rc = -EFAULT;
} else {
dev_err(&adapter->pdev->dev,
"cfg-req: timeout, status=0x%x, reset\n",
adapter->driver_cmds.cfg_op_cmd.status);
- leapraid_log_req_context(adapter, leap_mpi_cfgp_req);
+ leapraid_log_req_context(adapter, smid,
+ leap_mpi_cfgp_req);
issue_reset = true;
}
@@ -2147,7 +2164,7 @@ static int leapraid_req_cfg_func(struct leapraid_adapter *adapter,
mutex_unlock(&adapter->driver_cmds.cfg_op_cmd.mutex);
if (issue_reset) {
if (adapter->scan_dev_desc.first_scan_dev_fired) {
- dev_info(&adapter->pdev->dev,
+ dev_warn(&adapter->pdev->dev,
"%s:%d cfg-req: Failure, issuing reset\n",
__func__, __LINE__);
leapraid_hard_reset_handler(adapter, FULL_RESET);
@@ -2418,14 +2435,12 @@ static int leapraid_cfg_find_vol_in_page(
u16 phys_hdl;
phys_hdl = le16_to_cpu(elem->phys_disk_dev_hdl);
-
if (phys_hdl == pd_hdl) {
*vol_hdl = le16_to_cpu(elem->vol_dev_hdl);
return 0;
}
break;
}
-
case LEAPRAID_RAIDCFG_P0_EFLG_HOT_SPARE_ELEMENT:
*vol_hdl = 0;
return 0;
@@ -2592,7 +2607,6 @@ static int leapraid_cfg_get_number_pds(struct leapraid_adapter *adapter,
cfgp2.handle = hdl;
rc = leapraid_op_config_page(adapter, &raidvol_p0, cfgp1,
cfgp2, GET_RAID_VOLUME_PG0);
-
if (!rc)
*num_pds = raidvol_p0.num_phys_disks;
@@ -2812,13 +2826,12 @@ static void leapraid_timestamp_sync(struct leapraid_adapter *adapter)
ktime_t current_time;
bool issue_reset = false;
u64 time_stamp;
+ u16 smid;
mutex_lock(&adapter->driver_cmds.timestamp_sync_cmd.mutex);
adapter->driver_cmds.timestamp_sync_cmd.status = LEAPRAID_CMD_PENDING;
- io_unit_ctrl_req =
- leapraid_get_task_desc(
- adapter,
- adapter->driver_cmds.timestamp_sync_cmd.inter_taskid);
+ smid = adapter->driver_cmds.timestamp_sync_cmd.inter_taskid;
+ io_unit_ctrl_req = leapraid_get_task_desc(adapter, smid);
memset(io_unit_ctrl_req, 0, sizeof(struct leapraid_io_unit_ctrl_req));
io_unit_ctrl_req->func = LEAPRAID_FUNC_SAS_IO_UNIT_CTRL;
io_unit_ctrl_req->op = LEAPRAID_SAS_OP_SET_PARAMETER;
@@ -2832,9 +2845,7 @@ static void leapraid_timestamp_sync(struct leapraid_adapter *adapter)
io_unit_ctrl_req->adapter_para_value2 =
cpu_to_le32(time_stamp >> 32);
init_completion(&adapter->driver_cmds.timestamp_sync_cmd.done);
- leapraid_fire_task(
- adapter,
- adapter->driver_cmds.timestamp_sync_cmd.inter_taskid);
+ leapraid_fire_task(adapter, smid);
leapraid_debug_log_info(adapter);
wait_for_completion_timeout(&adapter->driver_cmds
.timestamp_sync_cmd.done,
@@ -2845,7 +2856,7 @@ static void leapraid_timestamp_sync(struct leapraid_adapter *adapter)
"%s: timestamp sync timeout, status=0x%x\n",
__func__,
adapter->driver_cmds.timestamp_sync_cmd.status);
- leapraid_log_req_context(adapter, io_unit_ctrl_req);
+ leapraid_log_req_context(adapter, smid, io_unit_ctrl_req);
issue_reset =
leapraid_check_reset(
adapter->driver_cmds.timestamp_sync_cmd.status);
@@ -2876,15 +2887,16 @@ static void leapraid_check_scheduled_fault_work(struct work_struct *work)
adapter_state = leapraid_get_adapter_state(adapter);
if (adapter_state != LEAPRAID_DB_OPERATIONAL) {
- dev_info(&adapter->pdev->dev, "%s:%d: call hard_reset\n",
- __func__, __LINE__);
+ dev_info(&adapter->pdev->dev, "%s:%d: call hard_reset 0x%x\n",
+ __func__, __LINE__, adapter_state);
rc = leapraid_hard_reset_handler(adapter, FULL_RESET);
- dev_warn(&adapter->pdev->dev, "%s: Hard reset %s\n",
- __func__, rc == 0 ? "success" : "failed");
-
adapter_state = leapraid_get_adapter_state(adapter);
- if (rc && adapter_state != LEAPRAID_DB_OPERATIONAL)
+ if (rc && adapter_state != LEAPRAID_DB_OPERATIONAL) {
+ dev_err(&adapter->pdev->dev,
+ "%s: Hard reset failed, state=0x%x rc=%d\n",
+ __func__, adapter_state, rc);
return;
+ }
}
if (++adapter->timestamp_sync_cnt >=
@@ -3247,7 +3259,6 @@ void leapraid_smart_polling_stop(struct leapraid_adapter *adapter)
wq = desc->smart_poll_wq;
desc->smart_poll_wq = NULL;
-
if (wq) {
if (!cancel_delayed_work_sync(&desc->smart_poll_work))
flush_workqueue(wq);
@@ -3289,7 +3300,6 @@ static void leapraid_overheat_work(struct work_struct *work)
adapter->scan_dev_desc.scan_start = 0;
adapter->scan_dev_desc.wait_scan_dev_done = 0;
adapter->scan_dev_desc.driver_loading = 0;
- wake_up(&adapter->access_ctrl.recovery_waitq);
wake_up(&adapter->access_ctrl.shost_recover_wq);
wake_up(&adapter->scan_dev_desc.wait_driver_loading);
@@ -3378,10 +3388,10 @@ static struct leapraid_fw_evt_work *leapraid_alloc_fw_evt_work(void)
{
struct leapraid_fw_evt_work *fw_evt =
kzalloc(sizeof(*fw_evt), GFP_ATOMIC);
- if (!fw_evt)
- return NULL;
- kref_init(&fw_evt->refcnt);
+ if (fw_evt)
+ kref_init(&fw_evt->refcnt);
+
return fw_evt;
}
@@ -3452,7 +3462,6 @@ void leapraid_clean_active_fw_evt(struct leapraid_adapter *adapter)
return;
adapter->fw_evt_s.fw_evt_cleanup = 1;
- wake_up(&adapter->access_ctrl.recovery_waitq);
if (adapter->access_ctrl.shost_recovering &&
adapter->fw_evt_s.cur_evt)
adapter->fw_evt_s.cur_evt->ignore = 1;
@@ -4367,7 +4376,7 @@ void leapraid_exp_rm(struct leapraid_adapter *adapter, u64 sas_addr,
leapraid_exp_node_rm(adapter, topo_node_exp);
}
-static int leapraid_internal_sas_topo_chg_evt(
+static void leapraid_internal_sas_topo_chg_evt(
struct leapraid_adapter *adapter,
struct leapraid_card_port *card_port,
struct leapraid_topo_node *topo_node_exp,
@@ -4384,11 +4393,11 @@ static int leapraid_internal_sas_topo_chg_evt(
evt_data = fw_evt->evt_data;
for (i = 0; i < evt_data->entry_num; i++) {
if (fw_evt->ignore)
- return 0;
+ return;
if (adapter->access_ctrl.host_removing ||
adapter->access_ctrl.pcie_recovering)
- return 0;
+ return;
phy_number = evt_data->start_phy_num + i;
if (phy_number >= max_phys)
@@ -4426,12 +4435,10 @@ static int leapraid_internal_sas_topo_chg_evt(
if (evt_data->exp_status == LEAPRAID_EVT_SAS_TOPO_ES_NOT_RESPONDING &&
topo_node_exp)
leapraid_exp_rm(adapter, sas_addr, card_port);
-
- return 0;
}
-static int leapraid_sas_topo_chg_evt(struct leapraid_adapter *adapter,
- struct leapraid_fw_evt_work *fw_evt)
+static void leapraid_sas_topo_chg_evt(struct leapraid_adapter *adapter,
+ struct leapraid_fw_evt_work *fw_evt)
{
struct leapraid_topo_node *topo_node_exp;
struct leapraid_card_port *card_port;
@@ -4444,13 +4451,13 @@ static int leapraid_sas_topo_chg_evt(struct leapraid_adapter *adapter,
if (adapter->access_ctrl.shost_recovering ||
adapter->access_ctrl.host_removing ||
adapter->access_ctrl.pcie_recovering)
- return 0;
+ return;
evt_data = fw_evt->evt_data;
leapraid_sas_host_add(adapter, adapter->dev_topo.card.phys_num > 0);
if (fw_evt->ignore)
- return 0;
+ return;
phdl = le16_to_cpu(evt_data->exp_dev_hdl);
card_port = leapraid_get_port_by_id(adapter,
@@ -4458,7 +4465,7 @@ static int leapraid_sas_topo_chg_evt(struct leapraid_adapter *adapter,
false);
if (evt_data->exp_status == LEAPRAID_EVT_SAS_TOPO_ES_ADDED &&
leapraid_exp_add(adapter, phdl) != 0)
- return 0;
+ return;
spin_lock_irqsave(&adapter->dev_topo.topo_node_lock, flags);
topo_node_exp = leapraid_exp_find_by_hdl(adapter, phdl);
@@ -4472,13 +4479,13 @@ static int leapraid_sas_topo_chg_evt(struct leapraid_adapter *adapter,
} else {
spin_unlock_irqrestore(&adapter->dev_topo.topo_node_lock,
flags);
- return 0;
+ return;
}
spin_unlock_irqrestore(&adapter->dev_topo.topo_node_lock, flags);
- return leapraid_internal_sas_topo_chg_evt(adapter, card_port,
- topo_node_exp, fw_evt,
- sas_addr, max_phys);
+ leapraid_internal_sas_topo_chg_evt(adapter, card_port,
+ topo_node_exp, fw_evt,
+ sas_addr, max_phys);
}
static void leapraid_reprobe_lun(struct scsi_device *sdev, void *no_uld_attach)
@@ -4588,7 +4595,6 @@ static void leapraid_sas_pd_hide(
}
spin_unlock_irqrestore(&adapter->dev_topo.sas_dev_lock, flags);
if (starget) {
- dev_info(&adapter->pdev->dev, "hide sas_dev, hdl=0x%x\n", hdl);
starget_for_each_device(starget,
(void *)LEAPRAID_NO_ULD_ATTACH_FLAG,
leapraid_reprobe_lun);
@@ -4608,7 +4614,6 @@ static void leapraid_sas_pd_expose(
u16 hdl;
hdl = le16_to_cpu(evt_data->phys_disk_dev_hdl);
-
if (!hdl || hdl > adapter->adapter_attr.features.max_dev_handle) {
dev_warn(&adapter->pdev->dev,
"%s: Invalid device handle\n", __func__);
@@ -4637,8 +4642,6 @@ static void leapraid_sas_pd_expose(
spin_unlock_irqrestore(&adapter->dev_topo.sas_dev_lock, flags);
if (starget) {
- dev_info(&adapter->pdev->dev,
- "expose sas_dev, hdl=0x%x\n", hdl);
starget_for_each_device(starget,
LEAPRAID_ULD_ATTACH_FLAG,
leapraid_reprobe_lun);
@@ -4971,7 +4974,7 @@ static void leapraid_remove_unresp_sas_end_dev(
leapraid_sdev_put(sas_dev);
}
- dev_info(&adapter->pdev->dev,
+ dev_warn(&adapter->pdev->dev,
"Unresponsive SAS end devices removed\n");
}
@@ -4996,7 +4999,7 @@ static void leapraid_remove_unresp_raid_volumes(
leapraid_sas_volume_delete_by_ptr(adapter, raid_volume);
}
- dev_info(&adapter->pdev->dev,
+ dev_warn(&adapter->pdev->dev,
"Unresponsive RAID volumes removed\n");
}
@@ -5020,7 +5023,7 @@ static void leapraid_remove_unresp_sas_exp(struct leapraid_adapter *adapter)
&head, list)
leapraid_exp_node_rm(adapter, topo_node_exp);
- dev_info(&adapter->pdev->dev,
+ dev_warn(&adapter->pdev->dev,
"Unresponsive SAS expanders removed\n");
}
@@ -5138,8 +5141,6 @@ static void leapraid_scan_exp_after_reset(struct leapraid_adapter *adapter)
u16 hdl;
u8 port_id;
- dev_info(&adapter->pdev->dev, "Begin scanning expanders\n");
-
cfgp1.form = LEAPRAID_SAS_CFG_PGAD_GET_NEXT_LOOP;
for (hdl = 0xFFFF, cfgp2.handle = hdl;
!leapraid_op_config_page(adapter, &exp_p0, cfgp1, cfgp2,
@@ -5170,8 +5171,6 @@ static void leapraid_scan_exp_after_reset(struct leapraid_adapter *adapter)
exp_p0.sas_address));
}
}
-
- dev_info(&adapter->pdev->dev, "Expanders scan complete\n");
}
static void leapraid_scan_phy_disks_after_reset(
@@ -5188,8 +5187,6 @@ static void leapraid_scan_phy_disks_after_reset(
u16 hdl, parent_hdl;
u64 sas_addr;
- dev_info(&adapter->pdev->dev, "Begin scanning phys disk\n");
-
cfgp1.form = LEAPRAID_SAS_CFG_PGAD_GET_NEXT_LOOP;
for (phys_disk_num = 0xFF, cfgp2.form_specific = phys_disk_num;
!leapraid_op_config_page(adapter, &raidpd_p0,
@@ -5238,8 +5235,6 @@ static void leapraid_scan_phy_disks_after_reset(
}
}
}
-
- dev_info(&adapter->pdev->dev, "PHYs disk scan complete\n");
}
static void leapraid_scan_vol_after_reset(struct leapraid_adapter *adapter)
@@ -5264,7 +5259,6 @@ static void leapraid_scan_vol_after_reset(struct leapraid_adapter *adapter)
return;
}
- dev_info(&adapter->pdev->dev, "Begin scanning volumes\n");
cfgp1.form = LEAPRAID_SAS_CFG_PGAD_GET_NEXT_LOOP;
for (hdl = 0xFFFF, cfgp2.handle = hdl;
!leapraid_op_config_page(adapter, vol_p1, cfgp1,
@@ -5301,8 +5295,6 @@ static void leapraid_scan_vol_after_reset(struct leapraid_adapter *adapter)
kfree(vol_p0);
kfree(vol_p1);
-
- dev_info(&adapter->pdev->dev, "Volumes scan complete\n");
}
static void leapraid_scan_sas_dev_after_reset(struct leapraid_adapter *adapter)
@@ -5315,9 +5307,6 @@ static void leapraid_scan_sas_dev_after_reset(struct leapraid_adapter *adapter)
u64 sas_address;
u8 port_id;
- dev_info(&adapter->pdev->dev,
- "Begin scanning SAS end devices\n");
-
cfgp1.form = LEAPRAID_SAS_CFG_PGAD_GET_NEXT_LOOP;
for (hdl = 0xFFFF, cfgp2.handle = hdl;
!leapraid_op_config_page(adapter, &sas_dev_p0, cfgp1, cfgp2,
@@ -5367,14 +5356,10 @@ static void leapraid_scan_sas_dev_after_reset(struct leapraid_adapter *adapter)
sas_dev_p0.sas_address));
}
}
-
- dev_info(&adapter->pdev->dev, "SAS end devices scan complete\n");
}
static void leapraid_scan_all_dev_after_reset(struct leapraid_adapter *adapter)
{
- dev_info(&adapter->pdev->dev, "Begin scanning devices\n");
-
leapraid_sas_host_add(adapter, adapter->dev_topo.card.phys_num > 0);
leapraid_scan_exp_after_reset(adapter);
if (adapter->adapter_attr.raid_support) {
@@ -5382,8 +5367,6 @@ static void leapraid_scan_all_dev_after_reset(struct leapraid_adapter *adapter)
leapraid_scan_vol_after_reset(adapter);
}
leapraid_scan_sas_dev_after_reset(adapter);
-
- dev_info(&adapter->pdev->dev, "Devices scan complete\n");
}
static void leapraid_hardreset_async_logic(struct leapraid_adapter *adapter)
@@ -5411,6 +5394,7 @@ static int leapraid_send_enc_cmd(struct leapraid_adapter *adapter,
void *req;
bool reset_flg = false;
int rc;
+ u16 smid;
mutex_lock(&adapter->driver_cmds.enc_cmd.mutex);
rc = leapraid_check_adapter_is_op(adapter, LEAPRAID_DB_WAIT_OP_SHORT,
@@ -5419,21 +5403,19 @@ static int leapraid_send_enc_cmd(struct leapraid_adapter *adapter,
goto unlock;
adapter->driver_cmds.enc_cmd.status = LEAPRAID_CMD_PENDING;
- req = leapraid_get_task_desc(
- adapter,
- adapter->driver_cmds.enc_cmd.inter_taskid);
+ smid = adapter->driver_cmds.enc_cmd.inter_taskid;
+ req = leapraid_get_task_desc(adapter, smid);
memset(req, 0, LEAPRAID_REQUEST_SIZE);
memcpy(req, sep_req, sizeof(struct leapraid_sep_req));
init_completion(&adapter->driver_cmds.enc_cmd.done);
- leapraid_fire_task(adapter,
- adapter->driver_cmds.enc_cmd.inter_taskid);
+ leapraid_fire_task(adapter, smid);
wait_for_completion_timeout(&adapter->driver_cmds.enc_cmd.done,
LEAPRAID_ENC_CMD_TIMEOUT * HZ);
if (!(adapter->driver_cmds.enc_cmd.status & LEAPRAID_CMD_DONE)) {
dev_err(&adapter->pdev->dev,
"%s: SEP command timeout, status=0x%x\n",
__func__, adapter->driver_cmds.enc_cmd.status);
- leapraid_log_req_context(adapter, sep_req);
+ leapraid_log_req_context(adapter, smid, sep_req);
reset_flg =
leapraid_check_reset(
adapter->driver_cmds.enc_cmd.status);
@@ -5497,10 +5479,10 @@ static int leapraid_wait_adapter_recovery(struct leapraid_adapter *adapter)
{
unsigned long flags;
- while (scsi_host_in_recovery(adapter->shost) ||
- adapter->access_ctrl.shost_recovering) {
- if (adapter->access_ctrl.host_removing ||
- adapter->fw_evt_s.fw_evt_cleanup) {
+ while (leapraid_shost_in_recovery(adapter->shost) ||
+ READ_ONCE(adapter->access_ctrl.shost_recovering)) {
+ if (READ_ONCE(adapter->access_ctrl.host_removing) ||
+ READ_ONCE(adapter->fw_evt_s.fw_evt_cleanup)) {
spin_lock_irqsave(
&adapter->reset_desc.adapter_reset_lock,
flags);
@@ -5520,12 +5502,13 @@ static int leapraid_wait_adapter_recovery(struct leapraid_adapter *adapter)
return -EFAULT;
}
- wait_event_timeout(adapter->access_ctrl.recovery_waitq,
- !adapter->access_ctrl.shost_recovering ||
- adapter->access_ctrl.host_removing ||
- adapter->fw_evt_s.fw_evt_cleanup,
- msecs_to_jiffies(1000));
+ wait_event_timeout(
+ adapter->access_ctrl.recovery_waitq,
+ (!leapraid_shost_in_recovery(adapter->shost) &&
+ !READ_ONCE(adapter->access_ctrl.shost_recovering)),
+ msecs_to_jiffies(1000));
}
+
return 0;
}
@@ -5610,7 +5593,6 @@ static void leapraid_sas_dev_stat_chg_evt(
leapraid_get_port_by_id(adapter,
event_data->physical_port,
false));
-
if (!sas_dev || !sas_dev->starget)
goto out_unlock;
@@ -5880,9 +5862,9 @@ static void leapraid_scan_dev_complete(struct leapraid_adapter *adapter)
leapraid_fw_evt_put(fw_evt);
}
-static u8 leapraid_handle_scan_cb(struct leapraid_adapter *adapter,
- struct leapraid_driver_cmd *cmd,
- struct leapraid_rep *rep)
+static void leapraid_handle_scan_cb(struct leapraid_adapter *adapter,
+ struct leapraid_driver_cmd *cmd,
+ struct leapraid_rep *rep)
{
u16 status;
@@ -5890,21 +5872,18 @@ static u8 leapraid_handle_scan_cb(struct leapraid_adapter *adapter,
status = le16_to_cpu(rep->adapter_status) &
LEAPRAID_ADAPTER_STATUS_MASK;
-
if (status != LEAPRAID_ADAPTER_STATUS_SUCCESS)
adapter->scan_dev_desc.scan_dev_failed = 1;
if (!cmd->async_scan_dev) {
complete(&cmd->done);
- return 1;
+ return;
}
if (status == LEAPRAID_ADAPTER_STATUS_SUCCESS)
leapraid_scan_dev_complete(adapter);
else
adapter->scan_dev_desc.scan_start_failed = status;
-
- return 1;
}
static void leapraid_handle_ctl_cb(struct leapraid_adapter *adapter,
@@ -5918,7 +5897,6 @@ static void leapraid_handle_ctl_cb(struct leapraid_adapter *adapter,
return;
scsiio_reply = (struct leapraid_scsiio_rep *)rep;
-
if (!(scsiio_reply->scsi_state &
LEAPRAID_SCSI_STATE_AUTOSENSE_VALID))
return;
@@ -5961,10 +5939,11 @@ static bool leapraid_driver_cmds_done(struct leapraid_adapter *adapter,
memcpy(&_sp_cmd->reply, leap_mpi_rep, reply_len);
_sp_cmd->status |= LEAPRAID_CMD_REPLY_VALID;
- if (_sp_cmd->cb_idx == LEAPRAID_SCAN_DEV_CB_IDX)
- return leapraid_handle_scan_cb(adapter,
- _sp_cmd,
- leap_mpi_rep);
+ if (_sp_cmd->cb_idx == LEAPRAID_SCAN_DEV_CB_IDX) {
+ leapraid_handle_scan_cb(adapter, _sp_cmd,
+ leap_mpi_rep);
+ return true;
+ }
if (_sp_cmd->cb_idx == LEAPRAID_CTL_CB_IDX)
leapraid_handle_ctl_cb(adapter, leap_mpi_rep, taskid);
@@ -6230,7 +6209,6 @@ static int leapraid_host_diag_reset(struct leapraid_adapter *adapter)
{
u32 host_diag;
- dev_info(&adapter->pdev->dev, "Entering host diag reset!\n");
pci_cfg_access_lock(adapter->pdev);
mutex_lock(&adapter->reset_desc.host_diag_mutex);
@@ -6254,14 +6232,13 @@ static int leapraid_host_diag_reset(struct leapraid_adapter *adapter)
goto out_failed;
pci_cfg_access_unlock(adapter->pdev);
- dev_info(&adapter->pdev->dev, "Host diag success!\n");
return 0;
out_cleanup:
mutex_unlock(&adapter->reset_desc.host_diag_mutex);
out_failed:
pci_cfg_access_unlock(adapter->pdev);
- dev_info(&adapter->pdev->dev, "Host diag failed!\n");
+ dev_err(&adapter->pdev->dev, "Host diag failed\n");
return -EFAULT;
}
@@ -6776,11 +6753,8 @@ static void leapraid_search_resp_sas_dev(struct leapraid_adapter *adapter)
struct leapraid_sas_dev_p0 sas_dev_p0;
u32 device_info;
- dev_info(&adapter->pdev->dev,
- "Begin searching for SAS end devices\n");
-
if (list_empty(&adapter->dev_topo.sas_dev_list))
- goto exit_search;
+ return;
cfgp1.form = LEAPRAID_SAS_CFG_PGAD_GET_NEXT_LOOP;
for (cfgp2.handle = 0xFFFF;
@@ -6793,9 +6767,6 @@ static void leapraid_search_resp_sas_dev(struct leapraid_adapter *adapter)
leapraid_mark_resp_sas_dev(adapter, &sas_dev_p0);
}
-exit_search:
- dev_info(&adapter->pdev->dev,
- "SAS end devices searching complete\n");
}
static void leapraid_mark_resp_raid_volume(struct leapraid_adapter *adapter,
@@ -6864,14 +6835,11 @@ static void leapraid_search_resp_raid_volume(struct leapraid_adapter *adapter)
if (!adapter->adapter_attr.raid_support)
return;
- dev_info(&adapter->pdev->dev,
- "Begin searching for RAID volumes\n");
-
spin_lock_irqsave(&adapter->dev_topo.raid_volume_lock, flags);
is_empty = list_empty(&adapter->dev_topo.raid_volume_list);
spin_unlock_irqrestore(&adapter->dev_topo.raid_volume_lock, flags);
if (is_empty)
- goto exit_search;
+ return;
cfgp1.form = LEAPRAID_SAS_CFG_PGAD_GET_NEXT_LOOP;
for (hdl = 0xFFFF, cfgp2.handle = hdl;
@@ -6909,9 +6877,6 @@ static void leapraid_search_resp_raid_volume(struct leapraid_adapter *adapter)
else
set_bit(hdl, adapter->dev_topo.pd_hdls);
}
-exit_search:
- dev_info(&adapter->pdev->dev,
- "RAID volumes searching complete\n");
}
static void leapraid_mark_resp_exp(struct leapraid_adapter *adapter,
@@ -6972,10 +6937,8 @@ static void leapraid_search_resp_exp(struct leapraid_adapter *adapter)
u16 hdl;
u8 port;
- dev_dbg(&adapter->pdev->dev,
- "Begin searching for expanders\n");
if (list_empty(&adapter->dev_topo.exp_list))
- goto exit_search;
+ return;
cfgp1.form = LEAPRAID_SAS_CFG_PGAD_GET_NEXT_LOOP;
for (hdl = 0xFFFF, cfgp2.handle = hdl;
@@ -6993,9 +6956,6 @@ static void leapraid_search_resp_exp(struct leapraid_adapter *adapter)
LEAPRAID_DISABLE_MP_PORT_ID);
leapraid_mark_resp_exp(adapter, &exp_p0);
}
-exit_search:
- dev_dbg(&adapter->pdev->dev,
- "Expander searching complete\n");
}
void leapraid_wait_cmds_done(struct leapraid_adapter *adapter)
@@ -7084,7 +7044,6 @@ int leapraid_hard_reset_handler(struct leapraid_adapter *adapter,
dev_err(&adapter->pdev->dev,
"Previous device scan failed or driver loading\n");
adapter->access_ctrl.host_removing = 1;
- wake_up(&adapter->access_ctrl.recovery_waitq);
rc = -EFAULT;
goto out_cleanup;
}
@@ -7105,8 +7064,8 @@ int leapraid_hard_reset_handler(struct leapraid_adapter *adapter,
leapraid_hardreset_barrier(adapter);
}
out_cleanup:
- dev_info(&adapter->pdev->dev, "Hard reset %s\n",
- rc == 0 ? "SUCCESS" : "FAILED");
+ if (rc)
+ dev_err(&adapter->pdev->dev, "Hard reset failed\n");
spin_lock_irqsave(&adapter->reset_desc.adapter_reset_lock, flags);
adapter->reset_desc.adapter_reset_results = rc;
@@ -7345,8 +7304,8 @@ static void leapraid_map_msix_to_cpu(struct leapraid_adapter *adapter)
{
struct leapraid_int_rq *int_rq;
const cpumask_t *affinity_mask;
+ int cpu;
u32 i;
- u16 cpu;
if (!adapter->adapter_attr.rq_cnt)
return;
@@ -7370,6 +7329,7 @@ static void leapraid_map_msix_to_cpu(struct leapraid_adapter *adapter)
int_rq->rq.msix_idx;
}
}
+ return;
out_apply_irq_affinity:
leapraid_cpus_on_irq(adapter);
}
@@ -7432,7 +7392,6 @@ static int leapraid_setup_irqs(struct leapraid_adapter *adapter)
adapter->notification_desc.iopoll_qdex,
adapter->notification_desc.iopoll_qdex,
PCI_IRQ_MSIX | PCI_IRQ_AFFINITY, NULL);
-
if (rc < 0) {
dev_err(&adapter->pdev->dev,
"%d MSI/MSIX vectors allocated failed!\n",
@@ -7465,7 +7424,6 @@ static int leapraid_setup_irqs(struct leapraid_adapter *adapter)
IRQF_SHARED,
adapter->notification_desc.int_rqs[i].rq.name,
&adapter->notification_desc.int_rqs[i].rq);
-
if (rc) {
dev_err(&adapter->pdev->dev,
"MSI/MSIx: request_irq %s failed!\n",
@@ -7523,8 +7481,6 @@ static int leapraid_setup_legacy_int(struct leapraid_adapter *adapter)
static int leapraid_set_legacy_int(struct leapraid_adapter *adapter)
{
- int rc;
-
adapter->notification_desc.msix_cpu_map_sz = num_online_cpus();
adapter->notification_desc.msix_cpu_map =
kzalloc(adapter->notification_desc.msix_cpu_map_sz,
@@ -7547,9 +7503,7 @@ static int leapraid_set_legacy_int(struct leapraid_adapter *adapter)
if (!adapter->notification_desc.int_rqs)
return -ENOMEM;
- rc = leapraid_setup_legacy_int(adapter);
-
- return rc;
+ return leapraid_setup_legacy_int(adapter);
}
static int leapraid_set_msix(struct leapraid_adapter *adapter)
@@ -7650,9 +7604,7 @@ static int leapraid_set_msix(struct leapraid_adapter *adapter)
return 0;
apply_legacy_int:
- rc = leapraid_set_legacy_int(adapter);
-
- return rc;
+ return leapraid_set_legacy_int(adapter);
}
static int leapraid_set_msi(struct leapraid_adapter *adapter)
@@ -7774,9 +7726,7 @@ static int leapraid_set_msi(struct leapraid_adapter *adapter)
return 0;
apply_legacy_int:
- rc = leapraid_set_legacy_int(adapter);
-
- return rc;
+ return leapraid_set_legacy_int(adapter);
}
static int leapraid_set_notification(struct leapraid_adapter *adapter)
@@ -7859,18 +7809,16 @@ static int leapraid_adapter_unit_reset(struct leapraid_adapter *adapter)
{
int rc = 0;
- dev_info(&adapter->pdev->dev, "fire unit reset\n");
writel(LEAPRAID_FUNC_ADAPTER_UNIT_RESET << LEAPRAID_DB_FUNC_SHIFT,
&adapter->iomem_base->db);
if (leapraid_db_wait_ack_and_clear_int(adapter))
rc = -EFAULT;
if (!leapraid_wait_adapter_ready(adapter)) {
- dev_info(&adapter->pdev->dev, "unit reset: FAILED\n");
+ dev_err(&adapter->pdev->dev, "unit reset failed\n");
return -EFAULT;
}
- dev_info(&adapter->pdev->dev, "unit reset: SUCCESS\n");
return rc;
}
@@ -7878,7 +7826,6 @@ static int leapraid_make_adapter_ready(struct leapraid_adapter *adapter,
enum reset_type type)
{
u32 db;
- int rc;
int count;
if (!leapraid_pci_active(adapter))
@@ -7917,8 +7864,7 @@ static int leapraid_make_adapter_ready(struct leapraid_adapter *adapter,
return 0;
full_reset:
- rc = leapraid_host_diag_reset(adapter);
- return rc;
+ return leapraid_host_diag_reset(adapter);
}
static void leapraid_fw_log_exit(struct leapraid_adapter *adapter)
@@ -8095,15 +8041,13 @@ int leapraid_internal_init_cmd_priv(struct leapraid_adapter *adapter,
return 0;
}
-int leapraid_internal_exit_cmd_priv(struct leapraid_adapter *adapter,
- struct leapraid_io_req_tracker *io_tracker)
+void leapraid_internal_exit_cmd_priv(struct leapraid_adapter *adapter,
+ struct leapraid_io_req_tracker *io_tracker)
{
if (io_tracker && io_tracker->chain)
dma_pool_free(adapter->mem_desc.sg_chain_pool,
io_tracker->chain,
io_tracker->chain_dma);
-
- return 0;
}
static int leapraid_request_host_memory(struct leapraid_adapter *adapter)
@@ -8394,9 +8338,10 @@ static int leapraid_alloc_dev_topo_bitmaps(struct leapraid_adapter *adapter)
{
u16 pd_hdls_sz;
- pd_hdls_sz = adapter->adapter_attr.features.max_dev_handle /
- LEAPRAID_BITS_PER_BYTE;
- pd_hdls_sz++;
+ pd_hdls_sz =
+ BITS_TO_LONGS(
+ adapter->adapter_attr.features.max_dev_handle + 1) *
+ sizeof(unsigned long);
adapter->dev_topo.pd_hdls_sz = pd_hdls_sz;
adapter->dev_topo.pd_hdls =
@@ -8636,48 +8581,52 @@ static int leapraid_cfg_pages(struct leapraid_adapter *adapter)
{
union cfg_param_1 cfgp1 = {0};
union cfg_param_2 cfgp2 = {0};
- struct leapraid_manufacturing_p0 manufacturing_page0;
- struct leapraid_bios_page3 bios_page3;
- struct leapraid_bios_page2 bios_page2;
+ union {
+ struct leapraid_manufacturing_p0 manufacturing_page0;
+ struct leapraid_bios_page3 bios_page3;
+ struct leapraid_bios_page2 bios_page2;
+ } cfg_page;
int rc;
- rc = leapraid_op_config_page(adapter, &bios_page3, cfgp1,
+ rc = leapraid_op_config_page(adapter, &cfg_page.bios_page3, cfgp1,
cfgp2, GET_BIOS_PG3);
if (rc)
return rc;
- rc = leapraid_op_config_page(adapter, &bios_page2, cfgp1,
- cfgp2, GET_BIOS_PG2);
- if (rc)
- return rc;
+ adapter->adapter_attr.bios_version =
+ le32_to_cpu(cfg_page.bios_page3.bios_version);
- rc = leapraid_op_config_page(adapter, &manufacturing_page0, cfgp1,
- cfgp2, GET_MANUFACTURING_PG0);
+ rc = leapraid_op_config_page(adapter, &cfg_page.bios_page2, cfgp1,
+ cfgp2, GET_BIOS_PG2);
if (rc)
return rc;
- adapter->adapter_attr.bios_version =
- le32_to_cpu(bios_page3.bios_version);
- snprintf(adapter->adapter_attr.board_name,
- sizeof(adapter->adapter_attr.board_name),
- "%.*s",
- (int)sizeof(manufacturing_page0.board_name),
- manufacturing_page0.board_name);
adapter->boot_devs.requested_boot_dev.form =
- bios_page2.requested_boot_dev_form;
+ cfg_page.bios_page2.requested_boot_dev_form;
memcpy(adapter->boot_devs.requested_boot_dev.pg_dev,
- &bios_page2.requested_boot_dev,
+ &cfg_page.bios_page2.requested_boot_dev,
LEAPRAID_BOOT_DEV_SIZE);
adapter->boot_devs.requested_alt_boot_dev.form =
- bios_page2.requested_alt_boot_dev_form;
+ cfg_page.bios_page2.requested_alt_boot_dev_form;
memcpy(adapter->boot_devs.requested_alt_boot_dev.pg_dev,
- &bios_page2.requested_alt_boot_dev,
+ &cfg_page.bios_page2.requested_alt_boot_dev,
LEAPRAID_BOOT_DEV_SIZE);
adapter->boot_devs.current_boot_dev.form =
- bios_page2.current_boot_dev_form;
+ cfg_page.bios_page2.current_boot_dev_form;
memcpy(adapter->boot_devs.current_boot_dev.pg_dev,
- &bios_page2.current_boot_dev,
+ &cfg_page.bios_page2.current_boot_dev,
LEAPRAID_BOOT_DEV_SIZE);
+
+ rc = leapraid_op_config_page(adapter, &cfg_page.manufacturing_page0,
+ cfgp1, cfgp2, GET_MANUFACTURING_PG0);
+ if (rc)
+ return rc;
+
+ snprintf(adapter->adapter_attr.board_name,
+ sizeof(adapter->adapter_attr.board_name),
+ "%.*s",
+ (int)sizeof(cfg_page.manufacturing_page0.board_name),
+ cfg_page.manufacturing_page0.board_name);
return rc;
}
@@ -8786,8 +8735,6 @@ int leapraid_scan_dev(struct leapraid_adapter *adapter, bool async_scan_dev)
out_cleanup:
adapter->driver_cmds.scan_dev_cmd.status = LEAPRAID_CMD_NOT_USED;
- dev_info(&adapter->pdev->dev,
- "Device scan %s\n", rc == 0 ? "SUCCESS" : "FAILED");
return rc;
}
@@ -8936,11 +8883,7 @@ static int leapraid_make_adapter_available(struct leapraid_adapter *adapter)
return 0;
}
- rc = leapraid_scan_dev(adapter, false);
- if (rc)
- return rc;
-
- return rc;
+ return leapraid_scan_dev(adapter, false);
}
int leapraid_ctrl_init(struct leapraid_adapter *adapter)
@@ -9006,7 +8949,6 @@ int leapraid_ctrl_init(struct leapraid_adapter *adapter)
out_free:
adapter->access_ctrl.host_removing = 1;
- wake_up(&adapter->access_ctrl.recovery_waitq);
leapraid_fw_log_exit(adapter);
leapraid_free_internal_scsi_cmd(adapter);
leapraid_disable_controller(adapter);
diff --git a/drivers/scsi/leapraid/leapraid_func.h b/drivers/scsi/leapraid/leapraid_func.h
index 359802578586..5b66a8922661 100644
--- a/drivers/scsi/leapraid/leapraid_func.h
+++ b/drivers/scsi/leapraid/leapraid_func.h
@@ -50,11 +50,11 @@
#define LEAPRAID_BOARD_NAME_LENGTH 17
#define LEAPRAID_AUTHOR "LeapIO Inc."
#define LEAPRAID_DESCRIPTION "LeapRAID Driver"
-#define LEAPRAID_DRIVER_VERSION "2.00.01.02"
+#define LEAPRAID_DRIVER_VERSION "2.00.01.05"
#define LEAPRAID_MAJOR_VERSION 2
#define LEAPRAID_MINOR_VERSION 00
#define LEAPRAID_BUILD_VERSION 01
-#define LEAPRAID_RELEASE_VERSION 02
+#define LEAPRAID_RELEASE_VERSION 05
#define LEAPRAID_MSG_VERSION 0x1021
#define LEAPRAID_HEADER_VERSION 0x0000
@@ -126,7 +126,6 @@
/* SMP (Serial Management Protocol). */
#define LEAPRAID_SMP_PT_FLAG_SGL_PTR 0x80
-#define LEAPRAID_SMP_FN_REPORT_PHY_ERR_LOG 0x91
#define LEAPRAID_SMP_FRAME_HEADER_SIZE 4
#define LEAPRAID_SCSI_HOST_SHIFT 16
#define LEAPRAID_SCSI_DRIVER_SHIFT 24
@@ -170,13 +169,9 @@
/* Basic constants and limits. */
#define LEAPRAID_BUSY_LIMIT 1
-#define LEAPRAID_INDEX_FIRST 0
-#define LEAPRAID_BITS_PER_BYTE 8
#define LEAPRAID_INVALID_HOST_DIAG_VAL 0xFFFFFFFF
/* Retry/Sleep configuration. */
-#define LEAPRAID_WRITE_SEQUENCE_OFFSET 0x4
-#define LEAPRAID_WRSEQ_KEY_VALUE_MASK 0xF
#define LEAPRAID_WRSEQ_FLUSH_KEY_VALUE 0x0
#define LEAPRAID_WRSEQ_1ST_KEY_VALUE 0xF
#define LEAPRAID_WRSEQ_2ND_KEY_VALUE 0x4
@@ -186,7 +181,6 @@
#define LEAPRAID_WRSEQ_6TH_KEY_VALUE 0xD
#define LEAPRAID_UNLOCK_RETRY_LIMIT 20
#define LEAPRAID_UNLOCK_SLEEP_MS 100
-#define LEAPRAID_MSLEEP_SHORT_MS 50
#define LEAPRAID_MSLEEP_NORMAL_MS 100
#define LEAPRAID_MSLEEP_EXTRA_LONG_MS 500
#define LEAPRAID_IO_POLL_DELAY_US 500
@@ -197,7 +191,6 @@
#define LEAPRAID_INVALID_DEV_HANDLE 0xFFFF
/* Commands queue depth. */
-#define LEAPRAID_COALESCING_DEPTH_MAX 256
#define LEAPRAID_DEFAULT_CMD_QD_OFFSET 64
#define LEAPRAID_REPLY_QD_ALIGNMENT 16
/* Task ID offset. */
@@ -223,7 +216,6 @@
#define LEAPRAID_CTL_CMD_TIMEOUT LEAPRAID_UNIFIED_TIMEOUT
#define LEAPRAID_SCAN_DEV_CMD_TIMEOUT 300
#define LEAPRAID_TIMESTAMP_SYNC_CMD_TIMEOUT LEAPRAID_UNIFIED_TIMEOUT
-#define LEAPRAID_RAID_ACTION_CMD_TIMEOUT LEAPRAID_UNIFIED_TIMEOUT
#define LEAPRAID_ENC_CMD_TIMEOUT LEAPRAID_UNIFIED_TIMEOUT
#define LEAPRAID_IO_CMD_TIMEOUT LEAPRAID_UNIFIED_TIMEOUT
#define LEAPRAID_NOTIFY_EVENT_CMD_TIMEOUT LEAPRAID_UNIFIED_TIMEOUT
@@ -598,6 +590,7 @@ struct leapraid_fw_evt_work {
* @leapraid_evt_masks: Array of event masks for filtering firmware events.
*/
struct leapraid_fw_evt_struct {
+ u32 leapraid_evt_masks[4];
char fw_evt_name[48];
struct workqueue_struct *fw_evt_thread;
spinlock_t fw_evt_lock; /* protects firmware event */
@@ -605,7 +598,6 @@ struct leapraid_fw_evt_struct {
struct leapraid_fw_evt_work *cur_evt;
struct task_struct *cur_evt_task;
u8 fw_evt_cleanup;
- u32 leapraid_evt_masks[4];
};
/**
@@ -1444,7 +1436,7 @@ int leapraid_get_volume_cap(struct leapraid_adapter *adapter,
int leapraid_internal_init_cmd_priv(
struct leapraid_adapter *adapter,
struct leapraid_io_req_tracker *io_tracker);
-int leapraid_internal_exit_cmd_priv(
+void leapraid_internal_exit_cmd_priv(
struct leapraid_adapter *adapter,
struct leapraid_io_req_tracker *io_tracker);
void leapraid_clean_active_fw_evt(struct leapraid_adapter *adapter);
@@ -1515,7 +1507,7 @@ int leapraid_op_config_page(struct leapraid_adapter *adapter,
void *cfgp, union cfg_param_1 cfgp1,
union cfg_param_2 cfgp2,
enum config_page_action cfg_op);
-void leapraid_log_req_context(struct leapraid_adapter *adapter,
+void leapraid_log_req_context(struct leapraid_adapter *adapter, u16 smid,
const void *req_data);
int leapraid_change_queue_depth(struct scsi_device *sdev, int qdepth);
diff --git a/drivers/scsi/leapraid/leapraid_os.c b/drivers/scsi/leapraid/leapraid_os.c
index 5a6cda0b5ea8..301ad59a48bf 100644
--- a/drivers/scsi/leapraid/leapraid_os.c
+++ b/drivers/scsi/leapraid/leapraid_os.c
@@ -157,9 +157,8 @@ static int leapraid_tm_post_processing(struct leapraid_adapter *adapter,
leapraid_sync_irqs(adapter, true);
leapraid_unmask_int(adapter);
- rc = leapraid_tm_cmd_map_status(adapter, channel, id, lun, type,
- taskid_task);
- return rc;
+ return leapraid_tm_cmd_map_status(adapter, channel, id, lun, type,
+ taskid_task);
}
static void leapraid_build_tm_req(struct leapraid_scsi_tm_req *scsi_tm_req,
@@ -185,6 +184,7 @@ int leapraid_issue_tm(struct leapraid_adapter *adapter, u16 hdl, uint channel,
struct leapraid_scsiio_req *scsiio_req;
struct leapraid_io_req_tracker *io_req_tracker = NULL;
u16 msix_task;
+ u16 taskid;
bool issue_reset = false;
u32 db;
int rc;
@@ -239,16 +239,15 @@ int leapraid_issue_tm(struct leapraid_adapter *adapter, u16 hdl, uint channel,
msix_task = io_req_tracker->msix_io;
else
msix_task = 0;
- leapraid_fire_hpr_task(adapter,
- adapter->driver_cmds.tm_cmd.hp_taskid,
- msix_task);
+ taskid = adapter->driver_cmds.tm_cmd.hp_taskid;
+ leapraid_fire_hpr_task(adapter, taskid, msix_task);
wait_for_completion_timeout(&adapter->driver_cmds.tm_cmd.done,
LEAPRAID_TM_CMD_TIMEOUT * HZ);
if (!(adapter->driver_cmds.tm_cmd.status & LEAPRAID_CMD_DONE)) {
dev_err(&adapter->pdev->dev,
"%s: TM cmd timeout, status=0x%x\n",
__func__, adapter->driver_cmds.tm_cmd.status);
- leapraid_log_req_context(adapter, scsi_tm_req);
+ leapraid_log_req_context(adapter, taskid, scsi_tm_req);
issue_reset =
leapraid_check_reset(
adapter->driver_cmds.tm_cmd.status);
@@ -647,7 +646,6 @@ static void leapraid_probe_sas(struct leapraid_adapter *adapter)
sas_dev->hdl,
sas_dev->parent_sas_addr,
sas_dev->card_port);
-
if (!added)
goto remove_dev;
@@ -808,10 +806,7 @@ static inline bool leapraid_is_scmd_permitted(struct leapraid_adapter *adapter,
return false;
opcode = scmd->cmnd[0];
- if (opcode == SYNCHRONIZE_CACHE || opcode == START_STOP)
- return true;
-
- return false;
+ return opcode == SYNCHRONIZE_CACHE || opcode == START_STOP;
}
return true;
}
@@ -1084,13 +1079,15 @@ static int leapraid_error_handler(struct scsi_cmnd *scmd,
out_eh_done:
if (type == LEAPRAID_TM_TASKTYPE_ABORT_TASK) {
- dev_info(&adapter->pdev->dev,
- "EH ABORT result: %s, scmd=0x%p\n",
- rc == SUCCESS ? "success" : "failed", scmd);
+ if (rc)
+ dev_err(&adapter->pdev->dev,
+ "EH ABORT result: failed, scmd=0x%p\n",
+ scmd);
} else {
- dev_info(&adapter->pdev->dev,
- "EH %s result: %s, scmd=0x%p\n",
- str, rc == SUCCESS ? "success" : "failed", scmd);
+ if (rc)
+ dev_err(&adapter->pdev->dev,
+ "EH %s result: failed, scmd=0x%p\n",
+ str, scmd);
if (sas_dev)
leapraid_sdev_put(sas_dev);
}
@@ -1144,8 +1141,10 @@ static int leapraid_eh_host_reset_handler(struct scsi_cmnd *scmd)
rc = SUCCESS;
out_host_reset_done:
- dev_info(&adapter->pdev->dev, "EH HOST RESET result: %s, scmd=0x%p\n",
- rc == SUCCESS ? "success" : "failed", scmd);
+ if (rc)
+ dev_err(&adapter->pdev->dev,
+ "EH HOST RESET result: failed, scmd=0x%p\n",
+ scmd);
return rc;
}
@@ -1210,7 +1209,7 @@ static int leapraid_slave_alloc(struct scsi_device *sdev)
return 0;
}
-static int leapraid_slave_cfg_volume(struct scsi_device *sdev)
+static bool leapraid_slave_cfg_volume(struct scsi_device *sdev)
{
struct Scsi_Host *shost = sdev->host;
struct leapraid_adapter *adapter = shost_priv(shost);
@@ -1259,10 +1258,10 @@ static int leapraid_slave_cfg_volume(struct scsi_device *sdev)
return 0;
}
-static int leapraid_slave_configure_extra(struct scsi_device *sdev,
- struct leapraid_sas_dev **psas_dev,
- u16 vol_hdl, u64 volume_wwid,
- bool *is_target_ssp, int *qd)
+static bool leapraid_slave_configure_extra(struct scsi_device *sdev,
+ struct leapraid_sas_dev **psas_dev,
+ u16 vol_hdl, u64 volume_wwid,
+ bool *is_target_ssp, int *qd)
{
struct leapraid_sas_dev *sas_dev;
struct leapraid_sdev_priv *sdev_priv;
@@ -1569,11 +1568,9 @@ static bool leapraid_scan_check_status(struct leapraid_adapter *adapter,
wake_up(&adapter->scan_dev_desc.wait_driver_loading);
adapter->scan_dev_desc.wait_scan_dev_done = 0;
adapter->access_ctrl.host_removing = 1;
- wake_up(&adapter->access_ctrl.recovery_waitq);
return true;
}
- dev_info(&adapter->pdev->dev, "Device scan: SUCCESS\n");
adapter->driver_cmds.scan_dev_cmd.status = LEAPRAID_CMD_NOT_USED;
leapraid_scan_dev_done(adapter);
return true;
@@ -2116,7 +2113,6 @@ static void leapraid_remove(struct pci_dev *pdev)
!atomic_read(&adapter->overheat_desc.thermal_alert));
adapter->access_ctrl.host_removing = 1;
- wake_up(&adapter->access_ctrl.recovery_waitq);
leapraid_wait_cmds_done(adapter);
@@ -2157,7 +2153,6 @@ static void leapraid_shutdown(struct pci_dev *pdev)
}
adapter->access_ctrl.host_removing = 1;
- wake_up(&adapter->access_ctrl.recovery_waitq);
leapraid_wait_cmds_done(adapter);
leapraid_clean_active_fw_evt(adapter);
leapraid_overheat_cleanup(adapter);
@@ -2244,7 +2239,6 @@ static pci_ers_result_t leapraid_pci_slot_reset(struct pci_dev *pdev)
dev_err(&pdev->dev, "%s PCI error slot reset\n",
adapter->adapter_attr.name);
- adapter->access_ctrl.pcie_recovering = 0;
adapter->pdev = pdev;
pci_restore_state(pdev);
if (leapraid_set_pcie_and_notification(adapter)) {
@@ -2254,13 +2248,15 @@ static pci_ers_result_t leapraid_pci_slot_reset(struct pci_dev *pdev)
return PCI_ERS_RESULT_DISCONNECT;
}
+ adapter->access_ctrl.pcie_recovering = 0;
dev_info(&pdev->dev, "%s: Hard reset triggered by PCI slot reset\n",
adapter->adapter_attr.name);
dev_info(&adapter->pdev->dev, "%s: %d: call hard_reset\n",
__func__, __LINE__);
rc = leapraid_hard_reset_handler(adapter, FULL_RESET);
- dev_info(&pdev->dev, "%s hard reset: %s\n",
- adapter->adapter_attr.name, rc == 0 ? "success" : "failed");
+ if (rc)
+ dev_err(&pdev->dev, "%s hard reset: failed\n",
+ adapter->adapter_attr.name);
return rc == 0 ? PCI_ERS_RESULT_RECOVERED :
PCI_ERS_RESULT_DISCONNECT;
@@ -2277,6 +2273,7 @@ static void leapraid_pci_resume(struct pci_dev *pdev)
}
dev_err(&pdev->dev, "PCI error resume!\n");
+
pci_aer_clear_nonfatal_status(pdev);
leapraid_check_scheduled_fault_start(adapter);
leapraid_fw_log_start(adapter);
diff --git a/drivers/scsi/leapraid/leapraid_transport.c b/drivers/scsi/leapraid/leapraid_transport.c
index 738bc55df416..e175ca4c1264 100644
--- a/drivers/scsi/leapraid/leapraid_transport.c
+++ b/drivers/scsi/leapraid/leapraid_transport.c
@@ -298,6 +298,7 @@ static int leapraid_transport_exp_report_manu(struct leapraid_adapter *adapter,
dma_addr_t c2h_dma_addr;
bool issue_reset = false;
void *data_out = NULL;
+ u16 inter_taskid;
size_t c2h_size;
size_t h2c_size;
void *psge;
@@ -338,10 +339,8 @@ static int leapraid_transport_exp_report_manu(struct leapraid_adapter *adapter,
rep_manu_request->allocated_response_length = 0;
rep_manu_request->request_length = 0;
- smp_passthrough_req =
- leapraid_get_task_desc(
- adapter,
- adapter->driver_cmds.transport_cmd.inter_taskid);
+ inter_taskid = adapter->driver_cmds.transport_cmd.inter_taskid;
+ smp_passthrough_req = leapraid_get_task_desc(adapter, inter_taskid);
memset(smp_passthrough_req, 0,
sizeof(struct leapraid_smp_passthrough_req));
smp_passthrough_req->func = LEAPRAID_FUNC_SMP_PASSTHROUGH;
@@ -354,8 +353,7 @@ static int leapraid_transport_exp_report_manu(struct leapraid_adapter *adapter,
c2h_dma_addr, c2h_size);
init_completion(&adapter->driver_cmds.transport_cmd.done);
- leapraid_fire_task(adapter,
- adapter->driver_cmds.transport_cmd.inter_taskid);
+ leapraid_fire_task(adapter, inter_taskid);
wait_for_completion_timeout(&adapter->driver_cmds.transport_cmd.done,
LEAPRAID_TRANSPORT_CMD_TIMEOUT * HZ);
if (!(adapter->driver_cmds.transport_cmd.status & LEAPRAID_CMD_DONE)) {
@@ -363,7 +361,8 @@ static int leapraid_transport_exp_report_manu(struct leapraid_adapter *adapter,
dev_err(&adapter->pdev->dev,
"%s: SMP passthrough timeout, st=0x%x\n",
__func__, adapter->driver_cmds.transport_cmd.status);
- leapraid_log_req_context(adapter, smp_passthrough_req);
+ leapraid_log_req_context(adapter, inter_taskid,
+ smp_passthrough_req);
if (!(adapter->driver_cmds.transport_cmd.status &
LEAPRAID_CMD_RESET))
issue_reset = true;
@@ -1249,20 +1248,21 @@ static void leapraid_build_smp_task(struct leapraid_adapter *adapter,
static int leapraid_send_smp_req(struct leapraid_adapter *adapter)
{
const struct leapraid_smp_passthrough_req *smp_passthrough_req;
+ u16 inter_taskid;
dev_dbg(&adapter->pdev->dev,
"%s: Sending smp request\n", __func__);
- smp_passthrough_req = leapraid_get_task_desc(
- adapter, adapter->driver_cmds.transport_cmd.inter_taskid);
+ inter_taskid = adapter->driver_cmds.transport_cmd.inter_taskid;
+ smp_passthrough_req = leapraid_get_task_desc(adapter, inter_taskid);
init_completion(&adapter->driver_cmds.transport_cmd.done);
- leapraid_fire_task(adapter,
- adapter->driver_cmds.transport_cmd.inter_taskid);
+ leapraid_fire_task(adapter, inter_taskid);
wait_for_completion_timeout(&adapter->driver_cmds.transport_cmd.done,
LEAPRAID_TRANSPORT_CMD_TIMEOUT * HZ);
if (!(adapter->driver_cmds.transport_cmd.status & LEAPRAID_CMD_DONE)) {
dev_err(&adapter->pdev->dev, "%s: timeout, st=0x%x\n",
__func__, adapter->driver_cmds.transport_cmd.status);
- leapraid_log_req_context(adapter, smp_passthrough_req);
+ leapraid_log_req_context(adapter, inter_taskid,
+ smp_passthrough_req);
if (!(adapter->driver_cmds.transport_cmd.status &
LEAPRAID_CMD_RESET)) {
dev_dbg(&adapter->pdev->dev,
--
2.25.1
1
0
From: Hao Dongdong <doubled(a)leap-io-kernel.com>
LeapIO inclusion
category: feature
bugzilla: https://atomgit.com/openeuler/kernel/issues/9538
------------------------------------------
leapraid driver changes from v2.00.01.02 to v2.00.01.05.
This update includes:
- recovery wait and hard reset flow stabilization
- improved timeout diagnostics with per-command context logging
- MSI-X/IRQ CPU affinity fixes
- SAS topology and event bitmap alignment fixes
- transport and task-management error-path cleanup
- config-page stack usage reduction and adapter info cleanup
- ioctl compatibility cleanup
- resource cleanup and failure-path hardening
Signed-off-by: Hao Dongdong <doubled(a)leap-io-kernel.com>
---
drivers/scsi/leapraid/leapraid.h | 21 --
drivers/scsi/leapraid/leapraid_app.c | 9 +-
drivers/scsi/leapraid/leapraid_func.c | 344 +++++++++------------
drivers/scsi/leapraid/leapraid_func.h | 18 +-
drivers/scsi/leapraid/leapraid_os.c | 61 ++--
drivers/scsi/leapraid/leapraid_transport.c | 24 +-
6 files changed, 191 insertions(+), 286 deletions(-)
diff --git a/drivers/scsi/leapraid/leapraid.h b/drivers/scsi/leapraid/leapraid.h
index 2a99417143ad..c9f403efb84f 100644
--- a/drivers/scsi/leapraid/leapraid.h
+++ b/drivers/scsi/leapraid/leapraid.h
@@ -27,8 +27,6 @@
/* Maximum number of retries waiting for doorbell to become operational. */
#define LEAPRAID_DB_WAIT_OP_SHORT 10
#define LEAPRAID_DB_WAIT_OP_LONG 200
-/* Sleep interval (in seconds) between doorbell polls. */
-#define LEAPRAID_DB_POLL_INTERVAL_S 1
/* Maximum number of retries waiting for host to end recovery. */
#define LEAPRAID_WAIT_SHOST_RECOVERY 400
@@ -180,7 +178,6 @@
#define LEAPRAID_CFG_PAGE_NUM_DEV0 0x0
/* SAS device page 0 flags. */
-#define LEAPRAID_SAS_DEV_P0_FLG_FP_CAP 0x2000
#define LEAPRAID_SAS_DEV_P0_FLG_SATA_SMART 0x0040
#define LEAPRAID_SAS_DEV_P0_FLG_ENC_LEVEL_VALID 0x0002
#define LEAPRAID_SAS_DEV_P0_FLG_DEV_PRESENT 0x0001
@@ -207,15 +204,9 @@
/* Physical disk page number. */
#define LEAPRAID_CFG_PAGE_NUM_PD0 0x0
-/* Adapter page number. */
-#define LEAPRAID_CFG_PAGE_NUM_ADAPTER1 0x1
-
#define LEAPRAID_CFG_UNIT_SIZE 4
/* Raid volume type and state. */
-#define LEAPRAID_VOL_STATE_MISSING 0x00
-#define LEAPRAID_VOL_STATE_FAILED 0x01
-#define LEAPRAID_VOL_STATE_INITIALIZING 0x02
#define LEAPRAID_VOL_STATE_ONLINE 0x03
#define LEAPRAID_VOL_STATE_DEGRADED 0x04
#define LEAPRAID_VOL_STATE_OPTIMAL 0x05
@@ -231,10 +222,6 @@
#define LEAPRAID_RAIDCFG_P0_EFLG_HOT_SPARE_ELEMENT 0x0002
#define LEAPRAID_RAIDCFG_P0_EFLG_OCE_ELEMENT 0x0003
-/* Raid action. */
-#define LEAPRAID_RAID_ACT_SYSTEM_SHUTDOWN_INITIATED 0x20
-#define LEAPRAID_RAID_ACT_PHYSDISK_HIDDEN 0x24
-
/* SAS negotiated link rates. */
#define LEAPRAID_SAS_NEG_LINK_RATE_MASK_PHYSICAL 0x0F
#define LEAPRAID_SAS_NEG_LINK_RATE_UNKNOWN_LINK_RATE 0x00
@@ -290,8 +277,6 @@
#define LEAPRAID_TM_MSGFLAGS_LINK_RESET 0x00
#define LEAPRAID_TM_RSP_INVALID_FRAME 0x02
-#define LEAPRAID_TM_RSP_TM_SUCCEEDED 0x08
-#define LEAPRAID_TM_RSP_IO_QUEUED_ON_ADAPTER 0x80
/* SCSI enclosure processor request defines. */
#define LEAPRAID_SEP_REQ_ACT_WRITE_STATUS 0x00
@@ -301,8 +286,6 @@
/* The capabilities of the adapter. */
#define LEAPRAID_ADAPTER_FEATURES_CAP_ATOMIC_REQ 0x00080000
-#define LEAPRAID_ADAPTER_FEATURES_CAP_RDPQ_ARRAY_CAPABLE 0x00040000
-#define LEAPRAID_ADAPTER_FEATURES_CAP_EVENT_REPLAY 0x00002000
#define LEAPRAID_ADAPTER_FEATURES_CAP_INTEGRATED_RAID 0x00001000
/* Event code definitions for the firmware. */
@@ -338,10 +321,6 @@
#define LEAPRAID_EVT_SAS_TOPO_RC_TARG_ADDED 0x01
#define LEAPRAID_EVT_SAS_TOPO_RC_TARG_NOT_RESPONDING 0x02
-/* SAS discovery event defines. */
-#define LEAPRAID_EVT_SAS_DISC_RC_STARTED 0x01
-#define LEAPRAID_EVT_SAS_DISC_RC_COMPLETED 0x02
-
/* Enclosure device status change event. */
#define LEAPRAID_EVT_SAS_ENCL_RC_ADDED 0x01
#define LEAPRAID_EVT_SAS_ENCL_RC_NOT_RESPONDING 0x02
diff --git a/drivers/scsi/leapraid/leapraid_app.c b/drivers/scsi/leapraid/leapraid_app.c
index 25ec57c2ce4b..8ee57865adca 100644
--- a/drivers/scsi/leapraid/leapraid_app.c
+++ b/drivers/scsi/leapraid/leapraid_app.c
@@ -388,6 +388,7 @@ static int leapraid_ctl_do_command(struct leapraid_adapter *adapter,
dev_err(&adapter->pdev->dev,
"%s: ctl_cmd timeout, status=0x%x\n",
__func__, adapter->driver_cmds.ctl_cmd.status);
+ leapraid_log_req_context(adapter, taskid, ctl_sp_mpi_req);
}
if ((leap_mpi_req->func == LEAPRAID_FUNC_SMP_PASSTHROUGH ||
@@ -590,7 +591,7 @@ static int leapraid_ctl_ioctl_main(struct file *file, unsigned int cmd,
break;
}
- if (karg.hdr.adapter_id != ioctl_header.adapter_id) {
+ if (karg.hdr.adapter_id != ioctl_header.adapter_id) {
rc = -EINVAL;
break;
}
@@ -621,11 +622,6 @@ static int leapraid_ctl_ioctl_main(struct file *file, unsigned int cmd,
return rc;
}
-static long bad_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
- return -ENOTTY;
-}
-
static long leapraid_ctl_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
@@ -679,7 +675,6 @@ static const struct file_operations leapraid_ctl_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = leapraid_ctl_ioctl,
.mmap = leapraid_fw_mmap,
- .compat_ioctl = bad_ioctl,
};
static struct miscdevice leapraid_ctl_dev = {
diff --git a/drivers/scsi/leapraid/leapraid_func.c b/drivers/scsi/leapraid/leapraid_func.c
index f2574feb2514..3701c9c8a4c7 100644
--- a/drivers/scsi/leapraid/leapraid_func.c
+++ b/drivers/scsi/leapraid/leapraid_func.c
@@ -47,6 +47,17 @@ static bool leapraid_should_skip_poll_work(struct leapraid_adapter *adapter);
static int leapraid_make_adapter_ready(struct leapraid_adapter *adapter,
enum reset_type type);
+static noinline bool leapraid_shost_in_recovery(struct Scsi_Host *shost)
+{
+ enum scsi_host_state state;
+
+ state = READ_ONCE(shost->shost_state);
+ return state == SHOST_RECOVERY ||
+ state == SHOST_CANCEL_RECOVERY ||
+ state == SHOST_DEL_RECOVERY ||
+ shost->tmf_in_progress;
+}
+
static void leapraid_debug_log_info(struct leapraid_adapter *adapter)
{
struct leapraid_reg_base __iomem *iomem_base = adapter->iomem_base;
@@ -81,6 +92,7 @@ static void leapraid_debug_log_info(struct leapraid_adapter *adapter)
debug_log[i + 2],
debug_log[i + 3]);
}
+
static inline bool leapraid_is_end_dev(u32 dev_type)
{
return (dev_type & LEAPRAID_DEVTYP_END_DEV) &&
@@ -171,7 +183,6 @@ static void leapraid_overheat_suspend(struct leapraid_adapter *adapter)
pdev = adapter->pdev;
shost = pci_get_drvdata(pdev);
-
if (!shost) {
dev_warn(&pdev->dev,
"Overheat suspend failed, invalid host or adapter\n");
@@ -1948,7 +1959,7 @@ static const char *leapraid_tm_type_name(u8 task_type)
}
}
-void leapraid_log_req_context(struct leapraid_adapter *adapter,
+void leapraid_log_req_context(struct leapraid_adapter *adapter, u16 smid,
const void *req_data)
{
const struct leapraid_req *req = req_data;
@@ -1961,8 +1972,8 @@ void leapraid_log_req_context(struct leapraid_adapter *adapter,
const struct leapraid_cfg_req *cfg_req = req_data;
dev_err(&adapter->pdev->dev,
- "cfg-req: func=0x%02x(%s) act=0x%02x(%s)\n",
- req->func, leapraid_func_name(req->func),
+ "cfg-req: smid=%u func=0x%02x(%s) action=0x%02x(%s)\n",
+ smid, req->func, leapraid_func_name(req->func),
cfg_req->action,
leapraid_cfg_action_name(cfg_req->action));
dev_err(&adapter->pdev->dev,
@@ -1984,12 +1995,12 @@ void leapraid_log_req_context(struct leapraid_adapter *adapter,
const struct leapraid_scsi_tm_req *tm_req = req_data;
dev_err(&adapter->pdev->dev,
- "scsi_tm: func=0x%02x(%s) task=0x%02x(%s)\n",
- req->func, leapraid_func_name(req->func),
+ "scsi_tm:: smid=%u func=0x%02x(%s) task=0x%02x(%s)\n",
+ smid, req->func, leapraid_func_name(req->func),
tm_req->task_type,
leapraid_tm_type_name(tm_req->task_type));
dev_err(&adapter->pdev->dev,
- "scsi_tm: dev_hdl=0x%04x task_mid=%u\n",
+ "scsi_tm:: dev_hdl=0x%04x task_mid=%u\n",
le16_to_cpu(tm_req->dev_hdl),
le16_to_cpu(tm_req->task_mid));
break;
@@ -1998,8 +2009,8 @@ void leapraid_log_req_context(struct leapraid_adapter *adapter,
const struct leapraid_sep_req *sep_req = req_data;
dev_err(&adapter->pdev->dev,
- "sep: func=0x%02x(%s) act=0x%02x(%s)\n",
- req->func, leapraid_func_name(req->func),
+ "sep: smid=%u func=0x%02x(%s) action=0x%02x(%s)\n",
+ smid, req->func, leapraid_func_name(req->func),
sep_req->act,
leapraid_sep_action_name(sep_req->act));
dev_err(&adapter->pdev->dev,
@@ -2013,11 +2024,11 @@ void leapraid_log_req_context(struct leapraid_adapter *adapter,
const struct leapraid_io_unit_ctrl_req *io_req = req_data;
dev_err(&adapter->pdev->dev,
- "timestamp sync: func=0x%02x(%s) op=0x%02x(%s)\n",
- req->func, leapraid_func_name(req->func),
+ "ctl_cmd: smid=%u func=0x%02x(%s) action=0x%02x(%s)\n",
+ smid, req->func, leapraid_func_name(req->func),
io_req->op, leapraid_sas_op_name(io_req->op));
dev_err(&adapter->pdev->dev,
- "timestamp sync: dev_hdl=0x%04x param=0x%02x(%s)\n",
+ "ctl_cmd: dev_hdl=0x%04x param=0x%02x(%s)\n",
le16_to_cpu(io_req->dev_hdl),
io_req->adapter_para,
leapraid_io_param_name(io_req->adapter_para));
@@ -2027,18 +2038,21 @@ void leapraid_log_req_context(struct leapraid_adapter *adapter,
const struct leapraid_smp_passthrough_req *smp_req = req_data;
dev_err(&adapter->pdev->dev,
- "transport: func=0x%02x(%s) port=%u req_len=%u\n",
- req->func, leapraid_func_name(req->func),
+ "smp_cmd: smid=%u func=0x%02x(%s) action=0x%02x\n",
+ smid, req->func, leapraid_func_name(req->func),
+ smp_req->passthrough_flg);
+ dev_err(&adapter->pdev->dev,
+ "smp_cmd: port=%u req_len=%u\n",
smp_req->physical_port,
le16_to_cpu(smp_req->req_data_len));
- dev_err(&adapter->pdev->dev, "transport: sas_addr=0x%016llx\n",
+ dev_err(&adapter->pdev->dev, "smp_cmd: sas_addr=0x%016llx\n",
(unsigned long long)le64_to_cpu(smp_req->sas_address));
break;
}
default:
dev_err(&adapter->pdev->dev,
- "%s: func=0x%02x(%s)\n",
- __func__, req->func, leapraid_func_name(req->func));
+ "cmd: smid=%u func=0x%02x(%s)\n",
+ smid, req->func, leapraid_func_name(req->func));
break;
}
}
@@ -2049,19 +2063,18 @@ static void leapraid_build_and_fire_cfg_req(
struct leapraid_cfg_rep *leap_mpi_cfgp_rep)
{
struct leapraid_cfg_req *local_leap_cfg_req;
+ u16 smid;
memset(leap_mpi_cfgp_rep, 0, sizeof(struct leapraid_cfg_rep));
memset(&adapter->driver_cmds.cfg_op_cmd.reply, 0,
sizeof(struct leapraid_cfg_rep));
adapter->driver_cmds.cfg_op_cmd.status = LEAPRAID_CMD_PENDING;
- local_leap_cfg_req = leapraid_get_task_desc(
- adapter,
- adapter->driver_cmds.cfg_op_cmd.inter_taskid);
+ smid = adapter->driver_cmds.cfg_op_cmd.inter_taskid;
+ local_leap_cfg_req = leapraid_get_task_desc(adapter, smid);
memcpy(local_leap_cfg_req, leap_mpi_cfgp_req,
sizeof(struct leapraid_cfg_req));
init_completion(&adapter->driver_cmds.cfg_op_cmd.done);
- leapraid_fire_task(adapter,
- adapter->driver_cmds.cfg_op_cmd.inter_taskid);
+ leapraid_fire_task(adapter, smid);
wait_for_completion_timeout(&adapter->driver_cmds.cfg_op_cmd.done,
LEAPRAID_CFG_OP_TIMEOUT * HZ);
}
@@ -2074,11 +2087,13 @@ static int leapraid_req_cfg_func(struct leapraid_adapter *adapter,
{
u32 adapter_status = UINT_MAX;
bool issue_reset = false;
+ u16 smid;
u8 retry_cnt;
int rc;
retry_cnt = 0;
mutex_lock(&adapter->driver_cmds.cfg_op_cmd.mutex);
+ smid = adapter->driver_cmds.cfg_op_cmd.inter_taskid;
retry:
if (retry_cnt) {
if (retry_cnt > LEAPRAID_CFG_REQ_RETRY_TIMES) {
@@ -2115,14 +2130,16 @@ static int leapraid_req_cfg_func(struct leapraid_adapter *adapter,
adapter->access_ctrl.shost_recovering ?
"shost recovery" : "pcie recovery",
adapter->driver_cmds.cfg_op_cmd.status);
- leapraid_log_req_context(adapter, leap_mpi_cfgp_req);
+ leapraid_log_req_context(adapter, smid,
+ leap_mpi_cfgp_req);
issue_reset = false;
rc = -EFAULT;
} else {
dev_err(&adapter->pdev->dev,
"cfg-req: timeout, status=0x%x, reset\n",
adapter->driver_cmds.cfg_op_cmd.status);
- leapraid_log_req_context(adapter, leap_mpi_cfgp_req);
+ leapraid_log_req_context(adapter, smid,
+ leap_mpi_cfgp_req);
issue_reset = true;
}
@@ -2162,7 +2179,7 @@ static int leapraid_req_cfg_func(struct leapraid_adapter *adapter,
mutex_unlock(&adapter->driver_cmds.cfg_op_cmd.mutex);
if (issue_reset) {
if (adapter->scan_dev_desc.first_scan_dev_fired) {
- dev_info(&adapter->pdev->dev,
+ dev_warn(&adapter->pdev->dev,
"%s:%d cfg-req: Failure, issuing reset\n",
__func__, __LINE__);
leapraid_hard_reset_handler(adapter, FULL_RESET);
@@ -2433,14 +2450,12 @@ static int leapraid_cfg_find_vol_in_page(
u16 phys_hdl;
phys_hdl = le16_to_cpu(elem->phys_disk_dev_hdl);
-
if (phys_hdl == pd_hdl) {
*vol_hdl = le16_to_cpu(elem->vol_dev_hdl);
return 0;
}
break;
}
-
case LEAPRAID_RAIDCFG_P0_EFLG_HOT_SPARE_ELEMENT:
*vol_hdl = 0;
return 0;
@@ -2607,7 +2622,6 @@ static int leapraid_cfg_get_number_pds(struct leapraid_adapter *adapter,
cfgp2.handle = hdl;
rc = leapraid_op_config_page(adapter, &raidvol_p0, cfgp1,
cfgp2, GET_RAID_VOLUME_PG0);
-
if (!rc)
*num_pds = raidvol_p0.num_phys_disks;
@@ -2827,13 +2841,12 @@ static void leapraid_timestamp_sync(struct leapraid_adapter *adapter)
ktime_t current_time;
bool issue_reset = false;
u64 time_stamp;
+ u16 smid;
mutex_lock(&adapter->driver_cmds.timestamp_sync_cmd.mutex);
adapter->driver_cmds.timestamp_sync_cmd.status = LEAPRAID_CMD_PENDING;
- io_unit_ctrl_req =
- leapraid_get_task_desc(
- adapter,
- adapter->driver_cmds.timestamp_sync_cmd.inter_taskid);
+ smid = adapter->driver_cmds.timestamp_sync_cmd.inter_taskid;
+ io_unit_ctrl_req = leapraid_get_task_desc(adapter, smid);
memset(io_unit_ctrl_req, 0, sizeof(struct leapraid_io_unit_ctrl_req));
io_unit_ctrl_req->func = LEAPRAID_FUNC_SAS_IO_UNIT_CTRL;
io_unit_ctrl_req->op = LEAPRAID_SAS_OP_SET_PARAMETER;
@@ -2847,9 +2860,7 @@ static void leapraid_timestamp_sync(struct leapraid_adapter *adapter)
io_unit_ctrl_req->adapter_para_value2 =
cpu_to_le32(time_stamp >> 32);
init_completion(&adapter->driver_cmds.timestamp_sync_cmd.done);
- leapraid_fire_task(
- adapter,
- adapter->driver_cmds.timestamp_sync_cmd.inter_taskid);
+ leapraid_fire_task(adapter, smid);
leapraid_debug_log_info(adapter);
wait_for_completion_timeout(&adapter->driver_cmds
.timestamp_sync_cmd.done,
@@ -2860,7 +2871,7 @@ static void leapraid_timestamp_sync(struct leapraid_adapter *adapter)
"%s: timestamp sync timeout, status=0x%x\n",
__func__,
adapter->driver_cmds.timestamp_sync_cmd.status);
- leapraid_log_req_context(adapter, io_unit_ctrl_req);
+ leapraid_log_req_context(adapter, smid, io_unit_ctrl_req);
issue_reset =
leapraid_check_reset(
adapter->driver_cmds.timestamp_sync_cmd.status);
@@ -2891,15 +2902,16 @@ static void leapraid_check_scheduled_fault_work(struct work_struct *work)
adapter_state = leapraid_get_adapter_state(adapter);
if (adapter_state != LEAPRAID_DB_OPERATIONAL) {
- dev_info(&adapter->pdev->dev, "%s:%d: call hard_reset\n",
- __func__, __LINE__);
+ dev_info(&adapter->pdev->dev, "%s:%d: call hard_reset 0x%x\n",
+ __func__, __LINE__, adapter_state);
rc = leapraid_hard_reset_handler(adapter, FULL_RESET);
- dev_warn(&adapter->pdev->dev, "%s: Hard reset %s\n",
- __func__, rc == 0 ? "success" : "failed");
-
adapter_state = leapraid_get_adapter_state(adapter);
- if (rc && adapter_state != LEAPRAID_DB_OPERATIONAL)
+ if (rc && adapter_state != LEAPRAID_DB_OPERATIONAL) {
+ dev_err(&adapter->pdev->dev,
+ "%s: Hard reset failed, state=0x%x rc=%d\n",
+ __func__, adapter_state, rc);
return;
+ }
}
if (++adapter->timestamp_sync_cnt >=
@@ -3262,7 +3274,6 @@ void leapraid_smart_polling_stop(struct leapraid_adapter *adapter)
wq = desc->smart_poll_wq;
desc->smart_poll_wq = NULL;
-
if (wq) {
if (!cancel_delayed_work_sync(&desc->smart_poll_work))
flush_workqueue(wq);
@@ -3304,7 +3315,6 @@ static void leapraid_overheat_work(struct work_struct *work)
adapter->scan_dev_desc.scan_start = 0;
adapter->scan_dev_desc.wait_scan_dev_done = 0;
adapter->scan_dev_desc.driver_loading = 0;
- wake_up(&adapter->access_ctrl.recovery_waitq);
wake_up(&adapter->access_ctrl.shost_recover_wq);
wake_up(&adapter->scan_dev_desc.wait_driver_loading);
@@ -3393,10 +3403,10 @@ static struct leapraid_fw_evt_work *leapraid_alloc_fw_evt_work(void)
{
struct leapraid_fw_evt_work *fw_evt =
kzalloc(sizeof(*fw_evt), GFP_ATOMIC);
- if (!fw_evt)
- return NULL;
- kref_init(&fw_evt->refcnt);
+ if (fw_evt)
+ kref_init(&fw_evt->refcnt);
+
return fw_evt;
}
@@ -3467,7 +3477,6 @@ void leapraid_clean_active_fw_evt(struct leapraid_adapter *adapter)
return;
adapter->fw_evt_s.fw_evt_cleanup = 1;
- wake_up(&adapter->access_ctrl.recovery_waitq);
if (adapter->access_ctrl.shost_recovering &&
adapter->fw_evt_s.cur_evt)
adapter->fw_evt_s.cur_evt->ignore = 1;
@@ -4382,7 +4391,7 @@ void leapraid_exp_rm(struct leapraid_adapter *adapter, u64 sas_addr,
leapraid_exp_node_rm(adapter, topo_node_exp);
}
-static int leapraid_internal_sas_topo_chg_evt(
+static void leapraid_internal_sas_topo_chg_evt(
struct leapraid_adapter *adapter,
struct leapraid_card_port *card_port,
struct leapraid_topo_node *topo_node_exp,
@@ -4399,11 +4408,11 @@ static int leapraid_internal_sas_topo_chg_evt(
evt_data = fw_evt->evt_data;
for (i = 0; i < evt_data->entry_num; i++) {
if (fw_evt->ignore)
- return 0;
+ return;
if (adapter->access_ctrl.host_removing ||
adapter->access_ctrl.pcie_recovering)
- return 0;
+ return;
phy_number = evt_data->start_phy_num + i;
if (phy_number >= max_phys)
@@ -4441,12 +4450,10 @@ static int leapraid_internal_sas_topo_chg_evt(
if (evt_data->exp_status == LEAPRAID_EVT_SAS_TOPO_ES_NOT_RESPONDING &&
topo_node_exp)
leapraid_exp_rm(adapter, sas_addr, card_port);
-
- return 0;
}
-static int leapraid_sas_topo_chg_evt(struct leapraid_adapter *adapter,
- struct leapraid_fw_evt_work *fw_evt)
+static void leapraid_sas_topo_chg_evt(struct leapraid_adapter *adapter,
+ struct leapraid_fw_evt_work *fw_evt)
{
struct leapraid_topo_node *topo_node_exp;
struct leapraid_card_port *card_port;
@@ -4459,13 +4466,13 @@ static int leapraid_sas_topo_chg_evt(struct leapraid_adapter *adapter,
if (adapter->access_ctrl.shost_recovering ||
adapter->access_ctrl.host_removing ||
adapter->access_ctrl.pcie_recovering)
- return 0;
+ return;
evt_data = fw_evt->evt_data;
leapraid_sas_host_add(adapter, adapter->dev_topo.card.phys_num > 0);
if (fw_evt->ignore)
- return 0;
+ return;
phdl = le16_to_cpu(evt_data->exp_dev_hdl);
card_port = leapraid_get_port_by_id(adapter,
@@ -4473,7 +4480,7 @@ static int leapraid_sas_topo_chg_evt(struct leapraid_adapter *adapter,
false);
if (evt_data->exp_status == LEAPRAID_EVT_SAS_TOPO_ES_ADDED &&
leapraid_exp_add(adapter, phdl) != 0)
- return 0;
+ return;
spin_lock_irqsave(&adapter->dev_topo.topo_node_lock, flags);
topo_node_exp = leapraid_exp_find_by_hdl(adapter, phdl);
@@ -4487,13 +4494,13 @@ static int leapraid_sas_topo_chg_evt(struct leapraid_adapter *adapter,
} else {
spin_unlock_irqrestore(&adapter->dev_topo.topo_node_lock,
flags);
- return 0;
+ return;
}
spin_unlock_irqrestore(&adapter->dev_topo.topo_node_lock, flags);
- return leapraid_internal_sas_topo_chg_evt(adapter, card_port,
- topo_node_exp, fw_evt,
- sas_addr, max_phys);
+ leapraid_internal_sas_topo_chg_evt(adapter, card_port,
+ topo_node_exp, fw_evt,
+ sas_addr, max_phys);
}
static void leapraid_reprobe_lun(struct scsi_device *sdev, void *no_uld_attach)
@@ -4603,7 +4610,6 @@ static void leapraid_sas_pd_hide(
}
spin_unlock_irqrestore(&adapter->dev_topo.sas_dev_lock, flags);
if (starget) {
- dev_info(&adapter->pdev->dev, "hide sas_dev, hdl=0x%x\n", hdl);
starget_for_each_device(starget,
(void *)LEAPRAID_NO_ULD_ATTACH_FLAG,
leapraid_reprobe_lun);
@@ -4623,7 +4629,6 @@ static void leapraid_sas_pd_expose(
u16 hdl;
hdl = le16_to_cpu(evt_data->phys_disk_dev_hdl);
-
if (!hdl || hdl > adapter->adapter_attr.features.max_dev_handle) {
dev_warn(&adapter->pdev->dev,
"%s: Invalid device handle\n", __func__);
@@ -4652,8 +4657,6 @@ static void leapraid_sas_pd_expose(
spin_unlock_irqrestore(&adapter->dev_topo.sas_dev_lock, flags);
if (starget) {
- dev_info(&adapter->pdev->dev,
- "expose sas_dev, hdl=0x%x\n", hdl);
starget_for_each_device(starget,
LEAPRAID_ULD_ATTACH_FLAG,
leapraid_reprobe_lun);
@@ -4986,7 +4989,7 @@ static void leapraid_remove_unresp_sas_end_dev(
leapraid_sdev_put(sas_dev);
}
- dev_info(&adapter->pdev->dev,
+ dev_warn(&adapter->pdev->dev,
"Unresponsive SAS end devices removed\n");
}
@@ -5011,7 +5014,7 @@ static void leapraid_remove_unresp_raid_volumes(
leapraid_sas_volume_delete_by_ptr(adapter, raid_volume);
}
- dev_info(&adapter->pdev->dev,
+ dev_warn(&adapter->pdev->dev,
"Unresponsive RAID volumes removed\n");
}
@@ -5035,7 +5038,7 @@ static void leapraid_remove_unresp_sas_exp(struct leapraid_adapter *adapter)
&head, list)
leapraid_exp_node_rm(adapter, topo_node_exp);
- dev_info(&adapter->pdev->dev,
+ dev_warn(&adapter->pdev->dev,
"Unresponsive SAS expanders removed\n");
}
@@ -5153,8 +5156,6 @@ static void leapraid_scan_exp_after_reset(struct leapraid_adapter *adapter)
u16 hdl;
u8 port_id;
- dev_info(&adapter->pdev->dev, "Begin scanning expanders\n");
-
cfgp1.form = LEAPRAID_SAS_CFG_PGAD_GET_NEXT_LOOP;
for (hdl = 0xFFFF, cfgp2.handle = hdl;
!leapraid_op_config_page(adapter, &exp_p0, cfgp1, cfgp2,
@@ -5185,8 +5186,6 @@ static void leapraid_scan_exp_after_reset(struct leapraid_adapter *adapter)
exp_p0.sas_address));
}
}
-
- dev_info(&adapter->pdev->dev, "Expanders scan complete\n");
}
static void leapraid_scan_phy_disks_after_reset(
@@ -5203,8 +5202,6 @@ static void leapraid_scan_phy_disks_after_reset(
u16 hdl, parent_hdl;
u64 sas_addr;
- dev_info(&adapter->pdev->dev, "Begin scanning phys disk\n");
-
cfgp1.form = LEAPRAID_SAS_CFG_PGAD_GET_NEXT_LOOP;
for (phys_disk_num = 0xFF, cfgp2.form_specific = phys_disk_num;
!leapraid_op_config_page(adapter, &raidpd_p0,
@@ -5253,8 +5250,6 @@ static void leapraid_scan_phy_disks_after_reset(
}
}
}
-
- dev_info(&adapter->pdev->dev, "PHYs disk scan complete\n");
}
static void leapraid_scan_vol_after_reset(struct leapraid_adapter *adapter)
@@ -5279,7 +5274,6 @@ static void leapraid_scan_vol_after_reset(struct leapraid_adapter *adapter)
return;
}
- dev_info(&adapter->pdev->dev, "Begin scanning volumes\n");
cfgp1.form = LEAPRAID_SAS_CFG_PGAD_GET_NEXT_LOOP;
for (hdl = 0xFFFF, cfgp2.handle = hdl;
!leapraid_op_config_page(adapter, vol_p1, cfgp1,
@@ -5316,8 +5310,6 @@ static void leapraid_scan_vol_after_reset(struct leapraid_adapter *adapter)
kfree(vol_p0);
kfree(vol_p1);
-
- dev_info(&adapter->pdev->dev, "Volumes scan complete\n");
}
static void leapraid_scan_sas_dev_after_reset(struct leapraid_adapter *adapter)
@@ -5330,9 +5322,6 @@ static void leapraid_scan_sas_dev_after_reset(struct leapraid_adapter *adapter)
u64 sas_address;
u8 port_id;
- dev_info(&adapter->pdev->dev,
- "Begin scanning SAS end devices\n");
-
cfgp1.form = LEAPRAID_SAS_CFG_PGAD_GET_NEXT_LOOP;
for (hdl = 0xFFFF, cfgp2.handle = hdl;
!leapraid_op_config_page(adapter, &sas_dev_p0, cfgp1, cfgp2,
@@ -5382,14 +5371,10 @@ static void leapraid_scan_sas_dev_after_reset(struct leapraid_adapter *adapter)
sas_dev_p0.sas_address));
}
}
-
- dev_info(&adapter->pdev->dev, "SAS end devices scan complete\n");
}
static void leapraid_scan_all_dev_after_reset(struct leapraid_adapter *adapter)
{
- dev_info(&adapter->pdev->dev, "Begin scanning devices\n");
-
leapraid_sas_host_add(adapter, adapter->dev_topo.card.phys_num > 0);
leapraid_scan_exp_after_reset(adapter);
if (adapter->adapter_attr.raid_support) {
@@ -5397,8 +5382,6 @@ static void leapraid_scan_all_dev_after_reset(struct leapraid_adapter *adapter)
leapraid_scan_vol_after_reset(adapter);
}
leapraid_scan_sas_dev_after_reset(adapter);
-
- dev_info(&adapter->pdev->dev, "Devices scan complete\n");
}
static void leapraid_hardreset_async_logic(struct leapraid_adapter *adapter)
@@ -5426,6 +5409,7 @@ static int leapraid_send_enc_cmd(struct leapraid_adapter *adapter,
void *req;
bool reset_flg = false;
int rc;
+ u16 smid;
mutex_lock(&adapter->driver_cmds.enc_cmd.mutex);
rc = leapraid_check_adapter_is_op(adapter, LEAPRAID_DB_WAIT_OP_SHORT,
@@ -5434,21 +5418,19 @@ static int leapraid_send_enc_cmd(struct leapraid_adapter *adapter,
goto unlock;
adapter->driver_cmds.enc_cmd.status = LEAPRAID_CMD_PENDING;
- req = leapraid_get_task_desc(
- adapter,
- adapter->driver_cmds.enc_cmd.inter_taskid);
+ smid = adapter->driver_cmds.enc_cmd.inter_taskid;
+ req = leapraid_get_task_desc(adapter, smid);
memset(req, 0, LEAPRAID_REQUEST_SIZE);
memcpy(req, sep_req, sizeof(struct leapraid_sep_req));
init_completion(&adapter->driver_cmds.enc_cmd.done);
- leapraid_fire_task(adapter,
- adapter->driver_cmds.enc_cmd.inter_taskid);
+ leapraid_fire_task(adapter, smid);
wait_for_completion_timeout(&adapter->driver_cmds.enc_cmd.done,
LEAPRAID_ENC_CMD_TIMEOUT * HZ);
if (!(adapter->driver_cmds.enc_cmd.status & LEAPRAID_CMD_DONE)) {
dev_err(&adapter->pdev->dev,
"%s: SEP command timeout, status=0x%x\n",
__func__, adapter->driver_cmds.enc_cmd.status);
- leapraid_log_req_context(adapter, sep_req);
+ leapraid_log_req_context(adapter, smid, sep_req);
reset_flg =
leapraid_check_reset(
adapter->driver_cmds.enc_cmd.status);
@@ -5512,10 +5494,10 @@ static int leapraid_wait_adapter_recovery(struct leapraid_adapter *adapter)
{
unsigned long flags;
- while (scsi_host_in_recovery(adapter->shost) ||
- adapter->access_ctrl.shost_recovering) {
- if (adapter->access_ctrl.host_removing ||
- adapter->fw_evt_s.fw_evt_cleanup) {
+ while (leapraid_shost_in_recovery(adapter->shost) ||
+ READ_ONCE(adapter->access_ctrl.shost_recovering)) {
+ if (READ_ONCE(adapter->access_ctrl.host_removing) ||
+ READ_ONCE(adapter->fw_evt_s.fw_evt_cleanup)) {
spin_lock_irqsave(
&adapter->reset_desc.adapter_reset_lock,
flags);
@@ -5535,12 +5517,13 @@ static int leapraid_wait_adapter_recovery(struct leapraid_adapter *adapter)
return -EFAULT;
}
- wait_event_timeout(adapter->access_ctrl.recovery_waitq,
- !adapter->access_ctrl.shost_recovering ||
- adapter->access_ctrl.host_removing ||
- adapter->fw_evt_s.fw_evt_cleanup,
- msecs_to_jiffies(1000));
+ wait_event_timeout(
+ adapter->access_ctrl.recovery_waitq,
+ (!leapraid_shost_in_recovery(adapter->shost) &&
+ !READ_ONCE(adapter->access_ctrl.shost_recovering)),
+ msecs_to_jiffies(1000));
}
+
return 0;
}
@@ -5625,7 +5608,6 @@ static void leapraid_sas_dev_stat_chg_evt(
leapraid_get_port_by_id(adapter,
event_data->physical_port,
false));
-
if (!sas_dev || !sas_dev->starget)
goto out_unlock;
@@ -5895,9 +5877,9 @@ static void leapraid_scan_dev_complete(struct leapraid_adapter *adapter)
leapraid_fw_evt_put(fw_evt);
}
-static u8 leapraid_handle_scan_cb(struct leapraid_adapter *adapter,
- struct leapraid_driver_cmd *cmd,
- struct leapraid_rep *rep)
+static void leapraid_handle_scan_cb(struct leapraid_adapter *adapter,
+ struct leapraid_driver_cmd *cmd,
+ struct leapraid_rep *rep)
{
u16 status;
@@ -5905,21 +5887,18 @@ static u8 leapraid_handle_scan_cb(struct leapraid_adapter *adapter,
status = le16_to_cpu(rep->adapter_status) &
LEAPRAID_ADAPTER_STATUS_MASK;
-
if (status != LEAPRAID_ADAPTER_STATUS_SUCCESS)
adapter->scan_dev_desc.scan_dev_failed = 1;
if (!cmd->async_scan_dev) {
complete(&cmd->done);
- return 1;
+ return;
}
if (status == LEAPRAID_ADAPTER_STATUS_SUCCESS)
leapraid_scan_dev_complete(adapter);
else
adapter->scan_dev_desc.scan_start_failed = status;
-
- return 1;
}
static void leapraid_handle_ctl_cb(struct leapraid_adapter *adapter,
@@ -5933,7 +5912,6 @@ static void leapraid_handle_ctl_cb(struct leapraid_adapter *adapter,
return;
scsiio_reply = (struct leapraid_scsiio_rep *)rep;
-
if (!(scsiio_reply->scsi_state &
LEAPRAID_SCSI_STATE_AUTOSENSE_VALID))
return;
@@ -5976,10 +5954,11 @@ static bool leapraid_driver_cmds_done(struct leapraid_adapter *adapter,
memcpy(&_sp_cmd->reply, leap_mpi_rep, reply_len);
_sp_cmd->status |= LEAPRAID_CMD_REPLY_VALID;
- if (_sp_cmd->cb_idx == LEAPRAID_SCAN_DEV_CB_IDX)
- return leapraid_handle_scan_cb(adapter,
- _sp_cmd,
- leap_mpi_rep);
+ if (_sp_cmd->cb_idx == LEAPRAID_SCAN_DEV_CB_IDX) {
+ leapraid_handle_scan_cb(adapter, _sp_cmd,
+ leap_mpi_rep);
+ return true;
+ }
if (_sp_cmd->cb_idx == LEAPRAID_CTL_CB_IDX)
leapraid_handle_ctl_cb(adapter, leap_mpi_rep, taskid);
@@ -6245,7 +6224,6 @@ static int leapraid_host_diag_reset(struct leapraid_adapter *adapter)
{
u32 host_diag;
- dev_info(&adapter->pdev->dev, "Entering host diag reset!\n");
pci_cfg_access_lock(adapter->pdev);
mutex_lock(&adapter->reset_desc.host_diag_mutex);
@@ -6269,14 +6247,13 @@ static int leapraid_host_diag_reset(struct leapraid_adapter *adapter)
goto out_failed;
pci_cfg_access_unlock(adapter->pdev);
- dev_info(&adapter->pdev->dev, "Host diag success!\n");
return 0;
out_cleanup:
mutex_unlock(&adapter->reset_desc.host_diag_mutex);
out_failed:
pci_cfg_access_unlock(adapter->pdev);
- dev_info(&adapter->pdev->dev, "Host diag failed!\n");
+ dev_err(&adapter->pdev->dev, "Host diag failed\n");
return -EFAULT;
}
@@ -6791,11 +6768,8 @@ static void leapraid_search_resp_sas_dev(struct leapraid_adapter *adapter)
struct leapraid_sas_dev_p0 sas_dev_p0;
u32 device_info;
- dev_info(&adapter->pdev->dev,
- "Begin searching for SAS end devices\n");
-
if (list_empty(&adapter->dev_topo.sas_dev_list))
- goto exit_search;
+ return;
cfgp1.form = LEAPRAID_SAS_CFG_PGAD_GET_NEXT_LOOP;
for (cfgp2.handle = 0xFFFF;
@@ -6808,9 +6782,6 @@ static void leapraid_search_resp_sas_dev(struct leapraid_adapter *adapter)
leapraid_mark_resp_sas_dev(adapter, &sas_dev_p0);
}
-exit_search:
- dev_info(&adapter->pdev->dev,
- "SAS end devices searching complete\n");
}
static void leapraid_mark_resp_raid_volume(struct leapraid_adapter *adapter,
@@ -6879,14 +6850,11 @@ static void leapraid_search_resp_raid_volume(struct leapraid_adapter *adapter)
if (!adapter->adapter_attr.raid_support)
return;
- dev_info(&adapter->pdev->dev,
- "Begin searching for RAID volumes\n");
-
spin_lock_irqsave(&adapter->dev_topo.raid_volume_lock, flags);
is_empty = list_empty(&adapter->dev_topo.raid_volume_list);
spin_unlock_irqrestore(&adapter->dev_topo.raid_volume_lock, flags);
if (is_empty)
- goto exit_search;
+ return;
cfgp1.form = LEAPRAID_SAS_CFG_PGAD_GET_NEXT_LOOP;
for (hdl = 0xFFFF, cfgp2.handle = hdl;
@@ -6924,9 +6892,6 @@ static void leapraid_search_resp_raid_volume(struct leapraid_adapter *adapter)
else
set_bit(hdl, adapter->dev_topo.pd_hdls);
}
-exit_search:
- dev_info(&adapter->pdev->dev,
- "RAID volumes searching complete\n");
}
static void leapraid_mark_resp_exp(struct leapraid_adapter *adapter,
@@ -6987,10 +6952,8 @@ static void leapraid_search_resp_exp(struct leapraid_adapter *adapter)
u16 hdl;
u8 port;
- dev_dbg(&adapter->pdev->dev,
- "Begin searching for expanders\n");
if (list_empty(&adapter->dev_topo.exp_list))
- goto exit_search;
+ return;
cfgp1.form = LEAPRAID_SAS_CFG_PGAD_GET_NEXT_LOOP;
for (hdl = 0xFFFF, cfgp2.handle = hdl;
@@ -7008,9 +6971,6 @@ static void leapraid_search_resp_exp(struct leapraid_adapter *adapter)
LEAPRAID_DISABLE_MP_PORT_ID);
leapraid_mark_resp_exp(adapter, &exp_p0);
}
-exit_search:
- dev_dbg(&adapter->pdev->dev,
- "Expander searching complete\n");
}
void leapraid_wait_cmds_done(struct leapraid_adapter *adapter)
@@ -7099,7 +7059,6 @@ int leapraid_hard_reset_handler(struct leapraid_adapter *adapter,
dev_err(&adapter->pdev->dev,
"Previous device scan failed or driver loading\n");
adapter->access_ctrl.host_removing = 1;
- wake_up(&adapter->access_ctrl.recovery_waitq);
rc = -EFAULT;
goto out_cleanup;
}
@@ -7120,8 +7079,8 @@ int leapraid_hard_reset_handler(struct leapraid_adapter *adapter,
leapraid_hardreset_barrier(adapter);
}
out_cleanup:
- dev_info(&adapter->pdev->dev, "Hard reset %s\n",
- rc == 0 ? "SUCCESS" : "FAILED");
+ if (rc)
+ dev_err(&adapter->pdev->dev, "Hard reset failed\n");
spin_lock_irqsave(&adapter->reset_desc.adapter_reset_lock, flags);
adapter->reset_desc.adapter_reset_results = rc;
@@ -7358,8 +7317,8 @@ static void leapraid_map_msix_to_cpu(struct leapraid_adapter *adapter)
{
struct leapraid_int_rq *int_rq;
const cpumask_t *affinity_mask;
+ int cpu;
u32 i;
- u16 cpu;
if (!adapter->adapter_attr.rq_cnt)
return;
@@ -7383,6 +7342,7 @@ static void leapraid_map_msix_to_cpu(struct leapraid_adapter *adapter)
int_rq->rq.msix_idx;
}
}
+ return;
out_apply_irq_affinity:
leapraid_cpus_on_irq(adapter);
}
@@ -7445,7 +7405,6 @@ static int leapraid_setup_irqs(struct leapraid_adapter *adapter)
adapter->notification_desc.iopoll_qdex,
adapter->notification_desc.iopoll_qdex,
PCI_IRQ_MSIX | PCI_IRQ_AFFINITY, NULL);
-
if (rc < 0) {
dev_err(&adapter->pdev->dev,
"%d MSI/MSIX vectors allocated failed!\n",
@@ -7478,7 +7437,6 @@ static int leapraid_setup_irqs(struct leapraid_adapter *adapter)
IRQF_SHARED,
adapter->notification_desc.int_rqs[i].rq.name,
&adapter->notification_desc.int_rqs[i].rq);
-
if (rc) {
dev_err(&adapter->pdev->dev,
"MSI/MSIx: request_irq %s failed!\n",
@@ -7536,8 +7494,6 @@ static int leapraid_setup_legacy_int(struct leapraid_adapter *adapter)
static int leapraid_set_legacy_int(struct leapraid_adapter *adapter)
{
- int rc;
-
adapter->notification_desc.msix_cpu_map_sz = num_online_cpus();
adapter->notification_desc.msix_cpu_map =
kzalloc(adapter->notification_desc.msix_cpu_map_sz,
@@ -7560,9 +7516,7 @@ static int leapraid_set_legacy_int(struct leapraid_adapter *adapter)
if (!adapter->notification_desc.int_rqs)
return -ENOMEM;
- rc = leapraid_setup_legacy_int(adapter);
-
- return rc;
+ return leapraid_setup_legacy_int(adapter);
}
static int leapraid_set_msix(struct leapraid_adapter *adapter)
@@ -7670,9 +7624,7 @@ static int leapraid_set_msix(struct leapraid_adapter *adapter)
return 0;
apply_legacy_int:
- rc = leapraid_set_legacy_int(adapter);
-
- return rc;
+ return leapraid_set_legacy_int(adapter);
}
static int leapraid_set_msi(struct leapraid_adapter *adapter)
@@ -7801,9 +7753,7 @@ static int leapraid_set_msi(struct leapraid_adapter *adapter)
return 0;
apply_legacy_int:
- rc = leapraid_set_legacy_int(adapter);
-
- return rc;
+ return leapraid_set_legacy_int(adapter);
}
static int leapraid_set_notification(struct leapraid_adapter *adapter)
@@ -7886,18 +7836,16 @@ static int leapraid_adapter_unit_reset(struct leapraid_adapter *adapter)
{
int rc = 0;
- dev_info(&adapter->pdev->dev, "fire unit reset\n");
writel(LEAPRAID_FUNC_ADAPTER_UNIT_RESET << LEAPRAID_DB_FUNC_SHIFT,
&adapter->iomem_base->db);
if (leapraid_db_wait_ack_and_clear_int(adapter))
rc = -EFAULT;
if (!leapraid_wait_adapter_ready(adapter)) {
- dev_info(&adapter->pdev->dev, "unit reset: FAILED\n");
+ dev_err(&adapter->pdev->dev, "unit reset failed\n");
return -EFAULT;
}
- dev_info(&adapter->pdev->dev, "unit reset: SUCCESS\n");
return rc;
}
@@ -7905,7 +7853,6 @@ static int leapraid_make_adapter_ready(struct leapraid_adapter *adapter,
enum reset_type type)
{
u32 db;
- int rc;
int count;
if (!leapraid_pci_active(adapter))
@@ -7944,8 +7891,7 @@ static int leapraid_make_adapter_ready(struct leapraid_adapter *adapter,
return 0;
full_reset:
- rc = leapraid_host_diag_reset(adapter);
- return rc;
+ return leapraid_host_diag_reset(adapter);
}
static void leapraid_fw_log_exit(struct leapraid_adapter *adapter)
@@ -8116,15 +8062,13 @@ int leapraid_internal_init_cmd_priv(struct leapraid_adapter *adapter,
return 0;
}
-int leapraid_internal_exit_cmd_priv(struct leapraid_adapter *adapter,
- struct leapraid_io_req_tracker *io_tracker)
+void leapraid_internal_exit_cmd_priv(struct leapraid_adapter *adapter,
+ struct leapraid_io_req_tracker *io_tracker)
{
if (io_tracker && io_tracker->chain)
dma_pool_free(adapter->mem_desc.sg_chain_pool,
io_tracker->chain,
io_tracker->chain_dma);
-
- return 0;
}
static int leapraid_request_host_memory(struct leapraid_adapter *adapter)
@@ -8405,9 +8349,10 @@ static int leapraid_alloc_dev_topo_bitmaps(struct leapraid_adapter *adapter)
{
u16 pd_hdls_sz;
- pd_hdls_sz = adapter->adapter_attr.features.max_dev_handle /
- LEAPRAID_BITS_PER_BYTE;
- pd_hdls_sz++;
+ pd_hdls_sz =
+ BITS_TO_LONGS(
+ adapter->adapter_attr.features.max_dev_handle + 1) *
+ sizeof(unsigned long);
adapter->dev_topo.pd_hdls_sz = pd_hdls_sz;
adapter->dev_topo.pd_hdls =
@@ -8643,48 +8588,52 @@ static int leapraid_cfg_pages(struct leapraid_adapter *adapter)
{
union cfg_param_1 cfgp1 = {0};
union cfg_param_2 cfgp2 = {0};
- struct leapraid_manufacturing_p0 manufacturing_page0;
- struct leapraid_bios_page3 bios_page3;
- struct leapraid_bios_page2 bios_page2;
+ union {
+ struct leapraid_manufacturing_p0 manufacturing_page0;
+ struct leapraid_bios_page3 bios_page3;
+ struct leapraid_bios_page2 bios_page2;
+ } cfg_page;
int rc;
- rc = leapraid_op_config_page(adapter, &bios_page3, cfgp1,
+ rc = leapraid_op_config_page(adapter, &cfg_page.bios_page3, cfgp1,
cfgp2, GET_BIOS_PG3);
if (rc)
return rc;
- rc = leapraid_op_config_page(adapter, &bios_page2, cfgp1,
- cfgp2, GET_BIOS_PG2);
- if (rc)
- return rc;
+ adapter->adapter_attr.bios_version =
+ le32_to_cpu(cfg_page.bios_page3.bios_version);
- rc = leapraid_op_config_page(adapter, &manufacturing_page0, cfgp1,
- cfgp2, GET_MANUFACTURING_PG0);
+ rc = leapraid_op_config_page(adapter, &cfg_page.bios_page2, cfgp1,
+ cfgp2, GET_BIOS_PG2);
if (rc)
return rc;
- adapter->adapter_attr.bios_version =
- le32_to_cpu(bios_page3.bios_version);
- snprintf(adapter->adapter_attr.board_name,
- sizeof(adapter->adapter_attr.board_name),
- "%.*s",
- (int)sizeof(manufacturing_page0.board_name),
- manufacturing_page0.board_name);
adapter->boot_devs.requested_boot_dev.form =
- bios_page2.requested_boot_dev_form;
+ cfg_page.bios_page2.requested_boot_dev_form;
memcpy(adapter->boot_devs.requested_boot_dev.pg_dev,
- &bios_page2.requested_boot_dev,
+ &cfg_page.bios_page2.requested_boot_dev,
LEAPRAID_BOOT_DEV_SIZE);
adapter->boot_devs.requested_alt_boot_dev.form =
- bios_page2.requested_alt_boot_dev_form;
+ cfg_page.bios_page2.requested_alt_boot_dev_form;
memcpy(adapter->boot_devs.requested_alt_boot_dev.pg_dev,
- &bios_page2.requested_alt_boot_dev,
+ &cfg_page.bios_page2.requested_alt_boot_dev,
LEAPRAID_BOOT_DEV_SIZE);
adapter->boot_devs.current_boot_dev.form =
- bios_page2.current_boot_dev_form;
+ cfg_page.bios_page2.current_boot_dev_form;
memcpy(adapter->boot_devs.current_boot_dev.pg_dev,
- &bios_page2.current_boot_dev,
+ &cfg_page.bios_page2.current_boot_dev,
LEAPRAID_BOOT_DEV_SIZE);
+
+ rc = leapraid_op_config_page(adapter, &cfg_page.manufacturing_page0,
+ cfgp1, cfgp2, GET_MANUFACTURING_PG0);
+ if (rc)
+ return rc;
+
+ snprintf(adapter->adapter_attr.board_name,
+ sizeof(adapter->adapter_attr.board_name),
+ "%.*s",
+ (int)sizeof(cfg_page.manufacturing_page0.board_name),
+ cfg_page.manufacturing_page0.board_name);
return rc;
}
@@ -8793,8 +8742,6 @@ int leapraid_scan_dev(struct leapraid_adapter *adapter, bool async_scan_dev)
out_cleanup:
adapter->driver_cmds.scan_dev_cmd.status = LEAPRAID_CMD_NOT_USED;
- dev_info(&adapter->pdev->dev,
- "Device scan %s\n", rc == 0 ? "SUCCESS" : "FAILED");
return rc;
}
@@ -8936,11 +8883,7 @@ static int leapraid_make_adapter_available(struct leapraid_adapter *adapter)
return 0;
}
- rc = leapraid_scan_dev(adapter, false);
- if (rc)
- return rc;
-
- return rc;
+ return leapraid_scan_dev(adapter, false);
}
int leapraid_ctrl_init(struct leapraid_adapter *adapter)
@@ -9006,7 +8949,6 @@ int leapraid_ctrl_init(struct leapraid_adapter *adapter)
out_free:
adapter->access_ctrl.host_removing = 1;
- wake_up(&adapter->access_ctrl.recovery_waitq);
leapraid_fw_log_exit(adapter);
leapraid_free_internal_scsi_cmd(adapter);
leapraid_disable_controller(adapter);
diff --git a/drivers/scsi/leapraid/leapraid_func.h b/drivers/scsi/leapraid/leapraid_func.h
index df61bc2e994a..6cd550756501 100644
--- a/drivers/scsi/leapraid/leapraid_func.h
+++ b/drivers/scsi/leapraid/leapraid_func.h
@@ -51,11 +51,11 @@
#define LEAPRAID_BOARD_NAME_LENGTH 17
#define LEAPRAID_AUTHOR "LeapIO Inc."
#define LEAPRAID_DESCRIPTION "LeapRAID Driver"
-#define LEAPRAID_DRIVER_VERSION "2.00.01.02"
+#define LEAPRAID_DRIVER_VERSION "2.00.01.05"
#define LEAPRAID_MAJOR_VERSION 2
#define LEAPRAID_MINOR_VERSION 00
#define LEAPRAID_BUILD_VERSION 01
-#define LEAPRAID_RELEASE_VERSION 02
+#define LEAPRAID_RELEASE_VERSION 05
#define LEAPRAID_MSG_VERSION 0x1021
#define LEAPRAID_HEADER_VERSION 0x0000
@@ -127,7 +127,6 @@
/* SMP (Serial Management Protocol). */
#define LEAPRAID_SMP_PT_FLAG_SGL_PTR 0x80
-#define LEAPRAID_SMP_FN_REPORT_PHY_ERR_LOG 0x91
#define LEAPRAID_SMP_FRAME_HEADER_SIZE 4
#define LEAPRAID_SCSI_HOST_SHIFT 16
#define LEAPRAID_SCSI_DRIVER_SHIFT 24
@@ -171,13 +170,9 @@
/* Basic constants and limits. */
#define LEAPRAID_BUSY_LIMIT 1
-#define LEAPRAID_INDEX_FIRST 0
-#define LEAPRAID_BITS_PER_BYTE 8
#define LEAPRAID_INVALID_HOST_DIAG_VAL 0xFFFFFFFF
/* Retry/Sleep configuration. */
-#define LEAPRAID_WRITE_SEQUENCE_OFFSET 0x4
-#define LEAPRAID_WRSEQ_KEY_VALUE_MASK 0xF
#define LEAPRAID_WRSEQ_FLUSH_KEY_VALUE 0x0
#define LEAPRAID_WRSEQ_1ST_KEY_VALUE 0xF
#define LEAPRAID_WRSEQ_2ND_KEY_VALUE 0x4
@@ -187,7 +182,6 @@
#define LEAPRAID_WRSEQ_6TH_KEY_VALUE 0xD
#define LEAPRAID_UNLOCK_RETRY_LIMIT 20
#define LEAPRAID_UNLOCK_SLEEP_MS 100
-#define LEAPRAID_MSLEEP_SHORT_MS 50
#define LEAPRAID_MSLEEP_NORMAL_MS 100
#define LEAPRAID_MSLEEP_EXTRA_LONG_MS 500
#define LEAPRAID_IO_POLL_DELAY_US 500
@@ -198,7 +192,6 @@
#define LEAPRAID_INVALID_DEV_HANDLE 0xFFFF
/* Commands queue depth. */
-#define LEAPRAID_COALESCING_DEPTH_MAX 256
#define LEAPRAID_DEFAULT_CMD_QD_OFFSET 64
#define LEAPRAID_REPLY_QD_ALIGNMENT 16
/* Task ID offset. */
@@ -224,7 +217,6 @@
#define LEAPRAID_CTL_CMD_TIMEOUT LEAPRAID_UNIFIED_TIMEOUT
#define LEAPRAID_SCAN_DEV_CMD_TIMEOUT 300
#define LEAPRAID_TIMESTAMP_SYNC_CMD_TIMEOUT LEAPRAID_UNIFIED_TIMEOUT
-#define LEAPRAID_RAID_ACTION_CMD_TIMEOUT LEAPRAID_UNIFIED_TIMEOUT
#define LEAPRAID_ENC_CMD_TIMEOUT LEAPRAID_UNIFIED_TIMEOUT
#define LEAPRAID_IO_CMD_TIMEOUT LEAPRAID_UNIFIED_TIMEOUT
#define LEAPRAID_NOTIFY_EVENT_CMD_TIMEOUT LEAPRAID_UNIFIED_TIMEOUT
@@ -599,6 +591,7 @@ struct leapraid_fw_evt_work {
* @leapraid_evt_masks: Array of event masks for filtering firmware events.
*/
struct leapraid_fw_evt_struct {
+ u32 leapraid_evt_masks[4];
char fw_evt_name[48];
struct workqueue_struct *fw_evt_thread;
spinlock_t fw_evt_lock; /* protects firmware event */
@@ -606,7 +599,6 @@ struct leapraid_fw_evt_struct {
struct leapraid_fw_evt_work *cur_evt;
struct task_struct *cur_evt_task;
u8 fw_evt_cleanup;
- u32 leapraid_evt_masks[4];
};
/**
@@ -1446,7 +1438,7 @@ int leapraid_get_volume_cap(struct leapraid_adapter *adapter,
int leapraid_internal_init_cmd_priv(
struct leapraid_adapter *adapter,
struct leapraid_io_req_tracker *io_tracker);
-int leapraid_internal_exit_cmd_priv(
+void leapraid_internal_exit_cmd_priv(
struct leapraid_adapter *adapter,
struct leapraid_io_req_tracker *io_tracker);
void leapraid_clean_active_fw_evt(struct leapraid_adapter *adapter);
@@ -1517,7 +1509,7 @@ int leapraid_op_config_page(struct leapraid_adapter *adapter,
void *cfgp, union cfg_param_1 cfgp1,
union cfg_param_2 cfgp2,
enum config_page_action cfg_op);
-void leapraid_log_req_context(struct leapraid_adapter *adapter,
+void leapraid_log_req_context(struct leapraid_adapter *adapter, u16 smid,
const void *req_data);
int leapraid_change_queue_depth(struct scsi_device *sdev, int qdepth);
diff --git a/drivers/scsi/leapraid/leapraid_os.c b/drivers/scsi/leapraid/leapraid_os.c
index c60c5d80c7b3..a69b8c6938a3 100644
--- a/drivers/scsi/leapraid/leapraid_os.c
+++ b/drivers/scsi/leapraid/leapraid_os.c
@@ -157,9 +157,8 @@ static int leapraid_tm_post_processing(struct leapraid_adapter *adapter,
leapraid_sync_irqs(adapter, true);
leapraid_unmask_int(adapter);
- rc = leapraid_tm_cmd_map_status(adapter, channel, id, lun, type,
- taskid_task);
- return rc;
+ return leapraid_tm_cmd_map_status(adapter, channel, id, lun, type,
+ taskid_task);
}
static void leapraid_build_tm_req(struct leapraid_scsi_tm_req *scsi_tm_req,
@@ -185,6 +184,7 @@ int leapraid_issue_tm(struct leapraid_adapter *adapter, u16 hdl, uint channel,
struct leapraid_scsiio_req *scsiio_req;
struct leapraid_io_req_tracker *io_req_tracker = NULL;
u16 msix_task;
+ u16 taskid;
bool issue_reset = false;
u32 db;
int rc;
@@ -239,16 +239,15 @@ int leapraid_issue_tm(struct leapraid_adapter *adapter, u16 hdl, uint channel,
msix_task = io_req_tracker->msix_io;
else
msix_task = 0;
- leapraid_fire_hpr_task(adapter,
- adapter->driver_cmds.tm_cmd.hp_taskid,
- msix_task);
+ taskid = adapter->driver_cmds.tm_cmd.hp_taskid;
+ leapraid_fire_hpr_task(adapter, taskid, msix_task);
wait_for_completion_timeout(&adapter->driver_cmds.tm_cmd.done,
LEAPRAID_TM_CMD_TIMEOUT * HZ);
if (!(adapter->driver_cmds.tm_cmd.status & LEAPRAID_CMD_DONE)) {
dev_err(&adapter->pdev->dev,
"%s: TM cmd timeout, status=0x%x\n",
__func__, adapter->driver_cmds.tm_cmd.status);
- leapraid_log_req_context(adapter, scsi_tm_req);
+ leapraid_log_req_context(adapter, taskid, scsi_tm_req);
issue_reset =
leapraid_check_reset(
adapter->driver_cmds.tm_cmd.status);
@@ -644,7 +643,6 @@ static void leapraid_probe_sas(struct leapraid_adapter *adapter)
sas_dev->hdl,
sas_dev->parent_sas_addr,
sas_dev->card_port);
-
if (!added)
goto remove_dev;
@@ -805,10 +803,7 @@ static inline bool leapraid_is_scmd_permitted(struct leapraid_adapter *adapter,
return false;
opcode = scmd->cmnd[0];
- if (opcode == SYNCHRONIZE_CACHE || opcode == START_STOP)
- return true;
-
- return false;
+ return opcode == SYNCHRONIZE_CACHE || opcode == START_STOP;
}
return true;
}
@@ -1101,13 +1096,15 @@ static int leapraid_error_handler(struct scsi_cmnd *scmd,
out_eh_done:
if (type == LEAPRAID_TM_TASKTYPE_ABORT_TASK) {
- dev_info(&adapter->pdev->dev,
- "EH ABORT result: %s, scmd=0x%p\n",
- rc == SUCCESS ? "success" : "failed", scmd);
+ if (rc)
+ dev_err(&adapter->pdev->dev,
+ "EH ABORT result: failed, scmd=0x%p\n",
+ scmd);
} else {
- dev_info(&adapter->pdev->dev,
- "EH %s result: %s, scmd=0x%p\n",
- str, rc == SUCCESS ? "success" : "failed", scmd);
+ if (rc)
+ dev_err(&adapter->pdev->dev,
+ "EH %s result: failed, scmd=0x%p\n",
+ str, scmd);
if (sas_dev)
leapraid_sdev_put(sas_dev);
}
@@ -1161,8 +1158,10 @@ static int leapraid_eh_host_reset_handler(struct scsi_cmnd *scmd)
rc = SUCCESS;
out_host_reset_done:
- dev_info(&adapter->pdev->dev, "EH HOST RESET result: %s, scmd=0x%p\n",
- rc == SUCCESS ? "success" : "failed", scmd);
+ if (rc)
+ dev_err(&adapter->pdev->dev,
+ "EH HOST RESET result: failed, scmd=0x%p\n",
+ scmd);
return rc;
}
@@ -1227,7 +1226,7 @@ static int leapraid_slave_alloc(struct scsi_device *sdev)
return 0;
}
-static int leapraid_slave_cfg_volume(struct scsi_device *sdev)
+static bool leapraid_slave_cfg_volume(struct scsi_device *sdev)
{
struct Scsi_Host *shost = sdev->host;
struct leapraid_adapter *adapter = shost_priv(shost);
@@ -1276,10 +1275,10 @@ static int leapraid_slave_cfg_volume(struct scsi_device *sdev)
return 0;
}
-static int leapraid_slave_configure_extra(struct scsi_device *sdev,
- struct leapraid_sas_dev **psas_dev,
- u16 vol_hdl, u64 volume_wwid,
- bool *is_target_ssp, int *qd)
+static bool leapraid_slave_configure_extra(struct scsi_device *sdev,
+ struct leapraid_sas_dev **psas_dev,
+ u16 vol_hdl, u64 volume_wwid,
+ bool *is_target_ssp, int *qd)
{
struct leapraid_sas_dev *sas_dev;
struct leapraid_sdev_priv *sdev_priv;
@@ -1586,11 +1585,9 @@ static bool leapraid_scan_check_status(struct leapraid_adapter *adapter,
wake_up(&adapter->scan_dev_desc.wait_driver_loading);
adapter->scan_dev_desc.wait_scan_dev_done = 0;
adapter->access_ctrl.host_removing = 1;
- wake_up(&adapter->access_ctrl.recovery_waitq);
return true;
}
- dev_info(&adapter->pdev->dev, "Device scan: SUCCESS\n");
adapter->driver_cmds.scan_dev_cmd.status = LEAPRAID_CMD_NOT_USED;
leapraid_scan_dev_done(adapter);
return true;
@@ -2206,7 +2203,6 @@ static void leapraid_remove(struct pci_dev *pdev)
!atomic_read(&adapter->overheat_desc.thermal_alert));
adapter->access_ctrl.host_removing = 1;
- wake_up(&adapter->access_ctrl.recovery_waitq);
leapraid_wait_cmds_done(adapter);
@@ -2247,7 +2243,6 @@ static void leapraid_shutdown(struct pci_dev *pdev)
}
adapter->access_ctrl.host_removing = 1;
- wake_up(&adapter->access_ctrl.recovery_waitq);
leapraid_wait_cmds_done(adapter);
leapraid_clean_active_fw_evt(adapter);
leapraid_overheat_cleanup(adapter);
@@ -2334,7 +2329,6 @@ static pci_ers_result_t leapraid_pci_slot_reset(struct pci_dev *pdev)
dev_err(&pdev->dev, "%s PCI error slot reset\n",
adapter->adapter_attr.name);
- adapter->access_ctrl.pcie_recovering = 0;
adapter->pdev = pdev;
pci_restore_state(pdev);
if (leapraid_set_pcie_and_notification(adapter)) {
@@ -2344,13 +2338,15 @@ static pci_ers_result_t leapraid_pci_slot_reset(struct pci_dev *pdev)
return PCI_ERS_RESULT_DISCONNECT;
}
+ adapter->access_ctrl.pcie_recovering = 0;
dev_info(&pdev->dev, "%s: Hard reset triggered by PCI slot reset\n",
adapter->adapter_attr.name);
dev_info(&adapter->pdev->dev, "%s: %d: call hard_reset\n",
__func__, __LINE__);
rc = leapraid_hard_reset_handler(adapter, FULL_RESET);
- dev_info(&pdev->dev, "%s hard reset: %s\n",
- adapter->adapter_attr.name, rc == 0 ? "success" : "failed");
+ if (rc)
+ dev_err(&pdev->dev, "%s hard reset: failed\n",
+ adapter->adapter_attr.name);
return rc == 0 ? PCI_ERS_RESULT_RECOVERED :
PCI_ERS_RESULT_DISCONNECT;
@@ -2367,6 +2363,7 @@ static void leapraid_pci_resume(struct pci_dev *pdev)
}
dev_err(&pdev->dev, "PCI error resume!\n");
+
pci_aer_clear_nonfatal_status(pdev);
leapraid_check_scheduled_fault_start(adapter);
leapraid_fw_log_start(adapter);
diff --git a/drivers/scsi/leapraid/leapraid_transport.c b/drivers/scsi/leapraid/leapraid_transport.c
index 738bc55df416..e175ca4c1264 100644
--- a/drivers/scsi/leapraid/leapraid_transport.c
+++ b/drivers/scsi/leapraid/leapraid_transport.c
@@ -298,6 +298,7 @@ static int leapraid_transport_exp_report_manu(struct leapraid_adapter *adapter,
dma_addr_t c2h_dma_addr;
bool issue_reset = false;
void *data_out = NULL;
+ u16 inter_taskid;
size_t c2h_size;
size_t h2c_size;
void *psge;
@@ -338,10 +339,8 @@ static int leapraid_transport_exp_report_manu(struct leapraid_adapter *adapter,
rep_manu_request->allocated_response_length = 0;
rep_manu_request->request_length = 0;
- smp_passthrough_req =
- leapraid_get_task_desc(
- adapter,
- adapter->driver_cmds.transport_cmd.inter_taskid);
+ inter_taskid = adapter->driver_cmds.transport_cmd.inter_taskid;
+ smp_passthrough_req = leapraid_get_task_desc(adapter, inter_taskid);
memset(smp_passthrough_req, 0,
sizeof(struct leapraid_smp_passthrough_req));
smp_passthrough_req->func = LEAPRAID_FUNC_SMP_PASSTHROUGH;
@@ -354,8 +353,7 @@ static int leapraid_transport_exp_report_manu(struct leapraid_adapter *adapter,
c2h_dma_addr, c2h_size);
init_completion(&adapter->driver_cmds.transport_cmd.done);
- leapraid_fire_task(adapter,
- adapter->driver_cmds.transport_cmd.inter_taskid);
+ leapraid_fire_task(adapter, inter_taskid);
wait_for_completion_timeout(&adapter->driver_cmds.transport_cmd.done,
LEAPRAID_TRANSPORT_CMD_TIMEOUT * HZ);
if (!(adapter->driver_cmds.transport_cmd.status & LEAPRAID_CMD_DONE)) {
@@ -363,7 +361,8 @@ static int leapraid_transport_exp_report_manu(struct leapraid_adapter *adapter,
dev_err(&adapter->pdev->dev,
"%s: SMP passthrough timeout, st=0x%x\n",
__func__, adapter->driver_cmds.transport_cmd.status);
- leapraid_log_req_context(adapter, smp_passthrough_req);
+ leapraid_log_req_context(adapter, inter_taskid,
+ smp_passthrough_req);
if (!(adapter->driver_cmds.transport_cmd.status &
LEAPRAID_CMD_RESET))
issue_reset = true;
@@ -1249,20 +1248,21 @@ static void leapraid_build_smp_task(struct leapraid_adapter *adapter,
static int leapraid_send_smp_req(struct leapraid_adapter *adapter)
{
const struct leapraid_smp_passthrough_req *smp_passthrough_req;
+ u16 inter_taskid;
dev_dbg(&adapter->pdev->dev,
"%s: Sending smp request\n", __func__);
- smp_passthrough_req = leapraid_get_task_desc(
- adapter, adapter->driver_cmds.transport_cmd.inter_taskid);
+ inter_taskid = adapter->driver_cmds.transport_cmd.inter_taskid;
+ smp_passthrough_req = leapraid_get_task_desc(adapter, inter_taskid);
init_completion(&adapter->driver_cmds.transport_cmd.done);
- leapraid_fire_task(adapter,
- adapter->driver_cmds.transport_cmd.inter_taskid);
+ leapraid_fire_task(adapter, inter_taskid);
wait_for_completion_timeout(&adapter->driver_cmds.transport_cmd.done,
LEAPRAID_TRANSPORT_CMD_TIMEOUT * HZ);
if (!(adapter->driver_cmds.transport_cmd.status & LEAPRAID_CMD_DONE)) {
dev_err(&adapter->pdev->dev, "%s: timeout, st=0x%x\n",
__func__, adapter->driver_cmds.transport_cmd.status);
- leapraid_log_req_context(adapter, smp_passthrough_req);
+ leapraid_log_req_context(adapter, inter_taskid,
+ smp_passthrough_req);
if (!(adapter->driver_cmds.transport_cmd.status &
LEAPRAID_CMD_RESET)) {
dev_dbg(&adapter->pdev->dev,
--
2.25.1
2
1
02 Jul '26
From: Mingyu Wang <25181214217(a)stu.xidian.edu.cn>
stable inclusion
from stable-v6.6.143
commit aa6ef734016912653a909477fb30aeb66c98b3a2
category: bugfix
bugzilla: https://atomgit.com/src-openeuler/kernel/issues/15650
CVE: CVE-2026-52948
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id…
--------------------------------
commit 617eb7c0961a8dfcfc811844a6396e406b2923ea upstream.
While fuzzing with Syzkaller, a persistent `schedule_timeout: wrong
timeout value` warning was observed, accompanied by SMBus controller
state machine corruption.
The I2C_TIMEOUT ioctl accepts a user-provided timeout in multiples of
10 ms. The user argument is checked against INT_MAX, but it is
subsequently multiplied by 10 before being passed to msecs_to_jiffies().
A malicious user can pass a large value (e.g., 429496729) that passes
the `arg > INT_MAX` check but overflows when multiplied by 10. This
results in a truncated 32-bit unsigned value that bypasses the
internal `(int)m < 0` check in `msecs_to_jiffies()`.
The truncated value is then assigned to `client->adapter->timeout`
(a signed 32-bit int), which is reinterpreted as a negative number.
When passed to wait_for_completion_timeout(), this negative value
undergoes sign extension to a 64-bit unsigned long, triggering the
`schedule_timeout` warning and causing premature returns. This leaves
the SMBus state machine in an unrecoverable state, constituting a
local Denial of Service (DoS).
Fix this by bounding the user argument to `INT_MAX / 10`.
Signed-off-by: Mingyu Wang <25181214217(a)stu.xidian.edu.cn>
[wsa: move the comment as well]
Signed-off-by: Wolfram Sang <wsa+renesas(a)sang-engineering.com>
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Signed-off-by: Yin Tirui <yintirui(a)huawei.com>
---
drivers/i2c/i2c-dev.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 7d337380a05d..2ee07fc675d6 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -476,12 +476,13 @@ static long i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
client->adapter->retries = arg;
break;
case I2C_TIMEOUT:
- if (arg > INT_MAX)
+ /*
+ * For historical reasons, user-space sets the timeout value in
+ * units of 10 ms.
+ */
+ if (arg > INT_MAX / 10)
return -EINVAL;
- /* For historical reasons, user-space sets the timeout
- * value in units of 10 ms.
- */
client->adapter->timeout = msecs_to_jiffies(arg * 10);
break;
default:
--
2.43.0
2
1
02 Jul '26
From: Cássio Gabriel <cassiogabrielcontato(a)gmail.com>
stable inclusion
from stable-v5.10.258
commit e2f1260a056eb3215c13c48c5378f3e4112dc3af
category: bugfix
bugzilla: https://atomgit.com/src-openeuler/kernel/issues/15665
CVE: CVE-2026-52963
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id…
--------------------------------
commit d6854daa67be623860f4e1873fd3d3c275aba4ed upstream.
snd_usbmidi_get_ms_info() validates the internal MIDIStreaming endpoint
descriptor size before using baAssocJackID[], but the descriptor walker can
still return a class-specific endpoint descriptor whose bLength exceeds the
remaining bytes in the endpoint-extra scan.
That leaves later flexible-array reads bounded by bLength, but not by the
remaining bytes in the endpoint-extra scan.
Stop walking when bLength is zero or
extends past the remaining endpoint-extra scan.
Fixes: 5c6cd7021a05 ("ALSA: usb-audio: Fix case when USB MIDI interface has more than one extra endpoint descriptor")
Cc: stable(a)vger.kernel.org
Signed-off-by: Cássio Gabriel <cassiogabrielcontato(a)gmail.com>
Link: https://patch.msgid.link/20260507-usb-midi-endpoint-scan-bounds-v1-1-329d73…
Signed-off-by: Takashi Iwai <tiwai(a)suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Signed-off-by: Lin Ruifeng <linruifeng4(a)huawei.com>
---
sound/usb/midi.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/sound/usb/midi.c b/sound/usb/midi.c
index b02e1a33304f..12c35cb0a707 100644
--- a/sound/usb/midi.c
+++ b/sound/usb/midi.c
@@ -1838,15 +1838,17 @@ static struct usb_ms_endpoint_descriptor *find_usb_ms_endpoint_descriptor(
while (extralen > 3) {
struct usb_ms_endpoint_descriptor *ms_ep =
(struct usb_ms_endpoint_descriptor *)extra;
+ int length = ms_ep->bLength;
- if (ms_ep->bLength > 3 &&
+ if (!length || length > extralen)
+ break;
+
+ if (length > 3 &&
ms_ep->bDescriptorType == USB_DT_CS_ENDPOINT &&
ms_ep->bDescriptorSubtype == UAC_MS_GENERAL)
return ms_ep;
- if (!extra[0])
- break;
- extralen -= extra[0];
- extra += extra[0];
+ extralen -= length;
+ extra += length;
}
return NULL;
}
--
2.34.1
2
1
02 Jul '26
From: Danilo Krummrich <dakr(a)kernel.org>
stable inclusion
from stable-v6.12.91
commit 4911b836f35c034c36f102db4ecbe339b38e7d1d
category: bugfix
bugzilla: https://atomgit.com/src-openeuler/kernel/issues/15812
CVE: CVE-2026-53115
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id…
--------------------------------
[ Upstream commit 6c8dfb0362732bf1e4829867a2a5239fedc592d0 ]
When a driver is probed through __driver_attach(), the bus' match()
callback is called without the device lock held, thus accessing the
driver_override field without a lock, which can cause a UAF.
Fix this by using the driver-core driver_override infrastructure taking
care of proper locking internally.
Note that calling match() from __driver_attach() without the device lock
held is intentional. [1]
Tested-by: Ioana Ciornei <ioana.ciornei(a)nxp.com>
Acked-by: Ioana Ciornei <ioana.ciornei(a)nxp.com>
Acked-by: Christophe Leroy (CS GROUP) <chleroy(a)kernel.org>
Link: https://lore.kernel.org/driver-core/DGRGTIRHA62X.3RY09D9SOK77P@kernel.org/ [1]
Reported-by: Gui-Dong Han <hanguidong02(a)gmail.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220789
Fixes: 1f86a00c1159 ("bus/fsl-mc: add support for 'driver_override' in the mc-bus")
Link: https://patch.msgid.link/20260324005919.2408620-3-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr(a)kernel.org>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
Conflicts:
drivers/bus/fsl-mc/fsl-mc-bus.c
[Context Conflicts]
Signed-off-by: Lin Ruifeng <linruifeng4(a)huawei.com>
---
drivers/bus/fsl-mc/fsl-mc-bus.c | 43 +++++--------------------------
drivers/vfio/fsl-mc/vfio_fsl_mc.c | 4 +--
include/linux/fsl/mc.h | 4 ---
3 files changed, 8 insertions(+), 43 deletions(-)
diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c
index 0806c8215675..4e45d92060fe 100644
--- a/drivers/bus/fsl-mc/fsl-mc-bus.c
+++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
@@ -86,12 +86,16 @@ static int fsl_mc_bus_match(struct device *dev, struct device_driver *drv)
struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(drv);
bool found = false;
+ int ret;
/* When driver_override is set, only bind to the matching driver */
- if (mc_dev->driver_override) {
- found = !strcmp(mc_dev->driver_override, mc_drv->driver.name);
+ ret = device_match_driver_override(dev, drv);
+ if (ret > 0) {
+ found = true;
goto out;
}
+ if (ret == 0)
+ goto out;
if (!mc_drv->match_id_table)
goto out;
@@ -180,39 +184,8 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
}
static DEVICE_ATTR_RO(modalias);
-static ssize_t driver_override_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
- int ret;
-
- if (WARN_ON(dev->bus != &fsl_mc_bus_type))
- return -EINVAL;
-
- ret = driver_set_override(dev, &mc_dev->driver_override, buf, count);
- if (ret)
- return ret;
-
- return count;
-}
-
-static ssize_t driver_override_show(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
- ssize_t len;
-
- device_lock(dev);
- len = snprintf(buf, PAGE_SIZE, "%s\n", mc_dev->driver_override);
- device_unlock(dev);
- return len;
-}
-static DEVICE_ATTR_RW(driver_override);
-
static struct attribute *fsl_mc_dev_attrs[] = {
&dev_attr_modalias.attr,
- &dev_attr_driver_override.attr,
NULL,
};
@@ -315,6 +288,7 @@ ATTRIBUTE_GROUPS(fsl_mc_bus);
struct bus_type fsl_mc_bus_type = {
.name = "fsl-mc",
+ .driver_override = true,
.match = fsl_mc_bus_match,
.uevent = fsl_mc_bus_uevent,
.dma_configure = fsl_mc_dma_configure,
@@ -924,9 +898,6 @@ static struct notifier_block fsl_mc_nb;
*/
void fsl_mc_device_remove(struct fsl_mc_device *mc_dev)
{
- kfree(mc_dev->driver_override);
- mc_dev->driver_override = NULL;
-
/*
* The device-specific remove callback will get invoked by device_del()
*/
diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
index f65d91c01f2e..03600872c480 100644
--- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c
+++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
@@ -430,9 +430,7 @@ static int vfio_fsl_mc_bus_notifier(struct notifier_block *nb,
if (action == BUS_NOTIFY_ADD_DEVICE &&
vdev->mc_dev == mc_cont) {
- mc_dev->driver_override = kasprintf(GFP_KERNEL, "%s",
- vfio_fsl_mc_ops.name);
- if (!mc_dev->driver_override)
+ if (device_set_driver_override(dev, vfio_fsl_mc_ops.name))
dev_warn(dev, "VFIO_FSL_MC: Setting driver override for device in dprc %s failed\n",
dev_name(&mc_cont->dev));
else
diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h
index a1b3de87a3d1..7a19f5a1cbcf 100644
--- a/include/linux/fsl/mc.h
+++ b/include/linux/fsl/mc.h
@@ -178,9 +178,6 @@ struct fsl_mc_obj_desc {
* @regions: pointer to array of MMIO region entries
* @irqs: pointer to array of pointers to interrupts allocated to this device
* @resource: generic resource associated with this MC object device, if any.
- * @driver_override: driver name to force a match; do not set directly,
- * because core frees it; use driver_set_override() to
- * set or clear it.
*
* Generic device object for MC object devices that are "attached" to a
* MC bus.
@@ -214,7 +211,6 @@ struct fsl_mc_device {
struct fsl_mc_device_irq **irqs;
struct fsl_mc_resource *resource;
struct device_link *consumer_link;
- const char *driver_override;
};
#define to_fsl_mc_device(_dev) \
--
2.34.1
2
1
[PATCH OLK-6.6] iommu/amd: Fix clone_alias() to use the original device's devid
by Zhang Yuwei 02 Jul '26
by Zhang Yuwei 02 Jul '26
02 Jul '26
From: Vasant Hegde <vasant.hegde(a)amd.com>
mainline inclusion
from mainline-v7.1-rc1
commit faad224fe0f0857a04ff2eb3c90f0de57f47d0f3
category: bugfix
bugzilla: https://atomgit.com/src-openeuler/kernel/issues/15755
CVE: CVE-2026-53053
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?…
--------------------------------
Currently clone_alias() assumes first argument (pdev) is always the
original device pointer. This function is called by
pci_for_each_dma_alias() which based on topology decides to send
original or alias device details in first argument.
This meant that the source devid used to look up and copy the DTE
may be incorrect, leading to wrong or stale DTE entries being
propagated to alias device.
Fix this by passing the original pdev as the opaque data argument to
both the direct clone_alias() call and pci_for_each_dma_alias(). Inside
clone_alias(), retrieve the original device from data and compute devid
from it.
Fixes: 3332364e4ebc ("iommu/amd: Support multiple PCI DMA aliases in device table")
Signed-off-by: Vasant Hegde <vasant.hegde(a)amd.com>
Signed-off-by: Joerg Roedel <joerg.roedel(a)amd.com>
Conflicts:
drivers/iommu/amd/iommu.c
[context conflict]
Signed-off-by: Zhang Yuwei <zhangyuwei20(a)huawei.com>
---
drivers/iommu/amd/iommu.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 72022dfb1c0d..d0ffc64204fc 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -353,11 +353,12 @@ struct iommu_dev_data *search_dev_data(struct amd_iommu *iommu, u16 devid)
return NULL;
}
-static int clone_alias(struct pci_dev *pdev, u16 alias, void *data)
+static int clone_alias(struct pci_dev *pdev_origin, u16 alias, void *data)
{
struct dev_table_entry new;
struct amd_iommu *iommu;
struct iommu_dev_data *dev_data, *alias_data;
+ struct pci_dev *pdev = data;
u16 devid = pci_dev_id(pdev);
int ret = 0;
@@ -404,9 +405,9 @@ static void clone_aliases(struct amd_iommu *iommu, struct device *dev)
* part of the PCI DMA aliases if it's bus differs
* from the original device.
*/
- clone_alias(pdev, iommu->pci_seg->alias_table[pci_dev_id(pdev)], NULL);
+ clone_alias(pdev, iommu->pci_seg->alias_table[pci_dev_id(pdev)], pdev);
- pci_for_each_dma_alias(pdev, clone_alias, NULL);
+ pci_for_each_dma_alias(pdev, clone_alias, pdev);
}
static void setup_aliases(struct amd_iommu *iommu, struct device *dev)
--
2.22.0
2
1
02 Jul '26
From: Takashi Iwai <tiwai(a)suse.de>
stable inclusion
from stable-v5.10.259
commit 92ad2d7f80cad43b046f093e808e11fe919d304a
category: bugfix
bugzilla: https://atomgit.com/src-openeuler/kernel/issues/15878
CVE: CVE-2026-53192
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id…
--------------------------------
commit 053a401b592be424fea9d57c789f66cd5d8cec11 upstream.
At releasing a timer object, e.g. when a userspace timer
(CONFIG_SND_UTIMER) gets closed and snd_timer_free() is called, it
tries to detach the timer instances and release the resources.
However, it's still possible that other in-flight tasks are holding
the timer instance where the to-be-deleted timer object is associated,
and this may lead to racy accesses.
Fortunately, most of ioctls dealing with the timer instance list
already have the protection with register_mutex, and this also avoids
such races. But, SNDRV_TIMER_IOCTL_PARAMS isn't protected, hence the
concurrent ioctl may lead to use-after-free.
This patch just adds the guard with register_mutex to protect
snd_timer_user_params() for covering the code path as a quick
workaround. It's no hot-path but rather a rarely issued ioctl, so the
performance penalty doesn't matter.
Reported-by: Kyle Zeng <kylebot(a)openai.com>
Tested-by: Kyle Zeng <kylebot(a)openai.com>
Cc: <stable(a)vger.kernel.org>
Link: https://patch.msgid.link/20260606161145.1933447-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai(a)suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Signed-off-by: Lin Yujun <linyujun809(a)h-partners.com>
---
sound/core/timer.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/sound/core/timer.c b/sound/core/timer.c
index 230babace502..e7cf47104257 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -1850,6 +1850,7 @@ static int snd_timer_user_params(struct file *file,
struct snd_timer *t;
int err;
+ guard(mutex)(®ister_mutex);
tu = file->private_data;
if (!tu->timeri)
return -EBADFD;
--
2.22.0
2
1
02 Jul '26
From: Takashi Iwai <tiwai(a)suse.de>
stable inclusion
from stable-v5.10.259
commit 92ad2d7f80cad43b046f093e808e11fe919d304a
category: bugfix
bugzilla: https://atomgit.com/src-openeuler/kernel/issues/15878
CVE: CVE-2026-53192
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id…
--------------------------------
commit 053a401b592be424fea9d57c789f66cd5d8cec11 upstream.
At releasing a timer object, e.g. when a userspace timer
(CONFIG_SND_UTIMER) gets closed and snd_timer_free() is called, it
tries to detach the timer instances and release the resources.
However, it's still possible that other in-flight tasks are holding
the timer instance where the to-be-deleted timer object is associated,
and this may lead to racy accesses.
Fortunately, most of ioctls dealing with the timer instance list
already have the protection with register_mutex, and this also avoids
such races. But, SNDRV_TIMER_IOCTL_PARAMS isn't protected, hence the
concurrent ioctl may lead to use-after-free.
This patch just adds the guard with register_mutex to protect
snd_timer_user_params() for covering the code path as a quick
workaround. It's no hot-path but rather a rarely issued ioctl, so the
performance penalty doesn't matter.
Reported-by: Kyle Zeng <kylebot(a)openai.com>
Tested-by: Kyle Zeng <kylebot(a)openai.com>
Cc: <stable(a)vger.kernel.org>
Link: https://patch.msgid.link/20260606161145.1933447-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai(a)suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Signed-off-by: Lin Yujun <linyujun809(a)h-partners.com>
---
sound/core/timer.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/sound/core/timer.c b/sound/core/timer.c
index 708c9a46eefe..7b91c11241f5 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -1842,6 +1842,7 @@ static int snd_timer_user_params(struct file *file,
struct snd_timer *t;
int err;
+ guard(mutex)(®ister_mutex);
tu = file->private_data;
if (!tu->timeri)
return -EBADFD;
--
2.22.0
2
1
02 Jul '26
From: Takashi Iwai <tiwai(a)suse.de>
stable inclusion
from stable-v5.10.259
commit 92ad2d7f80cad43b046f093e808e11fe919d304a
category: bugfix
bugzilla: NA
CVE: CVE-2026-53192
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id…
--------------------------------
commit 053a401b592be424fea9d57c789f66cd5d8cec11 upstream.
At releasing a timer object, e.g. when a userspace timer
(CONFIG_SND_UTIMER) gets closed and snd_timer_free() is called, it
tries to detach the timer instances and release the resources.
However, it's still possible that other in-flight tasks are holding
the timer instance where the to-be-deleted timer object is associated,
and this may lead to racy accesses.
Fortunately, most of ioctls dealing with the timer instance list
already have the protection with register_mutex, and this also avoids
such races. But, SNDRV_TIMER_IOCTL_PARAMS isn't protected, hence the
concurrent ioctl may lead to use-after-free.
This patch just adds the guard with register_mutex to protect
snd_timer_user_params() for covering the code path as a quick
workaround. It's no hot-path but rather a rarely issued ioctl, so the
performance penalty doesn't matter.
Reported-by: Kyle Zeng <kylebot(a)openai.com>
Tested-by: Kyle Zeng <kylebot(a)openai.com>
Cc: <stable(a)vger.kernel.org>
Link: https://patch.msgid.link/20260606161145.1933447-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai(a)suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Signed-off-by: Lin Yujun <linyujun809(a)h-partners.com>
---
sound/core/timer.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/sound/core/timer.c b/sound/core/timer.c
index 708c9a46eefe..7b91c11241f5 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -1842,6 +1842,7 @@ static int snd_timer_user_params(struct file *file,
struct snd_timer *t;
int err;
+ guard(mutex)(®ister_mutex);
tu = file->private_data;
if (!tu->timeri)
return -EBADFD;
--
2.22.0
2
1
02 Jul '26
From: Takashi Iwai <tiwai(a)suse.de>
stable inclusion
from stable-v5.10.259
commit 92ad2d7f80cad43b046f093e808e11fe919d304a
category: bugfix
bugzilla: NA
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id…
--------------------------------
commit 053a401b592be424fea9d57c789f66cd5d8cec11 upstream.
At releasing a timer object, e.g. when a userspace timer
(CONFIG_SND_UTIMER) gets closed and snd_timer_free() is called, it
tries to detach the timer instances and release the resources.
However, it's still possible that other in-flight tasks are holding
the timer instance where the to-be-deleted timer object is associated,
and this may lead to racy accesses.
Fortunately, most of ioctls dealing with the timer instance list
already have the protection with register_mutex, and this also avoids
such races. But, SNDRV_TIMER_IOCTL_PARAMS isn't protected, hence the
concurrent ioctl may lead to use-after-free.
This patch just adds the guard with register_mutex to protect
snd_timer_user_params() for covering the code path as a quick
workaround. It's no hot-path but rather a rarely issued ioctl, so the
performance penalty doesn't matter.
Reported-by: Kyle Zeng <kylebot(a)openai.com>
Tested-by: Kyle Zeng <kylebot(a)openai.com>
Cc: <stable(a)vger.kernel.org>
Link: https://patch.msgid.link/20260606161145.1933447-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai(a)suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Signed-off-by: Lin Yujun <linyujun809(a)h-partners.com>
---
sound/core/timer.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/sound/core/timer.c b/sound/core/timer.c
index 708c9a46eefe..7b91c11241f5 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -1842,6 +1842,7 @@ static int snd_timer_user_params(struct file *file,
struct snd_timer *t;
int err;
+ guard(mutex)(®ister_mutex);
tu = file->private_data;
if (!tu->timeri)
return -EBADFD;
--
2.22.0
2
1