From patchwork Mon Mar 17 04:33:46 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: 3841311 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 220599F369 for ; Mon, 17 Mar 2014 04:33:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 14D212018A for ; Mon, 17 Mar 2014 04:33:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id E663F2017A for ; Mon, 17 Mar 2014 04:33:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8607E8A760; Sun, 16 Mar 2014 21:33:52 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id C02B38A760 for ; Sun, 16 Mar 2014 21:33:50 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 16 Mar 2014 21:33:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,667,1389772800"; d="scan'208";a="500063748" Received: from fmsmsx108.amr.corp.intel.com ([10.19.9.228]) by fmsmga002.fm.intel.com with ESMTP; 16 Mar 2014 21:33:49 -0700 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by FMSMSX108.amr.corp.intel.com (10.19.9.228) with Microsoft SMTP Server (TLS) id 14.3.123.3; Sun, 16 Mar 2014 21:33:49 -0700 Received: from bgsmsx151.gar.corp.intel.com (10.224.48.42) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.123.3; Sun, 16 Mar 2014 21:33:49 -0700 Received: from bgsmsx103.gar.corp.intel.com ([169.254.4.75]) by BGSMSX151.gar.corp.intel.com ([169.254.3.159]) with mapi id 14.03.0123.003; Mon, 17 Mar 2014 10:03:46 +0530 From: "Gupta, Sourab" To: "Syrjala, Ville" Thread-Topic: [PATCH v2] drm/i915: Replaced Blitter ring based flips with MMIO flips for VLV Thread-Index: AQHPQZoVga8ySePvrUiJFdCxuQyaBA== Date: Mon, 17 Mar 2014 04:33:46 +0000 Message-ID: <65889429B5341B4E95B705EB9142B060095630@BGSMSX103.gar.corp.intel.com> References: <20140307133017.GL3852@intel.com> <1394701297-7261-1-git-send-email-sourab.gupta@intel.com> In-Reply-To: <1394701297-7261-1-git-send-email-sourab.gupta@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.223.10.10] MIME-Version: 1.0 Cc: "Goel, Akash" , "intel-gfx@lists.freedesktop.org" , Daniel Vetter Subject: Re: [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.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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 Hi Ville, Can you please review the below patch. Regards, Sourab -----Original Message----- From: Gupta, Sourab Sent: Thursday, March 13, 2014 2:32 PM To: intel-gfx@lists.freedesktop.org Cc: Gupta, Sourab; Ville Syrjälä; Daniel Vetter; Chris Wilson; Goel, Akash Subject: [PATCH v2] drm/i915: Replaced Blitter ring based flips with MMIO flips for VLV 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(+) + + 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); } -- 1.8.5.1 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);