From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A073CC3DA6F for ; Fri, 25 Aug 2023 07:13:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=s9sFL7BqBEiLRlReCe+4Du6WyAWWw6WnIMUA0ZYYnTc=; b=oS8v5S5EVttC+W ERqyBn2Bhd8QbG1q6Mxm15NHec0mtd5GBQGN+qxmpr8VNIbmUESl9VZoIkkfX3zVnf1sP024vALCd CevvXaZx6Begk7paxJTL/hQPsxW0dwyhgsFGCVS6JSvn92eX2vxyLygDt3Gtkbogz5tJtbj5cLp2w J4D5YLP3xTCc5eZ7g7+jHCYyKF0jQeA78Xhai6kFA+nSGsqcQ4tjmWGHpPSKx4DKbrcwhaQU+2vNY 4kOJaNebyTuBhOOjxifUFPxqptw54+SEdgCJ3dmiQRczAWUhJOJi/Qpn9QH4/OVOW6LUIC1zBjMm6 8hLmAi/15CYd7NQfViXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qZR0F-004WZb-0K; Fri, 25 Aug 2023 07:13:07 +0000 Received: from mx1.tq-group.com ([93.104.207.81]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qZR0B-004WY4-11 for linux-arm-kernel@lists.infradead.org; Fri, 25 Aug 2023 07:13:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1692947583; x=1724483583; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=q2k+Pyt4QngwrczcVgdUO+Ku35iTRGG8ZTnt0DwH5gs=; b=NatCd1bEoSK4kSr5Ut7KKo70vO0OaI+nfHoSOP2AXUl8POb8iwcBwm8M bClfaNO5RqVy9KcUzNj7bdItZFf0ldPJVK7f3eWr9qRSFziBwX7ZlY1ld Gmt9caPDFX+KNOGh7VXH7Nz2HXYlTw3B3W0nSMqwFm24+fLh6TcqCwczm 1M/EBdfiYf2JFoIBPZe72attM1aAr890JUYb0D+0dqCCgu5SjRNgpbUnl YFLi7Xl5M77BTPPShW6g4cgnfRyDuiC3JoS/8zo/HvcFXXr1eBw79Qf+I 5gCIYFy7SsBYgqj5mFKki/YXqXwBEYoussGm/Gz6MUiIwNk9GWwdWYFKP g==; X-IronPort-AV: E=Sophos;i="6.02,195,1688421600"; d="scan'208";a="32622174" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 25 Aug 2023 09:12:44 +0200 Received: from steina-w.localnet (steina-w.tq-net.de [10.123.53.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by vtuxmail01.tq-net.de (Postfix) with ESMTPSA id A0755280075; Fri, 25 Aug 2023 09:12:44 +0200 (CEST) From: Alexander Stein To: Herbert Xu , Martin Kaiser Cc: linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Martin Kaiser Subject: Re: [PATCH v2 3/6] hwrng: imx-rngc - use polling to detect end of self test Date: Fri, 25 Aug 2023 09:12:44 +0200 Message-ID: <8370215.EvYhyI6sBW@steina-w> Organization: TQ-Systems GmbH In-Reply-To: <20230824192059.1569591-4-martin@kaiser.cx> References: <20230824192059.1569591-1-martin@kaiser.cx> <20230824192059.1569591-4-martin@kaiser.cx> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230825_001303_751151_9F34BE01 X-CRM114-Status: GOOD ( 19.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Martin, thanks for splitting the series into single patches. Am Donnerstag, 24. August 2023, 21:20:56 CEST schrieb Martin Kaiser: > Use polling to detect the end of the rngc self test. This is much simpler > than using an interrupt and a completion. I'm still not convinced that using polling is simpler. By using = readl_poll_timeout() you will also get an interrupt, the timer one. Why = exactly is using polling much (!) simpler? > The selftest should take approx. 450us. Keep the overhead to a minimum > by polling every 500us. (We've already lowered the timeout to 1.5ms.) I suppose these times only hold true for a specific peripheral clock = frequency. Is it guaranteed that this frequency is fixed? For using IRQ it's simpler, there is no guessing: you return once the self = test finished. The timeout is identical anyway. Best regards, Alexander > Signed-off-by: Martin Kaiser > --- > v2: > - use shorter timeout and polling interval > = > drivers/char/hw_random/imx-rngc.c | 16 +++++++--------- > 1 file changed, 7 insertions(+), 9 deletions(-) > = > diff --git a/drivers/char/hw_random/imx-rngc.c > b/drivers/char/hw_random/imx-rngc.c index 8ff3d46674fd..09523936d2af 1006= 44 > --- a/drivers/char/hw_random/imx-rngc.c > +++ b/drivers/char/hw_random/imx-rngc.c > @@ -17,6 +17,7 @@ > #include > #include > #include > +#include > #include > = > #define RNGC_VER_ID 0x0000 > @@ -101,22 +102,19 @@ static inline void imx_rngc_irq_unmask(struct imx_r= ngc > *rngc) > = > static int imx_rngc_self_test(struct imx_rngc *rngc) > { > - u32 cmd; > + u32 cmd, status; > int ret; > = > - imx_rngc_irq_unmask(rngc); > - > /* run self test */ > cmd =3D readl(rngc->base + RNGC_COMMAND); > writel(cmd | RNGC_CMD_SELF_TEST, rngc->base + RNGC_COMMAND); > = > - ret =3D wait_for_completion_timeout(&rngc->rng_op_done, > - = usecs_to_jiffies(RNGC_SELFTEST_TIMEOUT)); > - imx_rngc_irq_mask_clear(rngc); > - if (!ret) > - return -ETIMEDOUT; > + ret =3D readl_poll_timeout(rngc->base + RNGC_STATUS, status, > + status & RNGC_STATUS_ST_DONE, 500, = RNGC_SELFTEST_TIMEOUT); > + if (ret < 0) > + return ret; > = > - return rngc->err_reg ? -EIO : 0; > + return readl(rngc->base + RNGC_ERROR) ? -EIO : 0; > } > = > static int imx_rngc_read(struct hwrng *rng, void *data, size_t max, bool > wait) -- = TQ-Systems GmbH | M=FChlstra=DFe 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht M=FCnchen, HRB 105018 Gesch=E4ftsf=FChrer: Detlef Schneider, R=FCdiger Stahl, Stefan Schneider http://www.tq-group.com/ _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel