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;