drm/i915: Make intel_pin_and_fence_fb_obj take plane and framebuffer

It will help future code if this function knows something about of the context
of the display setup object is being pinned for.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
Tvrtko Ursulin 2014-10-30 16:39:38 +00:00 committed by Daniel Vetter
parent 1df06b75f0
commit 850c4cdc6c
4 changed files with 25 additions and 24 deletions

View file

@ -2194,11 +2194,13 @@ static int intel_align_height(struct drm_device *dev, int height, bool tiled)
} }
int int
intel_pin_and_fence_fb_obj(struct drm_device *dev, intel_pin_and_fence_fb_obj(struct drm_plane *plane,
struct drm_i915_gem_object *obj, struct drm_framebuffer *fb,
struct intel_engine_cs *pipelined) struct intel_engine_cs *pipelined)
{ {
struct drm_device *dev = fb->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct drm_i915_gem_object *obj = intel_fb_obj(fb);
u32 alignment; u32 alignment;
int ret; int ret;
@ -2897,7 +2899,6 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
struct intel_crtc *intel_crtc = to_intel_crtc(crtc); struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
enum pipe pipe = intel_crtc->pipe; enum pipe pipe = intel_crtc->pipe;
struct drm_framebuffer *old_fb = crtc->primary->fb; struct drm_framebuffer *old_fb = crtc->primary->fb;
struct drm_i915_gem_object *obj = intel_fb_obj(fb);
struct drm_i915_gem_object *old_obj = intel_fb_obj(old_fb); struct drm_i915_gem_object *old_obj = intel_fb_obj(old_fb);
int ret; int ret;
@ -2920,9 +2921,9 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
} }
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
ret = intel_pin_and_fence_fb_obj(dev, obj, NULL); ret = intel_pin_and_fence_fb_obj(crtc->primary, fb, NULL);
if (ret == 0) if (ret == 0)
i915_gem_track_fb(old_obj, obj, i915_gem_track_fb(old_obj, intel_fb_obj(fb),
INTEL_FRONTBUFFER_PRIMARY(pipe)); INTEL_FRONTBUFFER_PRIMARY(pipe));
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
if (ret != 0) { if (ret != 0) {
@ -9689,7 +9690,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
ring = &dev_priv->ring[RCS]; ring = &dev_priv->ring[RCS];
} }
ret = intel_pin_and_fence_fb_obj(dev, obj, ring); ret = intel_pin_and_fence_fb_obj(crtc->primary, fb, ring);
if (ret) if (ret)
goto cleanup_pending; goto cleanup_pending;
@ -10857,9 +10858,7 @@ static int __intel_set_mode(struct drm_crtc *crtc,
struct drm_i915_gem_object *obj = intel_fb_obj(fb); struct drm_i915_gem_object *obj = intel_fb_obj(fb);
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
ret = intel_pin_and_fence_fb_obj(dev, ret = intel_pin_and_fence_fb_obj(crtc->primary, fb, NULL);
obj,
NULL);
if (ret != 0) { if (ret != 0) {
DRM_ERROR("pin & fence failed\n"); DRM_ERROR("pin & fence failed\n");
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
@ -11525,7 +11524,7 @@ intel_prepare_primary_plane(struct drm_plane *plane,
if (old_obj != obj) { if (old_obj != obj) {
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
ret = intel_pin_and_fence_fb_obj(dev, obj, NULL); ret = intel_pin_and_fence_fb_obj(plane, fb, NULL);
if (ret == 0) if (ret == 0)
i915_gem_track_fb(old_obj, obj, i915_gem_track_fb(old_obj, obj,
INTEL_FRONTBUFFER_PRIMARY(pipe)); INTEL_FRONTBUFFER_PRIMARY(pipe));
@ -13293,7 +13292,9 @@ void intel_modeset_gem_init(struct drm_device *dev)
if (obj == NULL) if (obj == NULL)
continue; continue;
if (intel_pin_and_fence_fb_obj(dev, obj, NULL)) { if (intel_pin_and_fence_fb_obj(c->primary,
c->primary->fb,
NULL)) {
DRM_ERROR("failed to pin boot fb on pipe %d\n", DRM_ERROR("failed to pin boot fb on pipe %d\n",
to_intel_crtc(c)->pipe); to_intel_crtc(c)->pipe);
drm_framebuffer_unreference(c->primary->fb); drm_framebuffer_unreference(c->primary->fb);

View file

@ -896,8 +896,8 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector,
struct drm_modeset_acquire_ctx *ctx); struct drm_modeset_acquire_ctx *ctx);
void intel_release_load_detect_pipe(struct drm_connector *connector, void intel_release_load_detect_pipe(struct drm_connector *connector,
struct intel_load_detect_pipe *old); struct intel_load_detect_pipe *old);
int intel_pin_and_fence_fb_obj(struct drm_device *dev, int intel_pin_and_fence_fb_obj(struct drm_plane *plane,
struct drm_i915_gem_object *obj, struct drm_framebuffer *fb,
struct intel_engine_cs *pipelined); struct intel_engine_cs *pipelined);
void intel_unpin_fb_obj(struct drm_i915_gem_object *obj); void intel_unpin_fb_obj(struct drm_i915_gem_object *obj);
struct drm_framebuffer * struct drm_framebuffer *

View file

@ -119,25 +119,25 @@ static int intelfb_alloc(struct drm_fb_helper *helper,
goto out; goto out;
} }
/* Flush everything out, we'll be doing GTT only from now on */
ret = intel_pin_and_fence_fb_obj(dev, obj, NULL);
if (ret) {
DRM_ERROR("failed to pin obj: %d\n", ret);
goto out_unref;
}
fb = __intel_framebuffer_create(dev, &mode_cmd, obj); fb = __intel_framebuffer_create(dev, &mode_cmd, obj);
if (IS_ERR(fb)) { if (IS_ERR(fb)) {
ret = PTR_ERR(fb); ret = PTR_ERR(fb);
goto out_unpin; goto out_unref;
}
/* Flush everything out, we'll be doing GTT only from now on */
ret = intel_pin_and_fence_fb_obj(NULL, fb, NULL);
if (ret) {
DRM_ERROR("failed to pin obj: %d\n", ret);
goto out_fb;
} }
ifbdev->fb = to_intel_framebuffer(fb); ifbdev->fb = to_intel_framebuffer(fb);
return 0; return 0;
out_unpin: out_fb:
i915_gem_object_ggtt_unpin(obj); drm_framebuffer_remove(fb);
out_unref: out_unref:
drm_gem_object_unreference(&obj->base); drm_gem_object_unreference(&obj->base);
out: out:

View file

@ -1256,7 +1256,7 @@ intel_prepare_sprite_plane(struct drm_plane *plane,
* the sprite planes only require 128KiB alignment and 32 PTE * the sprite planes only require 128KiB alignment and 32 PTE
* padding. * padding.
*/ */
ret = intel_pin_and_fence_fb_obj(dev, obj, NULL); ret = intel_pin_and_fence_fb_obj(plane, fb, NULL);
if (ret == 0) if (ret == 0)
i915_gem_track_fb(old_obj, obj, i915_gem_track_fb(old_obj, obj,
INTEL_FRONTBUFFER_SPRITE(pipe)); INTEL_FRONTBUFFER_SPRITE(pipe));