All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "Kevin Wolf" <kwolf@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	Qemu-block <qemu-block@nongnu.org>,
	"Havard Skinnemoen" <hskinnemoen@google.com>,
	"QEMU Developers" <qemu-devel@nongnu.org>,
	"CS20 KFTing" <kfting@nuvoton.com>,
	qemu-arm <qemu-arm@nongnu.org>, "Cédric Le Goater" <clg@kaod.org>,
	"IS20 Avi Fishman" <Avi.Fishman@nuvoton.com>
Subject: Re: [PATCH v5 10/11] hw/arm: Wire up BMC boot flash for npcm750-evb and quanta-gsj
Date: Wed, 15 Jul 2020 11:00:01 +0200	[thread overview]
Message-ID: <87pn8xywz2.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <e87663cf-7cb2-ca6c-a751-e5c1cebc5440@amsat.org> ("Philippe =?utf-8?Q?Mathieu-Daud=C3=A9=22's?= message of "Tue, 14 Jul 2020 19:16:35 +0200")

Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> On 7/14/20 6:21 PM, Markus Armbruster wrote:
>> Philippe Mathieu-Daudé <f4bug@amsat.org> writes:
>> 
>>> + qemu-block experts.
>>>
>>> On 7/14/20 11:16 AM, Markus Armbruster wrote:
>>>> Havard Skinnemoen <hskinnemoen@google.com> writes:
>>>>
>>>>> On Mon, Jul 13, 2020 at 7:57 AM Cédric Le Goater <clg@kaod.org> wrote:
>>>>>>
>>>>>> On 7/9/20 2:36 AM, Havard Skinnemoen wrote:
>>>>>>> This allows these NPCM7xx-based boards to boot from a flash image, e.g.
>>>>>>> one built with OpenBMC. For example like this:
>>>>>>>
>>>>>>> IMAGE=${OPENBMC}/build/tmp/deploy/images/gsj/image-bmc
>>>>>>> qemu-system-arm -machine quanta-gsj -nographic \
>>>>>>>       -bios ~/qemu/bootrom/npcm7xx_bootrom.bin \
>>>>>>>       -drive file=${IMAGE},if=mtd,bus=0,unit=0,format=raw,snapshot=on
>>>>>>>
>>>>>>> Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
>>>>>>> Signed-off-by: Havard Skinnemoen <hskinnemoen@google.com>
>>>>>>
>>>>>> May be we don't need to create the flash object if dinfo is NULL.
>>>>>
>>>>> It's soldered on the board, so you can't really boot the board without
>>>>> it. But if you think it's better to remove it altogether if we don't
>>>>> have an image to load into it, I can do that.
>>>>
>>>> If a device is a fixed part of the physical board, it should be a fixed
>>>> part of the virtual board, too.
>>>
>>> We agree so far but ... how to do it?
>>>
>>> I never used this API, does that makes sense?
>>>
>>>     if (!dinfo) {
>>>         QemuOpts *opts;
>>>
>>>         opts = qemu_opts_create(NULL, "spi-flash", 1, &error_abort);
>>>         qdict_put_str(opts, "format", "null-co");
>>>         qdict_put_int(opts, BLOCK_OPT_SIZE, 64 * MiB);
>>>         qdict_put_bool(opts, NULL_OPT_ZEROES, false); // XXX
>>>
>>>         dinfo = drive_new(opts, IF_MTD, &error_abort);
>>>         qemu_opts_del(opts);
>>>     }
>> 
>> I believe existing code special-cases "no backend" instead of making one
>> up.
>> 
>> Example: pflash_cfi0?.c
>> 
>> If ->blk is non-null, we read its contents into the memory buffer and
>> write updates back, else we leave it blank and don't write updates back.
>> 
>> Making one up could be more elegant.  To find out, you have to try.
>
> I'd rather avoid ad-hoc code in each device. I2C EEPROM do that too,
> it is a source of head aches.
>
>>From the emulation PoV I'd prefer to always use a block backend,
> regardless the user provide a drive.
>
>> 
>> We make up a few default drives (i.e. drives the user doesn't specify):
>> floppy, CD-ROM and SD card.  Ancient part of the user interface, uses
>> DriveInfo.  I doubt we should create more of them.
>> 
>> I believe block backends we make up for internal use should stay away
>> from DriveInfo.  Kevin, what do you think?  How would you make up a
>> null-co block backend for a device's internal use?
>
> I read 'DriveInfo' is the legacy interface, but all the code base use it
> so it is confusing, I don't understand what is the correct interface to
> use.

I admit the "legacy" bit is still aspirational.  We still haven't
managed to replace it for configuring certain onboard devices.

The thing being configured is a device's BlockBackend.

To understand the point I'm trying to make, please ignore "legacy", and
focus on the actual purpose of DriveInfo: it's (one kind of) user
configuration for a BlockBackend.

Now let me try to state the problem you're trying to solve.  Instead of
special-casing "no backend" in device code like pflash_cfi0?.c do, you
want to make up a "dummy" backend instead.  You need the dummy to read
some blank value and ignore writes.  One of the null block drivers
should fit the bill.

Now my point.  Why first make up user configuration, then use that to
create a BlockBackend, when you could just go ahead and create the
BlockBackend?

Sadly, I'm not sufficiently familiar with the block API anymore to tell
you exactly how.  blk_new_with_bs() looks promising.  Perhaps Kevin can
advise.

>>> We should probably add a public helper for that.
>> 
>> If we decide we want to make up backends, then yes, we should do that in
>> a helper, not in each device.
>> 
>>> 'XXX' because NOR flashes erase content is when hardware bit
>>> is set, so it would be more useful to return -1/0xff... rather
>>> than zeroes.



  reply	other threads:[~2020-07-15  9:01 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-09  0:35 [PATCH v5 00/11] Add Nuvoton NPCM730/NPCM750 SoCs and two BMC machines Havard Skinnemoen
2020-07-09  0:35 ` [PATCH v5 01/11] hw/misc: Add NPCM7xx System Global Control Registers device model Havard Skinnemoen
2020-07-09  6:04   ` Philippe Mathieu-Daudé
2020-07-09  6:43     ` Havard Skinnemoen
2020-07-09 16:23       ` Philippe Mathieu-Daudé
2020-07-09 17:09         ` Havard Skinnemoen
2020-07-09 17:24           ` Philippe Mathieu-Daudé
2020-07-09 17:42             ` Havard Skinnemoen
2020-07-10  9:31               ` Philippe Mathieu-Daudé
2020-07-11  6:46                 ` Havard Skinnemoen
2020-07-12  5:49                   ` Havard Skinnemoen
2020-07-09  0:35 ` [PATCH v5 02/11] hw/misc: Add NPCM7xx Clock Controller " Havard Skinnemoen
2020-07-15  7:18   ` Philippe Mathieu-Daudé
2020-07-09  0:36 ` [PATCH v5 03/11] hw/timer: Add NPCM7xx Timer " Havard Skinnemoen
2020-07-15  7:25   ` Philippe Mathieu-Daudé
2020-07-15 23:04     ` Havard Skinnemoen
2020-07-16  8:04       ` Philippe Mathieu-Daudé
2020-07-09  0:36 ` [PATCH v5 04/11] hw/arm: Add NPCM730 and NPCM750 SoC models Havard Skinnemoen
2020-07-09  6:11   ` Philippe Mathieu-Daudé
2020-07-13 15:02   ` Cédric Le Goater
2020-07-14  0:44     ` Havard Skinnemoen
2020-07-14 11:37       ` Philippe Mathieu-Daudé
2020-07-14 16:01         ` Markus Armbruster
2020-07-14 17:11           ` Philippe Mathieu-Daudé
2020-07-15  1:03             ` Havard Skinnemoen
2020-07-15  9:35               ` Markus Armbruster
2020-07-09  0:36 ` [PATCH v5 05/11] hw/arm: Add two NPCM7xx-based machines Havard Skinnemoen
2020-07-09  5:57   ` Philippe Mathieu-Daudé
2020-07-09  6:09     ` Philippe Mathieu-Daudé
2020-07-09  0:36 ` [PATCH v5 06/11] hw/arm: Load -bios image as a boot ROM for npcm7xx Havard Skinnemoen
2020-07-13 17:50   ` Philippe Mathieu-Daudé
2020-07-09  0:36 ` [PATCH v5 07/11] hw/nvram: NPCM7xx OTP device model Havard Skinnemoen
2020-07-09  0:36 ` [PATCH v5 08/11] hw/mem: Stubbed out NPCM7xx Memory Controller model Havard Skinnemoen
2020-07-09 16:29   ` Philippe Mathieu-Daudé
2020-07-09  0:36 ` [PATCH v5 09/11] hw/ssi: NPCM7xx Flash Interface Unit device model Havard Skinnemoen
2020-07-09 17:00   ` Philippe Mathieu-Daudé
2020-07-12  5:42     ` Havard Skinnemoen
2020-07-13 17:38       ` Philippe Mathieu-Daudé
2020-07-14  2:39         ` Havard Skinnemoen
2020-07-09  0:36 ` [PATCH v5 10/11] hw/arm: Wire up BMC boot flash for npcm750-evb and quanta-gsj Havard Skinnemoen
2020-07-13 14:57   ` Cédric Le Goater
2020-07-13 17:59     ` Philippe Mathieu-Daudé
2020-07-13 18:02       ` Philippe Mathieu-Daudé
2020-07-14  2:56     ` Havard Skinnemoen
2020-07-14  9:16       ` Markus Armbruster
2020-07-14 11:29         ` Philippe Mathieu-Daudé
2020-07-14 16:21           ` Markus Armbruster
2020-07-14 17:16             ` Philippe Mathieu-Daudé
2020-07-15  9:00               ` Markus Armbruster [this message]
2020-07-15 10:57                 ` Philippe Mathieu-Daudé
2020-07-15 20:54                   ` Havard Skinnemoen
2020-07-16 20:56                     ` Havard Skinnemoen
2020-07-17  7:48                       ` Philippe Mathieu-Daudé
2020-07-17  8:03                         ` Thomas Huth
2020-07-17  8:27                           ` Philippe Mathieu-Daudé
2020-07-17  9:00                             ` Philippe Mathieu-Daudé
2020-07-17 19:18                               ` Havard Skinnemoen
2020-07-17 20:21                                 ` Cédric Le Goater
2020-07-17 20:52                                 ` Philippe Mathieu-Daudé
2020-07-17 20:57                                   ` Havard Skinnemoen
2020-07-20  7:58                               ` Markus Armbruster
2020-07-15  7:42       ` Cédric Le Goater
2020-07-15 21:19         ` Havard Skinnemoen
2020-07-09  0:36 ` [PATCH v5 11/11] docs/system: Add Nuvoton machine documentation Havard Skinnemoen

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=87pn8xywz2.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=Avi.Fishman@nuvoton.com \
    --cc=clg@kaod.org \
    --cc=f4bug@amsat.org \
    --cc=hskinnemoen@google.com \
    --cc=kfting@nuvoton.com \
    --cc=kwolf@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@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 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.