Skip to contentSkip to conversation

more drmP.h cleanup

PATCH In review Daniel Vetter 11 participants 57 messages Mar 22, 2017 – Apr 4, 2017 8 messages not in the archive

Subsystems (9)
lore
Share & tools
lore
#0 lore raw

cover more drmP.h cleanup

Hi all,

So yeah this takes a bit longer than I hoped, but here's a few more things split out from drmP.h and properly documented. The vblank stuff took a bit a detour, since I opted to refactor stuff away instead of documenting it.

What's now left in drmP.h is struct drm_device and all the various debug printing stuff.

Cheers, Daniel

Daniel Vetter (16):
drm: drop extern from function decls
drm: Extract drm_debugfs.h
drm: document driver interface for CRC capturing drm/debugfs: Add kerneldoc
drm: update todo.rst
drm: Consolidate and document sysfs support
drm: Extract drm_ioctl.h
drm: document drm_ioctl.[hc]
drm/todo: Add tinydrm refactoring ideas
drm/vblank: Remove DRM_VBLANKTIME_IN_VBLANK
drm/vblank: Switch drm_driver->get_vblank_timestamp to return a bool drm/vblank: Switch to bool in_vblank_irq in get_vblank_timestamp drm/vblank: Add FIXME comments about moving the vblank ts hooks drm/vblank: drop the mode argument from
drm_calc_vbltimestamp_from_scanoutpos
drm/vblank: Simplify the get_scanout_position helper hook drm/doc: Small markup fixup

 Documentation/gpu/drm-internals.rst       |  50 --------
 Documentation/gpu/drm-uapi.rst            |  36 ++++++
 Documentation/gpu/todo.rst                | 139 +++++++++++++++-------
 drivers/gpu/drm/amd/amdgpu/amdgpu.h       |   4 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   |  14 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   |  41 -------
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h  |   3 +
 drivers/gpu/drm/drm_debugfs.c             |  56 ++-------
 drivers/gpu/drm/drm_debugfs_crc.c         |  17 +--
 drivers/gpu/drm/drm_internal.h            |   2 +-
 drivers/gpu/drm/drm_ioc32.c               |   1 -
 drivers/gpu/drm/drm_ioctl.c               |  46 ++++++++
 drivers/gpu/drm/drm_irq.c                 | 121 ++++++++++---------
 drivers/gpu/drm/drm_probe_helper.c        |   2 +-
 drivers/gpu/drm/drm_sysfs.c               |  70 +++++------
 drivers/gpu/drm/i915/i915_irq.c           |  52 ++-------
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c   |  45 ++-----
 drivers/gpu/drm/nouveau/nouveau_display.c |  37 ++----
 drivers/gpu/drm/nouveau/nouveau_display.h |   8 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c     |   2 +-
 drivers/gpu/drm/radeon/radeon_drv.c       |  18 ++-
 drivers/gpu/drm/radeon/radeon_kms.c       |  37 ------
 drivers/gpu/drm/radeon/radeon_mode.h      |   3 +
 drivers/gpu/drm/vc4/vc4_crtc.c            |  34 ++----
 drivers/gpu/drm/vc4/vc4_drv.c             |   2 +-
 drivers/gpu/drm/vc4/vc4_drv.h             |  11 +-
 include/drm/drmP.h                        | 120 +------------------
 include/drm/drm_crtc.h                    |   5 +-
 include/drm/drm_crtc_helper.h             |  38 +++---
 include/drm/drm_debugfs.h                 | 100 ++++++++++++++++
 include/drm/drm_drv.h                     |  56 ++++-----
 include/drm/drm_global.h                  |   8 +-
 include/drm/drm_hashtab.h                 |  20 ++--
 include/drm/drm_ioctl.h                   | 188 ++++++++++++++++++++++++++++++
 include/drm/drm_irq.h                     |  21 +++-
 include/drm/drm_of.h                      |  24 ++--
 include/drm/drm_pci.h                     |  22 ++--
 include/drm/drm_plane.h                   |  20 ++--
 include/drm/drm_prime.h                   |  30 ++---
 include/drm/drm_sysfs.h                   |  12 +-
 40 files changed, 785 insertions(+), 730 deletions(-)
 create mode 100644 include/drm/drm_debugfs.h
 create mode 100644 include/drm/drm_ioctl.h
Signature · 6 lines
2.11.0

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

PATCH 1/16 drm: drop extern from function decls

It's the default storage class for functions, entirely redundant. And a lot of these headers are a bit inconsistent due to organically grown.

---
 include/drm/drm_crtc_helper.h | 38 +++++++++++++++++++-------------------
 include/drm/drm_drv.h         |  4 ++--
 include/drm/drm_global.h      |  8 ++++----
 include/drm/drm_hashtab.h     | 20 ++++++++++----------
 include/drm/drm_of.h          | 24 ++++++++++++------------
 include/drm/drm_pci.h         | 22 +++++++++++-----------
 include/drm/drm_plane.h       | 20 ++++++++++----------
 include/drm/drm_prime.h       | 30 +++++++++++++++---------------
 include/drm/drm_sysfs.h       |  4 ++--
 9 files changed, 85 insertions(+), 85 deletions(-)
include/drm/drm_crtc_helper.h +19 -19
index d026f5017c33..7506a60df8b1 100644
@@ -43,18 +43,18 @@
 #include <drm/drm_modeset_helper_vtables.h>
 #include <drm/drm_modeset_helper.h>
 
-extern void drm_helper_disable_unused_functions(struct drm_device *dev);
-extern int drm_crtc_helper_set_config(struct drm_mode_set *set);
-extern bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
-				     struct drm_display_mode *mode,
-				     int x, int y,
-				     struct drm_framebuffer *old_fb);
-extern bool drm_helper_crtc_in_use(struct drm_crtc *crtc);
-extern bool drm_helper_encoder_in_use(struct drm_encoder *encoder);
+void drm_helper_disable_unused_functions(struct drm_device *dev);
+int drm_crtc_helper_set_config(struct drm_mode_set *set);
+bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
+			      struct drm_display_mode *mode,
+			      int x, int y,
+			      struct drm_framebuffer *old_fb);
+bool drm_helper_crtc_in_use(struct drm_crtc *crtc);
+bool drm_helper_encoder_in_use(struct drm_encoder *encoder);
 
-extern int drm_helper_connector_dpms(struct drm_connector *connector, int mode);
+int drm_helper_connector_dpms(struct drm_connector *connector, int mode);
 
-extern void drm_helper_resume_force_mode(struct drm_device *dev);
+void drm_helper_resume_force_mode(struct drm_device *dev);
 
 int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
 			     struct drm_display_mode *adjusted_mode, int x, int y,
@@ -63,15 +63,15 @@ int drm_helper_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
 				  struct drm_framebuffer *old_fb);
 
 /* drm_probe_helper.c */
-extern int drm_helper_probe_single_connector_modes(struct drm_connector
-						   *connector, uint32_t maxX,
-						   uint32_t maxY);
-extern void drm_kms_helper_poll_init(struct drm_device *dev);
-extern void drm_kms_helper_poll_fini(struct drm_device *dev);
-extern bool drm_helper_hpd_irq_event(struct drm_device *dev);
-extern void drm_kms_helper_hotplug_event(struct drm_device *dev);
+int drm_helper_probe_single_connector_modes(struct drm_connector
+					    *connector, uint32_t maxX,
+					    uint32_t maxY);
+void drm_kms_helper_poll_init(struct drm_device *dev);
+void drm_kms_helper_poll_fini(struct drm_device *dev);
+bool drm_helper_hpd_irq_event(struct drm_device *dev);
+void drm_kms_helper_hotplug_event(struct drm_device *dev);
 
-extern void drm_kms_helper_poll_disable(struct drm_device *dev);
-extern void drm_kms_helper_poll_enable(struct drm_device *dev);
+void drm_kms_helper_poll_disable(struct drm_device *dev);
+void drm_kms_helper_poll_enable(struct drm_device *dev);
 
 #endif
include/drm/drm_drv.h +2 -2
index fde343e0d581..d0b5f363bfa1 100644
@@ -503,11 +503,11 @@ struct drm_driver {
 	int dev_priv_size;
 };
 
-extern __printf(6, 7)
+__printf(6, 7)
 void drm_dev_printk(const struct device *dev, const char *level,
 		    unsigned int category, const char *function_name,
 		    const char *prefix, const char *format, ...);
-extern __printf(3, 4)
+__printf(3, 4)
 void drm_printk(const char *level, unsigned int category,
 		const char *format, ...);
 extern unsigned int drm_debug;
include/drm/drm_global.h +4 -4
index a06805eaf649..3a830602a2e4 100644
@@ -45,9 +45,9 @@ struct drm_global_reference {
 	void (*release) (struct drm_global_reference *);
 };
 
-extern void drm_global_init(void);
-extern void drm_global_release(void);
-extern int drm_global_item_ref(struct drm_global_reference *ref);
-extern void drm_global_item_unref(struct drm_global_reference *ref);
+void drm_global_init(void);
+void drm_global_release(void);
+int drm_global_item_ref(struct drm_global_reference *ref);
+void drm_global_item_unref(struct drm_global_reference *ref);
 
 #endif
include/drm/drm_hashtab.h +10 -10
index fce2ef3fdfff..bb95ff011baf 100644
@@ -49,17 +49,17 @@ struct drm_open_hash {
 	u8 order;
 };
 
-extern int drm_ht_create(struct drm_open_hash *ht, unsigned int order);
-extern int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item);
-extern int drm_ht_just_insert_please(struct drm_open_hash *ht, struct drm_hash_item *item,
-				     unsigned long seed, int bits, int shift,
-				     unsigned long add);
-extern int drm_ht_find_item(struct drm_open_hash *ht, unsigned long key, struct drm_hash_item **item);
+int drm_ht_create(struct drm_open_hash *ht, unsigned int order);
+int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item);
+int drm_ht_just_insert_please(struct drm_open_hash *ht, struct drm_hash_item *item,
+			      unsigned long seed, int bits, int shift,
+			      unsigned long add);
+int drm_ht_find_item(struct drm_open_hash *ht, unsigned long key, struct drm_hash_item **item);
 
-extern void drm_ht_verbose_list(struct drm_open_hash *ht, unsigned long key);
-extern int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key);
-extern int drm_ht_remove_item(struct drm_open_hash *ht, struct drm_hash_item *item);
-extern void drm_ht_remove(struct drm_open_hash *ht);
+void drm_ht_verbose_list(struct drm_open_hash *ht, unsigned long key);
+int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key);
+int drm_ht_remove_item(struct drm_open_hash *ht, struct drm_hash_item *item);
+void drm_ht_remove(struct drm_open_hash *ht);
 
 /*
  * RCU-safe interface
include/drm/drm_of.h +12 -12
index 26a64805cc15..d1fc563f068a 100644
@@ -11,18 +11,18 @@ struct drm_encoder;
 struct device_node;
 
 #ifdef CONFIG_OF
-extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
-					   struct device_node *port);
-extern void drm_of_component_match_add(struct device *master,
-				       struct component_match **matchptr,
-				       int (*compare)(struct device *, void *),
-				       struct device_node *node);
-extern int drm_of_component_probe(struct device *dev,
-				  int (*compare_of)(struct device *, void *),
-				  const struct component_master_ops *m_ops);
-extern int drm_of_encoder_active_endpoint(struct device_node *node,
-					  struct drm_encoder *encoder,
-					  struct of_endpoint *endpoint);
+uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
+				    struct device_node *port);
+void drm_of_component_match_add(struct device *master,
+				struct component_match **matchptr,
+				int (*compare)(struct device *, void *),
+				struct device_node *node);
+int drm_of_component_probe(struct device *dev,
+			   int (*compare_of)(struct device *, void *),
+			   const struct component_master_ops *m_ops);
+int drm_of_encoder_active_endpoint(struct device_node *node,
+				   struct drm_encoder *encoder,
+				   struct of_endpoint *endpoint);
 #else
 static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
 						  struct device_node *port)
include/drm/drm_pci.h +11 -11
index f5ebfcaf69e0..4579fac1080c 100644
@@ -39,17 +39,17 @@ struct drm_device;
 struct drm_driver;
 struct drm_master;
 
-extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size,
-					    size_t align);
-extern void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah);
+struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size,
+				     size_t align);
+void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah);
 
-extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver);
-extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
+int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver);
+void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
 #ifdef CONFIG_PCI
-extern int drm_get_pci_dev(struct pci_dev *pdev,
-			   const struct pci_device_id *ent,
-			   struct drm_driver *driver);
-extern int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master);
+int drm_get_pci_dev(struct pci_dev *pdev,
+		    const struct pci_device_id *ent,
+		    struct drm_driver *driver);
+int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master);
 #else
 static inline int drm_get_pci_dev(struct pci_dev *pdev,
 				  const struct pci_device_id *ent,
@@ -69,7 +69,7 @@ static inline int drm_pci_set_busid(struct drm_device *dev,
 #define DRM_PCIE_SPEED_50 2
 #define DRM_PCIE_SPEED_80 4
 
-extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
-extern int drm_pcie_get_max_link_width(struct drm_device *dev, u32 *mlw);
+int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
+int drm_pcie_get_max_link_width(struct drm_device *dev, u32 *mlw);
 
 #endif /* _DRM_PCI_H_ */
include/drm/drm_plane.h +10 -10
index 20867b4371ab..31da9f0c4ad2 100644
@@ -510,7 +510,7 @@ struct drm_plane {
 
 #define obj_to_plane(x) container_of(x, struct drm_plane, base)
 
-extern __printf(8, 9)
+__printf(8, 9)
 int drm_universal_plane_init(struct drm_device *dev,
 			     struct drm_plane *plane,
 			     uint32_t possible_crtcs,
@@ -519,13 +519,13 @@ int drm_universal_plane_init(struct drm_device *dev,
 			     unsigned int format_count,
 			     enum drm_plane_type type,
 			     const char *name, ...);
-extern int drm_plane_init(struct drm_device *dev,
-			  struct drm_plane *plane,
-			  uint32_t possible_crtcs,
-			  const struct drm_plane_funcs *funcs,
-			  const uint32_t *formats, unsigned int format_count,
-			  bool is_primary);
-extern void drm_plane_cleanup(struct drm_plane *plane);
+int drm_plane_init(struct drm_device *dev,
+		   struct drm_plane *plane,
+		   uint32_t possible_crtcs,
+		   const struct drm_plane_funcs *funcs,
+		   const uint32_t *formats, unsigned int format_count,
+		   bool is_primary);
+void drm_plane_cleanup(struct drm_plane *plane);
 
 /**
  * drm_plane_index - find the index of a registered plane
@@ -538,8 +538,8 @@ static inline unsigned int drm_plane_index(struct drm_plane *plane)
 {
 	return plane->index;
 }
-extern struct drm_plane * drm_plane_from_index(struct drm_device *dev, int idx);
-extern void drm_plane_force_disable(struct drm_plane *plane);
+struct drm_plane * drm_plane_from_index(struct drm_device *dev, int idx);
+void drm_plane_force_disable(struct drm_plane *plane);
 
 int drm_mode_plane_set_obj_prop(struct drm_plane *plane,
 				       struct drm_property *property,
include/drm/drm_prime.h +15 -15
index d09563ecc4b7..0b2a235c4be0 100644
@@ -57,24 +57,24 @@ struct drm_device;
 struct drm_gem_object;
 struct drm_file;
 
-extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
-					    struct drm_gem_object *obj,
-					    int flags);
-extern int drm_gem_prime_handle_to_fd(struct drm_device *dev,
-		struct drm_file *file_priv, uint32_t handle, uint32_t flags,
-		int *prime_fd);
-extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
-		struct dma_buf *dma_buf);
-extern int drm_gem_prime_fd_to_handle(struct drm_device *dev,
-		struct drm_file *file_priv, int prime_fd, uint32_t *handle);
+struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
+				     struct drm_gem_object *obj,
+				     int flags);
+int drm_gem_prime_handle_to_fd(struct drm_device *dev,
+			       struct drm_file *file_priv, uint32_t handle, uint32_t flags,
+			       int *prime_fd);
+struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
+					    struct dma_buf *dma_buf);
+int drm_gem_prime_fd_to_handle(struct drm_device *dev,
+			       struct drm_file *file_priv, int prime_fd, uint32_t *handle);
 struct dma_buf *drm_gem_dmabuf_export(struct drm_device *dev,
 				      struct dma_buf_export_info *exp_info);
-extern void drm_gem_dmabuf_release(struct dma_buf *dma_buf);
+void drm_gem_dmabuf_release(struct dma_buf *dma_buf);
 
-extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages,
-					    dma_addr_t *addrs, int max_pages);
-extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int nr_pages);
-extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg);
+int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages,
+				     dma_addr_t *addrs, int max_pages);
+struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int nr_pages);
+void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg);
 
 
 #endif /* __DRM_PRIME_H__ */
include/drm/drm_sysfs.h +2 -2
index 1d8e033fde67..23418c1f10d1 100644
@@ -6,7 +6,7 @@
  * don't want to include the full drmP.h file.
  */
 
-extern int drm_class_device_register(struct device *dev);
-extern void drm_class_device_unregister(struct device *dev);
+int drm_class_device_register(struct device *dev);
+void drm_class_device_unregister(struct device *dev);
 
 #endif
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/16
#2 lore raw

Re: [PATCH 01/16] drm: drop extern from function decls

Quoted 4 lines · Daniel Vetter

It's the default storage class for functions, entirely redundant. And a lot of these headers are a bit inconsistent due to organically grown.

Signature · 5 lines
Gabriel Krisman Bertazi
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

PATCH 2/16 drm: Extract drm_debugfs.h

In reply to Daniel Vetter

Doc polish will follow in the next patch.

---
 drivers/gpu/drm/drm_debugfs.c |  5 ++-
 include/drm/drmP.h            | 44 +------------------------
 include/drm/drm_debugfs.h     | 76 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 81 insertions(+), 44 deletions(-)
 create mode 100644 include/drm/drm_debugfs.h
drivers/gpu/drm/drm_debugfs.c +4 -1
index 1d2d18d82d2e..4b02f4230562 100644
@@ -34,9 +34,12 @@
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/export.h>
-#include <drm/drmP.h>
+
+#include <drm/drm_debugfs.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_atomic.h>
+#include <drm/drmP.h>
+
 #include "drm_internal.h"
 #include "drm_crtc_internal.h"
 
include/drm/drmP.h +1 -43

62 lines not on this page · raw message

include/drm/drm_debugfs.h new file +76 -0

76 lines not on this page · raw message

Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

Re: [Intel-gfx] [PATCH 02/16] drm: Extract drm_debugfs.h

Quoted 33 lines · Daniel Vetter

Doc polish will follow in the next patch.

---
 drivers/gpu/drm/drm_debugfs.c |  5 ++-
 include/drm/drmP.h            | 44 +------------------------
 include/drm/drm_debugfs.h     | 76 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 81 insertions(+), 44 deletions(-)
 create mode 100644 include/drm/drm_debugfs.h
drivers/gpu/drm/drm_debugfs.c +4 -1
index 1d2d18d82d2e..4b02f4230562 100644
@@ -34,9 +34,12 @@
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/export.h>
-#include <drm/drmP.h>
+
+#include <drm/drm_debugfs.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_atomic.h>
+#include <drm/drmP.h>
+
 #include "drm_internal.h"
 #include "drm_crtc_internal.h"
 
include/drm/drmP.h +0 -0
index 0e383438f793..60f3255c43a8 100644

include/drm/drmP.h line 81

Quoted 4 lines
include/drm/drmP.h +1 -0
@@ -78,6 +78,7 @@
 #include <drm/drm_prime.h>
 #include <drm/drm_pci.h>
 #include <drm/drm_file.h>
+#include <drm/drm_debugfs.h>

Why do we need this?

Quoted 90 lines
include/drm/drmP.h +0 -43
 struct module;
 
@@ -371,27 +372,6 @@ struct drm_ioctl_desc {
 #define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
 
 /**
- * Info file list entry. This structure represents a debugfs or proc file to
- * be created by the drm core
- */
-struct drm_info_list {
-	const char *name; /** file name */
-	int (*show)(struct seq_file*, void*); /** show callback */
-	u32 driver_features; /**< Required driver features for this entry */
-	void *data;
-};
-
-/**
- * debugfs node structure. This structure represents a debugfs file.
- */
-struct drm_info_node {
-	struct list_head list;
-	struct drm_minor *minor;
-	const struct drm_info_list *info_ent;
-	struct dentry *dent;
-};
-
-/**
  * DRM device structure. This structure represent a complete card that
  * may contain multiple heads.
  */
@@ -592,28 +572,6 @@ int drm_invalid_op(struct drm_device *dev, void *data,
  * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
  */
 
-				/* Debugfs support */
-#if defined(CONFIG_DEBUG_FS)
-extern int drm_debugfs_create_files(const struct drm_info_list *files,
-				    int count, struct dentry *root,
-				    struct drm_minor *minor);
-extern int drm_debugfs_remove_files(const struct drm_info_list *files,
-				    int count, struct drm_minor *minor);
-#else
-static inline int drm_debugfs_create_files(const struct drm_info_list *files,
-					   int count, struct dentry *root,
-					   struct drm_minor *minor)
-{
-	return 0;
-}
-
-static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
-					   int count, struct drm_minor *minor)
-{
-	return 0;
-}
-#endif
-
 			       /* sysfs support (drm_sysfs.c) */
 extern void drm_sysfs_hotplug_event(struct drm_device *dev);
 
include/drm/drm_debugfs.h new file +24 -0
new file mode 100644
index 000000000000..17e47c073fa9
@@ -0,0 +1,76 @@
+/*
+ * Internal Header for the Direct Rendering Manager
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * Copyright (c) 2009-2010, Code Aurora Forum.
+ * All rights reserved.
+ *
+ * Author: Rickard E. (Rik) Faith <[email protected]>
+ * Author: Gareth Hughes <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

include/drm/drm_debugfs.h line 34

Quoted 10 lines
include/drm/drm_debugfs.h new file +10 -0
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _DRM_DEBUGFS_H_
+#define _DRM_DEBUGFS_H_
+

Do we want to make headers standalone? If we do then we would need a few includes and forward declarations.

Quoted 12 lines
include/drm/drm_debugfs.h new file +12 -0
+/**
+ * Info file list entry. This structure represents a debugfs or proc file to
+ * be created by the drm core
+ */
+struct drm_info_list {
+	const char *name; /** file name */
+	int (*show)(struct seq_file*, void*); /** show callback */
+	u32 driver_features; /**< Required driver features for this entry */
+	void *data;
+};
+
+/**

include/drm/drm_debugfs.h line 56

Quoted 10 lines
include/drm/drm_debugfs.h new file +10 -0
+ * debugfs node structure. This structure represents a debugfs file.
+ */
+struct drm_info_node {
+	struct list_head list;
+	struct drm_minor *minor;
+	const struct drm_info_list *info_ent;
+	struct dentry *dent;
+};
+
+#endif /* _DRM_DEBUGFS_H_ */

Why is this guy in the middle of the file?

Quoted 27 lines
include/drm/drm_debugfs.h new file +20 -0
+#if defined(CONFIG_DEBUG_FS)
+int drm_debugfs_create_files(const struct drm_info_list *files,
+			     int count, struct dentry *root,
+			     struct drm_minor *minor);
+int drm_debugfs_remove_files(const struct drm_info_list *files,
+			     int count, struct drm_minor *minor);
+#else
+static inline int drm_debugfs_create_files(const struct drm_info_list *files,
+					   int count, struct dentry *root,
+					   struct drm_minor *minor)
+{
+	return 0;
+}
+
+static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
+					   int count, struct drm_minor *minor)
+{
+	return 0;
+}
+#endif
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

Re: [PATCH 02/16] drm: Extract drm_debugfs.h

Quoted 136 lines · Ville Syrjälä
Quoted 33 lines · Daniel Vetter

Doc polish will follow in the next patch.

---
 drivers/gpu/drm/drm_debugfs.c |  5 ++-
 include/drm/drmP.h            | 44 +------------------------
 include/drm/drm_debugfs.h     | 76 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 81 insertions(+), 44 deletions(-)
 create mode 100644 include/drm/drm_debugfs.h
drivers/gpu/drm/drm_debugfs.c +4 -1
index 1d2d18d82d2e..4b02f4230562 100644
@@ -34,9 +34,12 @@
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/export.h>
-#include <drm/drmP.h>
+
+#include <drm/drm_debugfs.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_atomic.h>
+#include <drm/drmP.h>
+
 #include "drm_internal.h"
 #include "drm_crtc_internal.h"
 
include/drm/drmP.h +0 -0
index 0e383438f793..60f3255c43a8 100644

include/drm/drmP.h line 81

Quoted 4 lines
include/drm/drmP.h +1 -0
@@ -78,6 +78,7 @@
 #include <drm/drm_prime.h>
 #include <drm/drm_pci.h>
 #include <drm/drm_file.h>
+#include <drm/drm_debugfs.h>

Why do we need this?

Quoted 95 lines
include/drm/drmP.h +0 -43
 struct module;
 
@@ -371,27 +372,6 @@ struct drm_ioctl_desc {
 #define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
 
 /**
- * Info file list entry. This structure represents a debugfs or proc file to
- * be created by the drm core
- */
-struct drm_info_list {
-	const char *name; /** file name */
-	int (*show)(struct seq_file*, void*); /** show callback */
-	u32 driver_features; /**< Required driver features for this entry */
-	void *data;
-};
-
-/**
- * debugfs node structure. This structure represents a debugfs file.
- */
-struct drm_info_node {
-	struct list_head list;
-	struct drm_minor *minor;
-	const struct drm_info_list *info_ent;
-	struct dentry *dent;
-};
-
-/**
  * DRM device structure. This structure represent a complete card that
  * may contain multiple heads.
  */
@@ -592,28 +572,6 @@ int drm_invalid_op(struct drm_device *dev, void *data,
  * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
  */
 
-				/* Debugfs support */
-#if defined(CONFIG_DEBUG_FS)
-extern int drm_debugfs_create_files(const struct drm_info_list *files,
-				    int count, struct dentry *root,
-				    struct drm_minor *minor);
-extern int drm_debugfs_remove_files(const struct drm_info_list *files,
-				    int count, struct drm_minor *minor);
-#else
-static inline int drm_debugfs_create_files(const struct drm_info_list *files,
-					   int count, struct dentry *root,
-					   struct drm_minor *minor)
-{
-	return 0;
-}
-
-static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
-					   int count, struct drm_minor *minor)
-{
-	return 0;
-}
-#endif
-
 			       /* sysfs support (drm_sysfs.c) */
 extern void drm_sysfs_hotplug_event(struct drm_device *dev);
 
include/drm/drm_debugfs.h new file +29 -0
new file mode 100644
index 000000000000..17e47c073fa9
@@ -0,0 +1,76 @@
+/*
+ * Internal Header for the Direct Rendering Manager
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * Copyright (c) 2009-2010, Code Aurora Forum.
+ * All rights reserved.
+ *
+ * Author: Rickard E. (Rik) Faith <[email protected]>
+ * Author: Gareth Hughes <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
Quoted 8 lines

include/drm/drm_debugfs.h line 34

Quoted 5 lines
include/drm/drm_debugfs.h new file +5 -0
+ */
+
+#ifndef _DRM_DEBUGFS_H_
+#define _DRM_DEBUGFS_H_
+

Do we want to make headers standalone? If we do then we would need a few includes and forward declarations.

Yes, but it's hard to make this work properly in one go. I sometimes try when it's easy, but very often you end up in loops. I think better to first split things, then try to get rid of drmP.h, one .c file at a time.

Quoted 16 lines
Quoted 16 lines
include/drm/drm_debugfs.h new file +16 -0
+/**
+ * Info file list entry. This structure represents a debugfs or proc file to
+ * be created by the drm core
+ */
+struct drm_info_list {
+	const char *name; /** file name */
+	int (*show)(struct seq_file*, void*); /** show callback */
+	u32 driver_features; /**< Required driver features for this entry */
+	void *data;
+};
+
+/**
+ * debugfs node structure. This structure represents a debugfs file.
+ */
+struct drm_info_node {
+	struct list_head list;
Quoted 8 lines

include/drm/drm_debugfs.h line 56

Quoted 6 lines
include/drm/drm_debugfs.h new file +6 -0
+	struct drm_minor *minor;
+	const struct drm_info_list *info_ent;
+	struct dentry *dent;
+};
+
+#endif /* _DRM_DEBUGFS_H_ */

Why is this guy in the middle of the file?

Oops, misplaced, will fix up and resend.
-Daniel

Quoted 35 lines
Quoted 27 lines
include/drm/drm_debugfs.h new file +20 -0
+#if defined(CONFIG_DEBUG_FS)
+int drm_debugfs_create_files(const struct drm_info_list *files,
+			     int count, struct dentry *root,
+			     struct drm_minor *minor);
+int drm_debugfs_remove_files(const struct drm_info_list *files,
+			     int count, struct drm_minor *minor);
+#else
+static inline int drm_debugfs_create_files(const struct drm_info_list *files,
+					   int count, struct dentry *root,
+					   struct drm_minor *minor)
+{
+	return 0;
+}
+
+static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
+					   int count, struct drm_minor *minor)
+{
+	return 0;
+}
+#endif
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

PATCH 1/1 drm: Extract drm_debugfs.h

In reply to Daniel Vetter

Doc polish will follow in the next patch.

v2: Put the include guard #endif at the end (Ville).

Cc Ville Syrjälä <[email protected]>
---
 drivers/gpu/drm/drm_debugfs.c |  5 ++-
 include/drm/drmP.h            | 44 +------------------------
 include/drm/drm_debugfs.h     | 77 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 82 insertions(+), 44 deletions(-)
 create mode 100644 include/drm/drm_debugfs.h
drivers/gpu/drm/drm_debugfs.c +4 -1
index 1d2d18d82d2e..4b02f4230562 100644
@@ -34,9 +34,12 @@
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/export.h>
-#include <drm/drmP.h>
+
+#include <drm/drm_debugfs.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_atomic.h>
+#include <drm/drmP.h>
+
 #include "drm_internal.h"
 #include "drm_crtc_internal.h"
 
include/drm/drmP.h +1 -43

62 lines not on this page · raw message

include/drm/drm_debugfs.h new file +77 -0

77 lines not on this page · raw message

Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#7 lore raw

Re: [PATCH] drm: Extract drm_debugfs.h

Quoted 6 lines · Daniel Vetter

Doc polish will follow in the next patch.

v2: Put the include guard #endif at the end (Ville).

Cc Ville Syrjälä <[email protected]>
Quoted 179 lines
---
 drivers/gpu/drm/drm_debugfs.c |  5 ++-
 include/drm/drmP.h            | 44 +------------------------
 include/drm/drm_debugfs.h     | 77 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 82 insertions(+), 44 deletions(-)
 create mode 100644 include/drm/drm_debugfs.h
drivers/gpu/drm/drm_debugfs.c +4 -1
index 1d2d18d82d2e..4b02f4230562 100644
@@ -34,9 +34,12 @@
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/export.h>
-#include <drm/drmP.h>
+
+#include <drm/drm_debugfs.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_atomic.h>
+#include <drm/drmP.h>
+
 #include "drm_internal.h"
 #include "drm_crtc_internal.h"
 
include/drm/drmP.h +1 -43
index 0e383438f793..60f3255c43a8 100644
@@ -78,6 +78,7 @@
 #include <drm/drm_prime.h>
 #include <drm/drm_pci.h>
 #include <drm/drm_file.h>
+#include <drm/drm_debugfs.h>
 
 struct module;
 
@@ -371,27 +372,6 @@ struct drm_ioctl_desc {
 #define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
 
 /**
- * Info file list entry. This structure represents a debugfs or proc file to
- * be created by the drm core
- */
-struct drm_info_list {
-	const char *name; /** file name */
-	int (*show)(struct seq_file*, void*); /** show callback */
-	u32 driver_features; /**< Required driver features for this entry */
-	void *data;
-};
-
-/**
- * debugfs node structure. This structure represents a debugfs file.
- */
-struct drm_info_node {
-	struct list_head list;
-	struct drm_minor *minor;
-	const struct drm_info_list *info_ent;
-	struct dentry *dent;
-};
-
-/**
  * DRM device structure. This structure represent a complete card that
  * may contain multiple heads.
  */
@@ -592,28 +572,6 @@ int drm_invalid_op(struct drm_device *dev, void *data,
  * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
  */
 
-				/* Debugfs support */
-#if defined(CONFIG_DEBUG_FS)
-extern int drm_debugfs_create_files(const struct drm_info_list *files,
-				    int count, struct dentry *root,
-				    struct drm_minor *minor);
-extern int drm_debugfs_remove_files(const struct drm_info_list *files,
-				    int count, struct drm_minor *minor);
-#else
-static inline int drm_debugfs_create_files(const struct drm_info_list *files,
-					   int count, struct dentry *root,
-					   struct drm_minor *minor)
-{
-	return 0;
-}
-
-static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
-					   int count, struct drm_minor *minor)
-{
-	return 0;
-}
-#endif
-
 			       /* sysfs support (drm_sysfs.c) */
 extern void drm_sysfs_hotplug_event(struct drm_device *dev);
 
include/drm/drm_debugfs.h new file +77 -0
new file mode 100644
index 000000000000..56924196d08d
@@ -0,0 +1,77 @@
+/*
+ * Internal Header for the Direct Rendering Manager
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * Copyright (c) 2009-2010, Code Aurora Forum.
+ * All rights reserved.
+ *
+ * Author: Rickard E. (Rik) Faith <[email protected]>
+ * Author: Gareth Hughes <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _DRM_DEBUGFS_H_
+#define _DRM_DEBUGFS_H_
+
+/**
+ * Info file list entry. This structure represents a debugfs or proc file to
+ * be created by the drm core
+ */
+struct drm_info_list {
+	const char *name; /** file name */
+	int (*show)(struct seq_file*, void*); /** show callback */
+	u32 driver_features; /**< Required driver features for this entry */
+	void *data;
+};
+
+/**
+ * debugfs node structure. This structure represents a debugfs file.
+ */
+struct drm_info_node {
+	struct list_head list;
+	struct drm_minor *minor;
+	const struct drm_info_list *info_ent;
+	struct dentry *dent;
+};
+
+#if defined(CONFIG_DEBUG_FS)
+int drm_debugfs_create_files(const struct drm_info_list *files,
+			     int count, struct dentry *root,
+			     struct drm_minor *minor);
+int drm_debugfs_remove_files(const struct drm_info_list *files,
+			     int count, struct drm_minor *minor);
+#else
+static inline int drm_debugfs_create_files(const struct drm_info_list *files,
+					   int count, struct dentry *root,
+					   struct drm_minor *minor)
+{
+	return 0;
+}
+
+static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
+					   int count, struct drm_minor *minor)
+{
+	return 0;
+}
+#endif
+
+#endif /* _DRM_DEBUGFS_H_ */
Signature · 1 line
2.11.0
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#8 lore raw

PATCH 3/16 drm: document driver interface for CRC capturing

In reply to Daniel Vetter

This was missed in Tomeu's patch. Also remove the kerneldoc for the internal function, we don't document that in general.

While at it word-smith the docs slightly for more clarity.

---
 Documentation/gpu/drm-uapi.rst    |  3 +++
 drivers/gpu/drm/drm_debugfs_crc.c | 17 ++++++-----------
 include/drm/drm_crtc.h            |  5 ++++-
 3 files changed, 13 insertions(+), 12 deletions(-)
Documentation/gpu/drm-uapi.rst +3 -0
index 352652810dab..369e8ca12b8e 100644
@@ -207,6 +207,9 @@ Display CRC Support
 .. kernel-doc:: drivers/gpu/drm/drm_debugfs_crc.c
    :doc: CRC ABI
 
+.. kernel-doc:: drivers/gpu/drm/drm_debugfs_crc.c
+   :export:
+
 VBlank event handling
 =====================
 
drivers/gpu/drm/drm_debugfs_crc.c +6 -11
index 96891c4a6e23..1722d8f21449 100644
@@ -36,7 +36,7 @@
  * DOC: CRC ABI
  *
  * DRM device drivers can provide to userspace CRC information of each frame as
- * it reached a given hardware component (a "source").
+ * it reached a given hardware component (a CRC sampling "source").
  *
  * Userspace can control generation of CRCs in a given CRTC by writing to the
  * file dri/0/crtc-N/crc/control in debugfs, with N being the index of the CRTC.
@@ -57,6 +57,11 @@
  * rely on being able to generate matching CRC values for the frame contents that
  * it submits. In this general case, the maximum userspace can do is to compare
  * the reported CRCs of frames that should have the same contents.
+ *
+ * On the driver side the implementation effort is minimal, drivers only need to
+ * implement &drm_crtc_funcs.set_crc_source. The debugfs files are automatically
+ * set up if that vfunc is set. CRC samples need to be captured in the driver by
+ * calling drm_crtc_add_crc_entry().
  */
 
 static int crc_control_show(struct seq_file *m, void *data)
@@ -280,16 +285,6 @@ static const struct file_operations drm_crtc_crc_data_fops = {
 	.release = crtc_crc_release,
 };
 
-/**
- * drm_debugfs_crtc_crc_add - Add files to debugfs for capture of frame CRCs
- * @crtc: CRTC to whom the frames will belong
- *
- * Adds files to debugfs directory that allows userspace to control the
- * generation of frame CRCs and to read them.
- *
- * Returns:
- * Zero on success, error code on failure.
- */
 int drm_debugfs_crtc_crc_add(struct drm_crtc *crtc)
 {
 	struct dentry *crc_ent, *ent;
include/drm/drm_crtc.h +4 -1
index 6ef59da3fd8e..24dcb121bad4 100644
@@ -590,9 +590,12 @@ struct drm_crtc_funcs {
 	 * When CRC generation is enabled, the driver should call
 	 * drm_crtc_add_crc_entry() at each frame, providing any information
 	 * that characterizes the frame contents in the crcN arguments, as
-	 * provided from the configured source. Drivers must accept a "auto"
+	 * provided from the configured source. Drivers must accept an "auto"
 	 * source name that will select a default source for this CRTC.
 	 *
+	 * Note that "auto" can depend upon the current modeset configuration,
+	 * e.g. it could pick an encoder or output specific CRC sampling point.
+	 *
 	 * This callback is optional if the driver does not support any CRC
 	 * generation functionality.
 	 *
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 3/16
#9 lore raw

Re: [Intel-gfx] [PATCH 03/16] drm: document driver interface for CRC capturing

Thanks for doing this.

Quoted 90 lines · Daniel Vetter

This was missed in Tomeu's patch. Also remove the kerneldoc for the internal function, we don't document that in general.

While at it word-smith the docs slightly for more clarity.

---
 Documentation/gpu/drm-uapi.rst    |  3 +++
 drivers/gpu/drm/drm_debugfs_crc.c | 17 ++++++-----------
 include/drm/drm_crtc.h            |  5 ++++-
 3 files changed, 13 insertions(+), 12 deletions(-)
Documentation/gpu/drm-uapi.rst +3 -0
index 352652810dab..369e8ca12b8e 100644
@@ -207,6 +207,9 @@ Display CRC Support
 .. kernel-doc:: drivers/gpu/drm/drm_debugfs_crc.c
    :doc: CRC ABI
 
+.. kernel-doc:: drivers/gpu/drm/drm_debugfs_crc.c
+   :export:
+
 VBlank event handling
 =====================
 
drivers/gpu/drm/drm_debugfs_crc.c +6 -11
index 96891c4a6e23..1722d8f21449 100644
@@ -36,7 +36,7 @@
  * DOC: CRC ABI
  *
  * DRM device drivers can provide to userspace CRC information of each frame as
- * it reached a given hardware component (a "source").
+ * it reached a given hardware component (a CRC sampling "source").
  *
  * Userspace can control generation of CRCs in a given CRTC by writing to the
  * file dri/0/crtc-N/crc/control in debugfs, with N being the index of the CRTC.
@@ -57,6 +57,11 @@
  * rely on being able to generate matching CRC values for the frame contents that
  * it submits. In this general case, the maximum userspace can do is to compare
  * the reported CRCs of frames that should have the same contents.
+ *
+ * On the driver side the implementation effort is minimal, drivers only need to
+ * implement &drm_crtc_funcs.set_crc_source. The debugfs files are automatically
+ * set up if that vfunc is set. CRC samples need to be captured in the driver by
+ * calling drm_crtc_add_crc_entry().
  */
 
 static int crc_control_show(struct seq_file *m, void *data)
@@ -280,16 +285,6 @@ static const struct file_operations drm_crtc_crc_data_fops = {
        .release = crtc_crc_release,
 };
 
-/**
- * drm_debugfs_crtc_crc_add - Add files to debugfs for capture of frame CRCs
- * @crtc: CRTC to whom the frames will belong
- *
- * Adds files to debugfs directory that allows userspace to control the
- * generation of frame CRCs and to read them.
- *
- * Returns:
- * Zero on success, error code on failure.
- */
 int drm_debugfs_crtc_crc_add(struct drm_crtc *crtc)
 {
        struct dentry *crc_ent, *ent;
include/drm/drm_crtc.h +4 -2
index 6ef59da3fd8e..24dcb121bad4 100644
@@ -590,9 +590,12 @@ struct drm_crtc_funcs {
         * When CRC generation is enabled, the driver should call
         * drm_crtc_add_crc_entry() at each frame, providing any information
         * that characterizes the frame contents in the crcN arguments, as
-        * provided from the configured source. Drivers must accept a "auto"
+        * provided from the configured source. Drivers must accept an "auto"
         * source name that will select a default source for this CRTC.
         *
+        * Note that "auto" can depend upon the current modeset configuration,
+        * e.g. it could pick an encoder or output specific CRC sampling point.
+        *
         * This callback is optional if the driver does not support any CRC
         * generation functionality.
         *
--

2.11.0

Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#10 lore raw

PATCH 4/16 drm/debugfs: Add kerneldoc

In reply to Daniel Vetter

I've decided to not document drm_debugfs_remove_files, it's on the way out.

The biggest part is a huge todor.rst entry with what all should be improved.

---
 Documentation/gpu/drm-uapi.rst |  9 ++++++++
 Documentation/gpu/todo.rst     | 26 +++++++++++++++++++++
 drivers/gpu/drm/drm_debugfs.c  | 51 ++++++------------------------------------
 drivers/gpu/drm/drm_internal.h |  2 +-
 include/drm/drm_debugfs.h      | 38 +++++++++++++++++++++++++------
 5 files changed, 74 insertions(+), 52 deletions(-)
Documentation/gpu/drm-uapi.rst +9 -0
index 369e8ca12b8e..76356c86e358 100644
@@ -210,6 +210,15 @@ Display CRC Support
 .. kernel-doc:: drivers/gpu/drm/drm_debugfs_crc.c
    :export:
 
+Debugfs Support
+---------------
+
+.. kernel-doc:: include/drm/drm_debugfs.h
+   :internal:
+
+.. kernel-doc:: drivers/gpu/drm/drm_debugfs.c
+   :export:
+
 VBlank event handling
 =====================
 
Documentation/gpu/todo.rst +26 -0
index 64e9d16170ce..9ecd2ebb8dd8 100644
@@ -272,6 +272,32 @@ This is a really varied tasks with lots of little bits and pieces:
 
 Contact: Daniel Vetter
 
+Clean up the debugfs support
+----------------------------
+
+There's a bunch of issues with it:
+
+- The drm_info_list -> show function doesn't even bother to cast to the drm
+  structure for you. This is lazy.
+
+- We probably want to have some support for debugfs files on crtc/connectors and
+  maybe other kms objects directly in core. There's even drm_print support in
+  the funcs for these objects to dump kms state, so it's all there. And then the
+  ->show functions should obviously give you a pointer to the right object.
+
+- The drm_info_list stuff is centered on drm_minor instead of drm_device. For
+  anything we want to print drm_device (or maybe drm_file) is the right thing.
+
+- The drm_driver->debugfs_init hooks we have is just an artifact of the old
+  midlayered load sequence. DRM debugfs should work more like sysfs, where you
+  can create properties/files for an object anytime you want, and the core
+  takes care of publishing/unpuplishing all the files at register/unregister
+  time. Drivers shouldn't need to worry about these technicalities, and fixing
+  this (together with the drm_minor->drm_device move) would allow us to remove
+  debugfs_init.
+
+Contact: Daniel Vetter
+
 Better Testing
 ==============
 
drivers/gpu/drm/drm_debugfs.c +7 -44

80 lines not on this page · raw message

drivers/gpu/drm/drm_internal.h +1 -1
index 92ff4b9393b1..3d8e8f878924 100644
@@ -100,7 +100,7 @@ int drm_gem_open_ioctl(struct drm_device *dev, void *data,
 void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
 void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
 
-/* drm_debugfs.c */
+/* drm_debugfs.c drm_debugfs_crc.c */
 #if defined(CONFIG_DEBUG_FS)
 int drm_debugfs_init(struct drm_minor *minor, int minor_id,
 		     struct dentry *root);
include/drm/drm_debugfs.h +31 -7
index 17e47c073fa9..d45bc1879412 100644
@@ -33,23 +33,47 @@
 #define _DRM_DEBUGFS_H_
 
 /**
- * Info file list entry. This structure represents a debugfs or proc file to
- * be created by the drm core
+ * struct drm_info_list - debugfs info list entry
+ *
+ * This structure represents a debugfs file to be created by the drm
+ * core.
  */
 struct drm_info_list {
-	const char *name; /** file name */
-	int (*show)(struct seq_file*, void*); /** show callback */
-	u32 driver_features; /**< Required driver features for this entry */
+	/** @name: file name */
+	const char *name;
+	/**
+	 * @show:
+	 *
+	 * Show callback. &seq_file->private will be set to the &struct
+	 * drm_info_node corresponding to the instance of this info on a given
+	 * &struct drm_minor.
+	 */
+	int (*show)(struct seq_file*, void*);
+	/** @driver_features: Required driver features for this entry */
+	u32 driver_features;
+	/** @data: Driver-private data, should not be device-specific. */
 	void *data;
 };
 
 /**
- * debugfs node structure. This structure represents a debugfs file.
+ * struct drm_info_node - Per-minor debugfs node structure
+ *
+ * This structure represents a debugfs file, as an instantiation of a &struct
+ * drm_info_list on a &struct drm_minor.
+ *
+ * FIXME:
+ *
+ * No it doesn't make a hole lot of sense that we duplicate debugfs entries for
+ * both the render and the primary nodes, but that's how this has organically
+ * grown. It should probably be fixed, with a compatibility link, if needed.
  */
 struct drm_info_node {
-	struct list_head list;
+	/** @minor: &struct drm_minor for this node. */
 	struct drm_minor *minor;
+	/** @info_ent: template for thise node. */
 	const struct drm_info_list *info_ent;
+	/* private: */
+	struct list_head list;
 	struct dentry *dent;
 };
 
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 4/16
#11 lore raw

Re: [PATCH 04/16] drm/debugfs: Add kerneldoc

Quoted 5 lines · Daniel Vetter

I've decided to not document drm_debugfs_remove_files, it's on the way out.

The biggest part is a huge todor.rst entry with what all should be improved.

todo.rst

Quoted 40 lines
---
 Documentation/gpu/drm-uapi.rst |  9 ++++++++
 Documentation/gpu/todo.rst     | 26 +++++++++++++++++++++
 drivers/gpu/drm/drm_debugfs.c  | 51 ++++++------------------------------------
 drivers/gpu/drm/drm_internal.h |  2 +-
 include/drm/drm_debugfs.h      | 38 +++++++++++++++++++++++++------
 5 files changed, 74 insertions(+), 52 deletions(-)
Documentation/gpu/drm-uapi.rst +9 -0
index 369e8ca12b8e..76356c86e358 100644
@@ -210,6 +210,15 @@ Display CRC Support
 .. kernel-doc:: drivers/gpu/drm/drm_debugfs_crc.c
    :export:
 
+Debugfs Support
+---------------
+
+.. kernel-doc:: include/drm/drm_debugfs.h
+   :internal:
+
+.. kernel-doc:: drivers/gpu/drm/drm_debugfs.c
+   :export:
+
 VBlank event handling
 =====================
 
Documentation/gpu/todo.rst +2 -0
index 64e9d16170ce..9ecd2ebb8dd8 100644
@@ -272,6 +272,32 @@ This is a really varied tasks with lots of little bits and pieces:
 
 Contact: Daniel Vetter
 
+Clean up the debugfs support
+----------------------------

Documentation/gpu/todo.rst This is a really varied tasks with lots of little bits and pieces: · line 286

Quoted 10 lines
Documentation/gpu/todo.rst +10 -0
+
+There's a bunch of issues with it:
+
+- The drm_info_list -> show function doesn't even bother to cast to the drm
+  structure for you. This is lazy.
+
+- We probably want to have some support for debugfs files on crtc/connectors and
+  maybe other kms objects directly in core. There's even drm_print support in
+  the funcs for these objects to dump kms state, so it's all there. And then the
+  ->show functions should obviously give you a pointer to the right object.

should you use ->show() ? not sure. Either way, extra space on the previuous "->show" instance.

Quoted 162 lines
Documentation/gpu/todo.rst +14 -0
+
+- The drm_info_list stuff is centered on drm_minor instead of drm_device. For
+  anything we want to print drm_device (or maybe drm_file) is the right thing.
+
+- The drm_driver->debugfs_init hooks we have is just an artifact of the old
+  midlayered load sequence. DRM debugfs should work more like sysfs, where you
+  can create properties/files for an object anytime you want, and the core
+  takes care of publishing/unpuplishing all the files at register/unregister
+  time. Drivers shouldn't need to worry about these technicalities, and fixing
+  this (together with the drm_minor->drm_device move) would allow us to remove
+  debugfs_init.
+
+Contact: Daniel Vetter
+
 Better Testing
 ==============
 
drivers/gpu/drm/drm_debugfs.c +7 -44
index 4b02f4230562..c1807d5754b2 100644
@@ -1,10 +1,3 @@
-/**
- * \file drm_debugfs.c
- * debugfs support for DRM
- *
- * \author Ben Gamari <[email protected]>
- */
-
 /*
  * Created: Sun Dec 21 13:08:50 2008 by [email protected]
  *
@@ -75,16 +68,15 @@ static const struct file_operations drm_debugfs_fops = {
 
 
 /**
- * Initialize a given set of debugfs files for a device
- *
- * \param files The array of files to create
- * \param count The number of files given
- * \param root DRI debugfs dir entry.
- * \param minor device minor number
- * \return Zero on success, non-zero on failure
+ * drm_debugfs_create_files - Initialize a given set of debugfs files for DRM
+ * 			minor
+ * @files: The array of files to create
+ * @count: The number of files given
+ * @root: DRI debugfs dir entry.
+ * @minor: device minor number
  *
  * Create a given set of debugfs files represented by an array of
- * &drm_info_list in the given root directory. These files will be removed
+ * &struct drm_info_list in the given root directory. These files will be removed
  * automatically on drm_debugfs_cleanup().
  */
 int drm_debugfs_create_files(const struct drm_info_list *files, int count,
@@ -133,17 +125,6 @@ int drm_debugfs_create_files(const struct drm_info_list *files, int count,
 }
 EXPORT_SYMBOL(drm_debugfs_create_files);
 
-/**
- * Initialize the DRI debugfs filesystem for a device
- *
- * \param dev DRM device
- * \param minor device minor number
- * \param root DRI debugfs dir entry.
- *
- * Create the DRI debugfs root entry "/sys/kernel/debug/dri", the device debugfs root entry
- * "/sys/kernel/debug/dri/%minor%/", and each entry in debugfs_list as
- * "/sys/kernel/debug/dri/%minor%/%name%".
- */
 int drm_debugfs_init(struct drm_minor *minor, int minor_id,
 		     struct dentry *root)
 {
@@ -189,16 +170,6 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id,
 }
 
 
-/**
- * Remove a list of debugfs files
- *
- * \param files The list of files
- * \param count The number of files
- * \param minor The minor of which we should remove the files
- * \return always zero.
- *
- * Remove all debugfs entries created by debugfs_init().
- */
 int drm_debugfs_remove_files(const struct drm_info_list *files, int count,
 			     struct drm_minor *minor)
 {
@@ -235,14 +206,6 @@ static void drm_debugfs_remove_all_files(struct drm_minor *minor)
 	mutex_unlock(&minor->debugfs_lock);
 }
 
-/**
- * Cleanup the debugfs filesystem resources.
- *
- * \param minor device minor number.
- * \return always zero.
- *
- * Remove all debugfs entries created by debugfs_init().
- */
 int drm_debugfs_cleanup(struct drm_minor *minor)
 {
 	if (!minor->debugfs_root)
drivers/gpu/drm/drm_internal.h +1 -1
index 92ff4b9393b1..3d8e8f878924 100644
@@ -100,7 +100,7 @@ int drm_gem_open_ioctl(struct drm_device *dev, void *data,
 void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
 void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
 
-/* drm_debugfs.c */
+/* drm_debugfs.c drm_debugfs_crc.c */
 #if defined(CONFIG_DEBUG_FS)
 int drm_debugfs_init(struct drm_minor *minor, int minor_id,
 		     struct dentry *root);
include/drm/drm_debugfs.h +23 -6
index 17e47c073fa9..d45bc1879412 100644
@@ -33,23 +33,47 @@
 #define _DRM_DEBUGFS_H_
 
 /**
- * Info file list entry. This structure represents a debugfs or proc file to
- * be created by the drm core
+ * struct drm_info_list - debugfs info list entry
+ *
+ * This structure represents a debugfs file to be created by the drm
+ * core.
  */
 struct drm_info_list {
-	const char *name; /** file name */
-	int (*show)(struct seq_file*, void*); /** show callback */
-	u32 driver_features; /**< Required driver features for this entry */
+	/** @name: file name */
+	const char *name;
+	/**
+	 * @show:
+	 *
+	 * Show callback. &seq_file->private will be set to the &struct
+	 * drm_info_node corresponding to the instance of this info on a given
+	 * &struct drm_minor.
+	 */
+	int (*show)(struct seq_file*, void*);
+	/** @driver_features: Required driver features for this entry */
+	u32 driver_features;
+	/** @data: Driver-private data, should not be device-specific. */
 	void *data;
 };
 
 /**
- * debugfs node structure. This structure represents a debugfs file.
+ * struct drm_info_node - Per-minor debugfs node structure
+ *
+ * This structure represents a debugfs file, as an instantiation of a &struct
+ * drm_info_list on a &struct drm_minor.
+ *
+ * FIXME:

include/drm/drm_debugfs.h line 73

Quoted 10 lines
include/drm/drm_debugfs.h +6 -1
+ *
+ * No it doesn't make a hole lot of sense that we duplicate debugfs entries for
+ * both the render and the primary nodes, but that's how this has organically
+ * grown. It should probably be fixed, with a compatibility link, if needed.
  */
 struct drm_info_node {
-	struct list_head list;
+	/** @minor: &struct drm_minor for this node. */
 	struct drm_minor *minor;
+	/** @info_ent: template for thise node. */

this node

With this nit-picks, feel free to add:

Quoted 5 lines
include/drm/drm_debugfs.h +2 -0
 	const struct drm_info_list *info_ent;
+	/* private: */
+	struct list_head list;
 	struct dentry *dent;
 };
Signature · 5 lines
Gabriel Krisman Bertazi
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#12 lore raw

PATCH 1/1 drm/debugfs: Add kerneldoc

In reply to Daniel Vetter

I've decided to not document drm_debugfs_remove_files, it's on the way out.

The biggest part is a huge todo.rst entry with what all should be improved.

v2: Nits from Gabriel.

---
 Documentation/gpu/drm-uapi.rst |  9 ++++++++
 Documentation/gpu/todo.rst     | 26 +++++++++++++++++++++
 drivers/gpu/drm/drm_debugfs.c  | 51 ++++++------------------------------------
 drivers/gpu/drm/drm_internal.h |  2 +-
 include/drm/drm_debugfs.h      | 38 +++++++++++++++++++++++++------
 5 files changed, 74 insertions(+), 52 deletions(-)
Documentation/gpu/drm-uapi.rst +9 -0
index 369e8ca12b8e..76356c86e358 100644
@@ -210,6 +210,15 @@ Display CRC Support
 .. kernel-doc:: drivers/gpu/drm/drm_debugfs_crc.c
    :export:
 
+Debugfs Support
+---------------
+
+.. kernel-doc:: include/drm/drm_debugfs.h
+   :internal:
+
+.. kernel-doc:: drivers/gpu/drm/drm_debugfs.c
+   :export:
+
 VBlank event handling
 =====================
 
Documentation/gpu/todo.rst +26 -0
index 64e9d16170ce..0cdaddad2b9b 100644
@@ -272,6 +272,32 @@ This is a really varied tasks with lots of little bits and pieces:
 
 Contact: Daniel Vetter
 
+Clean up the debugfs support
+----------------------------
+
+There's a bunch of issues with it:
+
+- The drm_info_list ->show() function doesn't even bother to cast to the drm
+  structure for you. This is lazy.
+
+- We probably want to have some support for debugfs files on crtc/connectors and
+  maybe other kms objects directly in core. There's even drm_print support in
+  the funcs for these objects to dump kms state, so it's all there. And then the
+  ->show() functions should obviously give you a pointer to the right object.
+
+- The drm_info_list stuff is centered on drm_minor instead of drm_device. For
+  anything we want to print drm_device (or maybe drm_file) is the right thing.
+
+- The drm_driver->debugfs_init hooks we have is just an artifact of the old
+  midlayered load sequence. DRM debugfs should work more like sysfs, where you
+  can create properties/files for an object anytime you want, and the core
+  takes care of publishing/unpuplishing all the files at register/unregister
+  time. Drivers shouldn't need to worry about these technicalities, and fixing
+  this (together with the drm_minor->drm_device move) would allow us to remove
+  debugfs_init.
+
+Contact: Daniel Vetter
+
 Better Testing
 ==============
 
drivers/gpu/drm/drm_debugfs.c +7 -44

80 lines not on this page · raw message

drivers/gpu/drm/drm_internal.h +1 -1
index 92ff4b9393b1..3d8e8f878924 100644
@@ -100,7 +100,7 @@ int drm_gem_open_ioctl(struct drm_device *dev, void *data,
 void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
 void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
 
-/* drm_debugfs.c */
+/* drm_debugfs.c drm_debugfs_crc.c */
 #if defined(CONFIG_DEBUG_FS)
 int drm_debugfs_init(struct drm_minor *minor, int minor_id,
 		     struct dentry *root);
include/drm/drm_debugfs.h +31 -7
index 56924196d08d..ac0f75df1ac9 100644
@@ -33,23 +33,47 @@
 #define _DRM_DEBUGFS_H_
 
 /**
- * Info file list entry. This structure represents a debugfs or proc file to
- * be created by the drm core
+ * struct drm_info_list - debugfs info list entry
+ *
+ * This structure represents a debugfs file to be created by the drm
+ * core.
  */
 struct drm_info_list {
-	const char *name; /** file name */
-	int (*show)(struct seq_file*, void*); /** show callback */
-	u32 driver_features; /**< Required driver features for this entry */
+	/** @name: file name */
+	const char *name;
+	/**
+	 * @show:
+	 *
+	 * Show callback. &seq_file->private will be set to the &struct
+	 * drm_info_node corresponding to the instance of this info on a given
+	 * &struct drm_minor.
+	 */
+	int (*show)(struct seq_file*, void*);
+	/** @driver_features: Required driver features for this entry */
+	u32 driver_features;
+	/** @data: Driver-private data, should not be device-specific. */
 	void *data;
 };
 
 /**
- * debugfs node structure. This structure represents a debugfs file.
+ * struct drm_info_node - Per-minor debugfs node structure
+ *
+ * This structure represents a debugfs file, as an instantiation of a &struct
+ * drm_info_list on a &struct drm_minor.
+ *
+ * FIXME:
+ *
+ * No it doesn't make a hole lot of sense that we duplicate debugfs entries for
+ * both the render and the primary nodes, but that's how this has organically
+ * grown. It should probably be fixed, with a compatibility link, if needed.
  */
 struct drm_info_node {
-	struct list_head list;
+	/** @minor: &struct drm_minor for this node. */
 	struct drm_minor *minor;
+	/** @info_ent: template for this node. */
 	const struct drm_info_list *info_ent;
+	/* private: */
+	struct list_head list;
 	struct dentry *dent;
 };
 
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#13 lore raw

Re: [PATCH] drm/debugfs: Add kerneldoc

Quoted 11 lines · Daniel Vetter

I've decided to not document drm_debugfs_remove_files, it's on the way out.

The biggest part is a huge todo.rst entry with what all should be improved.

v2: Nits from Gabriel.

Merged up to this patch to drm-misc-next.

I will trade reviews for more reviews to help get the remaining in!

Thanks, Daniel

Quoted 229 lines
---
 Documentation/gpu/drm-uapi.rst |  9 ++++++++
 Documentation/gpu/todo.rst     | 26 +++++++++++++++++++++
 drivers/gpu/drm/drm_debugfs.c  | 51 ++++++------------------------------------
 drivers/gpu/drm/drm_internal.h |  2 +-
 include/drm/drm_debugfs.h      | 38 +++++++++++++++++++++++++------
 5 files changed, 74 insertions(+), 52 deletions(-)
Documentation/gpu/drm-uapi.rst +9 -0
index 369e8ca12b8e..76356c86e358 100644
@@ -210,6 +210,15 @@ Display CRC Support
 .. kernel-doc:: drivers/gpu/drm/drm_debugfs_crc.c
    :export:
 
+Debugfs Support
+---------------
+
+.. kernel-doc:: include/drm/drm_debugfs.h
+   :internal:
+
+.. kernel-doc:: drivers/gpu/drm/drm_debugfs.c
+   :export:
+
 VBlank event handling
 =====================
 
Documentation/gpu/todo.rst +26 -0
index 64e9d16170ce..0cdaddad2b9b 100644
@@ -272,6 +272,32 @@ This is a really varied tasks with lots of little bits and pieces:
 
 Contact: Daniel Vetter
 
+Clean up the debugfs support
+----------------------------
+
+There's a bunch of issues with it:
+
+- The drm_info_list ->show() function doesn't even bother to cast to the drm
+  structure for you. This is lazy.
+
+- We probably want to have some support for debugfs files on crtc/connectors and
+  maybe other kms objects directly in core. There's even drm_print support in
+  the funcs for these objects to dump kms state, so it's all there. And then the
+  ->show() functions should obviously give you a pointer to the right object.
+
+- The drm_info_list stuff is centered on drm_minor instead of drm_device. For
+  anything we want to print drm_device (or maybe drm_file) is the right thing.
+
+- The drm_driver->debugfs_init hooks we have is just an artifact of the old
+  midlayered load sequence. DRM debugfs should work more like sysfs, where you
+  can create properties/files for an object anytime you want, and the core
+  takes care of publishing/unpuplishing all the files at register/unregister
+  time. Drivers shouldn't need to worry about these technicalities, and fixing
+  this (together with the drm_minor->drm_device move) would allow us to remove
+  debugfs_init.
+
+Contact: Daniel Vetter
+
 Better Testing
 ==============
 
drivers/gpu/drm/drm_debugfs.c +7 -44
index 4b02f4230562..c1807d5754b2 100644
@@ -1,10 +1,3 @@
-/**
- * \file drm_debugfs.c
- * debugfs support for DRM
- *
- * \author Ben Gamari <[email protected]>
- */
-
 /*
  * Created: Sun Dec 21 13:08:50 2008 by [email protected]
  *
@@ -75,16 +68,15 @@ static const struct file_operations drm_debugfs_fops = {
 
 
 /**
- * Initialize a given set of debugfs files for a device
- *
- * \param files The array of files to create
- * \param count The number of files given
- * \param root DRI debugfs dir entry.
- * \param minor device minor number
- * \return Zero on success, non-zero on failure
+ * drm_debugfs_create_files - Initialize a given set of debugfs files for DRM
+ * 			minor
+ * @files: The array of files to create
+ * @count: The number of files given
+ * @root: DRI debugfs dir entry.
+ * @minor: device minor number
  *
  * Create a given set of debugfs files represented by an array of
- * &drm_info_list in the given root directory. These files will be removed
+ * &struct drm_info_list in the given root directory. These files will be removed
  * automatically on drm_debugfs_cleanup().
  */
 int drm_debugfs_create_files(const struct drm_info_list *files, int count,
@@ -133,17 +125,6 @@ int drm_debugfs_create_files(const struct drm_info_list *files, int count,
 }
 EXPORT_SYMBOL(drm_debugfs_create_files);
 
-/**
- * Initialize the DRI debugfs filesystem for a device
- *
- * \param dev DRM device
- * \param minor device minor number
- * \param root DRI debugfs dir entry.
- *
- * Create the DRI debugfs root entry "/sys/kernel/debug/dri", the device debugfs root entry
- * "/sys/kernel/debug/dri/%minor%/", and each entry in debugfs_list as
- * "/sys/kernel/debug/dri/%minor%/%name%".
- */
 int drm_debugfs_init(struct drm_minor *minor, int minor_id,
 		     struct dentry *root)
 {
@@ -189,16 +170,6 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id,
 }
 
 
-/**
- * Remove a list of debugfs files
- *
- * \param files The list of files
- * \param count The number of files
- * \param minor The minor of which we should remove the files
- * \return always zero.
- *
- * Remove all debugfs entries created by debugfs_init().
- */
 int drm_debugfs_remove_files(const struct drm_info_list *files, int count,
 			     struct drm_minor *minor)
 {
@@ -235,14 +206,6 @@ static void drm_debugfs_remove_all_files(struct drm_minor *minor)
 	mutex_unlock(&minor->debugfs_lock);
 }
 
-/**
- * Cleanup the debugfs filesystem resources.
- *
- * \param minor device minor number.
- * \return always zero.
- *
- * Remove all debugfs entries created by debugfs_init().
- */
 int drm_debugfs_cleanup(struct drm_minor *minor)
 {
 	if (!minor->debugfs_root)
drivers/gpu/drm/drm_internal.h +1 -1
index 92ff4b9393b1..3d8e8f878924 100644
@@ -100,7 +100,7 @@ int drm_gem_open_ioctl(struct drm_device *dev, void *data,
 void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
 void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
 
-/* drm_debugfs.c */
+/* drm_debugfs.c drm_debugfs_crc.c */
 #if defined(CONFIG_DEBUG_FS)
 int drm_debugfs_init(struct drm_minor *minor, int minor_id,
 		     struct dentry *root);
include/drm/drm_debugfs.h +31 -7
index 56924196d08d..ac0f75df1ac9 100644
@@ -33,23 +33,47 @@
 #define _DRM_DEBUGFS_H_
 
 /**
- * Info file list entry. This structure represents a debugfs or proc file to
- * be created by the drm core
+ * struct drm_info_list - debugfs info list entry
+ *
+ * This structure represents a debugfs file to be created by the drm
+ * core.
  */
 struct drm_info_list {
-	const char *name; /** file name */
-	int (*show)(struct seq_file*, void*); /** show callback */
-	u32 driver_features; /**< Required driver features for this entry */
+	/** @name: file name */
+	const char *name;
+	/**
+	 * @show:
+	 *
+	 * Show callback. &seq_file->private will be set to the &struct
+	 * drm_info_node corresponding to the instance of this info on a given
+	 * &struct drm_minor.
+	 */
+	int (*show)(struct seq_file*, void*);
+	/** @driver_features: Required driver features for this entry */
+	u32 driver_features;
+	/** @data: Driver-private data, should not be device-specific. */
 	void *data;
 };
 
 /**
- * debugfs node structure. This structure represents a debugfs file.
+ * struct drm_info_node - Per-minor debugfs node structure
+ *
+ * This structure represents a debugfs file, as an instantiation of a &struct
+ * drm_info_list on a &struct drm_minor.
+ *
+ * FIXME:
+ *
+ * No it doesn't make a hole lot of sense that we duplicate debugfs entries for
+ * both the render and the primary nodes, but that's how this has organically
+ * grown. It should probably be fixed, with a compatibility link, if needed.
  */
 struct drm_info_node {
-	struct list_head list;
+	/** @minor: &struct drm_minor for this node. */
 	struct drm_minor *minor;
+	/** @info_ent: template for this node. */
 	const struct drm_info_list *info_ent;
+	/* private: */
+	struct list_head list;
 	struct dentry *dent;
 };
 
Signature · 1 line
2.11.0
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#14 lore raw

PATCH 5/16 drm: update todo.rst

In reply to Daniel Vetter

Just drive-by, but we have gsoc running so better to update it now.

Great news is that two entries can be removed because essentially all done.

---
 Documentation/gpu/todo.rst | 51 ++++------------------------------------------
 1 file changed, 4 insertions(+), 47 deletions(-)
Documentation/gpu/todo.rst +4 -47
index 9ecd2ebb8dd8..7dc6de07a3bc 100644
@@ -16,7 +16,7 @@ De-midlayer drivers
 With the recent ``drm_bus`` cleanup patches for 3.17 it is no longer required
 to have a ``drm_bus`` structure set up. Drivers can directly set up the
 ``drm_device`` structure instead of relying on bus methods in ``drm_usb.c``
-and ``drm_platform.c``. The goal is to get rid of the driver's ``->load`` /
+and ``drm_pci.c``. The goal is to get rid of the driver's ``->load`` /
 ``->unload`` callbacks and open-code the load/unload sequence properly, using
 the new two-stage ``drm_device`` setup/teardown.
 
@@ -151,7 +151,7 @@ fine-grained per-buffer object and per-context lockings scheme. Currently the
 following drivers still use ``struct_mutex``: ``msm``, ``omapdrm`` and
 ``udl``.
 
-Contact: Daniel Vetter
+Contact: Daniel Vetter, respective driver maintainers
 
 Switch to drm_connector_list_iter for any connector_list walking
 ----------------------------------------------------------------
@@ -193,6 +193,8 @@ plan is to switch to per-file driver API headers, which will also structure
 the kerneldoc better. This should also allow more fine-grained ``#include``
 directives.
 
+In the end no .c file should need to include ``drmP.h`` anymore.
+
 Contact: Daniel Vetter
 
 Add missing kerneldoc for exported functions
@@ -208,31 +210,6 @@ See https://dri.freedesktop.org/docs/drm/ for what's there already.
 
 Contact: Daniel Vetter
 
-Hide legacy cruft better
-------------------------
-
-Way back DRM supported only drivers which shadow-attached to PCI devices with
-userspace or fbdev drivers setting up outputs. Modern DRM drivers take charge
-of the entire device, you can spot them with the DRIVER_MODESET flag.
-
-Unfortunately there's still large piles of legacy code around which needs to
-be hidden so that driver writers don't accidentally end up using it. And to
-prevent security issues in those legacy IOCTLs from being exploited on modern
-drivers. This has multiple possible subtasks:
-
-* Make sure legacy IOCTLs can't be used on modern drivers.
-* Extract support code for legacy features into a ``drm-legacy.ko`` kernel
-  module and compile it only when one of the legacy drivers is enabled.
-* Extract legacy functions into their own headers and remove it that from the
-  monolithic ``drmP.h`` header.
-* Remove any lingering cruft from the OS abstraction layer from modern
-  drivers.
-
-This is mostly done, the only thing left is to split up ``drm_irq.c`` into
-legacy cruft and the parts needed by modern KMS drivers.
-
-Contact: Daniel Vetter
-
 Make panic handling work
 ------------------------
 
@@ -338,23 +315,3 @@ Driver Specific
 
 Outside DRM
 ===========
-
-Better kerneldoc
-----------------
-
-This is pretty much done, but there's some advanced topics:
-
-Come up with a way to hyperlink to struct members. Currently you can hyperlink
-to the struct using ``#struct_name``, but not to a member within. Would need
-buy-in from kerneldoc maintainers, and the big question is how to make it work
-without totally unsightly
-``drm_foo_bar_really_long_structure->even_longer_memeber`` all over the text
-which breaks text flow.
-
-Figure out how to integrate the asciidoc support for ascii-diagrams. We have a
-few of those (e.g. to describe mode timings), and asciidoc supports converting
-some ascii-art dialect into pngs. Would be really pretty to make that work.
-
-Contact: Daniel Vetter, Jani Nikula
-
-Jani is working on this already, hopefully lands in 4.8.
Signature · 6 lines
2.11.0

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

Re: [PATCH 05/16] drm: update todo.rst

Quoted 51 lines · Daniel Vetter

Just drive-by, but we have gsoc running so better to update it now.

Great news is that two entries can be removed because essentially all done.

---
 Documentation/gpu/todo.rst | 51 ++++------------------------------------------
 1 file changed, 4 insertions(+), 47 deletions(-)
Documentation/gpu/todo.rst +1 -1
index 9ecd2ebb8dd8..7dc6de07a3bc 100644
@@ -16,7 +16,7 @@ De-midlayer drivers
 With the recent ``drm_bus`` cleanup patches for 3.17 it is no longer required
 to have a ``drm_bus`` structure set up. Drivers can directly set up the
 ``drm_device`` structure instead of relying on bus methods in ``drm_usb.c``
-and ``drm_platform.c``. The goal is to get rid of the driver's ``->load`` /
+and ``drm_pci.c``. The goal is to get rid of the driver's ``->load`` /
 ``->unload`` callbacks and open-code the load/unload sequence properly, using
 the new two-stage ``drm_device`` setup/teardown.
 
@@ -151,7 +151,7 @@ fine-grained per-buffer object and per-context

lockings scheme. Currently the
following drivers still use ``struct_mutex``: ``msm``, ``omapdrm`` and ``udl``.

Documentation/gpu/todo.rst +3 -6
-Contact: Daniel Vetter
+Contact: Daniel Vetter, respective driver maintainers
 
 Switch to drm_connector_list_iter for any connector_list walking
 ----------------------------------------------------------------
@@ -193,6 +193,8 @@ plan is to switch to per-file driver API headers, which will also structure
 the kerneldoc better. This should also allow more fine-grained ``#include``
 directives.
 
+In the end no .c file should need to include ``drmP.h`` anymore.
+
 Contact: Daniel Vetter
 
 Add missing kerneldoc for exported functions
@@ -208,31 +210,6 @@ See https://dri.freedesktop.org/docs/drm/ for what's there already.
 
 Contact: Daniel Vetter
 
-Hide legacy cruft better
-------------------------
-
-Way back DRM supported only drivers which shadow-attached to PCI devices with
-userspace or fbdev drivers setting up outputs. Modern DRM drivers take charge

Documentation/gpu/todo.rst See https://dri.freedesktop.org/docs/drm/ for what's there already. · line 225

Quoted 10 lines
Documentation/gpu/todo.rst +0 -10
-of the entire device, you can spot them with the DRIVER_MODESET flag.
-
-Unfortunately there's still large piles of legacy code around which needs to
-be hidden so that driver writers don't accidentally end up using it. And to
-prevent security issues in those legacy IOCTLs from being exploited on modern
-drivers. This has multiple possible subtasks:
-
-* Make sure legacy IOCTLs can't be used on modern drivers.
-* Extract support code for legacy features into a ``drm-legacy.ko`` kernel
-  module and compile it only when one of the legacy drivers is enabled.

I've been interested in taking up the work to split drm-legacy.ko from drm.ko. The plan is to make it an optional module that legacy drivers depend on, in a way that you don't need to recompile drm.ko to use it.

I think the issue with the current CONFIG_DRM_VM, for instance, which hid some of the code for legacy drivers is the downside of requiring recompilation of drm.ko before using a legacy driver.

Anyway, if you agree with this change, can you keep this entry until that is done?

Signature · 5 lines
Gabriel Krisman Bertazi
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#16 lore raw

Re: [PATCH 05/16] drm: update todo.rst

Quoted 68 lines · Gabriel Krisman Bertazi
Quoted 51 lines · Daniel Vetter

Just drive-by, but we have gsoc running so better to update it now.

Great news is that two entries can be removed because essentially all done.

---
 Documentation/gpu/todo.rst | 51 ++++------------------------------------------
 1 file changed, 4 insertions(+), 47 deletions(-)
Documentation/gpu/todo.rst +1 -1
index 9ecd2ebb8dd8..7dc6de07a3bc 100644
@@ -16,7 +16,7 @@ De-midlayer drivers
 With the recent ``drm_bus`` cleanup patches for 3.17 it is no longer required
 to have a ``drm_bus`` structure set up. Drivers can directly set up the
 ``drm_device`` structure instead of relying on bus methods in ``drm_usb.c``
-and ``drm_platform.c``. The goal is to get rid of the driver's ``->load`` /
+and ``drm_pci.c``. The goal is to get rid of the driver's ``->load`` /
 ``->unload`` callbacks and open-code the load/unload sequence properly, using
 the new two-stage ``drm_device`` setup/teardown.
 
@@ -151,7 +151,7 @@ fine-grained per-buffer object and per-context

lockings scheme. Currently the
following drivers still use ``struct_mutex``: ``msm``, ``omapdrm`` and ``udl``.

Documentation/gpu/todo.rst +3 -6
-Contact: Daniel Vetter
+Contact: Daniel Vetter, respective driver maintainers
 
 Switch to drm_connector_list_iter for any connector_list walking
 ----------------------------------------------------------------
@@ -193,6 +193,8 @@ plan is to switch to per-file driver API headers, which will also structure
 the kerneldoc better. This should also allow more fine-grained ``#include``
 directives.
 
+In the end no .c file should need to include ``drmP.h`` anymore.
+
 Contact: Daniel Vetter
 
 Add missing kerneldoc for exported functions
@@ -208,31 +210,6 @@ See https://dri.freedesktop.org/docs/drm/ for what's there already.
 
 Contact: Daniel Vetter
 
-Hide legacy cruft better
-------------------------
-
-Way back DRM supported only drivers which shadow-attached to PCI devices with
-userspace or fbdev drivers setting up outputs. Modern DRM drivers take charge

Documentation/gpu/todo.rst See https://dri.freedesktop.org/docs/drm/ for what's there already. · line 225

Quoted 10 lines
Documentation/gpu/todo.rst +0 -10
-of the entire device, you can spot them with the DRIVER_MODESET flag.
-
-Unfortunately there's still large piles of legacy code around which needs to
-be hidden so that driver writers don't accidentally end up using it. And to
-prevent security issues in those legacy IOCTLs from being exploited on modern
-drivers. This has multiple possible subtasks:
-
-* Make sure legacy IOCTLs can't be used on modern drivers.
-* Extract support code for legacy features into a ``drm-legacy.ko`` kernel
-  module and compile it only when one of the legacy drivers is enabled.

I've been interested in taking up the work to split drm-legacy.ko from drm.ko. The plan is to make it an optional module that legacy drivers depend on, in a way that you don't need to recompile drm.ko to use it.

Quoted 6 lines

I think the issue with the current CONFIG_DRM_VM, for instance, which hid some of the code for legacy drivers is the downside of requiring recompilation of drm.ko before using a legacy driver.

Anyway, if you agree with this change, can you keep this entry until that is done?

Yeah if you're working on this already I can keep it. But you could keep working on this also even if there's no todo entry, we're not going to reject good ideas :-)

I'll resend with only the first sub-task removed, since that is done. -Daniel

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

PATCH 1/1 drm: update todo.rst

In reply to Daniel Vetter

Just drive-by, but we have gsoc running so better to update it now.

Great news is that two entries can be removed because essentially all done.

v2: Keep a bunch of the todos, Gabriel is working on them.

Cc Gabriel Krisman Bertazi <[email protected]>
---
 Documentation/gpu/todo.rst | 31 ++++---------------------------
 1 file changed, 4 insertions(+), 27 deletions(-)
Documentation/gpu/todo.rst +4 -27
index 0cdaddad2b9b..8f6943ccd834 100644
@@ -16,7 +16,7 @@ De-midlayer drivers
 With the recent ``drm_bus`` cleanup patches for 3.17 it is no longer required
 to have a ``drm_bus`` structure set up. Drivers can directly set up the
 ``drm_device`` structure instead of relying on bus methods in ``drm_usb.c``
-and ``drm_platform.c``. The goal is to get rid of the driver's ``->load`` /
+and ``drm_pci.c``. The goal is to get rid of the driver's ``->load`` /
 ``->unload`` callbacks and open-code the load/unload sequence properly, using
 the new two-stage ``drm_device`` setup/teardown.
 
@@ -151,7 +151,7 @@ fine-grained per-buffer object and per-context lockings scheme. Currently the
 following drivers still use ``struct_mutex``: ``msm``, ``omapdrm`` and
 ``udl``.
 
-Contact: Daniel Vetter
+Contact: Daniel Vetter, respective driver maintainers
 
 Switch to drm_connector_list_iter for any connector_list walking
 ----------------------------------------------------------------
@@ -193,6 +193,8 @@ plan is to switch to per-file driver API headers, which will also structure
 the kerneldoc better. This should also allow more fine-grained ``#include``
 directives.
 
+In the end no .c file should need to include ``drmP.h`` anymore.
+
 Contact: Daniel Vetter
 
 Add missing kerneldoc for exported functions
@@ -220,13 +222,8 @@ be hidden so that driver writers don't accidentally end up using it. And to
 prevent security issues in those legacy IOCTLs from being exploited on modern
 drivers. This has multiple possible subtasks:
 
-* Make sure legacy IOCTLs can't be used on modern drivers.
 * Extract support code for legacy features into a ``drm-legacy.ko`` kernel
   module and compile it only when one of the legacy drivers is enabled.
-* Extract legacy functions into their own headers and remove it that from the
-  monolithic ``drmP.h`` header.
-* Remove any lingering cruft from the OS abstraction layer from modern
-  drivers.
 
 This is mostly done, the only thing left is to split up ``drm_irq.c`` into
 legacy cruft and the parts needed by modern KMS drivers.
@@ -338,23 +335,3 @@ Driver Specific
 
 Outside DRM
 ===========
-
-Better kerneldoc
-----------------
-
-This is pretty much done, but there's some advanced topics:
-
-Come up with a way to hyperlink to struct members. Currently you can hyperlink
-to the struct using ``#struct_name``, but not to a member within. Would need
-buy-in from kerneldoc maintainers, and the big question is how to make it work
-without totally unsightly
-``drm_foo_bar_really_long_structure->even_longer_memeber`` all over the text
-which breaks text flow.
-
-Figure out how to integrate the asciidoc support for ascii-diagrams. We have a
-few of those (e.g. to describe mode timings), and asciidoc supports converting
-some ascii-art dialect into pngs. Would be really pretty to make that work.
-
-Contact: Daniel Vetter, Jani Nikula
-
-Jani is working on this already, hopefully lands in 4.8.
Signature · 6 lines
2.11.0

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

PATCH 6/16 drm: Consolidate and document sysfs support

In reply to Daniel Vetter

- remove docs for internal func, doesn't add value
- add short overview snippet instead explaining that drivers don't have to bother themselves with reg/unreg concerns
- drop the ttm comment about drmP.h, drmP.h is disappearing ...

---
 Documentation/gpu/drm-uapi.rst | 10 ++++++
 drivers/gpu/drm/drm_sysfs.c    | 70 ++++++++++++++++--------------------------
 include/drm/drmP.h             |  5 +--
 include/drm/drm_sysfs.h        |  8 ++---
 4 files changed, 42 insertions(+), 51 deletions(-)
Documentation/gpu/drm-uapi.rst +10 -0
index 76356c86e358..8b0f0e403f0c 100644
@@ -219,6 +219,16 @@ Debugfs Support
 .. kernel-doc:: drivers/gpu/drm/drm_debugfs.c
    :export:
 
+Sysfs Support
+=============
+
+.. kernel-doc:: drivers/gpu/drm/drm_sysfs.c
+   :doc: overview
+
+.. kernel-doc:: drivers/gpu/drm/drm_sysfs.c
+   :export:
+
+
 VBlank event handling
 =====================
 
drivers/gpu/drm/drm_sysfs.c +27 -43

108 lines not on this page · raw message

include/drm/drmP.h +1 -4
index 60f3255c43a8..fc2a0744413d 100644
@@ -79,6 +79,7 @@
 #include <drm/drm_pci.h>
 #include <drm/drm_file.h>
 #include <drm/drm_debugfs.h>
+#include <drm/drm_sysfs.h>
 
 struct module;
 
@@ -572,10 +573,6 @@ int drm_invalid_op(struct drm_device *dev, void *data,
  * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
  */
 
-			       /* sysfs support (drm_sysfs.c) */
-extern void drm_sysfs_hotplug_event(struct drm_device *dev);
-
-
 /*@}*/
 
 /* returns true if currently okay to sleep */
include/drm/drm_sysfs.h +4 -4
index 23418c1f10d1..70c9a1074aca 100644
@@ -1,12 +1,12 @@
 #ifndef _DRM_SYSFS_H_
 #define _DRM_SYSFS_H_
 
-/**
- * This minimalistic include file is intended for users (read TTM) that
- * don't want to include the full drmP.h file.
- */
+struct drm_device;
+struct device;
 
 int drm_class_device_register(struct device *dev);
 void drm_class_device_unregister(struct device *dev);
 
+void drm_sysfs_hotplug_event(struct drm_device *dev);
+
 #endif
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#19 lore raw

PATCH 7/16 drm: Extract drm_ioctl.h

In reply to Daniel Vetter

To match the drm_ioctl.c we already have.

---
 drivers/gpu/drm/drm_ioctl.c |   1 +
 include/drm/drmP.h          |  61 +-------------------------
 include/drm/drm_ioctl.h     | 102 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+), 60 deletions(-)
 create mode 100644 include/drm/drm_ioctl.h
drivers/gpu/drm/drm_ioctl.c +1 -0
index 601bb0ded9d2..7f4f4f48e390 100644
@@ -28,6 +28,7 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#include <drm/drm_ioctl.h>
 #include <drm/drmP.h>
 #include <drm/drm_auth.h>
 #include "drm_legacy.h"
include/drm/drmP.h +1 -60

79 lines not on this page · raw message

include/drm/drm_ioctl.h new file +102 -0

102 lines not on this page · raw message

Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 7/16
#20 lore raw

Re: [PATCH 07/16] drm: Extract drm_ioctl.h

Quoted 27 lines · Daniel Vetter

To match the drm_ioctl.c we already have.

---
 drivers/gpu/drm/drm_ioctl.c |   1 +
 include/drm/drmP.h          |  61 +-------------------------
 include/drm/drm_ioctl.h     | 102 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+), 60 deletions(-)
 create mode 100644 include/drm/drm_ioctl.h
drivers/gpu/drm/drm_ioctl.c +1 -0
index 601bb0ded9d2..7f4f4f48e390 100644
@@ -28,6 +28,7 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#include <drm/drm_ioctl.h>
 #include <drm/drmP.h>
 #include <drm/drm_auth.h>
 #include "drm_legacy.h"
include/drm/drmP.h +0 -0
index fc2a0744413d..248d2408e56b 100644

include/drm/drmP.h line 83

Quoted 4 lines
include/drm/drmP.h +1 -0
@@ -80,6 +80,7 @@
 #include <drm/drm_file.h>
 #include <drm/drm_debugfs.h>
 #include <drm/drm_sysfs.h>
+#include <drm/drm_ioctl.h>

Same question as for the debugfs thing. Why do we need this?

Quoted 130 lines
include/drm/drmP.h +0 -60
 struct module;
 
@@ -318,49 +319,6 @@ struct pci_controller;
 
 #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
 
-/**
- * Ioctl function type.
- *
- * \param inode device inode.
- * \param file_priv DRM file private pointer.
- * \param cmd command.
- * \param arg argument.
- */
-typedef int drm_ioctl_t(struct drm_device *dev, void *data,
-			struct drm_file *file_priv);
-
-typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
-			       unsigned long arg);
-
-#define DRM_IOCTL_NR(n)                _IOC_NR(n)
-#define DRM_MAJOR       226
-
-#define DRM_AUTH	0x1
-#define	DRM_MASTER	0x2
-#define DRM_ROOT_ONLY	0x4
-#define DRM_CONTROL_ALLOW 0x8
-#define DRM_UNLOCKED	0x10
-#define DRM_RENDER_ALLOW 0x20
-
-struct drm_ioctl_desc {
-	unsigned int cmd;
-	int flags;
-	drm_ioctl_t *func;
-	const char *name;
-};
-
-/**
- * Creates a driver or general drm_ioctl_desc array entry for the given
- * ioctl, for use by drm_ioctl().
- */
-
-#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags)				\
-	[DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = {	\
-		.cmd = DRM_IOCTL_##ioctl,				\
-		.func = _func,						\
-		.flags = _flags,					\
-		.name = #ioctl						\
-	 }
 
 /* Flags and return codes for get_vblank_timestamp() driver function. */
 #define DRM_CALLED_FROM_VBLIRQ 1
@@ -550,23 +508,6 @@ static inline int drm_device_is_unplugged(struct drm_device *dev)
 /*@{*/
 
 				/* Driver support (drm_drv.h) */
-extern int drm_ioctl_permit(u32 flags, struct drm_file *file_priv);
-extern long drm_ioctl(struct file *filp,
-		      unsigned int cmd, unsigned long arg);
-#ifdef CONFIG_COMPAT
-extern long drm_compat_ioctl(struct file *filp,
-			     unsigned int cmd, unsigned long arg);
-#else
-/* Let drm_compat_ioctl be assigned to .compat_ioctl unconditionally */
-#define drm_compat_ioctl NULL
-#endif
-extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);
-
-/* Misc. IOCTL support (drm_ioctl.c) */
-int drm_noop(struct drm_device *dev, void *data,
-	     struct drm_file *file_priv);
-int drm_invalid_op(struct drm_device *dev, void *data,
-		   struct drm_file *file_priv);
 
 /*
  * These are exported to drivers so that they can implement fencing using
include/drm/drm_ioctl.h new file +47 -0
new file mode 100644
index 000000000000..3c3677b5bdb2
@@ -0,0 +1,102 @@
+/*
+ * Internal Header for the Direct Rendering Manager
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * Copyright (c) 2009-2010, Code Aurora Forum.
+ * All rights reserved.
+ *
+ * Author: Rickard E. (Rik) Faith <[email protected]>
+ * Author: Gareth Hughes <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _DRM_IOCTL_H_
+#define _DRM_IOCTL_H_
+
+#include <linux/types.h>
+
+#include <asm/ioctl.h>
+
+struct drm_device;
+struct drm_file;
+struct file;
+
+/**
+ * Ioctl function type.
+ *
+ * \param inode device inode.
+ * \param file_priv DRM file private pointer.

include/drm/drm_ioctl.h line 57

Quoted 10 lines
include/drm/drm_ioctl.h new file +10 -0
+ * \param cmd command.
+ * \param arg argument.
+ */
+typedef int drm_ioctl_t(struct drm_device *dev, void *data,
+			struct drm_file *file_priv);
+
+typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
+			       unsigned long arg);
+
+#define DRM_IOCTL_NR(n)                _IOC_NR(n)

I wonder what's the point of this wrapper. Maybe leftovers from the out-of-tree days? Maybe nuke it while you're touching this stuff?

Quoted 7 lines
include/drm/drm_ioctl.h new file +7 -0
+#define DRM_MAJOR       226
+
+#define DRM_AUTH	0x1
+#define	DRM_MASTER	0x2
+#define DRM_ROOT_ONLY	0x4
+#define DRM_CONTROL_ALLOW 0x8
+#define DRM_UNLOCKED	0x10

include/drm/drm_ioctl.h line 74

Quoted 10 lines
include/drm/drm_ioctl.h new file +10 -0
+#define DRM_RENDER_ALLOW 0x20
+
+struct drm_ioctl_desc {
+	unsigned int cmd;
+	int flags;
+	drm_ioctl_t *func;
+	const char *name;
+};
+
+/**

s/**/*/ ?

include/drm/drm_ioctl.h line 85

Quoted 11 lines
include/drm/drm_ioctl.h new file +11 -0
+ * Creates a driver or general drm_ioctl_desc array entry for the given
+ * ioctl, for use by drm_ioctl().
+ */
+
+#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags)				\
+	[DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = {	\
+		.cmd = DRM_IOCTL_##ioctl,				\
+		.func = _func,						\
+		.flags = _flags,					\
+		.name = #ioctl						\
+	 }
        ^

Spurious space

Otherwise looks sane so

Quoted 24 lines
include/drm/drm_ioctl.h new file +17 -0
+
+int drm_ioctl_permit(u32 flags, struct drm_file *file_priv);
+long drm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
+#ifdef CONFIG_COMPAT
+long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
+#else
+/* Let drm_compat_ioctl be assigned to .compat_ioctl unconditionally */
+#define drm_compat_ioctl NULL
+#endif
+bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);
+
+int drm_noop(struct drm_device *dev, void *data,
+	     struct drm_file *file_priv);
+int drm_invalid_op(struct drm_device *dev, void *data,
+		   struct drm_file *file_priv);
+
+#endif /* _DRM_IOCTL_H_ */
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#21 lore raw

Re: [PATCH 07/16] drm: Extract drm_ioctl.h

Quoted 19 lines · Ville Syrjälä
Quoted 18 lines · Daniel Vetter

To match the drm_ioctl.c we already have.

---
 drivers/gpu/drm/drm_ioctl.c |   1 +
 include/drm/drmP.h          |  61 +-------------------------
 include/drm/drm_ioctl.h     | 102 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+), 60 deletions(-)
 create mode 100644 include/drm/drm_ioctl.h
drivers/gpu/drm/drm_ioctl.c +0 -0
index 601bb0ded9d2..7f4f4f48e390 100644
@@ -28,6 +28,7 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
Quoted 15 lines

include/drm/drmP.h line 83

Quoted 13 lines
drivers/gpu/drm/drm_ioctl.c +1 -0
+#include <drm/drm_ioctl.h>
 #include <drm/drmP.h>
 #include <drm/drm_auth.h>
 #include "drm_legacy.h"
include/drm/drmP.h +1 -0
index fc2a0744413d..248d2408e56b 100644
@@ -80,6 +80,7 @@
 #include <drm/drm_file.h>
 #include <drm/drm_debugfs.h>
 #include <drm/drm_sysfs.h>
+#include <drm/drm_ioctl.h>

Same question as for the debugfs thing. Why do we need this?

Try fixing up the drmP.h include hell, and you know that it'd take a few hundred patches. And right now it's impossible, because the most central structure (struct drm_device) is in here, so defacto we still have a monolithic header which needs everything.

First we need to split it completely, then all places that include drmP.h need to switch to individual headers (each time fixing up a pile of fallout), and then eventually (after fixing the few hundred places or so) we can remove all these include lines here (or well, get rid of drmP.h entirely). But not before. I tried.
-Daniel

Quoted 211 lines
Quoted 131 lines
include/drm/drmP.h +0 -60
 struct module;
 
@@ -318,49 +319,6 @@ struct pci_controller;
 
 #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
 
-/**
- * Ioctl function type.
- *
- * \param inode device inode.
- * \param file_priv DRM file private pointer.
- * \param cmd command.
- * \param arg argument.
- */
-typedef int drm_ioctl_t(struct drm_device *dev, void *data,
-			struct drm_file *file_priv);
-
-typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
-			       unsigned long arg);
-
-#define DRM_IOCTL_NR(n)                _IOC_NR(n)
-#define DRM_MAJOR       226
-
-#define DRM_AUTH	0x1
-#define	DRM_MASTER	0x2
-#define DRM_ROOT_ONLY	0x4
-#define DRM_CONTROL_ALLOW 0x8
-#define DRM_UNLOCKED	0x10
-#define DRM_RENDER_ALLOW 0x20
-
-struct drm_ioctl_desc {
-	unsigned int cmd;
-	int flags;
-	drm_ioctl_t *func;
-	const char *name;
-};
-
-/**
- * Creates a driver or general drm_ioctl_desc array entry for the given
- * ioctl, for use by drm_ioctl().
- */
-
-#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags)				\
-	[DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = {	\
-		.cmd = DRM_IOCTL_##ioctl,				\
-		.func = _func,						\
-		.flags = _flags,					\
-		.name = #ioctl						\
-	 }
 
 /* Flags and return codes for get_vblank_timestamp() driver function. */
 #define DRM_CALLED_FROM_VBLIRQ 1
@@ -550,23 +508,6 @@ static inline int drm_device_is_unplugged(struct drm_device *dev)
 /*@{*/
 
 				/* Driver support (drm_drv.h) */
-extern int drm_ioctl_permit(u32 flags, struct drm_file *file_priv);
-extern long drm_ioctl(struct file *filp,
-		      unsigned int cmd, unsigned long arg);
-#ifdef CONFIG_COMPAT
-extern long drm_compat_ioctl(struct file *filp,
-			     unsigned int cmd, unsigned long arg);
-#else
-/* Let drm_compat_ioctl be assigned to .compat_ioctl unconditionally */
-#define drm_compat_ioctl NULL
-#endif
-extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);
-
-/* Misc. IOCTL support (drm_ioctl.c) */
-int drm_noop(struct drm_device *dev, void *data,
-	     struct drm_file *file_priv);
-int drm_invalid_op(struct drm_device *dev, void *data,
-		   struct drm_file *file_priv);
 
 /*
  * These are exported to drivers so that they can implement fencing using
include/drm/drm_ioctl.h new file +47 -0
new file mode 100644
index 000000000000..3c3677b5bdb2
@@ -0,0 +1,102 @@
+/*
+ * Internal Header for the Direct Rendering Manager
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * Copyright (c) 2009-2010, Code Aurora Forum.
+ * All rights reserved.
+ *
+ * Author: Rickard E. (Rik) Faith <[email protected]>
+ * Author: Gareth Hughes <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _DRM_IOCTL_H_
+#define _DRM_IOCTL_H_
+
+#include <linux/types.h>
+
+#include <asm/ioctl.h>
+
+struct drm_device;
+struct drm_file;
+struct file;
+
+/**
+ * Ioctl function type.
+ *
+ * \param inode device inode.
+ * \param file_priv DRM file private pointer.

include/drm/drm_ioctl.h line 57

Quoted 10 lines
include/drm/drm_ioctl.h new file +10 -0
+ * \param cmd command.
+ * \param arg argument.
+ */
+typedef int drm_ioctl_t(struct drm_device *dev, void *data,
+			struct drm_file *file_priv);
+
+typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
+			       unsigned long arg);
+
+#define DRM_IOCTL_NR(n)                _IOC_NR(n)

I wonder what's the point of this wrapper. Maybe leftovers from the out-of-tree days? Maybe nuke it while you're touching this stuff?

Quoted 7 lines
include/drm/drm_ioctl.h new file +7 -0
+#define DRM_MAJOR       226
+
+#define DRM_AUTH	0x1
+#define	DRM_MASTER	0x2
+#define DRM_ROOT_ONLY	0x4
+#define DRM_CONTROL_ALLOW 0x8
+#define DRM_UNLOCKED	0x10

include/drm/drm_ioctl.h line 74

Quoted 10 lines
include/drm/drm_ioctl.h new file +10 -0
+#define DRM_RENDER_ALLOW 0x20
+
+struct drm_ioctl_desc {
+	unsigned int cmd;
+	int flags;
+	drm_ioctl_t *func;
+	const char *name;
+};
+
+/**

s/**/*/ ?

include/drm/drm_ioctl.h line 85

Quoted 11 lines
include/drm/drm_ioctl.h new file +11 -0
+ * Creates a driver or general drm_ioctl_desc array entry for the given
+ * ioctl, for use by drm_ioctl().
+ */
+
+#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags)				\
+	[DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = {	\
+		.cmd = DRM_IOCTL_##ioctl,				\
+		.func = _func,						\
+		.flags = _flags,					\
+		.name = #ioctl						\
+	 }
        ^

Spurious space

Otherwise looks sane so

Quoted 24 lines
include/drm/drm_ioctl.h new file +17 -0
+
+int drm_ioctl_permit(u32 flags, struct drm_file *file_priv);
+long drm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
+#ifdef CONFIG_COMPAT
+long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
+#else
+/* Let drm_compat_ioctl be assigned to .compat_ioctl unconditionally */
+#define drm_compat_ioctl NULL
+#endif
+bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);
+
+int drm_noop(struct drm_device *dev, void *data,
+	     struct drm_file *file_priv);
+int drm_invalid_op(struct drm_device *dev, void *data,
+		   struct drm_file *file_priv);
+
+#endif /* _DRM_IOCTL_H_ */
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä
Intel OTC
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#22 lore raw

Re: [Intel-gfx] [PATCH 07/16] drm: Extract drm_ioctl.h

Quoted 41 lines · Daniel Vetter
Quoted 19 lines · Ville Syrjälä
Quoted 18 lines · Daniel Vetter

To match the drm_ioctl.c we already have.

---
 drivers/gpu/drm/drm_ioctl.c |   1 +
 include/drm/drmP.h          |  61 +-------------------------
 include/drm/drm_ioctl.h     | 102 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+), 60 deletions(-)
 create mode 100644 include/drm/drm_ioctl.h
drivers/gpu/drm/drm_ioctl.c +0 -0
index 601bb0ded9d2..7f4f4f48e390 100644
@@ -28,6 +28,7 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
Quoted 15 lines

include/drm/drmP.h line 83

Quoted 13 lines
drivers/gpu/drm/drm_ioctl.c +1 -0
+#include <drm/drm_ioctl.h>
 #include <drm/drmP.h>
 #include <drm/drm_auth.h>
 #include "drm_legacy.h"
include/drm/drmP.h +1 -0
index fc2a0744413d..248d2408e56b 100644
@@ -80,6 +80,7 @@
 #include <drm/drm_file.h>
 #include <drm/drm_debugfs.h>
 #include <drm/drm_sysfs.h>
+#include <drm/drm_ioctl.h>

Same question as for the debugfs thing. Why do we need this?

Try fixing up the drmP.h include hell, and you know that it'd take a few hundred patches. And right now it's impossible, because the most central structure (struct drm_device) is in here, so defacto we still have a monolithic header which needs everything.

Quoted 5 lines

First we need to split it completely, then all places that include drmP.h need to switch to individual headers (each time fixing up a pile of fallout), and then eventually (after fixing the few hundred places or so) we can remove all these include lines here (or well, get rid of drmP.h entirely). But not before. I tried.

OK. I thought this stuff wouldn't have spread that far beyond the ioctl implementations, but I guess not.

Hmm. Had I spent any thought on this I would have realized that at least DRM_IOCTL_DEF_DRV() is used in pretty much every driver.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#23 lore raw

Re: [PATCH 07/16] drm: Extract drm_ioctl.h

In reply to Ville Syrjälä
Quoted 19 lines · Ville Syrjälä
Quoted 18 lines · Daniel Vetter

To match the drm_ioctl.c we already have.

---
 drivers/gpu/drm/drm_ioctl.c |   1 +
 include/drm/drmP.h          |  61 +-------------------------
 include/drm/drm_ioctl.h     | 102 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+), 60 deletions(-)
 create mode 100644 include/drm/drm_ioctl.h
drivers/gpu/drm/drm_ioctl.c +0 -0
index 601bb0ded9d2..7f4f4f48e390 100644
@@ -28,6 +28,7 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
Quoted 15 lines

include/drm/drmP.h line 83

Quoted 13 lines
drivers/gpu/drm/drm_ioctl.c +1 -0
+#include <drm/drm_ioctl.h>
 #include <drm/drmP.h>
 #include <drm/drm_auth.h>
 #include "drm_legacy.h"
include/drm/drmP.h +1 -0
index fc2a0744413d..248d2408e56b 100644
@@ -80,6 +80,7 @@
 #include <drm/drm_file.h>
 #include <drm/drm_debugfs.h>
 #include <drm/drm_sysfs.h>
+#include <drm/drm_ioctl.h>

Same question as for the debugfs thing. Why do we need this?

I forgot to scroll down, oops :(

Quoted 134 lines
Quoted 134 lines
include/drm/drmP.h +0 -60
 struct module;
 
@@ -318,49 +319,6 @@ struct pci_controller;
 
 #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
 
-/**
- * Ioctl function type.
- *
- * \param inode device inode.
- * \param file_priv DRM file private pointer.
- * \param cmd command.
- * \param arg argument.
- */
-typedef int drm_ioctl_t(struct drm_device *dev, void *data,
-			struct drm_file *file_priv);
-
-typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
-			       unsigned long arg);
-
-#define DRM_IOCTL_NR(n)                _IOC_NR(n)
-#define DRM_MAJOR       226
-
-#define DRM_AUTH	0x1
-#define	DRM_MASTER	0x2
-#define DRM_ROOT_ONLY	0x4
-#define DRM_CONTROL_ALLOW 0x8
-#define DRM_UNLOCKED	0x10
-#define DRM_RENDER_ALLOW 0x20
-
-struct drm_ioctl_desc {
-	unsigned int cmd;
-	int flags;
-	drm_ioctl_t *func;
-	const char *name;
-};
-
-/**
- * Creates a driver or general drm_ioctl_desc array entry for the given
- * ioctl, for use by drm_ioctl().
- */
-
-#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags)				\
-	[DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = {	\
-		.cmd = DRM_IOCTL_##ioctl,				\
-		.func = _func,						\
-		.flags = _flags,					\
-		.name = #ioctl						\
-	 }
 
 /* Flags and return codes for get_vblank_timestamp() driver function. */
 #define DRM_CALLED_FROM_VBLIRQ 1
@@ -550,23 +508,6 @@ static inline int drm_device_is_unplugged(struct drm_device *dev)
 /*@{*/
 
 				/* Driver support (drm_drv.h) */
-extern int drm_ioctl_permit(u32 flags, struct drm_file *file_priv);
-extern long drm_ioctl(struct file *filp,
-		      unsigned int cmd, unsigned long arg);
-#ifdef CONFIG_COMPAT
-extern long drm_compat_ioctl(struct file *filp,
-			     unsigned int cmd, unsigned long arg);
-#else
-/* Let drm_compat_ioctl be assigned to .compat_ioctl unconditionally */
-#define drm_compat_ioctl NULL
-#endif
-extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);
-
-/* Misc. IOCTL support (drm_ioctl.c) */
-int drm_noop(struct drm_device *dev, void *data,
-	     struct drm_file *file_priv);
-int drm_invalid_op(struct drm_device *dev, void *data,
-		   struct drm_file *file_priv);
 
 /*
  * These are exported to drivers so that they can implement fencing using
include/drm/drm_ioctl.h new file +52 -0
new file mode 100644
index 000000000000..3c3677b5bdb2
@@ -0,0 +1,102 @@
+/*
+ * Internal Header for the Direct Rendering Manager
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * Copyright (c) 2009-2010, Code Aurora Forum.
+ * All rights reserved.
+ *
+ * Author: Rickard E. (Rik) Faith <[email protected]>
+ * Author: Gareth Hughes <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _DRM_IOCTL_H_
+#define _DRM_IOCTL_H_
+
+#include <linux/types.h>
+
+#include <asm/ioctl.h>
+
+struct drm_device;
+struct drm_file;
+struct file;
+
+/**
+ * Ioctl function type.
+ *
+ * \param inode device inode.
+ * \param file_priv DRM file private pointer.
+ * \param cmd command.
+ * \param arg argument.
+ */
+typedef int drm_ioctl_t(struct drm_device *dev, void *data,
+			struct drm_file *file_priv);
Quoted 8 lines

include/drm/drm_ioctl.h line 57

Quoted 5 lines
include/drm/drm_ioctl.h new file +5 -0
+
+typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
+			       unsigned long arg);
+
+#define DRM_IOCTL_NR(n)                _IOC_NR(n)

I wonder what's the point of this wrapper. Maybe leftovers from the out-of-tree days? Maybe nuke it while you're touching this stuff?

It's used in a lot of places (all the 32 bit compat code). I guess we could nuke it (it does smell like *bsd compat cruft), but separate (big) patch.

Quoted 11 lines
Quoted 11 lines
include/drm/drm_ioctl.h new file +11 -0
+#define DRM_MAJOR       226
+
+#define DRM_AUTH	0x1
+#define	DRM_MASTER	0x2
+#define DRM_ROOT_ONLY	0x4
+#define DRM_CONTROL_ALLOW 0x8
+#define DRM_UNLOCKED	0x10
+#define DRM_RENDER_ALLOW 0x20
+
+struct drm_ioctl_desc {
+	unsigned int cmd;
Quoted 8 lines

include/drm/drm_ioctl.h line 74

Quoted 6 lines
include/drm/drm_ioctl.h new file +6 -0
+	int flags;
+	drm_ioctl_t *func;
+	const char *name;
+};
+
+/**

s/**/*/ ?

It'll get addressed in the next patch, where I clean up the kernel-doc. I assume I can still get your r-b for this patch here?

Quoted 13 lines

include/drm/drm_ioctl.h line 85

Quoted 11 lines
include/drm/drm_ioctl.h new file +11 -0
+ * Creates a driver or general drm_ioctl_desc array entry for the given
+ * ioctl, for use by drm_ioctl().
+ */
+
+#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags)				\
+	[DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = {	\
+		.cmd = DRM_IOCTL_##ioctl,				\
+		.func = _func,						\
+		.flags = _flags,					\
+		.name = #ioctl						\
+	 }
        ^
Quoted 1 line

Spurious space

Will fix, thx a lot for reviewing.
-Daniel

Quoted 32 lines

Otherwise looks sane so

Quoted 24 lines
include/drm/drm_ioctl.h new file +17 -0
+
+int drm_ioctl_permit(u32 flags, struct drm_file *file_priv);
+long drm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
+#ifdef CONFIG_COMPAT
+long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
+#else
+/* Let drm_compat_ioctl be assigned to .compat_ioctl unconditionally */
+#define drm_compat_ioctl NULL
+#endif
+bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);
+
+int drm_noop(struct drm_device *dev, void *data,
+	     struct drm_file *file_priv);
+int drm_invalid_op(struct drm_device *dev, void *data,
+		   struct drm_file *file_priv);
+
+#endif /* _DRM_IOCTL_H_ */
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä
Intel OTC
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#24 lore raw

Re: [PATCH 07/16] drm: Extract drm_ioctl.h

Quoted 16 lines · Daniel Vetter
Quoted 15 lines · Ville Syrjälä
Quoted 14 lines · Daniel Vetter

To match the drm_ioctl.c we already have.

---
 drivers/gpu/drm/drm_ioctl.c |   1 +
 include/drm/drmP.h          |  61 +-------------------------
 include/drm/drm_ioctl.h     | 102 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+), 60 deletions(-)
 create mode 100644 include/drm/drm_ioctl.h
drivers/gpu/drm/drm_ioctl.c +0 -0
index 601bb0ded9d2..7f4f4f48e390 100644

<snip>

Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/drm_ioctl.c +11 -0
+#define DRM_MAJOR       226
+
+#define DRM_AUTH	0x1
+#define	DRM_MASTER	0x2
+#define DRM_ROOT_ONLY	0x4
+#define DRM_CONTROL_ALLOW 0x8
+#define DRM_UNLOCKED	0x10
+#define DRM_RENDER_ALLOW 0x20
+
+struct drm_ioctl_desc {
+	unsigned int cmd;
Quoted 8 lines

drivers/gpu/drm/drm_ioctl.c

Quoted 6 lines
drivers/gpu/drm/drm_ioctl.c +6 -0
+	int flags;
+	drm_ioctl_t *func;
+	const char *name;
+};
+
+/**

s/**/*/ ?

Quoted 2 lines

It'll get addressed in the next patch, where I clean up the kernel-doc. I assume I can still get your r-b for this patch here?

Sure thing.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#25 lore raw

PATCH 1/1 drm: Extract drm_ioctl.h

In reply to Daniel Vetter

To match the drm_ioctl.c we already have.

v2: Remove spurious space (Ville).

---
 drivers/gpu/drm/drm_ioctl.c |   1 +
 include/drm/drmP.h          |  61 +-------------------------
 include/drm/drm_ioctl.h     | 102 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+), 60 deletions(-)
 create mode 100644 include/drm/drm_ioctl.h
drivers/gpu/drm/drm_ioctl.c +1 -0
index 601bb0ded9d2..7f4f4f48e390 100644
@@ -28,6 +28,7 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#include <drm/drm_ioctl.h>
 #include <drm/drmP.h>
 #include <drm/drm_auth.h>
 #include "drm_legacy.h"
include/drm/drmP.h +1 -60

79 lines not on this page · raw message

include/drm/drm_ioctl.h new file +102 -0

102 lines not on this page · raw message

Signature · 6 lines
2.11.0

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

PATCH 8/16 drm: document drm_ioctl.[hc]

In reply to Daniel Vetter

Also unify/merge with the existing stuff.

I was a bit torn where to put this, but in the end I decided to put all the ioctl/sysfs/debugfs stuff into drm-uapi.rst. That means we have a bit a split with the other uapi related stuff used internally, like drm_file.[hc], but I think overall this makes more sense.

If it's too confusing we can always add more cross-links to make it more discoverable. But the auto-sprinkling of links kernel-doc already does seems sufficient.

Also for prettier docs and more cross-links, switch the internal defines over to an enum, as usual.

---
 Documentation/gpu/drm-internals.rst |  50 ----------------
 Documentation/gpu/drm-uapi.rst      |  14 +++++
 drivers/gpu/drm/drm_ioc32.c         |   1 -
 drivers/gpu/drm/drm_ioctl.c         |  45 ++++++++++++++
 include/drm/drm_ioctl.h             | 116 +++++++++++++++++++++++++++++++-----
 5 files changed, 160 insertions(+), 66 deletions(-)
Documentation/gpu/drm-internals.rst +0 -50
index a09c721f9e89..babfb6143bd9 100644
@@ -255,56 +255,6 @@ File Operations
 .. kernel-doc:: drivers/gpu/drm/drm_file.c
    :export:
 
-IOCTLs
-------
-
-struct drm_ioctl_desc \*ioctls; int num_ioctls;
-    Driver-specific ioctls descriptors table.
-
-Driver-specific ioctls numbers start at DRM_COMMAND_BASE. The ioctls
-descriptors table is indexed by the ioctl number offset from the base
-value. Drivers can use the DRM_IOCTL_DEF_DRV() macro to initialize
-the table entries.
-
-::
-
-    DRM_IOCTL_DEF_DRV(ioctl, func, flags)
-
-``ioctl`` is the ioctl name. Drivers must define the DRM_##ioctl and
-DRM_IOCTL_##ioctl macros to the ioctl number offset from
-DRM_COMMAND_BASE and the ioctl number respectively. The first macro is
-private to the device while the second must be exposed to userspace in a
-public header.
-
-``func`` is a pointer to the ioctl handler function compatible with the
-``drm_ioctl_t`` type.
-
-::
-
-    typedef int drm_ioctl_t(struct drm_device *dev, void *data,
-            struct drm_file *file_priv);
-
-``flags`` is a bitmask combination of the following values. It restricts
-how the ioctl is allowed to be called.
-
--  DRM_AUTH - Only authenticated callers allowed
-
--  DRM_MASTER - The ioctl can only be called on the master file handle
-
--  DRM_ROOT_ONLY - Only callers with the SYSADMIN capability allowed
-
--  DRM_CONTROL_ALLOW - The ioctl can only be called on a control
-   device
-
--  DRM_UNLOCKED - The ioctl handler will be called without locking the
-   DRM global mutex. This is the enforced default for kms drivers (i.e.
-   using the DRIVER_MODESET flag) and hence shouldn't be used any more
-   for new drivers.
-
-.. kernel-doc:: drivers/gpu/drm/drm_ioctl.c
-   :export:
-
-
 Misc Utilities
 ==============
 
Documentation/gpu/drm-uapi.rst +14 -0
index 8b0f0e403f0c..858457567d3d 100644
@@ -160,6 +160,20 @@ other hand, a driver requires shared state between clients which is
 visible to user-space and accessible beyond open-file boundaries, they
 cannot support render nodes.
 
+IOCTL Support on Device Nodes
+=============================
+
+.. kernel-doc:: drivers/gpu/drm/drm_ioctl.c
+   :doc: driver specific ioctls
+
+.. kernel-doc:: include/drm/drm_ioctl.h
+   :internal:
+
+.. kernel-doc:: drivers/gpu/drm/drm_ioctl.c
+   :export:
+
+.. kernel-doc:: drivers/gpu/drm/drm_ioc32.c
+   :export:
 
 Testing and validation
 ======================
drivers/gpu/drm/drm_ioc32.c +0 -1
index b134482f4022..aeca0214caa8 100644
@@ -1141,5 +1141,4 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 
 	return ret;
 }
-
 EXPORT_SYMBOL(drm_compat_ioctl);
drivers/gpu/drm/drm_ioctl.c +45 -0

51 lines not on this page · raw message

include/drm/drm_ioctl.h +101 -15

148 lines not on this page · raw message

Signature · 6 lines
2.11.0

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

Re: [PATCH 08/16] drm: document drm_ioctl.[hc]

All warnings (new ones prefixed by >>):

Hi Daniel,

[auto build test WARNING on drm/drm-next]
[cannot apply to v4.11-rc3 next-20170324]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Daniel-Vetter/more-drmP-h-cleanup/20170325-030940
base:   git://people.freedesktop.org/~airlied/linux.git drm-next
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

WARNING: convert(1) not found, for SVG to PDF conversion install ImageMagick (https://www.imagemagick.org)
include/linux/init.h:1: warning: no structured comments found
kernel/sched/core.c:2085: warning: No description found for parameter 'rf' kernel/sched/core.c:2085: warning: Excess function parameter 'cookie' description in 'try_to_wake_up_local' include/linux/kthread.h:26: warning: Excess function parameter '...' description in 'kthread_create' kernel/sys.c:1: warning: no structured comments found
include/linux/device.h:969: warning: No description found for parameter 'dma_ops' drivers/dma-buf/seqno-fence.c:1: warning: no structured comments found include/linux/iio/iio.h:597: warning: No description found for parameter 'trig_readonly' include/linux/iio/trigger.h:151: warning: No description found for parameter 'indio_dev' include/linux/iio/trigger.h:151: warning: No description found for parameter 'trig' include/linux/device.h:970: warning: No description found for parameter 'dma_ops' drivers/regulator/core.c:1467: warning: Excess function parameter 'ret' description in 'regulator_dev_lookup' include/drm/drm_drv.h:524: warning: No description found for parameter 'set_busid' include/drm/drm_drv.h:524: warning: No description found for parameter 'irq_handler' include/drm/drm_drv.h:524: warning: No description found for parameter 'irq_preinstall' include/drm/drm_drv.h:524: warning: No description found for parameter 'irq_postinstall' include/drm/drm_drv.h:524: warning: No description found for parameter 'irq_uninstall' include/drm/drm_drv.h:524: warning: No description found for parameter 'debugfs_init' include/drm/drm_drv.h:524: warning: No description found for parameter 'gem_open_object' include/drm/drm_drv.h:524: warning: No description found for parameter 'gem_close_object' include/drm/drm_drv.h:524: warning: No description found for parameter 'prime_handle_to_fd' include/drm/drm_drv.h:524: warning: No description found for parameter 'prime_fd_to_handle' include/drm/drm_drv.h:524: warning: No description found for parameter 'gem_prime_export' include/drm/drm_drv.h:524: warning: No description found for parameter 'gem_prime_import' include/drm/drm_drv.h:524: warning: No description found for parameter 'gem_prime_pin' include/drm/drm_drv.h:524: warning: No description found for parameter 'gem_prime_unpin' include/drm/drm_drv.h:524: warning: No description found for parameter 'gem_prime_res_obj' include/drm/drm_drv.h:524: warning: No description found for parameter 'gem_prime_get_sg_table' include/drm/drm_drv.h:524: warning: No description found for parameter 'gem_prime_import_sg_table' include/drm/drm_drv.h:524: warning: No description found for parameter 'gem_prime_vmap' include/drm/drm_drv.h:524: warning: No description found for parameter 'gem_prime_vunmap' include/drm/drm_drv.h:524: warning: No description found for parameter 'gem_prime_mmap' include/drm/drm_drv.h:524: warning: No description found for parameter 'gem_vm_ops' include/drm/drm_drv.h:524: warning: No description found for parameter 'major' include/drm/drm_drv.h:524: warning: No description found for parameter 'minor' include/drm/drm_drv.h:524: warning: No description found for parameter 'patchlevel' include/drm/drm_drv.h:524: warning: No description found for parameter 'name' include/drm/drm_drv.h:524: warning: No description found for parameter 'desc' include/drm/drm_drv.h:524: warning: No description found for parameter 'date' include/drm/drm_drv.h:524: warning: No description found for parameter 'driver_features' include/drm/drm_drv.h:524: warning: No description found for parameter 'ioctls' include/drm/drm_drv.h:524: warning: No description found for parameter 'num_ioctls' include/drm/drm_drv.h:524: warning: No description found for parameter 'fops' include/drm/drm_connector.h:138: warning: No description found for parameter 'scdc' include/drm/drm_color_mgmt.h:1: warning: no structured comments found drivers/gpu/drm/drm_ioc32.c:3: warning: Cannot understand * \file drm_ioc32.c
on line 3 - I thought it was a doc line

>> drivers/gpu/drm/drm_ioc32.c:1124: warning: No description found for parameter 'filp'
>> drivers/gpu/drm/drm_ioc32.c:1124: warning: No description found for parameter 'cmd'
>> drivers/gpu/drm/drm_ioc32.c:1124: warning: No description found for parameter 'arg'

drivers/gpu/drm/i915/intel_lpe_audio.c:342: warning: No description found for parameter 'pipe' drivers/gpu/drm/i915/intel_lpe_audio.c:342: warning: No description found for parameter 'dp_output' drivers/gpu/drm/i915/intel_lpe_audio.c:342: warning: No description found for parameter 'link_rate' drivers/gpu/drm/i915/intel_lpe_audio.c:343: warning: No description found for parameter 'pipe' drivers/gpu/drm/i915/intel_lpe_audio.c:343: warning: No description found for parameter 'dp_output' drivers/gpu/drm/i915/intel_lpe_audio.c:343: warning: No description found for parameter 'link_rate' drivers/media/dvb-core/dvb_frontend.h:677: warning: No description found for parameter 'refcount' Documentation/core-api/assoc_array.rst:13: WARNING: Enumerated list ends without a blank line; unexpected unindent. Documentation/doc-guide/sphinx.rst:126: ERROR: Unknown target name: "sphinx c domain".
kernel/sched/fair.c:7616: WARNING: Inline emphasis start-string without end-string.
kernel/time/timer.c:1200: ERROR: Unexpected indentation.
kernel/time/timer.c:1202: ERROR: Unexpected indentation.
kernel/time/timer.c:1203: WARNING: Block quote ends without a blank line; unexpected unindent.
include/linux/wait.h:122: WARNING: Block quote ends without a blank line; unexpected unindent.
include/linux/wait.h:125: ERROR: Unexpected indentation.
include/linux/wait.h:127: WARNING: Block quote ends without a blank line; unexpected unindent.
kernel/time/hrtimer.c:990: WARNING: Block quote ends without a blank line; unexpected unindent.
kernel/signal.c:322: WARNING: Inline literal start-string without end-string.
include/linux/iio/iio.h:219: ERROR: Unexpected indentation.
include/linux/iio/iio.h:220: WARNING: Block quote ends without a blank line; unexpected unindent.
include/linux/iio/iio.h:226: WARNING: Definition list ends without a blank line; unexpected unindent. drivers/iio/industrialio-core.c:639: ERROR: Unknown target name: "iio_val".
drivers/iio/industrialio-core.c:646: ERROR: Unknown target name: "iio_val".
drivers/message/fusion/mptbase.c:5051: WARNING: Definition list ends without a blank line; unexpected unindent. drivers/tty/serial/serial_core.c:1898: WARNING: Definition list ends without a blank line; unexpected unindent. include/linux/regulator/driver.h:271: ERROR: Unknown target name: "regulator_regmap_x_voltage".
include/linux/spi/spi.h:369: ERROR: Unexpected indentation.
drivers/usb/core/message.c:478: ERROR: Unexpected indentation.
drivers/usb/core/message.c:479: WARNING: Block quote ends without a blank line; unexpected unindent. Documentation/driver-api/usb.rst:623: ERROR: Unknown target name: "usb_type".
Documentation/driver-api/usb.rst:623: ERROR: Unknown target name: "usb_dir".
Documentation/driver-api/usb.rst:623: ERROR: Unknown target name: "usb_recip".
Documentation/driver-api/usb.rst:689: ERROR: Unknown target name: "usbdevfs_urb_type".
drivers/gpu/drm/drm_scdc_helper.c:203: ERROR: Unexpected indentation.
drivers/gpu/drm/drm_scdc_helper.c:204: WARNING: Block quote ends without a blank line; unexpected unindent. drivers/gpu/drm/drm_ioctl.c:687: WARNING: Definition list ends without a blank line; unexpected unindent. sound/soc/soc-core.c:2670: ERROR: Unknown target name: "snd_soc_daifmt".
sound/core/jack.c:312: ERROR: Unknown target name: "snd_jack_btn".
Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 43: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 56: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 69: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 82: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 96: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 109: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 122: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 133: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 164: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 193: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 43: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 56: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 69: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 82: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 96: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 109: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 122: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 133: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 164: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 193: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 43: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 56: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 69: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 82: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 96: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 109: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 122: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 133: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 164: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 193: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 43: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 56: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 69: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 82: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 96: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 109: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 122: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 133: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 164: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 193: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 43: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 56: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 69: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 82: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 96: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 109: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 122: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 133: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 164: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 193: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 43: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 56: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 69: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 82: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 96: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 109: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 122: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 133: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 164: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 193: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 43: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 56: Having multiple values in <test> isn't supported and may not work as expected

vim +3 drivers/gpu/drm/drm_ioc32.c

9a186645 drivers/char/drm/drm_ioc32.c Dave Airlie 2005-06-23 1 /**

9a186645 drivers/char/drm/drm_ioc32.c Dave Airlie 2005-06-23   2   * \file drm_ioc32.c
9a186645 drivers/char/drm/drm_ioc32.c Dave Airlie 2005-06-23  @3   *
9a186645 drivers/char/drm/drm_ioc32.c Dave Airlie 2005-06-23   4   * 32-bit ioctl compatibility routines for the DRM.
9a186645 drivers/char/drm/drm_ioc32.c Dave Airlie 2005-06-23   5   *
9a186645 drivers/char/drm/drm_ioc32.c Dave Airlie 2005-06-23   6   * \author Paul Mackerras <[email protected]>
9a186645 drivers/char/drm/drm_ioc32.c Dave Airlie 2005-06-23   7   *
9a186645 drivers/char/drm/drm_ioc32.c Dave Airlie 2005-06-23   8   * Copyright (C) Paul Mackerras 2005.
9a186645 drivers/char/drm/drm_ioc32.c Dave Airlie 2005-06-23   9   * All Rights Reserved.
9a186645 drivers/char/drm/drm_ioc32.c Dave Airlie 2005-06-23  10   *
9a186645 drivers/char/drm/drm_ioc32.c Dave Airlie 2005-06-23  11   * Permission is hereby granted, free of charge, to any person obtaining a

:::::: The code at line 3 was first introduced by commit
:::::: 9a18664506dbce5e23f3c5de7b1c5a042dd26520 drm: 32/64-bit DRM ioctl compatibility patch

:::::: TO: Dave Airlie <airlied@starflyer.(none)>
:::::: CC: Dave Airlie <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#28 lore raw

PATCH 1/1 drm: document drm_ioctl.[hc]

In reply to Daniel Vetter

Also unify/merge with the existing stuff.

I was a bit torn where to put this, but in the end I decided to put all the ioctl/sysfs/debugfs stuff into drm-uapi.rst. That means we have a bit a split with the other uapi related stuff used internally, like drm_file.[hc], but I think overall this makes more sense.

If it's too confusing we can always add more cross-links to make it more discoverable. But the auto-sprinkling of links kernel-doc already does seems sufficient.

Also for prettier docs and more cross-links, switch the internal defines over to an enum, as usual.

v2: Update kerneldoc fro drm_compat_ioctl too (caught by 0day), plus a bit more drive-by polish.

---
 Documentation/gpu/drm-internals.rst |  50 ----------------
 Documentation/gpu/drm-uapi.rst      |  14 +++++
 drivers/gpu/drm/drm_ioc32.c         |  76 ++++++++++++-----------
 drivers/gpu/drm/drm_ioctl.c         |  50 +++++++++++++++-
 include/drm/drm_ioctl.h             | 116 +++++++++++++++++++++++++++++++-----
 5 files changed, 203 insertions(+), 103 deletions(-)
Documentation/gpu/drm-internals.rst +0 -50
index a09c721f9e89..babfb6143bd9 100644
@@ -255,56 +255,6 @@ File Operations
 .. kernel-doc:: drivers/gpu/drm/drm_file.c
    :export:
 
-IOCTLs
-------
-
-struct drm_ioctl_desc \*ioctls; int num_ioctls;
-    Driver-specific ioctls descriptors table.
-
-Driver-specific ioctls numbers start at DRM_COMMAND_BASE. The ioctls
-descriptors table is indexed by the ioctl number offset from the base
-value. Drivers can use the DRM_IOCTL_DEF_DRV() macro to initialize
-the table entries.
-
-::
-
-    DRM_IOCTL_DEF_DRV(ioctl, func, flags)
-
-``ioctl`` is the ioctl name. Drivers must define the DRM_##ioctl and
-DRM_IOCTL_##ioctl macros to the ioctl number offset from
-DRM_COMMAND_BASE and the ioctl number respectively. The first macro is
-private to the device while the second must be exposed to userspace in a
-public header.
-
-``func`` is a pointer to the ioctl handler function compatible with the
-``drm_ioctl_t`` type.
-
-::
-
-    typedef int drm_ioctl_t(struct drm_device *dev, void *data,
-            struct drm_file *file_priv);
-
-``flags`` is a bitmask combination of the following values. It restricts
-how the ioctl is allowed to be called.
-
--  DRM_AUTH - Only authenticated callers allowed
-
--  DRM_MASTER - The ioctl can only be called on the master file handle
-
--  DRM_ROOT_ONLY - Only callers with the SYSADMIN capability allowed
-
--  DRM_CONTROL_ALLOW - The ioctl can only be called on a control
-   device
-
--  DRM_UNLOCKED - The ioctl handler will be called without locking the
-   DRM global mutex. This is the enforced default for kms drivers (i.e.
-   using the DRIVER_MODESET flag) and hence shouldn't be used any more
-   for new drivers.
-
-.. kernel-doc:: drivers/gpu/drm/drm_ioctl.c
-   :export:
-
-
 Misc Utilities
 ==============
 
Documentation/gpu/drm-uapi.rst +14 -0
index 8b0f0e403f0c..858457567d3d 100644
@@ -160,6 +160,20 @@ other hand, a driver requires shared state between clients which is
 visible to user-space and accessible beyond open-file boundaries, they
 cannot support render nodes.
 
+IOCTL Support on Device Nodes
+=============================
+
+.. kernel-doc:: drivers/gpu/drm/drm_ioctl.c
+   :doc: driver specific ioctls
+
+.. kernel-doc:: include/drm/drm_ioctl.h
+   :internal:
+
+.. kernel-doc:: drivers/gpu/drm/drm_ioctl.c
+   :export:
+
+.. kernel-doc:: drivers/gpu/drm/drm_ioc32.c
+   :export:
 
 Testing and validation
 ======================
drivers/gpu/drm/drm_ioc32.c +40 -36

121 lines not on this page · raw message

drivers/gpu/drm/drm_ioctl.c +48 -2

61 lines not on this page · raw message

include/drm/drm_ioctl.h +101 -15

148 lines not on this page · raw message

Signature · 6 lines
2.11.0

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

PATCH 1/1 drm: document drm_ioctl.[hc]

Also unify/merge with the existing stuff.

I was a bit torn where to put this, but in the end I decided to put all the ioctl/sysfs/debugfs stuff into drm-uapi.rst. That means we have a bit a split with the other uapi related stuff used internally, like drm_file.[hc], but I think overall this makes more sense.

If it's too confusing we can always add more cross-links to make it more discoverable. But the auto-sprinkling of links kernel-doc already does seems sufficient.

Also for prettier docs and more cross-links, switch the internal defines over to an enum, as usual.

v2: Update kerneldoc fro drm_compat_ioctl too (caught by 0day), plus a bit more drive-by polish.

v3: Fix typo, spotted by xerpi on irc (Sergi).

---
 Documentation/gpu/drm-internals.rst |  50 ----------------
 Documentation/gpu/drm-uapi.rst      |  14 +++++
 drivers/gpu/drm/drm_ioc32.c         |  76 ++++++++++++-----------
 drivers/gpu/drm/drm_ioctl.c         |  50 +++++++++++++++-
 include/drm/drm_ioctl.h             | 116 +++++++++++++++++++++++++++++++-----
 5 files changed, 203 insertions(+), 103 deletions(-)
Documentation/gpu/drm-internals.rst +0 -50
index a09c721f9e89..babfb6143bd9 100644
@@ -255,56 +255,6 @@ File Operations
 .. kernel-doc:: drivers/gpu/drm/drm_file.c
    :export:
 
-IOCTLs
-------
-
-struct drm_ioctl_desc \*ioctls; int num_ioctls;
-    Driver-specific ioctls descriptors table.
-
-Driver-specific ioctls numbers start at DRM_COMMAND_BASE. The ioctls
-descriptors table is indexed by the ioctl number offset from the base
-value. Drivers can use the DRM_IOCTL_DEF_DRV() macro to initialize
-the table entries.
-
-::
-
-    DRM_IOCTL_DEF_DRV(ioctl, func, flags)
-
-``ioctl`` is the ioctl name. Drivers must define the DRM_##ioctl and
-DRM_IOCTL_##ioctl macros to the ioctl number offset from
-DRM_COMMAND_BASE and the ioctl number respectively. The first macro is
-private to the device while the second must be exposed to userspace in a
-public header.
-
-``func`` is a pointer to the ioctl handler function compatible with the
-``drm_ioctl_t`` type.
-
-::
-
-    typedef int drm_ioctl_t(struct drm_device *dev, void *data,
-            struct drm_file *file_priv);
-
-``flags`` is a bitmask combination of the following values. It restricts
-how the ioctl is allowed to be called.
-
--  DRM_AUTH - Only authenticated callers allowed
-
--  DRM_MASTER - The ioctl can only be called on the master file handle
-
--  DRM_ROOT_ONLY - Only callers with the SYSADMIN capability allowed
-
--  DRM_CONTROL_ALLOW - The ioctl can only be called on a control
-   device
-
--  DRM_UNLOCKED - The ioctl handler will be called without locking the
-   DRM global mutex. This is the enforced default for kms drivers (i.e.
-   using the DRIVER_MODESET flag) and hence shouldn't be used any more
-   for new drivers.
-
-.. kernel-doc:: drivers/gpu/drm/drm_ioctl.c
-   :export:
-
-
 Misc Utilities
 ==============
 
Documentation/gpu/drm-uapi.rst +14 -0
index 8b0f0e403f0c..858457567d3d 100644
@@ -160,6 +160,20 @@ other hand, a driver requires shared state between clients which is
 visible to user-space and accessible beyond open-file boundaries, they
 cannot support render nodes.
 
+IOCTL Support on Device Nodes
+=============================
+
+.. kernel-doc:: drivers/gpu/drm/drm_ioctl.c
+   :doc: driver specific ioctls
+
+.. kernel-doc:: include/drm/drm_ioctl.h
+   :internal:
+
+.. kernel-doc:: drivers/gpu/drm/drm_ioctl.c
+   :export:
+
+.. kernel-doc:: drivers/gpu/drm/drm_ioc32.c
+   :export:
 
 Testing and validation
 ======================
drivers/gpu/drm/drm_ioc32.c +40 -36

121 lines not on this page · raw message

drivers/gpu/drm/drm_ioctl.c +48 -2

61 lines not on this page · raw message

include/drm/drm_ioctl.h +101 -15

148 lines not on this page · raw message

Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#30 lore raw

PATCH 9/16 drm/todo: Add tinydrm refactoring ideas

In reply to Daniel Vetter

Discussed with Noralf on the list a bit.

An open question is tinydrm vs. drm_panel, but until we have a clear idea what's really needed in that space, I think it's best to just move forward with what we have.

Cc Noralf Trønnes <[email protected]>
---
 Documentation/gpu/todo.rst | 70 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)
Documentation/gpu/todo.rst +70 -0
index 7dc6de07a3bc..479bb040f6d4 100644
@@ -99,6 +99,30 @@ events for atomic commits correctly. But fixing these bugs is good anyway.
 
 Contact: Daniel Vetter, respective driver maintainers
 
+Better manual-upload support for atomic
+---------------------------------------
+
+This would be especially useful for tinydrm:
+
+- Add a struct drm_rect dirty_clip to drm_crtc_state. When duplicating the
+  crtc state, clear that to the max values, x/y = 0 and w/h = MAX_INT, in
+  __drm_atomic_helper_crtc_duplicate_state().
+
+- Move tinydrm_merge_clips into drm_framebuffer.c, dropping the tinydrm_
+  prefix ofc and using drm_fb_. drm_framebuffer.c makes sense since this
+  is a function useful to implement the fb->dirty function.
+
+- Create a new drm_fb_dirty function which does essentially what e.g.
+  mipi_dbi_fb_dirty does. You can use e.g. drm_atomic_helper_update_plane as the
+  template. But instead of doing a simple full-screen plane update, this new
+  helper also sets crtc_state->dirty_clip to the right coordinates. And of
+  course it needs to check whether the fb is actually active (and maybe where),
+  so there's some book-keeping involved. There's also some good fun involved in
+  scaling things appropriately. For that case we might simply give up and
+  declare the entire area covered by the plane as dirty.
+
+Contact: Noralf Trønnes, Daniel Vetter
+
 Fallout from atomic KMS
 -----------------------
 
@@ -313,5 +337,51 @@ Contact: Daniel Vetter
 Driver Specific
 ===============
 
+tinydrm
+-------
+
+Tinydrm is the helper driver for really simple fb drivers. The goal is to make
+those drivers as simple as possible, so lots of room for refactoring:
+
+- backlight helpers, probably best to put them into a new drm_backlight.c.
+  This is because drivers/video is de-facto unmaintained. We could also
+  move drivers/video/backlight to drivers/gpu/backlight and take it all
+  over within drm-misc, but that's more work.
+
+- spi helpers, probably best put into spi core/helper code. Thierry said
+  the spi maintainer is fast&reactive, so shouldn't be a big issue.
+
+- extract the mipi-dbi helper (well, the non-tinydrm specific parts at
+  least) into a separate helper, like we have for mipi-dsi already. Or follow
+  one of the ideas for having a shared dsi/dbi helper, abstracting away the
+  transport details more.
+
+- tinydrm_lastclose could be drm_fb_helper_lastclose. Only thing we need
+  for that is to store the drm_fb_helper pointer somewhere in
+  drm_device->mode_config. And then we could roll that out to all the
+  drivers.
+
+- tinydrm_gem_cma_prime_import_sg_table should probably go into the cma
+  helpers, as a _vmapped variant (since not every driver needs the vmap).
+  And tinydrm_gem_cma_free_object could the be merged into
+  drm_gem_cma_free_object().
+
+- tinydrm_fb_create we could move into drm_simple_pipe, only need to add
+  the fb_create hook to drm_simple_pipe_funcs, which would again simplify a
+  bunch of things (since it gives you a one-stop vfunc for simple drivers).
+
+- Quick aside: The unregister devm stuff is kinda getting the lifetimes of
+  a drm_device wrong. Doesn't matter, since everyone else gets it wrong
+  too :-)
+
+- With the fbdev pointer in dev->mode_config we could also make
+  suspend/resume helpers entirely generic, at least if we add a
+  dev->mode_config.suspend_state. We could even provide a generic pm_ops
+  structure with those.
+
+- also rework the drm_framebuffer_funcs->dirty hook wire-up, see above.
+
+Contact: Noralf Trønnes, Daniel Vetter
+
 Outside DRM
 ===========
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Acked-by on v1 9/16
#31 lore raw

Re: [PATCH 09/16] drm/todo: Add tinydrm refactoring ideas

Den 22.03.2017 09.36, skrev Daniel Vetter:

Quoted 9 lines

Discussed with Noralf on the list a bit.

An open question is tinydrm vs. drm_panel, but until we have a clear idea what's really needed in that space, I think it's best to just move forward with what we have.

Cc Noralf Trønnes <[email protected]>

---

Thanks Daniel,

Quoted 80 lines
  Documentation/gpu/todo.rst | 70 ++++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 70 insertions(+)
Documentation/gpu/todo.rst +62 -0
index 7dc6de07a3bc..479bb040f6d4 100644
@@ -99,6 +99,30 @@ events for atomic commits correctly. But fixing these bugs is good anyway.
 
  Contact: Daniel Vetter, respective driver maintainers
 
+Better manual-upload support for atomic
+---------------------------------------
+
+This would be especially useful for tinydrm:
+
+- Add a struct drm_rect dirty_clip to drm_crtc_state. When duplicating the
+  crtc state, clear that to the max values, x/y = 0 and w/h = MAX_INT, in
+  __drm_atomic_helper_crtc_duplicate_state().
+
+- Move tinydrm_merge_clips into drm_framebuffer.c, dropping the tinydrm_
+  prefix ofc and using drm_fb_. drm_framebuffer.c makes sense since this
+  is a function useful to implement the fb->dirty function.
+
+- Create a new drm_fb_dirty function which does essentially what e.g.
+  mipi_dbi_fb_dirty does. You can use e.g. drm_atomic_helper_update_plane as the
+  template. But instead of doing a simple full-screen plane update, this new
+  helper also sets crtc_state->dirty_clip to the right coordinates. And of
+  course it needs to check whether the fb is actually active (and maybe where),
+  so there's some book-keeping involved. There's also some good fun involved in
+  scaling things appropriately. For that case we might simply give up and
+  declare the entire area covered by the plane as dirty.
+
+Contact: Noralf Trønnes, Daniel Vetter
+
  Fallout from atomic KMS
  -----------------------
 
@@ -313,5 +337,51 @@ Contact: Daniel Vetter
  Driver Specific
  ===============
 
+tinydrm
+-------
+
+Tinydrm is the helper driver for really simple fb drivers. The goal is to make
+those drivers as simple as possible, so lots of room for refactoring:
+
+- backlight helpers, probably best to put them into a new drm_backlight.c.
+  This is because drivers/video is de-facto unmaintained. We could also
+  move drivers/video/backlight to drivers/gpu/backlight and take it all
+  over within drm-misc, but that's more work.
+
+- spi helpers, probably best put into spi core/helper code. Thierry said
+  the spi maintainer is fast&reactive, so shouldn't be a big issue.
+
+- extract the mipi-dbi helper (well, the non-tinydrm specific parts at
+  least) into a separate helper, like we have for mipi-dsi already. Or follow
+  one of the ideas for having a shared dsi/dbi helper, abstracting away the
+  transport details more.
+
+- tinydrm_lastclose could be drm_fb_helper_lastclose. Only thing we need
+  for that is to store the drm_fb_helper pointer somewhere in
+  drm_device->mode_config. And then we could roll that out to all the
+  drivers.
+
+- tinydrm_gem_cma_prime_import_sg_table should probably go into the cma
+  helpers, as a _vmapped variant (since not every driver needs the vmap).
+  And tinydrm_gem_cma_free_object could the be merged into
+  drm_gem_cma_free_object().
+
+- tinydrm_fb_create we could move into drm_simple_pipe, only need to add
+  the fb_create hook to drm_simple_pipe_funcs, which would again simplify a
+  bunch of things (since it gives you a one-stop vfunc for simple drivers).
+
+- Quick aside: The unregister devm stuff is kinda getting the lifetimes of
+  a drm_device wrong. Doesn't matter, since everyone else gets it wrong
+  too :-)
+
+- With the fbdev pointer in dev->mode_config we could also make

Documentation/gpu/todo.rst Contact: Daniel Vetter · line 387

Quoted 10 lines
Documentation/gpu/todo.rst +8 -0
+  suspend/resume helpers entirely generic, at least if we add a
+  dev->mode_config.suspend_state. We could even provide a generic pm_ops
+  structure with those.
+
+- also rework the drm_framebuffer_funcs->dirty hook wire-up, see above.
+
+Contact: Noralf Trønnes, Daniel Vetter
+
  Outside DRM
  ===========

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#32 lore raw

PATCH 10/16 drm/vblank: Remove DRM_VBLANKTIME_IN_VBLANK

In reply to Daniel Vetter

The core code doesn't care at all about this, it's entirely dead.

---
 drivers/gpu/drm/drm_irq.c | 8 --------
 include/drm/drmP.h        | 1 -
 2 files changed, 9 deletions(-)
drivers/gpu/drm/drm_irq.c +0 -8
index 53a526c7b24d..4b0c7475ed13 100644
@@ -810,14 +810,6 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 	/* Return upper bound of timestamp precision error. */
 	*max_error = duration_ns;
 
-	/* Check if in vblank area:
-	 * vpos is >=0 in video scanout area, but negative
-	 * within vblank area, counting down the number of lines until
-	 * start of scanout.
-	 */
-	if (vbl_status & DRM_SCANOUTPOS_IN_VBLANK)
-		ret |= DRM_VBLANKTIME_IN_VBLANK;
-
 	/* Convert scanout position into elapsed time at raw_time query
 	 * since start of scanout at first display scanline. delta_ns
 	 * can be negative if start of scanout hasn't happened yet.
include/drm/drmP.h +0 -1
index 248d2408e56b..27ecfcdbf752 100644
@@ -323,7 +323,6 @@ struct pci_controller;
 /* Flags and return codes for get_vblank_timestamp() driver function. */
 #define DRM_CALLED_FROM_VBLIRQ 1
 #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
-#define DRM_VBLANKTIME_IN_VBLANK         (1 << 1)
 
 /* get_scanout_position() return flags */
 #define DRM_SCANOUTPOS_VALID        (1 << 0)
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 10/16
#33 lore raw

Re: [PATCH 10/16] drm/vblank: Remove DRM_VBLANKTIME_IN_VBLANK

Quoted 15 lines · Daniel Vetter

The core code doesn't care at all about this, it's entirely dead.

---
 drivers/gpu/drm/drm_irq.c | 8 --------
 include/drm/drmP.h        | 1 -
 2 files changed, 9 deletions(-)
drivers/gpu/drm/drm_irq.c +0 -0
index 53a526c7b24d..4b0c7475ed13 100644
@@ -810,14 +810,6 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 	/* Return upper bound of timestamp precision error. */

drivers/gpu/drm/drm_irq.c int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, · line 820

Quoted 10 lines
drivers/gpu/drm/drm_irq.c +0 -8
 	*max_error = duration_ns;
 
-	/* Check if in vblank area:
-	 * vpos is >=0 in video scanout area, but negative
-	 * within vblank area, counting down the number of lines until
-	 * start of scanout.
-	 */
-	if (vbl_status & DRM_SCANOUTPOS_IN_VBLANK)
-		ret |= DRM_VBLANKTIME_IN_VBLANK;
-

Indeed nothing seems to look at it. And dropping it shouldn't change anything as we still always set the other bit, so the 'ret > 0' check in the caller should still work correctly.

Quoted 22 lines
drivers/gpu/drm/drm_irq.c +0 -0
 	/* Convert scanout position into elapsed time at raw_time query
 	 * since start of scanout at first display scanline. delta_ns
 	 * can be negative if start of scanout hasn't happened yet.
include/drm/drmP.h +0 -1
index 248d2408e56b..27ecfcdbf752 100644
@@ -323,7 +323,6 @@ struct pci_controller;
 /* Flags and return codes for get_vblank_timestamp() driver function. */
 #define DRM_CALLED_FROM_VBLIRQ 1
 #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
-#define DRM_VBLANKTIME_IN_VBLANK         (1 << 1)
 
 /* get_scanout_position() return flags */
 #define DRM_SCANOUTPOS_VALID        (1 << 0)
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

A message that is not in the archive (sent off-list or not yet received): 20170322083617.13361-1-daniel.vetter-/[email protected]

#35 lore raw

PATCH 11/16 drm/vblank: Switch drm_driver->get_vblank_timestamp to return a bool

There's really no reason for anything more:
- Calling this while the crtc vblank stuff isn't set up is a driver bug. Those places arlready DRM_ERROR.
- Calling this when the crtc is off is either a driver bug (callin drm_crtc_handle_vblank at the wrong time) or a core bug (for anything else). Again, we DRM_ERROR.
- EINVAL is checked at higher levels already, and if we'd use struct drm_crtc * instead of (dev, pipe) it would be real obvious that those are again core bugs.

The only valid failure mode is crap hardware that couldn't sample a useful timestamp, to ask the core to just grab a not-so-accurate timestampe. Bool is perfectly fine for that.

Cc Mario Kleiner <[email protected]>
Cc Eric Anholt <[email protected]>
Cc Rob Clark <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc Ben Skeggs <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h       |  8 +++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   | 14 ++++++------
 drivers/gpu/drm/drm_irq.c                 | 37 +++++++++++--------------------
 drivers/gpu/drm/i915/i915_irq.c           |  8 +++----
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c   | 12 +++++-----
 drivers/gpu/drm/nouveau/nouveau_display.c |  4 ++--
 drivers/gpu/drm/nouveau/nouveau_display.h |  4 ++--
 drivers/gpu/drm/radeon/radeon_drv.c       |  8 +++----
 drivers/gpu/drm/radeon/radeon_kms.c       | 14 ++++++------
 drivers/gpu/drm/vc4/vc4_crtc.c            |  2 +-
 drivers/gpu/drm/vc4/vc4_drv.h             |  2 +-
 include/drm/drmP.h                        |  1 -
 include/drm/drm_drv.h                     |  7 +++---
 include/drm/drm_irq.h                     | 10 ++++-----
 14 files changed, 59 insertions(+), 72 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 -4
index c8860f05bfb9..acd8631d8024 100644
@@ -1768,10 +1768,10 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon);
 u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags);
+bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags);
 long amdgpu_kms_compat_ioctl(struct file *filp, unsigned int cmd,
 			     unsigned long arg);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +7 -7
index 55f951bcc91f..ac42f707c046 100644
@@ -838,19 +838,19 @@ void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe)
  *
  * Gets the timestamp on the requested crtc based on the
  * scanout position.  (all asics).
- * Returns postive status flags on success, negative error on failure.
+ * Returns true on success, false on failure.
  */
-int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags)
+bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags)
 {
 	struct drm_crtc *crtc;
 	struct amdgpu_device *adev = dev->dev_private;
 
 	if (pipe >= dev->num_crtcs) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Get associated drm_crtc: */
@@ -859,7 +859,7 @@ int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
 		/* This can occur on driver load if some component fails to
 		 * initialize completely and driver is unloaded */
 		DRM_ERROR("Uninitialized crtc %d\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Helper routine in DRM core does all the work: */
drivers/gpu/drm/drm_irq.c +13 -24
index 4b0c7475ed13..2121ea29e1b2 100644
@@ -722,43 +722,32 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  * active. Higher level code is expected to handle this.
  *
  * Returns:
- * Negative value on error, failure or if not supported in current
- * video mode:
- *
- * -EINVAL    Invalid CRTC.
- * -EAGAIN    Temporary unavailable, e.g., called before initial modeset.
- * -ENOTSUPP  Function not supported in current display mode.
- * -EIO       Failed, e.g., due to failed scanout position query.
- *
- * Returns or'ed positive status flags on success:
- *
- * DRM_VBLANKTIME_SCANOUTPOS_METHOD - Signal this method used for timestamping.
- * DRM_VBLANKTIME_INVBL - Timestamp taken while scanout was in vblank interval.
  *
+ * Returns true on success, and false on failure, i.e. when no accurate
+ * timestamp could be acquired.
  */
-int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
-					  unsigned int pipe,
-					  int *max_error,
-					  struct timeval *vblank_time,
-					  unsigned flags,
-					  const struct drm_display_mode *mode)
+bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
+					   unsigned int pipe,
+					   int *max_error,
+					   struct timeval *vblank_time,
+					   unsigned flags,
+					   const struct drm_display_mode *mode)
 {
 	struct timeval tv_etime;
 	ktime_t stime, etime;
 	unsigned int vbl_status;
-	int ret = DRM_VBLANKTIME_SCANOUTPOS_METHOD;
 	int vpos, hpos, i;
 	int delta_ns, duration_ns;
 
 	if (pipe >= dev->num_crtcs) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Scanout position query not supported? Should not happen. */
 	if (!dev->driver->get_scanout_position) {
 		DRM_ERROR("Called from driver w/o get_scanout_position()!?\n");
-		return -EIO;
+		return false;
 	}
 
 	/* If mode timing undefined, just return as no-op:
@@ -766,7 +755,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 	 */
 	if (mode->crtc_clock == 0) {
 		DRM_DEBUG("crtc %u: Noop due to uninitialized mode.\n", pipe);
-		return -EAGAIN;
+		return false;
 	}
 
 	/* Get current scanout position with system timestamp.
@@ -790,7 +779,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 		if (!(vbl_status & DRM_SCANOUTPOS_VALID)) {
 			DRM_DEBUG("crtc %u : scanoutpos query failed [0x%x].\n",
 				  pipe, vbl_status);
-			return -EIO;
+			return false;
 		}
 
 		/* Compute uncertainty in timestamp of scanout position query. */
@@ -834,7 +823,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 		      (long)vblank_time->tv_sec, (long)vblank_time->tv_usec,
 		      duration_ns/1000, i);
 
-	return ret;
+	return true;
 }
 EXPORT_SYMBOL(drm_calc_vbltimestamp_from_scanoutpos);
 
drivers/gpu/drm/i915/i915_irq.c +4 -4
index 26aa1c170b43..df149d159ce7 100644
@@ -964,7 +964,7 @@ int intel_get_crtc_scanline(struct intel_crtc *crtc)
 	return position;
 }
 
-static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
+static bool i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 			      int *max_error,
 			      struct timeval *vblank_time,
 			      unsigned flags)
@@ -974,19 +974,19 @@ static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 
 	if (pipe >= INTEL_INFO(dev_priv)->num_pipes) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Get drm_crtc to timestamp: */
 	crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
 	if (crtc == NULL) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	if (!crtc->base.hwmode.crtc_clock) {
 		DRM_DEBUG_KMS("crtc %u is disabled\n", pipe);
-		return -EBUSY;
+		return false;
 	}
 
 	/* Helper routine in DRM core does all the work: */
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c +6 -6
index 41ccd2a15d3c..655700eb42ba 100644
@@ -595,23 +595,23 @@ static int mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	return ret;
 }
 
-static int mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
-				     int *max_error,
-				     struct timeval *vblank_time,
-				     unsigned flags)
+static bool mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
+				      int *max_error,
+				      struct timeval *vblank_time,
+				      unsigned flags)
 {
 	struct msm_drm_private *priv = dev->dev_private;
 	struct drm_crtc *crtc;
 
 	if (pipe < 0 || pipe >= priv->num_crtcs) {
 		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	crtc = priv->crtcs[pipe];
 	if (!crtc) {
 		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
drivers/gpu/drm/nouveau/nouveau_display.c +2 -2
index 33269c7df30f..42f18b0b9c43 100644
@@ -156,7 +156,7 @@ nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	return 0;
 }
 
-int
+bool
 nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
 			 int *max_error, struct timeval *time, unsigned flags)
 {
@@ -174,7 +174,7 @@ nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
 		}
 	}
 
-	return -EINVAL;
+	return false;
 }
 
 static void
drivers/gpu/drm/nouveau/nouveau_display.h +2 -2
index 4a75df06c139..bc9d1e7b0117 100644
@@ -71,8 +71,8 @@ void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
 int  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
 				unsigned int, int *, int *, ktime_t *,
 				ktime_t *, const struct drm_display_mode *);
-int  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
-			      struct timeval *, unsigned);
+bool  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
+			       struct timeval *, unsigned);
 
 int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 			    struct drm_pending_vblank_event *event,
drivers/gpu/drm/radeon/radeon_drv.c +4 -4
index 312436a8d9e5..6d79b5c2805b 100644
@@ -114,10 +114,10 @@ int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
 u32 radeon_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int radeon_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void radeon_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-int radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags);
+bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags);
 void radeon_driver_irq_preinstall_kms(struct drm_device *dev);
 int radeon_driver_irq_postinstall_kms(struct drm_device *dev);
 void radeon_driver_irq_uninstall_kms(struct drm_device *dev);
drivers/gpu/drm/radeon/radeon_kms.c +7 -7
index a32a62e03a44..9afe72010c64 100644
@@ -868,25 +868,25 @@ void radeon_disable_vblank_kms(struct drm_device *dev, int crtc)
  *
  * Gets the timestamp on the requested crtc based on the
  * scanout position.  (all asics).
- * Returns postive status flags on success, negative error on failure.
+ * Returns true on success, false on failure.
  */
-int radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags)
+bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags)
 {
 	struct drm_crtc *drmcrtc;
 	struct radeon_device *rdev = dev->dev_private;
 
 	if (crtc < 0 || crtc >= dev->num_crtcs) {
 		DRM_ERROR("Invalid crtc %d\n", crtc);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Get associated drm_crtc: */
 	drmcrtc = &rdev->mode_info.crtcs[crtc]->base;
 	if (!drmcrtc)
-		return -EINVAL;
+		return false;
 
 	/* Helper routine in DRM core does all the work: */
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error,
drivers/gpu/drm/vc4/vc4_crtc.c +1 -1
index 24edd0c22cc9..74260990b6bf 100644
@@ -270,7 +270,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 	return ret;
 }
 
-int vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
+bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
 				  int *max_error, struct timeval *vblank_time,
 				  unsigned flags)
 {
drivers/gpu/drm/vc4/vc4_drv.h +1 -1
index dffce6293d87..8a5d0e12ee02 100644
@@ -450,7 +450,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 			    unsigned int flags, int *vpos, int *hpos,
 			    ktime_t *stime, ktime_t *etime,
 			    const struct drm_display_mode *mode);
-int vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
+bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
 				  int *max_error, struct timeval *vblank_time,
 				  unsigned flags);
 
include/drm/drmP.h +0 -1
index 27ecfcdbf752..6304de7e041e 100644
@@ -322,7 +322,6 @@ struct pci_controller;
 
 /* Flags and return codes for get_vblank_timestamp() driver function. */
 #define DRM_CALLED_FROM_VBLIRQ 1
-#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
 
 /* get_scanout_position() return flags */
 #define DRM_SCANOUTPOS_VALID        (1 << 0)
include/drm/drm_drv.h +3 -4
index d0b5f363bfa1..da78e248d9d8 100644
@@ -316,11 +316,10 @@ struct drm_driver {
 	 *
 	 * Returns:
 	 *
-	 * Zero if timestamping isn't supported in current display mode or a
-	 * negative number on failure. A positive status code on success,
-	 * which describes how the vblank_time timestamp was computed.
+	 * True on success, false on failure, which means the core should
+	 * fallback to a simple timestamp taken in drm_crtc_handle_vblank().
 	 */
-	int (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
+	bool (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
 				     int *max_error,
 				     struct timeval *vblank_time,
 				     unsigned flags);
include/drm/drm_irq.h +5 -5
index cf0be6594c8c..f0d5ccf9b282 100644
@@ -153,11 +153,11 @@ void drm_crtc_vblank_on(struct drm_crtc *crtc);
 void drm_vblank_cleanup(struct drm_device *dev);
 u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
 
-int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
-					  unsigned int pipe, int *max_error,
-					  struct timeval *vblank_time,
-					  unsigned flags,
-					  const struct drm_display_mode *mode);
+bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
+					   unsigned int pipe, int *max_error,
+					   struct timeval *vblank_time,
+					   unsigned flags,
+					   const struct drm_display_mode *mode);
 void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 				     const struct drm_display_mode *mode);
 
Signature · 6 lines
2.11.0

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

A message that is not in the archive (sent off-list or not yet received): 20170322083617.13361-12-daniel.vetter-/[email protected]

#37 lore raw

Re: [Intel-gfx] [PATCH 11/16] drm/vblank: Switch drm_driver->get_vblank_timestamp to return a bool

Quoted 10 lines · Daniel Vetter

There's really no reason for anything more:
- Calling this while the crtc vblank stuff isn't set up is a driver bug. Those places arlready DRM_ERROR.
- Calling this when the crtc is off is either a driver bug (callin drm_crtc_handle_vblank at the wrong time) or a core bug (for anything else). Again, we DRM_ERROR.
- EINVAL is checked at higher levels already, and if we'd use struct drm_crtc * instead of (dev, pipe) it would be real obvious that those are again core bugs.

Quoted 3 lines

The only valid failure mode is crap hardware that couldn't sample a useful timestamp, to ask the core to just grab a not-so-accurate timestampe. Bool is perfectly fine for that.

FWIW, I'm not all that thrilled about changing int returns to bools, because it changes the check for success from !ret to ret, and the compiler won't help you. Sure, there aren't many call sites for the function, but, case in point, you forgot to change that lone call site. Though it still works by coincidence.

BR,
Jani.

Quoted 410 lines
Cc Mario Kleiner <[email protected]>
Cc Eric Anholt <[email protected]>
Cc Rob Clark <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc Ben Skeggs <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h       |  8 +++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   | 14 ++++++------
 drivers/gpu/drm/drm_irq.c                 | 37 +++++++++++--------------------
 drivers/gpu/drm/i915/i915_irq.c           |  8 +++----
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c   | 12 +++++-----
 drivers/gpu/drm/nouveau/nouveau_display.c |  4 ++--
 drivers/gpu/drm/nouveau/nouveau_display.h |  4 ++--
 drivers/gpu/drm/radeon/radeon_drv.c       |  8 +++----
 drivers/gpu/drm/radeon/radeon_kms.c       | 14 ++++++------
 drivers/gpu/drm/vc4/vc4_crtc.c            |  2 +-
 drivers/gpu/drm/vc4/vc4_drv.h             |  2 +-
 include/drm/drmP.h                        |  1 -
 include/drm/drm_drv.h                     |  7 +++---
 include/drm/drm_irq.h                     | 10 ++++-----
 14 files changed, 59 insertions(+), 72 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 -4
index c8860f05bfb9..acd8631d8024 100644
@@ -1768,10 +1768,10 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon);
 u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags);
+bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags);
 long amdgpu_kms_compat_ioctl(struct file *filp, unsigned int cmd,
 			     unsigned long arg);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +7 -7
index 55f951bcc91f..ac42f707c046 100644
@@ -838,19 +838,19 @@ void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe)
  *
  * Gets the timestamp on the requested crtc based on the
  * scanout position.  (all asics).
- * Returns postive status flags on success, negative error on failure.
+ * Returns true on success, false on failure.
  */
-int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags)
+bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags)
 {
 	struct drm_crtc *crtc;
 	struct amdgpu_device *adev = dev->dev_private;
 
 	if (pipe >= dev->num_crtcs) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Get associated drm_crtc: */
@@ -859,7 +859,7 @@ int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
 		/* This can occur on driver load if some component fails to
 		 * initialize completely and driver is unloaded */
 		DRM_ERROR("Uninitialized crtc %d\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Helper routine in DRM core does all the work: */
drivers/gpu/drm/drm_irq.c +13 -24
index 4b0c7475ed13..2121ea29e1b2 100644
@@ -722,43 +722,32 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  * active. Higher level code is expected to handle this.
  *
  * Returns:
- * Negative value on error, failure or if not supported in current
- * video mode:
- *
- * -EINVAL    Invalid CRTC.
- * -EAGAIN    Temporary unavailable, e.g., called before initial modeset.
- * -ENOTSUPP  Function not supported in current display mode.
- * -EIO       Failed, e.g., due to failed scanout position query.
- *
- * Returns or'ed positive status flags on success:
- *
- * DRM_VBLANKTIME_SCANOUTPOS_METHOD - Signal this method used for timestamping.
- * DRM_VBLANKTIME_INVBL - Timestamp taken while scanout was in vblank interval.
  *
+ * Returns true on success, and false on failure, i.e. when no accurate
+ * timestamp could be acquired.
  */
-int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
-					  unsigned int pipe,
-					  int *max_error,
-					  struct timeval *vblank_time,
-					  unsigned flags,
-					  const struct drm_display_mode *mode)
+bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
+					   unsigned int pipe,
+					   int *max_error,
+					   struct timeval *vblank_time,
+					   unsigned flags,
+					   const struct drm_display_mode *mode)
 {
 	struct timeval tv_etime;
 	ktime_t stime, etime;
 	unsigned int vbl_status;
-	int ret = DRM_VBLANKTIME_SCANOUTPOS_METHOD;
 	int vpos, hpos, i;
 	int delta_ns, duration_ns;
 
 	if (pipe >= dev->num_crtcs) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Scanout position query not supported? Should not happen. */
 	if (!dev->driver->get_scanout_position) {
 		DRM_ERROR("Called from driver w/o get_scanout_position()!?\n");
-		return -EIO;
+		return false;
 	}
 
 	/* If mode timing undefined, just return as no-op:
@@ -766,7 +755,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 	 */
 	if (mode->crtc_clock == 0) {
 		DRM_DEBUG("crtc %u: Noop due to uninitialized mode.\n", pipe);
-		return -EAGAIN;
+		return false;
 	}
 
 	/* Get current scanout position with system timestamp.
@@ -790,7 +779,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 		if (!(vbl_status & DRM_SCANOUTPOS_VALID)) {
 			DRM_DEBUG("crtc %u : scanoutpos query failed [0x%x].\n",
 				  pipe, vbl_status);
-			return -EIO;
+			return false;
 		}
 
 		/* Compute uncertainty in timestamp of scanout position query. */
@@ -834,7 +823,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 		      (long)vblank_time->tv_sec, (long)vblank_time->tv_usec,
 		      duration_ns/1000, i);
 
-	return ret;
+	return true;
 }
 EXPORT_SYMBOL(drm_calc_vbltimestamp_from_scanoutpos);
 
drivers/gpu/drm/i915/i915_irq.c +4 -4
index 26aa1c170b43..df149d159ce7 100644
@@ -964,7 +964,7 @@ int intel_get_crtc_scanline(struct intel_crtc *crtc)
 	return position;
 }
 
-static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
+static bool i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 			      int *max_error,
 			      struct timeval *vblank_time,
 			      unsigned flags)
@@ -974,19 +974,19 @@ static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 
 	if (pipe >= INTEL_INFO(dev_priv)->num_pipes) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Get drm_crtc to timestamp: */
 	crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
 	if (crtc == NULL) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	if (!crtc->base.hwmode.crtc_clock) {
 		DRM_DEBUG_KMS("crtc %u is disabled\n", pipe);
-		return -EBUSY;
+		return false;
 	}
 
 	/* Helper routine in DRM core does all the work: */
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c +6 -6
index 41ccd2a15d3c..655700eb42ba 100644
@@ -595,23 +595,23 @@ static int mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	return ret;
 }
 
-static int mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
-				     int *max_error,
-				     struct timeval *vblank_time,
-				     unsigned flags)
+static bool mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
+				      int *max_error,
+				      struct timeval *vblank_time,
+				      unsigned flags)
 {
 	struct msm_drm_private *priv = dev->dev_private;
 	struct drm_crtc *crtc;
 
 	if (pipe < 0 || pipe >= priv->num_crtcs) {
 		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	crtc = priv->crtcs[pipe];
 	if (!crtc) {
 		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
drivers/gpu/drm/nouveau/nouveau_display.c +2 -2
index 33269c7df30f..42f18b0b9c43 100644
@@ -156,7 +156,7 @@ nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	return 0;
 }
 
-int
+bool
 nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
 			 int *max_error, struct timeval *time, unsigned flags)
 {
@@ -174,7 +174,7 @@ nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
 		}
 	}
 
-	return -EINVAL;
+	return false;
 }
 
 static void
drivers/gpu/drm/nouveau/nouveau_display.h +2 -2
index 4a75df06c139..bc9d1e7b0117 100644
@@ -71,8 +71,8 @@ void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
 int  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
 				unsigned int, int *, int *, ktime_t *,
 				ktime_t *, const struct drm_display_mode *);
-int  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
-			      struct timeval *, unsigned);
+bool  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
+			       struct timeval *, unsigned);
 
 int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 			    struct drm_pending_vblank_event *event,
drivers/gpu/drm/radeon/radeon_drv.c +4 -4
index 312436a8d9e5..6d79b5c2805b 100644
@@ -114,10 +114,10 @@ int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
 u32 radeon_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int radeon_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void radeon_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-int radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags);
+bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags);
 void radeon_driver_irq_preinstall_kms(struct drm_device *dev);
 int radeon_driver_irq_postinstall_kms(struct drm_device *dev);
 void radeon_driver_irq_uninstall_kms(struct drm_device *dev);
drivers/gpu/drm/radeon/radeon_kms.c +7 -7
index a32a62e03a44..9afe72010c64 100644
@@ -868,25 +868,25 @@ void radeon_disable_vblank_kms(struct drm_device *dev, int crtc)
  *
  * Gets the timestamp on the requested crtc based on the
  * scanout position.  (all asics).
- * Returns postive status flags on success, negative error on failure.
+ * Returns true on success, false on failure.
  */
-int radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags)
+bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags)
 {
 	struct drm_crtc *drmcrtc;
 	struct radeon_device *rdev = dev->dev_private;
 
 	if (crtc < 0 || crtc >= dev->num_crtcs) {
 		DRM_ERROR("Invalid crtc %d\n", crtc);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Get associated drm_crtc: */
 	drmcrtc = &rdev->mode_info.crtcs[crtc]->base;
 	if (!drmcrtc)
-		return -EINVAL;
+		return false;
 
 	/* Helper routine in DRM core does all the work: */
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error,
drivers/gpu/drm/vc4/vc4_crtc.c +1 -1
index 24edd0c22cc9..74260990b6bf 100644
@@ -270,7 +270,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 	return ret;
 }
 
-int vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
+bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
 				  int *max_error, struct timeval *vblank_time,
 				  unsigned flags)
 {
drivers/gpu/drm/vc4/vc4_drv.h +1 -1
index dffce6293d87..8a5d0e12ee02 100644
@@ -450,7 +450,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 			    unsigned int flags, int *vpos, int *hpos,
 			    ktime_t *stime, ktime_t *etime,
 			    const struct drm_display_mode *mode);
-int vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
+bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
 				  int *max_error, struct timeval *vblank_time,
 				  unsigned flags);
 
include/drm/drmP.h +0 -1
index 27ecfcdbf752..6304de7e041e 100644
@@ -322,7 +322,6 @@ struct pci_controller;
 
 /* Flags and return codes for get_vblank_timestamp() driver function. */
 #define DRM_CALLED_FROM_VBLIRQ 1
-#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
 
 /* get_scanout_position() return flags */
 #define DRM_SCANOUTPOS_VALID        (1 << 0)
include/drm/drm_drv.h +3 -4
index d0b5f363bfa1..da78e248d9d8 100644
@@ -316,11 +316,10 @@ struct drm_driver {
 	 *
 	 * Returns:
 	 *
-	 * Zero if timestamping isn't supported in current display mode or a
-	 * negative number on failure. A positive status code on success,
-	 * which describes how the vblank_time timestamp was computed.
+	 * True on success, false on failure, which means the core should
+	 * fallback to a simple timestamp taken in drm_crtc_handle_vblank().
 	 */
-	int (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
+	bool (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
 				     int *max_error,
 				     struct timeval *vblank_time,
 				     unsigned flags);
include/drm/drm_irq.h +5 -5
index cf0be6594c8c..f0d5ccf9b282 100644
@@ -153,11 +153,11 @@ void drm_crtc_vblank_on(struct drm_crtc *crtc);
 void drm_vblank_cleanup(struct drm_device *dev);
 u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
 
-int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
-					  unsigned int pipe, int *max_error,
-					  struct timeval *vblank_time,
-					  unsigned flags,
-					  const struct drm_display_mode *mode);
+bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
+					   unsigned int pipe, int *max_error,
+					   struct timeval *vblank_time,
+					   unsigned flags,
+					   const struct drm_display_mode *mode);
 void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 				     const struct drm_display_mode *mode);
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
#38 lore raw

Re: [PATCH 11/16] drm/vblank: Switch drm_driver->get_vblank_timestamp to return a bool

Quoted 15 lines · Jani Nikula
Quoted 10 lines · Daniel Vetter

There's really no reason for anything more:
- Calling this while the crtc vblank stuff isn't set up is a driver bug. Those places arlready DRM_ERROR.
- Calling this when the crtc is off is either a driver bug (callin drm_crtc_handle_vblank at the wrong time) or a core bug (for anything else). Again, we DRM_ERROR.
- EINVAL is checked at higher levels already, and if we'd use struct drm_crtc * instead of (dev, pipe) it would be real obvious that those are again core bugs.

Quoted 3 lines

The only valid failure mode is crap hardware that couldn't sample a useful timestamp, to ask the core to just grab a not-so-accurate timestampe. Bool is perfectly fine for that.

Quoted 5 lines

FWIW, I'm not all that thrilled about changing int returns to bools, because it changes the check for success from !ret to ret, and the compiler won't help you. Sure, there aren't many call sites for the function, but, case in point, you forgot to change that lone call site. Though it still works by coincidence.

The old call site treated > 0 as success, and 0 or anything negative as failure. That the lone caller still works is the reason why I've switched to bool, because besides all the funny values that the caller gets and ignreos, it already is.

Or did I miss something?
-Daniel

Quoted 417 lines

BR,
Jani.

Quoted 410 lines
Cc Mario Kleiner <[email protected]>
Cc Eric Anholt <[email protected]>
Cc Rob Clark <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc Ben Skeggs <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h       |  8 +++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   | 14 ++++++------
 drivers/gpu/drm/drm_irq.c                 | 37 +++++++++++--------------------
 drivers/gpu/drm/i915/i915_irq.c           |  8 +++----
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c   | 12 +++++-----
 drivers/gpu/drm/nouveau/nouveau_display.c |  4 ++--
 drivers/gpu/drm/nouveau/nouveau_display.h |  4 ++--
 drivers/gpu/drm/radeon/radeon_drv.c       |  8 +++----
 drivers/gpu/drm/radeon/radeon_kms.c       | 14 ++++++------
 drivers/gpu/drm/vc4/vc4_crtc.c            |  2 +-
 drivers/gpu/drm/vc4/vc4_drv.h             |  2 +-
 include/drm/drmP.h                        |  1 -
 include/drm/drm_drv.h                     |  7 +++---
 include/drm/drm_irq.h                     | 10 ++++-----
 14 files changed, 59 insertions(+), 72 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 -4
index c8860f05bfb9..acd8631d8024 100644
@@ -1768,10 +1768,10 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon);
 u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags);
+bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags);
 long amdgpu_kms_compat_ioctl(struct file *filp, unsigned int cmd,
 			     unsigned long arg);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +7 -7
index 55f951bcc91f..ac42f707c046 100644
@@ -838,19 +838,19 @@ void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe)
  *
  * Gets the timestamp on the requested crtc based on the
  * scanout position.  (all asics).
- * Returns postive status flags on success, negative error on failure.
+ * Returns true on success, false on failure.
  */
-int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags)
+bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags)
 {
 	struct drm_crtc *crtc;
 	struct amdgpu_device *adev = dev->dev_private;
 
 	if (pipe >= dev->num_crtcs) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Get associated drm_crtc: */
@@ -859,7 +859,7 @@ int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
 		/* This can occur on driver load if some component fails to
 		 * initialize completely and driver is unloaded */
 		DRM_ERROR("Uninitialized crtc %d\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Helper routine in DRM core does all the work: */
drivers/gpu/drm/drm_irq.c +13 -24
index 4b0c7475ed13..2121ea29e1b2 100644
@@ -722,43 +722,32 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  * active. Higher level code is expected to handle this.
  *
  * Returns:
- * Negative value on error, failure or if not supported in current
- * video mode:
- *
- * -EINVAL    Invalid CRTC.
- * -EAGAIN    Temporary unavailable, e.g., called before initial modeset.
- * -ENOTSUPP  Function not supported in current display mode.
- * -EIO       Failed, e.g., due to failed scanout position query.
- *
- * Returns or'ed positive status flags on success:
- *
- * DRM_VBLANKTIME_SCANOUTPOS_METHOD - Signal this method used for timestamping.
- * DRM_VBLANKTIME_INVBL - Timestamp taken while scanout was in vblank interval.
  *
+ * Returns true on success, and false on failure, i.e. when no accurate
+ * timestamp could be acquired.
  */
-int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
-					  unsigned int pipe,
-					  int *max_error,
-					  struct timeval *vblank_time,
-					  unsigned flags,
-					  const struct drm_display_mode *mode)
+bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
+					   unsigned int pipe,
+					   int *max_error,
+					   struct timeval *vblank_time,
+					   unsigned flags,
+					   const struct drm_display_mode *mode)
 {
 	struct timeval tv_etime;
 	ktime_t stime, etime;
 	unsigned int vbl_status;
-	int ret = DRM_VBLANKTIME_SCANOUTPOS_METHOD;
 	int vpos, hpos, i;
 	int delta_ns, duration_ns;
 
 	if (pipe >= dev->num_crtcs) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Scanout position query not supported? Should not happen. */
 	if (!dev->driver->get_scanout_position) {
 		DRM_ERROR("Called from driver w/o get_scanout_position()!?\n");
-		return -EIO;
+		return false;
 	}
 
 	/* If mode timing undefined, just return as no-op:
@@ -766,7 +755,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 	 */
 	if (mode->crtc_clock == 0) {
 		DRM_DEBUG("crtc %u: Noop due to uninitialized mode.\n", pipe);
-		return -EAGAIN;
+		return false;
 	}
 
 	/* Get current scanout position with system timestamp.
@@ -790,7 +779,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 		if (!(vbl_status & DRM_SCANOUTPOS_VALID)) {
 			DRM_DEBUG("crtc %u : scanoutpos query failed [0x%x].\n",
 				  pipe, vbl_status);
-			return -EIO;
+			return false;
 		}
 
 		/* Compute uncertainty in timestamp of scanout position query. */
@@ -834,7 +823,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 		      (long)vblank_time->tv_sec, (long)vblank_time->tv_usec,
 		      duration_ns/1000, i);
 
-	return ret;
+	return true;
 }
 EXPORT_SYMBOL(drm_calc_vbltimestamp_from_scanoutpos);
 
drivers/gpu/drm/i915/i915_irq.c +4 -4
index 26aa1c170b43..df149d159ce7 100644
@@ -964,7 +964,7 @@ int intel_get_crtc_scanline(struct intel_crtc *crtc)
 	return position;
 }
 
-static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
+static bool i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 			      int *max_error,
 			      struct timeval *vblank_time,
 			      unsigned flags)
@@ -974,19 +974,19 @@ static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 
 	if (pipe >= INTEL_INFO(dev_priv)->num_pipes) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Get drm_crtc to timestamp: */
 	crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
 	if (crtc == NULL) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	if (!crtc->base.hwmode.crtc_clock) {
 		DRM_DEBUG_KMS("crtc %u is disabled\n", pipe);
-		return -EBUSY;
+		return false;
 	}
 
 	/* Helper routine in DRM core does all the work: */
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c +6 -6
index 41ccd2a15d3c..655700eb42ba 100644
@@ -595,23 +595,23 @@ static int mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	return ret;
 }
 
-static int mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
-				     int *max_error,
-				     struct timeval *vblank_time,
-				     unsigned flags)
+static bool mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
+				      int *max_error,
+				      struct timeval *vblank_time,
+				      unsigned flags)
 {
 	struct msm_drm_private *priv = dev->dev_private;
 	struct drm_crtc *crtc;
 
 	if (pipe < 0 || pipe >= priv->num_crtcs) {
 		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	crtc = priv->crtcs[pipe];
 	if (!crtc) {
 		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
drivers/gpu/drm/nouveau/nouveau_display.c +2 -2
index 33269c7df30f..42f18b0b9c43 100644
@@ -156,7 +156,7 @@ nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	return 0;
 }
 
-int
+bool
 nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
 			 int *max_error, struct timeval *time, unsigned flags)
 {
@@ -174,7 +174,7 @@ nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
 		}
 	}
 
-	return -EINVAL;
+	return false;
 }
 
 static void
drivers/gpu/drm/nouveau/nouveau_display.h +2 -2
index 4a75df06c139..bc9d1e7b0117 100644
@@ -71,8 +71,8 @@ void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
 int  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
 				unsigned int, int *, int *, ktime_t *,
 				ktime_t *, const struct drm_display_mode *);
-int  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
-			      struct timeval *, unsigned);
+bool  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
+			       struct timeval *, unsigned);
 
 int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 			    struct drm_pending_vblank_event *event,
drivers/gpu/drm/radeon/radeon_drv.c +4 -4
index 312436a8d9e5..6d79b5c2805b 100644
@@ -114,10 +114,10 @@ int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
 u32 radeon_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int radeon_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void radeon_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-int radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags);
+bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags);
 void radeon_driver_irq_preinstall_kms(struct drm_device *dev);
 int radeon_driver_irq_postinstall_kms(struct drm_device *dev);
 void radeon_driver_irq_uninstall_kms(struct drm_device *dev);
drivers/gpu/drm/radeon/radeon_kms.c +7 -7
index a32a62e03a44..9afe72010c64 100644
@@ -868,25 +868,25 @@ void radeon_disable_vblank_kms(struct drm_device *dev, int crtc)
  *
  * Gets the timestamp on the requested crtc based on the
  * scanout position.  (all asics).
- * Returns postive status flags on success, negative error on failure.
+ * Returns true on success, false on failure.
  */
-int radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags)
+bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags)
 {
 	struct drm_crtc *drmcrtc;
 	struct radeon_device *rdev = dev->dev_private;
 
 	if (crtc < 0 || crtc >= dev->num_crtcs) {
 		DRM_ERROR("Invalid crtc %d\n", crtc);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Get associated drm_crtc: */
 	drmcrtc = &rdev->mode_info.crtcs[crtc]->base;
 	if (!drmcrtc)
-		return -EINVAL;
+		return false;
 
 	/* Helper routine in DRM core does all the work: */
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error,
drivers/gpu/drm/vc4/vc4_crtc.c +1 -1
index 24edd0c22cc9..74260990b6bf 100644
@@ -270,7 +270,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 	return ret;
 }
 
-int vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
+bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
 				  int *max_error, struct timeval *vblank_time,
 				  unsigned flags)
 {
drivers/gpu/drm/vc4/vc4_drv.h +1 -1
index dffce6293d87..8a5d0e12ee02 100644
@@ -450,7 +450,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 			    unsigned int flags, int *vpos, int *hpos,
 			    ktime_t *stime, ktime_t *etime,
 			    const struct drm_display_mode *mode);
-int vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
+bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
 				  int *max_error, struct timeval *vblank_time,
 				  unsigned flags);
 
include/drm/drmP.h +0 -1
index 27ecfcdbf752..6304de7e041e 100644
@@ -322,7 +322,6 @@ struct pci_controller;
 
 /* Flags and return codes for get_vblank_timestamp() driver function. */
 #define DRM_CALLED_FROM_VBLIRQ 1
-#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
 
 /* get_scanout_position() return flags */
 #define DRM_SCANOUTPOS_VALID        (1 << 0)
include/drm/drm_drv.h +3 -4
index d0b5f363bfa1..da78e248d9d8 100644
@@ -316,11 +316,10 @@ struct drm_driver {
 	 *
 	 * Returns:
 	 *
-	 * Zero if timestamping isn't supported in current display mode or a
-	 * negative number on failure. A positive status code on success,
-	 * which describes how the vblank_time timestamp was computed.
+	 * True on success, false on failure, which means the core should
+	 * fallback to a simple timestamp taken in drm_crtc_handle_vblank().
 	 */
-	int (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
+	bool (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
 				     int *max_error,
 				     struct timeval *vblank_time,
 				     unsigned flags);
include/drm/drm_irq.h +5 -5
index cf0be6594c8c..f0d5ccf9b282 100644
@@ -153,11 +153,11 @@ void drm_crtc_vblank_on(struct drm_crtc *crtc);
 void drm_vblank_cleanup(struct drm_device *dev);
 u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
 
-int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
-					  unsigned int pipe, int *max_error,
-					  struct timeval *vblank_time,
-					  unsigned flags,
-					  const struct drm_display_mode *mode);
+bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
+					   unsigned int pipe, int *max_error,
+					   struct timeval *vblank_time,
+					   unsigned flags,
+					   const struct drm_display_mode *mode);
 void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 				     const struct drm_display_mode *mode);
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

A message that is not in the archive (sent off-list or not yet received): 20170322132305.zdtehgbox6erdhbq-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org

#40 lore raw

Re: [Intel-gfx] [PATCH 11/16] drm/vblank: Switch drm_driver->get_vblank_timestamp to return a bool

Quoted 22 lines · Daniel Vetter
Quoted 15 lines · Jani Nikula
Quoted 10 lines · Daniel Vetter

There's really no reason for anything more:
- Calling this while the crtc vblank stuff isn't set up is a driver bug. Those places arlready DRM_ERROR.
- Calling this when the crtc is off is either a driver bug (callin drm_crtc_handle_vblank at the wrong time) or a core bug (for anything else). Again, we DRM_ERROR.
- EINVAL is checked at higher levels already, and if we'd use struct drm_crtc * instead of (dev, pipe) it would be real obvious that those are again core bugs.

Quoted 3 lines

The only valid failure mode is crap hardware that couldn't sample a useful timestamp, to ask the core to just grab a not-so-accurate timestampe. Bool is perfectly fine for that.

Quoted 5 lines

FWIW, I'm not all that thrilled about changing int returns to bools, because it changes the check for success from !ret to ret, and the compiler won't help you. Sure, there aren't many call sites for the function, but, case in point, you forgot to change that lone call site. Though it still works by coincidence.

Quoted 6 lines

The old call site treated > 0 as success, and 0 or anything negative as failure. That the lone caller still works is the reason why I've switched to bool, because besides all the funny values that the caller gets and ignreos, it already is.

Or did I miss something?

Don't you think you should fix the call site too, if you insist on changing the return type?

BR,
Jani.

Quoted 419 lines

-Daniel

Quoted 417 lines

BR,
Jani.

Quoted 410 lines
Cc Mario Kleiner <[email protected]>
Cc Eric Anholt <[email protected]>
Cc Rob Clark <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc Ben Skeggs <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h       |  8 +++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   | 14 ++++++------
 drivers/gpu/drm/drm_irq.c                 | 37 +++++++++++--------------------
 drivers/gpu/drm/i915/i915_irq.c           |  8 +++----
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c   | 12 +++++-----
 drivers/gpu/drm/nouveau/nouveau_display.c |  4 ++--
 drivers/gpu/drm/nouveau/nouveau_display.h |  4 ++--
 drivers/gpu/drm/radeon/radeon_drv.c       |  8 +++----
 drivers/gpu/drm/radeon/radeon_kms.c       | 14 ++++++------
 drivers/gpu/drm/vc4/vc4_crtc.c            |  2 +-
 drivers/gpu/drm/vc4/vc4_drv.h             |  2 +-
 include/drm/drmP.h                        |  1 -
 include/drm/drm_drv.h                     |  7 +++---
 include/drm/drm_irq.h                     | 10 ++++-----
 14 files changed, 59 insertions(+), 72 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 -4
index c8860f05bfb9..acd8631d8024 100644
@@ -1768,10 +1768,10 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon);
 u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags);
+bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags);
 long amdgpu_kms_compat_ioctl(struct file *filp, unsigned int cmd,
 			     unsigned long arg);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +7 -7
index 55f951bcc91f..ac42f707c046 100644
@@ -838,19 +838,19 @@ void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe)
  *
  * Gets the timestamp on the requested crtc based on the
  * scanout position.  (all asics).
- * Returns postive status flags on success, negative error on failure.
+ * Returns true on success, false on failure.
  */
-int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags)
+bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags)
 {
 	struct drm_crtc *crtc;
 	struct amdgpu_device *adev = dev->dev_private;
 
 	if (pipe >= dev->num_crtcs) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Get associated drm_crtc: */
@@ -859,7 +859,7 @@ int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
 		/* This can occur on driver load if some component fails to
 		 * initialize completely and driver is unloaded */
 		DRM_ERROR("Uninitialized crtc %d\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Helper routine in DRM core does all the work: */
drivers/gpu/drm/drm_irq.c +13 -24
index 4b0c7475ed13..2121ea29e1b2 100644
@@ -722,43 +722,32 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  * active. Higher level code is expected to handle this.
  *
  * Returns:
- * Negative value on error, failure or if not supported in current
- * video mode:
- *
- * -EINVAL    Invalid CRTC.
- * -EAGAIN    Temporary unavailable, e.g., called before initial modeset.
- * -ENOTSUPP  Function not supported in current display mode.
- * -EIO       Failed, e.g., due to failed scanout position query.
- *
- * Returns or'ed positive status flags on success:
- *
- * DRM_VBLANKTIME_SCANOUTPOS_METHOD - Signal this method used for timestamping.
- * DRM_VBLANKTIME_INVBL - Timestamp taken while scanout was in vblank interval.
  *
+ * Returns true on success, and false on failure, i.e. when no accurate
+ * timestamp could be acquired.
  */
-int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
-					  unsigned int pipe,
-					  int *max_error,
-					  struct timeval *vblank_time,
-					  unsigned flags,
-					  const struct drm_display_mode *mode)
+bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
+					   unsigned int pipe,
+					   int *max_error,
+					   struct timeval *vblank_time,
+					   unsigned flags,
+					   const struct drm_display_mode *mode)
 {
 	struct timeval tv_etime;
 	ktime_t stime, etime;
 	unsigned int vbl_status;
-	int ret = DRM_VBLANKTIME_SCANOUTPOS_METHOD;
 	int vpos, hpos, i;
 	int delta_ns, duration_ns;
 
 	if (pipe >= dev->num_crtcs) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Scanout position query not supported? Should not happen. */
 	if (!dev->driver->get_scanout_position) {
 		DRM_ERROR("Called from driver w/o get_scanout_position()!?\n");
-		return -EIO;
+		return false;
 	}
 
 	/* If mode timing undefined, just return as no-op:
@@ -766,7 +755,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 	 */
 	if (mode->crtc_clock == 0) {
 		DRM_DEBUG("crtc %u: Noop due to uninitialized mode.\n", pipe);
-		return -EAGAIN;
+		return false;
 	}
 
 	/* Get current scanout position with system timestamp.
@@ -790,7 +779,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 		if (!(vbl_status & DRM_SCANOUTPOS_VALID)) {
 			DRM_DEBUG("crtc %u : scanoutpos query failed [0x%x].\n",
 				  pipe, vbl_status);
-			return -EIO;
+			return false;
 		}
 
 		/* Compute uncertainty in timestamp of scanout position query. */
@@ -834,7 +823,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 		      (long)vblank_time->tv_sec, (long)vblank_time->tv_usec,
 		      duration_ns/1000, i);
 
-	return ret;
+	return true;
 }
 EXPORT_SYMBOL(drm_calc_vbltimestamp_from_scanoutpos);
 
drivers/gpu/drm/i915/i915_irq.c +4 -4
index 26aa1c170b43..df149d159ce7 100644
@@ -964,7 +964,7 @@ int intel_get_crtc_scanline(struct intel_crtc *crtc)
 	return position;
 }
 
-static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
+static bool i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 			      int *max_error,
 			      struct timeval *vblank_time,
 			      unsigned flags)
@@ -974,19 +974,19 @@ static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 
 	if (pipe >= INTEL_INFO(dev_priv)->num_pipes) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Get drm_crtc to timestamp: */
 	crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
 	if (crtc == NULL) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	if (!crtc->base.hwmode.crtc_clock) {
 		DRM_DEBUG_KMS("crtc %u is disabled\n", pipe);
-		return -EBUSY;
+		return false;
 	}
 
 	/* Helper routine in DRM core does all the work: */
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c +6 -6
index 41ccd2a15d3c..655700eb42ba 100644
@@ -595,23 +595,23 @@ static int mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	return ret;
 }
 
-static int mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
-				     int *max_error,
-				     struct timeval *vblank_time,
-				     unsigned flags)
+static bool mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
+				      int *max_error,
+				      struct timeval *vblank_time,
+				      unsigned flags)
 {
 	struct msm_drm_private *priv = dev->dev_private;
 	struct drm_crtc *crtc;
 
 	if (pipe < 0 || pipe >= priv->num_crtcs) {
 		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	crtc = priv->crtcs[pipe];
 	if (!crtc) {
 		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
drivers/gpu/drm/nouveau/nouveau_display.c +2 -2
index 33269c7df30f..42f18b0b9c43 100644
@@ -156,7 +156,7 @@ nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	return 0;
 }
 
-int
+bool
 nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
 			 int *max_error, struct timeval *time, unsigned flags)
 {
@@ -174,7 +174,7 @@ nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
 		}
 	}
 
-	return -EINVAL;
+	return false;
 }
 
 static void
drivers/gpu/drm/nouveau/nouveau_display.h +2 -2
index 4a75df06c139..bc9d1e7b0117 100644
@@ -71,8 +71,8 @@ void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
 int  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
 				unsigned int, int *, int *, ktime_t *,
 				ktime_t *, const struct drm_display_mode *);
-int  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
-			      struct timeval *, unsigned);
+bool  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
+			       struct timeval *, unsigned);
 
 int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 			    struct drm_pending_vblank_event *event,
drivers/gpu/drm/radeon/radeon_drv.c +4 -4
index 312436a8d9e5..6d79b5c2805b 100644
@@ -114,10 +114,10 @@ int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
 u32 radeon_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int radeon_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void radeon_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-int radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags);
+bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags);
 void radeon_driver_irq_preinstall_kms(struct drm_device *dev);
 int radeon_driver_irq_postinstall_kms(struct drm_device *dev);
 void radeon_driver_irq_uninstall_kms(struct drm_device *dev);
drivers/gpu/drm/radeon/radeon_kms.c +7 -7
index a32a62e03a44..9afe72010c64 100644
@@ -868,25 +868,25 @@ void radeon_disable_vblank_kms(struct drm_device *dev, int crtc)
  *
  * Gets the timestamp on the requested crtc based on the
  * scanout position.  (all asics).
- * Returns postive status flags on success, negative error on failure.
+ * Returns true on success, false on failure.
  */
-int radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags)
+bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags)
 {
 	struct drm_crtc *drmcrtc;
 	struct radeon_device *rdev = dev->dev_private;
 
 	if (crtc < 0 || crtc >= dev->num_crtcs) {
 		DRM_ERROR("Invalid crtc %d\n", crtc);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Get associated drm_crtc: */
 	drmcrtc = &rdev->mode_info.crtcs[crtc]->base;
 	if (!drmcrtc)
-		return -EINVAL;
+		return false;
 
 	/* Helper routine in DRM core does all the work: */
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error,
drivers/gpu/drm/vc4/vc4_crtc.c +1 -1
index 24edd0c22cc9..74260990b6bf 100644
@@ -270,7 +270,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 	return ret;
 }
 
-int vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
+bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
 				  int *max_error, struct timeval *vblank_time,
 				  unsigned flags)
 {
drivers/gpu/drm/vc4/vc4_drv.h +1 -1
index dffce6293d87..8a5d0e12ee02 100644
@@ -450,7 +450,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 			    unsigned int flags, int *vpos, int *hpos,
 			    ktime_t *stime, ktime_t *etime,
 			    const struct drm_display_mode *mode);
-int vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
+bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
 				  int *max_error, struct timeval *vblank_time,
 				  unsigned flags);
 
include/drm/drmP.h +0 -1
index 27ecfcdbf752..6304de7e041e 100644
@@ -322,7 +322,6 @@ struct pci_controller;
 
 /* Flags and return codes for get_vblank_timestamp() driver function. */
 #define DRM_CALLED_FROM_VBLIRQ 1
-#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
 
 /* get_scanout_position() return flags */
 #define DRM_SCANOUTPOS_VALID        (1 << 0)
include/drm/drm_drv.h +3 -4
index d0b5f363bfa1..da78e248d9d8 100644
@@ -316,11 +316,10 @@ struct drm_driver {
 	 *
 	 * Returns:
 	 *
-	 * Zero if timestamping isn't supported in current display mode or a
-	 * negative number on failure. A positive status code on success,
-	 * which describes how the vblank_time timestamp was computed.
+	 * True on success, false on failure, which means the core should
+	 * fallback to a simple timestamp taken in drm_crtc_handle_vblank().
 	 */
-	int (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
+	bool (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
 				     int *max_error,
 				     struct timeval *vblank_time,
 				     unsigned flags);
include/drm/drm_irq.h +5 -5
index cf0be6594c8c..f0d5ccf9b282 100644
@@ -153,11 +153,11 @@ void drm_crtc_vblank_on(struct drm_crtc *crtc);
 void drm_vblank_cleanup(struct drm_device *dev);
 u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
 
-int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
-					  unsigned int pipe, int *max_error,
-					  struct timeval *vblank_time,
-					  unsigned flags,
-					  const struct drm_display_mode *mode);
+bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
+					   unsigned int pipe, int *max_error,
+					   struct timeval *vblank_time,
+					   unsigned flags,
+					   const struct drm_display_mode *mode);
 void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 				     const struct drm_display_mode *mode);
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

A message that is not in the archive (sent off-list or not yet received): [email protected]

#42 lore raw

Re: [Intel-gfx] [PATCH 11/16] drm/vblank: Switch drm_driver->get_vblank_timestamp to return a bool

Quoted 28 lines · Jani Nikula
Quoted 27 lines · Daniel Vetter
Quoted 15 lines · Jani Nikula
Quoted 10 lines · Daniel Vetter

There's really no reason for anything more:
- Calling this while the crtc vblank stuff isn't set up is a driver bug. Those places arlready DRM_ERROR.
- Calling this when the crtc is off is either a driver bug (callin drm_crtc_handle_vblank at the wrong time) or a core bug (for anything else). Again, we DRM_ERROR.
- EINVAL is checked at higher levels already, and if we'd use struct drm_crtc * instead of (dev, pipe) it would be real obvious that those are again core bugs.

Quoted 3 lines

The only valid failure mode is crap hardware that couldn't sample a useful timestamp, to ask the core to just grab a not-so-accurate timestampe. Bool is perfectly fine for that.

Quoted 5 lines

FWIW, I'm not all that thrilled about changing int returns to bools, because it changes the check for success from !ret to ret, and the compiler won't help you. Sure, there aren't many call sites for the function, but, case in point, you forgot to change that lone call site. Though it still works by coincidence.

The old call site treated > 0 as success, and 0 or anything negative as failure. That the lone caller still works is the reason why I've switched to bool, because besides all the funny values that the caller gets and ignreos, it already is.

Quoted 4 lines
Quoted 1 line

Or did I miss something?

Don't you think you should fix the call site too, if you insist on changing the return type?

Oops, I thought I've done that. Will fix up.
-Daniel

Quoted 429 lines

BR,
Jani.

Quoted 419 lines

-Daniel

Quoted 417 lines

BR,
Jani.

Quoted 410 lines
Cc Mario Kleiner <[email protected]>
Cc Eric Anholt <[email protected]>
Cc Rob Clark <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc Ben Skeggs <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h       |  8 +++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   | 14 ++++++------
 drivers/gpu/drm/drm_irq.c                 | 37 +++++++++++--------------------
 drivers/gpu/drm/i915/i915_irq.c           |  8 +++----
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c   | 12 +++++-----
 drivers/gpu/drm/nouveau/nouveau_display.c |  4 ++--
 drivers/gpu/drm/nouveau/nouveau_display.h |  4 ++--
 drivers/gpu/drm/radeon/radeon_drv.c       |  8 +++----
 drivers/gpu/drm/radeon/radeon_kms.c       | 14 ++++++------
 drivers/gpu/drm/vc4/vc4_crtc.c            |  2 +-
 drivers/gpu/drm/vc4/vc4_drv.h             |  2 +-
 include/drm/drmP.h                        |  1 -
 include/drm/drm_drv.h                     |  7 +++---
 include/drm/drm_irq.h                     | 10 ++++-----
 14 files changed, 59 insertions(+), 72 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 -4
index c8860f05bfb9..acd8631d8024 100644
@@ -1768,10 +1768,10 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon);
 u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags);
+bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags);
 long amdgpu_kms_compat_ioctl(struct file *filp, unsigned int cmd,
 			     unsigned long arg);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +7 -7
index 55f951bcc91f..ac42f707c046 100644
@@ -838,19 +838,19 @@ void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe)
  *
  * Gets the timestamp on the requested crtc based on the
  * scanout position.  (all asics).
- * Returns postive status flags on success, negative error on failure.
+ * Returns true on success, false on failure.
  */
-int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags)
+bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags)
 {
 	struct drm_crtc *crtc;
 	struct amdgpu_device *adev = dev->dev_private;
 
 	if (pipe >= dev->num_crtcs) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Get associated drm_crtc: */
@@ -859,7 +859,7 @@ int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
 		/* This can occur on driver load if some component fails to
 		 * initialize completely and driver is unloaded */
 		DRM_ERROR("Uninitialized crtc %d\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Helper routine in DRM core does all the work: */
drivers/gpu/drm/drm_irq.c +13 -24
index 4b0c7475ed13..2121ea29e1b2 100644
@@ -722,43 +722,32 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  * active. Higher level code is expected to handle this.
  *
  * Returns:
- * Negative value on error, failure or if not supported in current
- * video mode:
- *
- * -EINVAL    Invalid CRTC.
- * -EAGAIN    Temporary unavailable, e.g., called before initial modeset.
- * -ENOTSUPP  Function not supported in current display mode.
- * -EIO       Failed, e.g., due to failed scanout position query.
- *
- * Returns or'ed positive status flags on success:
- *
- * DRM_VBLANKTIME_SCANOUTPOS_METHOD - Signal this method used for timestamping.
- * DRM_VBLANKTIME_INVBL - Timestamp taken while scanout was in vblank interval.
  *
+ * Returns true on success, and false on failure, i.e. when no accurate
+ * timestamp could be acquired.
  */
-int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
-					  unsigned int pipe,
-					  int *max_error,
-					  struct timeval *vblank_time,
-					  unsigned flags,
-					  const struct drm_display_mode *mode)
+bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
+					   unsigned int pipe,
+					   int *max_error,
+					   struct timeval *vblank_time,
+					   unsigned flags,
+					   const struct drm_display_mode *mode)
 {
 	struct timeval tv_etime;
 	ktime_t stime, etime;
 	unsigned int vbl_status;
-	int ret = DRM_VBLANKTIME_SCANOUTPOS_METHOD;
 	int vpos, hpos, i;
 	int delta_ns, duration_ns;
 
 	if (pipe >= dev->num_crtcs) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Scanout position query not supported? Should not happen. */
 	if (!dev->driver->get_scanout_position) {
 		DRM_ERROR("Called from driver w/o get_scanout_position()!?\n");
-		return -EIO;
+		return false;
 	}
 
 	/* If mode timing undefined, just return as no-op:
@@ -766,7 +755,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 	 */
 	if (mode->crtc_clock == 0) {
 		DRM_DEBUG("crtc %u: Noop due to uninitialized mode.\n", pipe);
-		return -EAGAIN;
+		return false;
 	}
 
 	/* Get current scanout position with system timestamp.
@@ -790,7 +779,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 		if (!(vbl_status & DRM_SCANOUTPOS_VALID)) {
 			DRM_DEBUG("crtc %u : scanoutpos query failed [0x%x].\n",
 				  pipe, vbl_status);
-			return -EIO;
+			return false;
 		}
 
 		/* Compute uncertainty in timestamp of scanout position query. */
@@ -834,7 +823,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 		      (long)vblank_time->tv_sec, (long)vblank_time->tv_usec,
 		      duration_ns/1000, i);
 
-	return ret;
+	return true;
 }
 EXPORT_SYMBOL(drm_calc_vbltimestamp_from_scanoutpos);
 
drivers/gpu/drm/i915/i915_irq.c +4 -4
index 26aa1c170b43..df149d159ce7 100644
@@ -964,7 +964,7 @@ int intel_get_crtc_scanline(struct intel_crtc *crtc)
 	return position;
 }
 
-static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
+static bool i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 			      int *max_error,
 			      struct timeval *vblank_time,
 			      unsigned flags)
@@ -974,19 +974,19 @@ static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 
 	if (pipe >= INTEL_INFO(dev_priv)->num_pipes) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Get drm_crtc to timestamp: */
 	crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
 	if (crtc == NULL) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	if (!crtc->base.hwmode.crtc_clock) {
 		DRM_DEBUG_KMS("crtc %u is disabled\n", pipe);
-		return -EBUSY;
+		return false;
 	}
 
 	/* Helper routine in DRM core does all the work: */
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c +6 -6
index 41ccd2a15d3c..655700eb42ba 100644
@@ -595,23 +595,23 @@ static int mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	return ret;
 }
 
-static int mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
-				     int *max_error,
-				     struct timeval *vblank_time,
-				     unsigned flags)
+static bool mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
+				      int *max_error,
+				      struct timeval *vblank_time,
+				      unsigned flags)
 {
 	struct msm_drm_private *priv = dev->dev_private;
 	struct drm_crtc *crtc;
 
 	if (pipe < 0 || pipe >= priv->num_crtcs) {
 		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	crtc = priv->crtcs[pipe];
 	if (!crtc) {
 		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
drivers/gpu/drm/nouveau/nouveau_display.c +2 -2
index 33269c7df30f..42f18b0b9c43 100644
@@ -156,7 +156,7 @@ nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	return 0;
 }
 
-int
+bool
 nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
 			 int *max_error, struct timeval *time, unsigned flags)
 {
@@ -174,7 +174,7 @@ nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
 		}
 	}
 
-	return -EINVAL;
+	return false;
 }
 
 static void
drivers/gpu/drm/nouveau/nouveau_display.h +2 -2
index 4a75df06c139..bc9d1e7b0117 100644
@@ -71,8 +71,8 @@ void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
 int  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
 				unsigned int, int *, int *, ktime_t *,
 				ktime_t *, const struct drm_display_mode *);
-int  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
-			      struct timeval *, unsigned);
+bool  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
+			       struct timeval *, unsigned);
 
 int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 			    struct drm_pending_vblank_event *event,
drivers/gpu/drm/radeon/radeon_drv.c +4 -4
index 312436a8d9e5..6d79b5c2805b 100644
@@ -114,10 +114,10 @@ int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
 u32 radeon_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int radeon_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void radeon_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-int radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags);
+bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags);
 void radeon_driver_irq_preinstall_kms(struct drm_device *dev);
 int radeon_driver_irq_postinstall_kms(struct drm_device *dev);
 void radeon_driver_irq_uninstall_kms(struct drm_device *dev);
drivers/gpu/drm/radeon/radeon_kms.c +7 -7
index a32a62e03a44..9afe72010c64 100644
@@ -868,25 +868,25 @@ void radeon_disable_vblank_kms(struct drm_device *dev, int crtc)
  *
  * Gets the timestamp on the requested crtc based on the
  * scanout position.  (all asics).
- * Returns postive status flags on success, negative error on failure.
+ * Returns true on success, false on failure.
  */
-int radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags)
+bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags)
 {
 	struct drm_crtc *drmcrtc;
 	struct radeon_device *rdev = dev->dev_private;
 
 	if (crtc < 0 || crtc >= dev->num_crtcs) {
 		DRM_ERROR("Invalid crtc %d\n", crtc);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Get associated drm_crtc: */
 	drmcrtc = &rdev->mode_info.crtcs[crtc]->base;
 	if (!drmcrtc)
-		return -EINVAL;
+		return false;
 
 	/* Helper routine in DRM core does all the work: */
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error,
drivers/gpu/drm/vc4/vc4_crtc.c +1 -1
index 24edd0c22cc9..74260990b6bf 100644
@@ -270,7 +270,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 	return ret;
 }
 
-int vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
+bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
 				  int *max_error, struct timeval *vblank_time,
 				  unsigned flags)
 {
drivers/gpu/drm/vc4/vc4_drv.h +1 -1
index dffce6293d87..8a5d0e12ee02 100644
@@ -450,7 +450,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 			    unsigned int flags, int *vpos, int *hpos,
 			    ktime_t *stime, ktime_t *etime,
 			    const struct drm_display_mode *mode);
-int vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
+bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
 				  int *max_error, struct timeval *vblank_time,
 				  unsigned flags);
 
include/drm/drmP.h +0 -1
index 27ecfcdbf752..6304de7e041e 100644
@@ -322,7 +322,6 @@ struct pci_controller;
 
 /* Flags and return codes for get_vblank_timestamp() driver function. */
 #define DRM_CALLED_FROM_VBLIRQ 1
-#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
 
 /* get_scanout_position() return flags */
 #define DRM_SCANOUTPOS_VALID        (1 << 0)
include/drm/drm_drv.h +3 -4
index d0b5f363bfa1..da78e248d9d8 100644
@@ -316,11 +316,10 @@ struct drm_driver {
 	 *
 	 * Returns:
 	 *
-	 * Zero if timestamping isn't supported in current display mode or a
-	 * negative number on failure. A positive status code on success,
-	 * which describes how the vblank_time timestamp was computed.
+	 * True on success, false on failure, which means the core should
+	 * fallback to a simple timestamp taken in drm_crtc_handle_vblank().
 	 */
-	int (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
+	bool (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
 				     int *max_error,
 				     struct timeval *vblank_time,
 				     unsigned flags);
include/drm/drm_irq.h +5 -5
index cf0be6594c8c..f0d5ccf9b282 100644
@@ -153,11 +153,11 @@ void drm_crtc_vblank_on(struct drm_crtc *crtc);
 void drm_vblank_cleanup(struct drm_device *dev);
 u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
 
-int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
-					  unsigned int pipe, int *max_error,
-					  struct timeval *vblank_time,
-					  unsigned flags,
-					  const struct drm_display_mode *mode);
+bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
+					   unsigned int pipe, int *max_error,
+					   struct timeval *vblank_time,
+					   unsigned flags,
+					   const struct drm_display_mode *mode);
 void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 				     const struct drm_display_mode *mode);
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
#43 lore raw

PATCH 1/1 drm/vblank: Switch drm_driver->get_vblank_timestamp to return a bool

In reply to Daniel Vetter

There's really no reason for anything more:
- Calling this while the crtc vblank stuff isn't set up is a driver bug. Those places arlready DRM_ERROR.
- Calling this when the crtc is off is either a driver bug (callin drm_crtc_handle_vblank at the wrong time) or a core bug (for anything else). Again, we DRM_ERROR.
- EINVAL is checked at higher levels already, and if we'd use struct drm_crtc * instead of (dev, pipe) it would be real obvious that those are again core bugs.

The only valid failure mode is crap hardware that couldn't sample a useful timestamp, to ask the core to just grab a not-so-accurate timestampe. Bool is perfectly fine for that.

v2: Also fix up the one caller, I lost that in the shuffling (Jani).

Cc Jani Nikula <[email protected]>
Cc Mario Kleiner <[email protected]>
Cc Eric Anholt <[email protected]>
Cc Rob Clark <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc Ben Skeggs <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h       |  8 ++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   | 14 ++++-----
 drivers/gpu/drm/drm_irq.c                 | 49 ++++++++++++-------------------
 drivers/gpu/drm/i915/i915_irq.c           |  8 ++---
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c   | 12 ++++----
 drivers/gpu/drm/nouveau/nouveau_display.c |  4 +--
 drivers/gpu/drm/nouveau/nouveau_display.h |  4 +--
 drivers/gpu/drm/radeon/radeon_drv.c       |  8 ++---
 drivers/gpu/drm/radeon/radeon_kms.c       | 14 ++++-----
 drivers/gpu/drm/vc4/vc4_crtc.c            |  2 +-
 drivers/gpu/drm/vc4/vc4_drv.h             |  2 +-
 include/drm/drmP.h                        |  1 -
 include/drm/drm_drv.h                     |  7 ++---
 include/drm/drm_irq.h                     | 10 +++----
 14 files changed, 64 insertions(+), 79 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 -4
index c8860f05bfb9..acd8631d8024 100644
@@ -1768,10 +1768,10 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon);
 u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags);
+bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags);
 long amdgpu_kms_compat_ioctl(struct file *filp, unsigned int cmd,
 			     unsigned long arg);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +7 -7
index 55f951bcc91f..ac42f707c046 100644
@@ -838,19 +838,19 @@ void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe)
  *
  * Gets the timestamp on the requested crtc based on the
  * scanout position.  (all asics).
- * Returns postive status flags on success, negative error on failure.
+ * Returns true on success, false on failure.
  */
-int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags)
+bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags)
 {
 	struct drm_crtc *crtc;
 	struct amdgpu_device *adev = dev->dev_private;
 
 	if (pipe >= dev->num_crtcs) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Get associated drm_crtc: */
@@ -859,7 +859,7 @@ int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
 		/* This can occur on driver load if some component fails to
 		 * initialize completely and driver is unloaded */
 		DRM_ERROR("Uninitialized crtc %d\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Helper routine in DRM core does all the work: */
drivers/gpu/drm/drm_irq.c +18 -31

107 lines not on this page · raw message

drivers/gpu/drm/i915/i915_irq.c +4 -4
index 26aa1c170b43..df149d159ce7 100644
@@ -964,7 +964,7 @@ int intel_get_crtc_scanline(struct intel_crtc *crtc)
 	return position;
 }
 
-static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
+static bool i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 			      int *max_error,
 			      struct timeval *vblank_time,
 			      unsigned flags)
@@ -974,19 +974,19 @@ static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 
 	if (pipe >= INTEL_INFO(dev_priv)->num_pipes) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Get drm_crtc to timestamp: */
 	crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
 	if (crtc == NULL) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	if (!crtc->base.hwmode.crtc_clock) {
 		DRM_DEBUG_KMS("crtc %u is disabled\n", pipe);
-		return -EBUSY;
+		return false;
 	}
 
 	/* Helper routine in DRM core does all the work: */
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c +6 -6
index 41ccd2a15d3c..655700eb42ba 100644
@@ -595,23 +595,23 @@ static int mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	return ret;
 }
 
-static int mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
-				     int *max_error,
-				     struct timeval *vblank_time,
-				     unsigned flags)
+static bool mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
+				      int *max_error,
+				      struct timeval *vblank_time,
+				      unsigned flags)
 {
 	struct msm_drm_private *priv = dev->dev_private;
 	struct drm_crtc *crtc;
 
 	if (pipe < 0 || pipe >= priv->num_crtcs) {
 		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	crtc = priv->crtcs[pipe];
 	if (!crtc) {
 		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return -EINVAL;
+		return false;
 	}
 
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
drivers/gpu/drm/nouveau/nouveau_display.c +2 -2
index 33269c7df30f..42f18b0b9c43 100644
@@ -156,7 +156,7 @@ nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	return 0;
 }
 
-int
+bool
 nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
 			 int *max_error, struct timeval *time, unsigned flags)
 {
@@ -174,7 +174,7 @@ nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
 		}
 	}
 
-	return -EINVAL;
+	return false;
 }
 
 static void
drivers/gpu/drm/nouveau/nouveau_display.h +2 -2
index 4a75df06c139..bc9d1e7b0117 100644
@@ -71,8 +71,8 @@ void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
 int  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
 				unsigned int, int *, int *, ktime_t *,
 				ktime_t *, const struct drm_display_mode *);
-int  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
-			      struct timeval *, unsigned);
+bool  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
+			       struct timeval *, unsigned);
 
 int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 			    struct drm_pending_vblank_event *event,
drivers/gpu/drm/radeon/radeon_drv.c +4 -4
index 312436a8d9e5..6d79b5c2805b 100644
@@ -114,10 +114,10 @@ int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
 u32 radeon_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int radeon_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void radeon_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-int radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags);
+bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags);
 void radeon_driver_irq_preinstall_kms(struct drm_device *dev);
 int radeon_driver_irq_postinstall_kms(struct drm_device *dev);
 void radeon_driver_irq_uninstall_kms(struct drm_device *dev);
drivers/gpu/drm/radeon/radeon_kms.c +7 -7
index a32a62e03a44..9afe72010c64 100644
@@ -868,25 +868,25 @@ void radeon_disable_vblank_kms(struct drm_device *dev, int crtc)
  *
  * Gets the timestamp on the requested crtc based on the
  * scanout position.  (all asics).
- * Returns postive status flags on success, negative error on failure.
+ * Returns true on success, false on failure.
  */
-int radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
-				    int *max_error,
-				    struct timeval *vblank_time,
-				    unsigned flags)
+bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
+				     int *max_error,
+				     struct timeval *vblank_time,
+				     unsigned flags)
 {
 	struct drm_crtc *drmcrtc;
 	struct radeon_device *rdev = dev->dev_private;
 
 	if (crtc < 0 || crtc >= dev->num_crtcs) {
 		DRM_ERROR("Invalid crtc %d\n", crtc);
-		return -EINVAL;
+		return false;
 	}
 
 	/* Get associated drm_crtc: */
 	drmcrtc = &rdev->mode_info.crtcs[crtc]->base;
 	if (!drmcrtc)
-		return -EINVAL;
+		return false;
 
 	/* Helper routine in DRM core does all the work: */
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error,
drivers/gpu/drm/vc4/vc4_crtc.c +1 -1
index 24edd0c22cc9..74260990b6bf 100644
@@ -270,7 +270,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 	return ret;
 }
 
-int vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
+bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
 				  int *max_error, struct timeval *vblank_time,
 				  unsigned flags)
 {
drivers/gpu/drm/vc4/vc4_drv.h +1 -1
index dffce6293d87..8a5d0e12ee02 100644
@@ -450,7 +450,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 			    unsigned int flags, int *vpos, int *hpos,
 			    ktime_t *stime, ktime_t *etime,
 			    const struct drm_display_mode *mode);
-int vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
+bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
 				  int *max_error, struct timeval *vblank_time,
 				  unsigned flags);
 
include/drm/drmP.h +0 -1
index 27ecfcdbf752..6304de7e041e 100644
@@ -322,7 +322,6 @@ struct pci_controller;
 
 /* Flags and return codes for get_vblank_timestamp() driver function. */
 #define DRM_CALLED_FROM_VBLIRQ 1
-#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
 
 /* get_scanout_position() return flags */
 #define DRM_SCANOUTPOS_VALID        (1 << 0)
include/drm/drm_drv.h +3 -4
index d0b5f363bfa1..da78e248d9d8 100644
@@ -316,11 +316,10 @@ struct drm_driver {
 	 *
 	 * Returns:
 	 *
-	 * Zero if timestamping isn't supported in current display mode or a
-	 * negative number on failure. A positive status code on success,
-	 * which describes how the vblank_time timestamp was computed.
+	 * True on success, false on failure, which means the core should
+	 * fallback to a simple timestamp taken in drm_crtc_handle_vblank().
 	 */
-	int (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
+	bool (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
 				     int *max_error,
 				     struct timeval *vblank_time,
 				     unsigned flags);
include/drm/drm_irq.h +5 -5
index cf0be6594c8c..f0d5ccf9b282 100644
@@ -153,11 +153,11 @@ void drm_crtc_vblank_on(struct drm_crtc *crtc);
 void drm_vblank_cleanup(struct drm_device *dev);
 u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
 
-int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
-					  unsigned int pipe, int *max_error,
-					  struct timeval *vblank_time,
-					  unsigned flags,
-					  const struct drm_display_mode *mode);
+bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
+					   unsigned int pipe, int *max_error,
+					   struct timeval *vblank_time,
+					   unsigned flags,
+					   const struct drm_display_mode *mode);
 void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 				     const struct drm_display_mode *mode);
 
Signature · 6 lines
2.11.0

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

PATCH 15/16 drm/vblank: Simplify the get_scanout_position helper hook

In reply to a message not in the archive

- We can drop the different return value flags, the only caller only cares about whether the scanout position is valid or not. Also, it's entirely undefined what "accurate" means, if we'd really care we should probably wire the max_error through. But since we never even report this to userspace it's kinda moot.

- Drop all the fancy input flags, there's really only the "called from vblank irq" one. Well except for radeon/amdgpu, which added their own private flags.

Since amdgpu/radoen also use the scanoutposition function internally I just gave them a tiny wrapper, plus copies of all the old #defines they need. Everyone else gets simplified code.

Note how we could remove a lot of error conditions if we'd move this helper hook to drm_crtc_helper_funcs and would pass it a crtc directly.

v2: Make it compile on arm.

Cc Mario Kleiner <[email protected]>
Cc Eric Anholt <[email protected]>
Cc Rob Clark <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc Ben Skeggs <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   | 12 +++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h  |  3 +++
 drivers/gpu/drm/drm_irq.c                 | 16 ++++++++--------
 drivers/gpu/drm/i915/i915_irq.c           | 19 ++++++-------------
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c   | 19 +++++++------------
 drivers/gpu/drm/nouveau/nouveau_display.c | 16 +++++++---------
 drivers/gpu/drm/nouveau/nouveau_display.h |  6 +++---
 drivers/gpu/drm/radeon/radeon_drv.c       | 12 +++++++++++-
 drivers/gpu/drm/radeon/radeon_mode.h      |  3 +++
 drivers/gpu/drm/vc4/vc4_crtc.c            | 21 ++++++++++-----------
 drivers/gpu/drm/vc4/vc4_drv.h             |  8 ++++----
 include/drm/drmP.h                        |  8 --------
 include/drm/drm_drv.h                     | 26 ++++++++++----------------
 13 files changed, 83 insertions(+), 86 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +11 -1
index ba169a0699d5..87910850e5dc 100644
@@ -678,6 +678,16 @@ static const struct file_operations amdgpu_driver_kms_fops = {
 #endif
 };
 
+static bool
+amdgpu_get_crtc_scanout_position(struct drm_device *dev, unsigned int pipe,
+				 bool in_vblank_irq, int *vpos, int *hpos,
+				 ktime_t *stime, ktime_t *etime,
+				 const struct drm_display_mode *mode)
+{
+	return amdgpu_get_crtc_scanoutpos(dev, pipe, 0, vpos, hpos,
+					  stime, etime, mode);
+}
+
 static struct drm_driver kms_driver = {
 	.driver_features =
 	    DRIVER_USE_AGP |
@@ -693,7 +703,7 @@ static struct drm_driver kms_driver = {
 	.enable_vblank = amdgpu_enable_vblank_kms,
 	.disable_vblank = amdgpu_disable_vblank_kms,
 	.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
-	.get_scanout_position = amdgpu_get_crtc_scanoutpos,
+	.get_scanout_position = amdgpu_get_crtc_scanout_position,
 #if defined(CONFIG_DEBUG_FS)
 	.debugfs_init = amdgpu_debugfs_init,
 #endif
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +3 -0
index c12497bd3889..6b8f766a6a35 100644
@@ -534,6 +534,9 @@ struct amdgpu_framebuffer {
 				((em) == ATOM_ENCODER_MODE_DP_MST))
 
 /* Driver internal use only flags of amdgpu_get_crtc_scanoutpos() */
+#define DRM_SCANOUTPOS_VALID        (1 << 0)
+#define DRM_SCANOUTPOS_IN_VBLANK    (1 << 1)
+#define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
 #define USE_REAL_VBLANKSTART		(1 << 30)
 #define GET_DISTANCE_TO_VBLANKSTART	(1 << 31)
 
drivers/gpu/drm/drm_irq.c +8 -8
index 61d726b1f810..00e26b4312cc 100644
@@ -744,13 +744,12 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 {
 	struct timeval tv_etime;
 	ktime_t stime, etime;
-	unsigned int vbl_status;
+	bool vbl_status;
 	struct drm_crtc *crtc;
 	const struct drm_display_mode *mode;
 	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
 	int vpos, hpos, i;
 	int delta_ns, duration_ns;
-	unsigned flags = in_vblank_irq ? DRM_CALLED_FROM_VBLIRQ : 0;
 
 	if (!drm_core_check_feature(dev, DRIVER_MODESET))
 		return false;
@@ -793,15 +792,16 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 		 * Get vertical and horizontal scanout position vpos, hpos,
 		 * and bounding timestamps stime, etime, pre/post query.
 		 */
-		vbl_status = dev->driver->get_scanout_position(dev, pipe, flags,
+		vbl_status = dev->driver->get_scanout_position(dev, pipe,
+							       in_vblank_irq,
 							       &vpos, &hpos,
 							       &stime, &etime,
 							       mode);
 
 		/* Return as no-op if scanout query unsupported or failed. */
-		if (!(vbl_status & DRM_SCANOUTPOS_VALID)) {
-			DRM_DEBUG("crtc %u : scanoutpos query failed [0x%x].\n",
-				  pipe, vbl_status);
+		if (!vbl_status) {
+			DRM_DEBUG("crtc %u : scanoutpos query failed.\n",
+				  pipe);
 			return false;
 		}
 
@@ -840,8 +840,8 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 	etime = ktime_sub_ns(etime, delta_ns);
 	*vblank_time = ktime_to_timeval(etime);
 
-	DRM_DEBUG_VBL("crtc %u : v 0x%x p(%d,%d)@ %ld.%ld -> %ld.%ld [e %d us, %d rep]\n",
-		      pipe, vbl_status, hpos, vpos,
+	DRM_DEBUG_VBL("crtc %u : v p(%d,%d)@ %ld.%ld -> %ld.%ld [e %d us, %d rep]\n",
+		      pipe, hpos, vpos,
 		      (long)tv_etime.tv_sec, (long)tv_etime.tv_usec,
 		      (long)vblank_time->tv_sec, (long)vblank_time->tv_usec,
 		      duration_ns/1000, i);
drivers/gpu/drm/i915/i915_irq.c +6 -13
index feadfea77354..a211f9d2e6ca 100644
@@ -827,10 +827,10 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
 	return (position + crtc->scanline_offset) % vtotal;
 }
 
-static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
-				    unsigned int flags, int *vpos, int *hpos,
-				    ktime_t *stime, ktime_t *etime,
-				    const struct drm_display_mode *mode)
+static bool i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
+				     bool in_vblank_irq, int *vpos, int *hpos,
+				     ktime_t *stime, ktime_t *etime,
+				     const struct drm_display_mode *mode)
 {
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct intel_crtc *intel_crtc = intel_get_crtc_for_pipe(dev_priv,
@@ -838,13 +838,12 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	int position;
 	int vbl_start, vbl_end, hsync_start, htotal, vtotal;
 	bool in_vbl = true;
-	int ret = 0;
 	unsigned long irqflags;
 
 	if (WARN_ON(!mode->crtc_clock)) {
 		DRM_DEBUG_DRIVER("trying to get scanoutpos for disabled "
 				 "pipe %c\n", pipe_name(pipe));
-		return 0;
+		return false;
 	}
 
 	htotal = mode->crtc_htotal;
@@ -859,8 +858,6 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
 		vtotal /= 2;
 	}
 
-	ret |= DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE;
-
 	/*
 	 * Lock uncore.lock, as we will do multiple timing critical raw
 	 * register reads, potentially with preemption disabled, so the
@@ -944,11 +941,7 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
 		*hpos = position - (*vpos * htotal);
 	}
 
-	/* In vblank? */
-	if (in_vbl)
-		ret |= DRM_SCANOUTPOS_IN_VBLANK;
-
-	return ret;
+	return true;
 }
 
 int intel_get_crtc_scanline(struct intel_crtc *crtc)
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c +7 -12
index 6ba216b8bba9..959b826123a2 100644
@@ -530,31 +530,28 @@ static struct drm_encoder *get_encoder_from_crtc(struct drm_crtc *crtc)
 	return NULL;
 }
 
-static int mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
-			       unsigned int flags, int *vpos, int *hpos,
-			       ktime_t *stime, ktime_t *etime,
-			       const struct drm_display_mode *mode)
+static bool mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
+				bool in_vblank_irq, int *vpos, int *hpos,
+				ktime_t *stime, ktime_t *etime,
+				const struct drm_display_mode *mode)
 {
 	struct msm_drm_private *priv = dev->dev_private;
 	struct drm_crtc *crtc;
 	struct drm_encoder *encoder;
 	int line, vsw, vbp, vactive_start, vactive_end, vfp_end;
-	int ret = 0;
 
 	crtc = priv->crtcs[pipe];
 	if (!crtc) {
 		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return 0;
+		return false;
 	}
 
 	encoder = get_encoder_from_crtc(crtc);
 	if (!encoder) {
 		DRM_ERROR("no encoder found for crtc %d\n", pipe);
-		return 0;
+		return false;
 	}
 
-	ret |= DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE;
-
 	vsw = mode->crtc_vsync_end - mode->crtc_vsync_start;
 	vbp = mode->crtc_vtotal - mode->crtc_vsync_end;
 
@@ -578,10 +575,8 @@ static int mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
 
 	if (line < vactive_start) {
 		line -= vactive_start;
-		ret |= DRM_SCANOUTPOS_IN_VBLANK;
 	} else if (line > vactive_end) {
 		line = line - vfp_end - vactive_start;
-		ret |= DRM_SCANOUTPOS_IN_VBLANK;
 	} else {
 		line -= vactive_start;
 	}
@@ -592,7 +587,7 @@ static int mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	if (etime)
 		*etime = ktime_get();
 
-	return ret;
+	return true;
 }
 
 static u32 mdp5_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
drivers/gpu/drm/nouveau/nouveau_display.c +7 -9
index e4bdac13d4e9..8b3622afa530 100644
@@ -98,7 +98,7 @@ calc(int blanks, int blanke, int total, int line)
 	return line;
 }
 
-static int
+static bool
 nouveau_display_scanoutpos_head(struct drm_crtc *crtc, int *vpos, int *hpos,
 				ktime_t *stime, ktime_t *etime)
 {
@@ -111,16 +111,16 @@ nouveau_display_scanoutpos_head(struct drm_crtc *crtc, int *vpos, int *hpos,
 	};
 	struct nouveau_display *disp = nouveau_display(crtc->dev);
 	struct drm_vblank_crtc *vblank = &crtc->dev->vblank[drm_crtc_index(crtc)];
-	int ret, retry = 1;
+	int retry = 1;
+	bool ret = false;
 
 	do {
 		ret = nvif_mthd(&disp->disp, 0, &args, sizeof(args));
 		if (ret != 0)
-			return 0;
+			return false;
 
 		if (args.scan.vline) {
-			ret |= DRM_SCANOUTPOS_ACCURATE;
-			ret |= DRM_SCANOUTPOS_VALID;
+			ret = true;
 			break;
 		}
 
@@ -133,14 +133,12 @@ nouveau_display_scanoutpos_head(struct drm_crtc *crtc, int *vpos, int *hpos,
 	if (stime) *stime = ns_to_ktime(args.scan.time[0]);
 	if (etime) *etime = ns_to_ktime(args.scan.time[1]);
 
-	if (*vpos < 0)
-		ret |= DRM_SCANOUTPOS_IN_VBLANK;
 	return ret;
 }
 
-int
+bool
 nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
-			   unsigned int flags, int *vpos, int *hpos,
+			   bool in_vblank_irq, int *vpos, int *hpos,
 			   ktime_t *stime, ktime_t *etime,
 			   const struct drm_display_mode *mode)
 {
drivers/gpu/drm/nouveau/nouveau_display.h +3 -3
index 8360a85ed5ef..b76b65c7c8da 100644
@@ -68,9 +68,9 @@ int  nouveau_display_suspend(struct drm_device *dev, bool runtime);
 void nouveau_display_resume(struct drm_device *dev, bool runtime);
 int  nouveau_display_vblank_enable(struct drm_device *, unsigned int);
 void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
-int  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
-				unsigned int, int *, int *, ktime_t *,
-				ktime_t *, const struct drm_display_mode *);
+bool  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
+				 bool, int *, int *, ktime_t *,
+				 ktime_t *, const struct drm_display_mode *);
 
 int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 			    struct drm_pending_vblank_event *event,
drivers/gpu/drm/radeon/radeon_drv.c +11 -1
index a4bf09cd33f7..669ebfda8038 100644
@@ -525,6 +525,16 @@ static const struct file_operations radeon_driver_kms_fops = {
 #endif
 };
 
+static bool
+radeon_get_crtc_scanout_position(struct drm_device *dev, unsigned int pipe,
+				 bool in_vblank_irq, int *vpos, int *hpos,
+				 ktime_t *stime, ktime_t *etime,
+				 const struct drm_display_mode *mode)
+{
+	return radeon_get_crtc_scanoutpos(dev, pipe, 0, vpos, hpos,
+					  stime, etime, mode);
+}
+
 static struct drm_driver kms_driver = {
 	.driver_features =
 	    DRIVER_USE_AGP |
@@ -540,7 +550,7 @@ static struct drm_driver kms_driver = {
 	.enable_vblank = radeon_enable_vblank_kms,
 	.disable_vblank = radeon_disable_vblank_kms,
 	.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
-	.get_scanout_position = radeon_get_crtc_scanoutpos,
+	.get_scanout_position = radeon_get_crtc_scanout_position,
 	.irq_preinstall = radeon_driver_irq_preinstall_kms,
 	.irq_postinstall = radeon_driver_irq_postinstall_kms,
 	.irq_uninstall = radeon_driver_irq_uninstall_kms,
drivers/gpu/drm/radeon/radeon_mode.h +3 -0
index ad282648fc8b..00f5ec5c12c7 100644
@@ -691,6 +691,9 @@ struct atom_voltage_table
 };
 
 /* Driver internal use only flags of radeon_get_crtc_scanoutpos() */
+#define DRM_SCANOUTPOS_VALID        (1 << 0)
+#define DRM_SCANOUTPOS_IN_VBLANK    (1 << 1)
+#define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
 #define USE_REAL_VBLANKSTART 		(1 << 30)
 #define GET_DISTANCE_TO_VBLANKSTART	(1 << 31)
 
drivers/gpu/drm/vc4/vc4_crtc.c +10 -11
index 2567d6c9a4ee..e871862a21b8 100644
@@ -151,10 +151,10 @@ int vc4_crtc_debugfs_regs(struct seq_file *m, void *unused)
 }
 #endif
 
-int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
-			    unsigned int flags, int *vpos, int *hpos,
-			    ktime_t *stime, ktime_t *etime,
-			    const struct drm_display_mode *mode)
+bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
+			     bool in_vblank_irq, int *vpos, int *hpos,
+			     ktime_t *stime, ktime_t *etime,
+			     const struct drm_display_mode *mode)
 {
 	struct vc4_dev *vc4 = to_vc4_dev(dev);
 	struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
@@ -162,7 +162,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 	u32 val;
 	int fifo_lines;
 	int vblank_lines;
-	int ret = 0;
+	bool ret = false;
 
 	/* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */
 
@@ -198,7 +198,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 	fifo_lines = vc4_crtc->cob_size / mode->crtc_hdisplay;
 
 	if (fifo_lines > 0)
-		ret |= DRM_SCANOUTPOS_VALID;
+		ret = true;
 
 	/* HVS more than fifo_lines into frame for compositing? */
 	if (*vpos > fifo_lines) {
@@ -216,7 +216,6 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 		 */
 		*vpos -= fifo_lines + 1;
 
-		ret |= DRM_SCANOUTPOS_ACCURATE;
 		return ret;
 	}
 
@@ -229,10 +228,9 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 	 * We can't get meaningful readings wrt. scanline position of the PV
 	 * and need to make things up in a approximative but consistent way.
 	 */
-	ret |= DRM_SCANOUTPOS_IN_VBLANK;
 	vblank_lines = mode->vtotal - mode->vdisplay;
 
-	if (flags & DRM_CALLED_FROM_VBLIRQ) {
+	if (in_vblank_irq) {
 		/*
 		 * Assume the irq handler got called close to first
 		 * line of vblank, so PV has about a full vblank
@@ -254,9 +252,10 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 		 * we are at the very beginning of vblank, as the hvs just
 		 * started refilling, and the stime and etime timestamps
 		 * truly correspond to start of vblank.
+		 *
+		 * Unfortunately there's no way to report this to upper levels
+		 * and make it more useful.
 		 */
-		if ((val & SCALER_DISPSTATX_FULL) != SCALER_DISPSTATX_FULL)
-			ret |= DRM_SCANOUTPOS_ACCURATE;
 	} else {
 		/*
 		 * No clue where we are inside vblank. Return a vpos of zero,
drivers/gpu/drm/vc4/vc4_drv.h +4 -4
index 64c92e0eb8f7..c34a0915e49d 100644
@@ -446,10 +446,10 @@ int vc4_bo_stats_debugfs(struct seq_file *m, void *arg);
 extern struct platform_driver vc4_crtc_driver;
 bool vc4_event_pending(struct drm_crtc *crtc);
 int vc4_crtc_debugfs_regs(struct seq_file *m, void *arg);
-int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
-			    unsigned int flags, int *vpos, int *hpos,
-			    ktime_t *stime, ktime_t *etime,
-			    const struct drm_display_mode *mode);
+bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
+			     bool in_vblank_irq, int *vpos, int *hpos,
+			     ktime_t *stime, ktime_t *etime,
+			     const struct drm_display_mode *mode);
 
 /* vc4_debugfs.c */
 int vc4_debugfs_init(struct drm_minor *minor);
include/drm/drmP.h +0 -8
index 6304de7e041e..952c080e6b28 100644
@@ -320,14 +320,6 @@ struct pci_controller;
 #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
 
 
-/* Flags and return codes for get_vblank_timestamp() driver function. */
-#define DRM_CALLED_FROM_VBLIRQ 1
-
-/* get_scanout_position() return flags */
-#define DRM_SCANOUTPOS_VALID        (1 << 0)
-#define DRM_SCANOUTPOS_IN_VBLANK    (1 << 1)
-#define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
-
 /**
  * DRM device structure. This structure represent a complete card that
  * may contain multiple heads.
include/drm/drm_drv.h +10 -16
index 0a367cf5d8d5..e64e33b9dd26 100644
@@ -241,8 +241,10 @@ struct drm_driver {
 	 *     DRM device.
 	 * pipe:
 	 *     Id of the crtc to query.
-	 * flags:
-	 *     Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0).
+	 * in_vblank_irq:
+	 *     True when called from drm_crtc_handle_vblank().  Some drivers
+	 *     need to apply some workarounds for gpu-specific vblank irq quirks
+	 *     if flag is set.
 	 * vpos:
 	 *     Target location for current vertical scanout position.
 	 * hpos:
@@ -263,16 +265,8 @@ struct drm_driver {
 	 *
 	 * Returns:
 	 *
-	 * Flags, or'ed together as follows:
-	 *
-	 * DRM_SCANOUTPOS_VALID:
-	 *     Query successful.
-	 * DRM_SCANOUTPOS_INVBL:
-	 *     Inside vblank.
-	 * DRM_SCANOUTPOS_ACCURATE: Returned position is accurate. A lack of
-	 *     this flag means that returned position may be offset by a
-	 *     constant but unknown small number of scanlines wrt. real scanout
-	 *     position.
+	 * True on success, false if a reliable scanout position counter could
+	 * not be read out.
 	 *
 	 * FIXME:
 	 *
@@ -280,10 +274,10 @@ struct drm_driver {
 	 * move it to &struct drm_crtc_helper_funcs, like all the other
 	 * helper-internal hooks.
 	 */
-	int (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
-				     unsigned int flags, int *vpos, int *hpos,
-				     ktime_t *stime, ktime_t *etime,
-				     const struct drm_display_mode *mode);
+	bool (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
+				      bool in_vblank_irq, int *vpos, int *hpos,
+				      ktime_t *stime, ktime_t *etime,
+				      const struct drm_display_mode *mode);
 
 	/**
 	 * @get_vblank_timestamp:
Signature · 6 lines
2.11.0

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
#45 lore raw

[PATCH] drm/vblank: fix boolreturn.cocci warnings

drivers/gpu/drm/nouveau/nouveau_display.c:154:8-9: WARNING: return of 0/1 in function 'nouveau_display_scanoutpos' with return type bool

drivers/gpu/drm/nouveau/nouveau_display.c:154:8-9: WARNING: return of 0/1 in function 'nouveau_display_scanoutpos' with return type bool

Return statements in functions returning bool should use true/false instead of 1/0.
Generated by: scripts/coccinelle/misc/boolreturn.cocci

---

 nouveau_display.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_display.c +1 -1
@@ -151,7 +151,7 @@ nouveau_display_scanoutpos(struct drm_de
 		}
 	}
 
-	return 0;
+	return false;
 }
 
 static void

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#46 lore raw

Re: [PATCH 15/16] drm/vblank: Simplify the get_scanout_position helper hook

In reply to Daniel Vetter
coccinelle warnings: (new ones prefixed by >>)

Hi Daniel,

[auto build test WARNING on drm/drm-next]
[cannot apply to v4.11-rc3 next-20170324]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Daniel-Vetter/more-drmP-h-cleanup/20170325-030940
base:   git://people.freedesktop.org/~airlied/linux.git drm-next

coccinelle warnings: (new ones prefixed by >>)

>> drivers/gpu/drm/nouveau/nouveau_display.c:154:8-9: WARNING: return of 0/1 in function 'nouveau_display_scanoutpos' with return type bool

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#47 lore raw

PATCH 1/1 drm/vblank: Simplify the get_scanout_position helper hook

In reply to Daniel Vetter

- We can drop the different return value flags, the only caller only cares about whether the scanout position is valid or not. Also, it's entirely undefined what "accurate" means, if we'd really care we should probably wire the max_error through. But since we never even report this to userspace it's kinda moot.

- Drop all the fancy input flags, there's really only the "called from vblank irq" one. Well except for radeon/amdgpu, which added their own private flags.

Since amdgpu/radoen also use the scanoutposition function internally I just gave them a tiny wrapper, plus copies of all the old #defines they need. Everyone else gets simplified code.

Note how we could remove a lot of error conditions if we'd move this helper hook to drm_crtc_helper_funcs and would pass it a crtc directly.

v2: Make it compile on arm.

v3: Squash in fixup from 0day.

Cc Mario Kleiner <[email protected]>
Cc Eric Anholt <[email protected]>
Cc Rob Clark <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc Ben Skeggs <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   | 12 +++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h  |  3 +++
 drivers/gpu/drm/drm_irq.c                 | 16 ++++++++--------
 drivers/gpu/drm/i915/i915_irq.c           | 19 ++++++-------------
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c   | 19 +++++++------------
 drivers/gpu/drm/nouveau/nouveau_display.c | 18 ++++++++----------
 drivers/gpu/drm/nouveau/nouveau_display.h |  6 +++---
 drivers/gpu/drm/radeon/radeon_drv.c       | 12 +++++++++++-
 drivers/gpu/drm/radeon/radeon_mode.h      |  3 +++
 drivers/gpu/drm/vc4/vc4_crtc.c            | 21 ++++++++++-----------
 drivers/gpu/drm/vc4/vc4_drv.h             |  8 ++++----
 include/drm/drmP.h                        |  8 --------
 include/drm/drm_drv.h                     | 26 ++++++++++----------------
 13 files changed, 84 insertions(+), 87 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +11 -1
index 4b4861741d7f..9a0312aadf04 100644
@@ -679,6 +679,16 @@ static const struct file_operations amdgpu_driver_kms_fops = {
 #endif
 };
 
+static bool
+amdgpu_get_crtc_scanout_position(struct drm_device *dev, unsigned int pipe,
+				 bool in_vblank_irq, int *vpos, int *hpos,
+				 ktime_t *stime, ktime_t *etime,
+				 const struct drm_display_mode *mode)
+{
+	return amdgpu_get_crtc_scanoutpos(dev, pipe, 0, vpos, hpos,
+					  stime, etime, mode);
+}
+
 static struct drm_driver kms_driver = {
 	.driver_features =
 	    DRIVER_USE_AGP |
@@ -694,7 +704,7 @@ static struct drm_driver kms_driver = {
 	.enable_vblank = amdgpu_enable_vblank_kms,
 	.disable_vblank = amdgpu_disable_vblank_kms,
 	.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
-	.get_scanout_position = amdgpu_get_crtc_scanoutpos,
+	.get_scanout_position = amdgpu_get_crtc_scanout_position,
 #if defined(CONFIG_DEBUG_FS)
 	.debugfs_init = amdgpu_debugfs_init,
 #endif
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +3 -0
index c12497bd3889..6b8f766a6a35 100644
@@ -534,6 +534,9 @@ struct amdgpu_framebuffer {
 				((em) == ATOM_ENCODER_MODE_DP_MST))
 
 /* Driver internal use only flags of amdgpu_get_crtc_scanoutpos() */
+#define DRM_SCANOUTPOS_VALID        (1 << 0)
+#define DRM_SCANOUTPOS_IN_VBLANK    (1 << 1)
+#define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
 #define USE_REAL_VBLANKSTART		(1 << 30)
 #define GET_DISTANCE_TO_VBLANKSTART	(1 << 31)
 
drivers/gpu/drm/drm_irq.c +8 -8
index 46c923848c16..37541abac0d8 100644
@@ -742,13 +742,12 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 {
 	struct timeval tv_etime;
 	ktime_t stime, etime;
-	unsigned int vbl_status;
+	bool vbl_status;
 	struct drm_crtc *crtc;
 	const struct drm_display_mode *mode;
 	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
 	int vpos, hpos, i;
 	int delta_ns, duration_ns;
-	unsigned flags = in_vblank_irq ? DRM_CALLED_FROM_VBLIRQ : 0;
 
 	if (!drm_core_check_feature(dev, DRIVER_MODESET))
 		return false;
@@ -791,15 +790,16 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 		 * Get vertical and horizontal scanout position vpos, hpos,
 		 * and bounding timestamps stime, etime, pre/post query.
 		 */
-		vbl_status = dev->driver->get_scanout_position(dev, pipe, flags,
+		vbl_status = dev->driver->get_scanout_position(dev, pipe,
+							       in_vblank_irq,
 							       &vpos, &hpos,
 							       &stime, &etime,
 							       mode);
 
 		/* Return as no-op if scanout query unsupported or failed. */
-		if (!(vbl_status & DRM_SCANOUTPOS_VALID)) {
-			DRM_DEBUG("crtc %u : scanoutpos query failed [0x%x].\n",
-				  pipe, vbl_status);
+		if (!vbl_status) {
+			DRM_DEBUG("crtc %u : scanoutpos query failed.\n",
+				  pipe);
 			return false;
 		}
 
@@ -838,8 +838,8 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 	etime = ktime_sub_ns(etime, delta_ns);
 	*vblank_time = ktime_to_timeval(etime);
 
-	DRM_DEBUG_VBL("crtc %u : v 0x%x p(%d,%d)@ %ld.%ld -> %ld.%ld [e %d us, %d rep]\n",
-		      pipe, vbl_status, hpos, vpos,
+	DRM_DEBUG_VBL("crtc %u : v p(%d,%d)@ %ld.%ld -> %ld.%ld [e %d us, %d rep]\n",
+		      pipe, hpos, vpos,
 		      (long)tv_etime.tv_sec, (long)tv_etime.tv_usec,
 		      (long)vblank_time->tv_sec, (long)vblank_time->tv_usec,
 		      duration_ns/1000, i);
drivers/gpu/drm/i915/i915_irq.c +6 -13
index 6d279b8e897f..c9b53c93b4ed 100644
@@ -827,10 +827,10 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
 	return (position + crtc->scanline_offset) % vtotal;
 }
 
-static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
-				    unsigned int flags, int *vpos, int *hpos,
-				    ktime_t *stime, ktime_t *etime,
-				    const struct drm_display_mode *mode)
+static bool i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
+				     bool in_vblank_irq, int *vpos, int *hpos,
+				     ktime_t *stime, ktime_t *etime,
+				     const struct drm_display_mode *mode)
 {
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct intel_crtc *intel_crtc = intel_get_crtc_for_pipe(dev_priv,
@@ -838,13 +838,12 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	int position;
 	int vbl_start, vbl_end, hsync_start, htotal, vtotal;
 	bool in_vbl = true;
-	int ret = 0;
 	unsigned long irqflags;
 
 	if (WARN_ON(!mode->crtc_clock)) {
 		DRM_DEBUG_DRIVER("trying to get scanoutpos for disabled "
 				 "pipe %c\n", pipe_name(pipe));
-		return 0;
+		return false;
 	}
 
 	htotal = mode->crtc_htotal;
@@ -859,8 +858,6 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
 		vtotal /= 2;
 	}
 
-	ret |= DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE;
-
 	/*
 	 * Lock uncore.lock, as we will do multiple timing critical raw
 	 * register reads, potentially with preemption disabled, so the
@@ -944,11 +941,7 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
 		*hpos = position - (*vpos * htotal);
 	}
 
-	/* In vblank? */
-	if (in_vbl)
-		ret |= DRM_SCANOUTPOS_IN_VBLANK;
-
-	return ret;
+	return true;
 }
 
 int intel_get_crtc_scanline(struct intel_crtc *crtc)
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c +7 -12
index 6ba216b8bba9..959b826123a2 100644
@@ -530,31 +530,28 @@ static struct drm_encoder *get_encoder_from_crtc(struct drm_crtc *crtc)
 	return NULL;
 }
 
-static int mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
-			       unsigned int flags, int *vpos, int *hpos,
-			       ktime_t *stime, ktime_t *etime,
-			       const struct drm_display_mode *mode)
+static bool mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
+				bool in_vblank_irq, int *vpos, int *hpos,
+				ktime_t *stime, ktime_t *etime,
+				const struct drm_display_mode *mode)
 {
 	struct msm_drm_private *priv = dev->dev_private;
 	struct drm_crtc *crtc;
 	struct drm_encoder *encoder;
 	int line, vsw, vbp, vactive_start, vactive_end, vfp_end;
-	int ret = 0;
 
 	crtc = priv->crtcs[pipe];
 	if (!crtc) {
 		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return 0;
+		return false;
 	}
 
 	encoder = get_encoder_from_crtc(crtc);
 	if (!encoder) {
 		DRM_ERROR("no encoder found for crtc %d\n", pipe);
-		return 0;
+		return false;
 	}
 
-	ret |= DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE;
-
 	vsw = mode->crtc_vsync_end - mode->crtc_vsync_start;
 	vbp = mode->crtc_vtotal - mode->crtc_vsync_end;
 
@@ -578,10 +575,8 @@ static int mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
 
 	if (line < vactive_start) {
 		line -= vactive_start;
-		ret |= DRM_SCANOUTPOS_IN_VBLANK;
 	} else if (line > vactive_end) {
 		line = line - vfp_end - vactive_start;
-		ret |= DRM_SCANOUTPOS_IN_VBLANK;
 	} else {
 		line -= vactive_start;
 	}
@@ -592,7 +587,7 @@ static int mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	if (etime)
 		*etime = ktime_get();
 
-	return ret;
+	return true;
 }
 
 static u32 mdp5_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
drivers/gpu/drm/nouveau/nouveau_display.c +8 -10
index e4bdac13d4e9..e1829761fdf2 100644
@@ -98,7 +98,7 @@ calc(int blanks, int blanke, int total, int line)
 	return line;
 }
 
-static int
+static bool
 nouveau_display_scanoutpos_head(struct drm_crtc *crtc, int *vpos, int *hpos,
 				ktime_t *stime, ktime_t *etime)
 {
@@ -111,16 +111,16 @@ nouveau_display_scanoutpos_head(struct drm_crtc *crtc, int *vpos, int *hpos,
 	};
 	struct nouveau_display *disp = nouveau_display(crtc->dev);
 	struct drm_vblank_crtc *vblank = &crtc->dev->vblank[drm_crtc_index(crtc)];
-	int ret, retry = 1;
+	int retry = 1;
+	bool ret = false;
 
 	do {
 		ret = nvif_mthd(&disp->disp, 0, &args, sizeof(args));
 		if (ret != 0)
-			return 0;
+			return false;
 
 		if (args.scan.vline) {
-			ret |= DRM_SCANOUTPOS_ACCURATE;
-			ret |= DRM_SCANOUTPOS_VALID;
+			ret = true;
 			break;
 		}
 
@@ -133,14 +133,12 @@ nouveau_display_scanoutpos_head(struct drm_crtc *crtc, int *vpos, int *hpos,
 	if (stime) *stime = ns_to_ktime(args.scan.time[0]);
 	if (etime) *etime = ns_to_ktime(args.scan.time[1]);
 
-	if (*vpos < 0)
-		ret |= DRM_SCANOUTPOS_IN_VBLANK;
 	return ret;
 }
 
-int
+bool
 nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
-			   unsigned int flags, int *vpos, int *hpos,
+			   bool in_vblank_irq, int *vpos, int *hpos,
 			   ktime_t *stime, ktime_t *etime,
 			   const struct drm_display_mode *mode)
 {
@@ -153,7 +151,7 @@ nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
 		}
 	}
 
-	return 0;
+	return false;
 }
 
 static void
drivers/gpu/drm/nouveau/nouveau_display.h +3 -3
index 8360a85ed5ef..b76b65c7c8da 100644
@@ -68,9 +68,9 @@ int  nouveau_display_suspend(struct drm_device *dev, bool runtime);
 void nouveau_display_resume(struct drm_device *dev, bool runtime);
 int  nouveau_display_vblank_enable(struct drm_device *, unsigned int);
 void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
-int  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
-				unsigned int, int *, int *, ktime_t *,
-				ktime_t *, const struct drm_display_mode *);
+bool  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
+				 bool, int *, int *, ktime_t *,
+				 ktime_t *, const struct drm_display_mode *);
 
 int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 			    struct drm_pending_vblank_event *event,
drivers/gpu/drm/radeon/radeon_drv.c +11 -1
index a4bf09cd33f7..669ebfda8038 100644
@@ -525,6 +525,16 @@ static const struct file_operations radeon_driver_kms_fops = {
 #endif
 };
 
+static bool
+radeon_get_crtc_scanout_position(struct drm_device *dev, unsigned int pipe,
+				 bool in_vblank_irq, int *vpos, int *hpos,
+				 ktime_t *stime, ktime_t *etime,
+				 const struct drm_display_mode *mode)
+{
+	return radeon_get_crtc_scanoutpos(dev, pipe, 0, vpos, hpos,
+					  stime, etime, mode);
+}
+
 static struct drm_driver kms_driver = {
 	.driver_features =
 	    DRIVER_USE_AGP |
@@ -540,7 +550,7 @@ static struct drm_driver kms_driver = {
 	.enable_vblank = radeon_enable_vblank_kms,
 	.disable_vblank = radeon_disable_vblank_kms,
 	.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
-	.get_scanout_position = radeon_get_crtc_scanoutpos,
+	.get_scanout_position = radeon_get_crtc_scanout_position,
 	.irq_preinstall = radeon_driver_irq_preinstall_kms,
 	.irq_postinstall = radeon_driver_irq_postinstall_kms,
 	.irq_uninstall = radeon_driver_irq_uninstall_kms,
drivers/gpu/drm/radeon/radeon_mode.h +3 -0
index ad282648fc8b..00f5ec5c12c7 100644
@@ -691,6 +691,9 @@ struct atom_voltage_table
 };
 
 /* Driver internal use only flags of radeon_get_crtc_scanoutpos() */
+#define DRM_SCANOUTPOS_VALID        (1 << 0)
+#define DRM_SCANOUTPOS_IN_VBLANK    (1 << 1)
+#define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
 #define USE_REAL_VBLANKSTART 		(1 << 30)
 #define GET_DISTANCE_TO_VBLANKSTART	(1 << 31)
 
drivers/gpu/drm/vc4/vc4_crtc.c +10 -11
index 2567d6c9a4ee..e871862a21b8 100644
@@ -151,10 +151,10 @@ int vc4_crtc_debugfs_regs(struct seq_file *m, void *unused)
 }
 #endif
 
-int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
-			    unsigned int flags, int *vpos, int *hpos,
-			    ktime_t *stime, ktime_t *etime,
-			    const struct drm_display_mode *mode)
+bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
+			     bool in_vblank_irq, int *vpos, int *hpos,
+			     ktime_t *stime, ktime_t *etime,
+			     const struct drm_display_mode *mode)
 {
 	struct vc4_dev *vc4 = to_vc4_dev(dev);
 	struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
@@ -162,7 +162,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 	u32 val;
 	int fifo_lines;
 	int vblank_lines;
-	int ret = 0;
+	bool ret = false;
 
 	/* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */
 
@@ -198,7 +198,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 	fifo_lines = vc4_crtc->cob_size / mode->crtc_hdisplay;
 
 	if (fifo_lines > 0)
-		ret |= DRM_SCANOUTPOS_VALID;
+		ret = true;
 
 	/* HVS more than fifo_lines into frame for compositing? */
 	if (*vpos > fifo_lines) {
@@ -216,7 +216,6 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 		 */
 		*vpos -= fifo_lines + 1;
 
-		ret |= DRM_SCANOUTPOS_ACCURATE;
 		return ret;
 	}
 
@@ -229,10 +228,9 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 	 * We can't get meaningful readings wrt. scanline position of the PV
 	 * and need to make things up in a approximative but consistent way.
 	 */
-	ret |= DRM_SCANOUTPOS_IN_VBLANK;
 	vblank_lines = mode->vtotal - mode->vdisplay;
 
-	if (flags & DRM_CALLED_FROM_VBLIRQ) {
+	if (in_vblank_irq) {
 		/*
 		 * Assume the irq handler got called close to first
 		 * line of vblank, so PV has about a full vblank
@@ -254,9 +252,10 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 		 * we are at the very beginning of vblank, as the hvs just
 		 * started refilling, and the stime and etime timestamps
 		 * truly correspond to start of vblank.
+		 *
+		 * Unfortunately there's no way to report this to upper levels
+		 * and make it more useful.
 		 */
-		if ((val & SCALER_DISPSTATX_FULL) != SCALER_DISPSTATX_FULL)
-			ret |= DRM_SCANOUTPOS_ACCURATE;
 	} else {
 		/*
 		 * No clue where we are inside vblank. Return a vpos of zero,
drivers/gpu/drm/vc4/vc4_drv.h +4 -4
index 64c92e0eb8f7..c34a0915e49d 100644
@@ -446,10 +446,10 @@ int vc4_bo_stats_debugfs(struct seq_file *m, void *arg);
 extern struct platform_driver vc4_crtc_driver;
 bool vc4_event_pending(struct drm_crtc *crtc);
 int vc4_crtc_debugfs_regs(struct seq_file *m, void *arg);
-int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
-			    unsigned int flags, int *vpos, int *hpos,
-			    ktime_t *stime, ktime_t *etime,
-			    const struct drm_display_mode *mode);
+bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
+			     bool in_vblank_irq, int *vpos, int *hpos,
+			     ktime_t *stime, ktime_t *etime,
+			     const struct drm_display_mode *mode);
 
 /* vc4_debugfs.c */
 int vc4_debugfs_init(struct drm_minor *minor);
include/drm/drmP.h +0 -8
index 6304de7e041e..952c080e6b28 100644
@@ -320,14 +320,6 @@ struct pci_controller;
 #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
 
 
-/* Flags and return codes for get_vblank_timestamp() driver function. */
-#define DRM_CALLED_FROM_VBLIRQ 1
-
-/* get_scanout_position() return flags */
-#define DRM_SCANOUTPOS_VALID        (1 << 0)
-#define DRM_SCANOUTPOS_IN_VBLANK    (1 << 1)
-#define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
-
 /**
  * DRM device structure. This structure represent a complete card that
  * may contain multiple heads.
include/drm/drm_drv.h +10 -16
index 0a367cf5d8d5..e64e33b9dd26 100644
@@ -241,8 +241,10 @@ struct drm_driver {
 	 *     DRM device.
 	 * pipe:
 	 *     Id of the crtc to query.
-	 * flags:
-	 *     Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0).
+	 * in_vblank_irq:
+	 *     True when called from drm_crtc_handle_vblank().  Some drivers
+	 *     need to apply some workarounds for gpu-specific vblank irq quirks
+	 *     if flag is set.
 	 * vpos:
 	 *     Target location for current vertical scanout position.
 	 * hpos:
@@ -263,16 +265,8 @@ struct drm_driver {
 	 *
 	 * Returns:
 	 *
-	 * Flags, or'ed together as follows:
-	 *
-	 * DRM_SCANOUTPOS_VALID:
-	 *     Query successful.
-	 * DRM_SCANOUTPOS_INVBL:
-	 *     Inside vblank.
-	 * DRM_SCANOUTPOS_ACCURATE: Returned position is accurate. A lack of
-	 *     this flag means that returned position may be offset by a
-	 *     constant but unknown small number of scanlines wrt. real scanout
-	 *     position.
+	 * True on success, false if a reliable scanout position counter could
+	 * not be read out.
 	 *
 	 * FIXME:
 	 *
@@ -280,10 +274,10 @@ struct drm_driver {
 	 * move it to &struct drm_crtc_helper_funcs, like all the other
 	 * helper-internal hooks.
 	 */
-	int (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
-				     unsigned int flags, int *vpos, int *hpos,
-				     ktime_t *stime, ktime_t *etime,
-				     const struct drm_display_mode *mode);
+	bool (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
+				      bool in_vblank_irq, int *vpos, int *hpos,
+				      ktime_t *stime, ktime_t *etime,
+				      const struct drm_display_mode *mode);
 
 	/**
 	 * @get_vblank_timestamp:
Signature · 6 lines
2.11.0

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

PATCH 12/16 drm/vblank: Switch to bool in_vblank_irq in get_vblank_timestamp

In reply to Daniel Vetter

It's overkill to have a flag parameter which is essentially used just as a boolean. This takes care of core + adjusting drivers.

Adjusting the scanout position callback is a bit harder, since radeon also supplies it's own driver-private flags in there.

Cc Mario Kleiner <[email protected]>
Cc Eric Anholt <[email protected]>
Cc Rob Clark <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc Ben Skeggs <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h       |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   |  6 ++---
 drivers/gpu/drm/drm_irq.c                 | 41 +++++++++++++++++--------------
 drivers/gpu/drm/i915/i915_irq.c           |  4 +--
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c   |  4 +--
 drivers/gpu/drm/nouveau/nouveau_display.c |  5 ++--
 drivers/gpu/drm/nouveau/nouveau_display.h |  2 +-
 drivers/gpu/drm/radeon/radeon_drv.c       |  2 +-
 drivers/gpu/drm/radeon/radeon_kms.c       |  4 +--
 drivers/gpu/drm/vc4/vc4_crtc.c            |  4 +--
 drivers/gpu/drm/vc4/vc4_drv.h             |  2 +-
 include/drm/drm_drv.h                     | 11 ++++-----
 include/drm/drm_irq.h                     |  2 +-
 13 files changed, 46 insertions(+), 43 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
index acd8631d8024..edb3bb83e1a9 100644
@@ -1771,7 +1771,7 @@ void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
 				     int *max_error,
 				     struct timeval *vblank_time,
-				     unsigned flags);
+				     bool in_vblank_irq);
 long amdgpu_kms_compat_ioctl(struct file *filp, unsigned int cmd,
 			     unsigned long arg);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3 -3
index ac42f707c046..ad295e822d45 100644
@@ -834,7 +834,7 @@ void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe)
  * @crtc: crtc to get the timestamp for
  * @max_error: max error
  * @vblank_time: time value
- * @flags: flags passed to the driver
+ * @in_vblank_irq: called from drm_handle_vblank()
  *
  * Gets the timestamp on the requested crtc based on the
  * scanout position.  (all asics).
@@ -843,7 +843,7 @@ void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe)
 bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
 				     int *max_error,
 				     struct timeval *vblank_time,
-				     unsigned flags)
+				     bool in_vblank_irq)
 {
 	struct drm_crtc *crtc;
 	struct amdgpu_device *adev = dev->dev_private;
@@ -864,7 +864,7 @@ bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
 
 	/* Helper routine in DRM core does all the work: */
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
-						     vblank_time, flags,
+						     vblank_time, in_vblank_irq,
 						     &crtc->hwmode);
 }
 
drivers/gpu/drm/drm_irq.c +22 -19

136 lines not on this page · raw message

drivers/gpu/drm/i915/i915_irq.c +2 -2
index df149d159ce7..6c8a7e1284c3 100644
@@ -967,7 +967,7 @@ int intel_get_crtc_scanline(struct intel_crtc *crtc)
 static bool i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 			      int *max_error,
 			      struct timeval *vblank_time,
-			      unsigned flags)
+			      bool in_vblank_irq)
 {
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct intel_crtc *crtc;
@@ -991,7 +991,7 @@ static bool i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 
 	/* Helper routine in DRM core does all the work: */
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
-						     vblank_time, flags,
+						     vblank_time, in_vblank_irq,
 						     &crtc->base.hwmode);
 }
 
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c +2 -2
index 655700eb42ba..16184ccbdd3b 100644
@@ -598,7 +598,7 @@ static int mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
 static bool mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 				      int *max_error,
 				      struct timeval *vblank_time,
-				      unsigned flags)
+				      bool in_vblank_irq)
 {
 	struct msm_drm_private *priv = dev->dev_private;
 	struct drm_crtc *crtc;
@@ -615,7 +615,7 @@ static bool mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 	}
 
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
-						     vblank_time, flags,
+						     vblank_time, in_vblank_irq,
 						     &crtc->mode);
 }
 
drivers/gpu/drm/nouveau/nouveau_display.c +3 -2
index 42f18b0b9c43..be8ec18ba126 100644
@@ -158,7 +158,7 @@ nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
 
 bool
 nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
-			 int *max_error, struct timeval *time, unsigned flags)
+			 int *max_error, struct timeval *time, bool in_vblank_irq)
 {
 	struct drm_crtc *crtc;
 
@@ -170,7 +170,8 @@ nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
 			else
 				mode = &crtc->hwmode;
 			return drm_calc_vbltimestamp_from_scanoutpos(dev,
-					pipe, max_error, time, flags, mode);
+					pipe, max_error, time, in_vblank_irq,
+					mode);
 		}
 	}
 
drivers/gpu/drm/nouveau/nouveau_display.h +1 -1
index bc9d1e7b0117..f821fc9e2de3 100644
@@ -72,7 +72,7 @@ int  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
 				unsigned int, int *, int *, ktime_t *,
 				ktime_t *, const struct drm_display_mode *);
 bool  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
-			       struct timeval *, unsigned);
+			       struct timeval *, bool);
 
 int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 			    struct drm_pending_vblank_event *event,
drivers/gpu/drm/radeon/radeon_drv.c +1 -1
index 6d79b5c2805b..5fbbc6ac165d 100644
@@ -117,7 +117,7 @@ void radeon_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
 				     int *max_error,
 				     struct timeval *vblank_time,
-				     unsigned flags);
+				     bool in_vblank_irq);
 void radeon_driver_irq_preinstall_kms(struct drm_device *dev);
 int radeon_driver_irq_postinstall_kms(struct drm_device *dev);
 void radeon_driver_irq_uninstall_kms(struct drm_device *dev);
drivers/gpu/drm/radeon/radeon_kms.c +2 -2
index 9afe72010c64..41765d18f863 100644
@@ -873,7 +873,7 @@ void radeon_disable_vblank_kms(struct drm_device *dev, int crtc)
 bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
 				     int *max_error,
 				     struct timeval *vblank_time,
-				     unsigned flags)
+				     bool in_vblank_irq)
 {
 	struct drm_crtc *drmcrtc;
 	struct radeon_device *rdev = dev->dev_private;
@@ -890,7 +890,7 @@ bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
 
 	/* Helper routine in DRM core does all the work: */
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error,
-						     vblank_time, flags,
+						     vblank_time, in_vblank_irq,
 						     &drmcrtc->hwmode);
 }
 
drivers/gpu/drm/vc4/vc4_crtc.c +2 -2
index 74260990b6bf..18bd0d816fe3 100644
@@ -272,14 +272,14 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 
 bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
 				  int *max_error, struct timeval *vblank_time,
-				  unsigned flags)
+				  bool in_vblank_irq)
 {
 	struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
 	struct drm_crtc_state *state = crtc->state;
 
 	/* Helper routine in DRM core does all the work: */
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc_id, max_error,
-						     vblank_time, flags,
+						     vblank_time, in_vblank_irq,
 						     &state->adjusted_mode);
 }
 
drivers/gpu/drm/vc4/vc4_drv.h +1 -1
index 8a5d0e12ee02..815cdeb54971 100644
@@ -452,7 +452,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 			    const struct drm_display_mode *mode);
 bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
 				  int *max_error, struct timeval *vblank_time,
-				  unsigned flags);
+				  bool in_vblank_irq);
 
 /* vc4_debugfs.c */
 int vc4_debugfs_init(struct drm_minor *minor);
include/drm/drm_drv.h +5 -6
index da78e248d9d8..9fe6301edd6a 100644
@@ -308,11 +308,10 @@ struct drm_driver {
 	 *     Returns true upper bound on error for timestamp.
 	 * vblank_time:
 	 *     Target location for returned vblank timestamp.
-	 * flags:
-	 *     0 = Defaults, no special treatment needed.
-	 *     DRM_CALLED_FROM_VBLIRQ = Function is called from vblank
-	 *     irq handler. Some drivers need to apply some workarounds
-	 *     for gpu-specific vblank irq quirks if flag is set.
+	 * in_vblank_irq:
+	 *     True when called from drm_crtc_handle_vblank().  Some drivers
+	 *     need to apply some workarounds for gpu-specific vblank irq quirks
+	 *     if flag is set.
 	 *
 	 * Returns:
 	 *
@@ -322,7 +321,7 @@ struct drm_driver {
 	bool (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
 				     int *max_error,
 				     struct timeval *vblank_time,
-				     unsigned flags);
+				     bool in_vblank_irq);
 
 	/* these have to be filled in */
 
include/drm/drm_irq.h +1 -1
index f0d5ccf9b282..445406efb8dc 100644
@@ -156,7 +156,7 @@ u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
 bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 					   unsigned int pipe, int *max_error,
 					   struct timeval *vblank_time,
-					   unsigned flags,
+					   bool in_vblank_irq,
 					   const struct drm_display_mode *mode);
 void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 				     const struct drm_display_mode *mode);
Signature · 1 line
2.11.0
Reviewed-by on v1 12/16
#49 lore raw

Re: [PATCH 12/16] drm/vblank: Switch to bool in_vblank_irq in get_vblank_timestamp

Quoted 5 lines · Daniel Vetter

It's overkill to have a flag parameter which is essentially used just as a boolean. This takes care of core + adjusting drivers.

Adjusting the scanout position callback is a bit harder, since radeon also supplies it's own driver-private flags in there.

This part worried me, but indeed radeon only passes the custom flag to the scanout position hook. Patch lgtm

Quoted 423 lines
Cc Mario Kleiner <[email protected]>
Cc Eric Anholt <[email protected]>
Cc Rob Clark <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc Ben Skeggs <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h       |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   |  6 ++---
 drivers/gpu/drm/drm_irq.c                 | 41 +++++++++++++++++--------------
 drivers/gpu/drm/i915/i915_irq.c           |  4 +--
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c   |  4 +--
 drivers/gpu/drm/nouveau/nouveau_display.c |  5 ++--
 drivers/gpu/drm/nouveau/nouveau_display.h |  2 +-
 drivers/gpu/drm/radeon/radeon_drv.c       |  2 +-
 drivers/gpu/drm/radeon/radeon_kms.c       |  4 +--
 drivers/gpu/drm/vc4/vc4_crtc.c            |  4 +--
 drivers/gpu/drm/vc4/vc4_drv.h             |  2 +-
 include/drm/drm_drv.h                     | 11 ++++-----
 include/drm/drm_irq.h                     |  2 +-
 13 files changed, 46 insertions(+), 43 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
index acd8631d8024..edb3bb83e1a9 100644
@@ -1771,7 +1771,7 @@ void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
 				     int *max_error,
 				     struct timeval *vblank_time,
-				     unsigned flags);
+				     bool in_vblank_irq);
 long amdgpu_kms_compat_ioctl(struct file *filp, unsigned int cmd,
 			     unsigned long arg);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3 -3
index ac42f707c046..ad295e822d45 100644
@@ -834,7 +834,7 @@ void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe)
  * @crtc: crtc to get the timestamp for
  * @max_error: max error
  * @vblank_time: time value
- * @flags: flags passed to the driver
+ * @in_vblank_irq: called from drm_handle_vblank()
  *
  * Gets the timestamp on the requested crtc based on the
  * scanout position.  (all asics).
@@ -843,7 +843,7 @@ void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe)
 bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
 				     int *max_error,
 				     struct timeval *vblank_time,
-				     unsigned flags)
+				     bool in_vblank_irq)
 {
 	struct drm_crtc *crtc;
 	struct amdgpu_device *adev = dev->dev_private;
@@ -864,7 +864,7 @@ bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
 
 	/* Helper routine in DRM core does all the work: */
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
-						     vblank_time, flags,
+						     vblank_time, in_vblank_irq,
 						     &crtc->hwmode);
 }
 
drivers/gpu/drm/drm_irq.c +22 -19
index 2121ea29e1b2..059c3346db68 100644
@@ -54,7 +54,7 @@
 
 static bool
 drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
-			  struct timeval *tvblank, unsigned flags);
+			  struct timeval *tvblank, bool in_vblank_irq);
 
 static unsigned int drm_timestamp_precision = 20;  /* Default to 20 usecs. */
 
@@ -138,7 +138,7 @@ static void drm_reset_vblank_timestamp(struct drm_device *dev, unsigned int pipe
 	 */
 	do {
 		cur_vblank = __get_vblank_counter(dev, pipe);
-		rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, 0);
+		rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, false);
 	} while (cur_vblank != __get_vblank_counter(dev, pipe) && --count > 0);
 
 	/*
@@ -171,7 +171,7 @@ static void drm_reset_vblank_timestamp(struct drm_device *dev, unsigned int pipe
  * device vblank fields.
  */
 static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
-				    unsigned long flags)
+				    bool in_vblank_irq)
 {
 	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
 	u32 cur_vblank, diff;
@@ -194,7 +194,7 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
 	 */
 	do {
 		cur_vblank = __get_vblank_counter(dev, pipe);
-		rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, flags);
+		rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, in_vblank_irq);
 	} while (cur_vblank != __get_vblank_counter(dev, pipe) && --count > 0);
 
 	if (dev->max_vblank_count != 0) {
@@ -214,13 +214,13 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
 		 */
 		diff = DIV_ROUND_CLOSEST_ULL(diff_ns, framedur_ns);
 
-		if (diff == 0 && flags & DRM_CALLED_FROM_VBLIRQ)
+		if (diff == 0 && in_vblank_irq)
 			DRM_DEBUG_VBL("crtc %u: Redundant vblirq ignored."
 				      " diff_ns = %lld, framedur_ns = %d)\n",
 				      pipe, (long long) diff_ns, framedur_ns);
 	} else {
 		/* some kind of default for drivers w/o accurate vbl timestamping */
-		diff = (flags & DRM_CALLED_FROM_VBLIRQ) != 0;
+		diff = in_vblank_irq ? 1 : 0;
 	}
 
 	/*
@@ -253,7 +253,7 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
 	 * Otherwise reinitialize delayed at next vblank interrupt and assign 0
 	 * for now, to mark the vblanktimestamp as invalid.
 	 */
-	if (!rc && (flags & DRM_CALLED_FROM_VBLIRQ) == 0)
+	if (!rc && in_vblank_irq)
 		t_vblank = (struct timeval) {0, 0};
 
 	store_vblank(dev, pipe, diff, &t_vblank, cur_vblank);
@@ -291,7 +291,7 @@ u32 drm_accurate_vblank_count(struct drm_crtc *crtc)
 
 	spin_lock_irqsave(&dev->vblank_time_lock, flags);
 
-	drm_update_vblank_count(dev, pipe, 0);
+	drm_update_vblank_count(dev, pipe, false);
 	vblank = drm_vblank_count(dev, pipe);
 
 	spin_unlock_irqrestore(&dev->vblank_time_lock, flags);
@@ -347,7 +347,7 @@ static void vblank_disable_and_save(struct drm_device *dev, unsigned int pipe)
 	 * this time. This makes the count account for the entire time
 	 * between drm_crtc_vblank_on() and drm_crtc_vblank_off().
 	 */
-	drm_update_vblank_count(dev, pipe, 0);
+	drm_update_vblank_count(dev, pipe, false);
 
 	spin_unlock_irqrestore(&dev->vblank_time_lock, irqflags);
 }
@@ -698,9 +698,10 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  * @max_error: Desired maximum allowable error in timestamps (nanosecs)
  *             On return contains true maximum error of timestamp
  * @vblank_time: Pointer to struct timeval which should receive the timestamp
- * @flags: Flags to pass to driver:
- *         0 = Default,
- *         DRM_CALLED_FROM_VBLIRQ = If function is called from vbl IRQ handler
+ * @in_vblank_irq:
+ *     True when called from drm_crtc_handle_vblank().  Some drivers
+ *     need to apply some workarounds for gpu-specific vblank irq quirks
+ *     if flag is set.
  * @mode: mode which defines the scanout timings
  *
  * Implements calculation of exact vblank timestamps from given drm_display_mode
@@ -730,7 +731,7 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 					   unsigned int pipe,
 					   int *max_error,
 					   struct timeval *vblank_time,
-					   unsigned flags,
+					   bool in_vblank_irq,
 					   const struct drm_display_mode *mode)
 {
 	struct timeval tv_etime;
@@ -738,6 +739,7 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 	unsigned int vbl_status;
 	int vpos, hpos, i;
 	int delta_ns, duration_ns;
+	unsigned flags = in_vblank_irq ? DRM_CALLED_FROM_VBLIRQ : 0;
 
 	if (pipe >= dev->num_crtcs) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
@@ -841,9 +843,10 @@ static struct timeval get_drm_timestamp(void)
  * @dev: DRM device
  * @pipe: index of CRTC whose vblank timestamp to retrieve
  * @tvblank: Pointer to target struct timeval which should receive the timestamp
- * @flags: Flags to pass to driver:
- *         0 = Default,
- *         DRM_CALLED_FROM_VBLIRQ = If function is called from vbl IRQ handler
+ * @in_vblank_irq:
+ *     True when called from drm_crtc_handle_vblank().  Some drivers
+ *     need to apply some workarounds for gpu-specific vblank irq quirks
+ *     if flag is set.
  *
  * Fetches the system timestamp corresponding to the time of the most recent
  * vblank interval on specified CRTC. May call into kms-driver to
@@ -857,7 +860,7 @@ static struct timeval get_drm_timestamp(void)
  */
 static bool
 drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
-			  struct timeval *tvblank, unsigned flags)
+			  struct timeval *tvblank, bool in_vblank_irq)
 {
 	int ret;
 
@@ -867,7 +870,7 @@ drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
 	/* Query driver if possible and precision timestamping enabled. */
 	if (dev->driver->get_vblank_timestamp && (max_error > 0)) {
 		ret = dev->driver->get_vblank_timestamp(dev, pipe, &max_error,
-							tvblank, flags);
+							tvblank, in_vblank_irq);
 		if (ret > 0)
 			return true;
 	}
@@ -1710,7 +1713,7 @@ bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe)
 		return false;
 	}
 
-	drm_update_vblank_count(dev, pipe, DRM_CALLED_FROM_VBLIRQ);
+	drm_update_vblank_count(dev, pipe, true);
 
 	spin_unlock(&dev->vblank_time_lock);
 
drivers/gpu/drm/i915/i915_irq.c +2 -2
index df149d159ce7..6c8a7e1284c3 100644
@@ -967,7 +967,7 @@ int intel_get_crtc_scanline(struct intel_crtc *crtc)
 static bool i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 			      int *max_error,
 			      struct timeval *vblank_time,
-			      unsigned flags)
+			      bool in_vblank_irq)
 {
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct intel_crtc *crtc;
@@ -991,7 +991,7 @@ static bool i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 
 	/* Helper routine in DRM core does all the work: */
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
-						     vblank_time, flags,
+						     vblank_time, in_vblank_irq,
 						     &crtc->base.hwmode);
 }
 
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c +2 -2
index 655700eb42ba..16184ccbdd3b 100644
@@ -598,7 +598,7 @@ static int mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
 static bool mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 				      int *max_error,
 				      struct timeval *vblank_time,
-				      unsigned flags)
+				      bool in_vblank_irq)
 {
 	struct msm_drm_private *priv = dev->dev_private;
 	struct drm_crtc *crtc;
@@ -615,7 +615,7 @@ static bool mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 	}
 
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
-						     vblank_time, flags,
+						     vblank_time, in_vblank_irq,
 						     &crtc->mode);
 }
 
drivers/gpu/drm/nouveau/nouveau_display.c +3 -2
index 42f18b0b9c43..be8ec18ba126 100644
@@ -158,7 +158,7 @@ nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
 
 bool
 nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
-			 int *max_error, struct timeval *time, unsigned flags)
+			 int *max_error, struct timeval *time, bool in_vblank_irq)
 {
 	struct drm_crtc *crtc;
 
@@ -170,7 +170,8 @@ nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
 			else
 				mode = &crtc->hwmode;
 			return drm_calc_vbltimestamp_from_scanoutpos(dev,
-					pipe, max_error, time, flags, mode);
+					pipe, max_error, time, in_vblank_irq,
+					mode);
 		}
 	}
 
drivers/gpu/drm/nouveau/nouveau_display.h +1 -1
index bc9d1e7b0117..f821fc9e2de3 100644
@@ -72,7 +72,7 @@ int  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
 				unsigned int, int *, int *, ktime_t *,
 				ktime_t *, const struct drm_display_mode *);
 bool  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
-			       struct timeval *, unsigned);
+			       struct timeval *, bool);
 
 int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 			    struct drm_pending_vblank_event *event,
drivers/gpu/drm/radeon/radeon_drv.c +1 -1
index 6d79b5c2805b..5fbbc6ac165d 100644
@@ -117,7 +117,7 @@ void radeon_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
 				     int *max_error,
 				     struct timeval *vblank_time,
-				     unsigned flags);
+				     bool in_vblank_irq);
 void radeon_driver_irq_preinstall_kms(struct drm_device *dev);
 int radeon_driver_irq_postinstall_kms(struct drm_device *dev);
 void radeon_driver_irq_uninstall_kms(struct drm_device *dev);
drivers/gpu/drm/radeon/radeon_kms.c +2 -2
index 9afe72010c64..41765d18f863 100644
@@ -873,7 +873,7 @@ void radeon_disable_vblank_kms(struct drm_device *dev, int crtc)
 bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
 				     int *max_error,
 				     struct timeval *vblank_time,
-				     unsigned flags)
+				     bool in_vblank_irq)
 {
 	struct drm_crtc *drmcrtc;
 	struct radeon_device *rdev = dev->dev_private;
@@ -890,7 +890,7 @@ bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
 
 	/* Helper routine in DRM core does all the work: */
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error,
-						     vblank_time, flags,
+						     vblank_time, in_vblank_irq,
 						     &drmcrtc->hwmode);
 }
 
drivers/gpu/drm/vc4/vc4_crtc.c +2 -2
index 74260990b6bf..18bd0d816fe3 100644
@@ -272,14 +272,14 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 
 bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
 				  int *max_error, struct timeval *vblank_time,
-				  unsigned flags)
+				  bool in_vblank_irq)
 {
 	struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
 	struct drm_crtc_state *state = crtc->state;
 
 	/* Helper routine in DRM core does all the work: */
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc_id, max_error,
-						     vblank_time, flags,
+						     vblank_time, in_vblank_irq,
 						     &state->adjusted_mode);
 }
 
drivers/gpu/drm/vc4/vc4_drv.h +1 -1
index 8a5d0e12ee02..815cdeb54971 100644
@@ -452,7 +452,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 			    const struct drm_display_mode *mode);
 bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
 				  int *max_error, struct timeval *vblank_time,
-				  unsigned flags);
+				  bool in_vblank_irq);
 
 /* vc4_debugfs.c */
 int vc4_debugfs_init(struct drm_minor *minor);
include/drm/drm_drv.h +5 -6
index da78e248d9d8..9fe6301edd6a 100644
@@ -308,11 +308,10 @@ struct drm_driver {
 	 *     Returns true upper bound on error for timestamp.
 	 * vblank_time:
 	 *     Target location for returned vblank timestamp.
-	 * flags:
-	 *     0 = Defaults, no special treatment needed.
-	 *     DRM_CALLED_FROM_VBLIRQ = Function is called from vblank
-	 *     irq handler. Some drivers need to apply some workarounds
-	 *     for gpu-specific vblank irq quirks if flag is set.
+	 * in_vblank_irq:
+	 *     True when called from drm_crtc_handle_vblank().  Some drivers
+	 *     need to apply some workarounds for gpu-specific vblank irq quirks
+	 *     if flag is set.
 	 *
 	 * Returns:
 	 *
@@ -322,7 +321,7 @@ struct drm_driver {
 	bool (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
 				     int *max_error,
 				     struct timeval *vblank_time,
-				     unsigned flags);
+				     bool in_vblank_irq);
 
 	/* these have to be filled in */
 
include/drm/drm_irq.h +1 -1
index f0d5ccf9b282..445406efb8dc 100644
@@ -156,7 +156,7 @@ u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
 bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 					   unsigned int pipe, int *max_error,
 					   struct timeval *vblank_time,
-					   unsigned flags,
+					   bool in_vblank_irq,
 					   const struct drm_display_mode *mode);
 void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 				     const struct drm_display_mode *mode);
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 2 lines
Ville Syrjälä
Intel OTC
#50 lore raw

PATCH 13/16 drm/vblank: Add FIXME comments about moving the vblank ts hooks

In reply to Daniel Vetter

This is going to be a bit too much, but good to have at least a small note about where this should all head towards.

---
 include/drm/drm_drv.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
include/drm/drm_drv.h +10 -0
index 9fe6301edd6a..0a367cf5d8d5 100644
@@ -274,6 +274,11 @@ struct drm_driver {
 	 *     constant but unknown small number of scanlines wrt. real scanout
 	 *     position.
 	 *
+	 * FIXME:
+	 *
+	 * Since this is a helper to implement @get_vblank_timestamp, we should
+	 * move it to &struct drm_crtc_helper_funcs, like all the other
+	 * helper-internal hooks.
 	 */
 	int (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
 				     unsigned int flags, int *vpos, int *hpos,
@@ -317,6 +322,11 @@ struct drm_driver {
 	 *
 	 * True on success, false on failure, which means the core should
 	 * fallback to a simple timestamp taken in drm_crtc_handle_vblank().
+	 *
+	 * FIXME:
+	 *
+	 * We should move this hook to &struct drm_crtc_funcs like all the other
+	 * vblank hooks.
 	 */
 	bool (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
 				     int *max_error,
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#51 lore raw

PATCH 14/16 drm/vblank: drop the mode argument from drm_calc_vbltimestamp_from_scanoutpos

In reply to Daniel Vetter

If we restrict this helper to only kms drivers (which is the case) we can look up the correct mode easily ourselves. But it's a bit tricky:

- All legacy drivers look at crtc->hwmode. But that is update already at the beginning of the modeset helper, which means when we disable a pipe. Hence the final timestamps might be a bit off. But since this is an existing bug I'm not going to change it, but just try to be bug-for-bug compatible with the current code. This only applies to radeon&amdgpu.

- i915 tries to get it perfect by updating crtc->hwmode when the pipe is off (i.e. vblank->enabled = false).

- All other atomic drivers look at crtc->state->adjusted_mode. Those that look at state->requested_mode simply don't adjust their mode, so it's the same. That has two problems: Accessing crtc->state from interrupt handling code is unsafe, and it's updated before we shut down the pipe. For nonblocking modesets it's even worse.

For atomic drivers try to implement what i915 does. To do that we add a new hwmode field to the vblank structure, and update it from drm_calc_timestamping_constants(). For atomic drivers that's called from the right spot by the helper library already, so all fine. But for safety let's enforce that.

For legacy driver this function is only called at the end (oh the fun), which is broken, so again let's not bother and just stay bug-for-bug compatible.

The benefit is that we can use drm_calc_vbltimestamp_from_scanoutpos directly to implement ->get_vblank_timestamp in every driver, deleting a lot of code.

v2: Completely new approach, trying to mimick the i915 solution.

v3: Fixup kerneldoc.

Cc Mario Kleiner <[email protected]>
Cc Eric Anholt <[email protected]>
Cc Rob Clark <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc Ben Skeggs <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h       |  4 ---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   | 41 -------------------------------
 drivers/gpu/drm/drm_irq.c                 | 29 +++++++++++++++++++---
 drivers/gpu/drm/i915/i915_irq.c           | 33 +------------------------
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c   | 26 +-------------------
 drivers/gpu/drm/nouveau/nouveau_display.c | 22 -----------------
 drivers/gpu/drm/nouveau/nouveau_display.h |  2 --
 drivers/gpu/drm/nouveau/nouveau_drm.c     |  2 +-
 drivers/gpu/drm/radeon/radeon_drv.c       |  6 +----
 drivers/gpu/drm/radeon/radeon_kms.c       | 37 ----------------------------
 drivers/gpu/drm/vc4/vc4_crtc.c            | 13 ----------
 drivers/gpu/drm/vc4/vc4_drv.c             |  2 +-
 drivers/gpu/drm/vc4/vc4_drv.h             |  3 ---
 include/drm/drm_irq.h                     | 15 +++++++++--
 15 files changed, 44 insertions(+), 193 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -4
index edb3bb83e1a9..61bef9609b24 100644
@@ -1768,10 +1768,6 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon);
 u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				     int *max_error,
-				     struct timeval *vblank_time,
-				     bool in_vblank_irq);
 long amdgpu_kms_compat_ioctl(struct file *filp, unsigned int cmd,
 			     unsigned long arg);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
index 8a61296fd4cc..ba169a0699d5 100644
@@ -692,7 +692,7 @@ static struct drm_driver kms_driver = {
 	.get_vblank_counter = amdgpu_get_vblank_counter_kms,
 	.enable_vblank = amdgpu_enable_vblank_kms,
 	.disable_vblank = amdgpu_disable_vblank_kms,
-	.get_vblank_timestamp = amdgpu_get_vblank_timestamp_kms,
+	.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 	.get_scanout_position = amdgpu_get_crtc_scanoutpos,
 #if defined(CONFIG_DEBUG_FS)
 	.debugfs_init = amdgpu_debugfs_init,
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -41

47 lines not on this page · raw message

drivers/gpu/drm/drm_irq.c +25 -4
index 059c3346db68..61d726b1f810 100644
@@ -659,6 +659,8 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 	if (WARN_ON(pipe >= dev->num_crtcs))
 		return;
 
+	WARN_ON(drm_drv_uses_atomic_modeset(dev) && vblank->enabled);
+
 	/* Valid dotclock? */
 	if (dotclock > 0) {
 		int frame_size = mode->crtc_htotal * mode->crtc_vtotal;
@@ -682,6 +684,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 
 	vblank->linedur_ns  = linedur_ns;
 	vblank->framedur_ns = framedur_ns;
+	vblank->hwmode = *mode;
 
 	DRM_DEBUG("crtc %u: hwmode: htotal %d, vtotal %d, vdisplay %d\n",
 		  crtc->base.id, mode->crtc_htotal,
@@ -702,7 +705,6 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  *     True when called from drm_crtc_handle_vblank().  Some drivers
  *     need to apply some workarounds for gpu-specific vblank irq quirks
  *     if flag is set.
- * @mode: mode which defines the scanout timings
  *
  * Implements calculation of exact vblank timestamps from given drm_display_mode
  * timings and current video scanout position of a CRTC. This can be called from
@@ -722,6 +724,13 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  * returns as no operation if a doublescan or interlaced video mode is
  * active. Higher level code is expected to handle this.
  *
+ * This function can be used to implement the &drm_driver.get_vblank_timestamp
+ * directly, if the driver implements the &drm_driver.get_scanout_position hook.
+ *
+ * Note that atomic drivers must call drm_calc_timestamping_constants() before
+ * enabling a CRTC. The atomic helpers already take care of that in
+ * drm_atomic_helper_update_legacy_modeset_state().
+ *
  * Returns:
  *
  * Returns true on success, and false on failure, i.e. when no accurate
@@ -731,17 +740,24 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 					   unsigned int pipe,
 					   int *max_error,
 					   struct timeval *vblank_time,
-					   bool in_vblank_irq,
-					   const struct drm_display_mode *mode)
+					   bool in_vblank_irq)
 {
 	struct timeval tv_etime;
 	ktime_t stime, etime;
 	unsigned int vbl_status;
+	struct drm_crtc *crtc;
+	const struct drm_display_mode *mode;
+	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
 	int vpos, hpos, i;
 	int delta_ns, duration_ns;
 	unsigned flags = in_vblank_irq ? DRM_CALLED_FROM_VBLIRQ : 0;
 
-	if (pipe >= dev->num_crtcs) {
+	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+		return false;
+
+	crtc = drm_crtc_from_index(dev, pipe);
+
+	if (pipe >= dev->num_crtcs || !crtc) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
 		return false;
 	}
@@ -752,6 +768,11 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 		return false;
 	}
 
+	if (drm_drv_uses_atomic_modeset(dev))
+		mode = &vblank->hwmode;
+	else
+		mode = &crtc->hwmode;
+
 	/* If mode timing undefined, just return as no-op:
 	 * Happens during initial modesetting of a crtc.
 	 */
drivers/gpu/drm/i915/i915_irq.c +1 -32
index 6c8a7e1284c3..feadfea77354 100644
@@ -964,37 +964,6 @@ int intel_get_crtc_scanline(struct intel_crtc *crtc)
 	return position;
 }
 
-static bool i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
-			      int *max_error,
-			      struct timeval *vblank_time,
-			      bool in_vblank_irq)
-{
-	struct drm_i915_private *dev_priv = to_i915(dev);
-	struct intel_crtc *crtc;
-
-	if (pipe >= INTEL_INFO(dev_priv)->num_pipes) {
-		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return false;
-	}
-
-	/* Get drm_crtc to timestamp: */
-	crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
-	if (crtc == NULL) {
-		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return false;
-	}
-
-	if (!crtc->base.hwmode.crtc_clock) {
-		DRM_DEBUG_KMS("crtc %u is disabled\n", pipe);
-		return false;
-	}
-
-	/* Helper routine in DRM core does all the work: */
-	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
-						     vblank_time, in_vblank_irq,
-						     &crtc->base.hwmode);
-}
-
 static void ironlake_rps_change_irq_handler(struct drm_i915_private *dev_priv)
 {
 	u32 busy_up, busy_down, max_avg, min_avg;
@@ -4328,7 +4297,7 @@ void intel_irq_init(struct drm_i915_private *dev_priv)
 
 	dev_priv->hotplug.hpd_storm_threshold = HPD_STORM_DEFAULT_THRESHOLD;
 
-	dev->driver->get_vblank_timestamp = i915_get_vblank_timestamp;
+	dev->driver->get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos;
 	dev->driver->get_scanout_position = i915_get_crtc_scanoutpos;
 
 	if (IS_CHERRYVIEW(dev_priv)) {
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c +1 -25
index 16184ccbdd3b..6ba216b8bba9 100644
@@ -595,30 +595,6 @@ static int mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	return ret;
 }
 
-static bool mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
-				      int *max_error,
-				      struct timeval *vblank_time,
-				      bool in_vblank_irq)
-{
-	struct msm_drm_private *priv = dev->dev_private;
-	struct drm_crtc *crtc;
-
-	if (pipe < 0 || pipe >= priv->num_crtcs) {
-		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return false;
-	}
-
-	crtc = priv->crtcs[pipe];
-	if (!crtc) {
-		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return false;
-	}
-
-	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
-						     vblank_time, in_vblank_irq,
-						     &crtc->mode);
-}
-
 static u32 mdp5_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
 {
 	struct msm_drm_private *priv = dev->dev_private;
@@ -728,7 +704,7 @@ struct msm_kms *mdp5_kms_init(struct drm_device *dev)
 	dev->mode_config.max_width = 0xffff;
 	dev->mode_config.max_height = 0xffff;
 
-	dev->driver->get_vblank_timestamp = mdp5_get_vblank_timestamp;
+	dev->driver->get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos;
 	dev->driver->get_scanout_position = mdp5_get_scanoutpos;
 	dev->driver->get_vblank_counter = mdp5_get_vblank_counter;
 	dev->max_vblank_count = 0xffffffff;
drivers/gpu/drm/nouveau/nouveau_display.c +0 -22
index be8ec18ba126..e4bdac13d4e9 100644
@@ -156,28 +156,6 @@ nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	return 0;
 }
 
-bool
-nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
-			 int *max_error, struct timeval *time, bool in_vblank_irq)
-{
-	struct drm_crtc *crtc;
-
-	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-		if (nouveau_crtc(crtc)->index == pipe) {
-			struct drm_display_mode *mode;
-			if (drm_drv_uses_atomic_modeset(dev))
-				mode = &crtc->state->adjusted_mode;
-			else
-				mode = &crtc->hwmode;
-			return drm_calc_vbltimestamp_from_scanoutpos(dev,
-					pipe, max_error, time, in_vblank_irq,
-					mode);
-		}
-	}
-
-	return false;
-}
-
 static void
 nouveau_display_vblank_fini(struct drm_device *dev)
 {
drivers/gpu/drm/nouveau/nouveau_display.h +0 -2
index f821fc9e2de3..8360a85ed5ef 100644
@@ -71,8 +71,6 @@ void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
 int  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
 				unsigned int, int *, int *, ktime_t *,
 				ktime_t *, const struct drm_display_mode *);
-bool  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
-			       struct timeval *, bool);
 
 int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 			    struct drm_pending_vblank_event *event,
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -1
index ec719df619a6..1f751a3f570c 100644
@@ -978,7 +978,7 @@ driver_stub = {
 	.enable_vblank = nouveau_display_vblank_enable,
 	.disable_vblank = nouveau_display_vblank_disable,
 	.get_scanout_position = nouveau_display_scanoutpos,
-	.get_vblank_timestamp = nouveau_display_vblstamp,
+	.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 
 	.ioctls = nouveau_ioctls,
 	.num_ioctls = ARRAY_SIZE(nouveau_ioctls),
drivers/gpu/drm/radeon/radeon_drv.c +1 -5
index 5fbbc6ac165d..a4bf09cd33f7 100644
@@ -114,10 +114,6 @@ int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
 u32 radeon_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int radeon_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void radeon_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				     int *max_error,
-				     struct timeval *vblank_time,
-				     bool in_vblank_irq);
 void radeon_driver_irq_preinstall_kms(struct drm_device *dev);
 int radeon_driver_irq_postinstall_kms(struct drm_device *dev);
 void radeon_driver_irq_uninstall_kms(struct drm_device *dev);
@@ -543,7 +539,7 @@ static struct drm_driver kms_driver = {
 	.get_vblank_counter = radeon_get_vblank_counter_kms,
 	.enable_vblank = radeon_enable_vblank_kms,
 	.disable_vblank = radeon_disable_vblank_kms,
-	.get_vblank_timestamp = radeon_get_vblank_timestamp_kms,
+	.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 	.get_scanout_position = radeon_get_crtc_scanoutpos,
 	.irq_preinstall = radeon_driver_irq_preinstall_kms,
 	.irq_postinstall = radeon_driver_irq_postinstall_kms,
drivers/gpu/drm/radeon/radeon_kms.c +0 -37
index 41765d18f863..33b8b3d22969 100644
@@ -857,43 +857,6 @@ void radeon_disable_vblank_kms(struct drm_device *dev, int crtc)
 	spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
 }
 
-/**
- * radeon_get_vblank_timestamp_kms - get vblank timestamp
- *
- * @dev: drm dev pointer
- * @crtc: crtc to get the timestamp for
- * @max_error: max error
- * @vblank_time: time value
- * @flags: flags passed to the driver
- *
- * Gets the timestamp on the requested crtc based on the
- * scanout position.  (all asics).
- * Returns true on success, false on failure.
- */
-bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
-				     int *max_error,
-				     struct timeval *vblank_time,
-				     bool in_vblank_irq)
-{
-	struct drm_crtc *drmcrtc;
-	struct radeon_device *rdev = dev->dev_private;
-
-	if (crtc < 0 || crtc >= dev->num_crtcs) {
-		DRM_ERROR("Invalid crtc %d\n", crtc);
-		return false;
-	}
-
-	/* Get associated drm_crtc: */
-	drmcrtc = &rdev->mode_info.crtcs[crtc]->base;
-	if (!drmcrtc)
-		return false;
-
-	/* Helper routine in DRM core does all the work: */
-	return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error,
-						     vblank_time, in_vblank_irq,
-						     &drmcrtc->hwmode);
-}
-
 const struct drm_ioctl_desc radeon_ioctls_kms[] = {
 	DRM_IOCTL_DEF_DRV(RADEON_CP_INIT, drm_invalid_op, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 	DRM_IOCTL_DEF_DRV(RADEON_CP_START, drm_invalid_op, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
drivers/gpu/drm/vc4/vc4_crtc.c +0 -13
index 18bd0d816fe3..2567d6c9a4ee 100644
@@ -270,19 +270,6 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 	return ret;
 }
 
-bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
-				  int *max_error, struct timeval *vblank_time,
-				  bool in_vblank_irq)
-{
-	struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
-	struct drm_crtc_state *state = crtc->state;
-
-	/* Helper routine in DRM core does all the work: */
-	return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc_id, max_error,
-						     vblank_time, in_vblank_irq,
-						     &state->adjusted_mode);
-}
-
 static void vc4_crtc_destroy(struct drm_crtc *crtc)
 {
 	drm_crtc_cleanup(crtc);
drivers/gpu/drm/vc4/vc4_drv.c +1 -1
index 61e674baf3a6..e864256e12e5 100644
@@ -154,7 +154,7 @@ static struct drm_driver vc4_drm_driver = {
 	.irq_uninstall = vc4_irq_uninstall,
 
 	.get_scanout_position = vc4_crtc_get_scanoutpos,
-	.get_vblank_timestamp = vc4_crtc_get_vblank_timestamp,
+	.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 
 #if defined(CONFIG_DEBUG_FS)
 	.debugfs_init = vc4_debugfs_init,
drivers/gpu/drm/vc4/vc4_drv.h +0 -3
index 815cdeb54971..64c92e0eb8f7 100644
@@ -450,9 +450,6 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 			    unsigned int flags, int *vpos, int *hpos,
 			    ktime_t *stime, ktime_t *etime,
 			    const struct drm_display_mode *mode);
-bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
-				  int *max_error, struct timeval *vblank_time,
-				  bool in_vblank_irq);
 
 /* vc4_debugfs.c */
 int vc4_debugfs_init(struct drm_minor *minor);
include/drm/drm_irq.h +13 -2
index 445406efb8dc..b489cc856e7a 100644
@@ -121,6 +121,18 @@ struct drm_vblank_crtc {
 	 * drm_calc_timestamping_constants().
 	 */
 	int linedur_ns;
+
+	/**
+	 * @hwmode:
+	 *
+	 * Cache of the current hardware display mode. Only valide when @enabled
+	 * is set. This is used by helpers like
+	 * drm_calc_vbltimestamp_from_scanoutpos(). We can't just access the
+	 * hardware mode by e.g. looking at &drm_crtc_state.adjusted_mode,
+	 * because that one is really hard to get at from interrupt context.
+	 */
+	struct drm_display_mode hwmode;
+
 	/**
 	 * @enabled: Tracks the enabling state of the corresponding &drm_crtc to
 	 * avoid double-disabling and hence corrupting saved state. Needed by
@@ -156,8 +168,7 @@ u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
 bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 					   unsigned int pipe, int *max_error,
 					   struct timeval *vblank_time,
-					   bool in_vblank_irq,
-					   const struct drm_display_mode *mode);
+					   bool in_vblank_irq);
 void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 				     const struct drm_display_mode *mode);
 
Signature · 1 line
2.11.0

A message that is not in the archive (sent off-list or not yet received): 20170322083617.13361-15-daniel.vetter-/[email protected]

#53 lore raw

PATCH 1/1 drm/vblank: drop the mode argument from drm_calc_vbltimestamp_from_scanoutpos

If we restrict this helper to only kms drivers (which is the case) we can look up the correct mode easily ourselves. But it's a bit tricky:

- All legacy drivers look at crtc->hwmode. But that is update already at the beginning of the modeset helper, which means when we disable a pipe. Hence the final timestamps might be a bit off. But since this is an existing bug I'm not going to change it, but just try to be bug-for-bug compatible with the current code. This only applies to radeon&amdgpu.

- i915 tries to get it perfect by updating crtc->hwmode when the pipe is off (i.e. vblank->enabled = false).

- All other atomic drivers look at crtc->state->adjusted_mode. Those that look at state->requested_mode simply don't adjust their mode, so it's the same. That has two problems: Accessing crtc->state from interrupt handling code is unsafe, and it's updated before we shut down the pipe. For nonblocking modesets it's even worse.

For atomic drivers try to implement what i915 does. To do that we add a new hwmode field to the vblank structure, and update it from drm_calc_timestamping_constants(). For atomic drivers that's called from the right spot by the helper library already, so all fine. But for safety let's enforce that.

For legacy driver this function is only called at the end (oh the fun), which is broken, so again let's not bother and just stay bug-for-bug compatible.

The benefit is that we can use drm_calc_vbltimestamp_from_scanoutpos directly to implement ->get_vblank_timestamp in every driver, deleting a lot of code.

v2: Completely new approach, trying to mimick the i915 solution.

v3: Fixup kerneldoc.

v4: Drop the WARN_ON to check that the vblank is off, atomic helpers currently unconditionally call this. Recomputing the same stuff should be harmless.

Cc Mario Kleiner <[email protected]>
Cc Eric Anholt <[email protected]>
Cc Rob Clark <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc Ben Skeggs <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h       |  4 ---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   | 41 -------------------------------
 drivers/gpu/drm/drm_irq.c                 | 27 +++++++++++++++++---
 drivers/gpu/drm/i915/i915_irq.c           | 33 +------------------------
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c   | 26 +-------------------
 drivers/gpu/drm/nouveau/nouveau_display.c | 22 -----------------
 drivers/gpu/drm/nouveau/nouveau_display.h |  2 --
 drivers/gpu/drm/nouveau/nouveau_drm.c     |  2 +-
 drivers/gpu/drm/radeon/radeon_drv.c       |  6 +----
 drivers/gpu/drm/radeon/radeon_kms.c       | 37 ----------------------------
 drivers/gpu/drm/vc4/vc4_crtc.c            | 13 ----------
 drivers/gpu/drm/vc4/vc4_drv.c             |  2 +-
 drivers/gpu/drm/vc4/vc4_drv.h             |  3 ---
 include/drm/drm_irq.h                     | 15 +++++++++--
 15 files changed, 42 insertions(+), 193 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -4
index edb3bb83e1a9..61bef9609b24 100644
@@ -1768,10 +1768,6 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon);
 u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				     int *max_error,
-				     struct timeval *vblank_time,
-				     bool in_vblank_irq);
 long amdgpu_kms_compat_ioctl(struct file *filp, unsigned int cmd,
 			     unsigned long arg);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
index 8a61296fd4cc..ba169a0699d5 100644
@@ -692,7 +692,7 @@ static struct drm_driver kms_driver = {
 	.get_vblank_counter = amdgpu_get_vblank_counter_kms,
 	.enable_vblank = amdgpu_enable_vblank_kms,
 	.disable_vblank = amdgpu_disable_vblank_kms,
-	.get_vblank_timestamp = amdgpu_get_vblank_timestamp_kms,
+	.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 	.get_scanout_position = amdgpu_get_crtc_scanoutpos,
 #if defined(CONFIG_DEBUG_FS)
 	.debugfs_init = amdgpu_debugfs_init,
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -41

47 lines not on this page · raw message

drivers/gpu/drm/drm_irq.c +23 -4
index cdb064b46d04..46c923848c16 100644
@@ -682,6 +682,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 
 	vblank->linedur_ns  = linedur_ns;
 	vblank->framedur_ns = framedur_ns;
+	vblank->hwmode = *mode;
 
 	DRM_DEBUG("crtc %u: hwmode: htotal %d, vtotal %d, vdisplay %d\n",
 		  crtc->base.id, mode->crtc_htotal,
@@ -702,7 +703,6 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  *     True when called from drm_crtc_handle_vblank().  Some drivers
  *     need to apply some workarounds for gpu-specific vblank irq quirks
  *     if flag is set.
- * @mode: mode which defines the scanout timings
  *
  * Implements calculation of exact vblank timestamps from given drm_display_mode
  * timings and current video scanout position of a CRTC. This can be called from
@@ -722,6 +722,13 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  * returns as no operation if a doublescan or interlaced video mode is
  * active. Higher level code is expected to handle this.
  *
+ * This function can be used to implement the &drm_driver.get_vblank_timestamp
+ * directly, if the driver implements the &drm_driver.get_scanout_position hook.
+ *
+ * Note that atomic drivers must call drm_calc_timestamping_constants() before
+ * enabling a CRTC. The atomic helpers already take care of that in
+ * drm_atomic_helper_update_legacy_modeset_state().
+ *
  * Returns:
  *
  * Returns true on success, and false on failure, i.e. when no accurate
@@ -731,17 +738,24 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 					   unsigned int pipe,
 					   int *max_error,
 					   struct timeval *vblank_time,
-					   bool in_vblank_irq,
-					   const struct drm_display_mode *mode)
+					   bool in_vblank_irq)
 {
 	struct timeval tv_etime;
 	ktime_t stime, etime;
 	unsigned int vbl_status;
+	struct drm_crtc *crtc;
+	const struct drm_display_mode *mode;
+	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
 	int vpos, hpos, i;
 	int delta_ns, duration_ns;
 	unsigned flags = in_vblank_irq ? DRM_CALLED_FROM_VBLIRQ : 0;
 
-	if (pipe >= dev->num_crtcs) {
+	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+		return false;
+
+	crtc = drm_crtc_from_index(dev, pipe);
+
+	if (pipe >= dev->num_crtcs || !crtc) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
 		return false;
 	}
@@ -752,6 +766,11 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 		return false;
 	}
 
+	if (drm_drv_uses_atomic_modeset(dev))
+		mode = &vblank->hwmode;
+	else
+		mode = &crtc->hwmode;
+
 	/* If mode timing undefined, just return as no-op:
 	 * Happens during initial modesetting of a crtc.
 	 */
drivers/gpu/drm/i915/i915_irq.c +1 -32
index 6c8a7e1284c3..feadfea77354 100644
@@ -964,37 +964,6 @@ int intel_get_crtc_scanline(struct intel_crtc *crtc)
 	return position;
 }
 
-static bool i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
-			      int *max_error,
-			      struct timeval *vblank_time,
-			      bool in_vblank_irq)
-{
-	struct drm_i915_private *dev_priv = to_i915(dev);
-	struct intel_crtc *crtc;
-
-	if (pipe >= INTEL_INFO(dev_priv)->num_pipes) {
-		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return false;
-	}
-
-	/* Get drm_crtc to timestamp: */
-	crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
-	if (crtc == NULL) {
-		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return false;
-	}
-
-	if (!crtc->base.hwmode.crtc_clock) {
-		DRM_DEBUG_KMS("crtc %u is disabled\n", pipe);
-		return false;
-	}
-
-	/* Helper routine in DRM core does all the work: */
-	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
-						     vblank_time, in_vblank_irq,
-						     &crtc->base.hwmode);
-}
-
 static void ironlake_rps_change_irq_handler(struct drm_i915_private *dev_priv)
 {
 	u32 busy_up, busy_down, max_avg, min_avg;
@@ -4328,7 +4297,7 @@ void intel_irq_init(struct drm_i915_private *dev_priv)
 
 	dev_priv->hotplug.hpd_storm_threshold = HPD_STORM_DEFAULT_THRESHOLD;
 
-	dev->driver->get_vblank_timestamp = i915_get_vblank_timestamp;
+	dev->driver->get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos;
 	dev->driver->get_scanout_position = i915_get_crtc_scanoutpos;
 
 	if (IS_CHERRYVIEW(dev_priv)) {
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c +1 -25
index 16184ccbdd3b..6ba216b8bba9 100644
@@ -595,30 +595,6 @@ static int mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	return ret;
 }
 
-static bool mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
-				      int *max_error,
-				      struct timeval *vblank_time,
-				      bool in_vblank_irq)
-{
-	struct msm_drm_private *priv = dev->dev_private;
-	struct drm_crtc *crtc;
-
-	if (pipe < 0 || pipe >= priv->num_crtcs) {
-		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return false;
-	}
-
-	crtc = priv->crtcs[pipe];
-	if (!crtc) {
-		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return false;
-	}
-
-	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
-						     vblank_time, in_vblank_irq,
-						     &crtc->mode);
-}
-
 static u32 mdp5_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
 {
 	struct msm_drm_private *priv = dev->dev_private;
@@ -728,7 +704,7 @@ struct msm_kms *mdp5_kms_init(struct drm_device *dev)
 	dev->mode_config.max_width = 0xffff;
 	dev->mode_config.max_height = 0xffff;
 
-	dev->driver->get_vblank_timestamp = mdp5_get_vblank_timestamp;
+	dev->driver->get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos;
 	dev->driver->get_scanout_position = mdp5_get_scanoutpos;
 	dev->driver->get_vblank_counter = mdp5_get_vblank_counter;
 	dev->max_vblank_count = 0xffffffff;
drivers/gpu/drm/nouveau/nouveau_display.c +0 -22
index be8ec18ba126..e4bdac13d4e9 100644
@@ -156,28 +156,6 @@ nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	return 0;
 }
 
-bool
-nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
-			 int *max_error, struct timeval *time, bool in_vblank_irq)
-{
-	struct drm_crtc *crtc;
-
-	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-		if (nouveau_crtc(crtc)->index == pipe) {
-			struct drm_display_mode *mode;
-			if (drm_drv_uses_atomic_modeset(dev))
-				mode = &crtc->state->adjusted_mode;
-			else
-				mode = &crtc->hwmode;
-			return drm_calc_vbltimestamp_from_scanoutpos(dev,
-					pipe, max_error, time, in_vblank_irq,
-					mode);
-		}
-	}
-
-	return false;
-}
-
 static void
 nouveau_display_vblank_fini(struct drm_device *dev)
 {
drivers/gpu/drm/nouveau/nouveau_display.h +0 -2
index f821fc9e2de3..8360a85ed5ef 100644
@@ -71,8 +71,6 @@ void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
 int  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
 				unsigned int, int *, int *, ktime_t *,
 				ktime_t *, const struct drm_display_mode *);
-bool  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
-			       struct timeval *, bool);
 
 int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 			    struct drm_pending_vblank_event *event,
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -1
index ec719df619a6..1f751a3f570c 100644
@@ -978,7 +978,7 @@ driver_stub = {
 	.enable_vblank = nouveau_display_vblank_enable,
 	.disable_vblank = nouveau_display_vblank_disable,
 	.get_scanout_position = nouveau_display_scanoutpos,
-	.get_vblank_timestamp = nouveau_display_vblstamp,
+	.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 
 	.ioctls = nouveau_ioctls,
 	.num_ioctls = ARRAY_SIZE(nouveau_ioctls),
drivers/gpu/drm/radeon/radeon_drv.c +1 -5
index 5fbbc6ac165d..a4bf09cd33f7 100644
@@ -114,10 +114,6 @@ int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
 u32 radeon_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int radeon_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void radeon_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				     int *max_error,
-				     struct timeval *vblank_time,
-				     bool in_vblank_irq);
 void radeon_driver_irq_preinstall_kms(struct drm_device *dev);
 int radeon_driver_irq_postinstall_kms(struct drm_device *dev);
 void radeon_driver_irq_uninstall_kms(struct drm_device *dev);
@@ -543,7 +539,7 @@ static struct drm_driver kms_driver = {
 	.get_vblank_counter = radeon_get_vblank_counter_kms,
 	.enable_vblank = radeon_enable_vblank_kms,
 	.disable_vblank = radeon_disable_vblank_kms,
-	.get_vblank_timestamp = radeon_get_vblank_timestamp_kms,
+	.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 	.get_scanout_position = radeon_get_crtc_scanoutpos,
 	.irq_preinstall = radeon_driver_irq_preinstall_kms,
 	.irq_postinstall = radeon_driver_irq_postinstall_kms,
drivers/gpu/drm/radeon/radeon_kms.c +0 -37
index 41765d18f863..33b8b3d22969 100644
@@ -857,43 +857,6 @@ void radeon_disable_vblank_kms(struct drm_device *dev, int crtc)
 	spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
 }
 
-/**
- * radeon_get_vblank_timestamp_kms - get vblank timestamp
- *
- * @dev: drm dev pointer
- * @crtc: crtc to get the timestamp for
- * @max_error: max error
- * @vblank_time: time value
- * @flags: flags passed to the driver
- *
- * Gets the timestamp on the requested crtc based on the
- * scanout position.  (all asics).
- * Returns true on success, false on failure.
- */
-bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
-				     int *max_error,
-				     struct timeval *vblank_time,
-				     bool in_vblank_irq)
-{
-	struct drm_crtc *drmcrtc;
-	struct radeon_device *rdev = dev->dev_private;
-
-	if (crtc < 0 || crtc >= dev->num_crtcs) {
-		DRM_ERROR("Invalid crtc %d\n", crtc);
-		return false;
-	}
-
-	/* Get associated drm_crtc: */
-	drmcrtc = &rdev->mode_info.crtcs[crtc]->base;
-	if (!drmcrtc)
-		return false;
-
-	/* Helper routine in DRM core does all the work: */
-	return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error,
-						     vblank_time, in_vblank_irq,
-						     &drmcrtc->hwmode);
-}
-
 const struct drm_ioctl_desc radeon_ioctls_kms[] = {
 	DRM_IOCTL_DEF_DRV(RADEON_CP_INIT, drm_invalid_op, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 	DRM_IOCTL_DEF_DRV(RADEON_CP_START, drm_invalid_op, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
drivers/gpu/drm/vc4/vc4_crtc.c +0 -13
index 18bd0d816fe3..2567d6c9a4ee 100644
@@ -270,19 +270,6 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 	return ret;
 }
 
-bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
-				  int *max_error, struct timeval *vblank_time,
-				  bool in_vblank_irq)
-{
-	struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
-	struct drm_crtc_state *state = crtc->state;
-
-	/* Helper routine in DRM core does all the work: */
-	return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc_id, max_error,
-						     vblank_time, in_vblank_irq,
-						     &state->adjusted_mode);
-}
-
 static void vc4_crtc_destroy(struct drm_crtc *crtc)
 {
 	drm_crtc_cleanup(crtc);
drivers/gpu/drm/vc4/vc4_drv.c +1 -1
index 61e674baf3a6..e864256e12e5 100644
@@ -154,7 +154,7 @@ static struct drm_driver vc4_drm_driver = {
 	.irq_uninstall = vc4_irq_uninstall,
 
 	.get_scanout_position = vc4_crtc_get_scanoutpos,
-	.get_vblank_timestamp = vc4_crtc_get_vblank_timestamp,
+	.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 
 #if defined(CONFIG_DEBUG_FS)
 	.debugfs_init = vc4_debugfs_init,
drivers/gpu/drm/vc4/vc4_drv.h +0 -3
index 815cdeb54971..64c92e0eb8f7 100644
@@ -450,9 +450,6 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 			    unsigned int flags, int *vpos, int *hpos,
 			    ktime_t *stime, ktime_t *etime,
 			    const struct drm_display_mode *mode);
-bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
-				  int *max_error, struct timeval *vblank_time,
-				  bool in_vblank_irq);
 
 /* vc4_debugfs.c */
 int vc4_debugfs_init(struct drm_minor *minor);
include/drm/drm_irq.h +13 -2
index 445406efb8dc..b489cc856e7a 100644
@@ -121,6 +121,18 @@ struct drm_vblank_crtc {
 	 * drm_calc_timestamping_constants().
 	 */
 	int linedur_ns;
+
+	/**
+	 * @hwmode:
+	 *
+	 * Cache of the current hardware display mode. Only valide when @enabled
+	 * is set. This is used by helpers like
+	 * drm_calc_vbltimestamp_from_scanoutpos(). We can't just access the
+	 * hardware mode by e.g. looking at &drm_crtc_state.adjusted_mode,
+	 * because that one is really hard to get at from interrupt context.
+	 */
+	struct drm_display_mode hwmode;
+
 	/**
 	 * @enabled: Tracks the enabling state of the corresponding &drm_crtc to
 	 * avoid double-disabling and hence corrupting saved state. Needed by
@@ -156,8 +168,7 @@ u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
 bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 					   unsigned int pipe, int *max_error,
 					   struct timeval *vblank_time,
-					   bool in_vblank_irq,
-					   const struct drm_display_mode *mode);
+					   bool in_vblank_irq);
 void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 				     const struct drm_display_mode *mode);
 
Signature · 6 lines
2.11.0

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
#54 lore raw

Re: [PATCH] drm/vblank: drop the mode argument from drm_calc_vbltimestamp_from_scanoutpos

Quoted 19 lines · Daniel Vetter

If we restrict this helper to only kms drivers (which is the case) we can look up the correct mode easily ourselves. But it's a bit tricky:

- All legacy drivers look at crtc->hwmode. But that is update already at the beginning of the modeset helper, which means when we disable a pipe. Hence the final timestamps might be a bit off. But since this is an existing bug I'm not going to change it, but just try to be bug-for-bug compatible with the current code. This only applies to radeon&amdgpu.

- i915 tries to get it perfect by updating crtc->hwmode when the pipe is off (i.e. vblank->enabled = false).

- All other atomic drivers look at crtc->state->adjusted_mode. Those that look at state->requested_mode simply don't adjust their mode, so it's the same. That has two problems: Accessing crtc->state from interrupt handling code is unsafe, and it's updated before we shut down the pipe. For nonblocking modesets it's even worse.

Quoted 3 lines

For atomic drivers try to implement what i915 does. To do that we add a new hwmode field to the vblank structure, and update it from drm_calc_timestamping_constants().

i915 clear crtc->hwmode.crtc_clock when turning the crtc off, which this does not do for the new vblank->hwmode. I guess no one should really end up in these codepaths with a disabled crtc, but parts of drm_irq.c sort of look like they're expecting it to happen.

So should we have some way to clear out the vblank->hwmode.crtc_clock for disabled crtcs? And then maybe make some of these crtc_clock checks WARN and eventually just nuke it all if it looks like nothing is hitting those?

Quoted 518 lines

For atomic drivers that's called
from the right spot by the helper library already, so all fine. But for safety let's enforce that.

For legacy driver this function is only called at the end (oh the fun), which is broken, so again let's not bother and just stay bug-for-bug compatible.

The benefit is that we can use drm_calc_vbltimestamp_from_scanoutpos directly to implement ->get_vblank_timestamp in every driver, deleting a lot of code.

v2: Completely new approach, trying to mimick the i915 solution.

v3: Fixup kerneldoc.

v4: Drop the WARN_ON to check that the vblank is off, atomic helpers currently unconditionally call this. Recomputing the same stuff should be harmless.

Cc Mario Kleiner <[email protected]>
Cc Eric Anholt <[email protected]>
Cc Rob Clark <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc Ben Skeggs <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h       |  4 ---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   | 41 -------------------------------
 drivers/gpu/drm/drm_irq.c                 | 27 +++++++++++++++++---
 drivers/gpu/drm/i915/i915_irq.c           | 33 +------------------------
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c   | 26 +-------------------
 drivers/gpu/drm/nouveau/nouveau_display.c | 22 -----------------
 drivers/gpu/drm/nouveau/nouveau_display.h |  2 --
 drivers/gpu/drm/nouveau/nouveau_drm.c     |  2 +-
 drivers/gpu/drm/radeon/radeon_drv.c       |  6 +----
 drivers/gpu/drm/radeon/radeon_kms.c       | 37 ----------------------------
 drivers/gpu/drm/vc4/vc4_crtc.c            | 13 ----------
 drivers/gpu/drm/vc4/vc4_drv.c             |  2 +-
 drivers/gpu/drm/vc4/vc4_drv.h             |  3 ---
 include/drm/drm_irq.h                     | 15 +++++++++--
 15 files changed, 42 insertions(+), 193 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -4
index edb3bb83e1a9..61bef9609b24 100644
@@ -1768,10 +1768,6 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon);
 u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				     int *max_error,
-				     struct timeval *vblank_time,
-				     bool in_vblank_irq);
 long amdgpu_kms_compat_ioctl(struct file *filp, unsigned int cmd,
 			     unsigned long arg);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
index 8a61296fd4cc..ba169a0699d5 100644
@@ -692,7 +692,7 @@ static struct drm_driver kms_driver = {
 	.get_vblank_counter = amdgpu_get_vblank_counter_kms,
 	.enable_vblank = amdgpu_enable_vblank_kms,
 	.disable_vblank = amdgpu_disable_vblank_kms,
-	.get_vblank_timestamp = amdgpu_get_vblank_timestamp_kms,
+	.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 	.get_scanout_position = amdgpu_get_crtc_scanoutpos,
 #if defined(CONFIG_DEBUG_FS)
 	.debugfs_init = amdgpu_debugfs_init,
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -41
index ad295e822d45..32a492bd4e51 100644
@@ -827,47 +827,6 @@ void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe)
 	amdgpu_irq_put(adev, &adev->crtc_irq, idx);
 }
 
-/**
- * amdgpu_get_vblank_timestamp_kms - get vblank timestamp
- *
- * @dev: drm dev pointer
- * @crtc: crtc to get the timestamp for
- * @max_error: max error
- * @vblank_time: time value
- * @in_vblank_irq: called from drm_handle_vblank()
- *
- * Gets the timestamp on the requested crtc based on the
- * scanout position.  (all asics).
- * Returns true on success, false on failure.
- */
-bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				     int *max_error,
-				     struct timeval *vblank_time,
-				     bool in_vblank_irq)
-{
-	struct drm_crtc *crtc;
-	struct amdgpu_device *adev = dev->dev_private;
-
-	if (pipe >= dev->num_crtcs) {
-		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return false;
-	}
-
-	/* Get associated drm_crtc: */
-	crtc = &adev->mode_info.crtcs[pipe]->base;
-	if (!crtc) {
-		/* This can occur on driver load if some component fails to
-		 * initialize completely and driver is unloaded */
-		DRM_ERROR("Uninitialized crtc %d\n", pipe);
-		return false;
-	}
-
-	/* Helper routine in DRM core does all the work: */
-	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
-						     vblank_time, in_vblank_irq,
-						     &crtc->hwmode);
-}
-
 const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {
 	DRM_IOCTL_DEF_DRV(AMDGPU_GEM_CREATE, amdgpu_gem_create_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(AMDGPU_CTX, amdgpu_ctx_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
drivers/gpu/drm/drm_irq.c +23 -4
index cdb064b46d04..46c923848c16 100644
@@ -682,6 +682,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 
 	vblank->linedur_ns  = linedur_ns;
 	vblank->framedur_ns = framedur_ns;
+	vblank->hwmode = *mode;
 
 	DRM_DEBUG("crtc %u: hwmode: htotal %d, vtotal %d, vdisplay %d\n",
 		  crtc->base.id, mode->crtc_htotal,
@@ -702,7 +703,6 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  *     True when called from drm_crtc_handle_vblank().  Some drivers
  *     need to apply some workarounds for gpu-specific vblank irq quirks
  *     if flag is set.
- * @mode: mode which defines the scanout timings
  *
  * Implements calculation of exact vblank timestamps from given drm_display_mode
  * timings and current video scanout position of a CRTC. This can be called from
@@ -722,6 +722,13 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  * returns as no operation if a doublescan or interlaced video mode is
  * active. Higher level code is expected to handle this.
  *
+ * This function can be used to implement the &drm_driver.get_vblank_timestamp
+ * directly, if the driver implements the &drm_driver.get_scanout_position hook.
+ *
+ * Note that atomic drivers must call drm_calc_timestamping_constants() before
+ * enabling a CRTC. The atomic helpers already take care of that in
+ * drm_atomic_helper_update_legacy_modeset_state().
+ *
  * Returns:
  *
  * Returns true on success, and false on failure, i.e. when no accurate
@@ -731,17 +738,24 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 					   unsigned int pipe,
 					   int *max_error,
 					   struct timeval *vblank_time,
-					   bool in_vblank_irq,
-					   const struct drm_display_mode *mode)
+					   bool in_vblank_irq)
 {
 	struct timeval tv_etime;
 	ktime_t stime, etime;
 	unsigned int vbl_status;
+	struct drm_crtc *crtc;
+	const struct drm_display_mode *mode;
+	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
 	int vpos, hpos, i;
 	int delta_ns, duration_ns;
 	unsigned flags = in_vblank_irq ? DRM_CALLED_FROM_VBLIRQ : 0;
 
-	if (pipe >= dev->num_crtcs) {
+	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+		return false;
+
+	crtc = drm_crtc_from_index(dev, pipe);
+
+	if (pipe >= dev->num_crtcs || !crtc) {
 		DRM_ERROR("Invalid crtc %u\n", pipe);
 		return false;
 	}
@@ -752,6 +766,11 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 		return false;
 	}
 
+	if (drm_drv_uses_atomic_modeset(dev))
+		mode = &vblank->hwmode;
+	else
+		mode = &crtc->hwmode;
+
 	/* If mode timing undefined, just return as no-op:
 	 * Happens during initial modesetting of a crtc.
 	 */
drivers/gpu/drm/i915/i915_irq.c +1 -32
index 6c8a7e1284c3..feadfea77354 100644
@@ -964,37 +964,6 @@ int intel_get_crtc_scanline(struct intel_crtc *crtc)
 	return position;
 }
 
-static bool i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
-			      int *max_error,
-			      struct timeval *vblank_time,
-			      bool in_vblank_irq)
-{
-	struct drm_i915_private *dev_priv = to_i915(dev);
-	struct intel_crtc *crtc;
-
-	if (pipe >= INTEL_INFO(dev_priv)->num_pipes) {
-		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return false;
-	}
-
-	/* Get drm_crtc to timestamp: */
-	crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
-	if (crtc == NULL) {
-		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return false;
-	}
-
-	if (!crtc->base.hwmode.crtc_clock) {
-		DRM_DEBUG_KMS("crtc %u is disabled\n", pipe);
-		return false;
-	}
-
-	/* Helper routine in DRM core does all the work: */
-	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
-						     vblank_time, in_vblank_irq,
-						     &crtc->base.hwmode);
-}
-
 static void ironlake_rps_change_irq_handler(struct drm_i915_private *dev_priv)
 {
 	u32 busy_up, busy_down, max_avg, min_avg;
@@ -4328,7 +4297,7 @@ void intel_irq_init(struct drm_i915_private *dev_priv)
 
 	dev_priv->hotplug.hpd_storm_threshold = HPD_STORM_DEFAULT_THRESHOLD;
 
-	dev->driver->get_vblank_timestamp = i915_get_vblank_timestamp;
+	dev->driver->get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos;
 	dev->driver->get_scanout_position = i915_get_crtc_scanoutpos;
 
 	if (IS_CHERRYVIEW(dev_priv)) {
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c +1 -25
index 16184ccbdd3b..6ba216b8bba9 100644
@@ -595,30 +595,6 @@ static int mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	return ret;
 }
 
-static bool mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
-				      int *max_error,
-				      struct timeval *vblank_time,
-				      bool in_vblank_irq)
-{
-	struct msm_drm_private *priv = dev->dev_private;
-	struct drm_crtc *crtc;
-
-	if (pipe < 0 || pipe >= priv->num_crtcs) {
-		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return false;
-	}
-
-	crtc = priv->crtcs[pipe];
-	if (!crtc) {
-		DRM_ERROR("Invalid crtc %d\n", pipe);
-		return false;
-	}
-
-	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
-						     vblank_time, in_vblank_irq,
-						     &crtc->mode);
-}
-
 static u32 mdp5_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
 {
 	struct msm_drm_private *priv = dev->dev_private;
@@ -728,7 +704,7 @@ struct msm_kms *mdp5_kms_init(struct drm_device *dev)
 	dev->mode_config.max_width = 0xffff;
 	dev->mode_config.max_height = 0xffff;
 
-	dev->driver->get_vblank_timestamp = mdp5_get_vblank_timestamp;
+	dev->driver->get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos;
 	dev->driver->get_scanout_position = mdp5_get_scanoutpos;
 	dev->driver->get_vblank_counter = mdp5_get_vblank_counter;
 	dev->max_vblank_count = 0xffffffff;
drivers/gpu/drm/nouveau/nouveau_display.c +0 -22
index be8ec18ba126..e4bdac13d4e9 100644
@@ -156,28 +156,6 @@ nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
 	return 0;
 }
 
-bool
-nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
-			 int *max_error, struct timeval *time, bool in_vblank_irq)
-{
-	struct drm_crtc *crtc;
-
-	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-		if (nouveau_crtc(crtc)->index == pipe) {
-			struct drm_display_mode *mode;
-			if (drm_drv_uses_atomic_modeset(dev))
-				mode = &crtc->state->adjusted_mode;
-			else
-				mode = &crtc->hwmode;
-			return drm_calc_vbltimestamp_from_scanoutpos(dev,
-					pipe, max_error, time, in_vblank_irq,
-					mode);
-		}
-	}
-
-	return false;
-}
-
 static void
 nouveau_display_vblank_fini(struct drm_device *dev)
 {
drivers/gpu/drm/nouveau/nouveau_display.h +0 -2
index f821fc9e2de3..8360a85ed5ef 100644
@@ -71,8 +71,6 @@ void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
 int  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
 				unsigned int, int *, int *, ktime_t *,
 				ktime_t *, const struct drm_display_mode *);
-bool  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
-			       struct timeval *, bool);
 
 int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 			    struct drm_pending_vblank_event *event,
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -1
index ec719df619a6..1f751a3f570c 100644
@@ -978,7 +978,7 @@ driver_stub = {
 	.enable_vblank = nouveau_display_vblank_enable,
 	.disable_vblank = nouveau_display_vblank_disable,
 	.get_scanout_position = nouveau_display_scanoutpos,
-	.get_vblank_timestamp = nouveau_display_vblstamp,
+	.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 
 	.ioctls = nouveau_ioctls,
 	.num_ioctls = ARRAY_SIZE(nouveau_ioctls),
drivers/gpu/drm/radeon/radeon_drv.c +1 -5
index 5fbbc6ac165d..a4bf09cd33f7 100644
@@ -114,10 +114,6 @@ int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
 u32 radeon_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int radeon_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void radeon_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
-				     int *max_error,
-				     struct timeval *vblank_time,
-				     bool in_vblank_irq);
 void radeon_driver_irq_preinstall_kms(struct drm_device *dev);
 int radeon_driver_irq_postinstall_kms(struct drm_device *dev);
 void radeon_driver_irq_uninstall_kms(struct drm_device *dev);
@@ -543,7 +539,7 @@ static struct drm_driver kms_driver = {
 	.get_vblank_counter = radeon_get_vblank_counter_kms,
 	.enable_vblank = radeon_enable_vblank_kms,
 	.disable_vblank = radeon_disable_vblank_kms,
-	.get_vblank_timestamp = radeon_get_vblank_timestamp_kms,
+	.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 	.get_scanout_position = radeon_get_crtc_scanoutpos,
 	.irq_preinstall = radeon_driver_irq_preinstall_kms,
 	.irq_postinstall = radeon_driver_irq_postinstall_kms,
drivers/gpu/drm/radeon/radeon_kms.c +0 -37
index 41765d18f863..33b8b3d22969 100644
@@ -857,43 +857,6 @@ void radeon_disable_vblank_kms(struct drm_device *dev, int crtc)
 	spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
 }
 
-/**
- * radeon_get_vblank_timestamp_kms - get vblank timestamp
- *
- * @dev: drm dev pointer
- * @crtc: crtc to get the timestamp for
- * @max_error: max error
- * @vblank_time: time value
- * @flags: flags passed to the driver
- *
- * Gets the timestamp on the requested crtc based on the
- * scanout position.  (all asics).
- * Returns true on success, false on failure.
- */
-bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
-				     int *max_error,
-				     struct timeval *vblank_time,
-				     bool in_vblank_irq)
-{
-	struct drm_crtc *drmcrtc;
-	struct radeon_device *rdev = dev->dev_private;
-
-	if (crtc < 0 || crtc >= dev->num_crtcs) {
-		DRM_ERROR("Invalid crtc %d\n", crtc);
-		return false;
-	}
-
-	/* Get associated drm_crtc: */
-	drmcrtc = &rdev->mode_info.crtcs[crtc]->base;
-	if (!drmcrtc)
-		return false;
-
-	/* Helper routine in DRM core does all the work: */
-	return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error,
-						     vblank_time, in_vblank_irq,
-						     &drmcrtc->hwmode);
-}
-
 const struct drm_ioctl_desc radeon_ioctls_kms[] = {
 	DRM_IOCTL_DEF_DRV(RADEON_CP_INIT, drm_invalid_op, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 	DRM_IOCTL_DEF_DRV(RADEON_CP_START, drm_invalid_op, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
drivers/gpu/drm/vc4/vc4_crtc.c +0 -13
index 18bd0d816fe3..2567d6c9a4ee 100644
@@ -270,19 +270,6 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 	return ret;
 }
 
-bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
-				  int *max_error, struct timeval *vblank_time,
-				  bool in_vblank_irq)
-{
-	struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
-	struct drm_crtc_state *state = crtc->state;
-
-	/* Helper routine in DRM core does all the work: */
-	return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc_id, max_error,
-						     vblank_time, in_vblank_irq,
-						     &state->adjusted_mode);
-}
-
 static void vc4_crtc_destroy(struct drm_crtc *crtc)
 {
 	drm_crtc_cleanup(crtc);
drivers/gpu/drm/vc4/vc4_drv.c +1 -1
index 61e674baf3a6..e864256e12e5 100644
@@ -154,7 +154,7 @@ static struct drm_driver vc4_drm_driver = {
 	.irq_uninstall = vc4_irq_uninstall,
 
 	.get_scanout_position = vc4_crtc_get_scanoutpos,
-	.get_vblank_timestamp = vc4_crtc_get_vblank_timestamp,
+	.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 
 #if defined(CONFIG_DEBUG_FS)
 	.debugfs_init = vc4_debugfs_init,
drivers/gpu/drm/vc4/vc4_drv.h +0 -3
index 815cdeb54971..64c92e0eb8f7 100644
@@ -450,9 +450,6 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 			    unsigned int flags, int *vpos, int *hpos,
 			    ktime_t *stime, ktime_t *etime,
 			    const struct drm_display_mode *mode);
-bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
-				  int *max_error, struct timeval *vblank_time,
-				  bool in_vblank_irq);
 
 /* vc4_debugfs.c */
 int vc4_debugfs_init(struct drm_minor *minor);
include/drm/drm_irq.h +13 -2
index 445406efb8dc..b489cc856e7a 100644
@@ -121,6 +121,18 @@ struct drm_vblank_crtc {
 	 * drm_calc_timestamping_constants().
 	 */
 	int linedur_ns;
+
+	/**
+	 * @hwmode:
+	 *
+	 * Cache of the current hardware display mode. Only valide when @enabled
+	 * is set. This is used by helpers like
+	 * drm_calc_vbltimestamp_from_scanoutpos(). We can't just access the
+	 * hardware mode by e.g. looking at &drm_crtc_state.adjusted_mode,
+	 * because that one is really hard to get at from interrupt context.
+	 */
+	struct drm_display_mode hwmode;
+
 	/**
 	 * @enabled: Tracks the enabling state of the corresponding &drm_crtc to
 	 * avoid double-disabling and hence corrupting saved state. Needed by
@@ -156,8 +168,7 @@ u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
 bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 					   unsigned int pipe, int *max_error,
 					   struct timeval *vblank_time,
-					   bool in_vblank_irq,
-					   const struct drm_display_mode *mode);
+					   bool in_vblank_irq);
 void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 				     const struct drm_display_mode *mode);
 
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#56 lore raw

Re: [Intel-gfx] [PATCH] drm/vblank: drop the mode argument from drm_calc_vbltimestamp_from_scanoutpos

Quoted 29 lines · Ville Syrjälä
Quoted 19 lines · Daniel Vetter

If we restrict this helper to only kms drivers (which is the case) we can look up the correct mode easily ourselves. But it's a bit tricky:

- All legacy drivers look at crtc->hwmode. But that is update already at the beginning of the modeset helper, which means when we disable a pipe. Hence the final timestamps might be a bit off. But since this is an existing bug I'm not going to change it, but just try to be bug-for-bug compatible with the current code. This only applies to radeon&amdgpu.

- i915 tries to get it perfect by updating crtc->hwmode when the pipe is off (i.e. vblank->enabled = false).

- All other atomic drivers look at crtc->state->adjusted_mode. Those that look at state->requested_mode simply don't adjust their mode, so it's the same. That has two problems: Accessing crtc->state from interrupt handling code is unsafe, and it's updated before we shut down the pipe. For nonblocking modesets it's even worse.

Quoted 3 lines

For atomic drivers try to implement what i915 does. To do that we add a new hwmode field to the vblank structure, and update it from drm_calc_timestamping_constants().

i915 clear crtc->hwmode.crtc_clock when turning the crtc off, which this does not do for the new vblank->hwmode. I guess no one should really end up in these codepaths with a disabled crtc, but parts of drm_irq.c sort of look like they're expecting it to happen.

Quoted 4 lines

So should we have some way to clear out the vblank->hwmode.crtc_clock for disabled crtcs? And then maybe make some of these crtc_clock checks WARN and eventually just nuke it all if it looks like nothing is hitting those?

So the trouble is that with a pile of dpms on/off/on/off you could run drm_crtc_vblank_on/off a lot, without ever calling the drm_calc_vbltimestamps helper again to re-upload the mode. So I don't think we can clear vblank->hwmode.crtc_clock unfortunately in drm_crtc_vblank_off.

But what we could do (at least with atomic) is WARN in the vblank helper if it's called outside of drm_vblank_on/off ... Not sure how useful that is (it won't catch when a driver outright forgets to call these) or whether we have enough checks already. Would be a separate patch (can do ofc if we agree on what exactly).
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
#57 lore raw

Re: [Intel-gfx] [PATCH] drm/vblank: drop the mode argument from drm_calc_vbltimestamp_from_scanoutpos

Quoted 36 lines · Daniel Vetter
Quoted 29 lines · Ville Syrjälä
Quoted 19 lines · Daniel Vetter

If we restrict this helper to only kms drivers (which is the case) we can look up the correct mode easily ourselves. But it's a bit tricky:

- All legacy drivers look at crtc->hwmode. But that is update already at the beginning of the modeset helper, which means when we disable a pipe. Hence the final timestamps might be a bit off. But since this is an existing bug I'm not going to change it, but just try to be bug-for-bug compatible with the current code. This only applies to radeon&amdgpu.

- i915 tries to get it perfect by updating crtc->hwmode when the pipe is off (i.e. vblank->enabled = false).

- All other atomic drivers look at crtc->state->adjusted_mode. Those that look at state->requested_mode simply don't adjust their mode, so it's the same. That has two problems: Accessing crtc->state from interrupt handling code is unsafe, and it's updated before we shut down the pipe. For nonblocking modesets it's even worse.

Quoted 3 lines

For atomic drivers try to implement what i915 does. To do that we add a new hwmode field to the vblank structure, and update it from drm_calc_timestamping_constants().

i915 clear crtc->hwmode.crtc_clock when turning the crtc off, which this does not do for the new vblank->hwmode. I guess no one should really end up in these codepaths with a disabled crtc, but parts of drm_irq.c sort of look like they're expecting it to happen.

Quoted 4 lines

So should we have some way to clear out the vblank->hwmode.crtc_clock for disabled crtcs? And then maybe make some of these crtc_clock checks WARN and eventually just nuke it all if it looks like nothing is hitting those?

Quoted 5 lines

So the trouble is that with a pile of dpms on/off/on/off you could run drm_crtc_vblank_on/off a lot, without ever calling the drm_calc_vbltimestamps helper again to re-upload the mode. So I don't think we can clear vblank->hwmode.crtc_clock unfortunately in drm_crtc_vblank_off.

I was thinking that we'd just try to avoid making pontetially functional changes here. Ie. reset where we currently reset, which I think is somewhere in the atomic commit for i915, but definitely not in drm_crtc_vblank_off().

Quoted 11 lines

But what we could do (at least with atomic) is WARN in the vblank helper if it's called outside of drm_vblank_on/off ... Not sure how useful that is (it won't catch when a driver outright forgets to call these) or whether we have enough checks already. Would be a separate patch (can do ofc if we agree on what exactly).
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Signature · 2 lines
Ville Syrjälä
Intel OTC

A message that is not in the archive (sent off-list or not yet received): [email protected]

#59 lore raw

Re: [Intel-gfx] [PATCH] drm/vblank: drop the mode argument from drm_calc_vbltimestamp_from_scanoutpos

Quoted 43 lines · Ville Syrjälä
Quoted 36 lines · Daniel Vetter
Quoted 29 lines · Ville Syrjälä
Quoted 19 lines · Daniel Vetter

If we restrict this helper to only kms drivers (which is the case) we can look up the correct mode easily ourselves. But it's a bit tricky:

- All legacy drivers look at crtc->hwmode. But that is update already at the beginning of the modeset helper, which means when we disable a pipe. Hence the final timestamps might be a bit off. But since this is an existing bug I'm not going to change it, but just try to be bug-for-bug compatible with the current code. This only applies to radeon&amdgpu.

- i915 tries to get it perfect by updating crtc->hwmode when the pipe is off (i.e. vblank->enabled = false).

- All other atomic drivers look at crtc->state->adjusted_mode. Those that look at state->requested_mode simply don't adjust their mode, so it's the same. That has two problems: Accessing crtc->state from interrupt handling code is unsafe, and it's updated before we shut down the pipe. For nonblocking modesets it's even worse.

Quoted 3 lines

For atomic drivers try to implement what i915 does. To do that we add a new hwmode field to the vblank structure, and update it from drm_calc_timestamping_constants().

i915 clear crtc->hwmode.crtc_clock when turning the crtc off, which this does not do for the new vblank->hwmode. I guess no one should really end up in these codepaths with a disabled crtc, but parts of drm_irq.c sort of look like they're expecting it to happen.

Quoted 4 lines

So should we have some way to clear out the vblank->hwmode.crtc_clock for disabled crtcs? And then maybe make some of these crtc_clock checks WARN and eventually just nuke it all if it looks like nothing is hitting those?

Quoted 5 lines

So the trouble is that with a pile of dpms on/off/on/off you could run drm_crtc_vblank_on/off a lot, without ever calling the drm_calc_vbltimestamps helper again to re-upload the mode. So I don't think we can clear vblank->hwmode.crtc_clock unfortunately in drm_crtc_vblank_off.

Quoted 3 lines

I was thinking that we'd just try to avoid making pontetially functional changes here. Ie. reset where we currently reset, which I think is somewhere in the atomic commit for i915, but definitely not in drm_crtc_vblank_off().

Hm, sounds like a good idea. I'll try to shuffle things around. Upon re-reading all that stuff I also noticed that atm i915 only calls the helper that would update vblank->hwmode when we do a full modeset, but not when we just fastset. Shouldn't matter, because the hwmode will match, but better safe than sorry.

I'll re-read all that stuff again and will try to lock it down fully, like we have now, and remove the i915 crtc->hwmode access maybe entirely while at it.
-Daniel

Quoted 16 lines
Quoted 12 lines

But what we could do (at least with atomic) is WARN in the vblank helper if it's called outside of drm_vblank_on/off ... Not sure how useful that is (it won't catch when a driver outright forgets to call these) or whether we have enough checks already. Would be a separate patch (can do ofc if we agree on what exactly).
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Signature · 2 lines
Ville Syrjälä
Intel OTC
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

A message that is not in the archive (sent off-list or not yet received): 20170330182740.p4joh3spt4ghxco4-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org

#61 lore raw

Re: [Intel-gfx] [PATCH] drm/vblank: drop the mode argument from drm_calc_vbltimestamp_from_scanoutpos

Quoted 54 lines · Daniel Vetter
Quoted 43 lines · Ville Syrjälä
Quoted 36 lines · Daniel Vetter
Quoted 29 lines · Ville Syrjälä
Quoted 19 lines · Daniel Vetter

If we restrict this helper to only kms drivers (which is the case) we can look up the correct mode easily ourselves. But it's a bit tricky:

- All legacy drivers look at crtc->hwmode. But that is update already at the beginning of the modeset helper, which means when we disable a pipe. Hence the final timestamps might be a bit off. But since this is an existing bug I'm not going to change it, but just try to be bug-for-bug compatible with the current code. This only applies to radeon&amdgpu.

- i915 tries to get it perfect by updating crtc->hwmode when the pipe is off (i.e. vblank->enabled = false).

- All other atomic drivers look at crtc->state->adjusted_mode. Those that look at state->requested_mode simply don't adjust their mode, so it's the same. That has two problems: Accessing crtc->state from interrupt handling code is unsafe, and it's updated before we shut down the pipe. For nonblocking modesets it's even worse.

Quoted 3 lines

For atomic drivers try to implement what i915 does. To do that we add a new hwmode field to the vblank structure, and update it from drm_calc_timestamping_constants().

i915 clear crtc->hwmode.crtc_clock when turning the crtc off, which this does not do for the new vblank->hwmode. I guess no one should really end up in these codepaths with a disabled crtc, but parts of drm_irq.c sort of look like they're expecting it to happen.

Quoted 4 lines

So should we have some way to clear out the vblank->hwmode.crtc_clock for disabled crtcs? And then maybe make some of these crtc_clock checks WARN and eventually just nuke it all if it looks like nothing is hitting those?

Quoted 5 lines

So the trouble is that with a pile of dpms on/off/on/off you could run drm_crtc_vblank_on/off a lot, without ever calling the drm_calc_vbltimestamps helper again to re-upload the mode. So I don't think we can clear vblank->hwmode.crtc_clock unfortunately in drm_crtc_vblank_off.

Quoted 3 lines

I was thinking that we'd just try to avoid making pontetially functional changes here. Ie. reset where we currently reset, which I think is somewhere in the atomic commit for i915, but definitely not in drm_crtc_vblank_off().

Hm, sounds like a good idea. I'll try to shuffle things around. Upon re-reading all that stuff I also noticed that atm i915 only calls the helper that would update vblank->hwmode when we do a full modeset, but not when we just fastset. Shouldn't matter, because the hwmode will match, but better safe than sorry.

Quoted 3 lines

I'll re-read all that stuff again and will try to lock it down fully, like we have now, and remove the i915 crtc->hwmode access maybe entirely while at it.

Ok, I stitched something together which I think should work well. Done as a follow-up patch though since this refactoring patch here was already pretty big. Resend the entire pile for CI to double-check, review from you on the vblank stuff would be much appreciated.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
#62 lore raw

PATCH 16/16 drm/doc: Small markup fixup

In reply to Daniel Vetter

Drive-by cleanup.

---
 drivers/gpu/drm/drm_probe_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_probe_helper.c +1 -1
index 85005d57bde6..efb5e5e8ce62 100644
@@ -44,7 +44,7 @@
  *
  * This library provides some helper code for output probing. It provides an
  * implementation of the core &drm_connector_funcs.fill_modes interface with
- * drm_helper_probe_single_connector_modes.
+ * drm_helper_probe_single_connector_modes().
  *
  * It also provides support for polling connectors with a work item and for
  * generic hotplug interrupt handling where the driver doesn't or cannot keep
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#63 lore raw

✗ Fi.CI.BAT: failure for more drmP.h cleanup

In reply to Daniel Vetter
== Series Details ==

== Series Details ==

Series: more drmP.h cleanup
URL : https://patchwork.freedesktop.org/series/21670/
State : failure

== Summary ==

Series 21670v1 more drmP.h cleanup
https://patchwork.freedesktop.org/api/1.0/series/21670/revisions/1/mbox/

Test gem_exec_suspend:

        Subgroup basic-s4-devices:
                pass       -> DMESG-WARN (fi-bxt-t5700) fdo#100125
Test kms_busy:
        Subgroup basic-flip-default-a:
                pass       -> DMESG-WARN (fi-skl-6700k)
Test kms_cursor_legacy:
        Subgroup basic-busy-flip-before-cursor-atomic:
                pass       -> DMESG-WARN (fi-ilk-650)
        Subgroup basic-busy-flip-before-cursor-legacy:
                pass       -> DMESG-WARN (fi-ilk-650)
        Subgroup basic-flip-after-cursor-atomic:
                pass       -> DMESG-WARN (fi-ilk-650)
        Subgroup basic-flip-after-cursor-legacy:
                pass       -> DMESG-WARN (fi-ilk-650)
        Subgroup basic-flip-after-cursor-varying-size:
                pass       -> DMESG-WARN (fi-ilk-650)
        Subgroup basic-flip-before-cursor-atomic:
                pass       -> DMESG-WARN (fi-ilk-650)
        Subgroup basic-flip-before-cursor-legacy:
                pass       -> DMESG-WARN (fi-ilk-650)
        Subgroup basic-flip-before-cursor-varying-size:
                pass       -> DMESG-WARN (fi-ilk-650)
Test kms_pipe_crc_basic:
        Subgroup hang-read-crc-pipe-a:
                pass       -> DMESG-WARN (fi-skl-6700k)
        Subgroup nonblocking-crc-pipe-a:
                pass       -> DMESG-WARN (fi-skl-6700k)
        Subgroup nonblocking-crc-pipe-a-frame-sequence:
                pass       -> DMESG-WARN (fi-skl-6700k)
        Subgroup read-crc-pipe-a:
                pass       -> DMESG-WARN (fi-skl-6700k)
        Subgroup read-crc-pipe-a-frame-sequence:
                pass       -> DMESG-WARN (fi-skl-6700k)
        Subgroup suspend-read-crc-pipe-a:
                pass       -> DMESG-WARN (fi-skl-6700k)
        Subgroup suspend-read-crc-pipe-b:
                pass       -> FAIL       (fi-skl-6700k)

fdo#100125 https://bugs.freedesktop.org/show_bug.cgi?id=100125

fi-bdw-5557u     total:278  pass:267  dwarn:0   dfail:0   fail:0   skip:11  time: 452s
fi-bsw-n3050     total:278  pass:239  dwarn:0   dfail:0   fail:0   skip:39  time: 573s
fi-bxt-j4205     total:278  pass:259  dwarn:0   dfail:0   fail:0   skip:19  time: 538s
fi-bxt-t5700     total:278  pass:257  dwarn:1   dfail:0   fail:0   skip:20  time: 569s
fi-byt-j1900     total:278  pass:251  dwarn:0   dfail:0   fail:0   skip:27  time: 501s
fi-byt-n2820     total:278  pass:247  dwarn:0   dfail:0   fail:0   skip:31  time: 498s
fi-hsw-4770      total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time: 438s
fi-hsw-4770r     total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time: 435s
fi-ilk-650       total:278  pass:220  dwarn:8   dfail:0   fail:0   skip:50  time: 436s
fi-ivb-3520m     total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time: 515s
fi-ivb-3770      total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time: 493s
fi-kbl-7500u     total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time: 481s
fi-skl-6260u     total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time: 484s
fi-skl-6700hq    total:278  pass:261  dwarn:0   dfail:0   fail:0   skip:17  time: 596s
fi-skl-6700k     total:278  pass:248  dwarn:11  dfail:0   fail:1   skip:18  time: 485s
fi-skl-6770hq    total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time: 519s
fi-snb-2520m     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time: 551s
fi-snb-2600      total:278  pass:249  dwarn:0   dfail:0   fail:0   skip:29  time: 421s

5f9054cda46cabdbed50fdb5259ac80f89fe3082 drm-tip: 2017y-03m-22d-08h-22m-40s UTC integration manifest 3e01e0a drm/doc: Small markup fixup
547f303 drm/vblank: Simplify the get_scanout_position helper hook
00c42f3 drm/vblank: drop the mode argument from drm_calc_vbltimestamp_from_scanoutpos 3888cb6 drm/vblank: Add FIXME comments about moving the vblank ts hooks
d2e4be7 drm/vblank: Switch to bool in_vblank_irq in get_vblank_timestamp
5ef4901 drm/vblank: Switch drm_driver->get_vblank_timestamp to return a bool
d3ee8ff drm/vblank: Remove DRM_VBLANKTIME_IN_VBLANK
43a7ed1 drm/todo: Add tinydrm refactoring ideas
28488d6 drm: document drm_ioctl.[hc]
8109d3a drm: Extract drm_ioctl.h
16cf350 drm: Consolidate and document sysfs support
4784dfc drm: update todo.rst
9a8e72b drm/debugfs: Add kerneldoc
1a223d5 drm: document driver interface for CRC capturing
2dfcdff drm: Extract drm_debugfs.h
360a072 drm: drop extern from function decls

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4257/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#64 lore raw

✓ Fi.CI.BAT: success for more drmP.h cleanup (rev7)

In reply to Daniel Vetter
== Series Details ==

== Series Details ==

Series: more drmP.h cleanup (rev7)
URL : https://patchwork.freedesktop.org/series/21670/
State : success

== Summary ==

Series 21670v7 more drmP.h cleanup
https://patchwork.freedesktop.org/api/1.0/series/21670/revisions/7/mbox/

Test kms_pipe_crc_basic:

        Subgroup suspend-read-crc-pipe-a:
                fail       -> PASS       (fi-skl-6700k)
fi-bdw-5557u     total:278  pass:267  dwarn:0   dfail:0   fail:0   skip:11  time: 462s
fi-bdw-gvtdvm    total:278  pass:256  dwarn:8   dfail:0   fail:0   skip:14  time: 453s
fi-bsw-n3050     total:278  pass:239  dwarn:0   dfail:0   fail:0   skip:39  time: 584s
fi-bxt-j4205     total:278  pass:259  dwarn:0   dfail:0   fail:0   skip:19  time: 539s
fi-byt-j1900     total:278  pass:251  dwarn:0   dfail:0   fail:0   skip:27  time: 511s
fi-byt-n2820     total:278  pass:247  dwarn:0   dfail:0   fail:0   skip:31  time: 504s
fi-hsw-4770      total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time: 436s
fi-hsw-4770r     total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time: 433s
fi-ilk-650       total:278  pass:228  dwarn:0   dfail:0   fail:0   skip:50  time: 443s
fi-ivb-3520m     total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time: 524s
fi-ivb-3770      total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time: 499s
fi-kbl-7500u     total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time: 485s
fi-skl-6260u     total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time: 479s
fi-skl-6700hq    total:278  pass:261  dwarn:0   dfail:0   fail:0   skip:17  time: 598s
fi-skl-6700k     total:278  pass:256  dwarn:4   dfail:0   fail:0   skip:18  time: 490s
fi-skl-6770hq    total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time: 522s
fi-skl-gvtdvm    total:278  pass:265  dwarn:0   dfail:0   fail:0   skip:13  time: 469s
fi-snb-2520m     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time: 548s
fi-snb-2600      total:278  pass:249  dwarn:0   dfail:0   fail:0   skip:29  time: 422s

b1ecc49ac71e484430083e5b3b7cd75d4976a465 drm-tip: 2017y-03m-23d-07h-40m-49s UTC integration manifest f1b0b85 drm/vblank: Switch drm_driver->get_vblank_timestamp to return a bool
7dd3e06 drm/vblank: Remove DRM_VBLANKTIME_IN_VBLANK
4ce75fc drm/todo: Add tinydrm refactoring ideas
4bb2f71 drm: document drm_ioctl.[hc]
3b85dbb drm: Extract drm_ioctl.h
7218a99 drm: Consolidate and document sysfs support
6c65c2f drm: update todo.rst
a7ee095 drm/debugfs: Add kerneldoc
64feb24 drm: document driver interface for CRC capturing
c0d8423 drm: Extract drm_debugfs.h
de0dcf8 drm: drop extern from function decls

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4265/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx