diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-04-23 11:34:06 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-04-23 14:06:47 -0400 |
commit | 0fe27f063fcef920a0be93ad5e89d9c8ef5c5858 (patch) | |
tree | a9cbdea36556a405dca0e01d3aba21f8e41ae422 /drivers/gpu/drm/drm_plane_helper.c | |
parent | 49d9ec1ca62a4341f387617258107a5ee7f7b3ed (diff) |
drm: Simplify fb refcounting rules around ->update_plane
The introduction of primary planes has apparently caused a bit of fb
refcounting fun for people. That makes it a good time to clean up the
arcane rules and slight differences between ->update_plane and
->set_config. The new rules are:
- The core holds a reference for both the new and the old fb (if
they're non-NULL of course) while calling into the driver through
either ->update_plane or ->set_config.
- Drivers may not clobber plane->fb if their callback fails. If they
do that, they need to store a pointer to the old fb in it again.
When calling into the driver plane->fb still points at the current
(old) framebuffer.
- The core will update the plane->fb pointer on success. Drivers can
do that themselves too, but aren't required to any more for the
primary plane.
- The core will update fb refcounts for the plane->fb pointer,
presuming the drivers hold up their end of the bargain.
v2: Remove now unused tmpfb (Thierry)
v3: Drop broken changes from drm_mode_setplane (Ville). Also polish
the commit message a bit.
v4: Also fix up the handling of ->disable_plane in
drm_plane_force_disable. The issue was that we didn't save plane->fb
over the ->disable_plane call. Just paranoia, nothing relies on this.
v5: Keep still useful comments about directly calling ->set_config,
which I should have done for v4 already. Requested by Matt.
Cc: Thierry Reding <treding@nvidia.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/drm_plane_helper.c')
-rw-r--r-- | drivers/gpu/drm/drm_plane_helper.c | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c index 9540ff9f97fe..d966afa7ecae 100644 --- a/drivers/gpu/drm/drm_plane_helper.c +++ b/drivers/gpu/drm/drm_plane_helper.c | |||
@@ -124,7 +124,6 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc, | |||
124 | .y2 = crtc->mode.vdisplay, | 124 | .y2 = crtc->mode.vdisplay, |
125 | }; | 125 | }; |
126 | struct drm_connector **connector_list; | 126 | struct drm_connector **connector_list; |
127 | struct drm_framebuffer *tmpfb; | ||
128 | int num_connectors, ret; | 127 | int num_connectors, ret; |
129 | 128 | ||
130 | if (!crtc->enabled) { | 129 | if (!crtc->enabled) { |
@@ -178,21 +177,14 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc, | |||
178 | set.num_connectors = num_connectors; | 177 | set.num_connectors = num_connectors; |
179 | 178 | ||
180 | /* | 179 | /* |
181 | * set_config() adjusts crtc->primary->fb; however the DRM setplane | 180 | * We call set_config() directly here rather than using |
182 | * code that called us expects to handle the framebuffer update and | ||
183 | * reference counting; save and restore the current fb before | ||
184 | * calling it. | ||
185 | * | ||
186 | * N.B., we call set_config() directly here rather than using | ||
187 | * drm_mode_set_config_internal. We're reprogramming the same | 181 | * drm_mode_set_config_internal. We're reprogramming the same |
188 | * connectors that were already in use, so we shouldn't need the extra | 182 | * connectors that were already in use, so we shouldn't need the extra |
189 | * cross-CRTC fb refcounting to accomodate stealing connectors. | 183 | * cross-CRTC fb refcounting to accomodate stealing connectors. |
190 | * drm_mode_setplane() already handles the basic refcounting for the | 184 | * drm_mode_setplane() already handles the basic refcounting for the |
191 | * framebuffers involved in this operation. | 185 | * framebuffers involved in this operation. |
192 | */ | 186 | */ |
193 | tmpfb = plane->fb; | ||
194 | ret = crtc->funcs->set_config(&set); | 187 | ret = crtc->funcs->set_config(&set); |
195 | plane->fb = tmpfb; | ||
196 | 188 | ||
197 | kfree(connector_list); | 189 | kfree(connector_list); |
198 | return ret; | 190 | return ret; |