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

From: Andrew Worsley
Date: Sat Nov 11 2023 - 03:31:36 EST


It's inline - part of the email - not an attachment?

I can see it in the copy that went to me...

Andrew

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.
>
> ...
> [ 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
> ...
>
> In my case no driver provided /dev/dri/card0 device is available on boot up and X
> fails to start as per this from X start up log.
>
> ...
> [ 5.616] (WW) Falling back to old probe method for modesetting
> [ 5.616] (EE) open /dev/dri/card0: No such file or directory
> ...
>
> Fault confirmed and fixed on Asahi 6.5.0 kernel with both CONFIG_FB_EFI and
> CONFIG_DRM_SIMPLEDRM config options set.
>
> Signed-off-by: Andrew Worsley <amworsley@xxxxxxxxx>
> ---
> drivers/gpu/drm/tiny/simpledrm.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/tiny/simpledrm.c
> index 5fefc895bca2..e55a536b04cf 100644
> --- a/drivers/gpu/drm/tiny/simpledrm.c
> +++ b/drivers/gpu/drm/tiny/simpledrm.c
> @@ -8,6 +8,7 @@
> #include <linux/platform_device.h>
> #include <linux/pm_domain.h>
> #include <linux/regulator/consumer.h>
> +#include <linux/aperture.h>
>
> #include <drm/drm_aperture.h>
> #include <drm/drm_atomic.h>
> @@ -828,6 +829,13 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
> if (mem) {
> void *screen_base;
>
> + ret = aperture_remove_conflicting_devices(mem->start, resource_size(mem),
> + DRIVER_NAME);
> + if (ret) {
> + drm_err(dev, "aperture_remove_conflicting_devices: failed:%d\n",
> + __func__, ret);
> + return ERR_PTR(ret);
> + }
> ret = devm_aperture_acquire_from_firmware(dev, mem->start, resource_size(mem));
> if (ret) {
> drm_err(dev, "could not acquire memory range %pr: %d\n", mem, ret);
> @@ -848,6 +856,13 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
> if (!res)
> return ERR_PTR(-EINVAL);
>
> + ret = aperture_remove_conflicting_devices(res->start, resource_size(res),
> + DRIVER_NAME);
> + if (ret) {
> + drm_err(dev, "aperture_remove_conflicting_devices: failed:%d\n",
> + __func__, ret);
> + return ERR_PTR(ret);
> + }
> ret = devm_aperture_acquire_from_firmware(dev, res->start, resource_size(res));
> if (ret) {
> drm_err(dev, "could not acquire memory range %pr: %d\n", res, ret);
> --
> 2.42.0
>