Commit 619831f2 authored by Shivasharan S's avatar Shivasharan S Committed by Martin K. Petersen

scsi: megaraid_sas: Use megasas_wait_for_adapter_operational to detect...

scsi: megaraid_sas: Use megasas_wait_for_adapter_operational to detect controller state in IOCTL path

In IOCTL path, re-use megasas_wait_for_adapter_operational API to detect
controller state. This will make driver to use this API uniformly in all
cases where we need to wait for adapter to become operational.
Signed-off-by: default avatarSumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: default avatarShivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 149c5751
...@@ -7305,9 +7305,6 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg) ...@@ -7305,9 +7305,6 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg)
struct megasas_iocpacket *ioc; struct megasas_iocpacket *ioc;
struct megasas_instance *instance; struct megasas_instance *instance;
int error; int error;
int i;
unsigned long flags;
u32 wait_time = MEGASAS_RESET_WAIT_TIME;
ioc = memdup_user(user_ioc, sizeof(*ioc)); ioc = memdup_user(user_ioc, sizeof(*ioc));
if (IS_ERR(ioc)) if (IS_ERR(ioc))
...@@ -7319,10 +7316,6 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg) ...@@ -7319,10 +7316,6 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg)
goto out_kfree_ioc; goto out_kfree_ioc;
} }
/* Adjust ioctl wait time for VF mode */
if (instance->requestorId)
wait_time = MEGASAS_ROUTINE_WAIT_TIME_VF;
/* Block ioctls in VF mode */ /* Block ioctls in VF mode */
if (instance->requestorId && !allow_vf_ioctls) { if (instance->requestorId && !allow_vf_ioctls) {
error = -ENODEV; error = -ENODEV;
...@@ -7345,32 +7338,10 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg) ...@@ -7345,32 +7338,10 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg)
goto out_kfree_ioc; goto out_kfree_ioc;
} }
for (i = 0; i < wait_time; i++) { if (megasas_wait_for_adapter_operational(instance)) {
spin_lock_irqsave(&instance->hba_lock, flags);
if (atomic_read(&instance->adprecovery) == MEGASAS_HBA_OPERATIONAL) {
spin_unlock_irqrestore(&instance->hba_lock, flags);
break;
}
spin_unlock_irqrestore(&instance->hba_lock, flags);
if (!(i % MEGASAS_RESET_NOTICE_INTERVAL)) {
dev_notice(&instance->pdev->dev, "waiting"
"for controller reset to finish\n");
}
msleep(1000);
}
spin_lock_irqsave(&instance->hba_lock, flags);
if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) {
spin_unlock_irqrestore(&instance->hba_lock, flags);
dev_err(&instance->pdev->dev, "timed out while waiting for HBA to recover\n");
error = -ENODEV; error = -ENODEV;
goto out_up; goto out_up;
} }
spin_unlock_irqrestore(&instance->hba_lock, flags);
error = megasas_mgmt_fw_ioctl(instance, user_ioc, ioc); error = megasas_mgmt_fw_ioctl(instance, user_ioc, ioc);
out_up: out_up:
...@@ -7386,9 +7357,6 @@ static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg) ...@@ -7386,9 +7357,6 @@ static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg)
struct megasas_instance *instance; struct megasas_instance *instance;
struct megasas_aen aen; struct megasas_aen aen;
int error; int error;
int i;
unsigned long flags;
u32 wait_time = MEGASAS_RESET_WAIT_TIME;
if (file->private_data != file) { if (file->private_data != file) {
printk(KERN_DEBUG "megasas: fasync_helper was not " printk(KERN_DEBUG "megasas: fasync_helper was not "
...@@ -7412,32 +7380,8 @@ static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg) ...@@ -7412,32 +7380,8 @@ static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg)
return -ENODEV; return -ENODEV;
} }
for (i = 0; i < wait_time; i++) { if (megasas_wait_for_adapter_operational(instance))
spin_lock_irqsave(&instance->hba_lock, flags);
if (atomic_read(&instance->adprecovery) == MEGASAS_HBA_OPERATIONAL) {
spin_unlock_irqrestore(&instance->hba_lock,
flags);
break;
}
spin_unlock_irqrestore(&instance->hba_lock, flags);
if (!(i % MEGASAS_RESET_NOTICE_INTERVAL)) {
dev_notice(&instance->pdev->dev, "waiting for"
"controller reset to finish\n");
}
msleep(1000);
}
spin_lock_irqsave(&instance->hba_lock, flags);
if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) {
spin_unlock_irqrestore(&instance->hba_lock, flags);
dev_err(&instance->pdev->dev, "timed out while waiting for HBA to recover\n");
return -ENODEV; return -ENODEV;
}
spin_unlock_irqrestore(&instance->hba_lock, flags);
mutex_lock(&instance->reset_mutex); mutex_lock(&instance->reset_mutex);
error = megasas_register_aen(instance, aen.seq_num, error = megasas_register_aen(instance, aen.seq_num,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment