Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7742595rwd; Tue, 6 Jun 2023 15:54:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5uRreuVsKOxs9zVjvd+w1JCrANwaBszXs7EOeGbwpr9ZUEbRmpdh4HULFE59Dq5rddFg1g X-Received: by 2002:a92:d382:0:b0:335:fef6:6b76 with SMTP id o2-20020a92d382000000b00335fef66b76mr4722411ilo.6.1686092072554; Tue, 06 Jun 2023 15:54:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686092072; cv=none; d=google.com; s=arc-20160816; b=y9PRrP0VEmFSPwqbjyj3maHv2o3DLYprUbxzARNz4T/YdxzDjJIFL2fH3MfWaHGcNi oM9aCYPImtjNm+sh3RPIKZUifLHA7M9TCgJsgR6CAD+sff6es3g4zoZ8B6S5G7lvo7Hx IdVedDN4gJL0M8AB3fPoprCiBT8Paqc65ifLlqe8BA9hBu+1eD4dnsNAyqiYMLnJPYdB AwNelkk+73JhPWqwWg0J3b9py7/ca6IM5uen2Xk4BW4WdYIf5UkAxerqqv+tdh3laMLs WFHN94rv9G4ICDbFwKrxgpfpcSmtMyVCZET5apWP8rAQuccmc0Yo5h5YHYuonHoPUeMY Cbiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VAsnh4By1Dlsxa7yVRPYZeW4lQVXq7K2JYovOcCMg38=; b=F1j1OP5p333cRAeERhAWRGo1+wVIlRUh682c5SqcPFrXKV7S2MMh6FpdpVzksSwzt3 bpM+RK9IMh9CZ1NOpqHPhzZgun7TYVYsXdBNFZA0owh4J6MaQUC1gf1/vyGu/ePndIA6 8hz9YkE0M8tUTJMyyhanAqUO/yxt4X2J00e0w6RRCmRuFJw3zGm276CchcIG5wsoDUvv uYj7trg8xKjSSekWd/+PZVN1PNcpV2au8I+iHwXgWSID+KTIsSmFXG4jLulbxARtQ1ma QinTAnvc4xif1UilVWCUPgxKHTzBCqbmF6RN0wMTCqRqLCOoyR0aqzFuaTgDnZFHqpTK MIbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ax1HzVi9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a7-20020a637047000000b005404f8dd0eesi7951087pgn.602.2023.06.06.15.54.20; Tue, 06 Jun 2023 15:54:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ax1HzVi9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239928AbjFFWcy (ORCPT + 99 others); Tue, 6 Jun 2023 18:32:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239902AbjFFWco (ORCPT ); Tue, 6 Jun 2023 18:32:44 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D01D171D for ; Tue, 6 Jun 2023 15:31:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686090717; 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=VAsnh4By1Dlsxa7yVRPYZeW4lQVXq7K2JYovOcCMg38=; b=ax1HzVi9ci/HGfCdduMBVX5qkpZn8jabonWooRcoi0K1+IS4aNGWHwX0M5NQy05k6k1t2G 0T4zEg630NVwh13sqhKtcEURWuvR2PV9P1EB81r0oEuKvDzGaKjYc5R7bpkSHIPM3Ga0v/ YuoTKU4Ox3+R3F05C1teI3uoHv22fH4= 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-516-vUp2Jvu7MvmIZKqHYsZ-ag-1; Tue, 06 Jun 2023 18:31:55 -0400 X-MC-Unique: vUp2Jvu7MvmIZKqHYsZ-ag-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-50daa85e940so197984a12.0 for ; Tue, 06 Jun 2023 15:31:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686090714; x=1688682714; 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=VAsnh4By1Dlsxa7yVRPYZeW4lQVXq7K2JYovOcCMg38=; b=iHBHYE9BmlbuMH8aB1P3GGClX2xWOQeNssHwgSWJov6B+rvDzALbvFl6HFfuWCxCee wEyd8FQI53FrS/kN8HvGQsT/RbIlPxT4MqtlAyihFtILDRumt0E74K0bw5YJbmAZ6m6m lb7uTMjgZmj1xaRJOj6v2Yrr5zjfc9Kzehvo9Lqe8SG0cW+XqIk7lOkrnGeTt/gDvA05 juLj2b+awIbfVp3eoYOaipop1YmtiHpmgp60ABQjZWJmDk2DcWjAeacD5cZjxDgasBp0 R9xZlJBzxtW3npXKwvwb45TNFtRaeXapb4aORSyq6IcwQ8h00GWbxosDzFopDIVvhb5l WvTA== X-Gm-Message-State: AC+VfDyxjjoJcw4kmdH4usktKZhv2qCROnOUIOGMB91wgOYhku3td9+K RV+JPkUWxn63M0m2QHBJ+NN8jXuq8t1dNqJDgsbEqY1HOXNPyiLW78dogKg+7pyZPywBkjgstEu Dqaki0Ku6+hiTYrIH+XuAt4Qw X-Received: by 2002:a17:906:730c:b0:969:813c:9868 with SMTP id di12-20020a170906730c00b00969813c9868mr3689652ejc.18.1686090714340; Tue, 06 Jun 2023 15:31:54 -0700 (PDT) X-Received: by 2002:a17:906:730c:b0:969:813c:9868 with SMTP id di12-20020a170906730c00b00969813c9868mr3689629ejc.18.1686090714181; Tue, 06 Jun 2023 15:31:54 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id dc19-20020a170906c7d300b0096efd44dbffsm6037894ejb.105.2023.06.06.15.31.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 15:31:53 -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 v4 04/14] drm: debugfs: provide infrastructure to dump a DRM GPU VA space Date: Wed, 7 Jun 2023 00:31:20 +0200 Message-Id: <20230606223130.6132-5-dakr@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230606223130.6132-1-dakr@redhat.com> References: <20230606223130.6132-1-dakr@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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.40.1