From: Tom Rini <trini@konsulko.com>
To: Simon Glass <sjg@chromium.org>
Cc: "Dan Carpenter" <dan.carpenter@linaro.org>,
"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
"Yixun Lan" <dlan@gentoo.org>, "Huan Zhou" <me@per1cycle.org>,
u-boot@lists.denx.de, "Ben Dooks" <ben.dooks@codethink.co.uk>,
"Marcel Ziswiler" <marcel@ziswiler.com>,
"Bin Meng" <bmeng@tinylab.org>,
"Frieder Schrempf" <frieder.schrempf@kontron.de>,
"Jonas Schwöbel" <jonasschwoebel@yahoo.de>,
"Kever Yang" <kever.yang@rock-chips.com>,
Leo <ycliang@andestech.com>,
"Michal Simek" <michal.simek@amd.com>,
"Nishanth Menon" <nm@ti.com>,
"Quentin Schulz" <quentin.schulz@cherry.de>,
Randolph <randolph@andestech.com>,
"Rick Chen" <rick@andestech.com>,
"Samuel Holland" <samuel@sholland.org>,
"Sumit Garg" <sumit.garg@linaro.org>,
"Svyatoslav Ryhel" <clamor95@gmail.com>,
"Yu Chien Peter Lin" <peterlin@andestech.com>,
"Huan Zhou" <pericycle.cc@gmail.com>,
"Kongyang Liu" <seashell11234455@gmail.com>,
"Padmarao Begari" <padmarao.begari@amd.com>
Subject: Re: [PATCH] riscv: spacemit: k1: probe dram size during boot phase.
Date: Wed, 8 Jan 2025 11:15:10 -0600 [thread overview]
Message-ID: <20250108171510.GK3476@bill-the-cat> (raw)
In-Reply-To: <CAFLszTg4e8M01fScjjzhKvbG7AzgbTiZ3RgnzTvZN4-WZafPLA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2986 bytes --]
On Wed, Jan 08, 2025 at 10:03:08AM -0700, Simon Glass wrote:
> Hi Dan,
>
> On Wed, 8 Jan 2025 at 05:37, Dan Carpenter <dan.carpenter@linaro.org> wrote:
> >
> > On Wed, Jan 08, 2025 at 12:21:18PM +0100, Heinrich Schuchardt wrote:
> > > Am 8. Januar 2025 12:11:05 MEZ schrieb Yixun Lan <dlan@gentoo.org>:
> > > >Hi Huan:
> > > >
> > > >On 16:49 Wed 08 Jan , Huan Zhou wrote:
> > > >>
> > > >>
> > > >..
> > > >> ---
> > > >remove above "---"? otherwise following commit message will be
> > > >dropped during patch application..
> > > >
> > > >> This patch introduce improvement for get dram size on bananapi BPI-F3,
> > > >> retrieving the dram size dynamically.
> > > >> Have tested on bananapi BPIF3 4G and jupiter 8G.
> > > >>
> > > >> Signed-off-by: Huan Zhou <me@per1cycle.org>
> > > >> ---
> > > >> arch/riscv/cpu/k1/dram.c | 40 ++++++++++++++++++++++++++++++++++++++--
> > > >> 1 file changed, 38 insertions(+), 2 deletions(-)
> > > >>
> > > >> diff --git a/arch/riscv/cpu/k1/dram.c b/arch/riscv/cpu/k1/dram.c
> > > >> index c477c15cbfb19f0e3a0ee72985b602f5bda352d7..095217f2a4c053f7477d62c0776bcb51e623db47 100644
> > > >> --- a/arch/riscv/cpu/k1/dram.c
> > > >> +++ b/arch/riscv/cpu/k1/dram.c
> > > >> @@ -4,17 +4,53 @@
> > > >> */
> > > >>
> > > >> #include <asm/global_data.h>
> > > >> +#include <asm/io.h>
> > > >> #include <config.h>
> > > >> +#include <bitfield.h>
> > > >> #include <fdt_support.h>
> > > >> #include <linux/sizes.h>
> > > >>
> > > >> +#define DDR_BASE 0xC0000000
> > > >> DECLARE_GLOBAL_DATA_PTR;
> > > >>
> > > >> +static inline u32 map_format_size(u32 val)
> > > >> +{
> > > >> + u32 tmp;
> > > >> +
> > > >> + if (val & 0x1 == 0)
> > > >please add brackets explicitly, something like
> > > > if ((val & 0x1) == 0)
> > >
> > > We tend to avoid == 0 in U-Boot
> > >
> > > if (val & BIT(0))
> > >
> >
> > That's reversed.
> >
> > if (!(val & BIT(0)) {
> >
> > I have really complicated rules about when to use ! vs == 0.
> > https://staticthinking.wordpress.com/2024/02/20/when-to-use-0/
>
> I mostly agree with that and it provides some motivation for the
> conventions which have built up over the years in Linux/U-Boot/etc.
>
> If you want to send a patch:
>
> $ git grep 'if (ret != EFI_SUCCESS)' |wc
> 864 4841 51380
>
> I think the only place I would differ is with strcmp(), where I've got
> used to 0 meaning success, like in much other code.
To be clear here, we have ~900 examples of EFI_SUCCESS and ~250 examples
of other FOO_SUCCESS type tests. And if we're going to make some sort of
change here, we should (a) document it and (b) fix it everywhere.
And at the risk of confusing your intentions Simon, Dan has a well
deserved reputation in the Linux kernel for fixing what I would call "C
is trickier than you think, even if you're been doing it for decades"
bugs so just changing EFI code would be silly.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
next prev parent reply other threads:[~2025-01-08 17:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-08 8:49 [PATCH] riscv: spacemit: k1: probe dram size during boot phase Huan Zhou
2025-01-08 11:11 ` Yixun Lan
2025-01-08 11:21 ` Heinrich Schuchardt
2025-01-08 11:51 ` Huan Zhou
2025-01-08 12:37 ` Dan Carpenter
2025-01-08 12:44 ` Huan Zhou
2025-01-08 17:03 ` Simon Glass
2025-01-08 17:15 ` Tom Rini [this message]
2025-01-08 17:18 ` Dan Carpenter
2025-01-09 12:36 ` Simon Glass
2025-01-08 11:21 ` Huan Zhou
2025-01-08 11:36 ` Huan Zhou
2025-01-10 17:34 ` Marcel Ziswiler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250108171510.GK3476@bill-the-cat \
--to=trini@konsulko.com \
--cc=ben.dooks@codethink.co.uk \
--cc=bmeng@tinylab.org \
--cc=clamor95@gmail.com \
--cc=dan.carpenter@linaro.org \
--cc=dlan@gentoo.org \
--cc=frieder.schrempf@kontron.de \
--cc=jonasschwoebel@yahoo.de \
--cc=kever.yang@rock-chips.com \
--cc=marcel@ziswiler.com \
--cc=me@per1cycle.org \
--cc=michal.simek@amd.com \
--cc=nm@ti.com \
--cc=padmarao.begari@amd.com \
--cc=pericycle.cc@gmail.com \
--cc=peterlin@andestech.com \
--cc=quentin.schulz@cherry.de \
--cc=randolph@andestech.com \
--cc=rick@andestech.com \
--cc=samuel@sholland.org \
--cc=seashell11234455@gmail.com \
--cc=sjg@chromium.org \
--cc=sumit.garg@linaro.org \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
--cc=ycliang@andestech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.