From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EDE0C76188 for ; Tue, 4 Apr 2023 01:29:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233004AbjDDB3g (ORCPT ); Mon, 3 Apr 2023 21:29:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232760AbjDDB3Y (ORCPT ); Mon, 3 Apr 2023 21:29:24 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BE411739 for ; Mon, 3 Apr 2023 18:28:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680571688; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EZFPqC4WQTzfq8S5r5hBCf2SlUHwstyrVjQ9+R5S5vs=; b=YNRx4UrZ/sZfw91o6z9UkZZrlXIrS3BLIMsb7JFuma3IuWnbCmqJfceD3+EyXYuEhiZ6/S aRI9pZE5OspRAYIeRbDaAQ4JtqFH03TJKkimZWwrJAaorlqGyEw/0oeGhZF1KGhUS1YUNE GgT6hyBtyFHSTScz2p11x7P1Tlukl+o= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-201-r3AV0OwmPx6IBs7piOWEmw-1; Mon, 03 Apr 2023 21:28:07 -0400 X-MC-Unique: r3AV0OwmPx6IBs7piOWEmw-1 Received: by mail-ed1-f71.google.com with SMTP id i42-20020a0564020f2a00b004fd23c238beso43499845eda.0 for ; Mon, 03 Apr 2023 18:28:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680571686; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EZFPqC4WQTzfq8S5r5hBCf2SlUHwstyrVjQ9+R5S5vs=; b=bMylu9b2xhsO+XcyhFzKRL3cQ8lBsRCQeXH8GpP5loC++m4j0oxDkqY05aL5EvMU2Y fMm1KRCfVexGCbF7yNhumNZh7Hm9uemutnNqTSRMhPXT0G+a3seX8lu8oUv0uYE7wepi A8m+O5JWCJdRFWsRoywnSATtwDpVYEMiE16LTIACKtT/maLCNtXdrKHWJbPXrwB3QB4a EulIppg4pp2GgABFKkI1jVInAkr7q8xBE6jbOV0wG1XWona2ytc/sPjd4KiIEJVshCXS 5KkRNANbV35BvrimAeN8hdf8j+svz8RxnVDzHc9cZOg0/SZyT72L5NSBxu53Y/w+pG+F Ysuw== X-Gm-Message-State: AAQBX9f7SoK+nlWNIexIIDz0n3MIMkzpWQMwSf8xbGC9Fj86JdKH2/jw Woe3OQVwvORfjWUIbMKphRvLvRUdsV4jLTt7N6lS/ZHvJCdYDZKzusQOZJ+mo1+tk1k9KF9MY1n gjJviGVkJVTtt8Nz35Zr2ByEN X-Received: by 2002:a17:906:3a9b:b0:93d:770:25df with SMTP id y27-20020a1709063a9b00b0093d077025dfmr587851ejd.37.1680571686001; Mon, 03 Apr 2023 18:28:06 -0700 (PDT) X-Google-Smtp-Source: AKy350YRFuOmPg+fvmERVo3BNrgZjVuoI9Ki0TWGDpFssAfKrT9WIiw2x1JpIrMYlPLHFEDNiobo8g== X-Received: by 2002:a17:906:3a9b:b0:93d:770:25df with SMTP id y27-20020a1709063a9b00b0093d077025dfmr587820ejd.37.1680571685708; Mon, 03 Apr 2023 18:28:05 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de78:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id dx21-20020a170906a85500b008d044ede804sm5170526ejb.163.2023.04.03.18.28.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 18:28:05 -0700 (PDT) From: Danilo Krummrich To: airlied@gmail.com, daniel@ffwll.ch, tzimmermann@suse.de, mripard@kernel.org, corbet@lwn.net, christian.koenig@amd.com, bskeggs@redhat.com, Liam.Howlett@oracle.com, matthew.brost@intel.com, boris.brezillon@collabora.com, alexdeucher@gmail.com, ogabbay@kernel.org, bagasdotme@gmail.com, willy@infradead.org, jason@jlekstrand.net Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Danilo Krummrich Subject: [PATCH drm-next v3 05/15] drm: debugfs: provide infrastructure to dump a DRM GPU VA space Date: Tue, 4 Apr 2023 03:27:31 +0200 Message-Id: <20230404012741.116502-6-dakr@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230404012741.116502-1-dakr@redhat.com> References: <20230404012741.116502-1-dakr@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This commit adds a function to dump a DRM GPU VA space and a macro for drivers to register the struct drm_info_list 'gpuvas' entry. Most likely, most drivers might maintain one DRM GPU VA space per struct drm_file, but there might also be drivers not having a fixed relation between DRM GPU VA spaces and a DRM core infrastructure, hence we need the indirection via the driver iterating it's maintained DRM GPU VA spaces. Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/drm_debugfs.c | 41 +++++++++++++++++++++++++++++++++++ include/drm/drm_debugfs.h | 25 +++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 4855230ba2c6..82180fb1c200 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "drm_crtc_internal.h" #include "drm_internal.h" @@ -175,6 +176,46 @@ static const struct file_operations drm_debugfs_fops = { .release = single_release, }; +/** + * drm_debugfs_gpuva_info - dump the given DRM GPU VA space + * @m: pointer to the &seq_file to write + * @mgr: the &drm_gpuva_manager representing the GPU VA space + * + * Dumps the GPU VA mappings of a given DRM GPU VA manager. + * + * For each DRM GPU VA space drivers should call this function from their + * &drm_info_list's show callback. + * + * Returns: 0 on success, -ENODEV if the &mgr is not initialized + */ +int drm_debugfs_gpuva_info(struct seq_file *m, + struct drm_gpuva_manager *mgr) +{ + DRM_GPUVA_ITER(it, mgr, 0); + struct drm_gpuva *va, *kva = &mgr->kernel_alloc_node; + + if (!mgr->name) + return -ENODEV; + + seq_printf(m, "DRM GPU VA space (%s) [0x%016llx;0x%016llx]\n", + mgr->name, mgr->mm_start, mgr->mm_start + mgr->mm_range); + seq_printf(m, "Kernel reserved node [0x%016llx;0x%016llx]\n", + kva->va.addr, kva->va.addr + kva->va.range); + seq_puts(m, "\n"); + seq_puts(m, " VAs | start | range | end | object | object offset\n"); + seq_puts(m, "-------------------------------------------------------------------------------------------------------------\n"); + drm_gpuva_iter_for_each(va, it) { + if (unlikely(va == &mgr->kernel_alloc_node)) + continue; + + seq_printf(m, " | 0x%016llx | 0x%016llx | 0x%016llx | 0x%016llx | 0x%016llx\n", + va->va.addr, va->va.range, va->va.addr + va->va.range, + (u64)va->gem.obj, va->gem.offset); + } + + return 0; +} +EXPORT_SYMBOL(drm_debugfs_gpuva_info); /** * drm_debugfs_create_files - Initialize a given set of debugfs files for DRM diff --git a/include/drm/drm_debugfs.h b/include/drm/drm_debugfs.h index 7616f457ce70..cb2c1956a214 100644 --- a/include/drm/drm_debugfs.h +++ b/include/drm/drm_debugfs.h @@ -34,6 +34,22 @@ #include #include + +#include + +/** + * DRM_DEBUGFS_GPUVA_INFO - &drm_info_list entry to dump a GPU VA space + * @show: the &drm_info_list's show callback + * @data: driver private data + * + * Drivers should use this macro to define a &drm_info_list entry to provide a + * debugfs file for dumping the GPU VA space regions and mappings. + * + * For each DRM GPU VA space drivers should call drm_debugfs_gpuva_info() from + * their @show callback. + */ +#define DRM_DEBUGFS_GPUVA_INFO(show, data) {"gpuvas", show, DRIVER_GEM_GPUVA, data} + /** * struct drm_info_list - debugfs info list entry * @@ -134,6 +150,9 @@ void drm_debugfs_add_file(struct drm_device *dev, const char *name, void drm_debugfs_add_files(struct drm_device *dev, const struct drm_debugfs_info *files, int count); + +int drm_debugfs_gpuva_info(struct seq_file *m, + struct drm_gpuva_manager *mgr); #else static inline void drm_debugfs_create_files(const struct drm_info_list *files, int count, struct dentry *root, @@ -155,6 +174,12 @@ static inline void drm_debugfs_add_files(struct drm_device *dev, const struct drm_debugfs_info *files, int count) {} + +static inline int drm_debugfs_gpuva_info(struct seq_file *m, + struct drm_gpuva_manager *mgr) +{ + return 0; +} #endif #endif /* _DRM_DEBUGFS_H_ */ -- 2.39.2