diff mbox series

[07/43] fbdev/deferred-io: Provide get_page hook in struct fb_deferred_io

Message ID 20240312154834.26178-8-tzimmermann@suse.de (mailing list archive)
State Not Applicable
Headers show
Series drm: Provide fbdev emulation per memory manager | expand

Commit Message

Thomas Zimmermann March 12, 2024, 3:45 p.m. UTC
Add a callback for drivers to provide framebuffer pages to fbdev's
deferred-I/O helpers. Implementations need to acquire a reference on
the page before returning it. Returning NULL generates a SIGBUS
signal.

This will be useful for DRM's fbdev emulation with GEM-shemem buffer
objects.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/fbdev/core/fb_defio.c | 4 ++++
 include/linux/fb.h                  | 1 +
 2 files changed, 5 insertions(+)

Comments

Javier Martinez Canillas March 18, 2024, 5:11 p.m. UTC | #1
Thomas Zimmermann <tzimmermann@suse.de> writes:

> Add a callback for drivers to provide framebuffer pages to fbdev's
> deferred-I/O helpers. Implementations need to acquire a reference on
> the page before returning it. Returning NULL generates a SIGBUS
> signal.
>
> This will be useful for DRM's fbdev emulation with GEM-shemem buffer

GEM-shmem

> objects.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
diff mbox series

Patch

diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c
index 6e0bbcfdb01b5..51928ff7961a5 100644
--- a/drivers/video/fbdev/core/fb_defio.c
+++ b/drivers/video/fbdev/core/fb_defio.c
@@ -25,9 +25,13 @@ 
 
 static struct page *fb_deferred_io_get_page(struct fb_info *info, unsigned long offs)
 {
+	struct fb_deferred_io *fbdefio = info->fbdefio;
 	const void *screen_buffer = info->screen_buffer;
 	struct page *page = NULL;
 
+	if (fbdefio->get_page)
+		return fbdefio->get_page(info, offs);
+
 	if (is_vmalloc_addr(screen_buffer + offs))
 		page = vmalloc_to_page(screen_buffer + offs);
 	else if (info->fix.smem_start)
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 708e6a177b1be..bbb0805c0ab1e 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -219,6 +219,7 @@  struct fb_deferred_io {
 	struct mutex lock; /* mutex that protects the pageref list */
 	struct list_head pagereflist; /* list of pagerefs for touched pages */
 	/* callback */
+	struct page *(*get_page)(struct fb_info *info, unsigned long offset);
 	void (*deferred_io)(struct fb_info *info, struct list_head *pagelist);
 };
 #endif