Skip to content

Commit 0a61156

Browse files
effective-lightalexdeucher
authored andcommitted
drm/amdgpu: register a dirty framebuffer callback for fbcon
fbcon requires that we implement &drm_framebuffer_funcs.dirty. Otherwise, the framebuffer might take a while to flush (which would manifest as noticeable lag). However, we can't enable this callback for non-fbcon cases since it may cause too many atomic commits to be made at once. So, implement amdgpu_dirtyfb() and only enable it for fbcon framebuffers (we can use the "struct drm_file file" parameter in the callback to check for this since it is only NULL when called by fbcon, at least in the mainline kernel) on devices that support atomic KMS. Cc: Aurabindo Pillai <[email protected]> Cc: Mario Limonciello <[email protected]> Cc: [email protected] # 6.1+ Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2519 Reviewed-by: Mario Limonciello <[email protected]> Signed-off-by: Hamza Mahfooz <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 7b9f623 commit 0a61156

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#include <linux/pci.h>
3939
#include <linux/pm_runtime.h>
4040
#include <drm/drm_crtc_helper.h>
41+
#include <drm/drm_damage_helper.h>
42+
#include <drm/drm_drv.h>
4143
#include <drm/drm_edid.h>
4244
#include <drm/drm_fb_helper.h>
4345
#include <drm/drm_gem_framebuffer_helper.h>
@@ -532,11 +534,29 @@ bool amdgpu_display_ddc_probe(struct amdgpu_connector *amdgpu_connector,
532534
return true;
533535
}
534536

537+
static int amdgpu_dirtyfb(struct drm_framebuffer *fb, struct drm_file *file,
538+
unsigned int flags, unsigned int color,
539+
struct drm_clip_rect *clips, unsigned int num_clips)
540+
{
541+
542+
if (file)
543+
return -ENOSYS;
544+
545+
return drm_atomic_helper_dirtyfb(fb, file, flags, color, clips,
546+
num_clips);
547+
}
548+
535549
static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
536550
.destroy = drm_gem_fb_destroy,
537551
.create_handle = drm_gem_fb_create_handle,
538552
};
539553

554+
static const struct drm_framebuffer_funcs amdgpu_fb_funcs_atomic = {
555+
.destroy = drm_gem_fb_destroy,
556+
.create_handle = drm_gem_fb_create_handle,
557+
.dirty = amdgpu_dirtyfb
558+
};
559+
540560
uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,
541561
uint64_t bo_flags)
542562
{
@@ -1139,7 +1159,11 @@ static int amdgpu_display_gem_fb_verify_and_init(struct drm_device *dev,
11391159
if (ret)
11401160
goto err;
11411161

1142-
ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
1162+
if (drm_drv_uses_atomic_modeset(dev))
1163+
ret = drm_framebuffer_init(dev, &rfb->base,
1164+
&amdgpu_fb_funcs_atomic);
1165+
else
1166+
ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
11431167

11441168
if (ret)
11451169
goto err;

0 commit comments

Comments
 (0)