From patchwork Thu Sep 7 09:00:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 111874 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp517066qge; Thu, 7 Sep 2017 02:01:50 -0700 (PDT) X-Google-Smtp-Source: ADKCNb480+c9vdqf/FlA9KT6GjEro+ZWtTW7AF+LAMGXpBmhEQC+spOWbpGiqJRtrJCo4zbon/iJ X-Received: by 10.84.129.34 with SMTP id 31mr2294564plb.282.1504774909995; Thu, 07 Sep 2017 02:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504774909; cv=none; d=google.com; s=arc-20160816; b=mHS8RZuoR9B+qhrcI5I/mKad4JUuIG30drjpFG4agltbN/mJeFZq1Q60TkdomSXVs+ MYOPA1qFwzQ+Oh7PyV3v5tGfbtRWG9gKGTpLbCIH57tUvQQrAvPICZ9JJ7CDLPUdaUMh FUQP28J2uEFKC9UKHWyu6eBWogoNHG49bJ3yJnS9gK3mj9rwdG+0Ytg5dtVIctESRfIw nVBZ/t+0dzHeW/e+bxXKITrp2rUGTkuWUSL2662HIZugWdn8Y1gzyR859VFBA6YPpYbS YRlFCxUwek8mtNPp+6ShrcvR+oyPgTaGz+7QaQ82sulSYnj7m4ipnuySKW25HvbS3PXy i2cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=ygVRmwXQzWKb702PQIYi0AFGAis9YqVvuo2lFaJW/Gk=; b=MsBfvWw0stUurg8REuuGs5quQm4yEBj0q4dPtBvTOFU6Gz3XILfqrjGn1PTw139fsL oDMKG4YpDK/DqcBwyd7NVxHu562IsL/PYSwsvPtcZ7DVnddsKwFRcK8UyAUuqM0a2dfg 8pjFN4Aydn7HZlGjfow0Qzgs1d18CZtBSA9eQve3OVVHSOWIf1Utl/cBHvKyinkdyhul w8IWEYPJoGtzUiGMno3zt4ofvehqnT2Zw0zghQQXr94w+iFK4CwHmACK+8Twv3oJX2A1 SdTH30mpCRwckEPION/ZJR86x3ZxVmg10KeGBL4S88hR+2+yYdLH/eu9UkIKGos+ddUx VNSQ== 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 f12si2014550plt.140.2017.09.07.02.01.49; Thu, 07 Sep 2017 02:01:49 -0700 (PDT) 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 S1755047AbdIGJBs (ORCPT + 1 other); Thu, 7 Sep 2017 05:01:48 -0400 Received: from foss.arm.com ([217.140.101.70]:57286 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755044AbdIGJBq (ORCPT ); Thu, 7 Sep 2017 05:01:46 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7400280D; Thu, 7 Sep 2017 02:01:46 -0700 (PDT) Received: from gby.kfn.arm.com (unknown [10.45.48.140]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CEFCC3F540; Thu, 7 Sep 2017 02:01:44 -0700 (PDT) From: Gilad Ben-Yossef To: Greg Kroah-Hartman , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 7/8] staging: ccree: replace noop macro with inline Date: Thu, 7 Sep 2017 12:00:15 +0300 Message-Id: <1504774817-11984-8-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504774817-11984-1-git-send-email-gilad@benyossef.com> References: <1504774817-11984-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Replace noop macro with a noop inline function Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_driver.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h index 06a3c48..81ba827 100644 --- a/drivers/staging/ccree/ssi_driver.h +++ b/drivers/staging/ccree/ssi_driver.h @@ -187,8 +187,8 @@ struct async_gen_req_ctx { #ifdef DX_DUMP_BYTES void dump_byte_array(const char *name, const u8 *the_array, unsigned long size); #else -#define dump_byte_array(name, array, size) do { \ -} while (0); +static inline void dump_byte_array(const char *name, const u8 *the_array, + unsigned long size) {}; #endif int init_cc_regs(struct ssi_drvdata *drvdata, bool is_probe); From patchwork Thu Sep 7 09:00:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 111875 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp517173qge; Thu, 7 Sep 2017 02:01:54 -0700 (PDT) X-Google-Smtp-Source: ADKCNb67fnBgfgY3UpedKFGbrEC6dcdiEHtlgDO8P+v86Y/+GHsLWjnqmd0PS+tAXiP2flLzoHKr X-Received: by 10.84.133.4 with SMTP id 4mr2223701plf.3.1504774914381; Thu, 07 Sep 2017 02:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504774914; cv=none; d=google.com; s=arc-20160816; b=ont3yeRwLUF5Mrf6n2cZOSk64/msnBfx96iuLgISOHfnAx9ML5/FRhNPlf/tlVl8G3 U+OGQVEEu6hWYNhiI5K1e+/fldswo+Hp5EbacrHJkVIHCWVHSeWQeykDv/OQsxUuhC6R WvVWB18f5GVnfqeOkhz4OCpgtgCi9Y+++uBv3krjvKeRRIUyfPb/ktwJrUgeNvpfK/R0 GHWmaYnjn33+f7/iPWoDVQh6gzGoJrgGTGHtL0tZ5KfBXoJJQbIHnDMsWc/t/sPAPVl4 KJHmq4rYhjSi9u7nhvIwordG8A/BMReXSWN645mjtyxImo0Ii8TnU+guMS42uzj3SApN a10w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=uEn87tJ1J1D3j0gFmV2wfvG3pso4xK4xH+Syokohr/I=; b=ivX4bCri0+kzTowIYqgDuSY+gO3SxU7TEx0+z3kmIjS1YegETRrLU4BuMThRTkUqkv tLSdMwzT5rPFEf+f1WypUZz0lHtEg+/3V8L0KNma6HDainBjFk13UhBMExslaJse2+xD mf+bKR2nAs06RYBB8SEpHXHyftNvmFaBiBzS5CsnlP5IfM81bPteMH7UPklM5PDEQBCI dQ5lSIa78qdvfJZ4cvrLErgSTia819Jg0pywUM/tUSjgEpnAqEv7WRN7yGQdRJlq+sl8 oJtbJv9eKKyStPlZOvbS52Vo1Ov+sHV+m9uvxVFeq/2PZ/2kwM0A6FjFytDIi05vbVK6 9WMg== 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 x11si1732125plv.556.2017.09.07.02.01.54; Thu, 07 Sep 2017 02:01:54 -0700 (PDT) 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 S1755073AbdIGJBw (ORCPT + 1 other); Thu, 7 Sep 2017 05:01:52 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:57298 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755071AbdIGJBu (ORCPT ); Thu, 7 Sep 2017 05:01:50 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E349D80D; Thu, 7 Sep 2017 02:01:49 -0700 (PDT) Received: from gby.kfn.arm.com (unknown [10.45.48.140]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4BF943F540; Thu, 7 Sep 2017 02:01:48 -0700 (PDT) From: Gilad Ben-Yossef To: Greg Kroah-Hartman , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 8/8] staging: ccree: remove BUG macro usage Date: Thu, 7 Sep 2017 12:00:16 +0300 Message-Id: <1504774817-11984-9-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504774817-11984-1-git-send-email-gilad@benyossef.com> References: <1504774817-11984-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Replace BUG() macro usage that crash the kernel with alternatives that signal error and/or try to recover. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_buffer_mgr.c | 18 ++++++------------ drivers/staging/ccree/ssi_cipher.c | 1 - drivers/staging/ccree/ssi_pm.c | 3 ++- drivers/staging/ccree/ssi_request_mgr.c | 22 ++++++++++++++++------ 4 files changed, 24 insertions(+), 20 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c index 6393609..67c3296 100644 --- a/drivers/staging/ccree/ssi_buffer_mgr.c +++ b/drivers/staging/ccree/ssi_buffer_mgr.c @@ -81,11 +81,6 @@ static unsigned int ssi_buffer_mgr_get_sgl_nents( unsigned int nents = 0; while (nbytes != 0) { - if (sg_is_chain(sg_list)) { - SSI_LOG_ERR("Unexpected chained entry " - "in sg (entry =0x%X)\n", nents); - BUG(); - } if (sg_list->length != 0) { nents++; /* get the number of bytes in the last entry */ @@ -854,7 +849,7 @@ static inline int ssi_buffer_mgr_aead_chain_assoc( //if have reached the end of the sgl, then this is unexpected if (!current_sg) { SSI_LOG_ERR("reached end of sg list. unexpected\n"); - BUG(); + return -EINVAL; } sg_index += current_sg->length; mapped_nents++; @@ -1134,10 +1129,9 @@ static inline int ssi_buffer_mgr_aead_chain_data( offset = size_to_skip; - if (!sg_data) { - rc = -EINVAL; - goto chain_data_exit; - } + if (!sg_data) + return -EINVAL; + areq_ctx->src_sgl = req->src; areq_ctx->dst_sgl = req->dst; @@ -1154,7 +1148,7 @@ static inline int ssi_buffer_mgr_aead_chain_data( //if have reached the end of the sgl, then this is unexpected if (!areq_ctx->src_sgl) { SSI_LOG_ERR("reached end of sg list. unexpected\n"); - BUG(); + return -EINVAL; } sg_index += areq_ctx->src_sgl->length; src_mapped_nents--; @@ -1198,7 +1192,7 @@ static inline int ssi_buffer_mgr_aead_chain_data( //if have reached the end of the sgl, then this is unexpected if (!areq_ctx->dst_sgl) { SSI_LOG_ERR("reached end of sg list. unexpected\n"); - BUG(); + return -EINVAL; } sg_index += areq_ctx->dst_sgl->length; dst_mapped_nents--; diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c index ab0349f..a462075 100644 --- a/drivers/staging/ccree/ssi_cipher.c +++ b/drivers/staging/ccree/ssi_cipher.c @@ -541,7 +541,6 @@ ssi_blkcipher_create_setup_desc( break; default: SSI_LOG_ERR("Unsupported cipher mode (%d)\n", cipher_mode); - BUG(); } } diff --git a/drivers/staging/ccree/ssi_pm.c b/drivers/staging/ccree/ssi_pm.c index 31325e6..a50671a 100644 --- a/drivers/staging/ccree/ssi_pm.c +++ b/drivers/staging/ccree/ssi_pm.c @@ -109,7 +109,8 @@ int ssi_power_mgr_runtime_put_suspend(struct device *dev) rc = pm_runtime_put_autosuspend(dev); } else { /* Something wrong happens*/ - BUG(); + SSI_LOG_ERR("request to suspend already suspended queue"); + rc = -EBUSY; } return rc; } diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c index e5c2f92..97c2359 100644 --- a/drivers/staging/ccree/ssi_request_mgr.c +++ b/drivers/staging/ccree/ssi_request_mgr.c @@ -369,11 +369,16 @@ int send_request( enqueue_seq(cc_base, &req_mgr_h->compl_desc, (is_dout ? 0 : 1)); if (unlikely(req_mgr_h->q_free_slots < total_seq_len)) { - /*This means that there was a problem with the resume*/ - BUG(); + /* This situation should never occur. Maybe indicating problem + * with resuming power. Set the free slot count to 0 and hope + * for the best. + */ + SSI_LOG_ERR("HW free slot count mismatch."); + req_mgr_h->q_free_slots = 0; + } else { + /* Update the free slots in HW queue */ + req_mgr_h->q_free_slots -= total_seq_len; } - /* Update the free slots in HW queue */ - req_mgr_h->q_free_slots -= total_seq_len; spin_unlock_bh(&req_mgr_h->hw_lock); @@ -460,8 +465,13 @@ static void proc_completions(struct ssi_drvdata *drvdata) /* Dequeue request */ if (unlikely(request_mgr_handle->req_queue_head == request_mgr_handle->req_queue_tail)) { - SSI_LOG_ERR("Request queue is empty req_queue_head==req_queue_tail==%u\n", request_mgr_handle->req_queue_head); - BUG(); + /* We are supposed to handle a completion but our + * queue is empty. This is not normal. Return and + * hope for the best. + */ + SSI_LOG_ERR("Request queue is empty head == tail %u\n", + request_mgr_handle->req_queue_head); + break; } ssi_req = &request_mgr_handle->req_queue[request_mgr_handle->req_queue_tail];