mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-05-06 23:33:43 +00:00
drm/vmwgfx: Unpin the screen object backup buffer when not used
We were relying on the pinned screen object backup buffer to be destroyed when not used. But if we hold a copy of the atomic state, like when hibernating, the backup buffer might not be destroyed since it's refcounted by the atomic state. This causes us to hibernate with a buffer pinned in VRAM. Fix this by only having the buffer pinned when it is actually used by a screen object. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Sinclair Yeh <syeh@vmware.com>
This commit is contained in:
parent
89dc15b76f
commit
20fb5a635a
1 changed files with 21 additions and 8 deletions
|
@ -405,7 +405,11 @@ vmw_sou_primary_plane_cleanup_fb(struct drm_plane *plane,
|
||||||
struct drm_plane_state *old_state)
|
struct drm_plane_state *old_state)
|
||||||
{
|
{
|
||||||
struct vmw_plane_state *vps = vmw_plane_state_to_vps(old_state);
|
struct vmw_plane_state *vps = vmw_plane_state_to_vps(old_state);
|
||||||
|
struct drm_crtc *crtc = plane->state->crtc ?
|
||||||
|
plane->state->crtc : old_state->crtc;
|
||||||
|
|
||||||
|
if (vps->dmabuf)
|
||||||
|
vmw_dmabuf_unpin(vmw_priv(crtc->dev), vps->dmabuf, false);
|
||||||
vmw_dmabuf_unreference(&vps->dmabuf);
|
vmw_dmabuf_unreference(&vps->dmabuf);
|
||||||
vps->dmabuf_size = 0;
|
vps->dmabuf_size = 0;
|
||||||
|
|
||||||
|
@ -443,10 +447,17 @@ vmw_sou_primary_plane_prepare_fb(struct drm_plane *plane,
|
||||||
}
|
}
|
||||||
|
|
||||||
size = new_state->crtc_w * new_state->crtc_h * 4;
|
size = new_state->crtc_w * new_state->crtc_h * 4;
|
||||||
|
dev_priv = vmw_priv(crtc->dev);
|
||||||
|
|
||||||
if (vps->dmabuf) {
|
if (vps->dmabuf) {
|
||||||
if (vps->dmabuf_size == size)
|
if (vps->dmabuf_size == size) {
|
||||||
return 0;
|
/*
|
||||||
|
* Note that this might temporarily up the pin-count
|
||||||
|
* to 2, until cleanup_fb() is called.
|
||||||
|
*/
|
||||||
|
return vmw_dmabuf_pin_in_vram(dev_priv, vps->dmabuf,
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
vmw_dmabuf_unreference(&vps->dmabuf);
|
vmw_dmabuf_unreference(&vps->dmabuf);
|
||||||
vps->dmabuf_size = 0;
|
vps->dmabuf_size = 0;
|
||||||
|
@ -456,7 +467,6 @@ vmw_sou_primary_plane_prepare_fb(struct drm_plane *plane,
|
||||||
if (!vps->dmabuf)
|
if (!vps->dmabuf)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
dev_priv = vmw_priv(crtc->dev);
|
|
||||||
vmw_svga_enable(dev_priv);
|
vmw_svga_enable(dev_priv);
|
||||||
|
|
||||||
/* After we have alloced the backing store might not be able to
|
/* After we have alloced the backing store might not be able to
|
||||||
|
@ -467,13 +477,16 @@ vmw_sou_primary_plane_prepare_fb(struct drm_plane *plane,
|
||||||
&vmw_vram_ne_placement,
|
&vmw_vram_ne_placement,
|
||||||
false, &vmw_dmabuf_bo_free);
|
false, &vmw_dmabuf_bo_free);
|
||||||
vmw_overlay_resume_all(dev_priv);
|
vmw_overlay_resume_all(dev_priv);
|
||||||
|
if (ret) {
|
||||||
if (ret != 0)
|
|
||||||
vps->dmabuf = NULL; /* vmw_dmabuf_init frees on error */
|
vps->dmabuf = NULL; /* vmw_dmabuf_init frees on error */
|
||||||
else
|
return ret;
|
||||||
vps->dmabuf_size = size;
|
}
|
||||||
|
|
||||||
return ret;
|
/*
|
||||||
|
* TTM already thinks the buffer is pinned, but make sure the
|
||||||
|
* pin_count is upped.
|
||||||
|
*/
|
||||||
|
return vmw_dmabuf_pin_in_vram(dev_priv, vps->dmabuf, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue