From patchwork Tue Dec 27 23:03:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 37010 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1620758wrt; Tue, 27 Dec 2022 15:05:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXtOfpAYg8cocMx+kEe1KbbLLlQiAA6KUOx6Cr2ISrCDRVEhkzPkQoCa1l/InuD6ln4NLhs6 X-Received: by 2002:a17:906:d047:b0:78d:f454:ba46 with SMTP id bo7-20020a170906d04700b0078df454ba46mr19622412ejb.69.1672182355493; Tue, 27 Dec 2022 15:05:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672182355; cv=none; d=google.com; s=arc-20160816; b=urnfQ0r6jgmxQBCVdqpcEs994IXTZyLb9IscVC539FUWyKznoypvdhWpjrOqhOqSPF zhBTbKtKzaPcD+X9dDAV/YBKWji2yv/M0e4zGQehobPs/iS0/HtVmwvrV31MLdU5t+mY hr+Rys4gI0SSiCnQb20mtlg4tVutnE9i51YiX4HzE9aTw4Uh+J4W/DOimvt/bwmB8nYu v528mzLiMLKL7OpDZoagTi+1FJDaH9GamIS0GCyGgjzxRgjgX4+GcSxcmNWJElrVlKRX hznyrdZB0FB5XkEKSNTvYXb4m450FkCdUTgNmNagU1GSLEAYHsyzzp+EP4ZGHS0BS0wa hE4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=ALCXqoODJG4Fl1tVrTYiR0YIC0rXIReKhT1lUtG3hdA=; b=ufAn7nDBtf9CLzeZBooTv/8J2WBbMWWFTcsvlZq7kl3X/vGPynMEF4MPaKpwm9spVh q+kUVjqia9e7Ug6ThdK3ovU3z6M0rZsz22X4tGU8ku0jD64l6qr65VEbydmUv3glpbCN ROWDo8U17FwXxeat+AL29+ph7OEDwzHzHATynLAEpdag8Km0o56UdO7me01Xpmsz+bqs Hnoo8mFSdG6s8wXqMInbNA9m++topWE1k/iNvZVKuLFcMooMvSyMKkRE6Z7w51VtcQCf nXrbndlVKAnMlJcSUq/WiRXYcRqeAhiRtz3vXHS0iRCMIC2aT2eXJTuogbaZKdMvCFxc eMBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yUVecZ76; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn7-20020a1709070d0700b007c0b7b5ff5csi12938498ejc.646.2022.12.27.15.05.31; Tue, 27 Dec 2022 15:05:55 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=yUVecZ76; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232355AbiL0XEx (ORCPT + 99 others); Tue, 27 Dec 2022 18:04:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232357AbiL0XEW (ORCPT ); Tue, 27 Dec 2022 18:04:22 -0500 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABD2DDF92 for ; Tue, 27 Dec 2022 15:04:20 -0800 (PST) Received: by mail-lj1-x234.google.com with SMTP id s25so15076944lji.2 for ; Tue, 27 Dec 2022 15:04:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ALCXqoODJG4Fl1tVrTYiR0YIC0rXIReKhT1lUtG3hdA=; b=yUVecZ76fCB6IvA+Cy8N88tPkw06p37lZ0KXjxTx3ZHIslky5t2WXlZV9KZb/ZaFPK 26aLSaHZwMTeKto5N5oUi4HW12FrVrdFD8umOH9DB8DoPdV3MIL7bsFbWfGkoP0hxs98 A3267hW+oerZP6yQzyh2Gn/JaxqbCm8XCBJ+q4M3H+jOIPsQae5d1TEuD0BUiFkp376H iY1LUWlWKCFJGekC4nxaq5WJczPk5sUoAFpX/DZC9cT8Plmy3MCkuutHjcmfNnPMxiJw fW3RrTjPpbINPMFi26xnHCtSRItCjMSvKI10Ew9AnhUQzNFoBTVYD4WHjeh3WLLPGBr4 3LBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ALCXqoODJG4Fl1tVrTYiR0YIC0rXIReKhT1lUtG3hdA=; b=0o/cCR22siZIgy+cO2CO6neZ4c/ilpxMMZS/5O3ppf1SvYZm38jKLH8U2DLyp48mYu Q+SJAyiDOwPXYyNgR+7Qg7/gmPECM3zP35RcTUbm1u8LETgdG28k9/QlDa6c28rfJ+fN VTG4DFpK0UphiASwatwRU+xEzNkGiY6CyeFMab+iTJXHEvWp4vEAkZmymomph1XoVtxr K78kVNBFV6JIqhO3Z6H/WAe0uUnQMv+MjMVFOdqehmz8/MzjgisulQOrCeA50CBvrw2I 7Go1IyvaHzJYcMPDF9phr1Yzm9alVsx7ESNqX+1TX29910TrO59BL9XvGCvRhJn4F8nu 4Hmw== X-Gm-Message-State: AFqh2kpszWN6r8W7G8riDbv84l6EEXpUNBDbL6xu66EwS+HiQJG5X9A3 WC42zctfEUwP8H2XQEj/NbsPaLLl8iw7mQCwEHc= X-Received: by 2002:a2e:b0d0:0:b0:27f:8b85:4098 with SMTP id g16-20020a2eb0d0000000b0027f8b854098mr6719151ljl.52.1672182260250; Tue, 27 Dec 2022 15:04:20 -0800 (PST) Received: from Fecusia.local (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id bg25-20020a05651c0b9900b0027fbd4ee003sm876925ljb.124.2022.12.27.15.04.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Dec 2022 15:04:15 -0800 (PST) From: Linus Walleij Date: Wed, 28 Dec 2022 00:03:37 +0100 Subject: [PATCH 5/7] crypto: stm32/hash: Wait for idle before final CPU xmit MIME-Version: 1.0 Message-Id: <20221227-ux500-stm32-hash-v1-5-b637ac4cda01@linaro.org> References: <20221227-ux500-stm32-hash-v1-0-b637ac4cda01@linaro.org> In-Reply-To: <20221227-ux500-stm32-hash-v1-0-b637ac4cda01@linaro.org> To: Herbert Xu , "David S. Miller" , Rob Herring , Krzysztof Kozlowski , Maxime Coquelin , Alexandre Torgue , Lionel Debieve Cc: linux-crypto@vger.kernel.org, devicetree@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.11.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753410285705272626?= X-GMAIL-MSGID: =?utf-8?q?1753410285705272626?= When calculating the hash using the CPU, right before the final hash calculation, heavy testing on Ux500 reveals that it is wise to wait for the hardware to go idle before calculating the final hash. The default test vectors mostlt worked fine, but when I used the extensive tests and stress the hardware I ran into this problem. Signed-off-by: Linus Walleij --- drivers/crypto/stm32/stm32-hash.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c index 5f03be121787..92b2d55d6e93 100644 --- a/drivers/crypto/stm32/stm32-hash.c +++ b/drivers/crypto/stm32/stm32-hash.c @@ -362,6 +362,9 @@ static int stm32_hash_xmit_cpu(struct stm32_hash_dev *hdev, stm32_hash_write(hdev, HASH_DIN, buffer[count]); if (final) { + if (stm32_hash_wait_busy(hdev)) + return -ETIMEDOUT; + stm32_hash_set_nblw(hdev, length); reg = stm32_hash_read(hdev, HASH_STR); reg |= HASH_STR_DCAL;