Commit 66a749a7 authored by Thomas Zimmermann's avatar Thomas Zimmermann
Browse files

fbdev/hyperv_fb: Use fb_ops helpers for deferred I/O



Generate callback functions for struct fb_ops with the fbdev macro
FB_GEN_DEFAULT_DEFERRED_IOMEM_OPS(). Initialize struct fb_ops to
the generated functions with fbdev initializer macros.

The hyperv_fb driver is incomplete in its handling of deferred I/O
and damage framebuffers. Write operations do no trigger damage handling.
Fixing this is beyond the scope of this patch.

Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Wei Liu <wei.liu@kernel.org>
Cc: Dexuan Cui <decui@microsoft.com>
Acked-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230828132131.29295-5-tzimmermann@suse.de
parent ee057f97
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -1905,11 +1905,8 @@ config FB_BROADSHEET
config FB_HYPERV
	tristate "Microsoft Hyper-V Synthetic Video support"
	depends on FB && HYPERV
	select FB_CFB_FILLRECT
	select FB_CFB_COPYAREA
	select FB_CFB_IMAGEBLIT
	select FB_DEFERRED_IO
	select DMA_CMA if HAVE_DMA_CONTIGUOUS && CMA
	select FB_IOMEM_HELPERS_DEFERRED
	select VIDEO_NOMODESET
	help
	  This framebuffer driver supports Microsoft Hyper-V Synthetic Video.
+14 −34
Original line number Diff line number Diff line
@@ -848,58 +848,38 @@ static int hvfb_blank(int blank, struct fb_info *info)
	return 1;	/* get fb_blank to set the colormap to all black */
}

static void hvfb_cfb_fillrect(struct fb_info *p,
			      const struct fb_fillrect *rect)
static void hvfb_ops_damage_range(struct fb_info *info, off_t off, size_t len)
{
	struct hvfb_par *par = p->par;

	cfb_fillrect(p, rect);
	if (par->synchronous_fb)
		synthvid_update(p, 0, 0, INT_MAX, INT_MAX);
	else
		hvfb_ondemand_refresh_throttle(par, rect->dx, rect->dy,
					       rect->width, rect->height);
	/* TODO: implement damage handling */
}

static void hvfb_cfb_copyarea(struct fb_info *p,
			      const struct fb_copyarea *area)
static void hvfb_ops_damage_area(struct fb_info *info, u32 x, u32 y, u32 width, u32 height)
{
	struct hvfb_par *par = p->par;
	struct hvfb_par *par = info->par;

	cfb_copyarea(p, area);
	if (par->synchronous_fb)
		synthvid_update(p, 0, 0, INT_MAX, INT_MAX);
		synthvid_update(info, 0, 0, INT_MAX, INT_MAX);
	else
		hvfb_ondemand_refresh_throttle(par, area->dx, area->dy,
					       area->width, area->height);
		hvfb_ondemand_refresh_throttle(par, x, y, width, height);
}

static void hvfb_cfb_imageblit(struct fb_info *p,
			       const struct fb_image *image)
{
	struct hvfb_par *par = p->par;

	cfb_imageblit(p, image);
	if (par->synchronous_fb)
		synthvid_update(p, 0, 0, INT_MAX, INT_MAX);
	else
		hvfb_ondemand_refresh_throttle(par, image->dx, image->dy,
					       image->width, image->height);
}
/*
 * TODO: GEN1 codepaths allocate from system or DMA-able memory. Fix the
 *       driver to use the _SYSMEM_ or _DMAMEM_ helpers in these cases.
 */
FB_GEN_DEFAULT_DEFERRED_IOMEM_OPS(hvfb_ops,
				  hvfb_ops_damage_range,
				  hvfb_ops_damage_area)

static const struct fb_ops hvfb_ops = {
	.owner = THIS_MODULE,
	FB_DEFAULT_DEFERRED_OPS(hvfb_ops),
	.fb_check_var = hvfb_check_var,
	.fb_set_par = hvfb_set_par,
	.fb_setcolreg = hvfb_setcolreg,
	.fb_fillrect = hvfb_cfb_fillrect,
	.fb_copyarea = hvfb_cfb_copyarea,
	.fb_imageblit = hvfb_cfb_imageblit,
	.fb_blank = hvfb_blank,
	.fb_mmap = fb_deferred_io_mmap,
};


/* Get options from kernel paramenter "video=" */
static void hvfb_get_option(struct fb_info *info)
{