public inbox for chrome-platform@lists.linux.dev
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Julius Werner <jwerner@chromium.org>
Cc: tzungbi@kernel.org, briannorris@chromium.org, javierm@redhat.com,
	maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	airlied@gmail.com, simona@ffwll.ch,
	chrome-platform@lists.linux.dev, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/8] firmware: google: Do sysfb test before creating coreboot framebuffer
Date: Fri, 9 Jan 2026 10:17:22 +0100	[thread overview]
Message-ID: <9d9015fa-aba4-4dd7-a024-563f58b7f43a@suse.de> (raw)
In-Reply-To: <CAODwPW9_ym3E4za3yoUAs0+1sQfaKTDOau4Oh9Zm8+2uvYVgFQ@mail.gmail.com>

Hi

Am 08.01.26 um 17:55 schrieb Julius Werner:
> This seems less consistent to me, although tbh I don't understand the
> Linux device and driver framework that well. I think the original idea
> here was that the coreboot bus represents the coreboot table, and each
> entry is represented as one device (regardless of whether any driver
> actually wants to do anything with that entry). That's why we're
> creating a device for all the tags even though most of them aren't
> really interesting for kernel drivers. This also helps with inspecting
> things in sysfs.

We need to distinguish between coreboot and sysfb. Only one of these 
subsystems can handle the framebuffer. Having a framebuffer device on 
the coreboot bus, if the underlying framebuffer is managed by a 
different device seems even more incorrect.

>
> So the device with TAG_FRAMEBUFFER doesn't mean that we have a
> framebuffer, it just means that we have an entry in the table
> describing a framebuffer. Whether it should actually be used to set up
> a framebuffer should be up to the binding driver. That's why I think
> keeping this decision in the driver probe makes more sense, and
> excluding it from the devices on the bus is weird (because you're just
> randomly excluding one of the entries in the table from being
> represented like the others, just because of details about how its
> drivers would want to use it).
>
> If you want these devices to be bound by drivers outside this
> directory, then I think either that other driver needs to have the
> logic to decide when a coreboot framebuffer should actually be used,
> or maybe you should have a small stub driver in this directory that
> binds to the list entry device, makes the decision whether to actually
> use it, and if so creates a sub-device or something (if that's
> possible?) which the actual outside driver can find and bind to.

This is what the current code in framebuffer-coreboot.c does. It binds 
to the coreboot-framebuffer device and create another device for 
external DRM/fbdev drivers to handle. This is problematic, as

1) the additional device will be gone after the native hardware drivers 
takes over the display, so the pdev pointer at [1] is dangling. 
Apparently no one ever unloads the coreboot-framebuffer device to 
trigger this problem.

2) The corboot-framebuffer device sets itself as the external device's 
parent. This is incorrect. The framebuffer exists on top of a PCI 
graphics device, so that device should be the parent. Otherwise the user 
can hot-unplug the PCI hardware and the coreboot framebuffer operates on 
a bogus graphics aperture. Modeling the parent-child relationships 
correctly, avoids this problem.  We've seen these problems with 
UEFI/VESA framebuffers and fixed it accordingly. [2] Something similar 
should be done for coreboot. Coreboot devices can still be located on 
the coreboot bus.

[1] 
https://elixir.bootlin.com/linux/v6.18.4/source/drivers/firmware/google/framebuffer-coreboot.c#L92
[2] 
https://elixir.bootlin.com/linux/v6.18.4/source/drivers/firmware/sysfb.c#L160

Another question I have is why there's a separate device for the 
coreboot-table? Couldn't the kernel just create the coreboot bus and 
then populate it with the table entries? DT does that. If the 
coreboot-table device is really just the parent for the other deivce, 
that is incorrect, as I describe above.

The coreboot bus is only for convenience, I guess? Other subsystems 
(sysfb, DT) create platform devices directly.

Best regards
Thomas



