[PATCH 128/156] drm/nouveau/nvif: rework head "new event" api

Ben Skeggs bskeggs at nvidia.com
Tue Apr 16 23:39:34 UTC 2024


- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs at nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  3 +++
 drivers/gpu/drm/nouveau/include/nvif/if0013.h |  9 ---------
 drivers/gpu/drm/nouveau/nouveau_display.c     |  1 -
 drivers/gpu/drm/nouveau/nvif/head.c           | 15 +++++++++------
 .../gpu/drm/nouveau/nvkm/engine/disp/uhead.c  | 19 ++++++-------------
 5 files changed, 18 insertions(+), 29 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0013.h

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 927d0d75dd29..7aa44e4fe729 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -355,6 +355,9 @@ struct nvif_head_impl {
 	int (*scanoutpos)(struct nvif_head_priv *, s64 time[2],
 			  u16 *vblanks, u16 *vblanke, u16 *vtotal, u16 *vline,
 			  u16 *hblanks, u16 *hblanke, u16 *htotal, u16 *hline);
+
+	int (*vblank)(struct nvif_head_priv *, u64 handle,
+		      const struct nvif_event_impl **, struct nvif_event_priv **);
 };
 
 struct nvif_disp_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0013.h b/drivers/gpu/drm/nouveau/include/nvif/if0013.h
deleted file mode 100644
index f2b39f86a9cc..000000000000
--- a/drivers/gpu/drm/nouveau/include/nvif/if0013.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVIF_IF0013_H__
-#define __NVIF_IF0013_H__
-
-union nvif_head_event_args {
-	struct nvif_head_event_vn {
-	} vn;
-};
-#endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 0d2dae7a94d0..3f75c7f33429 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -42,7 +42,6 @@
 
 #include <nvif/class.h>
 #include <nvif/if0011.h>
-#include <nvif/if0013.h>
 #include <dispnv50/crc.h>
 
 int
diff --git a/drivers/gpu/drm/nouveau/nvif/head.c b/drivers/gpu/drm/nouveau/nvif/head.c
index 777f12f3236f..05f56169e6c3 100644
--- a/drivers/gpu/drm/nouveau/nvif/head.c
+++ b/drivers/gpu/drm/nouveau/nvif/head.c
@@ -24,17 +24,20 @@
 #include <nvif/driverif.h>
 #include <nvif/printf.h>
 
-#include <nvif/class.h>
-#include <nvif/if0013.h>
-
 int
 nvif_head_vblank_event_ctor(struct nvif_head *head, const char *name, nvif_event_func func,
 			    bool wait, struct nvif_event *event)
 {
-	int ret = nvif_event_ctor(&head->object, name ?: "nvifHeadVBlank", nvif_head_id(head),
-				  func, wait, NULL, 0, event);
+	int ret;
+
+	ret = head->impl->vblank(head->priv, nvif_handle(&event->object),
+				 &event->impl, &event->priv);
 	NVIF_ERRON(ret, &head->object, "[NEW EVENT:VBLANK]");
-	return ret;
+	if (ret)
+		return ret;
+
+	nvif_event_ctor(&head->object, name ?: "nvifHeadVblank", nvif_head_id(head), func, event);
+	return 0;
 }
 
 void
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
index ebf72333ae99..0ad97094a8c7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
@@ -22,8 +22,6 @@
 #include "uhead.h"
 #include <core/event.h>
 
-#include <nvif/if0013.h>
-
 #include <nvif/event.h>
 
 struct nvif_head_priv {
@@ -32,18 +30,13 @@ struct nvif_head_priv {
 };
 
 static int
-nvkm_uhead_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_uevent *uevent)
+nvkm_uhead_vblank(struct nvif_head_priv *uhead, u64 handle,
+		  const struct nvif_event_impl **pimpl, struct nvif_event_priv **ppriv)
 {
-	struct nvkm_head *head = container_of(object, struct nvif_head_priv, object)->head;
-	union nvif_head_event_args *args = argv;
-
-	if (!uevent)
-		return 0;
-	if (argc != sizeof(args->vn))
-		return -ENOSYS;
+	struct nvkm_head *head = uhead->head;
 
-	return nvkm_uevent_add(uevent, &head->disp->vblank, head->id,
-			       NVKM_DISP_HEAD_EVENT_VBLANK, NULL);
+	return nvkm_uevent_new_(&uhead->object, handle, &head->disp->vblank, false, head->id,
+				NVKM_DISP_HEAD_EVENT_VBLANK, NULL, pimpl, ppriv);
 }
 
 static int
@@ -86,6 +79,7 @@ static const struct nvif_head_impl
 nvkm_uhead_impl = {
 	.del = nvkm_uhead_del,
 	.scanoutpos = nvkm_uhead_scanoutpos,
+	.vblank = nvkm_uhead_vblank,
 };
 
 static void *
@@ -103,7 +97,6 @@ nvkm_uhead_dtor(struct nvkm_object *object)
 static const struct nvkm_object_func
 nvkm_uhead = {
 	.dtor = nvkm_uhead_dtor,
-	.uevent = nvkm_uhead_uevent,
 };
 
 int
-- 
2.41.0



More information about the Nouveau mailing list