[PATCH 126/156] drm/nouveau/nvif: rework disp "new head" api
Ben Skeggs
bskeggs at nvidia.com
Tue Apr 16 23:39:32 UTC 2024
- transition from "ioctl" interface
Signed-off-by: Ben Skeggs <bskeggs at nvidia.com>
---
.../gpu/drm/nouveau/include/nvif/driverif.h | 8 ++++++
drivers/gpu/drm/nouveau/include/nvif/head.h | 2 ++
drivers/gpu/drm/nouveau/include/nvif/if0013.h | 8 ------
drivers/gpu/drm/nouveau/nvif/head.c | 21 ++++++++------
.../gpu/drm/nouveau/nvkm/engine/disp/priv.h | 2 --
.../gpu/drm/nouveau/nvkm/engine/disp/udisp.c | 24 +++++++++++-----
.../gpu/drm/nouveau/nvkm/engine/disp/uhead.c | 28 +++++++++++++------
.../gpu/drm/nouveau/nvkm/engine/disp/uhead.h | 3 ++
8 files changed, 63 insertions(+), 33 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 57ad5022a534..83acedd108bb 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -16,6 +16,7 @@ struct nvif_disp_priv;
struct nvif_disp_caps_priv;
struct nvif_conn_priv;
struct nvif_outp_priv;
+struct nvif_head_priv;
struct nvif_driver {
const char *name;
@@ -348,6 +349,10 @@ struct nvif_outp_impl {
} dp;
};
+struct nvif_head_impl {
+ void (*del)(struct nvif_head_priv *);
+};
+
struct nvif_disp_impl {
void (*del)(struct nvif_disp_priv *);
@@ -371,6 +376,9 @@ struct nvif_disp_impl {
struct {
u32 mask;
+ int (*new)(struct nvif_disp_priv *, u8 id,
+ const struct nvif_head_impl **, struct nvif_head_priv **,
+ u64 handle);
} head;
struct {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/head.h b/drivers/gpu/drm/nouveau/include/nvif/head.h
index 3ec36999e956..fb25cd60987a 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/head.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/head.h
@@ -6,6 +6,8 @@
struct nvif_disp;
struct nvif_head {
+ const struct nvif_head_impl *impl;
+ struct nvif_head_priv *priv;
struct nvif_object object;
};
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0013.h b/drivers/gpu/drm/nouveau/include/nvif/if0013.h
index 6756c7467ae4..751f75bf7e59 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0013.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0013.h
@@ -2,14 +2,6 @@
#ifndef __NVIF_IF0013_H__
#define __NVIF_IF0013_H__
-union nvif_head_args {
- struct nvif_head_v0 {
- __u8 version;
- __u8 id;
- __u8 pad02[6];
- } v0;
-};
-
union nvif_head_event_args {
struct nvif_head_event_vn {
} vn;
diff --git a/drivers/gpu/drm/nouveau/nvif/head.c b/drivers/gpu/drm/nouveau/nvif/head.c
index f00e01d232db..777f12f3236f 100644
--- a/drivers/gpu/drm/nouveau/nvif/head.c
+++ b/drivers/gpu/drm/nouveau/nvif/head.c
@@ -21,6 +21,7 @@
*/
#include <nvif/head.h>
#include <nvif/disp.h>
+#include <nvif/driverif.h>
#include <nvif/printf.h>
#include <nvif/class.h>
@@ -39,20 +40,24 @@ nvif_head_vblank_event_ctor(struct nvif_head *head, const char *name, nvif_event
void
nvif_head_dtor(struct nvif_head *head)
{
- nvif_object_dtor(&head->object);
+ if (!head->impl)
+ return;
+
+ head->impl->del(head->priv);
+ head->impl = NULL;
}
int
nvif_head_ctor(struct nvif_disp *disp, const char *name, int id, struct nvif_head *head)
{
- struct nvif_head_v0 args;
int ret;
- args.version = 0;
- args.id = id;
+ ret = disp->impl->head.new(disp->priv, id, &head->impl, &head->priv,
+ nvif_handle(&head->object));
+ NVIF_ERRON(ret, &disp->object, "[NEW head id:%d]", id);
+ if (ret)
+ return ret;
- ret = nvif_object_ctor(&disp->object, name ? name : "nvifHead", id, NVIF_CLASS_HEAD,
- &args, sizeof(args), &head->object);
- NVIF_ERRON(ret, &disp->object, "[NEW head id:%d]", args.id);
- return ret;
+ nvif_object_ctor(&disp->object, name ?: "nvifHead", id, 0, &head->object);
+ return 0;
}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
index 0163660f215d..d16b47b2a9d6 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
@@ -88,6 +88,4 @@ void nv50_disp_chan_uevent_send(struct nvkm_disp *, int);
extern const struct nvkm_event_func gf119_disp_chan_uevent;
extern const struct nvkm_event_func gv100_disp_chan_uevent;
-
-int nvkm_uhead_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
index 0be6b28c79b8..6a65b3bffc19 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c
@@ -23,7 +23,7 @@
#include "ucaps.h"
#include "chan.h"
#include "uconn.h"
-#include "head.h"
+#include "uhead.h"
#include "uoutp.h"
#include <nvif/class.h>
@@ -33,12 +33,6 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
{
struct nvkm_disp *disp = container_of(object, struct nvif_disp_priv, object)->disp;
- if (index-- == 0) {
- sclass->base = (struct nvkm_sclass) { 0, 0, NVIF_CLASS_HEAD };
- sclass->ctor = nvkm_uhead_new;
- return 0;
- }
-
if (disp->func->user.core.oclass && index-- == 0) {
sclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.core.oclass };
sclass->ctor = nvkm_disp_core_new;
@@ -84,6 +78,21 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
return -EINVAL;
}
+static int
+nvkm_udisp_head_new(struct nvif_disp_priv *udisp, u8 id,
+ const struct nvif_head_impl **pimpl, struct nvif_head_priv **ppriv,
+ u64 handle)
+{
+ struct nvkm_object *object;
+ int ret;
+
+ ret = nvkm_uhead_new(udisp->disp, id, pimpl, ppriv, &object);
+ if (ret)
+ return ret;
+
+ return nvkm_object_link_rb(udisp->object.client, &udisp->object, handle, object);
+}
+
static int
nvkm_udisp_outp_new(struct nvif_disp_priv *udisp, u8 id,
const struct nvif_outp_impl **pimpl, struct nvif_outp_priv **ppriv)
@@ -143,6 +152,7 @@ nvkm_udisp_impl = {
.del = nvkm_udisp_del,
.conn.new = nvkm_udisp_conn_new,
.outp.new = nvkm_udisp_outp_new,
+ .head.new = nvkm_udisp_head_new,
};
static void *
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
index 3be82e01a59a..3456e988f9b3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
@@ -87,6 +87,19 @@ nvkm_uhead_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
}
}
+static void
+nvkm_uhead_del(struct nvif_head_priv *uhead)
+{
+ struct nvkm_object *object = &uhead->object;
+
+ nvkm_object_del(&object);
+}
+
+static const struct nvif_head_impl
+nvkm_uhead_impl = {
+ .del = nvkm_uhead_del,
+};
+
static void *
nvkm_uhead_dtor(struct nvkm_object *object)
{
@@ -106,18 +119,14 @@ nvkm_uhead = {
.uevent = nvkm_uhead_uevent,
};
-#include "udisp.h"
int
-nvkm_uhead_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nvkm_object **pobject)
+nvkm_uhead_new(struct nvkm_disp *disp, u8 id, const struct nvif_head_impl **pimpl,
+ struct nvif_head_priv **ppriv, struct nvkm_object **pobject)
{
- struct nvkm_disp *disp = container_of(oclass->parent, struct nvif_disp_priv, object)->disp;
struct nvkm_head *head;
- union nvif_head_args *args = argv;
struct nvif_head_priv *uhead;
- if (argc != sizeof(args->v0) || args->v0.version != 0)
- return -ENOSYS;
- if (!(head = nvkm_head_find(disp, args->v0.id)))
+ if (!(head = nvkm_head_find(disp, id)))
return -EINVAL;
uhead = kzalloc(sizeof(*uhead), GFP_KERNEL);
@@ -133,8 +142,11 @@ nvkm_uhead_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nv
head->user = true;
spin_unlock(&disp->user.lock);
- nvkm_object_ctor(&nvkm_uhead, oclass, &uhead->object);
+ nvkm_object_ctor(&nvkm_uhead, &(struct nvkm_oclass) {}, &uhead->object);
uhead->head = head;
+
+ *pimpl = &nvkm_uhead_impl;
+ *ppriv = uhead;
*pobject = &uhead->object;
return 0;
}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.h
index f19c9ae33707..1291f8c3874e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.h
@@ -2,5 +2,8 @@
#ifndef __NVKM_UHEAD_H__
#define __NVKM_UHEAD_H__
#include "head.h"
+#include <nvif/driverif.h>
+int nvkm_uhead_new(struct nvkm_disp *, u8 id, const struct nvif_head_impl **,
+ struct nvif_head_priv **, struct nvkm_object **);
#endif
--
2.41.0
More information about the Nouveau
mailing list