[PATCH 123/156] drm/nouveau/nvif: rework outp "dp mst id get"/"dp mst id put" apis

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


- transition from "ioctl" interfaces

Signed-off-by: Ben Skeggs <bskeggs at nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  2 +
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 18 ---------
 drivers/gpu/drm/nouveau/nvif/outp.c           | 19 +++-------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 38 +++++++++++--------
 4 files changed, 29 insertions(+), 48 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index dc103d2a20a9..e2123ba48fc7 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -341,6 +341,8 @@ struct nvif_outp_impl {
 		int (*drive)(struct nvif_outp_priv *, u8 lanes, u8 pe[4], u8 vs[4]);
 		int (*sst)(struct nvif_outp_priv *, u8 head,
 			   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);
 	} dp;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index 92c4988101eb..3c74cd17a3a7 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -2,26 +2,8 @@
 #ifndef __NVIF_IF0012_H__
 #define __NVIF_IF0012_H__
 
-#define NVIF_OUTP_V0_DP_MST_ID_GET 0x76
-#define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_dp_mst_id_put_args {
-	struct nvif_outp_dp_mst_id_put_v0 {
-		__u8  version;
-		__u8  pad01[3];
-		__u32 id;
-	} v0;
-};
-
-union nvif_outp_dp_mst_id_get_args {
-	struct nvif_outp_dp_mst_id_get_v0 {
-		__u8  version;
-		__u8  pad01[3];
-		__u32 id;
-	} v0;
-};
-
 union nvif_outp_dp_mst_vcpi_args {
 	struct nvif_outp_dp_mst_vcpi_v0 {
 		__u8  version;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index f56485c2ad2c..cca1c28671f4 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -49,30 +49,21 @@ nvif_outp_dp_mst_vcpi(struct nvif_outp *outp, int head,
 int
 nvif_outp_dp_mst_id_put(struct nvif_outp *outp, u32 id)
 {
-	struct nvif_outp_dp_mst_id_get_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.id = id;
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_DP_MST_ID_PUT, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[DP_MST_ID_PUT id:%08x]", args.id);
+	ret = outp->impl->dp.mst_id_put(outp->priv, id);
+	NVIF_ERRON(ret, &outp->object, "[DP_MST_ID_PUT id:%08x]", id);
 	return ret;
 }
 
 int
 nvif_outp_dp_mst_id_get(struct nvif_outp *outp, u32 *id)
 {
-	struct nvif_outp_dp_mst_id_get_v0 args;
 	int ret;
 
-	args.version = 0;
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_DP_MST_ID_GET, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[DP_MST_ID_GET] id:%08x", args.id);
-	if (ret)
-		return ret;
-
-	*id = args.id;
-	return 0;
+	ret = outp->impl->dp.mst_id_get(outp->priv, id);
+	NVIF_ERRON(ret, &outp->object, "[DP_MST_ID_GET] id:%08x", *id);
+	return ret;
 }
 
 int
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index cfa386c1bbeb..eead485fe0e2 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -77,29 +77,33 @@ nvkm_uoutp_mthd_dp_mst_vcpi(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_dp_mst_id_put(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_dp_mst_id_put(struct nvif_outp_priv *uoutp, u32 id)
 {
-	union nvif_outp_dp_mst_id_put_args *args = argv;
+	struct nvkm_outp *outp;
+	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-	        return -ENOSYS;
-	if (!outp->func->dp.mst_id_put)
-	        return -EINVAL;
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
 
-	return outp->func->dp.mst_id_put(outp, args->v0.id);
+	ret = outp->func->dp.mst_id_put(outp, id);
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
-nvkm_uoutp_mthd_dp_mst_id_get(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_dp_mst_id_get(struct nvif_outp_priv *uoutp, u32 *id)
 {
-	union nvif_outp_dp_mst_id_get_args *args = argv;
+	struct nvkm_outp *outp;
+	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-	        return -ENOSYS;
-	if (!outp->func->dp.mst_id_get)
-	        return -EINVAL;
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
 
-	return outp->func->dp.mst_id_get(outp, &args->v0.id);
+	ret = outp->func->dp.mst_id_get(outp, id);
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
@@ -558,8 +562,6 @@ static int
 nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_DP_MST_ID_GET: return nvkm_uoutp_mthd_dp_mst_id_get(outp, argv, argc);
-	case NVIF_OUTP_V0_DP_MST_ID_PUT: return nvkm_uoutp_mthd_dp_mst_id_put(outp, argv, argc);
 	case NVIF_OUTP_V0_DP_MST_VCPI  : return nvkm_uoutp_mthd_dp_mst_vcpi  (outp, argv, argc);
 	default:
 		break;
@@ -698,6 +700,10 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		uoutp->impl.dp.train = nvkm_uoutp_dp_train;
 		uoutp->impl.dp.drive = nvkm_uoutp_dp_drive;
 		uoutp->impl.dp.sst = nvkm_uoutp_dp_sst;
+		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;
+		}
 		break;
 	default:
 		WARN_ON(1);
-- 
2.41.0



More information about the Nouveau mailing list