All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
To: Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de, Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>,
	Anatolij Gustschin <agust@denx.de>, Tom Rini <trini@konsulko.com>,
	Bin Meng <bmeng.cn@gmail.com>, Asherah Connor <ashe@kivikakk.ee>,
	Alexander Graf <agraf@csgraf.de>,
	Mark Kettenis <mark.kettenis@xs4all.nl>
Subject: Re: [PATCH v2 4/7] qfw: Add flag to allow probing before relocation
Date: Mon, 28 Aug 2023 18:22:31 +0300	[thread overview]
Message-ID: <347da6dc-7adb-48cc-afb7-a47ca621bb06@gmail.com> (raw)
In-Reply-To: <CAPnjgZ0uez=Wj+_G7nrz8iknuc_Tn56TdHjSS2R_73h5-FrJvA@mail.gmail.com>

On 2023-08-22 21:56 +03:00, Simon Glass wrote:
> Hi Alper,
> 
> On Tue, 22 Aug 2023 at 06:10, Alper Nebi Yasak <alpernebiyasak@gmail.com> wrote:
>>
>> QEMU firmware config drivers need to be probed to bind the ramfb device.
>> The ramfb driver needs to be bound before relocation to properly reserve
>> video memory for it, otherwise it cannot be probed after relocation. Add
>> the flag to probe QEMU firmware config drivers before relocation so that
>> ramfb can work as an initial vidconsole.
>>
>> Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
>> ---
>> Alternatively, I guess I could default VIDEO_PCI_DEFAULT_FB_SIZE to a
>> higher size with "if VIDEO_RAMFB". But it exists because "PCI drivers
>> cannot be bound before relocation unless they are mentioned in the
>> devicetree" and qfw is in the QEMU-generated devicetree unlike those, so
>> I assumed this would be the preferred way.
>>
>> Changes in v2:
>> - Add patch "qfw: Add flag to allow probing before relocation"
>>
>>  drivers/misc/qfw.c         | 1 +
>>  drivers/misc/qfw_mmio.c    | 1 +
>>  drivers/misc/qfw_pio.c     | 1 +
>>  drivers/misc/qfw_sandbox.c | 1 +
>>  4 files changed, 4 insertions(+)
>>
>> diff --git a/drivers/misc/qfw.c b/drivers/misc/qfw.c
>> index 4e4260982cce..265f45290011 100644
>> --- a/drivers/misc/qfw.c
>> +++ b/drivers/misc/qfw.c
>> @@ -414,6 +414,7 @@ UCLASS_DRIVER(qfw) = {
>>         .name           = "qfw",
>>         .post_bind      = qfw_post_bind,
>>         .per_device_auto        = sizeof(struct qfw_dev),
>> +       .flags = DM_FLAG_PRE_RELOC,
>>  };
> 
> Should we add this to the DT instead?

I've experimented a bit, and got something that works nice on x86
because we have the device-trees in-tree. So I can add something to
arch/x86/dts/qemu-*.dts like:

    / {
        fw-cfg {
            compatible = "qemu,fw-cfg-pio";
            bootph-some-ram;

            qfw-ramfb {
                compatible = "qemu,qfw-ramfb";
                bootph-some-ram;
            };
        };
    };

Then add the compatibles as .of_match to qfw_pio and ramfb drivers, call
dm_scan_fdt_dev(dev) in qfw_post_bind(), merge qfw_bind_ramfb() into the
ramfb driver probe, and it will work without the board_early_init_[fr]
hooks or these flags. That all seems to be fine.

The problem is other arches where QEMU generates a device-tree at
runtime and passes it to U-Boot with OF_BOARD. It has, on arm64 (and
with @10100000 instead on riscv64):

    fw-cfg@9020000 {
        dma-coherent;
        reg = <0x00 0x9020000 0x00 0x18>;
        compatible = "qemu,fw-cfg-mmio";
    };

As a proof of concept, I used `qemu-system-* -M dumpdtb=file.dtb` and
`dtc -I dtb -O dts` to replace the empty qemu dts files, then set
OF_BOARD=n and OF_OMIT_DTB=n, and added similar modifications to
qemu-*-u-boot.dtsi. And everything seems fine like that as well.

I think it can be automated in Makefile, but I don't think disabling
OF_BOARD is right here. I see there's OF_BOARD_FIXUP, so I guess I'll
try finding the fw-cfg node there and adding the bootph props and ramfb
nodes... Is this going the right way?

(And the pio/ramfb compatibles don't exist, do we have to use u-boot,*?)

> In the case where it isn't present it can return -EPERM.
> 
> Regards,
> Simon

  reply	other threads:[~2023-08-28 15:22 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-22 12:10 [PATCH v2 0/7] Add support for QEMU's ramfb display Alper Nebi Yasak
2023-08-22 12:10 ` [PATCH v2 1/7] qfw: Add WRITE definition Alper Nebi Yasak
2023-08-22 12:10 ` [PATCH v2 2/7] ramfb: Add driver for ramfb display Alper Nebi Yasak
2023-08-22 18:56   ` Simon Glass
2023-08-22 12:10 ` [PATCH v2 3/7] qfw: Spawn ramfb device if its file is present Alper Nebi Yasak
2023-08-22 18:56   ` Simon Glass
2023-08-28 10:33     ` Alper Nebi Yasak
2023-08-22 12:10 ` [PATCH v2 4/7] qfw: Add flag to allow probing before relocation Alper Nebi Yasak
2023-08-22 18:56   ` Simon Glass
2023-08-28 15:22     ` Alper Nebi Yasak [this message]
2023-08-28 15:27       ` Tom Rini
2023-08-22 12:10 ` [PATCH v2 5/7] arm: qemu: Enable ramfb by default Alper Nebi Yasak
2023-08-22 18:56   ` Simon Glass
2023-08-28 15:46     ` Alper Nebi Yasak
2023-08-28 17:54       ` Simon Glass
2023-08-28 18:28         ` Alper Nebi Yasak
2023-08-28 20:32           ` Alexander Graf
2023-08-28 20:38           ` Simon Glass
2023-08-28 20:56             ` Alexander Graf
2023-08-22 12:10 ` [PATCH v2 6/7] riscv: " Alper Nebi Yasak
2023-08-22 18:56   ` Simon Glass
2023-08-22 12:10 ` [PATCH v2 7/7] x86: " Alper Nebi Yasak
2023-08-22 18:56   ` Simon Glass
2023-08-28 15:40     ` Alper Nebi Yasak
2023-08-28 15:47       ` Tom Rini

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=347da6dc-7adb-48cc-afb7-a47ca621bb06@gmail.com \
    --to=alpernebiyasak@gmail.com \
    --cc=agraf@csgraf.de \
    --cc=agust@denx.de \
    --cc=ashe@kivikakk.ee \
    --cc=bmeng.cn@gmail.com \
    --cc=mark.kettenis@xs4all.nl \
    --cc=rayagonda.kokatanur@broadcom.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=tuomas.tynkkynen@iki.fi \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /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.