Skip to contentSkip to conversation

drm: add some ttm/vram info to debugfs

PATCH In review Gerd Hoffmann 4 participants 16 messages Sep 4, 2019 – Sep 18, 2019

Subsystems (9)
lore
Share & tools
lore

Gerd Hoffmann

author maintainer
#0 lore raw

v3 cover drm: add some ttm/vram info to debugfs

Gerd Hoffmann (7):
drm: add drm_print_bits
drm/ttm: add drm gem ttm helpers, starting with
drm_gem_ttm_print_info()
drm/vram: use drm_gem_ttm_print_info
drm/vram: add vram-mm debugfs file
drm/qxl: use drm_gem_object_funcs callbacks
drm/qxl: use drm_gem_ttm_print_info
drm/vram: fix Kconfig

 drivers/gpu/drm/qxl/qxl_drv.h           |  1 +
 include/drm/drm_gem_ttm_helper.h        | 19 +++++++++
 include/drm/drm_gem_vram_helper.h       |  1 +
 include/drm/drm_print.h                 |  3 ++
 include/drm/drm_vram_mm_helper.h        |  1 +
 drivers/gpu/drm/drm_gem_ttm_helper.c    | 56 +++++++++++++++++++++++++
 drivers/gpu/drm/drm_gem_vram_helper.c   |  4 +-
 drivers/gpu/drm/drm_print.c             | 33 +++++++++++++++
 drivers/gpu/drm/drm_vram_mm_helper.c    | 44 +++++++++++++++++++
 drivers/gpu/drm/qxl/qxl_drv.c           |  8 ----
 drivers/gpu/drm/qxl/qxl_object.c        | 13 ++++++
 Documentation/gpu/drm-mm.rst            | 12 ++++++
 drivers/gpu/drm/Kconfig                 |  8 +++-
 drivers/gpu/drm/Makefile                |  3 ++
 drivers/gpu/drm/ast/Kconfig             |  2 +
 drivers/gpu/drm/bochs/Kconfig           |  2 +
 drivers/gpu/drm/hisilicon/hibmc/Kconfig |  3 +-
 drivers/gpu/drm/mgag200/Kconfig         |  2 +
 drivers/gpu/drm/vboxvideo/Kconfig       |  2 +
 19 files changed, 206 insertions(+), 11 deletions(-)
 create mode 100644 include/drm/drm_gem_ttm_helper.h
 create mode 100644 drivers/gpu/drm/drm_gem_ttm_helper.c
Signature · 6 lines
2.18.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#1 lore raw

PATCH v3 1/7 drm: add drm_print_bits

New helper to print named bits of some value (think flags fields).

---
 include/drm/drm_print.h     |  3 +++
 drivers/gpu/drm/drm_print.c | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
include/drm/drm_print.h +3 -0
index 112165d3195d..12d4916254b4 100644
@@ -89,6 +89,9 @@ __printf(2, 3)
 void drm_printf(struct drm_printer *p, const char *f, ...);
 void drm_puts(struct drm_printer *p, const char *str);
 void drm_print_regset32(struct drm_printer *p, struct debugfs_regset32 *regset);
