crypto: qat - fix firmware loader
cover crypto: qat - fix firmware loader
This patchset is to fix some issues in the QAT firmware loader:
* Patches #1 to #3, check the MMP binary size and return error if too large
* Patch #4 fixes a problem detected by clang static
* Patch #5 fixes a compiling warnings when building with clang
Jack Xu (5):
crypto: qat - return error when failing to map FW
crypto: qat - check MMP size before writing to the SRAM
crypto: qat - report an error if MMP file size is too large
crypto: qat - check return code of qat_hal_rd_rel_reg()
crypto: qat - remove unused macro in FW loader
.../qat/qat_common/icp_qat_fw_loader_handle.h | 2 +- drivers/crypto/qat/qat_common/qat_hal.c | 14 +++++++++----- drivers/crypto/qat/qat_common/qat_uclo.c | 12 +++++------- 3 files changed, 15 insertions(+), 13 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/5 crypto: qat - return error when failing to map FW
Save the return value of qat_uclo_map_auth_fw() function so that the function qat_uclo_wr_mimage() could return the correct value. This way, the procedure of adf_gen2_ae_fw_load() function could stop and exit properly by checking the return value of qat_uclo_wr_mimage().
--- drivers/crypto/qat/qat_common/qat_uclo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/qat/qat_common/qat_uclo.c +2 -1
@@ -1546,7 +1546,8 @@ int qat_uclo_wr_mimage(struct icp_qat_fw_loader_handle *handle,int status =0 ;if (handle->chip_info->fw_auth) { -if (!qat_uclo_map_auth_fw (handle, addr_ptr, mem_size, &desc)) + status =qat_uclo_map_auth_fw (handle, addr_ptr, mem_size, &desc); +if (!status) status =qat_uclo_auth_fw (handle, desc);qat_uclo_ummap_auth_fw (handle, &desc); }else {
Signature · 1 line
2.31.1
PATCH 2/5 crypto: qat - check MMP size before writing to the SRAM
In reply to Jack XuChange "sram_visible" to "mmp_sram_size" and compare it with the MMP size to prevent an overly large MMP file being written to SRAM.
--- drivers/crypto/qat/qat_common/icp_qat_fw_loader_handle.h | 2 +- drivers/crypto/qat/qat_common/qat_hal.c | 8 ++++---- drivers/crypto/qat/qat_common/qat_uclo.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/crypto/qat/qat_common/icp_qat_fw_loader_handle.h +1 -1
@@ -24,7 +24,7 @@ struct icp_qat_fw_loader_hal_handle { };struct icp_qat_fw_loader_chip_info { -bool sram_visible; +int mmp_sram_size;bool nn;bool lm2lm3;u32 lm_size;
drivers/crypto/qat/qat_common/qat_hal.c +4 -4
@@ -696,7 +696,7 @@ static int qat_hal_chip_init(struct icp_qat_fw_loader_handle *handle, handle->pci_dev = pci_info->pci_dev;switch (handle->pci_dev->device) {case ADF_4XXX_PCI_DEVICE_ID : - handle->chip_info->sram_visible = false; + handle->chip_info->mmp_sram_size =0 ; handle->chip_info->nn = false; handle->chip_info->lm2lm3 = true; handle->chip_info->lm_size =ICP_QAT_UCLO_MAX_LMEM_REG_2X ;
@@ -730,7 +730,7 @@ static int qat_hal_chip_init(struct icp_qat_fw_loader_handle *handle,break ;case PCI_DEVICE_ID_INTEL_QAT_C62X :case PCI_DEVICE_ID_INTEL_QAT_C3XXX : - handle->chip_info->sram_visible = false; + handle->chip_info->mmp_sram_size =0 ; handle->chip_info->nn = true; handle->chip_info->lm2lm3 = false; handle->chip_info->lm_size =ICP_QAT_UCLO_MAX_LMEM_REG ;
@@ -763,7 +763,7 @@ static int qat_hal_chip_init(struct icp_qat_fw_loader_handle *handle, + LOCAL_TO_XFER_REG_OFFSET);break ;case PCI_DEVICE_ID_INTEL_QAT_DH895XCC : - handle->chip_info->sram_visible = true; + handle->chip_info->mmp_sram_size =0x40000 ; handle->chip_info->nn = true; handle->chip_info->lm2lm3 = false; handle->chip_info->lm_size =ICP_QAT_UCLO_MAX_LMEM_REG ;
@@ -800,7 +800,7 @@ static int qat_hal_chip_init(struct icp_qat_fw_loader_handle *handle, goto out_err; } -if (handle->chip_info->sram_visible) { +if (handle->chip_info->mmp_sram_size >0 ) { sram_bar = &pci_info->pci_bars[hw_data->get_sram_bar_id (hw_data)]; handle->hal_sram_addr_v = sram_bar->virt_addr;
drivers/crypto/qat/qat_common/qat_uclo.c +1 -1
@@ -1551,7 +1551,7 @@ int qat_uclo_wr_mimage(struct icp_qat_fw_loader_handle *handle, status =qat_uclo_auth_fw (handle, desc);qat_uclo_ummap_auth_fw (handle, &desc); }else { -if (!handle->chip_info->sram_visible) { +if (handle->chip_info->mmp_sram_size < mem_size) {dev_dbg (&handle->pci_dev->dev,"QAT MMP fw not loaded for device 0x%x" , handle->pci_dev->device);
Signature · 1 line
2.31.1
PATCH 3/5 crypto: qat - report an error if MMP file size is too large
In reply to Jack XuChange the return status to error if MMP file size is too large so the driver load fails early if a large MMP firmware is loaded.
--- drivers/crypto/qat/qat_common/qat_uclo.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/crypto/qat/qat_common/qat_uclo.c +2 -4
@@ -1552,10 +1552,8 @@ int qat_uclo_wr_mimage(struct icp_qat_fw_loader_handle *handle,qat_uclo_ummap_auth_fw (handle, &desc); }else {if (handle->chip_info->mmp_sram_size < mem_size) { -dev_dbg (&handle->pci_dev->dev, -"QAT MMP fw not loaded for device 0x%x" , - handle->pci_dev->device); -return status; +pr_err ("QAT: MMP size is too large: 0x%x\n" , mem_size); +return -EFBIG ; }qat_uclo_wr_sram_by_words (handle,0 , addr_ptr, mem_size); }
Signature · 1 line
2.31.1
PATCH 4/5 crypto: qat - check return code of qat_hal_rd_rel_reg()
In reply to Jack XuCheck the return code of the function qat_hal_rd_rel_reg() and return it to the caller.
This is to fix the following warning when compiling the driver with clang scan-build:
drivers/crypto/qat/qat_common/qat_hal.c:1436:2: warning: 6th function call argument is an uninitialized value
--- drivers/crypto/qat/qat_common/qat_hal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/crypto/qat/qat_common/qat_hal.c +5 -1
@@ -1417,7 +1417,11 @@ static int qat_hal_put_rel_wr_xfer(struct icp_qat_fw_loader_handle *handle,pr_err ("QAT: bad xfrAddr=0x%x\n" , xfr_addr);return -EINVAL ; } -qat_hal_rd_rel_reg (handle, ae, ctx,ICP_GPB_REL , gprnum, &gprval); + status =qat_hal_rd_rel_reg (handle, ae, ctx,ICP_GPB_REL , gprnum, &gprval); +if (status) { +pr_err ("QAT: failed to read register" ); +return status; + } gpr_addr =qat_hal_get_reg_addr (ICP_GPB_REL , gprnum); data16low =0xffff & data; data16hi =0xffff & (data >>0x10 );
Signature · 1 line
2.31.1
PATCH 5/5 crypto: qat - remove unused macro in FW loader
In reply to Jack XuRemove the unused macro ICP_DH895XCC_PESRAM_BAR_SIZE in the firmware loader.
This is to fix the following warning when compiling the driver using the clang compiler with CC=clang W=2:
drivers/crypto/qat/qat_common/qat_uclo.c:345:9: warning: macro is not used [-Wunused-macros]
--- drivers/crypto/qat/qat_common/qat_uclo.c | 1 - 1 file changed, 1 deletion(-)
drivers/crypto/qat/qat_common/qat_uclo.c +0 -1
@@ -342,7 +342,6 @@ static int qat_uclo_init_umem_seg(struct icp_qat_fw_loader_handle *handle,return 0 ; } -#define ICP_DH895XCC_PESRAM_BAR_SIZE 0x80000static int qat_uclo_init_ae_memory (struct icp_qat_fw_loader_handle *handle,struct icp_qat_uof_initmem *init_mem) {
Signature · 1 line
2.31.1
Herbert Xu
maintainerQuoted 13 lines · Jack Xu
This patchset is to fix some issues in the QAT firmware loader:
* Patches #1 to #3, check the MMP binary size and return error if too large
* Patch #4 fixes a problem detected by clang static
* Patch #5 fixes a compiling warnings when building with clangJack Xu (5):
crypto: qat - return error when failing to map FW
crypto: qat - check MMP size before writing to the SRAM
crypto: qat - report an error if MMP file size is too large
crypto: qat - check return code ofqat_hal_rd_rel_reg()
crypto: qat - remove unused macro in FW loader
Quoted 4 lines
.../qat/qat_common/icp_qat_fw_loader_handle.h | 2 +- drivers/crypto/qat/qat_common/qat_hal.c | 14 +++++++++----- drivers/crypto/qat/qat_common/qat_uclo.c | 12 +++++------- 3 files changed, 15 insertions(+), 13 deletions(-)
All 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