From patchwork Thu Aug 24 19:20:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 136869 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp1348021vqm; Thu, 24 Aug 2023 12:41:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHH1NpbHCKXDm9B149H3pYVYjr7FMkVffcgxEXbnq6zar57uT3V7ufFmqwtcgbci+6h7kj7 X-Received: by 2002:a17:906:5187:b0:9a1:b5fc:8c56 with SMTP id y7-20020a170906518700b009a1b5fc8c56mr7379208ejk.55.1692906068873; Thu, 24 Aug 2023 12:41:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692906068; cv=none; d=google.com; s=arc-20160816; b=xySC71AXaVpUFlliy8ngirbUOQM0X4oXaR7RJbropV12uISBwUh75iOkF2BfDXrwN6 iUXn+5ORC+pUSsdBrAO+5iAAtXydonffQjzkXS2MQ7aR1cc+stIW9Vyl32/uSjjB3Ovl 0gbm7mbe9k/pgOCH3qT8J64Nae3ujZ6gqr5jJ/ADMS4flIFoo4CNc96nKqgsCrTzUm3a eA2Cz9AUPbdaxj2dSeg9qOjclelt/fDcnXxwvG1B4Qw/AdF87TtqY9ULOG+0+fq7rnet C7s7ptksCZGDvopTjueKZam2hRuDFPo1lPvrlgS3huEUys+WynI8H2PXu8G6U9O50mof IqKA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=HeGYXB423ImhM4HDuoYzq/ZZc9H0BonXNKNtV+n0w4A=; fh=MlvSK6e3kwN+F1KP9aqWF9U5JWJ1T+e+f4RH8e/Tu2E=; b=S+DwCf27BnUjTjBsa2em4Ma5+TJHtWyU59gzOa32ZllHxqW+Yp6DK+Rpgmk2XEPtyh /VoEiCXsDjweDnqcz86c/wgaaYTqe7vmzdYZXOYyD5cJOHXdupJqfra7kSjf3EEEdgM5 LXtoTetIRMackmozCR7z9azJsOEZFrQMpCqWXk8JZq9VDuaaMp8dH1JzccD2b+19EVcA S+YDRrsiFaXoF56aumSP7beEwA32N3KTcp7DgQcqsf85+PeTETLxv+T39cjsoXi0zqaw SVQZRiUYuGvVSOsUh6HJdg8c77WR3yAKbqPJVTwZKBUo495xe9kEZkb1DEIWVPtrrHc5 6+Pw== 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 kl11-20020a170907994b00b00988b90f50b3si6476ejc.607.2023.08.24.12.40.44; Thu, 24 Aug 2023 12:41:08 -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 S243186AbjHXTYK (ORCPT + 99 others); Thu, 24 Aug 2023 15:24:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242991AbjHXTXv (ORCPT ); Thu, 24 Aug 2023 15:23:51 -0400 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF95A1BE5; Thu, 24 Aug 2023 12:23:48 -0700 (PDT) Received: from dslb-188-097-211-187.188.097.pools.vodafone-ip.de ([188.97.211.187] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1qZFvi-00036P-8z; Thu, 24 Aug 2023 21:23:42 +0200 From: Martin Kaiser To: Herbert Xu Cc: Alexander Stein , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH v2 1/6] hwrng: imx-rngc - reasonable timeout for selftest Date: Thu, 24 Aug 2023 21:20:54 +0200 Message-Id: <20230824192059.1569591-2-martin@kaiser.cx> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230824192059.1569591-1-martin@kaiser.cx> References: <20230824192059.1569591-1-martin@kaiser.cx> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1775140674130755046 X-GMAIL-MSGID: 1775140674130755046 Set a more reasonable timeout for the rngc selftest. According to the reference manual, "The self test takes approximately 29,000 cycles to complete." With the rngc peripheral clock running at 66.5 MHz, this would be 436us. Let's use 1.5ms insteaf of 3sec for the timeout. Signed-off-by: Martin Kaiser --- v2: - adjust timeouts before we switch to polling drivers/char/hw_random/imx-rngc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c index e4b385b01b11..6024c923b67d 100644 --- a/drivers/char/hw_random/imx-rngc.c +++ b/drivers/char/hw_random/imx-rngc.c @@ -53,6 +53,7 @@ #define RNGC_TIMEOUT 3000 /* 3 sec */ +#define RNGC_SELFTEST_TIMEOUT 1500 /* us */ static bool self_test = true; module_param(self_test, bool, 0); @@ -110,7 +111,8 @@ static int imx_rngc_self_test(struct imx_rngc *rngc) cmd = readl(rngc->base + RNGC_COMMAND); writel(cmd | RNGC_CMD_SELF_TEST, rngc->base + RNGC_COMMAND); - ret = wait_for_completion_timeout(&rngc->rng_op_done, msecs_to_jiffies(RNGC_TIMEOUT)); + ret = wait_for_completion_timeout(&rngc->rng_op_done, + usecs_to_jiffies(RNGC_SELFTEST_TIMEOUT)); imx_rngc_irq_mask_clear(rngc); if (!ret) return -ETIMEDOUT; From patchwork Thu Aug 24 19:20:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 136868 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp1347144vqm; Thu, 24 Aug 2023 12:39:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEF7OpzIFD4MqjQ7nbViknyDAIcLdlQOvaGps2KiKCCrbNPJDUHQWXba8r3A1Cc10JByJw2 X-Received: by 2002:ac2:4e0a:0:b0:4fb:8948:2b28 with SMTP id e10-20020ac24e0a000000b004fb89482b28mr15292365lfr.63.1692905957637; Thu, 24 Aug 2023 12:39:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692905957; cv=none; d=google.com; s=arc-20160816; b=tytnOnTHvXQ6JOWxSKnjRazCk+19jWhYs4IMZrbf6tepEjaI75B7VNTInUYLN09rIp 9uYMiEQngFatD36Mx2y3geiLUkz/HawzcVTRTo0TAljO0xfARYWKz5x6Y4EVVbfra7lG +MLJ0s+zRujNdRh0wv30dX8l06ldsFfQvsnFMOhfKVeXRxn0GUe8H5/VTIsLHDLV7S4Y UPwou4asqUynrQuwLcfl3yEhjPQTs6XB4DRLc/XzUOlhuzoMPpRleh4ftMAzj96slfFn h2HIEPFo8xWQ8PAT7OZ7GVYK2E5JGa3tYNqM2nLst8PkXlDBGX+PdcoJt8CkN/k/sAu9 PJww== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jrGSyLg5jQstVBXLOEfmgYmvOpcUqNGtZRCAZiGU2Ak=; fh=MlvSK6e3kwN+F1KP9aqWF9U5JWJ1T+e+f4RH8e/Tu2E=; b=RslndqdVqHJqBPaxbWjpAnNrlABwNxCyzlijgBfocXZtMc6Jcy4pvanPegxhAoFjvK CNkvFcqkjHXOrbUdJSamO5wmI6JK8brfKU+mxE2Nvcl3gic90u63rbsF+ZZJoXURF8Bt 79cCMOaf0ylPvAHEIiGwp1XIEhOqAJLwPowf2/aHXAuxof9xLIedzefMbVVtnh+oYdOn NX8Zm0gaLYp3eyFiT6HyeOcAbufA0XeKadoHA+ImzStYSCUSkNBXlB75ITbQpZUecUtK ALtD2tYp32p7JjAa5vDm/sovOn9EdTnoh9Cs1f811zhblwd+J9jd7EMQDHLtM4unAUzX NRIA== 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 ay22-20020a056402203600b00529fa041d40si151546edb.353.2023.08.24.12.38.53; Thu, 24 Aug 2023 12:39:17 -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 S243196AbjHXTYN (ORCPT + 99 others); Thu, 24 Aug 2023 15:24:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243061AbjHXTXv (ORCPT ); Thu, 24 Aug 2023 15:23:51 -0400 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF8DD1BE2; Thu, 24 Aug 2023 12:23:48 -0700 (PDT) Received: from dslb-188-097-211-187.188.097.pools.vodafone-ip.de ([188.97.211.187] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1qZFvk-00036P-Nc; Thu, 24 Aug 2023 21:23:44 +0200 From: Martin Kaiser To: Herbert Xu Cc: Alexander Stein , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH v2 4/6] hwrng: imx-rngc - read status register for error checks Date: Thu, 24 Aug 2023 21:20:57 +0200 Message-Id: <20230824192059.1569591-5-martin@kaiser.cx> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230824192059.1569591-1-martin@kaiser.cx> References: <20230824192059.1569591-1-martin@kaiser.cx> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1775140557685094076 X-GMAIL-MSGID: 1775140557685094076 The error bit in the status register of the imx-rngc is set for any kind of error. Details about the error can be read from the bits in the error status register. In the imx_rngc_self_test function, we just need the info if there was an error or not. We can check the status register, there's no need to read the error status register. Signed-off-by: Martin Kaiser --- drivers/char/hw_random/imx-rngc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c index 09523936d2af..c2582673427d 100644 --- a/drivers/char/hw_random/imx-rngc.c +++ b/drivers/char/hw_random/imx-rngc.c @@ -114,7 +114,7 @@ static int imx_rngc_self_test(struct imx_rngc *rngc) if (ret < 0) return ret; - return readl(rngc->base + RNGC_ERROR) ? -EIO : 0; + return (status & RNGC_STATUS_ERROR) ? -EIO : 0; } static int imx_rngc_read(struct hwrng *rng, void *data, size_t max, bool wait)