From patchwork Sun Sep 3 08:56:43 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: 111516 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp175490qge; Sun, 3 Sep 2017 01:58:58 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5ZzztBO/8OC6e5OJD6n0PH17PgrCgsFBB31gNLGMjtn2BlXr9rI8Hp/co7cspA67/fCf1J X-Received: by 10.99.99.6 with SMTP id x6mr8334908pgb.224.1504429138642; Sun, 03 Sep 2017 01:58:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504429138; cv=none; d=google.com; s=arc-20160816; b=OACCZO3QDZ330BaWY0d81pBkGKIyzi6PQCjXI7JEM+bVH38cimQ9CdP/nMS/6ucbg7 pvZgKNXZ87XRLIRchE+hGrE8dox32fkXfV+lPwYztESKHjchp6ASMZDpZk3yE0kJURIO YGCsgiBmm+YNyNU/3ww8yrgZx7hJNswGMghYHwVFFbH/b8hvdjZJ61dTyUlTxPiTDsmr 5ruIoMFAK0aoTYOvt9ZcJijFHpe9QloE/O50t5+S4lpZ12ZzQFx/E0Z4crB4LMNd3Skz Yk6mSbYJri0jCflEGA8WrYtN4Aqtey+U4eKJaFaZigOIPeyUaEvARqddajjkx3E5JxDP qrIg== 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=vr0O0X1ppuf7Ox72JxDd97Kmq4myzJbIb1/QbStSqYg=; b=ETFMuQ7i+ASEbt6lCVoZwHPLf35dYVR9eD0WNlwxE3BStweryQku4iU6maNWG9CaAP d7H5aJVp4rdZyoSWiVn44B6Tei9JZcgD0pabBxPMgw9Z51syN29OVoqyVyNZ/mDTDzGA 5nYlUFl+1K2RCBWJR27NxvaZQxIUlrPUM4eNoU9vSKwi23kbQwvfDCalnaCJZd8J6NoM UfRRKfM+o6gAyJ5XMcrvdYAuOEshAKVqA308ca9ZtbhuMwjdULriWNKD1eRwbBGxdCRk cpLTh/4lAgYn5eTDDr+num2TYFNp2yymbunP3QXL/wdP+kkjZK/0o/y9bO0tGmWQBEYH ld+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 m87si3085859pfi.469.2017.09.03.01.58.58; Sun, 03 Sep 2017 01:58:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752130AbdICI5G (ORCPT + 26 others); Sun, 3 Sep 2017 04:57:06 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:49098 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751119AbdICI5B (ORCPT ); Sun, 3 Sep 2017 04:57:01 -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 20B1B2B; Sun, 3 Sep 2017 01:57:01 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D30303F483; Sun, 3 Sep 2017 01:56:58 -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 , Suniel Mahesh Subject: [PATCH 1/8] staging: ccree: Replace kzalloc with devm_kzalloc Date: Sun, 3 Sep 2017 11:56:43 +0300 Message-Id: <1504429011-25514-2-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504429011-25514-1-git-send-email-gilad@benyossef.com> References: <1504429011-25514-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suniel Mahesh It is recommended to use managed function devm_kzalloc, which simplifies driver cleanup paths and driver code. This patch does the following: (a) replace kzalloc with devm_kzalloc. (b) drop kfree(), because memory allocated with devm_kzalloc() is automatically freed on driver detach, otherwise it leads to a double free. (c) remove unnecessary blank lines. Signed-off-by: Suniel Mahesh [gby: rebase on top of latest coding style fixes changes] Acked-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_driver.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 9c6f120..47e0880 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -223,14 +223,15 @@ static int init_cc_resources(struct platform_device *plat_dev) struct resource *req_mem_cc_regs = NULL; void __iomem *cc_base = NULL; bool irq_registered = false; - struct ssi_drvdata *new_drvdata = kzalloc(sizeof(*new_drvdata), - GFP_KERNEL); + struct ssi_drvdata *new_drvdata; struct device *dev = &plat_dev->dev; struct device_node *np = dev->of_node; u32 signature_val; int rc = 0; - if (unlikely(!new_drvdata)) { + new_drvdata = devm_kzalloc(&plat_dev->dev, sizeof(*new_drvdata), + GFP_KERNEL); + if (!new_drvdata) { SSI_LOG_ERR("Failed to allocate drvdata"); rc = -ENOMEM; goto init_cc_res_err; @@ -435,10 +436,8 @@ static int init_cc_resources(struct platform_device *plat_dev) resource_size(new_drvdata->res_mem)); new_drvdata->res_mem = NULL; } - kfree(new_drvdata); dev_set_drvdata(&plat_dev->dev, NULL); } - return rc; } @@ -479,8 +478,6 @@ static void cleanup_cc_resources(struct platform_device *plat_dev) drvdata->cc_base = NULL; drvdata->res_mem = NULL; } - - kfree(drvdata); dev_set_drvdata(&plat_dev->dev, NULL); } From patchwork Sun Sep 3 08:56:44 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: 111509 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp174393qge; Sun, 3 Sep 2017 01:57:14 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4q1x76gySfzFvZ3cDg0/dhphgPdMUVLn+9CIHDQmq4zmo12fEX3KnjTKwpXYjSybdJXqne X-Received: by 10.84.130.39 with SMTP id 36mr8625931plc.143.1504429034211; Sun, 03 Sep 2017 01:57:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504429034; cv=none; d=google.com; s=arc-20160816; b=faFyBY4O+JUyOBEruDQogqbj4a+FXIS4r3Dr0bQ8bFsBtQoXwxCBRz7KvlH3VuuB7d AWNQAXvZHQv+Yk7ulmLbxGFAwTG8TWmvOlR2DXnAIDDPmxvwu8sTVHzmIQXCX3ygXXtb IZR0ZwhchpfdeI+aVxJvnj9f9lnSmVBJajFMOo8UcRkBBuUbAcqZVzDmyyrPHHVL2Qxk rwn5XcMRPrvc0InLCpzbZJ2YpGGCWzQ4c+noFCVi0TJ6Y+JS/b4e1CQtWtQKPjiHmtn0 pUVYJ5yO9aAbjYcOSmA1qoLpGzIaJP9T4d2Bn2Ryr7H3ZdlGYB3Jh7uAtsKkXQBeQfiu 9aRA== 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=WBFc9mldpDmCJp7r59odRl1RR1IG/4YwI1a6Ztw0VmM=; b=iSKg5Fu64BdYDX6+tWRbK6Q3t873StJd2+tDCcxN22yzbOt8UttaL44IBvfoO/7IpQ /dfz7ZZ/9G+Rv+zv02yqxH2gcF9Xq/e8Gfg5dGoi0pSuxQOgPvIbR7ME0ROEs2tU7rpo vCbgYeTrMN65gQOhHvyS5q3M5UtofRtkLxMlTyrUeDB9feLpIvh2nMxfPDxfQ2UzuQEV qWhohTo9jCOObJf2kp0MzGx/C5LziURAdU7Mo0P1EvSMRkTq9nzwTjehTPXZwxA437+8 ToxDGwVniQp2I28xJjs2KniA9LYWvrF8aKZ1pHakf1DqURqefsxGxGhFP5hxPiw8lyZm Sg7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 b11si663265pgr.536.2017.09.03.01.57.13; Sun, 03 Sep 2017 01:57:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752372AbdICI5H (ORCPT + 26 others); Sun, 3 Sep 2017 04:57:07 -0400 Received: from foss.arm.com ([217.140.101.70]:49108 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751635AbdICI5F (ORCPT ); Sun, 3 Sep 2017 04:57:05 -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 BD93D2B; Sun, 3 Sep 2017 01:57:04 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9ECBB3F483; Sun, 3 Sep 2017 01:57:02 -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 , Suniel Mahesh Subject: [PATCH 2/8] staging: ccree: Convert to devm_ioremap_resource for map, unmap Date: Sun, 3 Sep 2017 11:56:44 +0300 Message-Id: <1504429011-25514-3-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504429011-25514-1-git-send-email-gilad@benyossef.com> References: <1504429011-25514-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suniel Mahesh It is recommended to use managed function devm_ioremap_resource(), which simplifies driver cleanup paths and driver code. This patch does the following: (a) replace request_mem_region(), ioremap() and corresponding error handling with devm_ioremap_resource(). (b) remove struct resource pointer(res_mem) in struct ssi_drvdata as it seems redundant, use struct resource pointer which is defined locally and adjust return value of platform_get_resource() accordingly. (c) release_mem_region() and iounmap() are dropped, since devm_ioremap_ resource() releases and unmaps mem region on driver detach. (d) adjust log messages accordingly and remove any blank lines. Signed-off-by: Suniel Mahesh [gby: rebase on top of latest coding style fixes changes] Acked-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_driver.c | 60 ++++++++++---------------------------- drivers/staging/ccree/ssi_driver.h | 1 - 2 files changed, 15 insertions(+), 46 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 47e0880..cbe9a03 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -246,35 +246,21 @@ static int init_cc_resources(struct platform_device *plat_dev) dev_set_drvdata(&plat_dev->dev, new_drvdata); /* Get device resources */ /* First CC registers space */ - new_drvdata->res_mem = platform_get_resource(plat_dev, IORESOURCE_MEM, 0); - if (unlikely(!new_drvdata->res_mem)) { - SSI_LOG_ERR("Failed getting IO memory resource\n"); - rc = -ENODEV; - goto init_cc_res_err; - } - SSI_LOG_DEBUG("Got MEM resource (%s): start=%pad end=%pad\n", - new_drvdata->res_mem->name, - new_drvdata->res_mem->start, - new_drvdata->res_mem->end); + req_mem_cc_regs = platform_get_resource(plat_dev, IORESOURCE_MEM, 0); /* Map registers space */ - req_mem_cc_regs = request_mem_region(new_drvdata->res_mem->start, resource_size(new_drvdata->res_mem), "arm_cc7x_regs"); - if (unlikely(!req_mem_cc_regs)) { - SSI_LOG_ERR("Couldn't allocate registers memory region at " - "0x%08X\n", (unsigned int)new_drvdata->res_mem->start); - rc = -EBUSY; - goto init_cc_res_err; - } - cc_base = ioremap(new_drvdata->res_mem->start, resource_size(new_drvdata->res_mem)); - if (unlikely(!cc_base)) { - SSI_LOG_ERR("ioremap[CC](0x%08X,0x%08X) failed\n", - (unsigned int)new_drvdata->res_mem->start, - (unsigned int)resource_size(new_drvdata->res_mem)); - rc = -ENOMEM; + new_drvdata->cc_base = devm_ioremap_resource(&plat_dev->dev, + req_mem_cc_regs); + if (IS_ERR(new_drvdata->cc_base)) { + rc = PTR_ERR(new_drvdata->cc_base); goto init_cc_res_err; } - SSI_LOG_DEBUG("CC registers mapped from %pa to 0x%p\n", &new_drvdata->res_mem->start, cc_base); - new_drvdata->cc_base = cc_base; - + SSI_LOG_DEBUG("Got MEM resource (%s): start=%pad end=%pad\n", + req_mem_cc_regs->name, + req_mem_cc_regs->start, + req_mem_cc_regs->end); + SSI_LOG_DEBUG("CC registers mapped from %pa to 0x%p\n", + &req_mem_cc_regs->start, new_drvdata->cc_base); + cc_base = new_drvdata->cc_base; /* Then IRQ */ new_drvdata->res_irq = platform_get_resource(plat_dev, IORESOURCE_IRQ, 0); if (unlikely(!new_drvdata->res_irq)) { @@ -424,17 +410,9 @@ static int init_cc_resources(struct platform_device *plat_dev) #ifdef ENABLE_CC_SYSFS ssi_sysfs_fini(); #endif - - if (req_mem_cc_regs) { - if (irq_registered) { - free_irq(new_drvdata->res_irq->start, new_drvdata); - new_drvdata->res_irq = NULL; - iounmap(cc_base); - new_drvdata->cc_base = NULL; - } - release_mem_region(new_drvdata->res_mem->start, - resource_size(new_drvdata->res_mem)); - new_drvdata->res_mem = NULL; + if (irq_registered) { + free_irq(new_drvdata->res_irq->start, new_drvdata); + new_drvdata->res_irq = NULL; } dev_set_drvdata(&plat_dev->dev, NULL); } @@ -470,14 +448,6 @@ static void cleanup_cc_resources(struct platform_device *plat_dev) cc_clk_off(drvdata); free_irq(drvdata->res_irq->start, drvdata); drvdata->res_irq = NULL; - - if (drvdata->cc_base) { - iounmap(drvdata->cc_base); - release_mem_region(drvdata->res_mem->start, - resource_size(drvdata->res_mem)); - drvdata->cc_base = NULL; - drvdata->res_mem = NULL; - } dev_set_drvdata(&plat_dev->dev, NULL); } diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h index b6ad89a..518c0bf 100644 --- a/drivers/staging/ccree/ssi_driver.h +++ b/drivers/staging/ccree/ssi_driver.h @@ -128,7 +128,6 @@ struct ssi_crypto_req { * @fw_ver: SeP loaded firmware version */ struct ssi_drvdata { - struct resource *res_mem; struct resource *res_irq; void __iomem *cc_base; unsigned int irq; From patchwork Sun Sep 3 08:56:45 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: 111510 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp174453qge; Sun, 3 Sep 2017 01:57:19 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4Xry8hvlsmD3aCionhw/3z4XjrDoCVWskFZ+nAY8WTPUPfNF3gtPjB3P3u+CuNFDSs1YmO X-Received: by 10.99.180.73 with SMTP id n9mr8250046pgu.434.1504429039904; Sun, 03 Sep 2017 01:57:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504429039; cv=none; d=google.com; s=arc-20160816; b=isIpcbBTM3B//B7/01N+F9of6nNErVOPSlX++toL4YDKLzkC0QpJNOtZvYWQgWoemT Aja9nyEaHXzNB24ISYOTDzYDZyTptW/JvA8mIfUWaD/fY9rCQeBODDj3yL6cNonfVDja 1adQxt4uWQheOtyVbMoRilERK8twQkhUJJZv3iTsvRick++Jmg23p3WSkoj802ZGWbYC GXL7PEtxwi2od+6Kx+ZwiZhD6VgwUdESCNQA2CUvkEFSsGJV5Y3YS7vMAhY9esZp7JLY ZQzhGkXWJTUj0aDIZnIJOQG1HCd7Mj4773v+KAV30JOKj73R+0eeFzb8te1w9BEUUk5i BBJg== 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=KRr5Brtbn7+lWxsa1t3z9Rzcq69LpXlVz7xUB2/UEA8=; b=X1UON2FkxGXRTS9GRJ6KGz7sCmrEt8GPWG5z2IZfDSd7lsyW8ozyjkzoRloG5Jac8w D0jUPwG85DE84dxEH/zoYIF/t84UFJL3qWuwckOf8xfxyx9Wu5v2rX0681bBixAeWZNa XQEzU2ElMWuZPazJw4dvqyf5fI2ApR9o9iSXoHYW5xlYR0CXoRGxmwKI58LbTVb51kju xANmhVo2HvhW1779zoBUjX4/hGj6fQRKqhcghCik84qTRwlXquQ+rpZmkIldd++zBQlh DPDeKKENHm6lCNupjQPvVP0OBDSNLDNkC59TrSHe9z6/6Y1ArAxB4FYLnOebC0zA8OWD FJMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 m124si3204409pga.299.2017.09.03.01.57.19; Sun, 03 Sep 2017 01:57:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752847AbdICI5L (ORCPT + 26 others); Sun, 3 Sep 2017 04:57:11 -0400 Received: from foss.arm.com ([217.140.101.70]:49118 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752382AbdICI5I (ORCPT ); Sun, 3 Sep 2017 04:57:08 -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 7AB292B; Sun, 3 Sep 2017 01:57:08 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5CFAB3F483; Sun, 3 Sep 2017 01:57:06 -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 , Suniel Mahesh Subject: [PATCH 3/8] staging: ccree: Use platform_get_irq and devm_request_irq Date: Sun, 3 Sep 2017 11:56:45 +0300 Message-Id: <1504429011-25514-4-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504429011-25514-1-git-send-email-gilad@benyossef.com> References: <1504429011-25514-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suniel Mahesh It is recommended to use managed function devm_request_irq(), which simplifies driver cleanup paths and driver code. This patch does the following: (a) replace platform_get_resource(), request_irq() and corresponding error handling with platform_get_irq() and devm_request_irq(). (b) remove struct resource pointer(res_irq) in struct ssi_drvdata as it seems redundant. (c) change type of member irq in struct ssi_drvdata from unsigned int to int, as return type of platform_get_irq is int and can be used in error handling. (d) remove irq_registered variable from driver probe as it seems redundant. (e) free_irq is not required any more, devm_request_irq() free's it on driver detach. (f) adjust log messages accordingly and remove any blank lines. Signed-off-by: Suniel Mahesh Acked-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_driver.c | 30 +++++++++--------------------- drivers/staging/ccree/ssi_driver.h | 3 +-- 2 files changed, 10 insertions(+), 23 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index cbe9a03..3e7193d 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -222,7 +222,6 @@ static int init_cc_resources(struct platform_device *plat_dev) { struct resource *req_mem_cc_regs = NULL; void __iomem *cc_base = NULL; - bool irq_registered = false; struct ssi_drvdata *new_drvdata; struct device *dev = &plat_dev->dev; struct device_node *np = dev->of_node; @@ -262,26 +261,22 @@ static int init_cc_resources(struct platform_device *plat_dev) &req_mem_cc_regs->start, new_drvdata->cc_base); cc_base = new_drvdata->cc_base; /* Then IRQ */ - new_drvdata->res_irq = platform_get_resource(plat_dev, IORESOURCE_IRQ, 0); - if (unlikely(!new_drvdata->res_irq)) { + new_drvdata->irq = platform_get_irq(plat_dev, 0); + if (new_drvdata->irq < 0) { SSI_LOG_ERR("Failed getting IRQ resource\n"); - rc = -ENODEV; + rc = new_drvdata->irq; goto init_cc_res_err; } - rc = request_irq(new_drvdata->res_irq->start, cc_isr, - IRQF_SHARED, "arm_cc7x", new_drvdata); - if (unlikely(rc != 0)) { - SSI_LOG_ERR("Could not register to interrupt %llu\n", - (unsigned long long)new_drvdata->res_irq->start); + rc = devm_request_irq(&plat_dev->dev, new_drvdata->irq, cc_isr, + IRQF_SHARED, "arm_cc7x", new_drvdata); + if (rc) { + SSI_LOG_ERR("Could not register to interrupt %d\n", + new_drvdata->irq); goto init_cc_res_err; } init_completion(&new_drvdata->icache_setup_completion); - irq_registered = true; - SSI_LOG_DEBUG("Registered to IRQ (%s) %llu\n", - new_drvdata->res_irq->name, - (unsigned long long)new_drvdata->res_irq->start); - + SSI_LOG_DEBUG("Registered to IRQ: %d\n", new_drvdata->irq); new_drvdata->plat_dev = plat_dev; rc = cc_clk_on(new_drvdata); @@ -410,10 +405,6 @@ static int init_cc_resources(struct platform_device *plat_dev) #ifdef ENABLE_CC_SYSFS ssi_sysfs_fini(); #endif - if (irq_registered) { - free_irq(new_drvdata->res_irq->start, new_drvdata); - new_drvdata->res_irq = NULL; - } dev_set_drvdata(&plat_dev->dev, NULL); } return rc; @@ -443,11 +434,8 @@ static void cleanup_cc_resources(struct platform_device *plat_dev) #ifdef ENABLE_CC_SYSFS ssi_sysfs_fini(); #endif - fini_cc_regs(drvdata); cc_clk_off(drvdata); - free_irq(drvdata->res_irq->start, drvdata); - drvdata->res_irq = NULL; dev_set_drvdata(&plat_dev->dev, NULL); } diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h index 518c0bf..88ef370 100644 --- a/drivers/staging/ccree/ssi_driver.h +++ b/drivers/staging/ccree/ssi_driver.h @@ -128,9 +128,8 @@ struct ssi_crypto_req { * @fw_ver: SeP loaded firmware version */ struct ssi_drvdata { - struct resource *res_irq; void __iomem *cc_base; - unsigned int irq; + int irq; u32 irq_mask; u32 fw_ver; /* Calibration time of start/stop From patchwork Sun Sep 3 08:56:46 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: 111511 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp174459qge; Sun, 3 Sep 2017 01:57:20 -0700 (PDT) X-Google-Smtp-Source: ADKCNb6V92fKy4cCeDCKwdnEoinP3WKLZu8x3orqSdSEuaNYaXpP+08/5h0rC9/2RSytRSCk/Y79 X-Received: by 10.99.0.202 with SMTP id 193mr8201613pga.65.1504429040230; Sun, 03 Sep 2017 01:57:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504429040; cv=none; d=google.com; s=arc-20160816; b=ueEKZFb7TaBQDK0qixEYH5Oiz25KYRMJLIah9mq9RICPQ0Ped5ZPt2acWFdOAJ2App aZZWJVnGrNm260qkwh86/AgeUGWjjRbiSutMWIOaUwZId+D8+XYg78Kx/pZwdv9gP50K SI1wKkzEdHPAU+n2ECUCJ+zIIVWwHpMZXxTwUbFyGxEUxsXStsSGugB/KVq0wwknMJ8v 4vU6cgg1MMJ4lml3Zgi3wU6atx26XKgqgRUCPoKdV4sw26wNFeSJO+z2aZQQsGHsy5wu Ystzf1/oAtrGUayvN/I+s2MR2dkm1D3NnAxOGy7UG8jVg1DBAktl7QElR6Gz+xl2hcn4 h70g== 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=LVPf2nLy9ZEnC4c/QstXI/8S62Tz4ocERlcofS7FlJ0=; b=rNG7wEjcSUGjNof84pUFRdNxaQhVVxu59364aU1dT00zKweJuTcAXVYeUa9muDWM2I DjwadtQzPhCP4Q/OfMdU/71aTNRLqVeUR7KICu4xMhzlCF8FovIDTOg72IiZRBP0Ef3n N3cNAl9C1imnxrzNYJCqKjqHZNUw+4KyA5QFTXV5xaPBF5c9MaR+Ixl+lsdUnlczz0f+ YTv2FHS31kIOWfgeZUH8YS0GZ8w9/JJvUlZB+f0IQB7vG7t8lTRy4YGqmC/GrWkBNlnk aFUuqydDILR8i5k2KsaVtb4I4z3MvpnDBAzdG+0fLMGqLPJLw3vlLcD69ZMaQ2j8TdBM jHbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 m124si3204409pga.299.2017.09.03.01.57.20; Sun, 03 Sep 2017 01:57:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752873AbdICI5P (ORCPT + 26 others); Sun, 3 Sep 2017 04:57:15 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:49130 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752851AbdICI5M (ORCPT ); Sun, 3 Sep 2017 04:57:12 -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 EEA3413D5; Sun, 3 Sep 2017 01:57:11 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0FB903F483; Sun, 3 Sep 2017 01:57:09 -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 4/8] staging: ccree: simplify resource release on error Date: Sun, 3 Sep 2017 11:56:46 +0300 Message-Id: <1504429011-25514-5-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504429011-25514-1-git-send-email-gilad@benyossef.com> References: <1504429011-25514-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The resource release on probe/init error was being handled in an awkward manner and possibly leaking memory on certain (unlikely) error path. Fix it by simplifying the error resource release and making it easier to track. Reported-by: Dan Carpenter Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_aead.c | 3 +- drivers/staging/ccree/ssi_cipher.c | 3 +- drivers/staging/ccree/ssi_driver.c | 102 ++++++++++++++++++++----------------- drivers/staging/ccree/ssi_hash.c | 3 +- 4 files changed, 59 insertions(+), 52 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c index 5abe6b2..8191ec4 100644 --- a/drivers/staging/ccree/ssi_aead.c +++ b/drivers/staging/ccree/ssi_aead.c @@ -2720,6 +2720,7 @@ int ssi_aead_alloc(struct ssi_drvdata *drvdata) goto fail0; } + INIT_LIST_HEAD(&aead_handle->aead_list); drvdata->aead_handle = aead_handle; aead_handle->sram_workspace_addr = ssi_sram_mgr_alloc( @@ -2730,8 +2731,6 @@ int ssi_aead_alloc(struct ssi_drvdata *drvdata) goto fail1; } - INIT_LIST_HEAD(&aead_handle->aead_list); - /* Linux crypto */ for (alg = 0; alg < ARRAY_SIZE(aead_algs); alg++) { t_alg = ssi_aead_create_alg(&aead_algs[alg]); diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c index 8d31a93..4311746 100644 --- a/drivers/staging/ccree/ssi_cipher.c +++ b/drivers/staging/ccree/ssi_cipher.c @@ -1315,9 +1315,8 @@ int ssi_ablkcipher_alloc(struct ssi_drvdata *drvdata) if (!ablkcipher_handle) return -ENOMEM; - drvdata->blkcipher_handle = ablkcipher_handle; - INIT_LIST_HEAD(&ablkcipher_handle->blkcipher_alg_list); + drvdata->blkcipher_handle = ablkcipher_handle; /* Linux crypto */ SSI_LOG_DEBUG("Number of algorithms = %zu\n", ARRAY_SIZE(blkcipher_algs)); diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 3e7193d..dc22f13 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -233,16 +233,14 @@ static int init_cc_resources(struct platform_device *plat_dev) if (!new_drvdata) { SSI_LOG_ERR("Failed to allocate drvdata"); rc = -ENOMEM; - goto init_cc_res_err; + goto post_drvdata_err; } + dev_set_drvdata(&plat_dev->dev, new_drvdata); + new_drvdata->plat_dev = plat_dev; new_drvdata->clk = of_clk_get(np, 0); new_drvdata->coherent = of_dma_is_coherent(np); - /*Initialize inflight counter used in dx_ablkcipher_secure_complete used for count of BYSPASS blocks operations*/ - new_drvdata->inflight_counter = 0; - - dev_set_drvdata(&plat_dev->dev, new_drvdata); /* Get device resources */ /* First CC registers space */ req_mem_cc_regs = platform_get_resource(plat_dev, IORESOURCE_MEM, 0); @@ -250,38 +248,42 @@ static int init_cc_resources(struct platform_device *plat_dev) new_drvdata->cc_base = devm_ioremap_resource(&plat_dev->dev, req_mem_cc_regs); if (IS_ERR(new_drvdata->cc_base)) { + SSI_LOG_ERR("Failed to ioremap registers"); rc = PTR_ERR(new_drvdata->cc_base); - goto init_cc_res_err; + goto post_drvdata_err; } + SSI_LOG_DEBUG("Got MEM resource (%s): start=%pad end=%pad\n", req_mem_cc_regs->name, req_mem_cc_regs->start, req_mem_cc_regs->end); SSI_LOG_DEBUG("CC registers mapped from %pa to 0x%p\n", &req_mem_cc_regs->start, new_drvdata->cc_base); + cc_base = new_drvdata->cc_base; + /* Then IRQ */ new_drvdata->irq = platform_get_irq(plat_dev, 0); if (new_drvdata->irq < 0) { SSI_LOG_ERR("Failed getting IRQ resource\n"); rc = new_drvdata->irq; - goto init_cc_res_err; + goto post_drvdata_err; } + rc = devm_request_irq(&plat_dev->dev, new_drvdata->irq, cc_isr, IRQF_SHARED, "arm_cc7x", new_drvdata); if (rc) { SSI_LOG_ERR("Could not register to interrupt %d\n", new_drvdata->irq); - goto init_cc_res_err; + goto post_drvdata_err; } - init_completion(&new_drvdata->icache_setup_completion); - SSI_LOG_DEBUG("Registered to IRQ: %d\n", new_drvdata->irq); - new_drvdata->plat_dev = plat_dev; + + init_completion(&new_drvdata->icache_setup_completion); rc = cc_clk_on(new_drvdata); if (rc) - goto init_cc_res_err; + goto post_drvdata_err; if (!new_drvdata->plat_dev->dev.dma_mask) new_drvdata->plat_dev->dev.dma_mask = &new_drvdata->plat_dev->dev.coherent_dma_mask; @@ -295,7 +297,7 @@ static int init_cc_resources(struct platform_device *plat_dev) SSI_LOG_ERR("Invalid CC signature: SIGNATURE=0x%08X != expected=0x%08X\n", signature_val, (u32)DX_DEV_SIGNATURE); rc = -EINVAL; - goto init_cc_res_err; + goto post_clk_err; } SSI_LOG_DEBUG("CC SIGNATURE=0x%08X\n", signature_val); @@ -306,21 +308,26 @@ static int init_cc_resources(struct platform_device *plat_dev) rc = init_cc_regs(new_drvdata, true); if (unlikely(rc != 0)) { SSI_LOG_ERR("init_cc_regs failed\n"); - goto init_cc_res_err; + goto post_clk_err; } #ifdef ENABLE_CC_SYSFS rc = ssi_sysfs_init(&plat_dev->dev.kobj, new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("init_stat_db failed\n"); - goto init_cc_res_err; + goto post_regs_err; } #endif + rc = ssi_fips_init(new_drvdata); + if (unlikely(rc != 0)) { + SSI_LOG_ERR("SSI_FIPS_INIT failed 0x%x\n", rc); + goto post_sysfs_err; + } rc = ssi_sram_mgr_init(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("ssi_sram_mgr_init failed\n"); - goto init_cc_res_err; + goto post_fips_init_err; } new_drvdata->mlli_sram_addr = @@ -328,57 +335,51 @@ static int init_cc_resources(struct platform_device *plat_dev) if (unlikely(new_drvdata->mlli_sram_addr == NULL_SRAM_ADDR)) { SSI_LOG_ERR("Failed to alloc MLLI Sram buffer\n"); rc = -ENOMEM; - goto init_cc_res_err; + goto post_sram_mgr_err; } rc = request_mgr_init(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("request_mgr_init failed\n"); - goto init_cc_res_err; + goto post_sram_mgr_err; } rc = ssi_buffer_mgr_init(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("buffer_mgr_init failed\n"); - goto init_cc_res_err; + goto post_req_mgr_err; } rc = ssi_power_mgr_init(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("ssi_power_mgr_init failed\n"); - goto init_cc_res_err; - } - - rc = ssi_fips_init(new_drvdata); - if (unlikely(rc != 0)) { - SSI_LOG_ERR("SSI_FIPS_INIT failed 0x%x\n", rc); - goto init_cc_res_err; + goto post_buf_mgr_err; } rc = ssi_ivgen_init(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("ssi_ivgen_init failed\n"); - goto init_cc_res_err; + goto post_power_mgr_err; } /* Allocate crypto algs */ rc = ssi_ablkcipher_alloc(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("ssi_ablkcipher_alloc failed\n"); - goto init_cc_res_err; + goto post_ivgen_err; } /* hash must be allocated before aead since hash exports APIs */ rc = ssi_hash_alloc(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("ssi_hash_alloc failed\n"); - goto init_cc_res_err; + goto post_cipher_err; } rc = ssi_aead_alloc(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("ssi_aead_alloc failed\n"); - goto init_cc_res_err; + goto post_hash_err; } /* If we got here and FIPS mode is enabled @@ -389,24 +390,33 @@ static int init_cc_resources(struct platform_device *plat_dev) return 0; -init_cc_res_err: - SSI_LOG_ERR("Freeing CC HW resources!\n"); - - if (new_drvdata) { - ssi_aead_free(new_drvdata); - ssi_hash_free(new_drvdata); - ssi_ablkcipher_free(new_drvdata); - ssi_ivgen_fini(new_drvdata); - ssi_power_mgr_fini(new_drvdata); - ssi_buffer_mgr_fini(new_drvdata); - request_mgr_fini(new_drvdata); - ssi_sram_mgr_fini(new_drvdata); - ssi_fips_fini(new_drvdata); +post_hash_err: + ssi_hash_free(new_drvdata); +post_cipher_err: + ssi_ablkcipher_free(new_drvdata); +post_ivgen_err: + ssi_ivgen_fini(new_drvdata); +post_power_mgr_err: + ssi_power_mgr_fini(new_drvdata); +post_buf_mgr_err: + ssi_buffer_mgr_fini(new_drvdata); +post_req_mgr_err: + request_mgr_fini(new_drvdata); +post_sram_mgr_err: + ssi_sram_mgr_fini(new_drvdata); +post_fips_init_err: + ssi_fips_fini(new_drvdata); +post_sysfs_err: #ifdef ENABLE_CC_SYSFS - ssi_sysfs_fini(); + ssi_sysfs_fini(); #endif - dev_set_drvdata(&plat_dev->dev, NULL); - } +post_regs_err: + fini_cc_regs(new_drvdata); +post_clk_err: + cc_clk_off(new_drvdata); +post_drvdata_err: + SSI_LOG_ERR("ccree init error occurred!\n"); + dev_set_drvdata(&plat_dev->dev, NULL); return rc; } diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c index 13291ae..36495b5 100644 --- a/drivers/staging/ccree/ssi_hash.c +++ b/drivers/staging/ccree/ssi_hash.c @@ -2234,6 +2234,7 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata) goto fail; } + INIT_LIST_HEAD(&hash_handle->hash_list); drvdata->hash_handle = hash_handle; sram_size_to_alloc = sizeof(digest_len_init) + @@ -2264,8 +2265,6 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata) goto fail; } - INIT_LIST_HEAD(&hash_handle->hash_list); - /* ahash registration */ for (alg = 0; alg < ARRAY_SIZE(driver_hash); alg++) { struct ssi_hash_alg *t_alg; From patchwork Sun Sep 3 08:56:47 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: 111512 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp174468qge; Sun, 3 Sep 2017 01:57:20 -0700 (PDT) X-Google-Smtp-Source: ADKCNb76aOd89H3+mk7dfehCyQucrn5fJ7k4vwjsDLIgbnmq+ud8cBJY1138YUIWLr42sfGyLA3e X-Received: by 10.98.211.139 with SMTP id z11mr8198094pfk.304.1504429040551; Sun, 03 Sep 2017 01:57:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504429040; cv=none; d=google.com; s=arc-20160816; b=OBaMQ+PN+lg1tFYgRZsP0OjxEt8/XQ4gDmyrJxLjuImTxyIEJmL8WpswjJDEBTNQjY H9Cqt8Yxose28SkXY6Jp/yJp2OcY8/tLZQOwjCPzlA1FzFE2COm98GeTD06fVe2sJJfo Ao0zxjUM7uxapuwnwHTpSrTEX3C32Gf7mRN8S0hJ5P+WD9uBwbZBIa6segVG4Y6mMF31 +GoLPtIFG+ZgUvRW3hFLw2xT7I3U+ZZ1K1ZMaSF9HZtEHeD7H53ZfI8+NARoLH4LTKCC tJFUf/6tlnBt6V7ipypw+Atds9oBxkZVzKI+lIZOKdPOQcdBzg7BRKy1v05NHRRq169P z8uw== 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=cltr8pjqX4JQrNKKm4tUqzDLMeEjwcUbneo+qt0i6pw=; b=Nx9wqVhM1xXc44MH76SUfDC07g+SDvO6gp7t+LZG5Q2QQWvzb+BXfQryjrxSCLs3C6 uuJ9CNwzcpNzyrDyn4J/j3J3CM8VOQ0yJSxeEy75gNR+vqgDuzY/yeJP6Ke0JiOsMszA C6u130oJfN7u2qut+ggCeSuRoC1qsr15/1qV/Ds1PkYryXqibT8o2OHHZL0KxouXTKNN lEV9BDu6COVoRhg1tqhVJyZSlluOklRkj52mYiRb2+P4rAXIYlPC7DhvFDoyxR/wYAos vCzH1BECADfyLBoi5mO397cZM5qv0CHB2pQNqe9w/5ko5P7nDwROSIdfK3+p8ERuqtGV J5kQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 m124si3204409pga.299.2017.09.03.01.57.20; Sun, 03 Sep 2017 01:57:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752895AbdICI5S (ORCPT + 26 others); Sun, 3 Sep 2017 04:57:18 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:49142 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752868AbdICI5P (ORCPT ); Sun, 3 Sep 2017 04:57:15 -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 736562B; Sun, 3 Sep 2017 01:57:15 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8BF323F483; Sun, 3 Sep 2017 01:57:13 -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 5/8] staging: ccree: remove unused completion Date: Sun, 3 Sep 2017 11:56:47 +0300 Message-Id: <1504429011-25514-6-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504429011-25514-1-git-send-email-gilad@benyossef.com> References: <1504429011-25514-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org icache_setup_completion is no longer used. Remove it. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_driver.c | 2 -- drivers/staging/ccree/ssi_driver.h | 1 - 2 files changed, 3 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index dc22f13..8f1d7af 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -279,8 +279,6 @@ static int init_cc_resources(struct platform_device *plat_dev) } SSI_LOG_DEBUG("Registered to IRQ: %d\n", new_drvdata->irq); - init_completion(&new_drvdata->icache_setup_completion); - rc = cc_clk_on(new_drvdata); if (rc) goto post_drvdata_err; diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h index 88ef370..9b6476d 100644 --- a/drivers/staging/ccree/ssi_driver.h +++ b/drivers/staging/ccree/ssi_driver.h @@ -138,7 +138,6 @@ struct ssi_drvdata { u32 monitor_null_cycles; struct platform_device *plat_dev; ssi_sram_addr_t mlli_sram_addr; - struct completion icache_setup_completion; void *buff_mgr_handle; void *hash_handle; void *aead_handle; From patchwork Sun Sep 3 08:56:48 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: 111513 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp174546qge; Sun, 3 Sep 2017 01:57:27 -0700 (PDT) X-Google-Smtp-Source: ADKCNb7DNPgD7dwgi6qwPZfS59ccEa7QRn2LFMO4auAFRso49RjaCaNQbb4NcptZlY+pzt+w2/f6 X-Received: by 10.84.254.74 with SMTP id a10mr8762818pln.52.1504429047253; Sun, 03 Sep 2017 01:57:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504429047; cv=none; d=google.com; s=arc-20160816; b=hEvnh9367a2L1/HLb+WhKK+IgO2JairP7Fy2gT5UggghoK3eLEc9dfn/n2mkqyK4ut tJ4+1ldFjZ9pjMv1f7PVw7k7l+6Mzn33mRYZ3EINrEEeHzFrJu7KUPYAysgBdm7hswDX P4nor4To56sQJpA5FUjKlv8l6LSwM2e6NIaqn+LR4TON2a9ZUfPCE6m2qD46kV1W0ji+ T2+uZ4BRNnk2m720knkWC7a58C0OIA34edvCIdaj5crpwWPKYu+R0VkJPpKgQ+jWHHEy 33qIi98mjU+7PeylQx4VTC27i1mE41rATVP8+vR2KNHSN3uT00qoSaZdE13i7iJ44HBR BKzw== 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=fwtsk9ntsL2uaf31Vro4gEycuDzb/TJQ/Epr9eZi83o=; b=YGinxx3FS4hZRq6QidtMfRGfXG/YIg/9WyTeQSuRZrz4Udex3tS2XnGo9+aO4nt/pX Caa+z2c5Pje/h4+U+E4YtEKaDuoNOhAVhRALIFPt60P2hL+heGl06qV0krCGUI6V/0K7 SAVMuz0i4uKqxQGOZBg4MzwUDNz4szkXDbn5PYWv5BzQC0fwK4Mj33L4eVLKjdkUU3kP LxJvClZXCOlzqHm4d2fDHI9mNyrbzBDaGmPBLpSgVEUvLnmMBy3+L+z7hTLLkYRBH7m3 1sM2N73Q+9eg1FqEATJvxivhY9GDGQd1O1zxVr/p7TpV/5+bpUm3Mxk/Cx3VmQ2ljPb0 2bJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 a2si3391975pll.210.2017.09.03.01.57.26; Sun, 03 Sep 2017 01:57:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752917AbdICI5Y (ORCPT + 26 others); Sun, 3 Sep 2017 04:57:24 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:49150 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752898AbdICI5T (ORCPT ); Sun, 3 Sep 2017 04:57:19 -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 48C412B; Sun, 3 Sep 2017 01:57:19 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0A03D3F483; Sun, 3 Sep 2017 01:57:16 -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 6/8] staging: ccree: move over to BIT macro for bit defines Date: Sun, 3 Sep 2017 11:56:48 +0300 Message-Id: <1504429011-25514-7-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504429011-25514-1-git-send-email-gilad@benyossef.com> References: <1504429011-25514-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use BIT macro for bit definitions where needed. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_cipher.h | 10 +++++----- drivers/staging/ccree/ssi_driver.c | 3 ++- drivers/staging/ccree/ssi_driver.h | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_cipher.h b/drivers/staging/ccree/ssi_cipher.h index 296b375..c9a83df 100644 --- a/drivers/staging/ccree/ssi_cipher.h +++ b/drivers/staging/ccree/ssi_cipher.h @@ -27,11 +27,11 @@ #include "ssi_buffer_mgr.h" /* Crypto cipher flags */ -#define CC_CRYPTO_CIPHER_KEY_KFDE0 (1 << 0) -#define CC_CRYPTO_CIPHER_KEY_KFDE1 (1 << 1) -#define CC_CRYPTO_CIPHER_KEY_KFDE2 (1 << 2) -#define CC_CRYPTO_CIPHER_KEY_KFDE3 (1 << 3) -#define CC_CRYPTO_CIPHER_DU_SIZE_512B (1 << 4) +#define CC_CRYPTO_CIPHER_KEY_KFDE0 BIT(0) +#define CC_CRYPTO_CIPHER_KEY_KFDE1 BIT(1) +#define CC_CRYPTO_CIPHER_KEY_KFDE2 BIT(2) +#define CC_CRYPTO_CIPHER_KEY_KFDE3 BIT(3) +#define CC_CRYPTO_CIPHER_DU_SIZE_512B BIT(4) #define CC_CRYPTO_CIPHER_KEY_KFDE_MASK (CC_CRYPTO_CIPHER_KEY_KFDE0 | CC_CRYPTO_CIPHER_KEY_KFDE1 | CC_CRYPTO_CIPHER_KEY_KFDE2 | CC_CRYPTO_CIPHER_KEY_KFDE3) diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 8f1d7af..6d16220 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -185,7 +185,8 @@ int init_cc_regs(struct ssi_drvdata *drvdata, bool is_probe) CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_ICR), val); /* Unmask relevant interrupt cause */ - val = (~(SSI_COMP_IRQ_MASK | SSI_AXI_ERR_IRQ_MASK | SSI_GPR0_IRQ_MASK)); + val = (unsigned int)(~(SSI_COMP_IRQ_MASK | SSI_AXI_ERR_IRQ_MASK | + SSI_GPR0_IRQ_MASK)); CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IMR), val); #ifdef DX_HOST_IRQ_TIMER_INIT_VAL_REG_OFFSET diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h index 9b6476d..06a3c48 100644 --- a/drivers/staging/ccree/ssi_driver.h +++ b/drivers/staging/ccree/ssi_driver.h @@ -68,12 +68,12 @@ #define SSI_AXI_IRQ_MASK ((1 << DX_AXIM_CFG_BRESPMASK_BIT_SHIFT) | (1 << DX_AXIM_CFG_RRESPMASK_BIT_SHIFT) | \ (1 << DX_AXIM_CFG_INFLTMASK_BIT_SHIFT) | (1 << DX_AXIM_CFG_COMPMASK_BIT_SHIFT)) -#define SSI_AXI_ERR_IRQ_MASK (1 << DX_HOST_IRR_AXI_ERR_INT_BIT_SHIFT) +#define SSI_AXI_ERR_IRQ_MASK BIT(DX_HOST_IRR_AXI_ERR_INT_BIT_SHIFT) -#define SSI_COMP_IRQ_MASK (1 << DX_HOST_IRR_AXIM_COMP_INT_BIT_SHIFT) +#define SSI_COMP_IRQ_MASK BIT(DX_HOST_IRR_AXIM_COMP_INT_BIT_SHIFT) /* TEE FIPS status interrupt */ -#define SSI_GPR0_IRQ_MASK (1 << DX_HOST_IRR_GPR0_BIT_SHIFT) +#define SSI_GPR0_IRQ_MASK BIT(DX_HOST_IRR_GPR0_BIT_SHIFT) #define SSI_CRA_PRIO 3000 From patchwork Sun Sep 3 08:56:49 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: 111515 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp174929qge; Sun, 3 Sep 2017 01:58:05 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5dm6zoR3Z4kLCD8uR1xI4fBBeVYhj89tR4DVuCDGUhmovhOwsDifFjFXzoNiTOAErYdH4l X-Received: by 10.98.141.215 with SMTP id p84mr8083398pfk.117.1504429085102; Sun, 03 Sep 2017 01:58:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504429085; cv=none; d=google.com; s=arc-20160816; b=W9nMlaWP85g+XBrpirYGD3GMTxd3GYh68hqenl7lncfNrxbMwkMtzhcmlPvwTe2TJj 4lI5/jKyB607q85HTTOf9VsYz934TCu3nujLG9aCwiyz/J6gvueUaYHCDDnJdeovhQaC /z8RONQLO/vaVTtQMgJ/+egXAPDbnKYwUnmBfHvGwLFlGpIfmUM1pjbHHfq/4EbWgccA Q1GbXIJW5KH0aEDpkdL0gmYIjnyIsl6RLFniLkaGLqaeHC8AnGBBSaZHLZ+xs7gyGZBQ p/dsvs6irOiYV06YyfYUaakyas1hgNxShO/ErfyIboTPIJDEQuTZGolv0sUSiFdjyg5D NqqQ== 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=Eq8yzZYTp0muPsf2aWjurgIhCADdfAqo1PiWNBBBl2Dc5thjzbx4sEE2RotELuxw0j y4+skH3bANX23T71bQRAFzjmf2XOZuA+F+JN6oYdLtGrRikHgCUoL+oNkSOjgqnQjCx5 WBhC4BK/lflD+JVr212DzC3zmRKjWkpugm5sKD1qJ4aS13BBXdEhNmmPqxsDkJsGz5b8 rjjN6IciTMQoaHBXqHioi9iIXEnvai4L0zxXsumn+CiCTtRdxV6ouenaH8RXZh9ThvvO 4SikxTJGvEJOIzSCzq3oxixwlWkNiKqMPHhDwVZRd5Z03x+4o9LdoUT434M3Fsr9Bbjs AZhQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 i13si3243981pgn.52.2017.09.03.01.58.04; Sun, 03 Sep 2017 01:58:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753020AbdICI6D (ORCPT + 26 others); Sun, 3 Sep 2017 04:58:03 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:49162 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752901AbdICI5X (ORCPT ); Sun, 3 Sep 2017 04:57:23 -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 C121C2B; Sun, 3 Sep 2017 01:57:22 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D907F3F483; Sun, 3 Sep 2017 01:57:20 -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 7/8] staging: ccree: replace noop macro with inline Date: Sun, 3 Sep 2017 11:56:49 +0300 Message-Id: <1504429011-25514-8-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504429011-25514-1-git-send-email-gilad@benyossef.com> References: <1504429011-25514-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 Sun Sep 3 08:56:50 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: 111514 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp174604qge; Sun, 3 Sep 2017 01:57:34 -0700 (PDT) X-Google-Smtp-Source: ADKCNb52kDuDGWiHwyYUkFAQhT0alMxaoUzVal2N6Hh5/ITK2a4vCHm7lF8Dm70X9NZ8UKcp1pjP X-Received: by 10.84.175.195 with SMTP id t61mr8535590plb.190.1504429054185; Sun, 03 Sep 2017 01:57:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504429054; cv=none; d=google.com; s=arc-20160816; b=OmyWpycw08b6RwOWo5iiVnkBylbpkyJ014hXkWCl3/YTYVR1JYvTaKzC30FitmPOPd wKEYyKHjBjD1POqS0ldfd2/b3NtxgzQrim/LAttwqmwq0/cbpGxyFIoyPbnmAkyjamrC y1NhM/uMYoSzQoc2Vxi5GEroS9PlIkXKcoRGswdsq0kwMzcnCKZZmAkeuNrYxGHXfoMr D2DEquXiSIHoWQ0uMBHX42aT+jas4DbaT+krnfvSbtLGUlS6t7v05N+bE7vNWJS7brHb 2HNV1x7jhRdfX5Q3nne7SteYV0dnG5LEWPs0xgLAHXNW+o1rqdVyr2sXpzxlJoEE+O2h tgtg== 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=CL90o6nq3IUXMdMH2vhbWTUvl9id0UI2zZbtffyNxtc=; b=IvKrQGcUu4mNtDbKRKCHj2+TLxaGuKGBu4d3h8uPb0zKPl62K1ZdjHnMA/cVQQw2Un vEfqGIRtFWXbcHc24vGPLQL7fmib+EHC+z3+94NAonBMmIsK9pdg4aW7TZAFM0rWKwpm Fchwv2W5x5PLMpO4qC1LenphhtM+ANT6FVKwE4F/1kEQ8kjfPD17cepz5c02KZ7G5JKe L6oKZC8Xa8hlYLerHwRwTNpje1h23AQrv/GK2VMRr47mcrRTa8mNm2iMSL6sHbOkUwk2 MGaQbdlnXfUEvZ9eoNTjIhQGaqKfW4AXy3QqOAijany0FqlsTCu/Xa+EvddorsvWCAYY hvlQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 a2si3391975pll.210.2017.09.03.01.57.32; Sun, 03 Sep 2017 01:57:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752943AbdICI5a (ORCPT + 26 others); Sun, 3 Sep 2017 04:57:30 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:49174 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752898AbdICI50 (ORCPT ); Sun, 3 Sep 2017 04:57:26 -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 17CC52B; Sun, 3 Sep 2017 01:57:26 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5C36B3F483; Sun, 3 Sep 2017 01:57:24 -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 8/8] staging: ccree: remove BUG macro usage Date: Sun, 3 Sep 2017 11:56:50 +0300 Message-Id: <1504429011-25514-9-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504429011-25514-1-git-send-email-gilad@benyossef.com> References: <1504429011-25514-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 | 14 ++++++-------- drivers/staging/ccree/ssi_cipher.c | 1 - drivers/staging/ccree/ssi_pm.c | 3 ++- drivers/staging/ccree/ssi_request_mgr.c | 23 +++++++++++++++++------ 4 files changed, 25 insertions(+), 16 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c index 6393609..d744820 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,8 @@ 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(); + rc = -EINVAL; + goto chain_assoc_exit; } sg_index += current_sg->length; mapped_nents++; @@ -1154,7 +1150,8 @@ 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; + goto chain_data_exit; } sg_index += areq_ctx->src_sgl->length; src_mapped_nents--; @@ -1198,7 +1195,8 @@ 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(); + rc = -EINVAL; + goto chain_data_exit; } 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 4311746..68c9fc0 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..6914dc6 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); + goto out; } ssi_req = &request_mgr_handle->req_queue[request_mgr_handle->req_queue_tail]; @@ -487,6 +497,7 @@ static void proc_completions(struct ssi_drvdata *drvdata) request_mgr_handle->req_queue_tail = (request_mgr_handle->req_queue_tail + 1) & (MAX_REQUEST_QUEUE_SIZE - 1); SSI_LOG_DEBUG("Dequeue request tail=%u\n", request_mgr_handle->req_queue_tail); SSI_LOG_DEBUG("Request completed. axi_completed=%d\n", request_mgr_handle->axi_completed); +out: #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) rc = ssi_power_mgr_runtime_put_suspend(&plat_dev->dev); if (rc != 0)