All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/24] more docs and header splits
@ 2017-03-08 14:12 Daniel Vetter
  2017-03-08 14:12 ` [PATCH 01/24] drm/doc: Add todo about connector_list_iter Daniel Vetter
                   ` (22 more replies)
  0 siblings, 23 replies; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Intel Graphics Development

Hi all,

So I looked at drmP.h, thought "this is small, should finally be doable to split
it all into sensible pieces and document things".

Yes that joke was on me, only managed to do a few random things and then split
out drm_file related things. Plus clean those up and give the docs a fresh-up.

As usual, comments and review highly welcome.

Thanks, Daniel

Daniel Vetter (24):
  drm/doc: Add todo about connector_list_iter
  drm: Extract drm_prime.h
  drm: Move drm_lock_data out of drmP.h
  drm: Extract drm_pci.h
  drm: Remove drmP.h include from drm_kms_helper_common.c
  drm/doc: document fallback behaviour for atomic events
  drm: rename drm_fops.c to drm_file.c
  drm: Remove DRM_MINOR_CNT
  drm: Extract drm_file.h
  drm: Remove drm_pending_event->pid
  drm/doc: Document drm_file.[hc]
  drm/i915: Merge pre/postclose hooks
  drm/msm: switch to postclose
  drm/nouveau: Merge pre/postclose hooks
  drm/radeon: Merge pre/postclose hooks
  drm/tegra: switch to postclose
  drm/vgem: switch to postclose
  drm/etnaviv: switch to postclose
  drm/amdgpu: Merge pre/postclose hooks
  drm/exynos: Merge pre/postclose hooks
  drm/msm: Simplify vblank event delivery
  drm: Nerf the preclose callback for modern drivers
  drm: Create DEFINE_DRM_GEM_CMA_FOPS and roll it out to drivers
  drm/gem: Add DEFINE_DRM_GEM_FOPS

 Documentation/gpu/drm-internals.rst             |  56 +---
 Documentation/gpu/drm-mm.rst                    |   3 +
 Documentation/gpu/drm-uapi.rst                  |   4 +
 Documentation/gpu/todo.rst                      |  13 +
 drivers/gpu/drm/Makefile                        |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu.h             |   2 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c         |   1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c         |  17 +-
 drivers/gpu/drm/arm/hdlcd_drv.c                 |  12 +-
 drivers/gpu/drm/arm/malidp_drv.c                |  12 +-
 drivers/gpu/drm/armada/armada_drv.c             |  11 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c    |  12 +-
 drivers/gpu/drm/{drm_fops.c => drm_file.c}      |  77 +++--
 drivers/gpu/drm/drm_gem_cma_helper.c            |   3 +
 drivers/gpu/drm/drm_internal.h                  |   2 +-
 drivers/gpu/drm/drm_irq.c                       |   5 +-
 drivers/gpu/drm/drm_kms_helper_common.c         |   3 +-
 drivers/gpu/drm/drm_pci.c                       |   7 +
 drivers/gpu/drm/drm_prime.c                     |   3 +-
 drivers/gpu/drm/drm_trace.h                     |  20 +-
 drivers/gpu/drm/etnaviv/etnaviv_drv.c           |   4 +-
 drivers/gpu/drm/exynos/exynos_drm_drv.c         |   8 +-
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c       |  12 +-
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  12 +-
 drivers/gpu/drm/i915/i915_drv.c                 |  10 +-
 drivers/gpu/drm/imx/imx-drm-core.c              |  11 +-
 drivers/gpu/drm/meson/meson_drv.c               |  14 +-
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c        |  12 +-
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c        |  12 +-
 drivers/gpu/drm/msm/msm_drv.c                   |   4 +-
 drivers/gpu/drm/mxsfb/mxsfb_drv.c               |  14 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c           |   9 +-
 drivers/gpu/drm/nouveau/nouveau_usif.c          |   1 -
 drivers/gpu/drm/radeon/radeon_drv.c             |   3 -
 drivers/gpu/drm/radeon/radeon_kms.c             |  42 +--
 drivers/gpu/drm/rcar-du/rcar_du_drv.c           |  12 +-
 drivers/gpu/drm/shmobile/shmob_drm_drv.c        |  12 +-
 drivers/gpu/drm/sti/sti_drv.c                   |  11 +-
 drivers/gpu/drm/sun4i/sun4i_drv.c               |  12 +-
 drivers/gpu/drm/tegra/drm.c                     |   4 +-
 drivers/gpu/drm/tilcdc/tilcdc_drv.c             |  12 +-
 drivers/gpu/drm/vgem/vgem_drv.c                 |   4 +-
 drivers/gpu/drm/zte/zx_drm_drv.c                |  14 +-
 include/drm/drmP.h                              | 218 +-------------
 include/drm/drm_auth.h                          |  17 ++
 include/drm/drm_crtc.h                          |   6 +
 include/drm/drm_drv.h                           |  64 +++-
 include/drm/drm_file.h                          | 377 ++++++++++++++++++++++++
 include/drm/drm_gem.h                           |  30 ++
 include/drm/drm_gem_cma_helper.h                |  26 ++
 include/drm/drm_pci.h                           |  78 +++++
 include/drm/drm_prime.h                         |  80 +++++
 include/drm/drm_vma_manager.h                   |   1 -
 53 files changed, 824 insertions(+), 587 deletions(-)
 rename drivers/gpu/drm/{drm_fops.c => drm_file.c} (89%)
 create mode 100644 include/drm/drm_file.h
 create mode 100644 include/drm/drm_pci.h
 create mode 100644 include/drm/drm_prime.h

-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [PATCH 01/24] drm/doc: Add todo about connector_list_iter
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-08 15:12   ` [Intel-gfx] " Sean Paul
  2017-03-08 14:12 ` [PATCH 02/24] drm: Extract drm_prime.h Daniel Vetter
                   ` (21 subsequent siblings)
  22 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Intel Graphics Development, Daniel Vetter

At least radeon, amdgpu and nouveau should be converted. We have
patches for i915 already.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 Documentation/gpu/todo.rst | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index ce0f1a588e7f..63c7088cace3 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -153,6 +153,19 @@ following drivers still use ``struct_mutex``: ``msm``, ``omapdrm`` and
 
 Contact: Daniel Vetter
 
+Switch to drm_connector_list_iter for any connector_list walking
+----------------------------------------------------------------
+
+Connectors can be hotplugged, and we now have a special list of helpers to walk
+the connector_list in a race-free fashion, without incuring deadlocks on mutexes
+and other fun stuff.
+
+Unfortunately most drivers are not converted yet. At least all those supporting
+DP MST hotplug should be converted, since for those drivers the difference
+matters. See drm_for_each_connector_iter() vs. drm_for_each_connector().
+
+Contact: Daniel Vetter
+
 Core refactorings
 =================
 
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 02/24] drm: Extract drm_prime.h
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
  2017-03-08 14:12 ` [PATCH 01/24] drm/doc: Add todo about connector_list_iter Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-08 14:57   ` Gustavo Padovan
  2017-03-13 16:42   ` Sean Paul
  2017-03-08 14:12 ` [PATCH 03/24] drm: Move drm_lock_data out of drmP.h Daniel Vetter
                   ` (20 subsequent siblings)
  22 siblings, 2 replies; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Intel Graphics Development, Daniel Vetter

Plus a little bit more documentation.

v2: Untangle the missing forward decls to make drm_prime|gem.h
free-standing.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 Documentation/gpu/drm-mm.rst  |  3 ++
 drivers/gpu/drm/drm_prime.c   |  3 +-
 include/drm/drmP.h            | 32 ++----------------
 include/drm/drm_gem.h         |  4 +++
 include/drm/drm_prime.h       | 79 +++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_vma_manager.h |  1 -
 6 files changed, 91 insertions(+), 31 deletions(-)
 create mode 100644 include/drm/drm_prime.h

diff --git a/Documentation/gpu/drm-mm.rst b/Documentation/gpu/drm-mm.rst
index d47cbe3a9ef3..96b9c34c21e4 100644
--- a/Documentation/gpu/drm-mm.rst
+++ b/Documentation/gpu/drm-mm.rst
@@ -449,6 +449,9 @@ PRIME Helper Functions
 PRIME Function References
 -------------------------
 
+.. kernel-doc:: include/drm/drm_prime.h
+   :internal:
+
 .. kernel-doc:: drivers/gpu/drm/drm_prime.c
    :export:
 
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 866b294e7c61..9fb65b736a90 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -29,8 +29,9 @@
 #include <linux/export.h>
 #include <linux/dma-buf.h>
 #include <linux/rbtree.h>
-#include <drm/drmP.h>
+#include <drm/drm_prime.h>
 #include <drm/drm_gem.h>
+#include <drm/drmP.h>
 
 #include "drm_internal.h"
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 6105c050d7bc..5f829d2372da 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -51,13 +51,13 @@
 #include <linux/platform_device.h>
 #include <linux/poll.h>
 #include <linux/ratelimit.h>
-#include <linux/rbtree.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/vmalloc.h>
 #include <linux/workqueue.h>
 #include <linux/dma-fence.h>
+#include <linux/module.h>
 
 #include <asm/mman.h>
 #include <asm/pgalloc.h>
@@ -75,8 +75,8 @@
 #include <drm/drm_mm.h>
 #include <drm/drm_os_linux.h>
 #include <drm/drm_sarea.h>
-#include <drm/drm_vma_manager.h>
 #include <drm/drm_drv.h>
+#include <drm/drm_prime.h>
 
 struct module;
 
@@ -89,6 +89,7 @@ struct drm_dma_handle;
 struct drm_gem_object;
 struct drm_master;
 struct drm_vblank_crtc;
+struct drm_vma_offset_manager;
 
 struct device_node;
 struct videomode;
@@ -370,12 +371,6 @@ struct drm_pending_event {
 		      we deliver the event, for tracing only */
 };
 
-struct drm_prime_file_private {
-	struct mutex lock;
-	struct rb_root dmabufs;
-	struct rb_root handles;
-};
-
 /** File private data */
 struct drm_file {
 	unsigned authenticated :1;
@@ -759,27 +754,6 @@ static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
 }
 #endif
 
-struct dma_buf_export_info;
-
-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_dmabuf_export(struct drm_device *dev,
-				      struct dma_buf_export_info *exp_info);
-extern 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);
-
 
 extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size,
 					    size_t align);
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
index 3b2a28f7f49f..b9ade75ecd82 100644
--- a/include/drm/drm_gem.h
+++ b/include/drm/drm_gem.h
@@ -34,6 +34,10 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#include <linux/kref.h>
+
+#include <drm/drm_vma_manager.h>
+
 /**
  * struct drm_gem_object - GEM buffer object
  *
diff --git a/include/drm/drm_prime.h b/include/drm/drm_prime.h
new file mode 100644
index 000000000000..77ceca711bad
--- /dev/null
+++ b/include/drm/drm_prime.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright © 2012 Red Hat
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * Copyright (c) 2009-2010, Code Aurora Forum.
+ *
+ * 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
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Authors:
+ *      Dave Airlie <airlied@redhat.com>
+ *      Rob Clark <rob.clark@linaro.org>
+ *
+ */
+
+#ifndef __DRM_PRIME_H__
+#define __DRM_PRIME_H__
+
+#include <linux/mutex.h>
+#include <linux/rbtree.h>
+
+/**
+ * struct drm_prime_file_private - per-file tracking for PRIME
+ *
+ * This just contains the internal &struct dma_buf and handle caches for each
+ * &struct drm_file used by the PRIME core code.
+ */
+
+struct drm_prime_file_private {
+/* private: */
+	struct mutex lock;
+	struct rb_root dmabufs;
+	struct rb_root handles;
+};
+
+struct dma_buf_export_info;
+struct dma_buf;
+
+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_dmabuf_export(struct drm_device *dev,
+				      struct dma_buf_export_info *exp_info);
+extern 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);
+
+
+#endif /* __DRM_PRIME_H__ */
diff --git a/include/drm/drm_vma_manager.h b/include/drm/drm_vma_manager.h
index 9c03895dc479..d84d52f6d2b1 100644
--- a/include/drm/drm_vma_manager.h
+++ b/include/drm/drm_vma_manager.h
@@ -25,7 +25,6 @@
 
 #include <drm/drm_mm.h>
 #include <linux/mm.h>
-#include <linux/module.h>
 #include <linux/rbtree.h>
 #include <linux/spinlock.h>
 #include <linux/types.h>
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 03/24] drm: Move drm_lock_data out of drmP.h
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
  2017-03-08 14:12 ` [PATCH 01/24] drm/doc: Add todo about connector_list_iter Daniel Vetter
  2017-03-08 14:12 ` [PATCH 02/24] drm: Extract drm_prime.h Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-08 14:58   ` Gustavo Padovan
  2017-03-08 14:12 ` [PATCH 04/24] drm: Extract drm_pci.h Daniel Vetter
                   ` (19 subsequent siblings)
  22 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Intel Graphics Development, Daniel Vetter

And remove the semi-kernel-doc stuff, to make sure no one uses this.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 include/drm/drmP.h     | 15 ---------------
 include/drm/drm_auth.h | 17 +++++++++++++++++
 2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 5f829d2372da..22b6f6f45b07 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -428,21 +428,6 @@ struct drm_file {
 	struct drm_prime_file_private prime;
 };
 
-/**
- * Lock data.
- */
-struct drm_lock_data {
-	struct drm_hw_lock *hw_lock;	/**< Hardware lock */
-	/** Private of lock holder's file (NULL=kernel) */
-	struct drm_file *file_priv;
-	wait_queue_head_t lock_queue;	/**< Queue of blocked processes */
-	unsigned long lock_time;	/**< Time of last lock in jiffies */
-	spinlock_t spinlock;
-	uint32_t kernel_waiters;
-	uint32_t user_waiters;
-	int idle_has_lock;
-};
-
 /* Flags and return codes for get_vblank_timestamp() driver function. */
 #define DRM_CALLED_FROM_VBLIRQ 1
 #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
diff --git a/include/drm/drm_auth.h b/include/drm/drm_auth.h
index 1eb4a52cad8d..81a40c2a9a3e 100644
--- a/include/drm/drm_auth.h
+++ b/include/drm/drm_auth.h
@@ -28,6 +28,23 @@
 #ifndef _DRM_AUTH_H_
 #define _DRM_AUTH_H_
 
+/*
+ * Legacy DRI1 locking data structure. Only here instead of in drm_legacy.h for
+ * include ordering reasons.
+ *
+ * DO NOT USE.
+ */
+struct drm_lock_data {
+	struct drm_hw_lock *hw_lock;
+	struct drm_file *file_priv;
+	wait_queue_head_t lock_queue;
+	unsigned long lock_time;
+	spinlock_t spinlock;
+	uint32_t kernel_waiters;
+	uint32_t user_waiters;
+	int idle_has_lock;
+};
+
 /**
  * struct drm_master - drm master structure
  *
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 04/24] drm: Extract drm_pci.h
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
                   ` (2 preceding siblings ...)
  2017-03-08 14:12 ` [PATCH 03/24] drm: Move drm_lock_data out of drmP.h Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-08 14:59   ` [Intel-gfx] " Gustavo Padovan
  2017-03-08 14:12 ` [PATCH 05/24] drm: Remove drmP.h include from drm_kms_helper_common.c Daniel Vetter
                   ` (18 subsequent siblings)
  22 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Intel Graphics Development, Daniel Vetter

Just another step in finally making drmP.h obsolete.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_pci.c |  7 +++++
 include/drm/drmP.h        | 43 +++-----------------------
 include/drm/drm_pci.h     | 78 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 89 insertions(+), 39 deletions(-)
 create mode 100644 include/drm/drm_pci.h

diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index a3b356e70b35..1eb4fc3eee20 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -26,6 +26,7 @@
 #include <linux/slab.h>
 #include <linux/dma-mapping.h>
 #include <linux/export.h>
+#include <drm/drm_pci.h>
 #include <drm/drmP.h>
 #include "drm_internal.h"
 #include "drm_legacy.h"
@@ -36,6 +37,9 @@
  * @size: size of block to allocate
  * @align: alignment of block
  *
+ * FIXME: This is a needless abstraction of the Linux dma-api and should be
+ * removed.
+ *
  * Return: A handle to the allocated memory block on success or NULL on
  * failure.
  */
@@ -104,6 +108,9 @@ void __drm_legacy_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
  * drm_pci_free - Free a PCI consistent memory block
  * @dev: DRM device
  * @dmah: handle to memory block
+ *
+ * FIXME: This is a needless abstraction of the Linux dma-api and should be
+ * removed.
  */
 void drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
 {
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 22b6f6f45b07..1ad699de8769 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -47,7 +47,6 @@
 #include <linux/miscdevice.h>
 #include <linux/mm.h>
 #include <linux/mutex.h>
-#include <linux/pci.h>
 #include <linux/platform_device.h>
 #include <linux/poll.h>
 #include <linux/ratelimit.h>
@@ -77,6 +76,7 @@
 #include <drm/drm_sarea.h>
 #include <drm/drm_drv.h>
 #include <drm/drm_prime.h>
+#include <drm/drm_pci.h>
 
 struct module;
 
@@ -85,7 +85,6 @@ struct drm_device;
 struct drm_agp_head;
 struct drm_local_map;
 struct drm_device_dma;
-struct drm_dma_handle;
 struct drm_gem_object;
 struct drm_master;
 struct drm_vblank_crtc;
@@ -96,6 +95,9 @@ struct videomode;
 struct reservation_object;
 struct dma_buf_attachment;
 
+struct pci_dev;
+struct pci_controller;
+
 /*
  * The following categories are defined:
  *
@@ -739,49 +741,12 @@ static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
 }
 #endif
 
-
-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);
-
 			       /* sysfs support (drm_sysfs.c) */
 extern void drm_sysfs_hotplug_event(struct drm_device *dev);
 
 
 /*@}*/
 
-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);
-#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);
-#else
-static inline int drm_get_pci_dev(struct pci_dev *pdev,
-				  const struct pci_device_id *ent,
-				  struct drm_driver *driver)
-{
-	return -ENOSYS;
-}
-
-static inline int drm_pci_set_busid(struct drm_device *dev,
-				    struct drm_master *master)
-{
-	return -ENOSYS;
-}
-#endif
-
-#define DRM_PCIE_SPEED_25 1
-#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);
-
-/* platform section */
-extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);
-
 /* returns true if currently okay to sleep */
 static __inline__ bool drm_can_sleep(void)
 {
diff --git a/include/drm/drm_pci.h b/include/drm/drm_pci.h
new file mode 100644
index 000000000000..5081b3eba309
--- /dev/null
+++ b/include/drm/drm_pci.h
@@ -0,0 +1,78 @@
+/*
+ * 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 <faith@valinux.com>
+ * Author: Gareth Hughes <gareth@valinux.com>
+ *
+ * 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_PCI_H_
+#define _DRM_PCI_H_
+
+#include <linux/pci.h>
+
+struct drm_dma_handle;
+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);
+
+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);
+#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);
+#else
+static inline int drm_get_pci_dev(struct pci_dev *pdev,
+				  const struct pci_device_id *ent,
+				  struct drm_driver *driver)
+{
+	return -ENOSYS;
+}
+
+static inline int drm_pci_set_busid(struct drm_device *dev,
+				    struct drm_master *master)
+{
+	return -ENOSYS;
+}
+#endif
+
+#define DRM_PCIE_SPEED_25 1
+#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);
+
+/* platform section */
+extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);
+
+#endif /* _DRM_PCI_H_ */
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 05/24] drm: Remove drmP.h include from drm_kms_helper_common.c
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
                   ` (3 preceding siblings ...)
  2017-03-08 14:12 ` [PATCH 04/24] drm: Extract drm_pci.h Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-08 15:00   ` [Intel-gfx] " Gustavo Padovan
  2017-03-08 14:12 ` [PATCH 06/24] drm/doc: document fallback behaviour for atomic events Daniel Vetter
                   ` (17 subsequent siblings)
  22 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Intel Graphics Development, Daniel Vetter

An easy one as a drive-by.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_kms_helper_common.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_kms_helper_common.c b/drivers/gpu/drm/drm_kms_helper_common.c
index 45db36cd3d20..6e35a56a6102 100644
--- a/drivers/gpu/drm/drm_kms_helper_common.c
+++ b/drivers/gpu/drm/drm_kms_helper_common.c
@@ -25,8 +25,7 @@
  *
  */
 
-#include <drm/drmP.h>
-#include <drm/drm_fb_helper.h>
+#include <linux/module.h>
 
 #include "drm_crtc_helper_internal.h"
 
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 06/24] drm/doc: document fallback behaviour for atomic events
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
                   ` (4 preceding siblings ...)
  2017-03-08 14:12 ` [PATCH 05/24] drm: Remove drmP.h include from drm_kms_helper_common.c Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-08 14:57   ` Laurent Pinchart
  2017-03-08 14:12 ` [PATCH 07/24] drm: rename drm_fops.c to drm_file.c Daniel Vetter
                   ` (16 subsequent siblings)
  22 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development
  Cc: Daniel Vetter, Intel Graphics Development, Laurent Pinchart,
	Daniel Vetter

Worst case if the hw can't support completion signalling in a
race-free way we want the event to be too late, not too early.

Text adapted from a proposal from Laurent - the other side of how to
make hw work correctly where it's possible is imo already sufficiently
documented.

v2: Review from Laurent.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 include/drm/drm_crtc.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index cba29ffedafd..6ef59da3fd8e 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -204,6 +204,12 @@ struct drm_crtc_state {
 	 * drm_crtc_arm_vblank_event(). See the documentation of that function
 	 * for a detailed discussion of the constraints it needs to be used
 	 * safely.
+	 *
+	 * If the device can't notify of flip completion in a race-free way
+	 * at all, then the event should be armed just after the page flip is
+	 * committed. In the worst case the driver will send the event to
+	 * userspace one frame too late. This doesn't allow for a real atomic
+	 * update, but it should avoid tearing.
 	 */
 	struct drm_pending_vblank_event *event;
 
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 07/24] drm: rename drm_fops.c to drm_file.c
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
                   ` (5 preceding siblings ...)
  2017-03-08 14:12 ` [PATCH 06/24] drm/doc: document fallback behaviour for atomic events Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-08 15:02   ` [Intel-gfx] " Gustavo Padovan
  2017-03-08 14:12 ` [PATCH 08/24] drm: Remove DRM_MINOR_CNT Daniel Vetter
                   ` (15 subsequent siblings)
  22 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Intel Graphics Development, Daniel Vetter

It's not just file ops, but drm_file stuff in general. This is prep
work to extracting a drm_file.h header in the next patch.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 Documentation/gpu/drm-internals.rst        | 4 ++--
 drivers/gpu/drm/Makefile                   | 2 +-
 drivers/gpu/drm/{drm_fops.c => drm_file.c} | 3 ---
 drivers/gpu/drm/drm_internal.h             | 2 +-
 include/drm/drmP.h                         | 2 +-
 5 files changed, 5 insertions(+), 8 deletions(-)
 rename drivers/gpu/drm/{drm_fops.c => drm_file.c} (99%)

diff --git a/Documentation/gpu/drm-internals.rst b/Documentation/gpu/drm-internals.rst
index 29d6bf7bb1ac..ea329b71c459 100644
--- a/Documentation/gpu/drm-internals.rst
+++ b/Documentation/gpu/drm-internals.rst
@@ -298,10 +298,10 @@ over.
 File Operations
 ---------------
 
-.. kernel-doc:: drivers/gpu/drm/drm_fops.c
+.. kernel-doc:: drivers/gpu/drm/drm_file.c
    :doc: file operations
 
-.. kernel-doc:: drivers/gpu/drm/drm_fops.c
+.. kernel-doc:: drivers/gpu/drm/drm_file.c
    :export:
 
 IOCTLs
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 3ee95793d122..eb54ffabacc5 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -4,7 +4,7 @@
 
 drm-y       :=	drm_auth.o drm_bufs.o drm_cache.o \
 		drm_context.o drm_dma.o \
-		drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \
+		drm_file.o drm_gem.o drm_ioctl.o drm_irq.o \
 		drm_lock.o drm_memory.o drm_drv.o \
 		drm_scatter.o drm_pci.o \
 		drm_platform.o drm_sysfs.o drm_hashtab.o drm_mm.o \
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_file.c
similarity index 99%
rename from drivers/gpu/drm/drm_fops.c
rename to drivers/gpu/drm/drm_file.c
index afdf5b147f39..83e8c96ec4ab 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -1,7 +1,4 @@
 /*
- * \file drm_fops.c
- * File operations for DRM
- *
  * \author Rickard E. (Rik) Faith <faith@valinux.com>
  * \author Daryll Strauss <daryll@valinux.com>
  * \author Gareth Hughes <gareth@valinux.com>
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index f37388cb2fde..92ff4b9393b1 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -24,7 +24,7 @@
 #define DRM_IF_MAJOR 1
 #define DRM_IF_MINOR 4
 
-/* drm_fops.c */
+/* drm_file.c */
 extern struct mutex drm_global_mutex;
 void drm_lastclose(struct drm_device *dev);
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 1ad699de8769..826101785876 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -689,7 +689,7 @@ extern long drm_compat_ioctl(struct file *filp,
 #endif
 extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);
 
-/* File Operations (drm_fops.c) */
+/* File Operations (drm_file.c) */
 int drm_open(struct inode *inode, struct file *filp);
 ssize_t drm_read(struct file *filp, char __user *buffer,
 		 size_t count, loff_t *offset);
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 08/24] drm: Remove DRM_MINOR_CNT
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
                   ` (6 preceding siblings ...)
  2017-03-08 14:12 ` [PATCH 07/24] drm: rename drm_fops.c to drm_file.c Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-08 14:14   ` David Herrmann
  2017-03-13 16:56   ` Sean Paul
  2017-03-08 14:12 ` [PATCH 09/24] drm: Extract drm_file.h Daniel Vetter
                   ` (14 subsequent siblings)
  22 siblings, 2 replies; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Daniel Vetter, Intel Graphics Development

This was originally added by David Herrmann for range checks, but
entirely unused. It confused me, so let's remove it.

Cc: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 include/drm/drmP.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 826101785876..7bd6752683a4 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -444,7 +444,6 @@ enum drm_minor_type {
 	DRM_MINOR_PRIMARY,
 	DRM_MINOR_CONTROL,
 	DRM_MINOR_RENDER,
-	DRM_MINOR_CNT,
 };
 
 /**
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 09/24] drm: Extract drm_file.h
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
                   ` (7 preceding siblings ...)
  2017-03-08 14:12 ` [PATCH 08/24] drm: Remove DRM_MINOR_CNT Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-08 15:05   ` Gustavo Padovan
  2017-03-08 14:12 ` [PATCH 10/24] drm: Remove drm_pending_event->pid Daniel Vetter
                   ` (13 subsequent siblings)
  22 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Intel Graphics Development, Daniel Vetter

I'm torn on whether drm_minor really should be here or somewhere else.
Maybe with more clarity after untangling drmP.h more this is easier to
decide, for now I've put a FIXME comment right next to it. Right now
we need struct drm_minor for the inline drm_file type helpers, and so
it does kinda make sense to have them here.

Next patch will kerneldoc-ify the entire pile.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_file.c |   5 +-
 include/drm/drmP.h         | 127 +--------------------------------
 include/drm/drm_file.h     | 172 +++++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_prime.h    |   1 +
 4 files changed, 178 insertions(+), 127 deletions(-)
 create mode 100644 include/drm/drm_file.h

diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index 83e8c96ec4ab..d9e63d73d3ec 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -31,10 +31,13 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#include <drm/drmP.h>
 #include <linux/poll.h>
 #include <linux/slab.h>
 #include <linux/module.h>
+
+#include <drm/drm_file.h>
+#include <drm/drmP.h>
+
 #include "drm_legacy.h"
 #include "drm_internal.h"
 #include "drm_crtc_internal.h"
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 7bd6752683a4..4a0260e2b067 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -77,10 +77,10 @@
 #include <drm/drm_drv.h>
 #include <drm/drm_prime.h>
 #include <drm/drm_pci.h>
+#include <drm/drm_file.h>
 
 struct module;
 
-struct drm_file;
 struct drm_device;
 struct drm_agp_head;
 struct drm_local_map;
@@ -360,76 +360,6 @@ struct drm_ioctl_desc {
 		.name = #ioctl						\
 	 }
 
-/* Event queued up for userspace to read */
-struct drm_pending_event {
-	struct completion *completion;
-	void (*completion_release)(struct completion *completion);
-	struct drm_event *event;
-	struct dma_fence *fence;
-	struct list_head link;
-	struct list_head pending_link;
-	struct drm_file *file_priv;
-	pid_t pid; /* pid of requester, no guarantee it's valid by the time
-		      we deliver the event, for tracing only */
-};
-
-/** File private data */
-struct drm_file {
-	unsigned authenticated :1;
-	/* true when the client has asked us to expose stereo 3D mode flags */
-	unsigned stereo_allowed :1;
-	/*
-	 * true if client understands CRTC primary planes and cursor planes
-	 * in the plane list
-	 */
-	unsigned universal_planes:1;
-	/* true if client understands atomic properties */
-	unsigned atomic:1;
-	/*
-	 * This client is the creator of @master.
-	 * Protected by struct drm_device::master_mutex.
-	 */
-	unsigned is_master:1;
-
-	struct pid *pid;
-	drm_magic_t magic;
-	struct list_head lhead;
-	struct drm_minor *minor;
-	unsigned long lock_count;
-
-	/** Mapping of mm object handles to object pointers. */
-	struct idr object_idr;
-	/** Lock for synchronization of access to object_idr. */
-	spinlock_t table_lock;
-
-	struct file *filp;
-	void *driver_priv;
-
-	struct drm_master *master; /* master this node is currently associated with
-				      N.B. not always dev->master */
-	/**
-	 * fbs - List of framebuffers associated with this file.
-	 *
-	 * Protected by fbs_lock. Note that the fbs list holds a reference on
-	 * the fb object to prevent it from untimely disappearing.
-	 */
-	struct list_head fbs;
-	struct mutex fbs_lock;
-
-	/** User-created blob properties; this retains a reference on the
-	 *  property. */
-	struct list_head blobs;
-
-	wait_queue_head_t event_wait;
-	struct list_head pending_event_list;
-	struct list_head event_list;
-	int event_space;
-
-	struct mutex event_read_lock;
-
-	struct drm_prime_file_private prime;
-};
-
 /* Flags and return codes for get_vblank_timestamp() driver function. */
 #define DRM_CALLED_FROM_VBLIRQ 1
 #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
@@ -440,12 +370,6 @@ struct drm_file {
 #define DRM_SCANOUTPOS_IN_VBLANK    (1 << 1)
 #define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
 
-enum drm_minor_type {
-	DRM_MINOR_PRIMARY,
-	DRM_MINOR_CONTROL,
-	DRM_MINOR_RENDER,
-};
-
 /**
  * Info file list entry. This structure represents a debugfs or proc file to
  * be created by the drm core
@@ -468,21 +392,6 @@ struct drm_info_node {
 };
 
 /**
- * DRM minor structure. This structure represents a drm minor number.
- */
-struct drm_minor {
-	int index;			/**< Minor device number */
-	int type;                       /**< Control or render */
-	struct device *kdev;		/**< Linux device */
-	struct drm_device *dev;
-
-	struct dentry *debugfs_root;
-
-	struct list_head debugfs_list;
-	struct mutex debugfs_lock; /* Protects debugfs_list. */
-};
-
-/**
  * DRM device structure. This structure represent a complete card that
  * may contain multiple heads.
  */
@@ -656,21 +565,6 @@ static inline int drm_device_is_unplugged(struct drm_device *dev)
 	return ret;
 }
 
-static inline bool drm_is_render_client(const struct drm_file *file_priv)
-{
-	return file_priv->minor->type == DRM_MINOR_RENDER;
-}
-
-static inline bool drm_is_control_client(const struct drm_file *file_priv)
-{
-	return file_priv->minor->type == DRM_MINOR_CONTROL;
-}
-
-static inline bool drm_is_primary_client(const struct drm_file *file_priv)
-{
-	return file_priv->minor->type == DRM_MINOR_PRIMARY;
-}
-
 /******************************************************************/
 /** \name Internal function definitions */
 /*@{*/
@@ -688,25 +582,6 @@ extern long drm_compat_ioctl(struct file *filp,
 #endif
 extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);
 
-/* File Operations (drm_file.c) */
-int drm_open(struct inode *inode, struct file *filp);
-ssize_t drm_read(struct file *filp, char __user *buffer,
-		 size_t count, loff_t *offset);
-int drm_release(struct inode *inode, struct file *filp);
-unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
-int drm_event_reserve_init_locked(struct drm_device *dev,
-				  struct drm_file *file_priv,
-				  struct drm_pending_event *p,
-				  struct drm_event *e);
-int drm_event_reserve_init(struct drm_device *dev,
-			   struct drm_file *file_priv,
-			   struct drm_pending_event *p,
-			   struct drm_event *e);
-void drm_event_cancel_free(struct drm_device *dev,
-			   struct drm_pending_event *p);
-void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e);
-void drm_send_event(struct drm_device *dev, struct drm_pending_event *e);
-
 /* Misc. IOCTL support (drm_ioctl.c) */
 int drm_noop(struct drm_device *dev, void *data,
 	     struct drm_file *file_priv);
diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
new file mode 100644
index 000000000000..d1a25cc17fd1
--- /dev/null
+++ b/include/drm/drm_file.h
@@ -0,0 +1,172 @@
+/*
+ * 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 <faith@valinux.com>
+ * Author: Gareth Hughes <gareth@valinux.com>
+ *
+ * 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_FILE_H_
+#define _DRM_FILE_H_
+
+#include <linux/types.h>
+#include <linux/completion.h>
+
+#include <uapi/drm/drm.h>
+
+#include <drm/drm_prime.h>
+
+struct dma_fence;
+struct drm_file;
+struct drm_device;
+
+/*
+ * FIXME: Not sure we want to have drm_minor here in the end, but to avoid
+ * header include loops we need it here for now.
+ */
+enum drm_minor_type {
+	DRM_MINOR_PRIMARY,
+	DRM_MINOR_CONTROL,
+	DRM_MINOR_RENDER,
+};
+
+/**
+ * DRM minor structure. This structure represents a drm minor number.
+ */
+struct drm_minor {
+	int index;			/**< Minor device number */
+	int type;                       /**< Control or render */
+	struct device *kdev;		/**< Linux device */
+	struct drm_device *dev;
+
+	struct dentry *debugfs_root;
+
+	struct list_head debugfs_list;
+	struct mutex debugfs_lock; /* Protects debugfs_list. */
+};
+
+/* Event queued up for userspace to read */
+struct drm_pending_event {
+	struct completion *completion;
+	void (*completion_release)(struct completion *completion);
+	struct drm_event *event;
+	struct dma_fence *fence;
+	struct list_head link;
+	struct list_head pending_link;
+	struct drm_file *file_priv;
+	pid_t pid; /* pid of requester, no guarantee it's valid by the time
+		      we deliver the event, for tracing only */
+};
+
+/** File private data */
+struct drm_file {
+	unsigned authenticated :1;
+	/* true when the client has asked us to expose stereo 3D mode flags */
+	unsigned stereo_allowed :1;
+	/*
+	 * true if client understands CRTC primary planes and cursor planes
+	 * in the plane list
+	 */
+	unsigned universal_planes:1;
+	/* true if client understands atomic properties */
+	unsigned atomic:1;
+	/*
+	 * This client is the creator of @master.
+	 * Protected by struct drm_device::master_mutex.
+	 */
+	unsigned is_master:1;
+
+	struct pid *pid;
+	drm_magic_t magic;
+	struct list_head lhead;
+	struct drm_minor *minor;
+	unsigned long lock_count;
+
+	/** Mapping of mm object handles to object pointers. */
+	struct idr object_idr;
+	/** Lock for synchronization of access to object_idr. */
+	spinlock_t table_lock;
+
+	struct file *filp;
+	void *driver_priv;
+
+	struct drm_master *master; /* master this node is currently associated with
+				      N.B. not always dev->master */
+	/**
+	 * fbs - List of framebuffers associated with this file.
+	 *
+	 * Protected by fbs_lock. Note that the fbs list holds a reference on
+	 * the fb object to prevent it from untimely disappearing.
+	 */
+	struct list_head fbs;
+	struct mutex fbs_lock;
+
+	/** User-created blob properties; this retains a reference on the
+	 *  property. */
+	struct list_head blobs;
+
+	wait_queue_head_t event_wait;
+	struct list_head pending_event_list;
+	struct list_head event_list;
+	int event_space;
+
+	struct mutex event_read_lock;
+
+	struct drm_prime_file_private prime;
+};
+
+static inline bool drm_is_render_client(const struct drm_file *file_priv)
+{
+	return file_priv->minor->type == DRM_MINOR_RENDER;
+}
+
+static inline bool drm_is_control_client(const struct drm_file *file_priv)
+{
+	return file_priv->minor->type == DRM_MINOR_CONTROL;
+}
+
+static inline bool drm_is_primary_client(const struct drm_file *file_priv)
+{
+	return file_priv->minor->type == DRM_MINOR_PRIMARY;
+}
+
+int drm_open(struct inode *inode, struct file *filp);
+ssize_t drm_read(struct file *filp, char __user *buffer,
+		 size_t count, loff_t *offset);
+int drm_release(struct inode *inode, struct file *filp);
+unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
+int drm_event_reserve_init_locked(struct drm_device *dev,
+				  struct drm_file *file_priv,
+				  struct drm_pending_event *p,
+				  struct drm_event *e);
+int drm_event_reserve_init(struct drm_device *dev,
+			   struct drm_file *file_priv,
+			   struct drm_pending_event *p,
+			   struct drm_event *e);
+void drm_event_cancel_free(struct drm_device *dev,
+			   struct drm_pending_event *p);
+void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e);
+void drm_send_event(struct drm_device *dev, struct drm_pending_event *e);
+
+#endif /* _DRM_FILE_H_ */
diff --git a/include/drm/drm_prime.h b/include/drm/drm_prime.h
index 77ceca711bad..d09563ecc4b7 100644
--- a/include/drm/drm_prime.h
+++ b/include/drm/drm_prime.h
@@ -34,6 +34,7 @@
 
 #include <linux/mutex.h>
 #include <linux/rbtree.h>
+#include <linux/scatterlist.h>
 
 /**
  * struct drm_prime_file_private - per-file tracking for PRIME
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 10/24] drm: Remove drm_pending_event->pid
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
                   ` (8 preceding siblings ...)
  2017-03-08 14:12 ` [PATCH 09/24] drm: Extract drm_file.h Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-13 17:05   ` [Intel-gfx] " Sean Paul
  2017-03-08 14:12 ` [PATCH 11/24] drm/doc: Document drm_file.[hc] Daniel Vetter
                   ` (12 subsequent siblings)
  22 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Intel Graphics Development, Ben Skeggs

We might as well dump the drm_file pointer, that's about as useful
a cookie as the pid. Noticed while typing docs for drm_file and friends.

Since the only consumer of this is the tracepoints I think we can safely
change this - those tracepoints should not be uapi relevant at all. It
all goes back to

commit b9c2c9ae882f058084e13e339925dbf8d2d20271
Author: Jesse Barnes <jbarnes@virtuousgeek.org>
Date:   Thu Jul 1 16:48:09 2010 -0700

    drm: add per-event vblank event trace points

which doesn't give a special justification for using pid over a pointer.

Also note that the nouveau code setting it is entirely pointless:
Since this isn't a vblank event, it will never hit the vblank
tracepoints.

Cc: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_irq.c              |  5 ++---
 drivers/gpu/drm/drm_trace.h            | 20 ++++++++++----------
 drivers/gpu/drm/nouveau/nouveau_usif.c |  1 -
 include/drm/drm_file.h                 |  2 --
 4 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 1906723af389..9bdca69f754c 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -978,7 +978,7 @@ static void send_vblank_event(struct drm_device *dev,
 	e->event.tv_sec = now->tv_sec;
 	e->event.tv_usec = now->tv_usec;
 
-	trace_drm_vblank_event_delivered(e->base.pid, e->pipe,
+	trace_drm_vblank_event_delivered(e->base.file_priv, e->pipe,
 					 e->event.sequence);
 
 	drm_send_event_locked(dev, &e->base);
@@ -1505,7 +1505,6 @@ static int drm_queue_vblank_event(struct drm_device *dev, unsigned int pipe,
 	}
 
 	e->pipe = pipe;
-	e->base.pid = current->pid;
 	e->event.base.type = DRM_EVENT_VBLANK;
 	e->event.base.length = sizeof(e->event);
 	e->event.user_data = vblwait->request.signal;
@@ -1534,7 +1533,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, unsigned int pipe,
 	DRM_DEBUG("event on vblank count %u, current %u, crtc %u\n",
 		  vblwait->request.sequence, seq, pipe);
 
-	trace_drm_vblank_event_queued(current->pid, pipe,
+	trace_drm_vblank_event_queued(file_priv, pipe,
 				      vblwait->request.sequence);
 
 	e->event.sequence = vblwait->request.sequence;
diff --git a/drivers/gpu/drm/drm_trace.h b/drivers/gpu/drm/drm_trace.h
index ce3c42813fbb..14c5a777682e 100644
--- a/drivers/gpu/drm/drm_trace.h
+++ b/drivers/gpu/drm/drm_trace.h
@@ -24,36 +24,36 @@ TRACE_EVENT(drm_vblank_event,
 );
 
 TRACE_EVENT(drm_vblank_event_queued,
-	    TP_PROTO(pid_t pid, int crtc, unsigned int seq),
-	    TP_ARGS(pid, crtc, seq),
+	    TP_PROTO(struct drm_file *file, int crtc, unsigned int seq),
+	    TP_ARGS(file, crtc, seq),
 	    TP_STRUCT__entry(
-		    __field(pid_t, pid)
+		    __field(struct drm_file *, file)
 		    __field(int, crtc)
 		    __field(unsigned int, seq)
 		    ),
 	    TP_fast_assign(
-		    __entry->pid = pid;
+		    __entry->file = file;
 		    __entry->crtc = crtc;
 		    __entry->seq = seq;
 		    ),
-	    TP_printk("pid=%d, crtc=%d, seq=%u", __entry->pid, __entry->crtc, \
+	    TP_printk("file=%p, crtc=%d, seq=%u", __entry->file, __entry->crtc, \
 		      __entry->seq)
 );
 
 TRACE_EVENT(drm_vblank_event_delivered,
-	    TP_PROTO(pid_t pid, int crtc, unsigned int seq),
-	    TP_ARGS(pid, crtc, seq),
+	    TP_PROTO(struct drm_file *file, int crtc, unsigned int seq),
+	    TP_ARGS(file, crtc, seq),
 	    TP_STRUCT__entry(
-		    __field(pid_t, pid)
+		    __field(struct drm_file *, file)
 		    __field(int, crtc)
 		    __field(unsigned int, seq)
 		    ),
 	    TP_fast_assign(
-		    __entry->pid = pid;
+		    __entry->file = file;
 		    __entry->crtc = crtc;
 		    __entry->seq = seq;
 		    ),
-	    TP_printk("pid=%d, crtc=%d, seq=%u", __entry->pid, __entry->crtc, \
+	    TP_printk("file=%p, crtc=%d, seq=%u", __entry->file, __entry->crtc, \
 		      __entry->seq)
 );
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_usif.c b/drivers/gpu/drm/nouveau/nouveau_usif.c
index afbdbed1a690..9dc10b17ad34 100644
--- a/drivers/gpu/drm/nouveau/nouveau_usif.c
+++ b/drivers/gpu/drm/nouveau/nouveau_usif.c
@@ -211,7 +211,6 @@ usif_notify_get(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
 		goto done;
 	ntfy->p->base.event = &ntfy->p->e.base;
 	ntfy->p->base.file_priv = f;
-	ntfy->p->base.pid = current->pid;
 	ntfy->p->e.base.type = DRM_NOUVEAU_EVENT_NVIF;
 	ntfy->p->e.base.length = sizeof(ntfy->p->e.base) + ntfy->reply;
 
diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index d1a25cc17fd1..4e347399a7bd 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -75,8 +75,6 @@ struct drm_pending_event {
 	struct list_head link;
 	struct list_head pending_link;
 	struct drm_file *file_priv;
-	pid_t pid; /* pid of requester, no guarantee it's valid by the time
-		      we deliver the event, for tracing only */
 };
 
 /** File private data */
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 11/24] drm/doc: Document drm_file.[hc]
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
                   ` (9 preceding siblings ...)
  2017-03-08 14:12 ` [PATCH 10/24] drm: Remove drm_pending_event->pid Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-13 17:53   ` Sean Paul
  2017-03-08 14:12 ` [PATCH 12/24] drm/i915: Merge pre/postclose hooks Daniel Vetter
                   ` (11 subsequent siblings)
  22 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Intel Graphics Development, Daniel Vetter

Well, mostly drm_file.h, and clean up all related things:

- I didnt' figure out the difference between preclose and postclose.
  The existing explanation in drm-internals.rst didn't convince me,
  since it's also really outdated - we clean up pending DRM events in
  the core nowadays. I put a FIXME in for the future.

- Another FIXME is to have a macro for default fops.

- Lots of links all around, main areas are to tie the overview in
  drm_file.c more into the callbacks in struct drm_device, and the
  other is to link render/primary node code to the right sections in
  drm-uapi.rst.

- Also moved the open/close stuff to drm_drv.h from drm-internals.rst,
  seems like the better place for that information. Since that section
  was rather outdated this amounted to full-on rewrite.

A big missing piece here is some overview graph, but I think better to
wait with that one until drm_device and drm_driver are also fully
documented.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 Documentation/gpu/drm-internals.rst |  52 +------
 Documentation/gpu/drm-uapi.rst      |   4 +
 drivers/gpu/drm/drm_file.c          |  66 +++++----
 include/drm/drm_drv.h               |  81 ++++++++++-
 include/drm/drm_file.h              | 267 ++++++++++++++++++++++++++++++++----
 5 files changed, 356 insertions(+), 114 deletions(-)

diff --git a/Documentation/gpu/drm-internals.rst b/Documentation/gpu/drm-internals.rst
index ea329b71c459..7a2fe4a02212 100644
--- a/Documentation/gpu/drm-internals.rst
+++ b/Documentation/gpu/drm-internals.rst
@@ -246,61 +246,15 @@ drivers.
 Open/Close, File Operations and IOCTLs
 ======================================
 
-Open and Close
---------------
-
-Open and close handlers. None of those methods are mandatory::
-
-    int (*firstopen) (struct drm_device *);
-    void (*lastclose) (struct drm_device *);
-    int (*open) (struct drm_device *, struct drm_file *);
-    void (*preclose) (struct drm_device *, struct drm_file *);
-    void (*postclose) (struct drm_device *, struct drm_file *);
-
-The firstopen method is called by the DRM core for legacy UMS (User Mode
-Setting) drivers only when an application opens a device that has no
-other opened file handle. UMS drivers can implement it to acquire device
-resources. KMS drivers can't use the method and must acquire resources
-in the load method instead.
-
-Similarly the lastclose method is called when the last application
-holding a file handle opened on the device closes it, for both UMS and
-KMS drivers. Additionally, the method is also called at module unload
-time or, for hot-pluggable devices, when the device is unplugged. The
-firstopen and lastclose calls can thus be unbalanced.
-
-The open method is called every time the device is opened by an
-application. Drivers can allocate per-file private data in this method
-and store them in the struct :c:type:`struct drm_file
-<drm_file>` driver_priv field. Note that the open method is
-called before firstopen.
-
-The close operation is split into preclose and postclose methods.
-Drivers must stop and cleanup all per-file operations in the preclose
-method. For instance pending vertical blanking and page flip events must
-be cancelled. No per-file operation is allowed on the file handle after
-returning from the preclose method.
-
-Finally the postclose method is called as the last step of the close
-operation, right before calling the lastclose method if no other open
-file handle exists for the device. Drivers that have allocated per-file
-private data in the open method should free it here.
-
-The lastclose method should restore CRTC and plane properties to default
-value, so that a subsequent open of the device will not inherit state
-from the previous user. It can also be used to execute delayed power
-switching state changes, e.g. in conjunction with the :ref:`vga_switcheroo`
-infrastructure. Beyond that KMS drivers should not do any
-further cleanup. Only legacy UMS drivers might need to clean up device
-state so that the vga console or an independent fbdev driver could take
-over.
-
 File Operations
 ---------------
 
 .. kernel-doc:: drivers/gpu/drm/drm_file.c
    :doc: file operations
 
+.. kernel-doc:: include/drm/drm_file.h
+   :internal:
+
 .. kernel-doc:: drivers/gpu/drm/drm_file.c
    :export:
 
diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst
index fcc228ef5bc4..352652810dab 100644
--- a/Documentation/gpu/drm-uapi.rst
+++ b/Documentation/gpu/drm-uapi.rst
@@ -21,6 +21,8 @@ libdrm Device Lookup
    :doc: getunique and setversion story
 
 
+.. _drm_primary_node:
+
 Primary Nodes, DRM Master and Authentication
 ============================================
 
@@ -103,6 +105,8 @@ is already rather painful for the DRM subsystem, with multiple different uAPIs
 for the same thing co-existing. If we add a few more complete mistakes into the
 mix every year it would be entirely unmanageable.
 
+.. _drm_render_node:
+
 Render nodes
 ============
 
diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index d9e63d73d3ec..a8813a1115dc 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -50,12 +50,14 @@ DEFINE_MUTEX(drm_global_mutex);
  *
  * Drivers must define the file operations structure that forms the DRM
  * userspace API entry point, even though most of those operations are
- * implemented in the DRM core. The mandatory functions are drm_open(),
+ * implemented in the DRM core. The resulting &struct file_operations must be
+ * stored in the &drm_driver.fops field. The mandatory functions are drm_open(),
  * drm_read(), drm_ioctl() and drm_compat_ioctl() if CONFIG_COMPAT is enabled
- * (note that drm_compat_ioctl will be NULL if CONFIG_COMPAT=n). Drivers which
- * implement private ioctls that require 32/64 bit compatibility support must
- * provide their own .compat_ioctl() handler that processes private ioctls and
- * calls drm_compat_ioctl() for core ioctls.
+ * Note that drm_compat_ioctl will be NULL if CONFIG_COMPAT=n, so there's no
+ * need to sprinkle #ifdef into the code. Drivers which implement private ioctls
+ * that require 32/64 bit compatibility support must provide their own
+ * &file_operations.compat_ioctl handler that processes private ioctls and calls
+ * drm_compat_ioctl() for core ioctls.
  *
  * In addition drm_read() and drm_poll() provide support for DRM events. DRM
  * events are a generic and extensible means to send asynchronous events to
@@ -63,10 +65,14 @@ DEFINE_MUTEX(drm_global_mutex);
  * page flip completions by the KMS API. But drivers can also use it for their
  * own needs, e.g. to signal completion of rendering.
  *
+ * For the driver-side event interface see drm_event_reserve_init() and
+ * drm_send_event() as the main starting points.
+ *
  * The memory mapping implementation will vary depending on how the driver
  * manages memory. Legacy drivers will use the deprecated drm_legacy_mmap()
  * function, modern drivers should use one of the provided memory-manager
- * specific implementations. For GEM-based drivers this is drm_gem_mmap().
+ * specific implementations. For GEM-based drivers this is drm_gem_mmap(), and
+ * for drivers which use the CMA GEM helpers it's drm_gem_cma_mmap().
  *
  * No other file operations are supported by the DRM userspace API. Overall the
  * following is an example #file_operations structure::
@@ -82,6 +88,9 @@ DEFINE_MUTEX(drm_global_mutex);
  *             .llseek = no_llseek,
  *             .mmap = drm_gem_mmap,
  *     };
+ *
+ * FIXME: We should have a macro for this (and the CMA version) so that drivers
+ * don't have to repeat it all the time.
  */
 
 static int drm_open_helper(struct file *filp, struct drm_minor *minor);
@@ -111,9 +120,9 @@ static int drm_setup(struct drm_device * dev)
  * @inode: device inode
  * @filp: file pointer.
  *
- * This function must be used by drivers as their .open() #file_operations
- * method. It looks up the correct DRM device and instantiates all the per-file
- * resources for it.
+ * This function must be used by drivers as their &file_operations.open method.
+ * It looks up the correct DRM device and instantiates all the per-file
+ * resources for it. It also calls the &drm_driver.open driver callback.
  *
  * RETURNS:
  *
@@ -298,11 +307,6 @@ static void drm_events_release(struct drm_file *file_priv)
 	spin_unlock_irqrestore(&dev->event_lock, flags);
 }
 
-/*
- * drm_legacy_dev_reinit
- *
- * Reinitializes a legacy/ums drm device in it's lastclose function.
- */
 static void drm_legacy_dev_reinit(struct drm_device *dev)
 {
 	if (dev->irq_enabled)
@@ -327,15 +331,6 @@ static void drm_legacy_dev_reinit(struct drm_device *dev)
 	DRM_DEBUG("lastclose completed\n");
 }
 
-/*
- * Take down the DRM device.
- *
- * \param dev DRM device structure.
- *
- * Frees every resource in \p dev.
- *
- * \sa drm_device
- */
 void drm_lastclose(struct drm_device * dev)
 {
 	DRM_DEBUG("\n");
@@ -353,9 +348,11 @@ void drm_lastclose(struct drm_device * dev)
  * @inode: device inode
  * @filp: file pointer.
  *
- * This function must be used by drivers as their .release() #file_operations
- * method. It frees any resources associated with the open file, and if this is
- * the last open file for the DRM device also proceeds to call drm_lastclose().
+ * This function must be used by drivers as their &file_operations.release
+ * method. It frees any resources associated with the open file, and calls the
+ * &drm_driver.preclose and &drm_driver.lastclose driver callbacks. If this is
+ * the last open file for the DRM device also proceeds to call the
+ * &drm_driver.lastclose driver callback.
  *
  * RETURNS:
  *
@@ -443,13 +440,13 @@ EXPORT_SYMBOL(drm_release);
  * @count: count in bytes to read
  * @offset: offset to read
  *
- * This function must be used by drivers as their .read() #file_operations
+ * This function must be used by drivers as their &file_operations.read
  * method iff they use DRM events for asynchronous signalling to userspace.
  * Since events are used by the KMS API for vblank and page flip completion this
  * means all modern display drivers must use it.
  *
- * @offset is ignore, DRM events are read like a pipe. Therefore drivers also
- * must set the .llseek() #file_operation to no_llseek(). Polling support is
+ * @offset is ignored, DRM events are read like a pipe. Therefore drivers also
+ * must set the &file_operation.llseek  to no_llseek(). Polling support is
  * provided by drm_poll().
  *
  * This function will only ever read a full event. Therefore userspace must
@@ -537,10 +534,10 @@ EXPORT_SYMBOL(drm_read);
  * @filp: file pointer
  * @wait: poll waiter table
  *
- * This function must be used by drivers as their .read() #file_operations
- * method iff they use DRM events for asynchronous signalling to userspace.
- * Since events are used by the KMS API for vblank and page flip completion this
- * means all modern display drivers must use it.
+ * This function must be used by drivers as their &file_operations.read method
+ * iff they use DRM events for asynchronous signalling to userspace.  Since
+ * events are used by the KMS API for vblank and page flip completion this means
+ * all modern display drivers must use it.
  *
  * See also drm_read().
  *
@@ -650,7 +647,8 @@ EXPORT_SYMBOL(drm_event_reserve_init);
  * @p: tracking structure for the pending event
  *
  * This function frees the event @p initialized with drm_event_reserve_init()
- * and releases any allocated space.
+ * and releases any allocated space. It is used to cancel an event when the
+ * nonblocking operation could not be submitted and needed to be aborted.
  */
 void drm_event_cancel_free(struct drm_device *dev,
 			   struct drm_pending_event *p)
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index 4321d012c4ba..8f900fb30275 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -64,7 +64,6 @@ struct drm_mode_create_dumb;
  * structure for GEM drivers.
  */
 struct drm_driver {
-
 	/**
 	 * @load:
 	 *
@@ -76,14 +75,94 @@ struct drm_driver {
 	 * See drm_dev_init() and drm_dev_register() for proper and
 	 * race-free way to set up a &struct drm_device.
 	 *
+	 * This is deprecated, do not use!
+	 *
 	 * Returns:
 	 *
 	 * Zero on success, non-zero value on failure.
 	 */
 	int (*load) (struct drm_device *, unsigned long flags);
+
+	/**
+	 * @open:
+	 *
+	 * Driver callback when a new &struct drm_file is opened. Useful for
+	 * setting up driver-private data structures like buffer allocators,
+	 * execution contexts or similar things. Such driver-private resources
+	 * must be released again in @postclose.
+	 *
+	 * Since the display/modeset side of DRM can only be owned by exactly
+	 * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
+	 * there should never be a need to set up any modeset related resources
+	 * in this callback. Doing so would be a driver design bug.
+	 *
+	 * Returns:
+	 *
+	 * 0 on success, a negative error code on failure, which will be
+	 * promoted to userspace as the result of the open() system call.
+	 */
 	int (*open) (struct drm_device *, struct drm_file *);
+
+	/**
+	 * @preclose:
+	 *
+	 * One of the driver callbacks when a new &struct drm_file is closed.
+	 * Useful for tearing down driver-private data structures allocated in
+	 * @open like buffer allocators, execution contexts or similar things.
+	 *
+	 * Since the display/modeset side of DRM can only be owned by exactly
+	 * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
+	 * there should never be a need to tear down any modeset related
+	 * resources in this callback. Doing so would be a driver design bug.
+	 *
+	 * FIXME: It is not really clear why there's both @preclose and
+	 * @postclose. Without a really good reason, use @postclose only.
+	 */
 	void (*preclose) (struct drm_device *, struct drm_file *file_priv);
+
+	/**
+	 * @postclose:
+	 *
+	 * One of the driver callbacks when a new &struct drm_file is closed.
+	 * Useful for tearing down driver-private data structures allocated in
+	 * @open like buffer allocators, execution contexts or similar things.
+	 *
+	 * Since the display/modeset side of DRM can only be owned by exactly
+	 * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
+	 * there should never be a need to tear down any modeset related
+	 * resources in this callback. Doing so would be a driver design bug.
+	 *
+	 * FIXME: It is not really clear why there's both @preclose and
+	 * @postclose. Without a really good reason, use @postclose only.
+	 */
 	void (*postclose) (struct drm_device *, struct drm_file *);
+
+	/**
+	 * @lastclose:
+	 *
+	 * Called when the last &struct drm_file has been closed and there's
+	 * currently no userspace client for the &struct drm_device.
+	 *
+	 * Modern drivers should only use this to force-restore the fbdev
+	 * framebuffer using drm_fb_helper_restore_fbdev_mode_unlocked().
+	 * Anything else would indicate there's something seriously wrong.
+	 * Modern drivers can also use this to execute delayed power switching
+	 * state changes, e.g. in conjunction with the :ref:`vga_switcheroo`
+	 * infrastructure.
+	 *
+	 * This is called after @preclose and @postclose have been called.
+	 *
+	 * NOTE:
+	 *
+	 * All legacy drivers use this callback to de-initialize the hardware.
+	 * This is purely because of the shadow-attach model, where the DRM
+	 * kernel driver does not really own the hardware. Instead ownershipe is
+	 * handled with the help of userspace through an inheritedly racy dance
+	 * to set/unset the VT into raw mode.
+	 *
+	 * Legacy drivers initialize the hardware in the @firstopen callback,
+	 * which isn't even called for modern drivers.
+	 */
 	void (*lastclose) (struct drm_device *);
 
 	/**
diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index 4e347399a7bd..67244f2c0c54 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -45,6 +45,7 @@ struct drm_device;
  * FIXME: Not sure we want to have drm_minor here in the end, but to avoid
  * header include loops we need it here for now.
  */
+
 enum drm_minor_type {
 	DRM_MINOR_PRIMARY,
 	DRM_MINOR_CONTROL,
@@ -52,12 +53,19 @@ enum drm_minor_type {
 };
 
 /**
- * DRM minor structure. This structure represents a drm minor number.
+ * struct drm_minor - DRM device minor structure
+ *
+ * This structure represents a DRM minor number for device nodes in /dev.
+ * Entirely opaque to drivers and should never be inspected directly by drivers.
+ * Drivers instead should only interact with &struct drm_file and of course
+ * &struct drm_device, which is also where driver-private data and resources can
+ * be attached to.
  */
 struct drm_minor {
-	int index;			/**< Minor device number */
-	int type;                       /**< Control or render */
-	struct device *kdev;		/**< Linux device */
+	/* private: */
+	int index;			/* Minor device number */
+	int type;                       /* Control or render */
+	struct device *kdev;		/* Linux device */
 	struct drm_device *dev;
 
 	struct dentry *debugfs_root;
@@ -66,89 +74,288 @@ struct drm_minor {
 	struct mutex debugfs_lock; /* Protects debugfs_list. */
 };
 
-/* Event queued up for userspace to read */
+/**
+ * struct drm_pending_event - Event queued up for userspace to read
+ *
+ * This represents a DRM event. Drivers can use this as a generic completion
+ * mechanism, which supports kernel-internal &struct completion, &struct dma_fence
+ * and also the DRM-specific &struct drm_event delivery mechanism.
+ */
 struct drm_pending_event {
+	/**
+	 * @completion:
+	 *
+	 * Optional pointer to a kernel internal completion signalled when
+	 * drm_send_event() is called, useful to internally synchronize with
+	 * nonblcoking operations.
+	 */
 	struct completion *completion;
+
+	/**
+	 * @completion_release:
+	 *
+	 * Optional callback currently only used by the atomic modeset helpers
+	 * to clean up the reference count for the structure @completion is
+	 * stored in.
+	 */
 	void (*completion_release)(struct completion *completion);
+
+	/**
+	 * @event:
+	 *
+	 * Pointer to the actual event that should be sent to userspace to be
+	 * read using drm_read(). Can be optional, since nowadays events are
+	 * also used to signal kernel internal threads with @completion or DMA
+	 * transactions using @fence.
+	 */
 	struct drm_event *event;
+
+	/**
+	 * @fence:
+	 *
+	 * Optional DMA fence to unblock other hardware transactions which
+	 * depend upon the nonblocking DRM operation this event represents.
+	 */
 	struct dma_fence *fence;
+
+	/**
+	 * @file_priv:
+	 *
+	 * &struct drm_file where @event should be delivered to. Only set when
+	 * @event is set.
+	 */
+	struct drm_file *file_priv;
+
+	/**
+	 * @link:
+	 *
+	 * Double-linked list to keep track of this event. Can be used by the
+	 * driver up to the point when it calls drm_send_event(), after that
+	 * this list entry is owned by the core for its own book-keeping.
+	 */
 	struct list_head link;
+
+	/**
+	 * @pending_link:
+	 *
+	 * Entry on &drm_file.pending_event_list, to keep track of all pending
+	 * events for @file_priv, to allow correct unwinding of them when
+	 * userspace closes the file before the event is delivered.
+	 */
 	struct list_head pending_link;
-	struct drm_file *file_priv;
 };
 
-/** File private data */
+/**
+ * struct drm_file - DRM file private data
+ *
+ * This structure tracks per open file descriptor DRM state.
+ */
 struct drm_file {
+	/**
+	 * @authenticated:
+	 *
+	 * Whether the client is allowed to submit rendering, which for legacy
+	 * nodes means it must be authenticated.
+	 *
+	 * See also the :ref:`section on primary nodes and authentication
+	 * <drm_primary_node>`.
+	 */
+
 	unsigned authenticated :1;
-	/* true when the client has asked us to expose stereo 3D mode flags */
+
+	/**
+	 * @stereo_allowed:
+	 *
+	 * True when the client has asked us to expose stereo 3D mode flags.
+	 */
 	unsigned stereo_allowed :1;
-	/*
-	 * true if client understands CRTC primary planes and cursor planes
-	 * in the plane list
+
+	/**
+	 * @universal_planes:
+	 *
+	 * True if client understands CRTC primary planes and cursor planes
+	 * in the plane list. Automatically set when @atomic is set.
 	 */
 	unsigned universal_planes:1;
-	/* true if client understands atomic properties */
+
+	/** @atomic: True if client understands atomic properties. */
 	unsigned atomic:1;
-	/*
-	 * This client is the creator of @master.
-	 * Protected by struct drm_device::master_mutex.
+
+	/**
+	 * @is_master:
+	 *
+	 * This client is the creator of @master.  Protected by struct
+	 * &drm_device.master_mutex.
+	 *
+	 * See also the :ref:`section on primary nodes and authentication
+	 * <drm_primary_node>`.
 	 */
 	unsigned is_master:1;
 
+	/**
+	 * @master:
+	 *
+	 * Master this node is currently associated with. Only relevant if
+	 * drm_is_primary_client() returns true. Note that this only
+	 * matches &drm_device.master if the master is the currently active one.
+	 *
+	 * See also @authentication and @is_master and the :ref:`section on
+	 * primary nodes and authentication <drm_primary_node>`.
+	 */
+	struct drm_master *master;
+
+	/** @pid: Process that opened this file. */
 	struct pid *pid;
+
+	/** @magic: Authentication magic, see @authenticated. */
 	drm_magic_t magic;
+
+	/**
+	 * @lhead:
+	 *
+	 * List of all open files of a DRM device, linked into
+	 * &drm_device.filelist. Protected by &drm_device.filelist_mutex.
+	 */
 	struct list_head lhead;
+
+
+	/** @minor: &struct drm_minor for this file. */
 	struct drm_minor *minor;
-	unsigned long lock_count;
 
-	/** Mapping of mm object handles to object pointers. */
+	/**
+	 * @object_idr:
+	 *
+	 * Mapping of mm object handles to object pointers. Used by the GEM
+	 * subsystem. Protected by @table_lock.
+	 */
 	struct idr object_idr;
-	/** Lock for synchronization of access to object_idr. */
+
+	/** @table_lock: Protects @object_idr. */
 	spinlock_t table_lock;
 
+	/** @filp: Pointer to the core file structure. */
 	struct file *filp;
+
+	/**
+	 * @driver_priv:
+	 *
+	 * Optional pointer for driver private data. Can be allocated in
+	 * &drm_driver.open and should be freed in &drm_driver.postclose.
+	 */
 	void *driver_priv;
 
-	struct drm_master *master; /* master this node is currently associated with
-				      N.B. not always dev->master */
 	/**
-	 * fbs - List of framebuffers associated with this file.
+	 * @fbs:
+	 *
+	 * List of &struct drm_framebuffer associated with this file, using the
+	 * &drm_framebuffer.filp_head entry.
 	 *
-	 * Protected by fbs_lock. Note that the fbs list holds a reference on
-	 * the fb object to prevent it from untimely disappearing.
+	 * Protected by @fbs_lock. Note that the @fbs list holds a reference on
+	 * the framebuffer object to prevent it from untimely disappearing.
 	 */
 	struct list_head fbs;
+
+	/** @fbs_lock: Protects @fbs. */
 	struct mutex fbs_lock;
 
-	/** User-created blob properties; this retains a reference on the
-	 *  property. */
+	/**
+	 * @blobs:
+	 *
+	 * User-created blob properties; this retains a reference on the
+	 * property.
+	 *
+	 * Protected by @drm_mode_config.blob_lock;
+	 */
 	struct list_head blobs;
 
+	/** @event_wait: Waitqueue for new events added to @event_list. */
 	wait_queue_head_t event_wait;
+
+	/**
+	 * @pending_event_list:
+	 *
+	 * List of pending &struct drm_pending_event, used to clean up pending
+	 * events in case this file gets closed before the event is signalled.
+	 * Uses the &drm_pending_event.pending_link entry.
+	 *
+	 * Protect by &drm_device.event_lock.
+	 */
 	struct list_head pending_event_list;
+
+	/**
+	 * @event_list:
+	 *
+	 * List of &struct drm_pending_event, ready for devlivery to userspace
+	 * through drm_read(). Uses the &drm_pending_event.link entry.
+	 *
+	 * Protect by &drm_device.event_lock.
+	 */
 	struct list_head event_list;
+
+	/**
+	 * @event_space:
+	 *
+	 * Available event space to prevent userspace from
+	 * exhausting kernel memory. Currently limited to the fairly arbitrary
+	 * value of 4KB.
+	 */
 	int event_space;
 
+	/** @event_read_lock: Serializes drm_read(). */
 	struct mutex event_read_lock;
 
+	/**
+	 * @prime:
+	 *
+	 * Per-file buffer caches used by the PRIME buffer sharing code.
+	 */
 	struct drm_prime_file_private prime;
+
+	/* private: */
+	unsigned long lock_count; /* DRI1 legacy lock count */
 };
 
+/**
+ * drm_is_primary_client - is this an open file of the primary node
+ * @file_priv: DRM file
+ *
+ * Returns true if this is an open file of the primary node, i.e.
+ * &drm_file.minor of @file_priv is a primary minor.
+ *
+ * See also the :ref:`section on primary nodes and authentication
+ * <drm_primary_node>`.
+ */
+static inline bool drm_is_primary_client(const struct drm_file *file_priv)
+{
+	return file_priv->minor->type == DRM_MINOR_PRIMARY;
+}
+
+/**
+ * drm_is_render_client - is this an open file of the render node
+ * @file_priv: DRM file
+ *
+ * Returns true if this is an open file of the render node, i.e.
+ * &drm_file.minor of @file_priv is a render minor.
+ *
+ * See also the :ref:`section on render nodes <drm_render_node>`.
+ */
 static inline bool drm_is_render_client(const struct drm_file *file_priv)
 {
 	return file_priv->minor->type == DRM_MINOR_RENDER;
 }
 
+/**
+ * drm_is_control_client - is this an open file of the control node
+ * @file_priv: DRM file
+ *
+ * Control nodes are deprecated and in the process of getting removed from the
+ * DRM userspace API. Do not ever use!
+ */
 static inline bool drm_is_control_client(const struct drm_file *file_priv)
 {
 	return file_priv->minor->type == DRM_MINOR_CONTROL;
 }
 
-static inline bool drm_is_primary_client(const struct drm_file *file_priv)
-{
-	return file_priv->minor->type == DRM_MINOR_PRIMARY;
-}
-
 int drm_open(struct inode *inode, struct file *filp);
 ssize_t drm_read(struct file *filp, char __user *buffer,
 		 size_t count, loff_t *offset);
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 12/24] drm/i915: Merge pre/postclose hooks
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
                   ` (10 preceding siblings ...)
  2017-03-08 14:12 ` [PATCH 11/24] drm/doc: Document drm_file.[hc] Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-08 15:07   ` Chris Wilson
  2017-03-08 14:12 ` [PATCH 13/24] drm/msm: switch to postclose Daniel Vetter
                   ` (10 subsequent siblings)
  22 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Intel Graphics Development, Daniel Vetter

There's really not a reason afaics that we can't just clean up
everything at the end, in the terminal postclose hook: Since this is
closing a file descriptor we know no one else can have a reference or
a thread doing something with that drm_file except the close code.
Ordering shouldn't matter, as long as we don't kfree before we clean
stuff up.

In the past this was more relevant when drivers still had to track and
clean up pending drm events, but that's all done by the core now.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index b1e9027a4f80..1e511d17684e 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1423,17 +1423,14 @@ static void i915_driver_lastclose(struct drm_device *dev)
 	vga_switcheroo_process_delayed_switch();
 }
 
-static void i915_driver_preclose(struct drm_device *dev, struct drm_file *file)
+static void i915_driver_postclose(struct drm_device *dev, struct drm_file *file)
 {
+	struct drm_i915_file_private *file_priv = file->driver_priv;
+
 	mutex_lock(&dev->struct_mutex);
 	i915_gem_context_close(dev, file);
 	i915_gem_release(dev, file);
 	mutex_unlock(&dev->struct_mutex);
-}
-
-static void i915_driver_postclose(struct drm_device *dev, struct drm_file *file)
-{
-	struct drm_i915_file_private *file_priv = file->driver_priv;
 
 	kfree(file_priv);
 }
@@ -2638,7 +2635,6 @@ static struct drm_driver driver = {
 	.release = i915_driver_release,
 	.open = i915_driver_open,
 	.lastclose = i915_driver_lastclose,
-	.preclose = i915_driver_preclose,
 	.postclose = i915_driver_postclose,
 	.set_busid = drm_pci_set_busid,
 
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 13/24] drm/msm: switch to postclose
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
                   ` (11 preceding siblings ...)
  2017-03-08 14:12 ` [PATCH 12/24] drm/i915: Merge pre/postclose hooks Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-13 18:59   ` Sean Paul
  2017-03-08 14:12 ` [PATCH 16/24] drm/tegra: " Daniel Vetter
                   ` (9 subsequent siblings)
  22 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development
  Cc: Daniel Vetter, Intel Graphics Development, linux-arm-msm,
	Daniel Vetter, freedreno

I didn't spot anything that would require ordering here (well not
anywhere else either), and I'm trying to unify at least modern drivers
on one close hook.

Cc: Rob Clark <robdclark@gmail.com>
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/msm/msm_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 604331f3cf39..44774f02ef0e 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -540,7 +540,7 @@ static int msm_open(struct drm_device *dev, struct drm_file *file)
 	return 0;
 }
 
-static void msm_preclose(struct drm_device *dev, struct drm_file *file)
+static void msm_postclose(struct drm_device *dev, struct drm_file *file)
 {
 	struct msm_drm_private *priv = dev->dev_private;
 	struct msm_file_private *ctx = file->driver_priv;
@@ -813,7 +813,7 @@ static struct drm_driver msm_driver = {
 				DRIVER_ATOMIC |
 				DRIVER_MODESET,
 	.open               = msm_open,
-	.preclose           = msm_preclose,
+	.postclose           = msm_postclose,
 	.lastclose          = msm_lastclose,
 	.irq_handler        = msm_irq,
 	.irq_preinstall     = msm_irq_preinstall,
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 14/24] drm/nouveau: Merge pre/postclose hooks
       [not found] ` <20170308141257.12119-1-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
@ 2017-03-08 14:12   ` Daniel Vetter
       [not found]     ` <20170308141257.12119-15-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
  2017-03-08 14:12   ` [PATCH 15/24] drm/radeon: " Daniel Vetter
  2017-03-08 14:12   ` [PATCH 19/24] drm/amdgpu: " Daniel Vetter
  2 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development
  Cc: Daniel Vetter, Intel Graphics Development, Ben Skeggs,
	nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Again no apparent explanation for the split except hysterical raisins.
Merging them also makes it a bit more obviuos what's going on wrt the
runtime pm refdancing.

Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: nouveau@lists.freedesktop.org
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index f0bb7606eb8b..0e26be017de7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -881,7 +881,7 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
 }
 
 static void
-nouveau_drm_preclose(struct drm_device *dev, struct drm_file *fpriv)
+nouveau_drm_postclose(struct drm_device *dev, struct drm_file *fpriv)
 {
 	struct nouveau_cli *cli = nouveau_cli(fpriv);
 	struct nouveau_drm *drm = nouveau_drm(dev);
@@ -897,12 +897,6 @@ nouveau_drm_preclose(struct drm_device *dev, struct drm_file *fpriv)
 	list_del(&cli->head);
 	mutex_unlock(&drm->client.mutex);
 
-}
-
-static void
-nouveau_drm_postclose(struct drm_device *dev, struct drm_file *fpriv)
-{
-	struct nouveau_cli *cli = nouveau_cli(fpriv);
 	nouveau_cli_fini(cli);
 	kfree(cli);
 	pm_runtime_mark_last_busy(dev->dev);
@@ -974,7 +968,6 @@ driver_stub = {
 	.load = nouveau_drm_load,
 	.unload = nouveau_drm_unload,
 	.open = nouveau_drm_open,
-	.preclose = nouveau_drm_preclose,
 	.postclose = nouveau_drm_postclose,
 	.lastclose = nouveau_vga_lastclose,
 
-- 
2.11.0

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 15/24] drm/radeon: Merge pre/postclose hooks
       [not found] ` <20170308141257.12119-1-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
  2017-03-08 14:12   ` [PATCH 14/24] drm/nouveau: Merge pre/postclose hooks Daniel Vetter
@ 2017-03-08 14:12   ` Daniel Vetter
       [not found]     ` <20170308141257.12119-16-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
  2017-03-08 14:12   ` [PATCH 19/24] drm/amdgpu: " Daniel Vetter
  2 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development
  Cc: Daniel Vetter, Intel Graphics Development,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Alex Deucher,
	Daniel Vetter, Christian König

Again no apparent explanation for the split except hysterical raisins.
Merging them also makes it a bit more obviuos what's going on wrt the
runtime pm refdancing.

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/radeon/radeon_drv.c |  3 ---
 drivers/gpu/drm/radeon/radeon_kms.c | 42 +++++++++++++------------------------
 2 files changed, 14 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 956c425e639e..312436a8d9e5 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -108,8 +108,6 @@ void radeon_driver_lastclose_kms(struct drm_device *dev);
 int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv);
 void radeon_driver_postclose_kms(struct drm_device *dev,
 				 struct drm_file *file_priv);
-void radeon_driver_preclose_kms(struct drm_device *dev,
-				struct drm_file *file_priv);
 int radeon_suspend_kms(struct drm_device *dev, bool suspend,
 		       bool fbcon, bool freeze);
 int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
@@ -538,7 +536,6 @@ static struct drm_driver kms_driver = {
 	    DRIVER_PRIME | DRIVER_RENDER,
 	.load = radeon_driver_load_kms,
 	.open = radeon_driver_open_kms,
-	.preclose = radeon_driver_preclose_kms,
 	.postclose = radeon_driver_postclose_kms,
 	.lastclose = radeon_driver_lastclose_kms,
 	.set_busid = drm_pci_set_busid,
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 56f35c06742c..a32a62e03a44 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -691,13 +691,26 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
  * @dev: drm dev pointer
  * @file_priv: drm file
  *
- * On device post close, tear down vm on cayman+ (all asics).
+ * On device close, tear down hyperz and cmask filps on r1xx-r5xx
+ * (all asics).  And tear down vm on cayman+ (all asics).
  */
 void radeon_driver_postclose_kms(struct drm_device *dev,
 				 struct drm_file *file_priv)
 {
 	struct radeon_device *rdev = dev->dev_private;
 
+	pm_runtime_get_sync(dev->dev);
+
+	mutex_lock(&rdev->gem.mutex);
+	if (rdev->hyperz_filp == file_priv)
+		rdev->hyperz_filp = NULL;
+	if (rdev->cmask_filp == file_priv)
+		rdev->cmask_filp = NULL;
+	mutex_unlock(&rdev->gem.mutex);
+
+	radeon_uvd_free_handles(rdev, file_priv);
+	radeon_vce_free_handles(rdev, file_priv);
+
 	/* new gpu have virtual address space support */
 	if (rdev->family >= CHIP_CAYMAN && file_priv->driver_priv) {
 		struct radeon_fpriv *fpriv = file_priv->driver_priv;
@@ -721,33 +734,6 @@ void radeon_driver_postclose_kms(struct drm_device *dev,
 	pm_runtime_put_autosuspend(dev->dev);
 }
 
-/**
- * radeon_driver_preclose_kms - drm callback for pre close
- *
- * @dev: drm dev pointer
- * @file_priv: drm file
- *
- * On device pre close, tear down hyperz and cmask filps on r1xx-r5xx
- * (all asics).
- */
-void radeon_driver_preclose_kms(struct drm_device *dev,
-				struct drm_file *file_priv)
-{
-	struct radeon_device *rdev = dev->dev_private;
-
-	pm_runtime_get_sync(dev->dev);
-
-	mutex_lock(&rdev->gem.mutex);
-	if (rdev->hyperz_filp == file_priv)
-		rdev->hyperz_filp = NULL;
-	if (rdev->cmask_filp == file_priv)
-		rdev->cmask_filp = NULL;
-	mutex_unlock(&rdev->gem.mutex);
-
-	radeon_uvd_free_handles(rdev, file_priv);
-	radeon_vce_free_handles(rdev, file_priv);
-}
-
 /*
  * VBlank related functions.
  */
-- 
2.11.0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 16/24] drm/tegra: switch to postclose
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
                   ` (12 preceding siblings ...)
  2017-03-08 14:12 ` [PATCH 13/24] drm/msm: switch to postclose Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
       [not found]   ` <20170308141257.12119-17-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
  2017-03-08 14:12 ` [PATCH 17/24] drm/vgem: " Daniel Vetter
                   ` (8 subsequent siblings)
  22 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development
  Cc: linux-tegra, Daniel Vetter, Intel Graphics Development,
	Thierry Reding, Daniel Vetter

I didn't spot anything that would require ordering here (well not
anywhere else either), and I'm trying to unify at least modern drivers
on one close hook.

Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-tegra@vger.kernel.org
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/tegra/drm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index dba4e090d3df..3b419f9dbf4d 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -804,7 +804,7 @@ static const struct file_operations tegra_drm_fops = {
 	.llseek = noop_llseek,
 };
 
-static void tegra_drm_preclose(struct drm_device *drm, struct drm_file *file)
+static void tegra_drm_postclose(struct drm_device *drm, struct drm_file *file)
 {
 	struct tegra_drm_file *fpriv = file->driver_priv;
 	struct tegra_drm_context *context, *tmp;
@@ -868,7 +868,7 @@ static struct drm_driver tegra_drm_driver = {
 	.load = tegra_drm_load,
 	.unload = tegra_drm_unload,
 	.open = tegra_drm_open,
-	.preclose = tegra_drm_preclose,
+	.postclose = tegra_drm_postclose,
 	.lastclose = tegra_drm_lastclose,
 
 #if defined(CONFIG_DEBUG_FS)
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 17/24] drm/vgem: switch to postclose
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
                   ` (13 preceding siblings ...)
  2017-03-08 14:12 ` [PATCH 16/24] drm/tegra: " Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-13 19:11   ` Sean Paul
  2017-03-08 14:12 ` [PATCH 18/24] drm/etnaviv: " Daniel Vetter
                   ` (7 subsequent siblings)
  22 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Daniel Vetter, Intel Graphics Development

I didn't spot anything that would require ordering here (well not
anywhere else either), and I'm trying to unify at least modern drivers
on one close hook.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/vgem/vgem_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c
index a1f42d125e6e..9fee38a942c4 100644
--- a/drivers/gpu/drm/vgem/vgem_drv.c
+++ b/drivers/gpu/drm/vgem/vgem_drv.c
@@ -104,7 +104,7 @@ static int vgem_open(struct drm_device *dev, struct drm_file *file)
 	return 0;
 }
 
-static void vgem_preclose(struct drm_device *dev, struct drm_file *file)
+static void vgem_postclose(struct drm_device *dev, struct drm_file *file)
 {
 	struct vgem_file *vfile = file->driver_priv;
 
@@ -303,7 +303,7 @@ static int vgem_prime_mmap(struct drm_gem_object *obj,
 static struct drm_driver vgem_driver = {
 	.driver_features		= DRIVER_GEM | DRIVER_PRIME,
 	.open				= vgem_open,
-	.preclose			= vgem_preclose,
+	.postclose			= vgem_postclose,
 	.gem_free_object_unlocked	= vgem_gem_free_object,
 	.gem_vm_ops			= &vgem_gem_vm_ops,
 	.ioctls				= vgem_ioctls,
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 18/24] drm/etnaviv: switch to postclose
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
                   ` (14 preceding siblings ...)
  2017-03-08 14:12 ` [PATCH 17/24] drm/vgem: " Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-08 16:09   ` Lucas Stach
       [not found] ` <20170308141257.12119-1-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
                   ` (6 subsequent siblings)
  22 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development
  Cc: Daniel Vetter, Intel Graphics Development, etnaviv, Russell King,
	Daniel Vetter

I didn't spot anything that would require ordering here (well not
anywhere else either), and I'm trying to unify at least modern drivers
on one close hook.

Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Russell King <linux+etnaviv@armlinux.org.uk>
Cc: Christian Gmeiner <christian.gmeiner@gmail.com>
Cc: etnaviv@lists.freedesktop.org
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/etnaviv/etnaviv_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index 587e45043542..289a9f8c6671 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -111,7 +111,7 @@ static int etnaviv_open(struct drm_device *dev, struct drm_file *file)
 	return 0;
 }
 
-static void etnaviv_preclose(struct drm_device *dev, struct drm_file *file)
+static void etnaviv_postclose(struct drm_device *dev, struct drm_file *file)
 {
 	struct etnaviv_drm_private *priv = dev->dev_private;
 	struct etnaviv_file_private *ctx = file->driver_priv;
@@ -488,7 +488,7 @@ static struct drm_driver etnaviv_drm_driver = {
 				DRIVER_PRIME |
 				DRIVER_RENDER,
 	.open               = etnaviv_open,
-	.preclose           = etnaviv_preclose,
+	.postclose           = etnaviv_postclose,
 	.gem_free_object_unlocked = etnaviv_gem_free_object,
 	.gem_vm_ops         = &vm_ops,
 	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 19/24] drm/amdgpu: Merge pre/postclose hooks
       [not found] ` <20170308141257.12119-1-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
  2017-03-08 14:12   ` [PATCH 14/24] drm/nouveau: Merge pre/postclose hooks Daniel Vetter
  2017-03-08 14:12   ` [PATCH 15/24] drm/radeon: " Daniel Vetter
@ 2017-03-08 14:12   ` Daniel Vetter
  2 siblings, 0 replies; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development
  Cc: Daniel Vetter, Intel Graphics Development,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Alex Deucher,
	Daniel Vetter, Christian König

Again no apparent explanation for the split except hysterical raisins.
Merging them also makes it a bit more obviuos what's going on wrt the
runtime pm refdancing.

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     |  2 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 17 ++---------------
 3 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index c1b913541739..c8860f05bfb9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1762,8 +1762,6 @@ void amdgpu_driver_lastclose_kms(struct drm_device *dev);
 int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv);
 void amdgpu_driver_postclose_kms(struct drm_device *dev,
 				 struct drm_file *file_priv);
-void amdgpu_driver_preclose_kms(struct drm_device *dev,
-				struct drm_file *file_priv);
 int amdgpu_suspend(struct amdgpu_device *adev);
 int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon);
 int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 75fc376ba735..09eb5026983c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -684,7 +684,6 @@ static struct drm_driver kms_driver = {
 	    DRIVER_PRIME | DRIVER_RENDER | DRIVER_MODESET,
 	.load = amdgpu_driver_load_kms,
 	.open = amdgpu_driver_open_kms,
-	.preclose = amdgpu_driver_preclose_kms,
 	.postclose = amdgpu_driver_postclose_kms,
 	.lastclose = amdgpu_driver_lastclose_kms,
 	.set_busid = drm_pci_set_busid,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 61d94c745672..55f951bcc91f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -694,6 +694,8 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
 	if (!fpriv)
 		return;
 
+	pm_runtime_get_sync(dev->dev);
+
 	amdgpu_ctx_mgr_fini(&fpriv->ctx_mgr);
 
 	amdgpu_uvd_free_handles(adev, file_priv);
@@ -722,21 +724,6 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
 	pm_runtime_put_autosuspend(dev->dev);
 }
 
-/**
- * amdgpu_driver_preclose_kms - drm callback for pre close
- *
- * @dev: drm dev pointer
- * @file_priv: drm file
- *
- * On device pre close, tear down hyperz and cmask filps on r1xx-r5xx
- * (all asics).
- */
-void amdgpu_driver_preclose_kms(struct drm_device *dev,
-				struct drm_file *file_priv)
-{
-	pm_runtime_get_sync(dev->dev);
-}
-
 /*
  * VBlank related functions.
  */
-- 
2.11.0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 20/24] drm/exynos: Merge pre/postclose hooks
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
                   ` (16 preceding siblings ...)
       [not found] ` <20170308141257.12119-1-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-13 19:18   ` [Intel-gfx] " Sean Paul
  2017-03-08 14:12 ` [PATCH 21/24] drm/msm: Simplify vblank event delivery Daniel Vetter
                   ` (4 subsequent siblings)
  22 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development
  Cc: Joonyoung Shim, Daniel Vetter, Intel Graphics Development,
	Seung-Woo Kim, Inki Dae, Kyungmin Park, Daniel Vetter

Again no apparent explanation for the split except hysterical raisins.
Merging them also makes it a bit more obviuos what's going on wrt the
runtime pm refdancing.

Cc: Inki Dae <inki.dae@samsung.com>
Cc: Joonyoung Shim <jy0922.shim@samsung.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index b4522f67b3cb..180e3c9884e5 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -194,14 +194,9 @@ static int exynos_drm_open(struct drm_device *dev, struct drm_file *file)
 	return ret;
 }
 
-static void exynos_drm_preclose(struct drm_device *dev,
-					struct drm_file *file)
-{
-	exynos_drm_subdrv_close(dev, file);
-}
-
 static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file)
 {
+	exynos_drm_subdrv_close(dev, file);
 	kfree(file->driver_priv);
 	file->driver_priv = NULL;
 }
@@ -259,7 +254,6 @@ static struct drm_driver exynos_drm_driver = {
 	.load			= exynos_drm_load,
 	.unload			= exynos_drm_unload,
 	.open			= exynos_drm_open,
-	.preclose		= exynos_drm_preclose,
 	.lastclose		= exynos_drm_lastclose,
 	.postclose		= exynos_drm_postclose,
 	.gem_free_object_unlocked = exynos_drm_gem_free_object,
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 21/24] drm/msm: Simplify vblank event delivery
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
                   ` (17 preceding siblings ...)
  2017-03-08 14:12 ` [PATCH 20/24] drm/exynos: " Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-13 19:26   ` Sean Paul
  2017-03-08 14:12 ` [PATCH 22/24] drm: Nerf the preclose callback for modern drivers Daniel Vetter
                   ` (3 subsequent siblings)
  22 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development
  Cc: Daniel Vetter, Intel Graphics Development, linux-arm-msm,
	Daniel Vetter, freedreno

The core takes care of handling the send_event vs. close() issues, we
can remove that driver code.

Cc: Rob Clark <robdclark@gmail.com>
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c | 12 +++---------
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c | 12 +++---------
 2 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
index 1c29618f4ddb..f29194a74a19 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
@@ -114,15 +114,9 @@ static void complete_flip(struct drm_crtc *crtc, struct drm_file *file)
 	spin_lock_irqsave(&dev->event_lock, flags);
 	event = mdp4_crtc->event;
 	if (event) {
-		/* if regular vblank case (!file) or if cancel-flip from
-		 * preclose on file that requested flip, then send the
-		 * event:
-		 */
-		if (!file || (event->base.file_priv == file)) {
-			mdp4_crtc->event = NULL;
-			DBG("%s: send event: %p", mdp4_crtc->name, event);
-			drm_crtc_send_vblank_event(crtc, event);
-		}
+		mdp4_crtc->event = NULL;
+		DBG("%s: send event: %p", mdp4_crtc->name, event);
+		drm_crtc_send_vblank_event(crtc, event);
 	}
 	spin_unlock_irqrestore(&dev->event_lock, flags);
 }
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
index d0c8b38b96ce..87a19e0c0e67 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
@@ -138,15 +138,9 @@ static void complete_flip(struct drm_crtc *crtc, struct drm_file *file)
 	spin_lock_irqsave(&dev->event_lock, flags);
 	event = mdp5_crtc->event;
 	if (event) {
-		/* if regular vblank case (!file) or if cancel-flip from
-		 * preclose on file that requested flip, then send the
-		 * event:
-		 */
-		if (!file || (event->base.file_priv == file)) {
-			mdp5_crtc->event = NULL;
-			DBG("%s: send event: %p", crtc->name, event);
-			drm_crtc_send_vblank_event(crtc, event);
-		}
+		mdp5_crtc->event = NULL;
+		DBG("%s: send event: %p", crtc->name, event);
+		drm_crtc_send_vblank_event(crtc, event);
 	}
 	spin_unlock_irqrestore(&dev->event_lock, flags);
 
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 22/24] drm: Nerf the preclose callback for modern drivers
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
                   ` (18 preceding siblings ...)
  2017-03-08 14:12 ` [PATCH 21/24] drm/msm: Simplify vblank event delivery Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-09 10:48   ` Daniel Vetter
  2017-03-13 19:29   ` [Intel-gfx] " Sean Paul
  2017-03-08 14:12 ` [PATCH 23/24] drm: Create DEFINE_DRM_GEM_CMA_FOPS and roll it out to drivers Daniel Vetter
                   ` (2 subsequent siblings)
  22 siblings, 2 replies; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Intel Graphics Development, Daniel Vetter

With all drivers converted there's only legacy dri1 drivers using it.
Not going to touch those, instead just hide it like we've done with
other dri1 driver hooks like firstopen.

In all this I didn't find any real reason why we'd needed 2 hooks, and
having symmetry between open and close just appeases my OCD better.
Yeah, someone else could do an s/postclose/close/, but that's for
someone who understands cocci. And maybe after this series is reviewed
and landed, to avoid patch-regen churn.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_file.c |  8 ++++----
 include/drm/drm_drv.h      | 23 ++---------------------
 2 files changed, 6 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index a8813a1115dc..f8483fc6d3d7 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -350,9 +350,8 @@ void drm_lastclose(struct drm_device * dev)
  *
  * This function must be used by drivers as their &file_operations.release
  * method. It frees any resources associated with the open file, and calls the
- * &drm_driver.preclose and &drm_driver.lastclose driver callbacks. If this is
- * the last open file for the DRM device also proceeds to call the
- * &drm_driver.lastclose driver callback.
+ * &drm_driver.lastclose driver callback. If this is the last open file for the
+ * DRM device also proceeds to call the &drm_driver.lastclose driver callback.
  *
  * RETURNS:
  *
@@ -372,7 +371,8 @@ int drm_release(struct inode *inode, struct file *filp)
 	list_del(&file_priv->lhead);
 	mutex_unlock(&dev->filelist_mutex);
 
-	if (dev->driver->preclose)
+	if (drm_core_check_feature(dev, DRIVER_LEGACY) &&
+	    dev->driver->preclose)
 		dev->driver->preclose(dev, file_priv);
 
 	/* ========================================================
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index 8f900fb30275..fde343e0d581 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -104,23 +104,6 @@ struct drm_driver {
 	int (*open) (struct drm_device *, struct drm_file *);
 
 	/**
-	 * @preclose:
-	 *
-	 * One of the driver callbacks when a new &struct drm_file is closed.
-	 * Useful for tearing down driver-private data structures allocated in
-	 * @open like buffer allocators, execution contexts or similar things.
-	 *
-	 * Since the display/modeset side of DRM can only be owned by exactly
-	 * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
-	 * there should never be a need to tear down any modeset related
-	 * resources in this callback. Doing so would be a driver design bug.
-	 *
-	 * FIXME: It is not really clear why there's both @preclose and
-	 * @postclose. Without a really good reason, use @postclose only.
-	 */
-	void (*preclose) (struct drm_device *, struct drm_file *file_priv);
-
-	/**
 	 * @postclose:
 	 *
 	 * One of the driver callbacks when a new &struct drm_file is closed.
@@ -131,9 +114,6 @@ struct drm_driver {
 	 * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
 	 * there should never be a need to tear down any modeset related
 	 * resources in this callback. Doing so would be a driver design bug.
-	 *
-	 * FIXME: It is not really clear why there's both @preclose and
-	 * @postclose. Without a really good reason, use @postclose only.
 	 */
 	void (*postclose) (struct drm_device *, struct drm_file *);
 
@@ -150,7 +130,7 @@ struct drm_driver {
 	 * state changes, e.g. in conjunction with the :ref:`vga_switcheroo`
 	 * infrastructure.
 	 *
-	 * This is called after @preclose and @postclose have been called.
+	 * This is called after @postclose hook has been called.
 	 *
 	 * NOTE:
 	 *
@@ -516,6 +496,7 @@ struct drm_driver {
 	/* List of devices hanging off this driver with stealth attach. */
 	struct list_head legacy_dev_list;
 	int (*firstopen) (struct drm_device *);
+	void (*preclose) (struct drm_device *, struct drm_file *file_priv);
 	int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
 	int (*dma_quiescent) (struct drm_device *);
 	int (*context_dtor) (struct drm_device *dev, int context);
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 23/24] drm: Create DEFINE_DRM_GEM_CMA_FOPS and roll it out to drivers
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
                   ` (19 preceding siblings ...)
  2017-03-08 14:12 ` [PATCH 22/24] drm: Nerf the preclose callback for modern drivers Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-13 17:11   ` Liviu Dudau
  2017-03-13 19:31   ` [Intel-gfx] " Sean Paul
  2017-03-08 14:12 ` [PATCH 24/24] drm/gem: Add DEFINE_DRM_GEM_FOPS Daniel Vetter
  2017-03-08 17:52 ` ✓ Fi.CI.BAT: success for more docs and header splits Patchwork
  22 siblings, 2 replies; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Intel Graphics Development, Daniel Vetter

Less code ftw.

This converts all drivers except the tinydrm helper module. That one
needs more work, since it gets the THIS_MODULE reference from
tinydrm.ko instead of the actual driver module like it should.
Probably needs a similar trick like I used here with generating the
entire struct with a macro.

Cc: Noralf Trønnes <noralf@tronnes.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/arm/hdlcd_drv.c                 | 12 +-----------
 drivers/gpu/drm/arm/malidp_drv.c                | 12 +-----------
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c    | 12 +-----------
 drivers/gpu/drm/drm_file.c                      |  3 +++
 drivers/gpu/drm/drm_gem_cma_helper.c            |  3 +++
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c       | 12 +-----------
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 12 +-----------
 drivers/gpu/drm/imx/imx-drm-core.c              | 11 +----------
 drivers/gpu/drm/meson/meson_drv.c               | 14 +------------
 drivers/gpu/drm/mxsfb/mxsfb_drv.c               | 14 +------------
 drivers/gpu/drm/rcar-du/rcar_du_drv.c           | 12 +-----------
 drivers/gpu/drm/shmobile/shmob_drm_drv.c        | 12 +-----------
 drivers/gpu/drm/sti/sti_drv.c                   | 11 +----------
 drivers/gpu/drm/sun4i/sun4i_drv.c               | 12 +-----------
 drivers/gpu/drm/tilcdc/tilcdc_drv.c             | 12 +-----------
 drivers/gpu/drm/zte/zx_drm_drv.c                | 14 +------------
 include/drm/drm_gem_cma_helper.h                | 26 +++++++++++++++++++++++++
 17 files changed, 46 insertions(+), 158 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index 4840dc277339..0e74880b5e94 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -239,17 +239,7 @@ static int hdlcd_debugfs_init(struct drm_minor *minor)
 }
 #endif
 
-static const struct file_operations fops = {
-	.owner		= THIS_MODULE,
-	.open		= drm_open,
-	.release	= drm_release,
-	.unlocked_ioctl	= drm_ioctl,
-	.compat_ioctl	= drm_compat_ioctl,
-	.poll		= drm_poll,
-	.read		= drm_read,
-	.llseek		= noop_llseek,
-	.mmap		= drm_gem_cma_mmap,
-};
+DEFINE_DRM_GEM_CMA_FOPS(fops);
 
 static struct drm_driver hdlcd_driver = {
 	.driver_features = DRIVER_HAVE_IRQ | DRIVER_GEM |
diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index a9608a2e5a29..ea2546f766c2 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -178,17 +178,7 @@ static void malidp_lastclose(struct drm_device *drm)
 	drm_fbdev_cma_restore_mode(malidp->fbdev);
 }
 
-static const struct file_operations fops = {
-	.owner = THIS_MODULE,
-	.open = drm_open,
-	.release = drm_release,
-	.unlocked_ioctl = drm_ioctl,
-	.compat_ioctl = drm_compat_ioctl,
-	.poll = drm_poll,
-	.read = drm_read,
-	.llseek = noop_llseek,
-	.mmap = drm_gem_cma_mmap,
-};
+DEFINE_DRM_GEM_CMA_FOPS(fops);
 
 static struct drm_driver malidp_driver = {
 	.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC |
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 970bd87d7cce..178acbf5f6c5 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -724,17 +724,7 @@ static void atmel_hlcdc_dc_irq_uninstall(struct drm_device *dev)
 	regmap_read(dc->hlcdc->regmap, ATMEL_HLCDC_ISR, &isr);
 }
 
-static const struct file_operations fops = {
-	.owner              = THIS_MODULE,
-	.open               = drm_open,
-	.release            = drm_release,
-	.unlocked_ioctl     = drm_ioctl,
-	.compat_ioctl       = drm_compat_ioctl,
-	.poll               = drm_poll,
-	.read               = drm_read,
-	.llseek             = no_llseek,
-	.mmap               = drm_gem_cma_mmap,
-};
+DEFINE_DRM_GEM_CMA_FOPS(fops);
 
 static struct drm_driver atmel_hlcdc_dc_driver = {
 	.driver_features = DRIVER_HAVE_IRQ | DRIVER_GEM |
diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index f8483fc6d3d7..260a83563976 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -89,6 +89,9 @@ DEFINE_MUTEX(drm_global_mutex);
  *             .mmap = drm_gem_mmap,
  *     };
  *
+ * For CMA based drivers there is the DEFINE_DRM_GEM_CMA_FOPS() macro to make
+ * this simpler.
+ *
  * FIXME: We should have a macro for this (and the CMA version) so that drivers
  * don't have to repeat it all the time.
  */
diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
index bb968e76779b..bc28e7575254 100644
--- a/drivers/gpu/drm/drm_gem_cma_helper.c
+++ b/drivers/gpu/drm/drm_gem_cma_helper.c
@@ -338,6 +338,9 @@ static int drm_gem_cma_mmap_obj(struct drm_gem_cma_object *cma_obj,
  * as their ->mmap() handler in the DRM device file's file_operations
  * structure.
  *
+ * Instead of directly referencing this function, drivers should use the
+ * DEFINE_DRM_GEM_CMA_FOPS().macro.
+ *
  * Returns:
  * 0 on success or a negative error code on failure.
  */
diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
index b5391c124c64..6e00f4b267f1 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
@@ -161,17 +161,7 @@ static void fsl_dcu_drm_lastclose(struct drm_device *dev)
 	drm_fbdev_cma_restore_mode(fsl_dev->fbdev);
 }
 
-static const struct file_operations fsl_dcu_drm_fops = {
-	.owner		= THIS_MODULE,
-	.open		= drm_open,
-	.release	= drm_release,
-	.unlocked_ioctl	= drm_ioctl,
-	.compat_ioctl	= drm_compat_ioctl,
-	.poll		= drm_poll,
-	.read		= drm_read,
-	.llseek		= no_llseek,
-	.mmap		= drm_gem_cma_mmap,
-};
+DEFINE_DRM_GEM_CMA_FOPS(fsl_dcu_drm_fops);
 
 static struct drm_driver fsl_dcu_drm_driver = {
 	.driver_features	= DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET
diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
index 7ec93aec7e88..df4f50713e54 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
@@ -146,17 +146,7 @@ static int kirin_drm_kms_init(struct drm_device *dev)
 	return ret;
 }
 
-static const struct file_operations kirin_drm_fops = {
-	.owner		= THIS_MODULE,
-	.open		= drm_open,
-	.release	= drm_release,
-	.unlocked_ioctl	= drm_ioctl,
-	.compat_ioctl	= drm_compat_ioctl,
-	.poll		= drm_poll,
-	.read		= drm_read,
-	.llseek		= no_llseek,
-	.mmap		= drm_gem_cma_mmap,
-};
+DEFINE_DRM_GEM_CMA_FOPS(kirin_drm_fops);
 
 static int kirin_gem_cma_dumb_create(struct drm_file *file,
 				     struct drm_device *dev,
diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
index 4b7b92a7bcf7..70736615983c 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -57,16 +57,7 @@ static void imx_drm_driver_lastclose(struct drm_device *drm)
 	drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
 }
 
-static const struct file_operations imx_drm_driver_fops = {
-	.owner = THIS_MODULE,
-	.open = drm_open,
-	.release = drm_release,
-	.unlocked_ioctl = drm_ioctl,
-	.mmap = drm_gem_cma_mmap,
-	.poll = drm_poll,
-	.read = drm_read,
-	.llseek = noop_llseek,
-};
+DEFINE_DRM_GEM_CMA_FOPS(imx_drm_driver_fops);
 
 void imx_drm_connector_destroy(struct drm_connector *connector)
 {
diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
index 8d17d0e59cbe..bc562a07847b 100644
--- a/drivers/gpu/drm/meson/meson_drv.c
+++ b/drivers/gpu/drm/meson/meson_drv.c
@@ -91,19 +91,7 @@ static irqreturn_t meson_irq(int irq, void *arg)
 	return IRQ_HANDLED;
 }
 
-static const struct file_operations fops = {
-	.owner		= THIS_MODULE,
-	.open		= drm_open,
-	.release	= drm_release,
-	.unlocked_ioctl	= drm_ioctl,
-#ifdef CONFIG_COMPAT
-	.compat_ioctl	= drm_compat_ioctl,
-#endif
-	.poll		= drm_poll,
-	.read		= drm_read,
-	.llseek		= no_llseek,
-	.mmap		= drm_gem_cma_mmap,
-};
+DEFINE_DRM_GEM_CMA_FOPS(fops);
 
 static struct drm_driver meson_driver = {
 	.driver_features	= DRIVER_HAVE_IRQ | DRIVER_GEM |
diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index a4633ada8429..5ac712325c75 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -319,19 +319,7 @@ static irqreturn_t mxsfb_irq_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static const struct file_operations fops = {
-	.owner		= THIS_MODULE,
-	.open		= drm_open,
-	.release	= drm_release,
-	.unlocked_ioctl	= drm_ioctl,
-#ifdef CONFIG_COMPAT
-	.compat_ioctl	= drm_compat_ioctl,
-#endif
-	.poll		= drm_poll,
-	.read		= drm_read,
-	.llseek		= noop_llseek,
-	.mmap		= drm_gem_cma_mmap,
-};
+DEFINE_DRM_GEM_CMA_FOPS(fops);
 
 static struct drm_driver mxsfb_driver = {
 	.driver_features	= DRIVER_GEM | DRIVER_MODESET |
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 192346d4fb34..62a3b3e32153 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -226,17 +226,7 @@ static void rcar_du_lastclose(struct drm_device *dev)
 	drm_fbdev_cma_restore_mode(rcdu->fbdev);
 }
 
-static const struct file_operations rcar_du_fops = {
-	.owner		= THIS_MODULE,
-	.open		= drm_open,
-	.release	= drm_release,
-	.unlocked_ioctl	= drm_ioctl,
-	.compat_ioctl	= drm_compat_ioctl,
-	.poll		= drm_poll,
-	.read		= drm_read,
-	.llseek		= no_llseek,
-	.mmap		= drm_gem_cma_mmap,
-};
+DEFINE_DRM_GEM_CMA_FOPS(rcar_du_fops);
 
 static struct drm_driver rcar_du_driver = {
 	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index 34fefa0ba0f0..75f2e5e6d7fb 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -221,17 +221,7 @@ static irqreturn_t shmob_drm_irq(int irq, void *arg)
 	return IRQ_HANDLED;
 }
 
-static const struct file_operations shmob_drm_fops = {
-	.owner		= THIS_MODULE,
-	.open		= drm_open,
-	.release	= drm_release,
-	.unlocked_ioctl	= drm_ioctl,
-	.compat_ioctl	= drm_compat_ioctl,
-	.poll		= drm_poll,
-	.read		= drm_read,
-	.llseek		= no_llseek,
-	.mmap		= drm_gem_cma_mmap,
-};
+DEFINE_DRM_GEM_CMA_FOPS(shmob_drm_fops);
 
 static struct drm_driver shmob_drm_driver = {
 	.driver_features	= DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index 3b15c2cb2306..23da9bc4666a 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -167,16 +167,7 @@ static void sti_mode_config_init(struct drm_device *dev)
 	dev->mode_config.funcs = &sti_mode_config_funcs;
 }
 
-static const struct file_operations sti_driver_fops = {
-	.owner = THIS_MODULE,
-	.open = drm_open,
-	.mmap = drm_gem_cma_mmap,
-	.poll = drm_poll,
-	.read = drm_read,
-	.unlocked_ioctl = drm_ioctl,
-	.compat_ioctl = drm_compat_ioctl,
-	.release = drm_release,
-};
+DEFINE_DRM_GEM_CMA_FOPS(sti_driver_fops);
 
 static struct drm_driver sti_driver = {
 	.driver_features = DRIVER_MODESET |
diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
index 9ccf7c4deb6d..329ea56106a5 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -25,17 +25,7 @@
 #include "sun4i_framebuffer.h"
 #include "sun4i_layer.h"
 
-static const struct file_operations sun4i_drv_fops = {
-	.owner		= THIS_MODULE,
-	.open		= drm_open,
-	.release	= drm_release,
-	.unlocked_ioctl	= drm_ioctl,
-	.compat_ioctl	= drm_compat_ioctl,
-	.poll		= drm_poll,
-	.read		= drm_read,
-	.llseek		= no_llseek,
-	.mmap		= drm_gem_cma_mmap,
-};
+DEFINE_DRM_GEM_CMA_FOPS(sun4i_drv_fops);
 
 static struct drm_driver sun4i_drv_driver = {
 	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC,
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 81d80a2ffeb1..480411c2e802 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -530,17 +530,7 @@ static int tilcdc_debugfs_init(struct drm_minor *minor)
 }
 #endif
 
-static const struct file_operations fops = {
-	.owner              = THIS_MODULE,
-	.open               = drm_open,
-	.release            = drm_release,
-	.unlocked_ioctl     = drm_ioctl,
-	.compat_ioctl       = drm_compat_ioctl,
-	.poll               = drm_poll,
-	.read               = drm_read,
-	.llseek             = no_llseek,
-	.mmap               = drm_gem_cma_mmap,
-};
+DEFINE_DRM_GEM_CMA_FOPS(fops);
 
 static struct drm_driver tilcdc_driver = {
 	.driver_features    = (DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET |
diff --git a/drivers/gpu/drm/zte/zx_drm_drv.c b/drivers/gpu/drm/zte/zx_drm_drv.c
index b24a70ba4b83..614e854f6be5 100644
--- a/drivers/gpu/drm/zte/zx_drm_drv.c
+++ b/drivers/gpu/drm/zte/zx_drm_drv.c
@@ -53,19 +53,7 @@ static void zx_drm_lastclose(struct drm_device *drm)
 	drm_fbdev_cma_restore_mode(priv->fbdev);
 }
 
-static const struct file_operations zx_drm_fops = {
-	.owner = THIS_MODULE,
-	.open = drm_open,
-	.release = drm_release,
-	.unlocked_ioctl = drm_ioctl,
-#ifdef CONFIG_COMPAT
-	.compat_ioctl = drm_compat_ioctl,
-#endif
-	.poll = drm_poll,
-	.read = drm_read,
-	.llseek = noop_llseek,
-	.mmap = drm_gem_cma_mmap,
-};
+DEFINE_DRM_GEM_CMA_FOPS(zx_drm_fops);
 
 static struct drm_driver zx_drm_driver = {
 	.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
diff --git a/include/drm/drm_gem_cma_helper.h b/include/drm/drm_gem_cma_helper.h
index 2abcd5190cc1..f962d33667cf 100644
--- a/include/drm/drm_gem_cma_helper.h
+++ b/include/drm/drm_gem_cma_helper.h
@@ -26,6 +26,32 @@ to_drm_gem_cma_obj(struct drm_gem_object *gem_obj)
 	return container_of(gem_obj, struct drm_gem_cma_object, base);
 }
 
+/**
+ * DEFINE_DRM_GEM_CMA_FOPS() - macro to generate file operations for CMA drivers
+ * @name: name for the generated structure
+ *
+ * This macro autogenerates a suitable &struct file_operations for CMA based
+ * drivers, which can be assigned to &drm_driver.fops. Note that this structure
+ * cannot be shared between drivers, because it contains a reference to the
+ * current module using THIS_MODULE.
+ *
+ * Note that the declaration is already marked as static - if you need a
+ * non-static version of this you're probably doing it wrong and will break the
+ * THIS_MODULE reference by accident.
+ */
+#define DEFINE_DRM_GEM_CMA_FOPS(name) \
+	static const struct file_operations name = {\
+		.owner		= THIS_MODULE,\
+		.open		= drm_open,\
+		.release	= drm_release,\
+		.unlocked_ioctl	= drm_ioctl,\
+		.compat_ioctl	= drm_compat_ioctl,\
+		.poll		= drm_poll,\
+		.read		= drm_read,\
+		.llseek		= noop_llseek,\
+		.mmap		= drm_gem_cma_mmap,\
+	}
+
 /* free GEM object */
 void drm_gem_cma_free_object(struct drm_gem_object *gem_obj);
 
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 24/24] drm/gem: Add DEFINE_DRM_GEM_FOPS
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
                   ` (20 preceding siblings ...)
  2017-03-08 14:12 ` [PATCH 23/24] drm: Create DEFINE_DRM_GEM_CMA_FOPS and roll it out to drivers Daniel Vetter
@ 2017-03-08 14:12 ` Daniel Vetter
  2017-03-13 19:35   ` Sean Paul
  2017-03-08 17:52 ` ✓ Fi.CI.BAT: success for more docs and header splits Patchwork
  22 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 14:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Intel Graphics Development, Daniel Vetter

Sadly there's only 1 driver which can use it, everyone else is special
for some reason:

- gma500 has a horrible runtime PM ioctl wrapper that probably doesn't
  really work but meh.
- i915 needs special compat_ioctl handler because regrets.
- arcgpu needs to fixup the pgprot because (no idea why it can't do
  that in the fault handler like everyone else).
- tegra does even worse stuff with pgprot
- udl does something with vm_flags too ...
- cma helpers, etnaviv, mtk, msm, rockchip, omap all implement some
  variation on prefaulting.
- exynos is exynos, I got lost in the midlayers.
- vc4 has to reinvent half of cma helpers because those are too much
  midlayer, plus vm_flags dances.
- vgem also seems unhappy with the default vm_flags.

So pretty sad divergence and I'm sure we could do better, but not
really an idea. Oh well, maybe this macro here helps to encourage more
consistency at least going forward.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/armada/armada_drv.c | 11 +----------
 drivers/gpu/drm/drm_file.c          |  8 +++-----
 include/drm/drm_gem.h               | 26 ++++++++++++++++++++++++++
 3 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index 1952e8748fea..f986e9ff093d 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -60,16 +60,7 @@ static void armada_drm_lastclose(struct drm_device *dev)
 	armada_fbdev_lastclose(dev);
 }
 
-static const struct file_operations armada_drm_fops = {
-	.owner			= THIS_MODULE,
-	.llseek			= no_llseek,
-	.read			= drm_read,
-	.poll			= drm_poll,
-	.unlocked_ioctl		= drm_ioctl,
-	.mmap			= drm_gem_mmap,
-	.open			= drm_open,
-	.release		= drm_release,
-};
+DEFINE_DRM_GEM_FOPS(armada_drm_fops);
 
 static struct drm_driver armada_drm_driver = {
 	.lastclose		= armada_drm_lastclose,
diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index 260a83563976..0701362dcca1 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -89,11 +89,9 @@ DEFINE_MUTEX(drm_global_mutex);
  *             .mmap = drm_gem_mmap,
  *     };
  *
- * For CMA based drivers there is the DEFINE_DRM_GEM_CMA_FOPS() macro to make
- * this simpler.
- *
- * FIXME: We should have a macro for this (and the CMA version) so that drivers
- * don't have to repeat it all the time.
+ * For plain GEM based drivers there is the DEFINE_DRM_GEM_FOPS() macro, and for
+ * CMA based drivers there is the DEFINE_DRM_GEM_CMA_FOPS() macro to make this
+ * simpler.
  */
 
 static int drm_open_helper(struct file *filp, struct drm_minor *minor);
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
index b9ade75ecd82..663d80358057 100644
--- a/include/drm/drm_gem.h
+++ b/include/drm/drm_gem.h
@@ -178,6 +178,32 @@ struct drm_gem_object {
 	struct dma_buf_attachment *import_attach;
 };
 
+/**
+ * DEFINE_DRM_GEM_FOPS() - macro to generate file operations for GEM drivers
+ * @name: name for the generated structure
+ *
+ * This macro autogenerates a suitable &struct file_operations for GEM based
+ * drivers, which can be assigned to &drm_driver.fops. Note that this structure
+ * cannot be shared between drivers, because it contains a reference to the
+ * current module using THIS_MODULE.
+ *
+ * Note that the declaration is already marked as static - if you need a
+ * non-static version of this you're probably doing it wrong and will break the
+ * THIS_MODULE reference by accident.
+ */
+#define DEFINE_DRM_GEM_FOPS(name) \
+	static const struct file_operations name = {\
+		.owner		= THIS_MODULE,\
+		.open		= drm_open,\
+		.release	= drm_release,\
+		.unlocked_ioctl	= drm_ioctl,\
+		.compat_ioctl	= drm_compat_ioctl,\
+		.poll		= drm_poll,\
+		.read		= drm_read,\
+		.llseek		= noop_llseek,\
+		.mmap		= drm_gem_mmap,\
+	}
+
 void drm_gem_object_release(struct drm_gem_object *obj);
 void drm_gem_object_free(struct kref *kref);
 int drm_gem_object_init(struct drm_device *dev,
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 72+ messages in thread

* Re: [PATCH 08/24] drm: Remove DRM_MINOR_CNT
  2017-03-08 14:12 ` [PATCH 08/24] drm: Remove DRM_MINOR_CNT Daniel Vetter
@ 2017-03-08 14:14   ` David Herrmann
  2017-03-13 16:56   ` Sean Paul
  1 sibling, 0 replies; 72+ messages in thread
From: David Herrmann @ 2017-03-08 14:14 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

Hi

On Wed, Mar 8, 2017 at 3:12 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> This was originally added by David Herrmann for range checks, but
> entirely unused. It confused me, so let's remove it.
>
> Cc: David Herrmann <dh.herrmann@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  include/drm/drmP.h | 1 -
>  1 file changed, 1 deletion(-)

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>

Thanks
David

> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 826101785876..7bd6752683a4 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -444,7 +444,6 @@ enum drm_minor_type {
>         DRM_MINOR_PRIMARY,
>         DRM_MINOR_CONTROL,
>         DRM_MINOR_RENDER,
> -       DRM_MINOR_CNT,
>  };
>
>  /**
> --
> 2.11.0
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 15/24] drm/radeon: Merge pre/postclose hooks
       [not found]     ` <20170308141257.12119-16-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
@ 2017-03-08 14:25       ` Christian König
       [not found]         ` <79dc5480-6354-2379-8a7a-a2c099209256-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 72+ messages in thread
From: Christian König @ 2017-03-08 14:25 UTC (permalink / raw)
  To: Daniel Vetter, DRI Development
  Cc: Alex Deucher, Daniel Vetter, Intel Graphics Development,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Reviewed-by: Christian König <christian.koenig@amd.com> for this one and 
#19.

Christian.

Am 08.03.2017 um 15:12 schrieb Daniel Vetter:
> Again no apparent explanation for the split except hysterical raisins.
> Merging them also makes it a bit more obviuos what's going on wrt the
> runtime pm refdancing.
>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: amd-gfx@lists.freedesktop.org
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>   drivers/gpu/drm/radeon/radeon_drv.c |  3 ---
>   drivers/gpu/drm/radeon/radeon_kms.c | 42 +++++++++++++------------------------
>   2 files changed, 14 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
> index 956c425e639e..312436a8d9e5 100644
> --- a/drivers/gpu/drm/radeon/radeon_drv.c
> +++ b/drivers/gpu/drm/radeon/radeon_drv.c
> @@ -108,8 +108,6 @@ void radeon_driver_lastclose_kms(struct drm_device *dev);
>   int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv);
>   void radeon_driver_postclose_kms(struct drm_device *dev,
>   				 struct drm_file *file_priv);
> -void radeon_driver_preclose_kms(struct drm_device *dev,
> -				struct drm_file *file_priv);
>   int radeon_suspend_kms(struct drm_device *dev, bool suspend,
>   		       bool fbcon, bool freeze);
>   int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
> @@ -538,7 +536,6 @@ static struct drm_driver kms_driver = {
>   	    DRIVER_PRIME | DRIVER_RENDER,
>   	.load = radeon_driver_load_kms,
>   	.open = radeon_driver_open_kms,
> -	.preclose = radeon_driver_preclose_kms,
>   	.postclose = radeon_driver_postclose_kms,
>   	.lastclose = radeon_driver_lastclose_kms,
>   	.set_busid = drm_pci_set_busid,
> diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
> index 56f35c06742c..a32a62e03a44 100644
> --- a/drivers/gpu/drm/radeon/radeon_kms.c
> +++ b/drivers/gpu/drm/radeon/radeon_kms.c
> @@ -691,13 +691,26 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
>    * @dev: drm dev pointer
>    * @file_priv: drm file
>    *
> - * On device post close, tear down vm on cayman+ (all asics).
> + * On device close, tear down hyperz and cmask filps on r1xx-r5xx
> + * (all asics).  And tear down vm on cayman+ (all asics).
>    */
>   void radeon_driver_postclose_kms(struct drm_device *dev,
>   				 struct drm_file *file_priv)
>   {
>   	struct radeon_device *rdev = dev->dev_private;
>   
> +	pm_runtime_get_sync(dev->dev);
> +
> +	mutex_lock(&rdev->gem.mutex);
> +	if (rdev->hyperz_filp == file_priv)
> +		rdev->hyperz_filp = NULL;
> +	if (rdev->cmask_filp == file_priv)
> +		rdev->cmask_filp = NULL;
> +	mutex_unlock(&rdev->gem.mutex);
> +
> +	radeon_uvd_free_handles(rdev, file_priv);
> +	radeon_vce_free_handles(rdev, file_priv);
> +
>   	/* new gpu have virtual address space support */
>   	if (rdev->family >= CHIP_CAYMAN && file_priv->driver_priv) {
>   		struct radeon_fpriv *fpriv = file_priv->driver_priv;
> @@ -721,33 +734,6 @@ void radeon_driver_postclose_kms(struct drm_device *dev,
>   	pm_runtime_put_autosuspend(dev->dev);
>   }
>   
> -/**
> - * radeon_driver_preclose_kms - drm callback for pre close
> - *
> - * @dev: drm dev pointer
> - * @file_priv: drm file
> - *
> - * On device pre close, tear down hyperz and cmask filps on r1xx-r5xx
> - * (all asics).
> - */
> -void radeon_driver_preclose_kms(struct drm_device *dev,
> -				struct drm_file *file_priv)
> -{
> -	struct radeon_device *rdev = dev->dev_private;
> -
> -	pm_runtime_get_sync(dev->dev);
> -
> -	mutex_lock(&rdev->gem.mutex);
> -	if (rdev->hyperz_filp == file_priv)
> -		rdev->hyperz_filp = NULL;
> -	if (rdev->cmask_filp == file_priv)
> -		rdev->cmask_filp = NULL;
> -	mutex_unlock(&rdev->gem.mutex);
> -
> -	radeon_uvd_free_handles(rdev, file_priv);
> -	radeon_vce_free_handles(rdev, file_priv);
> -}
> -
>   /*
>    * VBlank related functions.
>    */


_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 02/24] drm: Extract drm_prime.h
  2017-03-08 14:12 ` [PATCH 02/24] drm: Extract drm_prime.h Daniel Vetter
@ 2017-03-08 14:57   ` Gustavo Padovan
  2017-03-13 16:42   ` Sean Paul
  1 sibling, 0 replies; 72+ messages in thread
From: Gustavo Padovan @ 2017-03-08 14:57 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

Hi Daniel,

2017-03-08 Daniel Vetter <daniel.vetter@ffwll.ch>:

> Plus a little bit more documentation.
> 
> v2: Untangle the missing forward decls to make drm_prime|gem.h
> free-standing.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  Documentation/gpu/drm-mm.rst  |  3 ++
>  drivers/gpu/drm/drm_prime.c   |  3 +-
>  include/drm/drmP.h            | 32 ++----------------
>  include/drm/drm_gem.h         |  4 +++
>  include/drm/drm_prime.h       | 79 +++++++++++++++++++++++++++++++++++++++++++
>  include/drm/drm_vma_manager.h |  1 -
>  6 files changed, 91 insertions(+), 31 deletions(-)
>  create mode 100644 include/drm/drm_prime.h

Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com>

Gustavo

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 06/24] drm/doc: document fallback behaviour for atomic events
  2017-03-08 14:12 ` [PATCH 06/24] drm/doc: document fallback behaviour for atomic events Daniel Vetter
@ 2017-03-08 14:57   ` Laurent Pinchart
  0 siblings, 0 replies; 72+ messages in thread
From: Laurent Pinchart @ 2017-03-08 14:57 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

Hi Daniel,

Thank you for the patch.

On Wednesday 08 Mar 2017 15:12:39 Daniel Vetter wrote:
> Worst case if the hw can't support completion signalling in a
> race-free way we want the event to be too late, not too early.
> 
> Text adapted from a proposal from Laurent - the other side of how to
> make hw work correctly where it's possible is imo already sufficiently
> documented.
> 
> v2: Review from Laurent.
> 
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  include/drm/drm_crtc.h | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index cba29ffedafd..6ef59da3fd8e 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -204,6 +204,12 @@ struct drm_crtc_state {
>  	 * drm_crtc_arm_vblank_event(). See the documentation of that function
>  	 * for a detailed discussion of the constraints it needs to be used
>  	 * safely.
> +	 *
> +	 * If the device can't notify of flip completion in a race-free way
> +	 * at all, then the event should be armed just after the page flip is
> +	 * committed. In the worst case the driver will send the event to
> +	 * userspace one frame too late. This doesn't allow for a real atomic
> +	 * update, but it should avoid tearing.
>  	 */
>  	struct drm_pending_vblank_event *event;

-- 
Regards,

Laurent Pinchart

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 03/24] drm: Move drm_lock_data out of drmP.h
  2017-03-08 14:12 ` [PATCH 03/24] drm: Move drm_lock_data out of drmP.h Daniel Vetter
@ 2017-03-08 14:58   ` Gustavo Padovan
  0 siblings, 0 replies; 72+ messages in thread
From: Gustavo Padovan @ 2017-03-08 14:58 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

2017-03-08 Daniel Vetter <daniel.vetter@ffwll.ch>:

> And remove the semi-kernel-doc stuff, to make sure no one uses this.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  include/drm/drmP.h     | 15 ---------------
>  include/drm/drm_auth.h | 17 +++++++++++++++++
>  2 files changed, 17 insertions(+), 15 deletions(-)

Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com>

Gustavo
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [Intel-gfx] [PATCH 04/24] drm: Extract drm_pci.h
  2017-03-08 14:12 ` [PATCH 04/24] drm: Extract drm_pci.h Daniel Vetter
@ 2017-03-08 14:59   ` Gustavo Padovan
  0 siblings, 0 replies; 72+ messages in thread
From: Gustavo Padovan @ 2017-03-08 14:59 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

2017-03-08 Daniel Vetter <daniel.vetter@ffwll.ch>:

> Just another step in finally making drmP.h obsolete.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/drm_pci.c |  7 +++++
>  include/drm/drmP.h        | 43 +++-----------------------
>  include/drm/drm_pci.h     | 78 +++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 89 insertions(+), 39 deletions(-)
>  create mode 100644 include/drm/drm_pci.h

Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com>

Gustavo
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [Intel-gfx] [PATCH 05/24] drm: Remove drmP.h include from drm_kms_helper_common.c
  2017-03-08 14:12 ` [PATCH 05/24] drm: Remove drmP.h include from drm_kms_helper_common.c Daniel Vetter
@ 2017-03-08 15:00   ` Gustavo Padovan
  0 siblings, 0 replies; 72+ messages in thread
From: Gustavo Padovan @ 2017-03-08 15:00 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

2017-03-08 Daniel Vetter <daniel.vetter@ffwll.ch>:

> An easy one as a drive-by.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/drm_kms_helper_common.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_kms_helper_common.c b/drivers/gpu/drm/drm_kms_helper_common.c
> index 45db36cd3d20..6e35a56a6102 100644
> --- a/drivers/gpu/drm/drm_kms_helper_common.c
> +++ b/drivers/gpu/drm/drm_kms_helper_common.c
> @@ -25,8 +25,7 @@
>   *
>   */
>  
> -#include <drm/drmP.h>
> -#include <drm/drm_fb_helper.h>
> +#include <linux/module.h>

Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com>

Gustavo

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [Intel-gfx] [PATCH 07/24] drm: rename drm_fops.c to drm_file.c
  2017-03-08 14:12 ` [PATCH 07/24] drm: rename drm_fops.c to drm_file.c Daniel Vetter
@ 2017-03-08 15:02   ` Gustavo Padovan
  0 siblings, 0 replies; 72+ messages in thread
From: Gustavo Padovan @ 2017-03-08 15:02 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

2017-03-08 Daniel Vetter <daniel.vetter@ffwll.ch>:

> It's not just file ops, but drm_file stuff in general. This is prep
> work to extracting a drm_file.h header in the next patch.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  Documentation/gpu/drm-internals.rst        | 4 ++--
>  drivers/gpu/drm/Makefile                   | 2 +-
>  drivers/gpu/drm/{drm_fops.c => drm_file.c} | 3 ---
>  drivers/gpu/drm/drm_internal.h             | 2 +-
>  include/drm/drmP.h                         | 2 +-
>  5 files changed, 5 insertions(+), 8 deletions(-)
>  rename drivers/gpu/drm/{drm_fops.c => drm_file.c} (99%)

Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com>

Gustavo

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 09/24] drm: Extract drm_file.h
  2017-03-08 14:12 ` [PATCH 09/24] drm: Extract drm_file.h Daniel Vetter
@ 2017-03-08 15:05   ` Gustavo Padovan
  2017-03-09 10:52     ` Daniel Vetter
  0 siblings, 1 reply; 72+ messages in thread
From: Gustavo Padovan @ 2017-03-08 15:05 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

2017-03-08 Daniel Vetter <daniel.vetter@ffwll.ch>:

> I'm torn on whether drm_minor really should be here or somewhere else.
> Maybe with more clarity after untangling drmP.h more this is easier to
> decide, for now I've put a FIXME comment right next to it. Right now
> we need struct drm_minor for the inline drm_file type helpers, and so
> it does kinda make sense to have them here.
> 
> Next patch will kerneldoc-ify the entire pile.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/drm_file.c |   5 +-
>  include/drm/drmP.h         | 127 +--------------------------------
>  include/drm/drm_file.h     | 172 +++++++++++++++++++++++++++++++++++++++++++++
>  include/drm/drm_prime.h    |   1 +
>  4 files changed, 178 insertions(+), 127 deletions(-)
>  create mode 100644 include/drm/drm_file.h

Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com>

Gustavo

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 12/24] drm/i915: Merge pre/postclose hooks
  2017-03-08 14:12 ` [PATCH 12/24] drm/i915: Merge pre/postclose hooks Daniel Vetter
@ 2017-03-08 15:07   ` Chris Wilson
  2017-03-08 15:45     ` Daniel Vetter
  0 siblings, 1 reply; 72+ messages in thread
From: Chris Wilson @ 2017-03-08 15:07 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

On Wed, Mar 08, 2017 at 03:12:45PM +0100, Daniel Vetter wrote:
> There's really not a reason afaics that we can't just clean up
> everything at the end, in the terminal postclose hook: Since this is
> closing a file descriptor we know no one else can have a reference or
> a thread doing something with that drm_file except the close code.
> Ordering shouldn't matter, as long as we don't kfree before we clean
> stuff up.

My gut feeling was that preclose is the one we want to keep, as that is
closer to the onion unwind - during open, we do the core drm ops first
(e.g. drm_gem_open) before the backend, so during close we should do the
driver before the core.

Maybe completely wrong ofc.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [Intel-gfx] [PATCH 01/24] drm/doc: Add todo about connector_list_iter
  2017-03-08 14:12 ` [PATCH 01/24] drm/doc: Add todo about connector_list_iter Daniel Vetter
@ 2017-03-08 15:12   ` Sean Paul
  0 siblings, 0 replies; 72+ messages in thread
From: Sean Paul @ 2017-03-08 15:12 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

On Wed, Mar 08, 2017 at 03:12:34PM +0100, Daniel Vetter wrote:
> At least radeon, amdgpu and nouveau should be converted. We have
> patches for i915 already.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  Documentation/gpu/todo.rst | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
> index ce0f1a588e7f..63c7088cace3 100644
> --- a/Documentation/gpu/todo.rst
> +++ b/Documentation/gpu/todo.rst
> @@ -153,6 +153,19 @@ following drivers still use ``struct_mutex``: ``msm``, ``omapdrm`` and
>  
>  Contact: Daniel Vetter
>  
> +Switch to drm_connector_list_iter for any connector_list walking
> +----------------------------------------------------------------
> +
> +Connectors can be hotplugged, and we now have a special list of helpers to walk
> +the connector_list in a race-free fashion, without incuring deadlocks on mutexes

s/incuring/incurring/

With that,

Reviewed-by: Sean Paul <seanpaul@chromium.org>

> +and other fun stuff.
> +
> +Unfortunately most drivers are not converted yet. At least all those supporting
> +DP MST hotplug should be converted, since for those drivers the difference
> +matters. See drm_for_each_connector_iter() vs. drm_for_each_connector().
> +
> +Contact: Daniel Vetter
> +
>  Core refactorings
>  =================
>  
> -- 
> 2.11.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 12/24] drm/i915: Merge pre/postclose hooks
  2017-03-08 15:07   ` Chris Wilson
@ 2017-03-08 15:45     ` Daniel Vetter
  2017-03-14 13:38       ` Daniel Vetter
  0 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 15:45 UTC (permalink / raw)
  To: Chris Wilson, Daniel Vetter, DRI Development,
	Intel Graphics Development, Daniel Vetter

On Wed, Mar 08, 2017 at 03:07:48PM +0000, Chris Wilson wrote:
> On Wed, Mar 08, 2017 at 03:12:45PM +0100, Daniel Vetter wrote:
> > There's really not a reason afaics that we can't just clean up
> > everything at the end, in the terminal postclose hook: Since this is
> > closing a file descriptor we know no one else can have a reference or
> > a thread doing something with that drm_file except the close code.
> > Ordering shouldn't matter, as long as we don't kfree before we clean
> > stuff up.
> 
> My gut feeling was that preclose is the one we want to keep, as that is
> closer to the onion unwind - during open, we do the core drm ops first
> (e.g. drm_gem_open) before the backend, so during close we should do the
> driver before the core.
> 
> Maybe completely wrong ofc.

I wasn't sure whether drivers might have some random pointers to fpriv
that they might chase when we tear down gem objects and stuff like that.
And if you look at what's before postclose, we still have onion
unwrapping: All the things before it (fb cleanup, gem cleanup, master
dropping) is stuff that userspace adds to the file _after_ it's fully
opened.

Well it's not entirely clear, because gem destroys the idr before
postclose, which might or might not trip up someone.

But afaik all the other destructive cleanup is done after postclose.

So maybe that's the split we want in drm_close?

- First release all runtime resources acquired after ->open. Not
  destructive cleanup, fpriv should keep working like right after ->open
  has returned. These functions would all have _release in their names.
- call the driver's ->postclose.
- All the destructive cleanup. Those functions would all have _destroy in
  their names.

Since there's not really a real issue right now I'd prefer if we postpone
this cleanup though, and first get all the driver patches merged. Just in
case I missed something ...

I kinda want to do an s/postclose/close/ using cocci anyway, so this isn't
the last series on this topic.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 18/24] drm/etnaviv: switch to postclose
  2017-03-08 14:12 ` [PATCH 18/24] drm/etnaviv: " Daniel Vetter
@ 2017-03-08 16:09   ` Lucas Stach
  2017-03-08 18:15     ` Daniel Vetter
  0 siblings, 1 reply; 72+ messages in thread
From: Lucas Stach @ 2017-03-08 16:09 UTC (permalink / raw)
  To: Daniel Vetter, DRI Development
  Cc: Daniel Vetter, Intel Graphics Development, etnaviv, Russell King

Am Mittwoch, den 08.03.2017, 15:12 +0100 schrieb Daniel Vetter:
> I didn't spot anything that would require ordering here (well not
> anywhere else either), and I'm trying to unify at least modern
> drivers
> on one close hook.
> 
> Cc: Lucas Stach <l.stach@pengutronix.de>
> Cc: Russell King <linux+etnaviv@armlinux.org.uk>
> Cc: Christian Gmeiner <christian.gmeiner@gmail.com>
> Cc: etnaviv@lists.freedesktop.org
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

Acked-by: Lucas Stach <l.stach@pengutronix.de>

for merging through drm-misc

> ---
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> index 587e45043542..289a9f8c6671 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> @@ -111,7 +111,7 @@ static int etnaviv_open(struct drm_device *dev,
> struct drm_file *file)
>  	return 0;
>  }
>  
> -static void etnaviv_preclose(struct drm_device *dev, struct drm_file
> *file)
> +static void etnaviv_postclose(struct drm_device *dev, struct
> drm_file *file)
>  {
>  	struct etnaviv_drm_private *priv = dev->dev_private;
>  	struct etnaviv_file_private *ctx = file->driver_priv;
> @@ -488,7 +488,7 @@ static struct drm_driver etnaviv_drm_driver = {
>  				DRIVER_PRIME |
>  				DRIVER_RENDER,
>  	.open               = etnaviv_open,
> -	.preclose           = etnaviv_preclose,
> +	.postclose           = etnaviv_postclose,
>  	.gem_free_object_unlocked = etnaviv_gem_free_object,
>  	.gem_vm_ops         = &vm_ops,
>  	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* ✓ Fi.CI.BAT: success for more docs and header splits
  2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
                   ` (21 preceding siblings ...)
  2017-03-08 14:12 ` [PATCH 24/24] drm/gem: Add DEFINE_DRM_GEM_FOPS Daniel Vetter
@ 2017-03-08 17:52 ` Patchwork
  22 siblings, 0 replies; 72+ messages in thread
From: Patchwork @ 2017-03-08 17:52 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: intel-gfx

== Series Details ==

Series: more docs and header splits
URL   : https://patchwork.freedesktop.org/series/20908/
State : success

== Summary ==

Series 20908v1 more docs and header splits
https://patchwork.freedesktop.org/api/1.0/series/20908/revisions/1/mbox/

Test gem_exec_flush:
        Subgroup basic-batch-kernel-default-uc:
                fail       -> PASS       (fi-snb-2600) fdo#100007
Test gem_exec_suspend:
        Subgroup basic-s3:
                fail       -> PASS       (fi-kbl-7500u)
        Subgroup basic-s4-devices:
                fail       -> DMESG-WARN (fi-kbl-7500u) fdo#100099
                dmesg-warn -> PASS       (fi-bxt-t5700)
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-a:
                fail       -> PASS       (fi-kbl-7500u)
        Subgroup suspend-read-crc-pipe-b:
                fail       -> PASS       (fi-kbl-7500u)
        Subgroup suspend-read-crc-pipe-c:
                fail       -> PASS       (fi-kbl-7500u) fdo#100044

fdo#100007 https://bugs.freedesktop.org/show_bug.cgi?id=100007
fdo#100099 https://bugs.freedesktop.org/show_bug.cgi?id=100099
fdo#100044 https://bugs.freedesktop.org/show_bug.cgi?id=100044

fi-bdw-5557u     total:278  pass:267  dwarn:0   dfail:0   fail:0   skip:11  time: 462s
fi-bsw-n3050     total:278  pass:239  dwarn:0   dfail:0   fail:0   skip:39  time: 602s
fi-bxt-j4205     total:278  pass:259  dwarn:0   dfail:0   fail:0   skip:19  time: 533s
fi-bxt-t5700     total:278  pass:258  dwarn:0   dfail:0   fail:0   skip:20  time: 627s
fi-byt-j1900     total:278  pass:251  dwarn:0   dfail:0   fail:0   skip:27  time: 505s
fi-byt-n2820     total:278  pass:247  dwarn:0   dfail:0   fail:0   skip:31  time: 499s
fi-hsw-4770      total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time: 440s
fi-hsw-4770r     total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time: 442s
fi-ilk-650       total:278  pass:228  dwarn:0   dfail:0   fail:0   skip:50  time: 434s
fi-ivb-3520m     total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time: 502s
fi-ivb-3770      total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time: 496s
fi-kbl-7500u     total:278  pass:259  dwarn:1   dfail:0   fail:0   skip:18  time: 483s
fi-skl-6260u     total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time: 506s
fi-skl-6700hq    total:278  pass:261  dwarn:0   dfail:0   fail:0   skip:17  time: 602s
fi-skl-6700k     total:278  pass:256  dwarn:4   dfail:0   fail:0   skip:18  time: 506s
fi-skl-6770hq    total:53   pass:51   dwarn:0   dfail:0   fail:0   skip:1   time: 0s
fi-snb-2520m     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time: 553s
fi-snb-2600      total:278  pass:249  dwarn:0   dfail:0   fail:0   skip:29  time: 421s

6f8585956c95605b9c797ffde8f65e408b8d1e33 drm-tip: 2017y-03m-08d-14h-47m-28s UTC integration manifest
71324c3 drm/gem: Add DEFINE_DRM_GEM_FOPS
a69202f drm: Create DEFINE_DRM_GEM_CMA_FOPS and roll it out to drivers
96dc78e drm: Nerf the preclose callback for modern drivers
9a58191 drm/msm: Simplify vblank event delivery
0f2e4ac drm/exynos: Merge pre/postclose hooks
8e06a61 drm/amdgpu: Merge pre/postclose hooks
f277496 drm/etnaviv: switch to postclose
eb71ae3 drm/vgem: switch to postclose
701a968 drm/tegra: switch to postclose
733a999 drm/radeon: Merge pre/postclose hooks
7a0b24c drm/nouveau: Merge pre/postclose hooks
8899467 drm/msm: switch to postclose
5f98570 drm/i915: Merge pre/postclose hooks
ffb01ca drm/doc: Document drm_file.[hc]
e0f0db2 drm: Remove drm_pending_event->pid
879e0ff drm: Extract drm_file.h
55beaf7 drm: Remove DRM_MINOR_CNT
9e6ef96 drm: rename drm_fops.c to drm_file.c
e023e3d drm/doc: document fallback behaviour for atomic events
05568e4 drm: Remove drmP.h include from drm_kms_helper_common.c
08c3e16 drm: Extract drm_pci.h
310f18d drm: Move drm_lock_data out of drmP.h
4363844 drm: Extract drm_prime.h
d6625e3 drm/doc: Add todo about connector_list_iter

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4099/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 18/24] drm/etnaviv: switch to postclose
  2017-03-08 16:09   ` Lucas Stach
@ 2017-03-08 18:15     ` Daniel Vetter
  2017-03-09 10:03       ` Lucas Stach
  0 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-08 18:15 UTC (permalink / raw)
  To: Lucas Stach
  Cc: Daniel Vetter, Intel Graphics Development, etnaviv,
	DRI Development, Russell King, Daniel Vetter

On Wed, Mar 08, 2017 at 05:09:45PM +0100, Lucas Stach wrote:
> Am Mittwoch, den 08.03.2017, 15:12 +0100 schrieb Daniel Vetter:
> > I didn't spot anything that would require ordering here (well not
> > anywhere else either), and I'm trying to unify at least modern
> > drivers
> > on one close hook.
> > 
> > Cc: Lucas Stach <l.stach@pengutronix.de>
> > Cc: Russell King <linux+etnaviv@armlinux.org.uk>
> > Cc: Christian Gmeiner <christian.gmeiner@gmail.com>
> > Cc: etnaviv@lists.freedesktop.org
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> 
> Acked-by: Lucas Stach <l.stach@pengutronix.de>
> 
> for merging through drm-misc

t-b would be great, this entire area is rather wonky and full of decades
of cargo-culting. I'm not sure I missed something important, so really
want each patch to see some testing before we merge it, if possible.
-Daniel

> 
> > ---
> >  drivers/gpu/drm/etnaviv/etnaviv_drv.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> > b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> > index 587e45043542..289a9f8c6671 100644
> > --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> > +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> > @@ -111,7 +111,7 @@ static int etnaviv_open(struct drm_device *dev,
> > struct drm_file *file)
> >  	return 0;
> >  }
> >  
> > -static void etnaviv_preclose(struct drm_device *dev, struct drm_file
> > *file)
> > +static void etnaviv_postclose(struct drm_device *dev, struct
> > drm_file *file)
> >  {
> >  	struct etnaviv_drm_private *priv = dev->dev_private;
> >  	struct etnaviv_file_private *ctx = file->driver_priv;
> > @@ -488,7 +488,7 @@ static struct drm_driver etnaviv_drm_driver = {
> >  				DRIVER_PRIME |
> >  				DRIVER_RENDER,
> >  	.open               = etnaviv_open,
> > -	.preclose           = etnaviv_preclose,
> > +	.postclose           = etnaviv_postclose,
> >  	.gem_free_object_unlocked = etnaviv_gem_free_object,
> >  	.gem_vm_ops         = &vm_ops,
> >  	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 15/24] drm/radeon: Merge pre/postclose hooks
       [not found]         ` <79dc5480-6354-2379-8a7a-a2c099209256-5C7GfCeVMHo@public.gmane.org>
@ 2017-03-09  3:58           ` Alex Deucher
  0 siblings, 0 replies; 72+ messages in thread
From: Alex Deucher @ 2017-03-09  3:58 UTC (permalink / raw)
  To: Christian König
  Cc: Daniel Vetter, Intel Graphics Development, amd-gfx list,
	DRI Development, Alex Deucher, Daniel Vetter

On Wed, Mar 8, 2017 at 9:25 AM, Christian König
<christian.koenig@amd.com> wrote:
> Reviewed-by: Christian König <christian.koenig@amd.com> for this one and
> #19.

Applied both.

Thanks!

Alex

>
> Christian.
>
>
> Am 08.03.2017 um 15:12 schrieb Daniel Vetter:
>>
>> Again no apparent explanation for the split except hysterical raisins.
>> Merging them also makes it a bit more obviuos what's going on wrt the
>> runtime pm refdancing.
>>
>> Cc: Alex Deucher <alexander.deucher@amd.com>
>> Cc: Christian König <christian.koenig@amd.com>
>> Cc: amd-gfx@lists.freedesktop.org
>> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
>> ---
>>   drivers/gpu/drm/radeon/radeon_drv.c |  3 ---
>>   drivers/gpu/drm/radeon/radeon_kms.c | 42
>> +++++++++++++------------------------
>>   2 files changed, 14 insertions(+), 31 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/radeon/radeon_drv.c
>> b/drivers/gpu/drm/radeon/radeon_drv.c
>> index 956c425e639e..312436a8d9e5 100644
>> --- a/drivers/gpu/drm/radeon/radeon_drv.c
>> +++ b/drivers/gpu/drm/radeon/radeon_drv.c
>> @@ -108,8 +108,6 @@ void radeon_driver_lastclose_kms(struct drm_device
>> *dev);
>>   int radeon_driver_open_kms(struct drm_device *dev, struct drm_file
>> *file_priv);
>>   void radeon_driver_postclose_kms(struct drm_device *dev,
>>                                  struct drm_file *file_priv);
>> -void radeon_driver_preclose_kms(struct drm_device *dev,
>> -                               struct drm_file *file_priv);
>>   int radeon_suspend_kms(struct drm_device *dev, bool suspend,
>>                        bool fbcon, bool freeze);
>>   int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
>> @@ -538,7 +536,6 @@ static struct drm_driver kms_driver = {
>>             DRIVER_PRIME | DRIVER_RENDER,
>>         .load = radeon_driver_load_kms,
>>         .open = radeon_driver_open_kms,
>> -       .preclose = radeon_driver_preclose_kms,
>>         .postclose = radeon_driver_postclose_kms,
>>         .lastclose = radeon_driver_lastclose_kms,
>>         .set_busid = drm_pci_set_busid,
>> diff --git a/drivers/gpu/drm/radeon/radeon_kms.c
>> b/drivers/gpu/drm/radeon/radeon_kms.c
>> index 56f35c06742c..a32a62e03a44 100644
>> --- a/drivers/gpu/drm/radeon/radeon_kms.c
>> +++ b/drivers/gpu/drm/radeon/radeon_kms.c
>> @@ -691,13 +691,26 @@ int radeon_driver_open_kms(struct drm_device *dev,
>> struct drm_file *file_priv)
>>    * @dev: drm dev pointer
>>    * @file_priv: drm file
>>    *
>> - * On device post close, tear down vm on cayman+ (all asics).
>> + * On device close, tear down hyperz and cmask filps on r1xx-r5xx
>> + * (all asics).  And tear down vm on cayman+ (all asics).
>>    */
>>   void radeon_driver_postclose_kms(struct drm_device *dev,
>>                                  struct drm_file *file_priv)
>>   {
>>         struct radeon_device *rdev = dev->dev_private;
>>   +     pm_runtime_get_sync(dev->dev);
>> +
>> +       mutex_lock(&rdev->gem.mutex);
>> +       if (rdev->hyperz_filp == file_priv)
>> +               rdev->hyperz_filp = NULL;
>> +       if (rdev->cmask_filp == file_priv)
>> +               rdev->cmask_filp = NULL;
>> +       mutex_unlock(&rdev->gem.mutex);
>> +
>> +       radeon_uvd_free_handles(rdev, file_priv);
>> +       radeon_vce_free_handles(rdev, file_priv);
>> +
>>         /* new gpu have virtual address space support */
>>         if (rdev->family >= CHIP_CAYMAN && file_priv->driver_priv) {
>>                 struct radeon_fpriv *fpriv = file_priv->driver_priv;
>> @@ -721,33 +734,6 @@ void radeon_driver_postclose_kms(struct drm_device
>> *dev,
>>         pm_runtime_put_autosuspend(dev->dev);
>>   }
>>   -/**
>> - * radeon_driver_preclose_kms - drm callback for pre close
>> - *
>> - * @dev: drm dev pointer
>> - * @file_priv: drm file
>> - *
>> - * On device pre close, tear down hyperz and cmask filps on r1xx-r5xx
>> - * (all asics).
>> - */
>> -void radeon_driver_preclose_kms(struct drm_device *dev,
>> -                               struct drm_file *file_priv)
>> -{
>> -       struct radeon_device *rdev = dev->dev_private;
>> -
>> -       pm_runtime_get_sync(dev->dev);
>> -
>> -       mutex_lock(&rdev->gem.mutex);
>> -       if (rdev->hyperz_filp == file_priv)
>> -               rdev->hyperz_filp = NULL;
>> -       if (rdev->cmask_filp == file_priv)
>> -               rdev->cmask_filp = NULL;
>> -       mutex_unlock(&rdev->gem.mutex);
>> -
>> -       radeon_uvd_free_handles(rdev, file_priv);
>> -       radeon_vce_free_handles(rdev, file_priv);
>> -}
>> -
>>   /*
>>    * VBlank related functions.
>>    */
>
>
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 18/24] drm/etnaviv: switch to postclose
  2017-03-08 18:15     ` Daniel Vetter
@ 2017-03-09 10:03       ` Lucas Stach
  0 siblings, 0 replies; 72+ messages in thread
From: Lucas Stach @ 2017-03-09 10:03 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, etnaviv,
	DRI Development, Russell King, Daniel Vetter

Am Mittwoch, den 08.03.2017, 19:15 +0100 schrieb Daniel Vetter:
> On Wed, Mar 08, 2017 at 05:09:45PM +0100, Lucas Stach wrote:
> > Am Mittwoch, den 08.03.2017, 15:12 +0100 schrieb Daniel Vetter:
> > > I didn't spot anything that would require ordering here (well not
> > > anywhere else either), and I'm trying to unify at least modern
> > > drivers
> > > on one close hook.
> > > 
> > > Cc: Lucas Stach <l.stach@pengutronix.de>
> > > Cc: Russell King <linux+etnaviv@armlinux.org.uk>
> > > Cc: Christian Gmeiner <christian.gmeiner@gmail.com>
> > > Cc: etnaviv@lists.freedesktop.org
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > 
> > Acked-by: Lucas Stach <l.stach@pengutronix.de>
> > 
> > for merging through drm-misc
> 
> t-b would be great, this entire area is rather wonky and full of decades
> of cargo-culting. I'm not sure I missed something important, so really
> want each patch to see some testing before we merge it, if possible.
> -Daniel

In that case I'll just merge it through my tree, so it gets our usual
internal testing.

Now applied.

Regards,
Lucas
> 
> > 
> > > ---
> > >  drivers/gpu/drm/etnaviv/etnaviv_drv.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> > > b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> > > index 587e45043542..289a9f8c6671 100644
> > > --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> > > +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> > > @@ -111,7 +111,7 @@ static int etnaviv_open(struct drm_device *dev,
> > > struct drm_file *file)
> > >  	return 0;
> > >  }
> > >  
> > > -static void etnaviv_preclose(struct drm_device *dev, struct drm_file
> > > *file)
> > > +static void etnaviv_postclose(struct drm_device *dev, struct
> > > drm_file *file)
> > >  {
> > >  	struct etnaviv_drm_private *priv = dev->dev_private;
> > >  	struct etnaviv_file_private *ctx = file->driver_priv;
> > > @@ -488,7 +488,7 @@ static struct drm_driver etnaviv_drm_driver = {
> > >  				DRIVER_PRIME |
> > >  				DRIVER_RENDER,
> > >  	.open               = etnaviv_open,
> > > -	.preclose           = etnaviv_preclose,
> > > +	.postclose           = etnaviv_postclose,
> > >  	.gem_free_object_unlocked = etnaviv_gem_free_object,
> > >  	.gem_vm_ops         = &vm_ops,
> > >  	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
> 


_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 22/24] drm: Nerf the preclose callback for modern drivers
  2017-03-08 14:12 ` [PATCH 22/24] drm: Nerf the preclose callback for modern drivers Daniel Vetter
@ 2017-03-09 10:48   ` Daniel Vetter
  2017-03-13 19:29   ` [Intel-gfx] " Sean Paul
  1 sibling, 0 replies; 72+ messages in thread
From: Daniel Vetter @ 2017-03-09 10:48 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Intel Graphics Development, Daniel Vetter

On Wed, Mar 08, 2017 at 03:12:55PM +0100, Daniel Vetter wrote:
> With all drivers converted there's only legacy dri1 drivers using it.
> Not going to touch those, instead just hide it like we've done with
> other dri1 driver hooks like firstopen.
> 
> In all this I didn't find any real reason why we'd needed 2 hooks, and
> having symmetry between open and close just appeases my OCD better.
> Yeah, someone else could do an s/postclose/close/, but that's for
> someone who understands cocci. And maybe after this series is reviewed
> and landed, to avoid patch-regen churn.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

From irc:

Acked-by: Dave Airlie <airlied@gmail.com>
> ---
>  drivers/gpu/drm/drm_file.c |  8 ++++----
>  include/drm/drm_drv.h      | 23 ++---------------------
>  2 files changed, 6 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> index a8813a1115dc..f8483fc6d3d7 100644
> --- a/drivers/gpu/drm/drm_file.c
> +++ b/drivers/gpu/drm/drm_file.c
> @@ -350,9 +350,8 @@ void drm_lastclose(struct drm_device * dev)
>   *
>   * This function must be used by drivers as their &file_operations.release
>   * method. It frees any resources associated with the open file, and calls the
> - * &drm_driver.preclose and &drm_driver.lastclose driver callbacks. If this is
> - * the last open file for the DRM device also proceeds to call the
> - * &drm_driver.lastclose driver callback.
> + * &drm_driver.lastclose driver callback. If this is the last open file for the
> + * DRM device also proceeds to call the &drm_driver.lastclose driver callback.
>   *
>   * RETURNS:
>   *
> @@ -372,7 +371,8 @@ int drm_release(struct inode *inode, struct file *filp)
>  	list_del(&file_priv->lhead);
>  	mutex_unlock(&dev->filelist_mutex);
>  
> -	if (dev->driver->preclose)
> +	if (drm_core_check_feature(dev, DRIVER_LEGACY) &&
> +	    dev->driver->preclose)
>  		dev->driver->preclose(dev, file_priv);
>  
>  	/* ========================================================
> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> index 8f900fb30275..fde343e0d581 100644
> --- a/include/drm/drm_drv.h
> +++ b/include/drm/drm_drv.h
> @@ -104,23 +104,6 @@ struct drm_driver {
>  	int (*open) (struct drm_device *, struct drm_file *);
>  
>  	/**
> -	 * @preclose:
> -	 *
> -	 * One of the driver callbacks when a new &struct drm_file is closed.
> -	 * Useful for tearing down driver-private data structures allocated in
> -	 * @open like buffer allocators, execution contexts or similar things.
> -	 *
> -	 * Since the display/modeset side of DRM can only be owned by exactly
> -	 * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
> -	 * there should never be a need to tear down any modeset related
> -	 * resources in this callback. Doing so would be a driver design bug.
> -	 *
> -	 * FIXME: It is not really clear why there's both @preclose and
> -	 * @postclose. Without a really good reason, use @postclose only.
> -	 */
> -	void (*preclose) (struct drm_device *, struct drm_file *file_priv);
> -
> -	/**
>  	 * @postclose:
>  	 *
>  	 * One of the driver callbacks when a new &struct drm_file is closed.
> @@ -131,9 +114,6 @@ struct drm_driver {
>  	 * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
>  	 * there should never be a need to tear down any modeset related
>  	 * resources in this callback. Doing so would be a driver design bug.
> -	 *
> -	 * FIXME: It is not really clear why there's both @preclose and
> -	 * @postclose. Without a really good reason, use @postclose only.
>  	 */
>  	void (*postclose) (struct drm_device *, struct drm_file *);
>  
> @@ -150,7 +130,7 @@ struct drm_driver {
>  	 * state changes, e.g. in conjunction with the :ref:`vga_switcheroo`
>  	 * infrastructure.
>  	 *
> -	 * This is called after @preclose and @postclose have been called.
> +	 * This is called after @postclose hook has been called.
>  	 *
>  	 * NOTE:
>  	 *
> @@ -516,6 +496,7 @@ struct drm_driver {
>  	/* List of devices hanging off this driver with stealth attach. */
>  	struct list_head legacy_dev_list;
>  	int (*firstopen) (struct drm_device *);
> +	void (*preclose) (struct drm_device *, struct drm_file *file_priv);
>  	int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
>  	int (*dma_quiescent) (struct drm_device *);
>  	int (*context_dtor) (struct drm_device *dev, int context);
> -- 
> 2.11.0
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 09/24] drm: Extract drm_file.h
  2017-03-08 15:05   ` Gustavo Padovan
@ 2017-03-09 10:52     ` Daniel Vetter
  0 siblings, 0 replies; 72+ messages in thread
From: Daniel Vetter @ 2017-03-09 10:52 UTC (permalink / raw)
  To: Gustavo Padovan, Daniel Vetter, DRI Development,
	Intel Graphics Development, Daniel Vetter

On Wed, Mar 08, 2017 at 12:05:50PM -0300, Gustavo Padovan wrote:
> 2017-03-08 Daniel Vetter <daniel.vetter@ffwll.ch>:
> 
> > I'm torn on whether drm_minor really should be here or somewhere else.
> > Maybe with more clarity after untangling drmP.h more this is easier to
> > decide, for now I've put a FIXME comment right next to it. Right now
> > we need struct drm_minor for the inline drm_file type helpers, and so
> > it does kinda make sense to have them here.
> > 
> > Next patch will kerneldoc-ify the entire pile.
> > 
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > ---
> >  drivers/gpu/drm/drm_file.c |   5 +-
> >  include/drm/drmP.h         | 127 +--------------------------------
> >  include/drm/drm_file.h     | 172 +++++++++++++++++++++++++++++++++++++++++++++
> >  include/drm/drm_prime.h    |   1 +
> >  4 files changed, 178 insertions(+), 127 deletions(-)
> >  create mode 100644 include/drm/drm_file.h
> 
> Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com>

Merged up to this patch, thanks a lot to everyone for the reviews.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 02/24] drm: Extract drm_prime.h
  2017-03-08 14:12 ` [PATCH 02/24] drm: Extract drm_prime.h Daniel Vetter
  2017-03-08 14:57   ` Gustavo Padovan
@ 2017-03-13 16:42   ` Sean Paul
  2017-03-14  9:12     ` [Intel-gfx] " Daniel Vetter
  1 sibling, 1 reply; 72+ messages in thread
From: Sean Paul @ 2017-03-13 16:42 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

On Wed, Mar 08, 2017 at 03:12:35PM +0100, Daniel Vetter wrote:
> Plus a little bit more documentation.
> 
> v2: Untangle the missing forward decls to make drm_prime|gem.h
> free-standing.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  Documentation/gpu/drm-mm.rst  |  3 ++
>  drivers/gpu/drm/drm_prime.c   |  3 +-
>  include/drm/drmP.h            | 32 ++----------------
>  include/drm/drm_gem.h         |  4 +++
>  include/drm/drm_prime.h       | 79 +++++++++++++++++++++++++++++++++++++++++++
>  include/drm/drm_vma_manager.h |  1 -
>  6 files changed, 91 insertions(+), 31 deletions(-)
>  create mode 100644 include/drm/drm_prime.h
> 
> diff --git a/Documentation/gpu/drm-mm.rst b/Documentation/gpu/drm-mm.rst
> index d47cbe3a9ef3..96b9c34c21e4 100644
> --- a/Documentation/gpu/drm-mm.rst
> +++ b/Documentation/gpu/drm-mm.rst
> @@ -449,6 +449,9 @@ PRIME Helper Functions
>  PRIME Function References
>  -------------------------
>  
> +.. kernel-doc:: include/drm/drm_prime.h
> +   :internal:
> +
>  .. kernel-doc:: drivers/gpu/drm/drm_prime.c
>     :export:
>  
> diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
> index 866b294e7c61..9fb65b736a90 100644
> --- a/drivers/gpu/drm/drm_prime.c
> +++ b/drivers/gpu/drm/drm_prime.c
> @@ -29,8 +29,9 @@
>  #include <linux/export.h>
>  #include <linux/dma-buf.h>
>  #include <linux/rbtree.h>
> -#include <drm/drmP.h>
> +#include <drm/drm_prime.h>
>  #include <drm/drm_gem.h>
> +#include <drm/drmP.h>
>  
>  #include "drm_internal.h"
>  
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 6105c050d7bc..5f829d2372da 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -51,13 +51,13 @@
>  #include <linux/platform_device.h>
>  #include <linux/poll.h>
>  #include <linux/ratelimit.h>
> -#include <linux/rbtree.h>
>  #include <linux/sched.h>
>  #include <linux/slab.h>
>  #include <linux/types.h>
>  #include <linux/vmalloc.h>
>  #include <linux/workqueue.h>
>  #include <linux/dma-fence.h>
> +#include <linux/module.h>
>  
>  #include <asm/mman.h>
>  #include <asm/pgalloc.h>
> @@ -75,8 +75,8 @@
>  #include <drm/drm_mm.h>
>  #include <drm/drm_os_linux.h>
>  #include <drm/drm_sarea.h>
> -#include <drm/drm_vma_manager.h>
>  #include <drm/drm_drv.h>
> +#include <drm/drm_prime.h>
>  
>  struct module;
>  
> @@ -89,6 +89,7 @@ struct drm_dma_handle;
>  struct drm_gem_object;
>  struct drm_master;
>  struct drm_vblank_crtc;
> +struct drm_vma_offset_manager;
>  
>  struct device_node;
>  struct videomode;
> @@ -370,12 +371,6 @@ struct drm_pending_event {
>  		      we deliver the event, for tracing only */
>  };
>  
> -struct drm_prime_file_private {
> -	struct mutex lock;
> -	struct rb_root dmabufs;
> -	struct rb_root handles;
> -};
> -
>  /** File private data */
>  struct drm_file {
>  	unsigned authenticated :1;
> @@ -759,27 +754,6 @@ static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
>  }
>  #endif
>  
> -struct dma_buf_export_info;
> -
> -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_dmabuf_export(struct drm_device *dev,
> -				      struct dma_buf_export_info *exp_info);
> -extern 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);
> -
>  
>  extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size,
>  					    size_t align);
> diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
> index 3b2a28f7f49f..b9ade75ecd82 100644
> --- a/include/drm/drm_gem.h
> +++ b/include/drm/drm_gem.h
> @@ -34,6 +34,10 @@
>   * OTHER DEALINGS IN THE SOFTWARE.
>   */
>  
> +#include <linux/kref.h>
> +
> +#include <drm/drm_vma_manager.h>
> +
>  /**
>   * struct drm_gem_object - GEM buffer object
>   *
> diff --git a/include/drm/drm_prime.h b/include/drm/drm_prime.h
> new file mode 100644
> index 000000000000..77ceca711bad
> --- /dev/null
> +++ b/include/drm/drm_prime.h
> @@ -0,0 +1,79 @@
> +/*
> + * Copyright © 2012 Red Hat
> + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
> + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
> + * Copyright (c) 2009-2010, Code Aurora Forum.
> + *
> + * 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
> + * THE AUTHORS OR COPYRIGHT HOLDERS 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.
> + *
> + * Authors:
> + *      Dave Airlie <airlied@redhat.com>
> + *      Rob Clark <rob.clark@linaro.org>
> + *
> + */
> +
> +#ifndef __DRM_PRIME_H__
> +#define __DRM_PRIME_H__
> +
> +#include <linux/mutex.h>
> +#include <linux/rbtree.h>
> +
> +/**
> + * struct drm_prime_file_private - per-file tracking for PRIME
> + *
> + * This just contains the internal &struct dma_buf and handle caches for each
> + * &struct drm_file used by the PRIME core code.
> + */
> +
> +struct drm_prime_file_private {
> +/* private: */

I'm a little confused by this comment. The struct has private in its name, I'm
not sure you're adding any additional information. Could you either remove or
expand this?

Aside from that,

Reviewed-by: Sean Paul <seanpaul@chromium.org>

Sean

> +	struct mutex lock;
> +	struct rb_root dmabufs;
> +	struct rb_root handles;
> +};
> +
> +struct dma_buf_export_info;
> +struct dma_buf;
> +
> +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_dmabuf_export(struct drm_device *dev,
> +				      struct dma_buf_export_info *exp_info);
> +extern 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);
> +
> +
> +#endif /* __DRM_PRIME_H__ */
> diff --git a/include/drm/drm_vma_manager.h b/include/drm/drm_vma_manager.h
> index 9c03895dc479..d84d52f6d2b1 100644
> --- a/include/drm/drm_vma_manager.h
> +++ b/include/drm/drm_vma_manager.h
> @@ -25,7 +25,6 @@
>  
>  #include <drm/drm_mm.h>
>  #include <linux/mm.h>
> -#include <linux/module.h>
>  #include <linux/rbtree.h>
>  #include <linux/spinlock.h>
>  #include <linux/types.h>
> -- 
> 2.11.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 08/24] drm: Remove DRM_MINOR_CNT
  2017-03-08 14:12 ` [PATCH 08/24] drm: Remove DRM_MINOR_CNT Daniel Vetter
  2017-03-08 14:14   ` David Herrmann
@ 2017-03-13 16:56   ` Sean Paul
  1 sibling, 0 replies; 72+ messages in thread
From: Sean Paul @ 2017-03-13 16:56 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

On Wed, Mar 08, 2017 at 03:12:41PM +0100, Daniel Vetter wrote:
> This was originally added by David Herrmann for range checks, but
> entirely unused. It confused me, so let's remove it.
> 
> Cc: David Herrmann <dh.herrmann@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

Reviewed-by: Sean Paul <seanpaul@chromium.org>
> ---
>  include/drm/drmP.h | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 826101785876..7bd6752683a4 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -444,7 +444,6 @@ enum drm_minor_type {
>  	DRM_MINOR_PRIMARY,
>  	DRM_MINOR_CONTROL,
>  	DRM_MINOR_RENDER,
> -	DRM_MINOR_CNT,
>  };
>  
>  /**
> -- 
> 2.11.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [Intel-gfx] [PATCH 10/24] drm: Remove drm_pending_event->pid
  2017-03-08 14:12 ` [PATCH 10/24] drm: Remove drm_pending_event->pid Daniel Vetter
@ 2017-03-13 17:05   ` Sean Paul
  2017-03-14 13:20     ` Daniel Vetter
  0 siblings, 1 reply; 72+ messages in thread
From: Sean Paul @ 2017-03-13 17:05 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Intel Graphics Development, Ben Skeggs, DRI Development

On Wed, Mar 08, 2017 at 03:12:43PM +0100, Daniel Vetter wrote:
> We might as well dump the drm_file pointer, that's about as useful
> a cookie as the pid. Noticed while typing docs for drm_file and friends.
> 
> Since the only consumer of this is the tracepoints I think we can safely
> change this - those tracepoints should not be uapi relevant at all. It
> all goes back to
> 
> commit b9c2c9ae882f058084e13e339925dbf8d2d20271
> Author: Jesse Barnes <jbarnes@virtuousgeek.org>
> Date:   Thu Jul 1 16:48:09 2010 -0700
> 
>     drm: add per-event vblank event trace points
> 
> which doesn't give a special justification for using pid over a pointer.

Well, it's friendlier to look at, I suppose.

> 
> Also note that the nouveau code setting it is entirely pointless:
> Since this isn't a vblank event, it will never hit the vblank
> tracepoints.
> 
> Cc: Ben Skeggs <bskeggs@redhat.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/drm_irq.c              |  5 ++---
>  drivers/gpu/drm/drm_trace.h            | 20 ++++++++++----------
>  drivers/gpu/drm/nouveau/nouveau_usif.c |  1 -
>  include/drm/drm_file.h                 |  2 --
>  4 files changed, 12 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 1906723af389..9bdca69f754c 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -978,7 +978,7 @@ static void send_vblank_event(struct drm_device *dev,
>  	e->event.tv_sec = now->tv_sec;
>  	e->event.tv_usec = now->tv_usec;
>  
> -	trace_drm_vblank_event_delivered(e->base.pid, e->pipe,
> +	trace_drm_vblank_event_delivered(e->base.file_priv, e->pipe,
>  					 e->event.sequence);
>  
>  	drm_send_event_locked(dev, &e->base);
> @@ -1505,7 +1505,6 @@ static int drm_queue_vblank_event(struct drm_device *dev, unsigned int pipe,
>  	}
>  
>  	e->pipe = pipe;
> -	e->base.pid = current->pid;

Do you think it would be worthwhile to output the pid:file_priv mapping here in
case someone is using pid?

Regardless, the code looks correct, and I don't any skin in this game, so I'll
add my R-b and let you decide what to do if no one else complains.

Reviewed-by: Sean Paul <seanpaul@chromium.org>

>  	e->event.base.type = DRM_EVENT_VBLANK;
>  	e->event.base.length = sizeof(e->event);
>  	e->event.user_data = vblwait->request.signal;
> @@ -1534,7 +1533,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, unsigned int pipe,
>  	DRM_DEBUG("event on vblank count %u, current %u, crtc %u\n",
>  		  vblwait->request.sequence, seq, pipe);
>  
> -	trace_drm_vblank_event_queued(current->pid, pipe,
> +	trace_drm_vblank_event_queued(file_priv, pipe,
>  				      vblwait->request.sequence);
>  
>  	e->event.sequence = vblwait->request.sequence;
> diff --git a/drivers/gpu/drm/drm_trace.h b/drivers/gpu/drm/drm_trace.h
> index ce3c42813fbb..14c5a777682e 100644
> --- a/drivers/gpu/drm/drm_trace.h
> +++ b/drivers/gpu/drm/drm_trace.h
> @@ -24,36 +24,36 @@ TRACE_EVENT(drm_vblank_event,
>  );
>  
>  TRACE_EVENT(drm_vblank_event_queued,
> -	    TP_PROTO(pid_t pid, int crtc, unsigned int seq),
> -	    TP_ARGS(pid, crtc, seq),
> +	    TP_PROTO(struct drm_file *file, int crtc, unsigned int seq),
> +	    TP_ARGS(file, crtc, seq),
>  	    TP_STRUCT__entry(
> -		    __field(pid_t, pid)
> +		    __field(struct drm_file *, file)
>  		    __field(int, crtc)
>  		    __field(unsigned int, seq)
>  		    ),
>  	    TP_fast_assign(
> -		    __entry->pid = pid;
> +		    __entry->file = file;
>  		    __entry->crtc = crtc;
>  		    __entry->seq = seq;
>  		    ),
> -	    TP_printk("pid=%d, crtc=%d, seq=%u", __entry->pid, __entry->crtc, \
> +	    TP_printk("file=%p, crtc=%d, seq=%u", __entry->file, __entry->crtc, \
>  		      __entry->seq)
>  );
>  
>  TRACE_EVENT(drm_vblank_event_delivered,
> -	    TP_PROTO(pid_t pid, int crtc, unsigned int seq),
> -	    TP_ARGS(pid, crtc, seq),
> +	    TP_PROTO(struct drm_file *file, int crtc, unsigned int seq),
> +	    TP_ARGS(file, crtc, seq),
>  	    TP_STRUCT__entry(
> -		    __field(pid_t, pid)
> +		    __field(struct drm_file *, file)
>  		    __field(int, crtc)
>  		    __field(unsigned int, seq)
>  		    ),
>  	    TP_fast_assign(
> -		    __entry->pid = pid;
> +		    __entry->file = file;
>  		    __entry->crtc = crtc;
>  		    __entry->seq = seq;
>  		    ),
> -	    TP_printk("pid=%d, crtc=%d, seq=%u", __entry->pid, __entry->crtc, \
> +	    TP_printk("file=%p, crtc=%d, seq=%u", __entry->file, __entry->crtc, \
>  		      __entry->seq)
>  );
>  
> diff --git a/drivers/gpu/drm/nouveau/nouveau_usif.c b/drivers/gpu/drm/nouveau/nouveau_usif.c
> index afbdbed1a690..9dc10b17ad34 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_usif.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_usif.c
> @@ -211,7 +211,6 @@ usif_notify_get(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
>  		goto done;
>  	ntfy->p->base.event = &ntfy->p->e.base;
>  	ntfy->p->base.file_priv = f;
> -	ntfy->p->base.pid = current->pid;
>  	ntfy->p->e.base.type = DRM_NOUVEAU_EVENT_NVIF;
>  	ntfy->p->e.base.length = sizeof(ntfy->p->e.base) + ntfy->reply;
>  
> diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
> index d1a25cc17fd1..4e347399a7bd 100644
> --- a/include/drm/drm_file.h
> +++ b/include/drm/drm_file.h
> @@ -75,8 +75,6 @@ struct drm_pending_event {
>  	struct list_head link;
>  	struct list_head pending_link;
>  	struct drm_file *file_priv;
> -	pid_t pid; /* pid of requester, no guarantee it's valid by the time
> -		      we deliver the event, for tracing only */
>  };
>  
>  /** File private data */
> -- 
> 2.11.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 23/24] drm: Create DEFINE_DRM_GEM_CMA_FOPS and roll it out to drivers
  2017-03-08 14:12 ` [PATCH 23/24] drm: Create DEFINE_DRM_GEM_CMA_FOPS and roll it out to drivers Daniel Vetter
@ 2017-03-13 17:11   ` Liviu Dudau
  2017-03-13 19:31   ` [Intel-gfx] " Sean Paul
  1 sibling, 0 replies; 72+ messages in thread
From: Liviu Dudau @ 2017-03-13 17:11 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

On Wed, Mar 08, 2017 at 03:12:56PM +0100, Daniel Vetter wrote:
> Less code ftw.
> 
> This converts all drivers except the tinydrm helper module. That one
> needs more work, since it gets the THIS_MODULE reference from
> tinydrm.ko instead of the actual driver module like it should.
> Probably needs a similar trick like I used here with generating the
> entire struct with a macro.
> 
> Cc: Noralf Trønnes <noralf@tronnes.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/arm/hdlcd_drv.c                 | 12 +-----------
>  drivers/gpu/drm/arm/malidp_drv.c                | 12 +-----------

For the hdlcd_drv.c and malidp_drv.c changes:

Acked-by: Liviu Dudau <Liviu.Dudau@arm.com>

For the rest of the series:

Reviewed-by: Liviu Dudau <Liviu.Dudau@arm.com>

Best regards,
Liviu

>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c    | 12 +-----------
>  drivers/gpu/drm/drm_file.c                      |  3 +++
>  drivers/gpu/drm/drm_gem_cma_helper.c            |  3 +++
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c       | 12 +-----------
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 12 +-----------
>  drivers/gpu/drm/imx/imx-drm-core.c              | 11 +----------
>  drivers/gpu/drm/meson/meson_drv.c               | 14 +------------
>  drivers/gpu/drm/mxsfb/mxsfb_drv.c               | 14 +------------
>  drivers/gpu/drm/rcar-du/rcar_du_drv.c           | 12 +-----------
>  drivers/gpu/drm/shmobile/shmob_drm_drv.c        | 12 +-----------
>  drivers/gpu/drm/sti/sti_drv.c                   | 11 +----------
>  drivers/gpu/drm/sun4i/sun4i_drv.c               | 12 +-----------
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c             | 12 +-----------
>  drivers/gpu/drm/zte/zx_drm_drv.c                | 14 +------------
>  include/drm/drm_gem_cma_helper.h                | 26 +++++++++++++++++++++++++
>  17 files changed, 46 insertions(+), 158 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index 4840dc277339..0e74880b5e94 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -239,17 +239,7 @@ static int hdlcd_debugfs_init(struct drm_minor *minor)
>  }
>  #endif
>  
> -static const struct file_operations fops = {
> -	.owner		= THIS_MODULE,
> -	.open		= drm_open,
> -	.release	= drm_release,
> -	.unlocked_ioctl	= drm_ioctl,
> -	.compat_ioctl	= drm_compat_ioctl,
> -	.poll		= drm_poll,
> -	.read		= drm_read,
> -	.llseek		= noop_llseek,
> -	.mmap		= drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(fops);
>  
>  static struct drm_driver hdlcd_driver = {
>  	.driver_features = DRIVER_HAVE_IRQ | DRIVER_GEM |
> diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
> index a9608a2e5a29..ea2546f766c2 100644
> --- a/drivers/gpu/drm/arm/malidp_drv.c
> +++ b/drivers/gpu/drm/arm/malidp_drv.c
> @@ -178,17 +178,7 @@ static void malidp_lastclose(struct drm_device *drm)
>  	drm_fbdev_cma_restore_mode(malidp->fbdev);
>  }
>  
> -static const struct file_operations fops = {
> -	.owner = THIS_MODULE,
> -	.open = drm_open,
> -	.release = drm_release,
> -	.unlocked_ioctl = drm_ioctl,
> -	.compat_ioctl = drm_compat_ioctl,
> -	.poll = drm_poll,
> -	.read = drm_read,
> -	.llseek = noop_llseek,
> -	.mmap = drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(fops);
>  
>  static struct drm_driver malidp_driver = {
>  	.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC |
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> index 970bd87d7cce..178acbf5f6c5 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> @@ -724,17 +724,7 @@ static void atmel_hlcdc_dc_irq_uninstall(struct drm_device *dev)
>  	regmap_read(dc->hlcdc->regmap, ATMEL_HLCDC_ISR, &isr);
>  }
>  
> -static const struct file_operations fops = {
> -	.owner              = THIS_MODULE,
> -	.open               = drm_open,
> -	.release            = drm_release,
> -	.unlocked_ioctl     = drm_ioctl,
> -	.compat_ioctl       = drm_compat_ioctl,
> -	.poll               = drm_poll,
> -	.read               = drm_read,
> -	.llseek             = no_llseek,
> -	.mmap               = drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(fops);
>  
>  static struct drm_driver atmel_hlcdc_dc_driver = {
>  	.driver_features = DRIVER_HAVE_IRQ | DRIVER_GEM |
> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> index f8483fc6d3d7..260a83563976 100644
> --- a/drivers/gpu/drm/drm_file.c
> +++ b/drivers/gpu/drm/drm_file.c
> @@ -89,6 +89,9 @@ DEFINE_MUTEX(drm_global_mutex);
>   *             .mmap = drm_gem_mmap,
>   *     };
>   *
> + * For CMA based drivers there is the DEFINE_DRM_GEM_CMA_FOPS() macro to make
> + * this simpler.
> + *
>   * FIXME: We should have a macro for this (and the CMA version) so that drivers
>   * don't have to repeat it all the time.
>   */
> diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
> index bb968e76779b..bc28e7575254 100644
> --- a/drivers/gpu/drm/drm_gem_cma_helper.c
> +++ b/drivers/gpu/drm/drm_gem_cma_helper.c
> @@ -338,6 +338,9 @@ static int drm_gem_cma_mmap_obj(struct drm_gem_cma_object *cma_obj,
>   * as their ->mmap() handler in the DRM device file's file_operations
>   * structure.
>   *
> + * Instead of directly referencing this function, drivers should use the
> + * DEFINE_DRM_GEM_CMA_FOPS().macro.
> + *
>   * Returns:
>   * 0 on success or a negative error code on failure.
>   */
> diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> index b5391c124c64..6e00f4b267f1 100644
> --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> @@ -161,17 +161,7 @@ static void fsl_dcu_drm_lastclose(struct drm_device *dev)
>  	drm_fbdev_cma_restore_mode(fsl_dev->fbdev);
>  }
>  
> -static const struct file_operations fsl_dcu_drm_fops = {
> -	.owner		= THIS_MODULE,
> -	.open		= drm_open,
> -	.release	= drm_release,
> -	.unlocked_ioctl	= drm_ioctl,
> -	.compat_ioctl	= drm_compat_ioctl,
> -	.poll		= drm_poll,
> -	.read		= drm_read,
> -	.llseek		= no_llseek,
> -	.mmap		= drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(fsl_dcu_drm_fops);
>  
>  static struct drm_driver fsl_dcu_drm_driver = {
>  	.driver_features	= DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET
> diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> index 7ec93aec7e88..df4f50713e54 100644
> --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> @@ -146,17 +146,7 @@ static int kirin_drm_kms_init(struct drm_device *dev)
>  	return ret;
>  }
>  
> -static const struct file_operations kirin_drm_fops = {
> -	.owner		= THIS_MODULE,
> -	.open		= drm_open,
> -	.release	= drm_release,
> -	.unlocked_ioctl	= drm_ioctl,
> -	.compat_ioctl	= drm_compat_ioctl,
> -	.poll		= drm_poll,
> -	.read		= drm_read,
> -	.llseek		= no_llseek,
> -	.mmap		= drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(kirin_drm_fops);
>  
>  static int kirin_gem_cma_dumb_create(struct drm_file *file,
>  				     struct drm_device *dev,
> diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
> index 4b7b92a7bcf7..70736615983c 100644
> --- a/drivers/gpu/drm/imx/imx-drm-core.c
> +++ b/drivers/gpu/drm/imx/imx-drm-core.c
> @@ -57,16 +57,7 @@ static void imx_drm_driver_lastclose(struct drm_device *drm)
>  	drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
>  }
>  
> -static const struct file_operations imx_drm_driver_fops = {
> -	.owner = THIS_MODULE,
> -	.open = drm_open,
> -	.release = drm_release,
> -	.unlocked_ioctl = drm_ioctl,
> -	.mmap = drm_gem_cma_mmap,
> -	.poll = drm_poll,
> -	.read = drm_read,
> -	.llseek = noop_llseek,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(imx_drm_driver_fops);
>  
>  void imx_drm_connector_destroy(struct drm_connector *connector)
>  {
> diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
> index 8d17d0e59cbe..bc562a07847b 100644
> --- a/drivers/gpu/drm/meson/meson_drv.c
> +++ b/drivers/gpu/drm/meson/meson_drv.c
> @@ -91,19 +91,7 @@ static irqreturn_t meson_irq(int irq, void *arg)
>  	return IRQ_HANDLED;
>  }
>  
> -static const struct file_operations fops = {
> -	.owner		= THIS_MODULE,
> -	.open		= drm_open,
> -	.release	= drm_release,
> -	.unlocked_ioctl	= drm_ioctl,
> -#ifdef CONFIG_COMPAT
> -	.compat_ioctl	= drm_compat_ioctl,
> -#endif
> -	.poll		= drm_poll,
> -	.read		= drm_read,
> -	.llseek		= no_llseek,
> -	.mmap		= drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(fops);
>  
>  static struct drm_driver meson_driver = {
>  	.driver_features	= DRIVER_HAVE_IRQ | DRIVER_GEM |
> diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> index a4633ada8429..5ac712325c75 100644
> --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> @@ -319,19 +319,7 @@ static irqreturn_t mxsfb_irq_handler(int irq, void *data)
>  	return IRQ_HANDLED;
>  }
>  
> -static const struct file_operations fops = {
> -	.owner		= THIS_MODULE,
> -	.open		= drm_open,
> -	.release	= drm_release,
> -	.unlocked_ioctl	= drm_ioctl,
> -#ifdef CONFIG_COMPAT
> -	.compat_ioctl	= drm_compat_ioctl,
> -#endif
> -	.poll		= drm_poll,
> -	.read		= drm_read,
> -	.llseek		= noop_llseek,
> -	.mmap		= drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(fops);
>  
>  static struct drm_driver mxsfb_driver = {
>  	.driver_features	= DRIVER_GEM | DRIVER_MODESET |
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> index 192346d4fb34..62a3b3e32153 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> @@ -226,17 +226,7 @@ static void rcar_du_lastclose(struct drm_device *dev)
>  	drm_fbdev_cma_restore_mode(rcdu->fbdev);
>  }
>  
> -static const struct file_operations rcar_du_fops = {
> -	.owner		= THIS_MODULE,
> -	.open		= drm_open,
> -	.release	= drm_release,
> -	.unlocked_ioctl	= drm_ioctl,
> -	.compat_ioctl	= drm_compat_ioctl,
> -	.poll		= drm_poll,
> -	.read		= drm_read,
> -	.llseek		= no_llseek,
> -	.mmap		= drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(rcar_du_fops);
>  
>  static struct drm_driver rcar_du_driver = {
>  	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME
> diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> index 34fefa0ba0f0..75f2e5e6d7fb 100644
> --- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> +++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> @@ -221,17 +221,7 @@ static irqreturn_t shmob_drm_irq(int irq, void *arg)
>  	return IRQ_HANDLED;
>  }
>  
> -static const struct file_operations shmob_drm_fops = {
> -	.owner		= THIS_MODULE,
> -	.open		= drm_open,
> -	.release	= drm_release,
> -	.unlocked_ioctl	= drm_ioctl,
> -	.compat_ioctl	= drm_compat_ioctl,
> -	.poll		= drm_poll,
> -	.read		= drm_read,
> -	.llseek		= no_llseek,
> -	.mmap		= drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(shmob_drm_fops);
>  
>  static struct drm_driver shmob_drm_driver = {
>  	.driver_features	= DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 3b15c2cb2306..23da9bc4666a 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -167,16 +167,7 @@ static void sti_mode_config_init(struct drm_device *dev)
>  	dev->mode_config.funcs = &sti_mode_config_funcs;
>  }
>  
> -static const struct file_operations sti_driver_fops = {
> -	.owner = THIS_MODULE,
> -	.open = drm_open,
> -	.mmap = drm_gem_cma_mmap,
> -	.poll = drm_poll,
> -	.read = drm_read,
> -	.unlocked_ioctl = drm_ioctl,
> -	.compat_ioctl = drm_compat_ioctl,
> -	.release = drm_release,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(sti_driver_fops);
>  
>  static struct drm_driver sti_driver = {
>  	.driver_features = DRIVER_MODESET |
> diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
> index 9ccf7c4deb6d..329ea56106a5 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
> @@ -25,17 +25,7 @@
>  #include "sun4i_framebuffer.h"
>  #include "sun4i_layer.h"
>  
> -static const struct file_operations sun4i_drv_fops = {
> -	.owner		= THIS_MODULE,
> -	.open		= drm_open,
> -	.release	= drm_release,
> -	.unlocked_ioctl	= drm_ioctl,
> -	.compat_ioctl	= drm_compat_ioctl,
> -	.poll		= drm_poll,
> -	.read		= drm_read,
> -	.llseek		= no_llseek,
> -	.mmap		= drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(sun4i_drv_fops);
>  
>  static struct drm_driver sun4i_drv_driver = {
>  	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC,
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> index 81d80a2ffeb1..480411c2e802 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> @@ -530,17 +530,7 @@ static int tilcdc_debugfs_init(struct drm_minor *minor)
>  }
>  #endif
>  
> -static const struct file_operations fops = {
> -	.owner              = THIS_MODULE,
> -	.open               = drm_open,
> -	.release            = drm_release,
> -	.unlocked_ioctl     = drm_ioctl,
> -	.compat_ioctl       = drm_compat_ioctl,
> -	.poll               = drm_poll,
> -	.read               = drm_read,
> -	.llseek             = no_llseek,
> -	.mmap               = drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(fops);
>  
>  static struct drm_driver tilcdc_driver = {
>  	.driver_features    = (DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET |
> diff --git a/drivers/gpu/drm/zte/zx_drm_drv.c b/drivers/gpu/drm/zte/zx_drm_drv.c
> index b24a70ba4b83..614e854f6be5 100644
> --- a/drivers/gpu/drm/zte/zx_drm_drv.c
> +++ b/drivers/gpu/drm/zte/zx_drm_drv.c
> @@ -53,19 +53,7 @@ static void zx_drm_lastclose(struct drm_device *drm)
>  	drm_fbdev_cma_restore_mode(priv->fbdev);
>  }
>  
> -static const struct file_operations zx_drm_fops = {
> -	.owner = THIS_MODULE,
> -	.open = drm_open,
> -	.release = drm_release,
> -	.unlocked_ioctl = drm_ioctl,
> -#ifdef CONFIG_COMPAT
> -	.compat_ioctl = drm_compat_ioctl,
> -#endif
> -	.poll = drm_poll,
> -	.read = drm_read,
> -	.llseek = noop_llseek,
> -	.mmap = drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(zx_drm_fops);
>  
>  static struct drm_driver zx_drm_driver = {
>  	.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
> diff --git a/include/drm/drm_gem_cma_helper.h b/include/drm/drm_gem_cma_helper.h
> index 2abcd5190cc1..f962d33667cf 100644
> --- a/include/drm/drm_gem_cma_helper.h
> +++ b/include/drm/drm_gem_cma_helper.h
> @@ -26,6 +26,32 @@ to_drm_gem_cma_obj(struct drm_gem_object *gem_obj)
>  	return container_of(gem_obj, struct drm_gem_cma_object, base);
>  }
>  
> +/**
> + * DEFINE_DRM_GEM_CMA_FOPS() - macro to generate file operations for CMA drivers
> + * @name: name for the generated structure
> + *
> + * This macro autogenerates a suitable &struct file_operations for CMA based
> + * drivers, which can be assigned to &drm_driver.fops. Note that this structure
> + * cannot be shared between drivers, because it contains a reference to the
> + * current module using THIS_MODULE.
> + *
> + * Note that the declaration is already marked as static - if you need a
> + * non-static version of this you're probably doing it wrong and will break the
> + * THIS_MODULE reference by accident.
> + */
> +#define DEFINE_DRM_GEM_CMA_FOPS(name) \
> +	static const struct file_operations name = {\
> +		.owner		= THIS_MODULE,\
> +		.open		= drm_open,\
> +		.release	= drm_release,\
> +		.unlocked_ioctl	= drm_ioctl,\
> +		.compat_ioctl	= drm_compat_ioctl,\
> +		.poll		= drm_poll,\
> +		.read		= drm_read,\
> +		.llseek		= noop_llseek,\
> +		.mmap		= drm_gem_cma_mmap,\
> +	}
> +
>  /* free GEM object */
>  void drm_gem_cma_free_object(struct drm_gem_object *gem_obj);
>  
> -- 
> 2.11.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 11/24] drm/doc: Document drm_file.[hc]
  2017-03-08 14:12 ` [PATCH 11/24] drm/doc: Document drm_file.[hc] Daniel Vetter
@ 2017-03-13 17:53   ` Sean Paul
  2017-03-14 13:25     ` Daniel Vetter
  2017-03-14 13:27     ` Daniel Vetter
  0 siblings, 2 replies; 72+ messages in thread
From: Sean Paul @ 2017-03-13 17:53 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

On Wed, Mar 08, 2017 at 03:12:44PM +0100, Daniel Vetter wrote:
> Well, mostly drm_file.h, and clean up all related things:
> 
> - I didnt' figure out the difference between preclose and postclose.
>   The existing explanation in drm-internals.rst didn't convince me,
>   since it's also really outdated - we clean up pending DRM events in
>   the core nowadays. I put a FIXME in for the future.
> 
> - Another FIXME is to have a macro for default fops.
> 
> - Lots of links all around, main areas are to tie the overview in
>   drm_file.c more into the callbacks in struct drm_device, and the
>   other is to link render/primary node code to the right sections in
>   drm-uapi.rst.
> 
> - Also moved the open/close stuff to drm_drv.h from drm-internals.rst,
>   seems like the better place for that information. Since that section
>   was rather outdated this amounted to full-on rewrite.
> 
> A big missing piece here is some overview graph, but I think better to
> wait with that one until drm_device and drm_driver are also fully
> documented.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

Overall, awesome patch, really does a good job explaining the parameters and how
they interact with each other (bonus points for the lock breadcrumbs). I just
have a few optional nits and some spelling errors.

Reviewed-by: Sean Paul <seanpaul@chromium.org>

> ---
>  Documentation/gpu/drm-internals.rst |  52 +------
>  Documentation/gpu/drm-uapi.rst      |   4 +
>  drivers/gpu/drm/drm_file.c          |  66 +++++----
>  include/drm/drm_drv.h               |  81 ++++++++++-
>  include/drm/drm_file.h              | 267 ++++++++++++++++++++++++++++++++----
>  5 files changed, 356 insertions(+), 114 deletions(-)
> 
> diff --git a/Documentation/gpu/drm-internals.rst b/Documentation/gpu/drm-internals.rst
> index ea329b71c459..7a2fe4a02212 100644
> --- a/Documentation/gpu/drm-internals.rst
> +++ b/Documentation/gpu/drm-internals.rst
> @@ -246,61 +246,15 @@ drivers.
>  Open/Close, File Operations and IOCTLs
>  ======================================
>  
> -Open and Close
> ---------------
> -
> -Open and close handlers. None of those methods are mandatory::
> -
> -    int (*firstopen) (struct drm_device *);
> -    void (*lastclose) (struct drm_device *);
> -    int (*open) (struct drm_device *, struct drm_file *);
> -    void (*preclose) (struct drm_device *, struct drm_file *);
> -    void (*postclose) (struct drm_device *, struct drm_file *);
> -
> -The firstopen method is called by the DRM core for legacy UMS (User Mode
> -Setting) drivers only when an application opens a device that has no
> -other opened file handle. UMS drivers can implement it to acquire device
> -resources. KMS drivers can't use the method and must acquire resources
> -in the load method instead.
> -
> -Similarly the lastclose method is called when the last application
> -holding a file handle opened on the device closes it, for both UMS and
> -KMS drivers. Additionally, the method is also called at module unload
> -time or, for hot-pluggable devices, when the device is unplugged. The
> -firstopen and lastclose calls can thus be unbalanced.
> -
> -The open method is called every time the device is opened by an
> -application. Drivers can allocate per-file private data in this method
> -and store them in the struct :c:type:`struct drm_file
> -<drm_file>` driver_priv field. Note that the open method is
> -called before firstopen.
> -
> -The close operation is split into preclose and postclose methods.
> -Drivers must stop and cleanup all per-file operations in the preclose
> -method. For instance pending vertical blanking and page flip events must
> -be cancelled. No per-file operation is allowed on the file handle after
> -returning from the preclose method.
> -
> -Finally the postclose method is called as the last step of the close
> -operation, right before calling the lastclose method if no other open
> -file handle exists for the device. Drivers that have allocated per-file
> -private data in the open method should free it here.
> -
> -The lastclose method should restore CRTC and plane properties to default
> -value, so that a subsequent open of the device will not inherit state
> -from the previous user. It can also be used to execute delayed power
> -switching state changes, e.g. in conjunction with the :ref:`vga_switcheroo`
> -infrastructure. Beyond that KMS drivers should not do any
> -further cleanup. Only legacy UMS drivers might need to clean up device
> -state so that the vga console or an independent fbdev driver could take
> -over.
> -
>  File Operations
>  ---------------
>  
>  .. kernel-doc:: drivers/gpu/drm/drm_file.c
>     :doc: file operations
>  
> +.. kernel-doc:: include/drm/drm_file.h
> +   :internal:
> +
>  .. kernel-doc:: drivers/gpu/drm/drm_file.c
>     :export:
>  
> diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst
> index fcc228ef5bc4..352652810dab 100644
> --- a/Documentation/gpu/drm-uapi.rst
> +++ b/Documentation/gpu/drm-uapi.rst
> @@ -21,6 +21,8 @@ libdrm Device Lookup
>     :doc: getunique and setversion story
>  
>  
> +.. _drm_primary_node:
> +
>  Primary Nodes, DRM Master and Authentication
>  ============================================
>  
> @@ -103,6 +105,8 @@ is already rather painful for the DRM subsystem, with multiple different uAPIs
>  for the same thing co-existing. If we add a few more complete mistakes into the
>  mix every year it would be entirely unmanageable.
>  
> +.. _drm_render_node:
> +
>  Render nodes
>  ============
>  
> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> index d9e63d73d3ec..a8813a1115dc 100644
> --- a/drivers/gpu/drm/drm_file.c
> +++ b/drivers/gpu/drm/drm_file.c
> @@ -50,12 +50,14 @@ DEFINE_MUTEX(drm_global_mutex);
>   *
>   * Drivers must define the file operations structure that forms the DRM
>   * userspace API entry point, even though most of those operations are
> - * implemented in the DRM core. The mandatory functions are drm_open(),
> + * implemented in the DRM core. The resulting &struct file_operations must be
> + * stored in the &drm_driver.fops field. The mandatory functions are drm_open(),
>   * drm_read(), drm_ioctl() and drm_compat_ioctl() if CONFIG_COMPAT is enabled
> - * (note that drm_compat_ioctl will be NULL if CONFIG_COMPAT=n). Drivers which
> - * implement private ioctls that require 32/64 bit compatibility support must
> - * provide their own .compat_ioctl() handler that processes private ioctls and
> - * calls drm_compat_ioctl() for core ioctls.
> + * Note that drm_compat_ioctl will be NULL if CONFIG_COMPAT=n, so there's no
> + * need to sprinkle #ifdef into the code. Drivers which implement private ioctls
> + * that require 32/64 bit compatibility support must provide their own
> + * &file_operations.compat_ioctl handler that processes private ioctls and calls
> + * drm_compat_ioctl() for core ioctls.
>   *
>   * In addition drm_read() and drm_poll() provide support for DRM events. DRM
>   * events are a generic and extensible means to send asynchronous events to
> @@ -63,10 +65,14 @@ DEFINE_MUTEX(drm_global_mutex);
>   * page flip completions by the KMS API. But drivers can also use it for their
>   * own needs, e.g. to signal completion of rendering.
>   *
> + * For the driver-side event interface see drm_event_reserve_init() and
> + * drm_send_event() as the main starting points.
> + *
>   * The memory mapping implementation will vary depending on how the driver
>   * manages memory. Legacy drivers will use the deprecated drm_legacy_mmap()
>   * function, modern drivers should use one of the provided memory-manager
> - * specific implementations. For GEM-based drivers this is drm_gem_mmap().
> + * specific implementations. For GEM-based drivers this is drm_gem_mmap(), and
> + * for drivers which use the CMA GEM helpers it's drm_gem_cma_mmap().
>   *
>   * No other file operations are supported by the DRM userspace API. Overall the
>   * following is an example #file_operations structure::
> @@ -82,6 +88,9 @@ DEFINE_MUTEX(drm_global_mutex);
>   *             .llseek = no_llseek,
>   *             .mmap = drm_gem_mmap,
>   *     };
> + *
> + * FIXME: We should have a macro for this (and the CMA version) so that drivers
> + * don't have to repeat it all the time.
>   */
>  
>  static int drm_open_helper(struct file *filp, struct drm_minor *minor);
> @@ -111,9 +120,9 @@ static int drm_setup(struct drm_device * dev)
>   * @inode: device inode
>   * @filp: file pointer.
>   *
> - * This function must be used by drivers as their .open() #file_operations
> - * method. It looks up the correct DRM device and instantiates all the per-file
> - * resources for it.
> + * This function must be used by drivers as their &file_operations.open method.
> + * It looks up the correct DRM device and instantiates all the per-file
> + * resources for it. It also calls the &drm_driver.open driver callback.
>   *
>   * RETURNS:
>   *
> @@ -298,11 +307,6 @@ static void drm_events_release(struct drm_file *file_priv)
>  	spin_unlock_irqrestore(&dev->event_lock, flags);
>  }
>  
> -/*
> - * drm_legacy_dev_reinit
> - *
> - * Reinitializes a legacy/ums drm device in it's lastclose function.
> - */
>  static void drm_legacy_dev_reinit(struct drm_device *dev)
>  {
>  	if (dev->irq_enabled)
> @@ -327,15 +331,6 @@ static void drm_legacy_dev_reinit(struct drm_device *dev)
>  	DRM_DEBUG("lastclose completed\n");
>  }
>  
> -/*
> - * Take down the DRM device.
> - *
> - * \param dev DRM device structure.
> - *
> - * Frees every resource in \p dev.
> - *
> - * \sa drm_device
> - */
>  void drm_lastclose(struct drm_device * dev)
>  {
>  	DRM_DEBUG("\n");
> @@ -353,9 +348,11 @@ void drm_lastclose(struct drm_device * dev)
>   * @inode: device inode
>   * @filp: file pointer.
>   *
> - * This function must be used by drivers as their .release() #file_operations
> - * method. It frees any resources associated with the open file, and if this is
> - * the last open file for the DRM device also proceeds to call drm_lastclose().
> + * This function must be used by drivers as their &file_operations.release
> + * method. It frees any resources associated with the open file, and calls the
> + * &drm_driver.preclose and &drm_driver.lastclose driver callbacks. If this is
> + * the last open file for the DRM device also proceeds to call the
> + * &drm_driver.lastclose driver callback.
>   *
>   * RETURNS:
>   *
> @@ -443,13 +440,13 @@ EXPORT_SYMBOL(drm_release);
>   * @count: count in bytes to read
>   * @offset: offset to read
>   *
> - * This function must be used by drivers as their .read() #file_operations
> + * This function must be used by drivers as their &file_operations.read
>   * method iff they use DRM events for asynchronous signalling to userspace.
>   * Since events are used by the KMS API for vblank and page flip completion this
>   * means all modern display drivers must use it.
>   *
> - * @offset is ignore, DRM events are read like a pipe. Therefore drivers also
> - * must set the .llseek() #file_operation to no_llseek(). Polling support is
> + * @offset is ignored, DRM events are read like a pipe. Therefore drivers also
> + * must set the &file_operation.llseek  to no_llseek(). Polling support is

nit: double space before 'to'

>   * provided by drm_poll().
>   *
>   * This function will only ever read a full event. Therefore userspace must
> @@ -537,10 +534,10 @@ EXPORT_SYMBOL(drm_read);
>   * @filp: file pointer
>   * @wait: poll waiter table
>   *
> - * This function must be used by drivers as their .read() #file_operations
> - * method iff they use DRM events for asynchronous signalling to userspace.
> - * Since events are used by the KMS API for vblank and page flip completion this
> - * means all modern display drivers must use it.
> + * This function must be used by drivers as their &file_operations.read method
> + * iff they use DRM events for asynchronous signalling to userspace.  Since
> + * events are used by the KMS API for vblank and page flip completion this means
> + * all modern display drivers must use it.
>   *
>   * See also drm_read().
>   *
> @@ -650,7 +647,8 @@ EXPORT_SYMBOL(drm_event_reserve_init);
>   * @p: tracking structure for the pending event
>   *
>   * This function frees the event @p initialized with drm_event_reserve_init()
> - * and releases any allocated space.
> + * and releases any allocated space. It is used to cancel an event when the
> + * nonblocking operation could not be submitted and needed to be aborted.
>   */
>  void drm_event_cancel_free(struct drm_device *dev,
>  			   struct drm_pending_event *p)
> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> index 4321d012c4ba..8f900fb30275 100644
> --- a/include/drm/drm_drv.h
> +++ b/include/drm/drm_drv.h
> @@ -64,7 +64,6 @@ struct drm_mode_create_dumb;
>   * structure for GEM drivers.
>   */
>  struct drm_driver {
> -
>  	/**
>  	 * @load:
>  	 *
> @@ -76,14 +75,94 @@ struct drm_driver {
>  	 * See drm_dev_init() and drm_dev_register() for proper and
>  	 * race-free way to set up a &struct drm_device.
>  	 *
> +	 * This is deprecated, do not use!
> +	 *
>  	 * Returns:
>  	 *
>  	 * Zero on success, non-zero value on failure.
>  	 */
>  	int (*load) (struct drm_device *, unsigned long flags);
> +
> +	/**
> +	 * @open:
> +	 *
> +	 * Driver callback when a new &struct drm_file is opened. Useful for
> +	 * setting up driver-private data structures like buffer allocators,
> +	 * execution contexts or similar things. Such driver-private resources
> +	 * must be released again in @postclose.
> +	 *
> +	 * Since the display/modeset side of DRM can only be owned by exactly
> +	 * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
> +	 * there should never be a need to set up any modeset related resources
> +	 * in this callback. Doing so would be a driver design bug.
> +	 *
> +	 * Returns:
> +	 *
> +	 * 0 on success, a negative error code on failure, which will be
> +	 * promoted to userspace as the result of the open() system call.
> +	 */
>  	int (*open) (struct drm_device *, struct drm_file *);
> +
> +	/**
> +	 * @preclose:
> +	 *
> +	 * One of the driver callbacks when a new &struct drm_file is closed.
> +	 * Useful for tearing down driver-private data structures allocated in
> +	 * @open like buffer allocators, execution contexts or similar things.
> +	 *
> +	 * Since the display/modeset side of DRM can only be owned by exactly
> +	 * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
> +	 * there should never be a need to tear down any modeset related
> +	 * resources in this callback. Doing so would be a driver design bug.
> +	 *
> +	 * FIXME: It is not really clear why there's both @preclose and
> +	 * @postclose. Without a really good reason, use @postclose only.
> +	 */
>  	void (*preclose) (struct drm_device *, struct drm_file *file_priv);
> +
> +	/**
> +	 * @postclose:
> +	 *
> +	 * One of the driver callbacks when a new &struct drm_file is closed.
> +	 * Useful for tearing down driver-private data structures allocated in
> +	 * @open like buffer allocators, execution contexts or similar things.
> +	 *
> +	 * Since the display/modeset side of DRM can only be owned by exactly
> +	 * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
> +	 * there should never be a need to tear down any modeset related
> +	 * resources in this callback. Doing so would be a driver design bug.
> +	 *
> +	 * FIXME: It is not really clear why there's both @preclose and
> +	 * @postclose. Without a really good reason, use @postclose only.
> +	 */
>  	void (*postclose) (struct drm_device *, struct drm_file *);
> +
> +	/**
> +	 * @lastclose:
> +	 *
> +	 * Called when the last &struct drm_file has been closed and there's
> +	 * currently no userspace client for the &struct drm_device.
> +	 *
> +	 * Modern drivers should only use this to force-restore the fbdev
> +	 * framebuffer using drm_fb_helper_restore_fbdev_mode_unlocked().
> +	 * Anything else would indicate there's something seriously wrong.
> +	 * Modern drivers can also use this to execute delayed power switching
> +	 * state changes, e.g. in conjunction with the :ref:`vga_switcheroo`
> +	 * infrastructure.
> +	 *
> +	 * This is called after @preclose and @postclose have been called.
> +	 *
> +	 * NOTE:
> +	 *
> +	 * All legacy drivers use this callback to de-initialize the hardware.
> +	 * This is purely because of the shadow-attach model, where the DRM
> +	 * kernel driver does not really own the hardware. Instead ownershipe is
> +	 * handled with the help of userspace through an inheritedly racy dance
> +	 * to set/unset the VT into raw mode.
> +	 *
> +	 * Legacy drivers initialize the hardware in the @firstopen callback,
> +	 * which isn't even called for modern drivers.
> +	 */
>  	void (*lastclose) (struct drm_device *);
>  
>  	/**
> diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
> index 4e347399a7bd..67244f2c0c54 100644
> --- a/include/drm/drm_file.h
> +++ b/include/drm/drm_file.h
> @@ -45,6 +45,7 @@ struct drm_device;
>   * FIXME: Not sure we want to have drm_minor here in the end, but to avoid
>   * header include loops we need it here for now.
>   */
> +
>  enum drm_minor_type {
>  	DRM_MINOR_PRIMARY,
>  	DRM_MINOR_CONTROL,
> @@ -52,12 +53,19 @@ enum drm_minor_type {
>  };
>  
>  /**
> - * DRM minor structure. This structure represents a drm minor number.
> + * struct drm_minor - DRM device minor structure
> + *
> + * This structure represents a DRM minor number for device nodes in /dev.
> + * Entirely opaque to drivers and should never be inspected directly by drivers.
> + * Drivers instead should only interact with &struct drm_file and of course
> + * &struct drm_device, which is also where driver-private data and resources can
> + * be attached to.
>   */
>  struct drm_minor {
> -	int index;			/**< Minor device number */
> -	int type;                       /**< Control or render */
> -	struct device *kdev;		/**< Linux device */
> +	/* private: */

Same comment here re: the private comment. I don't think it adds anything beyond
what you've already said in the overview.

> +	int index;			/* Minor device number */
> +	int type;                       /* Control or render */
> +	struct device *kdev;		/* Linux device */
>  	struct drm_device *dev;
>  
>  	struct dentry *debugfs_root;
> @@ -66,89 +74,288 @@ struct drm_minor {
>  	struct mutex debugfs_lock; /* Protects debugfs_list. */
>  };
>  
> -/* Event queued up for userspace to read */
> +/**
> + * struct drm_pending_event - Event queued up for userspace to read
> + *
> + * This represents a DRM event. Drivers can use this as a generic completion
> + * mechanism, which supports kernel-internal &struct completion, &struct dma_fence
> + * and also the DRM-specific &struct drm_event delivery mechanism.
> + */
>  struct drm_pending_event {
> +	/**
> +	 * @completion:
> +	 *
> +	 * Optional pointer to a kernel internal completion signalled when
> +	 * drm_send_event() is called, useful to internally synchronize with
> +	 * nonblcoking operations.

nonblocking

> +	 */
>  	struct completion *completion;
> +
> +	/**
> +	 * @completion_release:
> +	 *
> +	 * Optional callback currently only used by the atomic modeset helpers
> +	 * to clean up the reference count for the structure @completion is
> +	 * stored in.
> +	 */
>  	void (*completion_release)(struct completion *completion);
> +
> +	/**
> +	 * @event:
> +	 *
> +	 * Pointer to the actual event that should be sent to userspace to be
> +	 * read using drm_read(). Can be optional, since nowadays events are
> +	 * also used to signal kernel internal threads with @completion or DMA
> +	 * transactions using @fence.
> +	 */
>  	struct drm_event *event;
> +
> +	/**
> +	 * @fence:
> +	 *
> +	 * Optional DMA fence to unblock other hardware transactions which
> +	 * depend upon the nonblocking DRM operation this event represents.
> +	 */
>  	struct dma_fence *fence;
> +
> +	/**
> +	 * @file_priv:
> +	 *
> +	 * &struct drm_file where @event should be delivered to. Only set when
> +	 * @event is set.
> +	 */
> +	struct drm_file *file_priv;
> +
> +	/**
> +	 * @link:
> +	 *
> +	 * Double-linked list to keep track of this event. Can be used by the
> +	 * driver up to the point when it calls drm_send_event(), after that
> +	 * this list entry is owned by the core for its own book-keeping.
> +	 */
>  	struct list_head link;
> +
> +	/**
> +	 * @pending_link:
> +	 *
> +	 * Entry on &drm_file.pending_event_list, to keep track of all pending
> +	 * events for @file_priv, to allow correct unwinding of them when
> +	 * userspace closes the file before the event is delivered.
> +	 */
>  	struct list_head pending_link;
> -	struct drm_file *file_priv;
>  };
>  
> -/** File private data */
> +/**
> + * struct drm_file - DRM file private data
> + *
> + * This structure tracks per open file descriptor DRM state.

nit: This structure tracks DRM state per open file descriptor.

> + */
>  struct drm_file {
> +	/**
> +	 * @authenticated:
> +	 *
> +	 * Whether the client is allowed to submit rendering, which for legacy
> +	 * nodes means it must be authenticated.
> +	 *
> +	 * See also the :ref:`section on primary nodes and authentication
> +	 * <drm_primary_node>`.
> +	 */
> +

nit: extra line

>  	unsigned authenticated :1;
> -	/* true when the client has asked us to expose stereo 3D mode flags */
> +
> +	/**
> +	 * @stereo_allowed:
> +	 *
> +	 * True when the client has asked us to expose stereo 3D mode flags.
> +	 */
>  	unsigned stereo_allowed :1;
> -	/*
> -	 * true if client understands CRTC primary planes and cursor planes
> -	 * in the plane list
> +
> +	/**
> +	 * @universal_planes:
> +	 *
> +	 * True if client understands CRTC primary planes and cursor planes
> +	 * in the plane list. Automatically set when @atomic is set.
>  	 */
>  	unsigned universal_planes:1;
> -	/* true if client understands atomic properties */
> +
> +	/** @atomic: True if client understands atomic properties. */
>  	unsigned atomic:1;
> -	/*
> -	 * This client is the creator of @master.
> -	 * Protected by struct drm_device::master_mutex.
> +
> +	/**
> +	 * @is_master:
> +	 *
> +	 * This client is the creator of @master.  Protected by struct

nit: double space before Protected

> +	 * &drm_device.master_mutex.
> +	 *
> +	 * See also the :ref:`section on primary nodes and authentication
> +	 * <drm_primary_node>`.
>  	 */
>  	unsigned is_master:1;
>  
> +	/**
> +	 * @master:
> +	 *
> +	 * Master this node is currently associated with. Only relevant if
> +	 * drm_is_primary_client() returns true. Note that this only
> +	 * matches &drm_device.master if the master is the currently active one.
> +	 *
> +	 * See also @authentication and @is_master and the :ref:`section on
> +	 * primary nodes and authentication <drm_primary_node>`.
> +	 */
> +	struct drm_master *master;
> +
> +	/** @pid: Process that opened this file. */
>  	struct pid *pid;
> +
> +	/** @magic: Authentication magic, see @authenticated. */
>  	drm_magic_t magic;
> +
> +	/**
> +	 * @lhead:
> +	 *
> +	 * List of all open files of a DRM device, linked into
> +	 * &drm_device.filelist. Protected by &drm_device.filelist_mutex.
> +	 */
>  	struct list_head lhead;
> +
> +

nit: extra line

> +	/** @minor: &struct drm_minor for this file. */
>  	struct drm_minor *minor;
> -	unsigned long lock_count;
>  
> -	/** Mapping of mm object handles to object pointers. */
> +	/**
> +	 * @object_idr:
> +	 *
> +	 * Mapping of mm object handles to object pointers. Used by the GEM
> +	 * subsystem. Protected by @table_lock.
> +	 */
>  	struct idr object_idr;
> -	/** Lock for synchronization of access to object_idr. */
> +
> +	/** @table_lock: Protects @object_idr. */
>  	spinlock_t table_lock;
>  
> +	/** @filp: Pointer to the core file structure. */
>  	struct file *filp;
> +
> +	/**
> +	 * @driver_priv:
> +	 *
> +	 * Optional pointer for driver private data. Can be allocated in
> +	 * &drm_driver.open and should be freed in &drm_driver.postclose.
> +	 */
>  	void *driver_priv;
>  
> -	struct drm_master *master; /* master this node is currently associated with
> -				      N.B. not always dev->master */
>  	/**
> -	 * fbs - List of framebuffers associated with this file.
> +	 * @fbs:
> +	 *
> +	 * List of &struct drm_framebuffer associated with this file, using the
> +	 * &drm_framebuffer.filp_head entry.
>  	 *
> -	 * Protected by fbs_lock. Note that the fbs list holds a reference on
> -	 * the fb object to prevent it from untimely disappearing.
> +	 * Protected by @fbs_lock. Note that the @fbs list holds a reference on
> +	 * the framebuffer object to prevent it from untimely disappearing.
>  	 */
>  	struct list_head fbs;
> +
> +	/** @fbs_lock: Protects @fbs. */
>  	struct mutex fbs_lock;
>  
> -	/** User-created blob properties; this retains a reference on the
> -	 *  property. */
> +	/**
> +	 * @blobs:
> +	 *
> +	 * User-created blob properties; this retains a reference on the
> +	 * property.
> +	 *
> +	 * Protected by @drm_mode_config.blob_lock;
> +	 */
>  	struct list_head blobs;
>  
> +	/** @event_wait: Waitqueue for new events added to @event_list. */
>  	wait_queue_head_t event_wait;
> +
> +	/**
> +	 * @pending_event_list:
> +	 *
> +	 * List of pending &struct drm_pending_event, used to clean up pending
> +	 * events in case this file gets closed before the event is signalled.
> +	 * Uses the &drm_pending_event.pending_link entry.
> +	 *
> +	 * Protect by &drm_device.event_lock.
> +	 */
>  	struct list_head pending_event_list;
> +
> +	/**
> +	 * @event_list:
> +	 *
> +	 * List of &struct drm_pending_event, ready for devlivery to userspace

Dat 'dev' muscle memory :-)

> +	 * through drm_read(). Uses the &drm_pending_event.link entry.
> +	 *
> +	 * Protect by &drm_device.event_lock.
> +	 */
>  	struct list_head event_list;
> +
> +	/**
> +	 * @event_space:
> +	 *
> +	 * Available event space to prevent userspace from
> +	 * exhausting kernel memory. Currently limited to the fairly arbitrary
> +	 * value of 4KB.
> +	 */
>  	int event_space;
>  
> +	/** @event_read_lock: Serializes drm_read(). */
>  	struct mutex event_read_lock;
>  
> +	/**
> +	 * @prime:
> +	 *
> +	 * Per-file buffer caches used by the PRIME buffer sharing code.
> +	 */
>  	struct drm_prime_file_private prime;
> +
> +	/* private: */
> +	unsigned long lock_count; /* DRI1 legacy lock count */
>  };
>  
> +/**
> + * drm_is_primary_client - is this an open file of the primary node
> + * @file_priv: DRM file
> + *
> + * Returns true if this is an open file of the primary node, i.e.
> + * &drm_file.minor of @file_priv is a primary minor.
> + *
> + * See also the :ref:`section on primary nodes and authentication
> + * <drm_primary_node>`.
> + */
> +static inline bool drm_is_primary_client(const struct drm_file *file_priv)
> +{
> +	return file_priv->minor->type == DRM_MINOR_PRIMARY;
> +}
> +
> +/**
> + * drm_is_render_client - is this an open file of the render node
> + * @file_priv: DRM file
> + *
> + * Returns true if this is an open file of the render node, i.e.
> + * &drm_file.minor of @file_priv is a render minor.
> + *
> + * See also the :ref:`section on render nodes <drm_render_node>`.
> + */
>  static inline bool drm_is_render_client(const struct drm_file *file_priv)
>  {
>  	return file_priv->minor->type == DRM_MINOR_RENDER;
>  }
>  
> +/**
> + * drm_is_control_client - is this an open file of the control node
> + * @file_priv: DRM file
> + *
> + * Control nodes are deprecated and in the process of getting removed from the
> + * DRM userspace API. Do not ever use!
> + */
>  static inline bool drm_is_control_client(const struct drm_file *file_priv)
>  {
>  	return file_priv->minor->type == DRM_MINOR_CONTROL;
>  }
>  
> -static inline bool drm_is_primary_client(const struct drm_file *file_priv)
> -{
> -	return file_priv->minor->type == DRM_MINOR_PRIMARY;
> -}
> -
>  int drm_open(struct inode *inode, struct file *filp);
>  ssize_t drm_read(struct file *filp, char __user *buffer,
>  		 size_t count, loff_t *offset);
> -- 
> 2.11.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 13/24] drm/msm: switch to postclose
  2017-03-08 14:12 ` [PATCH 13/24] drm/msm: switch to postclose Daniel Vetter
@ 2017-03-13 18:59   ` Sean Paul
  0 siblings, 0 replies; 72+ messages in thread
From: Sean Paul @ 2017-03-13 18:59 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: linux-arm-msm, Intel Graphics Development, freedreno,
	DRI Development, Daniel Vetter

On Wed, Mar 08, 2017 at 03:12:46PM +0100, Daniel Vetter wrote:
> I didn't spot anything that would require ordering here (well not
> anywhere else either), and I'm trying to unify at least modern drivers
> on one close hook.
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: linux-arm-msm@vger.kernel.org
> Cc: freedreno@lists.freedesktop.org
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

I think I've convinced myself that this is functionally equivalent (or at least
if Bad Things could happen with postclose, they would also be Bad Things with
preclose). So, fwiw:

Reviewed-by: Sean Paul <seanpaul@chromium.org>

> ---
>  drivers/gpu/drm/msm/msm_drv.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index 604331f3cf39..44774f02ef0e 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -540,7 +540,7 @@ static int msm_open(struct drm_device *dev, struct drm_file *file)
>  	return 0;
>  }
>  
> -static void msm_preclose(struct drm_device *dev, struct drm_file *file)
> +static void msm_postclose(struct drm_device *dev, struct drm_file *file)
>  {
>  	struct msm_drm_private *priv = dev->dev_private;
>  	struct msm_file_private *ctx = file->driver_priv;
> @@ -813,7 +813,7 @@ static struct drm_driver msm_driver = {
>  				DRIVER_ATOMIC |
>  				DRIVER_MODESET,
>  	.open               = msm_open,
> -	.preclose           = msm_preclose,
> +	.postclose           = msm_postclose,
>  	.lastclose          = msm_lastclose,
>  	.irq_handler        = msm_irq,
>  	.irq_preinstall     = msm_irq_preinstall,
> -- 
> 2.11.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 14/24] drm/nouveau: Merge pre/postclose hooks
       [not found]     ` <20170308141257.12119-15-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
@ 2017-03-13 19:07       ` Sean Paul
  0 siblings, 0 replies; 72+ messages in thread
From: Sean Paul @ 2017-03-13 19:07 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Ben Skeggs,
	DRI Development, nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Wed, Mar 08, 2017 at 03:12:47PM +0100, Daniel Vetter wrote:
> Again no apparent explanation for the split except hysterical raisins.
> Merging them also makes it a bit more obviuos what's going on wrt the
> runtime pm refdancing.

Yeah, holding the pm reference from preclose to postclose had me a little
nervous. However, it seems like the reference is just needed for
nouveau_abi16_fini() and nouveau_cli_fini(), as opposed to being needed while
drm_release() is active.

Reviewed-by: Sean Paul <seanpaul@chromium.org>

> 
> Cc: Ben Skeggs <bskeggs@redhat.com>
> Cc: nouveau@lists.freedesktop.org
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/nouveau/nouveau_drm.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index f0bb7606eb8b..0e26be017de7 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -881,7 +881,7 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
>  }
>  
>  static void
> -nouveau_drm_preclose(struct drm_device *dev, struct drm_file *fpriv)
> +nouveau_drm_postclose(struct drm_device *dev, struct drm_file *fpriv)
>  {
>  	struct nouveau_cli *cli = nouveau_cli(fpriv);
>  	struct nouveau_drm *drm = nouveau_drm(dev);
> @@ -897,12 +897,6 @@ nouveau_drm_preclose(struct drm_device *dev, struct drm_file *fpriv)
>  	list_del(&cli->head);
>  	mutex_unlock(&drm->client.mutex);
>  
> -}
> -
> -static void
> -nouveau_drm_postclose(struct drm_device *dev, struct drm_file *fpriv)
> -{
> -	struct nouveau_cli *cli = nouveau_cli(fpriv);
>  	nouveau_cli_fini(cli);
>  	kfree(cli);
>  	pm_runtime_mark_last_busy(dev->dev);
> @@ -974,7 +968,6 @@ driver_stub = {
>  	.load = nouveau_drm_load,
>  	.unload = nouveau_drm_unload,
>  	.open = nouveau_drm_open,
> -	.preclose = nouveau_drm_preclose,
>  	.postclose = nouveau_drm_postclose,
>  	.lastclose = nouveau_vga_lastclose,
>  
> -- 
> 2.11.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 16/24] drm/tegra: switch to postclose
       [not found]   ` <20170308141257.12119-17-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
@ 2017-03-13 19:10     ` Sean Paul
  0 siblings, 0 replies; 72+ messages in thread
From: Sean Paul @ 2017-03-13 19:10 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: DRI Development, linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	Intel Graphics Development, Daniel Vetter

On Wed, Mar 08, 2017 at 03:12:49PM +0100, Daniel Vetter wrote:
> I didn't spot anything that would require ordering here (well not
> anywhere else either), and I'm trying to unify at least modern drivers
> on one close hook.
> 
> Cc: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Signed-off-by: Daniel Vetter <daniel.vetter-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

Reviewed-by: Sean Paul <seanpaul-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>

> ---
>  drivers/gpu/drm/tegra/drm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
> index dba4e090d3df..3b419f9dbf4d 100644
> --- a/drivers/gpu/drm/tegra/drm.c
> +++ b/drivers/gpu/drm/tegra/drm.c
> @@ -804,7 +804,7 @@ static const struct file_operations tegra_drm_fops = {
>  	.llseek = noop_llseek,
>  };
>  
> -static void tegra_drm_preclose(struct drm_device *drm, struct drm_file *file)
> +static void tegra_drm_postclose(struct drm_device *drm, struct drm_file *file)
>  {
>  	struct tegra_drm_file *fpriv = file->driver_priv;
>  	struct tegra_drm_context *context, *tmp;
> @@ -868,7 +868,7 @@ static struct drm_driver tegra_drm_driver = {
>  	.load = tegra_drm_load,
>  	.unload = tegra_drm_unload,
>  	.open = tegra_drm_open,
> -	.preclose = tegra_drm_preclose,
> +	.postclose = tegra_drm_postclose,
>  	.lastclose = tegra_drm_lastclose,
>  
>  #if defined(CONFIG_DEBUG_FS)
> -- 
> 2.11.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 17/24] drm/vgem: switch to postclose
  2017-03-08 14:12 ` [PATCH 17/24] drm/vgem: " Daniel Vetter
@ 2017-03-13 19:11   ` Sean Paul
  2017-03-14 13:27     ` Daniel Vetter
  0 siblings, 1 reply; 72+ messages in thread
From: Sean Paul @ 2017-03-13 19:11 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

On Wed, Mar 08, 2017 at 03:12:50PM +0100, Daniel Vetter wrote:
> I didn't spot anything that would require ordering here (well not
> anywhere else either), and I'm trying to unify at least modern drivers
> on one close hook.
> 
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

Reviewed-by: Sean Paul <seanpaul@chromium.org>

> ---
>  drivers/gpu/drm/vgem/vgem_drv.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c
> index a1f42d125e6e..9fee38a942c4 100644
> --- a/drivers/gpu/drm/vgem/vgem_drv.c
> +++ b/drivers/gpu/drm/vgem/vgem_drv.c
> @@ -104,7 +104,7 @@ static int vgem_open(struct drm_device *dev, struct drm_file *file)
>  	return 0;
>  }
>  
> -static void vgem_preclose(struct drm_device *dev, struct drm_file *file)
> +static void vgem_postclose(struct drm_device *dev, struct drm_file *file)
>  {
>  	struct vgem_file *vfile = file->driver_priv;
>  
> @@ -303,7 +303,7 @@ static int vgem_prime_mmap(struct drm_gem_object *obj,
>  static struct drm_driver vgem_driver = {
>  	.driver_features		= DRIVER_GEM | DRIVER_PRIME,
>  	.open				= vgem_open,
> -	.preclose			= vgem_preclose,
> +	.postclose			= vgem_postclose,
>  	.gem_free_object_unlocked	= vgem_gem_free_object,
>  	.gem_vm_ops			= &vgem_gem_vm_ops,
>  	.ioctls				= vgem_ioctls,
> -- 
> 2.11.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [Intel-gfx] [PATCH 20/24] drm/exynos: Merge pre/postclose hooks
  2017-03-08 14:12 ` [PATCH 20/24] drm/exynos: " Daniel Vetter
@ 2017-03-13 19:18   ` Sean Paul
  2017-03-14 13:28     ` Daniel Vetter
  0 siblings, 1 reply; 72+ messages in thread
From: Sean Paul @ 2017-03-13 19:18 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Intel Graphics Development, Seung-Woo Kim, DRI Development,
	Kyungmin Park, Daniel Vetter

On Wed, Mar 08, 2017 at 03:12:53PM +0100, Daniel Vetter wrote:
> Again no apparent explanation for the split except hysterical raisins.
> Merging them also makes it a bit more obviuos what's going on wrt the
> runtime pm refdancing.

Commit message copypasta.

The code is 

Reviewed-by: Sean Paul <seanpaul@chromium.org>

> 
> Cc: Inki Dae <inki.dae@samsung.com>
> Cc: Joonyoung Shim <jy0922.shim@samsung.com>
> Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
> Cc: Kyungmin Park <kyungmin.park@samsung.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/exynos/exynos_drm_drv.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> index b4522f67b3cb..180e3c9884e5 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> @@ -194,14 +194,9 @@ static int exynos_drm_open(struct drm_device *dev, struct drm_file *file)
>  	return ret;
>  }
>  
> -static void exynos_drm_preclose(struct drm_device *dev,
> -					struct drm_file *file)
> -{
> -	exynos_drm_subdrv_close(dev, file);
> -}
> -
>  static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file)
>  {
> +	exynos_drm_subdrv_close(dev, file);
>  	kfree(file->driver_priv);
>  	file->driver_priv = NULL;
>  }
> @@ -259,7 +254,6 @@ static struct drm_driver exynos_drm_driver = {
>  	.load			= exynos_drm_load,
>  	.unload			= exynos_drm_unload,
>  	.open			= exynos_drm_open,
> -	.preclose		= exynos_drm_preclose,
>  	.lastclose		= exynos_drm_lastclose,
>  	.postclose		= exynos_drm_postclose,
>  	.gem_free_object_unlocked = exynos_drm_gem_free_object,
> -- 
> 2.11.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 21/24] drm/msm: Simplify vblank event delivery
  2017-03-08 14:12 ` [PATCH 21/24] drm/msm: Simplify vblank event delivery Daniel Vetter
@ 2017-03-13 19:26   ` Sean Paul
  0 siblings, 0 replies; 72+ messages in thread
From: Sean Paul @ 2017-03-13 19:26 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: linux-arm-msm, Intel Graphics Development, freedreno,
	DRI Development, Daniel Vetter

On Wed, Mar 08, 2017 at 03:12:54PM +0100, Daniel Vetter wrote:
> The core takes care of handling the send_event vs. close() issues, we
> can remove that driver code.
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: linux-arm-msm@vger.kernel.org
> Cc: freedreno@lists.freedesktop.org
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c | 12 +++---------
>  drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c | 12 +++---------
>  2 files changed, 6 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
> index 1c29618f4ddb..f29194a74a19 100644
> --- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
> +++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
> @@ -114,15 +114,9 @@ static void complete_flip(struct drm_crtc *crtc, struct drm_file *file)

file unused now?

>  	spin_lock_irqsave(&dev->event_lock, flags);
>  	event = mdp4_crtc->event;
>  	if (event) {
> -		/* if regular vblank case (!file) or if cancel-flip from
> -		 * preclose on file that requested flip, then send the
> -		 * event:
> -		 */
> -		if (!file || (event->base.file_priv == file)) {
> -			mdp4_crtc->event = NULL;
> -			DBG("%s: send event: %p", mdp4_crtc->name, event);
> -			drm_crtc_send_vblank_event(crtc, event);
> -		}
> +		mdp4_crtc->event = NULL;
> +		DBG("%s: send event: %p", mdp4_crtc->name, event);
> +		drm_crtc_send_vblank_event(crtc, event);
>  	}
>  	spin_unlock_irqrestore(&dev->event_lock, flags);
>  }
> diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
> index d0c8b38b96ce..87a19e0c0e67 100644
> --- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
> +++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
> @@ -138,15 +138,9 @@ static void complete_flip(struct drm_crtc *crtc, struct drm_file *file)
>  	spin_lock_irqsave(&dev->event_lock, flags);
>  	event = mdp5_crtc->event;
>  	if (event) {
> -		/* if regular vblank case (!file) or if cancel-flip from
> -		 * preclose on file that requested flip, then send the
> -		 * event:
> -		 */
> -		if (!file || (event->base.file_priv == file)) {
> -			mdp5_crtc->event = NULL;
> -			DBG("%s: send event: %p", crtc->name, event);
> -			drm_crtc_send_vblank_event(crtc, event);
> -		}
> +		mdp5_crtc->event = NULL;
> +		DBG("%s: send event: %p", crtc->name, event);
> +		drm_crtc_send_vblank_event(crtc, event);
>  	}
>  	spin_unlock_irqrestore(&dev->event_lock, flags);
>  
> -- 
> 2.11.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [Intel-gfx] [PATCH 22/24] drm: Nerf the preclose callback for modern drivers
  2017-03-08 14:12 ` [PATCH 22/24] drm: Nerf the preclose callback for modern drivers Daniel Vetter
  2017-03-09 10:48   ` Daniel Vetter
@ 2017-03-13 19:29   ` Sean Paul
  2017-03-14 13:50     ` Daniel Vetter
  1 sibling, 1 reply; 72+ messages in thread
From: Sean Paul @ 2017-03-13 19:29 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

On Wed, Mar 08, 2017 at 03:12:55PM +0100, Daniel Vetter wrote:
> With all drivers converted there's only legacy dri1 drivers using it.
> Not going to touch those, instead just hide it like we've done with
> other dri1 driver hooks like firstopen.
> 
> In all this I didn't find any real reason why we'd needed 2 hooks, and
> having symmetry between open and close just appeases my OCD better.
> Yeah, someone else could do an s/postclose/close/, but that's for
> someone who understands cocci. And maybe after this series is reviewed
> and landed, to avoid patch-regen churn.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/drm_file.c |  8 ++++----
>  include/drm/drm_drv.h      | 23 ++---------------------
>  2 files changed, 6 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> index a8813a1115dc..f8483fc6d3d7 100644
> --- a/drivers/gpu/drm/drm_file.c
> +++ b/drivers/gpu/drm/drm_file.c
> @@ -350,9 +350,8 @@ void drm_lastclose(struct drm_device * dev)
>   *
>   * This function must be used by drivers as their &file_operations.release
>   * method. It frees any resources associated with the open file, and calls the
> - * &drm_driver.preclose and &drm_driver.lastclose driver callbacks. If this is
> - * the last open file for the DRM device also proceeds to call the
> - * &drm_driver.lastclose driver callback.
> + * &drm_driver.lastclose driver callback. If this is the last open file for the

s/lastclose/postclose/

Once that's fixed,

Reviewed-by: Sean Paul <seanpaul@chromium.org>

> + * DRM device also proceeds to call the &drm_driver.lastclose driver callback.
>   *
>   * RETURNS:
>   *
> @@ -372,7 +371,8 @@ int drm_release(struct inode *inode, struct file *filp)
>  	list_del(&file_priv->lhead);
>  	mutex_unlock(&dev->filelist_mutex);
>  
> -	if (dev->driver->preclose)
> +	if (drm_core_check_feature(dev, DRIVER_LEGACY) &&
> +	    dev->driver->preclose)
>  		dev->driver->preclose(dev, file_priv);
>  
>  	/* ========================================================
> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> index 8f900fb30275..fde343e0d581 100644
> --- a/include/drm/drm_drv.h
> +++ b/include/drm/drm_drv.h
> @@ -104,23 +104,6 @@ struct drm_driver {
>  	int (*open) (struct drm_device *, struct drm_file *);
>  
>  	/**
> -	 * @preclose:
> -	 *
> -	 * One of the driver callbacks when a new &struct drm_file is closed.
> -	 * Useful for tearing down driver-private data structures allocated in
> -	 * @open like buffer allocators, execution contexts or similar things.
> -	 *
> -	 * Since the display/modeset side of DRM can only be owned by exactly
> -	 * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
> -	 * there should never be a need to tear down any modeset related
> -	 * resources in this callback. Doing so would be a driver design bug.
> -	 *
> -	 * FIXME: It is not really clear why there's both @preclose and
> -	 * @postclose. Without a really good reason, use @postclose only.
> -	 */
> -	void (*preclose) (struct drm_device *, struct drm_file *file_priv);
> -
> -	/**
>  	 * @postclose:
>  	 *
>  	 * One of the driver callbacks when a new &struct drm_file is closed.
> @@ -131,9 +114,6 @@ struct drm_driver {
>  	 * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
>  	 * there should never be a need to tear down any modeset related
>  	 * resources in this callback. Doing so would be a driver design bug.
> -	 *
> -	 * FIXME: It is not really clear why there's both @preclose and
> -	 * @postclose. Without a really good reason, use @postclose only.
>  	 */
>  	void (*postclose) (struct drm_device *, struct drm_file *);
>  
> @@ -150,7 +130,7 @@ struct drm_driver {
>  	 * state changes, e.g. in conjunction with the :ref:`vga_switcheroo`
>  	 * infrastructure.
>  	 *
> -	 * This is called after @preclose and @postclose have been called.
> +	 * This is called after @postclose hook has been called.
>  	 *
>  	 * NOTE:
>  	 *
> @@ -516,6 +496,7 @@ struct drm_driver {
>  	/* List of devices hanging off this driver with stealth attach. */
>  	struct list_head legacy_dev_list;
>  	int (*firstopen) (struct drm_device *);
> +	void (*preclose) (struct drm_device *, struct drm_file *file_priv);
>  	int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
>  	int (*dma_quiescent) (struct drm_device *);
>  	int (*context_dtor) (struct drm_device *dev, int context);
> -- 
> 2.11.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [Intel-gfx] [PATCH 23/24] drm: Create DEFINE_DRM_GEM_CMA_FOPS and roll it out to drivers
  2017-03-08 14:12 ` [PATCH 23/24] drm: Create DEFINE_DRM_GEM_CMA_FOPS and roll it out to drivers Daniel Vetter
  2017-03-13 17:11   ` Liviu Dudau
@ 2017-03-13 19:31   ` Sean Paul
  2017-03-13 19:33     ` Sean Paul
  1 sibling, 1 reply; 72+ messages in thread
From: Sean Paul @ 2017-03-13 19:31 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

On Wed, Mar 08, 2017 at 03:12:56PM +0100, Daniel Vetter wrote:
> Less code ftw.
> 
> This converts all drivers except the tinydrm helper module. That one
> needs more work, since it gets the THIS_MODULE reference from
> tinydrm.ko instead of the actual driver module like it should.
> Probably needs a similar trick like I used here with generating the
> entire struct with a macro.
> 
> Cc: Noralf Trønnes <noralf@tronnes.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/arm/hdlcd_drv.c                 | 12 +-----------
>  drivers/gpu/drm/arm/malidp_drv.c                | 12 +-----------
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c    | 12 +-----------
>  drivers/gpu/drm/drm_file.c                      |  3 +++
>  drivers/gpu/drm/drm_gem_cma_helper.c            |  3 +++
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c       | 12 +-----------
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 12 +-----------
>  drivers/gpu/drm/imx/imx-drm-core.c              | 11 +----------
>  drivers/gpu/drm/meson/meson_drv.c               | 14 +------------
>  drivers/gpu/drm/mxsfb/mxsfb_drv.c               | 14 +------------
>  drivers/gpu/drm/rcar-du/rcar_du_drv.c           | 12 +-----------
>  drivers/gpu/drm/shmobile/shmob_drm_drv.c        | 12 +-----------
>  drivers/gpu/drm/sti/sti_drv.c                   | 11 +----------
>  drivers/gpu/drm/sun4i/sun4i_drv.c               | 12 +-----------
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c             | 12 +-----------
>  drivers/gpu/drm/zte/zx_drm_drv.c                | 14 +------------
>  include/drm/drm_gem_cma_helper.h                | 26 +++++++++++++++++++++++++
>  17 files changed, 46 insertions(+), 158 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index 4840dc277339..0e74880b5e94 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -239,17 +239,7 @@ static int hdlcd_debugfs_init(struct drm_minor *minor)
>  }
>  #endif
>  
> -static const struct file_operations fops = {
> -	.owner		= THIS_MODULE,
> -	.open		= drm_open,
> -	.release	= drm_release,
> -	.unlocked_ioctl	= drm_ioctl,
> -	.compat_ioctl	= drm_compat_ioctl,
> -	.poll		= drm_poll,
> -	.read		= drm_read,
> -	.llseek		= noop_llseek,
> -	.mmap		= drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(fops);
>  
>  static struct drm_driver hdlcd_driver = {
>  	.driver_features = DRIVER_HAVE_IRQ | DRIVER_GEM |
> diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
> index a9608a2e5a29..ea2546f766c2 100644
> --- a/drivers/gpu/drm/arm/malidp_drv.c
> +++ b/drivers/gpu/drm/arm/malidp_drv.c
> @@ -178,17 +178,7 @@ static void malidp_lastclose(struct drm_device *drm)
>  	drm_fbdev_cma_restore_mode(malidp->fbdev);
>  }
>  
> -static const struct file_operations fops = {
> -	.owner = THIS_MODULE,
> -	.open = drm_open,
> -	.release = drm_release,
> -	.unlocked_ioctl = drm_ioctl,
> -	.compat_ioctl = drm_compat_ioctl,
> -	.poll = drm_poll,
> -	.read = drm_read,
> -	.llseek = noop_llseek,
> -	.mmap = drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(fops);
>  
>  static struct drm_driver malidp_driver = {
>  	.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC |
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> index 970bd87d7cce..178acbf5f6c5 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> @@ -724,17 +724,7 @@ static void atmel_hlcdc_dc_irq_uninstall(struct drm_device *dev)
>  	regmap_read(dc->hlcdc->regmap, ATMEL_HLCDC_ISR, &isr);
>  }
>  
> -static const struct file_operations fops = {
> -	.owner              = THIS_MODULE,
> -	.open               = drm_open,
> -	.release            = drm_release,
> -	.unlocked_ioctl     = drm_ioctl,
> -	.compat_ioctl       = drm_compat_ioctl,
> -	.poll               = drm_poll,
> -	.read               = drm_read,
> -	.llseek             = no_llseek,
> -	.mmap               = drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(fops);
>  
>  static struct drm_driver atmel_hlcdc_dc_driver = {
>  	.driver_features = DRIVER_HAVE_IRQ | DRIVER_GEM |
> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> index f8483fc6d3d7..260a83563976 100644
> --- a/drivers/gpu/drm/drm_file.c
> +++ b/drivers/gpu/drm/drm_file.c
> @@ -89,6 +89,9 @@ DEFINE_MUTEX(drm_global_mutex);
>   *             .mmap = drm_gem_mmap,
>   *     };
>   *
> + * For CMA based drivers there is the DEFINE_DRM_GEM_CMA_FOPS() macro to make
> + * this simpler.
> + *
>   * FIXME: We should have a macro for this (and the CMA version) so that drivers

s_(and the CMA version)__

Reviewed-by: Sean Paul <seanpaul@chromium.org>

>   * don't have to repeat it all the time.
>   */
> diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
> index bb968e76779b..bc28e7575254 100644
> --- a/drivers/gpu/drm/drm_gem_cma_helper.c
> +++ b/drivers/gpu/drm/drm_gem_cma_helper.c
> @@ -338,6 +338,9 @@ static int drm_gem_cma_mmap_obj(struct drm_gem_cma_object *cma_obj,
>   * as their ->mmap() handler in the DRM device file's file_operations
>   * structure.
>   *
> + * Instead of directly referencing this function, drivers should use the
> + * DEFINE_DRM_GEM_CMA_FOPS().macro.
> + *
>   * Returns:
>   * 0 on success or a negative error code on failure.
>   */
> diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> index b5391c124c64..6e00f4b267f1 100644
> --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> @@ -161,17 +161,7 @@ static void fsl_dcu_drm_lastclose(struct drm_device *dev)
>  	drm_fbdev_cma_restore_mode(fsl_dev->fbdev);
>  }
>  
> -static const struct file_operations fsl_dcu_drm_fops = {
> -	.owner		= THIS_MODULE,
> -	.open		= drm_open,
> -	.release	= drm_release,
> -	.unlocked_ioctl	= drm_ioctl,
> -	.compat_ioctl	= drm_compat_ioctl,
> -	.poll		= drm_poll,
> -	.read		= drm_read,
> -	.llseek		= no_llseek,
> -	.mmap		= drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(fsl_dcu_drm_fops);
>  
>  static struct drm_driver fsl_dcu_drm_driver = {
>  	.driver_features	= DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET
> diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> index 7ec93aec7e88..df4f50713e54 100644
> --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> @@ -146,17 +146,7 @@ static int kirin_drm_kms_init(struct drm_device *dev)
>  	return ret;
>  }
>  
> -static const struct file_operations kirin_drm_fops = {
> -	.owner		= THIS_MODULE,
> -	.open		= drm_open,
> -	.release	= drm_release,
> -	.unlocked_ioctl	= drm_ioctl,
> -	.compat_ioctl	= drm_compat_ioctl,
> -	.poll		= drm_poll,
> -	.read		= drm_read,
> -	.llseek		= no_llseek,
> -	.mmap		= drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(kirin_drm_fops);
>  
>  static int kirin_gem_cma_dumb_create(struct drm_file *file,
>  				     struct drm_device *dev,
> diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
> index 4b7b92a7bcf7..70736615983c 100644
> --- a/drivers/gpu/drm/imx/imx-drm-core.c
> +++ b/drivers/gpu/drm/imx/imx-drm-core.c
> @@ -57,16 +57,7 @@ static void imx_drm_driver_lastclose(struct drm_device *drm)
>  	drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
>  }
>  
> -static const struct file_operations imx_drm_driver_fops = {
> -	.owner = THIS_MODULE,
> -	.open = drm_open,
> -	.release = drm_release,
> -	.unlocked_ioctl = drm_ioctl,
> -	.mmap = drm_gem_cma_mmap,
> -	.poll = drm_poll,
> -	.read = drm_read,
> -	.llseek = noop_llseek,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(imx_drm_driver_fops);
>  
>  void imx_drm_connector_destroy(struct drm_connector *connector)
>  {
> diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
> index 8d17d0e59cbe..bc562a07847b 100644
> --- a/drivers/gpu/drm/meson/meson_drv.c
> +++ b/drivers/gpu/drm/meson/meson_drv.c
> @@ -91,19 +91,7 @@ static irqreturn_t meson_irq(int irq, void *arg)
>  	return IRQ_HANDLED;
>  }
>  
> -static const struct file_operations fops = {
> -	.owner		= THIS_MODULE,
> -	.open		= drm_open,
> -	.release	= drm_release,
> -	.unlocked_ioctl	= drm_ioctl,
> -#ifdef CONFIG_COMPAT
> -	.compat_ioctl	= drm_compat_ioctl,
> -#endif
> -	.poll		= drm_poll,
> -	.read		= drm_read,
> -	.llseek		= no_llseek,
> -	.mmap		= drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(fops);
>  
>  static struct drm_driver meson_driver = {
>  	.driver_features	= DRIVER_HAVE_IRQ | DRIVER_GEM |
> diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> index a4633ada8429..5ac712325c75 100644
> --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> @@ -319,19 +319,7 @@ static irqreturn_t mxsfb_irq_handler(int irq, void *data)
>  	return IRQ_HANDLED;
>  }
>  
> -static const struct file_operations fops = {
> -	.owner		= THIS_MODULE,
> -	.open		= drm_open,
> -	.release	= drm_release,
> -	.unlocked_ioctl	= drm_ioctl,
> -#ifdef CONFIG_COMPAT
> -	.compat_ioctl	= drm_compat_ioctl,
> -#endif
> -	.poll		= drm_poll,
> -	.read		= drm_read,
> -	.llseek		= noop_llseek,
> -	.mmap		= drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(fops);
>  
>  static struct drm_driver mxsfb_driver = {
>  	.driver_features	= DRIVER_GEM | DRIVER_MODESET |
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> index 192346d4fb34..62a3b3e32153 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> @@ -226,17 +226,7 @@ static void rcar_du_lastclose(struct drm_device *dev)
>  	drm_fbdev_cma_restore_mode(rcdu->fbdev);
>  }
>  
> -static const struct file_operations rcar_du_fops = {
> -	.owner		= THIS_MODULE,
> -	.open		= drm_open,
> -	.release	= drm_release,
> -	.unlocked_ioctl	= drm_ioctl,
> -	.compat_ioctl	= drm_compat_ioctl,
> -	.poll		= drm_poll,
> -	.read		= drm_read,
> -	.llseek		= no_llseek,
> -	.mmap		= drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(rcar_du_fops);
>  
>  static struct drm_driver rcar_du_driver = {
>  	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME
> diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> index 34fefa0ba0f0..75f2e5e6d7fb 100644
> --- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> +++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> @@ -221,17 +221,7 @@ static irqreturn_t shmob_drm_irq(int irq, void *arg)
>  	return IRQ_HANDLED;
>  }
>  
> -static const struct file_operations shmob_drm_fops = {
> -	.owner		= THIS_MODULE,
> -	.open		= drm_open,
> -	.release	= drm_release,
> -	.unlocked_ioctl	= drm_ioctl,
> -	.compat_ioctl	= drm_compat_ioctl,
> -	.poll		= drm_poll,
> -	.read		= drm_read,
> -	.llseek		= no_llseek,
> -	.mmap		= drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(shmob_drm_fops);
>  
>  static struct drm_driver shmob_drm_driver = {
>  	.driver_features	= DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 3b15c2cb2306..23da9bc4666a 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -167,16 +167,7 @@ static void sti_mode_config_init(struct drm_device *dev)
>  	dev->mode_config.funcs = &sti_mode_config_funcs;
>  }
>  
> -static const struct file_operations sti_driver_fops = {
> -	.owner = THIS_MODULE,
> -	.open = drm_open,
> -	.mmap = drm_gem_cma_mmap,
> -	.poll = drm_poll,
> -	.read = drm_read,
> -	.unlocked_ioctl = drm_ioctl,
> -	.compat_ioctl = drm_compat_ioctl,
> -	.release = drm_release,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(sti_driver_fops);
>  
>  static struct drm_driver sti_driver = {
>  	.driver_features = DRIVER_MODESET |
> diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
> index 9ccf7c4deb6d..329ea56106a5 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
> @@ -25,17 +25,7 @@
>  #include "sun4i_framebuffer.h"
>  #include "sun4i_layer.h"
>  
> -static const struct file_operations sun4i_drv_fops = {
> -	.owner		= THIS_MODULE,
> -	.open		= drm_open,
> -	.release	= drm_release,
> -	.unlocked_ioctl	= drm_ioctl,
> -	.compat_ioctl	= drm_compat_ioctl,
> -	.poll		= drm_poll,
> -	.read		= drm_read,
> -	.llseek		= no_llseek,
> -	.mmap		= drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(sun4i_drv_fops);
>  
>  static struct drm_driver sun4i_drv_driver = {
>  	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC,
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> index 81d80a2ffeb1..480411c2e802 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> @@ -530,17 +530,7 @@ static int tilcdc_debugfs_init(struct drm_minor *minor)
>  }
>  #endif
>  
> -static const struct file_operations fops = {
> -	.owner              = THIS_MODULE,
> -	.open               = drm_open,
> -	.release            = drm_release,
> -	.unlocked_ioctl     = drm_ioctl,
> -	.compat_ioctl       = drm_compat_ioctl,
> -	.poll               = drm_poll,
> -	.read               = drm_read,
> -	.llseek             = no_llseek,
> -	.mmap               = drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(fops);
>  
>  static struct drm_driver tilcdc_driver = {
>  	.driver_features    = (DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET |
> diff --git a/drivers/gpu/drm/zte/zx_drm_drv.c b/drivers/gpu/drm/zte/zx_drm_drv.c
> index b24a70ba4b83..614e854f6be5 100644
> --- a/drivers/gpu/drm/zte/zx_drm_drv.c
> +++ b/drivers/gpu/drm/zte/zx_drm_drv.c
> @@ -53,19 +53,7 @@ static void zx_drm_lastclose(struct drm_device *drm)
>  	drm_fbdev_cma_restore_mode(priv->fbdev);
>  }
>  
> -static const struct file_operations zx_drm_fops = {
> -	.owner = THIS_MODULE,
> -	.open = drm_open,
> -	.release = drm_release,
> -	.unlocked_ioctl = drm_ioctl,
> -#ifdef CONFIG_COMPAT
> -	.compat_ioctl = drm_compat_ioctl,
> -#endif
> -	.poll = drm_poll,
> -	.read = drm_read,
> -	.llseek = noop_llseek,
> -	.mmap = drm_gem_cma_mmap,
> -};
> +DEFINE_DRM_GEM_CMA_FOPS(zx_drm_fops);
>  
>  static struct drm_driver zx_drm_driver = {
>  	.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
> diff --git a/include/drm/drm_gem_cma_helper.h b/include/drm/drm_gem_cma_helper.h
> index 2abcd5190cc1..f962d33667cf 100644
> --- a/include/drm/drm_gem_cma_helper.h
> +++ b/include/drm/drm_gem_cma_helper.h
> @@ -26,6 +26,32 @@ to_drm_gem_cma_obj(struct drm_gem_object *gem_obj)
>  	return container_of(gem_obj, struct drm_gem_cma_object, base);
>  }
>  
> +/**
> + * DEFINE_DRM_GEM_CMA_FOPS() - macro to generate file operations for CMA drivers
> + * @name: name for the generated structure
> + *
> + * This macro autogenerates a suitable &struct file_operations for CMA based
> + * drivers, which can be assigned to &drm_driver.fops. Note that this structure
> + * cannot be shared between drivers, because it contains a reference to the
> + * current module using THIS_MODULE.
> + *
> + * Note that the declaration is already marked as static - if you need a
> + * non-static version of this you're probably doing it wrong and will break the
> + * THIS_MODULE reference by accident.
> + */
> +#define DEFINE_DRM_GEM_CMA_FOPS(name) \
> +	static const struct file_operations name = {\
> +		.owner		= THIS_MODULE,\
> +		.open		= drm_open,\
> +		.release	= drm_release,\
> +		.unlocked_ioctl	= drm_ioctl,\
> +		.compat_ioctl	= drm_compat_ioctl,\
> +		.poll		= drm_poll,\
> +		.read		= drm_read,\
> +		.llseek		= noop_llseek,\
> +		.mmap		= drm_gem_cma_mmap,\
> +	}
> +
>  /* free GEM object */
>  void drm_gem_cma_free_object(struct drm_gem_object *gem_obj);
>  
> -- 
> 2.11.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [Intel-gfx] [PATCH 23/24] drm: Create DEFINE_DRM_GEM_CMA_FOPS and roll it out to drivers
  2017-03-13 19:31   ` [Intel-gfx] " Sean Paul
@ 2017-03-13 19:33     ` Sean Paul
  0 siblings, 0 replies; 72+ messages in thread
From: Sean Paul @ 2017-03-13 19:33 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

On Mon, Mar 13, 2017 at 03:31:40PM -0400, Sean Paul wrote:
> On Wed, Mar 08, 2017 at 03:12:56PM +0100, Daniel Vetter wrote:
> > Less code ftw.
> > 
> > This converts all drivers except the tinydrm helper module. That one
> > needs more work, since it gets the THIS_MODULE reference from
> > tinydrm.ko instead of the actual driver module like it should.
> > Probably needs a similar trick like I used here with generating the
> > entire struct with a macro.
> > 
> > Cc: Noralf Trønnes <noralf@tronnes.org>
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > ---
> >  drivers/gpu/drm/arm/hdlcd_drv.c                 | 12 +-----------
> >  drivers/gpu/drm/arm/malidp_drv.c                | 12 +-----------
> >  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c    | 12 +-----------
> >  drivers/gpu/drm/drm_file.c                      |  3 +++
> >  drivers/gpu/drm/drm_gem_cma_helper.c            |  3 +++
> >  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c       | 12 +-----------
> >  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 12 +-----------
> >  drivers/gpu/drm/imx/imx-drm-core.c              | 11 +----------
> >  drivers/gpu/drm/meson/meson_drv.c               | 14 +------------
> >  drivers/gpu/drm/mxsfb/mxsfb_drv.c               | 14 +------------
> >  drivers/gpu/drm/rcar-du/rcar_du_drv.c           | 12 +-----------
> >  drivers/gpu/drm/shmobile/shmob_drm_drv.c        | 12 +-----------
> >  drivers/gpu/drm/sti/sti_drv.c                   | 11 +----------
> >  drivers/gpu/drm/sun4i/sun4i_drv.c               | 12 +-----------
> >  drivers/gpu/drm/tilcdc/tilcdc_drv.c             | 12 +-----------
> >  drivers/gpu/drm/zte/zx_drm_drv.c                | 14 +------------
> >  include/drm/drm_gem_cma_helper.h                | 26 +++++++++++++++++++++++++
> >  17 files changed, 46 insertions(+), 158 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> > index 4840dc277339..0e74880b5e94 100644
> > --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> > +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> > @@ -239,17 +239,7 @@ static int hdlcd_debugfs_init(struct drm_minor *minor)
> >  }
> >  #endif
> >  
> > -static const struct file_operations fops = {
> > -	.owner		= THIS_MODULE,
> > -	.open		= drm_open,
> > -	.release	= drm_release,
> > -	.unlocked_ioctl	= drm_ioctl,
> > -	.compat_ioctl	= drm_compat_ioctl,
> > -	.poll		= drm_poll,
> > -	.read		= drm_read,
> > -	.llseek		= noop_llseek,
> > -	.mmap		= drm_gem_cma_mmap,
> > -};
> > +DEFINE_DRM_GEM_CMA_FOPS(fops);
> >  
> >  static struct drm_driver hdlcd_driver = {
> >  	.driver_features = DRIVER_HAVE_IRQ | DRIVER_GEM |
> > diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
> > index a9608a2e5a29..ea2546f766c2 100644
> > --- a/drivers/gpu/drm/arm/malidp_drv.c
> > +++ b/drivers/gpu/drm/arm/malidp_drv.c
> > @@ -178,17 +178,7 @@ static void malidp_lastclose(struct drm_device *drm)
> >  	drm_fbdev_cma_restore_mode(malidp->fbdev);
> >  }
> >  
> > -static const struct file_operations fops = {
> > -	.owner = THIS_MODULE,
> > -	.open = drm_open,
> > -	.release = drm_release,
> > -	.unlocked_ioctl = drm_ioctl,
> > -	.compat_ioctl = drm_compat_ioctl,
> > -	.poll = drm_poll,
> > -	.read = drm_read,
> > -	.llseek = noop_llseek,
> > -	.mmap = drm_gem_cma_mmap,
> > -};
> > +DEFINE_DRM_GEM_CMA_FOPS(fops);
> >  
> >  static struct drm_driver malidp_driver = {
> >  	.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC |
> > diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> > index 970bd87d7cce..178acbf5f6c5 100644
> > --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> > +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> > @@ -724,17 +724,7 @@ static void atmel_hlcdc_dc_irq_uninstall(struct drm_device *dev)
> >  	regmap_read(dc->hlcdc->regmap, ATMEL_HLCDC_ISR, &isr);
> >  }
> >  
> > -static const struct file_operations fops = {
> > -	.owner              = THIS_MODULE,
> > -	.open               = drm_open,
> > -	.release            = drm_release,
> > -	.unlocked_ioctl     = drm_ioctl,
> > -	.compat_ioctl       = drm_compat_ioctl,
> > -	.poll               = drm_poll,
> > -	.read               = drm_read,
> > -	.llseek             = no_llseek,
> > -	.mmap               = drm_gem_cma_mmap,
> > -};
> > +DEFINE_DRM_GEM_CMA_FOPS(fops);
> >  
> >  static struct drm_driver atmel_hlcdc_dc_driver = {
> >  	.driver_features = DRIVER_HAVE_IRQ | DRIVER_GEM |
> > diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> > index f8483fc6d3d7..260a83563976 100644
> > --- a/drivers/gpu/drm/drm_file.c
> > +++ b/drivers/gpu/drm/drm_file.c
> > @@ -89,6 +89,9 @@ DEFINE_MUTEX(drm_global_mutex);
> >   *             .mmap = drm_gem_mmap,
> >   *     };
> >   *
> > + * For CMA based drivers there is the DEFINE_DRM_GEM_CMA_FOPS() macro to make
> > + * this simpler.
> > + *
> >   * FIXME: We should have a macro for this (and the CMA version) so that drivers
> 
> s_(and the CMA version)__

Whoops, just saw 24/24 removes this entirely. ¯\_(ツ)_/¯

> 
> Reviewed-by: Sean Paul <seanpaul@chromium.org>
> 
> >   * don't have to repeat it all the time.
> >   */
> > diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
> > index bb968e76779b..bc28e7575254 100644
> > --- a/drivers/gpu/drm/drm_gem_cma_helper.c
> > +++ b/drivers/gpu/drm/drm_gem_cma_helper.c
> > @@ -338,6 +338,9 @@ static int drm_gem_cma_mmap_obj(struct drm_gem_cma_object *cma_obj,
> >   * as their ->mmap() handler in the DRM device file's file_operations
> >   * structure.
> >   *
> > + * Instead of directly referencing this function, drivers should use the
> > + * DEFINE_DRM_GEM_CMA_FOPS().macro.
> > + *
> >   * Returns:
> >   * 0 on success or a negative error code on failure.
> >   */
> > diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> > index b5391c124c64..6e00f4b267f1 100644
> > --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> > +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> > @@ -161,17 +161,7 @@ static void fsl_dcu_drm_lastclose(struct drm_device *dev)
> >  	drm_fbdev_cma_restore_mode(fsl_dev->fbdev);
> >  }
> >  
> > -static const struct file_operations fsl_dcu_drm_fops = {
> > -	.owner		= THIS_MODULE,
> > -	.open		= drm_open,
> > -	.release	= drm_release,
> > -	.unlocked_ioctl	= drm_ioctl,
> > -	.compat_ioctl	= drm_compat_ioctl,
> > -	.poll		= drm_poll,
> > -	.read		= drm_read,
> > -	.llseek		= no_llseek,
> > -	.mmap		= drm_gem_cma_mmap,
> > -};
> > +DEFINE_DRM_GEM_CMA_FOPS(fsl_dcu_drm_fops);
> >  
> >  static struct drm_driver fsl_dcu_drm_driver = {
> >  	.driver_features	= DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET
> > diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> > index 7ec93aec7e88..df4f50713e54 100644
> > --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> > +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> > @@ -146,17 +146,7 @@ static int kirin_drm_kms_init(struct drm_device *dev)
> >  	return ret;
> >  }
> >  
> > -static const struct file_operations kirin_drm_fops = {
> > -	.owner		= THIS_MODULE,
> > -	.open		= drm_open,
> > -	.release	= drm_release,
> > -	.unlocked_ioctl	= drm_ioctl,
> > -	.compat_ioctl	= drm_compat_ioctl,
> > -	.poll		= drm_poll,
> > -	.read		= drm_read,
> > -	.llseek		= no_llseek,
> > -	.mmap		= drm_gem_cma_mmap,
> > -};
> > +DEFINE_DRM_GEM_CMA_FOPS(kirin_drm_fops);
> >  
> >  static int kirin_gem_cma_dumb_create(struct drm_file *file,
> >  				     struct drm_device *dev,
> > diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
> > index 4b7b92a7bcf7..70736615983c 100644
> > --- a/drivers/gpu/drm/imx/imx-drm-core.c
> > +++ b/drivers/gpu/drm/imx/imx-drm-core.c
> > @@ -57,16 +57,7 @@ static void imx_drm_driver_lastclose(struct drm_device *drm)
> >  	drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
> >  }
> >  
> > -static const struct file_operations imx_drm_driver_fops = {
> > -	.owner = THIS_MODULE,
> > -	.open = drm_open,
> > -	.release = drm_release,
> > -	.unlocked_ioctl = drm_ioctl,
> > -	.mmap = drm_gem_cma_mmap,
> > -	.poll = drm_poll,
> > -	.read = drm_read,
> > -	.llseek = noop_llseek,
> > -};
> > +DEFINE_DRM_GEM_CMA_FOPS(imx_drm_driver_fops);
> >  
> >  void imx_drm_connector_destroy(struct drm_connector *connector)
> >  {
> > diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
> > index 8d17d0e59cbe..bc562a07847b 100644
> > --- a/drivers/gpu/drm/meson/meson_drv.c
> > +++ b/drivers/gpu/drm/meson/meson_drv.c
> > @@ -91,19 +91,7 @@ static irqreturn_t meson_irq(int irq, void *arg)
> >  	return IRQ_HANDLED;
> >  }
> >  
> > -static const struct file_operations fops = {
> > -	.owner		= THIS_MODULE,
> > -	.open		= drm_open,
> > -	.release	= drm_release,
> > -	.unlocked_ioctl	= drm_ioctl,
> > -#ifdef CONFIG_COMPAT
> > -	.compat_ioctl	= drm_compat_ioctl,
> > -#endif
> > -	.poll		= drm_poll,
> > -	.read		= drm_read,
> > -	.llseek		= no_llseek,
> > -	.mmap		= drm_gem_cma_mmap,
> > -};
> > +DEFINE_DRM_GEM_CMA_FOPS(fops);
> >  
> >  static struct drm_driver meson_driver = {
> >  	.driver_features	= DRIVER_HAVE_IRQ | DRIVER_GEM |
> > diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> > index a4633ada8429..5ac712325c75 100644
> > --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> > +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> > @@ -319,19 +319,7 @@ static irqreturn_t mxsfb_irq_handler(int irq, void *data)
> >  	return IRQ_HANDLED;
> >  }
> >  
> > -static const struct file_operations fops = {
> > -	.owner		= THIS_MODULE,
> > -	.open		= drm_open,
> > -	.release	= drm_release,
> > -	.unlocked_ioctl	= drm_ioctl,
> > -#ifdef CONFIG_COMPAT
> > -	.compat_ioctl	= drm_compat_ioctl,
> > -#endif
> > -	.poll		= drm_poll,
> > -	.read		= drm_read,
> > -	.llseek		= noop_llseek,
> > -	.mmap		= drm_gem_cma_mmap,
> > -};
> > +DEFINE_DRM_GEM_CMA_FOPS(fops);
> >  
> >  static struct drm_driver mxsfb_driver = {
> >  	.driver_features	= DRIVER_GEM | DRIVER_MODESET |
> > diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> > index 192346d4fb34..62a3b3e32153 100644
> > --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> > +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> > @@ -226,17 +226,7 @@ static void rcar_du_lastclose(struct drm_device *dev)
> >  	drm_fbdev_cma_restore_mode(rcdu->fbdev);
> >  }
> >  
> > -static const struct file_operations rcar_du_fops = {
> > -	.owner		= THIS_MODULE,
> > -	.open		= drm_open,
> > -	.release	= drm_release,
> > -	.unlocked_ioctl	= drm_ioctl,
> > -	.compat_ioctl	= drm_compat_ioctl,
> > -	.poll		= drm_poll,
> > -	.read		= drm_read,
> > -	.llseek		= no_llseek,
> > -	.mmap		= drm_gem_cma_mmap,
> > -};
> > +DEFINE_DRM_GEM_CMA_FOPS(rcar_du_fops);
> >  
> >  static struct drm_driver rcar_du_driver = {
> >  	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME
> > diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> > index 34fefa0ba0f0..75f2e5e6d7fb 100644
> > --- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> > +++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> > @@ -221,17 +221,7 @@ static irqreturn_t shmob_drm_irq(int irq, void *arg)
> >  	return IRQ_HANDLED;
> >  }
> >  
> > -static const struct file_operations shmob_drm_fops = {
> > -	.owner		= THIS_MODULE,
> > -	.open		= drm_open,
> > -	.release	= drm_release,
> > -	.unlocked_ioctl	= drm_ioctl,
> > -	.compat_ioctl	= drm_compat_ioctl,
> > -	.poll		= drm_poll,
> > -	.read		= drm_read,
> > -	.llseek		= no_llseek,
> > -	.mmap		= drm_gem_cma_mmap,
> > -};
> > +DEFINE_DRM_GEM_CMA_FOPS(shmob_drm_fops);
> >  
> >  static struct drm_driver shmob_drm_driver = {
> >  	.driver_features	= DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET
> > diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> > index 3b15c2cb2306..23da9bc4666a 100644
> > --- a/drivers/gpu/drm/sti/sti_drv.c
> > +++ b/drivers/gpu/drm/sti/sti_drv.c
> > @@ -167,16 +167,7 @@ static void sti_mode_config_init(struct drm_device *dev)
> >  	dev->mode_config.funcs = &sti_mode_config_funcs;
> >  }
> >  
> > -static const struct file_operations sti_driver_fops = {
> > -	.owner = THIS_MODULE,
> > -	.open = drm_open,
> > -	.mmap = drm_gem_cma_mmap,
> > -	.poll = drm_poll,
> > -	.read = drm_read,
> > -	.unlocked_ioctl = drm_ioctl,
> > -	.compat_ioctl = drm_compat_ioctl,
> > -	.release = drm_release,
> > -};
> > +DEFINE_DRM_GEM_CMA_FOPS(sti_driver_fops);
> >  
> >  static struct drm_driver sti_driver = {
> >  	.driver_features = DRIVER_MODESET |
> > diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
> > index 9ccf7c4deb6d..329ea56106a5 100644
> > --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
> > +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
> > @@ -25,17 +25,7 @@
> >  #include "sun4i_framebuffer.h"
> >  #include "sun4i_layer.h"
> >  
> > -static const struct file_operations sun4i_drv_fops = {
> > -	.owner		= THIS_MODULE,
> > -	.open		= drm_open,
> > -	.release	= drm_release,
> > -	.unlocked_ioctl	= drm_ioctl,
> > -	.compat_ioctl	= drm_compat_ioctl,
> > -	.poll		= drm_poll,
> > -	.read		= drm_read,
> > -	.llseek		= no_llseek,
> > -	.mmap		= drm_gem_cma_mmap,
> > -};
> > +DEFINE_DRM_GEM_CMA_FOPS(sun4i_drv_fops);
> >  
> >  static struct drm_driver sun4i_drv_driver = {
> >  	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC,
> > diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> > index 81d80a2ffeb1..480411c2e802 100644
> > --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> > +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> > @@ -530,17 +530,7 @@ static int tilcdc_debugfs_init(struct drm_minor *minor)
> >  }
> >  #endif
> >  
> > -static const struct file_operations fops = {
> > -	.owner              = THIS_MODULE,
> > -	.open               = drm_open,
> > -	.release            = drm_release,
> > -	.unlocked_ioctl     = drm_ioctl,
> > -	.compat_ioctl       = drm_compat_ioctl,
> > -	.poll               = drm_poll,
> > -	.read               = drm_read,
> > -	.llseek             = no_llseek,
> > -	.mmap               = drm_gem_cma_mmap,
> > -};
> > +DEFINE_DRM_GEM_CMA_FOPS(fops);
> >  
> >  static struct drm_driver tilcdc_driver = {
> >  	.driver_features    = (DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET |
> > diff --git a/drivers/gpu/drm/zte/zx_drm_drv.c b/drivers/gpu/drm/zte/zx_drm_drv.c
> > index b24a70ba4b83..614e854f6be5 100644
> > --- a/drivers/gpu/drm/zte/zx_drm_drv.c
> > +++ b/drivers/gpu/drm/zte/zx_drm_drv.c
> > @@ -53,19 +53,7 @@ static void zx_drm_lastclose(struct drm_device *drm)
> >  	drm_fbdev_cma_restore_mode(priv->fbdev);
> >  }
> >  
> > -static const struct file_operations zx_drm_fops = {
> > -	.owner = THIS_MODULE,
> > -	.open = drm_open,
> > -	.release = drm_release,
> > -	.unlocked_ioctl = drm_ioctl,
> > -#ifdef CONFIG_COMPAT
> > -	.compat_ioctl = drm_compat_ioctl,
> > -#endif
> > -	.poll = drm_poll,
> > -	.read = drm_read,
> > -	.llseek = noop_llseek,
> > -	.mmap = drm_gem_cma_mmap,
> > -};
> > +DEFINE_DRM_GEM_CMA_FOPS(zx_drm_fops);
> >  
> >  static struct drm_driver zx_drm_driver = {
> >  	.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
> > diff --git a/include/drm/drm_gem_cma_helper.h b/include/drm/drm_gem_cma_helper.h
> > index 2abcd5190cc1..f962d33667cf 100644
> > --- a/include/drm/drm_gem_cma_helper.h
> > +++ b/include/drm/drm_gem_cma_helper.h
> > @@ -26,6 +26,32 @@ to_drm_gem_cma_obj(struct drm_gem_object *gem_obj)
> >  	return container_of(gem_obj, struct drm_gem_cma_object, base);
> >  }
> >  
> > +/**
> > + * DEFINE_DRM_GEM_CMA_FOPS() - macro to generate file operations for CMA drivers
> > + * @name: name for the generated structure
> > + *
> > + * This macro autogenerates a suitable &struct file_operations for CMA based
> > + * drivers, which can be assigned to &drm_driver.fops. Note that this structure
> > + * cannot be shared between drivers, because it contains a reference to the
> > + * current module using THIS_MODULE.
> > + *
> > + * Note that the declaration is already marked as static - if you need a
> > + * non-static version of this you're probably doing it wrong and will break the
> > + * THIS_MODULE reference by accident.
> > + */
> > +#define DEFINE_DRM_GEM_CMA_FOPS(name) \
> > +	static const struct file_operations name = {\
> > +		.owner		= THIS_MODULE,\
> > +		.open		= drm_open,\
> > +		.release	= drm_release,\
> > +		.unlocked_ioctl	= drm_ioctl,\
> > +		.compat_ioctl	= drm_compat_ioctl,\
> > +		.poll		= drm_poll,\
> > +		.read		= drm_read,\
> > +		.llseek		= noop_llseek,\
> > +		.mmap		= drm_gem_cma_mmap,\
> > +	}
> > +
> >  /* free GEM object */
> >  void drm_gem_cma_free_object(struct drm_gem_object *gem_obj);
> >  
> > -- 
> > 2.11.0
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 24/24] drm/gem: Add DEFINE_DRM_GEM_FOPS
  2017-03-08 14:12 ` [PATCH 24/24] drm/gem: Add DEFINE_DRM_GEM_FOPS Daniel Vetter
@ 2017-03-13 19:35   ` Sean Paul
  2017-03-14 13:31     ` Daniel Vetter
  0 siblings, 1 reply; 72+ messages in thread
From: Sean Paul @ 2017-03-13 19:35 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

On Wed, Mar 08, 2017 at 03:12:57PM +0100, Daniel Vetter wrote:
> Sadly there's only 1 driver which can use it, everyone else is special
> for some reason:
> 
> - gma500 has a horrible runtime PM ioctl wrapper that probably doesn't
>   really work but meh.
> - i915 needs special compat_ioctl handler because regrets.
> - arcgpu needs to fixup the pgprot because (no idea why it can't do
>   that in the fault handler like everyone else).
> - tegra does even worse stuff with pgprot
> - udl does something with vm_flags too ...
> - cma helpers, etnaviv, mtk, msm, rockchip, omap all implement some
>   variation on prefaulting.
> - exynos is exynos, I got lost in the midlayers.
> - vc4 has to reinvent half of cma helpers because those are too much
>   midlayer, plus vm_flags dances.
> - vgem also seems unhappy with the default vm_flags.

I wonder whether a todo entry to clean this up would be appropriate.

Reviewed-by: Sean Paul <seanpaul@chromium.org>
> 
> So pretty sad divergence and I'm sure we could do better, but not
> really an idea. Oh well, maybe this macro here helps to encourage more
> consistency at least going forward.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/armada/armada_drv.c | 11 +----------
>  drivers/gpu/drm/drm_file.c          |  8 +++-----
>  include/drm/drm_gem.h               | 26 ++++++++++++++++++++++++++
>  3 files changed, 30 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> index 1952e8748fea..f986e9ff093d 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -60,16 +60,7 @@ static void armada_drm_lastclose(struct drm_device *dev)
>  	armada_fbdev_lastclose(dev);
>  }
>  
> -static const struct file_operations armada_drm_fops = {
> -	.owner			= THIS_MODULE,
> -	.llseek			= no_llseek,
> -	.read			= drm_read,
> -	.poll			= drm_poll,
> -	.unlocked_ioctl		= drm_ioctl,
> -	.mmap			= drm_gem_mmap,
> -	.open			= drm_open,
> -	.release		= drm_release,
> -};
> +DEFINE_DRM_GEM_FOPS(armada_drm_fops);
>  
>  static struct drm_driver armada_drm_driver = {
>  	.lastclose		= armada_drm_lastclose,
> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> index 260a83563976..0701362dcca1 100644
> --- a/drivers/gpu/drm/drm_file.c
> +++ b/drivers/gpu/drm/drm_file.c
> @@ -89,11 +89,9 @@ DEFINE_MUTEX(drm_global_mutex);
>   *             .mmap = drm_gem_mmap,
>   *     };
>   *
> - * For CMA based drivers there is the DEFINE_DRM_GEM_CMA_FOPS() macro to make
> - * this simpler.
> - *
> - * FIXME: We should have a macro for this (and the CMA version) so that drivers
> - * don't have to repeat it all the time.
> + * For plain GEM based drivers there is the DEFINE_DRM_GEM_FOPS() macro, and for
> + * CMA based drivers there is the DEFINE_DRM_GEM_CMA_FOPS() macro to make this
> + * simpler.
>   */
>  
>  static int drm_open_helper(struct file *filp, struct drm_minor *minor);
> diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
> index b9ade75ecd82..663d80358057 100644
> --- a/include/drm/drm_gem.h
> +++ b/include/drm/drm_gem.h
> @@ -178,6 +178,32 @@ struct drm_gem_object {
>  	struct dma_buf_attachment *import_attach;
>  };
>  
> +/**
> + * DEFINE_DRM_GEM_FOPS() - macro to generate file operations for GEM drivers
> + * @name: name for the generated structure
> + *
> + * This macro autogenerates a suitable &struct file_operations for GEM based
> + * drivers, which can be assigned to &drm_driver.fops. Note that this structure
> + * cannot be shared between drivers, because it contains a reference to the
> + * current module using THIS_MODULE.
> + *
> + * Note that the declaration is already marked as static - if you need a
> + * non-static version of this you're probably doing it wrong and will break the
> + * THIS_MODULE reference by accident.
> + */
> +#define DEFINE_DRM_GEM_FOPS(name) \
> +	static const struct file_operations name = {\
> +		.owner		= THIS_MODULE,\
> +		.open		= drm_open,\
> +		.release	= drm_release,\
> +		.unlocked_ioctl	= drm_ioctl,\
> +		.compat_ioctl	= drm_compat_ioctl,\
> +		.poll		= drm_poll,\
> +		.read		= drm_read,\
> +		.llseek		= noop_llseek,\
> +		.mmap		= drm_gem_mmap,\
> +	}
> +
>  void drm_gem_object_release(struct drm_gem_object *obj);
>  void drm_gem_object_free(struct kref *kref);
>  int drm_gem_object_init(struct drm_device *dev,
> -- 
> 2.11.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [Intel-gfx] [PATCH 02/24] drm: Extract drm_prime.h
  2017-03-13 16:42   ` Sean Paul
@ 2017-03-14  9:12     ` Daniel Vetter
  2017-03-14 15:42       ` Sean Paul
  0 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-14  9:12 UTC (permalink / raw)
  To: Sean Paul
  Cc: Daniel Vetter, Intel Graphics Development, DRI Development,
	Daniel Vetter

On Mon, Mar 13, 2017 at 12:42:54PM -0400, Sean Paul wrote:
> On Wed, Mar 08, 2017 at 03:12:35PM +0100, Daniel Vetter wrote:
> > +/**
> > + * struct drm_prime_file_private - per-file tracking for PRIME
> > + *
> > + * This just contains the internal &struct dma_buf and handle caches for each
> > + * &struct drm_file used by the PRIME core code.
> > + */
> > +
> > +struct drm_prime_file_private {
> > +/* private: */
> 
> I'm a little confused by this comment. The struct has private in its name, I'm
> not sure you're adding any additional information. Could you either remove or
> expand this?

private: is special markup for kernel-doc to ingore everything below as
implementation-internals. This avoids warnings when building the docs. I
have no idea why it doesn't use the usual /** kernel-doc comment starter
...
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [Intel-gfx] [PATCH 10/24] drm: Remove drm_pending_event->pid
  2017-03-13 17:05   ` [Intel-gfx] " Sean Paul
@ 2017-03-14 13:20     ` Daniel Vetter
  0 siblings, 0 replies; 72+ messages in thread
From: Daniel Vetter @ 2017-03-14 13:20 UTC (permalink / raw)
  To: Sean Paul
  Cc: Daniel Vetter, Intel Graphics Development, Ben Skeggs, DRI Development

On Mon, Mar 13, 2017 at 01:05:27PM -0400, Sean Paul wrote:
> On Wed, Mar 08, 2017 at 03:12:43PM +0100, Daniel Vetter wrote:
> > We might as well dump the drm_file pointer, that's about as useful
> > a cookie as the pid. Noticed while typing docs for drm_file and friends.
> > 
> > Since the only consumer of this is the tracepoints I think we can safely
> > change this - those tracepoints should not be uapi relevant at all. It
> > all goes back to
> > 
> > commit b9c2c9ae882f058084e13e339925dbf8d2d20271
> > Author: Jesse Barnes <jbarnes@virtuousgeek.org>
> > Date:   Thu Jul 1 16:48:09 2010 -0700
> > 
> >     drm: add per-event vblank event trace points
> > 
> > which doesn't give a special justification for using pid over a pointer.
> 
> Well, it's friendlier to look at, I suppose.
> 
> > 
> > Also note that the nouveau code setting it is entirely pointless:
> > Since this isn't a vblank event, it will never hit the vblank
> > tracepoints.
> > 
> > Cc: Ben Skeggs <bskeggs@redhat.com>
> > Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> > ---
> >  drivers/gpu/drm/drm_irq.c              |  5 ++---
> >  drivers/gpu/drm/drm_trace.h            | 20 ++++++++++----------
> >  drivers/gpu/drm/nouveau/nouveau_usif.c |  1 -
> >  include/drm/drm_file.h                 |  2 --
> >  4 files changed, 12 insertions(+), 16 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> > index 1906723af389..9bdca69f754c 100644
> > --- a/drivers/gpu/drm/drm_irq.c
> > +++ b/drivers/gpu/drm/drm_irq.c
> > @@ -978,7 +978,7 @@ static void send_vblank_event(struct drm_device *dev,
> >  	e->event.tv_sec = now->tv_sec;
> >  	e->event.tv_usec = now->tv_usec;
> >  
> > -	trace_drm_vblank_event_delivered(e->base.pid, e->pipe,
> > +	trace_drm_vblank_event_delivered(e->base.file_priv, e->pipe,
> >  					 e->event.sequence);
> >  
> >  	drm_send_event_locked(dev, &e->base);
> > @@ -1505,7 +1505,6 @@ static int drm_queue_vblank_event(struct drm_device *dev, unsigned int pipe,
> >  	}
> >  
> >  	e->pipe = pipe;
> > -	e->base.pid = current->pid;
> 
> Do you think it would be worthwhile to output the pid:file_priv mapping here in
> case someone is using pid?
> 
> Regardless, the code looks correct, and I don't any skin in this game, so I'll
> add my R-b and let you decide what to do if no one else complains.

I considered it, but then went meh. It's super-easy to change back to
fpriv->pid if anyone wants that, so if someone pipes up I'll volunteer for
that. The one issue with that is that on systems with logind, logind opens
all drm fd for compositors, so they all have the same pid. With fpriv
itself you can at least tell them apart ...

> Reviewed-by: Sean Paul <seanpaul@chromium.org>

I'll take this one :-)
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 11/24] drm/doc: Document drm_file.[hc]
  2017-03-13 17:53   ` Sean Paul
@ 2017-03-14 13:25     ` Daniel Vetter
  2017-03-14 13:27     ` Daniel Vetter
  1 sibling, 0 replies; 72+ messages in thread
From: Daniel Vetter @ 2017-03-14 13:25 UTC (permalink / raw)
  To: Sean Paul
  Cc: Daniel Vetter, Intel Graphics Development, DRI Development,
	Daniel Vetter

On Mon, Mar 13, 2017 at 01:53:28PM -0400, Sean Paul wrote:
> On Wed, Mar 08, 2017 at 03:12:44PM +0100, Daniel Vetter wrote:
> > Well, mostly drm_file.h, and clean up all related things:
> > 
> > - I didnt' figure out the difference between preclose and postclose.
> >   The existing explanation in drm-internals.rst didn't convince me,
> >   since it's also really outdated - we clean up pending DRM events in
> >   the core nowadays. I put a FIXME in for the future.
> > 
> > - Another FIXME is to have a macro for default fops.
> > 
> > - Lots of links all around, main areas are to tie the overview in
> >   drm_file.c more into the callbacks in struct drm_device, and the
> >   other is to link render/primary node code to the right sections in
> >   drm-uapi.rst.
> > 
> > - Also moved the open/close stuff to drm_drv.h from drm-internals.rst,
> >   seems like the better place for that information. Since that section
> >   was rather outdated this amounted to full-on rewrite.
> > 
> > A big missing piece here is some overview graph, but I think better to
> > wait with that one until drm_device and drm_driver are also fully
> > documented.
> > 
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> 
> Overall, awesome patch, really does a good job explaining the parameters and how
> they interact with each other (bonus points for the lock breadcrumbs). I just
> have a few optional nits and some spelling errors.
> 
> Reviewed-by: Sean Paul <seanpaul@chromium.org>

Fixed all the nits, except for /* private: */, as explained, that's just
kernel-doc markup to annotate internal structure stuff that users
shouldn't look at.

Thanks a lot for your careful read-through,
Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 11/24] drm/doc: Document drm_file.[hc]
  2017-03-13 17:53   ` Sean Paul
  2017-03-14 13:25     ` Daniel Vetter
@ 2017-03-14 13:27     ` Daniel Vetter
  1 sibling, 0 replies; 72+ messages in thread
From: Daniel Vetter @ 2017-03-14 13:27 UTC (permalink / raw)
  To: Sean Paul
  Cc: Daniel Vetter, Intel Graphics Development, DRI Development,
	Daniel Vetter

On Mon, Mar 13, 2017 at 01:53:28PM -0400, Sean Paul wrote:
> On Wed, Mar 08, 2017 at 03:12:44PM +0100, Daniel Vetter wrote:
> > Well, mostly drm_file.h, and clean up all related things:
> > 
> > - I didnt' figure out the difference between preclose and postclose.
> >   The existing explanation in drm-internals.rst didn't convince me,
> >   since it's also really outdated - we clean up pending DRM events in
> >   the core nowadays. I put a FIXME in for the future.
> > 
> > - Another FIXME is to have a macro for default fops.
> > 
> > - Lots of links all around, main areas are to tie the overview in
> >   drm_file.c more into the callbacks in struct drm_device, and the
> >   other is to link render/primary node code to the right sections in
> >   drm-uapi.rst.
> > 
> > - Also moved the open/close stuff to drm_drv.h from drm-internals.rst,
> >   seems like the better place for that information. Since that section
> >   was rather outdated this amounted to full-on rewrite.
> > 
> > A big missing piece here is some overview graph, but I think better to
> > wait with that one until drm_device and drm_driver are also fully
> > documented.
> > 
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> 
> Overall, awesome patch, really does a good job explaining the parameters and how
> they interact with each other (bonus points for the lock breadcrumbs). I just
> have a few optional nits and some spelling errors.
> 
> Reviewed-by: Sean Paul <seanpaul@chromium.org>

Merged up to this one to drm-misc. As mentioned a few times on irc, I'd
like to get the post/preclose patches through relevant driver trees, for
maximum amount of testing.
-Daniel
> 
> > ---
> >  Documentation/gpu/drm-internals.rst |  52 +------
> >  Documentation/gpu/drm-uapi.rst      |   4 +
> >  drivers/gpu/drm/drm_file.c          |  66 +++++----
> >  include/drm/drm_drv.h               |  81 ++++++++++-
> >  include/drm/drm_file.h              | 267 ++++++++++++++++++++++++++++++++----
> >  5 files changed, 356 insertions(+), 114 deletions(-)
> > 
> > diff --git a/Documentation/gpu/drm-internals.rst b/Documentation/gpu/drm-internals.rst
> > index ea329b71c459..7a2fe4a02212 100644
> > --- a/Documentation/gpu/drm-internals.rst
> > +++ b/Documentation/gpu/drm-internals.rst
> > @@ -246,61 +246,15 @@ drivers.
> >  Open/Close, File Operations and IOCTLs
> >  ======================================
> >  
> > -Open and Close
> > ---------------
> > -
> > -Open and close handlers. None of those methods are mandatory::
> > -
> > -    int (*firstopen) (struct drm_device *);
> > -    void (*lastclose) (struct drm_device *);
> > -    int (*open) (struct drm_device *, struct drm_file *);
> > -    void (*preclose) (struct drm_device *, struct drm_file *);
> > -    void (*postclose) (struct drm_device *, struct drm_file *);
> > -
> > -The firstopen method is called by the DRM core for legacy UMS (User Mode
> > -Setting) drivers only when an application opens a device that has no
> > -other opened file handle. UMS drivers can implement it to acquire device
> > -resources. KMS drivers can't use the method and must acquire resources
> > -in the load method instead.
> > -
> > -Similarly the lastclose method is called when the last application
> > -holding a file handle opened on the device closes it, for both UMS and
> > -KMS drivers. Additionally, the method is also called at module unload
> > -time or, for hot-pluggable devices, when the device is unplugged. The
> > -firstopen and lastclose calls can thus be unbalanced.
> > -
> > -The open method is called every time the device is opened by an
> > -application. Drivers can allocate per-file private data in this method
> > -and store them in the struct :c:type:`struct drm_file
> > -<drm_file>` driver_priv field. Note that the open method is
> > -called before firstopen.
> > -
> > -The close operation is split into preclose and postclose methods.
> > -Drivers must stop and cleanup all per-file operations in the preclose
> > -method. For instance pending vertical blanking and page flip events must
> > -be cancelled. No per-file operation is allowed on the file handle after
> > -returning from the preclose method.
> > -
> > -Finally the postclose method is called as the last step of the close
> > -operation, right before calling the lastclose method if no other open
> > -file handle exists for the device. Drivers that have allocated per-file
> > -private data in the open method should free it here.
> > -
> > -The lastclose method should restore CRTC and plane properties to default
> > -value, so that a subsequent open of the device will not inherit state
> > -from the previous user. It can also be used to execute delayed power
> > -switching state changes, e.g. in conjunction with the :ref:`vga_switcheroo`
> > -infrastructure. Beyond that KMS drivers should not do any
> > -further cleanup. Only legacy UMS drivers might need to clean up device
> > -state so that the vga console or an independent fbdev driver could take
> > -over.
> > -
> >  File Operations
> >  ---------------
> >  
> >  .. kernel-doc:: drivers/gpu/drm/drm_file.c
> >     :doc: file operations
> >  
> > +.. kernel-doc:: include/drm/drm_file.h
> > +   :internal:
> > +
> >  .. kernel-doc:: drivers/gpu/drm/drm_file.c
> >     :export:
> >  
> > diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst
> > index fcc228ef5bc4..352652810dab 100644
> > --- a/Documentation/gpu/drm-uapi.rst
> > +++ b/Documentation/gpu/drm-uapi.rst
> > @@ -21,6 +21,8 @@ libdrm Device Lookup
> >     :doc: getunique and setversion story
> >  
> >  
> > +.. _drm_primary_node:
> > +
> >  Primary Nodes, DRM Master and Authentication
> >  ============================================
> >  
> > @@ -103,6 +105,8 @@ is already rather painful for the DRM subsystem, with multiple different uAPIs
> >  for the same thing co-existing. If we add a few more complete mistakes into the
> >  mix every year it would be entirely unmanageable.
> >  
> > +.. _drm_render_node:
> > +
> >  Render nodes
> >  ============
> >  
> > diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> > index d9e63d73d3ec..a8813a1115dc 100644
> > --- a/drivers/gpu/drm/drm_file.c
> > +++ b/drivers/gpu/drm/drm_file.c
> > @@ -50,12 +50,14 @@ DEFINE_MUTEX(drm_global_mutex);
> >   *
> >   * Drivers must define the file operations structure that forms the DRM
> >   * userspace API entry point, even though most of those operations are
> > - * implemented in the DRM core. The mandatory functions are drm_open(),
> > + * implemented in the DRM core. The resulting &struct file_operations must be
> > + * stored in the &drm_driver.fops field. The mandatory functions are drm_open(),
> >   * drm_read(), drm_ioctl() and drm_compat_ioctl() if CONFIG_COMPAT is enabled
> > - * (note that drm_compat_ioctl will be NULL if CONFIG_COMPAT=n). Drivers which
> > - * implement private ioctls that require 32/64 bit compatibility support must
> > - * provide their own .compat_ioctl() handler that processes private ioctls and
> > - * calls drm_compat_ioctl() for core ioctls.
> > + * Note that drm_compat_ioctl will be NULL if CONFIG_COMPAT=n, so there's no
> > + * need to sprinkle #ifdef into the code. Drivers which implement private ioctls
> > + * that require 32/64 bit compatibility support must provide their own
> > + * &file_operations.compat_ioctl handler that processes private ioctls and calls
> > + * drm_compat_ioctl() for core ioctls.
> >   *
> >   * In addition drm_read() and drm_poll() provide support for DRM events. DRM
> >   * events are a generic and extensible means to send asynchronous events to
> > @@ -63,10 +65,14 @@ DEFINE_MUTEX(drm_global_mutex);
> >   * page flip completions by the KMS API. But drivers can also use it for their
> >   * own needs, e.g. to signal completion of rendering.
> >   *
> > + * For the driver-side event interface see drm_event_reserve_init() and
> > + * drm_send_event() as the main starting points.
> > + *
> >   * The memory mapping implementation will vary depending on how the driver
> >   * manages memory. Legacy drivers will use the deprecated drm_legacy_mmap()
> >   * function, modern drivers should use one of the provided memory-manager
> > - * specific implementations. For GEM-based drivers this is drm_gem_mmap().
> > + * specific implementations. For GEM-based drivers this is drm_gem_mmap(), and
> > + * for drivers which use the CMA GEM helpers it's drm_gem_cma_mmap().
> >   *
> >   * No other file operations are supported by the DRM userspace API. Overall the
> >   * following is an example #file_operations structure::
> > @@ -82,6 +88,9 @@ DEFINE_MUTEX(drm_global_mutex);
> >   *             .llseek = no_llseek,
> >   *             .mmap = drm_gem_mmap,
> >   *     };
> > + *
> > + * FIXME: We should have a macro for this (and the CMA version) so that drivers
> > + * don't have to repeat it all the time.
> >   */
> >  
> >  static int drm_open_helper(struct file *filp, struct drm_minor *minor);
> > @@ -111,9 +120,9 @@ static int drm_setup(struct drm_device * dev)
> >   * @inode: device inode
> >   * @filp: file pointer.
> >   *
> > - * This function must be used by drivers as their .open() #file_operations
> > - * method. It looks up the correct DRM device and instantiates all the per-file
> > - * resources for it.
> > + * This function must be used by drivers as their &file_operations.open method.
> > + * It looks up the correct DRM device and instantiates all the per-file
> > + * resources for it. It also calls the &drm_driver.open driver callback.
> >   *
> >   * RETURNS:
> >   *
> > @@ -298,11 +307,6 @@ static void drm_events_release(struct drm_file *file_priv)
> >  	spin_unlock_irqrestore(&dev->event_lock, flags);
> >  }
> >  
> > -/*
> > - * drm_legacy_dev_reinit
> > - *
> > - * Reinitializes a legacy/ums drm device in it's lastclose function.
> > - */
> >  static void drm_legacy_dev_reinit(struct drm_device *dev)
> >  {
> >  	if (dev->irq_enabled)
> > @@ -327,15 +331,6 @@ static void drm_legacy_dev_reinit(struct drm_device *dev)
> >  	DRM_DEBUG("lastclose completed\n");
> >  }
> >  
> > -/*
> > - * Take down the DRM device.
> > - *
> > - * \param dev DRM device structure.
> > - *
> > - * Frees every resource in \p dev.
> > - *
> > - * \sa drm_device
> > - */
> >  void drm_lastclose(struct drm_device * dev)
> >  {
> >  	DRM_DEBUG("\n");
> > @@ -353,9 +348,11 @@ void drm_lastclose(struct drm_device * dev)
> >   * @inode: device inode
> >   * @filp: file pointer.
> >   *
> > - * This function must be used by drivers as their .release() #file_operations
> > - * method. It frees any resources associated with the open file, and if this is
> > - * the last open file for the DRM device also proceeds to call drm_lastclose().
> > + * This function must be used by drivers as their &file_operations.release
> > + * method. It frees any resources associated with the open file, and calls the
> > + * &drm_driver.preclose and &drm_driver.lastclose driver callbacks. If this is
> > + * the last open file for the DRM device also proceeds to call the
> > + * &drm_driver.lastclose driver callback.
> >   *
> >   * RETURNS:
> >   *
> > @@ -443,13 +440,13 @@ EXPORT_SYMBOL(drm_release);
> >   * @count: count in bytes to read
> >   * @offset: offset to read
> >   *
> > - * This function must be used by drivers as their .read() #file_operations
> > + * This function must be used by drivers as their &file_operations.read
> >   * method iff they use DRM events for asynchronous signalling to userspace.
> >   * Since events are used by the KMS API for vblank and page flip completion this
> >   * means all modern display drivers must use it.
> >   *
> > - * @offset is ignore, DRM events are read like a pipe. Therefore drivers also
> > - * must set the .llseek() #file_operation to no_llseek(). Polling support is
> > + * @offset is ignored, DRM events are read like a pipe. Therefore drivers also
> > + * must set the &file_operation.llseek  to no_llseek(). Polling support is
> 
> nit: double space before 'to'
> 
> >   * provided by drm_poll().
> >   *
> >   * This function will only ever read a full event. Therefore userspace must
> > @@ -537,10 +534,10 @@ EXPORT_SYMBOL(drm_read);
> >   * @filp: file pointer
> >   * @wait: poll waiter table
> >   *
> > - * This function must be used by drivers as their .read() #file_operations
> > - * method iff they use DRM events for asynchronous signalling to userspace.
> > - * Since events are used by the KMS API for vblank and page flip completion this
> > - * means all modern display drivers must use it.
> > + * This function must be used by drivers as their &file_operations.read method
> > + * iff they use DRM events for asynchronous signalling to userspace.  Since
> > + * events are used by the KMS API for vblank and page flip completion this means
> > + * all modern display drivers must use it.
> >   *
> >   * See also drm_read().
> >   *
> > @@ -650,7 +647,8 @@ EXPORT_SYMBOL(drm_event_reserve_init);
> >   * @p: tracking structure for the pending event
> >   *
> >   * This function frees the event @p initialized with drm_event_reserve_init()
> > - * and releases any allocated space.
> > + * and releases any allocated space. It is used to cancel an event when the
> > + * nonblocking operation could not be submitted and needed to be aborted.
> >   */
> >  void drm_event_cancel_free(struct drm_device *dev,
> >  			   struct drm_pending_event *p)
> > diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> > index 4321d012c4ba..8f900fb30275 100644
> > --- a/include/drm/drm_drv.h
> > +++ b/include/drm/drm_drv.h
> > @@ -64,7 +64,6 @@ struct drm_mode_create_dumb;
> >   * structure for GEM drivers.
> >   */
> >  struct drm_driver {
> > -
> >  	/**
> >  	 * @load:
> >  	 *
> > @@ -76,14 +75,94 @@ struct drm_driver {
> >  	 * See drm_dev_init() and drm_dev_register() for proper and
> >  	 * race-free way to set up a &struct drm_device.
> >  	 *
> > +	 * This is deprecated, do not use!
> > +	 *
> >  	 * Returns:
> >  	 *
> >  	 * Zero on success, non-zero value on failure.
> >  	 */
> >  	int (*load) (struct drm_device *, unsigned long flags);
> > +
> > +	/**
> > +	 * @open:
> > +	 *
> > +	 * Driver callback when a new &struct drm_file is opened. Useful for
> > +	 * setting up driver-private data structures like buffer allocators,
> > +	 * execution contexts or similar things. Such driver-private resources
> > +	 * must be released again in @postclose.
> > +	 *
> > +	 * Since the display/modeset side of DRM can only be owned by exactly
> > +	 * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
> > +	 * there should never be a need to set up any modeset related resources
> > +	 * in this callback. Doing so would be a driver design bug.
> > +	 *
> > +	 * Returns:
> > +	 *
> > +	 * 0 on success, a negative error code on failure, which will be
> > +	 * promoted to userspace as the result of the open() system call.
> > +	 */
> >  	int (*open) (struct drm_device *, struct drm_file *);
> > +
> > +	/**
> > +	 * @preclose:
> > +	 *
> > +	 * One of the driver callbacks when a new &struct drm_file is closed.
> > +	 * Useful for tearing down driver-private data structures allocated in
> > +	 * @open like buffer allocators, execution contexts or similar things.
> > +	 *
> > +	 * Since the display/modeset side of DRM can only be owned by exactly
> > +	 * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
> > +	 * there should never be a need to tear down any modeset related
> > +	 * resources in this callback. Doing so would be a driver design bug.
> > +	 *
> > +	 * FIXME: It is not really clear why there's both @preclose and
> > +	 * @postclose. Without a really good reason, use @postclose only.
> > +	 */
> >  	void (*preclose) (struct drm_device *, struct drm_file *file_priv);
> > +
> > +	/**
> > +	 * @postclose:
> > +	 *
> > +	 * One of the driver callbacks when a new &struct drm_file is closed.
> > +	 * Useful for tearing down driver-private data structures allocated in
> > +	 * @open like buffer allocators, execution contexts or similar things.
> > +	 *
> > +	 * Since the display/modeset side of DRM can only be owned by exactly
> > +	 * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
> > +	 * there should never be a need to tear down any modeset related
> > +	 * resources in this callback. Doing so would be a driver design bug.
> > +	 *
> > +	 * FIXME: It is not really clear why there's both @preclose and
> > +	 * @postclose. Without a really good reason, use @postclose only.
> > +	 */
> >  	void (*postclose) (struct drm_device *, struct drm_file *);
> > +
> > +	/**
> > +	 * @lastclose:
> > +	 *
> > +	 * Called when the last &struct drm_file has been closed and there's
> > +	 * currently no userspace client for the &struct drm_device.
> > +	 *
> > +	 * Modern drivers should only use this to force-restore the fbdev
> > +	 * framebuffer using drm_fb_helper_restore_fbdev_mode_unlocked().
> > +	 * Anything else would indicate there's something seriously wrong.
> > +	 * Modern drivers can also use this to execute delayed power switching
> > +	 * state changes, e.g. in conjunction with the :ref:`vga_switcheroo`
> > +	 * infrastructure.
> > +	 *
> > +	 * This is called after @preclose and @postclose have been called.
> > +	 *
> > +	 * NOTE:
> > +	 *
> > +	 * All legacy drivers use this callback to de-initialize the hardware.
> > +	 * This is purely because of the shadow-attach model, where the DRM
> > +	 * kernel driver does not really own the hardware. Instead ownershipe is
> > +	 * handled with the help of userspace through an inheritedly racy dance
> > +	 * to set/unset the VT into raw mode.
> > +	 *
> > +	 * Legacy drivers initialize the hardware in the @firstopen callback,
> > +	 * which isn't even called for modern drivers.
> > +	 */
> >  	void (*lastclose) (struct drm_device *);
> >  
> >  	/**
> > diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
> > index 4e347399a7bd..67244f2c0c54 100644
> > --- a/include/drm/drm_file.h
> > +++ b/include/drm/drm_file.h
> > @@ -45,6 +45,7 @@ struct drm_device;
> >   * FIXME: Not sure we want to have drm_minor here in the end, but to avoid
> >   * header include loops we need it here for now.
> >   */
> > +
> >  enum drm_minor_type {
> >  	DRM_MINOR_PRIMARY,
> >  	DRM_MINOR_CONTROL,
> > @@ -52,12 +53,19 @@ enum drm_minor_type {
> >  };
> >  
> >  /**
> > - * DRM minor structure. This structure represents a drm minor number.
> > + * struct drm_minor - DRM device minor structure
> > + *
> > + * This structure represents a DRM minor number for device nodes in /dev.
> > + * Entirely opaque to drivers and should never be inspected directly by drivers.
> > + * Drivers instead should only interact with &struct drm_file and of course
> > + * &struct drm_device, which is also where driver-private data and resources can
> > + * be attached to.
> >   */
> >  struct drm_minor {
> > -	int index;			/**< Minor device number */
> > -	int type;                       /**< Control or render */
> > -	struct device *kdev;		/**< Linux device */
> > +	/* private: */
> 
> Same comment here re: the private comment. I don't think it adds anything beyond
> what you've already said in the overview.
> 
> > +	int index;			/* Minor device number */
> > +	int type;                       /* Control or render */
> > +	struct device *kdev;		/* Linux device */
> >  	struct drm_device *dev;
> >  
> >  	struct dentry *debugfs_root;
> > @@ -66,89 +74,288 @@ struct drm_minor {
> >  	struct mutex debugfs_lock; /* Protects debugfs_list. */
> >  };
> >  
> > -/* Event queued up for userspace to read */
> > +/**
> > + * struct drm_pending_event - Event queued up for userspace to read
> > + *
> > + * This represents a DRM event. Drivers can use this as a generic completion
> > + * mechanism, which supports kernel-internal &struct completion, &struct dma_fence
> > + * and also the DRM-specific &struct drm_event delivery mechanism.
> > + */
> >  struct drm_pending_event {
> > +	/**
> > +	 * @completion:
> > +	 *
> > +	 * Optional pointer to a kernel internal completion signalled when
> > +	 * drm_send_event() is called, useful to internally synchronize with
> > +	 * nonblcoking operations.
> 
> nonblocking
> 
> > +	 */
> >  	struct completion *completion;
> > +
> > +	/**
> > +	 * @completion_release:
> > +	 *
> > +	 * Optional callback currently only used by the atomic modeset helpers
> > +	 * to clean up the reference count for the structure @completion is
> > +	 * stored in.
> > +	 */
> >  	void (*completion_release)(struct completion *completion);
> > +
> > +	/**
> > +	 * @event:
> > +	 *
> > +	 * Pointer to the actual event that should be sent to userspace to be
> > +	 * read using drm_read(). Can be optional, since nowadays events are
> > +	 * also used to signal kernel internal threads with @completion or DMA
> > +	 * transactions using @fence.
> > +	 */
> >  	struct drm_event *event;
> > +
> > +	/**
> > +	 * @fence:
> > +	 *
> > +	 * Optional DMA fence to unblock other hardware transactions which
> > +	 * depend upon the nonblocking DRM operation this event represents.
> > +	 */
> >  	struct dma_fence *fence;
> > +
> > +	/**
> > +	 * @file_priv:
> > +	 *
> > +	 * &struct drm_file where @event should be delivered to. Only set when
> > +	 * @event is set.
> > +	 */
> > +	struct drm_file *file_priv;
> > +
> > +	/**
> > +	 * @link:
> > +	 *
> > +	 * Double-linked list to keep track of this event. Can be used by the
> > +	 * driver up to the point when it calls drm_send_event(), after that
> > +	 * this list entry is owned by the core for its own book-keeping.
> > +	 */
> >  	struct list_head link;
> > +
> > +	/**
> > +	 * @pending_link:
> > +	 *
> > +	 * Entry on &drm_file.pending_event_list, to keep track of all pending
> > +	 * events for @file_priv, to allow correct unwinding of them when
> > +	 * userspace closes the file before the event is delivered.
> > +	 */
> >  	struct list_head pending_link;
> > -	struct drm_file *file_priv;
> >  };
> >  
> > -/** File private data */
> > +/**
> > + * struct drm_file - DRM file private data
> > + *
> > + * This structure tracks per open file descriptor DRM state.
> 
> nit: This structure tracks DRM state per open file descriptor.
> 
> > + */
> >  struct drm_file {
> > +	/**
> > +	 * @authenticated:
> > +	 *
> > +	 * Whether the client is allowed to submit rendering, which for legacy
> > +	 * nodes means it must be authenticated.
> > +	 *
> > +	 * See also the :ref:`section on primary nodes and authentication
> > +	 * <drm_primary_node>`.
> > +	 */
> > +
> 
> nit: extra line
> 
> >  	unsigned authenticated :1;
> > -	/* true when the client has asked us to expose stereo 3D mode flags */
> > +
> > +	/**
> > +	 * @stereo_allowed:
> > +	 *
> > +	 * True when the client has asked us to expose stereo 3D mode flags.
> > +	 */
> >  	unsigned stereo_allowed :1;
> > -	/*
> > -	 * true if client understands CRTC primary planes and cursor planes
> > -	 * in the plane list
> > +
> > +	/**
> > +	 * @universal_planes:
> > +	 *
> > +	 * True if client understands CRTC primary planes and cursor planes
> > +	 * in the plane list. Automatically set when @atomic is set.
> >  	 */
> >  	unsigned universal_planes:1;
> > -	/* true if client understands atomic properties */
> > +
> > +	/** @atomic: True if client understands atomic properties. */
> >  	unsigned atomic:1;
> > -	/*
> > -	 * This client is the creator of @master.
> > -	 * Protected by struct drm_device::master_mutex.
> > +
> > +	/**
> > +	 * @is_master:
> > +	 *
> > +	 * This client is the creator of @master.  Protected by struct
> 
> nit: double space before Protected
> 
> > +	 * &drm_device.master_mutex.
> > +	 *
> > +	 * See also the :ref:`section on primary nodes and authentication
> > +	 * <drm_primary_node>`.
> >  	 */
> >  	unsigned is_master:1;
> >  
> > +	/**
> > +	 * @master:
> > +	 *
> > +	 * Master this node is currently associated with. Only relevant if
> > +	 * drm_is_primary_client() returns true. Note that this only
> > +	 * matches &drm_device.master if the master is the currently active one.
> > +	 *
> > +	 * See also @authentication and @is_master and the :ref:`section on
> > +	 * primary nodes and authentication <drm_primary_node>`.
> > +	 */
> > +	struct drm_master *master;
> > +
> > +	/** @pid: Process that opened this file. */
> >  	struct pid *pid;
> > +
> > +	/** @magic: Authentication magic, see @authenticated. */
> >  	drm_magic_t magic;
> > +
> > +	/**
> > +	 * @lhead:
> > +	 *
> > +	 * List of all open files of a DRM device, linked into
> > +	 * &drm_device.filelist. Protected by &drm_device.filelist_mutex.
> > +	 */
> >  	struct list_head lhead;
> > +
> > +
> 
> nit: extra line
> 
> > +	/** @minor: &struct drm_minor for this file. */
> >  	struct drm_minor *minor;
> > -	unsigned long lock_count;
> >  
> > -	/** Mapping of mm object handles to object pointers. */
> > +	/**
> > +	 * @object_idr:
> > +	 *
> > +	 * Mapping of mm object handles to object pointers. Used by the GEM
> > +	 * subsystem. Protected by @table_lock.
> > +	 */
> >  	struct idr object_idr;
> > -	/** Lock for synchronization of access to object_idr. */
> > +
> > +	/** @table_lock: Protects @object_idr. */
> >  	spinlock_t table_lock;
> >  
> > +	/** @filp: Pointer to the core file structure. */
> >  	struct file *filp;
> > +
> > +	/**
> > +	 * @driver_priv:
> > +	 *
> > +	 * Optional pointer for driver private data. Can be allocated in
> > +	 * &drm_driver.open and should be freed in &drm_driver.postclose.
> > +	 */
> >  	void *driver_priv;
> >  
> > -	struct drm_master *master; /* master this node is currently associated with
> > -				      N.B. not always dev->master */
> >  	/**
> > -	 * fbs - List of framebuffers associated with this file.
> > +	 * @fbs:
> > +	 *
> > +	 * List of &struct drm_framebuffer associated with this file, using the
> > +	 * &drm_framebuffer.filp_head entry.
> >  	 *
> > -	 * Protected by fbs_lock. Note that the fbs list holds a reference on
> > -	 * the fb object to prevent it from untimely disappearing.
> > +	 * Protected by @fbs_lock. Note that the @fbs list holds a reference on
> > +	 * the framebuffer object to prevent it from untimely disappearing.
> >  	 */
> >  	struct list_head fbs;
> > +
> > +	/** @fbs_lock: Protects @fbs. */
> >  	struct mutex fbs_lock;
> >  
> > -	/** User-created blob properties; this retains a reference on the
> > -	 *  property. */
> > +	/**
> > +	 * @blobs:
> > +	 *
> > +	 * User-created blob properties; this retains a reference on the
> > +	 * property.
> > +	 *
> > +	 * Protected by @drm_mode_config.blob_lock;
> > +	 */
> >  	struct list_head blobs;
> >  
> > +	/** @event_wait: Waitqueue for new events added to @event_list. */
> >  	wait_queue_head_t event_wait;
> > +
> > +	/**
> > +	 * @pending_event_list:
> > +	 *
> > +	 * List of pending &struct drm_pending_event, used to clean up pending
> > +	 * events in case this file gets closed before the event is signalled.
> > +	 * Uses the &drm_pending_event.pending_link entry.
> > +	 *
> > +	 * Protect by &drm_device.event_lock.
> > +	 */
> >  	struct list_head pending_event_list;
> > +
> > +	/**
> > +	 * @event_list:
> > +	 *
> > +	 * List of &struct drm_pending_event, ready for devlivery to userspace
> 
> Dat 'dev' muscle memory :-)
> 
> > +	 * through drm_read(). Uses the &drm_pending_event.link entry.
> > +	 *
> > +	 * Protect by &drm_device.event_lock.
> > +	 */
> >  	struct list_head event_list;
> > +
> > +	/**
> > +	 * @event_space:
> > +	 *
> > +	 * Available event space to prevent userspace from
> > +	 * exhausting kernel memory. Currently limited to the fairly arbitrary
> > +	 * value of 4KB.
> > +	 */
> >  	int event_space;
> >  
> > +	/** @event_read_lock: Serializes drm_read(). */
> >  	struct mutex event_read_lock;
> >  
> > +	/**
> > +	 * @prime:
> > +	 *
> > +	 * Per-file buffer caches used by the PRIME buffer sharing code.
> > +	 */
> >  	struct drm_prime_file_private prime;
> > +
> > +	/* private: */
> > +	unsigned long lock_count; /* DRI1 legacy lock count */
> >  };
> >  
> > +/**
> > + * drm_is_primary_client - is this an open file of the primary node
> > + * @file_priv: DRM file
> > + *
> > + * Returns true if this is an open file of the primary node, i.e.
> > + * &drm_file.minor of @file_priv is a primary minor.
> > + *
> > + * See also the :ref:`section on primary nodes and authentication
> > + * <drm_primary_node>`.
> > + */
> > +static inline bool drm_is_primary_client(const struct drm_file *file_priv)
> > +{
> > +	return file_priv->minor->type == DRM_MINOR_PRIMARY;
> > +}
> > +
> > +/**
> > + * drm_is_render_client - is this an open file of the render node
> > + * @file_priv: DRM file
> > + *
> > + * Returns true if this is an open file of the render node, i.e.
> > + * &drm_file.minor of @file_priv is a render minor.
> > + *
> > + * See also the :ref:`section on render nodes <drm_render_node>`.
> > + */
> >  static inline bool drm_is_render_client(const struct drm_file *file_priv)
> >  {
> >  	return file_priv->minor->type == DRM_MINOR_RENDER;
> >  }
> >  
> > +/**
> > + * drm_is_control_client - is this an open file of the control node
> > + * @file_priv: DRM file
> > + *
> > + * Control nodes are deprecated and in the process of getting removed from the
> > + * DRM userspace API. Do not ever use!
> > + */
> >  static inline bool drm_is_control_client(const struct drm_file *file_priv)
> >  {
> >  	return file_priv->minor->type == DRM_MINOR_CONTROL;
> >  }
> >  
> > -static inline bool drm_is_primary_client(const struct drm_file *file_priv)
> > -{
> > -	return file_priv->minor->type == DRM_MINOR_PRIMARY;
> > -}
> > -
> >  int drm_open(struct inode *inode, struct file *filp);
> >  ssize_t drm_read(struct file *filp, char __user *buffer,
> >  		 size_t count, loff_t *offset);
> > -- 
> > 2.11.0
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 17/24] drm/vgem: switch to postclose
  2017-03-13 19:11   ` Sean Paul
@ 2017-03-14 13:27     ` Daniel Vetter
  0 siblings, 0 replies; 72+ messages in thread
From: Daniel Vetter @ 2017-03-14 13:27 UTC (permalink / raw)
  To: Sean Paul
  Cc: Daniel Vetter, Intel Graphics Development, DRI Development,
	Daniel Vetter

On Mon, Mar 13, 2017 at 03:11:05PM -0400, Sean Paul wrote:
> On Wed, Mar 08, 2017 at 03:12:50PM +0100, Daniel Vetter wrote:
> > I didn't spot anything that would require ordering here (well not
> > anywhere else either), and I'm trying to unify at least modern drivers
> > on one close hook.
> > 
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> 
> Reviewed-by: Sean Paul <seanpaul@chromium.org>

Pushed to drm-misc.
-Daniel

> 
> > ---
> >  drivers/gpu/drm/vgem/vgem_drv.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c
> > index a1f42d125e6e..9fee38a942c4 100644
> > --- a/drivers/gpu/drm/vgem/vgem_drv.c
> > +++ b/drivers/gpu/drm/vgem/vgem_drv.c
> > @@ -104,7 +104,7 @@ static int vgem_open(struct drm_device *dev, struct drm_file *file)
> >  	return 0;
> >  }
> >  
> > -static void vgem_preclose(struct drm_device *dev, struct drm_file *file)
> > +static void vgem_postclose(struct drm_device *dev, struct drm_file *file)
> >  {
> >  	struct vgem_file *vfile = file->driver_priv;
> >  
> > @@ -303,7 +303,7 @@ static int vgem_prime_mmap(struct drm_gem_object *obj,
> >  static struct drm_driver vgem_driver = {
> >  	.driver_features		= DRIVER_GEM | DRIVER_PRIME,
> >  	.open				= vgem_open,
> > -	.preclose			= vgem_preclose,
> > +	.postclose			= vgem_postclose,
> >  	.gem_free_object_unlocked	= vgem_gem_free_object,
> >  	.gem_vm_ops			= &vgem_gem_vm_ops,
> >  	.ioctls				= vgem_ioctls,
> > -- 
> > 2.11.0
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 20/24] drm/exynos: Merge pre/postclose hooks
  2017-03-13 19:18   ` [Intel-gfx] " Sean Paul
@ 2017-03-14 13:28     ` Daniel Vetter
  2017-03-15  0:54       ` Inki Dae
  0 siblings, 1 reply; 72+ messages in thread
From: Daniel Vetter @ 2017-03-14 13:28 UTC (permalink / raw)
  To: Sean Paul
  Cc: Joonyoung Shim, Daniel Vetter, Intel Graphics Development,
	Seung-Woo Kim, DRI Development, Inki Dae, Kyungmin Park,
	Daniel Vetter

On Mon, Mar 13, 2017 at 03:18:05PM -0400, Sean Paul wrote:
> On Wed, Mar 08, 2017 at 03:12:53PM +0100, Daniel Vetter wrote:
> > Again no apparent explanation for the split except hysterical raisins.
> > Merging them also makes it a bit more obviuos what's going on wrt the
> > runtime pm refdancing.
> 
> Commit message copypasta.

Hm, yeah. Inki, can you pls adjust that when merging to exynos-next? Just
drop the last sentence that talks about pm refdancing.
-Daniel

> 
> The code is 
> 
> Reviewed-by: Sean Paul <seanpaul@chromium.org>
> 
> > 
> > Cc: Inki Dae <inki.dae@samsung.com>
> > Cc: Joonyoung Shim <jy0922.shim@samsung.com>
> > Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
> > Cc: Kyungmin Park <kyungmin.park@samsung.com>
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > ---
> >  drivers/gpu/drm/exynos/exynos_drm_drv.c | 8 +-------
> >  1 file changed, 1 insertion(+), 7 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> > index b4522f67b3cb..180e3c9884e5 100644
> > --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> > +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> > @@ -194,14 +194,9 @@ static int exynos_drm_open(struct drm_device *dev, struct drm_file *file)
> >  	return ret;
> >  }
> >  
> > -static void exynos_drm_preclose(struct drm_device *dev,
> > -					struct drm_file *file)
> > -{
> > -	exynos_drm_subdrv_close(dev, file);
> > -}
> > -
> >  static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file)
> >  {
> > +	exynos_drm_subdrv_close(dev, file);
> >  	kfree(file->driver_priv);
> >  	file->driver_priv = NULL;
> >  }
> > @@ -259,7 +254,6 @@ static struct drm_driver exynos_drm_driver = {
> >  	.load			= exynos_drm_load,
> >  	.unload			= exynos_drm_unload,
> >  	.open			= exynos_drm_open,
> > -	.preclose		= exynos_drm_preclose,
> >  	.lastclose		= exynos_drm_lastclose,
> >  	.postclose		= exynos_drm_postclose,
> >  	.gem_free_object_unlocked = exynos_drm_gem_free_object,
> > -- 
> > 2.11.0
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 24/24] drm/gem: Add DEFINE_DRM_GEM_FOPS
  2017-03-13 19:35   ` Sean Paul
@ 2017-03-14 13:31     ` Daniel Vetter
  0 siblings, 0 replies; 72+ messages in thread
From: Daniel Vetter @ 2017-03-14 13:31 UTC (permalink / raw)
  To: Sean Paul
  Cc: Daniel Vetter, Intel Graphics Development, DRI Development,
	Daniel Vetter

On Mon, Mar 13, 2017 at 03:35:43PM -0400, Sean Paul wrote:
> On Wed, Mar 08, 2017 at 03:12:57PM +0100, Daniel Vetter wrote:
> > Sadly there's only 1 driver which can use it, everyone else is special
> > for some reason:
> > 
> > - gma500 has a horrible runtime PM ioctl wrapper that probably doesn't
> >   really work but meh.
> > - i915 needs special compat_ioctl handler because regrets.
> > - arcgpu needs to fixup the pgprot because (no idea why it can't do
> >   that in the fault handler like everyone else).
> > - tegra does even worse stuff with pgprot
> > - udl does something with vm_flags too ...
> > - cma helpers, etnaviv, mtk, msm, rockchip, omap all implement some
> >   variation on prefaulting.
> > - exynos is exynos, I got lost in the midlayers.
> > - vc4 has to reinvent half of cma helpers because those are too much
> >   midlayer, plus vm_flags dances.
> > - vgem also seems unhappy with the default vm_flags.
> 
> I wonder whether a todo entry to clean this up would be appropriate.

I would have, if I actually had an idea what we should be doing here. All
the reasons are kinda semi-legit: Adjusting flags to get the right caching
mode, prefaulting, subclassing for special needs are all reasonable things
to do. I have honestly not enough clue about cross-platform issues to come
up with a good suggestion, especially about the flags stuff.

> Reviewed-by: Sean Paul <seanpaul@chromium.org>

Merged the last two patches too, thx a lot for review.
-Daniel

> > 
> > So pretty sad divergence and I'm sure we could do better, but not
> > really an idea. Oh well, maybe this macro here helps to encourage more
> > consistency at least going forward.
> > 
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > ---
> >  drivers/gpu/drm/armada/armada_drv.c | 11 +----------
> >  drivers/gpu/drm/drm_file.c          |  8 +++-----
> >  include/drm/drm_gem.h               | 26 ++++++++++++++++++++++++++
> >  3 files changed, 30 insertions(+), 15 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> > index 1952e8748fea..f986e9ff093d 100644
> > --- a/drivers/gpu/drm/armada/armada_drv.c
> > +++ b/drivers/gpu/drm/armada/armada_drv.c
> > @@ -60,16 +60,7 @@ static void armada_drm_lastclose(struct drm_device *dev)
> >  	armada_fbdev_lastclose(dev);
> >  }
> >  
> > -static const struct file_operations armada_drm_fops = {
> > -	.owner			= THIS_MODULE,
> > -	.llseek			= no_llseek,
> > -	.read			= drm_read,
> > -	.poll			= drm_poll,
> > -	.unlocked_ioctl		= drm_ioctl,
> > -	.mmap			= drm_gem_mmap,
> > -	.open			= drm_open,
> > -	.release		= drm_release,
> > -};
> > +DEFINE_DRM_GEM_FOPS(armada_drm_fops);
> >  
> >  static struct drm_driver armada_drm_driver = {
> >  	.lastclose		= armada_drm_lastclose,
> > diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> > index 260a83563976..0701362dcca1 100644
> > --- a/drivers/gpu/drm/drm_file.c
> > +++ b/drivers/gpu/drm/drm_file.c
> > @@ -89,11 +89,9 @@ DEFINE_MUTEX(drm_global_mutex);
> >   *             .mmap = drm_gem_mmap,
> >   *     };
> >   *
> > - * For CMA based drivers there is the DEFINE_DRM_GEM_CMA_FOPS() macro to make
> > - * this simpler.
> > - *
> > - * FIXME: We should have a macro for this (and the CMA version) so that drivers
> > - * don't have to repeat it all the time.
> > + * For plain GEM based drivers there is the DEFINE_DRM_GEM_FOPS() macro, and for
> > + * CMA based drivers there is the DEFINE_DRM_GEM_CMA_FOPS() macro to make this
> > + * simpler.
> >   */
> >  
> >  static int drm_open_helper(struct file *filp, struct drm_minor *minor);
> > diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
> > index b9ade75ecd82..663d80358057 100644
> > --- a/include/drm/drm_gem.h
> > +++ b/include/drm/drm_gem.h
> > @@ -178,6 +178,32 @@ struct drm_gem_object {
> >  	struct dma_buf_attachment *import_attach;
> >  };
> >  
> > +/**
> > + * DEFINE_DRM_GEM_FOPS() - macro to generate file operations for GEM drivers
> > + * @name: name for the generated structure
> > + *
> > + * This macro autogenerates a suitable &struct file_operations for GEM based
> > + * drivers, which can be assigned to &drm_driver.fops. Note that this structure
> > + * cannot be shared between drivers, because it contains a reference to the
> > + * current module using THIS_MODULE.
> > + *
> > + * Note that the declaration is already marked as static - if you need a
> > + * non-static version of this you're probably doing it wrong and will break the
> > + * THIS_MODULE reference by accident.
> > + */
> > +#define DEFINE_DRM_GEM_FOPS(name) \
> > +	static const struct file_operations name = {\
> > +		.owner		= THIS_MODULE,\
> > +		.open		= drm_open,\
> > +		.release	= drm_release,\
> > +		.unlocked_ioctl	= drm_ioctl,\
> > +		.compat_ioctl	= drm_compat_ioctl,\
> > +		.poll		= drm_poll,\
> > +		.read		= drm_read,\
> > +		.llseek		= noop_llseek,\
> > +		.mmap		= drm_gem_mmap,\
> > +	}
> > +
> >  void drm_gem_object_release(struct drm_gem_object *obj);
> >  void drm_gem_object_free(struct kref *kref);
> >  int drm_gem_object_init(struct drm_device *dev,
> > -- 
> > 2.11.0
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 12/24] drm/i915: Merge pre/postclose hooks
  2017-03-08 15:45     ` Daniel Vetter
@ 2017-03-14 13:38       ` Daniel Vetter
  0 siblings, 0 replies; 72+ messages in thread
From: Daniel Vetter @ 2017-03-14 13:38 UTC (permalink / raw)
  To: Chris Wilson, Daniel Vetter, DRI Development,
	Intel Graphics Development, Daniel Vetter

On Wed, Mar 08, 2017 at 04:45:13PM +0100, Daniel Vetter wrote:
> On Wed, Mar 08, 2017 at 03:07:48PM +0000, Chris Wilson wrote:
> > On Wed, Mar 08, 2017 at 03:12:45PM +0100, Daniel Vetter wrote:
> > > There's really not a reason afaics that we can't just clean up
> > > everything at the end, in the terminal postclose hook: Since this is
> > > closing a file descriptor we know no one else can have a reference or
> > > a thread doing something with that drm_file except the close code.
> > > Ordering shouldn't matter, as long as we don't kfree before we clean
> > > stuff up.
> > 
> > My gut feeling was that preclose is the one we want to keep, as that is
> > closer to the onion unwind - during open, we do the core drm ops first
> > (e.g. drm_gem_open) before the backend, so during close we should do the
> > driver before the core.
> > 
> > Maybe completely wrong ofc.
> 
> I wasn't sure whether drivers might have some random pointers to fpriv
> that they might chase when we tear down gem objects and stuff like that.
> And if you look at what's before postclose, we still have onion
> unwrapping: All the things before it (fb cleanup, gem cleanup, master
> dropping) is stuff that userspace adds to the file _after_ it's fully
> opened.
> 
> Well it's not entirely clear, because gem destroys the idr before
> postclose, which might or might not trip up someone.
> 
> But afaik all the other destructive cleanup is done after postclose.
> 
> So maybe that's the split we want in drm_close?
> 
> - First release all runtime resources acquired after ->open. Not
>   destructive cleanup, fpriv should keep working like right after ->open
>   has returned. These functions would all have _release in their names.
> - call the driver's ->postclose.
> - All the destructive cleanup. Those functions would all have _destroy in
>   their names.
> 
> Since there's not really a real issue right now I'd prefer if we postpone
> this cleanup though, and first get all the driver patches merged. Just in
> case I missed something ...
> 
> I kinda want to do an s/postclose/close/ using cocci anyway, so this isn't
> the last series on this topic.

And merged with Chris' irc r-b.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 22/24] drm: Nerf the preclose callback for modern drivers
  2017-03-13 19:29   ` [Intel-gfx] " Sean Paul
@ 2017-03-14 13:50     ` Daniel Vetter
  0 siblings, 0 replies; 72+ messages in thread
From: Daniel Vetter @ 2017-03-14 13:50 UTC (permalink / raw)
  To: Sean Paul
  Cc: Daniel Vetter, Intel Graphics Development, DRI Development,
	Daniel Vetter

On Mon, Mar 13, 2017 at 03:29:20PM -0400, Sean Paul wrote:
> On Wed, Mar 08, 2017 at 03:12:55PM +0100, Daniel Vetter wrote:
> > With all drivers converted there's only legacy dri1 drivers using it.
> > Not going to touch those, instead just hide it like we've done with
> > other dri1 driver hooks like firstopen.
> > 
> > In all this I didn't find any real reason why we'd needed 2 hooks, and
> > having symmetry between open and close just appeases my OCD better.
> > Yeah, someone else could do an s/postclose/close/, but that's for
> > someone who understands cocci. And maybe after this series is reviewed
> > and landed, to avoid patch-regen churn.
> > 
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > ---
> >  drivers/gpu/drm/drm_file.c |  8 ++++----
> >  include/drm/drm_drv.h      | 23 ++---------------------
> >  2 files changed, 6 insertions(+), 25 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> > index a8813a1115dc..f8483fc6d3d7 100644
> > --- a/drivers/gpu/drm/drm_file.c
> > +++ b/drivers/gpu/drm/drm_file.c
> > @@ -350,9 +350,8 @@ void drm_lastclose(struct drm_device * dev)
> >   *
> >   * This function must be used by drivers as their &file_operations.release
> >   * method. It frees any resources associated with the open file, and calls the
> > - * &drm_driver.preclose and &drm_driver.lastclose driver callbacks. If this is
> > - * the last open file for the DRM device also proceeds to call the
> > - * &drm_driver.lastclose driver callback.
> > + * &drm_driver.lastclose driver callback. If this is the last open file for the
> 
> s/lastclose/postclose/
> 
> Once that's fixed,
> 
> Reviewed-by: Sean Paul <seanpaul@chromium.org>

Fixed locally and will include it when I'm resending the entire pile with
the stragglers filled out.
-Daniel

> 
> > + * DRM device also proceeds to call the &drm_driver.lastclose driver callback.
> >   *
> >   * RETURNS:
> >   *
> > @@ -372,7 +371,8 @@ int drm_release(struct inode *inode, struct file *filp)
> >  	list_del(&file_priv->lhead);
> >  	mutex_unlock(&dev->filelist_mutex);
> >  
> > -	if (dev->driver->preclose)
> > +	if (drm_core_check_feature(dev, DRIVER_LEGACY) &&
> > +	    dev->driver->preclose)
> >  		dev->driver->preclose(dev, file_priv);
> >  
> >  	/* ========================================================
> > diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> > index 8f900fb30275..fde343e0d581 100644
> > --- a/include/drm/drm_drv.h
> > +++ b/include/drm/drm_drv.h
> > @@ -104,23 +104,6 @@ struct drm_driver {
> >  	int (*open) (struct drm_device *, struct drm_file *);
> >  
> >  	/**
> > -	 * @preclose:
> > -	 *
> > -	 * One of the driver callbacks when a new &struct drm_file is closed.
> > -	 * Useful for tearing down driver-private data structures allocated in
> > -	 * @open like buffer allocators, execution contexts or similar things.
> > -	 *
> > -	 * Since the display/modeset side of DRM can only be owned by exactly
> > -	 * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
> > -	 * there should never be a need to tear down any modeset related
> > -	 * resources in this callback. Doing so would be a driver design bug.
> > -	 *
> > -	 * FIXME: It is not really clear why there's both @preclose and
> > -	 * @postclose. Without a really good reason, use @postclose only.
> > -	 */
> > -	void (*preclose) (struct drm_device *, struct drm_file *file_priv);
> > -
> > -	/**
> >  	 * @postclose:
> >  	 *
> >  	 * One of the driver callbacks when a new &struct drm_file is closed.
> > @@ -131,9 +114,6 @@ struct drm_driver {
> >  	 * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
> >  	 * there should never be a need to tear down any modeset related
> >  	 * resources in this callback. Doing so would be a driver design bug.
> > -	 *
> > -	 * FIXME: It is not really clear why there's both @preclose and
> > -	 * @postclose. Without a really good reason, use @postclose only.
> >  	 */
> >  	void (*postclose) (struct drm_device *, struct drm_file *);
> >  
> > @@ -150,7 +130,7 @@ struct drm_driver {
> >  	 * state changes, e.g. in conjunction with the :ref:`vga_switcheroo`
> >  	 * infrastructure.
> >  	 *
> > -	 * This is called after @preclose and @postclose have been called.
> > +	 * This is called after @postclose hook has been called.
> >  	 *
> >  	 * NOTE:
> >  	 *
> > @@ -516,6 +496,7 @@ struct drm_driver {
> >  	/* List of devices hanging off this driver with stealth attach. */
> >  	struct list_head legacy_dev_list;
> >  	int (*firstopen) (struct drm_device *);
> > +	void (*preclose) (struct drm_device *, struct drm_file *file_priv);
> >  	int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
> >  	int (*dma_quiescent) (struct drm_device *);
> >  	int (*context_dtor) (struct drm_device *dev, int context);
> > -- 
> > 2.11.0
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [Intel-gfx] [PATCH 02/24] drm: Extract drm_prime.h
  2017-03-14  9:12     ` [Intel-gfx] " Daniel Vetter
@ 2017-03-14 15:42       ` Sean Paul
  0 siblings, 0 replies; 72+ messages in thread
From: Sean Paul @ 2017-03-14 15:42 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, DRI Development,
	Daniel Vetter

On Tue, Mar 14, 2017 at 10:12:59AM +0100, Daniel Vetter wrote:
> On Mon, Mar 13, 2017 at 12:42:54PM -0400, Sean Paul wrote:
> > On Wed, Mar 08, 2017 at 03:12:35PM +0100, Daniel Vetter wrote:
> > > +/**
> > > + * struct drm_prime_file_private - per-file tracking for PRIME
> > > + *
> > > + * This just contains the internal &struct dma_buf and handle caches for each
> > > + * &struct drm_file used by the PRIME core code.
> > > + */
> > > +
> > > +struct drm_prime_file_private {
> > > +/* private: */
> > 
> > I'm a little confused by this comment. The struct has private in its name, I'm
> > not sure you're adding any additional information. Could you either remove or
> > expand this?
> 
> private: is special markup for kernel-doc to ingore everything below as
> implementation-internals. This avoids warnings when building the docs. I
> have no idea why it doesn't use the usual /** kernel-doc comment starter

Yeah, that kind of sucks. When there are public and private members, it's pretty
easy to reason about. However, when the struct is strictly private, it's pretty
redundant/annoying.

Ah well.

Sean

> ...
> -Daniel
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH 20/24] drm/exynos: Merge pre/postclose hooks
  2017-03-14 13:28     ` Daniel Vetter
@ 2017-03-15  0:54       ` Inki Dae
  2017-03-15  9:09         ` [Intel-gfx] " Inki Dae
  0 siblings, 1 reply; 72+ messages in thread
From: Inki Dae @ 2017-03-15  0:54 UTC (permalink / raw)
  To: Daniel Vetter, Sean Paul
  Cc: Joonyoung Shim, Daniel Vetter, Intel Graphics Development,
	Seung-Woo Kim, DRI Development, Kyungmin Park, Daniel Vetter



2017년 03월 14일 22:28에 Daniel Vetter 이(가) 쓴 글:
> On Mon, Mar 13, 2017 at 03:18:05PM -0400, Sean Paul wrote:
>> On Wed, Mar 08, 2017 at 03:12:53PM +0100, Daniel Vetter wrote:
>>> Again no apparent explanation for the split except hysterical raisins.
>>> Merging them also makes it a bit more obviuos what's going on wrt the
>>> runtime pm refdancing.
>>
>> Commit message copypasta.
> 
> Hm, yeah. Inki, can you pls adjust that when merging to exynos-next? Just
> drop the last sentence that talks about pm refdancing.
> -Daniel

No problem. :)

Thanks,
Inki Dae

> 
>>
>> The code is 
>>
>> Reviewed-by: Sean Paul <seanpaul@chromium.org>
>>
>>>
>>> Cc: Inki Dae <inki.dae@samsung.com>
>>> Cc: Joonyoung Shim <jy0922.shim@samsung.com>
>>> Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
>>> Cc: Kyungmin Park <kyungmin.park@samsung.com>
>>> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
>>> ---
>>>  drivers/gpu/drm/exynos/exynos_drm_drv.c | 8 +-------
>>>  1 file changed, 1 insertion(+), 7 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>> index b4522f67b3cb..180e3c9884e5 100644
>>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>> @@ -194,14 +194,9 @@ static int exynos_drm_open(struct drm_device *dev, struct drm_file *file)
>>>  	return ret;
>>>  }
>>>  
>>> -static void exynos_drm_preclose(struct drm_device *dev,
>>> -					struct drm_file *file)
>>> -{
>>> -	exynos_drm_subdrv_close(dev, file);
>>> -}
>>> -
>>>  static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file)
>>>  {
>>> +	exynos_drm_subdrv_close(dev, file);
>>>  	kfree(file->driver_priv);
>>>  	file->driver_priv = NULL;
>>>  }
>>> @@ -259,7 +254,6 @@ static struct drm_driver exynos_drm_driver = {
>>>  	.load			= exynos_drm_load,
>>>  	.unload			= exynos_drm_unload,
>>>  	.open			= exynos_drm_open,
>>> -	.preclose		= exynos_drm_preclose,
>>>  	.lastclose		= exynos_drm_lastclose,
>>>  	.postclose		= exynos_drm_postclose,
>>>  	.gem_free_object_unlocked = exynos_drm_gem_free_object,
>>> -- 
>>> 2.11.0
>>>
>>> _______________________________________________
>>> Intel-gfx mailing list
>>> Intel-gfx@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [Intel-gfx] [PATCH 20/24] drm/exynos: Merge pre/postclose hooks
  2017-03-15  0:54       ` Inki Dae
@ 2017-03-15  9:09         ` Inki Dae
  2017-03-15  9:52           ` Daniel Vetter
  0 siblings, 1 reply; 72+ messages in thread
From: Inki Dae @ 2017-03-15  9:09 UTC (permalink / raw)
  To: dri-devel



2017년 03월 15일 09:54에 Inki Dae 이(가) 쓴 글:
> 
> 
> 2017년 03월 14일 22:28에 Daniel Vetter 이(가) 쓴 글:
>> On Mon, Mar 13, 2017 at 03:18:05PM -0400, Sean Paul wrote:
>>> On Wed, Mar 08, 2017 at 03:12:53PM +0100, Daniel Vetter wrote:
>>>> Again no apparent explanation for the split except hysterical raisins.
>>>> Merging them also makes it a bit more obviuos what's going on wrt the
>>>> runtime pm refdancing.
>>>
>>> Commit message copypasta.
>>
>> Hm, yeah. Inki, can you pls adjust that when merging to exynos-next? Just
>> drop the last sentence that talks about pm refdancing.
>> -Daniel
> 
> No problem. :)

Seems you want this patch to be tested enough on each maintainer tree. Picked it up.

Thanks,
Inki Dae

> 
> Thanks,
> Inki Dae
> 
>>
>>>
>>> The code is 
>>>
>>> Reviewed-by: Sean Paul <seanpaul@chromium.org>
>>>
>>>>
>>>> Cc: Inki Dae <inki.dae@samsung.com>
>>>> Cc: Joonyoung Shim <jy0922.shim@samsung.com>
>>>> Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
>>>> Cc: Kyungmin Park <kyungmin.park@samsung.com>
>>>> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
>>>> ---
>>>>  drivers/gpu/drm/exynos/exynos_drm_drv.c | 8 +-------
>>>>  1 file changed, 1 insertion(+), 7 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>>> index b4522f67b3cb..180e3c9884e5 100644
>>>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>>> @@ -194,14 +194,9 @@ static int exynos_drm_open(struct drm_device *dev, struct drm_file *file)
>>>>  	return ret;
>>>>  }
>>>>  
>>>> -static void exynos_drm_preclose(struct drm_device *dev,
>>>> -					struct drm_file *file)
>>>> -{
>>>> -	exynos_drm_subdrv_close(dev, file);
>>>> -}
>>>> -
>>>>  static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file)
>>>>  {
>>>> +	exynos_drm_subdrv_close(dev, file);
>>>>  	kfree(file->driver_priv);
>>>>  	file->driver_priv = NULL;
>>>>  }
>>>> @@ -259,7 +254,6 @@ static struct drm_driver exynos_drm_driver = {
>>>>  	.load			= exynos_drm_load,
>>>>  	.unload			= exynos_drm_unload,
>>>>  	.open			= exynos_drm_open,
>>>> -	.preclose		= exynos_drm_preclose,
>>>>  	.lastclose		= exynos_drm_lastclose,
>>>>  	.postclose		= exynos_drm_postclose,
>>>>  	.gem_free_object_unlocked = exynos_drm_gem_free_object,
>>>> -- 
>>>> 2.11.0
>>>>
>>>> _______________________________________________
>>>> Intel-gfx mailing list
>>>> Intel-gfx@lists.freedesktop.org
>>>> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
>>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [Intel-gfx] [PATCH 20/24] drm/exynos: Merge pre/postclose hooks
  2017-03-15  9:09         ` [Intel-gfx] " Inki Dae
@ 2017-03-15  9:52           ` Daniel Vetter
  0 siblings, 0 replies; 72+ messages in thread
From: Daniel Vetter @ 2017-03-15  9:52 UTC (permalink / raw)
  To: Inki Dae; +Cc: dri-devel

On Wed, Mar 15, 2017 at 06:09:25PM +0900, Inki Dae wrote:
> 
> 
> 2017년 03월 15일 09:54에 Inki Dae 이(가) 쓴 글:
> > 
> > 
> > 2017년 03월 14일 22:28에 Daniel Vetter 이(가) 쓴 글:
> >> On Mon, Mar 13, 2017 at 03:18:05PM -0400, Sean Paul wrote:
> >>> On Wed, Mar 08, 2017 at 03:12:53PM +0100, Daniel Vetter wrote:
> >>>> Again no apparent explanation for the split except hysterical raisins.
> >>>> Merging them also makes it a bit more obviuos what's going on wrt the
> >>>> runtime pm refdancing.
> >>>
> >>> Commit message copypasta.
> >>
> >> Hm, yeah. Inki, can you pls adjust that when merging to exynos-next? Just
> >> drop the last sentence that talks about pm refdancing.
> >> -Daniel
> > 
> > No problem. :)
> 
> Seems you want this patch to be tested enough on each maintainer tree. Picked it up.

Thanks a lot.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 72+ messages in thread

end of thread, other threads:[~2017-03-15  9:52 UTC | newest]

Thread overview: 72+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
2017-03-08 14:12 ` [PATCH 01/24] drm/doc: Add todo about connector_list_iter Daniel Vetter
2017-03-08 15:12   ` [Intel-gfx] " Sean Paul
2017-03-08 14:12 ` [PATCH 02/24] drm: Extract drm_prime.h Daniel Vetter
2017-03-08 14:57   ` Gustavo Padovan
2017-03-13 16:42   ` Sean Paul
2017-03-14  9:12     ` [Intel-gfx] " Daniel Vetter
2017-03-14 15:42       ` Sean Paul
2017-03-08 14:12 ` [PATCH 03/24] drm: Move drm_lock_data out of drmP.h Daniel Vetter
2017-03-08 14:58   ` Gustavo Padovan
2017-03-08 14:12 ` [PATCH 04/24] drm: Extract drm_pci.h Daniel Vetter
2017-03-08 14:59   ` [Intel-gfx] " Gustavo Padovan
2017-03-08 14:12 ` [PATCH 05/24] drm: Remove drmP.h include from drm_kms_helper_common.c Daniel Vetter
2017-03-08 15:00   ` [Intel-gfx] " Gustavo Padovan
2017-03-08 14:12 ` [PATCH 06/24] drm/doc: document fallback behaviour for atomic events Daniel Vetter
2017-03-08 14:57   ` Laurent Pinchart
2017-03-08 14:12 ` [PATCH 07/24] drm: rename drm_fops.c to drm_file.c Daniel Vetter
2017-03-08 15:02   ` [Intel-gfx] " Gustavo Padovan
2017-03-08 14:12 ` [PATCH 08/24] drm: Remove DRM_MINOR_CNT Daniel Vetter
2017-03-08 14:14   ` David Herrmann
2017-03-13 16:56   ` Sean Paul
2017-03-08 14:12 ` [PATCH 09/24] drm: Extract drm_file.h Daniel Vetter
2017-03-08 15:05   ` Gustavo Padovan
2017-03-09 10:52     ` Daniel Vetter
2017-03-08 14:12 ` [PATCH 10/24] drm: Remove drm_pending_event->pid Daniel Vetter
2017-03-13 17:05   ` [Intel-gfx] " Sean Paul
2017-03-14 13:20     ` Daniel Vetter
2017-03-08 14:12 ` [PATCH 11/24] drm/doc: Document drm_file.[hc] Daniel Vetter
2017-03-13 17:53   ` Sean Paul
2017-03-14 13:25     ` Daniel Vetter
2017-03-14 13:27     ` Daniel Vetter
2017-03-08 14:12 ` [PATCH 12/24] drm/i915: Merge pre/postclose hooks Daniel Vetter
2017-03-08 15:07   ` Chris Wilson
2017-03-08 15:45     ` Daniel Vetter
2017-03-14 13:38       ` Daniel Vetter
2017-03-08 14:12 ` [PATCH 13/24] drm/msm: switch to postclose Daniel Vetter
2017-03-13 18:59   ` Sean Paul
2017-03-08 14:12 ` [PATCH 16/24] drm/tegra: " Daniel Vetter
     [not found]   ` <20170308141257.12119-17-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
2017-03-13 19:10     ` Sean Paul
2017-03-08 14:12 ` [PATCH 17/24] drm/vgem: " Daniel Vetter
2017-03-13 19:11   ` Sean Paul
2017-03-14 13:27     ` Daniel Vetter
2017-03-08 14:12 ` [PATCH 18/24] drm/etnaviv: " Daniel Vetter
2017-03-08 16:09   ` Lucas Stach
2017-03-08 18:15     ` Daniel Vetter
2017-03-09 10:03       ` Lucas Stach
     [not found] ` <20170308141257.12119-1-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
2017-03-08 14:12   ` [PATCH 14/24] drm/nouveau: Merge pre/postclose hooks Daniel Vetter
     [not found]     ` <20170308141257.12119-15-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
2017-03-13 19:07       ` Sean Paul
2017-03-08 14:12   ` [PATCH 15/24] drm/radeon: " Daniel Vetter
     [not found]     ` <20170308141257.12119-16-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
2017-03-08 14:25       ` Christian König
     [not found]         ` <79dc5480-6354-2379-8a7a-a2c099209256-5C7GfCeVMHo@public.gmane.org>
2017-03-09  3:58           ` Alex Deucher
2017-03-08 14:12   ` [PATCH 19/24] drm/amdgpu: " Daniel Vetter
2017-03-08 14:12 ` [PATCH 20/24] drm/exynos: " Daniel Vetter
2017-03-13 19:18   ` [Intel-gfx] " Sean Paul
2017-03-14 13:28     ` Daniel Vetter
2017-03-15  0:54       ` Inki Dae
2017-03-15  9:09         ` [Intel-gfx] " Inki Dae
2017-03-15  9:52           ` Daniel Vetter
2017-03-08 14:12 ` [PATCH 21/24] drm/msm: Simplify vblank event delivery Daniel Vetter
2017-03-13 19:26   ` Sean Paul
2017-03-08 14:12 ` [PATCH 22/24] drm: Nerf the preclose callback for modern drivers Daniel Vetter
2017-03-09 10:48   ` Daniel Vetter
2017-03-13 19:29   ` [Intel-gfx] " Sean Paul
2017-03-14 13:50     ` Daniel Vetter
2017-03-08 14:12 ` [PATCH 23/24] drm: Create DEFINE_DRM_GEM_CMA_FOPS and roll it out to drivers Daniel Vetter
2017-03-13 17:11   ` Liviu Dudau
2017-03-13 19:31   ` [Intel-gfx] " Sean Paul
2017-03-13 19:33     ` Sean Paul
2017-03-08 14:12 ` [PATCH 24/24] drm/gem: Add DEFINE_DRM_GEM_FOPS Daniel Vetter
2017-03-13 19:35   ` Sean Paul
2017-03-14 13:31     ` Daniel Vetter
2017-03-08 17:52 ` ✓ Fi.CI.BAT: success for more docs and header splits Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.