mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
crypto: qat - factor out AER reset helpers
Move the shutdown and recovery sequences out of adf_error_detected() and adf_slot_reset() into reset_prepare() and reset_done() helpers. This makes the AER recovery path easier to follow and prepares the common reset flow for reuse by additional PCI reset callbacks without duplicating the logic. No functional change intended. Cc: stable@vger.kernel.org Signed-off-by: Ahsan Atta <ahsan.atta@intel.com> Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Reviewed-by: Damian Muszynski <damian.muszynski@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
9676657117
commit
56707afb92
|
|
@ -17,6 +17,58 @@ struct adf_fatal_error_data {
|
|||
static struct workqueue_struct *device_reset_wq;
|
||||
static struct workqueue_struct *device_sriov_wq;
|
||||
|
||||
static pci_ers_result_t reset_prepare(struct pci_dev *pdev)
|
||||
{
|
||||
struct adf_accel_dev *accel_dev = adf_devmgr_pci_to_accel_dev(pdev);
|
||||
|
||||
if (!accel_dev) {
|
||||
dev_err(&pdev->dev, "Can't find acceleration device\n");
|
||||
return PCI_ERS_RESULT_DISCONNECT;
|
||||
}
|
||||
|
||||
if (!adf_dev_started(accel_dev))
|
||||
return PCI_ERS_RESULT_CAN_RECOVER;
|
||||
|
||||
set_bit(ADF_STATUS_RESTARTING, &accel_dev->status);
|
||||
if (accel_dev->hw_device->exit_arb) {
|
||||
dev_dbg(&pdev->dev, "Disabling arbitration\n");
|
||||
accel_dev->hw_device->exit_arb(accel_dev);
|
||||
}
|
||||
adf_dev_restarting_notify(accel_dev);
|
||||
adf_dev_down(accel_dev);
|
||||
|
||||
return PCI_ERS_RESULT_NEED_RESET;
|
||||
}
|
||||
|
||||
static pci_ers_result_t reset_done(struct pci_dev *pdev)
|
||||
{
|
||||
struct adf_accel_dev *accel_dev = adf_devmgr_pci_to_accel_dev(pdev);
|
||||
int res;
|
||||
|
||||
if (!accel_dev) {
|
||||
dev_err(&pdev->dev, "Can't find acceleration device\n");
|
||||
return PCI_ERS_RESULT_DISCONNECT;
|
||||
}
|
||||
|
||||
if (!adf_devmgr_in_reset(accel_dev))
|
||||
goto reset_complete;
|
||||
|
||||
pci_restore_state(pdev);
|
||||
res = adf_dev_up(accel_dev, false);
|
||||
if (res && res != -EALREADY)
|
||||
return PCI_ERS_RESULT_DISCONNECT;
|
||||
|
||||
adf_reenable_sriov(accel_dev);
|
||||
adf_pf2vf_notify_restarted(accel_dev);
|
||||
adf_dev_restarted_notify(accel_dev);
|
||||
clear_bit(ADF_STATUS_RESTARTING, &accel_dev->status);
|
||||
|
||||
reset_complete:
|
||||
dev_info(&pdev->dev, "Device reset completed successfully\n");
|
||||
|
||||
return PCI_ERS_RESULT_RECOVERED;
|
||||
}
|
||||
|
||||
static pci_ers_result_t adf_error_detected(struct pci_dev *pdev,
|
||||
pci_channel_state_t state)
|
||||
{
|
||||
|
|
@ -33,20 +85,10 @@ static pci_ers_result_t adf_error_detected(struct pci_dev *pdev,
|
|||
return PCI_ERS_RESULT_DISCONNECT;
|
||||
}
|
||||
|
||||
if (!adf_dev_started(accel_dev))
|
||||
return PCI_ERS_RESULT_CAN_RECOVER;
|
||||
|
||||
adf_error_notifier(accel_dev);
|
||||
adf_pf2vf_notify_fatal_error(accel_dev);
|
||||
set_bit(ADF_STATUS_RESTARTING, &accel_dev->status);
|
||||
if (accel_dev->hw_device->exit_arb) {
|
||||
dev_dbg(&pdev->dev, "Disabling arbitration\n");
|
||||
accel_dev->hw_device->exit_arb(accel_dev);
|
||||
}
|
||||
adf_dev_restarting_notify(accel_dev);
|
||||
adf_dev_down(accel_dev);
|
||||
|
||||
return PCI_ERS_RESULT_NEED_RESET;
|
||||
return reset_prepare(pdev);
|
||||
}
|
||||
|
||||
/* reset dev data */
|
||||
|
|
@ -199,29 +241,7 @@ static int adf_dev_aer_schedule_reset(struct adf_accel_dev *accel_dev,
|
|||
|
||||
static pci_ers_result_t adf_slot_reset(struct pci_dev *pdev)
|
||||
{
|
||||
struct adf_accel_dev *accel_dev = adf_devmgr_pci_to_accel_dev(pdev);
|
||||
int res = 0;
|
||||
|
||||
if (!accel_dev) {
|
||||
pr_err("QAT: Can't find acceleration device\n");
|
||||
return PCI_ERS_RESULT_DISCONNECT;
|
||||
}
|
||||
|
||||
if (!adf_devmgr_in_reset(accel_dev))
|
||||
goto reset_complete;
|
||||
|
||||
pci_restore_state(pdev);
|
||||
res = adf_dev_up(accel_dev, false);
|
||||
if (res && res != -EALREADY)
|
||||
return PCI_ERS_RESULT_DISCONNECT;
|
||||
|
||||
adf_reenable_sriov(accel_dev);
|
||||
adf_pf2vf_notify_restarted(accel_dev);
|
||||
adf_dev_restarted_notify(accel_dev);
|
||||
clear_bit(ADF_STATUS_RESTARTING, &accel_dev->status);
|
||||
|
||||
reset_complete:
|
||||
return PCI_ERS_RESULT_RECOVERED;
|
||||
return reset_done(pdev);
|
||||
}
|
||||
|
||||
static void adf_resume(struct pci_dev *pdev)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user