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 <[email protected]>
---
drivers/gpu/drm/drm_debugfs.c | 56 +++++++++++++++++++++++++++++++++++
include/drm/drm_debugfs.h | 25 ++++++++++++++++
2 files changed, 81 insertions(+)
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index 4f643a490dc3..5389dd73c0fb 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -39,6 +39,7 @@
#include <drm/drm_file.h>
#include <drm/drm_gem.h>
#include <drm/drm_managed.h>
+#include <drm/drm_gpuva_mgr.h>
#include "drm_crtc_internal.h"
#include "drm_internal.h"
@@ -175,6 +176,61 @@ 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 regions and 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)
+{
+ struct drm_gpuva_region *reg;
+ struct drm_gpuva *va;
+
+ if (!mgr->name)
+ return -ENODEV;
+
+ seq_printf(m, "DRM GPU VA space (%s)\n", mgr->name);
+ seq_puts (m, "\n");
+ seq_puts (m, " VA regions | start | range | end | sparse\n");
+ seq_puts (m, "------------------------------------------------------------------------------------\n");
+ seq_printf(m, " VA space | 0x%016llx | 0x%016llx | 0x%016llx | -\n",
+ mgr->mm_start, mgr->mm_range, mgr->mm_start + mgr->mm_range);
+ seq_puts (m, "-----------------------------------------------------------------------------------\n");
+ drm_gpuva_for_each_region(reg, mgr) {
+ struct drm_mm_node *node = ®->node;
+
+ if (node == &mgr->kernel_alloc_node) {
+ seq_printf(m, " kernel node | 0x%016llx | 0x%016llx | 0x%016llx | -\n",
+ node->start, node->size, node->start + node->size);
+ continue;
+ }
+
+ seq_printf(m, " | 0x%016llx | 0x%016llx | 0x%016llx | %s\n",
+ node->start, node->size, node->start + node->size,
+ reg->sparse ? "true" : "false");
+ }
+ seq_puts(m, "\n");
+ seq_puts(m, " VAs | start | range | end | object | object offset\n");
+ seq_puts(m, "-------------------------------------------------------------------------------------------------------------\n");
+ drm_gpuva_for_each_va(va, mgr) {
+ struct drm_mm_node *node = &va->node;
+
+ seq_printf(m, " | 0x%016llx | 0x%016llx | 0x%016llx | 0x%016llx | 0x%016llx\n",
+ node->start, node->size, node->start + node->size,
+ (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 <linux/types.h>
#include <linux/seq_file.h>
+
+#include <drm/drm_gpuva_mgr.h>
+
+/**
+ * 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.0
Hi Danilo,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on 0b45ac1170ea6416bc1d36798414c04870cd356d]
url: https://github.com/intel-lab-lkp/linux/commits/Danilo-Krummrich/drm-execution-context-for-GEM-buffers/20230118-141552
base: 0b45ac1170ea6416bc1d36798414c04870cd356d
patch link: https://lore.kernel.org/r/20230118061256.2689-5-dakr%40redhat.com
patch subject: [PATCH drm-next 04/14] drm: debugfs: provide infrastructure to dump a DRM GPU VA space
config: i386-randconfig-a003 (https://download.01.org/0day-ci/archive/20230118/[email protected]/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/e00f79934034ce7eb4e7fc0d722a3d28d75d44bf
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Danilo-Krummrich/drm-execution-context-for-GEM-buffers/20230118-141552
git checkout e00f79934034ce7eb4e7fc0d722a3d28d75d44bf
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=i386 olddefconfig
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/gpu/drm/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
All warnings (new ones prefixed by >>):
drivers/gpu/drm/drm_debugfs.c: In function 'drm_debugfs_gpuva_info':
>> drivers/gpu/drm/drm_debugfs.c:228:28: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
228 | (u64)va->gem.obj, va->gem.offset);
| ^
vim +228 drivers/gpu/drm/drm_debugfs.c
178
179 /**
180 * drm_debugfs_gpuva_info - dump the given DRM GPU VA space
181 * @m: pointer to the &seq_file to write
182 * @mgr: the &drm_gpuva_manager representing the GPU VA space
183 *
184 * Dumps the GPU VA regions and mappings of a given DRM GPU VA manager.
185 *
186 * For each DRM GPU VA space drivers should call this function from their
187 * &drm_info_list's show callback.
188 *
189 * Returns: 0 on success, -ENODEV if the &mgr is not initialized
190 */
191 int drm_debugfs_gpuva_info(struct seq_file *m,
192 struct drm_gpuva_manager *mgr)
193 {
194 struct drm_gpuva_region *reg;
195 struct drm_gpuva *va;
196
197 if (!mgr->name)
198 return -ENODEV;
199
200 seq_printf(m, "DRM GPU VA space (%s)\n", mgr->name);
201 seq_puts (m, "\n");
202 seq_puts (m, " VA regions | start | range | end | sparse\n");
203 seq_puts (m, "------------------------------------------------------------------------------------\n");
204 seq_printf(m, " VA space | 0x%016llx | 0x%016llx | 0x%016llx | -\n",
205 mgr->mm_start, mgr->mm_range, mgr->mm_start + mgr->mm_range);
206 seq_puts (m, "-----------------------------------------------------------------------------------\n");
207 drm_gpuva_for_each_region(reg, mgr) {
208 struct drm_mm_node *node = ®->node;
209
210 if (node == &mgr->kernel_alloc_node) {
211 seq_printf(m, " kernel node | 0x%016llx | 0x%016llx | 0x%016llx | -\n",
212 node->start, node->size, node->start + node->size);
213 continue;
214 }
215
216 seq_printf(m, " | 0x%016llx | 0x%016llx | 0x%016llx | %s\n",
217 node->start, node->size, node->start + node->size,
218 reg->sparse ? "true" : "false");
219 }
220 seq_puts(m, "\n");
221 seq_puts(m, " VAs | start | range | end | object | object offset\n");
222 seq_puts(m, "-------------------------------------------------------------------------------------------------------------\n");
223 drm_gpuva_for_each_va(va, mgr) {
224 struct drm_mm_node *node = &va->node;
225
226 seq_printf(m, " | 0x%016llx | 0x%016llx | 0x%016llx | 0x%016llx | 0x%016llx\n",
227 node->start, node->size, node->start + node->size,
> 228 (u64)va->gem.obj, va->gem.offset);
229 }
230
231 return 0;
232 }
233 EXPORT_SYMBOL(drm_debugfs_gpuva_info);
234
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
Hi Danilo,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on 0b45ac1170ea6416bc1d36798414c04870cd356d]
url: https://github.com/intel-lab-lkp/linux/commits/Danilo-Krummrich/drm-execution-context-for-GEM-buffers/20230118-141552
base: 0b45ac1170ea6416bc1d36798414c04870cd356d
patch link: https://lore.kernel.org/r/20230118061256.2689-5-dakr%40redhat.com
patch subject: [PATCH drm-next 04/14] drm: debugfs: provide infrastructure to dump a DRM GPU VA space
config: parisc-randconfig-s041-20230115 (https://download.01.org/0day-ci/archive/20230118/[email protected]/config)
compiler: hppa-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/e00f79934034ce7eb4e7fc0d722a3d28d75d44bf
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Danilo-Krummrich/drm-execution-context-for-GEM-buffers/20230118-141552
git checkout e00f79934034ce7eb4e7fc0d722a3d28d75d44bf
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=parisc olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=parisc SHELL=/bin/bash drivers/gpu/drm/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
sparse warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/drm_debugfs.c:228:33: sparse: sparse: non size-preserving pointer to integer cast
vim +228 drivers/gpu/drm/drm_debugfs.c
178
179 /**
180 * drm_debugfs_gpuva_info - dump the given DRM GPU VA space
181 * @m: pointer to the &seq_file to write
182 * @mgr: the &drm_gpuva_manager representing the GPU VA space
183 *
184 * Dumps the GPU VA regions and mappings of a given DRM GPU VA manager.
185 *
186 * For each DRM GPU VA space drivers should call this function from their
187 * &drm_info_list's show callback.
188 *
189 * Returns: 0 on success, -ENODEV if the &mgr is not initialized
190 */
191 int drm_debugfs_gpuva_info(struct seq_file *m,
192 struct drm_gpuva_manager *mgr)
193 {
194 struct drm_gpuva_region *reg;
195 struct drm_gpuva *va;
196
197 if (!mgr->name)
198 return -ENODEV;
199
200 seq_printf(m, "DRM GPU VA space (%s)\n", mgr->name);
201 seq_puts (m, "\n");
202 seq_puts (m, " VA regions | start | range | end | sparse\n");
203 seq_puts (m, "------------------------------------------------------------------------------------\n");
204 seq_printf(m, " VA space | 0x%016llx | 0x%016llx | 0x%016llx | -\n",
205 mgr->mm_start, mgr->mm_range, mgr->mm_start + mgr->mm_range);
206 seq_puts (m, "-----------------------------------------------------------------------------------\n");
207 drm_gpuva_for_each_region(reg, mgr) {
208 struct drm_mm_node *node = ®->node;
209
210 if (node == &mgr->kernel_alloc_node) {
211 seq_printf(m, " kernel node | 0x%016llx | 0x%016llx | 0x%016llx | -\n",
212 node->start, node->size, node->start + node->size);
213 continue;
214 }
215
216 seq_printf(m, " | 0x%016llx | 0x%016llx | 0x%016llx | %s\n",
217 node->start, node->size, node->start + node->size,
218 reg->sparse ? "true" : "false");
219 }
220 seq_puts(m, "\n");
221 seq_puts(m, " VAs | start | range | end | object | object offset\n");
222 seq_puts(m, "-------------------------------------------------------------------------------------------------------------\n");
223 drm_gpuva_for_each_va(va, mgr) {
224 struct drm_mm_node *node = &va->node;
225
226 seq_printf(m, " | 0x%016llx | 0x%016llx | 0x%016llx | 0x%016llx | 0x%016llx\n",
227 node->start, node->size, node->start + node->size,
> 228 (u64)va->gem.obj, va->gem.offset);
229 }
230
231 return 0;
232 }
233 EXPORT_SYMBOL(drm_debugfs_gpuva_info);
234
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests