From patchwork Fri Feb 7 20:37:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Vivi X-Patchwork-Id: 3607651 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 133F19F344 for ; Fri, 7 Feb 2014 20:37:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2599F2012F for ; Fri, 7 Feb 2014 20:37:28 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 606B520163 for ; Fri, 7 Feb 2014 20:37:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1C3B71057A0; Fri, 7 Feb 2014 12:37:25 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yh0-f45.google.com (mail-yh0-f45.google.com [209.85.213.45]) by gabe.freedesktop.org (Postfix) with ESMTP id ACAB910578E for ; Fri, 7 Feb 2014 12:37:22 -0800 (PST) Received: by mail-yh0-f45.google.com with SMTP id i57so3129333yha.18 for ; Fri, 07 Feb 2014 12:37:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=262yJoYo4D6AcrZD4KtXQMqAbmErmMZo/71KDYjSTbg=; b=h238eidTbYjaHV2VqZ6XeVPEZxX5IQNjs2iwK4FvxlHJDRT5870KqfnfK90XURNHjd U0QzcPFaKqpS5FqBXfke5XpvfhdfnhhA4+R0tottfJA6MQSnktjcJI1mWcpIbM+5y7oN MBJrID6xILBZsXtYyXBdoQZpSGFJj7zPExaJsjaYt1kjUxsQP9WcO9jQyToPQWhWMXla cV1uOcp8xfBoMwqavRUpiyMEHlD0AUYQZ3CxfU05QqqGDoCMlLhew5O5ZKTdnSRCxMK8 DPrK7d9s17DYPDk8rbxTo6ucYkH4Efdn1S8LHxKHjox1qdhPc6AiCjGX9HqovSAKFU6L IxKg== X-Received: by 10.236.63.5 with SMTP id z5mr1614791yhc.49.1391805440964; Fri, 07 Feb 2014 12:37:20 -0800 (PST) Received: from localhost.localdomain ([189.67.97.168]) by mx.google.com with ESMTPSA id q9sm13697981yhk.16.2014.02.07.12.37.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Feb 2014 12:37:20 -0800 (PST) From: Rodrigo Vivi To: intel-gfx@lists.freedesktop.org Date: Fri, 7 Feb 2014 18:37:01 -0200 Message-Id: <1391805427-4576-4-git-send-email-rodrigo.vivi@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1391805427-4576-1-git-send-email-rodrigo.vivi@gmail.com> References: <1391805427-4576-1-git-send-email-rodrigo.vivi@gmail.com> Subject: [Intel-gfx] [PATCH 3/9] drm/i915: make crtc enable/disable asynchronous 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: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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: Jesse Barnes The intent is to get back to userspace as quickly as possible so it can start doing drawing or whatever. It should also allow our suspend/resume/init time to improve a lot. Signed-off-by: Rodrigo Vivi --- drivers/gpu/drm/i915/i915_irq.c | 10 +++++++++- drivers/gpu/drm/i915/intel_display.c | 27 ++++++++++++++++++++------- drivers/gpu/drm/i915/intel_drv.h | 4 ++++ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index e9c94c9..749c20f 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c @@ -917,8 +917,16 @@ static void i915_hotplug_work_func(struct work_struct *work) intel_connector = to_intel_connector(connector); intel_encoder = intel_connector->encoder; if (hpd_event_bits & (1 << intel_encoder->hpd_pin)) { - if (intel_encoder->hot_plug) + if (intel_encoder->hot_plug) { + struct drm_crtc *crtc = + intel_encoder->base.crtc; + if (crtc) { + mutex_lock(&crtc->mutex); + intel_sync_crtc(intel_encoder->base.crtc); + mutex_unlock(&crtc->mutex); + } intel_encoder->hot_plug(intel_encoder); + } if (intel_hpd_irq_event(dev, connector)) changed = true; } diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 21a950d..6ecd9da 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -1746,6 +1746,11 @@ static void intel_crtc_disable_work(struct work_struct *work) { struct intel_crtc *intel_crtc = container_of(work, struct intel_crtc, disable_work); + struct drm_i915_private *dev_priv = intel_crtc->base.dev->dev_private; + + mutex_lock(&intel_crtc->base.mutex); + dev_priv->display._crtc_disable(&intel_crtc->base); + mutex_unlock(&intel_crtc->base.mutex); } void intel_queue_crtc_disable(struct drm_crtc *crtc) @@ -1761,6 +1766,11 @@ static void intel_crtc_enable_work(struct work_struct *work) { struct intel_crtc *intel_crtc = container_of(work, struct intel_crtc, enable_work); + struct drm_i915_private *dev_priv = intel_crtc->base.dev->dev_private; + + mutex_lock(&intel_crtc->base.mutex); + dev_priv->display._crtc_enable(&intel_crtc->base); + mutex_unlock(&intel_crtc->base.mutex); } static void intel_queue_crtc_enable(struct drm_crtc *crtc) @@ -1772,14 +1782,16 @@ static void intel_queue_crtc_enable(struct drm_crtc *crtc) queue_work(dev_priv->wq, &intel_crtc->enable_work); } -static void intel_sync_crtc(struct drm_crtc *crtc) +void intel_sync_crtc(struct drm_crtc *crtc) { - struct drm_device *dev = crtc->dev; - struct drm_i915_private *dev_priv = dev->dev_private; struct intel_crtc *intel_crtc = to_intel_crtc(crtc); + WARN(!mutex_is_locked(&intel_crtc->base.mutex), "need crtc mutex\n"); + + mutex_unlock(&intel_crtc->base.mutex); flush_work(&intel_crtc->disable_work); flush_work(&intel_crtc->enable_work); + mutex_lock(&intel_crtc->base.mutex); } /** @@ -9781,8 +9793,9 @@ static int intel_set_mode(struct drm_crtc *crtc, ret = __intel_set_mode(crtc, mode, x, y, fb); - if (ret == 0) - intel_modeset_check_state(crtc->dev); + /* FIXME: need to check after the CRTC changes have been applied */ +// if (ret == 0) +// intel_modeset_check_state(crtc->dev); return ret; } @@ -10348,8 +10361,8 @@ static void intel_crtc_init(struct drm_device *dev, int pipe) drm_crtc_helper_add(&intel_crtc->base, &intel_helper_funcs); - INIT_WORK(intel_crtc->enable_work, intel_crtc_enable_work); - INIT_WORK(intel_crtc->disable_work, intel_crtc_disable_work); + INIT_WORK(&intel_crtc->enable_work, intel_crtc_enable_work); + INIT_WORK(&intel_crtc->disable_work, intel_crtc_disable_work); } enum pipe intel_get_pipe_from_connector(struct intel_connector *connector) diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 5b5b51e..f104fe1 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -376,6 +376,9 @@ struct intel_crtc { /* watermarks currently being used */ struct intel_pipe_wm active; } wm; + + struct work_struct enable_work; + struct work_struct disable_work; }; struct intel_plane_wm_parameters { @@ -728,6 +731,7 @@ void hsw_disable_ips(struct intel_crtc *crtc); void intel_display_set_init_power(struct drm_device *dev, bool enable); int valleyview_get_vco(struct drm_i915_private *dev_priv); void intel_queue_crtc_disable(struct drm_crtc *crtc); +void intel_sync_crtc(struct drm_crtc *crtc); /* intel_dp.c */ void intel_dp_init(struct drm_device *dev, int output_reg, enum port port);