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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3794C76188 for ; Tue, 4 Apr 2023 01:28:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5FE596B007B; Mon, 3 Apr 2023 21:28:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 55E9E6B007D; Mon, 3 Apr 2023 21:28:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B1EB900002; Mon, 3 Apr 2023 21:28:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 28DF76B007B for ; Mon, 3 Apr 2023 21:28:11 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E5D051C5940 for ; Tue, 4 Apr 2023 01:28:10 +0000 (UTC) X-FDA: 80641972740.25.A14E892 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf03.hostedemail.com (Postfix) with ESMTP id E392A20019 for ; Tue, 4 Apr 2023 01:28:08 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fV4jwO5j; spf=pass (imf03.hostedemail.com: domain of dakr@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dakr@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680571688; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EZFPqC4WQTzfq8S5r5hBCf2SlUHwstyrVjQ9+R5S5vs=; b=C8vLg5q9KOqiBSQTYSW0tLACGEhvnYHOsSjDlIR5Oai7dwh6dVHsZHFI/hcPVzeR6Q9pFt wckivvbmAI+79kjanpN+zZT7qz7iXW53N5Zf86q682zokwLscVVgwcR0rbIVayp8VEZax6 +Ja7fYXABbc2as/0YIF8kCUbv8zm6EI= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fV4jwO5j; spf=pass (imf03.hostedemail.com: domain of dakr@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dakr@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680571688; a=rsa-sha256; cv=none; b=Cq6tm4gwN+MVIS3wvO/gGbb5KWKX86888aFxlzDl1zGxAVfxgxgzKlBBhNvivcLDgWvib4 fxQe8GQwAh11Yv9W+MSkXbuafLGTKd1lQhwd6EssVrjM408w4o43q8FJeq/9CQHfqM+huJ /Yx0lSpv1vG5YxmFqe05ipcoFjRB9Bw= 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-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EZFPqC4WQTzfq8S5r5hBCf2SlUHwstyrVjQ9+R5S5vs=; b=fV4jwO5jV64K7Q1LYHZSqnoj2+RXNTrWx5rwdPjBHkLqT6ViTXHLyvTFxw3N7EG43WMTLK bmWaPfolJUMvpWXB/FLqbkeLkeSOti3EtoqIbNZKq/CD2RZQT8uHKWNjS0vSSbTPv8KXar 9lQb5GmEqFaLDJkTVuBpvXI9/7iwBGc= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-201-VI1MG21-PRKevldmL2b0Dg-1; Mon, 03 Apr 2023 21:28:07 -0400 X-MC-Unique: VI1MG21-PRKevldmL2b0Dg-1 Received: by mail-ed1-f70.google.com with SMTP id c1-20020a0564021f8100b004acbe232c03so42920922edc.9 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=3IRhSW/ygkaHo4Mrf2JR4sjo7Ae+l68wQRABemY0sJUhll6mUUcyMCWDvmW1b1yZd8 W9SaG6oxu1GNYZ2eyhiKhPFlArMU/MgVDJv9Yb2mLhBEkvc1yz554Ydib0bGt/xkbjPl /sLiLm+Q2+cc1VfQH3TgwTA8pvWNfFOJyKDABgTQLYFpSE7eI9DWqGZhtgWLB9tdr71H UKUhDF+D+i8Wlf8ghSc6F1DAnPTGg4pjY1oZwDE+m1gF5SvYeeOt+8O7QoZWRXjdkuFP jrIMRBrTOGGYDzSKSfl4mJy9FZ5tvtpVUVgLvZ8oCx34aYpzTAZiEqbMPqV1orMuMLJl Ow3A== X-Gm-Message-State: AAQBX9e1SwMk1UzpMesDiIGl15DKAAw1WUoJZ3DEzxYnPGkWHYSrOaGu aEjyesLxBNZZV/S5n3U8j5N2rHs4NNIb27qrIKiuMb26o+XPxReJMv6qu3IRIneKjBA9zQzfy9W LT1hQKugeqNg= X-Received: by 2002:a17:906:3a9b:b0:93d:770:25df with SMTP id y27-20020a1709063a9b00b0093d077025dfmr587849ejd.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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: y3zjfnfg9iao94tas5qzbk7n8k8ctiz6 X-Rspamd-Queue-Id: E392A20019 X-HE-Tag: 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PxgQi6Qgqw80Gzo9svroE/BbS+c62Vp9syUSGJ5vKyENF2GTOZre6FiOzvw7l5bPpGxyg2pIllI18KOJv0Dhfg/PKGQdqV1HCkMNEtIsN/GD+N79mkj7/V/Vs13KmrOczMBNxR5R43AZx+rAJMV5+NplW3mpT6+aqiGDvj2a1IFVc1HjCXRgmswn/gqE6qI7Gdy9634qkjES2HR37vHLrb3bhTx+mJmfK+co5do4NkIEGgC+bPPqxEAzMHdiPT4Kat9WxwUlnrmAFS9R2mRMn7c/dF3FgzS7BMzJs4wRBgx41VqbpefdW8guI7Y4VFVWzMQDMxeMihRH5fmfyABaIu3lnyp4VHv3UW+Mb7TW+8yuE3QUlfE2S5N/OiouiqIVI3hCNd X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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