From patchwork Thu Mar 13 09:01:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: sourab.gupta@intel.com X-Patchwork-Id: 3822891 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 375D69F72D for ; Thu, 13 Mar 2014 09:01:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1A3D9201B6 for ; Thu, 13 Mar 2014 09:01:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8687E2028D for ; Thu, 13 Mar 2014 09:01:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B7F6CFAE0C; Thu, 13 Mar 2014 02:01:18 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 672EAFAE0C for ; Thu, 13 Mar 2014 02:01:16 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 13 Mar 2014 02:01:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,645,1389772800"; d="scan'208";a="471496562" Received: from sourabgu-desktop.iind.intel.com ([10.223.82.69]) by orsmga001.jf.intel.com with ESMTP; 13 Mar 2014 02:01:00 -0700 From: sourab.gupta@intel.com To: intel-gfx@lists.freedesktop.org Date: Thu, 13 Mar 2014 14:31:37 +0530 Message-Id: <1394701297-7261-1-git-send-email-sourab.gupta@intel.com> X-Mailer: git-send-email 1.8.5.1 In-Reply-To: <20140307133017.GL3852@intel.com> References: <20140307133017.GL3852@intel.com> MIME-Version: 1.0 Cc: Sourab Gupta , Akash Goel , Daniel Vetter Subject: [Intel-gfx] [PATCH v2] drm/i915: Replaced Blitter ring based flips with MMIO flips for VLV 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@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sourab Gupta Using MMIO based flips on VLV for Media power well residency optimization. The blitter ring is currently being used just for command streamer based flip calls. For pure 3D workloads, with MMIO flips, there will be no use of blitter ring and this will ensure the 100% residency for Media well. v2: The MMIO flips now use the interrupt driven mechanism for issuing the flips when target seqno is reached. (Incorporating Ville's idea) Cc: Ville Syrjälä Cc: Daniel Vetter Cc: Chris Wilson Signed-off-by: Sourab Gupta Signed-off-by: Akash Goel --- drivers/gpu/drm/i915/i915_dma.c | 1 + drivers/gpu/drm/i915/i915_drv.h | 13 ++++ drivers/gpu/drm/i915/i915_irq.c | 2 + drivers/gpu/drm/i915/intel_display.c | 125 +++++++++++++++++++++++++++++++++++ 4 files changed, 141 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index e4d2b9f..d6ae334 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c @@ -1566,6 +1566,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) spin_lock_init(&dev_priv->backlight_lock); spin_lock_init(&dev_priv->uncore.lock); spin_lock_init(&dev_priv->mm.object_stat_lock); + spin_lock_init(&dev_priv->flip_lock); mutex_init(&dev_priv->dpio_lock); mutex_init(&dev_priv->modeset_restore_lock); diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index a0d90ef..af35197 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1436,6 +1436,12 @@ struct intel_pipe_crc { wait_queue_head_t wq; }; +struct i915_flip_data { + struct drm_crtc *crtc; + u32 seqno; + u32 ring_id; +}; + typedef struct drm_i915_private { struct drm_device *dev; struct kmem_cache *slab; @@ -1643,6 +1649,11 @@ typedef struct drm_i915_private { struct i915_ums_state ums; u32 suspend_count; + + /* protects the flip_data */ + spinlock_t flip_lock; + + struct i915_flip_data flip_data[I915_MAX_PIPES]; } drm_i915_private_t; static inline struct drm_i915_private *to_i915(const struct drm_device *dev) @@ -2681,6 +2692,8 @@ int i915_reg_read_ioctl(struct drm_device *dev, void *data, int i915_get_reset_stats_ioctl(struct drm_device *dev, void *data, struct drm_file *file); +void intel_notify_mmio_flip(struct drm_device *dev, + struct intel_ring_buffer *ring); /* overlay */ extern struct intel_overlay_error_state *intel_overlay_capture_error_state(struct drm_device *dev); extern void intel_overlay_print_error_state(struct drm_i915_error_state_buf *e, diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index be2713f..9b2007e 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c @@ -1062,6 +1062,8 @@ static void ironlake_rps_change_irq_handler(struct drm_device *dev) static void notify_ring(struct drm_device *dev, struct intel_ring_buffer *ring) { + intel_notify_mmio_flip(dev, ring); + if (ring->obj == NULL) return; diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 2bccc68..8bd2f57 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -8813,6 +8813,122 @@ err: return ret; } +static void intel_do_mmio_flip(struct drm_crtc *crtc) +{ + struct intel_crtc *intel_crtc; + + intel_crtc = to_intel_crtc(crtc) ; + + intel_mark_page_flip_active(intel_crtc); + i9xx_update_plane(crtc, crtc->fb, 0, 0); +} + +static bool intel_postpone_flip(struct drm_i915_gem_object *obj) +{ + int ret; + if(!obj->ring) + return false; + + if (i915_seqno_passed(obj->ring->get_seqno(obj->ring, false), + obj->last_write_seqno)) + return false; + + if (obj->last_write_seqno == obj->ring->outstanding_lazy_seqno) { + ret = i915_add_request(obj->ring, NULL); + if(WARN_ON(ret)) + return false; + } + + if(WARN_ON(!obj->ring->irq_get(obj->ring))) + return false; + + return true; +} + +void intel_notify_mmio_flip(struct drm_device *dev, + struct intel_ring_buffer *ring) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + struct intel_crtc *intel_crtc; + struct i915_flip_data *flip_data; + unsigned long irq_flags; + u32 seqno, count; + + BUG_ON(!ring); + + seqno = ring->get_seqno(ring, false); + + spin_lock_irqsave(&dev_priv->flip_lock, irq_flags); + + for(count=0;countflip_data[count]); + intel_crtc = to_intel_crtc(flip_data->crtc); + if ((flip_data->seqno != 0) && + (ring->id == flip_data->ring_id) && + ( seqno >= flip_data->seqno ) ) { + /*FIXME: Can move do_mmio_flip out of spinlock protection */ + intel_do_mmio_flip(flip_data->crtc); + flip_data->seqno = 0; + ring->irq_put(ring); + } + } + spin_unlock_irqrestore(&dev_priv->flip_lock, irq_flags); +} + +/* Using MMIO based flips starting from VLV, for Media power well + * residency optimization. The other alternative of having Render + * ring based flip calls is not being used, as the performance + * (FPS) of certain 3D Apps was getting severly affected. + */ +static int intel_gen7_queue_mmio_flip(struct drm_device *dev, + struct drm_crtc *crtc, + struct drm_framebuffer *fb, + struct drm_i915_gem_object *obj, + uint32_t flags) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + struct intel_crtc *intel_crtc = to_intel_crtc(crtc); + struct i915_flip_data *flip_data = &(dev_priv->flip_data[intel_crtc->pipe]); + unsigned long irq_flags; + int ret; + + ret = intel_pin_and_fence_fb_obj(dev, obj, obj->ring); + if (ret) + goto err; + + switch (intel_crtc->plane) { + case PLANE_A: + case PLANE_B: + case PLANE_C: + break; + default: + WARN_ONCE(1, "unknown plane in flip command\n"); + ret = -ENODEV; + goto err_unpin; + } + + if(!intel_postpone_flip(obj)) { + intel_do_mmio_flip(crtc); + return 0; + } + + spin_lock_irqsave(&dev_priv->flip_lock, irq_flags); + flip_data->seqno = obj->last_write_seqno; + flip_data->ring_id = obj->ring->id; + spin_unlock_irqrestore(&dev_priv->flip_lock, irq_flags); + + /* Double check to catch cases where irq fired before + * flip data was ready + */ + intel_notify_mmio_flip(dev, obj->ring); + return 0; + +err_unpin: + intel_unpin_fb_obj(obj); +err: + return ret; +} + static int intel_gen7_queue_flip(struct drm_device *dev, struct drm_crtc *crtc, struct drm_framebuffer *fb, @@ -10581,6 +10697,12 @@ static void intel_crtc_init(struct drm_device *dev, int pipe) dev_priv->pipe_to_crtc_mapping[intel_crtc->pipe] = &intel_crtc->base; drm_crtc_helper_add(&intel_crtc->base, &intel_helper_funcs); + + if (IS_VALLEYVIEW(dev)) { + dev_priv->flip_data[pipe].crtc = + dev_priv->pipe_to_crtc_mapping[pipe]; + dev_priv->flip_data[pipe].seqno = 0; + } } enum pipe intel_get_pipe_from_connector(struct intel_connector *connector) @@ -11103,6 +11225,9 @@ static void intel_init_display(struct drm_device *dev) dev_priv->display.queue_flip = intel_gen7_queue_flip; break; } + if (IS_VALLEYVIEW(dev)) { + dev_priv->display.queue_flip = intel_gen7_queue_mmio_flip; + } intel_panel_init_backlight_funcs(dev); }