Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2638269rdb; Tue, 12 Sep 2023 07:54:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF2ZKJGfW+4OWYtRcEFHOu9NtzBFZnsmR/imlYGt214PAgmsWMt2hlW5NnZBCKFYHueKxyY X-Received: by 2002:aa7:8307:0:b0:68c:59cb:2dd9 with SMTP id bk7-20020aa78307000000b0068c59cb2dd9mr3276403pfb.1.1694530473186; Tue, 12 Sep 2023 07:54:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694530473; cv=none; d=google.com; s=arc-20160816; b=vjHdeluodEwqK9R15793AymNN8BRNLOFfkUnrnjfcQA3u/trZB1uX52lLpi8YaAJpM 5Zju6uvtVCPd7GqNrDFH/ECd4BhsmrhD3JbFdxD/spuXqSxTjFL/ZU5GSD8vIGBynzYW ZgwxFSzStXno44sCFW9J4h7Zfo8TgWb/ePWQahIeKgXy7+iF8qnBjt4Bm3wsnE8IgXK4 WPx6Dw+WAjrleQRqN3HmIhwCUn5gSaWnAFZeiWXFH1GEZ0Aqug/cY8wUAY5gT5tr1VYj aI1OBPIwFWd/4bqN8ijNIZWz7m2m1qzgwIqceMIbMOUkgG1i098Z0XsafKQtjGpeWruK MzTw== 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=/gE0M9rJJ138eoV7fjvPV7xVpBgbznyvZDJAw7aGpSw=; fh=SqCs7KZ8ytcbnkiRESvNRChZIthYOwhcUjFjEDfWP4k=; b=KAwt/UzzHUMPvgvMvGwwvJ2G9TRt+0Ily5VBVIC9FGnD0HVVnrxNWkjn0dbxys2Otk Xediiv0UK8L3WOJfVF0O+f6uX6ztjTwVGE1vl4XA7uUkYeIYRBnHXQZ/2xqfxeEp1a1T xKsG1GKBGhgyAq4EQhZ1YIlPdk2LM1x626tUMfvCor/A5czKj2te8Ri0CsoJzVWv91fk 7dwbpaDCQ3G5/y872Ac1wiCoZ++sTfgYZNLdPWuaOya4IMIhwfnpRx5+Nh2XKrpOmAOj ff0rCUxXBxysCxu2xgJuAMKtuV+fBLCCLDkjKg9Ue2d4G45yf4KKzSK1JKgBZuvGvpVR DsTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id i63-20020a638742000000b0056a19c7c2e5si7746522pge.361.2023.09.12.07.54.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 07:54:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id B2D2B81DF243; Tue, 12 Sep 2023 07:34:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236055AbjILOey (ORCPT + 99 others); Tue, 12 Sep 2023 10:34:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236047AbjILOeu (ORCPT ); Tue, 12 Sep 2023 10:34:50 -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 17B12CC3; Tue, 12 Sep 2023 07:34:46 -0700 (PDT) Received: from dslb-178-004-201-190.178.004.pools.vodafone-ip.de ([178.4.201.190] 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 1qg4TU-0005wr-LB; Tue, 12 Sep 2023 16:34:44 +0200 From: Martin Kaiser To: Herbert Xu Cc: linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 2/2] hwrng: imx-rngc - reasonable timeout for initial seed Date: Tue, 12 Sep 2023 16:31:18 +0200 Message-Id: <20230912143117.55965-3-martin@kaiser.cx> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230912143117.55965-1-martin@kaiser.cx> References: <20230912143117.55965-1-martin@kaiser.cx> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 12 Sep 2023 07:34:57 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 pete.vger.email Set a more reasonable timeout for calculating the initial seed. The reference manuals says that "The initial seed takes approximately 2,000,000 clock cycles." The rngc peripheral clock runs at >= 33.25MHz, so seeding takes at most 60ms. A timeout of 200ms is more appropriate than the current value of 3 seconds. Signed-off-by: Martin Kaiser --- drivers/char/hw_random/imx-rngc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c index 127c292dfbbf..118a72acb99b 100644 --- a/drivers/char/hw_random/imx-rngc.c +++ b/drivers/char/hw_random/imx-rngc.c @@ -51,9 +51,8 @@ #define RNGC_ERROR_STATUS_STAT_ERR 0x00000008 -#define RNGC_TIMEOUT 3000 /* 3 sec */ - #define RNGC_SELFTEST_TIMEOUT 2500 /* us */ +#define RNGC_SEED_TIMEOUT 200 /* ms */ static bool self_test = true; module_param(self_test, bool, 0); @@ -184,7 +183,8 @@ static int imx_rngc_init(struct hwrng *rng) cmd = readl(rngc->base + RNGC_COMMAND); writel(cmd | RNGC_CMD_SEED, 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, + msecs_to_jiffies(RNGC_SEED_TIMEOUT)); if (!ret) { ret = -ETIMEDOUT; goto err; -- 2.39.2