From patchwork Wed Jul 3 08:13:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11029069 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E0C0B13B1 for ; Wed, 3 Jul 2019 08:15:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4A4328786 for ; Wed, 3 Jul 2019 08:15:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C933A2880A; Wed, 3 Jul 2019 08:15:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59C9D28786 for ; Wed, 3 Jul 2019 08:15:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727275AbfGCIOB (ORCPT ); Wed, 3 Jul 2019 04:14:01 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38193 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727004AbfGCIOA (ORCPT ); Wed, 3 Jul 2019 04:14:00 -0400 Received: by mail-pf1-f196.google.com with SMTP id y15so856374pfn.5; Wed, 03 Jul 2019 01:13:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6x6jWn1arFYtCfxNQ45HZjLDVkH250RmOZOdF+kQcoI=; b=N50zpxJwnQFYf34e2vjC/buPUEmo71NS8jbvOqdqR8/g1FHy8o3AYLowccVfeiRgcM n8f22BJK86jY+QLfkLJgtQSW3JIeDacJXodSJm9GO61ZVfs0Rby2wGaBnPwySgERTmxf oF3oqF62ynoddlZW+W2hZJMzAzctR4XtHk1rD33msYh5FqcHgqyAGu5WuXV0CV4qXPiU oeZe6x5WEv+lW2J7RSTmZXO/mf4xw4xPUJH2y84ZANb4tIu627NgG5cglLVYHR2fYLyH MCPFeXFGXx4olNZpqCPMTTlz5uqfWN8XwTXGbtHI84RnFM/tQ8i5N5nh4VgnUrnUqDgz q4+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6x6jWn1arFYtCfxNQ45HZjLDVkH250RmOZOdF+kQcoI=; b=dLZEiehr5TmzJ9rUJ3jSZyyqPktX7fkdDtskIu5WTgJWFBtkkcxZi3QvwbCdniS1rl R5cc5HbFQa0dWPfT2K+QHagu080PNQoadSSciOocnkmV19J9JwOz1IyskCxO0ppo+H5Q t3ElmPhTn9mAbCFaAABk+c42nhQWabAQJ1dkEw5ymPO4PuSqU7v9gmZ0PpdEZ3FbDCoz neVYpJIpO66dnWqghH7fyMgCFtsnhUEJRYDJJ0unrK7zUIBmeIsaMU7eRuSUSeuHl70w v5w663gQEiWxC5VSTQ4CkbHBJqvA+DLDweWR6KpJIe/KG5kMG3TphTIcvVaWX9lwNgL0 GN4A== X-Gm-Message-State: APjAAAWoBesQB4lAVsvMcla5IaN8hCslG7qqM+FOZ4vNuro7uvPi3wbE 1iBPqrLt4tECNE1pLgS5DBY0dTtjlDA= X-Google-Smtp-Source: APXvYqwZYbvTT+7X+Zd3zsAH8twpYtWuKStEbv+6mrfkYCWkO469a/5y+/PYTbl8r3Gk2e05e4aNFw== X-Received: by 2002:a17:90a:e38f:: with SMTP id b15mr11382311pjz.85.1562141638765; Wed, 03 Jul 2019 01:13:58 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id d2sm1445306pgo.0.2019.07.03.01.13.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 01:13:57 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , =?utf-8?q?Horia_Geant=C4=83?= , Chris Spencer , Cory Tusar , Chris Healy , Lucas Stach , Aymen Sghaier , Leonard Crestez , linux-kernel@vger.kernel.org Subject: [PATCH v4 01/16] crypto: caam - move DMA mask selection into a function Date: Wed, 3 Jul 2019 01:13:12 -0700 Message-Id: <20190703081327.17505-2-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190703081327.17505-1-andrew.smirnov@gmail.com> References: <20190703081327.17505-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Exactly the same code to figure out DMA mask is repeated twice in the driver code. To avoid repetition, move that logic into a standalone subroutine in intern.h. While at it re-shuffle the code to make it more readable with early returns. Signed-off-by: Andrey Smirnov Reviewed-by: Horia Geantă Cc: Chris Spencer Cc: Cory Tusar Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Aymen Sghaier Cc: Leonard Crestez Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/caam/ctrl.c | 11 +---------- drivers/crypto/caam/intern.h | 20 ++++++++++++++++++++ drivers/crypto/caam/jr.c | 15 +-------------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index 4e43ca4d3656..e674d8770cdb 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -688,16 +688,7 @@ static int caam_probe(struct platform_device *pdev) JRSTART_JR1_START | JRSTART_JR2_START | JRSTART_JR3_START); - if (sizeof(dma_addr_t) == sizeof(u64)) { - if (caam_dpaa2) - ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(49)); - else if (of_device_is_compatible(nprop, "fsl,sec-v5.0")) - ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40)); - else - ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(36)); - } else { - ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)); - } + ret = dma_set_mask_and_coherent(dev, caam_get_dma_mask(dev)); if (ret) { dev_err(dev, "dma_set_mask_and_coherent failed (%d)\n", ret); goto iounmap_ctrl; diff --git a/drivers/crypto/caam/intern.h b/drivers/crypto/caam/intern.h index 6af84bbc612c..ec25d260fa40 100644 --- a/drivers/crypto/caam/intern.h +++ b/drivers/crypto/caam/intern.h @@ -10,6 +10,8 @@ #ifndef INTERN_H #define INTERN_H +#include "ctrl.h" + /* Currently comes from Kconfig param as a ^2 (driver-required) */ #define JOBR_DEPTH (1 << CONFIG_CRYPTO_DEV_FSL_CAAM_RINGSIZE) @@ -215,4 +217,22 @@ DEFINE_SIMPLE_ATTRIBUTE(caam_fops_u32_ro, caam_debugfs_u32_get, NULL, "%llu\n"); DEFINE_SIMPLE_ATTRIBUTE(caam_fops_u64_ro, caam_debugfs_u64_get, NULL, "%llu\n"); #endif +static inline u64 caam_get_dma_mask(struct device *dev) +{ + struct device_node *nprop = dev->of_node; + + if (sizeof(dma_addr_t) != sizeof(u64)) + return DMA_BIT_MASK(32); + + if (caam_dpaa2) + return DMA_BIT_MASK(49); + + if (of_device_is_compatible(nprop, "fsl,sec-v5.0-job-ring") || + of_device_is_compatible(nprop, "fsl,sec-v5.0")) + return DMA_BIT_MASK(40); + + return DMA_BIT_MASK(36); +} + + #endif /* INTERN_H */ diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c index cea811fed320..4b25b2fa3d02 100644 --- a/drivers/crypto/caam/jr.c +++ b/drivers/crypto/caam/jr.c @@ -543,20 +543,7 @@ static int caam_jr_probe(struct platform_device *pdev) jrpriv->rregs = (struct caam_job_ring __iomem __force *)ctrl; - if (sizeof(dma_addr_t) == sizeof(u64)) { - if (caam_dpaa2) - error = dma_set_mask_and_coherent(jrdev, - DMA_BIT_MASK(49)); - else if (of_device_is_compatible(nprop, - "fsl,sec-v5.0-job-ring")) - error = dma_set_mask_and_coherent(jrdev, - DMA_BIT_MASK(40)); - else - error = dma_set_mask_and_coherent(jrdev, - DMA_BIT_MASK(36)); - } else { - error = dma_set_mask_and_coherent(jrdev, DMA_BIT_MASK(32)); - } + error = dma_set_mask_and_coherent(jrdev, caam_get_dma_mask(jrdev)); if (error) { dev_err(jrdev, "dma_set_mask_and_coherent failed (%d)\n", error); From patchwork Wed Jul 3 08:13:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11029067 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 641CB13B1 for ; Wed, 3 Jul 2019 08:15:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5814028786 for ; Wed, 3 Jul 2019 08:15:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C87428807; Wed, 3 Jul 2019 08:15:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E3B228833 for ; Wed, 3 Jul 2019 08:15:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727283AbfGCIOC (ORCPT ); Wed, 3 Jul 2019 04:14:02 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:33447 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727019AbfGCIOB (ORCPT ); Wed, 3 Jul 2019 04:14:01 -0400 Received: by mail-pl1-f195.google.com with SMTP id c14so819211plo.0; Wed, 03 Jul 2019 01:14:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OifUTPwtrbsJcu6VA62AeaQvTf5xpoAnkAcZtXAOudc=; b=RkeUm4vdTQplnZ0XHutG+0YjlWSYn2RR3xrnOtOpnjBHI5MrUr+EZ64nJqO3fiIMHW 2I1GFBDlbXQ+bNqbrcKpbaUDkMSHnYzIFpmXlY1jc95gSKNtSbNyPgPVAtJraYNW3WeA Rexerdwa8iQwzLlg/n/1fW04icWqp9apaoJACzojiR17cvRlXWYCIJseh19PjwWHhwFE 0tUSQpeLNj1sxU8dybDcSiiwO1bFFHJwj9sn+7uG5uunB8eg7LRQN4T0wKj2ASs9PuwR FYG9nLmr1cYV46fimhJgulDlLy7y3I5mCaJ0JSW9eL0ETLHDX0XjixwIEyi8Iyhapk4d H7pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OifUTPwtrbsJcu6VA62AeaQvTf5xpoAnkAcZtXAOudc=; b=rzlACjUncwzQXCkYXo8jOi/CbXCLAdBvuh6cWqgFlKwINTc2rzTZrQogxynbSU8qnn UOVkIbxisWq7CVFKVbiEfKM6bdD8wwamv8B6Ji1PRF2Zwj5jxu6Y2X6UVayV/fxLhuPW qs3ACo8ImSfrXRM6ajBlNqX2P7f0D6bYMewo2pp7wttsOwf/QulcHKGsK3/PfEfCWXDE lYhCjxjDwHLR3CVrOqyqwO9nbHVG3AWeAHlLU6e5gYWSL/0VTKRbVVVI3nF6OzGa7p+g V8Cq/XnXOmFtoE9ztEcbGqgurHz+YJAm0b+BWsghtYPrs9sdAuFBqu8kEtsdXRPQhz0A Xlfg== X-Gm-Message-State: APjAAAVDUHfDAPr7x4l9fGpfVidunzwFkxq1sQbnNDnjgpv44YwGqjoS nFqDc9yMFLrVcU83lBoPVoPCS7Jsb04= X-Google-Smtp-Source: APXvYqw74n/nvcZTjUc0R/uZJgn2K8rJ499Jx4fuaW4NLJt2xKHFsoxoOr9HbTVDD1K+OVam/pJEvg== X-Received: by 2002:a17:902:29a7:: with SMTP id h36mr41847886plb.158.1562141639924; Wed, 03 Jul 2019 01:13:59 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id d2sm1445306pgo.0.2019.07.03.01.13.58 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 01:13:59 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , Chris Spencer , Cory Tusar , Chris Healy , Lucas Stach , =?utf-8?q?Horia_Geant=C4=83?= , Aymen Sghaier , Leonard Crestez , linux-kernel@vger.kernel.org Subject: [PATCH v4 02/16] crypto: caam - simplify clock initialization Date: Wed, 3 Jul 2019 01:13:13 -0700 Message-Id: <20190703081327.17505-3-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190703081327.17505-1-andrew.smirnov@gmail.com> References: <20190703081327.17505-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Simplify clock initialization code by converting it to use clk-bulk, devres and soc_device_match() match table. No functional change intended. Signed-off-by: Andrey Smirnov Cc: Chris Spencer Cc: Cory Tusar Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Aymen Sghaier Cc: Leonard Crestez Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Leonard Crestez --- drivers/crypto/caam/ctrl.c | 203 +++++++++++++++++------------------ drivers/crypto/caam/intern.h | 7 +- 2 files changed, 98 insertions(+), 112 deletions(-) diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index e674d8770cdb..908d3ecf6d1c 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -25,16 +25,6 @@ EXPORT_SYMBOL(caam_dpaa2); #include "qi.h" #endif -/* - * i.MX targets tend to have clock control subsystems that can - * enable/disable clocking to our device. - */ -static inline struct clk *caam_drv_identify_clk(struct device *dev, - char *clk_name) -{ - return caam_imx ? devm_clk_get(dev, clk_name) : NULL; -} - /* * Descriptor to instantiate RNG State Handle 0 in normal mode and * load the JDKEK, TDKEK and TDSK registers @@ -342,13 +332,6 @@ static int caam_remove(struct platform_device *pdev) /* Unmap controller region */ iounmap(ctrl); - /* shut clocks off before finalizing shutdown */ - clk_disable_unprepare(ctrlpriv->caam_ipg); - if (ctrlpriv->caam_mem) - clk_disable_unprepare(ctrlpriv->caam_mem); - clk_disable_unprepare(ctrlpriv->caam_aclk); - if (ctrlpriv->caam_emi_slow) - clk_disable_unprepare(ctrlpriv->caam_emi_slow); return 0; } @@ -497,20 +480,102 @@ static const struct of_device_id caam_match[] = { }; MODULE_DEVICE_TABLE(of, caam_match); +struct caam_imx_data { + const struct clk_bulk_data *clks; + int num_clks; +}; + +static const struct clk_bulk_data caam_imx6_clks[] = { + { .id = "ipg" }, + { .id = "mem" }, + { .id = "aclk" }, + { .id = "emi_slow" }, +}; + +static const struct caam_imx_data caam_imx6_data = { + .clks = caam_imx6_clks, + .num_clks = ARRAY_SIZE(caam_imx6_clks), +}; + +static const struct clk_bulk_data caam_imx7_clks[] = { + { .id = "ipg" }, + { .id = "aclk" }, +}; + +static const struct caam_imx_data caam_imx7_data = { + .clks = caam_imx7_clks, + .num_clks = ARRAY_SIZE(caam_imx7_clks), +}; + +static const struct clk_bulk_data caam_imx6ul_clks[] = { + { .id = "ipg" }, + { .id = "mem" }, + { .id = "aclk" }, +}; + +static const struct caam_imx_data caam_imx6ul_data = { + .clks = caam_imx6ul_clks, + .num_clks = ARRAY_SIZE(caam_imx6ul_clks), +}; + +static const struct soc_device_attribute caam_imx_soc_table[] = { + { .soc_id = "i.MX6UL", .data = &caam_imx6ul_data }, + { .soc_id = "i.MX6*", .data = &caam_imx6_data }, + { .soc_id = "i.MX7*", .data = &caam_imx7_data }, + { .family = "Freescale i.MX" }, +}; + +static void disable_clocks(void *data) +{ + struct caam_drv_private *ctrlpriv = data; + + clk_bulk_disable_unprepare(ctrlpriv->num_clks, ctrlpriv->clks); +} + +static int init_clocks(struct device *dev, + struct caam_drv_private *ctrlpriv, + const struct caam_imx_data *data) +{ + int ret; + + ctrlpriv->num_clks = data->num_clks; + ctrlpriv->clks = devm_kmemdup(dev, data->clks, + data->num_clks * sizeof(data->clks[0]), + GFP_KERNEL); + if (!ctrlpriv->clks) + return -ENOMEM; + + ret = devm_clk_bulk_get(dev, ctrlpriv->num_clks, ctrlpriv->clks); + if (ret) { + dev_err(dev, + "Failed to request all necessary clocks\n"); + return ret; + } + + ret = clk_bulk_prepare_enable(ctrlpriv->num_clks, ctrlpriv->clks); + if (ret) { + dev_err(dev, + "Failed to prepare/enable all necessary clocks\n"); + return ret; + } + + ret = devm_add_action_or_reset(dev, disable_clocks, ctrlpriv); + if (ret) + return ret; + + return 0; +} + /* Probe routine for CAAM top (controller) level */ static int caam_probe(struct platform_device *pdev) { int ret, ring, gen_sk, ent_delay = RTSDCTL_ENT_DLY_MIN; u64 caam_id; - static const struct soc_device_attribute imx_soc[] = { - {.family = "Freescale i.MX"}, - {}, - }; + const struct soc_device_attribute *imx_soc_match; struct device *dev; struct device_node *nprop, *np; struct caam_ctrl __iomem *ctrl; struct caam_drv_private *ctrlpriv; - struct clk *clk; #ifdef CONFIG_DEBUG_FS struct caam_perfmon *perfmon; #endif @@ -527,91 +592,25 @@ static int caam_probe(struct platform_device *pdev) dev_set_drvdata(dev, ctrlpriv); nprop = pdev->dev.of_node; - caam_imx = (bool)soc_device_match(imx_soc); - - /* Enable clocking */ - clk = caam_drv_identify_clk(&pdev->dev, "ipg"); - if (IS_ERR(clk)) { - ret = PTR_ERR(clk); - dev_err(&pdev->dev, - "can't identify CAAM ipg clk: %d\n", ret); - return ret; - } - ctrlpriv->caam_ipg = clk; - - if (!of_machine_is_compatible("fsl,imx7d") && - !of_machine_is_compatible("fsl,imx7s") && - !of_machine_is_compatible("fsl,imx7ulp")) { - clk = caam_drv_identify_clk(&pdev->dev, "mem"); - if (IS_ERR(clk)) { - ret = PTR_ERR(clk); - dev_err(&pdev->dev, - "can't identify CAAM mem clk: %d\n", ret); - return ret; + imx_soc_match = soc_device_match(caam_imx_soc_table); + if (imx_soc_match) { + if (!imx_soc_match->data) { + dev_err(dev, "No clock data provided for i.MX SoC"); + return -EINVAL; } - ctrlpriv->caam_mem = clk; - } - clk = caam_drv_identify_clk(&pdev->dev, "aclk"); - if (IS_ERR(clk)) { - ret = PTR_ERR(clk); - dev_err(&pdev->dev, - "can't identify CAAM aclk clk: %d\n", ret); - return ret; - } - ctrlpriv->caam_aclk = clk; - - if (!of_machine_is_compatible("fsl,imx6ul") && - !of_machine_is_compatible("fsl,imx7d") && - !of_machine_is_compatible("fsl,imx7s") && - !of_machine_is_compatible("fsl,imx7ulp")) { - clk = caam_drv_identify_clk(&pdev->dev, "emi_slow"); - if (IS_ERR(clk)) { - ret = PTR_ERR(clk); - dev_err(&pdev->dev, - "can't identify CAAM emi_slow clk: %d\n", ret); + ret = init_clocks(dev, ctrlpriv, imx_soc_match->data); + if (ret) return ret; - } - ctrlpriv->caam_emi_slow = clk; - } - - ret = clk_prepare_enable(ctrlpriv->caam_ipg); - if (ret < 0) { - dev_err(&pdev->dev, "can't enable CAAM ipg clock: %d\n", ret); - return ret; - } - - if (ctrlpriv->caam_mem) { - ret = clk_prepare_enable(ctrlpriv->caam_mem); - if (ret < 0) { - dev_err(&pdev->dev, "can't enable CAAM secure mem clock: %d\n", - ret); - goto disable_caam_ipg; - } - } - - ret = clk_prepare_enable(ctrlpriv->caam_aclk); - if (ret < 0) { - dev_err(&pdev->dev, "can't enable CAAM aclk clock: %d\n", ret); - goto disable_caam_mem; - } - - if (ctrlpriv->caam_emi_slow) { - ret = clk_prepare_enable(ctrlpriv->caam_emi_slow); - if (ret < 0) { - dev_err(&pdev->dev, "can't enable CAAM emi slow clock: %d\n", - ret); - goto disable_caam_aclk; - } } + caam_imx = (bool)imx_soc_match; /* Get configuration properties from device tree */ /* First, get register page */ ctrl = of_iomap(nprop, 0); if (ctrl == NULL) { dev_err(dev, "caam: of_iomap() failed\n"); - ret = -ENOMEM; - goto disable_caam_emi_slow; + return -ENOMEM; } caam_little_end = !(bool)(rd_reg32(&ctrl->perfmon.status) & @@ -899,16 +898,6 @@ static int caam_probe(struct platform_device *pdev) #endif iounmap_ctrl: iounmap(ctrl); -disable_caam_emi_slow: - if (ctrlpriv->caam_emi_slow) - clk_disable_unprepare(ctrlpriv->caam_emi_slow); -disable_caam_aclk: - clk_disable_unprepare(ctrlpriv->caam_aclk); -disable_caam_mem: - if (ctrlpriv->caam_mem) - clk_disable_unprepare(ctrlpriv->caam_mem); -disable_caam_ipg: - clk_disable_unprepare(ctrlpriv->caam_ipg); return ret; } diff --git a/drivers/crypto/caam/intern.h b/drivers/crypto/caam/intern.h index ec25d260fa40..1f01703f510a 100644 --- a/drivers/crypto/caam/intern.h +++ b/drivers/crypto/caam/intern.h @@ -94,11 +94,8 @@ struct caam_drv_private { Handles of the RNG4 block are initialized by this driver */ - struct clk *caam_ipg; - struct clk *caam_mem; - struct clk *caam_aclk; - struct clk *caam_emi_slow; - + struct clk_bulk_data *clks; + int num_clks; /* * debugfs entries for developer view into driver/device * variables at runtime. From patchwork Wed Jul 3 08:13:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11029065 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8337313A4 for ; Wed, 3 Jul 2019 08:15:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77A2228786 for ; Wed, 3 Jul 2019 08:15:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C2C82880A; Wed, 3 Jul 2019 08:15:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 127E928786 for ; Wed, 3 Jul 2019 08:15:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727294AbfGCIOC (ORCPT ); Wed, 3 Jul 2019 04:14:02 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:46251 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727282AbfGCIOC (ORCPT ); Wed, 3 Jul 2019 04:14:02 -0400 Received: by mail-pl1-f196.google.com with SMTP id e5so785184pls.13; Wed, 03 Jul 2019 01:14:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nmCsYbm1OChUS/6iyzuZc8+iRZsteMJe/aD4EAVxC/s=; b=UByox/6ooMiUeUN9pNJYDu5l/7oPAkbrqiAGR6ZlR/yGvFd0NRmZtOy8mgQFOl9Xx9 P+RKZo5hMxaIa/X1bDjJ+L2JRQZzKiTGgm83+W16ScQKadvAn7mw2EagotmP0zEx3tPU bDKkMfb/slpwP27vSkSn7gL/T7abisnqf2tBOpH/09W3cSP+5em66Fsj30cXq15fbj1E rrTA1Eb3Sn2RdWuHj081Kh8Ko+H8N87p+AuP5Dl32aelgOpB0z2ZZvABLPMRNoOL2D7h roMDXQfCoJDbAGAHYJRfSdaWvpiQzYT6iNKR18YqyJaKO87Wgny2tZvCjlNOYLjVVjQ6 8SLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nmCsYbm1OChUS/6iyzuZc8+iRZsteMJe/aD4EAVxC/s=; b=YXV9coBG60Xaj7zedKqR2UyhY0xaqNK9KvCMxvDcDvBC2Gzq0N2dDjJpWG66aB4NRt keXCfv5x9MZr0Gl7hwtvnhOde/NH3DjiWsuG+AkRTdQ7jgl/9C6HvPNthWAMSeMa+5fc Bvpz/UhRIf5h/ZPat066aAE02Fk7QzA4XJqPYrz1qN7N+Owxw8MRoGdfRrmQ6LrPSTCi Ebrg6qli1dbsGeTZwWCAWzcHsTZD/iSNNSXJjdk54nGUncAHIuS1fpD364fKiEXwTEib yc0rrfiZv7Xqezec+iQ3LmwyRJC0pbZ0Y48Zf5ztkvPZuWcyeDm3RwrtYlmIWWrl63V8 t10A== X-Gm-Message-State: APjAAAWjLv0mFiaGGn/U1EE5gmNSsW+VoIyCowXGyDm19nCHEmlOT0v/ atnhfmKnaThSlxcIVBIstZHOvz05//0= X-Google-Smtp-Source: APXvYqxPwQGd/DQpl5Vf317Gi61kfH7TZG6TGsyBMCktingto6JDt3KHixMP9vvfKMcenuLf4NVcyw== X-Received: by 2002:a17:902:106:: with SMTP id 6mr41661031plb.64.1562141641353; Wed, 03 Jul 2019 01:14:01 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id d2sm1445306pgo.0.2019.07.03.01.13.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 01:14:00 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , Chris Spencer , Cory Tusar , Chris Healy , Lucas Stach , =?utf-8?q?Horia_Geant=C4=83?= , Aymen Sghaier , Leonard Crestez , linux-kernel@vger.kernel.org Subject: [PATCH v4 03/16] crypto: caam - move tasklet_init() call down Date: Wed, 3 Jul 2019 01:13:14 -0700 Message-Id: <20190703081327.17505-4-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190703081327.17505-1-andrew.smirnov@gmail.com> References: <20190703081327.17505-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move tasklet_init() call further down in order to simplify error path cleanup. No functional change intended. Signed-off-by: Andrey Smirnov Cc: Chris Spencer Cc: Cory Tusar Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Aymen Sghaier Cc: Leonard Crestez Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/caam/jr.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c index 4b25b2fa3d02..a7ca2bbe243f 100644 --- a/drivers/crypto/caam/jr.c +++ b/drivers/crypto/caam/jr.c @@ -441,15 +441,13 @@ static int caam_jr_init(struct device *dev) jrp = dev_get_drvdata(dev); - tasklet_init(&jrp->irqtask, caam_jr_dequeue, (unsigned long)dev); - /* Connect job ring interrupt handler. */ error = request_irq(jrp->irq, caam_jr_interrupt, IRQF_SHARED, dev_name(dev), dev); if (error) { dev_err(dev, "can't connect JobR %d interrupt (%d)\n", jrp->ridx, jrp->irq); - goto out_kill_deq; + return error; } error = caam_reset_hw_jr(dev); @@ -471,6 +469,8 @@ static int caam_jr_init(struct device *dev) if (!jrp->entinfo) goto out_free_outring; + tasklet_init(&jrp->irqtask, caam_jr_dequeue, (unsigned long)dev); + for (i = 0; i < JOBR_DEPTH; i++) jrp->entinfo[i].desc_addr_dma = !0; @@ -504,8 +504,6 @@ static int caam_jr_init(struct device *dev) dev_err(dev, "can't allocate job rings for %d\n", jrp->ridx); out_free_irq: free_irq(jrp->irq, dev); -out_kill_deq: - tasklet_kill(&jrp->irqtask); return error; } From patchwork Wed Jul 3 08:13:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11029063 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C5B2513B1 for ; Wed, 3 Jul 2019 08:15:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9DC528786 for ; Wed, 3 Jul 2019 08:15:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AABA62880A; Wed, 3 Jul 2019 08:15:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E01028786 for ; Wed, 3 Jul 2019 08:15:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727562AbfGCIPJ (ORCPT ); Wed, 3 Jul 2019 04:15:09 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:33748 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727311AbfGCIOD (ORCPT ); Wed, 3 Jul 2019 04:14:03 -0400 Received: by mail-pf1-f193.google.com with SMTP id x15so870044pfq.0; Wed, 03 Jul 2019 01:14:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6BcX9hRF1ZcJg0bLQVxEUNzqf7x1OYXFm4Avex33mzw=; b=NXBXHY2rOfDIIefdmLBUtihvwLxZoamAXmXEhzmcHgE1//wHqu3N1fJ0mn8cVhHOCY oEG9EAi5UrMAFjLuT380GshZwbi9WWx5FVLWdP/QZyW9ZAA6CmM3qbw/f1ahx9RcQLxR FYTyL4nso9PO/ba16bytiqE7aorc8O6S/c7ZG7OM023sGc1+izwyw7WiDvL9v4W1cKf4 ZPBVAVDOOGRRfS7TyyW5v/plLynTgr+i6pL/B09mmY+WQOv9bmJkP46+e3MZTYcWPq2C xdcMXwaK6ASx+lfT91VB/cds4KVep1xnFDTRrWZSpQ/g+xIZYhkynwJ8X82KgADmODYy 8DMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6BcX9hRF1ZcJg0bLQVxEUNzqf7x1OYXFm4Avex33mzw=; b=Q2EnOC8f1HTJluq2GyFhl+J0Ga5rVU/aBc+O1uR5IZ6XD/8wR+7ZZhRaxq4OYc/vZH rpENtXBCB8Y8jLCw2BwOC0Z0kOAkP6xCulZSIjvi0Q/LCGeHNElfpHBuCMKX76fZZzyI yzPBSZc5P/fQCRZt+LX7NKe0DVWO63x8uKPuxXiqCa59i28NwzhGFu6qRDqCFIgmypE7 PlRkZzlsnYrszhlcr3DOMD/p3cqnyFxRaYPUz6mGDwqSNQGys6CbQe2g3BCBX8nj23qr r5bY/bMETOitxnFZ2mtMmbhRIyPtwW/aawWhVNRK4Y7P2ivuMjam2+x7RlXzTrshmnHj IHhw== X-Gm-Message-State: APjAAAXtevJdkHSOe9Nq/vSOGeuNEhF8Why8c1k4e8W594K0SgkM5OZz vwd1iaDWRrdrexBH2yqVEK+dDTH6g6Y= X-Google-Smtp-Source: APXvYqw8B01YxlWv3cdvdz1KbV9dJR9VvgR4WsLnkObSzKzJf+FzgcxEKHUe8Cq+m7lYJnf+Gu0+ww== X-Received: by 2002:a63:3f84:: with SMTP id m126mr34593874pga.213.1562141642532; Wed, 03 Jul 2019 01:14:02 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id d2sm1445306pgo.0.2019.07.03.01.14.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 01:14:01 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , Chris Spencer , Cory Tusar , Chris Healy , Lucas Stach , =?utf-8?q?Horia_Geant=C4=83?= , Aymen Sghaier , Leonard Crestez , linux-kernel@vger.kernel.org Subject: [PATCH v4 04/16] crypto: caam - use deveres to allocate 'entinfo' Date: Wed, 3 Jul 2019 01:13:15 -0700 Message-Id: <20190703081327.17505-5-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190703081327.17505-1-andrew.smirnov@gmail.com> References: <20190703081327.17505-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use deveres to allocate 'entinfo' and drop corresponding call to kfree(). No functional change intended. Signed-off-by: Andrey Smirnov Cc: Chris Spencer Cc: Cory Tusar Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Aymen Sghaier Cc: Leonard Crestez Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/caam/jr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c index a7ca2bbe243f..fc7deb445aa8 100644 --- a/drivers/crypto/caam/jr.c +++ b/drivers/crypto/caam/jr.c @@ -125,7 +125,6 @@ static int caam_jr_shutdown(struct device *dev) jrp->inpring, inpbusaddr); dma_free_coherent(dev, sizeof(struct jr_outentry) * JOBR_DEPTH, jrp->outring, outbusaddr); - kfree(jrp->entinfo); return ret; } @@ -465,7 +464,8 @@ static int caam_jr_init(struct device *dev) if (!jrp->outring) goto out_free_inpring; - jrp->entinfo = kcalloc(JOBR_DEPTH, sizeof(*jrp->entinfo), GFP_KERNEL); + jrp->entinfo = devm_kcalloc(dev, JOBR_DEPTH, sizeof(*jrp->entinfo), + GFP_KERNEL); if (!jrp->entinfo) goto out_free_outring; From patchwork Wed Jul 3 08:13:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11029061 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D9E413A4 for ; Wed, 3 Jul 2019 08:15:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1099628786 for ; Wed, 3 Jul 2019 08:15:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0505928972; Wed, 3 Jul 2019 08:15:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A82228807 for ; Wed, 3 Jul 2019 08:15:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727327AbfGCIOF (ORCPT ); Wed, 3 Jul 2019 04:14:05 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:36464 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727185AbfGCIOF (ORCPT ); Wed, 3 Jul 2019 04:14:05 -0400 Received: by mail-pl1-f194.google.com with SMTP id k8so811616plt.3; Wed, 03 Jul 2019 01:14:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9WUDh01MjOopjE2651F/x1CBV/vDwEN3vFSVjbCfKwU=; b=Lq1x3a+QBg/bPxKkRGIQH/UAK1iYekfX7MVQv7letnQBccACuyCFvLD2qVTuuFZogz /FcNgnWnpj/a2NPZW0/tO0DZQDYKfZvD+02K9I/HBO1NLrv1pOv2c+WqDCcPdPQrgAmG pdKSios3ua9DEdcOrAC1Oh41B1lWYLZ80h2uTqtl8oDUGFws873ha8tNjwouYxPHyE5g znOgH2cqbld/afw/9vwVVCWGmzUV7zhRZmrs+/D2jc7ERbk5QlboxsrVthIG+YqkFU/K kIf2CXA4YkgjyghFJ2jVJnMuCsdoe+FiPOHyojlZKBwg6KOTi11OSu0Gppkr6ooM1TTz 25Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9WUDh01MjOopjE2651F/x1CBV/vDwEN3vFSVjbCfKwU=; b=McbInfIBLP/RnpO/InIjePYLDMNtxi2dFRCXg/6IOsY+fUeMWoENjXtUv8dWr/tsGE QGOXZvgriUizi0txoTTvFBg2+GNkjLq0PLgalrIlBaODykX8nB6V7m61u4+7ePLrDyAF FRoC/saGiv72eH6+BkQeTCL6ym+i5JTyvx6tF6Tn4B2Jh/My2M3v6zrqv2+fb1cwmUq2 HB2KiAcrZrHAtzWVF4smCBUqmHvYMM2oNGRHBD1sXD1M1cumykA5GsZhD+GByct4AB1n xbRgz47OpIjQYi3PyFj6qP38GKePw8ZvMdtAGSj+3cU2qF19cRRoyRb6l9tq9jEEw+Vv /vXg== X-Gm-Message-State: APjAAAW5RUj1uS5Hsv12Uf5iatAMIOf6GA99lF8nbR75QLDYie8VOhuw UYnsmJPRt23aqKjgm0PwfSv2ExfgOak= X-Google-Smtp-Source: APXvYqyS/mLU68zLObUvHEK0z68mtiUbdOO0ip92Wh2px534KXtR/5l/W1NpAs0gdeylAoUcJyB7yQ== X-Received: by 2002:a17:902:1e6:: with SMTP id b93mr40713178plb.295.1562141643827; Wed, 03 Jul 2019 01:14:03 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id d2sm1445306pgo.0.2019.07.03.01.14.02 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 01:14:03 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , Chris Spencer , Cory Tusar , Chris Healy , Lucas Stach , =?utf-8?q?Horia_Geant=C4=83?= , Aymen Sghaier , Leonard Crestez , linux-kernel@vger.kernel.org Subject: [PATCH v4 05/16] crypto: caam - use devres to allocate 'outring' Date: Wed, 3 Jul 2019 01:13:16 -0700 Message-Id: <20190703081327.17505-6-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190703081327.17505-1-andrew.smirnov@gmail.com> References: <20190703081327.17505-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use devres to allocate 'outring' and drop corresponding call to dma_free_coherent() as well as extra references to 'struct jr_outentry' (needed in following commits). No functional change inteded. Signed-off-by: Andrey Smirnov Cc: Chris Spencer Cc: Cory Tusar Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Aymen Sghaier Cc: Leonard Crestez Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/caam/jr.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c index fc7deb445aa8..1eaa91dcc146 100644 --- a/drivers/crypto/caam/jr.c +++ b/drivers/crypto/caam/jr.c @@ -108,7 +108,7 @@ static int caam_reset_hw_jr(struct device *dev) static int caam_jr_shutdown(struct device *dev) { struct caam_drv_private_jr *jrp = dev_get_drvdata(dev); - dma_addr_t inpbusaddr, outbusaddr; + dma_addr_t inpbusaddr; int ret; ret = caam_reset_hw_jr(dev); @@ -120,11 +120,8 @@ static int caam_jr_shutdown(struct device *dev) /* Free rings */ inpbusaddr = rd_reg64(&jrp->rregs->inpring_base); - outbusaddr = rd_reg64(&jrp->rregs->outring_base); dma_free_coherent(dev, sizeof(dma_addr_t) * JOBR_DEPTH, jrp->inpring, inpbusaddr); - dma_free_coherent(dev, sizeof(struct jr_outentry) * JOBR_DEPTH, - jrp->outring, outbusaddr); return ret; } @@ -459,15 +456,16 @@ static int caam_jr_init(struct device *dev) if (!jrp->inpring) goto out_free_irq; - jrp->outring = dma_alloc_coherent(dev, sizeof(*jrp->outring) * - JOBR_DEPTH, &outbusaddr, GFP_KERNEL); + jrp->outring = dmam_alloc_coherent(dev, sizeof(*jrp->outring) * + JOBR_DEPTH, &outbusaddr, + GFP_KERNEL); if (!jrp->outring) goto out_free_inpring; jrp->entinfo = devm_kcalloc(dev, JOBR_DEPTH, sizeof(*jrp->entinfo), GFP_KERNEL); if (!jrp->entinfo) - goto out_free_outring; + return -ENOMEM; tasklet_init(&jrp->irqtask, caam_jr_dequeue, (unsigned long)dev); @@ -495,9 +493,6 @@ static int caam_jr_init(struct device *dev) return 0; -out_free_outring: - dma_free_coherent(dev, sizeof(struct jr_outentry) * JOBR_DEPTH, - jrp->outring, outbusaddr); out_free_inpring: dma_free_coherent(dev, sizeof(dma_addr_t) * JOBR_DEPTH, jrp->inpring, inpbusaddr); From patchwork Wed Jul 3 08:13:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11029059 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 07D6313B1 for ; Wed, 3 Jul 2019 08:15:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED4F32880A for ; Wed, 3 Jul 2019 08:15:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD76728833; Wed, 3 Jul 2019 08:15:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69E6A28786 for ; Wed, 3 Jul 2019 08:15:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727355AbfGCIPC (ORCPT ); Wed, 3 Jul 2019 04:15:02 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:36469 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727321AbfGCIOG (ORCPT ); Wed, 3 Jul 2019 04:14:06 -0400 Received: by mail-pl1-f195.google.com with SMTP id k8so811648plt.3; Wed, 03 Jul 2019 01:14:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2h20kHGJbizKH54h9j83TWNj7oYw/atmUiwKwp86SnQ=; b=fKeKmBgH/r9868YdIKvLTA3k7CbTCv10o66dZK6ybUnyyvWVMD8R2TGU1qJh+hAnJp HrpDNCdtD8A7vfpn4ptaqEs/c829m0VMWfbzqUyj+9W+2VihboRzNBJG/SB4qUsKGk3o 1hZ89ZtUcxPloAuxR/6QDl/k3Xanh5UMwgYmfEGclxWLcbFCBw1w5skOSPlE5+0DSKJI wp01QNb9PjRNTD8pt1iwpnv4DAaJre2FUE48GNbf1tDXfmAETLuoUOtbrTjn5WPy1xZ4 sSirh2H87bN0hlye6RsmBvwVI1IGk8AIXN2G6Sg34rsvLzOB1NMy8XPZhmhVlWJD+Ahl MjUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2h20kHGJbizKH54h9j83TWNj7oYw/atmUiwKwp86SnQ=; b=l2gZRRXyws2jkXJE92PDkbgXPRmreMF8RZOA16BbiTyn19zhzjE2RMZqVWTd2kMOJl /OtDhkuqLHVjYPpP8NLKN6NF5DnxVFlcj9jRRgwgrJTY1gVwDGKQ3PxcfY+SDfWmRUHE x/pHgQLhawqxBj3J4f6l2aP3S8qzUZkssMIHsVrkOQDy3iAf3NpW2RLnLYC5xiuxsUgw G++LZODdB5IZwlkRp1PYoHq1Rswmq3WX2rz6Qv8bxkGLCdlBXPRl7qkoBIBgbtgSwIfi vRxiErgj3AvHg3EOkKUVWJftaFFsTlxOZt2/R1i3lIt/iF6Irc94mBaKKlishKty+kMC ji0A== X-Gm-Message-State: APjAAAWquRsEi+MhO6JIbnlZvp/BQs56GAeSMUbMErxru1PncwKe7/r6 sz1+iW/ncZrLRDmwXE9/eH4QjLAGjoE= X-Google-Smtp-Source: APXvYqzjwjB4kCIa+danq4eu6nHIemNaNDAtFQxoSKzSjiWGZh7s0VOdA19bW6jxIk9Wz5V2GmjpuA== X-Received: by 2002:a17:902:f213:: with SMTP id gn19mr42057694plb.35.1562141645054; Wed, 03 Jul 2019 01:14:05 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id d2sm1445306pgo.0.2019.07.03.01.14.03 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 01:14:04 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , Chris Spencer , Cory Tusar , Chris Healy , Lucas Stach , =?utf-8?q?Horia_Geant=C4=83?= , Aymen Sghaier , Leonard Crestez , linux-kernel@vger.kernel.org Subject: [PATCH v4 06/16] crypto: caam - use devres to allocate 'inpring' Date: Wed, 3 Jul 2019 01:13:17 -0700 Message-Id: <20190703081327.17505-7-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190703081327.17505-1-andrew.smirnov@gmail.com> References: <20190703081327.17505-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use devres to allocate 'inpring' and drop corresponding dma_free_coherent() call as well explicit references to size of 'inpring' elemet (needet in following commits). No functional change intended. Signed-off-by: Andrey Smirnov Cc: Chris Spencer Cc: Cory Tusar Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Aymen Sghaier Cc: Leonard Crestez Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/caam/jr.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c index 1eaa91dcc146..813e9135babd 100644 --- a/drivers/crypto/caam/jr.c +++ b/drivers/crypto/caam/jr.c @@ -108,7 +108,6 @@ static int caam_reset_hw_jr(struct device *dev) static int caam_jr_shutdown(struct device *dev) { struct caam_drv_private_jr *jrp = dev_get_drvdata(dev); - dma_addr_t inpbusaddr; int ret; ret = caam_reset_hw_jr(dev); @@ -118,11 +117,6 @@ static int caam_jr_shutdown(struct device *dev) /* Release interrupt */ free_irq(jrp->irq, dev); - /* Free rings */ - inpbusaddr = rd_reg64(&jrp->rregs->inpring_base); - dma_free_coherent(dev, sizeof(dma_addr_t) * JOBR_DEPTH, - jrp->inpring, inpbusaddr); - return ret; } @@ -451,8 +445,9 @@ static int caam_jr_init(struct device *dev) goto out_free_irq; error = -ENOMEM; - jrp->inpring = dma_alloc_coherent(dev, sizeof(*jrp->inpring) * - JOBR_DEPTH, &inpbusaddr, GFP_KERNEL); + jrp->inpring = dmam_alloc_coherent(dev, sizeof(*jrp->inpring) * + JOBR_DEPTH, &inpbusaddr, + GFP_KERNEL); if (!jrp->inpring) goto out_free_irq; @@ -460,7 +455,7 @@ static int caam_jr_init(struct device *dev) JOBR_DEPTH, &outbusaddr, GFP_KERNEL); if (!jrp->outring) - goto out_free_inpring; + return -ENOMEM; jrp->entinfo = devm_kcalloc(dev, JOBR_DEPTH, sizeof(*jrp->entinfo), GFP_KERNEL); @@ -493,10 +488,6 @@ static int caam_jr_init(struct device *dev) return 0; -out_free_inpring: - dma_free_coherent(dev, sizeof(dma_addr_t) * JOBR_DEPTH, - jrp->inpring, inpbusaddr); - dev_err(dev, "can't allocate job rings for %d\n", jrp->ridx); out_free_irq: free_irq(jrp->irq, dev); return error; From patchwork Wed Jul 3 08:13:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11029039 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0271F1398 for ; Wed, 3 Jul 2019 08:14:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBD5B28786 for ; Wed, 3 Jul 2019 08:14:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF29728833; Wed, 3 Jul 2019 08:14:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 64DA528786 for ; Wed, 3 Jul 2019 08:14:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727240AbfGCIOJ (ORCPT ); Wed, 3 Jul 2019 04:14:09 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:36809 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727349AbfGCIOH (ORCPT ); Wed, 3 Jul 2019 04:14:07 -0400 Received: by mail-pf1-f195.google.com with SMTP id r7so861620pfl.3; Wed, 03 Jul 2019 01:14:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E8M9KHyXwUEtFUyzJoarpboyeyNZ234MBzkiPCu7LgU=; b=vUhrNbCDIvS67tnXwUfLw5GEGFQea54Ki+FXYGZ5Cn5018Oa/iCRe8dxG9Y5nw8JEB PFbSvFGj2v/FF19rfEYoaP9svsPxxXFGYNrFAR0cd0GtMBfAAYFEfxGeO3BRkyHlgsa6 hodyY9kNf3/heyZxe+iAvJmxWn0xQGnKUkm0eZSEHO5UYgqaV26pYJcUlRxN8UQ0IHA0 tx62sESoyhEgJfwaQ45iMLFs4PjWtWrYOaBoiIyE2jhk3Z5mrMCBdGPJ8HF+L/Jl7bWG czapO6Ix8xXPTDig6mD0fcRnyKURPfLRbPXIPmCrBW5QfwiEBfzBBixx4pP9ywpwESTO guQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E8M9KHyXwUEtFUyzJoarpboyeyNZ234MBzkiPCu7LgU=; b=WlRK++25nGh9Eye3Tgi5kH2DwRT9+g4mXgEnn0YtRgHSHxeEPgnRLkd2T8NGhC04qE MWpallPuwZayUSakP/oo91kd6ZxKSsgnPjb2SV9e57TM62VUNM3nAN6D+qG7gz2uPA7u mQpDltMT8Fx+a1S2M3soIni9BPU98jE/XdH1dHoeD18lir045EzGSUPOPuFSJ0I0VSen EJYasPa/9p248nnoAwKPxgnaAB1TvvXgplHiL5q1mwN+3nUdFD3ybNJihH1Pv2Wi73ix 6i25x0KdDZL+X/p0tj9O0VBv188aK694GsKzBOb6mKo7qxAZWKvRcJ+ncLQ6Kw91eqfu bPLQ== X-Gm-Message-State: APjAAAU17PAcPkelG+qmkYMYYfmz9+7zYN+sHOkRazNuTkkowTqrHEVm hfmJqctwFlGJboV/Ml1Aw87yK1rbsog= X-Google-Smtp-Source: APXvYqxoo0GbFdu6WkqUIO+eV+iQSsWyzK2BmStOWYbRyx1gYRnTxImOvn36tHGY8WJJB+wn769gug== X-Received: by 2002:a63:d53:: with SMTP id 19mr36802567pgn.453.1562141646350; Wed, 03 Jul 2019 01:14:06 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id d2sm1445306pgo.0.2019.07.03.01.14.05 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 01:14:05 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , Chris Spencer , Cory Tusar , Chris Healy , Lucas Stach , =?utf-8?q?Horia_Geant=C4=83?= , Aymen Sghaier , Leonard Crestez , linux-kernel@vger.kernel.org Subject: [PATCH v4 07/16] crytpo: caam - make use of iowrite64*_hi_lo in wr_reg64 Date: Wed, 3 Jul 2019 01:13:18 -0700 Message-Id: <20190703081327.17505-8-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190703081327.17505-1-andrew.smirnov@gmail.com> References: <20190703081327.17505-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to be able to unify 64 and 32 bit implementations of wr_reg64, let's convert it to use helpers from first. Here are the steps of the transformation: 1. Inline wr_reg32 helpers: if (!caam_imx && caam_little_end) { if (caam_little_end) { iowrite32(data >> 32, (u32 __iomem *)(reg) + 1); iowrite32(data, (u32 __iomem *)(reg)); } else { iowrite32be(data >> 32, (u32 __iomem *)(reg) + 1); iowrite32be(data, (u32 __iomem *)(reg)); } } else { if (caam_little_end) { iowrite32(data >> 32, (u32 __iomem *)(reg)); iowrite32(data, (u32 __iomem *)(reg) + 1); } else { iowrite32be(data >> 32, (u32 __iomem *)(reg)); iowrite32be(data, (u32 __iomem *)(reg) + 1); } } 2. Transfrom the conditionals such that the check for 'caam_little_end' is at the top level: if (caam_little_end) { if (!caam_imx) { iowrite32(data >> 32, (u32 __iomem *)(reg) + 1); iowrite32(data, (u32 __iomem *)(reg)); } else { iowrite32(data >> 32, (u32 __iomem *)(reg)); iowrite32(data, (u32 __iomem *)(reg) + 1); } } else { iowrite32be(data >> 32, (u32 __iomem *)(reg)); iowrite32be(data, (u32 __iomem *)(reg) + 1); } 3. Invert the check for !caam_imx: if (caam_little_end) { if (caam_imx) { iowrite32(data >> 32, (u32 __iomem *)(reg)); iowrite32(data, (u32 __iomem *)(reg) + 1); } else { iowrite32(data >> 32, (u32 __iomem *)(reg) + 1); iowrite32(data, (u32 __iomem *)(reg)); } } else { iowrite32be(data >> 32, (u32 __iomem *)(reg)); iowrite32be(data, (u32 __iomem *)(reg) + 1); } 4. Make use of iowrite64* helpers from if (caam_little_end) { if (caam_imx) { iowrite32(data >> 32, (u32 __iomem *)(reg)); iowrite32(data, (u32 __iomem *)(reg) + 1); } else { iowrite64(data, reg); } } else { iowrite64be(data, reg); } No functional change intended. Signed-off-by: Andrey Smirnov Cc: Chris Spencer Cc: Cory Tusar Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Aymen Sghaier Cc: Leonard Crestez Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/caam/regs.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/caam/regs.h b/drivers/crypto/caam/regs.h index 8591914d5c51..6e8352ac0d92 100644 --- a/drivers/crypto/caam/regs.h +++ b/drivers/crypto/caam/regs.h @@ -12,6 +12,7 @@ #include #include #include +#include /* * Architecture-specific register access methods @@ -157,12 +158,15 @@ static inline u64 rd_reg64(void __iomem *reg) #else /* CONFIG_64BIT */ static inline void wr_reg64(void __iomem *reg, u64 data) { - if (!caam_imx && caam_little_end) { - wr_reg32((u32 __iomem *)(reg) + 1, data >> 32); - wr_reg32((u32 __iomem *)(reg), data); + if (caam_little_end) { + if (caam_imx) { + iowrite32(data >> 32, (u32 __iomem *)(reg)); + iowrite32(data, (u32 __iomem *)(reg) + 1); + } else { + iowrite64(data, reg); + } } else { - wr_reg32((u32 __iomem *)(reg), data >> 32); - wr_reg32((u32 __iomem *)(reg) + 1, data); + iowrite64be(data, reg); } } From patchwork Wed Jul 3 08:13:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11029041 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EEA001398 for ; Wed, 3 Jul 2019 08:14:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3C9C28786 for ; Wed, 3 Jul 2019 08:14:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7AA02880A; Wed, 3 Jul 2019 08:14:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFA8E28807 for ; Wed, 3 Jul 2019 08:14:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727363AbfGCIOJ (ORCPT ); Wed, 3 Jul 2019 04:14:09 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:38694 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727185AbfGCIOJ (ORCPT ); Wed, 3 Jul 2019 04:14:09 -0400 Received: by mail-pg1-f195.google.com with SMTP id z75so814471pgz.5; Wed, 03 Jul 2019 01:14:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HCmJmyzmQT4Pt6JaXDG9/uRNYLrXoyYw1jAGneb5HzY=; b=ZZnIX9UaZGyuDvO48xtLr/H1WO8/EBI2wEYk1XHvwBJVcjwsQGK5gkEmlb1eY8S82G 14ZRWDzdxXdnu5CSjJV7Y6AZxCkSEwnYWPD8yJAiskPfr+iJvnlqRqgJJ3g9YOlgpv+w u11t3H2O517+696LChy64YGdWoNLI4WaTJ019UPrwqZsdpNXxP0NzOsWaaWGHKnOHiKj mwr3vuDC6Uzs/yr71SBCQKIGf/3WsJuc1pWOds9iQ1j+RwlEfKDCfuQpOp0kD1rFjfZo a+LIkkZpnLgXDNBQ406PqJPzuU8qSLLWcALZ8Y1WqGSxNaqgb6f+DIDiu/6UhVNfl/yS OIig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HCmJmyzmQT4Pt6JaXDG9/uRNYLrXoyYw1jAGneb5HzY=; b=kqtfve1ou+5XtvV01XUsBKIJdVdltT8Tw4Vaz/42ASUu3X8NJWeWhIuF0mT2iUIsTL loPJrk1LJOQ6ff/85a0ziGz/EbVpUKBKK0PgyCNxlXMnkujJPmzdbLEz7rs31IMgX2Fr xO+REVwhZZ7nHHeZHKjbPRAYQ5dR7GYZQS3pkOJOfjZ+R4IypPp0XwnYPqvRdWQw6/cc +oytpBfoNldK3JK/fGcsEGRPb1qjbKwbOJ2h7IZj5Qs6aVw5igM1/AVXssLWCyDU6i6u Yoc5DAIoIhk+QxErbShG0OB7HYuWhqwEvM0/JKw5qCQpZGnIsuTlo3OgoWD+DZfv/bER zGHg== X-Gm-Message-State: APjAAAUh8oymHqQybuUf4zIH7uKptSlF6Z6G0JjdD282OHL/1NjXM2gy MH+A5LrKyL9L2UiWITlZyqZ6zAHO+bQ= X-Google-Smtp-Source: APXvYqzaR5M8wziwkPrxSec1KbxGfXyehUKrRQebI+8TmPvE84ahWfftCUUbP8FlaLVx6eF2DJFghg== X-Received: by 2002:a63:62c3:: with SMTP id w186mr36989443pgb.64.1562141647547; Wed, 03 Jul 2019 01:14:07 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id d2sm1445306pgo.0.2019.07.03.01.14.06 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 01:14:06 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , Chris Spencer , Cory Tusar , Chris Healy , Lucas Stach , =?utf-8?q?Horia_Geant=C4=83?= , Aymen Sghaier , Leonard Crestez , linux-kernel@vger.kernel.org Subject: [PATCH v4 08/16] crypto: caam - use ioread64*_hi_lo in rd_reg64 Date: Wed, 3 Jul 2019 01:13:19 -0700 Message-Id: <20190703081327.17505-9-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190703081327.17505-1-andrew.smirnov@gmail.com> References: <20190703081327.17505-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Following the same transformation logic as outlined in previous commit converting wr_reg64, convert rd_reg64 to use helpers from first. No functional change intended. Signed-off-by: Andrey Smirnov Cc: Chris Spencer Cc: Cory Tusar Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Aymen Sghaier Cc: Leonard Crestez Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/caam/regs.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/caam/regs.h b/drivers/crypto/caam/regs.h index 6e8352ac0d92..afdc0d1aa338 100644 --- a/drivers/crypto/caam/regs.h +++ b/drivers/crypto/caam/regs.h @@ -172,12 +172,20 @@ static inline void wr_reg64(void __iomem *reg, u64 data) static inline u64 rd_reg64(void __iomem *reg) { - if (!caam_imx && caam_little_end) - return ((u64)rd_reg32((u32 __iomem *)(reg) + 1) << 32 | - (u64)rd_reg32((u32 __iomem *)(reg))); + if (caam_little_end) { + if (caam_imx) { + u32 low, high; - return ((u64)rd_reg32((u32 __iomem *)(reg)) << 32 | - (u64)rd_reg32((u32 __iomem *)(reg) + 1)); + high = ioread32(reg); + low = ioread32(reg + sizeof(u32)); + + return low + ((u64)high << 32); + } else { + return ioread64(reg); + } + } else { + return ioread64be(reg); + } } #endif /* CONFIG_64BIT */ From patchwork Wed Jul 3 08:13:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11029057 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D46F413A4 for ; Wed, 3 Jul 2019 08:14:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8EB428807 for ; Wed, 3 Jul 2019 08:14:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCDC428833; Wed, 3 Jul 2019 08:14:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 624DB28807 for ; Wed, 3 Jul 2019 08:14:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727124AbfGCIOy (ORCPT ); Wed, 3 Jul 2019 04:14:54 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:47062 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727364AbfGCIOK (ORCPT ); Wed, 3 Jul 2019 04:14:10 -0400 Received: by mail-pg1-f196.google.com with SMTP id i8so796118pgm.13; Wed, 03 Jul 2019 01:14:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xMpnTuEF4VNlabdEsAMZ4XSxyFLWi8ZClVXNYx4KkpU=; b=qVZHkme6fvf8aglv3tkuK+jmDsuPAZVTAiDpb/GEFk76c/tx5ID7g6ByTtMgAAd9Wy pQkuun8ELlsVeAN9Tpy91FqesxZETKkrOTiohCo6pS37EJr+sp72i3hhHlked9/L8C4Q OL4qyRAlI6/REBifttko2nfSKwTajfSX6ublH/jkcQbOfbup9ri87A8eBNIzTPy9zgzJ NZp1qLWydzn35z98Ey/P6cN1AmMBbmsmg7ZRIjbL/GWfBdWlks0fq+6RdOP9ScyR4vwK 1IU3PWKVYLZHLjqs98idwwe+5A+KueTA49n67gR4cyHNSoFTiFJpIxVcBGFHB62i50ch 3EdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xMpnTuEF4VNlabdEsAMZ4XSxyFLWi8ZClVXNYx4KkpU=; b=F4cQo5fkV/a14UJ2AQuVu3AIAH/idK5s0xRof1zoglI3SXGl1Jf3Wnw1fbun/u72oB sWkJxeQu5p57v4EqUMd0l3ghEApxRX+6UbUL5BW7/TzlGCPnDRSWFQDjShWfK628VM2s zGp9XkLpk4elgiuOFDD9WFwmXlAuLvGEy+n3KpUAAFufA4LT1LAg//Z0SUt2Gyxy1S/K wRPXvCA/2V3eOolICha4yJa0BzF0r2AMT0qfyT31UPUE2RoPoJZIk3zyE0Cr7g8fS37a FiKCGNIiJ8Ntuxg4vWmV4trxh7oFAVcZdeZkPSJ3jfdN0Htgc2ieQj5Lofpbq+srlOhM PiFA== X-Gm-Message-State: APjAAAVKvTNqOcjz1dVdALrf1Xg+LNyHT02SVuRcQSOH1OiUE8cp0qHe aeZjvuxCDrgQ9tIa9hvSDatAdGzPlaY= X-Google-Smtp-Source: APXvYqy6ReGzaO65rzPd9ZNz3J4puHYREDfAlMBe6X+nugyhLMeATX/71BccuFBJHLXnXJQq7e2UZw== X-Received: by 2002:a63:224a:: with SMTP id t10mr35544309pgm.289.1562141649226; Wed, 03 Jul 2019 01:14:09 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id d2sm1445306pgo.0.2019.07.03.01.14.08 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 01:14:08 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , Chris Spencer , Cory Tusar , Chris Healy , Lucas Stach , =?utf-8?q?Horia_Geant=C4=83?= , Aymen Sghaier , Leonard Crestez , linux-kernel@vger.kernel.org Subject: [PATCH v4 09/16] crypto: caam - drop 64-bit only wr/rd_reg64() Date: Wed, 3 Jul 2019 01:13:20 -0700 Message-Id: <20190703081327.17505-10-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190703081327.17505-1-andrew.smirnov@gmail.com> References: <20190703081327.17505-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since 32-bit of both wr_reg64 and rd_reg64 now use 64-bit IO helpers, these functions should no longer be necessary. No functional change intended. Signed-off-by: Andrey Smirnov Cc: Chris Spencer Cc: Cory Tusar Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Aymen Sghaier Cc: Leonard Crestez Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/caam/regs.h | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/drivers/crypto/caam/regs.h b/drivers/crypto/caam/regs.h index afdc0d1aa338..fb494d14f262 100644 --- a/drivers/crypto/caam/regs.h +++ b/drivers/crypto/caam/regs.h @@ -138,24 +138,6 @@ static inline void clrsetbits_32(void __iomem *reg, u32 clear, u32 set) * base + 0x0000 : least-significant 32 bits * base + 0x0004 : most-significant 32 bits */ -#ifdef CONFIG_64BIT -static inline void wr_reg64(void __iomem *reg, u64 data) -{ - if (caam_little_end) - iowrite64(data, reg); - else - iowrite64be(data, reg); -} - -static inline u64 rd_reg64(void __iomem *reg) -{ - if (caam_little_end) - return ioread64(reg); - else - return ioread64be(reg); -} - -#else /* CONFIG_64BIT */ static inline void wr_reg64(void __iomem *reg, u64 data) { if (caam_little_end) { @@ -187,7 +169,6 @@ static inline u64 rd_reg64(void __iomem *reg) return ioread64be(reg); } } -#endif /* CONFIG_64BIT */ static inline u64 cpu_to_caam_dma64(dma_addr_t value) { From patchwork Wed Jul 3 08:13:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11029055 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 37E831398 for ; Wed, 3 Jul 2019 08:14:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CF0328786 for ; Wed, 3 Jul 2019 08:14:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 213472880A; Wed, 3 Jul 2019 08:14:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93F3228786 for ; Wed, 3 Jul 2019 08:14:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727349AbfGCIOL (ORCPT ); Wed, 3 Jul 2019 04:14:11 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:43451 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727374AbfGCIOL (ORCPT ); Wed, 3 Jul 2019 04:14:11 -0400 Received: by mail-pg1-f195.google.com with SMTP id f25so803487pgv.10; Wed, 03 Jul 2019 01:14:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PkneT3aecs6Kbwyjtaql2AriO4Q+BBNKS7A4THu3IYU=; b=RiDwKn+FlKgrr41ZvjT3tbd7ujE40hDraiJKOBSkwLxwpQDvQ8nTXFKMo46K5IRrdq 3SaLq94hb4FAzn0zcDq7VsdBMSWi3qpBgs43hguMnPdgEGllxujL3INNOuKqicHETFYF lX+BDtu2Yj/1Ze9+QALF3zu2ntdzO1feO8N9HIG+oQ6pNyBUjXVdmIRQedPKammvfsC/ TBs3AVTOeMfo5L+AmvLhwOgfmjjkq7yqUw//bXdjFVXl1CSm9o1ZrEOwBnkRZNn0OlBp E8k50UeA/MX84/LMcfAHTMiTUBpZesq0tc6QRfbHxws/1hgAvXqx54Zrxax3iJey4mt6 gz1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PkneT3aecs6Kbwyjtaql2AriO4Q+BBNKS7A4THu3IYU=; b=PWYqAudM+DV+7ebHYAxrIERdOISsXdy4JeFTUTwCUldnv/EbVVCKXP+nJQyYap29ff 50NwhpV7tvaKiX2V0cgrtYyG1zWqxjTtLxRSQO5BQhxQCQ90/74QaGMZAFg+DIOlmR/1 XB09M8CRneMKBZ3om19Ny10/lwT2mF/tN0uy29SaEa025dZXTpznYg46ozK49kO5YVnY oaTsZKg5zaWQ+nJvmPxlfkv2DTP92D07L/UGgJq3sAwpf6aU1lf5HHOiGTDkYAt0Zz0Q IqeznlqvDMcvU8X2cAOAAbyfZHgQCHtskgCk31MKFaC2ipk9yjLkDAH22Onc7sdtTb/U R9Kg== X-Gm-Message-State: APjAAAUK+6elrLE7/Oeag0b6aXhcrbHDBKwu3VEiAr3RBk8IZEzwkGyT b4UjKIeFCN7NT/obYrRRiOgbk+tfDQI= X-Google-Smtp-Source: APXvYqwZzveMeYPZadlqmFOO4kJHKq3ImJw1NWDaYErehoJdabJXzHqx0oCVnpu1UlopyRnZRgEB2w== X-Received: by 2002:a65:64d3:: with SMTP id t19mr26322063pgv.112.1562141650474; Wed, 03 Jul 2019 01:14:10 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id d2sm1445306pgo.0.2019.07.03.01.14.09 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 01:14:09 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , Chris Spencer , Cory Tusar , Chris Healy , Lucas Stach , =?utf-8?q?Horia_Geant=C4=83?= , Aymen Sghaier , Leonard Crestez , linux-kernel@vger.kernel.org Subject: [PATCH v4 10/16] crypto: caam - make CAAM_PTR_SZ dynamic Date: Wed, 3 Jul 2019 01:13:21 -0700 Message-Id: <20190703081327.17505-11-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190703081327.17505-1-andrew.smirnov@gmail.com> References: <20190703081327.17505-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to be able to configure CAAM pointer size at run-time, which needed to support i.MX8MQ, which is 64-bit SoC with 32-bit pointer size, convert CAAM_PTR_SZ to refer to a global variable of the same name ("caam_ptr_sz") and adjust the rest of the code accordingly. No functional change intended. Signed-off-by: Andrey Smirnov Cc: Chris Spencer Cc: Cory Tusar Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Aymen Sghaier Cc: Leonard Crestez Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/caam/caamalg.c | 2 +- drivers/crypto/caam/caamhash.c | 2 +- drivers/crypto/caam/caamrng.c | 2 +- drivers/crypto/caam/ctrl.c | 2 ++ drivers/crypto/caam/desc_constr.h | 10 ++++++++-- drivers/crypto/caam/error.c | 3 +++ 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c index 4b03c967009b..7f13ccc1e603 100644 --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c @@ -74,7 +74,7 @@ #define CHACHAPOLY_DESC_JOB_IO_LEN (AEAD_DESC_JOB_IO_LEN + CAAM_CMD_SZ * 6) -#define DESC_MAX_USED_BYTES (CAAM_DESC_BYTES_MAX - DESC_JOB_IO_LEN) +#define DESC_MAX_USED_BYTES (CAAM_DESC_BYTES_MAX - DESC_JOB_IO_LEN_MIN) #define DESC_MAX_USED_LEN (DESC_MAX_USED_BYTES / CAAM_CMD_SZ) struct caam_alg_entry { diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c index a87526f62737..4bfec53ccb8e 100644 --- a/drivers/crypto/caam/caamhash.c +++ b/drivers/crypto/caam/caamhash.c @@ -538,7 +538,7 @@ struct ahash_edesc { dma_addr_t sec4_sg_dma; int src_nents; int sec4_sg_bytes; - u32 hw_desc[DESC_JOB_IO_LEN / sizeof(u32)] ____cacheline_aligned; + u32 hw_desc[DESC_JOB_IO_LEN_MAX / sizeof(u32)] ____cacheline_aligned; struct sec4_sg_entry sec4_sg[0]; }; diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c index 561bcb535184..511f0b44e258 100644 --- a/drivers/crypto/caam/caamrng.c +++ b/drivers/crypto/caam/caamrng.c @@ -53,7 +53,7 @@ L1_CACHE_BYTES) /* length of descriptors */ -#define DESC_JOB_O_LEN (CAAM_CMD_SZ * 2 + CAAM_PTR_SZ * 2) +#define DESC_JOB_O_LEN (CAAM_CMD_SZ * 2 + CAAM_PTR_SZ_MAX * 2) #define DESC_RNG_LEN (3 * CAAM_CMD_SZ) /* Buffer, its dma address and lock */ diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index 908d3ecf6d1c..42692a2bc2f3 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -605,6 +605,8 @@ static int caam_probe(struct platform_device *pdev) } caam_imx = (bool)imx_soc_match; + caam_ptr_sz = sizeof(dma_addr_t); + /* Get configuration properties from device tree */ /* First, get register page */ ctrl = of_iomap(nprop, 0); diff --git a/drivers/crypto/caam/desc_constr.h b/drivers/crypto/caam/desc_constr.h index 5988a26a2441..3a83a3332ba9 100644 --- a/drivers/crypto/caam/desc_constr.h +++ b/drivers/crypto/caam/desc_constr.h @@ -14,9 +14,14 @@ #define IMMEDIATE (1 << 23) #define CAAM_CMD_SZ sizeof(u32) -#define CAAM_PTR_SZ sizeof(dma_addr_t) +#define CAAM_PTR_SZ caam_ptr_sz +#define CAAM_PTR_SZ_MAX sizeof(dma_addr_t) +#define CAAM_PTR_SZ_MIN sizeof(u32) #define CAAM_DESC_BYTES_MAX (CAAM_CMD_SZ * MAX_CAAM_DESCSIZE) -#define DESC_JOB_IO_LEN (CAAM_CMD_SZ * 5 + CAAM_PTR_SZ * 3) +#define __DESC_JOB_IO_LEN(n) (CAAM_CMD_SZ * 5 + (n) * 3) +#define DESC_JOB_IO_LEN __DESC_JOB_IO_LEN(CAAM_PTR_SZ) +#define DESC_JOB_IO_LEN_MAX __DESC_JOB_IO_LEN(CAAM_PTR_SZ_MAX) +#define DESC_JOB_IO_LEN_MIN __DESC_JOB_IO_LEN(CAAM_PTR_SZ_MIN) #ifdef DEBUG #define PRINT_POS do { printk(KERN_DEBUG "%02d: %s\n", desc_len(desc),\ @@ -37,6 +42,7 @@ (LDOFF_ENABLE_AUTO_NFIFO << LDST_OFFSET_SHIFT)) extern bool caam_little_end; +extern size_t caam_ptr_sz; /* * HW fetches 4 S/G table entries at a time, irrespective of how many entries diff --git a/drivers/crypto/caam/error.c b/drivers/crypto/caam/error.c index 4f0d45865aa2..885cd364a01d 100644 --- a/drivers/crypto/caam/error.c +++ b/drivers/crypto/caam/error.c @@ -56,6 +56,9 @@ EXPORT_SYMBOL(caam_little_end); bool caam_imx; EXPORT_SYMBOL(caam_imx); +size_t caam_ptr_sz; +EXPORT_SYMBOL(caam_ptr_sz); + static const struct { u8 value; const char *error_text; From patchwork Wed Jul 3 08:13:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11029053 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E890D1398 for ; Wed, 3 Jul 2019 08:14:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC7BF28786 for ; Wed, 3 Jul 2019 08:14:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D042E2880A; Wed, 3 Jul 2019 08:14:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76D1328786 for ; Wed, 3 Jul 2019 08:14:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727134AbfGCIOq (ORCPT ); Wed, 3 Jul 2019 04:14:46 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:41141 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727387AbfGCION (ORCPT ); Wed, 3 Jul 2019 04:14:13 -0400 Received: by mail-pf1-f194.google.com with SMTP id m30so848522pff.8; Wed, 03 Jul 2019 01:14:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BNJCQUNcof8kUIy33ye35eh+3AWm1VC+G5oQzkM3XSE=; b=W1PlvIKgP130iBW/CWaGg2E4gyreddiydyWXoUFaUxVZda2Sa+Ywmjc4qtpjQfAFil w6TcV2W4rf12tLJf0F4jS4OWmfauCs0HyJ6aN0VOx+Spl11pm76ZVRC3Pw2HUnP5/zI2 ZrllQ63V+fmRd0NjBC7vrNbBVB4b11xbj6M8mwzupQWAItiRTTWEZzPfDO9WQI4ZAX7k aUwUZsZz/rjL1Hr94Myg9iQxF5L+NaTXfb7uI13uO9UxaOlP+8iBjZkKWZ0ozlEQ9AJX 3wpnJgzKhd8hAant7dFiJx2sK4NbzEyPBdR+qCJlLW24sh8yH8IMlGTrK8nf24o+ierA G8lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BNJCQUNcof8kUIy33ye35eh+3AWm1VC+G5oQzkM3XSE=; b=hyPkyCAN0ck3z2UDTE2D0O8nPLdIItYW0bn0NrePutPjWUlv3LKtVpEM58WRPA44OG G/lYitONHEas4SADDpVla4ABTlTCYnHZll47Jd2kyiulPQlixH5ZbdJmtL5MHwc0Fhyh DDbCQyXBwKRJb+du32RVbv17O0ipTRammuBn78QxXZNKFESlasAKJGyHVq+McWNFOx3p CHOzQ8PmxvdvIsgcxQGvcWdTIW7yjffiWduQeeV2kYPERa5MaqZCI0VLe+hAoY46SLvj haEZ7k3/ax/cB/ABzJG+5/csSc/rqsxB80HYaRfrt5BZd4mADBb6bciQacbdf2Cy7ana NjKA== X-Gm-Message-State: APjAAAV+ufrSpetaLQpp1j8qNPybqyvaV+LS4fZPSEv27DaY329Grmjf W9juA4UMVU9HJvmAKwZsPdMY/nuGFoU= X-Google-Smtp-Source: APXvYqzLhtW9WvGwVBrx3SpH3veFov4tarZ2p7IpD8tq3OaiQwQgT2pZm4IoMoiEEQ13tlrXBiTpAw== X-Received: by 2002:a63:a41:: with SMTP id z1mr35542460pgk.290.1562141652048; Wed, 03 Jul 2019 01:14:12 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id d2sm1445306pgo.0.2019.07.03.01.14.10 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 01:14:11 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , Chris Spencer , Cory Tusar , Chris Healy , Lucas Stach , =?utf-8?q?Horia_Geant=C4=83?= , Aymen Sghaier , Leonard Crestez , linux-kernel@vger.kernel.org Subject: [PATCH v4 11/16] crypto: caam - move cpu_to_caam_dma() selection to runtime Date: Wed, 3 Jul 2019 01:13:22 -0700 Message-Id: <20190703081327.17505-12-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190703081327.17505-1-andrew.smirnov@gmail.com> References: <20190703081327.17505-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of selecting the implementation of cpu_to_caam_dma()/caam_dma_to_cpu() at build time using the preprocessor, convert the code to do that at run-time using IS_ENABLED macro. This is needed to add support for i.MX8MQ. No functional change intended. Signed-off-by: Andrey Smirnov Cc: Chris Spencer Cc: Cory Tusar Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Aymen Sghaier Cc: Leonard Crestez Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/caam/regs.h | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/caam/regs.h b/drivers/crypto/caam/regs.h index fb494d14f262..511e28ba740a 100644 --- a/drivers/crypto/caam/regs.h +++ b/drivers/crypto/caam/regs.h @@ -188,13 +188,21 @@ static inline u64 caam_dma64_to_cpu(u64 value) return caam64_to_cpu(value); } -#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT -#define cpu_to_caam_dma(value) cpu_to_caam_dma64(value) -#define caam_dma_to_cpu(value) caam_dma64_to_cpu(value) -#else -#define cpu_to_caam_dma(value) cpu_to_caam32(value) -#define caam_dma_to_cpu(value) caam32_to_cpu(value) -#endif /* CONFIG_ARCH_DMA_ADDR_T_64BIT */ +static inline u64 cpu_to_caam_dma(u64 value) +{ + if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT)) + return cpu_to_caam_dma64(value); + else + return cpu_to_caam32(value); +} + +static inline u64 caam_dma_to_cpu(u64 value) +{ + if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT)) + return caam_dma64_to_cpu(value); + else + return caam32_to_cpu(value); +} /* * jr_outentry From patchwork Wed Jul 3 08:13:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11029051 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 59CC313A4 for ; Wed, 3 Jul 2019 08:14:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C3D728786 for ; Wed, 3 Jul 2019 08:14:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E4CB2880A; Wed, 3 Jul 2019 08:14:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB26F28786 for ; Wed, 3 Jul 2019 08:14:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727411AbfGCIOP (ORCPT ); Wed, 3 Jul 2019 04:14:15 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:33761 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727403AbfGCIOO (ORCPT ); Wed, 3 Jul 2019 04:14:14 -0400 Received: by mail-pf1-f193.google.com with SMTP id x15so870309pfq.0; Wed, 03 Jul 2019 01:14:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JsaGYh5oI2Sxay5T/tRKxxVHI+1jxM9KtqCiKY4aPvk=; b=L77cWPHJSvrVFB2KVrUvLZ9y/iL2adGSp9JfyqbEC1s2i2CAxLaG/FZeX9YFC5W+Yz 8nk6iRNqfD+hwA7hd4gr2ZY+BD/M5nUCvk3tiCLdl0KnFrMRaH5jlOG+x0bGsCgMde2R +A1Zoc0mRIp8DcAzzTD/HnY1S/FNolgFw5mcamdhioJnhnC3W6U0LG55ZeJ+9Wy3NDHe bgHu/8RQ/WtGITh66vy+yVvPA3kvD4nj/d6mtvUwppzy6ofjL5Q6chqi8Xy18Dem429J Dhhre45Jo2KdFqWgojiIOb6WvpqKGHFbzMtzkh4n35EH7IrQUQEd1wnbqZ2TFWADb55G YBog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JsaGYh5oI2Sxay5T/tRKxxVHI+1jxM9KtqCiKY4aPvk=; b=gVsnMAqmgeyrkl/7pxrQndUSbUlvYJjR3Rj3Ti1Sxq9EjRKcufVmzpZWXLMQrjjVSG rdeJZbDy+kkVM6ogWvWwULtFVlv9fXPWucoUDgZV4Bwx22VCr6Pwp1w0aDgRZoPp1s2Y npGncaDAfVPk6CW4H4L8bS1B4hq5cpPsC0aKeuzZXZHs/JL8OqR9EnxJ4t/fKrTy8bHR jeJ0wwkMFABk5+MCuMq7cEG23D/tXN8qHimdgivOsRlG8QOjAE/PqUBturiQ61SRHRiK kgZvS6pDXkhl15XMNO6rbODqaCVL3baG3VzFkUNaT9fxcEvFSzjmb+gWtlTwmGegt2is 9iiw== X-Gm-Message-State: APjAAAXeeqYaJ/zm12tCfKkIMLNmVCKcba81FRI8L+Maeey0qaa8R3Ow /LA24/1lFFaSBo/9hvZDgse1tisdczE= X-Google-Smtp-Source: APXvYqzTxcyuNBMV/+9ihTZG24HI2OA/zO6XuWoSz13tHX/TBVkjt6E9xuTbk6Nt3y4Ny+YtlDVwaw== X-Received: by 2002:a63:221f:: with SMTP id i31mr29807587pgi.251.1562141653187; Wed, 03 Jul 2019 01:14:13 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id d2sm1445306pgo.0.2019.07.03.01.14.12 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 01:14:12 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , Chris Spencer , Cory Tusar , Chris Healy , Lucas Stach , =?utf-8?q?Horia_Geant=C4=83?= , Aymen Sghaier , Leonard Crestez , linux-kernel@vger.kernel.org Subject: [PATCH v4 12/16] crypto: caam - drop explicit usage of struct jr_outentry Date: Wed, 3 Jul 2019 01:13:23 -0700 Message-Id: <20190703081327.17505-13-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190703081327.17505-1-andrew.smirnov@gmail.com> References: <20190703081327.17505-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Using struct jr_outentry to specify the layout of JobR output ring is not appropriate for all 64-bit SoC, since some of them, like i.MX8MQ, use 32-bit pointers there which doesn't match 64-bit dma_addr_t. Convert existing code to use explicit helper functions to access any of the JobR output ring elements, so that the support for i.MX8MQ can be added later. No functional change intended. Signed-off-by: Andrey Smirnov Cc: Chris Spencer Cc: Cory Tusar Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Aymen Sghaier Cc: Leonard Crestez Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/caam/intern.h | 2 +- drivers/crypto/caam/jr.c | 10 +++++---- drivers/crypto/caam/regs.h | 40 ++++++++++++++++++++++++++++++++---- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/drivers/crypto/caam/intern.h b/drivers/crypto/caam/intern.h index 1f01703f510a..081805c0f88b 100644 --- a/drivers/crypto/caam/intern.h +++ b/drivers/crypto/caam/intern.h @@ -58,7 +58,7 @@ struct caam_drv_private_jr { dma_addr_t *inpring; /* Base of input ring, alloc DMA-safe */ int out_ring_read_index; /* Output index "tail" */ int tail; /* entinfo (s/w ring) tail index */ - struct jr_outentry *outring; /* Base of output ring, DMA-safe */ + void *outring; /* Base of output ring, DMA-safe */ }; /* diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c index 813e9135babd..88777cc8adcd 100644 --- a/drivers/crypto/caam/jr.c +++ b/drivers/crypto/caam/jr.c @@ -214,7 +214,7 @@ static void caam_jr_dequeue(unsigned long devarg) for (i = 0; CIRC_CNT(head, tail + i, JOBR_DEPTH) >= 1; i++) { sw_idx = (tail + i) & (JOBR_DEPTH - 1); - if (jrp->outring[hw_idx].desc == + if (jr_outentry_desc(jrp->outring, hw_idx) == caam_dma_to_cpu(jrp->entinfo[sw_idx].desc_addr_dma)) break; /* found */ } @@ -223,7 +223,8 @@ static void caam_jr_dequeue(unsigned long devarg) /* Unmap just-run descriptor so we can post-process */ dma_unmap_single(dev, - caam_dma_to_cpu(jrp->outring[hw_idx].desc), + caam_dma_to_cpu(jr_outentry_desc(jrp->outring, + hw_idx)), jrp->entinfo[sw_idx].desc_size, DMA_TO_DEVICE); @@ -234,7 +235,8 @@ static void caam_jr_dequeue(unsigned long devarg) usercall = jrp->entinfo[sw_idx].callbk; userarg = jrp->entinfo[sw_idx].cbkarg; userdesc = jrp->entinfo[sw_idx].desc_addr_virt; - userstatus = caam32_to_cpu(jrp->outring[hw_idx].jrstatus); + userstatus = caam32_to_cpu(jr_outentry_jrstatus(jrp->outring, + hw_idx)); /* * Make sure all information from the job has been obtained @@ -451,7 +453,7 @@ static int caam_jr_init(struct device *dev) if (!jrp->inpring) goto out_free_irq; - jrp->outring = dmam_alloc_coherent(dev, sizeof(*jrp->outring) * + jrp->outring = dmam_alloc_coherent(dev, SIZEOF_JR_OUTENTRY * JOBR_DEPTH, &outbusaddr, GFP_KERNEL); if (!jrp->outring) diff --git a/drivers/crypto/caam/regs.h b/drivers/crypto/caam/regs.h index 511e28ba740a..0cc4a48dfc30 100644 --- a/drivers/crypto/caam/regs.h +++ b/drivers/crypto/caam/regs.h @@ -71,6 +71,7 @@ extern bool caam_little_end; extern bool caam_imx; +extern size_t caam_ptr_sz; #define caam_to_cpu(len) \ static inline u##len caam##len ## _to_cpu(u##len val) \ @@ -208,10 +209,41 @@ static inline u64 caam_dma_to_cpu(u64 value) * jr_outentry * Represents each entry in a JobR output ring */ -struct jr_outentry { - dma_addr_t desc;/* Pointer to completed descriptor */ - u32 jrstatus; /* Status for completed descriptor */ -} __packed; + +static inline void jr_outentry_get(void *outring, int hw_idx, dma_addr_t *desc, + u32 *jrstatus) +{ + struct { + dma_addr_t desc;/* Pointer to completed descriptor */ + u32 jrstatus; /* Status for completed descriptor */ + } __packed *outentry = outring; + + *desc = outentry[hw_idx].desc; + *jrstatus = outentry[hw_idx].jrstatus; +} + +#define SIZEOF_JR_OUTENTRY (caam_ptr_sz + sizeof(u32)) + +static inline dma_addr_t jr_outentry_desc(void *outring, int hw_idx) +{ + dma_addr_t desc; + u32 unused; + + jr_outentry_get(outring, hw_idx, &desc, &unused); + + return desc; +} + +static inline u32 jr_outentry_jrstatus(void *outring, int hw_idx) +{ + dma_addr_t unused; + u32 jrstatus; + + jr_outentry_get(outring, hw_idx, &unused, &jrstatus); + + return jrstatus; +} + /* Version registers (Era 10+) e80-eff */ struct version_regs { From patchwork Wed Jul 3 08:13:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11029047 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ABCC11398 for ; Wed, 3 Jul 2019 08:14:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A02EE28807 for ; Wed, 3 Jul 2019 08:14:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9470B28833; Wed, 3 Jul 2019 08:14:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 151A128807 for ; Wed, 3 Jul 2019 08:14:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727417AbfGCIOQ (ORCPT ); Wed, 3 Jul 2019 04:14:16 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:35504 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727414AbfGCIOQ (ORCPT ); Wed, 3 Jul 2019 04:14:16 -0400 Received: by mail-pf1-f196.google.com with SMTP id d126so865787pfd.2; Wed, 03 Jul 2019 01:14:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=acSQGaqvkGp3mvounPRRghTuQfM60axtHBshvdJN2QY=; b=Gf+EoZd8jc+dZE7zFplsrWncC2B1ZpgPjad2XR5GG4L6GVTPyXVq5nCdQSNkbBydcy GIntxPFevORF2eYUEZ4fgGs20cVk1TEJSFRnoRJNWIfCVqxOZgZmsVxxNHe08T6AdiDg 85nfeaYfeZqxbYfJibi+oAwYKDj21UO5hB72jSuSbvhNzZrhgTn+j8uvAMFA/u2fZu3k N8onOpoUSfUxCF7iwjTUgVTFW/H1AItQzDUpQhVF05P2MtlxsyCyuyu/Z6lEJugX8iZw gAAbHQzP3YRLtmm4SUbtJxztyPWmUg1REQRvqMiULzu8ZVp3UeSTDFNqNfvtUjqMlTni VHkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=acSQGaqvkGp3mvounPRRghTuQfM60axtHBshvdJN2QY=; b=OIecWYKTuO3LcfhUR53wU1C3hhq55VrlUJc5L4yV9MgBcPfM63STNFyHpPAiOOW5Ya jIaOjV1Jaw6MmScPCmFl1QcL+DXAOZPI66178R3erYru98VP/p1CdVQ11Y05AaovZN2l vW3CrbuXhmthQ4hSG3yHKqg0YfhkM4s6V4/95zWX+iwk7l4imljuzMohGKml8mILbah/ IMAZFbeF6gtJLTY6oTNPVCnd8fY7lzyo6Npcf6ZN6hoCRtJPUy/Fc8jgCb1DPIYRtE1f v1woibepdB8Fl0N4IByg5DvIYgSh/zY7DrqlkP5XPOqnf1uxVsSe3igimlXrDZzSsxDs pP0A== X-Gm-Message-State: APjAAAXEmOD/yAAeyosc13Yx4sF0ntbuEjx4oJi03nGONcMAVi+qXLLL SW7oa/CtFHMdcYUUWCjvRzokR5Rv4mM= X-Google-Smtp-Source: APXvYqw87H6zgg3sY9Oe8VuORrp7I9q422aqHXW/hcABMaqFiJ+EAzq1Pl5WOY4mXUql1/46mZBPjw== X-Received: by 2002:a63:6986:: with SMTP id e128mr37215243pgc.220.1562141654777; Wed, 03 Jul 2019 01:14:14 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id d2sm1445306pgo.0.2019.07.03.01.14.13 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 01:14:13 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , Chris Spencer , Cory Tusar , Chris Healy , Lucas Stach , =?utf-8?q?Horia_Geant=C4=83?= , Aymen Sghaier , Leonard Crestez , linux-kernel@vger.kernel.org Subject: [PATCH v4 13/16] crypto: caam - don't hardcode inpentry size Date: Wed, 3 Jul 2019 01:13:24 -0700 Message-Id: <20190703081327.17505-14-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190703081327.17505-1-andrew.smirnov@gmail.com> References: <20190703081327.17505-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Using dma_addr_t for elements of JobR input ring is not appropriate on all 64-bit SoCs, some of which, like i.MX8MQ, use only 32-bit wide pointers there. Convert all of the code to use explicit helper function that can be later extended to support i.MX8MQ. No functional change intended. Signed-off-by: Andrey Smirnov Cc: Chris Spencer Cc: Cory Tusar Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Aymen Sghaier Cc: Leonard Crestez Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/caam/intern.h | 3 ++- drivers/crypto/caam/jr.c | 4 ++-- drivers/crypto/caam/regs.h | 9 +++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/caam/intern.h b/drivers/crypto/caam/intern.h index 081805c0f88b..c00c7c84ec84 100644 --- a/drivers/crypto/caam/intern.h +++ b/drivers/crypto/caam/intern.h @@ -55,7 +55,8 @@ struct caam_drv_private_jr { spinlock_t inplock ____cacheline_aligned; /* Input ring index lock */ u32 inpring_avail; /* Number of free entries in input ring */ int head; /* entinfo (s/w ring) head index */ - dma_addr_t *inpring; /* Base of input ring, alloc DMA-safe */ + void *inpring; /* Base of input ring, alloc + * DMA-safe */ int out_ring_read_index; /* Output index "tail" */ int tail; /* entinfo (s/w ring) tail index */ void *outring; /* Base of output ring, DMA-safe */ diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c index 88777cc8adcd..fd20eee8169a 100644 --- a/drivers/crypto/caam/jr.c +++ b/drivers/crypto/caam/jr.c @@ -391,7 +391,7 @@ int caam_jr_enqueue(struct device *dev, u32 *desc, head_entry->cbkarg = areq; head_entry->desc_addr_dma = desc_dma; - jrp->inpring[head] = cpu_to_caam_dma(desc_dma); + jr_inpentry_set(jrp->inpring, head, cpu_to_caam_dma(desc_dma)); /* * Guarantee that the descriptor's DMA address has been written to @@ -447,7 +447,7 @@ static int caam_jr_init(struct device *dev) goto out_free_irq; error = -ENOMEM; - jrp->inpring = dmam_alloc_coherent(dev, sizeof(*jrp->inpring) * + jrp->inpring = dmam_alloc_coherent(dev, SIZEOF_JR_INPENTRY * JOBR_DEPTH, &inpbusaddr, GFP_KERNEL); if (!jrp->inpring) diff --git a/drivers/crypto/caam/regs.h b/drivers/crypto/caam/regs.h index 0cc4a48dfc30..ec49f5ba9689 100644 --- a/drivers/crypto/caam/regs.h +++ b/drivers/crypto/caam/regs.h @@ -244,6 +244,15 @@ static inline u32 jr_outentry_jrstatus(void *outring, int hw_idx) return jrstatus; } +static inline void jr_inpentry_set(void *inpring, int hw_idx, dma_addr_t val) +{ + dma_addr_t *inpentry = inpring; + + inpentry[hw_idx] = val; +} + +#define SIZEOF_JR_INPENTRY caam_ptr_sz + /* Version registers (Era 10+) e80-eff */ struct version_regs { From patchwork Wed Jul 3 08:13:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11029049 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 900C613A4 for ; Wed, 3 Jul 2019 08:14:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8420028786 for ; Wed, 3 Jul 2019 08:14:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75CC128807; Wed, 3 Jul 2019 08:14:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF1B92893D for ; Wed, 3 Jul 2019 08:14:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727108AbfGCIOf (ORCPT ); Wed, 3 Jul 2019 04:14:35 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:34938 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727421AbfGCIOR (ORCPT ); Wed, 3 Jul 2019 04:14:17 -0400 Received: by mail-pg1-f196.google.com with SMTP id s27so823053pgl.2; Wed, 03 Jul 2019 01:14:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sfNx/lihxTLsSQ25blP2NoJmyaaiNQYSBnuHzQR5/Go=; b=YsUuSMa9xaALaOZ+KqKGRzlJCE/jtFWGyRySjbdM9kI0593WgMdfAVOQpHg+x3Gd6Y vDG0TIb1foiBRPBspGzQXJpOPZB5YXoPO0+jMZuizmGqUKKvBNGGD4K7S/wUAGQCdefB kpdhbpuiDhG6FJeEphxPs+bqUm1zKP/8mRcHX5qGS+iw5UCfJgP7JUdlfUVIcJPdRpw7 +WtMp/oZx2GCzrOqDEOwVox/wXWUQEMSKaRSW64lmP0U3ISryh2KkkyK7W8ROWiBPZVC 0qKxHpvhL52W2OY0+s2CIFfC5RvG4MN/t3VuiZoiDmbtM8Hw/J/GPnwL3H9axaFePaAO Y9AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sfNx/lihxTLsSQ25blP2NoJmyaaiNQYSBnuHzQR5/Go=; b=bck/K24++wDddbOc53T+Qv5Lce4U+4cUdZG8qpm6N7i7/iAfKri8vF/RiTmQuqA8bJ H/3EvRjAOylKnoPg6Bm7VQp6KgMCkE9wtwe7Ojcj0qPivtMe85WQXkmidogpkvQzXBS3 fLASvxCTKs9JYRCgTGLtcdtsKdrijvHmquj3leXEELsI5px7x2inq01u9dZMBDSwycal 36Pb3f9guNVY0jKlqMe6/BmbxUpUj1Bzu+mrUKx0rTf4xV9s9avZoq6eAlLVsJ7oPD4e zyWl80WbZBTHDCC5bi8/Jc8VLfLdIA/xdoliDJ0WkbPqZyt4pY8UAMWR8n8L0hT1c7m9 TncA== X-Gm-Message-State: APjAAAWN/JFpcP5wfkKABDwtsppS4GxHP0TNjwxzIux5efLaXyQS/ANF a78f0ynHrU7d2dLtThE7QsvRwnmXnds= X-Google-Smtp-Source: APXvYqz/JVeXxMMdTWPp69kUJcYY/Om72HUI6DT/W2d3/M40sFB+fyjOZQ/4QIfh4wzlgBtYk3zMuA== X-Received: by 2002:a63:d002:: with SMTP id z2mr2278758pgf.364.1562141656252; Wed, 03 Jul 2019 01:14:16 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id d2sm1445306pgo.0.2019.07.03.01.14.14 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 01:14:15 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , Chris Spencer , Cory Tusar , Chris Healy , Lucas Stach , =?utf-8?q?Horia_Geant=C4=83?= , Aymen Sghaier , Leonard Crestez , linux-kernel@vger.kernel.org Subject: [PATCH v4 14/16] crypto: caam - force DMA address to 32-bit on 64-bit i.MX SoCs Date: Wed, 3 Jul 2019 01:13:25 -0700 Message-Id: <20190703081327.17505-15-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190703081327.17505-1-andrew.smirnov@gmail.com> References: <20190703081327.17505-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP i.MX8 SoC still use 32-bit addresses in its CAAM implmentation, so change all of the code to be able to handle that. Signed-off-by: Andrey Smirnov Cc: Chris Spencer Cc: Cory Tusar Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Aymen Sghaier Cc: Leonard Crestez Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/caam/caampkc.c | 8 +++---- drivers/crypto/caam/ctrl.c | 6 +++-- drivers/crypto/caam/desc_constr.h | 10 ++++++-- drivers/crypto/caam/intern.h | 2 +- drivers/crypto/caam/pdb.h | 16 +++++++++---- drivers/crypto/caam/pkc_desc.c | 8 +++---- drivers/crypto/caam/regs.h | 39 +++++++++++++++++++++++-------- 7 files changed, 62 insertions(+), 27 deletions(-) diff --git a/drivers/crypto/caam/caampkc.c b/drivers/crypto/caam/caampkc.c index 19b02c1973fc..8badf783791c 100644 --- a/drivers/crypto/caam/caampkc.c +++ b/drivers/crypto/caam/caampkc.c @@ -17,13 +17,13 @@ #include "sg_sw_sec4.h" #include "caampkc.h" -#define DESC_RSA_PUB_LEN (2 * CAAM_CMD_SZ + sizeof(struct rsa_pub_pdb)) +#define DESC_RSA_PUB_LEN (2 * CAAM_CMD_SZ + SIZEOF_RSA_PUB_PDB) #define DESC_RSA_PRIV_F1_LEN (2 * CAAM_CMD_SZ + \ - sizeof(struct rsa_priv_f1_pdb)) + SIZEOF_RSA_PRIV_F1_PDB) #define DESC_RSA_PRIV_F2_LEN (2 * CAAM_CMD_SZ + \ - sizeof(struct rsa_priv_f2_pdb)) + SIZEOF_RSA_PRIV_F2_PDB) #define DESC_RSA_PRIV_F3_LEN (2 * CAAM_CMD_SZ + \ - sizeof(struct rsa_priv_f3_pdb)) + SIZEOF_RSA_PRIV_F3_PDB) #define CAAM_RSA_MAX_INPUT_SIZE 512 /* for a 4096-bit modulus */ /* buffer filled with zeros, used for padding */ diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index 42692a2bc2f3..adb560950e59 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -602,11 +602,13 @@ static int caam_probe(struct platform_device *pdev) ret = init_clocks(dev, ctrlpriv, imx_soc_match->data); if (ret) return ret; + + caam_ptr_sz = sizeof(u32); + } else { + caam_ptr_sz = sizeof(dma_addr_t); } caam_imx = (bool)imx_soc_match; - caam_ptr_sz = sizeof(dma_addr_t); - /* Get configuration properties from device tree */ /* First, get register page */ ctrl = of_iomap(nprop, 0); diff --git a/drivers/crypto/caam/desc_constr.h b/drivers/crypto/caam/desc_constr.h index 3a83a3332ba9..5602b8f192de 100644 --- a/drivers/crypto/caam/desc_constr.h +++ b/drivers/crypto/caam/desc_constr.h @@ -109,9 +109,15 @@ static inline void init_job_desc_pdb(u32 * const desc, u32 options, static inline void append_ptr(u32 * const desc, dma_addr_t ptr) { - dma_addr_t *offset = (dma_addr_t *)desc_end(desc); + if (caam_ptr_sz == sizeof(dma_addr_t)) { + dma_addr_t *offset = (dma_addr_t *)desc_end(desc); - *offset = cpu_to_caam_dma(ptr); + *offset = cpu_to_caam_dma(ptr); + } else { + u32 *offset = (u32 *)desc_end(desc); + + *offset = cpu_to_caam_dma(ptr); + } (*desc) = cpu_to_caam32(caam32_to_cpu(*desc) + CAAM_PTR_SZ / CAAM_CMD_SZ); diff --git a/drivers/crypto/caam/intern.h b/drivers/crypto/caam/intern.h index c00c7c84ec84..731b06becd9c 100644 --- a/drivers/crypto/caam/intern.h +++ b/drivers/crypto/caam/intern.h @@ -219,7 +219,7 @@ static inline u64 caam_get_dma_mask(struct device *dev) { struct device_node *nprop = dev->of_node; - if (sizeof(dma_addr_t) != sizeof(u64)) + if (caam_ptr_sz != sizeof(u64)) return DMA_BIT_MASK(32); if (caam_dpaa2) diff --git a/drivers/crypto/caam/pdb.h b/drivers/crypto/caam/pdb.h index 810f0bef0652..68c1fd5dee5d 100644 --- a/drivers/crypto/caam/pdb.h +++ b/drivers/crypto/caam/pdb.h @@ -512,7 +512,9 @@ struct rsa_pub_pdb { dma_addr_t n_dma; dma_addr_t e_dma; u32 f_len; -} __packed; +}; + +#define SIZEOF_RSA_PUB_PDB (2 * sizeof(u32) + 4 * caam_ptr_sz) /** * RSA Decrypt PDB - Private Key Form #1 @@ -528,7 +530,9 @@ struct rsa_priv_f1_pdb { dma_addr_t f_dma; dma_addr_t n_dma; dma_addr_t d_dma; -} __packed; +}; + +#define SIZEOF_RSA_PRIV_F1_PDB (sizeof(u32) + 4 * caam_ptr_sz) /** * RSA Decrypt PDB - Private Key Form #2 @@ -554,7 +558,9 @@ struct rsa_priv_f2_pdb { dma_addr_t tmp1_dma; dma_addr_t tmp2_dma; u32 p_q_len; -} __packed; +}; + +#define SIZEOF_RSA_PRIV_F2_PDB (2 * sizeof(u32) + 7 * caam_ptr_sz) /** * RSA Decrypt PDB - Private Key Form #3 @@ -586,6 +592,8 @@ struct rsa_priv_f3_pdb { dma_addr_t tmp1_dma; dma_addr_t tmp2_dma; u32 p_q_len; -} __packed; +}; + +#define SIZEOF_RSA_PRIV_F3_PDB (2 * sizeof(u32) + 9 * caam_ptr_sz) #endif diff --git a/drivers/crypto/caam/pkc_desc.c b/drivers/crypto/caam/pkc_desc.c index 2a8d87ea94bf..0d5ee762e036 100644 --- a/drivers/crypto/caam/pkc_desc.c +++ b/drivers/crypto/caam/pkc_desc.c @@ -13,7 +13,7 @@ /* Descriptor for RSA Public operation */ void init_rsa_pub_desc(u32 *desc, struct rsa_pub_pdb *pdb) { - init_job_desc_pdb(desc, 0, sizeof(*pdb)); + init_job_desc_pdb(desc, 0, SIZEOF_RSA_PUB_PDB); append_cmd(desc, pdb->sgf); append_ptr(desc, pdb->f_dma); append_ptr(desc, pdb->g_dma); @@ -26,7 +26,7 @@ void init_rsa_pub_desc(u32 *desc, struct rsa_pub_pdb *pdb) /* Descriptor for RSA Private operation - Private Key Form #1 */ void init_rsa_priv_f1_desc(u32 *desc, struct rsa_priv_f1_pdb *pdb) { - init_job_desc_pdb(desc, 0, sizeof(*pdb)); + init_job_desc_pdb(desc, 0, SIZEOF_RSA_PRIV_F1_PDB); append_cmd(desc, pdb->sgf); append_ptr(desc, pdb->g_dma); append_ptr(desc, pdb->f_dma); @@ -39,7 +39,7 @@ void init_rsa_priv_f1_desc(u32 *desc, struct rsa_priv_f1_pdb *pdb) /* Descriptor for RSA Private operation - Private Key Form #2 */ void init_rsa_priv_f2_desc(u32 *desc, struct rsa_priv_f2_pdb *pdb) { - init_job_desc_pdb(desc, 0, sizeof(*pdb)); + init_job_desc_pdb(desc, 0, SIZEOF_RSA_PRIV_F2_PDB); append_cmd(desc, pdb->sgf); append_ptr(desc, pdb->g_dma); append_ptr(desc, pdb->f_dma); @@ -56,7 +56,7 @@ void init_rsa_priv_f2_desc(u32 *desc, struct rsa_priv_f2_pdb *pdb) /* Descriptor for RSA Private operation - Private Key Form #3 */ void init_rsa_priv_f3_desc(u32 *desc, struct rsa_priv_f3_pdb *pdb) { - init_job_desc_pdb(desc, 0, sizeof(*pdb)); + init_job_desc_pdb(desc, 0, SIZEOF_RSA_PRIV_F3_PDB); append_cmd(desc, pdb->sgf); append_ptr(desc, pdb->g_dma); append_ptr(desc, pdb->f_dma); diff --git a/drivers/crypto/caam/regs.h b/drivers/crypto/caam/regs.h index ec49f5ba9689..3c3ad474d08f 100644 --- a/drivers/crypto/caam/regs.h +++ b/drivers/crypto/caam/regs.h @@ -191,7 +191,8 @@ static inline u64 caam_dma64_to_cpu(u64 value) static inline u64 cpu_to_caam_dma(u64 value) { - if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT)) + if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) && + !caam_imx) return cpu_to_caam_dma64(value); else return cpu_to_caam32(value); @@ -199,7 +200,8 @@ static inline u64 cpu_to_caam_dma(u64 value) static inline u64 caam_dma_to_cpu(u64 value) { - if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT)) + if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) && + !caam_imx) return caam_dma64_to_cpu(value); else return caam32_to_cpu(value); @@ -213,13 +215,24 @@ static inline u64 caam_dma_to_cpu(u64 value) static inline void jr_outentry_get(void *outring, int hw_idx, dma_addr_t *desc, u32 *jrstatus) { - struct { - dma_addr_t desc;/* Pointer to completed descriptor */ - u32 jrstatus; /* Status for completed descriptor */ - } __packed *outentry = outring; - *desc = outentry[hw_idx].desc; - *jrstatus = outentry[hw_idx].jrstatus; + if (caam_imx) { + struct { + u32 desc; + u32 jrstatus; + } __packed *outentry = outring; + + *desc = outentry[hw_idx].desc; + *jrstatus = outentry[hw_idx].jrstatus; + } else { + struct { + dma_addr_t desc;/* Pointer to completed descriptor */ + u32 jrstatus; /* Status for completed descriptor */ + } __packed *outentry = outring; + + *desc = outentry[hw_idx].desc; + *jrstatus = outentry[hw_idx].jrstatus; + } } #define SIZEOF_JR_OUTENTRY (caam_ptr_sz + sizeof(u32)) @@ -246,9 +259,15 @@ static inline u32 jr_outentry_jrstatus(void *outring, int hw_idx) static inline void jr_inpentry_set(void *inpring, int hw_idx, dma_addr_t val) { - dma_addr_t *inpentry = inpring; + if (caam_imx) { + u32 *inpentry = inpring; - inpentry[hw_idx] = val; + inpentry[hw_idx] = val; + } else { + dma_addr_t *inpentry = inpring; + + inpentry[hw_idx] = val; + } } #define SIZEOF_JR_INPENTRY caam_ptr_sz From patchwork Wed Jul 3 08:13:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11029045 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CAB6313A4 for ; Wed, 3 Jul 2019 08:14:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF66428786 for ; Wed, 3 Jul 2019 08:14:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3B7A2880A; Wed, 3 Jul 2019 08:14:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A38E28786 for ; Wed, 3 Jul 2019 08:14:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727442AbfGCIOa (ORCPT ); Wed, 3 Jul 2019 04:14:30 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:47075 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727432AbfGCIOT (ORCPT ); Wed, 3 Jul 2019 04:14:19 -0400 Received: by mail-pg1-f196.google.com with SMTP id i8so796299pgm.13; Wed, 03 Jul 2019 01:14:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iFdFgnbGfYNFGWijUj/XlW0cCu4McvzsQkcXKLZ/y8I=; b=AczUvvKP6F/HCai5Oa1GCtVY1AilofYFPC69OkqStFoCsrPmasZt2WLIFsv7rylS5V Pg+3Gh75cv6pqIcHduFuRyI7fj+lu0NKIckkEHHYmr4WNIPKacHqpRsBL7zLmiCCHY0r hbmkzC5Oa6ig9++PaYvyes6gLisM9baNhpFYMlhn+9F3HJwXnwBpTMbx4zKxdWGgSFWt 93mPMbBRmJ3CDcgomnZsIvG42w7DiJZ+YBrqwcdgBX2R65owBrdNEutdzZcZM3CwHUFX FcZKtNsaXe+KRP6UHTx2l5KgoT+pzB1OYAZQUNnDGkQ+WrV7eDTNEA5Kgy3nlVwuxEP7 n2FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iFdFgnbGfYNFGWijUj/XlW0cCu4McvzsQkcXKLZ/y8I=; b=PkIqzYUYjZX6MdrNHcHmu3N7cB9+hsVMptlVrE62JlwZTFgvZE+/g+cYYzM0XFVz0i XHKQhUbS/YRmZVqoGa0V6Nz8iNSUZfIK6adYi2t/q15mL7XLOuDmTZbZEWOKgIQzYFYo IiroWVQHANI2Fn5i8lrRSoI0ziU2uinRcawV80XzNgDeCp4pUPJRbAZqqgowY/RovWnP u5svLL5nXkznSzgIJmlqivfvL3rEeua5LPZSaIJi8HceizCWRQVy15VL71eCv9FZX6TW 0f9X8hvyLcgqRfaAFy3cE6Ky2twZG/W4KaT2dACETUR2faiBEbN/a2k6cP7VUaOK46EQ vAlA== X-Gm-Message-State: APjAAAU/DuzWfQx0qmcJz7nOzEsUFndmthUAUVwnfQSDT+pq15I1dz5W TeGkReEdTScMqlXJB/o5YYeWc2wtgkY= X-Google-Smtp-Source: APXvYqwzaR4dkXTDNAVT6FQnOKxqCmAVx0fDduq+qzwa+fkB6r+tP4P4cjVwaIoF9IYm6+Gm/iDqpg== X-Received: by 2002:a65:4cc4:: with SMTP id n4mr36959361pgt.307.1562141657808; Wed, 03 Jul 2019 01:14:17 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id d2sm1445306pgo.0.2019.07.03.01.14.16 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 01:14:17 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , Chris Spencer , Cory Tusar , Chris Healy , Lucas Stach , =?utf-8?q?Horia_Geant=C4=83?= , Aymen Sghaier , Leonard Crestez , linux-kernel@vger.kernel.org Subject: [PATCH v4 15/16] crypto: caam - always select job ring via RSR on i.MX8MQ Date: Wed, 3 Jul 2019 01:13:26 -0700 Message-Id: <20190703081327.17505-16-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190703081327.17505-1-andrew.smirnov@gmail.com> References: <20190703081327.17505-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Per feedback from NXP tech support the way to use register based service interface on i.MX8MQ is to follow the same set of steps outlined for the case when virtualization is enabled, regardless if it is. Current version of SRM for i.MX8MQ speaks of DECO DID_MS and DECO DID_LS registers, but apparently those are not implemented, so the case when SCFGR[VIRT_EN]=0 should be handles the same as the case when SCFGR[VIRT_EN]=1 Signed-off-by: Andrey Smirnov Cc: Chris Spencer Cc: Cory Tusar Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Aymen Sghaier Cc: Leonard Crestez Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/caam/ctrl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index adb560950e59..a354c64ca39d 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -97,7 +97,12 @@ static inline int run_descriptor_deco0(struct device *ctrldev, u32 *desc, int i; - if (ctrlpriv->virt_en == 1) { + if (ctrlpriv->virt_en == 1 || + /* + * Apparently on i.MX8MQ it doesn't matter if virt_en == 1 + * and the following steps should be performed regardless + */ + of_machine_is_compatible("fsl,imx8mq")) { clrsetbits_32(&ctrl->deco_rsr, 0, DECORSR_JR0); while (!(rd_reg32(&ctrl->deco_rsr) & DECORSR_VALID) && From patchwork Wed Jul 3 08:13:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11029043 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA83813A4 for ; Wed, 3 Jul 2019 08:14:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FA8128786 for ; Wed, 3 Jul 2019 08:14:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93D782880A; Wed, 3 Jul 2019 08:14:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3674928786 for ; Wed, 3 Jul 2019 08:14:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727454AbfGCIOU (ORCPT ); Wed, 3 Jul 2019 04:14:20 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:34620 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727442AbfGCIOU (ORCPT ); Wed, 3 Jul 2019 04:14:20 -0400 Received: by mail-pg1-f195.google.com with SMTP id p10so825100pgn.1; Wed, 03 Jul 2019 01:14:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=p3NE6eF8wtZSbcEMraRfzpbuJsj8vIEFXgZ9uVdKcjs=; b=MjGvB2vdicUC+rpaKAkXobo4d4VHJRRoHXJfCbyAa/hzEWdvz8mdYPZiIwCB46+imG DDNtYWfLtizE6NhwQmkrSzcMBVXU4z3kRgDuOgPYJ48fVdoo+5smd8lySjs4Rwo+qWf+ 27L0n6Br7f3GCdtpc1BQTIB0OSQ1odY/rxsJxJSqFkpG3v/RPqn/LrYulYJvC5hA08Y5 syancLCDgupxxzz8dlWLIa37qsiuP/0IRh0B1hGGFAnNzt9XGd3JWARku2O0V8VF7PQ5 UA4UOCjeclOtCo3XgjuxtatOiJL/NWkqmvGTjMDhbFtXMexUNMOqgMioriSqoD0Q6Pqa JaEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p3NE6eF8wtZSbcEMraRfzpbuJsj8vIEFXgZ9uVdKcjs=; b=Li/KLlhSy2QYL6rkOncx2AM2x4wOr8pRw1pr5rBmosjCIIf59Vx6wt4jqm7RKm6QFb iUHsYiLsOd61JHbrVqtzE74iOUfBVzlPdosR9G5UXOjPgADm4hNrTNZ3yAGd+PYk2/6n NFrG67mCW9PPja/05hajf4CRAq33W3z4kpzO15KrRUhvR2qZV11A/x+O0h9n9zCVZNeP fiJxX/qDzbPOKMIovkj0tpWNA4ngs/6MgR6PjICwY8hXOczxadfgE+gmkVSnwQm8PvDF r6HbZ4xoHEYU/TlQ/wsQ2VJ9+I4QqHaZIw5ucESvxg7YDy6eXuXK7Iu0fduRyXknXzyt GPtg== X-Gm-Message-State: APjAAAUtSl3w9PDRSlIpkDKCN9jhLKC1wUgb9YaSn+vMa75sdmyXmyQ5 sItP429o61afEN+2fYboVxdi9FFucFM= X-Google-Smtp-Source: APXvYqxD0vSuPSwOFaa0ONFk6vM54vgp5nr7d54JfN1Tutz7WSjZUlZ3J8J0UV1Jul9hXde0zjsmFQ== X-Received: by 2002:a63:545c:: with SMTP id e28mr36881906pgm.374.1562141659184; Wed, 03 Jul 2019 01:14:19 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id d2sm1445306pgo.0.2019.07.03.01.14.18 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 01:14:18 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , Chris Spencer , Cory Tusar , Chris Healy , Lucas Stach , =?utf-8?q?Horia_Geant=C4=83?= , Aymen Sghaier , Leonard Crestez , linux-kernel@vger.kernel.org Subject: [PATCH v4 16/16] crypto: caam - add clock entry for i.MX8MQ Date: Wed, 3 Jul 2019 01:13:27 -0700 Message-Id: <20190703081327.17505-17-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190703081327.17505-1-andrew.smirnov@gmail.com> References: <20190703081327.17505-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add clock entry needed to support i.MX8MQ. Signed-off-by: Andrey Smirnov Cc: Chris Spencer Cc: Cory Tusar Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Aymen Sghaier Cc: Leonard Crestez Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/caam/ctrl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index a354c64ca39d..916b63f4f93b 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -527,6 +527,7 @@ static const struct soc_device_attribute caam_imx_soc_table[] = { { .soc_id = "i.MX6UL", .data = &caam_imx6ul_data }, { .soc_id = "i.MX6*", .data = &caam_imx6_data }, { .soc_id = "i.MX7*", .data = &caam_imx7_data }, + { .soc_id = "i.MX8MQ", .data = &caam_imx7_data }, { .family = "Freescale i.MX" }, };