crypto: qat - power up 4xxx device
PATCH 1/1 crypto: qat - power up 4xxx device
After reset or boot, QAT 4xxx devices are inactive and require to be explicitly activated.
This is done by writing the DRV_ACTIVE bit in the PM_INTERRUPT register and polling the PM_INIT_STATE to make sure that the transaction has completed properly.
If this is not done, the driver will fail the initialization sequence reporting the following message:
[ 22.081193] 4xxx 0000:f7:00.0: enabling device (0140 -> 0142)
[ 22.720285] QAT: AE0 is inactive!!
[ 22.720287] QAT: failed to get device out of reset
[ 22.720288] 4xxx 0000:f7:00.0: qat_hal_clr_reset error
[ 22.720290] 4xxx 0000:f7:00.0: Failed to init the AEs
[ 22.720290] 4xxx 0000:f7:00.0: Failed to initialise Acceleration Engine
[ 22.720789] 4xxx 0000:f7:00.0: Resetting device qat_dev0
[ 22.825099] 4xxx: probe of 0000:f7:00.0 failed with error -14The patch also temporarily disables the power management source of interrupt, to avoid possible spurious interrupts as the power management feature is not fully supported.
The device init function has been added to adf_dev_init(), and not in the probe of 4xxx to make sure that the device is re-enabled in case of reset.
Note that the error code reported by hw_data->init_device() in adf_dev_init() has been shadowed for consistency with the other calls in the same function.
--- .../crypto/qat/qat_4xxx/adf_4xxx_hw_data.c | 31 +++++++++++++++++++ .../crypto/qat/qat_4xxx/adf_4xxx_hw_data.h | 10 ++++++ .../crypto/qat/qat_common/adf_accel_devices.h | 1 + drivers/crypto/qat/qat_common/adf_init.c | 5 +++ 4 files changed, 47 insertions(+)
drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c +31 -0
@@ -1,5 +1,6 @@// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) /* Copyright(c) 2020 Intel Corporation */ +#include <linux/iopoll.h> #include <adf_accel_devices.h> #include <adf_common_drv.h> #include <adf_pf2vf_msg.h>
@@ -161,6 +162,35 @@ static void adf_enable_ints(struct adf_accel_dev *accel_dev)ADF_CSR_WR (addr,ADF_4XXX_SMIAPF_MASK_OFFSET ,0 ); } +static int adf_init_device (struct adf_accel_dev *accel_dev) +{ +void __iomem *addr; +u32 status; +u32 csr; +int ret; + + addr = (&GET_BARS (accel_dev)[ADF_4XXX_PMISC_BAR ])->virt_addr; + +/* Temporarily mask PM interrupt */ + csr =ADF_CSR_RD (addr,ADF_4XXX_ERRMSK2 ); + csr |=ADF_4XXX_PM_SOU ; +ADF_CSR_WR (addr,ADF_4XXX_ERRMSK2 , csr); + +/* Set DRV_ACTIVE bit to power up the device */ +ADF_CSR_WR (addr,ADF_4XXX_PM_INTERRUPT ,ADF_4XXX_PM_DRV_ACTIVE ); + +/* Poll status register to make sure the device is powered up */ + ret =read_poll_timeout (ADF_CSR_RD , status, + status &ADF_4XXX_PM_INIT_STATE , +ADF_4XXX_PM_POLL_DELAY_US , +ADF_4XXX_PM_POLL_TIMEOUT_US , true, addr, +ADF_4XXX_PM_STATUS ); +if (ret) +dev_err (&GET_DEV (accel_dev),"Failed to power up the device\n" ); + +return ret; +} +static int adf_enable_pf2vf_comms (struct adf_accel_dev *accel_dev) {return 0 ;
@@ -215,6 +245,7 @@ void adf_init_hw_data_4xxx(struct adf_hw_device_data *hw_data) hw_data->exit_arb = adf_exit_arb; hw_data->get_arb_mapping = adf_get_arbiter_mapping; hw_data->enable_ints = adf_enable_ints; + hw_data->init_device = adf_init_device; hw_data->reset_device = adf_reset_flr; hw_data->admin_ae_mask =ADF_4XXX_ADMIN_AE_MASK ; hw_data->uof_get_num_objs = uof_get_num_objs;
drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.h +10 -0
@@ -62,6 +62,16 @@#define ADF_4XXX_ADMINMSGLR_OFFSET (0x500578)#define ADF_4XXX_MAILBOX_BASE_OFFSET (0x600970) +/* Power management */ +#define ADF_4XXX_PM_POLL_DELAY_US 20 +#define ADF_4XXX_PM_POLL_TIMEOUT_US USEC_PER_SEC +#define ADF_4XXX_PM_STATUS (0x50A00C) +#define ADF_4XXX_PM_INTERRUPT (0x50A028) +#define ADF_4XXX_PM_DRV_ACTIVE BIT(20) +#define ADF_4XXX_PM_INIT_STATE BIT(21) +/* Power management source in ERRSOU2 and ERRMSK2 */ +#define ADF_4XXX_PM_SOU BIT(18) +/* Firmware Binaries */ #define ADF_4XXX_FW "qat_4xxx.bin"#define ADF_4XXX_MMP "qat_4xxx_mmp.bin"
drivers/crypto/qat/qat_common/adf_accel_devices.h +1 -0
@@ -170,6 +170,7 @@ struct adf_hw_device_data {int (*init_arb)(struct adf_accel_dev *accel_dev);void (*exit_arb)(struct adf_accel_dev *accel_dev);const u32 *(*get_arb_mapping)(void ); +int (*init_device)(struct adf_accel_dev *accel_dev);void (*disable_iov)(struct adf_accel_dev *accel_dev);void (*configure_iov_threads)(struct adf_accel_dev *accel_dev,bool enable);
drivers/crypto/qat/qat_common/adf_init.c +5 -0
@@ -79,6 +79,11 @@ int adf_dev_init(struct adf_accel_dev *accel_dev)return -EFAULT ; } +if (hw_data->init_device && hw_data->init_device (accel_dev)) { +dev_err (&GET_DEV (accel_dev),"Failed to initialize device\n" ); +return -EFAULT ; + } +if (hw_data->init_admin_comms && hw_data->init_admin_comms (accel_dev)) {dev_err (&GET_DEV (accel_dev),"Failed initialize admin comms\n" );return -EFAULT ;
Signature · 1 line
2.31.1
Herbert Xu
maintainerQuoted 32 lines · Giovanni Cabiddu
After reset or boot, QAT 4xxx devices are inactive and require to be explicitly activated.
This is done by writing theDRV_ACTIVEbit in thePM_INTERRUPTregister and polling thePM_INIT_STATEto make sure that the transaction has completed properly.If this is not done, the driver will fail the initialization sequence reporting the following message:
[ 22.081193] 4xxx 0000:f7:00.0: enabling device (0140 -> 0142) [ 22.720285] QAT: AE0 is inactive!! [ 22.720287] QAT: failed to get device out of reset [ 22.720288] 4xxx 0000:f7:00.0: qat_hal_clr_reset error [ 22.720290] 4xxx 0000:f7:00.0: Failed to init the AEs [ 22.720290] 4xxx 0000:f7:00.0: Failed to initialise Acceleration Engine [ 22.720789] 4xxx 0000:f7:00.0: Resetting device qat_dev0 [ 22.825099] 4xxx: probe of 0000:f7:00.0 failed with error -14The patch also temporarily disables the power management source of interrupt, to avoid possible spurious interrupts as the power management feature is not fully supported.
The device init function has been added to
adf_dev_init(), and not in the probe of 4xxx to make sure that the device is re-enabled in case of reset.Note that the error code reported by
hw_data->init_device()inadf_dev_init()has been shadowed for consistency with the other calls in the same function.Fixes 8c8268166e83 ("crypto: qat - add qat_4xxx driver")Signed-off-by Giovanni Cabiddu <[email protected]>Reviewed-by Wojciech Ziemba <[email protected]>
Quoted 6 lines
--- .../crypto/qat/qat_4xxx/adf_4xxx_hw_data.c | 31 +++++++++++++++++++ .../crypto/qat/qat_4xxx/adf_4xxx_hw_data.h | 10 ++++++ .../crypto/qat/qat_common/adf_accel_devices.h | 1 + drivers/crypto/qat/qat_common/adf_init.c | 5 +++ 4 files changed, 47 insertions(+)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Herbert Xu
maintainerHi Giovanni:
Quoted 19 lines · Giovanni Cabiddu
drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c +18
-0+static int adf_init_device (struct adf_accel_dev *accel_dev) +{ +void __iomem *addr; +u32 status; +u32 csr; +int ret; + + addr = (&GET_BARS (accel_dev)[ADF_4XXX_PMISC_BAR ])->virt_addr; + +/* Temporarily mask PM interrupt */ + csr =ADF_CSR_RD (addr,ADF_4XXX_ERRMSK2 ); + csr |=ADF_4XXX_PM_SOU ; +ADF_CSR_WR (addr,ADF_4XXX_ERRMSK2 , csr); + +/* Set DRV_ACTIVE bit to power up the device */ +ADF_CSR_WR (addr,ADF_4XXX_PM_INTERRUPT ,ADF_4XXX_PM_DRV_ACTIVE ); + +/* Poll status register to make sure the device is powered up */
drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c static void adf_enable_ints(struct adf_accel_dev *accel_dev) · line 192
Quoted 10 lines
drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c +10
-0+ ret =read_poll_timeout (ADF_CSR_RD , status, + status &ADF_4XXX_PM_INIT_STATE , +ADF_4XXX_PM_POLL_DELAY_US , +ADF_4XXX_PM_POLL_TIMEOUT_US , true, addr, +ADF_4XXX_PM_STATUS ); +if (ret) +dev_err (&GET_DEV (accel_dev),"Failed to power up the device\n" ); + +return ret; +}
I just received a bug report that this printk is triggering on a warm reboot via kexec:
https://issues.redhat.com/browse/RHEL-84366
[ 11.040319] vpr089-p05-15u kernel: 4xxx 0000:01:00.0: Failed to power up the device [ 11.148557] vpr089-p05-15u kernel: 4xxx 0000:01:00.0: Failed to initialize device [ 11.148702] vpr089-p05-15u kernel: 4xxx 0000:01:00.0: Resetting device qat_dev0 [ 11.148809] vpr089-p05-15u kernel: 4xxx 0000:01:00.0: probe with driver 4xxx failed with error -14
Could you please take a look at it?
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 18 lines · Herbert Xu
Hi Giovanni:
drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c static void adf_enable_ints(struct adf_accel_dev *accel_dev) · line 192
Quoted 11 lines · Giovanni Cabiddu
drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c +11
-0+/* Poll status register to make sure the device is powered up */ + ret =read_poll_timeout (ADF_CSR_RD , status, + status &ADF_4XXX_PM_INIT_STATE , +ADF_4XXX_PM_POLL_DELAY_US , +ADF_4XXX_PM_POLL_TIMEOUT_US , true, addr, +ADF_4XXX_PM_STATUS ); +if (ret) +dev_err (&GET_DEV (accel_dev),"Failed to power up the device\n" ); + +return ret; +}I just received a bug report that this printk is triggering on a warm reboot via kexec:
Quoted 8 lines
https://issues.redhat.com/browse/RHEL-84366
[ 11.040319] vpr089-p05-15u kernel: 4xxx 0000:01:00.0: Failed to power up the device [ 11.148557] vpr089-p05-15u kernel: 4xxx 0000:01:00.0: Failed to initialize device [ 11.148702] vpr089-p05-15u kernel: 4xxx 0000:01:00.0: Resetting device qat_dev0 [ 11.148809] vpr089-p05-15u kernel: 4xxx 0000:01:00.0: probe with driver 4xxx failed with error -14Could you please take a look at it?
Sure.
It could be that the device is not get properly reset during a warm reboot. I'm going to have a look.
Thanks,
Signature · 1 line
Giovanni