From 40d481266497437ebaa5312c9af9641361b172f8 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Thu, 28 Nov 2024 14:25:03 +0100 Subject: [PATCH] fbdev-dma: Support deferred I/O without smem_start Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/drm_fbdev_dma.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/gpu/drm/drm_fbdev_dma.c b/drivers/gpu/drm/drm_fbdev_dma.c index b14b581c059d..6a94d1b62479 100644 --- a/drivers/gpu/drm/drm_fbdev_dma.c +++ b/drivers/gpu/drm/drm_fbdev_dma.c @@ -8,6 +8,7 @@ #include #include #include +#include /* * struct fb_ops @@ -124,6 +125,28 @@ static const struct drm_fb_helper_funcs drm_fbdev_dma_helper_funcs = { .fb_dirty = drm_fbdev_dma_helper_fb_dirty, }; +static struct page *drm_fbdev_dma_get_page(struct fb_info *info, unsigned long offset) +{ + struct drm_fb_helper *fb_helper = info->par; + struct drm_framebuffer *fb = fb_helper->fb; + struct drm_gem_object *obj = drm_gem_fb_get_obj(fb, 0); + const void *addr = info->screen_buffer + offset; + struct page *page = NULL; + + if (fb_WARN_ON_ONCE(info, offset > obj->size)) + return NULL; + + if (is_vmalloc_addr(addr)) + page = vmalloc_to_page(addr); + else if (virt_addr_valid(addr)) + page = virt_to_page(addr); + + if (!fb_WARN_ON_ONCE(info, !page)) + get_page(page); + + return page; +} + /* * struct drm_fb_helper */ @@ -217,6 +240,7 @@ int drm_fbdev_dma_driver_fbdev_probe(struct drm_fb_helper *fb_helper, /* deferred I/O */ if (use_deferred_io) { fb_helper->fbdefio.delay = HZ / 20; + fb_helper->fbdefio.get_page = drm_fbdev_dma_get_page; fb_helper->fbdefio.deferred_io = drm_fb_helper_deferred_io; info->fbdefio = &fb_helper->fbdefio; -- 2.47.0