All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/9] drm: Create a driver hook for allocating GEM object structs.
@ 2015-12-01 20:35 ` Eric Anholt
  0 siblings, 0 replies; 53+ messages in thread
From: Eric Anholt @ 2015-12-01 20:35 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-kernel

The CMA helpers had no way for a driver to extend the struct with its
own fields.  Since the CMA helpers are mostly "Allocate a
drm_gem_cma_object, then fill in a few fields", it's hard to write as
pure helpers without passing in a driver callback for the allocate
step.

Signed-off-by: Eric Anholt <eric@anholt.net>
---
 drivers/gpu/drm/drm_gem_cma_helper.c | 10 ++++++----
 include/drm/drmP.h                   |  7 +++++++
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
index e109b49..0f7b00ba 100644
--- a/drivers/gpu/drm/drm_gem_cma_helper.c
+++ b/drivers/gpu/drm/drm_gem_cma_helper.c
@@ -59,11 +59,13 @@ __drm_gem_cma_create(struct drm_device *drm, size_t size)
 	struct drm_gem_object *gem_obj;
 	int ret;
 
-	cma_obj = kzalloc(sizeof(*cma_obj), GFP_KERNEL);
-	if (!cma_obj)
+	if (drm->driver->gem_create_object)
+		gem_obj = drm->driver->gem_create_object(drm, size);
+	else
+		gem_obj = kzalloc(sizeof(*cma_obj), GFP_KERNEL);
+	if (!gem_obj)
 		return ERR_PTR(-ENOMEM);
-
-	gem_obj = &cma_obj->base;
+	cma_obj = container_of(gem_obj, struct drm_gem_cma_object, base);
 
 	ret = drm_gem_object_init(drm, gem_obj, size);
 	if (ret)
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 0b921ae..22ff162 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -580,6 +580,13 @@ struct drm_driver {
 	int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
 	void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
 
+	/**
+	 * Hook for allocating the GEM object struct, for use by core
+	 * helpers.
+	 */
+	struct drm_gem_object *(*gem_create_object)(struct drm_device *dev,
+						    size_t size);
+
 	/* prime: */
 	/* export handle -> fd (see drm_gem_prime_handle_to_fd() helper) */
 	int (*prime_handle_to_fd)(struct drm_device *dev, struct drm_file *file_priv,
-- 
2.6.2

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

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

end of thread, other threads:[~2015-12-08  4:06 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-01 20:35 [PATCH 1/9] drm: Create a driver hook for allocating GEM object structs Eric Anholt
2015-12-01 20:35 ` Eric Anholt
2015-12-01 20:35 ` [PATCH 2/9] drm/vc4: Add a BO cache Eric Anholt
2015-12-01 20:35   ` Eric Anholt
2015-12-01 20:35 ` [PATCH 3/9] drm/vc4: Add create and map BO ioctls Eric Anholt
2015-12-01 20:35   ` Eric Anholt
2015-12-04 14:29   ` Emil Velikov
2015-12-04 14:29     ` Emil Velikov
2015-12-08  1:16     ` Eric Anholt
2015-12-08  1:16       ` Eric Anholt
2015-12-08  2:56       ` Michel Dänzer
2015-12-08  2:56         ` Michel Dänzer
2015-12-08  4:05         ` Eric Anholt
2015-12-08  4:05           ` Eric Anholt
2015-12-01 20:35 ` [PATCH 4/9] drm/vc4: Add an API for creating GPU shaders in GEM BOs Eric Anholt
2015-12-01 20:35   ` Eric Anholt
2015-12-02 11:35   ` Emil Velikov
2015-12-02 11:35     ` Emil Velikov
2015-12-02 19:24     ` Eric Anholt
2015-12-02 19:24       ` Eric Anholt
2015-12-01 20:35 ` [PATCH 5/9] drm/vc4: Fix a typo in a V3D debug register Eric Anholt
2015-12-01 20:35   ` Eric Anholt
2015-12-01 20:35 ` [PATCH 6/9] drm/vc4: Bind and initialize the V3D engine Eric Anholt
2015-12-01 20:35   ` Eric Anholt
2015-12-01 20:35 ` [PATCH 7/9] drm/vc4: Add support for drawing 3D frames Eric Anholt
2015-12-01 20:35   ` Eric Anholt
2015-12-02 11:29   ` Emil Velikov
2015-12-02 11:29     ` Emil Velikov
2015-12-02 19:27     ` Eric Anholt
2015-12-02 19:27       ` Eric Anholt
2015-12-01 20:35 ` [PATCH 8/9] drm/vc4: Add support for async pageflips Eric Anholt
2015-12-01 20:35   ` Eric Anholt
2015-12-02 14:05   ` Daniel Stone
2015-12-02 14:05     ` Daniel Stone
2015-12-04  1:42     ` Eric Anholt
2015-12-04  1:42       ` Eric Anholt
2015-12-07 10:13       ` Daniel Stone
2015-12-07 10:13         ` Daniel Stone
2015-12-01 20:35 ` [PATCH 9/9] drm/vc4: Add an interface for capturing the GPU state after a hang Eric Anholt
2015-12-01 20:35   ` Eric Anholt
2015-12-02 11:45   ` Emil Velikov
2015-12-02 11:45     ` Emil Velikov
2015-12-02 19:35     ` Eric Anholt
2015-12-02 19:35       ` Eric Anholt
2015-12-02 22:26       ` Daniel Vetter
2015-12-02 22:26         ` Daniel Vetter
2015-12-02 22:58         ` Daniel Stone
2015-12-03 11:55           ` Emil Velikov
2015-12-03 11:55             ` Emil Velikov
2015-12-03 11:46       ` Emil Velikov
2015-12-03 11:46         ` Emil Velikov
2015-12-02  8:58 ` [PATCH 1/9] drm: Create a driver hook for allocating GEM object structs Daniel Vetter
2015-12-02  8:58   ` Daniel Vetter

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.