qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Palmer Dabbelt <palmerdabbelt@google.com>
To: alistair23@gmail.com
Cc: david@gibson.dropbear.id.au,
	Peter Maydell <peter.maydell@linaro.org>,
	palmer@sifive.com, Christoph Hellwig <hch@infradead.org>,
	qemu-riscv@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH] RISC-V: virt: This is a "sifive,test1" test finisher
Date: Thu, 21 Nov 2019 11:06:04 -0800 (PST)	[thread overview]
Message-ID: <mhng-4aa5b4bf-df3d-41c9-a597-3396a5626422@palmerdabbelt.mtv.corp.google.com> (raw)
In-Reply-To: <CAKmqyKNTUNMvxxBdE4kZA44a=d9bPWCkrG9ScUp89MkHFteciQ@mail.gmail.com>

On Thu, 21 Nov 2019 10:55:32 PST (-0800), alistair23@gmail.com wrote:
> On Wed, Nov 20, 2019 at 6:40 PM Palmer Dabbelt <palmerdabbelt@google.com> wrote:
>>
>> On Sun, 10 Nov 2019 13:10:33 PST (-0800), david@gibson.dropbear.id.au wrote:
>> > On Fri, Nov 08, 2019 at 10:13:16AM -0800, Palmer Dabbelt wrote:
>> >> On Fri, 08 Nov 2019 10:04:47 PST (-0800), Peter Maydell wrote:
>> >> > On Fri, 8 Nov 2019 at 17:15, Alistair Francis <alistair23@gmail.com> wrote:
>> >> > >
>> >> > > On Fri, Nov 8, 2019 at 9:05 AM Palmer Dabbelt <palmer@sifive.com> wrote:
>> >> > > >
>> >> > > > The test finisher implements the reset command, which means it's a
>> >> > > > "sifive,test1" device.  This is a backwards compatible change, so it's
>> >> > > > also a "sifive,test0" device.  I copied the odd idiom for adding a
>> >> > > > two-string compatible field from the ARM virt board.
>> >> > > >
>> >> > > > Fixes: 9a2551ed6f ("riscv: sifive_test: Add reset functionality")
>> >> > > > Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
>> >> > > > Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com>
>> >> > > > ---
>> >> > > >  hw/riscv/virt.c | 5 ++++-
>> >> > > >  1 file changed, 4 insertions(+), 1 deletion(-)
>> >> > > >
>> >> > > > diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
>> >> > > > index 23f340df19..74f2dce81c 100644
>> >> > > > --- a/hw/riscv/virt.c
>> >> > > > +++ b/hw/riscv/virt.c
>> >> > > > @@ -359,7 +359,10 @@ static void create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
>> >> > > >      nodename = g_strdup_printf("/test@%lx",
>> >> > > >          (long)memmap[VIRT_TEST].base);
>> >> > > >      qemu_fdt_add_subnode(fdt, nodename);
>> >> > > > -    qemu_fdt_setprop_string(fdt, nodename, "compatible", "sifive,test0");
>> >> > > > +    {
>> >> > > > +        const char compat[] = "sifive,test1\0sifive,test0";
>> >> > >
>> >> > > Does this really work? Why not use qemu_fdt_setprop_cells()?
>> >> > >
>> >> > > Alistair
>> >> > >
>> >> > > > +        qemu_fdt_setprop(fdt, nodename, "compatible", compat, sizeof(compat));
>> >> > > > +    }
>> >> >
>> >> > qemu_fdt_setprop_cells() is for "set this property to
>> >> > contain this list of 32-bit integers" (and it does a byteswap
>> >> > of each 32-bit value from host to BE). That's not what
>> >> > you want for a string (or a string list, which is what
>> >> > we have here).
>> >> >
>> >> > Cc'ing David Gibson who's our device tree expert to see if there's
>> >> > a nicer way to write this. Oddly, given that it's used in the
>> >> > ubiquitous 'compatible' prop, the dtc Documentation/manual.txt
>> >> > doesn't say anything about properties being able to be
>> >> > 'string lists', only 'strings', '32 bit numbers', 'lists of
>> >> > 32-bit numbers' and 'byte sequences'. You have to dig through
>> >> > the header file comments to deduce that a string list is
>> >> > represented by a string with embedded NULs separating
>> >> > each list item.
>> >>
>> >> I copied this from hw/arm/virt.c, but messed up.  There they use
>> >>
>> >>        const char compat[] = "arm,armv8-timer\0arm,armv7-timer";
>> >>        qemu_fdt_setprop(vms->fdt, "/timer", "compatible",
>> >>                         compat, sizeof(compat));
>> >
>> > I'm not sure what you're saying is messed up.  AFAICT, this matches
>> > the code you have above, and both should be correct.
>>
>> Sorry, I must have been hallucinating.  For some reason I though I wrote
>> qemu_fdt_setprop_string(... compat).
>>
>> I'd like to take this for 4.2 if possible, but I don't think I have a
>> reviewed-by (I just got my email set up on my Google computer, so it might be
>> messy for a bit).  I'm happy to submit the cleaner valist version after 4.2, as
>> per Peter's suggestion.
>>
>> Alistair: are you OK with this?
>
> Yeah, that works for me.
>
> For 5.0 we can then merge Anup's patch and your series improving the
> multi compat support.

Sounds good.  I think the syscon driver is the right way to go, but I don't
think it's 4.2 material as it's all a bit late.  This one at least fixes the
bug where the DTS and hardware don't match.

> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
>
> Alistair
>
>>
>> >> I'll send a v2, but I'd be happy to add some sort of setprop_stringlist
>> >> function.  Maybe we just indicate the length with two '\0's?  IIRC that's
>> >> how other similar-looking data structures are encoded.
>> >>
>> >
>> > --
>> > David Gibson                  | I'll have my music baroque, and my code
>> > david AT gibson.dropbear.id.au        | minimalist, thank you.  NOT _the_ _other_
>> >                               | _way_ _around_!
>> > http://www.ozlabs.org/~dgibson


  reply	other threads:[~2019-11-21 19:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-07 22:25 [PATCH] RISC-V: virt: This is a "sifive,test1" test finisher Palmer Dabbelt
2019-11-08 17:13 ` Alistair Francis
2019-11-08 18:04   ` Peter Maydell
2019-11-08 18:13     ` Palmer Dabbelt
2019-11-10 21:10       ` David Gibson
2019-11-21  2:40         ` Palmer Dabbelt
2019-11-21 18:55           ` Alistair Francis
2019-11-21 19:06             ` Palmer Dabbelt [this message]
2019-11-10 21:09     ` David Gibson

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=mhng-4aa5b4bf-df3d-41c9-a597-3396a5626422@palmerdabbelt.mtv.corp.google.com \
    --to=palmerdabbelt@google.com \
    --cc=alistair23@gmail.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=hch@infradead.org \
    --cc=palmer@sifive.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).