From patchwork Wed Oct 8 15:32:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ander Conselvan de Oliveira X-Patchwork-Id: 5054231 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 6223B9F30B for ; Wed, 8 Oct 2014 15:32:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5827A201F2 for ; Wed, 8 Oct 2014 15:32:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 32B2620125 for ; Wed, 8 Oct 2014 15:32:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C9D316E2E4; Wed, 8 Oct 2014 08:32:55 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-la0-f46.google.com (mail-la0-f46.google.com [209.85.215.46]) by gabe.freedesktop.org (Postfix) with ESMTP id 0EF2B6E2DA for ; Wed, 8 Oct 2014 08:32:51 -0700 (PDT) Received: by mail-la0-f46.google.com with SMTP id gi9so8658520lab.5 for ; Wed, 08 Oct 2014 08:32:50 -0700 (PDT) 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=t2n+7H0YfUvAYV//uQIS2G1+XTtvDwVrrTs13wZ77DA=; b=uQzwzcHRjCd/WbFe2CWy/YadhfEULvsB8dsWG3Wb8IxEGOf7rkzhXFYByjc/RosZGJ gF5psHj5h93EFrsNIVrihYzfOHOllf67hHXkAYpEeRQ4yIdvI/ZxaIdddX20YLYhxcR4 pAqtWe5nBwJwii8x23ooHlLFCMYZDhP1/gc6iJothF4KlUZINaG5pSqY0pPyGULkFSdi jWXJXCD/CcOkyr1Kb3ZOFupd9mvQSNY6QCW0910pNp7SOJEWpFICL4NtVEywnyNFm/F5 H4lpUrfg8nHZ4GZodEFCWHpGlPmt7tYDaBI2nLDCq4hBNN7R+kr6RimhN2MbS5WRksI+ rAMQ== X-Received: by 10.112.135.137 with SMTP id ps9mr11779153lbb.24.1412782370485; Wed, 08 Oct 2014 08:32:50 -0700 (PDT) Received: from snb-laptop.Elisa (a88-114-204-203.elisa-laajakaista.fi. [88.114.204.203]) by mx.google.com with ESMTPSA id s8sm124598las.29.2014.10.08.08.32.48 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Oct 2014 08:32:49 -0700 (PDT) From: Ander Conselvan de Oliveira To: intel-gfx@lists.freedesktop.org Date: Wed, 8 Oct 2014 18:32:22 +0300 Message-Id: <1412782343-28836-4-git-send-email-conselvan2@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1412782343-28836-1-git-send-email-conselvan2@gmail.com> References: <1412782343-28836-1-git-send-email-conselvan2@gmail.com> Cc: Ander Conselvan de Oliveira Subject: [Intel-gfx] [PATCH 3/4] drm/i915: Convert shared dpll reference count to a crtc mask 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, 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: Ander Conselvan de Oliveira This will be used in a follow up patch to properly release shared DPLLs without relying on the shared_dpll field in pipe_config. Signed-off-by: Ander Conselvan de Oliveira --- drivers/gpu/drm/i915/i915_debugfs.c | 4 +-- drivers/gpu/drm/i915/i915_drv.h | 4 +-- drivers/gpu/drm/i915/intel_display.c | 63 +++++++++++++++++++++++------------- 3 files changed, 44 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index da4036d..71885d8 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -2627,8 +2627,8 @@ static int i915_shared_dplls_info(struct seq_file *m, void *unused) struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; seq_printf(m, "DPLL%i: %s, id: %i\n", i, pll->name, pll->id); - seq_printf(m, " refcount: %i, active: %i, on: %s\n", pll->refcount, - pll->active, yesno(pll->on)); + seq_printf(m, " crtc_mask: 0x%08x, active: %d, on: %s\n", + pll->crtc_mask, pll->active, yesno(pll->on)); seq_printf(m, " tracked hardware state:\n"); seq_printf(m, " dpll: 0x%08x\n", pll->hw_state.dpll); seq_printf(m, " dpll_md: 0x%08x\n", pll->hw_state.dpll_md); diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index ac6232b..cb6df07 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -227,8 +227,8 @@ struct intel_dpll_hw_state { }; struct intel_shared_dpll { - int refcount; /* count of number of CRTCs sharing this PLL */ - int active; /* count of number of active CRTCs (i.e. DPMS on) */ + unsigned crtc_mask; /* mask of CRTCs sharing this PLL */ + int active; /* count of number of active CRTCs (i.e. DPMS on) */ bool on; /* is the PLL actually active? Disabled during modeset */ const char *name; /* should match the index in the dev_priv->shared_dplls array */ diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 9d8fe8d..46df2db 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -1778,7 +1778,7 @@ static void intel_prepare_shared_dpll(struct intel_crtc *crtc) if (WARN_ON(pll == NULL)) return; - WARN_ON(!pll->refcount); + WARN_ON(!pll->crtc_mask); if (pll->active == 0) { DRM_DEBUG_DRIVER("setting up %s\n", pll->name); WARN_ON(pll->on); @@ -1805,7 +1805,7 @@ static void intel_enable_shared_dpll(struct intel_crtc *crtc) if (WARN_ON(pll == NULL)) return; - if (WARN_ON(pll->refcount == 0)) + if (WARN_ON(pll->crtc_mask == 0)) return; DRM_DEBUG_KMS("enable %s (active %d, on? %d) for crtc %d\n", @@ -1837,7 +1837,7 @@ static void intel_disable_shared_dpll(struct intel_crtc *crtc) if (WARN_ON(pll == NULL)) return; - if (WARN_ON(pll->refcount == 0)) + if (WARN_ON(pll->crtc_mask == 0)) return; DRM_DEBUG_KMS("disable %s (active %d, on? %d) for crtc %d\n", @@ -3835,12 +3835,13 @@ void intel_put_shared_dpll(struct intel_crtc *crtc) if (pll == NULL) return; - if (pll->refcount == 0) { - WARN(1, "bad %s refcount\n", pll->name); + if (!(pll->crtc_mask & (1 << crtc->pipe))) { + WARN(1, "bad %s crtc mask\n", pll->name); return; } - if (--pll->refcount == 0) { + pll->crtc_mask &= ~(1 << crtc->pipe); + if (pll->crtc_mask == 0) { WARN_ON(pll->on); WARN_ON(pll->active); } @@ -3868,7 +3869,7 @@ struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc) DRM_DEBUG_KMS("CRTC:%d using pre-allocated %s\n", crtc->base.base.id, pll->name); - WARN_ON(pll->refcount); + WARN_ON(pll->crtc_mask); goto found; } @@ -3877,14 +3878,15 @@ struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc) pll = &dev_priv->shared_dplls[i]; /* Only want to check enabled timings first */ - if (pll->refcount == 0) + if (pll->crtc_mask == 0) continue; if (memcmp(&crtc->config.dpll_hw_state, &pll->hw_state, sizeof(pll->hw_state)) == 0) { - DRM_DEBUG_KMS("CRTC:%d sharing existing %s (refcount %d, ative %d)\n", - crtc->base.base.id, - pll->name, pll->refcount, pll->active); + DRM_DEBUG_KMS("CRTC:%d sharing existing %s " + "(crtc_mask 0x%08x, active %d)\n", + crtc->base.base.id, pll->name, + pll->crtc_mask, pll->active); goto found; } @@ -3893,7 +3895,7 @@ struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc) /* Ok no matching timings, maybe there's a free one? */ for (i = 0; i < dev_priv->num_shared_dpll; i++) { pll = &dev_priv->shared_dplls[i]; - if (pll->refcount == 0) { + if (pll->crtc_mask == 0) { DRM_DEBUG_KMS("CRTC:%d allocated %s\n", crtc->base.base.id, pll->name); goto found; @@ -3903,14 +3905,14 @@ struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc) return NULL; found: - if (pll->refcount == 0) + if (pll->crtc_mask == 0) pll->hw_state = crtc->config.dpll_hw_state; crtc->config.shared_dpll = i; DRM_DEBUG_DRIVER("using %s for pipe %c\n", pll->name, pipe_name(crtc->pipe)); - pll->refcount++; + pll->crtc_mask |= 1 << crtc->pipe; return pll; } @@ -10812,6 +10814,19 @@ check_crtc_state(struct drm_device *dev) } } +static int mask_to_refcount(unsigned mask) +{ + int refcount = 0; + + while (mask) { + if (mask & 1) + refcount++; + mask >>= 1; + } + + return refcount; +} + static void check_shared_dpll_state(struct drm_device *dev) { @@ -10831,9 +10846,9 @@ check_shared_dpll_state(struct drm_device *dev) active = pll->get_hw_state(dev_priv, pll, &dpll_hw_state); - WARN(pll->active > pll->refcount, + WARN(pll->active > mask_to_refcount(pll->crtc_mask), "more active pll users than references: %i vs %i\n", - pll->active, pll->refcount); + pll->active, mask_to_refcount(pll->crtc_mask)); WARN(pll->active && !pll->on, "pll in active use but not on in sw tracking\n"); WARN(pll->on && !pll->active, @@ -10851,9 +10866,9 @@ check_shared_dpll_state(struct drm_device *dev) WARN(pll->active != active_crtcs, "pll active crtcs mismatch (expected %i, found %i)\n", pll->active, active_crtcs); - WARN(pll->refcount != enabled_crtcs, + WARN(mask_to_refcount(pll->crtc_mask) != enabled_crtcs, "pll enabled crtcs mismatch (expected %i, found %i)\n", - pll->refcount, enabled_crtcs); + mask_to_refcount(pll->crtc_mask), enabled_crtcs); WARN(pll->on && memcmp(&pll->hw_state, &dpll_hw_state, sizeof(dpll_hw_state)), @@ -13270,16 +13285,18 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) pll->on = pll->get_hw_state(dev_priv, pll, &pll->hw_state); pll->active = 0; + pll->crtc_mask = 0; for_each_intel_crtc(dev, crtc) { - if (crtc->active && intel_crtc_to_shared_dpll(crtc) == pll) + if (crtc->active && intel_crtc_to_shared_dpll(crtc) == pll) { pll->active++; + pll->crtc_mask |= 1 << crtc->pipe; + } } - pll->refcount = pll->active; - DRM_DEBUG_KMS("%s hw state readout: refcount %i, on %i\n", - pll->name, pll->refcount, pll->on); + DRM_DEBUG_KMS("%s hw state readout: crtc_mask 0x%08x, on %i\n", + pll->name, pll->crtc_mask, pll->on); - if (pll->refcount) + if (pll->crtc_mask) intel_display_power_get(dev_priv, POWER_DOMAIN_PLLS); }