From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by mx.groups.io with SMTP id smtpd.web12.5940.1574860638375735228 for ; Wed, 27 Nov 2019 05:17:18 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=DfgLeQIp; spf=pass (domain: linaro.org, ip: 209.85.221.67, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-wr1-f67.google.com with SMTP id s5so26627519wrw.2 for ; Wed, 27 Nov 2019 05:17:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ufla6W0TVEJcQHgapVUxcU6l/OMcpD1iR35efqcrqzQ=; b=DfgLeQIp+MFu4Hd4XrowLuKETq4y0N+ooGh5yTLfqmBfyMS0kqOlDDmjjJk+O2TBv4 DiebggW3flDsNJgUDjzylfpbvl/xlsSBqliU9c+fgA3RsK2PwsESuthNm27+QS4deiGv Sbfe13XU9hkPivKyYK+g2XcZkCHnZsBRMi0LcRJk2nVqHqY2ktTNr9ik4BbNNos7Djg2 3OVk3beu/XhMtAXzeY5LiGoBwynjI/zuXB9OgI9v/CiakOhWI8srmnB3JoFARwy97+Q4 s4XYxq6GbTE1VExHTC2wzE8mAnSkMisGNAY1kNyurkzNUjA5/PXTFbMZ4mKjDugOd4uS SK7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ufla6W0TVEJcQHgapVUxcU6l/OMcpD1iR35efqcrqzQ=; b=YfwbpN8agAXipKQMKf7fyfx/OMlHtrEgIPURqyQDf9W7Zlr0mAdO6efCMtvxJblHlc /cf0clIDmmkSpZD3CGrsY5OnNawMEZ5IQN0UBN+Bm6Z+6swfW3NdAXp4a5DXcX/R7IB1 8aEG0bnpTLFsxbvAvzUlNNKWYFSvf0PpXqjyL6Q8NxuD7cQK0p2PDcQh+KKKFaNevITx NH9VUXCYvewLjQ+wfRv8aRzPN0hPWlLIGfDL2TdOBXLVD3YjihjBJvnhBVckkbvPRHJE dXwgKyrMRZC8Jfpmv/yUB5cCudL6TNrom0RV5w9LmWOaw1ikDYFp2jlfEs83TWp8pbw2 V2qg== X-Gm-Message-State: APjAAAW1H9Y+WhnRSwu92IClkDpWC1kz9Uq0dMLwH8cQgXjcw4EDPNNv rhNB23jUVUqQkPcYebh1iqyBDQyIlbnKYFT39/z0OQ== X-Google-Smtp-Source: APXvYqyL6otKDnijeOf7NNTbgpuUFhbHJ9GgEc63ceewg6DYveKbRHqLjw54+HcQxAvpdgOPBFilG2/viPigV5VJtt0= X-Received: by 2002:a5d:6652:: with SMTP id f18mr777143wrw.246.1574860636886; Wed, 27 Nov 2019 05:17:16 -0800 (PST) MIME-Version: 1.0 References: <20191127123706.4604-1-pete@akeo.ie> <20191127123706.4604-2-pete@akeo.ie> In-Reply-To: From: "Ard Biesheuvel" Date: Wed, 27 Nov 2019 14:17:05 +0100 Message-ID: Subject: Re: [edk2-platforms][PATCH 1/5] Silicon/Bcm283x: Clean up Bcm2836.h header To: Pete Batard Cc: edk2-devel-groups-io , Leif Lindholm , =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= , samer.el-haj-mahmoud@arm.com, "Andrei E. Warkentin" Content-Type: text/plain; charset="UTF-8" On Wed, 27 Nov 2019 at 14:09, Pete Batard wrote: > > On 2019.11.27 13:00, Ard Biesheuvel wrote: > > On Wed, 27 Nov 2019 at 13:56, Pete Batard wrote: > >> > >> On 2019.11.27 12:48, Ard Biesheuvel wrote: > >>> On Wed, 27 Nov 2019 at 13:37, Pete Batard wrote: > >>>> > >>>> Add missing RNG registers, prefer reusing shorter define's > >>>> instead of PCDs and clean up spacing. > >>>> > >>> > >>> Is there a source for these register definitions? > >> > >> I used the most recent Linux driver I could find (but I guess I need to > >> point out that it was used for reference with regards to the registers. > >> Especially, no code was copied from that source). > >> > >>> It seems the Linux > >>> driver deviates from the below (and the warmup count thing uses the > >>> status register as well), so it would be helpful to quote the > >>> authoritative reference here. > >> > >> https://github.com/raspberrypi/linux/blob/rpi-5.4.y/drivers/char/hw_random/iproc-rng200.c#L223-L224 > >> seems to indicate that RNG_WARMUP_COUNT (0x40000) should go into > >> RNG_TOTAL_BIT_COUNT_THRESHOLD_OFFSET (them) / RNG_BIT_COUNT_THRESHOLD > >> (us) and not the status register. > >> > >> Now, of course, since we don't have a public datasheet, it's hard to > >> have absolute certainty on what's the proper register to write, but I > >> guess the most recent code with a Broadcom Corporation copyright has to > >> our next best thing when it comes to authoritative answer... > >> > > > > Well, there is this one too > > > > https://github.com/raspberrypi/linux/blob/rpi-5.4.y/drivers/char/hw_random/bcm2835-rng.c > > > > which is what I used as the basis for the existing version. > > Okay. Looks like 2835 (which has to be the basis for the Bcm2837 used on > the Pi 3) and 2838 (basis for Bcm2711) have at least one difference with > regards to where the warmup count should go. > > I guess an easy fix, if we don't want to have to spin 2 separate > drivers, is to write to both RNG_STATUS and RNG_BIT_COUNT_THRESHOLD > during init. > > I have tested on Pi 3 and not seen any ill effect to writing to > RNG_BIT_COUNT_THRESHOLD. > I don't like that at all tbh. A misbehaving RNG is virtually undetectable (unless it starts returning zeroes), so knowingly deviating from the initialization routines like that should really be avoided. > Would something like this work for you in a v2? > > Alternatively, I could change the new PcdBcm283xRngUseFifo PCD to > PcdBcm283xRng2838Compatible and use that for the conditional code. > These are two different IP blocks, with different register layouts etc, so I don't really see the point in parameterizing the existing driver like that. I'd prefer it if we could just clone the existing one and make the changes unconditionally.