Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp377455ybl; Thu, 9 Jan 2020 23:54:31 -0800 (PST) X-Google-Smtp-Source: APXvYqyDiu2h0QY1VVgJ6rikZLo+t/xXjs2+Yfc5lMZsOEIwiHK2eJXF584vM1SGl3aIgFheYJ+i X-Received: by 2002:a9d:70d9:: with SMTP id w25mr1582896otj.231.1578642870802; Thu, 09 Jan 2020 23:54:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578642870; cv=none; d=google.com; s=arc-20160816; b=eGPjoDud2IsBrvQps5jFPeWbgDpUmRmlbpC5I4QLCgBcAhih+X9Vt2oUFolI+4hX+l CJClt04LuoyPVD3i5BnXHCplaPLDSLTtU8Xj4ZlG0NODdc66BiL3Uxi2SuaGtaN5R3iY BvWgQJh9tJYko3x3ecBYXCJdBS8kMKNR9TVQMLj/sVmw6amK9idPEqfHEtZ1/pMmb4ls bWc0hxE8Jvu4YbXf7YQsmdko4ouZNkkYWaLnX3HUV7ktYS+PfKvys4clzPeaHh/17yu6 0K+iaYu+adZSqiiK1WtmUdtfV2RGO6PqQ8UH2DJi+J3xwZOOqS9PZK2ZjZebGCQQVN0r HxNw== 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=4T8R/OHp8IUfH3p73E4AcP3RvxS21wwtMj4gnHlWkDY=; b=kDNhE5O96xBu5h7XEuWLdR3UoFmF5AlmH9e1UP0WnLd6yX0cvbvlgXYlK5J8paTk5C Lrkc4MU06tXDJHyA8vjJDzVOQpiHiJXn7N8YJ2qKpu6gc2aQX33tzx5CZ7JvRNjurYU3 BbwAu5jcmdrq5yZgYoFmlyIvAcYjw/kdEqrXgiQ5JlDUNYWYhkQo4i9AXlEvcGJapxoh NZl02uDkPouN+AatJL1yD6hfTGLWfudMjSzCi8Cv7i/i2ksZouo8uts1cqLrAquKaJkc xLGPuVfqauHWeak+/M+b8ILyLQO8Gp8+6zvvIG+d+aF00DuS/EvKEwAVNR52WnMRB3HR 9ZUg== 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 w19si749720otj.209.2020.01.09.23.53.56; Thu, 09 Jan 2020 23:54:30 -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 S1726598AbgAJHxz (ORCPT + 99 others); Fri, 10 Jan 2020 02:53:55 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:42438 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726401AbgAJHxy (ORCPT ); Fri, 10 Jan 2020 02:53:54 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id F06C69CB4F3436C2AF8C; Fri, 10 Jan 2020 15:53:51 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Fri, 10 Jan 2020 15:53:44 +0800 From: Zaibo Xu To: , CC: , , , , , , , , , , Subject: [PATCH 6/9] crypto: hisilicon - Add callback error check Date: Fri, 10 Jan 2020 15:49:55 +0800 Message-ID: <1578642598-8584-7-git-send-email-xuzaibo@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1578642598-8584-1-git-send-email-xuzaibo@huawei.com> References: <1578642598-8584-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 Add error type parameter for call back checking inside. Signed-off-by: Zaibo Xu --- drivers/crypto/hisilicon/sec2/sec.h | 2 +- drivers/crypto/hisilicon/sec2/sec_crypto.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/crypto/hisilicon/sec2/sec.h b/drivers/crypto/hisilicon/sec2/sec.h index c3b6012..97d5150 100644 --- a/drivers/crypto/hisilicon/sec2/sec.h +++ b/drivers/crypto/hisilicon/sec2/sec.h @@ -56,7 +56,7 @@ struct sec_req_op { void (*do_transfer)(struct sec_ctx *ctx, struct sec_req *req); int (*bd_fill)(struct sec_ctx *ctx, struct sec_req *req); int (*bd_send)(struct sec_ctx *ctx, struct sec_req *req); - void (*callback)(struct sec_ctx *ctx, struct sec_req *req); + void (*callback)(struct sec_ctx *ctx, struct sec_req *req, int err); int (*process)(struct sec_ctx *ctx, struct sec_req *req); }; diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c index a6d5207..568c174 100644 --- a/drivers/crypto/hisilicon/sec2/sec_crypto.c +++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c @@ -104,6 +104,7 @@ static void sec_req_cb(struct hisi_qp *qp, void *resp) struct sec_ctx *ctx; struct sec_req *req; u16 done, flag; + int err = 0; u8 type; type = bd->type_cipher_auth & SEC_TYPE_MASK; @@ -119,16 +120,18 @@ static void sec_req_cb(struct hisi_qp *qp, void *resp) flag = (le16_to_cpu(bd->type2.done_flag) & SEC_FLAG_MASK) >> SEC_FLAG_OFFSET; if (req->err_type || done != SEC_SQE_DONE || - flag != SEC_SQE_CFLAG) + flag != SEC_SQE_CFLAG) { dev_err(SEC_CTX_DEV(ctx), "err_type[%d],done[%d],flag[%d]\n", req->err_type, done, flag); + err = -EIO; + } atomic64_inc(&ctx->sec->debug.dfx.recv_cnt); ctx->req_op->buf_unmap(ctx, req); - ctx->req_op->callback(ctx, req); + ctx->req_op->callback(ctx, req, err); } static int sec_bd_send(struct sec_ctx *ctx, struct sec_req *req) @@ -618,7 +621,8 @@ static void sec_update_iv(struct sec_req *req) dev_err(SEC_CTX_DEV(req->ctx), "copy output iv error!\n"); } -static void sec_skcipher_callback(struct sec_ctx *ctx, struct sec_req *req) +static void sec_skcipher_callback(struct sec_ctx *ctx, struct sec_req *req, + int err) { struct skcipher_request *sk_req = req->c_req.sk_req; struct sec_qp_ctx *qp_ctx = req->qp_ctx; @@ -627,13 +631,13 @@ static void sec_skcipher_callback(struct sec_ctx *ctx, struct sec_req *req) sec_free_req_id(req); /* IV output at encrypto of CBC mode */ - if (ctx->c_ctx.c_mode == SEC_CMODE_CBC && req->c_req.encrypt) + if (!err && ctx->c_ctx.c_mode == SEC_CMODE_CBC && req->c_req.encrypt) sec_update_iv(req); if (req->fake_busy) sk_req->base.complete(&sk_req->base, -EINPROGRESS); - sk_req->base.complete(&sk_req->base, req->err_type); + sk_req->base.complete(&sk_req->base, err); } static void sec_request_uninit(struct sec_ctx *ctx, struct sec_req *req) -- 2.8.1