2022-05-22 16:19:26

by Huacai Chen

[permalink] [raw]
Subject: Re: [PATCH V11 09/22] LoongArch: Add boot and setup routines

Hi, Javier,

On Sat, May 21, 2022 at 12:32 AM Javier Martinez Canillas
<[email protected]> wrote:
>
> On 5/20/22 17:19, Huacai Chen wrote:
> > Hi, Javier,
>
> [snip]
>
> >> Conversely, if the sysfb_init() is executed first then the platform device
> >> will be registered and latter when the driver's init register the driver
> >> this will match the already registered device.
> > Yes, you are right, my consideration is too complex. The only real
> > problem is a harmless error "efifb: a framebuffer is already
> > registered" when both efifb and the native display driver are
> > built-in.
> >
>
> But this shouldn't be a problem if you drop your register_gop_device() that
> registers an "efi-framebuffer", since sysfb would either register a platform
> device "simple-framebufer" or "efi-framebuffer", but never both. Those are
> mutually exclusive.
>
> I think what's happening now is that sysfb is registering a "simple-framebuffer"
> but your register_gop_device() function is also registering an "efi-framebuffer".
No, I have already removed register_gop_device(). Now my problem is like this:
1, efifb (or simpledrm) is built-in;
2, a native display driver (such as radeon) is also built-in.

Because efifb, radeon and sysfb are all in device_initcall() level,
the order in practise is like this:

efifb registered at first, but no "efi-framebuffer" device yet.
radeon registered later, and /dev/fb0 created.
sysfb_init() comes at last, it registers "efi-framebuffer" and then
causes the error "efifb: a framebuffer is already registered".
make sysfb_init() to be subsys_initcall_sync() can avoid this.

Huacai

>
> --
> Best regards,
>
> Javier Martinez Canillas
> Linux Engineering
> Red Hat
>


2022-05-23 06:06:45

by Javier Martinez Canillas

[permalink] [raw]
Subject: Re: [PATCH V11 09/22] LoongArch: Add boot and setup routines

Hello Huacai,

On 5/21/22 03:40, Huacai Chen wrote:
> Hi, Javier,

[snip]

>>>> Conversely, if the sysfb_init() is executed first then the platform device
>>>> will be registered and latter when the driver's init register the driver
>>>> this will match the already registered device.
>>> Yes, you are right, my consideration is too complex. The only real
>>> problem is a harmless error "efifb: a framebuffer is already
>>> registered" when both efifb and the native display driver are
>>> built-in.
>>>
>>
>> But this shouldn't be a problem if you drop your register_gop_device() that
>> registers an "efi-framebuffer", since sysfb would either register a platform
>> device "simple-framebufer" or "efi-framebuffer", but never both. Those are
>> mutually exclusive.
>>
>> I think what's happening now is that sysfb is registering a "simple-framebuffer"
>> but your register_gop_device() function is also registering an "efi-framebuffer".
> No, I have already removed register_gop_device(). Now my problem is like this:
> 1, efifb (or simpledrm) is built-in;
> 2, a native display driver (such as radeon) is also built-in.
>

Ah, I see. The common configuration is for the firmware-provide framebuffer
drivers ({efi,simple}fb,simpledrm,etc) to be built-in and native drivers to
be built as a module.

> Because efifb, radeon and sysfb are all in device_initcall() level,
> the order in practise is like this:
>
> efifb registered at first, but no "efi-framebuffer" device yet.
> radeon registered later, and /dev/fb0 created.
> sysfb_init() comes at last, it registers "efi-framebuffer" and then
> causes the error "efifb: a framebuffer is already registered".

Yes, this is problem because only conflicting framebuffers and associated
devices are unregistered when a real driver is registered, but no devices
that have not matched with drivers and registered framebuffers or disable
devices to be registered later.

I proposed the following patch series but the conclusion was that this has
to be fixed in a more general way:

https://lore.kernel.org/lkml/[email protected]/

> make sysfb_init() to be subsys_initcall_sync() can avoid this.
>

Right, now I understand your problem and you are correct that this will
avoid it. But I believe is just papering over the issue, the problem is
that if a native fbdev or DRM driver probed, then sysfb (or any other
platform code) should not register a device to match a driver that will
attempt to use a firmware-provided framebuffer.

A problem with moving to subsys_initcall_sync() is that this will delay
more when a display is available in the system, and just to cope up with
a corner case (as mentioned the common case is native drivers as module).
--
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat