[PATCH 124/156] drm/nouveau/nvif: rework outp "dp mst vcpi" api

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


- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs at nvidia.com>
---
 drivers/gpu/drm/nouveau/dispnv50/disp.c       |  1 -
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  2 +
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 17 ------
 drivers/gpu/drm/nouveau/include/nvif/outp.h   |  1 -
 drivers/gpu/drm/nouveau/nvif/outp.c           | 12 +----
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 54 +++++--------------
 6 files changed, 17 insertions(+), 70 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0012.h

diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index 0bac0e813184..5e12de0aabb6 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -50,7 +50,6 @@
 #include <nvif/class.h>
 #include <nvif/cl0002.h>
 #include <nvif/event.h>
-#include <nvif/if0012.h>
 #include <nvif/if0014.h>
 #include <nvif/timer.h>
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index e2123ba48fc7..f7c7a98089b3 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -343,6 +343,8 @@ struct nvif_outp_impl {
 			   u32 watermark, u32 hblanksym, u32 vblanksym);
 		int (*mst_id_get)(struct nvif_outp_priv *, u32 *id);
 		int (*mst_id_put)(struct nvif_outp_priv *, u32 id);
+		int (*mst_vcpi)(struct nvif_outp_priv *, u8 head,
+				u8 start_slot, u8 num_slots, u16 pbn, u16 aligned_pbn);
 	} dp;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
deleted file mode 100644
index 3c74cd17a3a7..000000000000
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVIF_IF0012_H__
-#define __NVIF_IF0012_H__
-
-#define NVIF_OUTP_V0_DP_MST_VCPI   0x78
-
-union nvif_outp_dp_mst_vcpi_args {
-	struct nvif_outp_dp_mst_vcpi_v0 {
-		__u8  version;
-		__u8  head;
-		__u8  start_slot;
-		__u8  num_slots;
-		__u16 pbn;
-		__u16 aligned_pbn;
-	} v0;
-};
-#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/outp.h b/drivers/gpu/drm/nouveau/include/nvif/outp.h
index 7f7620ec1487..ea4d2d4f11f8 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/outp.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/outp.h
@@ -3,7 +3,6 @@
 #define __NVIF_OUTP_H__
 #include <nvif/object.h>
 #include <nvif/driverif.h>
-#include <nvif/if0012.h>
 #include <drm/display/drm_dp.h>
 struct nvif_disp;
 
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index cca1c28671f4..f04154e7a7b4 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -29,20 +29,12 @@ int
 nvif_outp_dp_mst_vcpi(struct nvif_outp *outp, int head,
 		      u8 start_slot, u8 num_slots, u16 pbn, u16 aligned_pbn)
 {
-	struct nvif_outp_dp_mst_vcpi_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.head = head;
-	args.start_slot = start_slot;
-	args.num_slots = num_slots;
-	args.pbn = pbn;
-	args.aligned_pbn = aligned_pbn;
-
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_DP_MST_VCPI, &args, sizeof(args));
+	ret = outp->impl->dp.mst_vcpi(outp->priv, head, start_slot, num_slots, pbn, aligned_pbn);
 	NVIF_ERRON(ret, &outp->object,
 		   "[DP_MST_VCPI head:%d start_slot:%02x num_slots:%02x pbn:%04x aligned_pbn:%04x]",
-		   args.head, args.start_slot, args.num_slots, args.pbn, args.aligned_pbn);
+		   head, start_slot, num_slots, pbn, aligned_pbn);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index eead485fe0e2..9d415a71c744 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -26,8 +26,6 @@
 
 #include <subdev/i2c.h>
 
-#include <nvif/if0012.h>
-
 struct nvif_outp_priv {
 	struct nvkm_object object;
 	struct nvkm_outp *outp;
@@ -61,18 +59,22 @@ nvkm_uoutp_lock_acquired(struct nvif_outp_priv *uoutp)
 }
 
 static int
-nvkm_uoutp_mthd_dp_mst_vcpi(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_dp_mst_vcpi(struct nvif_outp_priv *uoutp, u8 head,
+		       u8 start_slot, u8 num_slots, u16 pbn, u16 aligned_pbn)
 {
-	struct nvkm_ior *ior = outp->ior;
-	union nvif_outp_dp_mst_vcpi_args *args = argv;
+	struct nvkm_ior *ior;
+	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (!ior->func->dp || !ior->func->dp->vcpi || !nvkm_head_find(outp->disp, args->v0.head))
+	if (!nvkm_head_find(uoutp->outp->disp, head))
 		return -EINVAL;
 
-	ior->func->dp->vcpi(ior, args->v0.head, args->v0.start_slot, args->v0.num_slots,
-				 args->v0.pbn, args->v0.aligned_pbn);
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
+
+	ior = uoutp->outp->ior;
+	ior->func->dp->vcpi(ior, head, start_slot, num_slots, pbn, aligned_pbn);
+	nvkm_uoutp_unlock(uoutp);
 	return 0;
 }
 
@@ -558,36 +560,6 @@ nvkm_uoutp_detect(struct nvif_outp_priv *uoutp, enum nvif_outp_detect_status *st
 	return 0;
 }
 
-static int
-nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
-{
-	switch (mthd) {
-	case NVIF_OUTP_V0_DP_MST_VCPI  : return nvkm_uoutp_mthd_dp_mst_vcpi  (outp, argv, argc);
-	default:
-		break;
-	}
-
-	return -EINVAL;
-}
-
-static int
-nvkm_uoutp_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
-{
-	struct nvkm_outp *outp = container_of(object, struct nvif_outp_priv, object)->outp;
-	struct nvkm_disp *disp = outp->disp;
-	int ret;
-
-	mutex_lock(&disp->super.mutex);
-
-	if (outp->ior)
-		ret = nvkm_uoutp_mthd_acquired(outp, mthd, argv, argc);
-	else
-		ret = -EIO;
-
-	mutex_unlock(&disp->super.mutex);
-	return ret;
-}
-
 static void
 nvkm_uoutp_del(struct nvif_outp_priv *uoutp)
 {
@@ -619,7 +591,6 @@ nvkm_uoutp_dtor(struct nvkm_object *object)
 static const struct nvkm_object_func
 nvkm_uoutp = {
 	.dtor = nvkm_uoutp_dtor,
-	.mthd = nvkm_uoutp_mthd,
 };
 
 int
@@ -703,6 +674,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		if (outp->func->dp.mst_id_get) {
 			uoutp->impl.dp.mst_id_get = nvkm_uoutp_dp_mst_id_get;
 			uoutp->impl.dp.mst_id_put = nvkm_uoutp_dp_mst_id_put;
+			uoutp->impl.dp.mst_vcpi = nvkm_uoutp_dp_mst_vcpi;
 		}
 		break;
 	default:
-- 
2.41.0



More information about the Nouveau mailing list