From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by mx.groups.io with SMTP id smtpd.web10.5931.1574860912475725794 for ; Wed, 27 Nov 2019 05:21:52 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=fWvQU7pY; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.128.66, mailfrom: pete@akeo.ie) Received: by mail-wm1-f66.google.com with SMTP id j18so4893615wmk.1 for ; Wed, 27 Nov 2019 05:21:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akeo-ie.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=/O2ULZ4OsQumzjMd17JRMirJwffBAhC5D81sl44ZLB8=; b=fWvQU7pYIhu1340YinFn0t5fvyudx35OV+N1XhfR9m9ee784KiWpbnyKLm/QOhDRFu hD6SkQP40qOeMA1WZ1/Sr0CRmUAdi5SoCtJ9tTOb/d3rPtA8TIGtFd9K6pVEP+N6KTHG 2IbQbx3ug/Vmexz3wHHtZbkCgQ+np9/SFw3F5pdoxvjIJkwKyhZGgSfCibPpnvfj55/Y 5XDmTxT06CNef3CgJAKE0txrMqR6Rk6W8XaATFmnmYqb1gSRHoiuV0BIBX7+i2+mfLCi EY6qrBcPPWpawLKRR7hwLmx9N0fTv5i4Pvxboo3ibFkVFa4LgSvkFT6pKcrozlqBJE4B q46g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=/O2ULZ4OsQumzjMd17JRMirJwffBAhC5D81sl44ZLB8=; b=dAWgEf3Asi700HUiNjGznQW0eEpBNnEV5b0HilIJG7rBJZM90J0KkdrODfG0kCXuBX h4uViemFBc8tm0uEz9yPFmsfSeHb3oJDLk4UdjxZAZ0keZhmSdSo0iHEgemwphiLmPwD jvN/O099L9st3JVxr1yRcNvOVrlYpCwR2vlh32fr7MdmvQYR6ypYV6Exj83MCF2Udcgo W3tSwzJHrRpEceBI738pvur2diYHdKtKK7M4u1z2CmgxoT8lcesXdHKchLngPPK3Gkmx ZJ0OSP0S0MYvFNkFNErcOWojsgj56harySkxSlzrz/lYtaQcfr8pNztDAaDPzxGjYZFG pQ5A== X-Gm-Message-State: APjAAAXm0xmBkeC2ZJndcVNiwvWGmLGeuf2enYcB0O8Kys83RPU3KNSI YwQzFzhUk14Rp9RaKIhzR+KrEg== X-Google-Smtp-Source: APXvYqwLmkojT2Trc0+yn/RuZSzn7Yq7+jVWNP8FqiiheBLUFq+oPFnMeAajjG3tKFZq+A1g1pLVyQ== X-Received: by 2002:a1c:20c6:: with SMTP id g189mr4632937wmg.6.1574860910977; Wed, 27 Nov 2019 05:21:50 -0800 (PST) Return-Path: Received: from [10.0.0.122] ([84.203.37.1]) by smtp.googlemail.com with ESMTPSA id 5sm6539780wmk.48.2019.11.27.05.21.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Nov 2019 05:21:49 -0800 (PST) Subject: Re: [edk2-platforms][PATCH 1/5] Silicon/Bcm283x: Clean up Bcm2836.h header To: Ard Biesheuvel Cc: edk2-devel-groups-io , Leif Lindholm , =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= , samer.el-haj-mahmoud@arm.com, "Andrei E. Warkentin" References: <20191127123706.4604-1-pete@akeo.ie> <20191127123706.4604-2-pete@akeo.ie> From: "Pete Batard" Message-ID: <7bfe2750-7a4b-d559-5d21-0bbab5d1733b@akeo.ie> Date: Wed, 27 Nov 2019 13:21:48 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit On 2019.11.27 13:17, Ard Biesheuvel wrote: > 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. Okay. I was pretty much expecting that answer... Regards, /Pete