Re: [PATCH v4 13/13] drm/i915: Implement dedicated fbdev I/O helpers
Hi Thomas, > > > - if (helper->funcs->fb_dirty) { > > > - drm_fb_helper_memory_range_to_clip(info, pos, ret, > > > _area); > > > - drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1, > > > - drm_rect_width(_area), > > > - drm_rect_height(_area)); > > > - } > > > > The generated helpers do not have the if (helper->funcs->fb_dirty) > > check. > > Is this implemented somewhere else that I missed? > > It's not needed any longer. We used to test if the fbdev code needs damage > handling by looking for a fb_dirty callback. If so, we ran the damage > handling code. > > With the patchset applied, the fbdev code that does not need damage handling > calls fb_{io,sys}_write() directly. The fbdev code that needs damage > handling (generic, i915, msm) uses the generator macro that creates > necessary the calls unconditionally. We know each case at build time. > > (I think I have to move the msm patch after patch 10/13 to make it > bisectable.) > > AFAICT the missing test for fb_dirty is also one of the reasons why there's > a difference in performance. > > Hopefully, this answers your question? Makes perfect sense - thanks. That also implies that my conditional r-b's are now OK. Sam
Re: [PATCH v4 13/13] drm/i915: Implement dedicated fbdev I/O helpers
Hi Am 29.05.23 um 21:36 schrieb Sam Ravnborg: Hi Thomas, On Wed, May 24, 2023 at 11:21:50AM +0200, Thomas Zimmermann wrote: Implement dedicated fbdev helpers for framebuffer I/O instead of using DRM's helpers. Use an fbdev generator macro for deferred I/O to create the fbdev callbacks. i915 was the only caller of the DRM helpers, so remove them from the helper module. i915's fbdev emulation is still incomplete as it doesn't implement deferred I/O and damage handling for mmaped pages. v4: * generate deferred-I/O helpers * use initializer macros for fb_ops v2: * use FB_IO_HELPERS options Signed-off-by: Thomas Zimmermann Cc: Jani Nikula Cc: Joonas Lahtinen Cc: Rodrigo Vivi Cc: Tvrtko Ursulin Cc: "Ville Syrjälä" --- drivers/gpu/drm/Kconfig| 3 - drivers/gpu/drm/drm_fb_helper.c| 107 - drivers/gpu/drm/i915/Kconfig | 1 + drivers/gpu/drm/i915/display/intel_fbdev.c | 14 +-- include/drm/drm_fb_helper.h| 39 5 files changed, 9 insertions(+), 155 deletions(-) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 92a782827b7b..bb2e48cc6cd6 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -133,9 +133,6 @@ config DRM_FBDEV_EMULATION bool "Enable legacy fbdev support for your modesetting driver" depends on DRM_KMS_HELPER depends on FB=y || FB=DRM_KMS_HELPER - select FB_CFB_FILLRECT - select FB_CFB_COPYAREA - select FB_CFB_IMAGEBLIT select FRAMEBUFFER_CONSOLE if !EXPERT select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE default y diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index bab6b252f02a..9978147bbc8a 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -736,113 +736,6 @@ void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagerefli } EXPORT_SYMBOL(drm_fb_helper_deferred_io); -/** - * drm_fb_helper_cfb_read - Implements struct _ops.fb_read for I/O memory - * @info: fb_info struct pointer - * @buf: userspace buffer to read from framebuffer memory - * @count: number of bytes to read from framebuffer memory - * @ppos: read offset within framebuffer memory - * - * Returns: - * The number of bytes read on success, or an error code otherwise. - */ -ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf, - size_t count, loff_t *ppos) -{ - return fb_io_read(info, buf, count, ppos); -} -EXPORT_SYMBOL(drm_fb_helper_cfb_read); - -/** - * drm_fb_helper_cfb_write - Implements struct _ops.fb_write for I/O memory - * @info: fb_info struct pointer - * @buf: userspace buffer to write to framebuffer memory - * @count: number of bytes to write to framebuffer memory - * @ppos: write offset within framebuffer memory - * - * Returns: - * The number of bytes written on success, or an error code otherwise. - */ -ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char __user *buf, - size_t count, loff_t *ppos) -{ - struct drm_fb_helper *helper = info->par; - loff_t pos = *ppos; - ssize_t ret; - struct drm_rect damage_area; - - ret = fb_io_write(info, buf, count, ppos); - if (ret <= 0) - return ret; - - if (helper->funcs->fb_dirty) { - drm_fb_helper_memory_range_to_clip(info, pos, ret, _area); - drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1, -drm_rect_width(_area), -drm_rect_height(_area)); - } The generated helpers do not have the if (helper->funcs->fb_dirty) check. Is this implemented somewhere else that I missed? It's not needed any longer. We used to test if the fbdev code needs damage handling by looking for a fb_dirty callback. If so, we ran the damage handling code. With the patchset applied, the fbdev code that does not need damage handling calls fb_{io,sys}_write() directly. The fbdev code that needs damage handling (generic, i915, msm) uses the generator macro that creates necessary the calls unconditionally. We know each case at build time. (I think I have to move the msm patch after patch 10/13 to make it bisectable.) AFAICT the missing test for fb_dirty is also one of the reasons why there's a difference in performance. Hopefully, this answers your question? Best regards Thomas Sam - - return ret; -} -EXPORT_SYMBOL(drm_fb_helper_cfb_write); - -/** - * drm_fb_helper_cfb_fillrect - wrapper around cfb_fillrect - * @info: fbdev registered by the helper - * @rect: info about rectangle to fill - * - * A wrapper around cfb_fillrect implemented by fbdev core - */ -void drm_fb_helper_cfb_fillrect(struct fb_info *info, - const struct fb_fillrect *rect) -{
Re: [PATCH v4 13/13] drm/i915: Implement dedicated fbdev I/O helpers
Hi, On 2023/5/30 03:36, Sam Ravnborg wrote: Hi Thomas, On Wed, May 24, 2023 at 11:21:50AM +0200, Thomas Zimmermann wrote: Implement dedicated fbdev helpers for framebuffer I/O instead of using DRM's helpers. Use an fbdev generator macro for deferred I/O to create the fbdev callbacks. i915 was the only caller of the DRM helpers, so remove them from the helper module. i915's fbdev emulation is still incomplete as it doesn't implement deferred I/O and damage handling for mmaped pages. v4: * generate deferred-I/O helpers * use initializer macros for fb_ops v2: * use FB_IO_HELPERS options Signed-off-by: Thomas Zimmermann Cc: Jani Nikula Cc: Joonas Lahtinen Cc: Rodrigo Vivi Cc: Tvrtko Ursulin Cc: "Ville Syrjälä" --- drivers/gpu/drm/Kconfig| 3 - drivers/gpu/drm/drm_fb_helper.c| 107 - drivers/gpu/drm/i915/Kconfig | 1 + drivers/gpu/drm/i915/display/intel_fbdev.c | 14 +-- include/drm/drm_fb_helper.h| 39 5 files changed, 9 insertions(+), 155 deletions(-) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 92a782827b7b..bb2e48cc6cd6 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -133,9 +133,6 @@ config DRM_FBDEV_EMULATION bool "Enable legacy fbdev support for your modesetting driver" depends on DRM_KMS_HELPER depends on FB=y || FB=DRM_KMS_HELPER - select FB_CFB_FILLRECT - select FB_CFB_COPYAREA - select FB_CFB_IMAGEBLIT select FRAMEBUFFER_CONSOLE if !EXPERT select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE default y diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index bab6b252f02a..9978147bbc8a 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -736,113 +736,6 @@ void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagerefli } EXPORT_SYMBOL(drm_fb_helper_deferred_io); -/** - * drm_fb_helper_cfb_read - Implements struct _ops.fb_read for I/O memory - * @info: fb_info struct pointer - * @buf: userspace buffer to read from framebuffer memory - * @count: number of bytes to read from framebuffer memory - * @ppos: read offset within framebuffer memory - * - * Returns: - * The number of bytes read on success, or an error code otherwise. - */ -ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf, - size_t count, loff_t *ppos) -{ - return fb_io_read(info, buf, count, ppos); -} -EXPORT_SYMBOL(drm_fb_helper_cfb_read); - -/** - * drm_fb_helper_cfb_write - Implements struct _ops.fb_write for I/O memory - * @info: fb_info struct pointer - * @buf: userspace buffer to write to framebuffer memory - * @count: number of bytes to write to framebuffer memory - * @ppos: write offset within framebuffer memory - * - * Returns: - * The number of bytes written on success, or an error code otherwise. - */ -ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char __user *buf, - size_t count, loff_t *ppos) -{ - struct drm_fb_helper *helper = info->par; - loff_t pos = *ppos; - ssize_t ret; - struct drm_rect damage_area; - - ret = fb_io_write(info, buf, count, ppos); - if (ret <= 0) - return ret; - - if (helper->funcs->fb_dirty) { - drm_fb_helper_memory_range_to_clip(info, pos, ret, _area); - drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1, -drm_rect_width(_area), -drm_rect_height(_area)); - } The generated helpers do not have the if (helper->funcs->fb_dirty) check. Nice catch! If I understand this correctly, fb_io_write() will write directly to the ultimate destination. There no need to check if (helper->funcs->fb_dirty) anymore. code inside the curly brace of `if (helper->funcs->fb_dirty) { }` can be delete safely . This could turn out to be an optimization. This is a benefit of untangled implement. previously this is a generic (tangled) implement, which intended to be used by both the UMA device driver and non-UMA device(with dedicate VRAM) driver. drm_fbdev_generic always has a shadow screen buffer allocated in system RAM, it always has the fb_dirty hooked, so this could be an optimization for fbdev_generic by eliminate if (helper->funcs->fb_dirty) check. while dma helper based driver could switch to drm_fbdev_dma, they writing to gem buffer directly, no shadow buffer is needed. With those patch, device driver with dedicated video memory can also choose FB_CFB_* to update (iomem)framebuffer directly, despite slower. Is this implemented somewhere else that I missed? Sam drm_fb_helper_fb_dirty() function has a check: ``` if (drm_WARN_ON_ONCE(dev, !helper->funcs->fb_dirty))
Re: [PATCH v4 13/13] drm/i915: Implement dedicated fbdev I/O helpers
Hi Thomas, On Wed, May 24, 2023 at 11:21:50AM +0200, Thomas Zimmermann wrote: > Implement dedicated fbdev helpers for framebuffer I/O instead > of using DRM's helpers. Use an fbdev generator macro for > deferred I/O to create the fbdev callbacks. i915 was the only > caller of the DRM helpers, so remove them from the helper module. > > i915's fbdev emulation is still incomplete as it doesn't implement > deferred I/O and damage handling for mmaped pages. > > v4: > * generate deferred-I/O helpers > * use initializer macros for fb_ops > v2: > * use FB_IO_HELPERS options > > Signed-off-by: Thomas Zimmermann > Cc: Jani Nikula > Cc: Joonas Lahtinen > Cc: Rodrigo Vivi > Cc: Tvrtko Ursulin > Cc: "Ville Syrjälä" > --- > drivers/gpu/drm/Kconfig| 3 - > drivers/gpu/drm/drm_fb_helper.c| 107 - > drivers/gpu/drm/i915/Kconfig | 1 + > drivers/gpu/drm/i915/display/intel_fbdev.c | 14 +-- > include/drm/drm_fb_helper.h| 39 > 5 files changed, 9 insertions(+), 155 deletions(-) Nice diffstat! Assuming there is a good explanation on the dirty check: Reviewed-by: Sam Ravnborg
Re: [PATCH v4 13/13] drm/i915: Implement dedicated fbdev I/O helpers
Hi Thomas, On Wed, May 24, 2023 at 11:21:50AM +0200, Thomas Zimmermann wrote: > Implement dedicated fbdev helpers for framebuffer I/O instead > of using DRM's helpers. Use an fbdev generator macro for > deferred I/O to create the fbdev callbacks. i915 was the only > caller of the DRM helpers, so remove them from the helper module. > > i915's fbdev emulation is still incomplete as it doesn't implement > deferred I/O and damage handling for mmaped pages. > > v4: > * generate deferred-I/O helpers > * use initializer macros for fb_ops > v2: > * use FB_IO_HELPERS options > > Signed-off-by: Thomas Zimmermann > Cc: Jani Nikula > Cc: Joonas Lahtinen > Cc: Rodrigo Vivi > Cc: Tvrtko Ursulin > Cc: "Ville Syrjälä" > --- > drivers/gpu/drm/Kconfig| 3 - > drivers/gpu/drm/drm_fb_helper.c| 107 - > drivers/gpu/drm/i915/Kconfig | 1 + > drivers/gpu/drm/i915/display/intel_fbdev.c | 14 +-- > include/drm/drm_fb_helper.h| 39 > 5 files changed, 9 insertions(+), 155 deletions(-) > > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig > index 92a782827b7b..bb2e48cc6cd6 100644 > --- a/drivers/gpu/drm/Kconfig > +++ b/drivers/gpu/drm/Kconfig > @@ -133,9 +133,6 @@ config DRM_FBDEV_EMULATION > bool "Enable legacy fbdev support for your modesetting driver" > depends on DRM_KMS_HELPER > depends on FB=y || FB=DRM_KMS_HELPER > - select FB_CFB_FILLRECT > - select FB_CFB_COPYAREA > - select FB_CFB_IMAGEBLIT > select FRAMEBUFFER_CONSOLE if !EXPERT > select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE > default y > diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c > index bab6b252f02a..9978147bbc8a 100644 > --- a/drivers/gpu/drm/drm_fb_helper.c > +++ b/drivers/gpu/drm/drm_fb_helper.c > @@ -736,113 +736,6 @@ void drm_fb_helper_deferred_io(struct fb_info *info, > struct list_head *pagerefli > } > EXPORT_SYMBOL(drm_fb_helper_deferred_io); > > -/** > - * drm_fb_helper_cfb_read - Implements struct _ops.fb_read for I/O memory > - * @info: fb_info struct pointer > - * @buf: userspace buffer to read from framebuffer memory > - * @count: number of bytes to read from framebuffer memory > - * @ppos: read offset within framebuffer memory > - * > - * Returns: > - * The number of bytes read on success, or an error code otherwise. > - */ > -ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf, > -size_t count, loff_t *ppos) > -{ > - return fb_io_read(info, buf, count, ppos); > -} > -EXPORT_SYMBOL(drm_fb_helper_cfb_read); > - > -/** > - * drm_fb_helper_cfb_write - Implements struct _ops.fb_write for I/O > memory > - * @info: fb_info struct pointer > - * @buf: userspace buffer to write to framebuffer memory > - * @count: number of bytes to write to framebuffer memory > - * @ppos: write offset within framebuffer memory > - * > - * Returns: > - * The number of bytes written on success, or an error code otherwise. > - */ > -ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char __user *buf, > - size_t count, loff_t *ppos) > -{ > - struct drm_fb_helper *helper = info->par; > - loff_t pos = *ppos; > - ssize_t ret; > - struct drm_rect damage_area; > - > - ret = fb_io_write(info, buf, count, ppos); > - if (ret <= 0) > - return ret; > - > - if (helper->funcs->fb_dirty) { > - drm_fb_helper_memory_range_to_clip(info, pos, ret, > _area); > - drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1, > - drm_rect_width(_area), > - drm_rect_height(_area)); > - } The generated helpers do not have the if (helper->funcs->fb_dirty) check. Is this implemented somewhere else that I missed? Sam > - > - return ret; > -} > -EXPORT_SYMBOL(drm_fb_helper_cfb_write); > - > -/** > - * drm_fb_helper_cfb_fillrect - wrapper around cfb_fillrect > - * @info: fbdev registered by the helper > - * @rect: info about rectangle to fill > - * > - * A wrapper around cfb_fillrect implemented by fbdev core > - */ > -void drm_fb_helper_cfb_fillrect(struct fb_info *info, > - const struct fb_fillrect *rect) > -{ > - struct drm_fb_helper *helper = info->par; > - > - cfb_fillrect(info, rect); > - > - if (helper->funcs->fb_dirty) > - drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, > rect->height); > -} > -EXPORT_SYMBOL(drm_fb_helper_cfb_fillrect); > - > -/** > - * drm_fb_helper_cfb_copyarea - wrapper around cfb_copyarea > - * @info: fbdev registered by the helper > - * @area: info about area to copy > - * > - * A wrapper around cfb_copyarea implemented by fbdev core > - */ > -void drm_fb_helper_cfb_copyarea(struct fb_info *info, > - const struct
[PATCH v4 13/13] drm/i915: Implement dedicated fbdev I/O helpers
Implement dedicated fbdev helpers for framebuffer I/O instead of using DRM's helpers. Use an fbdev generator macro for deferred I/O to create the fbdev callbacks. i915 was the only caller of the DRM helpers, so remove them from the helper module. i915's fbdev emulation is still incomplete as it doesn't implement deferred I/O and damage handling for mmaped pages. v4: * generate deferred-I/O helpers * use initializer macros for fb_ops v2: * use FB_IO_HELPERS options Signed-off-by: Thomas Zimmermann Cc: Jani Nikula Cc: Joonas Lahtinen Cc: Rodrigo Vivi Cc: Tvrtko Ursulin Cc: "Ville Syrjälä" --- drivers/gpu/drm/Kconfig| 3 - drivers/gpu/drm/drm_fb_helper.c| 107 - drivers/gpu/drm/i915/Kconfig | 1 + drivers/gpu/drm/i915/display/intel_fbdev.c | 14 +-- include/drm/drm_fb_helper.h| 39 5 files changed, 9 insertions(+), 155 deletions(-) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 92a782827b7b..bb2e48cc6cd6 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -133,9 +133,6 @@ config DRM_FBDEV_EMULATION bool "Enable legacy fbdev support for your modesetting driver" depends on DRM_KMS_HELPER depends on FB=y || FB=DRM_KMS_HELPER - select FB_CFB_FILLRECT - select FB_CFB_COPYAREA - select FB_CFB_IMAGEBLIT select FRAMEBUFFER_CONSOLE if !EXPERT select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE default y diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index bab6b252f02a..9978147bbc8a 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -736,113 +736,6 @@ void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagerefli } EXPORT_SYMBOL(drm_fb_helper_deferred_io); -/** - * drm_fb_helper_cfb_read - Implements struct _ops.fb_read for I/O memory - * @info: fb_info struct pointer - * @buf: userspace buffer to read from framebuffer memory - * @count: number of bytes to read from framebuffer memory - * @ppos: read offset within framebuffer memory - * - * Returns: - * The number of bytes read on success, or an error code otherwise. - */ -ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf, - size_t count, loff_t *ppos) -{ - return fb_io_read(info, buf, count, ppos); -} -EXPORT_SYMBOL(drm_fb_helper_cfb_read); - -/** - * drm_fb_helper_cfb_write - Implements struct _ops.fb_write for I/O memory - * @info: fb_info struct pointer - * @buf: userspace buffer to write to framebuffer memory - * @count: number of bytes to write to framebuffer memory - * @ppos: write offset within framebuffer memory - * - * Returns: - * The number of bytes written on success, or an error code otherwise. - */ -ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char __user *buf, - size_t count, loff_t *ppos) -{ - struct drm_fb_helper *helper = info->par; - loff_t pos = *ppos; - ssize_t ret; - struct drm_rect damage_area; - - ret = fb_io_write(info, buf, count, ppos); - if (ret <= 0) - return ret; - - if (helper->funcs->fb_dirty) { - drm_fb_helper_memory_range_to_clip(info, pos, ret, _area); - drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1, -drm_rect_width(_area), -drm_rect_height(_area)); - } - - return ret; -} -EXPORT_SYMBOL(drm_fb_helper_cfb_write); - -/** - * drm_fb_helper_cfb_fillrect - wrapper around cfb_fillrect - * @info: fbdev registered by the helper - * @rect: info about rectangle to fill - * - * A wrapper around cfb_fillrect implemented by fbdev core - */ -void drm_fb_helper_cfb_fillrect(struct fb_info *info, - const struct fb_fillrect *rect) -{ - struct drm_fb_helper *helper = info->par; - - cfb_fillrect(info, rect); - - if (helper->funcs->fb_dirty) - drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, rect->height); -} -EXPORT_SYMBOL(drm_fb_helper_cfb_fillrect); - -/** - * drm_fb_helper_cfb_copyarea - wrapper around cfb_copyarea - * @info: fbdev registered by the helper - * @area: info about area to copy - * - * A wrapper around cfb_copyarea implemented by fbdev core - */ -void drm_fb_helper_cfb_copyarea(struct fb_info *info, - const struct fb_copyarea *area) -{ - struct drm_fb_helper *helper = info->par; - - cfb_copyarea(info, area); - - if (helper->funcs->fb_dirty) - drm_fb_helper_damage(helper, area->dx, area->dy, area->width, area->height); -} -EXPORT_SYMBOL(drm_fb_helper_cfb_copyarea); - -/** - * drm_fb_helper_cfb_imageblit - wrapper around cfb_imageblit - * @info: fbdev registered by the helper - * @image: