Skip to content

Commit 359c664

Browse files
author
Thomas Zimmermann
committed
drm/gem: Implement shadow-plane {begin, end}_fb_access with vmap
Move the vmap code for shadow-plane helpers from prepare_fb to begin_fb_access helpers. Vunmap is now performed at the end of the current pageflip, instead of the end of the following pageflip. Reduces the duration of the mapping from while the framebuffer is being displayed to just the atomic commit. This is safe as outside of the pageflip, nothing should access the mapped buffer memory. Unmapping the framebuffer BO memory early allows to reduce address- space consumption and possibly allows for evicting the memory pages. The change is effectively a rename of prepare_fb and cleanup_fb implementations, plus updates to the shadow-plane init macro. As there's no longer a prepare_fb helper for shadow planes, atomic helpers will call drm_gem_plane_helper_prepare_fb() automatically. v2: * fix typos in commit message (Javier) Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Javier Martinez Canillas <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 94d879e commit 359c664

File tree

2 files changed

+31
-36
lines changed

2 files changed

+31
-36
lines changed

drivers/gpu/drm/drm_gem_atomic_helper.c

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -360,48 +360,43 @@ void drm_gem_reset_shadow_plane(struct drm_plane *plane)
360360
EXPORT_SYMBOL(drm_gem_reset_shadow_plane);
361361

362362
/**
363-
* drm_gem_prepare_shadow_fb - prepares shadow framebuffers
363+
* drm_gem_begin_shadow_fb_access - prepares shadow framebuffers for CPU access
364364
* @plane: the plane
365365
* @plane_state: the plane state of type struct drm_shadow_plane_state
366366
*
367-
* This function implements struct &drm_plane_helper_funcs.prepare_fb. It
367+
* This function implements struct &drm_plane_helper_funcs.begin_fb_access. It
368368
* maps all buffer objects of the plane's framebuffer into kernel address
369-
* space and stores them in &struct drm_shadow_plane_state.map. The
370-
* framebuffer will be synchronized as part of the atomic commit.
369+
* space and stores them in struct &drm_shadow_plane_state.map. The first data
370+
* bytes are available in struct &drm_shadow_plane_state.data.
371371
*
372-
* See drm_gem_cleanup_shadow_fb() for cleanup.
372+
* See drm_gem_end_shadow_fb_access() for cleanup.
373373
*
374374
* Returns:
375375
* 0 on success, or a negative errno code otherwise.
376376
*/
377-
int drm_gem_prepare_shadow_fb(struct drm_plane *plane, struct drm_plane_state *plane_state)
377+
int drm_gem_begin_shadow_fb_access(struct drm_plane *plane, struct drm_plane_state *plane_state)
378378
{
379379
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
380380
struct drm_framebuffer *fb = plane_state->fb;
381-
int ret;
382381

383382
if (!fb)
384383
return 0;
385384

386-
ret = drm_gem_plane_helper_prepare_fb(plane, plane_state);
387-
if (ret)
388-
return ret;
389-
390385
return drm_gem_fb_vmap(fb, shadow_plane_state->map, shadow_plane_state->data);
391386
}
392-
EXPORT_SYMBOL(drm_gem_prepare_shadow_fb);
387+
EXPORT_SYMBOL(drm_gem_begin_shadow_fb_access);
393388

