diff mbox series

[9/9] crypto: qat - improve aer error reset handling

Message ID 20240103040722.14467-10-mun.chun.yep@intel.com (mailing list archive)
State Changes Requested
Delegated to: Herbert Xu
Headers show
Series crypto: qat - improve recovery flows | expand

Commit Message

Mun Chun Yep Jan. 3, 2024, 4:07 a.m. UTC
Disable worker threads and clear pci bus master in aer error handler.

This is to avoid new requests to be processed and allow dummy responses
generation for in-flight requests in user space before resetting a device.

Signed-off-by: Mun Chun Yep <mun.chun.yep@intel.com>
Reviewed-by: Ahsan Atta <ahsan.atta@intel.com>
Reviewed-by: Markas Rapoportas <markas.rapoportas@intel.com>
---
 drivers/crypto/intel/qat/qat_common/adf_aer.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
diff mbox series

Patch

diff --git a/drivers/crypto/intel/qat/qat_common/adf_aer.c b/drivers/crypto/intel/qat/qat_common/adf_aer.c
index b3d4b6b99c65..df0ff0caf419 100644
--- a/drivers/crypto/intel/qat/qat_common/adf_aer.c
+++ b/drivers/crypto/intel/qat/qat_common/adf_aer.c
@@ -28,6 +28,14 @@  static pci_ers_result_t adf_error_detected(struct pci_dev *pdev,
 		return PCI_ERS_RESULT_DISCONNECT;
 	}
 
+	if (accel_dev->hw_device->exit_arb) {
+		dev_info(&pdev->dev, "Disabling arbitration\n");
+		accel_dev->hw_device->exit_arb(accel_dev);
+	}
+	adf_error_notifier(accel_dev);
+	adf_pf2vf_notify_fatal_error(accel_dev);
+	pci_clear_master(pdev);
+
 	if (state == pci_channel_io_perm_failure) {
 		dev_err(&pdev->dev, "Can't recover from device error\n");
 		return PCI_ERS_RESULT_DISCONNECT;
@@ -111,9 +119,18 @@  static void adf_device_reset_worker(struct work_struct *work)
 		  container_of(work, struct adf_reset_dev_data, reset_work);
 	struct adf_accel_dev *accel_dev = reset_data->accel_dev;
 	unsigned long wait_jiffies = msecs_to_jiffies(10000);
+	struct pci_dev *pdev = accel_to_pci_dev(accel_dev);
 	struct adf_sriov_dev_data sriov_data;
 
 	adf_dev_restarting_notify(accel_dev);
+
+	/*
+	 * re-enable device to support pf/vf comms as it would be disabled
+	 * in the detect function of aer driver
+	 */
+	if (!pdev->is_busmaster)
+		pci_set_master(pdev);
+
 	if (adf_dev_restart(accel_dev)) {
 		/* The device hanged and we can't restart it so stop here */
 		dev_err(&GET_DEV(accel_dev), "Restart device failed\n");