diff options
author | Shivasharan S <shivasharan.srikanteshwara@broadcom.com> | 2018-01-05 08:27:43 -0500 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2018-01-10 23:25:17 -0500 |
commit | 619831f23bf76e7d420991df3baefc8e24cc5432 (patch) | |
tree | 86097afffc3bf5f1b9e08cec3f9523b0e44cfc4a | |
parent | 149c5751e672ca0a4892c1e5fd6b87535e81268d (diff) |
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: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r-- | drivers/scsi/megaraid/megaraid_sas_base.c | 60 |
1 files changed, 2 insertions, 58 deletions
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 5ab343d386f9..34d1fb75285a 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c | |||
@@ -7305,9 +7305,6 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg) | |||
7305 | struct megasas_iocpacket *ioc; | 7305 | struct megasas_iocpacket *ioc; |
7306 | struct megasas_instance *instance; | 7306 | struct megasas_instance *instance; |
7307 | int error; | 7307 | int error; |
7308 | int i; | ||
7309 | unsigned long flags; | ||
7310 | u32 wait_time = MEGASAS_RESET_WAIT_TIME; | ||
7311 | 7308 | ||
7312 | ioc = memdup_user(user_ioc, sizeof(*ioc)); | 7309 | ioc = memdup_user(user_ioc, sizeof(*ioc)); |
7313 | if (IS_ERR(ioc)) | 7310 | if (IS_ERR(ioc)) |
@@ -7319,10 +7316,6 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg) | |||
7319 | goto out_kfree_ioc; | 7316 | goto out_kfree_ioc; |
7320 | } | 7317 | } |
7321 | 7318 | ||
7322 | /* Adjust ioctl wait time for VF mode */ | ||
7323 | if (instance->requestorId) | ||
7324 | wait_time = MEGASAS_ROUTINE_WAIT_TIME_VF; | ||
7325 | |||
7326 | /* Block ioctls in VF mode */ | 7319 | /* Block ioctls in VF mode */ |
7327 | if (instance->requestorId && !allow_vf_ioctls) { | 7320 | if (instance->requestorId && !allow_vf_ioctls) { |
7328 | error = -ENODEV; | 7321 | error = -ENODEV; |
@@ -7345,32 +7338,10 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg) | |||
7345 | goto out_kfree_ioc; | 7338 | goto out_kfree_ioc; |
7346 | } | 7339 | } |
7347 | 7340 | ||
7348 | for (i = 0; i < wait_time; i++) { | 7341 | if (megasas_wait_for_adapter_operational(instance)) { |
7349 | |||
7350 | spin_lock_irqsave(&instance->hba_lock, flags); | ||
7351 | if (atomic_read(&instance->adprecovery) == MEGASAS_HBA_OPERATIONAL) { | ||
7352 | spin_unlock_irqrestore(&instance->hba_lock, flags); | ||
7353 | break; | ||
7354 | } | ||
7355 | spin_unlock_irqrestore(&instance->hba_lock, flags); | ||
7356 | |||
7357 | if (!(i % MEGASAS_RESET_NOTICE_INTERVAL)) { | ||
7358 | dev_notice(&instance->pdev->dev, "waiting" | ||
7359 | "for controller reset to finish\n"); | ||
7360 | } | ||
7361 | |||
7362 | msleep(1000); | ||
7363 | } | ||
7364 | |||
7365 | spin_lock_irqsave(&instance->hba_lock, flags); | ||
7366 | if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) { | ||
7367 | spin_unlock_irqrestore(&instance->hba_lock, flags); | ||
7368 | |||
7369 | dev_err(&instance->pdev->dev, "timed out while waiting for HBA to recover\n"); | ||
7370 | error = -ENODEV; | 7342 | error = -ENODEV; |
7371 | goto out_up; | 7343 | goto out_up; |
7372 | } | 7344 | } |
7373 | spin_unlock_irqrestore(&instance->hba_lock, flags); | ||
7374 | 7345 | ||
7375 | error = megasas_mgmt_fw_ioctl(instance, user_ioc, ioc); | 7346 | error = megasas_mgmt_fw_ioctl(instance, user_ioc, ioc); |
7376 | out_up: | 7347 | out_up: |
@@ -7386,9 +7357,6 @@ static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg) | |||
7386 | struct megasas_instance *instance; | 7357 | struct megasas_instance *instance; |
7387 | struct megasas_aen aen; | 7358 | struct megasas_aen aen; |
7388 | int error; | 7359 | int error; |
7389 | int i; | ||
7390 | unsigned long flags; | ||
7391 | u32 wait_time = MEGASAS_RESET_WAIT_TIME; | ||
7392 | 7360 | ||
7393 | if (file->private_data != file) { | 7361 | if (file->private_data != file) { |
7394 | printk(KERN_DEBUG "megasas: fasync_helper was not " | 7362 | 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 | return -ENODEV; | 7380 | return -ENODEV; |
7413 | } | 7381 | } |
7414 | 7382 | ||
7415 | for (i = 0; i < wait_time; i++) { | 7383 | if (megasas_wait_for_adapter_operational(instance)) |
7416 | |||
7417 | spin_lock_irqsave(&instance->hba_lock, flags); | ||
7418 | if (atomic_read(&instance->adprecovery) == MEGASAS_HBA_OPERATIONAL) { | ||
7419 | spin_unlock_irqrestore(&instance->hba_lock, | ||
7420 | flags); | ||
7421 | break; | ||
7422 | } | ||
7423 | |||
7424 | spin_unlock_irqrestore(&instance->hba_lock, flags); | ||
7425 | |||
7426 | if (!(i % MEGASAS_RESET_NOTICE_INTERVAL)) { | ||
7427 | dev_notice(&instance->pdev->dev, "waiting for" | ||
7428 | "controller reset to finish\n"); | ||
7429 | } | ||
7430 | |||
7431 | msleep(1000); | ||
7432 | } | ||
7433 | |||
7434 | spin_lock_irqsave(&instance->hba_lock, flags); | ||
7435 | if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) { | ||
7436 | spin_unlock_irqrestore(&instance->hba_lock, flags); | ||
7437 | dev_err(&instance->pdev->dev, "timed out while waiting for HBA to recover\n"); | ||
7438 | return -ENODEV; | 7384 | return -ENODEV; |
7439 | } | ||
7440 | spin_unlock_irqrestore(&instance->hba_lock, flags); | ||
7441 | 7385 | ||
7442 | mutex_lock(&instance->reset_mutex); | 7386 | mutex_lock(&instance->reset_mutex); |
7443 | error = megasas_register_aen(instance, aen.seq_num, | 7387 | error = megasas_register_aen(instance, aen.seq_num, |