Re: [PATCH] Fix failure of simpledrm probe when trying to grab FB from the EFI-based Framebuffer

From: Javier Martinez Canillas
Date: Sun Nov 12 2023 - 05:36:55 EST


Andrew Worsley <amworsley@xxxxxxxxx> writes:

Hello Andrew,

> On Sat, 11 Nov 2023 at 20:10, Javier Martinez Canillas
> <javierm@xxxxxxxxxx> wrote:
>>
> ....
>> > On Sat, 11 Nov 2023 at 15:30, Andrew Worsley <amworsley@xxxxxxxxx> wrote:
>> >>
>> >> The simpledrm.c does not call aperture_remove_conflicting_devices() in it's probe
>> >> function as the drivers/video/aperture.c documentation says it should. Consequently
>> >> it's request for the FB memory fails.
>> >>
>>
>> The current behaviour is correct since aperture_remove_conflicting_devices()
>> is for native drivers to remove simple framebuffer devices such as simpledrm,
>> simplefb, efifb, etc.
>
> The efifb is the driver that has "grabbed" the FB earlier
>
> Here's a debug output with a dump_stack() call in the devm_aperture_acquire()
> % grep --color -A14 -B4 devm_aperture_acquire ~/dmesg2.txt
> [ 0.055752] efifb: framebuffer at 0xbd58dc000, using 16000k, total 16000k
> [ 0.055755] efifb: mode is 2560x1600x32, linelength=10240, pages=1
> [ 0.055758] efifb: scrolling: redraw
> [ 0.055759] efifb: Truecolor: size=2:10:10:10, shift=30:20:10:0
> [ 0.055771] devm_aperture_acquire: dump stack for debugging
> [ 0.055775] CPU: 2 PID: 1 Comm: swapper/0 Tainted: G S

I see. This is the problem then. Your platform then is using a Device Tree
that contains a "simple-framebuffer" node but also doing a UEFI boot and
providing an EFI GOP table that is picked by the Linux EFI stub on boot.

[...]

>>
>> >> ...
>> >> [ 3.085302] simple-framebuffer bd58dc000.framebuffer: [drm] *ERROR* could not acquire memory range [??? 0xffff6e1d8629d580-0x2a5000001a7 flags 0x0]: -16
>> >> [ 3.086433] simple-framebuffer: probe of bd58dc000.framebuffer failed with error -16
>> >> ...
>> >>
>>
>> This is -EBUSY. What is your kernel configuration? Can you share it please.
>
> Attached - hope that's acceptable...
>
>

Thanks a lot for providing this. It was very helpful to understand the issue.

[...]

>>
>> I would rather try to understand what is going on in your setup and why
>> the acquire is returning -EBUSY.
>>
>
> Ok - thanks - let me know where to go from here.
>

I think that what we should do instead is to prevent both the EFI GOP and
"simple-framebuffer" to provide a system framebuffer information and the
kernel to register two devices (a "simple-framebuffer" by the OF core and
an "efi-framebuffer" by the sysfb infrastructure).

In my opinion, the DTB is the best source of truth on an DT platform and
so is the sysfb that should be disabled if there's a "simple-framebuffer"
DT node found.

Can you please try the following (untested) patch?