Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5900529rwb; Mon, 5 Dec 2022 05:42:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf6GtrPP3Dymvi2SXYtEqLQQGgFYQi+6w74+3E8OpveLYg9gEnAFmhX8Qag2r8sXHLMTVvw5 X-Received: by 2002:a17:906:3a41:b0:78d:9caa:31b7 with SMTP id a1-20020a1709063a4100b0078d9caa31b7mr57332881ejf.263.1670247766387; Mon, 05 Dec 2022 05:42:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670247766; cv=none; d=google.com; s=arc-20160816; b=G83AwdsECw9SIYixfMwM3oA0fHMHHT5KwygP9VMbX2B90/t/GxIYFlkEm2tq3BEw4B vldrcnVyxEfG58AhEqFli6xosREdUWpczLmphDBQXTjmVD00OCDsem6tlIJdiOHmwp0f Pc5o/6TlJ73os1r8/hP0RMq1V9tzlFsIcbFhKcXvg4QP1rBvx1HxRs47Xzs+nFubzITu K1craaeRI90xpR+CGZxH6SmgeRyKxt0Vy8sTJklMJGldJbRK0hMnL6Q4J3SZgsxinJ11 zdEJA549edU1Z1W7VooRnfGFpsxdBRtZJjqaQk9taEVkaw3uH51g2QUauyT8CjZyaAYI eZAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=77miVuUVU22opWZzTtZsOCj5BnnAupU555MsmQ4hl2o=; b=t1jZM6C7WRnq17IR2oq2Nh2mAzWcgd7njKx+9nVr+5zS/veBpzTp0q2Mz+OwqP3F1h XNOAWOUK+DqQYv3XjELxcIxxlFo0XplATkkYBGRnYkv3WwfhBnbAtrOOS0UNc81zVHP1 im/FDcqU/BgvjSZHLn9eGAn8IWoEdgGo88Pl5w0BRQQa92jz2GXEXwTfH0kZgWSx1CiI Z54yISmJ7Tmi9CGt5LlawW1YMOWD2j2tTljP09amfgFEM6VmriQogMGSY9ZrgkOPOJYy T359U5oLi65FUAXeP8G89lyevmMx8hFrP0ZojmqZ8wu48s4Z6RUW1uAfvNorHR+g4rGZ M/+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=ZHV2azxK; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l21-20020a170906795500b007919dbd3770si12559723ejo.485.2022.12.05.05.42.19; Mon, 05 Dec 2022 05:42:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=ZHV2azxK; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232299AbiLENa0 (ORCPT + 99 others); Mon, 5 Dec 2022 08:30:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232248AbiLENaZ (ORCPT ); Mon, 5 Dec 2022 08:30:25 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A44331CB10; Mon, 5 Dec 2022 05:30:22 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3058961087; Mon, 5 Dec 2022 13:30:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A809C433C1; Mon, 5 Dec 2022 13:30:20 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="ZHV2azxK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1670247018; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=77miVuUVU22opWZzTtZsOCj5BnnAupU555MsmQ4hl2o=; b=ZHV2azxKBleZixdMsY3L6P7O6rjWGg/LZL3gSZLqZGPG5YIwdQKHZWN7dR36amXBb5CEHm Vt0EYxfpl8P+3ki5UFRU3RBGw0U7lNkkhW7xbBznehCiIVl/Lh8eTsGiW/u07+ZiLTqUIF zv3kThwvJt/l/BZyuHsKPi3OhdKVJ5g= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 5dae6f5e (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 5 Dec 2022 13:30:18 +0000 (UTC) Date: Mon, 5 Dec 2022 14:30:17 +0100 From: "Jason A. Donenfeld" To: Aurelien Jarno Cc: Olivia Mackall , Herbert Xu , Rob Herring , Krzysztof Kozlowski , Heiko Stuebner , Philipp Zabel , Lin Jinhan , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "moderated list:ARM/Rockchip SoC support" , "open list:ARM/Rockchip SoC support" , open list Subject: Re: [PATCH v2 2/3] hwrng: add Rockchip SoC hwrng driver Message-ID: References: <20221128184718.1963353-1-aurelien@aurel32.net> <20221128184718.1963353-3-aurelien@aurel32.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Dec 05, 2022 at 02:13:45PM +0100, Jason A. Donenfeld wrote: > If your intention is "90%", this should be 921 or 922, because the > quality knob is out of 1024, not 1000. > > Herbert - this seems like a fairly common pitfall I've seen all over the > place. It might be worth making a mental memo to reject or ask questions > about numbers that seem "too round", when you look at these sorts of > patches. Or alternatively we could introduce a cheesy macro like: #define HWRNG_PERCENTAGE(p) ((p) * 1024 / 100) and then enforce that everyone use that. But that's a bit wacky too, in the sense of - why is anybody using a non-obvious percentage in the first place. Like if you see "512" (or better, "1024 / 2"), okay fine, it's a device that guarantees 50%, which seems like a common enough physical thing. But if we see "HWRNG_PERCENTAGE(90)", the first question is why? What causes that? Seems very weird. And it's probably wrong. But if it *is* right, that deserves a big comment with explanation, where the calculation for that "921" literal can be explained in full, or, better, evaluated as a constant expression in terms of hardware constants -- something like HW_CLOCKRATE/FROBNICATOR_INTENSITY*1024/TURBOENCABULATION_MODE_WEIGHT, and then it all makes sense. So maybe rather than a macro or accepting barebones "921" values, if the value isn't 1024 (0), then it needs a comment + an expression computing the value. Seem reasonable? Jason