Skip to content

Commit

Permalink
crypto: hisilicon - Update debugfs usage of SEC V2
Browse files Browse the repository at this point in the history
Applied some advices of Marco Elver on atomic usage of Debugfs,
which is carried out by basing on Arnd Bergmann's fixing patch.

Reported-by: Arnd Bergmann <[email protected]>
Reported-by: Marco Elver <[email protected]>
Signed-off-by: Zaibo Xu <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
zaiboxu authored and herbertx committed Jan 16, 2020
1 parent 279c075 commit ca0d158
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion drivers/crypto/hisilicon/sec2/sec.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct sec_req {
int req_id;

/* Status of the SEC request */
atomic_t fake_busy;
bool fake_busy;
};

/**
Expand Down
8 changes: 4 additions & 4 deletions drivers/crypto/hisilicon/sec2/sec_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static int sec_bd_send(struct sec_ctx *ctx, struct sec_req *req)
return -ENOBUFS;

if (!ret) {
if (atomic_read(&req->fake_busy))
if (req->fake_busy)
ret = -EBUSY;
else
ret = -EINPROGRESS;
Expand Down Expand Up @@ -641,7 +641,7 @@ static void sec_skcipher_callback(struct sec_ctx *ctx, struct sec_req *req)
if (ctx->c_ctx.c_mode == SEC_CMODE_CBC && req->c_req.encrypt)
sec_update_iv(req);

if (atomic_cmpxchg(&req->fake_busy, 1, 0) != 1)
if (req->fake_busy)
sk_req->base.complete(&sk_req->base, -EINPROGRESS);

sk_req->base.complete(&sk_req->base, req->err_type);
Expand Down Expand Up @@ -672,9 +672,9 @@ static int sec_request_init(struct sec_ctx *ctx, struct sec_req *req)
}

if (ctx->fake_req_limit <= atomic_inc_return(&qp_ctx->pending_reqs))
atomic_set(&req->fake_busy, 1);
req->fake_busy = true;
else
atomic_set(&req->fake_busy, 0);
req->fake_busy = false;

ret = ctx->req_op->get_res(ctx, req);
if (ret) {
Expand Down
18 changes: 9 additions & 9 deletions drivers/crypto/hisilicon/sec2/sec_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,13 +608,13 @@ static const struct file_operations sec_dbg_fops = {
.write = sec_debug_write,
};

static int debugfs_atomic64_t_get(void *data, u64 *val)
static int sec_debugfs_atomic64_get(void *data, u64 *val)
{
*val = atomic64_read((atomic64_t *)data);
return 0;
*val = atomic64_read((atomic64_t *)data);
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(fops_atomic64_t_ro, debugfs_atomic64_t_get, NULL,
"%lld\n");
DEFINE_DEBUGFS_ATTRIBUTE(sec_atomic64_ops, sec_debugfs_atomic64_get,
NULL, "%lld\n");

static int sec_core_debug_init(struct sec_dev *sec)
{
Expand All @@ -636,11 +636,11 @@ static int sec_core_debug_init(struct sec_dev *sec)

debugfs_create_regset32("regs", 0444, tmp_d, regset);

debugfs_create_file("send_cnt", 0444, tmp_d, &dfx->send_cnt,
&fops_atomic64_t_ro);
debugfs_create_file("send_cnt", 0444, tmp_d,
&dfx->send_cnt, &sec_atomic64_ops);

debugfs_create_file("recv_cnt", 0444, tmp_d, &dfx->recv_cnt,
&fops_atomic64_t_ro);
debugfs_create_file("recv_cnt", 0444, tmp_d,
&dfx->recv_cnt, &sec_atomic64_ops);

return 0;
}
Expand Down

0 comments on commit ca0d158

Please sign in to comment.