From patchwork Fri Oct 31 22:54:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 5207391 Return-Path: X-Original-To: patchwork-dri-devel@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 E607F9F387 for ; Fri, 31 Oct 2014 23:56:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2F6DB20160 for ; Fri, 31 Oct 2014 23:56:56 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 3EFAA20173 for ; Fri, 31 Oct 2014 23:56:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 661A06E86C; Fri, 31 Oct 2014 16:56:40 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pd0-f181.google.com (mail-pd0-f181.google.com [209.85.192.181]) by gabe.freedesktop.org (Postfix) with ESMTP id F110D6E84A for ; Fri, 31 Oct 2014 15:57:08 -0700 (PDT) Received: by mail-pd0-f181.google.com with SMTP id y10so8117158pdj.12 for ; Fri, 31 Oct 2014 15:57:08 -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=57rPO73rmxdCylmFrCdSZ5CElTGEsYc5hwdLe4CR+PM=; b=DvWS/A7SHN4i/beraGvnQyFssUzm7X17PDue9A8JW5nWyh/4SFytuDR/PA3vF58Yvl cQviWEbJa9WMn8G3s/wWNt6t1j8naRlI2XdQFuOrSgWSXfNO764PiH9yBGphTfZ0il+N iBSKw0UKYx57rm9xgthaLcw6hvLakj8fIkNAnLBiP8ktg8IPFH1X2/cutl0sL8/C3LOj Az5i7PxilCkVHI1Z3s490q1Lr8d02k+CXGG3S3kpZkGRkcXSV7tC+Fa15g9vaZL5ZQeq IUCzqK0kw1N/AIHv1uWL5ZbqoyytL30xkF0cyPIlP2ZYKHDsdwqncQXSQqw+oTybkhcZ Ceyw== X-Received: by 10.68.57.199 with SMTP id k7mr27614949pbq.80.1414796228871; Fri, 31 Oct 2014 15:57:08 -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.57.08 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 15:57:08 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: dri-devel@lists.freedesktop.org Subject: [PATCH 25/72] gpu: ipu-v3: Consolidate mutex lock in ipu_dmfc_alloc_bandwidth() Date: Fri, 31 Oct 2014 15:54:08 -0700 Message-Id: <1414796095-10107-26-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 dmfc mutex was being acquired in ipu_dmfc_free_bandwidth(), freed, then immediately re-acquired in ipu_dmfc_alloc_bandwidth(). Acquire the lock once at the beginning of ipu_dmfc_alloc_bandwidth(). Signed-off-by: Steve Longerbeam --- drivers/gpu/ipu-v3/ipu-dmfc.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/ipu-v3/ipu-dmfc.c b/drivers/gpu/ipu-v3/ipu-dmfc.c index 6ef4932..1823004 100644 --- a/drivers/gpu/ipu-v3/ipu-dmfc.c +++ b/drivers/gpu/ipu-v3/ipu-dmfc.c @@ -283,7 +283,7 @@ static int dmfc_find_slots(struct ipu_dmfc_priv *priv, int slots) return -EBUSY; } -void ipu_dmfc_free_bandwidth(struct dmfc_channel *dmfc) +static void dmfc_free_bandwidth(struct dmfc_channel *dmfc) { struct ipu_dmfc_priv *priv = dmfc->priv; int i; @@ -291,10 +291,8 @@ void ipu_dmfc_free_bandwidth(struct dmfc_channel *dmfc) dev_dbg(priv->dev, "dmfc: freeing %d slots starting from segment %d\n", dmfc->slots, dmfc->segment); - mutex_lock(&priv->mutex); - if (!dmfc->slots) - goto out; + return; dmfc->slotmask = 0; dmfc->slots = 0; @@ -320,7 +318,14 @@ void ipu_dmfc_free_bandwidth(struct dmfc_channel *dmfc) priv->channels[i].segment, priv->channels[i].burstsize); } -out: +} + +void ipu_dmfc_free_bandwidth(struct dmfc_channel *dmfc) +{ + struct ipu_dmfc_priv *priv = dmfc->priv; + + mutex_lock(&priv->mutex); + dmfc_free_bandwidth(dmfc); mutex_unlock(&priv->mutex); } EXPORT_SYMBOL_GPL(ipu_dmfc_free_bandwidth); @@ -337,10 +342,10 @@ int ipu_dmfc_alloc_bandwidth(struct dmfc_channel *dmfc, "dmfc: trying to allocate %ldMpixel/s for IPU channel %d\n", bandwidth_pixel_per_second / 1000000, dmfc->data->ipu_channel); - ipu_dmfc_free_bandwidth(dmfc); - mutex_lock(&priv->mutex); + dmfc_free_bandwidth(dmfc); + if (slots > 8) { ret = -EBUSY; goto out;