[PATCH v3 0/4] fbdev: Add deferred I/O support for contiguous kernel memory framebuffers

mhkelley58
2025-05-23T16:15:42Z

From: Michael Kelley <mhklinux@outlook.com>

Current deferred I/O code works only for framebuffer memory that is
allocated with vmalloc(). The code assumes that the underlying page
refcount can be used by the mm subsystem to manage each framebuffer
page's lifecycle, which is consistent with vmalloc'ed memory, but not
with contiguous kernel memory from alloc_pages() or similar. When used
with contiguous kernel memory, current deferred I/O code eventually
causes the memory free lists to be scrambled, and a kernel panic ensues.
The problem is seen with the hyperv_fb driver when mmap'ing the
framebuffer into user space, as that driver uses alloc_pages() for the
framebuffer in some configurations. This patch set fixes the problem
by supporting contiguous kernel memory framebuffers with deferred I/O.

Patch 1 exports a 'mm' subsystem function needed by Patch 3.

Pathc 2 defines the FBINFO_KMEMFB flag for use by Patches 3 and 4.

Patch 3 is the changes to the fbdev deferred I/O code. More details
are in the commit message of Patch 3.

Patch 4 updates the hyperv_fb driver to use the new functionality
from Patch 3.

Michael Kelley (4):
mm: Export vmf_insert_mixed_mkwrite()
fbdev: Add flag indicating framebuffer is allocated from kernel memory
fbdev/deferred-io: Support contiguous kernel memory framebuffers
fbdev: hyperv_fb: Fix mmap of framebuffers allocated using
alloc_pages()

drivers/video/fbdev/core/fb_defio.c | 128 +++++++++++++++++++++++-----
drivers/video/fbdev/hyperv_fb.c | 1 +
include/linux/fb.h | 1 +
mm/memory.c | 1 +
4 files changed, 111 insertions(+), 20 deletions(-)

--
2.25.1