Skip to content

Commit

Permalink
crypto: qat - change SLAs cleanup flow at shutdown
Browse files Browse the repository at this point in the history
[ Upstream commit c2304e1 ]

The implementation of the Rate Limiting (RL) feature includes the cleanup
of all SLAs during device shutdown. For each SLA, the firmware is notified
of the removal through an admin message, the data structures that take
into account the budgets are updated and the memory is freed.
However, this explicit cleanup is not necessary as (1) the device is
reset, and the firmware state is lost and (2) all RL data structures
are freed anyway.

In addition, if the device is unresponsive, for example after a PCI
AER error is detected, the admin interface might not be available.
This might slow down the shutdown sequence and cause a timeout in
the recovery flows which in turn makes the driver believe that the
device is not recoverable.

Fix by replacing the explicit SLAs removal with just a free of the
SLA data structures.

Fixes: d9fb840 ("crypto: qat - add rate limiting feature to qat_4xxx")
Cc: <[email protected]>
Signed-off-by: Damian Muszynski <[email protected]>
Reviewed-by: Giovanni Cabiddu <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
dmuszyns authored and gregkh committed Mar 29, 2024
1 parent 9cb88c4 commit de5f665
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion drivers/crypto/intel/qat/qat_common/adf_rl.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,24 @@ static void clear_sla(struct adf_rl *rl_data, struct rl_sla *sla)
sla_type_arr[node_id] = NULL;
}

static void free_all_sla(struct adf_accel_dev *accel_dev)
{
struct adf_rl *rl_data = accel_dev->rate_limiting;
int sla_id;

mutex_lock(&rl_data->rl_lock);

for (sla_id = 0; sla_id < RL_NODES_CNT_MAX; sla_id++) {
if (!rl_data->sla[sla_id])
continue;

kfree(rl_data->sla[sla_id]);
rl_data->sla[sla_id] = NULL;
}

mutex_unlock(&rl_data->rl_lock);
}

/**
* add_update_sla() - handles the creation and the update of an SLA
* @accel_dev: pointer to acceleration device structure
Expand Down Expand Up @@ -1155,7 +1173,7 @@ void adf_rl_stop(struct adf_accel_dev *accel_dev)
return;

adf_sysfs_rl_rm(accel_dev);
adf_rl_remove_sla_all(accel_dev, true);
free_all_sla(accel_dev);
}

void adf_rl_exit(struct adf_accel_dev *accel_dev)
Expand Down

0 comments on commit de5f665

Please sign in to comment.