Skip to contentSkip to conversation

drm/fence: add drm_crtc_create_fence()

PATCH In review Gustavo Padovan 2 participants 3 messages Dec 6, 2016 – Dec 7, 2016

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

PATCH 1/1 drm/fence: add drm_crtc_create_fence()

From: Gustavo Padovan <[email protected]>

Instead of dealing with crtc details inside drm_atomic.c we should just export a function that creates a new crtc fence for us and use that.

---
 drivers/gpu/drm/drm_atomic.c        | 16 +---------------
 drivers/gpu/drm/drm_crtc.c          | 18 +++++++++++++++++-
 drivers/gpu/drm/drm_crtc_internal.h |  2 +-
 3 files changed, 19 insertions(+), 17 deletions(-)
drivers/gpu/drm/drm_atomic.c +1 -15
index 19d7bcb..72fa5b2 100644
@@ -1864,20 +1864,6 @@ EXPORT_SYMBOL(drm_atomic_clean_old_fb);
  *	helpers and for the DRM event handling for existing userspace.
  */
 
-static struct dma_fence *get_crtc_fence(struct drm_crtc *crtc)
-{
-	struct dma_fence *fence;
-
-	fence = kzalloc(sizeof(*fence), GFP_KERNEL);
-	if (!fence)
-		return NULL;
-
-	dma_fence_init(fence, &drm_crtc_fence_ops, &crtc->fence_lock,
-		       crtc->fence_context, ++crtc->fence_seqno);
-
-	return fence;
-}
-
 struct drm_out_fence_state {
 	s64 __user *out_fence_ptr;
 	struct sync_file *sync_file;
@@ -1959,7 +1945,7 @@ static int prepare_crtc_signaling(struct drm_device *dev,
 			f[*num_fences].out_fence_ptr = fence_ptr;
 			*fence_state = f;
 
-			fence = get_crtc_fence(crtc);
+			fence = drm_crtc_create_fence(crtc);
 			if (!fence)
 				return -ENOMEM;
 
drivers/gpu/drm/drm_crtc.c +17 -1
index 90931e0..e75f62c 100644
@@ -152,6 +152,8 @@ static void drm_crtc_crc_fini(struct drm_crtc *crtc)
 #endif
 }
 
+static const struct dma_fence_ops drm_crtc_fence_ops;
+
 static struct drm_crtc *fence_to_crtc(struct dma_fence *fence)
 {
 	BUG_ON(fence->ops != &drm_crtc_fence_ops);
@@ -177,13 +179,27 @@ static bool drm_crtc_fence_enable_signaling(struct dma_fence *fence)
 	return true;
 }
 
-const struct dma_fence_ops drm_crtc_fence_ops = {
+static const struct dma_fence_ops drm_crtc_fence_ops = {
 	.get_driver_name = drm_crtc_fence_get_driver_name,
 	.get_timeline_name = drm_crtc_fence_get_timeline_name,
 	.enable_signaling = drm_crtc_fence_enable_signaling,
 	.wait = dma_fence_default_wait,
 };
 
+struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc)
+{
+	struct dma_fence *fence;
+
+	fence = kzalloc(sizeof(*fence), GFP_KERNEL);
+	if (!fence)
+		return NULL;
+
+	dma_fence_init(fence, &drm_crtc_fence_ops, &crtc->fence_lock,
+		       crtc->fence_context, ++crtc->fence_seqno);
+
+	return fence;
+}
+
 /**
  * drm_crtc_init_with_planes - Initialise a new CRTC object with
  *    specified primary and cursor planes.
drivers/gpu/drm/drm_crtc_internal.h +1 -1
index 33b17d0..cdf6860 100644
@@ -43,7 +43,7 @@ int drm_crtc_check_viewport(const struct drm_crtc *crtc,
 int drm_crtc_register_all(struct drm_device *dev);
 void drm_crtc_unregister_all(struct drm_device *dev);
 
-extern const struct dma_fence_ops drm_crtc_fence_ops;
+struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc);
 
 /* IOCTLs */
 int drm_mode_getcrtc(struct drm_device *dev,
Signature · 6 lines
2.5.5

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Gustavo Padovan

From: Gustavo Padovan <[email protected]>

Instead of dealing with crtc details inside drm_atomic.c we should just export a function that creates a new crtc fence for us and use that.

Yeah, seems reasonable.

Quoted 102 lines
---
 drivers/gpu/drm/drm_atomic.c        | 16 +---------------
 drivers/gpu/drm/drm_crtc.c          | 18 +++++++++++++++++-
 drivers/gpu/drm/drm_crtc_internal.h |  2 +-
 3 files changed, 19 insertions(+), 17 deletions(-)
drivers/gpu/drm/drm_atomic.c +1 -15
index 19d7bcb..72fa5b2 100644
@@ -1864,20 +1864,6 @@ EXPORT_SYMBOL(drm_atomic_clean_old_fb);
  *	helpers and for the DRM event handling for existing userspace.
  */
 
-static struct dma_fence *get_crtc_fence(struct drm_crtc *crtc)
-{
-	struct dma_fence *fence;
-
-	fence = kzalloc(sizeof(*fence), GFP_KERNEL);
-	if (!fence)
-		return NULL;
-
-	dma_fence_init(fence, &drm_crtc_fence_ops, &crtc->fence_lock,
-		       crtc->fence_context, ++crtc->fence_seqno);
-
-	return fence;
-}
-
 struct drm_out_fence_state {
 	s64 __user *out_fence_ptr;
 	struct sync_file *sync_file;
@@ -1959,7 +1945,7 @@ static int prepare_crtc_signaling(struct drm_device *dev,
 			f[*num_fences].out_fence_ptr = fence_ptr;
 			*fence_state = f;
 
-			fence = get_crtc_fence(crtc);
+			fence = drm_crtc_create_fence(crtc);
 			if (!fence)
 				return -ENOMEM;
 
drivers/gpu/drm/drm_crtc.c +17 -1
index 90931e0..e75f62c 100644
@@ -152,6 +152,8 @@ static void drm_crtc_crc_fini(struct drm_crtc *crtc)
 #endif
 }
 
+static const struct dma_fence_ops drm_crtc_fence_ops;
+
 static struct drm_crtc *fence_to_crtc(struct dma_fence *fence)
 {
 	BUG_ON(fence->ops != &drm_crtc_fence_ops);
@@ -177,13 +179,27 @@ static bool drm_crtc_fence_enable_signaling(struct dma_fence *fence)
 	return true;
 }
 
-const struct dma_fence_ops drm_crtc_fence_ops = {
+static const struct dma_fence_ops drm_crtc_fence_ops = {
 	.get_driver_name = drm_crtc_fence_get_driver_name,
 	.get_timeline_name = drm_crtc_fence_get_timeline_name,
 	.enable_signaling = drm_crtc_fence_enable_signaling,
 	.wait = dma_fence_default_wait,
 };
 
+struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc)
+{
+	struct dma_fence *fence;
+
+	fence = kzalloc(sizeof(*fence), GFP_KERNEL);
+	if (!fence)
+		return NULL;
+
+	dma_fence_init(fence, &drm_crtc_fence_ops, &crtc->fence_lock,
+		       crtc->fence_context, ++crtc->fence_seqno);
+
+	return fence;
+}
+
 /**
  * drm_crtc_init_with_planes - Initialise a new CRTC object with
  *    specified primary and cursor planes.
drivers/gpu/drm/drm_crtc_internal.h +1 -1
index 33b17d0..cdf6860 100644
@@ -43,7 +43,7 @@ int drm_crtc_check_viewport(const struct drm_crtc *crtc,
 int drm_crtc_register_all(struct drm_device *dev);
 void drm_crtc_unregister_all(struct drm_device *dev);
 
-extern const struct dma_fence_ops drm_crtc_fence_ops;
+struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc);
 
 /* IOCTLs */
 int drm_mode_getcrtc(struct drm_device *dev,
Signature · 6 lines
2.5.5

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

2016-12-07 Daniel Vetter <[email protected]>:

Quoted 7 lines · Gustavo Padovan
Quoted 6 lines

From: Gustavo Padovan <[email protected]>

Instead of dealing with crtc details inside drm_atomic.c we should just export a function that creates a new crtc fence for us and use that.

Quoted 6 lines
Quoted 2 lines

Yeah, seems reasonable.

Applied to drm-misc. Thanks for reviewing.

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