From: Chenghai Huang <huangchenghai2@huawei.com> When zstd uses blk_type to inform the driver that the previous block is an uncompressible block, the repcode of the current compression block should be based on the repcode of the last compressible block, rather than always using the repcode of the previous block regardless of whether it is compressible or not. Use CTX_REPCODE1_OFFSET as the address offset for storing the repcode of the previous block, and CTX_REPCODE2_OFFSET as the address offset for storing the repcode of the last compressible block. Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com> Signed-off-by: Zongyu Wu <wuzongyu1@huawei.com> --- drv/hisi_comp.c | 16 +++++++++------- v1/drv/hisi_zip_udrv.c | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/drv/hisi_comp.c b/drv/hisi_comp.c index 87d2103..ab2b5e7 100644 --- a/drv/hisi_comp.c +++ b/drv/hisi_comp.c @@ -822,9 +822,14 @@ static int fill_buf_lz77_zstd(handle_t h_qp, struct hisi_zip_sqe *sqe, if (msg->ctx_buf) { ctx_buf = msg->ctx_buf + RSV_OFFSET; - if (msg->alg_type == WD_LZ77_ZSTD && data->blk_type != COMP_BLK) - memcpy(ctx_buf + CTX_HW_REPCODE_OFFSET, - msg->ctx_buf + CTX_REPCODE2_OFFSET, REPCODE_SIZE); + if (msg->alg_type == WD_LZ77_ZSTD) { + if (data->blk_type != COMP_BLK) + memcpy(ctx_buf + CTX_HW_REPCODE_OFFSET, + msg->ctx_buf + CTX_REPCODE2_OFFSET, REPCODE_SIZE); + else + memcpy(msg->ctx_buf + CTX_REPCODE2_OFFSET, + msg->ctx_buf + CTX_REPCODE1_OFFSET, REPCODE_SIZE); + } } fill_buf_size_lz77_zstd(sqe, in_size, lits_size, seq_avail_out); @@ -1203,12 +1208,9 @@ static void get_data_size_lz77_zstd(struct hisi_zip_sqe *sqe, enum wd_comp_op_ty data->freq = data->sequences_start + (data->seq_num << SEQ_DATA_SIZE_SHIFT) + OVERFLOW_DATA_SIZE; - if (ctx_buf) { - memcpy(ctx_buf + CTX_REPCODE2_OFFSET, - ctx_buf + CTX_REPCODE1_OFFSET, REPCODE_SIZE); + if (ctx_buf) memcpy(ctx_buf + CTX_REPCODE1_OFFSET, ctx_buf + RSV_OFFSET + CTX_HW_REPCODE_OFFSET, REPCODE_SIZE); - } } } diff --git a/v1/drv/hisi_zip_udrv.c b/v1/drv/hisi_zip_udrv.c index ab4254e..8908e27 100644 --- a/v1/drv/hisi_zip_udrv.c +++ b/v1/drv/hisi_zip_udrv.c @@ -687,9 +687,14 @@ static void fill_zip_sqe_hw_info_lz77_zstd(void *ssqe, struct wcrypto_comp_msg * sqe->ctx_dw0 = *(__u32 *)msg->ctx_buf; sqe->ctx_dw1 = *(__u32 *)(msg->ctx_buf + CTX_PRIV1_OFFSET); sqe->ctx_dw2 = *(__u32 *)(msg->ctx_buf + CTX_PRIV2_OFFSET); - if (format->blk_type != COMP_BLK) - memcpy(msg->ctx_buf + CTX_HW_REPCODE_OFFSET + CTX_BUFFER_OFFSET, - msg->ctx_buf + CTX_REPCODE2_OFFSET, REPCODE_SIZE); + if (msg->alg_type == WCRYPTO_LZ77_ZSTD) { + if (format->blk_type != COMP_BLK) + memcpy(msg->ctx_buf + CTX_HW_REPCODE_OFFSET + CTX_BUFFER_OFFSET, + msg->ctx_buf + CTX_REPCODE2_OFFSET, REPCODE_SIZE); + else + memcpy(msg->ctx_buf + CTX_REPCODE2_OFFSET, + msg->ctx_buf + CTX_REPCODE1_OFFSET, REPCODE_SIZE); + } } sqe->isize = msg->isize; @@ -820,13 +825,10 @@ static void fill_priv_lz77_zstd(void *ssqe, struct wcrypto_comp_msg *recv_msg) OVERFLOW_DATA_SIZE; } - if (ctx_buf) { - memcpy(ctx_buf + CTX_REPCODE2_OFFSET, - ctx_buf + CTX_REPCODE1_OFFSET, REPCODE_SIZE); + if (ctx_buf) memcpy(ctx_buf + CTX_REPCODE1_OFFSET, ctx_buf + CTX_BUFFER_OFFSET + CTX_HW_REPCODE_OFFSET, REPCODE_SIZE); - } } int qm_parse_zip_sqe_v3(void *hw_msg, const struct qm_queue_info *info, -- 2.33.0