Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1440824ybl; Fri, 10 Jan 2020 18:49:17 -0800 (PST) X-Google-Smtp-Source: APXvYqwPZpho2Gam+1HaidUxwITRPZiWsBbOe1jyw3CWUUiha+Y1DJSfXFu92kZNlnmLmb09tJnu X-Received: by 2002:aca:d6c4:: with SMTP id n187mr5104583oig.29.1578710957274; Fri, 10 Jan 2020 18:49:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578710957; cv=none; d=google.com; s=arc-20160816; b=ebe7mu4YVv/ohWQ2ZZpDd96NBvA413oOQymBRzL1E2A185gxdnWRbtHQls1hK5oXsf ySGWC9uEu6OPD+CLNipFwyeV3dA5sXto4szoTwJC6IXnKlEh+L6lH04BSxNeTqSA2jvH AZxZKzcapdlUtbbcbquA6c75Fp8rAYEe4WN/Y/rizQKJPeRZhd+n/+x4ewQPkeZHV7ao 3ja5oEwl3YBAlHad0ok4XxIQwb/77qwCsWO0uome3884+H+Z9tB+ghHyoee5ptrRpWHk FwwSwFJV+8W+kLX9Q4JiD5brRrOSQymR96RZagw28QXve9X8WPu0TW5CsBNV2JwEz+7O kefg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=hv1940aDhpNP4/oeX4lDU5E8Xx4MvCj+KblEhf9TL/Q=; b=VXHTkXo6fQiAVkx1KtHIYUuEh0DHxxk2KruvUGRtfqbyMJTaXaFTsEvpaVjba6FcST QtpXbgKyr+6yqVQx8WEI97g0v5UjPR5BDLJ653IyAoz+ZnTT2Afb/N8SrdKgsbV0B6/p mtg7ldwOMqoo+HEPUwEZe7tD9Sxv6d7bq61PTiH6ob640I3IkuiLt8HUMDcs1il1VFXN m+4vi8KolCZXq8nfvrcbjMLHIJAw3wSxJpSHmlLnlTWEJecAQiu6mb6l9oMoOwDFlob8 WKiEbk42ipVRTT2tUFLu7/nPD3t5kNLI80lSLGk3WRxRwp4Ykeh7Q4b07V1ti2ZTq/HC QU0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6si2627174otp.5.2020.01.10.18.49.06; Fri, 10 Jan 2020 18:49:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728200AbgAKCpv (ORCPT + 99 others); Fri, 10 Jan 2020 21:45:51 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:45380 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728195AbgAKCpv (ORCPT ); Fri, 10 Jan 2020 21:45:51 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 56A80761319FBECDECC4; Sat, 11 Jan 2020 10:45:49 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.439.0; Sat, 11 Jan 2020 10:45:41 +0800 From: Zaibo Xu To: , CC: , , , , , , , , , , Subject: [PATCH v2 1/9] crypto: hisilicon - Update debugfs usage of SEC V2 Date: Sat, 11 Jan 2020 10:41:48 +0800 Message-ID: <1578710516-40535-2-git-send-email-xuzaibo@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1578710516-40535-1-git-send-email-xuzaibo@huawei.com> References: <1578710516-40535-1-git-send-email-xuzaibo@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-CFilter-Loop: Reflected Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 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 Reported-by: Marco Elver Signed-off-by: Zaibo Xu --- drivers/crypto/hisilicon/sec2/sec.h | 2 +- drivers/crypto/hisilicon/sec2/sec_crypto.c | 8 ++++---- drivers/crypto/hisilicon/sec2/sec_main.c | 18 +++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/crypto/hisilicon/sec2/sec.h b/drivers/crypto/hisilicon/sec2/sec.h index b846d73..841f4c5 100644 --- a/drivers/crypto/hisilicon/sec2/sec.h +++ b/drivers/crypto/hisilicon/sec2/sec.h @@ -40,7 +40,7 @@ struct sec_req { int req_id; /* Status of the SEC request */ - atomic_t fake_busy; + bool fake_busy; }; /** diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c index 0a5391f..2475aaf 100644 --- a/drivers/crypto/hisilicon/sec2/sec_crypto.c +++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c @@ -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; @@ -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); @@ -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) { diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c index ab742df..d40e2da 100644 --- a/drivers/crypto/hisilicon/sec2/sec_main.c +++ b/drivers/crypto/hisilicon/sec2/sec_main.c @@ -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) { @@ -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; } -- 2.8.1