From patchwork Fri Oct 31 22:53:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 5207361 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5DCA1C11AC for ; Fri, 31 Oct 2014 23:56:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C12F020160 for ; Fri, 31 Oct 2014 23:56:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0753C20158 for ; Fri, 31 Oct 2014 23:56:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2392F6E853; Fri, 31 Oct 2014 16:56:39 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by gabe.freedesktop.org (Postfix) with ESMTP id CCF6C6E848 for ; Fri, 31 Oct 2014 15:56:59 -0700 (PDT) Received: by mail-pa0-f47.google.com with SMTP id kx10so8536906pab.6 for ; Fri, 31 Oct 2014 15:56:59 -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=8iKO38/zr6XItPjWyTEXoOJh8XulJFEW4+M+81kiIFs=; b=mrODEnMnSu1496HinJz40g14f9Rjc26T9UHP2jTBOAUU3bB4PcT7+o5mHcTj91d29T Uo5sn6PTzZGa8GWOZkmhHdRJBBAdfW3KmP7SUlPVujwLI76WSOaE40DceYQnYFTpnuJH ZOUOL0OLXiLesLIXX/LtQCSEoKg9cSaqUddzCrG8zocxMIQefoyfdZxuyG1x8JfDuKBy MrcGecS84p77n7Wo2CcYHC9KGjVTQ7tTrHq5IVnqcwwg2qNU/SthPBhHLBVs5XMqkn0T muStvahDB6xCX9iiZl6HGrV1/vy8A0/dGKH2fEMBNFf4bMtKNiQvf5LeyTTVN8e5h9SL waDg== X-Received: by 10.70.89.101 with SMTP id bn5mr13655185pdb.134.1414796219719; Fri, 31 Oct 2014 15:56:59 -0700 (PDT) Received: from mothership.mgc.mentorg.com (c-50-152-159-227.hsd1.ca.comcast.net. [50.152.159.227]) by mx.google.com with ESMTPSA id ev8sm10870656pdb.28.2014.10.31.15.56.58 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 15:56:59 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: dri-devel@lists.freedesktop.org Subject: [PATCH 14/72] gpu: ipu-v3: Implement use counter for ipu_dc_enable(), ipu_dc_disable() Date: Fri, 31 Oct 2014 15:53:57 -0700 Message-Id: <1414796095-10107-15-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1414796095-10107-1-git-send-email-steve_longerbeam@mentor.com> References: <1414796095-10107-1-git-send-email-steve_longerbeam@mentor.com> X-Mailman-Approved-At: Fri, 31 Oct 2014 16:56:31 -0700 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.7 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 The functions ipu_dc_enable() and ipu_dc_disable() enable/disable the DC globally in the IPU_CONF register, but the DC is used by multiple clients on different DC channels. So make sure to only disable/enable the DC globally based on a use counter. Signed-off-by: Steve Longerbeam --- drivers/gpu/ipu-v3/ipu-dc.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/ipu-v3/ipu-dc.c b/drivers/gpu/ipu-v3/ipu-dc.c index f53fce5..79879e7 100644 --- a/drivers/gpu/ipu-v3/ipu-dc.c +++ b/drivers/gpu/ipu-v3/ipu-dc.c @@ -144,6 +144,7 @@ struct ipu_dc_priv { struct completion comp; int dc_irq; int dp_irq; + int use_count; }; /* forward references */ @@ -345,7 +346,14 @@ void ipu_dc_enable(struct ipu_dc *dc) { struct ipu_dc_priv *priv = dc->priv; - ipu_module_enable(priv->ipu, IPU_CONF_DC_EN); + mutex_lock(&priv->mutex); + + if (!priv->use_count) + ipu_module_enable(priv->ipu, IPU_CONF_DC_EN); + + priv->use_count++; + + mutex_unlock(&priv->mutex); } EXPORT_SYMBOL_GPL(ipu_dc_enable); @@ -409,7 +417,16 @@ void ipu_dc_disable(struct ipu_dc *dc) { struct ipu_dc_priv *priv = dc->priv; - ipu_module_disable(priv->ipu, IPU_CONF_DC_EN); + mutex_lock(&priv->mutex); + + priv->use_count--; + if (!priv->use_count) + ipu_module_disable(priv->ipu, IPU_CONF_DC_EN); + + if (priv->use_count < 0) + priv->use_count = 0; + + mutex_unlock(&priv->mutex); } EXPORT_SYMBOL_GPL(ipu_dc_disable);