From patchwork Tue Sep 12 14:31:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 138668 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp892337vqx; Tue, 12 Sep 2023 23:43:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWTOex4m/uxGBaobuyyQTS9yOZy/ebVe6itUgjXfVZQyW9csikeBBkNNIFKI73dqxIlDQG X-Received: by 2002:a17:90a:8c88:b0:269:18f5:683e with SMTP id b8-20020a17090a8c8800b0026918f5683emr1391755pjo.3.1694587400480; Tue, 12 Sep 2023 23:43:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694587400; cv=none; d=google.com; s=arc-20160816; b=UE+Hy1JCmfNjcevrMOOINgI0u2mWg/w5SRbBshp0jBAh3jgjZzAccNrBcpWckPWB1g SzG+K4XHnMIgcapwCDW9D7/zTfiCnoJiNFc4ZlWsfFYh0qG2SYy3r9fNZtXkTHCdeGsJ +t32H6z5wo6O0YMmIrCZpWYWBZN3gmRK3lq0u/mtVf2LknXXk2ze3RvgQWIgbFBgn5AN CEeInLzrx+Z87U3GjlyzJnm6Er0OqgZk1mJqWKkycDGNCC/MYEEpZe2h4oWKNpkN+ebu OYWVvR+KlZ+CKP7PGGer2VuGX7HZpQ3wjQnado+mNK2zmfeY7KmNseZFHnKcgeToJ7y5 3JcQ== 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=eBML06wzieRCT46r7BIzYmwH/lYIn9PmgTZqGbe9rzA=; fh=SqCs7KZ8ytcbnkiRESvNRChZIthYOwhcUjFjEDfWP4k=; b=Ld4Kf8tmCeH3RcKBdTlKNtudIsb0l+AEUcmwP+vwoSdQbHZl4231sU34/N3ww3bZiu nEUTmXaICXSVwMpJbYKMA/w56HyovmFShjE8z+C5vdxHp9nENgLpfCr07SCVAthj4bMh ARK/rG4N9p3c+VhH0x0hXki6e5VA1wwXVoOMgT4kr9SQy8ZWP+0CpkGcEU4HCPawZOmC udMX8+Iku4h4QyxM5dXDjYKo7PK14W7r2Vi/MU87Ai0KgIlOBH2YLMBFOxnUAjORIJcg 7HTe/oe7Q7zO5Msw1SUIt0PhB7bXdAXC5Jn9exyhwESVwuMHUnv7WijKlQ2kTUYpCAjF RjRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id n5-20020a17090a9f0500b0025bdc2a0b15si924619pjp.135.2023.09.12.23.43.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 23:43:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id C76EF807C648; Tue, 12 Sep 2023 07:34:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236060AbjILOex (ORCPT + 37 others); Tue, 12 Sep 2023 10:34:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236033AbjILOeq (ORCPT ); Tue, 12 Sep 2023 10:34:46 -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 E7688CCC; Tue, 12 Sep 2023 07:34:42 -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 1qg4TQ-0005wr-0k; Tue, 12 Sep 2023 16:34:40 +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 1/2] hwrng: imx-rngc - reasonable timeout for selftest Date: Tue, 12 Sep 2023 16:31:17 +0200 Message-Id: <20230912143117.55965-2-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 (snail.vger.email [0.0.0.0]); Tue, 12 Sep 2023 07:34:57 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776903677892330250 X-GMAIL-MSGID: 1776903677892330250 Set a more reasonable timeout for the rngc selftest. According to the reference manual, "The self test takes approximately 29,000 cycles to complete." The lowest possible frequency of the rngc peripheral clock is 33.25MHz, the selftest would then take about 872us. 2.5ms should be enough for the selftest timeout. Signed-off-by: Martin Kaiser --- 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..127c292dfbbf 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 2500 /* 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 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;