+void drm_print_bits(struct drm_printer *p,
+		    unsigned long value, const char *bits[],
+		    unsigned int from, unsigned int to);
 
 __printf(2, 0)
 /**
drivers/gpu/drm/drm_print.c +33 -0
index ad302d71eeee..dfa27367ebb8 100644
@@ -185,6 +185,39 @@ void drm_printf(struct drm_printer *p, const char *f, ...)
 }
 EXPORT_SYMBOL(drm_printf);
 
+/**
+ * drm_print_bits - print bits to a &drm_printer stream
+ *
+ * Print bits (in flag fields for example) in human readable form.
+ * The first name in the @bits array is for the bit indexed by @from.
+ *
+ * @p: the &drm_printer
+ * @value: field value.
+ * @bits: Array with bit names.
+ * @from: start of bit range to print (inclusive).
+ * @to: end of bit range to print (exclusive).
+ */
+void drm_print_bits(struct drm_printer *p,
+		    unsigned long value, const char *bits[],
+		    unsigned int from, unsigned int to)
+{
+	bool first = true;
+	unsigned int i;
+
+	for (i = from; i < to; i++) {
+		if (!(value & (1 << i)))
+			continue;
+		if (WARN_ON_ONCE(!bits[i-from]))
+			continue;
+		drm_printf(p, "%s%s", first ? "" : ",",
+			   bits[i-from]);
+		first = false;
+	}
+	if (first)
+		drm_printf(p, "(none)");
+}
+EXPORT_SYMBOL(drm_print_bits);
+
 void drm_dev_printk(const struct device *dev, const char *level,
 		    const char *format, ...)
 {
Signature · 1 line
2.18.1
maintainer Acked-by on v3 1/7
#2 lore raw

Re: [PATCH v3 1/7] drm: add drm_print_bits

Am 04.09.19 um 07:47 schrieb Gerd Hoffmann:

Quoted 57 lines

New helper to print named bits of some value (think flags fields).

---
 include/drm/drm_print.h     |  3 +++
 drivers/gpu/drm/drm_print.c | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
include/drm/drm_print.h +3 -0
index 112165d3195d..12d4916254b4 100644
@@ -89,6 +89,9 @@ __printf(2, 3)
 void drm_printf(struct drm_printer *p, const char *f, ...);
 void drm_puts(struct drm_printer *p, const char *str);
 void drm_print_regset32(struct drm_printer *p, struct debugfs_regset32 *regset);
+void drm_print_bits(struct drm_printer *p,
+		    unsigned long value, const char *bits[],
+		    unsigned int from, unsigned int to);
 
 __printf(2, 0)
 /**
drivers/gpu/drm/drm_print.c +26 -0
index ad302d71eeee..dfa27367ebb8 100644
@@ -185,6 +185,39 @@ void drm_printf(struct drm_printer *p, const char *f, ...)
 }
 EXPORT_SYMBOL(drm_printf);
 
+/**
+ * drm_print_bits - print bits to a &drm_printer stream
+ *
+ * Print bits (in flag fields for example) in human readable form.
+ * The first name in the @bits array is for the bit indexed by @from.
+ *
+ * @p: the &drm_printer
+ * @value: field value.
+ * @bits: Array with bit names.
+ * @from: start of bit range to print (inclusive).
+ * @to: end of bit range to print (exclusive).
+ */
+void drm_print_bits(struct drm_printer *p,
+		    unsigned long value, const char *bits[],
+		    unsigned int from, unsigned int to)
+{
+	bool first = true;
+	unsigned int i;
+
+	for (i = from; i < to; i++) {
+		if (!(value & (1 << i)))
+			continue;
+		if (WARN_ON_ONCE(!bits[i-from]))
+			continue;
+		drm_printf(p, "%s%s", first ? "" : ",",
+			   bits[i-from]);

drivers/gpu/drm/drm_print.c void drm_printf(struct drm_printer *p, const char *f, ...) · line 223

Quoted 10 lines
drivers/gpu/drm/drm_print.c +7 -0
+		first = false;
+	}
+	if (first)
+		drm_printf(p, "(none)");
+}
+EXPORT_SYMBOL(drm_print_bits);
+
 void drm_dev_printk(const struct device *dev, const char *level,
 		    const char *format, ...)
 {
Signature · 5 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)
#3 lore raw

Re: [PATCH v3 1/7] drm: add drm_print_bits

Quoted 33 lines · Thomas Zimmermann

Am 04.09.19 um 07:47 schrieb Gerd Hoffmann:

Quoted 30 lines

New helper to print named bits of some value (think flags fields).

---
 include/drm/drm_print.h     |  3 +++
 drivers/gpu/drm/drm_print.c | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
include/drm/drm_print.h +3 -0
index 112165d3195d..12d4916254b4 100644
@@ -89,6 +89,9 @@ __printf(2, 3)
 void drm_printf(struct drm_printer *p, const char *f, ...);
 void drm_puts(struct drm_printer *p, const char *str);
 void drm_print_regset32(struct drm_printer *p, struct debugfs_regset32 *regset);
+void drm_print_bits(struct drm_printer *p,
+		    unsigned long value, const char *bits[],
+		    unsigned int from, unsigned int to);
 
 __printf(2, 0)
 /**
drivers/gpu/drm/drm_print.c +0 -0
index ad302d71eeee..dfa27367ebb8 100644
@@ -185,6 +185,39 @@ void drm_printf(struct drm_printer *p, const char *f, ...)
 }
 EXPORT_SYMBOL(drm_printf);
 
Quoted 11 lines

drivers/gpu/drm/drm_print.c void drm_printf(struct drm_printer *p, const char *f, ...) · line 198

Quoted 11 lines
drivers/gpu/drm/drm_print.c +11 -0
+/**
+ * drm_print_bits - print bits to a &drm_printer stream
+ *
+ * Print bits (in flag fields for example) in human readable form.
+ * The first name in the @bits array is for the bit indexed by @from.
+ *
+ * @p: the &drm_printer
+ * @value: field value.
+ * @bits: Array with bit names.
+ * @from: start of bit range to print (inclusive).
+ * @to: end of bit range to print (exclusive).

Just an aside: At least in drm we generally but the parameter docs above the free-flow text.
-Daniel

Quoted 44 lines
Quoted 16 lines
drivers/gpu/drm/drm_print.c +15 -0
+ */
+void drm_print_bits(struct drm_printer *p,
+		    unsigned long value, const char *bits[],
+		    unsigned int from, unsigned int to)
+{
+	bool first = true;
+	unsigned int i;
+
+	for (i = from; i < to; i++) {
+		if (!(value & (1 << i)))
+			continue;
+		if (WARN_ON_ONCE(!bits[i-from]))
+			continue;
+		drm_printf(p, "%s%s", first ? "" : ",",
+			   bits[i-from]);

drivers/gpu/drm/drm_print.c void drm_printf(struct drm_printer *p, const char *f, ...) · line 223

Quoted 10 lines
drivers/gpu/drm/drm_print.c +7 -0
+		first = false;
+	}
+	if (first)
+		drm_printf(p, "(none)");
+}
+EXPORT_SYMBOL(drm_print_bits);
+
 void drm_dev_printk(const struct device *dev, const char *level,
 		    const char *format, ...)
 {
Signature · 14 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)





_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#4 lore raw

Re: [PATCH v3 1/7] drm: add drm_print_bits

In reply to Gerd Hoffmann
Quoted 42 lines · Gerd Hoffmann

New helper to print named bits of some value (think flags fields).

---
 include/drm/drm_print.h     |  3 +++
 drivers/gpu/drm/drm_print.c | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
include/drm/drm_print.h +3 -0
index 112165d3195d..12d4916254b4 100644
@@ -89,6 +89,9 @@ __printf(2, 3)
 void drm_printf(struct drm_printer *p, const char *f, ...);
 void drm_puts(struct drm_printer *p, const char *str);
 void drm_print_regset32(struct drm_printer *p, struct debugfs_regset32 *regset);
+void drm_print_bits(struct drm_printer *p,
+		    unsigned long value, const char *bits[],
+		    unsigned int from, unsigned int to);
 
 __printf(2, 0)
 /**
drivers/gpu/drm/drm_print.c +12 -0
index ad302d71eeee..dfa27367ebb8 100644
@@ -185,6 +185,39 @@ void drm_printf(struct drm_printer *p, const char *f, ...)
 }
 EXPORT_SYMBOL(drm_printf);
 
+/**
+ * drm_print_bits - print bits to a &drm_printer stream
+ *
+ * Print bits (in flag fields for example) in human readable form.
+ * The first name in the @bits array is for the bit indexed by @from.
+ *
+ * @p: the &drm_printer
+ * @value: field value.
+ * @bits: Array with bit names.
+ * @from: start of bit range to print (inclusive).
+ * @to: end of bit range to print (exclusive).
+ */

drivers/gpu/drm/drm_print.c void drm_printf(struct drm_printer *p, const char *f, ...) · line 209

Quoted 10 lines
drivers/gpu/drm/drm_print.c +10 -0
+void drm_print_bits(struct drm_printer *p,
+		    unsigned long value, const char *bits[],
+		    unsigned int from, unsigned int to)
+{
+	bool first = true;
+	unsigned int i;
+
+	for (i = from; i < to; i++) {
+		if (!(value & (1 << i)))
+			continue;

for_each_set_bit from bitops.h?

drivers/gpu/drm/drm_print.c void drm_printf(struct drm_printer *p, const char *f, ...) · line 213

Quoted 4 lines
drivers/gpu/drm/drm_print.c +4 -0
+		if (WARN_ON_ONCE(!bits[i-from]))
+			continue;
+		drm_printf(p, "%s%s", first ? "" : ",",
+			   bits[i-from]);

I wonder about the usefulness of from and to, as well as indexing (i-from) for the strings.

To limit the values to be printed in a more general way than range, you can use:

	drm_print_bits(p, value & GENMASK(h, l), bits);

And obviously to adjust the starting position:

	drm_print_bits(p, value >> l, bits);

Seems like a simple len parameter to indicate the ARRAY_SIZE() of bits would be more straighforward to guard against array overflow.

	drm_print_bits(p, value, bits, ARRAY_SIZE(bits));

BR,
Jani.

Quoted 10 lines
drivers/gpu/drm/drm_print.c +7 -0
+		first = false;
+	}
+	if (first)
+		drm_printf(p, "(none)");
+}
+EXPORT_SYMBOL(drm_print_bits);
+
 void drm_dev_printk(const struct device *dev, const char *level,
 		    const char *format, ...)
 {
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
author maintainer
#5 lore raw

PATCH v3 2/7 drm/ttm: add drm gem ttm helpers, starting with drm_gem_ttm_print_info()

In reply to Gerd Hoffmann

Now with ttm_buffer_object being a subclass of drm_gem_object we can easily lookup ttm_buffer_object for a given drm_gem_object, which in turn allows to create common helper functions.

This patch starts off with a drm_gem_ttm_print_info() helper function which adds some ttm specific lines to the debug output.

---
 include/drm/drm_gem_ttm_helper.h     | 19 ++++++++++
 drivers/gpu/drm/drm_gem_ttm_helper.c | 56 ++++++++++++++++++++++++++++
 Documentation/gpu/drm-mm.rst         | 12 ++++++
 drivers/gpu/drm/Kconfig              |  7 ++++
 drivers/gpu/drm/Makefile             |  3 ++
 5 files changed, 97 insertions(+)
 create mode 100644 include/drm/drm_gem_ttm_helper.h
 create mode 100644 drivers/gpu/drm/drm_gem_ttm_helper.c
include/drm/drm_gem_ttm_helper.h new file +19 -0
new file mode 100644
index 000000000000..6268f89c5a48
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef DRM_GEM_TTM_HELPER_H
+#define DRM_GEM_TTM_HELPER_H
+
+#include <linux/kernel.h>
+
+#include <drm/drm_gem.h>
+#include <drm/drm_device.h>
+#include <drm/ttm/ttm_bo_api.h>
+#include <drm/ttm/ttm_bo_driver.h>
+
+#define drm_gem_ttm_of_gem(gem_obj) \
+	container_of(gem_obj, struct ttm_buffer_object, base)
+
+void drm_gem_ttm_print_info(struct drm_printer *p, unsigned int indent,
+			    const struct drm_gem_object *gem);
+
+#endif
drivers/gpu/drm/drm_gem_ttm_helper.c new file +56 -0

56 lines not on this page · raw message

Documentation/gpu/drm-mm.rst +12 -0
index b664f054c259..a70a1d9f30ec 100644
@@ -412,6 +412,18 @@ VRAM MM Helper Functions Reference
 .. kernel-doc:: drivers/gpu/drm/drm_vram_mm_helper.c
    :export:
 
+GEM TTM Helper Functions Reference
+-----------------------------------
+
+.. kernel-doc:: drivers/gpu/drm/drm_gem_ttm_helper.c
+   :doc: overview
+
+.. kernel-doc:: include/drm/drm_gem_ttm_helper.h
+   :internal:
+
+.. kernel-doc:: drivers/gpu/drm/drm_gem_ttm_helper.c
+   :export:
+
 VMA Offset Manager
 ==================
 
drivers/gpu/drm/Kconfig +7 -0
index e6f40fb54c9a..f7b25519f95c 100644
@@ -172,6 +172,13 @@ config DRM_VRAM_HELPER
 	help
 	  Helpers for VRAM memory management
 
+config DRM_TTM_HELPER
+	tristate
+	depends on DRM
+	select DRM_TTM
+	help
+	  Helpers for ttm-based gem objects
+
 config DRM_GEM_CMA_HELPER
 	bool
 	depends on DRM
drivers/gpu/drm/Makefile +3 -0
index 10f8329a8b71..545c61d6528b 100644
@@ -37,6 +37,9 @@ drm_vram_helper-y := drm_gem_vram_helper.o \
 		     drm_vram_mm_helper.o
 obj-$(CONFIG_DRM_VRAM_HELPER) += drm_vram_helper.o
 
+drm_ttm_helper-y := drm_gem_ttm_helper.o
+obj-$(CONFIG_DRM_TTM_HELPER) += drm_ttm_helper.o
+
 drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_dsc.o drm_probe_helper.o \
 		drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o \
 		drm_kms_helper_common.o drm_dp_dual_mode_helper.o \
Signature · 6 lines
2.18.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#6 lore raw

PATCH v3 3/7 drm/vram: use drm_gem_ttm_print_info

In reply to Gerd Hoffmann
---
 drivers/gpu/drm/drm_gem_vram_helper.c | 4 +++-
 drivers/gpu/drm/Kconfig               | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_gem_vram_helper.c +3 -1
index fd751078bae1..71552f757b4a 100644
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 
+#include <drm/drm_gem_ttm_helper.h>
 #include <drm/drm_gem_vram_helper.h>
 #include <drm/drm_device.h>
 #include <drm/drm_mode.h>
@@ -633,5 +634,6 @@ static const struct drm_gem_object_funcs drm_gem_vram_object_funcs = {
 	.pin	= drm_gem_vram_object_pin,
 	.unpin	= drm_gem_vram_object_unpin,
 	.vmap	= drm_gem_vram_object_vmap,
-	.vunmap	= drm_gem_vram_object_vunmap
+	.vunmap	= drm_gem_vram_object_vunmap,
+	.print_info = drm_gem_ttm_print_info,
 };
drivers/gpu/drm/Kconfig +1 -0
index f7b25519f95c..1be8ad30d8fe 100644
@@ -169,6 +169,7 @@ config DRM_VRAM_HELPER
 	tristate
 	depends on DRM
 	select DRM_TTM
+	select DRM_TTM_HELPER
 	help
 	  Helpers for VRAM memory management
 
Signature · 6 lines
2.18.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#7 lore raw

PATCH v3 4/7 drm/vram: add vram-mm debugfs file

In reply to Gerd Hoffmann

Wire up drm_mm_print() for vram helpers, using a new debugfs file, so one can see how vram is used:

   # cat /sys/kernel/debug/dri/0/vram-mm
   0x0000000000000000-0x0000000000000300: 768: used
   0x0000000000000300-0x0000000000000600: 768: used
   0x0000000000000600-0x0000000000000900: 768: used
   0x0000000000000900-0x0000000000000c00: 768: used
   0x0000000000000c00-0x0000000000004000: 13312: free
   total: 16384, used 3072 free 13312
---
 include/drm/drm_gem_vram_helper.h    |  1 +
 include/drm/drm_vram_mm_helper.h     |  1 +
 drivers/gpu/drm/drm_vram_mm_helper.c | 44 ++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+)
include/drm/drm_gem_vram_helper.h +1 -0
index ac217d768456..91c6934138f2 100644
@@ -122,6 +122,7 @@ int drm_gem_vram_driver_dumb_mmap_offset(struct drm_file *file,
  * &struct drm_driver with default functions.
  */
 #define DRM_GEM_VRAM_DRIVER \
+	.debugfs_init             = drm_vram_mm_debugfs_init, \
 	.dumb_create		  = drm_gem_vram_driver_dumb_create, \
 	.dumb_map_offset	  = drm_gem_vram_driver_dumb_mmap_offset, \
 	.gem_prime_mmap		  = drm_gem_prime_mmap
include/drm/drm_vram_mm_helper.h +1 -0
index 2aacfb1ccfae..9e0ac9aaac7d 100644
@@ -60,6 +60,7 @@ static inline struct drm_vram_mm *drm_vram_mm_of_bdev(
 	return container_of(bdev, struct drm_vram_mm, bdev);
 }
 
+int drm_vram_mm_debugfs_init(struct drm_minor *minor);
 int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
 		     uint64_t vram_base, size_t vram_size,
 		     const struct drm_vram_mm_funcs *funcs);
drivers/gpu/drm/drm_vram_mm_helper.c +44 -0

57 lines not on this page · raw message

Signature · 1 line
2.18.1
author maintainer
#8 lore raw

PATCH v3 5/7 drm/qxl: use drm_gem_object_funcs callbacks

In reply to Gerd Hoffmann

Switch qxl to use drm_gem_object_funcs callbacks
instead of drm_driver callbacks.

---
 drivers/gpu/drm/qxl/qxl_drv.c    |  8 --------
 drivers/gpu/drm/qxl/qxl_object.c | 12 ++++++++++++
 2 files changed, 12 insertions(+), 8 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.c +0 -8
index 2b726a51a302..996d428fa7e6 100644
@@ -258,16 +258,8 @@ static struct drm_driver qxl_driver = {
 #endif
 	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
 	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
-	.gem_prime_pin = qxl_gem_prime_pin,
-	.gem_prime_unpin = qxl_gem_prime_unpin,
-	.gem_prime_get_sg_table = qxl_gem_prime_get_sg_table,
 	.gem_prime_import_sg_table = qxl_gem_prime_import_sg_table,
-	.gem_prime_vmap = qxl_gem_prime_vmap,
-	.gem_prime_vunmap = qxl_gem_prime_vunmap,
 	.gem_prime_mmap = qxl_gem_prime_mmap,
-	.gem_free_object_unlocked = qxl_gem_object_free,
-	.gem_open_object = qxl_gem_object_open,
-	.gem_close_object = qxl_gem_object_close,
 	.fops = &qxl_fops,
 	.ioctls = qxl_ioctls,
 	.irq_handler = qxl_irq_handler,
drivers/gpu/drm/qxl/qxl_object.c +12 -0
index 548dfe6f3b26..29aab7b14513 100644
@@ -77,6 +77,17 @@ void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain, bool pinned)
 	}
 }
 
