drm/fbdev-dma: Only set smem_start is enable per module option
authorjsg <jsg@openbsd.org>
Mon, 8 Jul 2024 02:13:36 +0000 (02:13 +0000)
committerjsg <jsg@openbsd.org>
Mon, 8 Jul 2024 02:13:36 +0000 (02:13 +0000)
From Thomas Zimmermann
f29fcfbf6067c0d8c83f84a045da9276c08deac5 in linux-6.6.y/6.6.37
d92a7580392ad4681b1d4f9275d00b95375ebe01 in mainline linux

sys/dev/pci/drm/drm_fb_helper.c
sys/dev/pci/drm/drm_fbdev_dma.c

index 0911eb6..1a0be9c 100644 (file)
@@ -532,6 +532,9 @@ struct fb_info *drm_fb_helper_alloc_info(struct drm_fb_helper *fb_helper)
        if (!info)
                return ERR_PTR(-ENOMEM);
 
+       if (!drm_leak_fbdev_smem)
+               info->flags |= FBINFO_HIDE_SMEM_START;
+
 #ifdef __linux__
        ret = fb_alloc_cmap(&info->cmap, 256, 0);
        if (ret)
@@ -1925,9 +1928,6 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper)
        info = fb_helper->info;
        info->var.pixclock = 0;
 
-       if (!drm_leak_fbdev_smem)
-               info->flags |= FBINFO_HIDE_SMEM_START;
-
        /* Need to drop locks to avoid recursive deadlock in
         * register_framebuffer. This is ok because the only thing left to do is
         * register the fbdev emulation instance in kernel_fb_helper_list. */
index 4ef5cbb..64e81c3 100644 (file)
@@ -138,7 +138,10 @@ static int drm_fbdev_dma_helper_fb_probe(struct drm_fb_helper *fb_helper,
                info->flags |= FBINFO_READS_FAST; /* signal caching */
        info->screen_size = sizes->surface_height * fb->pitches[0];
        info->screen_buffer = map.vaddr;
-       info->fix.smem_start = page_to_phys(virt_to_page(info->screen_buffer));
+       if (!(info->flags & FBINFO_HIDE_SMEM_START)) {
+               if (!drm_WARN_ON(dev, is_vmalloc_addr(info->screen_buffer)))
+                       info->fix.smem_start = page_to_phys(virt_to_page(info->screen_buffer));
+       }
        info->fix.smem_len = info->screen_size;
 
        return 0;