crypto: qat - add shutdown handler to qat_c3xxx
authorGiovanni Cabiddu <giovanni.cabiddu@intel.com>
Wed, 26 Mar 2025 15:59:53 +0000 (15:59 +0000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 7 Apr 2025 05:22:26 +0000 (13:22 +0800)
During a warm reset via kexec, the system bypasses the driver removal
sequence, meaning that the remove() callback is not invoked.
If a QAT device is not shutdown properly, the device driver will fail to
load in a newly rebooted kernel.

This might result in output like the following after the kexec reboot:

    QAT: AE0 is inactive!!
    QAT: failed to get device out of reset
    c3xxx 0000:3f:00.0: qat_hal_clr_reset error
    c3xxx 0000:3f:00.0: Failed to init the AEs
    c3xxx 0000:3f:00.0: Failed to initialise Acceleration Engine
    c3xxx 0000:3f:00.0: Resetting device qat_dev0
    c3xxx 0000:3f:00.0: probe with driver c3xxx failed with error -14

Implement the shutdown() handler that hooks into the reboot notifier
list. This brings down the QAT device and ensures it is shut down
properly.

Cc: <stable@vger.kernel.org>
Fixes: 890c55f4dc0e ("crypto: qat - add support for c3xxx accel type")
Reviewed-by: Ahsan Atta <ahsan.atta@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/intel/qat/qat_c3xxx/adf_drv.c

index 260f34d0d5414dc17267c5beec3e46c1aa0eae7f..bceb5dd8b148c8f5bc66b4a0015f378597cb42b3 100644 (file)
@@ -209,6 +209,13 @@ static void adf_remove(struct pci_dev *pdev)
        kfree(accel_dev);
 }
 
+static void adf_shutdown(struct pci_dev *pdev)
+{
+       struct adf_accel_dev *accel_dev = adf_devmgr_pci_to_accel_dev(pdev);
+
+       adf_dev_down(accel_dev);
+}
+
 static const struct pci_device_id adf_pci_tbl[] = {
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_QAT_C3XXX) },
        { }
@@ -220,6 +227,7 @@ static struct pci_driver adf_driver = {
        .name = ADF_C3XXX_DEVICE_NAME,
        .probe = adf_probe,
        .remove = adf_remove,
+       .shutdown = adf_shutdown,
        .sriov_configure = adf_sriov_configure,
        .err_handler = &adf_err_handler,
 };