Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp7118imp; Wed, 20 Feb 2019 13:04:55 -0800 (PST) X-Google-Smtp-Source: AHgI3IbQDb6pLpWrApzXMuP8J1Y+YTSeyvld8OqOksy9nY50XRVfzs8iKFsM7kM1NYflgpMJeUOl X-Received: by 2002:aa7:8597:: with SMTP id w23mr24704185pfn.87.1550696695432; Wed, 20 Feb 2019 13:04:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550696695; cv=none; d=google.com; s=arc-20160816; b=ITSZXnoeI3pVbvWZgkEo6NvsvG3EdPk7P9fXGefFvsqWUgmHiCd5zArnre4S4PXPMd MWqYSwptN4jDNaytxk+884YaF7XhUuvgvOlf8r007UG8gZs4Qyb/rZDRkc8tuUY+R8U0 YBQdowOWbAfxaoeIoGbKLiU3Vg5X4w7mqAfoes6bKnSMlc482+MZsDDikXDIitB+pRx0 dFG95WEg9yUu75m1etvvwtIYn5uQxIOjvHJHU2o3eCshHI9wFGtgbZtHCglfQDRJh/9m Zc+6eQQQD0q/6UlYbB7o+lJtpbZM4dnVPLNVexbMSmFNCLuU7Jwuc4fr/5esb1d/bOIv LTrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=BI6ouTc3Mc7m1dxO6TH3gkjLv3DOerEz8jJVn4asOFM=; b=d4Ep4tc/IfyKbrAa+Yc3vjY95X9/3FgkpQ/0KaKLYVAFQmD2DQG+eqGPfgk+NKnscy B4Cpfy1YH9hfNsQkisV/SvbXc7W0Cc1sGKs0YETt0hISm/KBoR7FhHZ1ZcOra6hABvdu FbXs20+LUQRaFtmpWmsuMG9Dqe72+eM27/IEuHXSOtMxF9EPsU4bfEtbnZ/KTLPnALqt 3I2J7J9pF/JSaKrfA6gAmbz6Ad8XHLDxywFW0Qlo9to3n3SqMqlpuYCJiGw/h94lrYxh S2HmswkVbHZj00VgYEhg9Ve4DC3nbVwEf89gZvvneFXncNuq+PEAOC1LQWObgNxjBoU2 eXbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x67si19121826pfb.255.2019.02.20.13.04.39; Wed, 20 Feb 2019 13:04:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727160AbfBTVDz (ORCPT + 99 others); Wed, 20 Feb 2019 16:03:55 -0500 Received: from anholt.net ([50.246.234.109]:51848 "EHLO anholt.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727069AbfBTVDu (ORCPT ); Wed, 20 Feb 2019 16:03:50 -0500 Received: from localhost (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id 612C110A047F; Wed, 20 Feb 2019 13:03:50 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at anholt.net Received: from anholt.net ([127.0.0.1]) by localhost (kingsolver.anholt.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id OTQv1H3piqCp; Wed, 20 Feb 2019 13:03:48 -0800 (PST) Received: from eliezer.anholt.net (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id E385510A2D1F; Wed, 20 Feb 2019 13:03:44 -0800 (PST) Received: by eliezer.anholt.net (Postfix, from userid 1000) id 9E2352FE464F; Wed, 20 Feb 2019 13:03:43 -0800 (PST) From: Eric Anholt To: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org, Paul Kocialkowski , Maxime Ripard , Eric Anholt Subject: [PATCH 4/7] drm/vc4: Use drm_printer for the debugfs and runtime bo stats output. Date: Wed, 20 Feb 2019 13:03:40 -0800 Message-Id: <20190220210343.28157-4-eric@anholt.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190220210343.28157-1-eric@anholt.net> References: <20190220210343.28157-1-eric@anholt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now I can extend the stats without more copy and pasting between the two. Signed-off-by: Eric Anholt --- drivers/gpu/drm/vc4/vc4_bo.c | 48 +++++++++++------------------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c index 8c509d560bf0..88ebd681d7eb 100644 --- a/drivers/gpu/drm/vc4/vc4_bo.c +++ b/drivers/gpu/drm/vc4/vc4_bo.c @@ -40,7 +40,7 @@ static bool is_user_label(int label) return label >= VC4_BO_TYPE_COUNT; } -static void vc4_bo_stats_dump(struct vc4_dev *vc4) +static void vc4_bo_stats_print(struct drm_printer *p, struct vc4_dev *vc4) { int i; @@ -48,21 +48,21 @@ static void vc4_bo_stats_dump(struct vc4_dev *vc4) if (!vc4->bo_labels[i].num_allocated) continue; - DRM_INFO("%30s: %6dkb BOs (%d)\n", - vc4->bo_labels[i].name, - vc4->bo_labels[i].size_allocated / 1024, - vc4->bo_labels[i].num_allocated); + drm_printf(p, "%30s: %6dkb BOs (%d)\n", + vc4->bo_labels[i].name, + vc4->bo_labels[i].size_allocated / 1024, + vc4->bo_labels[i].num_allocated); } mutex_lock(&vc4->purgeable.lock); if (vc4->purgeable.num) - DRM_INFO("%30s: %6zdkb BOs (%d)\n", "userspace BO cache", - vc4->purgeable.size / 1024, vc4->purgeable.num); + drm_printf(p, "%30s: %6zdkb BOs (%d)\n", "userspace BO cache", + vc4->purgeable.size / 1024, vc4->purgeable.num); if (vc4->purgeable.purged_num) - DRM_INFO("%30s: %6zdkb BOs (%d)\n", "total purged BO", - vc4->purgeable.purged_size / 1024, - vc4->purgeable.purged_num); + drm_printf(p, "%30s: %6zdkb BOs (%d)\n", "total purged BO", + vc4->purgeable.purged_size / 1024, + vc4->purgeable.purged_num); mutex_unlock(&vc4->purgeable.lock); } @@ -71,30 +71,9 @@ static int vc4_bo_stats_debugfs(struct seq_file *m, void *unused) struct drm_info_node *node = (struct drm_info_node *)m->private; struct drm_device *dev = node->minor->dev; struct vc4_dev *vc4 = to_vc4_dev(dev); - int i; - - mutex_lock(&vc4->bo_lock); - for (i = 0; i < vc4->num_labels; i++) { - if (!vc4->bo_labels[i].num_allocated) - continue; - - seq_printf(m, "%30s: %6dkb BOs (%d)\n", - vc4->bo_labels[i].name, - vc4->bo_labels[i].size_allocated / 1024, - vc4->bo_labels[i].num_allocated); - } - mutex_unlock(&vc4->bo_lock); + struct drm_printer p = drm_seq_file_printer(m); - mutex_lock(&vc4->purgeable.lock); - if (vc4->purgeable.num) - seq_printf(m, "%30s: %6zdkb BOs (%d)\n", "userspace BO cache", - vc4->purgeable.size / 1024, vc4->purgeable.num); - - if (vc4->purgeable.purged_num) - seq_printf(m, "%30s: %6zdkb BOs (%d)\n", "total purged BO", - vc4->purgeable.purged_size / 1024, - vc4->purgeable.purged_num); - mutex_unlock(&vc4->purgeable.lock); + vc4_bo_stats_print(&p, vc4); return 0; } @@ -473,8 +452,9 @@ struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t unaligned_size, } if (IS_ERR(cma_obj)) { + struct drm_printer p = drm_info_printer(vc4->dev->dev); DRM_ERROR("Failed to allocate from CMA:\n"); - vc4_bo_stats_dump(vc4); + vc4_bo_stats_print(&p, vc4); return ERR_PTR(-ENOMEM); } bo = to_vc4_bo(&cma_obj->base); -- 2.20.1