From patchwork Fri Sep 25 11:57:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 7263501 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E75BCBEEC1 for ; Fri, 25 Sep 2015 11:58:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E3CE320B1A for ; Fri, 25 Sep 2015 11:58:20 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DE5FF20B0F for ; Fri, 25 Sep 2015 11:58:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7922BA543; Fri, 25 Sep 2015 04:58:07 -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.4.pengutronix.de [92.198.50.35]) by gabe.freedesktop.org (Postfix) with ESMTPS id DE3466F09C for ; Fri, 25 Sep 2015 04:58:04 -0700 (PDT) Received: from weser.hi.4.pengutronix.de ([10.1.0.109] helo=weser.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1ZfRda-0004Em-Ac; Fri, 25 Sep 2015 13:58:02 +0200 From: Lucas Stach To: Russell King , Christian Gmeiner Subject: [PATCH 13/48] staging: etnaviv: fix gpu debugfs show implementation Date: Fri, 25 Sep 2015 13:57:25 +0200 Message-Id: <1443182280-15868-14-git-send-email-l.stach@pengutronix.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1443182280-15868-1-git-send-email-l.stach@pengutronix.de> References: <20150916080435.GA21084@n2100.arm.linux.org.uk> <1443182280-15868-1-git-send-email-l.stach@pengutronix.de> X-SA-Exim-Connect-IP: 10.1.0.109 X-SA-Exim-Mail-From: l.stach@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: dri-devel@lists.freedesktop.org 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.2 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 From: Russell King Signed-off-by: Russell King --- drivers/staging/etnaviv/etnaviv_drv.c | 43 ++++++++++++++++++++--------------- drivers/staging/etnaviv/etnaviv_gpu.c | 21 ++++++++++++++--- drivers/staging/etnaviv/etnaviv_gpu.h | 2 +- 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/drivers/staging/etnaviv/etnaviv_drv.c b/drivers/staging/etnaviv/etnaviv_drv.c index 8dcd7f19ecff..1071c449f3d4 100644 --- a/drivers/staging/etnaviv/etnaviv_drv.c +++ b/drivers/staging/etnaviv/etnaviv_drv.c @@ -187,23 +187,6 @@ static void etnaviv_preclose(struct drm_device *dev, struct drm_file *file) */ #ifdef CONFIG_DEBUG_FS -static int etnaviv_gpu_show(struct drm_device *dev, struct seq_file *m) -{ - struct etnaviv_drm_private *priv = dev->dev_private; - struct etnaviv_gpu *gpu; - unsigned int i; - - for (i = 0; i < ETNA_MAX_PIPES; i++) { - gpu = priv->gpu[i]; - if (gpu) { - seq_printf(m, "%s Status:\n", dev_name(gpu->dev)); - etnaviv_gpu_debugfs(gpu, m); - } - } - - return 0; -} - static int etnaviv_gem_show(struct drm_device *dev, struct seq_file *m) { struct etnaviv_drm_private *priv = dev->dev_private; @@ -266,8 +249,32 @@ static int show_locked(struct seq_file *m, void *arg) return ret; } +static int show_each_gpu(struct seq_file *m, void *arg) +{ + struct drm_info_node *node = (struct drm_info_node *) m->private; + struct drm_device *dev = node->minor->dev; + struct etnaviv_drm_private *priv = dev->dev_private; + struct etnaviv_gpu *gpu; + int (*show)(struct etnaviv_gpu *gpu, struct seq_file *m) = + node->info_ent->data; + unsigned int i; + int ret = 0; + + for (i = 0; i < ETNA_MAX_PIPES; i++) { + gpu = priv->gpu[i]; + if (!gpu) + continue; + + ret = show(gpu, m); + if (ret < 0) + break; + } + + return ret; +} + static struct drm_info_list etnaviv_debugfs_list[] = { - {"gpu", show_locked, 0, etnaviv_gpu_show}, + {"gpu", show_each_gpu, 0, etnaviv_gpu_debugfs}, {"gem", show_locked, 0, etnaviv_gem_show}, { "mm", show_locked, 0, etnaviv_mm_show }, {"mmu", show_locked, 0, etnaviv_mmu_show}, diff --git a/drivers/staging/etnaviv/etnaviv_gpu.c b/drivers/staging/etnaviv/etnaviv_gpu.c index 570bcd60025b..9f4e99855517 100644 --- a/drivers/staging/etnaviv/etnaviv_gpu.c +++ b/drivers/staging/etnaviv/etnaviv_gpu.c @@ -547,13 +547,21 @@ static void verify_dma(struct etnaviv_gpu *gpu, struct dma_debug *debug) } } -void etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m) +int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m) { struct dma_debug debug; u32 dma_lo, dma_hi, axi, idle; + int ret; + + seq_printf(m, "%s Status:\n", dev_name(gpu->dev)); + + ret = pm_runtime_get_sync(gpu->dev); + if (ret < 0) + return ret; - if (pm_runtime_get_sync(gpu->dev) < 0) - return; + ret = mutex_lock_interruptible(&gpu->drm->struct_mutex); + if (ret < 0) + goto err_rpm; dma_lo = gpu_read(gpu, VIVS_FE_DMA_LOW); dma_hi = gpu_read(gpu, VIVS_FE_DMA_HIGH); @@ -653,8 +661,15 @@ void etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m) seq_printf(m, "\t last fetch 64 bit word: 0x%08x 0x%08x\n", dma_lo, dma_hi); + ret = 0; + + mutex_unlock(&gpu->drm->struct_mutex); + +err_rpm: pm_runtime_mark_last_busy(gpu->dev); pm_runtime_put_autosuspend(gpu->dev); + + return ret; } #endif diff --git a/drivers/staging/etnaviv/etnaviv_gpu.h b/drivers/staging/etnaviv/etnaviv_gpu.h index 21e45e875e73..6b4f241c0ca6 100644 --- a/drivers/staging/etnaviv/etnaviv_gpu.h +++ b/drivers/staging/etnaviv/etnaviv_gpu.h @@ -146,7 +146,7 @@ int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, uint32_t param, int etnaviv_gpu_init(struct etnaviv_gpu *gpu); #ifdef CONFIG_DEBUG_FS -void etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m); +int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m); #endif void etnaviv_gpu_retire(struct etnaviv_gpu *gpu);