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;