[PATCH 118/156] drm/nouveau/nvif: rework outp "dp aux xfer" api

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


- transition from "ioctl" interface

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

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 0dd85d4fa9ab..2069eedde843 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -327,6 +327,7 @@ struct nvif_outp_impl {
 		u32 link_bw;
 
 		int (*aux_pwr)(struct nvif_outp_priv *, bool enable);
+		int (*aux_xfer)(struct nvif_outp_priv *, u8 type, u32 addr, u8 *data, u8 *size);
 	} dp;
 };
 
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index c0981a5f9e87..b036197aadea 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -4,7 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_DP_AUX_XFER   0x71
 #define NVIF_OUTP_V0_DP_RATES      0x72
 #define NVIF_OUTP_V0_DP_TRAIN      0x73
 #define NVIF_OUTP_V0_DP_DRIVE      0x74
@@ -13,17 +12,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_dp_aux_xfer_args {
-	struct nvif_outp_dp_aux_xfer_v0 {
-		__u8  version;
-		__u8  pad01;
-		__u8  type;
-		__u8  size;
-		__u32 addr;
-		__u8  data[16];
-	} v0;
-};
-
 union nvif_outp_dp_rates_args {
 	struct nvif_outp_dp_rates_v0 {
 		__u8  version;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index 8b09a7ae9876..602362aa0203 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -157,24 +157,16 @@ nvif_outp_dp_rates(struct nvif_outp *outp, struct nvif_outp_dp_rate *rate, int r
 int
 nvif_outp_dp_aux_xfer(struct nvif_outp *outp, u8 type, u8 *psize, u32 addr, u8 *data)
 {
-	struct nvif_outp_dp_aux_xfer_v0 args;
 	u8 size = *psize;
 	int ret;
 
-	args.version = 0;
-	args.type = type;
-	args.size = size;
-	args.addr = addr;
-	memcpy(args.data, data, size);
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_DP_AUX_XFER, &args, sizeof(args));
+	ret = outp->impl->dp.aux_xfer(outp->priv, type, addr, data, &size);
 	NVIF_DEBUG(&outp->object, "[DP_AUX_XFER type:%d size:%d addr:%05x] %d size:%d (ret: %d)",
-		   args.type, size, args.addr, ret, args.size, ret);
+		   type, *psize, addr, ret, size, ret);
 	if (ret < 0)
 		return ret;
 
-	*psize = args.size;
-
-	memcpy(data, args.data, size);
+	*psize = size;
 	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 36b4ea9a10fd..f7226bcb9ef4 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -181,17 +181,15 @@ nvkm_uoutp_mthd_dp_rates(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_dp_aux_xfer(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_dp_aux_xfer(struct nvif_outp_priv *uoutp, u8 type, u32 addr, u8 *data, u8 *size)
 {
-	union nvif_outp_dp_aux_xfer_args *args = argv;
-
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (!outp->func->dp.aux_xfer)
-		return -EINVAL;
+	struct nvkm_outp *outp = uoutp->outp;
+	int ret;
 
-	return outp->func->dp.aux_xfer(outp, args->v0.type, args->v0.addr,
-					     args->v0.data, &args->v0.size);
+	nvkm_uoutp_lock(uoutp);
+	ret = outp->func->dp.aux_xfer(outp, type, addr, data, size);
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
@@ -563,7 +561,6 @@ static int
 nvkm_uoutp_mthd_noacquire(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc, bool *invalid)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_DP_AUX_XFER: return nvkm_uoutp_mthd_dp_aux_xfer(outp, argv, argc);
 	case NVIF_OUTP_V0_DP_RATES   : return nvkm_uoutp_mthd_dp_rates   (outp, argv, argc);
 	default:
 		break;
@@ -704,6 +701,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		uoutp->impl.dp.link_nr = outp->info.dpconf.link_nr;
 		uoutp->impl.dp.link_bw = outp->info.dpconf.link_bw * 27000;
 		uoutp->impl.dp.aux_pwr = nvkm_uoutp_dp_aux_pwr;
+		uoutp->impl.dp.aux_xfer = nvkm_uoutp_dp_aux_xfer;
 		break;
 	default:
 		WARN_ON(1);
-- 
2.41.0



More information about the Nouveau mailing list