>
> On Thu, Jan 8, 2026 at 3:51 PM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>> Test sysfb before creating the coreboot framebuffer device. Skip
>> device creation if the test fails, as this framebuffer does not exist.
>>
>> Depending on the system setup, the initial framebuffer can be provided
>> by the boot loader via screen_info boot parameters and handled by the
>> kernel's sysfb code in drivers/firmware/sysfb.c. With the sysfb test in
>> the coreboot-framebuffer probing, the coreboot device is present without
>> the framebuffer. Even after the sysfb device has been replaced with a
>> native PCI device, the coreboot device persists.
>>
>> Skipping device creation early avoids all these inconsistencies. It
>> further prepares coreboot to support graphics drivers besides the one
>> in framebuffer-coreboot.c.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> ---
>>   drivers/firmware/google/coreboot_table.c       | 17 +++++++++++++++++
>>   drivers/firmware/google/coreboot_table.h       |  1 +
>>   drivers/firmware/google/framebuffer-coreboot.c | 16 ----------------
>>   3 files changed, 18 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/firmware/google/coreboot_table.c b/drivers/firmware/google/coreboot_table.c
>> index 882db32e51be..c34426e5002d 100644
>> --- a/drivers/firmware/google/coreboot_table.c
>> +++ b/drivers/firmware/google/coreboot_table.c
>> @@ -18,6 +18,7 @@
>>   #include <linux/of.h>
>>   #include <linux/platform_device.h>
>>   #include <linux/slab.h>
>> +#include <linux/sysfb.h>
>>
>>   #include "coreboot_table.h"
>>
>> @@ -118,6 +119,22 @@ static int coreboot_table_populate(struct device *dev, void *ptr)
>>                          return -EINVAL;
>>                  }
>>
>> +               switch (entry->tag) {
>> +               case CB_TAG_FRAMEBUFFER:
>> +                       /*
>> +                        * On coreboot systems, the advertised CB_TAG_FRAMEBUFFER entry
>> +                        * in the coreboot table should only be used if the payload did
>> +                        * not pass a framebuffer information to the Linux kernel.
>> +                        *
>> +                        * If the global screen_info data has been filled, the generic
>> +                        * system framebuffers (sysfb) will already register a platform
>> +                        * device and pass that screen_info as platform_data to a driver
>> +                        * that can scan-out using the system-provided framebuffer.
>> +                        */
>> +                       if (sysfb_handles_screen_info())
>> +                               continue;
>> +               }
>> +
>>                  device = kzalloc(sizeof(device->dev) + entry->size, GFP_KERNEL);
>>                  if (!device)
>>                          return -ENOMEM;
>> diff --git a/drivers/firmware/google/coreboot_table.h b/drivers/firmware/google/coreboot_table.h
>> index bb6f0f7299b4..e3c353676940 100644
>> --- a/drivers/firmware/google/coreboot_table.h
>> +++ b/drivers/firmware/google/coreboot_table.h
>> @@ -40,6 +40,7 @@ struct lb_cbmem_ref {
>>          u64 cbmem_addr;
>>   };
>>
>> +#define CB_TAG_FRAMEBUFFER 0x12
>>   #define LB_TAG_CBMEM_ENTRY 0x31
>>
>>   /* Corresponds to LB_TAG_CBMEM_ENTRY */
>> diff --git a/drivers/firmware/google/framebuffer-coreboot.c b/drivers/firmware/google/framebuffer-coreboot.c
>> index c68c9f56370f..bb53d1a47409 100644
>> --- a/drivers/firmware/google/framebuffer-coreboot.c
>> +++ b/drivers/firmware/google/framebuffer-coreboot.c
>> @@ -15,12 +15,9 @@
>>   #include <linux/module.h>
>>   #include <linux/platform_data/simplefb.h>
>>   #include <linux/platform_device.h>
>> -#include <linux/sysfb.h>
>>
>>   #include "coreboot_table.h"
>>
>> -#define CB_TAG_FRAMEBUFFER 0x12
>> -
>>   static const struct simplefb_format formats[] = SIMPLEFB_FORMATS;
>>
>>   static int framebuffer_probe(struct coreboot_device *dev)
>> @@ -37,19 +34,6 @@ static int framebuffer_probe(struct coreboot_device *dev)
>>                  .format = NULL,
>>          };
>>
>> -       /*
>> -        * On coreboot systems, the advertised LB_TAG_FRAMEBUFFER entry
>> -        * in the coreboot table should only be used if the payload did
>> -        * not pass a framebuffer information to the Linux kernel.
>> -        *
>> -        * If the global screen_info data has been filled, the Generic
>> -        * System Framebuffers (sysfb) will already register a platform
>> -        * device and pass that screen_info as platform_data to a driver
>> -        * that can scan-out using the system provided framebuffer.
>> -        */
>> -       if (sysfb_handles_screen_info())
>> -               return -ENODEV;
>> -
>>          if (!fb->physical_address)
>>                  return -ENODEV;
>>
>> --
>> 2.52.0
>>

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)



  reply	other threads:[~2026-01-09  9:17 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-08 14:19 [PATCH 0/8] drm, coreboot: Add DRM coreboot driver Thomas Zimmermann
2026-01-08 14:19 ` [PATCH 1/8] firmware: google: Do sysfb test before creating coreboot framebuffer Thomas Zimmermann
2026-01-08 16:55   ` Julius Werner
2026-01-09  9:17     ` Thomas Zimmermann [this message]
2026-01-09 10:21       ` Javier Martinez Canillas
2026-01-13 22:32         ` Julius Werner
2026-01-14  8:13           ` Thomas Zimmermann
2026-01-14 20:32             ` Julius Werner
2026-01-08 14:19 ` [PATCH 2/8] firmware: google: Init coreboot bus with subsys_initcall() Thomas Zimmermann
2026-01-09 10:24   ` Javier Martinez Canillas
2026-01-08 14:19 ` [PATCH 3/8] firmware: google: Clean up include statements in coreboot_table.h Thomas Zimmermann
2026-01-09 10:24   ` Javier Martinez Canillas
2026-01-08 14:19 ` [PATCH 4/8] firmware: google: Export coreboot driver and device interfaces Thomas Zimmermann
2026-01-09 10:26   ` Javier Martinez Canillas
2026-01-08 14:19 ` [PATCH 5/8] video/aperture: Support coreboot devices Thomas Zimmermann
2026-01-09 10:30   ` Javier Martinez Canillas
2026-01-08 14:19 ` [PATCH 6/8] drm/sysfb: Remove duplicate declarations Thomas Zimmermann
2026-01-09 10:31   ` Javier Martinez Canillas
2026-01-14  9:02     ` Thomas Zimmermann
2026-01-08 14:19 ` [PATCH 7/8] drm/sysfb: Generalize pixel-format matching Thomas Zimmermann
2026-01-09 10:32   ` Javier Martinez Canillas
2026-01-08 14:19 ` [PATCH 8/8] drm/sysfb: corebootdrm: Add DRM driver for coreboot framebuffers Thomas Zimmermann
2026-01-14 21:49   ` kernel test robot
2026-01-14 22:12   ` kernel test robot
2026-01-08 18:10 ` [PATCH 0/8] drm, coreboot: Add DRM coreboot driver Brian Norris
2026-01-09  8:50   ` Thomas Zimmermann
2026-01-09 10:37     ` Javier Martinez Canillas

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=9d9015fa-aba4-4dd7-a024-563f58b7f43a@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=briannorris@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=jwerner@chromium.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzungbi@kernel.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