394389
/**
395-
* drm_gem_cleanup_shadow_fb - releases shadow framebuffers
390+
* drm_gem_end_shadow_fb_access - releases shadow framebuffers from CPU access
396391
* @plane: the plane
397392
* @plane_state: the plane state of type struct drm_shadow_plane_state
398393
*
399-
* This function implements struct &drm_plane_helper_funcs.cleanup_fb.
400-
* This function unmaps all buffer objects of the plane's framebuffer.
394+
* This function implements struct &drm_plane_helper_funcs.end_fb_access. It
395+
* undoes all effects of drm_gem_begin_shadow_fb_access() in reverse order.
401396
*
402-
* See drm_gem_prepare_shadow_fb() for more information.
397+
* See drm_gem_begin_shadow_fb_access() for more information.
403398
*/
404-
void drm_gem_cleanup_shadow_fb(struct drm_plane *plane, struct drm_plane_state *plane_state)
399+
void drm_gem_end_shadow_fb_access(struct drm_plane *plane, struct drm_plane_state *plane_state)
405400
{
406401
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
407402
struct drm_framebuffer *fb = plane_state->fb;
@@ -411,7 +406,7 @@ void drm_gem_cleanup_shadow_fb(struct drm_plane *plane, struct drm_plane_state *
411406

412407
drm_gem_fb_vunmap(fb, shadow_plane_state->map);
413408
}
414-
EXPORT_SYMBOL(drm_gem_cleanup_shadow_fb);
409+
EXPORT_SYMBOL(drm_gem_end_shadow_fb_access);
415410

416411
/**
417412
* drm_gem_simple_kms_begin_shadow_fb_access - prepares shadow framebuffers for CPU access
@@ -426,12 +421,12 @@ EXPORT_SYMBOL(drm_gem_cleanup_shadow_fb);
426421
* Returns:
427422
* 0 on success, or a negative errno code otherwise.
428423
*/
429-
int drm_gem_simple_kms_prepare_shadow_fb(struct drm_simple_display_pipe *pipe,
430-
struct drm_plane_state *plane_state)
424+
int drm_gem_simple_kms_begin_shadow_fb_access(struct drm_simple_display_pipe *pipe,
425+
struct drm_plane_state *plane_state)
431426
{
432-
return drm_gem_prepare_shadow_fb(&pipe->plane, plane_state);
427+
return drm_gem_begin_shadow_fb_access(&pipe->plane, plane_state);
433428
}
434-
EXPORT_SYMBOL(drm_gem_simple_kms_prepare_shadow_fb);
429+
EXPORT_SYMBOL(drm_gem_simple_kms_begin_shadow_fb_access);
435430

436431
/**
437432
* drm_gem_simple_kms_end_shadow_fb_access - releases shadow framebuffers from CPU access
@@ -444,12 +439,12 @@ EXPORT_SYMBOL(drm_gem_simple_kms_prepare_shadow_fb);
444439
*
445440
* See drm_gem_simple_kms_begin_shadow_fb_access().
446441
*/
447-
void drm_gem_simple_kms_cleanup_shadow_fb(struct drm_simple_display_pipe *pipe,
448-
struct drm_plane_state *plane_state)
442+
void drm_gem_simple_kms_end_shadow_fb_access(struct drm_simple_display_pipe *pipe,
443+
struct drm_plane_state *plane_state)
449444
{
450-
drm_gem_cleanup_shadow_fb(&pipe->plane, plane_state);
445+
drm_gem_end_shadow_fb_access(&pipe->plane, plane_state);
451446
}
452-
EXPORT_SYMBOL(drm_gem_simple_kms_cleanup_shadow_fb);
447+
EXPORT_SYMBOL(drm_gem_simple_kms_end_shadow_fb_access);
453448

454449
/**
455450
* drm_gem_simple_kms_reset_shadow_plane - resets a shadow-buffered plane

include/drm/drm_gem_atomic_helper.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ void drm_gem_destroy_shadow_plane_state(struct drm_plane *plane,
103103
.atomic_duplicate_state = drm_gem_duplicate_shadow_plane_state, \
104104
.atomic_destroy_state = drm_gem_destroy_shadow_plane_state
105105

106-
int drm_gem_prepare_shadow_fb(struct drm_plane *plane, struct drm_plane_state *plane_state);
107-
void drm_gem_cleanup_shadow_fb(struct drm_plane *plane, struct drm_plane_state *plane_state);
106+
int drm_gem_begin_shadow_fb_access(struct drm_plane *plane, struct drm_plane_state *plane_state);
107+
void drm_gem_end_shadow_fb_access(struct drm_plane *plane, struct drm_plane_state *plane_state);
108108

109109
/**
110110
* DRM_GEM_SHADOW_PLANE_HELPER_FUNCS -
@@ -115,13 +115,13 @@ void drm_gem_cleanup_shadow_fb(struct drm_plane *plane, struct drm_plane_state *
115115
* functions.
116116
*/
117117
#define DRM_GEM_SHADOW_PLANE_HELPER_FUNCS \
118-
.prepare_fb = drm_gem_prepare_shadow_fb, \
119-
.cleanup_fb = drm_gem_cleanup_shadow_fb
118+
.begin_fb_access = drm_gem_begin_shadow_fb_access, \
119+
.end_fb_access = drm_gem_end_shadow_fb_access
120120

121-
int drm_gem_simple_kms_prepare_shadow_fb(struct drm_simple_display_pipe *pipe,
122-
struct drm_plane_state *plane_state);
123-
void drm_gem_simple_kms_cleanup_shadow_fb(struct drm_simple_display_pipe *pipe,
124-
struct drm_plane_state *plane_state);
121+
int drm_gem_simple_kms_begin_shadow_fb_access(struct drm_simple_display_pipe *pipe,
122+
struct drm_plane_state *plane_state);
123+
void drm_gem_simple_kms_end_shadow_fb_access(struct drm_simple_display_pipe *pipe,
124+
struct drm_plane_state *plane_state);
125125
void drm_gem_simple_kms_reset_shadow_plane(struct drm_simple_display_pipe *pipe);
126126
struct drm_plane_state *
127127
drm_gem_simple_kms_duplicate_shadow_plane_state(struct drm_simple_display_pipe *pipe);
@@ -137,8 +137,8 @@ void drm_gem_simple_kms_destroy_shadow_plane_state(struct drm_simple_display_pip
137137
* functions.
138138
*/
139139
#define DRM_GEM_SIMPLE_DISPLAY_PIPE_SHADOW_PLANE_FUNCS \
140-
.prepare_fb = drm_gem_simple_kms_prepare_shadow_fb, \
141-
.cleanup_fb = drm_gem_simple_kms_cleanup_shadow_fb, \
140+
.begin_fb_access = drm_gem_simple_kms_begin_shadow_fb_access, \
141+
.end_fb_access = drm_gem_simple_kms_end_shadow_fb_access, \
142142
.reset_plane = drm_gem_simple_kms_reset_shadow_plane, \
143143
.duplicate_plane_state = drm_gem_simple_kms_duplicate_shadow_plane_state, \
144144
.destroy_plane_state = drm_gem_simple_kms_destroy_shadow_plane_state

0 commit comments

Comments
 (0)