From patchwork Sat Dec 1 20:03:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 1829701 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id A9ADF3FCF6 for ; Sat, 1 Dec 2012 20:13:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 034BFE611C for ; Sat, 1 Dec 2012 12:13:13 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-ee0-f49.google.com (mail-ee0-f49.google.com [74.125.83.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 15BDFE5D12 for ; Sat, 1 Dec 2012 12:12:37 -0800 (PST) Received: by mail-ee0-f49.google.com with SMTP id c4so916292eek.36 for ; Sat, 01 Dec 2012 12:12:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=6rWzy7Q/Gf8+ARRwx1y7lXuuoGGNcuDl67nOGf5aK50=; b=dRCB4B96b3akUh0pCl0GHl5c8whHDaoD9daJPCODjBS1NWK3vm8zFS33k8Q/SxUUfu 9QoGjg0yzJqAO2RLoS68OofDmGpYeTnYgc/2NGY6sxNQnIsBmD76xV7QSqlu3DT1RrcY g6+o8fDID31UAAY4tcQ+TsU1KNB9VqKboDaQU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=6rWzy7Q/Gf8+ARRwx1y7lXuuoGGNcuDl67nOGf5aK50=; b=lkXCk3Uvjw3bGiiNy4w47NIiMZ6jrPn7NkF/ghNFVd6mMWJHVKwpPf5R4p+Ab20r7w xMpyAufKE4ZjcXcQ202h++cgjz+YL8GFdERVS/dZpXrLNoZ2g19TV3uicbZw5CsmR7Rb QEWuSz0+12GYMlfNnBapjdzDGnYJka/WlbvDw/zN3cLxSMaJHYqSaDpCr5NgRYQuZ9FJ B9QEZ6bRRml5rqLqkdnNcHN8NN+SDS34SFyvYs7VN9Fc0HWaGxA6m4aK0w7whcGoUzRP 66db/uwICIXyMSjR9SrQ3faMfLeFy65eqDHojQjrtWyzTPajRmM4ajV++HUimox7bWbg y5sQ== Received: by 10.14.218.69 with SMTP id j45mr18739809eep.35.1354392757211; Sat, 01 Dec 2012 12:12:37 -0800 (PST) Received: from wespe.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPS id y44sm19732080eel.14.2012.12.01.12.12.36 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 01 Dec 2012 12:12:36 -0800 (PST) From: Daniel Vetter To: Intel Graphics Development Date: Sat, 1 Dec 2012 21:03:22 +0100 Message-Id: <1354392202-16051-2-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1354392202-16051-1-git-send-email-daniel.vetter@ffwll.ch> References: <1354366429-2324-4-git-send-email-daniel.vetter@ffwll.ch> <1354392202-16051-1-git-send-email-daniel.vetter@ffwll.ch> X-Gm-Message-State: ALoCoQkwYPideOEMw8q31qDuv4Ng6nYQwG5nXFJeIueZ6n2G/j90AWNq3c0l2IaP+/PWsBxmL2MF Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 2/2] drm/i915: reorder setup sequence to have irqs for output setup 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+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Otherwise the new&shiny irq-driven gmbus and dp aux code won't work that well. Noticed since the dp aux code doesn't have an automatic fallback with a timeout (since the hw provides for that already). v2: Simple move drm_irq_install before intel_modeset_gem_init, as suggested by Ben Widawsky. v3: Now that interrupts are enabled before all connectors are fully set up, we might fall over serving a HPD interrupt while things are still being set up. Instead of jumping through massive hoops and complicating the code with a separate hpd irq enable step, simply block out the hotplug work item from doing anything until things are in place. v4: Actually, we can enable hotplug processing only after the fbdev is fully set up, since we call down into the fbdev from the hotplug work functions. So stick the hpd enabling right next to the poll helper initialization. v5: We need to enable irqs before intel_modeset_init, since that function sets up the outputs. v6: Fixup cleanup sequence, too. Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_dma.c | 23 ++++++++++++++--------- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_irq.c | 4 ++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 2e8b8cf..644481c 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c @@ -1294,19 +1294,21 @@ static int i915_load_modeset_init(struct drm_device *dev) if (ret) goto cleanup_vga_switcheroo; + ret = drm_irq_install(dev); + if (ret) + goto cleanup_gem_stolen; + + /* Important: The output setup functions called by modeset_init need + * working irqs for e.g. gmbus and dp aux transfers. */ intel_modeset_init(dev); ret = i915_gem_init(dev); if (ret) - goto cleanup_gem_stolen; - - intel_modeset_gem_init(dev); + goto cleanup_irq; INIT_WORK(&dev_priv->console_resume_work, intel_console_resume); - ret = drm_irq_install(dev); - if (ret) - goto cleanup_gem; + intel_modeset_gem_init(dev); /* Always safe in the mode setting case. */ /* FIXME: do pre/post-mode set stuff in core KMS code */ @@ -1314,7 +1316,10 @@ static int i915_load_modeset_init(struct drm_device *dev) ret = intel_fbdev_init(dev); if (ret) - goto cleanup_irq; + goto cleanup_gem; + + /* Only enable hotplug handling once the fbdev is fully set up. */ + dev_priv->enable_hotplug_processing = true; drm_kms_helper_poll_init(dev); @@ -1323,13 +1328,13 @@ static int i915_load_modeset_init(struct drm_device *dev) return 0; -cleanup_irq: - drm_irq_uninstall(dev); cleanup_gem: mutex_lock(&dev->struct_mutex); i915_gem_cleanup_ringbuffer(dev); mutex_unlock(&dev->struct_mutex); i915_gem_cleanup_aliasing_ppgtt(dev); +cleanup_irq: + drm_irq_uninstall(dev); cleanup_gem_stolen: i915_gem_cleanup_stolen(dev); cleanup_vga_switcheroo: diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 31ab43b..9e05d98 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -664,6 +664,7 @@ typedef struct drm_i915_private { u32 hotplug_supported_mask; struct work_struct hotplug_work; + bool enable_hotplug_processing; int num_pipe; int num_pch_pll; diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index 30a2fb5..712b088 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c @@ -287,6 +287,10 @@ static void i915_hotplug_work_func(struct work_struct *work) struct drm_mode_config *mode_config = &dev->mode_config; struct intel_encoder *encoder; + /* HPD irq before everything is fully set up. */ + if (!dev_priv->enable_hotplug_processing) + return; + mutex_lock(&mode_config->mutex); DRM_DEBUG_KMS("running encoder hotplug functions\n");