crypto: qat - replace state machine calls
The device state machine functions are unsafe and interdependent on each other. To perform a state transition, these shall be called in a specific order: * device up: adf_dev_init() -> adf_dev_start() * device down: adf_dev_stop() -> adf_dev_shutdown() Replace all the state machine functions used in the QAT driver with the safe wrappers adf_dev_up() and adf_dev_down(). Signed-off-by: Shashank Gupta <shashank.gupta@intel.com> Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
1bdc85550a
commit
2b60f79c7b
@ -411,15 +411,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||||||
goto out_err_disable_aer;
|
goto out_err_disable_aer;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = hw_data->dev_config(accel_dev);
|
ret = adf_dev_up(accel_dev, true);
|
||||||
if (ret)
|
|
||||||
goto out_err_disable_aer;
|
|
||||||
|
|
||||||
ret = adf_dev_init(accel_dev);
|
|
||||||
if (ret)
|
|
||||||
goto out_err_dev_shutdown;
|
|
||||||
|
|
||||||
ret = adf_dev_start(accel_dev);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_err_dev_stop;
|
goto out_err_dev_stop;
|
||||||
|
|
||||||
@ -430,9 +422,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
out_err_dev_stop:
|
out_err_dev_stop:
|
||||||
adf_dev_stop(accel_dev);
|
adf_dev_down(accel_dev, false);
|
||||||
out_err_dev_shutdown:
|
|
||||||
adf_dev_shutdown(accel_dev);
|
|
||||||
out_err_disable_aer:
|
out_err_disable_aer:
|
||||||
adf_disable_aer(accel_dev);
|
adf_disable_aer(accel_dev);
|
||||||
out_err:
|
out_err:
|
||||||
@ -448,8 +438,7 @@ static void adf_remove(struct pci_dev *pdev)
|
|||||||
pr_err("QAT: Driver removal failed\n");
|
pr_err("QAT: Driver removal failed\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
adf_dev_stop(accel_dev);
|
adf_dev_down(accel_dev, false);
|
||||||
adf_dev_shutdown(accel_dev);
|
|
||||||
adf_disable_aer(accel_dev);
|
adf_disable_aer(accel_dev);
|
||||||
adf_cleanup_accel(accel_dev);
|
adf_cleanup_accel(accel_dev);
|
||||||
}
|
}
|
||||||
|
@ -201,24 +201,14 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||||||
goto out_err_disable_aer;
|
goto out_err_disable_aer;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = hw_data->dev_config(accel_dev);
|
ret = adf_dev_up(accel_dev, true);
|
||||||
if (ret)
|
|
||||||
goto out_err_disable_aer;
|
|
||||||
|
|
||||||
ret = adf_dev_init(accel_dev);
|
|
||||||
if (ret)
|
|
||||||
goto out_err_dev_shutdown;
|
|
||||||
|
|
||||||
ret = adf_dev_start(accel_dev);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_err_dev_stop;
|
goto out_err_dev_stop;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
out_err_dev_stop:
|
out_err_dev_stop:
|
||||||
adf_dev_stop(accel_dev);
|
adf_dev_down(accel_dev, false);
|
||||||
out_err_dev_shutdown:
|
|
||||||
adf_dev_shutdown(accel_dev);
|
|
||||||
out_err_disable_aer:
|
out_err_disable_aer:
|
||||||
adf_disable_aer(accel_dev);
|
adf_disable_aer(accel_dev);
|
||||||
out_err_free_reg:
|
out_err_free_reg:
|
||||||
@ -239,8 +229,7 @@ static void adf_remove(struct pci_dev *pdev)
|
|||||||
pr_err("QAT: Driver removal failed\n");
|
pr_err("QAT: Driver removal failed\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
adf_dev_stop(accel_dev);
|
adf_dev_down(accel_dev, false);
|
||||||
adf_dev_shutdown(accel_dev);
|
|
||||||
adf_disable_aer(accel_dev);
|
adf_disable_aer(accel_dev);
|
||||||
adf_cleanup_accel(accel_dev);
|
adf_cleanup_accel(accel_dev);
|
||||||
adf_cleanup_pci_dev(accel_dev);
|
adf_cleanup_pci_dev(accel_dev);
|
||||||
|
@ -173,20 +173,14 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||||||
/* Completion for VF2PF request/response message exchange */
|
/* Completion for VF2PF request/response message exchange */
|
||||||
init_completion(&accel_dev->vf.msg_received);
|
init_completion(&accel_dev->vf.msg_received);
|
||||||
|
|
||||||
ret = adf_dev_init(accel_dev);
|
ret = adf_dev_up(accel_dev, false);
|
||||||
if (ret)
|
|
||||||
goto out_err_dev_shutdown;
|
|
||||||
|
|
||||||
ret = adf_dev_start(accel_dev);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_err_dev_stop;
|
goto out_err_dev_stop;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
out_err_dev_stop:
|
out_err_dev_stop:
|
||||||
adf_dev_stop(accel_dev);
|
adf_dev_down(accel_dev, false);
|
||||||
out_err_dev_shutdown:
|
|
||||||
adf_dev_shutdown(accel_dev);
|
|
||||||
out_err_free_reg:
|
out_err_free_reg:
|
||||||
pci_release_regions(accel_pci_dev->pci_dev);
|
pci_release_regions(accel_pci_dev->pci_dev);
|
||||||
out_err_disable:
|
out_err_disable:
|
||||||
@ -206,8 +200,7 @@ static void adf_remove(struct pci_dev *pdev)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
adf_flush_vf_wq(accel_dev);
|
adf_flush_vf_wq(accel_dev);
|
||||||
adf_dev_stop(accel_dev);
|
adf_dev_down(accel_dev, false);
|
||||||
adf_dev_shutdown(accel_dev);
|
|
||||||
adf_cleanup_accel(accel_dev);
|
adf_cleanup_accel(accel_dev);
|
||||||
adf_cleanup_pci_dev(accel_dev);
|
adf_cleanup_pci_dev(accel_dev);
|
||||||
kfree(accel_dev);
|
kfree(accel_dev);
|
||||||
|
@ -201,24 +201,14 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||||||
goto out_err_disable_aer;
|
goto out_err_disable_aer;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = hw_data->dev_config(accel_dev);
|
ret = adf_dev_up(accel_dev, true);
|
||||||
if (ret)
|
|
||||||
goto out_err_disable_aer;
|
|
||||||
|
|
||||||
ret = adf_dev_init(accel_dev);
|
|
||||||
if (ret)
|
|
||||||
goto out_err_dev_shutdown;
|
|
||||||
|
|
||||||
ret = adf_dev_start(accel_dev);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_err_dev_stop;
|
goto out_err_dev_stop;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
out_err_dev_stop:
|
out_err_dev_stop:
|
||||||
adf_dev_stop(accel_dev);
|
adf_dev_down(accel_dev, false);
|
||||||
out_err_dev_shutdown:
|
|
||||||
adf_dev_shutdown(accel_dev);
|
|
||||||
out_err_disable_aer:
|
out_err_disable_aer:
|
||||||
adf_disable_aer(accel_dev);
|
adf_disable_aer(accel_dev);
|
||||||
out_err_free_reg:
|
out_err_free_reg:
|
||||||
@ -239,8 +229,7 @@ static void adf_remove(struct pci_dev *pdev)
|
|||||||
pr_err("QAT: Driver removal failed\n");
|
pr_err("QAT: Driver removal failed\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
adf_dev_stop(accel_dev);
|
adf_dev_down(accel_dev, false);
|
||||||
adf_dev_shutdown(accel_dev);
|
|
||||||
adf_disable_aer(accel_dev);
|
adf_disable_aer(accel_dev);
|
||||||
adf_cleanup_accel(accel_dev);
|
adf_cleanup_accel(accel_dev);
|
||||||
adf_cleanup_pci_dev(accel_dev);
|
adf_cleanup_pci_dev(accel_dev);
|
||||||
|
@ -173,20 +173,14 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||||||
/* Completion for VF2PF request/response message exchange */
|
/* Completion for VF2PF request/response message exchange */
|
||||||
init_completion(&accel_dev->vf.msg_received);
|
init_completion(&accel_dev->vf.msg_received);
|
||||||
|
|
||||||
ret = adf_dev_init(accel_dev);
|
ret = adf_dev_up(accel_dev, false);
|
||||||
if (ret)
|
|
||||||
goto out_err_dev_shutdown;
|
|
||||||
|
|
||||||
ret = adf_dev_start(accel_dev);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_err_dev_stop;
|
goto out_err_dev_stop;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
out_err_dev_stop:
|
out_err_dev_stop:
|
||||||
adf_dev_stop(accel_dev);
|
adf_dev_down(accel_dev, false);
|
||||||
out_err_dev_shutdown:
|
|
||||||
adf_dev_shutdown(accel_dev);
|
|
||||||
out_err_free_reg:
|
out_err_free_reg:
|
||||||
pci_release_regions(accel_pci_dev->pci_dev);
|
pci_release_regions(accel_pci_dev->pci_dev);
|
||||||
out_err_disable:
|
out_err_disable:
|
||||||
@ -206,8 +200,7 @@ static void adf_remove(struct pci_dev *pdev)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
adf_flush_vf_wq(accel_dev);
|
adf_flush_vf_wq(accel_dev);
|
||||||
adf_dev_stop(accel_dev);
|
adf_dev_down(accel_dev, false);
|
||||||
adf_dev_shutdown(accel_dev);
|
|
||||||
adf_cleanup_accel(accel_dev);
|
adf_cleanup_accel(accel_dev);
|
||||||
adf_cleanup_pci_dev(accel_dev);
|
adf_cleanup_pci_dev(accel_dev);
|
||||||
kfree(accel_dev);
|
kfree(accel_dev);
|
||||||
|
@ -244,8 +244,7 @@ static void adf_ctl_stop_devices(u32 id)
|
|||||||
if (!accel_dev->is_vf)
|
if (!accel_dev->is_vf)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
adf_dev_stop(accel_dev);
|
adf_dev_down(accel_dev, false);
|
||||||
adf_dev_shutdown(accel_dev);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,8 +253,7 @@ static void adf_ctl_stop_devices(u32 id)
|
|||||||
if (!adf_dev_started(accel_dev))
|
if (!adf_dev_started(accel_dev))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
adf_dev_stop(accel_dev);
|
adf_dev_down(accel_dev, false);
|
||||||
adf_dev_shutdown(accel_dev);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,23 +307,16 @@ static int adf_ctl_ioctl_dev_start(struct file *fp, unsigned int cmd,
|
|||||||
if (!accel_dev)
|
if (!accel_dev)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!adf_dev_started(accel_dev)) {
|
dev_info(&GET_DEV(accel_dev),
|
||||||
dev_info(&GET_DEV(accel_dev),
|
"Starting acceleration device qat_dev%d.\n",
|
||||||
"Starting acceleration device qat_dev%d.\n",
|
ctl_data->device_id);
|
||||||
ctl_data->device_id);
|
|
||||||
ret = adf_dev_init(accel_dev);
|
ret = adf_dev_up(accel_dev, false);
|
||||||
if (!ret)
|
|
||||||
ret = adf_dev_start(accel_dev);
|
|
||||||
} else {
|
|
||||||
dev_info(&GET_DEV(accel_dev),
|
|
||||||
"Acceleration device qat_dev%d already started.\n",
|
|
||||||
ctl_data->device_id);
|
|
||||||
}
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&GET_DEV(accel_dev), "Failed to start qat_dev%d\n",
|
dev_err(&GET_DEV(accel_dev), "Failed to start qat_dev%d\n",
|
||||||
ctl_data->device_id);
|
ctl_data->device_id);
|
||||||
adf_dev_stop(accel_dev);
|
adf_dev_down(accel_dev, false);
|
||||||
adf_dev_shutdown(accel_dev);
|
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
kfree(ctl_data);
|
kfree(ctl_data);
|
||||||
|
@ -159,7 +159,7 @@ int adf_sriov_configure(struct pci_dev *pdev, int numvfs)
|
|||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = adf_dev_shutdown_cache_cfg(accel_dev);
|
ret = adf_dev_down(accel_dev, true);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -184,13 +184,7 @@ int adf_sriov_configure(struct pci_dev *pdev, int numvfs)
|
|||||||
if (!accel_dev->pf.vf_info)
|
if (!accel_dev->pf.vf_info)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (adf_dev_init(accel_dev)) {
|
if (adf_dev_up(accel_dev, false)) {
|
||||||
dev_err(&GET_DEV(accel_dev), "Failed to init qat_dev%d\n",
|
|
||||||
accel_dev->accel_id);
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (adf_dev_start(accel_dev)) {
|
|
||||||
dev_err(&GET_DEV(accel_dev), "Failed to start qat_dev%d\n",
|
dev_err(&GET_DEV(accel_dev), "Failed to start qat_dev%d\n",
|
||||||
accel_dev->accel_id);
|
accel_dev->accel_id);
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
@ -71,8 +71,7 @@ static void adf_dev_stop_async(struct work_struct *work)
|
|||||||
struct adf_accel_dev *accel_dev = stop_data->accel_dev;
|
struct adf_accel_dev *accel_dev = stop_data->accel_dev;
|
||||||
|
|
||||||
adf_dev_restarting_notify(accel_dev);
|
adf_dev_restarting_notify(accel_dev);
|
||||||
adf_dev_stop(accel_dev);
|
adf_dev_down(accel_dev, false);
|
||||||
adf_dev_shutdown(accel_dev);
|
|
||||||
|
|
||||||
/* Re-enable PF2VF interrupts */
|
/* Re-enable PF2VF interrupts */
|
||||||
adf_enable_pf2vf_interrupts(accel_dev);
|
adf_enable_pf2vf_interrupts(accel_dev);
|
||||||
|
@ -201,24 +201,14 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||||||
goto out_err_disable_aer;
|
goto out_err_disable_aer;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = hw_data->dev_config(accel_dev);
|
ret = adf_dev_up(accel_dev, true);
|
||||||
if (ret)
|
|
||||||
goto out_err_disable_aer;
|
|
||||||
|
|
||||||
ret = adf_dev_init(accel_dev);
|
|
||||||
if (ret)
|
|
||||||
goto out_err_dev_shutdown;
|
|
||||||
|
|
||||||
ret = adf_dev_start(accel_dev);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_err_dev_stop;
|
goto out_err_dev_stop;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
out_err_dev_stop:
|
out_err_dev_stop:
|
||||||
adf_dev_stop(accel_dev);
|
adf_dev_down(accel_dev, false);
|
||||||
out_err_dev_shutdown:
|
|
||||||
adf_dev_shutdown(accel_dev);
|
|
||||||
out_err_disable_aer:
|
out_err_disable_aer:
|
||||||
adf_disable_aer(accel_dev);
|
adf_disable_aer(accel_dev);
|
||||||
out_err_free_reg:
|
out_err_free_reg:
|
||||||
@ -239,8 +229,7 @@ static void adf_remove(struct pci_dev *pdev)
|
|||||||
pr_err("QAT: Driver removal failed\n");
|
pr_err("QAT: Driver removal failed\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
adf_dev_stop(accel_dev);
|
adf_dev_down(accel_dev, false);
|
||||||
adf_dev_shutdown(accel_dev);
|
|
||||||
adf_disable_aer(accel_dev);
|
adf_disable_aer(accel_dev);
|
||||||
adf_cleanup_accel(accel_dev);
|
adf_cleanup_accel(accel_dev);
|
||||||
adf_cleanup_pci_dev(accel_dev);
|
adf_cleanup_pci_dev(accel_dev);
|
||||||
|
@ -173,20 +173,14 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||||||
/* Completion for VF2PF request/response message exchange */
|
/* Completion for VF2PF request/response message exchange */
|
||||||
init_completion(&accel_dev->vf.msg_received);
|
init_completion(&accel_dev->vf.msg_received);
|
||||||
|
|
||||||
ret = adf_dev_init(accel_dev);
|
ret = adf_dev_up(accel_dev, false);
|
||||||
if (ret)
|
|
||||||
goto out_err_dev_shutdown;
|
|
||||||
|
|
||||||
ret = adf_dev_start(accel_dev);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_err_dev_stop;
|
goto out_err_dev_stop;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
out_err_dev_stop:
|
out_err_dev_stop:
|
||||||
adf_dev_stop(accel_dev);
|
adf_dev_down(accel_dev, false);
|
||||||
out_err_dev_shutdown:
|
|
||||||
adf_dev_shutdown(accel_dev);
|
|
||||||
out_err_free_reg:
|
out_err_free_reg:
|
||||||
pci_release_regions(accel_pci_dev->pci_dev);
|
pci_release_regions(accel_pci_dev->pci_dev);
|
||||||
out_err_disable:
|
out_err_disable:
|
||||||
@ -206,8 +200,7 @@ static void adf_remove(struct pci_dev *pdev)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
adf_flush_vf_wq(accel_dev);
|
adf_flush_vf_wq(accel_dev);
|
||||||
adf_dev_stop(accel_dev);
|
adf_dev_down(accel_dev, false);
|
||||||
adf_dev_shutdown(accel_dev);
|
|
||||||
adf_cleanup_accel(accel_dev);
|
adf_cleanup_accel(accel_dev);
|
||||||
adf_cleanup_pci_dev(accel_dev);
|
adf_cleanup_pci_dev(accel_dev);
|
||||||
kfree(accel_dev);
|
kfree(accel_dev);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user