+static const struct drm_gem_object_funcs qxl_object_funcs = {
+	.free = qxl_gem_object_free,
+	.open = qxl_gem_object_open,
+	.close = qxl_gem_object_close,
+	.pin = qxl_gem_prime_pin,
+	.unpin = qxl_gem_prime_unpin,
+	.get_sg_table = qxl_gem_prime_get_sg_table,
+	.vmap = qxl_gem_prime_vmap,
+	.vunmap = qxl_gem_prime_vunmap,
+};
+
 int qxl_bo_create(struct qxl_device *qdev,
 		  unsigned long size, bool kernel, bool pinned, u32 domain,
 		  struct qxl_surface *surf,
@@ -100,6 +111,7 @@ int qxl_bo_create(struct qxl_device *qdev,
 		kfree(bo);
 		return r;
 	}
+	bo->tbo.base.funcs = &qxl_object_funcs;
 	bo->type = domain;
 	bo->pin_count = pinned ? 1 : 0;
 	bo->surface_id = 0;
Signature · 1 line
2.18.1
author maintainer
#9 lore raw

PATCH v3 5/7 drm/qxl: use drm_gem_object_funcs callbacks

In reply to Gerd Hoffmann

Switch qxl to use drm_gem_object_funcs callbacks
instead of drm_driver callbacks.

---
 drivers/gpu/drm/qxl/qxl_drv.c    |  8 --------
 drivers/gpu/drm/qxl/qxl_object.c | 12 ++++++++++++
 2 files changed, 12 insertions(+), 8 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.c +0 -8
index 2b726a51a302..996d428fa7e6 100644
@@ -258,16 +258,8 @@ static struct drm_driver qxl_driver = {
 #endif
 	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
 	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
-	.gem_prime_pin = qxl_gem_prime_pin,
-	.gem_prime_unpin = qxl_gem_prime_unpin,
-	.gem_prime_get_sg_table = qxl_gem_prime_get_sg_table,
 	.gem_prime_import_sg_table = qxl_gem_prime_import_sg_table,
-	.gem_prime_vmap = qxl_gem_prime_vmap,
-	.gem_prime_vunmap = qxl_gem_prime_vunmap,
 	.gem_prime_mmap = qxl_gem_prime_mmap,
-	.gem_free_object_unlocked = qxl_gem_object_free,
-	.gem_open_object = qxl_gem_object_open,
-	.gem_close_object = qxl_gem_object_close,
 	.fops = &qxl_fops,
 	.ioctls = qxl_ioctls,
 	.irq_handler = qxl_irq_handler,
drivers/gpu/drm/qxl/qxl_object.c +12 -0
index 548dfe6f3b26..29aab7b14513 100644
@@ -77,6 +77,17 @@ void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain, bool pinned)
 	}
 }
 
