Thread (54 messages) 54 messages, 2 authors, 3d ago

Re: [PATCH v4 18/38] fbdev: defio: assert FBINFO_VIRTFB, drop VM_IO, add VM_MIXEDMAP

flat view

From: Suren Baghdasaryan <surenb@google.com>
Date: 2026-10-04 18:02:17
Also in: bpf, fuse-devel, kvm, kvm-riscv, kvmarm, linux-arch, linux-doc, linux-fbdev, linux-fsdevel, linux-mm, linux-perf-users, linux-rdma, linux-riscv, linux-s390, linux-scsi, linux-sound, linux-trace-kernel, linux-usb, lkml, selinux, sparclinux

On Sat, Oct 3, 2026 at 6:39 PM Lorenzo Stoakes (ARM) [off-list ref] wrote:
Currently all drivers which use defio allocate system memory. All of them
also set FBINFO_VIRTFB, other than ssd1307fb, however this driver allocates
system RAM, so simply failed to set this flag when it ought to.

This patch sets FBINFO_VIRTFB on ssd1307fb probe, then drops setting VM_IO
in fb_deferred_io_mmap() and instead requires FBINFO_VIRTFB to be set,
erroring out with a kernel warning if not.

The logic requires a page from the driver and since commit 1ecbc7dd2902
("fbdev/deferred-io: Always call get_page() for framebuffer pages") has
always required it to be refcounted, so this was implicitly already the
case.

Finally this patch sets VM_MIXEDMAP, as the logic is mapping
kernel-allocated memory so this is appropriate.

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
With the same disclaimer as in previous patch,

Reviewed-by: Suren Baghdasaryan <surenb@google.com>

quoted hunk ↗ jump to hunk
---
 drivers/video/fbdev/core/fb_defio.c | 6 +++---
 drivers/video/fbdev/ssd1307fb.c     | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c
index fd00b86e1ae6..fb359ecc3966 100644
--- a/drivers/video/fbdev/core/fb_defio.c
+++ b/drivers/video/fbdev/core/fb_defio.c
@@ -366,13 +366,13 @@ int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct *vma)
 {
        vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);

+       if (WARN_ON_ONCE(!(info->flags & FBINFO_VIRTFB)))
+               return -EINVAL;
        if (!try_module_get(THIS_MODULE))
                return -EINVAL;

        vma->vm_ops = &fb_deferred_io_vm_ops;
-       vm_flags_set(vma, VM_DONTEXPAND | VM_DONTDUMP);
-       if (!(info->flags & FBINFO_VIRTFB))
-               vm_flags_set(vma, VM_IO);
+       vm_flags_set(vma, VM_MIXEDMAP | VM_DONTEXPAND | VM_DONTDUMP);
        vma->vm_private_data = info->fbdefio_state;

        fb_deferred_io_state_get(info->fbdefio_state); /* released in vma->vm_ops->close() */
diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
index c4fdecafd856..958514a35433 100644
--- a/drivers/video/fbdev/ssd1307fb.c
+++ b/drivers/video/fbdev/ssd1307fb.c
@@ -763,6 +763,8 @@ static int ssd1307fb_probe(struct i2c_client *client)
        info->fix.smem_start = __pa(vmem);
        info->fix.smem_len = vmem_size;

+       info->flags = FBINFO_VIRTFB;
+
        fb_deferred_io_init(info);

        i2c_set_clientdata(client, info);

--
2.55.0
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help