Message ID | 20230313135646.2077707-1-jiajie.ho@starfivetech.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1227198wrd; Mon, 13 Mar 2023 07:45:21 -0700 (PDT) X-Google-Smtp-Source: AK7set9b0ddd6pFAAmHZQAW5DbLyJJqwM8FdnW7o2brJaY0vcfHCkcOPymJWwbOfyC+FL7JvIs1S X-Received: by 2002:a17:90a:316:b0:236:6a28:f784 with SMTP id 22-20020a17090a031600b002366a28f784mr34874279pje.3.1678718720972; Mon, 13 Mar 2023 07:45:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678718720; cv=none; d=google.com; s=arc-20160816; b=Wvu59bXF6FxL4+0utdaD1TcC6Kj3z69f4vgNckTmOrW+/kdaWmhZ7A238Yl/NBn79A rWJgez73TURX6hEvNOZNVk1Ycxe3MxeU6wCLTzhfAj7bog0IahzRz7u0fntmkNA3wsXN f/atyqAfpVPI4aiIeWKdHktvAJGJzQrVyzT+Psgmd2GxOIH1cYqu9eFCBBnuqGXkHiAS lugjVk0K/oJKYpv8i8tA33SICiObgNtUBAZh6YtEcCAzLSS0B/Fzp/K/ABKV5aVQKQza PO72sj6YzI1sRaEIJRO0xcpp66grZfF5iVrIffH+XbhyHhcVsS1jbX1G6DfbK2Om+MAR EQfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Tf46gGrZo/pWMUJmx30ViZFFHrkRBV04P5WUIOAKpG8=; b=SmvOGByrXkpjMea2LDMF3K+7qbhXRQTUwMwYhcxPBxBh2nNOHyLCkhq77iGiRNQxFb 7Y4k47180KzzduUus+zoVezkMR4ncfKvPfhEV3NnXpPADza/49/ojo3Nv+lGRWeVvo5O PYYpjOLcdFYFy7PaIRjzY7gp0FSUrvilYgINMMqyZVESRQ1Bpwhr6r8ebQ/sMErgD3GW 4JJKyzeC6mY7xsTkk7TaKTEO5SUyaqpPwmwOQq3NDdxtWz3zW+fiv9iLOMis4NUA2G1i kPDa9NT5zWGmqluonGG2U5J0LdTB6ED9B0FECB4JJUTtK8hcnD0mZ6Fl84i8tP5VRTSq mekA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b15-20020a17090ae38f00b00233cf305f6bsi6685738pjz.111.2023.03.13.07.45.05; Mon, 13 Mar 2023 07:45:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230118AbjCMN5q convert rfc822-to-8bit (ORCPT <rfc822;realc9580@gmail.com> + 99 others); Mon, 13 Mar 2023 09:57:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbjCMN5n (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 13 Mar 2023 09:57:43 -0400 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F7B4222ED; Mon, 13 Mar 2023 06:57:36 -0700 (PDT) Received: from EXMBX165.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX165", Issuer "EXMBX165" (not verified)) by ex01.ufhost.com (Postfix) with ESMTP id DDF9A24DBCE; Mon, 13 Mar 2023 21:57:32 +0800 (CST) Received: from EXMBX068.cuchost.com (172.16.6.68) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 13 Mar 2023 21:57:32 +0800 Received: from ubuntu.localdomain (202.190.105.77) by EXMBX068.cuchost.com (172.16.6.68) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 13 Mar 2023 21:57:12 +0800 From: Jia Jie Ho <jiajie.ho@starfivetech.com> To: Herbert Xu <herbert@gondor.apana.org.au>, "David S . Miller" <davem@davemloft.net>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Emil Renner Berthing <kernel@esmil.dk>, Conor Dooley <conor.dooley@microchip.com> CC: <linux-crypto@vger.kernel.org>, <devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-riscv@lists.infradead.org> Subject: [PATCH v3 0/4] crypto: starfive - Add drivers for crypto engine Date: Mon, 13 Mar 2023 21:56:42 +0800 Message-ID: <20230313135646.2077707-1-jiajie.ho@starfivetech.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [202.190.105.77] X-ClientProxiedBy: EXCAS064.cuchost.com (172.16.6.24) To EXMBX068.cuchost.com (172.16.6.68) X-YovoleRuleAgent: yovoleflag Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760264161218764249?= X-GMAIL-MSGID: =?utf-8?q?1760264161218764249?= |
Series |
crypto: starfive - Add drivers for crypto engine
|
|
Message
JiaJie Ho
March 13, 2023, 1:56 p.m. UTC
This patch series adds kernel driver support for StarFive JH7110 crypto engine. The first patch adds Documentations for the device and Patch 2 adds device probe and DMA init for the module. Patch 3 adds crypto and DMA dts node for VisionFive 2 board. Patch 4 adds hash/hmac support to the module. Patch 3 needs to be applied on top of: https://patchwork.kernel.org/project/linux-riscv/patch/20230221024645.127922-18-hal.feng@starfivetech.com/ https://patchwork.kernel.org/project/linux-riscv/cover/20230120024445.244345-1-xingyu.wu@starfivetech.com/ Changes v2->v3: - Only implement digest and use fallback for other ops (Herbert) - Use interrupt instead of polling for hash complete (Herbert) - Remove manual data copy from out-of-bound memory location as it will be handled by DMA API. (Christoph & Herbert) Changes v1->v2: - Fixed yaml filename and format (Krzysztof) - Removed unnecessary property names in yaml (Krzysztof) - Moved of_device_id table close to usage (Krzysztof) - Use dev_err_probe for error returns (Krzysztof) - Dropped redundant readl and writel wrappers (Krzysztof) - Updated commit signed offs (Conor) - Dropped redundant node in dts, module set to on in dtsi (Conor) Jia Jie Ho (4): dt-bindings: crypto: Add StarFive crypto module crypto: starfive - Add crypto engine support riscv: dts: starfive: Add crypto and DMA node for VisionFive 2 crypto: starfive - Add hash and HMAC support .../crypto/starfive,jh7110-crypto.yaml | 70 ++ MAINTAINERS | 7 + arch/riscv/boot/dts/starfive/jh7110.dtsi | 28 + drivers/crypto/Kconfig | 1 + drivers/crypto/Makefile | 1 + drivers/crypto/starfive/Kconfig | 21 + drivers/crypto/starfive/Makefile | 4 + drivers/crypto/starfive/jh7110-cryp.c | 239 ++++ drivers/crypto/starfive/jh7110-cryp.h | 134 +++ drivers/crypto/starfive/jh7110-hash.c | 1041 +++++++++++++++++ 10 files changed, 1546 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/starfive,jh7110-crypto.yaml create mode 100644 drivers/crypto/starfive/Kconfig create mode 100644 drivers/crypto/starfive/Makefile create mode 100644 drivers/crypto/starfive/jh7110-cryp.c create mode 100644 drivers/crypto/starfive/jh7110-cryp.h create mode 100644 drivers/crypto/starfive/jh7110-hash.c
Comments
> On 13 Mar 2023 21:56:46 +0800 Jia Jie Ho <jiajie.ho@starfivetech.com> > > +static int starfive_hash_xmit_dma(struct starfive_cryp_ctx *ctx) { [...] > > + dmaengine_slave_config(cryp->tx, &cryp->cfg_in); > > + > > + in_desc = dmaengine_prep_slave_sg(cryp->tx, rctx->in_sg, > > + rctx->in_sg_len, > DMA_MEM_TO_DEV, > > + DMA_PREP_INTERRUPT | > DMA_CTRL_ACK); > > + > > + if (!in_desc) > > + return -EINVAL; > > + > > + reinit_completion(&cryp->tx_comp); > > What breaks without reinit? Hi Hillf, So far, I don't see errors without the reinit. I kept the reinit to reset the done field in case there is a prior transfer. I'll remove this if it is not needed. > > + > > + in_desc->callback = starfive_hash_dma_callback; > > + in_desc->callback_param = cryp; > > + > > + cookie = dmaengine_submit(in_desc); > > + dma_async_issue_pending(cryp->tx); > > + > > + if (!wait_for_completion_timeout(&cryp->tx_comp, > > + msecs_to_jiffies(10000))) { > > + dev_err(cryp->dev, "wait_for_completion_timeout error, > cookie = %x\n", > > + dma_async_is_tx_complete(cryp->rx, cookie, > > + NULL, NULL)); > > What prevents wakeup from coming in case of timeout? Usually, timeout is caused by failure to complete all data transfer. It might be due to errors in dma chan setup or in case the hardware hangs. Thanks for taking time looking into the patch. Best regards, Jia Jie
> -----Original Message----- > From: Jia Jie Ho <jiajie.ho@starfivetech.com> > Sent: 13 March, 2023 9:57 PM > To: Herbert Xu <herbert@gondor.apana.org.au>; David S . Miller > <davem@davemloft.net>; Rob Herring <robh+dt@kernel.org>; Krzysztof > Kozlowski <krzysztof.kozlowski+dt@linaro.org>; Emil Renner Berthing > <kernel@esmil.dk>; Conor Dooley <conor.dooley@microchip.com> > Cc: linux-crypto@vger.kernel.org; devicetree@vger.kernel.org; linux- > kernel@vger.kernel.org; linux-riscv@lists.infradead.org > Subject: [PATCH v3 0/4] crypto: starfive - Add drivers for crypto engine > > This patch series adds kernel driver support for StarFive JH7110 crypto engine. > The first patch adds Documentations for the device and Patch 2 adds device > probe and DMA init for the module. Patch 3 adds crypto and DMA dts node > for VisionFive 2 board. Patch 4 adds hash/hmac support to the module. > > Patch 3 needs to be applied on top of: > https://patchwork.kernel.org/project/linux- > riscv/patch/20230221024645.127922-18-hal.feng@starfivetech.com/ > https://patchwork.kernel.org/project/linux- > riscv/cover/20230120024445.244345-1-xingyu.wu@starfivetech.com/ > > Changes v2->v3: > - Only implement digest and use fallback for other ops (Herbert) > - Use interrupt instead of polling for hash complete (Herbert) > - Remove manual data copy from out-of-bound memory location as it will > be handled by DMA API. (Christoph & Herbert) > > Changes v1->v2: > - Fixed yaml filename and format (Krzysztof) > - Removed unnecessary property names in yaml (Krzysztof) > - Moved of_device_id table close to usage (Krzysztof) > - Use dev_err_probe for error returns (Krzysztof) > - Dropped redundant readl and writel wrappers (Krzysztof) > - Updated commit signed offs (Conor) > - Dropped redundant node in dts, module set to on in dtsi (Conor) > > Jia Jie Ho (4): > dt-bindings: crypto: Add StarFive crypto module > crypto: starfive - Add crypto engine support > riscv: dts: starfive: Add crypto and DMA node for VisionFive 2 > crypto: starfive - Add hash and HMAC support > > .../crypto/starfive,jh7110-crypto.yaml | 70 ++ > MAINTAINERS | 7 + > arch/riscv/boot/dts/starfive/jh7110.dtsi | 28 + > drivers/crypto/Kconfig | 1 + > drivers/crypto/Makefile | 1 + > drivers/crypto/starfive/Kconfig | 21 + > drivers/crypto/starfive/Makefile | 4 + > drivers/crypto/starfive/jh7110-cryp.c | 239 ++++ > drivers/crypto/starfive/jh7110-cryp.h | 134 +++ > drivers/crypto/starfive/jh7110-hash.c | 1041 +++++++++++++++++ > 10 files changed, 1546 insertions(+) > create mode 100644 > Documentation/devicetree/bindings/crypto/starfive,jh7110-crypto.yaml > create mode 100644 drivers/crypto/starfive/Kconfig create mode 100644 > drivers/crypto/starfive/Makefile create mode 100644 > drivers/crypto/starfive/jh7110-cryp.c > create mode 100644 drivers/crypto/starfive/jh7110-cryp.h > create mode 100644 drivers/crypto/starfive/jh7110-hash.c > > -- > 2.25.1 Hi Herbert/David, Could you please help review this patch series? Thanks in advance. Best regards, Jia Jie