From patchwork Wed Jul 6 23:06:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 9217315 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AD525607D9 for ; Wed, 6 Jul 2016 23:07:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DE5E28527 for ; Wed, 6 Jul 2016 23:07:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FCEE28524; Wed, 6 Jul 2016 23:07:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 385E728524 for ; Wed, 6 Jul 2016 23:07:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932596AbcGFXHk (ORCPT ); Wed, 6 Jul 2016 19:07:40 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:36416 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932567AbcGFXHf (ORCPT ); Wed, 6 Jul 2016 19:07:35 -0400 Received: by mail-pa0-f65.google.com with SMTP id ib6so90656pad.3 for ; Wed, 06 Jul 2016 16:07:35 -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=taruoVAHpycKSrmYUdbOwWX602+uW9wkd4uh7t5jVU4=; b=N+eAko1V1kpKs20fr1FC1QY7gDSrqviqFQ/DT7WEO14BGAsOuqSz5bbgubKrgneXVI fxUlH55FsxzyCWBTTR7IxXCjtSVDXiz1BqfSuKPLDZxE9HowFxPAaK6pWvM1DPakDTJu wZf53C883vy+WUwOqUKagblNWl6TtgT3kg1r1RN83GKa6HVal1MdRHDZbCjp6LFLUUDC c0TtWONDEJ9+JuJIeWqhbP9ku0Cn/TdiENaZvCKQuXIgA75P/pXi8crBKdWNo/ZdgnsI pjrFW8v3djW/hTRKkDkI05jVRnMbr6Pg87WErSNWQ31XGzZLD6sssW+83HoXhm9GtkIn cr7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=taruoVAHpycKSrmYUdbOwWX602+uW9wkd4uh7t5jVU4=; b=i/jmX+mizbrQo4G9lDML8hOqbKB39QSLCk0fWH9LHClQv6y7hCprjt9c6p3fWL6c6k xUIbrAfRqVjS0eTA5Tzouf2ZFhry1k7TEsQ6RGAnzflmlyEmb3ATnNdrKeevteHGqNO9 iHQzfeK5/cF9SD0r64uwO8snRjbM4UOFhUqNm11eJjfNdNzNSh1badfQQYz5ZGDc14Mk 6mF31Ij5FDZ8qLJUoeqje+DQoGgz74h+6FZYbkYkqpMhgiqpztHyYoUE53qVgRfO6nUi dijiJkW9MWJGRH/7bKQKJmwIC04O3QQlMqsTrhcYoAVGowKK5S9L1wzgZDl9eB+/vLvP k+dA== X-Gm-Message-State: ALyK8tILpxiyUR47ZcCmAym1gnLMA83B5JbjdpzEUyaM693LApYZL93nc9wCUjY1ihg4kg== X-Received: by 10.66.156.9 with SMTP id wa9mr46036946pab.64.1467846454970; Wed, 06 Jul 2016 16:07:34 -0700 (PDT) Received: from mothership.sklembedded.com (c-73-241-2-21.hsd1.ca.comcast.net. [73.241.2.21]) by smtp.googlemail.com with ESMTPSA id c189sm6724125pfg.19.2016.07.06.16.07.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Jul 2016 16:07:34 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH 13/28] gpu: ipu-v3: Fix IRT usage Date: Wed, 6 Jul 2016 16:06:43 -0700 Message-Id: <1467846418-12913-14-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467846418-12913-1-git-send-email-steve_longerbeam@mentor.com> References: <1465944574-15745-1-git-send-email-steve_longerbeam@mentor.com> <1467846418-12913-1-git-send-email-steve_longerbeam@mentor.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There can be multiple IC tasks using the IRT, so the IRT needs a separate use counter. Create a private ipu_irt_enable() to enable the IRT module when any IC task requires rotation, and ipu_irt_disable() when a task no longer needs the IRT. Signed-off-by: Steve Longerbeam --- drivers/gpu/ipu-v3/ipu-ic.c | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/ipu-v3/ipu-ic.c b/drivers/gpu/ipu-v3/ipu-ic.c index f306a9c..5329bfe 100644 --- a/drivers/gpu/ipu-v3/ipu-ic.c +++ b/drivers/gpu/ipu-v3/ipu-ic.c @@ -160,6 +160,7 @@ struct ipu_ic_priv { spinlock_t lock; struct ipu_soc *ipu; int use_count; + int irt_use_count; struct ipu_ic task[IC_NUM_TASKS]; }; @@ -379,8 +380,6 @@ void ipu_ic_task_disable(struct ipu_ic *ic) ipu_ic_write(ic, ic_conf, IC_CONF); - ic->rotation = ic->graphics = false; - spin_unlock_irqrestore(&priv->lock, flags); } EXPORT_SYMBOL_GPL(ipu_ic_task_disable); @@ -639,22 +638,44 @@ int ipu_ic_set_src(struct ipu_ic *ic, int csi_id, bool vdi) } EXPORT_SYMBOL_GPL(ipu_ic_set_src); +static void ipu_irt_enable(struct ipu_ic *ic) +{ + struct ipu_ic_priv *priv = ic->priv; + + if (!priv->irt_use_count) + ipu_module_enable(priv->ipu, IPU_CONF_ROT_EN); + + priv->irt_use_count++; +} + +static void ipu_irt_disable(struct ipu_ic *ic) +{ + struct ipu_ic_priv *priv = ic->priv; + + priv->irt_use_count--; + + if (!priv->irt_use_count) + ipu_module_disable(priv->ipu, IPU_CONF_ROT_EN); + + if (priv->irt_use_count < 0) + priv->irt_use_count = 0; +} + int ipu_ic_enable(struct ipu_ic *ic) { struct ipu_ic_priv *priv = ic->priv; unsigned long flags; - u32 module = IPU_CONF_IC_EN; spin_lock_irqsave(&priv->lock, flags); - if (ic->rotation) - module |= IPU_CONF_ROT_EN; - if (!priv->use_count) - ipu_module_enable(priv->ipu, module); + ipu_module_enable(priv->ipu, IPU_CONF_IC_EN); priv->use_count++; + if (ic->rotation) + ipu_irt_enable(ic); + spin_unlock_irqrestore(&priv->lock, flags); return 0; @@ -665,18 +686,22 @@ int ipu_ic_disable(struct ipu_ic *ic) { struct ipu_ic_priv *priv = ic->priv; unsigned long flags; - u32 module = IPU_CONF_IC_EN | IPU_CONF_ROT_EN; spin_lock_irqsave(&priv->lock, flags); priv->use_count--; if (!priv->use_count) - ipu_module_disable(priv->ipu, module); + ipu_module_disable(priv->ipu, IPU_CONF_IC_EN); if (priv->use_count < 0) priv->use_count = 0; + if (ic->rotation) + ipu_irt_disable(ic); + + ic->rotation = ic->graphics = false; + spin_unlock_irqrestore(&priv->lock, flags); return 0;