+static const struct drm_gem_object_funcs qxl_object_funcs = {
+	.free = qxl_gem_object_free,
+	.open = qxl_gem_object_open,
+	.close = qxl_gem_object_close,
+	.pin = qxl_gem_prime_pin,
+	.unpin = qxl_gem_prime_unpin,
+	.get_sg_table = qxl_gem_prime_get_sg_table,
+	.vmap = qxl_gem_prime_vmap,
+	.vunmap = qxl_gem_prime_vunmap,
+};
+
 int qxl_bo_create(struct qxl_device *qdev,
 		  unsigned long size, bool kernel, bool pinned, u32 domain,
 		  struct qxl_surface *surf,
@@ -100,6 +111,7 @@ int qxl_bo_create(struct qxl_device *qdev,
 		kfree(bo);
 		return r;
 	}
+	bo->tbo.base.funcs = &qxl_object_funcs;
 	bo->type = domain;
 	bo->pin_count = pinned ? 1 : 0;
 	bo->surface_id = 0;
Signature · 1 line
2.18.1
author maintainer
#10 lore raw

PATCH v3 6/7 drm/qxl: use drm_gem_ttm_print_info

In reply to Gerd Hoffmann
---
 drivers/gpu/drm/qxl/qxl_drv.h    | 1 +
 drivers/gpu/drm/qxl/qxl_object.c | 1 +
 2 files changed, 2 insertions(+)
drivers/gpu/drm/qxl/qxl_drv.h +1 -0
index 9e034c5fa87d..d4051409ce64 100644
@@ -38,6 +38,7 @@
 #include <drm/drm_crtc.h>
 #include <drm/drm_encoder.h>
 #include <drm/drm_fb_helper.h>
+#include <drm/drm_gem_ttm_helper.h>
 #include <drm/drm_ioctl.h>
 #include <drm/drm_gem.h>
 #include <drm/qxl_drm.h>
drivers/gpu/drm/qxl/qxl_object.c +1 -0
index 29aab7b14513..c013c516f561 100644
@@ -86,6 +86,7 @@ static const struct drm_gem_object_funcs qxl_object_funcs = {
 	.get_sg_table = qxl_gem_prime_get_sg_table,
 	.vmap = qxl_gem_prime_vmap,
 	.vunmap = qxl_gem_prime_vunmap,
+	.print_info = drm_gem_ttm_print_info,
 };
 
 int qxl_bo_create(struct qxl_device *qdev,
Signature · 1 line
2.18.1
author maintainer
#11 lore raw

PATCH v3 6/7 drm/qxl: use drm_gem_ttm_print_info

In reply to Gerd Hoffmann
---
 drivers/gpu/drm/qxl/qxl_drv.h    | 1 +
 drivers/gpu/drm/qxl/qxl_object.c | 1 +
 2 files changed, 2 insertions(+)
drivers/gpu/drm/qxl/qxl_drv.h +1 -0
index 9e034c5fa87d..d4051409ce64 100644
@@ -38,6 +38,7 @@
 #include <drm/drm_crtc.h>
 #include <drm/drm_encoder.h>
 #include <drm/drm_fb_helper.h>
+#include <drm/drm_gem_ttm_helper.h>
 #include <drm/drm_ioctl.h>
 #include <drm/drm_gem.h>
 #include <drm/qxl_drm.h>
drivers/gpu/drm/qxl/qxl_object.c +1 -0
index 29aab7b14513..c013c516f561 100644
@@ -86,6 +86,7 @@ static const struct drm_gem_object_funcs qxl_object_funcs = {
 	.get_sg_table = qxl_gem_prime_get_sg_table,
 	.vmap = qxl_gem_prime_vmap,
 	.vunmap = qxl_gem_prime_vunmap,
+	.print_info = drm_gem_ttm_print_info,
 };
 
 int qxl_bo_create(struct qxl_device *qdev,
Signature · 1 line
2.18.1
author maintainer
#12 lore raw

PATCH v3 7/7 drm/vram: fix Kconfig

In reply to Gerd Hoffmann

select isn't recursive, so we can't turn on DRM_TTM + DRM_TTM_HELPER in config DRM_VRAM_HELPER, we have to select them on the vram users instead.

---
 drivers/gpu/drm/Kconfig                 | 2 --
 drivers/gpu/drm/ast/Kconfig             | 2 ++
 drivers/gpu/drm/bochs/Kconfig           | 2 ++
 drivers/gpu/drm/hisilicon/hibmc/Kconfig | 3 ++-
 drivers/gpu/drm/mgag200/Kconfig         | 2 ++
 drivers/gpu/drm/vboxvideo/Kconfig       | 2 ++
 6 files changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/Kconfig +0 -2
index 1be8ad30d8fe..cd11a3bde19c 100644
@@ -168,8 +168,6 @@ config DRM_TTM
 config DRM_VRAM_HELPER
 	tristate
 	depends on DRM
-	select DRM_TTM
-	select DRM_TTM_HELPER
 	help
 	  Helpers for VRAM memory management
 
drivers/gpu/drm/ast/Kconfig +2 -0
index 829620d5326c..fbcf2f45cef5 100644
@@ -4,6 +4,8 @@ config DRM_AST
 	depends on DRM && PCI && MMU
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	help
 	 Say yes for experimental AST GPU driver. Do not enable
 	 this driver without having a working -modesetting,
drivers/gpu/drm/bochs/Kconfig +2 -0
index 32b043abb668..7bcdf294fed8 100644
@@ -4,6 +4,8 @@ config DRM_BOCHS
 	depends on DRM && PCI && MMU
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	help
 	  Choose this option for qemu.
 	  If M is selected the module will be called bochs-drm.
drivers/gpu/drm/hisilicon/hibmc/Kconfig +2 -1
index f20eedf0073a..8ad9a5b12e40 100644
@@ -4,7 +4,8 @@ config DRM_HISI_HIBMC
 	depends on DRM && PCI && MMU
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
-
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	help
 	  Choose this option if you have a Hisilicon Hibmc soc chipset.
 	  If M is selected the module will be called hibmc-drm.
drivers/gpu/drm/mgag200/Kconfig +2 -0
index 76fee0fbdcae..aed11f4f4c55 100644
@@ -4,6 +4,8 @@ config DRM_MGAG200
 	depends on DRM && PCI && MMU
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	help
 	 This is a KMS driver for the MGA G200 server chips, it
          does not support the original MGA G200 or any of the desktop
drivers/gpu/drm/vboxvideo/Kconfig +2 -0
index 56ba510f21a2..45fe135d6e43 100644
@@ -4,6 +4,8 @@ config DRM_VBOXVIDEO
 	depends on DRM && X86 && PCI
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	select GENERIC_ALLOCATOR
 	help
 	  This is a KMS driver for the virtual Graphics Card used in
Signature · 1 line
2.18.1
maintainer Acked-by on v3 7/7
#13 lore raw

Re: [PATCH v3 7/7] drm/vram: fix Kconfig

Am 04.09.19 um 07:47 schrieb Gerd Hoffmann:

Quoted 86 lines

select isn't recursive, so we can't turn on DRM_TTM + DRM_TTM_HELPER in config DRM_VRAM_HELPER, we have to select them on the vram users instead.

---
 drivers/gpu/drm/Kconfig                 | 2 --
 drivers/gpu/drm/ast/Kconfig             | 2 ++
 drivers/gpu/drm/bochs/Kconfig           | 2 ++
 drivers/gpu/drm/hisilicon/hibmc/Kconfig | 3 ++-
 drivers/gpu/drm/mgag200/Kconfig         | 2 ++
 drivers/gpu/drm/vboxvideo/Kconfig       | 2 ++
 6 files changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/Kconfig +0 -2
index 1be8ad30d8fe..cd11a3bde19c 100644
@@ -168,8 +168,6 @@ config DRM_TTM
 config DRM_VRAM_HELPER
 	tristate
 	depends on DRM
-	select DRM_TTM
-	select DRM_TTM_HELPER
 	help
 	  Helpers for VRAM memory management
 
drivers/gpu/drm/ast/Kconfig +2 -0
index 829620d5326c..fbcf2f45cef5 100644
@@ -4,6 +4,8 @@ config DRM_AST
 	depends on DRM && PCI && MMU
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	help
 	 Say yes for experimental AST GPU driver. Do not enable
 	 this driver without having a working -modesetting,
drivers/gpu/drm/bochs/Kconfig +2 -0
index 32b043abb668..7bcdf294fed8 100644
@@ -4,6 +4,8 @@ config DRM_BOCHS
 	depends on DRM && PCI && MMU
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	help
 	  Choose this option for qemu.
 	  If M is selected the module will be called bochs-drm.
drivers/gpu/drm/hisilicon/hibmc/Kconfig +2 -1
index f20eedf0073a..8ad9a5b12e40 100644
@@ -4,7 +4,8 @@ config DRM_HISI_HIBMC
 	depends on DRM && PCI && MMU
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
-
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	help
 	  Choose this option if you have a Hisilicon Hibmc soc chipset.
 	  If M is selected the module will be called hibmc-drm.
drivers/gpu/drm/mgag200/Kconfig +2 -0
index 76fee0fbdcae..aed11f4f4c55 100644
@@ -4,6 +4,8 @@ config DRM_MGAG200
 	depends on DRM && PCI && MMU
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	help
 	 This is a KMS driver for the MGA G200 server chips, it
          does not support the original MGA G200 or any of the desktop
drivers/gpu/drm/vboxvideo/Kconfig +0 -0
index 56ba510f21a2..45fe135d6e43 100644

drivers/gpu/drm/vboxvideo/Kconfig config DRM_VBOXVIDEO · line 11

Quoted 8 lines
drivers/gpu/drm/vboxvideo/Kconfig +2 -0
@@ -4,6 +4,8 @@ config DRM_VBOXVIDEO
 	depends on DRM && X86 && PCI
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	select GENERIC_ALLOCATOR
 	help
 	  This is a KMS driver for the virtual Graphics Card used in

Thanks for fixing the Kconfigs for VRAM helpers.

Signature · 5 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)
maintainer Acked-by on v3 7/7
#14 lore raw

Re: [PATCH v3 7/7] drm/vram: fix Kconfig

In reply to Gerd Hoffmann

Am 04.09.19 um 07:47 schrieb Gerd Hoffmann:

Quoted 86 lines

select isn't recursive, so we can't turn on DRM_TTM + DRM_TTM_HELPER in config DRM_VRAM_HELPER, we have to select them on the vram users instead.

---
 drivers/gpu/drm/Kconfig                 | 2 --
 drivers/gpu/drm/ast/Kconfig             | 2 ++
 drivers/gpu/drm/bochs/Kconfig           | 2 ++
 drivers/gpu/drm/hisilicon/hibmc/Kconfig | 3 ++-
 drivers/gpu/drm/mgag200/Kconfig         | 2 ++
 drivers/gpu/drm/vboxvideo/Kconfig       | 2 ++
 6 files changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/Kconfig +0 -2
index 1be8ad30d8fe..cd11a3bde19c 100644
@@ -168,8 +168,6 @@ config DRM_TTM
 config DRM_VRAM_HELPER
 	tristate
 	depends on DRM
-	select DRM_TTM
-	select DRM_TTM_HELPER
 	help
 	  Helpers for VRAM memory management
 
drivers/gpu/drm/ast/Kconfig +2 -0
index 829620d5326c..fbcf2f45cef5 100644
@@ -4,6 +4,8 @@ config DRM_AST
 	depends on DRM && PCI && MMU
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	help
 	 Say yes for experimental AST GPU driver. Do not enable
 	 this driver without having a working -modesetting,
drivers/gpu/drm/bochs/Kconfig +2 -0
index 32b043abb668..7bcdf294fed8 100644
@@ -4,6 +4,8 @@ config DRM_BOCHS
 	depends on DRM && PCI && MMU
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	help
 	  Choose this option for qemu.
 	  If M is selected the module will be called bochs-drm.
drivers/gpu/drm/hisilicon/hibmc/Kconfig +2 -1
index f20eedf0073a..8ad9a5b12e40 100644
@@ -4,7 +4,8 @@ config DRM_HISI_HIBMC
 	depends on DRM && PCI && MMU
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
-
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	help
 	  Choose this option if you have a Hisilicon Hibmc soc chipset.
 	  If M is selected the module will be called hibmc-drm.
drivers/gpu/drm/mgag200/Kconfig +2 -0
index 76fee0fbdcae..aed11f4f4c55 100644
@@ -4,6 +4,8 @@ config DRM_MGAG200
 	depends on DRM && PCI && MMU
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	help
 	 This is a KMS driver for the MGA G200 server chips, it
          does not support the original MGA G200 or any of the desktop
drivers/gpu/drm/vboxvideo/Kconfig +0 -0
index 56ba510f21a2..45fe135d6e43 100644

drivers/gpu/drm/vboxvideo/Kconfig config DRM_VBOXVIDEO · line 11

Quoted 8 lines
drivers/gpu/drm/vboxvideo/Kconfig +2 -0
@@ -4,6 +4,8 @@ config DRM_VBOXVIDEO
 	depends on DRM && X86 && PCI
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	select GENERIC_ALLOCATOR
 	help
 	  This is a KMS driver for the virtual Graphics Card used in

Thanks for fixing the Kconfigs for VRAM helpers.

Signature · 5 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

author maintainer
#15 lore raw

PATCH v3 7/7 drm/vram: fix Kconfig

In reply to Gerd Hoffmann

select isn't recursive, so we can't turn on DRM_TTM + DRM_TTM_HELPER in config DRM_VRAM_HELPER, we have to select them on the vram users instead.

---
 drivers/gpu/drm/Kconfig                 | 2 --
 drivers/gpu/drm/ast/Kconfig             | 2 ++
 drivers/gpu/drm/bochs/Kconfig           | 2 ++
 drivers/gpu/drm/hisilicon/hibmc/Kconfig | 3 ++-
 drivers/gpu/drm/mgag200/Kconfig         | 2 ++
 drivers/gpu/drm/vboxvideo/Kconfig       | 2 ++
 6 files changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/Kconfig +0 -2
index 1be8ad30d8fe..cd11a3bde19c 100644
@@ -168,8 +168,6 @@ config DRM_TTM
 config DRM_VRAM_HELPER
 	tristate
 	depends on DRM
-	select DRM_TTM
-	select DRM_TTM_HELPER
 	help
 	  Helpers for VRAM memory management
 
drivers/gpu/drm/ast/Kconfig +2 -0
index 829620d5326c..fbcf2f45cef5 100644
@@ -4,6 +4,8 @@ config DRM_AST
 	depends on DRM && PCI && MMU
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	help
 	 Say yes for experimental AST GPU driver. Do not enable
 	 this driver without having a working -modesetting,
drivers/gpu/drm/bochs/Kconfig +2 -0
index 32b043abb668..7bcdf294fed8 100644
@@ -4,6 +4,8 @@ config DRM_BOCHS
 	depends on DRM && PCI && MMU
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	help
 	  Choose this option for qemu.
 	  If M is selected the module will be called bochs-drm.
drivers/gpu/drm/hisilicon/hibmc/Kconfig +2 -1
index f20eedf0073a..8ad9a5b12e40 100644
@@ -4,7 +4,8 @@ config DRM_HISI_HIBMC
 	depends on DRM && PCI && MMU
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
-
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	help
 	  Choose this option if you have a Hisilicon Hibmc soc chipset.
 	  If M is selected the module will be called hibmc-drm.
drivers/gpu/drm/mgag200/Kconfig +2 -0
index 76fee0fbdcae..aed11f4f4c55 100644
@@ -4,6 +4,8 @@ config DRM_MGAG200
 	depends on DRM && PCI && MMU
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	help
 	 This is a KMS driver for the MGA G200 server chips, it
          does not support the original MGA G200 or any of the desktop
drivers/gpu/drm/vboxvideo/Kconfig +2 -0
index 56ba510f21a2..45fe135d6e43 100644
@@ -4,6 +4,8 @@ config DRM_VBOXVIDEO
 	depends on DRM && X86 && PCI
 	select DRM_KMS_HELPER
 	select DRM_VRAM_HELPER
+	select DRM_TTM
+	select DRM_TTM_HELPER
 	select GENERIC_ALLOCATOR
 	help
 	  This is a KMS driver for the virtual Graphics Card used in
Signature · 1 line
2.18.1