From patchwork Fri Jun 21 08:57:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Zabel X-Patchwork-Id: 2761121 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 215C0C0AB1 for ; Fri, 21 Jun 2013 09:00:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EEA01201B4 for ; Fri, 21 Jun 2013 09:00:36 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D5F39201B0 for ; Fri, 21 Jun 2013 09:00:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AA3A0E654A for ; Fri, 21 Jun 2013 02:00:35 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [92.198.50.35]) by gabe.freedesktop.org (Postfix) with ESMTP id 1966BE64D2 for ; Fri, 21 Jun 2013 01:57:33 -0700 (PDT) Received: from dude.hi.pengutronix.de ([10.1.0.7] helo=dude.pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Upx9n-0001FL-NI; Fri, 21 Jun 2013 10:57:23 +0200 From: Philipp Zabel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/4] staging: drm/imx: ipu-dmfc: fix bandwidth allocation Date: Fri, 21 Jun 2013 10:57:19 +0200 Message-Id: <1371805041-9299-3-git-send-email-p.zabel@pengutronix.de> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1371805041-9299-1-git-send-email-p.zabel@pengutronix.de> References: <1371805041-9299-1-git-send-email-p.zabel@pengutronix.de> X-SA-Exim-Connect-IP: 10.1.0.7 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org Cc: kernel@pengutronix.de, Greg Kroah-Hartman , dri-devel@lists.freedesktop.org, Fabio Estevam X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 The IPU can request up to four pixels per access, which gives four times the bandwidth compared to what the driver currently assumes. After correcting this, we have to increase safety margins for bandwidth requirement calculations. Signed-off-by: Philipp Zabel --- drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c b/drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c index 91821bc..1dc9817 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c @@ -292,7 +292,7 @@ int ipu_dmfc_alloc_bandwidth(struct dmfc_channel *dmfc, { struct ipu_dmfc_priv *priv = dmfc->priv; int slots = dmfc_bandwidth_to_slots(priv, bandwidth_pixel_per_second); - int segment = 0, ret = 0; + int segment = -1, ret = 0; dev_dbg(priv->dev, "dmfc: trying to allocate %ldMpixel/s for IPU channel %d\n", bandwidth_pixel_per_second / 1000000, @@ -307,7 +307,17 @@ int ipu_dmfc_alloc_bandwidth(struct dmfc_channel *dmfc, goto out; } - segment = dmfc_find_slots(priv, slots); + /* Always allocate at least 128*4 bytes (2 slots) */ + if (slots < 2) + slots = 2; + + /* For the MEM_BG channel, first try to allocate twice the slots */ + if (dmfc->data->ipu_channel == IPUV3_CHANNEL_MEM_BG_SYNC) + segment = dmfc_find_slots(priv, slots * 2); + if (segment >= 0) + slots *= 2; + else + segment = dmfc_find_slots(priv, slots); if (segment < 0) { ret = -EBUSY; goto out; @@ -391,7 +401,7 @@ int ipu_dmfc_init(struct ipu_soc *ipu, struct device *dev, unsigned long base, * We have a total bandwidth of clkrate * 4pixel divided * into 8 slots. */ - priv->bandwidth_per_slot = clk_get_rate(ipu_clk) / 8; + priv->bandwidth_per_slot = clk_get_rate(ipu_clk) * 4 / 8; dev_dbg(dev, "dmfc: 8 slots with %ldMpixel/s bandwidth each\n", priv->bandwidth_per_slot / 1000000);