Skip to content

Commit b97c537

Browse files
guptas2herbertx
authored andcommitted
crypto: qat - refactor device restart logic
Refactor the restart logic by moving it into the function adf_dev_restart() which uses the safe function adf_dev_up() and adf_dev_down(). This commit does not implement any functional change. Signed-off-by: Shashank Gupta <[email protected]> Reviewed-by: Giovanni Cabiddu <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 2b60f79 commit b97c537

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

drivers/crypto/qat/qat_common/adf_aer.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ static void adf_device_reset_worker(struct work_struct *work)
9090
struct adf_accel_dev *accel_dev = reset_data->accel_dev;
9191

9292
adf_dev_restarting_notify(accel_dev);
93-
adf_dev_stop(accel_dev);
94-
adf_dev_shutdown(accel_dev);
95-
if (adf_dev_init(accel_dev) || adf_dev_start(accel_dev)) {
93+
if (adf_dev_restart(accel_dev)) {
9694
/* The device hanged and we can't restart it so stop here */
9795
dev_err(&GET_DEV(accel_dev), "Restart device failed\n");
9896
kfree(reset_data);

drivers/crypto/qat/qat_common/adf_common_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ int adf_dev_shutdown_cache_cfg(struct adf_accel_dev *accel_dev);
6060

6161
int adf_dev_up(struct adf_accel_dev *accel_dev, bool init_config);
6262
int adf_dev_down(struct adf_accel_dev *accel_dev, bool cache_config);
63+
int adf_dev_restart(struct adf_accel_dev *accel_dev);
6364

6465
void adf_devmgr_update_class_index(struct adf_hw_device_data *hw_data);
6566
void adf_clean_vf_map(bool);

drivers/crypto/qat/qat_common/adf_init.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,3 +464,21 @@ int adf_dev_up(struct adf_accel_dev *accel_dev, bool config)
464464
return ret;
465465
}
466466
EXPORT_SYMBOL_GPL(adf_dev_up);
467+
468+
int adf_dev_restart(struct adf_accel_dev *accel_dev)
469+
{
470+
int ret = 0;
471+
472+
if (!accel_dev)
473+
return -EFAULT;
474+
475+
adf_dev_down(accel_dev, false);
476+
477+
ret = adf_dev_up(accel_dev, false);
478+
/* if device is already up return success*/
479+
if (ret == -EALREADY)
480+
return 0;
481+
482+
return ret;
483+
}
484+
EXPORT_SYMBOL_GPL(adf_dev_restart);

0 commit comments

Comments
 (0)