From patchwork Wed Dec 12 16:16:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 1869431 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 5B729DF266 for ; Wed, 12 Dec 2012 18:02:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5E419E6618 for ; Wed, 12 Dec 2012 10:02:08 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id A8FE1E5DCF; Wed, 12 Dec 2012 08:20:58 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 12 Dec 2012 08:20:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.84,267,1355126400"; d="scan'208";a="263033560" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.168]) by fmsmga002.fm.intel.com with SMTP; 12 Dec 2012 08:20:55 -0800 Received: by stinkbox (sSMTP sendmail emulation); Wed, 12 Dec 2012 18:20:54 +0200 From: ville.syrjala@linux.intel.com To: dri-devel@lists.freedesktop.org Date: Wed, 12 Dec 2012 18:16:36 +0200 Message-Id: <1355329008-31459-70-git-send-email-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 1.7.8.6 In-Reply-To: <1355329008-31459-1-git-send-email-ville.syrjala@linux.intel.com> References: <1355329008-31459-1-git-send-email-ville.syrjala@linux.intel.com> MIME-Version: 1.0 Cc: intel-gfx@lists.freedesktop.org Subject: [Intel-gfx] [PATCH 69/81] drm/i915: Refactor flip preaparation X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org From: Ville Syrjälä Most of the code for preparing the 'struct intel_flip' instances was identical betwen the CRTC and plane codepaths. Refactor the common parts into a single function. Signed-off-by: Ville Syrjälä --- drivers/gpu/drm/i915/intel_atomic.c | 122 +++++++++++++++-------------------- 1 files changed, 52 insertions(+), 70 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c index 36446d1..3717e89 100644 --- a/drivers/gpu/drm/i915/intel_atomic.c +++ b/drivers/gpu/drm/i915/intel_atomic.c @@ -2258,6 +2258,50 @@ void intel_atomic_wedged(struct drm_device *dev) spin_unlock_irqrestore(&dev_priv->flip.lock, flags); } +static void intel_atomic_flip_init(struct intel_flip *intel_flip, + struct drm_device *dev, + u32 flip_seq, + struct drm_i915_file_private *file_priv, + struct drm_pending_atomic_event *event, + struct drm_framebuffer *fb, + bool unpin_old_fb, struct drm_framebuffer *old_fb) +{ + intel_flip->flip_seq = flip_seq; + + if (event) { + intel_flip->event = event; + + /* need to keep track of it in case process exits */ + spin_lock_irq(&dev->event_lock); + list_add_tail(&intel_flip->pending_head, &file_priv->pending_flips); + spin_unlock_irq(&dev->event_lock); + } + + if (fb) { + struct drm_i915_gem_object *obj = to_intel_framebuffer(fb)->obj; + + mutex_lock(&dev->struct_mutex); +#ifdef USE_WRITE_SEQNO + intel_flip->seqno = obj->last_write_seqno; +#else + intel_flip->seqno = obj->last_read_seqno; +#endif + intel_flip->ring = obj->ring; + mutex_unlock(&dev->struct_mutex); + } + + if (old_fb) + intel_flip->old_fb_id = old_fb->base.id; + + if (unpin_old_fb && old_fb) { + intel_flip->old_bo = to_intel_framebuffer(old_fb)->obj; + + mutex_lock(&dev->struct_mutex); + drm_gem_object_reference(&intel_flip->old_bo->base); + mutex_unlock(&dev->struct_mutex); + } +} + static void atomic_pipe_commit(struct drm_device *dev, struct intel_atomic_state *state, int pipe) @@ -2290,33 +2334,13 @@ static void atomic_pipe_commit(struct drm_device *dev, drm_flip_init(&intel_flip->base, &intel_crtc->flip_helper); - intel_flip->flip_seq = flip_seq; - - if (st->event) { - intel_flip->event = st->event; - st->event = NULL; - /* need to keep track of it in case process exits */ - spin_lock_irq(&dev->event_lock); - list_add_tail(&intel_flip->pending_head, - &file_priv->pending_flips); - spin_unlock_irq(&dev->event_lock); - } + intel_atomic_flip_init(intel_flip, dev, flip_seq, + file_priv, st->event, crtc->fb, + st->fb_dirty, st->old.fb); + st->event = NULL; intel_flip->crtc = crtc; - if (crtc->fb) { - struct drm_i915_gem_object *obj = to_intel_framebuffer(crtc->fb)->obj; - - mutex_lock(&dev->struct_mutex); -#ifdef USE_WRITE_SEQNO - intel_flip->seqno = obj->last_write_seqno; -#else - intel_flip->seqno = obj->last_read_seqno; -#endif - intel_flip->ring = obj->ring; - mutex_unlock(&dev->struct_mutex); - } - /* update primary_disabled befoer calc_plane() */ intel_crtc->primary_disabled = st->primary_disabled; @@ -2330,17 +2354,6 @@ static void atomic_pipe_commit(struct drm_device *dev, intel_flip->old_cursor_bo = st->old.cursor_bo; } - if (st->old.fb) - intel_flip->old_fb_id = st->old.fb->base.id; - - if (st->fb_dirty && st->old.fb) { - intel_flip->old_bo = to_intel_framebuffer(st->old.fb)->obj; - - mutex_lock(&dev->struct_mutex); - drm_gem_object_reference(&intel_flip->old_bo->base); - mutex_unlock(&dev->struct_mutex); - } - list_add_tail(&intel_flip->base.list, &flips); } @@ -2361,48 +2374,17 @@ static void atomic_pipe_commit(struct drm_device *dev, drm_flip_init(&intel_flip->base, &intel_plane->flip_helper); - intel_flip->flip_seq = flip_seq; - - if (st->event) { - intel_flip->event = st->event; - st->event = NULL; - /* need to keep track of it in case process exits */ - spin_lock_irq(&dev->event_lock); - list_add_tail(&intel_flip->pending_head, - &file_priv->pending_flips); - spin_unlock_irq(&dev->event_lock); - } + intel_atomic_flip_init(intel_flip, dev, flip_seq, + file_priv, st->event, plane->fb, + st->dirty, st->old.fb); + st->event = NULL; intel_flip->crtc = intel_get_crtc_for_pipe(dev, pipe); intel_flip->plane = plane; - if (plane->fb) { - struct drm_i915_gem_object *obj = to_intel_framebuffer(plane->fb)->obj; - - mutex_lock(&dev->struct_mutex); -#ifdef USE_WRITE_SEQNO - intel_flip->seqno = obj->last_write_seqno; -#else - intel_flip->seqno = obj->last_read_seqno; -#endif - intel_flip->ring = obj->ring; - mutex_unlock(&dev->struct_mutex); - } - intel_plane->calc(plane, plane->fb, &st->coords); intel_flip->regs = intel_plane->regs; - if (st->old.fb) - intel_flip->old_fb_id = st->old.fb->base.id; - - if (st->dirty && st->old.fb) { - intel_flip->old_bo = to_intel_framebuffer(st->old.fb)->obj; - - mutex_lock(&dev->struct_mutex); - drm_gem_object_reference(&intel_flip->old_bo->base); - mutex_unlock(&dev->struct_mutex); - } - list_add_tail(&intel_flip->base.list, &flips); }