From patchwork Tue Sep 12 14:31:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 138471 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp722932vqx; Tue, 12 Sep 2023 15:45:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH2UFeNvY4FNJmZb2pdwQCZ9uDg8p6+cB0OJ+RsiIFsQyR8EWlOEl9NZ2jQty8x+eVj47og X-Received: by 2002:a17:903:11d1:b0:1c0:ce0f:ab57 with SMTP id q17-20020a17090311d100b001c0ce0fab57mr1477080plh.3.1694558711991; Tue, 12 Sep 2023 15:45:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694558711; cv=none; d=google.com; s=arc-20160816; b=F5lxNkoB7/PPyty/9mU+8G3tMXo6hgsmVf76HCe4OLc0G0BPBnz+WnIArcKg2l4mGM s3jBAyMFdMuISVnR0kIPv5R1z6ytlX2Aw+kmA7x0u6i++5Js8mswKKtHd7PTQOwl3FV6 EWDvTyyTd/Ix7hFcFbT0brj1fMi17RAeBElf0v2iqoCJfikSah6rLJ7gcFdJA40aV7l9 790tDe45KCLj0ZxNxuNRUO2WQ14QKUT84A4EvQLYUm6mNINEQfMXvyFCD9qhS2PStX5G uGE2y/u9dWZqQnV03YMOfGLKp/iMndqojD/a8OM8gK2Fs5jkzeMGiG7dj9m/GPCFa37y XtwA== 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=1J/OiJhswU+ijrWVEMob7T32JDh7lPH74t+Umlejb7evp52Zl73zjQn/jg3YksV+K8 zkgM4nwB69Ty+hS7XyZqgZxuQ2g6yuJwH8KzYn11CPR4dTvMXkDgMv4gJMg7PlPh3HbZ BFtousmbx6v0gBLjeZtxUBVkSNwlQ0h3I8uiOHlFFsHRPKBejlnSwguX4qd/mHbl15Gu 0je1o4nC2r/TxnS4wj6HBszSzdjYo5W5ul86mnroen721p1rObDdklnxc0mLeY1bU6yN 2Le9x2GV7QBAMNbl32SuzmeFPW6qcXhZfZPCicsYW/oJ3xl235Pcs9cu0ATcjbprk6q4 qgog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id l5-20020a170903120500b001bd9d2e20absi9323699plh.230.2023.09.12.15.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 15:45:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id B95B9822D562; Tue, 12 Sep 2023 07:35:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236085AbjILOe4 (ORCPT + 37 others); Tue, 12 Sep 2023 10:34:56 -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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 12 Sep 2023 07:35:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776873596050659855 X-GMAIL-MSGID: 1776873596050659855 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;