Skip to content
/ linux Public

Commit 963d8f9

Browse files
Chenghai HuangSasha Levin
authored andcommitted
crypto: hisilicon/zip - adjust the way to obtain the req in the callback function
[ Upstream commit 19c2475 ] In the shared queue design, multiple tfms use same qp, and one qp need to corresponds to multiple qp_ctx. So use tag to obtain the req virtual address. Build a one-to-one relationship between tfm and qp_ctx. finaly remove the old get_tag operation. Fixes: 2bcf363 ("crypto: hisilicon/zip - initialize operations about 'sqe' in 'acomp_alg.init'") Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com> Signed-off-by: Weili Qian <qianweili@huawei.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 87a1b86 commit 963d8f9

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

drivers/crypto/hisilicon/zip/zip_crypto.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ enum {
3636
HZIP_CTX_Q_NUM
3737
};
3838

39+
#define GET_REQ_FROM_SQE(sqe) ((u64)(sqe)->dw26 | (u64)(sqe)->dw27 << 32)
3940
#define COMP_NAME_TO_TYPE(alg_name) \
4041
(!strcmp((alg_name), "deflate") ? HZIP_ALG_TYPE_DEFLATE : 0)
4142

@@ -45,6 +46,7 @@ struct hisi_zip_req {
4546
struct hisi_acc_hw_sgl *hw_dst;
4647
dma_addr_t dma_src;
4748
dma_addr_t dma_dst;
49+
struct hisi_zip_qp_ctx *qp_ctx;
4850
u16 req_id;
4951
};
5052

@@ -71,7 +73,6 @@ struct hisi_zip_sqe_ops {
7173
void (*fill_req_type)(struct hisi_zip_sqe *sqe, u8 req_type);
7274
void (*fill_tag)(struct hisi_zip_sqe *sqe, struct hisi_zip_req *req);
7375
void (*fill_sqe_type)(struct hisi_zip_sqe *sqe, u8 sqe_type);
74-
u32 (*get_tag)(struct hisi_zip_sqe *sqe);
7576
u32 (*get_status)(struct hisi_zip_sqe *sqe);
7677
u32 (*get_dstlen)(struct hisi_zip_sqe *sqe);
7778
};
@@ -128,6 +129,7 @@ static struct hisi_zip_req *hisi_zip_create_req(struct hisi_zip_qp_ctx *qp_ctx,
128129
req_cache = q + req_id;
129130
req_cache->req_id = req_id;
130131
req_cache->req = req;
132+
req_cache->qp_ctx = qp_ctx;
131133

132134
return req_cache;
133135
}
@@ -178,7 +180,8 @@ static void hisi_zip_fill_req_type(struct hisi_zip_sqe *sqe, u8 req_type)
178180

179181
static void hisi_zip_fill_tag(struct hisi_zip_sqe *sqe, struct hisi_zip_req *req)
180182
{
181-
sqe->dw26 = req->req_id;
183+
sqe->dw26 = lower_32_bits((u64)req);
184+
sqe->dw27 = upper_32_bits((u64)req);
182185
}
183186

184187
static void hisi_zip_fill_sqe_type(struct hisi_zip_sqe *sqe, u8 sqe_type)
@@ -232,7 +235,7 @@ static int hisi_zip_do_work(struct hisi_zip_qp_ctx *qp_ctx,
232235
&req->dma_dst);
233236
if (IS_ERR(req->hw_dst)) {
234237
ret = PTR_ERR(req->hw_dst);
235-
dev_err(dev, "failed to map the dst buffer to hw slg (%d)!\n",
238+
dev_err(dev, "failed to map the dst buffer to hw sgl (%d)!\n",
236239
ret);
237240
goto err_unmap_input;
238241
}
@@ -258,11 +261,6 @@ static int hisi_zip_do_work(struct hisi_zip_qp_ctx *qp_ctx,
258261
return ret;
259262
}
260263

261-
static u32 hisi_zip_get_tag(struct hisi_zip_sqe *sqe)
262-
{
263-
return sqe->dw26;
264-
}
265-
266264
static u32 hisi_zip_get_status(struct hisi_zip_sqe *sqe)
267265
{
268266
return sqe->dw3 & HZIP_BD_STATUS_M;
@@ -275,14 +273,12 @@ static u32 hisi_zip_get_dstlen(struct hisi_zip_sqe *sqe)
275273

276274
static void hisi_zip_acomp_cb(struct hisi_qp *qp, void *data)
277275
{
278-
struct hisi_zip_qp_ctx *qp_ctx = qp->qp_ctx;
276+
struct hisi_zip_sqe *sqe = data;
277+
struct hisi_zip_req *req = (struct hisi_zip_req *)GET_REQ_FROM_SQE(sqe);
278+
struct hisi_zip_qp_ctx *qp_ctx = req->qp_ctx;
279279
const struct hisi_zip_sqe_ops *ops = qp_ctx->ctx->ops;
280280
struct hisi_zip_dfx *dfx = &qp_ctx->zip_dev->dfx;
281-
struct hisi_zip_req_q *req_q = &qp_ctx->req_q;
282281
struct device *dev = &qp->qm->pdev->dev;
283-
struct hisi_zip_sqe *sqe = data;
284-
u32 tag = ops->get_tag(sqe);
285-
struct hisi_zip_req *req = req_q->q + tag;
286282
struct acomp_req *acomp_req = req->req;
287283
int err = 0;
288284
u32 status;
@@ -386,7 +382,6 @@ static const struct hisi_zip_sqe_ops hisi_zip_ops = {
386382
.fill_req_type = hisi_zip_fill_req_type,
387383
.fill_tag = hisi_zip_fill_tag,
388384
.fill_sqe_type = hisi_zip_fill_sqe_type,
389-
.get_tag = hisi_zip_get_tag,
390385
.get_status = hisi_zip_get_status,
391386
.get_dstlen = hisi_zip_get_dstlen,
392387
};
@@ -574,7 +569,6 @@ static void hisi_zip_acomp_exit(struct crypto_acomp *tfm)
574569
{
575570
struct hisi_zip_ctx *ctx = crypto_tfm_ctx(&tfm->base);
576571

577-
hisi_zip_set_acomp_cb(ctx, NULL);
578572
hisi_zip_release_sgl_pool(ctx);
579573
hisi_zip_release_req_q(ctx);
580574
hisi_zip_ctx_exit(ctx);

0 commit comments

Comments
 (0)