Skip to contentSkip to conversation

drm/nouveau: replace "ioctl" interface between drm/nvkm

PATCH In review Ben Skeggs 4 participants 163 messages Apr 16, 2024 – Apr 22, 2024 Page 2 of 3

Subsystems (4)
lore
Share & tools
lore
author
#74 lore raw

PATCH 73/156 drm/nouveau/nvif: rework ctrl "pstate user" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  9 ++++
 drivers/gpu/drm/nouveau/include/nvif/if0001.h | 15 ------
 drivers/gpu/drm/nouveau/nouveau_debugfs.c     | 10 ++--
 drivers/gpu/drm/nouveau/nvkm/device/ctrl.c    | 51 ++++---------------
 4 files changed, 24 insertions(+), 61 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0001.h
drivers/gpu/drm/nouveau/include/nvif/driverif.h +9 -0
index bfa22c977323..e22e0347f623 100644
@@ -23,6 +23,14 @@ struct nvif_mapinfo {
 	u64 length;
 };
 
+struct nvif_control_pstate_user {
+	u8  version;
+#define NVIF_CONTROL_PSTATE_USER_STATE_UNKNOWN                          (-1)
+#define NVIF_CONTROL_PSTATE_USER_STATE_PERFMON                          (-2)
+	s8  ustate; /*  in: pstate identifier */
+	s8  pwrsrc; /*  in: target power source */
+};
+
 struct nvif_control_pstate_attr {
 	u8  version;
 #define NVIF_CONTROL_PSTATE_ATTR_STATE_CURRENT                          (-1)
@@ -57,6 +65,7 @@ struct nvif_control_impl {
 	struct {
 		void (*info)(struct nvif_control_priv *, struct nvif_control_pstate_info *);
 		int  (*attr)(struct nvif_control_priv *, struct nvif_control_pstate_attr *);
+		int  (*user)(struct nvif_control_priv *, struct nvif_control_pstate_user *);
 	} pstate;
 };
 
drivers/gpu/drm/nouveau/include/nvif/if0001.h deleted +0 -15
deleted file mode 100644
index b84da0b7d079..000000000000
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVIF_IF0001_H__
-#define __NVIF_IF0001_H__
-
-#define NVIF_CONTROL_PSTATE_USER                                           0x02
-
-struct nvif_control_pstate_user_v0 {
-	__u8  version;
-#define NVIF_CONTROL_PSTATE_USER_V0_STATE_UNKNOWN                          (-1)
-#define NVIF_CONTROL_PSTATE_USER_V0_STATE_PERFMON                          (-2)
-	__s8  ustate; /*  in: pstate identifier */
-	__s8  pwrsrc; /*  in: target power source */
-	__u8  pad03[5];
-};
-#endif
drivers/gpu/drm/nouveau/nouveau_debugfs.c +4 -6
index 33a64f95f64f..837653ca1753 100644
@@ -29,7 +29,6 @@
  */
 
 #include <linux/debugfs.h>
-#include <nvif/if0001.h>
 #include "nouveau_debugfs.h"
 #include "nouveau_drv.h"
 
@@ -138,7 +137,7 @@ nouveau_debugfs_pstate_set(struct file *file, const char __user *ubuf,
 	struct seq_file *m = file->private_data;
 	struct drm_device *drm = m->private;
 	struct nouveau_debugfs *debugfs = nouveau_debugfs(drm);
-	struct nvif_control_pstate_user_v0 args = { .pwrsrc = -EINVAL };
+	struct nvif_control_pstate_user args = { .pwrsrc = -EINVAL };
 	char buf[32] = {}, *tmp, *cur = buf;
 	long value, ret;
 
@@ -164,10 +163,10 @@ nouveau_debugfs_pstate_set(struct file *file, const char __user *ubuf,
 	}
 
 	if (!strcasecmp(cur, "none"))
-		args.ustate = NVIF_CONTROL_PSTATE_USER_V0_STATE_UNKNOWN;
+		args.ustate = NVIF_CONTROL_PSTATE_USER_STATE_UNKNOWN;
 	else
 	if (!strcasecmp(cur, "auto"))
-		args.ustate = NVIF_CONTROL_PSTATE_USER_V0_STATE_PERFMON;
+		args.ustate = NVIF_CONTROL_PSTATE_USER_STATE_PERFMON;
 	else {
 		ret = kstrtol(cur, 16, &value);
 		if (ret)
@@ -181,8 +180,7 @@ nouveau_debugfs_pstate_set(struct file *file, const char __user *ubuf,
 		return ret;
 	}
 
-	ret = nvif_mthd(&debugfs->ctrl, NVIF_CONTROL_PSTATE_USER,
-			&args, sizeof(args));
+	ret = debugfs->impl->pstate.user(debugfs->priv, &args);
 	pm_runtime_put_autosuspend(drm->dev);
 	if (ret < 0)
 		return ret;
drivers/gpu/drm/nouveau/nvkm/device/ctrl.c +11 -40

79 lines not on this page · raw message

Signature · 1 line
2.41.0
author
#75 lore raw

PATCH 74/156 drm/nouveau/nvif: remove ctrl from object rb

In reply to Ben Skeggs

- no more users

---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h | 3 +--
 drivers/gpu/drm/nouveau/nouveau_debugfs.c       | 2 +-
 drivers/gpu/drm/nouveau/nvkm/device/user.c      | 6 +++---
 3 files changed, 5 insertions(+), 6 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +1 -2
index e22e0347f623..05d69ea0f002 100644
@@ -112,8 +112,7 @@ struct nvif_device_impl {
 
 	struct {
 		int (*new)(struct nvif_device_priv *,
-			   const struct nvif_control_impl **, struct nvif_control_priv **,
-			   u64 handle);
+			   const struct nvif_control_impl **, struct nvif_control_priv **);
 	} control;
 
 	struct {
drivers/gpu/drm/nouveau/nouveau_debugfs.c +1 -1
index 837653ca1753..0c744a72aff2 100644
@@ -293,7 +293,7 @@ nouveau_debugfs_init(struct nouveau_drm *drm)
 		return -ENOMEM;
 
 	ret = drm->device.impl->control.new(drm->device.priv, &drm->debugfs->impl,
-					    &drm->debugfs->priv, nvif_handle(&drm->debugfs->ctrl));
+					    &drm->debugfs->priv);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/nouveau/nvkm/device/user.c +3 -3
index 14d548c3f6b0..97d54b812165 100644
@@ -41,8 +41,7 @@ struct nvif_device_priv {
 
 static int
 nvkm_udevice_control_new(struct nvif_device_priv *udev,
-			 const struct nvif_control_impl **pimpl, struct nvif_control_priv **ppriv,
-			 u64 handle)
+			 const struct nvif_control_impl **pimpl, struct nvif_control_priv **ppriv)
 {
 	struct nvkm_object *object;
 	int ret;
@@ -51,7 +50,8 @@ nvkm_udevice_control_new(struct nvif_device_priv *udev,
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+	nvkm_object_link(&udev->object, object);
+	return 0;
 }
 
 static u64
Signature · 1 line
2.41.0
author
#76 lore raw

PATCH 75/156 drm/nouveau/nvif: rework device "new usermode" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  8 +++++
 drivers/gpu/drm/nouveau/include/nvif/user.h   |  5 +++-
 drivers/gpu/drm/nouveau/nouveau_dma.c         |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c         |  2 +-
 drivers/gpu/drm/nouveau/nvif/user.c           | 16 ++++++----
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 19 ++++++++++--
 .../gpu/drm/nouveau/nvkm/subdev/vfn/base.c    |  1 -
 .../gpu/drm/nouveau/nvkm/subdev/vfn/priv.h    |  3 --
 .../gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c    | 29 +++++++++++++++----
 .../gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.h    |  9 ++++++
 10 files changed, 73 insertions(+), 21 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.h
drivers/gpu/drm/nouveau/include/nvif/driverif.h +8 -0
index 05d69ea0f002..35a5869eb036 100644
@@ -4,6 +4,7 @@
 struct nvif_client_priv;
 struct nvif_device_priv;
 struct nvif_control_priv;
+struct nvif_usermode_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -69,6 +70,10 @@ struct nvif_control_impl {
 	} pstate;
 };
 
+struct nvif_usermode_impl {
+	void (*del)(struct nvif_usermode_priv *);
+};
+
 struct nvif_device_impl {
 	void (*del)(struct nvif_device_priv *);
 
@@ -117,6 +122,9 @@ struct nvif_device_impl {
 
 	struct {
 		s32 oclass;
+		int (*new)(struct nvif_device_priv *,
+			   const struct nvif_usermode_impl **, struct nvif_usermode_priv **,
+			   u64 handle);
 	} usermode;
 
 	struct {
drivers/gpu/drm/nouveau/include/nvif/user.h +4 -1
index 146986a9fe53..51104955c1e3 100644
@@ -4,8 +4,11 @@
 struct nvif_device;
 
 struct nvif_user {
-	const struct nvif_user_func *func;
+	const struct nvif_usermode_impl *impl;
+	struct nvif_usermode_priv *priv;
 	struct nvif_object object;
+
+	const struct nvif_user_func *func;
 };
 
 struct nvif_user_func {
drivers/gpu/drm/nouveau/nouveau_dma.c +1 -1
index a1f329ef0641..83eb9c9fa67e 100644
@@ -72,7 +72,7 @@ void
 nv50_dma_push(struct nouveau_channel *chan, u64 offset, u32 length,
 	      bool no_prefetch)
 {
-	struct nvif_user *user = &chan->cli->drm->client.device.user;
+	struct nvif_user *user = &chan->cli->drm->device.user;
 	struct nouveau_bo *pb = chan->push.buffer;
 	int ip = (chan->dma.ib_put * 2) + chan->dma.ib_base;
 
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -1
index 76990dde1b6a..a91ad8e65a0f 100644
@@ -474,7 +474,7 @@ nouveau_accel_init(struct nouveau_drm *drm)
 
 	/* Volta requires access to a doorbell register for kickoff. */
 	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_VOLTA) {
-		ret = nvif_user_ctor(device, "drmUsermode");
+		ret = nvif_user_ctor(&drm->device, "drmUsermode");
 		if (ret)
 			return;
 	}
drivers/gpu/drm/nouveau/nvif/user.c +10 -6
index d8d37c1c8169..878883aff9c5 100644
@@ -21,6 +21,7 @@
  */
 #include <nvif/user.h>
 #include <nvif/device.h>
+#include <nvif/driverif.h>
 #include <nvif/printf.h>
 
 #include <nvif/class.h>
@@ -28,8 +29,9 @@
 void
 nvif_user_dtor(struct nvif_device *device)
 {
-	if (device->user.func) {
-		nvif_object_dtor(&device->user.object);
+	if (device->user.impl) {
+		device->user.impl->del(device->user.priv);
+		device->user.impl = NULL;
 		device->user.func = NULL;
 	}
 }
@@ -53,13 +55,15 @@ nvif_user_ctor(struct nvif_device *device, const char *name)
 		return -ENODEV;
 	}
 
-	ret = nvif_object_ctor(&device->object, name ? name : "nvifUsermode",
-			       0, oclass, NULL, 0,
-			       &device->user.object);
+	ret = device->impl->usermode.new(device->priv, &device->user.impl, &device->user.priv,
+					 nvif_handle(&device->user.object));
+	NVIF_ERRON(ret, &device->object, "[NEW usermode%04x]", oclass);
 	if (ret)
 		return ret;
 
-	nvif_object_map(&device->user.object, NULL, 0);
+	nvif_object_ctor(&device->object, name ?: "nvifUsermode", 0, oclass, &device->user.object);
 	device->user.func = func;
+
+	nvif_object_map(&device->user.object, NULL, 0);
 	return 0;
 }
drivers/gpu/drm/nouveau/nvkm/device/user.c +17 -2
index 97d54b812165..aadd0c0956ee 100644
@@ -29,6 +29,7 @@
 #include <subdev/fb.h>
 #include <subdev/instmem.h>
 #include <subdev/timer.h>
+#include <subdev/vfn/uvfn.h>
 #include <engine/disp/priv.h>
 #include <engine/fifo/ufifo.h>
 
@@ -39,6 +40,20 @@ struct nvif_device_priv {
 	struct nvif_device_impl impl;
 };
 
+static int
+nvkm_udevice_usermode_new(struct nvif_device_priv *udev, const struct nvif_usermode_impl **pimpl,
+			  struct nvif_usermode_priv **ppriv, u64 handle)
+{
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_uvfn_new(udev->device, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+}
+
 static int
 nvkm_udevice_control_new(struct nvif_device_priv *udev,
 			 const struct nvif_control_impl **pimpl, struct nvif_control_priv **ppriv)
@@ -74,6 +89,7 @@ nvkm_udevice_impl = {
 	.del = nvkm_udevice_del,
 	.time = nvkm_udevice_time,
 	.control.new = nvkm_udevice_control_new,
+	.usermode.new = nvkm_udevice_usermode_new,
 };
 
 static int
@@ -154,8 +170,6 @@ nvkm_udevice_child_get(struct nvkm_object *object, int index,
 			sclass = &device->mmu->user;
 		else if (device->fault && index-- == 0)
 			sclass = &device->fault->user;
-		else if (device->vfn && index-- == 0)
-			sclass = &device->vfn->user;
 		else
 			return -EINVAL;
 
@@ -263,6 +277,7 @@ nvkm_udevice_new(struct nvkm_device *device,
 
 	if (device->vfn) {
 		udev->impl.usermode.oclass = device->vfn->user.base.oclass;
+		udev->impl.usermode.new = nvkm_udevice_usermode_new;
 	}
 
 	if (device->mmu) {
drivers/gpu/drm/nouveau/nvkm/subdev/vfn/base.c +0 -1
index 62e81d551f44..2215de6c4803 100644
@@ -54,7 +54,6 @@ nvkm_vfn_new_(const struct nvkm_vfn_func *func, struct nvkm_device *device,
 			return ret;
 	}
 
-	vfn->user.ctor = nvkm_uvfn_new;
 	vfn->user.base = func->user.base;
 	return 0;
 }
drivers/gpu/drm/nouveau/nvkm/subdev/vfn/priv.h +0 -3
index 3a09781ad032..40245777c600 100644
@@ -24,7 +24,4 @@ int nvkm_vfn_new_(const struct nvkm_vfn_func *, struct nvkm_device *, enum nvkm_
 		  u32 addr, struct nvkm_vfn **);
 
 extern const struct nvkm_intr_func tu102_vfn_intr;
-
-int nvkm_uvfn_new(struct nvkm_device *, const struct nvkm_oclass *, void *, u32,
-		  struct nvkm_object **);
 #endif
drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c +23 -6
index fe35024d69ba..6b0ddeb1f568 100644
@@ -19,6 +19,7 @@
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
+#include "uvfn.h"
 #include "priv.h"
 
 #include <core/object.h>
@@ -26,6 +27,8 @@
 struct nvif_usermode_priv {
 	struct nvkm_object object;
 	struct nvkm_vfn *vfn;
+
+	struct nvif_usermode_impl impl;
 };
 
 static int
@@ -41,26 +44,40 @@ nvkm_uvfn_map(struct nvkm_object *object, void *argv, u32 argc,
 	return 0;
 }
 
+static void
+nvkm_uvfn_del(struct nvif_usermode_priv *uvfn)
+{
+	struct nvkm_object *object = &uvfn->object;
+
+	nvkm_object_del(&object);
+}
+
+static const struct nvif_usermode_impl
+nvkm_uvfn_impl = {
+	.del = nvkm_uvfn_del,
+};
+
 static const struct nvkm_object_func
 nvkm_uvfn = {
 	.map = nvkm_uvfn_map,
 };
 
 int
-nvkm_uvfn_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
-	      void *argv, u32 argc, struct nvkm_object **pobject)
+nvkm_uvfn_new(struct nvkm_device *device, const struct nvif_usermode_impl **pimpl,
+	      struct nvif_usermode_priv **ppriv, struct nvkm_object **pobject)
 {
 	struct nvif_usermode_priv *uvfn;
 
-	if (argc != 0)
-		return -ENOSYS;
-
 	if (!(uvfn = kzalloc(sizeof(*uvfn), GFP_KERNEL)))
 		return -ENOMEM;
 
-	nvkm_object_ctor(&nvkm_uvfn, oclass, &uvfn->object);
+	nvkm_object_ctor(&nvkm_uvfn, &(struct nvkm_oclass) {}, &uvfn->object);
 	uvfn->vfn = device->vfn;
 
+	uvfn->impl = nvkm_uvfn_impl;
+
+	*pimpl = &uvfn->impl;
+	*ppriv = uvfn;
 	*pobject = &uvfn->object;
 	return 0;
 }
drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.h new file +9 -0
new file mode 100644
index 000000000000..23f636eb3b58
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_UVFN_H__
+#define __NVKM_UVFN_H__
+#include <subdev/vfn.h>
+#include <nvif/driverif.h>
+
+int nvkm_uvfn_new(struct nvkm_device *, const struct nvif_usermode_impl **,
+		  struct nvif_usermode_priv **, struct nvkm_object **);
+#endif
Signature · 1 line
2.41.0
author
#77 lore raw

PATCH 76/156 drm/nouveau/nvif: rework usermode "map" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h    |  1 +
 drivers/gpu/drm/nouveau/include/nvif/user.h    |  1 +
 drivers/gpu/drm/nouveau/nvif/user.c            |  9 ++++++++-
 drivers/gpu/drm/nouveau/nvif/userc361.c        |  8 ++++----
 drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c | 18 ++++--------------
 5 files changed, 18 insertions(+), 19 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +1 -0
index 35a5869eb036..3f481d19e7c6 100644
@@ -72,6 +72,7 @@ struct nvif_control_impl {
 
 struct nvif_usermode_impl {
 	void (*del)(struct nvif_usermode_priv *);
+	struct nvif_mapinfo map;
 };
 
 struct nvif_device_impl {
drivers/gpu/drm/nouveau/include/nvif/user.h +1 -0
index 51104955c1e3..4214492b617b 100644
@@ -7,6 +7,7 @@ struct nvif_user {
 	const struct nvif_usermode_impl *impl;
 	struct nvif_usermode_priv *priv;
 	struct nvif_object object;
+	struct nvif_map map;
 
 	const struct nvif_user_func *func;
 };
drivers/gpu/drm/nouveau/nvif/user.c +8 -1
index 878883aff9c5..dbeae9f1e6d2 100644
@@ -30,6 +30,8 @@ void
 nvif_user_dtor(struct nvif_device *device)
 {
 	if (device->user.impl) {
+		nvif_object_unmap_cpu(&device->user.map);
+
 		device->user.impl->del(device->user.priv);
 		device->user.impl = NULL;
 		device->user.func = NULL;
@@ -64,6 +66,11 @@ nvif_user_ctor(struct nvif_device *device, const char *name)
 	nvif_object_ctor(&device->object, name ?: "nvifUsermode", 0, oclass, &device->user.object);
 	device->user.func = func;
 
-	nvif_object_map(&device->user.object, NULL, 0);
+	ret = nvif_object_map_cpu(&device->user.object, &device->user.impl->map, &device->user.map);
+	if (ret) {
+		nvif_user_dtor(device);
+		return ret;
+	}
+
 	return 0;
 }
drivers/gpu/drm/nouveau/nvif/userc361.c +4 -4
index 1116f871b272..2431b162b3c9 100644
@@ -27,9 +27,9 @@ nvif_userc361_time(struct nvif_user *user)
 	u32 hi, lo;
 
 	do {
-		hi = nvif_rd32(&user->object, 0x084);
-		lo = nvif_rd32(&user->object, 0x080);
-	} while (hi != nvif_rd32(&user->object, 0x084));
+		hi = nvif_rd32(user, 0x084);
+		lo = nvif_rd32(user, 0x080);
+	} while (hi != nvif_rd32(user, 0x084));
 
 	return ((u64)hi << 32 | lo);
 }
@@ -37,7 +37,7 @@ nvif_userc361_time(struct nvif_user *user)
 static void
 nvif_userc361_doorbell(struct nvif_user *user, u32 token)
 {
-	nvif_wr32(&user->object, 0x90, token);
+	nvif_wr32(user, 0x90, token);
 }
 
 const struct nvif_user_func
drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c +4 -14
index 6b0ddeb1f568..f00490e5aa7b 100644
@@ -31,19 +31,6 @@ struct nvif_usermode_priv {
 	struct nvif_usermode_impl impl;
 };
 
-static int
-nvkm_uvfn_map(struct nvkm_object *object, void *argv, u32 argc,
-	      enum nvkm_object_map *type, u64 *addr, u64 *size)
-{
-	struct nvkm_vfn *vfn = container_of(object, struct nvif_usermode_priv, object)->vfn;
-	struct nvkm_device *device = vfn->subdev.device;
-
-	*addr = device->func->resource_addr(device, 0) + vfn->addr.user;
-	*size = vfn->func->user.size;
-	*type = NVKM_OBJECT_MAP_IO;
-	return 0;
-}
-
 static void
 nvkm_uvfn_del(struct nvif_usermode_priv *uvfn)
 {
@@ -59,13 +46,13 @@ nvkm_uvfn_impl = {
 
 static const struct nvkm_object_func
 nvkm_uvfn = {
-	.map = nvkm_uvfn_map,
 };
 
 int
 nvkm_uvfn_new(struct nvkm_device *device, const struct nvif_usermode_impl **pimpl,
 	      struct nvif_usermode_priv **ppriv, struct nvkm_object **pobject)
 {
+	struct nvkm_vfn *vfn = device->vfn;
 	struct nvif_usermode_priv *uvfn;
 
 	if (!(uvfn = kzalloc(sizeof(*uvfn), GFP_KERNEL)))
@@ -75,6 +62,9 @@ nvkm_uvfn_new(struct nvkm_device *device, const struct nvif_usermode_impl **pimp
 	uvfn->vfn = device->vfn;
 
 	uvfn->impl = nvkm_uvfn_impl;
+	uvfn->impl.map.type = NVIF_MAP_IO;
+	uvfn->impl.map.handle = device->func->resource_addr(device, 0) + vfn->addr.user;
+	uvfn->impl.map.length = vfn->func->user.size;
 
 	*pimpl = &uvfn->impl;
 	*ppriv = uvfn;
Signature · 1 line
2.41.0
author
#78 lore raw

PATCH 77/156 drm/nouveau/nvif: remove usermode from object rb

In reply to Ben Skeggs

- no more users

---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h | 3 +--
 drivers/gpu/drm/nouveau/nvif/user.c             | 3 +--
 drivers/gpu/drm/nouveau/nvkm/device/user.c      | 5 +++--
 3 files changed, 5 insertions(+), 6 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +1 -2
index 3f481d19e7c6..cd96e9c36f55 100644
@@ -124,8 +124,7 @@ struct nvif_device_impl {
 	struct {
 		s32 oclass;
 		int (*new)(struct nvif_device_priv *,
-			   const struct nvif_usermode_impl **, struct nvif_usermode_priv **,
-			   u64 handle);
+			   const struct nvif_usermode_impl **, struct nvif_usermode_priv **);
 	} usermode;
 
 	struct {
drivers/gpu/drm/nouveau/nvif/user.c +1 -2
index dbeae9f1e6d2..4b955fce8382 100644
@@ -57,8 +57,7 @@ nvif_user_ctor(struct nvif_device *device, const char *name)
 		return -ENODEV;
 	}
 
-	ret = device->impl->usermode.new(device->priv, &device->user.impl, &device->user.priv,
-					 nvif_handle(&device->user.object));
+	ret = device->impl->usermode.new(device->priv, &device->user.impl, &device->user.priv);
 	NVIF_ERRON(ret, &device->object, "[NEW usermode%04x]", oclass);
 	if (ret)
 		return ret;
drivers/gpu/drm/nouveau/nvkm/device/user.c +3 -2
index aadd0c0956ee..cd126f5b165a 100644
@@ -42,7 +42,7 @@ struct nvif_device_priv {
 
 static int
 nvkm_udevice_usermode_new(struct nvif_device_priv *udev, const struct nvif_usermode_impl **pimpl,
-			  struct nvif_usermode_priv **ppriv, u64 handle)
+			  struct nvif_usermode_priv **ppriv)
 {
 	struct nvkm_object *object;
 	int ret;
@@ -51,7 +51,8 @@ nvkm_udevice_usermode_new(struct nvif_device_priv *udev, const struct nvif_userm
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+	nvkm_object_link(&udev->object, object);
+	return 0;
 }
 
 static int
Signature · 1 line
2.41.0
author
#79 lore raw

PATCH 78/156 drm/nouveau/nvif: rework device "new mmu" api

In reply to Ben Skeggs

- transition from "ioctl" interfaces

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 13 ++++++
 drivers/gpu/drm/nouveau/include/nvif/if0008.h |  7 ---
 drivers/gpu/drm/nouveau/include/nvif/mmu.h    |  8 ++--
 drivers/gpu/drm/nouveau/nouveau_drm.c         |  5 +-
 drivers/gpu/drm/nouveau/nouveau_ttm.c         |  4 +-
 drivers/gpu/drm/nouveau/nvif/mmu.c            | 30 ++++++------
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 22 +++++++--
 .../gpu/drm/nouveau/nvkm/subdev/mmu/base.c    |  1 -
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c    | 46 ++++++++++++-------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h    | 10 ++--
 10 files changed, 94 insertions(+), 52 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +13 -0
index cd96e9c36f55..7bba8c79d71e 100644
@@ -5,6 +5,7 @@ struct nvif_client_priv;
 struct nvif_device_priv;
 struct nvif_control_priv;
 struct nvif_usermode_priv;
+struct nvif_mmu_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -75,6 +76,16 @@ struct nvif_usermode_impl {
 	struct nvif_mapinfo map;
 };
 
+struct nvif_mmu_impl {
+	void (*del)(struct nvif_mmu_priv *);
+
+	u8 dmabits;
+	u8 heap_nr;
+	u8 type_nr;
+
+	u16 kind_nr;
+};
+
 struct nvif_device_impl {
 	void (*del)(struct nvif_device_priv *);
 
@@ -129,6 +140,8 @@ struct nvif_device_impl {
 
 	struct {
 		s32 oclass;
+		int (*new)(struct nvif_device_priv *, const struct nvif_mmu_impl **,
+			   struct nvif_mmu_priv **, u64 handle);
 	} mmu;
 
 	struct {
drivers/gpu/drm/nouveau/include/nvif/if0008.h +0 -7
index c21d09f04f1d..618df13762d3 100644
@@ -1,12 +1,5 @@
 #ifndef __NVIF_IF0008_H__
 #define __NVIF_IF0008_H__
-struct nvif_mmu_v0 {
-	__u8  version;
-	__u8  dmabits;
-	__u8  heap_nr;
-	__u8  type_nr;
-	__u16 kind_nr;
-};
 
 #define NVIF_MMU_V0_HEAP                                                   0x00
 #define NVIF_MMU_V0_TYPE                                                   0x01
drivers/gpu/drm/nouveau/include/nvif/mmu.h +5 -3
index 2035ef1d35f5..414caaa2230a 100644
@@ -1,10 +1,13 @@
 #ifndef __NVIF_MMU_H__
 #define __NVIF_MMU_H__
 #include <nvif/object.h>
+#include <nvif/driverif.h>
+struct nvif_device;
 
 struct nvif_mmu {
+	const struct nvif_mmu_impl *impl;
+	struct nvif_mmu_priv *priv;
 	struct nvif_object object;
-	u8  dmabits;
 	u8  heap_nr;
 	u8  type_nr;
 	u8  kind_inv;
@@ -31,8 +34,7 @@ struct nvif_mmu {
 	u8 *kind;
 };
 
-int nvif_mmu_ctor(struct nvif_object *, const char *name, s32 oclass,
-		  struct nvif_mmu *);
+int nvif_mmu_ctor(struct nvif_device *, const char *name, struct nvif_mmu *);
 void nvif_mmu_dtor(struct nvif_mmu *);
 
 static inline bool
drivers/gpu/drm/nouveau/nouveau_drm.c +2 -3
index a91ad8e65a0f..1dba64a1e590 100644
@@ -236,8 +236,7 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
 
 	cli->device.object.map.ptr = drm->device.object.map.ptr;
 
-	ret = nvif_mmu_ctor(&cli->device.object, "drmMmu", drm->mmu.object.oclass,
-			    &cli->mmu);
+	ret = nvif_mmu_ctor(&cli->device, "drmMmu", &cli->mmu);
 	if (ret) {
 		NV_PRINTK(err, cli, "MMU allocation failed: %d\n", ret);
 		goto done;
@@ -569,7 +568,7 @@ nouveau_drm_device_init(struct drm_device *dev, struct nvkm_device *nvkm)
 		goto fail_nvif;
 	}
 
-	ret = nvif_mmu_ctor(&drm->device.object, "drmMmu", drm->device.impl->mmu.oclass, &drm->mmu);
+	ret = nvif_mmu_ctor(&drm->device, "drmMmu", &drm->mmu);
 	if (ret) {
 		NV_ERROR(drm, "MMU allocation failed: %d\n", ret);
 		goto fail_nvif;
drivers/gpu/drm/nouveau/nouveau_ttm.c +2 -2
index 57c7e3ba8e7b..f87ca8a0e6ae 100644
@@ -302,8 +302,8 @@ nouveau_ttm_init(struct nouveau_drm *drm)
 	ret = ttm_device_init(&drm->ttm.bdev, &nouveau_bo_driver, drm->dev->dev,
 				  dev->anon_inode->i_mapping,
 				  dev->vma_offset_manager,
-				  drm_need_swiotlb(drm->client.mmu.dmabits),
-				  drm->client.mmu.dmabits <= 32);
+				  drm_need_swiotlb(drm->mmu.impl->dmabits),
+				  drm->mmu.impl->dmabits <= 32);
 	if (ret) {
 		NV_ERROR(drm, "error initialising bo driver, %d\n", ret);
 		return ret;
drivers/gpu/drm/nouveau/nvif/mmu.c +17 -13
index c9dd3cff49a0..cc15cf99462c 100644
@@ -20,6 +20,8 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 #include <nvif/mmu.h>
+#include <nvif/device.h>
+#include <nvif/printf.h>
 
 #include <nvif/class.h>
 #include <nvif/if0008.h>
@@ -27,18 +29,18 @@
 void
 nvif_mmu_dtor(struct nvif_mmu *mmu)
 {
-	if (!nvif_object_constructed(&mmu->object))
+	if (!mmu->impl)
 		return;
 
 	kfree(mmu->kind);
 	kfree(mmu->type);
 	kfree(mmu->heap);
-	nvif_object_dtor(&mmu->object);
+	mmu->impl->del(mmu->priv);
+	mmu->impl = NULL;
 }
 
 int
-nvif_mmu_ctor(struct nvif_object *parent, const char *name, s32 oclass,
-	      struct nvif_mmu *mmu)
+nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu)
 {
 	static const struct nvif_mclass mems[] = {
 		{ NVIF_CLASS_MEM_GF100, -1 },
@@ -46,23 +48,25 @@ nvif_mmu_ctor(struct nvif_object *parent, const char *name, s32 oclass,
 		{ NVIF_CLASS_MEM_NV04 , -1 },
 		{}
 	};
-	struct nvif_mmu_v0 args;
+	const s32 oclass = device->impl->mmu.oclass;
 	int ret, i;
 
-	args.version = 0;
+	mmu->impl = NULL;
 	mmu->heap = NULL;
 	mmu->type = NULL;
 	mmu->kind = NULL;
 
-	ret = nvif_object_ctor(parent, name ? name : "nvifMmu", 0, oclass,
-			       &args, sizeof(args), &mmu->object);
+	ret = device->impl->mmu.new(device->priv, &mmu->impl, &mmu->priv,
+				    nvif_handle(&mmu->object));
+	NVIF_ERRON(ret, &device->object, "[NEW mmu%08x]", oclass);
 	if (ret)
-		goto done;
+		return ret;
+
+	nvif_object_ctor(&device->object, name ?: "nvifMmu", 0, oclass, &mmu->object);
 
-	mmu->dmabits = args.dmabits;
-	mmu->heap_nr = args.heap_nr;
-	mmu->type_nr = args.type_nr;
-	mmu->kind_nr = args.kind_nr;
+	mmu->heap_nr = mmu->impl->heap_nr;
+	mmu->type_nr = mmu->impl->type_nr;
+	mmu->kind_nr = mmu->impl->kind_nr;
 
 	ret = nvif_mclass(&mmu->object, mems);
 	if (ret < 0)
drivers/gpu/drm/nouveau/nvkm/device/user.c +19 -3
index cd126f5b165a..e9486d9da64b 100644
@@ -29,6 +29,7 @@
 #include <subdev/fb.h>
 #include <subdev/instmem.h>
 #include <subdev/timer.h>
+#include <subdev/mmu/ummu.h>
 #include <subdev/vfn/uvfn.h>
 #include <engine/disp/priv.h>
 #include <engine/fifo/ufifo.h>
@@ -76,6 +77,22 @@ nvkm_udevice_time(struct nvif_device_priv *udev)
 	return nvkm_timer_read(udev->device->timer);
 }
 
+static int
+nvkm_udevice_mmu_new(struct nvif_device_priv *udev,
+		     const struct nvif_mmu_impl **pimpl, struct nvif_mmu_priv **ppriv,
+		     u64 handle)
+{
+	struct nvkm_device *device = udev->device;
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_ummu_new(device, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+}
+
 static void
 nvkm_udevice_del(struct nvif_device_priv *udev)
 {
@@ -167,9 +184,7 @@ nvkm_udevice_child_get(struct nvkm_object *object, int index,
 	}
 
 	if (!sclass) {
-		if (device->mmu && index-- == 0)
-			sclass = &device->mmu->user;
-		else if (device->fault && index-- == 0)
+		if (device->fault && index-- == 0)
 			sclass = &device->fault->user;
 		else
 			return -EINVAL;
@@ -283,6 +298,7 @@ nvkm_udevice_new(struct nvkm_device *device,
 
 	if (device->mmu) {
 		udev->impl.mmu.oclass = device->mmu->user.base.oclass;
+		udev->impl.mmu.new = nvkm_udevice_mmu_new;
 	}
 
 	if (device->fault) {
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c +0 -1
index 7b949a43c372..08ad3ed84631 100644
@@ -426,7 +426,6 @@ nvkm_mmu_ctor(const struct nvkm_mmu_func *func, struct nvkm_device *device,
 	mmu->dma_bits = func->dma_bits;
 	nvkm_mmu_ptc_init(mmu);
 	mutex_init(&mmu->mutex);
-	mmu->user.ctor = nvkm_ummu_new;
 	mmu->user.base = func->mmu.user;
 	spin_lock_init(&mmu->umem_lock);
 	INIT_LIST_HEAD(&mmu->umem);
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c +29 -17

67 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h +7 -3
index 35ae48758017..c03563aa4cae 100644
@@ -1,15 +1,19 @@
 #ifndef __NVKM_UMMU_H__
 #define __NVKM_UMMU_H__
 #include <core/object.h>
-#include "priv.h"
+struct nvkm_device;
+
+#include <nvif/driverif.h>
 
 #define nvkm_ummu nvif_mmu_priv
 
 struct nvif_mmu_priv {
 	struct nvkm_object object;
 	struct nvkm_mmu *mmu;
+
+	struct nvif_mmu_impl impl;
 };
 
-int nvkm_ummu_new(struct nvkm_device *, const struct nvkm_oclass *,
-		  void *argv, u32 argc, struct nvkm_object **);
+int nvkm_ummu_new(struct nvkm_device *, const struct nvif_mmu_impl **, struct nvif_mmu_priv **,
+		  struct nvkm_object **);
 #endif
Signature · 1 line
2.41.0
author
#80 lore raw

PATCH 79/156 drm/nouveau/nvif: rework mmu "sclass" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  8 +++
 drivers/gpu/drm/nouveau/include/nvif/mem.h    |  4 +-
 drivers/gpu/drm/nouveau/include/nvif/mmu.h    |  1 -
 drivers/gpu/drm/nouveau/include/nvif/vmm.h    |  2 +-
 drivers/gpu/drm/nouveau/nouveau_bo.c          | 10 ++--
 drivers/gpu/drm/nouveau/nouveau_chan.c        |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c         | 54 ++++++++-----------
 drivers/gpu/drm/nouveau/nouveau_drv.h         |  2 -
 drivers/gpu/drm/nouveau/nouveau_mem.c         | 10 ++--
 drivers/gpu/drm/nouveau/nouveau_svm.c         |  3 +-
 drivers/gpu/drm/nouveau/nouveau_uvmm.c        |  3 +-
 drivers/gpu/drm/nouveau/nouveau_vmm.c         |  4 +-
 drivers/gpu/drm/nouveau/nouveau_vmm.h         |  2 +-
 drivers/gpu/drm/nouveau/nvif/mem.c            | 10 ++--
 drivers/gpu/drm/nouveau/nvif/mmu.c            | 11 ----
 drivers/gpu/drm/nouveau/nvif/vmm.c            |  4 +-
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c    |  4 ++
 17 files changed, 60 insertions(+), 74 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +8 -0
index 7bba8c79d71e..a1b97bc5e933 100644
@@ -84,6 +84,14 @@ struct nvif_mmu_impl {
 	u8 type_nr;
 
 	u16 kind_nr;
+
+	struct {
+		s32 oclass;
+	} mem;
+
+	struct {
+		s32 oclass;
+	} vmm;
 };
 
 struct nvif_device_impl {
drivers/gpu/drm/nouveau/include/nvif/mem.h +2 -2
index 9e1071dd56a0..217d13126f13 100644
@@ -10,10 +10,10 @@ struct nvif_mem {
 	u64 size;
 };
 
-int nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name, s32 oclass,
+int nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name,
 		       int type, u8 page, u64 size, void *argv, u32 argc,
 		       struct nvif_mem *);
-int nvif_mem_ctor(struct nvif_mmu *mmu, const char *name, s32 oclass, u8 type,
+int nvif_mem_ctor(struct nvif_mmu *mmu, const char *name, u8 type,
 		  u8 page, u64 size, void *argv, u32 argc, struct nvif_mem *);
 void nvif_mem_dtor(struct nvif_mem *);
 
drivers/gpu/drm/nouveau/include/nvif/mmu.h +0 -1
index 414caaa2230a..ed5d011f4237 100644
@@ -12,7 +12,6 @@ struct nvif_mmu {
 	u8  type_nr;
 	u8  kind_inv;
 	u16 kind_nr;
-	s32 mem;
 
 	struct {
 		u64 size;
drivers/gpu/drm/nouveau/include/nvif/vmm.h +1 -1
index 0ecedd0ee0a5..e8d8fbd56010 100644
@@ -36,7 +36,7 @@ struct nvif_vmm {
 	int page_nr;
 };
 
-int nvif_vmm_ctor(struct nvif_mmu *, const char *name, s32 oclass,
+int nvif_vmm_ctor(struct nvif_mmu *, const char *name,
 		  enum nvif_vmm_type, u64 addr, u64 size, void *argv, u32 argc,
 		  struct nvif_vmm *);
 void nvif_vmm_dtor(struct nvif_vmm *);
drivers/gpu/drm/nouveau/nouveau_bo.c +5 -5
index e1483fd5d283..cbb8f54db83f 100644
@@ -1158,7 +1158,7 @@ nouveau_ttm_io_mem_free_locked(struct nouveau_drm *drm,
 {
 	struct nouveau_mem *mem = nouveau_mem(reg);
 
-	if (drm->client.mem->oclass >= NVIF_CLASS_MEM_NV50) {
+	if (drm->mmu.impl->mem.oclass >= NVIF_CLASS_MEM_NV50) {
 		switch (reg->mem_type) {
 		case TTM_PL_TT:
 			if (mem->kind)
@@ -1179,7 +1179,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *reg)
 	struct nouveau_drm *drm = nouveau_bdev(bdev);
 	struct nvkm_device *device = nvxx_device(&drm->client.device);
 	struct nouveau_mem *mem = nouveau_mem(reg);
-	struct nvif_mmu *mmu = &drm->client.mmu;
+	struct nvif_mmu *mmu = &drm->mmu;
 	int ret;
 
 	mutex_lock(&drm->ttm.io_reserve_mutex);
@@ -1198,7 +1198,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *reg)
 			reg->bus.caching = ttm_write_combined;
 		}
 #endif
-		if (drm->client.mem->oclass < NVIF_CLASS_MEM_NV50 ||
+		if (mmu->impl->mem.oclass < NVIF_CLASS_MEM_NV50 ||
 		    !mem->kind) {
 			/* untiled */
 			ret = 0;
@@ -1217,7 +1217,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *reg)
 		else
 			reg->bus.caching = ttm_write_combined;
 
-		if (drm->client.mem->oclass >= NVIF_CLASS_MEM_NV50) {
+		if (mmu->impl->mem.oclass >= NVIF_CLASS_MEM_NV50) {
 			union {
 				struct nv50_mem_map_v0 nv50;
 				struct gf100_mem_map_v0 gf100;
@@ -1225,7 +1225,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *reg)
 			u64 handle, length;
 			u32 argc = 0;
 
-			switch (mem->mem.object.oclass) {
+			switch (mmu->impl->mem.oclass) {
 			case NVIF_CLASS_MEM_NV50:
 				args.nv50.version = 0;
 				args.nv50.ro = 0;
drivers/gpu/drm/nouveau/nouveau_chan.c +1 -1
index 636ca1f284f8..dd4f9915ccaf 100644
@@ -328,7 +328,7 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 
 	/* allocate userd */
 	if (oclass >= VOLTA_CHANNEL_GPFIFO_A) {
-		ret = nvif_mem_ctor(&cli->mmu, "abi16ChanUSERD", NVIF_CLASS_MEM_GF100,
+		ret = nvif_mem_ctor(&cli->mmu, "abi16ChanUSERD",
 				    NVIF_MEM_VRAM | NVIF_MEM_COHERENT | NVIF_MEM_MAPPABLE,
 				    0, PAGE_SIZE, NULL, 0, &chan->mem_userd);
 		if (ret)
drivers/gpu/drm/nouveau/nouveau_drm.c +23 -31

77 lines not on this page · raw message

drivers/gpu/drm/nouveau/nouveau_drv.h +0 -2
index 35dfc95b32ed..38d33a4d5c49 100644
@@ -100,8 +100,6 @@ struct nouveau_cli {
 
 	struct nouveau_sched *sched;
 
-	const struct nvif_mclass *mem;
-
 	struct list_head head;
 	void *abi16;
 	struct list_head objects;
drivers/gpu/drm/nouveau/nouveau_mem.c +4 -6
index baea74899fcf..75abd545c92d 100644
@@ -90,7 +90,6 @@ nouveau_mem_host(struct ttm_resource *reg, struct ttm_tt *tt)
 {
 	struct nouveau_mem *mem = nouveau_mem(reg);
 	struct nouveau_drm *drm = mem->drm;
-	struct nouveau_cli *cli = &drm->cli;
 	struct nvif_mmu *mmu = &drm->mmu;
 	struct nvif_mem_ram_v0 args = {};
 	u8 type;
@@ -115,7 +114,7 @@ nouveau_mem_host(struct ttm_resource *reg, struct ttm_tt *tt)
 		args.dma = tt->dma_address;
 
 	mutex_lock(&drm->client_mutex);
-	ret = nvif_mem_ctor_type(mmu, "ttmHostMem", cli->mem->oclass, type, PAGE_SHIFT,
+	ret = nvif_mem_ctor_type(mmu, "ttmHostMem", type, PAGE_SHIFT,
 				 reg->size,
 				 &args, sizeof(args), &mem->mem);
 	mutex_unlock(&drm->client_mutex);
@@ -127,15 +126,14 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
 {
 	struct nouveau_mem *mem = nouveau_mem(reg);
 	struct nouveau_drm *drm = mem->drm;
-	struct nouveau_cli *cli = &drm->cli;
 	struct nvif_mmu *mmu = &drm->mmu;
 	u64 size = ALIGN(reg->size, 1 << page);
 	int ret;
 
 	mutex_lock(&drm->client_mutex);
-	switch (cli->mem->oclass) {
+	switch (drm->mmu.impl->mem.oclass) {
 	case NVIF_CLASS_MEM_GF100:
-		ret = nvif_mem_ctor_type(mmu, "ttmVram", cli->mem->oclass,
+		ret = nvif_mem_ctor_type(mmu, "ttmVram",
 					 drm->ttm.type_vram, page, size,
 					 &(struct gf100_mem_v0) {
 						.contig = contig,
@@ -143,7 +141,7 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
 					 &mem->mem);
 		break;
 	case NVIF_CLASS_MEM_NV50:
-		ret = nvif_mem_ctor_type(mmu, "ttmVram", cli->mem->oclass,
+		ret = nvif_mem_ctor_type(mmu, "ttmVram",
 					 drm->ttm.type_vram, page, size,
 					 &(struct nv50_mem_v0) {
 						.bankswz = mmu->kind[mem->kind] == 2,
drivers/gpu/drm/nouveau/nouveau_svm.c +1 -2
index 477336672652..a478b5a9ed0a 100644
@@ -346,8 +346,7 @@ nouveau_svmm_init(struct drm_device *dev, void *data,
 	 * All future channel/memory allocations will make use of this
 	 * VMM instead of the standard one.
 	 */
-	ret = nvif_vmm_ctor(&cli->mmu, "svmVmm",
-			    cli->vmm.vmm.object.oclass, MANAGED,
+	ret = nvif_vmm_ctor(&cli->mmu, "svmVmm", MANAGED,
 			    args->unmanaged_addr, args->unmanaged_size,
 			    &(struct gp100_vmm_v0) {
 				.fault_replay = true,
drivers/gpu/drm/nouveau/nouveau_uvmm.c +1 -2
index 0a0a11dc9ec0..d35096071c1a 100644
@@ -1865,8 +1865,7 @@ nouveau_uvmm_ioctl_vm_init(struct drm_device *dev,
 	/* GPUVM takes care from here on. */
 	drm_gem_object_put(r_obj);
 
-	ret = nvif_vmm_ctor(&cli->mmu, "uvmm",
-			    cli->vmm.vmm.object.oclass, RAW,
+	ret = nvif_vmm_ctor(&cli->mmu, "uvmm", RAW,
 			    init->kernel_managed_addr,
 			    init->kernel_managed_size,
 			    NULL, 0, &uvmm->vmm.vmm);
drivers/gpu/drm/nouveau/nouveau_vmm.c +2 -2
index 3dda885df5b2..93807d21ceff 100644
@@ -129,9 +129,9 @@ nouveau_vmm_fini(struct nouveau_vmm *vmm)
 }
 
 int
-nouveau_vmm_init(struct nouveau_cli *cli, s32 oclass, struct nouveau_vmm *vmm)
+nouveau_vmm_init(struct nouveau_cli *cli, struct nouveau_vmm *vmm)
 {
-	int ret = nvif_vmm_ctor(&cli->mmu, "drmVmm", oclass, UNMANAGED,
+	int ret = nvif_vmm_ctor(&cli->mmu, "drmVmm", UNMANAGED,
 				PAGE_SIZE, 0, NULL, 0, &vmm->vmm);
 	if (ret)
 		return ret;
drivers/gpu/drm/nouveau/nouveau_vmm.h +1 -1
index 2b98d975f37e..196d8a819617 100644
@@ -28,6 +28,6 @@ struct nouveau_vmm {
 	struct nouveau_svmm *svmm;
 };
 
-int nouveau_vmm_init(struct nouveau_cli *, s32 oclass, struct nouveau_vmm *);
+int nouveau_vmm_init(struct nouveau_cli *, struct nouveau_vmm *);
 void nouveau_vmm_fini(struct nouveau_vmm *);
 #endif
drivers/gpu/drm/nouveau/nvif/mem.c +5 -5
index 0e1b7b4c2e91..0f0b4a7c5e80 100644
@@ -28,7 +28,7 @@ int
 nvif_mem_ctor_map(struct nvif_mmu *mmu, const char *name, u8 type, u64 size,
 		  struct nvif_mem *mem)
 {
-	int ret = nvif_mem_ctor(mmu, name, mmu->mem, NVIF_MEM_MAPPABLE | type,
+	int ret = nvif_mem_ctor(mmu, name, NVIF_MEM_MAPPABLE | type,
 				0, size, NULL, 0, mem);
 	if (ret == 0) {
 		ret = nvif_object_map(&mem->object, NULL, 0);
@@ -45,7 +45,7 @@ nvif_mem_dtor(struct nvif_mem *mem)
 }
 
 int
-nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name, s32 oclass,
+nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name,
 		   int type, u8 page, u64 size, void *argv, u32 argc,
 		   struct nvif_mem *mem)
 {
@@ -69,7 +69,7 @@ nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name, s32 oclass,
 	args->size = size;
 	memcpy(args->data, argv, argc);
 
-	ret = nvif_object_ctor(&mmu->object, name ? name : "nvifMem", 0, oclass,
+	ret = nvif_object_ctor(&mmu->object, name ? name : "nvifMem", 0, mmu->impl->mem.oclass,
 			       args, sizeof(*args) + argc, &mem->object);
 	if (ret == 0) {
 		mem->type = mmu->type[type].type;
@@ -85,7 +85,7 @@ nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name, s32 oclass,
 }
 
 int
-nvif_mem_ctor(struct nvif_mmu *mmu, const char *name, s32 oclass, u8 type,
+nvif_mem_ctor(struct nvif_mmu *mmu, const char *name, u8 type,
 	      u8 page, u64 size, void *argv, u32 argc, struct nvif_mem *mem)
 {
 	int ret = -EINVAL, i;
@@ -94,7 +94,7 @@ nvif_mem_ctor(struct nvif_mmu *mmu, const char *name, s32 oclass, u8 type,
 
 	for (i = 0; ret && i < mmu->type_nr; i++) {
 		if ((mmu->type[i].type & type) == type) {
-			ret = nvif_mem_ctor_type(mmu, name, oclass, i, page,
+			ret = nvif_mem_ctor_type(mmu, name, i, page,
 						 size, argv, argc, mem);
 		}
 	}
drivers/gpu/drm/nouveau/nvif/mmu.c +0 -11
index cc15cf99462c..7e592a6d8530 100644
@@ -42,12 +42,6 @@ nvif_mmu_dtor(struct nvif_mmu *mmu)
 int
 nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu)
 {
-	static const struct nvif_mclass mems[] = {
-		{ NVIF_CLASS_MEM_GF100, -1 },
-		{ NVIF_CLASS_MEM_NV50 , -1 },
-		{ NVIF_CLASS_MEM_NV04 , -1 },
-		{}
-	};
 	const s32 oclass = device->impl->mmu.oclass;
 	int ret, i;
 
@@ -68,11 +62,6 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu
 	mmu->type_nr = mmu->impl->type_nr;
 	mmu->kind_nr = mmu->impl->kind_nr;
 
-	ret = nvif_mclass(&mmu->object, mems);
-	if (ret < 0)
-		goto done;
-	mmu->mem = mems[ret].oclass;
-
 	mmu->heap = kmalloc_array(mmu->heap_nr, sizeof(*mmu->heap),
 				  GFP_KERNEL);
 	mmu->type = kmalloc_array(mmu->type_nr, sizeof(*mmu->type),
drivers/gpu/drm/nouveau/nvif/vmm.c +2 -2
index 99296f03371a..2738ea9229cc 100644
@@ -196,7 +196,7 @@ nvif_vmm_dtor(struct nvif_vmm *vmm)
 }
 
 int
-nvif_vmm_ctor(struct nvif_mmu *mmu, const char *name, s32 oclass,
+nvif_vmm_ctor(struct nvif_mmu *mmu, const char *name,
 	      enum nvif_vmm_type type, u64 addr, u64 size, void *argv, u32 argc,
 	      struct nvif_vmm *vmm)
 {
@@ -225,7 +225,7 @@ nvif_vmm_ctor(struct nvif_mmu *mmu, const char *name, s32 oclass,
 	memcpy(args->data, argv, argc);
 
 	ret = nvif_object_ctor(&mmu->object, name ? name : "nvifVmm", 0,
-			       oclass, args, argn, &vmm->object);
+			       mmu->impl->vmm.oclass, args, argn, &vmm->object);
 	if (ret)
 		goto done;
 
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c +4 -0
index f97dec6c3309..9f44d469b4da 100644
@@ -186,6 +186,10 @@ nvkm_ummu_new(struct nvkm_device *device, const struct nvif_mmu_impl **pimpl,
 	ummu->impl.type_nr = mmu->type_nr;
 	ummu->impl.kind_nr = kinds;
 
+	ummu->impl.mem.oclass = mmu->func->mem.user.oclass;
+
+	ummu->impl.vmm.oclass = mmu->func->vmm.user.oclass;
+
 	*pimpl = &ummu->impl;
 	*ppriv = ummu;
 	*pobject = &ummu->object;
Signature · 1 line
2.41.0
author
#81 lore raw

PATCH 80/156 drm/nouveau/nvif: rework mmu "heap" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  4 ++++
 drivers/gpu/drm/nouveau/include/nvif/if0008.h |  8 -------
 drivers/gpu/drm/nouveau/include/nvif/mmu.h    |  5 ----
 drivers/gpu/drm/nouveau/nvif/mmu.c            | 18 +--------------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c    | 23 ++-----------------
 5 files changed, 7 insertions(+), 51 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +4 -0
index a1b97bc5e933..9205c2c3b34e 100644
@@ -85,6 +85,10 @@ struct nvif_mmu_impl {
 
 	u16 kind_nr;
 
+	struct {
+		u64 size;
+	} heap[4];
+
 	struct {
 		s32 oclass;
 	} mem;
drivers/gpu/drm/nouveau/include/nvif/if0008.h +0 -8
index 618df13762d3..551bdf49d6e2 100644
@@ -1,17 +1,9 @@
 #ifndef __NVIF_IF0008_H__
 #define __NVIF_IF0008_H__
 
-#define NVIF_MMU_V0_HEAP                                                   0x00
 #define NVIF_MMU_V0_TYPE                                                   0x01
 #define NVIF_MMU_V0_KIND                                                   0x02
 
-struct nvif_mmu_heap_v0 {
-	__u8  version;
-	__u8  index;
-	__u8  pad02[6];
-	__u64 size;
-};
-
 struct nvif_mmu_type_v0 {
 	__u8  version;
 	__u8  index;
drivers/gpu/drm/nouveau/include/nvif/mmu.h +0 -5
index ed5d011f4237..ff4938911621 100644
@@ -8,15 +8,10 @@ struct nvif_mmu {
 	const struct nvif_mmu_impl *impl;
 	struct nvif_mmu_priv *priv;
 	struct nvif_object object;
-	u8  heap_nr;
 	u8  type_nr;
 	u8  kind_inv;
 	u16 kind_nr;
 
-	struct {
-		u64 size;
-	} *heap;
-
 	struct {
 #define NVIF_MEM_VRAM                                                      0x01
 #define NVIF_MEM_HOST                                                      0x02
drivers/gpu/drm/nouveau/nvif/mmu.c +1 -17
index 7e592a6d8530..ec5ec8be98c0 100644
@@ -34,7 +34,6 @@ nvif_mmu_dtor(struct nvif_mmu *mmu)
 
 	kfree(mmu->kind);
 	kfree(mmu->type);
-	kfree(mmu->heap);
 	mmu->impl->del(mmu->priv);
 	mmu->impl = NULL;
 }
@@ -46,7 +45,6 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu
 	int ret, i;
 
 	mmu->impl = NULL;
-	mmu->heap = NULL;
 	mmu->type = NULL;
 	mmu->kind = NULL;
 
@@ -58,15 +56,12 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu
 
 	nvif_object_ctor(&device->object, name ?: "nvifMmu", 0, oclass, &mmu->object);
 
-	mmu->heap_nr = mmu->impl->heap_nr;
 	mmu->type_nr = mmu->impl->type_nr;
 	mmu->kind_nr = mmu->impl->kind_nr;
 
-	mmu->heap = kmalloc_array(mmu->heap_nr, sizeof(*mmu->heap),
-				  GFP_KERNEL);
 	mmu->type = kmalloc_array(mmu->type_nr, sizeof(*mmu->type),
 				  GFP_KERNEL);
-	if (ret = -ENOMEM, !mmu->heap || !mmu->type)
+	if (ret = -ENOMEM, !mmu->type)
 		goto done;
 
 	mmu->kind = kmalloc_array(mmu->kind_nr, sizeof(*mmu->kind),
@@ -74,17 +69,6 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu
 	if (!mmu->kind && mmu->kind_nr)
 		goto done;
 
-	for (i = 0; i < mmu->heap_nr; i++) {
-		struct nvif_mmu_heap_v0 args = { .index = i };
-
-		ret = nvif_object_mthd(&mmu->object, NVIF_MMU_V0_HEAP,
-				       &args, sizeof(args));
-		if (ret)
-			goto done;
-
-		mmu->heap[i].size = args.size;
-	}
-
 	for (i = 0; i < mmu->type_nr; i++) {
 		struct nvif_mmu_type_v0 args = { .index = i };
 
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c +2 -21
index 9f44d469b4da..9a42721eabd8 100644
@@ -53,26 +53,6 @@ nvkm_ummu_sclass(struct nvkm_object *object, int index,
 	return -EINVAL;
 }
 
-static int
-nvkm_ummu_heap(struct nvkm_ummu *ummu, void *argv, u32 argc)
-{
-	struct nvkm_mmu *mmu = ummu->mmu;
-	union {
-		struct nvif_mmu_heap_v0 v0;
-	} *args = argv;
-	int ret = -ENOSYS;
-	u8 index;
-
-	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
-		if ((index = args->v0.index) >= mmu->heap_nr)
-			return -EINVAL;
-		args->v0.size = mmu->heap[index].size;
-	} else
-		return ret;
-
-	return 0;
-}
-
 static int
 nvkm_ummu_type(struct nvkm_ummu *ummu, void *argv, u32 argc)
 {
@@ -147,7 +127,6 @@ nvkm_ummu_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 {
 	struct nvif_mmu_priv *ummu = container_of(object, typeof(*ummu), object);
 	switch (mthd) {
-	case NVIF_MMU_V0_HEAP: return nvkm_ummu_heap(ummu, argv, argc);
 	case NVIF_MMU_V0_TYPE: return nvkm_ummu_type(ummu, argv, argc);
 	case NVIF_MMU_V0_KIND: return nvkm_ummu_kind(ummu, argv, argc);
 	default:
@@ -185,6 +164,8 @@ nvkm_ummu_new(struct nvkm_device *device, const struct nvif_mmu_impl **pimpl,
 	ummu->impl.heap_nr = mmu->heap_nr;
 	ummu->impl.type_nr = mmu->type_nr;
 	ummu->impl.kind_nr = kinds;
+	for (int i = 0; i < mmu->heap_nr; i++)
+		ummu->impl.heap[i].size = mmu->heap[i].size;
 
 	ummu->impl.mem.oclass = mmu->func->mem.user.oclass;
 
Signature · 1 line
2.41.0
author
#82 lore raw

PATCH 81/156 drm/nouveau/nvif: rework mmu "type" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 13 ++++++
 drivers/gpu/drm/nouveau/include/nvif/if0008.h | 15 -------
 drivers/gpu/drm/nouveau/include/nvif/mmu.h    | 18 +-------
 drivers/gpu/drm/nouveau/nouveau_bo.c          |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drv.h         |  5 ++-
 drivers/gpu/drm/nouveau/nouveau_mem.c         |  4 +-
 drivers/gpu/drm/nouveau/nvif/mem.c            |  6 +--
 drivers/gpu/drm/nouveau/nvif/mmu.c            | 30 +------------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c    | 45 +++++++------------
 9 files changed, 40 insertions(+), 98 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +13 -0
index 9205c2c3b34e..fa08478cc38f 100644
@@ -89,6 +89,19 @@ struct nvif_mmu_impl {
 		u64 size;
 	} heap[4];
 
+	struct {
+#define NVIF_MEM_VRAM     0x01
+#define NVIF_MEM_HOST     0x02
+#define NVIF_MEM_COMP     0x04
+#define NVIF_MEM_DISP     0x08
+#define NVIF_MEM_KIND     0x10
+#define NVIF_MEM_MAPPABLE 0x20
+#define NVIF_MEM_COHERENT 0x40
+#define NVIF_MEM_UNCACHED 0x80
+		u8 type;
+		u8 heap;
+	} type[16];
+
 	struct {
 		s32 oclass;
 	} mem;
drivers/gpu/drm/nouveau/include/nvif/if0008.h +0 -15
index 551bdf49d6e2..0413e7e4ca0c 100644
@@ -1,23 +1,8 @@
 #ifndef __NVIF_IF0008_H__
 #define __NVIF_IF0008_H__
 
-#define NVIF_MMU_V0_TYPE                                                   0x01
 #define NVIF_MMU_V0_KIND                                                   0x02
 
-struct nvif_mmu_type_v0 {
-	__u8  version;
-	__u8  index;
-	__u8  heap;
-	__u8  vram;
-	__u8  host;
-	__u8  comp;
-	__u8  disp;
-	__u8  kind;
-	__u8  mappable;
-	__u8  coherent;
-	__u8  uncached;
-};
-
 struct nvif_mmu_kind_v0 {
 	__u8  version;
 	__u8  kind_inv;
drivers/gpu/drm/nouveau/include/nvif/mmu.h +2 -16
index ff4938911621..203328a2d611 100644
@@ -8,23 +8,9 @@ struct nvif_mmu {
 	const struct nvif_mmu_impl *impl;
 	struct nvif_mmu_priv *priv;
 	struct nvif_object object;
-	u8  type_nr;
 	u8  kind_inv;
 	u16 kind_nr;
 
-	struct {
-#define NVIF_MEM_VRAM                                                      0x01
-#define NVIF_MEM_HOST                                                      0x02
-#define NVIF_MEM_COMP                                                      0x04
-#define NVIF_MEM_DISP                                                      0x08
-#define NVIF_MEM_KIND                                                      0x10
-#define NVIF_MEM_MAPPABLE                                                  0x20
-#define NVIF_MEM_COHERENT                                                  0x40
-#define NVIF_MEM_UNCACHED                                                  0x80
-		u8 type;
-		u8 heap;
-	} *type;
-
 	u8 *kind;
 };
 
@@ -45,8 +31,8 @@ static inline int
 nvif_mmu_type(struct nvif_mmu *mmu, u8 mask)
 {
 	int i;
-	for (i = 0; i < mmu->type_nr; i++) {
-		if ((mmu->type[i].type & mask) == mask)
+	for (i = 0; i < mmu->impl->type_nr; i++) {
+		if ((mmu->impl->type[i].type & mask) == mask)
 			return i;
 	}
 	return -EINVAL;
drivers/gpu/drm/nouveau/nouveau_bo.c +1 -1
index cbb8f54db83f..08d522aaae38 100644
@@ -1212,7 +1212,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *reg)
 
 		/* Some BARs do not support being ioremapped WC */
 		if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA &&
-		    mmu->type[drm->ttm.type_vram].type & NVIF_MEM_UNCACHED)
+		    mmu->impl->type[drm->ttm.type_vram].type & NVIF_MEM_UNCACHED)
 			reg->bus.caching = ttm_uncached;
 		else
 			reg->bus.caching = ttm_write_combined;
drivers/gpu/drm/nouveau/nouveau_drv.h +3 -2
index 38d33a4d5c49..823fa6d87690 100644
@@ -318,8 +318,9 @@ nouveau_drm(struct drm_device *dev)
 static inline bool
 nouveau_drm_use_coherent_gpu_mapping(struct nouveau_drm *drm)
 {
-	struct nvif_mmu *mmu = &drm->client.mmu;
-	return !(mmu->type[drm->ttm.type_host[0]].type & NVIF_MEM_UNCACHED);
+	struct nvif_mmu *mmu = &drm->mmu;
+
+	return !(mmu->impl->type[drm->ttm.type_host[0]].type & NVIF_MEM_UNCACHED);
 }
 
 int nouveau_pmops_suspend(struct device *);
drivers/gpu/drm/nouveau/nouveau_mem.c +2 -2
index 75abd545c92d..554500a650db 100644
@@ -100,9 +100,9 @@ nouveau_mem_host(struct ttm_resource *reg, struct ttm_tt *tt)
 	else
 		type = drm->ttm.type_host[0];
 
-	if (mem->kind && !(mmu->type[type].type & NVIF_MEM_KIND))
+	if (mem->kind && !(mmu->impl->type[type].type & NVIF_MEM_KIND))
 		mem->comp = mem->kind = 0;
-	if (mem->comp && !(mmu->type[type].type & NVIF_MEM_COMP)) {
+	if (mem->comp && !(mmu->impl->type[type].type & NVIF_MEM_COMP)) {
 		if (mmu->object.oclass >= NVIF_CLASS_MMU_GF100)
 			mem->kind = mmu->kind[mem->kind];
 		mem->comp = 0;
drivers/gpu/drm/nouveau/nvif/mem.c +3 -3
index 0f0b4a7c5e80..600fe051be11 100644
@@ -72,7 +72,7 @@ nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name,
 	ret = nvif_object_ctor(&mmu->object, name ? name : "nvifMem", 0, mmu->impl->mem.oclass,
 			       args, sizeof(*args) + argc, &mem->object);
 	if (ret == 0) {
-		mem->type = mmu->type[type].type;
+		mem->type = mmu->impl->type[type].type;
 		mem->page = args->page;
 		mem->addr = args->addr;
 		mem->size = args->size;
@@ -92,8 +92,8 @@ nvif_mem_ctor(struct nvif_mmu *mmu, const char *name, u8 type,
 
 	mem->object.client = NULL;
 
-	for (i = 0; ret && i < mmu->type_nr; i++) {
-		if ((mmu->type[i].type & type) == type) {
+	for (i = 0; ret && i < mmu->impl->type_nr; i++) {
+		if ((mmu->impl->type[i].type & type) == type) {
 			ret = nvif_mem_ctor_type(mmu, name, i, page,
 						 size, argv, argc, mem);
 		}
drivers/gpu/drm/nouveau/nvif/mmu.c +1 -29
index ec5ec8be98c0..e727a6587658 100644
@@ -33,7 +33,6 @@ nvif_mmu_dtor(struct nvif_mmu *mmu)
 		return;
 
 	kfree(mmu->kind);
-	kfree(mmu->type);
 	mmu->impl->del(mmu->priv);
 	mmu->impl = NULL;
 }
@@ -42,10 +41,9 @@ int
 nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu)
 {
 	const s32 oclass = device->impl->mmu.oclass;
-	int ret, i;
+	int ret;
 
 	mmu->impl = NULL;
-	mmu->type = NULL;
 	mmu->kind = NULL;
 
 	ret = device->impl->mmu.new(device->priv, &mmu->impl, &mmu->priv,
@@ -56,39 +54,13 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu
 
 	nvif_object_ctor(&device->object, name ?: "nvifMmu", 0, oclass, &mmu->object);
 
-	mmu->type_nr = mmu->impl->type_nr;
 	mmu->kind_nr = mmu->impl->kind_nr;
 
-	mmu->type = kmalloc_array(mmu->type_nr, sizeof(*mmu->type),
-				  GFP_KERNEL);
-	if (ret = -ENOMEM, !mmu->type)
-		goto done;
-
 	mmu->kind = kmalloc_array(mmu->kind_nr, sizeof(*mmu->kind),
 				  GFP_KERNEL);
 	if (!mmu->kind && mmu->kind_nr)
 		goto done;
 
-	for (i = 0; i < mmu->type_nr; i++) {
-		struct nvif_mmu_type_v0 args = { .index = i };
-
-		ret = nvif_object_mthd(&mmu->object, NVIF_MMU_V0_TYPE,
-				       &args, sizeof(args));
-		if (ret)
-			goto done;
-
-		mmu->type[i].type = 0;
-		if (args.vram) mmu->type[i].type |= NVIF_MEM_VRAM;
-		if (args.host) mmu->type[i].type |= NVIF_MEM_HOST;
-		if (args.comp) mmu->type[i].type |= NVIF_MEM_COMP;
-		if (args.disp) mmu->type[i].type |= NVIF_MEM_DISP;
-		if (args.kind    ) mmu->type[i].type |= NVIF_MEM_KIND;
-		if (args.mappable) mmu->type[i].type |= NVIF_MEM_MAPPABLE;
-		if (args.coherent) mmu->type[i].type |= NVIF_MEM_COHERENT;
-		if (args.uncached) mmu->type[i].type |= NVIF_MEM_UNCACHED;
-		mmu->type[i].heap = args.heap;
-	}
-
 	if (mmu->kind_nr) {
 		struct nvif_mmu_kind_v0 *kind;
 		size_t argc = struct_size(kind, data, mmu->kind_nr);
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c +15 -30

66 lines not on this page · raw message

Signature · 1 line
2.41.0
author
#83 lore raw

PATCH 82/156 drm/nouveau/nvif: rework mmu "kind" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  3 ++
 drivers/gpu/drm/nouveau/include/nvif/if0008.h | 12 -----
 drivers/gpu/drm/nouveau/include/nvif/mmu.h    |  6 +--
 drivers/gpu/drm/nouveau/nouveau_bo.c          |  4 +-
 drivers/gpu/drm/nouveau/nouveau_mem.c         |  4 +-
 drivers/gpu/drm/nouveau/nvif/mmu.c            | 31 -----------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c    | 53 ++-----------------
 7 files changed, 13 insertions(+), 100 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0008.h
drivers/gpu/drm/nouveau/include/nvif/driverif.h +3 -0
index fa08478cc38f..f387ec622a45 100644
@@ -83,6 +83,7 @@ struct nvif_mmu_impl {
 	u8 heap_nr;
 	u8 type_nr;
 
+	u8 kind_inv;
 	u16 kind_nr;
 
 	struct {
@@ -102,6 +103,8 @@ struct nvif_mmu_impl {
 		u8 heap;
 	} type[16];
 
+	const u8 *kind;
+
 	struct {
 		s32 oclass;
 	} mem;
drivers/gpu/drm/nouveau/include/nvif/if0008.h deleted +0 -12
deleted file mode 100644
index 0413e7e4ca0c..000000000000
@@ -1,12 +0,0 @@
-#ifndef __NVIF_IF0008_H__
-#define __NVIF_IF0008_H__
-
-#define NVIF_MMU_V0_KIND                                                   0x02
-
-struct nvif_mmu_kind_v0 {
-	__u8  version;
-	__u8  kind_inv;
-	__u16 count;
-	__u8  data[];
-};
-#endif
drivers/gpu/drm/nouveau/include/nvif/mmu.h +1 -5
index 203328a2d611..f1e51a5544da 100644
@@ -8,10 +8,6 @@ struct nvif_mmu {
 	const struct nvif_mmu_impl *impl;
 	struct nvif_mmu_priv *priv;
 	struct nvif_object object;
-	u8  kind_inv;
-	u16 kind_nr;
-
-	u8 *kind;
 };
 
 int nvif_mmu_ctor(struct nvif_device *, const char *name, struct nvif_mmu *);
@@ -21,7 +17,7 @@ static inline bool
 nvif_mmu_kind_valid(struct nvif_mmu *mmu, u8 kind)
 {
 	if (kind) {
-		if (kind >= mmu->kind_nr || mmu->kind[kind] == mmu->kind_inv)
+		if (kind >= mmu->impl->kind_nr || mmu->impl->kind[kind] == mmu->impl->kind_inv)
 			return false;
 	}
 	return true;
drivers/gpu/drm/nouveau/nouveau_bo.c +2 -2
index 08d522aaae38..0d946e31bccd 100644
@@ -250,7 +250,7 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
 				return ERR_PTR(-EINVAL);
 			}
 
-			nvbo->comp = mmu->kind[nvbo->kind] != nvbo->kind;
+			nvbo->comp = mmu->impl->kind[nvbo->kind] != nvbo->kind;
 		} else if (cli->device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
 			nvbo->kind = (tile_flags & 0x00007f00) >> 8;
 			nvbo->comp = (tile_flags & 0x00030000) >> 16;
@@ -299,7 +299,7 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
 		/* Disable compression if suitable settings couldn't be found. */
 		if (nvbo->comp && !vmm->page[pi].comp) {
 			if (mmu->object.oclass >= NVIF_CLASS_MMU_GF100)
-				nvbo->kind = mmu->kind[nvbo->kind];
+				nvbo->kind = mmu->impl->kind[nvbo->kind];
 			nvbo->comp = 0;
 		}
 		nvbo->page = vmm->page[pi].shift;
drivers/gpu/drm/nouveau/nouveau_mem.c +2 -2
index 554500a650db..872d689db7ba 100644
@@ -104,7 +104,7 @@ nouveau_mem_host(struct ttm_resource *reg, struct ttm_tt *tt)
 		mem->comp = mem->kind = 0;
 	if (mem->comp && !(mmu->impl->type[type].type & NVIF_MEM_COMP)) {
 		if (mmu->object.oclass >= NVIF_CLASS_MMU_GF100)
-			mem->kind = mmu->kind[mem->kind];
+			mem->kind = mmu->impl->kind[mem->kind];
 		mem->comp = 0;
 	}
 
@@ -144,7 +144,7 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
 		ret = nvif_mem_ctor_type(mmu, "ttmVram",
 					 drm->ttm.type_vram, page, size,
 					 &(struct nv50_mem_v0) {
-						.bankswz = mmu->kind[mem->kind] == 2,
+						.bankswz = mmu->impl->kind[mem->kind] == 2,
 						.contig = contig,
 					 }, sizeof(struct nv50_mem_v0),
 					 &mem->mem);
drivers/gpu/drm/nouveau/nvif/mmu.c +0 -31
index e727a6587658..d1d09e5a6909 100644
@@ -24,7 +24,6 @@
 #include <nvif/printf.h>
 
 #include <nvif/class.h>
-#include <nvif/if0008.h>
 
 void
 nvif_mmu_dtor(struct nvif_mmu *mmu)
@@ -32,7 +31,6 @@ nvif_mmu_dtor(struct nvif_mmu *mmu)
 	if (!mmu->impl)
 		return;
 
-	kfree(mmu->kind);
 	mmu->impl->del(mmu->priv);
 	mmu->impl = NULL;
 }
@@ -44,7 +42,6 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu
 	int ret;
 
 	mmu->impl = NULL;
-	mmu->kind = NULL;
 
 	ret = device->impl->mmu.new(device->priv, &mmu->impl, &mmu->priv,
 				    nvif_handle(&mmu->object));
@@ -53,33 +50,5 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu
 		return ret;
 
 	nvif_object_ctor(&device->object, name ?: "nvifMmu", 0, oclass, &mmu->object);
-
-	mmu->kind_nr = mmu->impl->kind_nr;
-
-	mmu->kind = kmalloc_array(mmu->kind_nr, sizeof(*mmu->kind),
-				  GFP_KERNEL);
-	if (!mmu->kind && mmu->kind_nr)
-		goto done;
-
-	if (mmu->kind_nr) {
-		struct nvif_mmu_kind_v0 *kind;
-		size_t argc = struct_size(kind, data, mmu->kind_nr);
-
-		if (ret = -ENOMEM, !(kind = kmalloc(argc, GFP_KERNEL)))
-			goto done;
-		kind->version = 0;
-		kind->count = mmu->kind_nr;
-
-		ret = nvif_object_mthd(&mmu->object, NVIF_MMU_V0_KIND,
-				       kind, argc);
-		if (ret == 0)
-			memcpy(mmu->kind, kind->data, kind->count);
-		mmu->kind_inv = kind->kind_inv;
-		kfree(kind);
-	}
-
-done:
-	if (ret)
-		nvif_mmu_dtor(mmu);
 	return ret;
 }
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c +5 -48

94 lines not on this page · raw message

Signature · 1 line
2.41.0
author
#84 lore raw

PATCH 83/156 drm/nouveau/nvif: rework mmu "new mem" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 drivers/gpu/drm/nouveau/dispnv50/crc.c        |  6 +--
 drivers/gpu/drm/nouveau/dispnv50/lut.c        |  2 +-
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 11 +++++
 drivers/gpu/drm/nouveau/include/nvif/mem.h    |  8 ++--
 drivers/gpu/drm/nouveau/nouveau_bo.c          | 10 ++--
 drivers/gpu/drm/nouveau/nouveau_mem.c         |  4 +-
 drivers/gpu/drm/nouveau/nouveau_vmm.c         | 10 ++--
 drivers/gpu/drm/nouveau/nvif/mem.c            | 43 +++++++----------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/umem.c    | 47 +++++++++++--------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/umem.h    |  5 +-
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c    | 23 +++++----
 11 files changed, 92 insertions(+), 77 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/crc.c +3 -3
index 0864d36a06f2..694c25a19e25 100644
@@ -513,9 +513,9 @@ nv50_crc_ctx_init(struct nv50_head *head, struct nvif_mmu *mmu,
 			       (&(struct nv_dma_v0) {
 					.target = NV_DMA_V0_TARGET_VRAM,
 					.access = NV_DMA_V0_ACCESS_RDWR,
-					.start = ctx->mem.addr,
-					.limit =  ctx->mem.addr
-						+ ctx->mem.size - 1,
+					.start = ctx->mem.impl->addr,
+					.limit =  ctx->mem.impl->addr
+						+ ctx->mem.impl->size - 1,
 			       }), sizeof(struct nv_dma_v0),
 			       &ctx->ntfy);
 	if (ret)
drivers/gpu/drm/nouveau/dispnv50/lut.c +1 -1
index 6b2ad1e6eab9..7d68a7efc1d5 100644
@@ -34,7 +34,7 @@ nv50_lut_load(struct nv50_lut *lut, int buffer, struct drm_property_blob *blob,
 {
 	struct drm_color_lut *in = blob ? blob->data : NULL;
 	void __iomem *mem = lut->mem[buffer].object.map.ptr;
-	const u32 addr = lut->mem[buffer].addr;
+	const u32 addr = lut->mem[buffer].impl->addr;
 	int i;
 
 	if (!in) {
drivers/gpu/drm/nouveau/include/nvif/driverif.h +11 -0
index f387ec622a45..de380979e1a4 100644
@@ -6,6 +6,7 @@ struct nvif_device_priv;
 struct nvif_control_priv;
 struct nvif_usermode_priv;
 struct nvif_mmu_priv;
+struct nvif_mem_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -76,6 +77,14 @@ struct nvif_usermode_impl {
 	struct nvif_mapinfo map;
 };
 
+struct nvif_mem_impl {
+	void (*del)(struct nvif_mem_priv *);
+
+	u8 page;
+	u64 addr;
+	u64 size;
+};
+
 struct nvif_mmu_impl {
 	void (*del)(struct nvif_mmu_priv *);
 
@@ -107,6 +116,8 @@ struct nvif_mmu_impl {
 
 	struct {
 		s32 oclass;
+		int (*new)(struct nvif_mmu_priv *, u8 type, u8 page, u64 size, void *argv, u32 argc,
+			   const struct nvif_mem_impl **, struct nvif_mem_priv **, u64 handle);
 	} mem;
 
 	struct {
drivers/gpu/drm/nouveau/include/nvif/mem.h +4 -4
index 217d13126f13..8d432d238b95 100644
@@ -3,11 +3,11 @@
 #include "mmu.h"
 
 struct nvif_mem {
+	const struct nvif_mem_impl *impl;
+	struct nvif_mem_priv *priv;
 	struct nvif_object object;
-	u8  type;
-	u8  page;
-	u64 addr;
-	u64 size;
+
+	u8 type;
 };
 
 int nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name,
drivers/gpu/drm/nouveau/nouveau_bo.c +5 -5
index 0d946e31bccd..6c90f853513d 100644
@@ -835,13 +835,13 @@ nouveau_bo_move_prep(struct nouveau_drm *drm, struct ttm_buffer_object *bo,
 	struct nvif_vmm *vmm = &drm->client.vmm.vmm;
 	int ret;
 
-	ret = nvif_vmm_get(vmm, LAZY, false, old_mem->mem.page, 0,
-			   old_mem->mem.size, &old_mem->vma[0]);
+	ret = nvif_vmm_get(vmm, LAZY, false, old_mem->mem.impl->page, 0,
+			   old_mem->mem.impl->size, &old_mem->vma[0]);
 	if (ret)
 		return ret;
 
-	ret = nvif_vmm_get(vmm, LAZY, false, new_mem->mem.page, 0,
-			   new_mem->mem.size, &old_mem->vma[1]);
+	ret = nvif_vmm_get(vmm, LAZY, false, new_mem->mem.impl->page, 0,
+			   new_mem->mem.impl->size, &old_mem->vma[1]);
 	if (ret)
 		goto done;
 
@@ -1001,7 +1001,7 @@ static void nouveau_bo_move_ntfy(struct ttm_buffer_object *bo,
 	nouveau_bo_del_io_reserve_lru(bo);
 
 	if (mem && new_reg->mem_type != TTM_PL_SYSTEM &&
-	    mem->mem.page == nvbo->page) {
+	    mem->mem.impl->page == nvbo->page) {
 		list_for_each_entry(vma, &nvbo->vma_list, head) {
 			nouveau_vma_map(vma, mem);
 		}
drivers/gpu/drm/nouveau/nouveau_mem.c +2 -2
index 872d689db7ba..ff67f00c93c5 100644
@@ -72,7 +72,7 @@ nouveau_mem_map(struct nouveau_mem *mem,
 		return -ENOSYS;
 	}
 
-	return nvif_vmm_map(vmm, vma->addr, mem->mem.size, &args, argc, &mem->mem, 0);
+	return nvif_vmm_map(vmm, vma->addr, mem->mem.impl->size, &args, argc, &mem->mem, 0);
 }
 
 void
@@ -156,7 +156,7 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
 	}
 	mutex_unlock(&drm->client_mutex);
 
-	reg->start = mem->mem.addr >> PAGE_SHIFT;
+	reg->start = mem->mem.impl->addr >> PAGE_SHIFT;
 	return ret;
 }
 
drivers/gpu/drm/nouveau/nouveau_vmm.c +5 -5
index 93807d21ceff..26a41769551a 100644
@@ -97,17 +97,17 @@ nouveau_vma_new(struct nouveau_bo *nvbo, struct nouveau_vmm *vmm,
 	list_add_tail(&vma->head, &nvbo->vma_list);
 
 	if (nvbo->bo.resource->mem_type != TTM_PL_SYSTEM &&
-	    mem->mem.page == nvbo->page) {
-		ret = nvif_vmm_get(&vmm->vmm, LAZY, false, mem->mem.page, 0,
-				   mem->mem.size, &tmp);
+	    mem->mem.impl->page == nvbo->page) {
+		ret = nvif_vmm_get(&vmm->vmm, LAZY, false, mem->mem.impl->page, 0,
+				   mem->mem.impl->size, &tmp);
 		if (ret)
 			goto done;
 
 		vma->addr = tmp.addr;
 		ret = nouveau_vma_map(vma, mem);
 	} else {
-		ret = nvif_vmm_get(&vmm->vmm, PTES, false, mem->mem.page, 0,
-				   mem->mem.size, &tmp);
+		ret = nvif_vmm_get(&vmm->vmm, PTES, false, mem->mem.impl->page, 0,
+				   mem->mem.impl->size, &tmp);
 		if (ret)
 			goto done;
 
drivers/gpu/drm/nouveau/nvif/mem.c +16 -27

67 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c +27 -20

82 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.h +3 -2
index d2012ab625d3..df7017eb98f4 100644
@@ -1,7 +1,8 @@
 #ifndef __NVKM_UMEM_H__
 #define __NVKM_UMEM_H__
 #include "mem.h"
+#include <nvif/driverif.h>
 
-int nvkm_umem_new(const struct nvkm_oclass *, void *argv, u32 argc,
-		  struct nvkm_object **);
+int nvkm_umem_new(struct nvkm_mmu *, u8 type, u8 page, u64 size, void *, u32,
+		  const struct nvif_mem_impl **, struct nvif_mem_priv **, struct nvkm_object **);
 #endif
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c +15 -8
index 05ec276facd9..8458583af0a7 100644
@@ -31,14 +31,6 @@ nvkm_ummu_sclass(struct nvkm_object *object, int index,
 {
 	struct nvkm_mmu *mmu = container_of(object, struct nvif_mmu_priv, object)->mmu;
 
-	if (mmu->func->mem.user.oclass) {
-		if (index-- == 0) {
-			oclass->base = mmu->func->mem.user;
-			oclass->ctor = nvkm_umem_new;
-			return 0;
-		}
-	}
-
 	if (mmu->func->vmm.user.oclass) {
 		if (index-- == 0) {
 			oclass->base = mmu->func->vmm.user;
@@ -50,6 +42,20 @@ nvkm_ummu_sclass(struct nvkm_object *object, int index,
 	return -EINVAL;
 }
 
+static int
+nvkm_ummu_mem_new(struct nvif_mmu_priv *ummu, u8 type, u8 page, u64 size, void *argv, u32 argc,
+		  const struct nvif_mem_impl **pimpl, struct nvif_mem_priv **ppriv, u64 handle)
+{
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_umem_new(ummu->mmu, type, page, size, argv, argc, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	return nvkm_object_link_rb(ummu->object.client, &ummu->object, handle, object);
+}
+
 static void
 nvkm_ummu_del(struct nvif_mmu_priv *ummu)
 {
@@ -110,6 +116,7 @@ nvkm_ummu_new(struct nvkm_device *device, const struct nvif_mmu_impl **pimpl,
 	}
 
 	ummu->impl.mem.oclass = mmu->func->mem.user.oclass;
+	ummu->impl.mem.new = nvkm_ummu_mem_new;
 
 	ummu->impl.vmm.oclass = mmu->func->vmm.user.oclass;
 
Signature · 1 line
2.41.0
author
#85 lore raw

PATCH 84/156 drm/nouveau/nvif: rework mem "map"/"unmap" apis

In reply to Ben Skeggs

- transition from "ioctl" interfaces

---
 drivers/gpu/drm/nouveau/dispnv50/crc.c        |  8 ++--
 drivers/gpu/drm/nouveau/dispnv50/crc.h        |  1 +
 drivers/gpu/drm/nouveau/dispnv50/crc907d.c    |  4 +-
 drivers/gpu/drm/nouveau/dispnv50/crcc37d.c    |  4 +-
 drivers/gpu/drm/nouveau/dispnv50/disp.c       | 14 +++---
 drivers/gpu/drm/nouveau/dispnv50/lut.c        | 12 ++---
 drivers/gpu/drm/nouveau/dispnv50/lut.h        |  5 +-
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  3 ++
 drivers/gpu/drm/nouveau/include/nvif/mem.h    |  6 ++-
 drivers/gpu/drm/nouveau/include/nvif/push.h   |  3 +-
 drivers/gpu/drm/nouveau/nouveau_bo.c          | 21 ++++----
 drivers/gpu/drm/nouveau/nouveau_chan.c        | 31 +++++++-----
 drivers/gpu/drm/nouveau/nouveau_chan.h        |  6 ++-
 drivers/gpu/drm/nouveau/nouveau_dma.c         |  8 ++--
 drivers/gpu/drm/nouveau/nouveau_dma.h         |  2 +-
 drivers/gpu/drm/nouveau/nv10_fence.c          |  2 +-
 drivers/gpu/drm/nouveau/nvif/mem.c            | 48 ++++++++++++++++++-
 .../gpu/drm/nouveau/nvkm/subdev/mmu/umem.c    | 24 ++++------
 18 files changed, 132 insertions(+), 70 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/crc.c +4 -4
index 694c25a19e25..9482e69c3647 100644
@@ -120,7 +120,7 @@ static void nv50_crc_ctx_flip_work(struct kthread_work *base)
 
 static inline void nv50_crc_reset_ctx(struct nv50_crc_notifier_ctx *ctx)
 {
-	memset_io(ctx->mem.object.map.ptr, 0, ctx->mem.object.map.size);
+	memset_io(ctx->map.ptr, 0, ctx->map.impl->length);
 }
 
 static void
@@ -503,7 +503,7 @@ nv50_crc_ctx_init(struct nv50_head *head, struct nvif_mmu *mmu,
 	struct nv50_core *core = nv50_disp(head->base.base.dev)->core;
 	int ret;
 
-	ret = nvif_mem_ctor_map(mmu, "kmsCrcNtfy", NVIF_MEM_VRAM, len, &ctx->mem);
+	ret = nvif_mem_ctor_map(mmu, "kmsCrcNtfy", NVIF_MEM_VRAM, len, &ctx->mem, &ctx->map);
 	if (ret)
 		return ret;
 
@@ -524,7 +524,7 @@ nv50_crc_ctx_init(struct nv50_head *head, struct nvif_mmu *mmu,
 	return 0;
 
 fail_fini:
-	nvif_mem_dtor(&ctx->mem);
+	nvif_mem_unmap_dtor(&ctx->mem, &ctx->map);
 	return ret;
 }
 
@@ -532,7 +532,7 @@ static inline void
 nv50_crc_ctx_fini(struct nv50_crc_notifier_ctx *ctx)
 {
 	nvif_object_dtor(&ctx->ntfy);
-	nvif_mem_dtor(&ctx->mem);
+	nvif_mem_unmap_dtor(&ctx->mem, &ctx->map);
 }
 
 int nv50_crc_set_source(struct drm_crtc *crtc, const char *source_str)
drivers/gpu/drm/nouveau/dispnv50/crc.h +1 -0
index 4823f1fde2dd..48564ceddb97 100644
@@ -40,6 +40,7 @@ enum nv50_crc_source_type {
 
 struct nv50_crc_notifier_ctx {
 	struct nvif_mem mem;
+	struct nvif_map map;
 	struct nvif_object ntfy;
 };
 
drivers/gpu/drm/nouveau/dispnv50/crc907d.c +2 -2
index a674ba435b05..998978967c4c 100644
@@ -89,7 +89,7 @@ static u32 crc907d_get_entry(struct nv50_head *head,
 			     struct nv50_crc_notifier_ctx *ctx,
 			     enum nv50_crc_source source, int idx)
 {
-	struct crc907d_notifier __iomem *notifier = ctx->mem.object.map.ptr;
+	struct crc907d_notifier __iomem *notifier = ctx->map.ptr;
 
 	return ioread32_native(&notifier->entries[idx].output_crc[0]);
 }
@@ -98,7 +98,7 @@ static bool crc907d_ctx_finished(struct nv50_head *head,
 				 struct nv50_crc_notifier_ctx *ctx)
 {
 	struct nouveau_drm *drm = nouveau_drm(head->base.base.dev);
-	struct crc907d_notifier __iomem *notifier = ctx->mem.object.map.ptr;
+	struct crc907d_notifier __iomem *notifier = ctx->map.ptr;
 	const u32 status = ioread32_native(&notifier->status);
 	const u32 overflow = status & 0x0000003e;
 
drivers/gpu/drm/nouveau/dispnv50/crcc37d.c +2 -2
index 4821ce32f9ed..6af15f3232d9 100644
@@ -67,7 +67,7 @@ int crcc37d_set_ctx(struct nv50_head *head, struct nv50_crc_notifier_ctx *ctx)
 u32 crcc37d_get_entry(struct nv50_head *head, struct nv50_crc_notifier_ctx *ctx,
 		      enum nv50_crc_source source, int idx)
 {
-	struct crcc37d_notifier __iomem *notifier = ctx->mem.object.map.ptr;
+	struct crcc37d_notifier __iomem *notifier = ctx->map.ptr;
 	struct crcc37d_entry __iomem *entry = &notifier->entries[idx];
 	u32 __iomem *crc_addr;
 
@@ -82,7 +82,7 @@ u32 crcc37d_get_entry(struct nv50_head *head, struct nv50_crc_notifier_ctx *ctx,
 bool crcc37d_ctx_finished(struct nv50_head *head, struct nv50_crc_notifier_ctx *ctx)
 {
 	struct nouveau_drm *drm = nouveau_drm(head->base.base.dev);
-	struct crcc37d_notifier __iomem *notifier = ctx->mem.object.map.ptr;
+	struct crcc37d_notifier __iomem *notifier = ctx->map.ptr;
 	const u32 status = ioread32_native(&notifier->status);
 	const u32 overflow = status & 0x0000007e;
 
drivers/gpu/drm/nouveau/dispnv50/disp.c +7 -7
index 4508c24720e2..b89a8f4ee506 100644
@@ -124,7 +124,7 @@ nv50_dmac_destroy(struct nv50_dmac *dmac)
 {
 	nv50_chan_destroy(&dmac->base);
 
-	nvif_mem_dtor(&dmac->push.mem);
+	nvif_mem_unmap_dtor(&dmac->push.mem, &dmac->push.map);
 }
 
 static void
@@ -132,7 +132,7 @@ nv50_dmac_kick(struct nvif_push *push)
 {
 	struct nv50_dmac *dmac = container_of(push, typeof(*dmac), push);
 
-	push->hw.cur = push->cur - (u32 __iomem *)dmac->push.mem.object.map.ptr;
+	push->hw.cur = push->cur - (u32 __iomem *)dmac->push.map.ptr;
 	if (push->hw.put != push->hw.cur) {
 		/* Push buffer fetches are not coherent with BAR1, we need to ensure
 		 * writes have been flushed right through to VRAM before writing PUT.
@@ -198,13 +198,13 @@ nv50_dmac_wait(struct nvif_push *push, u32 size)
 	if (WARN_ON(size > push->hw.max))
 		return -EINVAL;
 
-	push->hw.cur = push->cur - (u32 __iomem *)dmac->push.mem.object.map.ptr;
+	push->hw.cur = push->cur - (u32 __iomem *)dmac->push.map.ptr;
 	if (push->hw.cur + size >= push->hw.max) {
 		int ret = nv50_dmac_wind(dmac);
 		if (ret)
 			return ret;
 
-		push->cur = dmac->push.mem.object.map.ptr;
+		push->cur = dmac->push.map.ptr;
 		push->cur = push->cur + push->hw.cur;
 		nv50_dmac_kick(push);
 	}
@@ -217,7 +217,7 @@ nv50_dmac_wait(struct nvif_push *push, u32 size)
 		return -ETIMEDOUT;
 	}
 
-	push->bgn = dmac->push.mem.object.map.ptr;
+	push->bgn = dmac->push.map.ptr;
 	push->bgn = push->bgn + push->hw.cur;
 	push->cur = push->bgn;
 	push->end = push->cur + free;
@@ -253,13 +253,13 @@ nv50_dmac_create(struct nouveau_drm *drm,
 		type |= NVIF_MEM_VRAM;
 
 	ret = nvif_mem_ctor_map(&drm->mmu, "kmsChanPush", type, 0x1000,
-				&dmac->push.mem);
+				&dmac->push.mem, &dmac->push.map);
 	if (ret)
 		return ret;
 
 	dmac->push.wait = nv50_dmac_wait;
 	dmac->push.kick = nv50_dmac_kick;
-	dmac->push.bgn = dmac->push.mem.object.map.ptr;
+	dmac->push.bgn = dmac->push.map.ptr;
 	dmac->push.cur = dmac->push.bgn;
 	dmac->push.end = dmac->push.bgn;
 	dmac->push.hw.max = 0x1000/4 - 1;
drivers/gpu/drm/nouveau/dispnv50/lut.c +6 -6
index 7d68a7efc1d5..54885e5b3196 100644
@@ -33,8 +33,8 @@ nv50_lut_load(struct nv50_lut *lut, int buffer, struct drm_property_blob *blob,
 	      void (*load)(struct drm_color_lut *, int, void __iomem *))
 {
 	struct drm_color_lut *in = blob ? blob->data : NULL;
-	void __iomem *mem = lut->mem[buffer].object.map.ptr;
-	const u32 addr = lut->mem[buffer].impl->addr;
+	void __iomem *mem = lut->id[buffer].map.ptr;
+	const u32 addr = lut->id[buffer].mem.impl->addr;
 	int i;
 
 	if (!in) {
@@ -59,8 +59,8 @@ void
 nv50_lut_fini(struct nv50_lut *lut)
 {
 	int i;
-	for (i = 0; i < ARRAY_SIZE(lut->mem); i++)
-		nvif_mem_dtor(&lut->mem[i]);
+	for (i = 0; i < ARRAY_SIZE(lut->id); i++)
+		nvif_mem_unmap_dtor(&lut->id[i].mem, &lut->id[i].map);
 }
 
 int
@@ -69,9 +69,9 @@ nv50_lut_init(struct nv50_disp *disp, struct nvif_mmu *mmu,
 {
 	const u32 size = disp->disp->object.oclass < GF110_DISP ? 257 : 1025;
 	int i;
-	for (i = 0; i < ARRAY_SIZE(lut->mem); i++) {
+	for (i = 0; i < ARRAY_SIZE(lut->id); i++) {
 		int ret = nvif_mem_ctor_map(mmu, "kmsLut", NVIF_MEM_VRAM,
-					    size * 8, &lut->mem[i]);
+					    size * 8, &lut->id[i].mem, &lut->id[i].map);
 		if (ret)
 			return ret;
 	}
drivers/gpu/drm/nouveau/dispnv50/lut.h +4 -1
index b3b9040cfe9a..a7130c3c7a4a 100644
@@ -6,7 +6,10 @@ struct drm_color_lut;
 struct nv50_disp;
 
 struct nv50_lut {
-	struct nvif_mem mem[2];
+	struct {
+		struct nvif_mem mem;
+		struct nvif_map map;
+	} id[2];
 };
 
 int nv50_lut_init(struct nv50_disp *, struct nvif_mmu *, struct nv50_lut *);
drivers/gpu/drm/nouveau/include/nvif/driverif.h +3 -0
index de380979e1a4..2d883125f02b 100644
@@ -83,6 +83,9 @@ struct nvif_mem_impl {
 	u8 page;
 	u64 addr;
 	u64 size;
+
+	int (*map)(struct nvif_mem_priv *, void *argv, u32 argc, struct nvif_mapinfo *);
+	int (*unmap)(struct nvif_mem_priv *);
 };
 
 struct nvif_mmu_impl {
drivers/gpu/drm/nouveau/include/nvif/mem.h +5 -1
index 8d432d238b95..e35cbc6f0ef7 100644
@@ -8,6 +8,7 @@ struct nvif_mem {
 	struct nvif_object object;
 
 	u8 type;
+	struct nvif_mapinfo mapinfo;
 };
 
 int nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name,
@@ -16,7 +17,10 @@ int nvif_mem_ctor_type(struct nvif_mmu *mmu, const char *name,
 int nvif_mem_ctor(struct nvif_mmu *mmu, const char *name, u8 type,
 		  u8 page, u64 size, void *argv, u32 argc, struct nvif_mem *);
 void nvif_mem_dtor(struct nvif_mem *);
+int nvif_mem_map(struct nvif_mem *, void *argv, u32 argc, struct nvif_map *);
+int nvif_mem_unmap(struct nvif_mem *);
 
 int nvif_mem_ctor_map(struct nvif_mmu *, const char *name, u8 type, u64 size,
-		      struct nvif_mem *);
+		      struct nvif_mem *, struct nvif_map *map);
+int nvif_mem_unmap_dtor(struct nvif_mem *, struct nvif_map *);
 #endif
drivers/gpu/drm/nouveau/include/nvif/push.h +2 -1
index b88024ef6cc0..8817947a2ea0 100644
@@ -28,6 +28,7 @@
 
 struct nvif_push {
 	struct nvif_mem mem;
+	struct nvif_map map;
 
 	struct {
 		u32 cur;
@@ -68,7 +69,7 @@ PUSH_KICK(struct nvif_push *push)
 #ifdef CONFIG_NOUVEAU_DEBUG_PUSH
 #define PUSH_PRINTF(p,f,a...) do {                              \
 	struct nvif_push *_ppp = (p);                           \
-	u32 __o = _ppp->cur - (u32 *)_ppp->mem.object.map.ptr;  \
+	u32 __o = _ppp->cur - (u32 *)_ppp->map.ptr;             \
 	NVIF_DEBUG(&_ppp->mem.object, "%08x: "f, __o * 4, ##a); \
 	(void)__o;                                              \
 } while(0)
drivers/gpu/drm/nouveau/nouveau_bo.c +11 -10
index 6c90f853513d..4c7aced7c398 100644
@@ -1162,10 +1162,10 @@ nouveau_ttm_io_mem_free_locked(struct nouveau_drm *drm,
 		switch (reg->mem_type) {
 		case TTM_PL_TT:
 			if (mem->kind)
-				nvif_object_unmap_handle(&mem->mem.object);
+				mem->mem.impl->unmap(mem->mem.priv);
 			break;
 		case TTM_PL_VRAM:
-			nvif_object_unmap_handle(&mem->mem.object);
+			mem->mem.impl->unmap(mem->mem.priv);
 			break;
 		default:
 			break;
@@ -1222,7 +1222,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *reg)
 				struct nv50_mem_map_v0 nv50;
 				struct gf100_mem_map_v0 gf100;
 			} args;
-			u64 handle, length;
+			struct nvif_mapinfo mapinfo;
 			u32 argc = 0;
 
 			switch (mmu->impl->mem.oclass) {
@@ -1244,16 +1244,17 @@ nouveau_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *reg)
 				break;
 			}
 
-			ret = nvif_object_map_handle(&mem->mem.object,
-						     &args, argc,
-						     &handle, &length);
-			if (ret != 1) {
-				if (WARN_ON(ret == 0))
-					ret = -EINVAL;
+			ret = mem->mem.impl->map(mem->mem.priv, &args, argc, &mapinfo);
+			if (ret)
+				goto out;
+
+			if (WARN_ON(mapinfo.type != NVIF_MAP_IO)) {
+				mem->mem.impl->unmap(mem->mem.priv);
+				ret = -EINVAL;
 				goto out;
 			}
 
-			reg->bus.offset = handle;
+			reg->bus.offset = mapinfo.handle;
 		}
 		ret = 0;
 		break;
drivers/gpu/drm/nouveau/nouveau_chan.c +19 -12
index dd4f9915ccaf..db6eb3de694e 100644
@@ -101,8 +101,11 @@ nouveau_channel_del(struct nouveau_channel **pchan)
 		nvif_object_dtor(&chan->gart);
 		nvif_object_dtor(&chan->vram);
 		nvif_event_dtor(&chan->kill);
+		if (!chan->userd.map.impl)
+			chan->userd.map.ptr = NULL;
+		nvif_object_unmap_cpu(&chan->userd.map);
 		nvif_object_dtor(&chan->user);
-		nvif_mem_dtor(&chan->mem_userd);
+		nvif_mem_dtor(&chan->userd.mem);
 		nvif_object_dtor(&chan->push.ctxdma);
 		nouveau_vma_del(&chan->push.vma);
 		nouveau_bo_unmap(chan->push.buffer);
@@ -131,7 +134,7 @@ nouveau_channel_wait(struct nvif_push *push, u32 size)
 	chan->dma.cur = chan->dma.cur + (chan->chan.push.cur - chan->chan.push.bgn);
 	ret = RING_SPACE(chan, size);
 	if (ret == 0) {
-		chan->chan.push.bgn = chan->chan.push.mem.object.map.ptr;
+		chan->chan.push.bgn = chan->chan.push.map.ptr;
 		chan->chan.push.bgn = chan->chan.push.bgn + chan->dma.cur;
 		chan->chan.push.cur = chan->chan.push.bgn;
 		chan->chan.push.end = chan->chan.push.bgn + size;
@@ -179,7 +182,7 @@ nouveau_channel_prep(struct nouveau_cli *cli,
 	chan->chan.push.mem.object.parent = cli->base.object.parent;
 	chan->chan.push.mem.object.client = &cli->base;
 	chan->chan.push.mem.object.name = "chanPush";
-	chan->chan.push.mem.object.map.ptr = chan->push.buffer->kmap.virtual;
+	chan->chan.push.map.ptr = chan->push.buffer->kmap.virtual;
 	chan->chan.push.wait = nouveau_channel_wait;
 	chan->chan.push.kick = nouveau_channel_kick;
 
@@ -330,16 +333,12 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 	if (oclass >= VOLTA_CHANNEL_GPFIFO_A) {
 		ret = nvif_mem_ctor(&cli->mmu, "abi16ChanUSERD",
 				    NVIF_MEM_VRAM | NVIF_MEM_COHERENT | NVIF_MEM_MAPPABLE,
-				    0, PAGE_SIZE, NULL, 0, &chan->mem_userd);
+				    0, PAGE_SIZE, NULL, 0, &chan->userd.mem);
 		if (ret)
 			return ret;
 
-		args.chan.huserd = nvif_handle(&chan->mem_userd.object);
+		args.chan.huserd = nvif_handle(&chan->userd.mem.object);
 		args.chan.ouserd = 0;
-
-		chan->userd = &chan->mem_userd.object;
-	} else {
-		chan->userd = &chan->user;
 	}
 
 	get_task_comm(name, current);
@@ -366,9 +365,17 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 	struct nv_dma_v0 args = {};
 	int ret, i;
 
-	ret = nvif_object_map(chan->userd, NULL, 0);
-	if (ret)
-		return ret;
+	if (!chan->userd.mem.impl) {
+		ret = nvif_object_map(&chan->user, NULL, 0);
+		if (ret)
+			return ret;
+
+		chan->userd.map.ptr = chan->user.map.ptr;
+	} else {
+		ret = nvif_mem_map(&chan->userd.mem, NULL, 0, &chan->userd.map);
+		if (ret)
+			return ret;
+	}
 
 	if (chan->user.oclass >= FERMI_CHANNEL_GPFIFO) {
 		struct {
drivers/gpu/drm/nouveau/nouveau_chan.h +4 -2
index 016f668c0bc1..811271ae6fe1 100644
@@ -14,8 +14,10 @@ struct nouveau_channel {
 	struct nouveau_cli *cli;
 	struct nouveau_vmm *vmm;
 
-	struct nvif_mem mem_userd;
-	struct nvif_object *userd;
+	struct {
+		struct nvif_mem mem;
+		struct nvif_map map;
+	} userd;
 
 	int runlist;
 	int chid;
drivers/gpu/drm/nouveau/nouveau_dma.c +4 -4
index 83eb9c9fa67e..43374a04654a 100644
@@ -42,9 +42,9 @@ READ_GET(struct nouveau_channel *chan, uint64_t *prev_get, int *timeout)
 {
 	uint64_t val;
 
-	val = nvif_rd32(chan->userd, chan->user_get);
+	val = nvif_rd32(&chan->userd, chan->user_get);
         if (chan->user_get_hi)
-		val |= (uint64_t)nvif_rd32(chan->userd, chan->user_get_hi) << 32;
+		val |= (uint64_t)nvif_rd32(&chan->userd, chan->user_get_hi) << 32;
 
 	/* reset counter as long as GET is still advancing, this is
 	 * to avoid misdetecting a GPU lockup if the GPU happens to
@@ -89,7 +89,7 @@ nv50_dma_push(struct nouveau_channel *chan, u64 offset, u32 length,
 	/* Flush writes. */
 	nouveau_bo_rd32(pb, 0);
 
-	nvif_wr32(chan->userd, 0x8c, chan->dma.ib_put);
+	nvif_wr32(&chan->userd, 0x8c, chan->dma.ib_put);
 	if (user->func && user->func->doorbell)
 		user->func->doorbell(user, chan->token);
 	chan->dma.ib_free--;
@@ -101,7 +101,7 @@ nv50_dma_push_wait(struct nouveau_channel *chan, int count)
 	uint32_t cnt = 0, prev_get = 0;
 
 	while (chan->dma.ib_free < count) {
-		uint32_t get = nvif_rd32(chan->userd, 0x88);
+		uint32_t get = nvif_rd32(&chan->userd, 0x88);
 		if (get != prev_get) {
 			prev_get = get;
 			cnt = 0;
drivers/gpu/drm/nouveau/nouveau_dma.h +1 -1
index c52cda82353e..e5d718844c76 100644
@@ -84,7 +84,7 @@ OUT_RING(struct nouveau_channel *chan, int data)
 #define WRITE_PUT(val) do {                                                    \
 	mb();                                                   \
 	nouveau_bo_rd32(chan->push.buffer, 0);                                 \
-	nvif_wr32(&chan->user, chan->user_put, ((val) << 2) + chan->push.addr);\
+	nvif_wr32(&chan->userd, chan->user_put, ((val) << 2) + chan->push.addr);\
 } while (0)
 
 static inline void
drivers/gpu/drm/nouveau/nv10_fence.c +1 -1
index 1e45b5fcbf23..cbef6ef4bfb7 100644
@@ -52,7 +52,7 @@ nv10_fence_sync(struct nouveau_fence *fence,
 u32
 nv10_fence_read(struct nouveau_channel *chan)
 {
-	return NVIF_RD32(&chan->user, NV06E, REFERENCE);
+	return NVIF_RD32(&chan->userd, NV06E, REFERENCE);
 }
 
 void
drivers/gpu/drm/nouveau/nvif/mem.c +46 -2

66 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c +10 -14
index f1ec0ed8e7c3..6756e3e207d9 100644
@@ -78,10 +78,8 @@ nvkm_umem_search(struct nvkm_mmu *mmu, struct nvkm_client *client, u64 handle)
 }
 
 static int
-nvkm_umem_unmap(struct nvkm_object *object)
+nvkm_umem_unmap(struct nvif_mem_priv *umem)
 {
-	struct nvif_mem_priv *umem = container_of(object, typeof(*umem), object);
-
 	if (!umem->map)
 		return -EEXIST;
 
@@ -101,10 +99,8 @@ nvkm_umem_unmap(struct nvkm_object *object)
 }
 
 static int
-nvkm_umem_map(struct nvkm_object *object, void *argv, u32 argc,
-	      enum nvkm_object_map *type, u64 *handle, u64 *length)
+nvkm_umem_map(struct nvif_mem_priv *umem, void *argv, u32 argc, struct nvif_mapinfo *map)
 {
-	struct nvif_mem_priv *umem = container_of(object, typeof(*umem), object);
 	struct nvkm_mmu *mmu = umem->mmu;
 
 	if (!umem->mappable)
@@ -117,24 +113,24 @@ nvkm_umem_map(struct nvkm_object *object, void *argv, u32 argc,
 		if (ret)
 			return ret;
 
-		*handle = (unsigned long)(void *)umem->map;
-		*length = nvkm_memory_size(umem->memory);
-		*type = NVKM_OBJECT_MAP_VA;
+		map->handle = (unsigned long)(void *)umem->map;
+		map->length = nvkm_memory_size(umem->memory);
+		map->type = NVIF_MAP_VA;
 		return 0;
 	} else
 	if ((umem->type & NVKM_MEM_VRAM) ||
 	    (umem->type & NVKM_MEM_KIND)) {
 		int ret = mmu->func->mem.umap(mmu, umem->memory, argv, argc,
-					      handle, length, &umem->bar);
+					      &map->handle, &map->length, &umem->bar);
 		if (ret)
 			return ret;
 
-		*type = NVKM_OBJECT_MAP_IO;
+		map->type = NVIF_MAP_IO;
 	} else {
 		return -EINVAL;
 	}
 
-	umem->io = (*type == NVKM_OBJECT_MAP_IO);
+	umem->io = (map->type == NVIF_MAP_IO);
 	return 0;
 }
 
@@ -149,6 +145,8 @@ nvkm_umem_del(struct nvif_mem_priv *umem)
 static const struct nvif_mem_impl
 nvkm_umem_impl = {
 	.del = nvkm_umem_del,
+	.map = nvkm_umem_map,
+	.unmap = nvkm_umem_unmap,
 };
 
 static void *
@@ -166,8 +164,6 @@ nvkm_umem_dtor(struct nvkm_object *object)
 static const struct nvkm_object_func
 nvkm_umem = {
 	.dtor = nvkm_umem_dtor,
-	.map = nvkm_umem_map,
-	.unmap = nvkm_umem_unmap,
 };
 
 int
Signature · 1 line
2.41.0
author
#86 lore raw

PATCH 85/156 drm/nouveau/nvif: rework mmu "new vmm" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 18 +++++++
 drivers/gpu/drm/nouveau/include/nvif/if000c.h | 12 -----
 drivers/gpu/drm/nouveau/include/nvif/vmm.h    | 12 ++---
 drivers/gpu/drm/nouveau/nouveau_bo.c          |  4 +-
 drivers/gpu/drm/nouveau/nouveau_chan.c        | 10 ++--
 drivers/gpu/drm/nouveau/nouveau_svm.c         |  2 +-
 drivers/gpu/drm/nouveau/nouveau_ttm.c         |  2 +-
 drivers/gpu/drm/nouveau/nouveau_uvmm.c        |  2 +-
 drivers/gpu/drm/nouveau/nouveau_vmm.c         |  2 +-
 drivers/gpu/drm/nouveau/nvif/mmu.c            |  2 +-
 drivers/gpu/drm/nouveau/nvif/vmm.c            | 48 +++++++----------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c    | 24 ++++-----
 .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h    |  2 -
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 51 +++++++++++--------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h    |  4 +-
 15 files changed, 94 insertions(+), 101 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +18 -0
index 2d883125f02b..4d256a3c3fcf 100644
@@ -7,6 +7,7 @@ struct nvif_control_priv;
 struct nvif_usermode_priv;
 struct nvif_mmu_priv;
 struct nvif_mem_priv;
+struct nvif_vmm_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -88,6 +89,20 @@ struct nvif_mem_impl {
 	int (*unmap)(struct nvif_mem_priv *);
 };
 
+enum nvif_vmm_type {
+	NVIF_VMM_TYPE_UNMANAGED,
+	NVIF_VMM_TYPE_MANAGED,
+	NVIF_VMM_TYPE_RAW,
+};
+
+struct nvif_vmm_impl {
+	void (*del)(struct nvif_vmm_priv *);
+
+	u64 start;
+	u64 limit;
+	u8 page_nr;
+};
+
 struct nvif_mmu_impl {
 	void (*del)(struct nvif_mmu_priv *);
 
@@ -125,6 +140,9 @@ struct nvif_mmu_impl {
 
 	struct {
 		s32 oclass;
+		int (*new)(struct nvif_mmu_priv *, enum nvif_vmm_type type, u64 addr, u64 size,
+			   void *, u32, const struct nvif_vmm_impl **, struct nvif_vmm_priv **,
+			   u64 handle);
 	} vmm;
 };
 
drivers/gpu/drm/nouveau/include/nvif/if000c.h +0 -12
index a5a182b3c28d..c505c5de0088 100644
@@ -1,17 +1,5 @@
 #ifndef __NVIF_IF000C_H__
 #define __NVIF_IF000C_H__
-struct nvif_vmm_v0 {
-	__u8  version;
-	__u8  page_nr;
-#define NVIF_VMM_V0_TYPE_UNMANAGED                                         0x00
-#define NVIF_VMM_V0_TYPE_MANAGED                                           0x01
-#define NVIF_VMM_V0_TYPE_RAW                                               0x02
-	__u8  type;
-	__u8  pad03[5];
-	__u64 addr;
-	__u64 size;
-	__u8  data[];
-};
 
 #define NVIF_VMM_V0_PAGE                                                   0x00
 #define NVIF_VMM_V0_GET                                                    0x01
drivers/gpu/drm/nouveau/include/nvif/vmm.h +3 -9
index e8d8fbd56010..c4b5d53d9bfd 100644
@@ -1,15 +1,10 @@
 #ifndef __NVIF_VMM_H__
 #define __NVIF_VMM_H__
 #include <nvif/object.h>
+#include <nvif/driverif.h> /* NVIF_VMM_TYPE */
 struct nvif_mem;
 struct nvif_mmu;
 
-enum nvif_vmm_type {
-	UNMANAGED,
-	MANAGED,
-	RAW,
-};
-
 enum nvif_vmm_get {
 	ADDR,
 	PTES,
@@ -22,9 +17,9 @@ struct nvif_vma {
 };
 
 struct nvif_vmm {
+	const struct nvif_vmm_impl *impl;
+	struct nvif_vmm_priv *priv;
 	struct nvif_object object;
-	u64 start;
-	u64 limit;
 
 	struct {
 		u8 shift;
@@ -33,7 +28,6 @@ struct nvif_vmm {
 		bool host:1;
 		bool comp:1;
 	} *page;
-	int page_nr;
 };
 
 int nvif_vmm_ctor(struct nvif_mmu *, const char *name,
drivers/gpu/drm/nouveau/nouveau_bo.c +2 -2
index 4c7aced7c398..29e00f8fdd12 100644
@@ -264,7 +264,7 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
 		nvbo->mode = tile_mode;
 
 		/* Determine the desirable target GPU page size for the buffer. */
-		for (i = 0; i < vmm->page_nr; i++) {
+		for (i = 0; i < vmm->impl->page_nr; i++) {
 			/* Because we cannot currently allow VMM maps to fail
 			 * during buffer migration, we need to determine page
 			 * size for the buffer up-front, and pre-allocate its
@@ -311,7 +311,7 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
 			return ERR_PTR(-EINVAL);
 
 		/* Determine the desirable target GPU page size for the buffer. */
-		for (i = 0; i < vmm->page_nr; i++) {
+		for (i = 0; i < vmm->impl->page_nr; i++) {
 			/* Because we cannot currently allow VMM maps to fail
 			 * during buffer migration, we need to determine page
 			 * size for the buffer up-front, and pre-allocate its
drivers/gpu/drm/nouveau/nouveau_chan.c +5 -5
index db6eb3de694e..27c477ed6b9b 100644
@@ -208,7 +208,7 @@ nouveau_channel_prep(struct nouveau_cli *cli,
 		args.target = NV_DMA_V0_TARGET_VM;
 		args.access = NV_DMA_V0_ACCESS_VM;
 		args.start = 0;
-		args.limit = chan->vmm->vmm.limit - 1;
+		args.limit = chan->vmm->vmm.impl->limit - 1;
 	} else
 	if (chan->push.buffer->bo.resource->mem_type == TTM_PL_VRAM) {
 		if (device->info.family == NV_DEVICE_INFO_V0_TNT) {
@@ -237,7 +237,7 @@ nouveau_channel_prep(struct nouveau_cli *cli,
 			args.target = NV_DMA_V0_TARGET_VM;
 			args.access = NV_DMA_V0_ACCESS_RDWR;
 			args.start = 0;
-			args.limit = chan->vmm->vmm.limit - 1;
+			args.limit = chan->vmm->vmm.impl->limit - 1;
 		}
 	}
 
@@ -404,7 +404,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 			args.target = NV_DMA_V0_TARGET_VM;
 			args.access = NV_DMA_V0_ACCESS_VM;
 			args.start = 0;
-			args.limit = chan->vmm->vmm.limit - 1;
+			args.limit = chan->vmm->vmm.impl->limit - 1;
 		} else {
 			args.target = NV_DMA_V0_TARGET_VRAM;
 			args.access = NV_DMA_V0_ACCESS_RDWR;
@@ -422,7 +422,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 			args.target = NV_DMA_V0_TARGET_VM;
 			args.access = NV_DMA_V0_ACCESS_VM;
 			args.start = 0;
-			args.limit = chan->vmm->vmm.limit - 1;
+			args.limit = chan->vmm->vmm.impl->limit - 1;
 		} else
 		if (drm->agp.bridge) {
 			args.target = NV_DMA_V0_TARGET_AGP;
@@ -433,7 +433,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 			args.target = NV_DMA_V0_TARGET_VM;
 			args.access = NV_DMA_V0_ACCESS_RDWR;
 			args.start = 0;
-			args.limit = chan->vmm->vmm.limit - 1;
+			args.limit = chan->vmm->vmm.impl->limit - 1;
 		}
 
 		ret = nvif_object_ctor(&chan->user, "abi16ChanGartCtxDma", gart,
drivers/gpu/drm/nouveau/nouveau_svm.c +1 -1
index a478b5a9ed0a..cf5dfbe63e69 100644
@@ -346,7 +346,7 @@ nouveau_svmm_init(struct drm_device *dev, void *data,
 	 * All future channel/memory allocations will make use of this
 	 * VMM instead of the standard one.
 	 */
-	ret = nvif_vmm_ctor(&cli->mmu, "svmVmm", MANAGED,
+	ret = nvif_vmm_ctor(&cli->mmu, "svmVmm", NVIF_VMM_TYPE_MANAGED,
 			    args->unmanaged_addr, args->unmanaged_size,
 			    &(struct gp100_vmm_v0) {
 				.fault_replay = true,
drivers/gpu/drm/nouveau/nouveau_ttm.c +1 -1
index f87ca8a0e6ae..2d6f1c97db1c 100644
@@ -326,7 +326,7 @@ nouveau_ttm_init(struct nouveau_drm *drm)
 
 	/* GART init */
 	if (!drm->agp.bridge) {
-		drm->gem.gart_available = drm->client.vmm.vmm.limit;
+		drm->gem.gart_available = drm->cli.vmm.vmm.impl->limit;
 	} else {
 		drm->gem.gart_available = drm->agp.size;
 	}
drivers/gpu/drm/nouveau/nouveau_uvmm.c +1 -1
index d35096071c1a..1340138bbc13 100644
@@ -1865,7 +1865,7 @@ nouveau_uvmm_ioctl_vm_init(struct drm_device *dev,
 	/* GPUVM takes care from here on. */
 	drm_gem_object_put(r_obj);
 
-	ret = nvif_vmm_ctor(&cli->mmu, "uvmm", RAW,
+	ret = nvif_vmm_ctor(&cli->mmu, "uvmm", NVIF_VMM_TYPE_RAW,
 			    init->kernel_managed_addr,
 			    init->kernel_managed_size,
 			    NULL, 0, &uvmm->vmm.vmm);
drivers/gpu/drm/nouveau/nouveau_vmm.c +1 -1
index 26a41769551a..353c1a3f9714 100644
@@ -131,7 +131,7 @@ nouveau_vmm_fini(struct nouveau_vmm *vmm)
 int
 nouveau_vmm_init(struct nouveau_cli *cli, struct nouveau_vmm *vmm)
 {
-	int ret = nvif_vmm_ctor(&cli->mmu, "drmVmm", UNMANAGED,
+	int ret = nvif_vmm_ctor(&cli->mmu, "drmVmm", NVIF_VMM_TYPE_UNMANAGED,
 				PAGE_SIZE, 0, NULL, 0, &vmm->vmm);
 	if (ret)
 		return ret;
drivers/gpu/drm/nouveau/nvif/mmu.c +1 -1
index d1d09e5a6909..cf1d27f2678d 100644
@@ -50,5 +50,5 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu
 		return ret;
 
 	nvif_object_ctor(&device->object, name ?: "nvifMmu", 0, oclass, &mmu->object);
-	return ret;
+	return 0;
 }
drivers/gpu/drm/nouveau/nvif/vmm.c +17 -31

85 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c +11 -13
index 8458583af0a7..7afb68dc4bed 100644
@@ -26,20 +26,18 @@
 #include <core/client.h>
 
 static int
-nvkm_ummu_sclass(struct nvkm_object *object, int index,
-		 struct nvkm_oclass *oclass)
+nvkm_ummu_vmm_new(struct nvif_mmu_priv *ummu, enum nvif_vmm_type type, u64 addr, u64 size,
+		  void *argv, u32 argc, const struct nvif_vmm_impl **pimpl,
+		  struct nvif_vmm_priv **ppriv, u64 handle)
 {
-	struct nvkm_mmu *mmu = container_of(object, struct nvif_mmu_priv, object)->mmu;
-
-	if (mmu->func->vmm.user.oclass) {
-		if (index-- == 0) {
-			oclass->base = mmu->func->vmm.user;
-			oclass->ctor = nvkm_uvmm_new;
-			return 0;
-		}
-	}
+	struct nvkm_object *object;
+	int ret;
 
-	return -EINVAL;
+	ret = nvkm_uvmm_new(ummu->mmu, type, addr, size, argv, argc, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	return nvkm_object_link_rb(ummu->object.client, &ummu->object, handle, object);
 }
 
 static int
@@ -71,7 +69,6 @@ nvkm_ummu_impl = {
 
 static const struct nvkm_object_func
 nvkm_ummu = {
-	.sclass = nvkm_ummu_sclass,
 };
 
 int
@@ -119,6 +116,7 @@ nvkm_ummu_new(struct nvkm_device *device, const struct nvif_mmu_impl **pimpl,
 	ummu->impl.mem.new = nvkm_ummu_mem_new;
 
 	ummu->impl.vmm.oclass = mmu->func->vmm.user.oclass;
+	ummu->impl.vmm.new = nvkm_ummu_vmm_new;
 
 	*pimpl = &ummu->impl;
 	*ppriv = ummu;
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.h +0 -2
index c03563aa4cae..d80b2af494dd 100644
@@ -5,8 +5,6 @@ struct nvkm_device;
 
 #include <nvif/driverif.h>
 
-#define nvkm_ummu nvif_mmu_priv
-
 struct nvif_mmu_priv {
 	struct nvkm_object object;
 	struct nvkm_mmu *mmu;
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c +30 -21

93 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h +3 -1
index cf0172a320c3..51c639cd0ce0 100644
@@ -1,7 +1,9 @@
 #ifndef __NVKM_UVMM_H__
 #define __NVKM_UVMM_H__
 #include "vmm.h"
+#include <nvif/driverif.h>
 
-int nvkm_uvmm_new(const struct nvkm_oclass *, void *argv, u32 argc,
+int nvkm_uvmm_new(struct nvkm_mmu *mmu, u8 type, u64 addr, u64 size,
+		  void *, u32, const struct nvif_vmm_impl **, struct nvif_vmm_priv **,
 		  struct nvkm_object **);
 #endif
Signature · 1 line
2.41.0
author
#87 lore raw

PATCH 86/156 drm/nouveau/nvif: remove mmu from object rb

In reply to Ben Skeggs

- no more users

---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h | 2 +-
 drivers/gpu/drm/nouveau/nvif/mmu.c              | 3 +--
 drivers/gpu/drm/nouveau/nvkm/device/user.c      | 6 +++---
 3 files changed, 5 insertions(+), 6 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +1 -1
index 4d256a3c3fcf..8f1410ab8256 100644
@@ -201,7 +201,7 @@ struct nvif_device_impl {
 	struct {
 		s32 oclass;
 		int (*new)(struct nvif_device_priv *, const struct nvif_mmu_impl **,
-			   struct nvif_mmu_priv **, u64 handle);
+			   struct nvif_mmu_priv **);
 	} mmu;
 
 	struct {
drivers/gpu/drm/nouveau/nvif/mmu.c +1 -2
index cf1d27f2678d..b5adf35d9535 100644
@@ -43,8 +43,7 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu
 
 	mmu->impl = NULL;
 
-	ret = device->impl->mmu.new(device->priv, &mmu->impl, &mmu->priv,
-				    nvif_handle(&mmu->object));
+	ret = device->impl->mmu.new(device->priv, &mmu->impl, &mmu->priv);
 	NVIF_ERRON(ret, &device->object, "[NEW mmu%08x]", oclass);
 	if (ret)
 		return ret;
drivers/gpu/drm/nouveau/nvkm/device/user.c +3 -3
index e9486d9da64b..e63462188f2a 100644
@@ -79,8 +79,7 @@ nvkm_udevice_time(struct nvif_device_priv *udev)
 
 static int
 nvkm_udevice_mmu_new(struct nvif_device_priv *udev,
-		     const struct nvif_mmu_impl **pimpl, struct nvif_mmu_priv **ppriv,
-		     u64 handle)
+		     const struct nvif_mmu_impl **pimpl, struct nvif_mmu_priv **ppriv)
 {
 	struct nvkm_device *device = udev->device;
 	struct nvkm_object *object;
@@ -90,7 +89,8 @@ nvkm_udevice_mmu_new(struct nvif_device_priv *udev,
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+	nvkm_object_link(&udev->object, object);
+	return 0;
 }
 
 static void
Signature · 1 line
2.41.0
author
#88 lore raw

PATCH 87/156 drm/nouveau/nvif: rework vmm "page" api

In reply to Ben Skeggs

- transition from "ioctl" interfaces

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  8 ++++
 drivers/gpu/drm/nouveau/include/nvif/if000c.h | 12 ------
 drivers/gpu/drm/nouveau/include/nvif/vmm.h    |  8 ----
 drivers/gpu/drm/nouveau/nouveau_bo.c          | 20 +++++-----
 drivers/gpu/drm/nouveau/nvif/vmm.c            | 32 +--------------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 40 +++++--------------
 6 files changed, 29 insertions(+), 91 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +8 -0
index 8f1410ab8256..7540fe4d02c0 100644
@@ -101,6 +101,14 @@ struct nvif_vmm_impl {
 	u64 start;
 	u64 limit;
 	u8 page_nr;
+
+	struct {
+		u8 shift;
+		bool sparse;
+		bool vram;
+		bool host;
+		bool comp;
+	} page[8];
 };
 
 struct nvif_mmu_impl {
drivers/gpu/drm/nouveau/include/nvif/if000c.h +0 -12
index c505c5de0088..f554062469c3 100644
@@ -1,7 +1,6 @@
 #ifndef __NVIF_IF000C_H__
 #define __NVIF_IF000C_H__
 
-#define NVIF_VMM_V0_PAGE                                                   0x00
 #define NVIF_VMM_V0_GET                                                    0x01
 #define NVIF_VMM_V0_PUT                                                    0x02
 #define NVIF_VMM_V0_MAP                                                    0x03
@@ -11,17 +10,6 @@
 #define NVIF_VMM_V0_RAW                                                    0x07
 #define NVIF_VMM_V0_MTHD(i)                                         ((i) + 0x80)
 
-struct nvif_vmm_page_v0 {
-	__u8  version;
-	__u8  index;
-	__u8  shift;
-	__u8  sparse;
-	__u8  vram;
-	__u8  host;
-	__u8  comp;
-	__u8  pad07[1];
-};
-
 struct nvif_vmm_get_v0 {
 	__u8  version;
 #define NVIF_VMM_GET_V0_ADDR                                               0x00
drivers/gpu/drm/nouveau/include/nvif/vmm.h +0 -8
index c4b5d53d9bfd..3019ddc98782 100644
@@ -20,14 +20,6 @@ struct nvif_vmm {
 	const struct nvif_vmm_impl *impl;
 	struct nvif_vmm_priv *priv;
 	struct nvif_object object;
-
-	struct {
-		u8 shift;
-		bool sparse:1;
-		bool vram:1;
-		bool host:1;
-		bool comp:1;
-	} *page;
 };
 
 int nvif_vmm_ctor(struct nvif_mmu *, const char *name,
drivers/gpu/drm/nouveau/nouveau_bo.c +10 -10
index 29e00f8fdd12..ed81872e2dba 100644
@@ -273,21 +273,21 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
 			 * Skip page sizes that can't support needed domains.
 			 */
 			if (cli->device.info.family > NV_DEVICE_INFO_V0_CURIE &&
-			    (domain & NOUVEAU_GEM_DOMAIN_VRAM) && !vmm->page[i].vram)
+			    (domain & NOUVEAU_GEM_DOMAIN_VRAM) && !vmm->impl->page[i].vram)
 				continue;
 			if ((domain & NOUVEAU_GEM_DOMAIN_GART) &&
-			    (!vmm->page[i].host || vmm->page[i].shift > PAGE_SHIFT))
+			    (!vmm->impl->page[i].host || vmm->impl->page[i].shift > PAGE_SHIFT))
 				continue;
 
 			/* Select this page size if it's the first that supports
 			 * the potential memory domains, or when it's compatible
 			 * with the requested compression settings.
 			 */
-			if (pi < 0 || !nvbo->comp || vmm->page[i].comp)
+			if (pi < 0 || !nvbo->comp || vmm->impl->page[i].comp)
 				pi = i;
 
 			/* Stop once the buffer is larger than the current page size. */
-			if (*size >= 1ULL << vmm->page[i].shift)
+			if (*size >= 1ULL << vmm->impl->page[i].shift)
 				break;
 		}
 
@@ -297,12 +297,12 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
 		}
 
 		/* Disable compression if suitable settings couldn't be found. */
-		if (nvbo->comp && !vmm->page[pi].comp) {
+		if (nvbo->comp && !vmm->impl->page[pi].comp) {
 			if (mmu->object.oclass >= NVIF_CLASS_MMU_GF100)
 				nvbo->kind = mmu->impl->kind[nvbo->kind];
 			nvbo->comp = 0;
 		}
-		nvbo->page = vmm->page[pi].shift;
+		nvbo->page = vmm->impl->page[pi].shift;
 	} else {
 		/* reject other tile flags when in VM mode. */
 		if (tile_mode)
@@ -319,24 +319,24 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
 			 *
 			 * Skip page sizes that can't support needed domains.
 			 */
-			if ((domain & NOUVEAU_GEM_DOMAIN_VRAM) && !vmm->page[i].vram)
+			if ((domain & NOUVEAU_GEM_DOMAIN_VRAM) && !vmm->impl->page[i].vram)
 				continue;
 			if ((domain & NOUVEAU_GEM_DOMAIN_GART) &&
-			    (!vmm->page[i].host || vmm->page[i].shift > PAGE_SHIFT))
+			    (!vmm->impl->page[i].host || vmm->impl->page[i].shift > PAGE_SHIFT))
 				continue;
 
 			/* pick the last one as it will be smallest. */
 			pi = i;
 
 			/* Stop once the buffer is larger than the current page size. */
-			if (*size >= 1ULL << vmm->page[i].shift)
+			if (*size >= 1ULL << vmm->impl->page[i].shift)
 				break;
 		}
 		if (WARN_ON(pi < 0)) {
 			kfree(nvbo);
 			return ERR_PTR(-EINVAL);
 		}
-		nvbo->page = vmm->page[pi].shift;
+		nvbo->page = vmm->impl->page[pi].shift;
 	}
 
 	nouveau_bo_fixup_align(nvbo, align, size);
drivers/gpu/drm/nouveau/nvif/vmm.c +1 -31
index 35564e9c93ab..73c63bfd1e38 100644
@@ -196,7 +196,6 @@ nvif_vmm_dtor(struct nvif_vmm *vmm)
 	if (!vmm->impl)
 		return;
 
-	kfree(vmm->page);
 	vmm->impl->del(vmm->priv);
 	vmm->impl = NULL;
 }
@@ -207,9 +206,7 @@ nvif_vmm_ctor(struct nvif_mmu *mmu, const char *name,
 	      struct nvif_vmm *vmm)
 {
 	const u32 oclass = mmu->impl->vmm.oclass;
-	int ret, i;
-
-	vmm->page = NULL;
+	int ret;
 
 	ret = mmu->impl->vmm.new(mmu->priv, type, addr, size, argv, argc, &vmm->impl, &vmm->priv,
 				 nvif_handle(&vmm->object));
@@ -218,32 +215,5 @@ nvif_vmm_ctor(struct nvif_mmu *mmu, const char *name,
 		return ret;
 
 	nvif_object_ctor(&mmu->object, name ?: "nvifVmm", 0, oclass, &vmm->object);
-
-	vmm->page = kmalloc_array(vmm->impl->page_nr, sizeof(*vmm->page),
-				  GFP_KERNEL);
-	if (!vmm->page) {
-		ret = -ENOMEM;
-		goto done;
-	}
-
-	for (i = 0; i < vmm->impl->page_nr; i++) {
-		struct nvif_vmm_page_v0 args = { .index = i };
-
-		ret = nvif_object_mthd(&vmm->object, NVIF_VMM_V0_PAGE,
-				       &args, sizeof(args));
-		if (ret)
-			break;
-
-		vmm->page[i].shift = args.shift;
-		vmm->page[i].sparse = args.sparse;
-		vmm->page[i].vram = args.vram;
-		vmm->page[i].host = args.host;
-		vmm->page[i].comp = args.comp;
-	}
-
-done:
-	if (ret)
-		nvif_vmm_dtor(vmm);
-
 	return ret;
 }
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c +10 -30
index 28d491a03c59..15aa6a37060b 100644
@@ -307,34 +307,6 @@ nvkm_uvmm_mthd_get(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
 	return ret;
 }
 
-static int
-nvkm_uvmm_mthd_page(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
-{
-	union {
-		struct nvif_vmm_page_v0 v0;
-	} *args = argv;
-	const struct nvkm_vmm_page *page;
-	int ret = -ENOSYS;
-	u8 type, index, nr;
-
-	page = uvmm->vmm->func->page;
-	for (nr = 0; page[nr].shift; nr++);
-
-	if (!(nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
-		if ((index = args->v0.index) >= nr)
-			return -EINVAL;
-		type = page[index].type;
-		args->v0.shift = page[index].shift;
-		args->v0.sparse = !!(type & NVKM_VMM_PAGE_SPARSE);
-		args->v0.vram = !!(type & NVKM_VMM_PAGE_VRAM);
-		args->v0.host = !!(type & NVKM_VMM_PAGE_HOST);
-		args->v0.comp = !!(type & NVKM_VMM_PAGE_COMP);
-	} else
-		return -ENOSYS;
-
-	return 0;
-}
-
 static inline int
 nvkm_uvmm_page_index(struct nvif_vmm_priv *uvmm, u64 size, u8 shift, u8 *refd)
 {
@@ -502,7 +474,6 @@ nvkm_uvmm_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 {
 	struct nvif_vmm_priv *uvmm = container_of(object, typeof(*uvmm), object);
 	switch (mthd) {
-	case NVIF_VMM_V0_PAGE  : return nvkm_uvmm_mthd_page  (uvmm, argv, argc);
 	case NVIF_VMM_V0_GET   : return nvkm_uvmm_mthd_get   (uvmm, argv, argc);
 	case NVIF_VMM_V0_PUT   : return nvkm_uvmm_mthd_put   (uvmm, argv, argc);
 	case NVIF_VMM_V0_MAP   : return nvkm_uvmm_mthd_map   (uvmm, argv, argc);
@@ -595,8 +566,17 @@ nvkm_uvmm_new(struct nvkm_mmu *mmu, u8 type, u64 addr, u64 size, void *argv, u32
 	uvmm->impl.limit = uvmm->vmm->limit;
 
 	page = uvmm->vmm->func->page;
-	while (page && (page++)->shift)
+	for (int i = 0; page->shift; i++, page++) {
+		if (WARN_ON(i >= ARRAY_SIZE(uvmm->impl.page)))
+			break;
+
+		uvmm->impl.page[i].shift  = page->shift;
+		uvmm->impl.page[i].sparse = !!(page->type & NVKM_VMM_PAGE_SPARSE);
+		uvmm->impl.page[i].vram   = !!(page->type & NVKM_VMM_PAGE_VRAM);
+		uvmm->impl.page[i].host   = !!(page->type & NVKM_VMM_PAGE_HOST);
+		uvmm->impl.page[i].comp   = !!(page->type & NVKM_VMM_PAGE_COMP);
 		uvmm->impl.page_nr++;
+	}
 
 	*pimpl = &uvmm->impl;
 	*ppriv = uvmm;
Signature · 1 line
2.41.0
author
#89 lore raw

PATCH 88/156 drm/nouveau/nvif: rework vmm "get"/"put" apis

In reply to Ben Skeggs

- transition from "ioctl" interfaces

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 10 ++++
 drivers/gpu/drm/nouveau/include/nvif/if000c.h | 22 ---------
 drivers/gpu/drm/nouveau/include/nvif/vmm.h    | 10 +---
 drivers/gpu/drm/nouveau/nouveau_bo.c          |  4 +-
 drivers/gpu/drm/nouveau/nouveau_ttm.c         |  2 +-
 drivers/gpu/drm/nouveau/nouveau_vmm.c         |  4 +-
 drivers/gpu/drm/nouveau/nvif/vmm.c            | 38 ++++-----------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 46 +++++--------------
 8 files changed, 39 insertions(+), 97 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +10 -0
index 7540fe4d02c0..673969d46b66 100644
@@ -95,6 +95,12 @@ enum nvif_vmm_type {
 	NVIF_VMM_TYPE_RAW,
 };
 
+enum nvif_vmm_get_type {
+	NVIF_VMM_GET_ADDR,
+	NVIF_VMM_GET_PTES,
+	NVIF_VMM_GET_LAZY,
+};
+
 struct nvif_vmm_impl {
 	void (*del)(struct nvif_vmm_priv *);
 
@@ -109,6 +115,10 @@ struct nvif_vmm_impl {
 		bool host;
 		bool comp;
 	} page[8];
+
+	int (*get)(struct nvif_vmm_priv *, enum nvif_vmm_get_type, bool sparse, u8 page,
+		   u8 align, u64 size, u64 *addr);
+	int (*put)(struct nvif_vmm_priv *, u64 addr);
 };
 
 struct nvif_mmu_impl {
drivers/gpu/drm/nouveau/include/nvif/if000c.h +0 -22
index f554062469c3..50a834d5eb19 100644
@@ -1,8 +1,6 @@
 #ifndef __NVIF_IF000C_H__
 #define __NVIF_IF000C_H__
 
-#define NVIF_VMM_V0_GET                                                    0x01
-#define NVIF_VMM_V0_PUT                                                    0x02
 #define NVIF_VMM_V0_MAP                                                    0x03
 #define NVIF_VMM_V0_UNMAP                                                  0x04
 #define NVIF_VMM_V0_PFNMAP                                                 0x05
@@ -10,26 +8,6 @@
 #define NVIF_VMM_V0_RAW                                                    0x07
 #define NVIF_VMM_V0_MTHD(i)                                         ((i) + 0x80)
 
-struct nvif_vmm_get_v0 {
-	__u8  version;
-#define NVIF_VMM_GET_V0_ADDR                                               0x00
-#define NVIF_VMM_GET_V0_PTES                                               0x01
-#define NVIF_VMM_GET_V0_LAZY	                                           0x02
-	__u8  type;
-	__u8  sparse;
-	__u8  page;
-	__u8  align;
-	__u8  pad05[3];
-	__u64 size;
-	__u64 addr;
-};
-
-struct nvif_vmm_put_v0 {
-	__u8  version;
-	__u8  pad01[7];
-	__u64 addr;
-};
-
 struct nvif_vmm_map_v0 {
 	__u8  version;
 	__u8  pad01[7];
drivers/gpu/drm/nouveau/include/nvif/vmm.h +2 -8
index 3019ddc98782..375d19345482 100644
@@ -1,16 +1,10 @@
 #ifndef __NVIF_VMM_H__
 #define __NVIF_VMM_H__
 #include <nvif/object.h>
-#include <nvif/driverif.h> /* NVIF_VMM_TYPE */
+#include <nvif/driverif.h> /* NVIF_VMM_TYPE_*, NVIF_VMM_GET_* */
 struct nvif_mem;
 struct nvif_mmu;
 
-enum nvif_vmm_get {
-	ADDR,
-	PTES,
-	LAZY
-};
-
 struct nvif_vma {
 	u64 addr;
 	u64 size;
@@ -26,7 +20,7 @@ int nvif_vmm_ctor(struct nvif_mmu *, const char *name,
 		  enum nvif_vmm_type, u64 addr, u64 size, void *argv, u32 argc,
 		  struct nvif_vmm *);
 void nvif_vmm_dtor(struct nvif_vmm *);
-int nvif_vmm_get(struct nvif_vmm *, enum nvif_vmm_get, bool sparse,
+int nvif_vmm_get(struct nvif_vmm *, enum nvif_vmm_get_type, bool sparse,
 		 u8 page, u8 align, u64 size, struct nvif_vma *);
 void nvif_vmm_put(struct nvif_vmm *, struct nvif_vma *);
 int nvif_vmm_map(struct nvif_vmm *, u64 addr, u64 size, void *argv, u32 argc,
drivers/gpu/drm/nouveau/nouveau_bo.c +2 -2
index ed81872e2dba..7db05d6699d8 100644
@@ -835,12 +835,12 @@ nouveau_bo_move_prep(struct nouveau_drm *drm, struct ttm_buffer_object *bo,
 	struct nvif_vmm *vmm = &drm->client.vmm.vmm;
 	int ret;
 
-	ret = nvif_vmm_get(vmm, LAZY, false, old_mem->mem.impl->page, 0,
+	ret = nvif_vmm_get(vmm, NVIF_VMM_GET_LAZY, false, old_mem->mem.impl->page, 0,
 			   old_mem->mem.impl->size, &old_mem->vma[0]);
 	if (ret)
 		return ret;
 
-	ret = nvif_vmm_get(vmm, LAZY, false, new_mem->mem.impl->page, 0,
+	ret = nvif_vmm_get(vmm, NVIF_VMM_GET_LAZY, false, new_mem->mem.impl->page, 0,
 			   new_mem->mem.impl->size, &old_mem->vma[1]);
 	if (ret)
 		goto done;
drivers/gpu/drm/nouveau/nouveau_ttm.c +1 -1
index 2d6f1c97db1c..fc1d6fd94480 100644
@@ -138,7 +138,7 @@ nv04_gart_manager_new(struct ttm_resource_manager *man,
 
 	mem = nouveau_mem(*res);
 	ttm_resource_init(bo, place, *res);
-	ret = nvif_vmm_get(&drm->cli.vmm.vmm, PTES, false, 12, 0,
+	ret = nvif_vmm_get(&drm->cli.vmm.vmm, NVIF_VMM_GET_PTES, false, 12, 0,
 			   (long)(*res)->size, &mem->vma[0]);
 	if (ret) {
 		nouveau_mem_del(man, *res);
drivers/gpu/drm/nouveau/nouveau_vmm.c +2 -2
index 353c1a3f9714..94dd0bf547dc 100644
@@ -98,7 +98,7 @@ nouveau_vma_new(struct nouveau_bo *nvbo, struct nouveau_vmm *vmm,
 
 	if (nvbo->bo.resource->mem_type != TTM_PL_SYSTEM &&
 	    mem->mem.impl->page == nvbo->page) {
-		ret = nvif_vmm_get(&vmm->vmm, LAZY, false, mem->mem.impl->page, 0,
+		ret = nvif_vmm_get(&vmm->vmm, NVIF_VMM_GET_LAZY, false, mem->mem.impl->page, 0,
 				   mem->mem.impl->size, &tmp);
 		if (ret)
 			goto done;
@@ -106,7 +106,7 @@ nouveau_vma_new(struct nouveau_bo *nvbo, struct nouveau_vmm *vmm,
 		vma->addr = tmp.addr;
 		ret = nouveau_vma_map(vma, mem);
 	} else {
-		ret = nvif_vmm_get(&vmm->vmm, PTES, false, mem->mem.impl->page, 0,
+		ret = nvif_vmm_get(&vmm->vmm, NVIF_VMM_GET_PTES, false, mem->mem.impl->page, 0,
 				   mem->mem.impl->size, &tmp);
 		if (ret)
 			goto done;
drivers/gpu/drm/nouveau/nvif/vmm.c +10 -28
index 73c63bfd1e38..cf00e7af6063 100644
@@ -66,44 +66,26 @@ nvif_vmm_map(struct nvif_vmm *vmm, u64 addr, u64 size, void *argv, u32 argc,
 void
 nvif_vmm_put(struct nvif_vmm *vmm, struct nvif_vma *vma)
 {
-	if (vma->size) {
-		WARN_ON(nvif_object_mthd(&vmm->object, NVIF_VMM_V0_PUT,
-					 &(struct nvif_vmm_put_v0) {
-						.addr = vma->addr,
-					 }, sizeof(struct nvif_vmm_put_v0)));
+	if (vmm && vma->size) {
+		WARN_ON(vmm->impl->put(vmm->priv, vma->addr));
 		vma->size = 0;
 	}
 }
 
 int
-nvif_vmm_get(struct nvif_vmm *vmm, enum nvif_vmm_get type, bool sparse,
+nvif_vmm_get(struct nvif_vmm *vmm, enum nvif_vmm_get_type type, bool sparse,
 	     u8 page, u8 align, u64 size, struct nvif_vma *vma)
 {
-	struct nvif_vmm_get_v0 args;
 	int ret;
 
-	args.version = vma->size = 0;
-	args.sparse = sparse;
-	args.page = page;
-	args.align = align;
-	args.size = size;
-
-	switch (type) {
-	case ADDR: args.type = NVIF_VMM_GET_V0_ADDR; break;
-	case PTES: args.type = NVIF_VMM_GET_V0_PTES; break;
-	case LAZY: args.type = NVIF_VMM_GET_V0_LAZY; break;
-	default:
-		WARN_ON(1);
-		return -EINVAL;
-	}
+	vma->size = 0;
 
-	ret = nvif_object_mthd(&vmm->object, NVIF_VMM_V0_GET,
-			       &args, sizeof(args));
-	if (ret == 0) {
-		vma->addr = args.addr;
-		vma->size = args.size;
-	}
-	return ret;
+	ret = vmm->impl->get(vmm->priv, type, sparse, page, align, size, &vma->addr);
+	if (ret)
+		return ret;
+
+	vma->size = size;
+	return 0;
 }
 
 int
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c +12 -34

84 lines not on this page · raw message

Signature · 1 line
2.41.0
author
#90 lore raw

PATCH 89/156 drm/nouveau/nvif: rework vmm "map"/"unmap" apis

In reply to Ben Skeggs

- transition from "ioctl" interfaces

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  4 ++
 drivers/gpu/drm/nouveau/include/nvif/if000c.h | 18 --------
 drivers/gpu/drm/nouveau/nvif/vmm.c            | 28 +------------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/umem.c    |  9 ++++
 .../gpu/drm/nouveau/nvkm/subdev/mmu/umem.h    |  1 +
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 41 ++++---------------
 6 files changed, 24 insertions(+), 77 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +4 -0
index 673969d46b66..94d0fb23ed2f 100644
@@ -119,6 +119,10 @@ struct nvif_vmm_impl {
 	int (*get)(struct nvif_vmm_priv *, enum nvif_vmm_get_type, bool sparse, u8 page,
 		   u8 align, u64 size, u64 *addr);
 	int (*put)(struct nvif_vmm_priv *, u64 addr);
+
+	int (*map)(struct nvif_vmm_priv *, u64 addr, u64 size, void *, u32,
+		   struct nvif_mem_priv *, u64 offset);
+	int (*unmap)(struct nvif_vmm_priv *, u64 addr);
 };
 
 struct nvif_mmu_impl {
drivers/gpu/drm/nouveau/include/nvif/if000c.h +0 -18
index 50a834d5eb19..9b979fa5c7ac 100644
@@ -1,29 +1,11 @@
 #ifndef __NVIF_IF000C_H__
 #define __NVIF_IF000C_H__
 
-#define NVIF_VMM_V0_MAP                                                    0x03
-#define NVIF_VMM_V0_UNMAP                                                  0x04
 #define NVIF_VMM_V0_PFNMAP                                                 0x05
 #define NVIF_VMM_V0_PFNCLR                                                 0x06
 #define NVIF_VMM_V0_RAW                                                    0x07
 #define NVIF_VMM_V0_MTHD(i)                                         ((i) + 0x80)
 
-struct nvif_vmm_map_v0 {
-	__u8  version;
-	__u8  pad01[7];
-	__u64 addr;
-	__u64 size;
-	__u64 memory;
-	__u64 offset;
-	__u8  data[];
-};
-
-struct nvif_vmm_unmap_v0 {
-	__u8  version;
-	__u8  pad01[7];
-	__u64 addr;
-};
-
 struct nvif_vmm_raw_v0 {
 	__u8 version;
 #define NVIF_VMM_RAW_V0_GET	0x0
drivers/gpu/drm/nouveau/nvif/vmm.c +2 -26
index cf00e7af6063..6821d8657e12 100644
@@ -29,38 +29,14 @@
 int
 nvif_vmm_unmap(struct nvif_vmm *vmm, u64 addr)
 {
-	return nvif_object_mthd(&vmm->object, NVIF_VMM_V0_UNMAP,
-				&(struct nvif_vmm_unmap_v0) { .addr = addr },
-				sizeof(struct nvif_vmm_unmap_v0));
+	return vmm->impl->unmap(vmm->priv, addr);
 }
 
 int
 nvif_vmm_map(struct nvif_vmm *vmm, u64 addr, u64 size, void *argv, u32 argc,
 	     struct nvif_mem *mem, u64 offset)
 {
-	struct nvif_vmm_map_v0 *args;
-	u8 stack[48];
-	int ret;
-
-	if (sizeof(*args) + argc > sizeof(stack)) {
-		if (!(args = kmalloc(sizeof(*args) + argc, GFP_KERNEL)))
-			return -ENOMEM;
-	} else {
-		args = (void *)stack;
-	}
-
-	args->version = 0;
-	args->addr = addr;
-	args->size = size;
-	args->memory = nvif_handle(&mem->object);
-	args->offset = offset;
-	memcpy(args->data, argv, argc);
-
-	ret = nvif_object_mthd(&vmm->object, NVIF_VMM_V0_MAP,
-			       args, sizeof(*args) + argc);
-	if (args != (void *)stack)
-		kfree(args);
-	return ret;
+	return vmm->impl->map(vmm->priv, addr, size, argv, argc, mem->priv, offset);
 }
 
 void
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c +9 -0
index 6756e3e207d9..0676615093bb 100644
@@ -48,6 +48,15 @@ struct nvif_mem_priv {
 	struct nvif_mem_impl impl;
 };
 
+struct nvkm_memory *
+nvkm_umem_ref(struct nvif_mem_priv *umem)
+{
+	if (umem)
+		return nvkm_memory_ref(umem->memory);
+
+	return NULL;
+}
+
 static const struct nvkm_object_func nvkm_umem;
 struct nvkm_memory *
 nvkm_umem_search(struct nvkm_mmu *mmu, struct nvkm_client *client, u64 handle)
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.h +1 -0
index df7017eb98f4..a548a578758f 100644
@@ -5,4 +5,5 @@
 
 int nvkm_umem_new(struct nvkm_mmu *, u8 type, u8 page, u64 size, void *, u32,
 		  const struct nvif_mem_impl **, struct nvif_mem_priv **, struct nvkm_object **);
+struct nvkm_memory *nvkm_umem_ref(struct nvif_mem_priv *);
 #endif
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c +8 -33

76 lines not on this page · raw message

Signature · 1 line
2.41.0
author
#91 lore raw

PATCH 90/156 drm/nouveau/nvif: rework vmm "pfnmap"/"pfnclr" apis

In reply to Ben Skeggs

- transition from "ioctl" interfaces

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 12 ++++
 drivers/gpu/drm/nouveau/include/nvif/if000c.h | 27 --------
 drivers/gpu/drm/nouveau/nouveau_dmem.c        |  8 +--
 drivers/gpu/drm/nouveau/nouveau_svm.c         | 64 ++++++++-----------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 37 ++---------
 5 files changed, 50 insertions(+), 98 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +12 -0
index 94d0fb23ed2f..afca57d53c8c 100644
@@ -123,6 +123,18 @@ struct nvif_vmm_impl {
 	int (*map)(struct nvif_vmm_priv *, u64 addr, u64 size, void *, u32,
 		   struct nvif_mem_priv *, u64 offset);
 	int (*unmap)(struct nvif_vmm_priv *, u64 addr);
+
+#define NVIF_VMM_PFNMAP_ADDR       0xfffffffffffff000ULL
+#define NVIF_VMM_PFNMAP_ADDR_SHIFT                    12
+#define NVIF_VMM_PFNMAP_APER       0x00000000000000f0ULL
+#define NVIF_VMM_PFNMAP_HOST       0x0000000000000000ULL
+#define NVIF_VMM_PFNMAP_VRAM       0x0000000000000010ULL
+#define NVIF_VMM_PFNMAP_A          0x0000000000000004ULL
+#define NVIF_VMM_PFNMAP_W          0x0000000000000002ULL
+#define NVIF_VMM_PFNMAP_V          0x0000000000000001ULL
+#define NVIF_VMM_PFNMAP_NONE       0x0000000000000000ULL
+	int (*pfnmap)(struct nvif_vmm_priv *, u8 page, u64 addr, u64 size, u64 *phys);
+	int (*pfnclr)(struct nvif_vmm_priv *, u64 addr, u64 size);
 };
 
 struct nvif_mmu_impl {
drivers/gpu/drm/nouveau/include/nvif/if000c.h +0 -27
index 9b979fa5c7ac..709837ffea4e 100644
@@ -1,8 +1,6 @@
 #ifndef __NVIF_IF000C_H__
 #define __NVIF_IF000C_H__
 
-#define NVIF_VMM_V0_PFNMAP                                                 0x05
-#define NVIF_VMM_V0_PFNCLR                                                 0x06
 #define NVIF_VMM_V0_RAW                                                    0x07
 #define NVIF_VMM_V0_MTHD(i)                                         ((i) + 0x80)
 
@@ -25,29 +23,4 @@ struct nvif_vmm_raw_v0 {
 	__u64 memory;
 	__u64 argv;
 };
-
-struct nvif_vmm_pfnmap_v0 {
-	__u8  version;
-	__u8  page;
-	__u8  pad02[6];
-	__u64 addr;
-	__u64 size;
-#define NVIF_VMM_PFNMAP_V0_ADDR                           0xfffffffffffff000ULL
-#define NVIF_VMM_PFNMAP_V0_ADDR_SHIFT                                        12
-#define NVIF_VMM_PFNMAP_V0_APER                           0x00000000000000f0ULL
-#define NVIF_VMM_PFNMAP_V0_HOST                           0x0000000000000000ULL
-#define NVIF_VMM_PFNMAP_V0_VRAM                           0x0000000000000010ULL
-#define NVIF_VMM_PFNMAP_V0_A				  0x0000000000000004ULL
-#define NVIF_VMM_PFNMAP_V0_W                              0x0000000000000002ULL
-#define NVIF_VMM_PFNMAP_V0_V                              0x0000000000000001ULL
-#define NVIF_VMM_PFNMAP_V0_NONE                           0x0000000000000000ULL
-	__u64 phys[];
-};
-
-struct nvif_vmm_pfnclr_v0 {
-	__u8  version;
-	__u8  pad01[7];
-	__u64 addr;
-	__u64 size;
-};
 #endif
drivers/gpu/drm/nouveau/nouveau_dmem.c +4 -4
index b2f20e33bf66..a2369841353d 100644
@@ -645,10 +645,10 @@ static unsigned long nouveau_dmem_migrate_copy_one(struct nouveau_drm *drm,
 	}
 
 	dpage->zone_device_data = svmm;
-	*pfn = NVIF_VMM_PFNMAP_V0_V | NVIF_VMM_PFNMAP_V0_VRAM |
-		((paddr >> PAGE_SHIFT) << NVIF_VMM_PFNMAP_V0_ADDR_SHIFT);
+	*pfn = NVIF_VMM_PFNMAP_V | NVIF_VMM_PFNMAP_VRAM |
+		((paddr >> PAGE_SHIFT) << NVIF_VMM_PFNMAP_ADDR_SHIFT);
 	if (src & MIGRATE_PFN_WRITE)
-		*pfn |= NVIF_VMM_PFNMAP_V0_W;
+		*pfn |= NVIF_VMM_PFNMAP_W;
 	return migrate_pfn(page_to_pfn(dpage));
 
 out_dma_unmap:
@@ -656,7 +656,7 @@ static unsigned long nouveau_dmem_migrate_copy_one(struct nouveau_drm *drm,
 out_free_page:
 	nouveau_dmem_page_free_locked(drm, dpage);
 out:
-	*pfn = NVIF_VMM_PFNMAP_V0_NONE;
+	*pfn = NVIF_VMM_PFNMAP_NONE;
 	return 0;
 }
 
drivers/gpu/drm/nouveau/nouveau_svm.c +28 -36

144 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c +6 -31
index dae965fe2977..b1bd1dd3d5dd 100644
@@ -52,20 +52,10 @@ nvkm_uvmm_search(struct nvkm_client *client, u64 handle)
 }
 
 static int
-nvkm_uvmm_mthd_pfnclr(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
+nvkm_uvmm_pfnclr(struct nvif_vmm_priv *uvmm, u64 addr, u64 size)
 {
-	union {
-		struct nvif_vmm_pfnclr_v0 v0;
-	} *args = argv;
 	struct nvkm_vmm *vmm = uvmm->vmm;
-	int ret = -ENOSYS;
-	u64 addr, size;
-
-	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
-		addr = args->v0.addr;
-		size = args->v0.size;
-	} else
-		return ret;
+	int ret;
 
 	if (nvkm_vmm_in_managed_range(vmm, addr, size) && vmm->managed.raw)
 		return -EINVAL;
@@ -80,25 +70,10 @@ nvkm_uvmm_mthd_pfnclr(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
 }
 
 static int
-nvkm_uvmm_mthd_pfnmap(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
+nvkm_uvmm_pfnmap(struct nvif_vmm_priv *uvmm, u8 page, u64 addr, u64 size, u64 *phys)
 {
-	union {
-		struct nvif_vmm_pfnmap_v0 v0;
-	} *args = argv;
 	struct nvkm_vmm *vmm = uvmm->vmm;
-	int ret = -ENOSYS;
-	u64 addr, size, *phys;
-	u8  page;
-
-	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, true))) {
-		page = args->v0.page;
-		addr = args->v0.addr;
-		size = args->v0.size;
-		phys = args->v0.phys;
-		if (argc != (size >> page) * sizeof(args->v0.phys[0]))
-			return -EINVAL;
-	} else
-		return ret;
+	int ret;
 
 	if (nvkm_vmm_in_managed_range(vmm, addr, size) && vmm->managed.raw)
 		return -EINVAL;
@@ -427,8 +402,6 @@ nvkm_uvmm_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 {
 	struct nvif_vmm_priv *uvmm = container_of(object, typeof(*uvmm), object);
 	switch (mthd) {
-	case NVIF_VMM_V0_PFNMAP: return nvkm_uvmm_mthd_pfnmap(uvmm, argv, argc);
-	case NVIF_VMM_V0_PFNCLR: return nvkm_uvmm_mthd_pfnclr(uvmm, argv, argc);
 	case NVIF_VMM_V0_RAW   : return nvkm_uvmm_mthd_raw   (uvmm, argv, argc);
 	case NVIF_VMM_V0_MTHD(0x00) ... NVIF_VMM_V0_MTHD(0x7f):
 		if (uvmm->vmm->func->mthd) {
@@ -458,6 +431,8 @@ nvkm_uvmm_impl = {
 	.put = nvkm_uvmm_put,
 	.map = nvkm_uvmm_map,
 	.unmap = nvkm_uvmm_unmap,
+	.pfnmap = nvkm_uvmm_pfnmap,
+	.pfnclr = nvkm_uvmm_pfnclr,
 };
 
 static void *
Signature · 1 line
2.41.0
author
#92 lore raw

PATCH 91/156 drm/nouveau/nvif: rework vmm "raw get"/"raw put" apis

In reply to Ben Skeggs

- transition from ioctl interfaces

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  5 +++++
 drivers/gpu/drm/nouveau/include/nvif/if000c.h |  2 --
 drivers/gpu/drm/nouveau/nvif/vmm.c            | 22 ++-----------------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 22 +++++++++----------
 4 files changed, 17 insertions(+), 34 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +5 -0
index afca57d53c8c..65958649f08c 100644
@@ -135,6 +135,11 @@ struct nvif_vmm_impl {
 #define NVIF_VMM_PFNMAP_NONE       0x0000000000000000ULL
 	int (*pfnmap)(struct nvif_vmm_priv *, u8 page, u64 addr, u64 size, u64 *phys);
 	int (*pfnclr)(struct nvif_vmm_priv *, u64 addr, u64 size);
+
+	struct {
+		int (*get)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size);
+		int (*put)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size);
+	} raw;
 };
 
 struct nvif_mmu_impl {
drivers/gpu/drm/nouveau/include/nvif/if000c.h +0 -2
index 709837ffea4e..c81fae28395a 100644
@@ -6,8 +6,6 @@
 
 struct nvif_vmm_raw_v0 {
 	__u8 version;
-#define NVIF_VMM_RAW_V0_GET	0x0
-#define NVIF_VMM_RAW_V0_PUT	0x1
 #define NVIF_VMM_RAW_V0_MAP	0x2
 #define NVIF_VMM_RAW_V0_UNMAP	0x3
 #define NVIF_VMM_RAW_V0_SPARSE	0x4
drivers/gpu/drm/nouveau/nvif/vmm.c +2 -20
index 6821d8657e12..d7ca6afaeb04 100644
@@ -68,31 +68,13 @@ int
 nvif_vmm_raw_get(struct nvif_vmm *vmm, u64 addr, u64 size,
 		 u8 shift)
 {
-	struct nvif_vmm_raw_v0 args = {
-		.version = 0,
-		.op = NVIF_VMM_RAW_V0_GET,
-		.addr = addr,
-		.size = size,
-		.shift = shift,
-	};
-
-	return nvif_object_mthd(&vmm->object, NVIF_VMM_V0_RAW,
-				&args, sizeof(args));
+	return vmm->impl->raw.get(vmm->priv, shift, addr, size);
 }
 
 int
 nvif_vmm_raw_put(struct nvif_vmm *vmm, u64 addr, u64 size, u8 shift)
 {
-	struct nvif_vmm_raw_v0 args = {
-		.version = 0,
-		.op = NVIF_VMM_RAW_V0_PUT,
-		.addr = addr,
-		.size = size,
-		.shift = shift,
-	};
-
-	return nvif_object_mthd(&vmm->object, NVIF_VMM_V0_RAW,
-				&args, sizeof(args));
+	return vmm->impl->raw.put(vmm->priv, shift, addr, size);
 }
 
 int
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c +10 -12
index b1bd1dd3d5dd..51c7e0fd7876 100644
@@ -260,37 +260,37 @@ nvkm_uvmm_page_index(struct nvif_vmm_priv *uvmm, u64 size, u8 shift, u8 *refd)
 }
 
 static int
-nvkm_uvmm_mthd_raw_get(struct nvkm_uvmm *uvmm, struct nvif_vmm_raw_v0 *args)
+nvkm_uvmm_raw_get(struct nvif_vmm_priv *uvmm, u8 shift, u64 addr, u64 size)
 {
 	struct nvkm_vmm *vmm = uvmm->vmm;
 	u8 refd;
 	int ret;
 
-	if (!nvkm_vmm_in_managed_range(vmm, args->addr, args->size))
+	if (!nvkm_vmm_in_managed_range(vmm, addr, size))
 		return -EINVAL;
 
-	ret = nvkm_uvmm_page_index(uvmm, args->size, args->shift, &refd);
+	ret = nvkm_uvmm_page_index(uvmm, size, shift, &refd);
 	if (ret)
 		return ret;
 
-	return nvkm_vmm_raw_get(vmm, args->addr, args->size, refd);
+	return nvkm_vmm_raw_get(vmm, addr, size, refd);
 }
 
 static int
-nvkm_uvmm_mthd_raw_put(struct nvkm_uvmm *uvmm, struct nvif_vmm_raw_v0 *args)
+nvkm_uvmm_raw_put(struct nvif_vmm_priv *uvmm, u8 shift, u64 addr, u64 size)
 {
 	struct nvkm_vmm *vmm = uvmm->vmm;
 	u8 refd;
 	int ret;
 
-	if (!nvkm_vmm_in_managed_range(vmm, args->addr, args->size))
+	if (!nvkm_vmm_in_managed_range(vmm, addr, size))
 		return -EINVAL;
 
-	ret = nvkm_uvmm_page_index(uvmm, args->size, args->shift, &refd);
+	ret = nvkm_uvmm_page_index(uvmm, size, shift, &refd);
 	if (ret)
 		return ret;
 
-	nvkm_vmm_raw_put(vmm, args->addr, args->size, refd);
+	nvkm_vmm_raw_put(vmm, addr, size, refd);
 
 	return 0;
 }
@@ -382,10 +382,6 @@ nvkm_uvmm_mthd_raw(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
 		return ret;
 
 	switch (args->v0.op) {
-	case NVIF_VMM_RAW_V0_GET:
-		return nvkm_uvmm_mthd_raw_get(uvmm, &args->v0);
-	case NVIF_VMM_RAW_V0_PUT:
-		return nvkm_uvmm_mthd_raw_put(uvmm, &args->v0);
 	case NVIF_VMM_RAW_V0_MAP:
 		return nvkm_uvmm_mthd_raw_map(uvmm, &args->v0);
 	case NVIF_VMM_RAW_V0_UNMAP:
@@ -433,6 +429,8 @@ nvkm_uvmm_impl = {
 	.unmap = nvkm_uvmm_unmap,
 	.pfnmap = nvkm_uvmm_pfnmap,
 	.pfnclr = nvkm_uvmm_pfnclr,
+	.raw.get = nvkm_uvmm_raw_get,
+	.raw.put = nvkm_uvmm_raw_put,
 };
 
 static void *
Signature · 1 line
2.41.0
author
#93 lore raw

PATCH 92/156 drm/nouveau/nvif: rework vmm "raw map"/"raw unmap" apis

In reply to Ben Skeggs

- transition from "ioctl" interfaces

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  3 ++
 drivers/gpu/drm/nouveau/include/nvif/if000c.h |  2 -
 drivers/gpu/drm/nouveau/nvif/vmm.c            | 28 +------------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 39 +++++++------------
 4 files changed, 19 insertions(+), 53 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +3 -0
index 65958649f08c..1cea0a07b2e8 100644
@@ -139,6 +139,9 @@ struct nvif_vmm_impl {
 	struct {
 		int (*get)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size);
 		int (*put)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size);
+		int (*map)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size, void *, u32,
+			   struct nvif_mem_priv *, u64 offset);
+		int (*unmap)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size, bool sparse);
 	} raw;
 };
 
drivers/gpu/drm/nouveau/include/nvif/if000c.h +0 -2
index c81fae28395a..232cc1142798 100644
@@ -6,8 +6,6 @@
 
 struct nvif_vmm_raw_v0 {
 	__u8 version;
-#define NVIF_VMM_RAW_V0_MAP	0x2
-#define NVIF_VMM_RAW_V0_UNMAP	0x3
 #define NVIF_VMM_RAW_V0_SPARSE	0x4
 	__u8  op;
 	__u8  sparse;
drivers/gpu/drm/nouveau/nvif/vmm.c +2 -26
index d7ca6afaeb04..16c6aaa81326 100644
@@ -81,38 +81,14 @@ int
 nvif_vmm_raw_map(struct nvif_vmm *vmm, u64 addr, u64 size, u8 shift,
 		 void *argv, u32 argc, struct nvif_mem *mem, u64 offset)
 {
-	struct nvif_vmm_raw_v0 args = {
-		.version = 0,
-		.op = NVIF_VMM_RAW_V0_MAP,
-		.addr = addr,
-		.size = size,
-		.shift = shift,
-		.memory = nvif_handle(&mem->object),
-		.offset = offset,
-		.argv = (u64)(uintptr_t)argv,
-		.argc = argc,
-	};
-
-
-	return nvif_object_mthd(&vmm->object, NVIF_VMM_V0_RAW,
-				&args, sizeof(args));
+	return vmm->impl->raw.map(vmm->priv, shift, addr, size, argv, argc, mem->priv, offset);
 }
 
 int
 nvif_vmm_raw_unmap(struct nvif_vmm *vmm, u64 addr, u64 size,
 		   u8 shift, bool sparse)
 {
-	struct nvif_vmm_raw_v0 args = {
-		.version = 0,
-		.op = NVIF_VMM_RAW_V0_UNMAP,
-		.addr = addr,
-		.size = size,
-		.shift = shift,
-		.sparse = sparse,
-	};
-
-	return nvif_object_mthd(&vmm->object, NVIF_VMM_V0_RAW,
-				&args, sizeof(args));
+	return vmm->impl->raw.unmap(vmm->priv, shift, addr, size, sparse);
 }
 
 int
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c +14 -25
index 51c7e0fd7876..7c8a7a5dc3f9 100644
@@ -296,40 +296,33 @@ nvkm_uvmm_raw_put(struct nvif_vmm_priv *uvmm, u8 shift, u64 addr, u64 size)
 }
 
 static int
-nvkm_uvmm_mthd_raw_map(struct nvkm_uvmm *uvmm, struct nvif_vmm_raw_v0 *args)
+nvkm_uvmm_raw_map(struct nvif_vmm_priv *uvmm, u8 shift, u64 addr, u64 size, void *argv, u32 argc,
+		  struct nvif_mem_priv *umem, u64 offset)
 {
-	struct nvkm_client *client = uvmm->object.client;
 	struct nvkm_vmm *vmm = uvmm->vmm;
 	struct nvkm_vma vma = {
-		.addr = args->addr,
-		.size = args->size,
+		.addr = addr,
+		.size = size,
 		.used = true,
 		.mapref = false,
 		.no_comp = true,
 	};
 	struct nvkm_memory *memory;
-	void *argv = (void *)(uintptr_t)args->argv;
-	unsigned int argc = args->argc;
-	u64 handle = args->memory;
 	u8 refd;
 	int ret;
 
-	if (!nvkm_vmm_in_managed_range(vmm, args->addr, args->size))
+	if (!nvkm_vmm_in_managed_range(vmm, addr, size))
 		return -EINVAL;
 
-	ret = nvkm_uvmm_page_index(uvmm, args->size, args->shift, &refd);
+	ret = nvkm_uvmm_page_index(uvmm, size, shift, &refd);
 	if (ret)
 		return ret;
 
 	vma.page = vma.refd = refd;
 
-	memory = nvkm_umem_search(uvmm->vmm->mmu, client, args->memory);
-	if (IS_ERR(memory)) {
-		VMM_DEBUG(vmm, "memory %016llx %ld\n", handle, PTR_ERR(memory));
-		return PTR_ERR(memory);
-	}
+	memory = nvkm_umem_ref(umem);
 
-	ret = nvkm_memory_map(memory, args->offset, vmm, &vma, argv, argc);
+	ret = nvkm_memory_map(memory, offset, vmm, &vma, argv, argc);
 
 	nvkm_memory_unref(&vma.memory);
 	nvkm_memory_unref(&memory);
@@ -337,22 +330,20 @@ nvkm_uvmm_mthd_raw_map(struct nvkm_uvmm *uvmm, struct nvif_vmm_raw_v0 *args)
 }
 
 static int
-nvkm_uvmm_mthd_raw_unmap(struct nvkm_uvmm *uvmm, struct nvif_vmm_raw_v0 *args)
+nvkm_uvmm_raw_unmap(struct nvif_vmm_priv *uvmm, u8 shift, u64 addr, u64 size, bool sparse)
 {
 	struct nvkm_vmm *vmm = uvmm->vmm;
 	u8 refd;
 	int ret;
 
-	if (!nvkm_vmm_in_managed_range(vmm, args->addr, args->size))
+	if (!nvkm_vmm_in_managed_range(vmm, addr, size))
 		return -EINVAL;
 
-	ret = nvkm_uvmm_page_index(uvmm, args->size, args->shift, &refd);
+	ret = nvkm_uvmm_page_index(uvmm, size, shift, &refd);
 	if (ret)
 		return ret;
 
-	nvkm_vmm_raw_unmap(vmm, args->addr, args->size,
-			   args->sparse, refd);
-
+	nvkm_vmm_raw_unmap(vmm, addr, size, sparse, refd);
 	return 0;
 }
 
@@ -382,10 +373,6 @@ nvkm_uvmm_mthd_raw(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
 		return ret;
 
 	switch (args->v0.op) {
-	case NVIF_VMM_RAW_V0_MAP:
-		return nvkm_uvmm_mthd_raw_map(uvmm, &args->v0);
-	case NVIF_VMM_RAW_V0_UNMAP:
-		return nvkm_uvmm_mthd_raw_unmap(uvmm, &args->v0);
 	case NVIF_VMM_RAW_V0_SPARSE:
 		return nvkm_uvmm_mthd_raw_sparse(uvmm, &args->v0);
 	default:
@@ -431,6 +418,8 @@ nvkm_uvmm_impl = {
 	.pfnclr = nvkm_uvmm_pfnclr,
 	.raw.get = nvkm_uvmm_raw_get,
 	.raw.put = nvkm_uvmm_raw_put,
+	.raw.map = nvkm_uvmm_raw_map,
+	.raw.unmap = nvkm_uvmm_raw_unmap,
 };
 
 static void *
Signature · 1 line
2.41.0
author
#94 lore raw

PATCH 93/156 drm/nouveau/nvif: rework vmm "raw sparse" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  1 +
 drivers/gpu/drm/nouveau/include/nvif/if000c.h | 16 ----------
 drivers/gpu/drm/nouveau/nvif/vmm.c            | 11 +------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 32 +++----------------
 4 files changed, 6 insertions(+), 54 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +1 -0
index 1cea0a07b2e8..da5760df9e20 100644
@@ -142,6 +142,7 @@ struct nvif_vmm_impl {
 		int (*map)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size, void *, u32,
 			   struct nvif_mem_priv *, u64 offset);
 		int (*unmap)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size, bool sparse);
+		int (*sparse)(struct nvif_vmm_priv *, u64 addr, u64 size, bool ref);
 	} raw;
 };
 
drivers/gpu/drm/nouveau/include/nvif/if000c.h +0 -16
index 232cc1142798..61a12396e996 100644
@@ -1,22 +1,6 @@
 #ifndef __NVIF_IF000C_H__
 #define __NVIF_IF000C_H__
 
-#define NVIF_VMM_V0_RAW                                                    0x07
 #define NVIF_VMM_V0_MTHD(i)                                         ((i) + 0x80)
 
-struct nvif_vmm_raw_v0 {
-	__u8 version;
-#define NVIF_VMM_RAW_V0_SPARSE	0x4
-	__u8  op;
-	__u8  sparse;
-	__u8  ref;
-	__u8  shift;
-	__u32 argc;
-	__u8  pad01[7];
-	__u64 addr;
-	__u64 size;
-	__u64 offset;
-	__u64 memory;
-	__u64 argv;
-};
 #endif
drivers/gpu/drm/nouveau/nvif/vmm.c +1 -10
index 16c6aaa81326..c3005f16a32e 100644
@@ -94,16 +94,7 @@ nvif_vmm_raw_unmap(struct nvif_vmm *vmm, u64 addr, u64 size,
 int
 nvif_vmm_raw_sparse(struct nvif_vmm *vmm, u64 addr, u64 size, bool ref)
 {
-	struct nvif_vmm_raw_v0 args = {
-		.version = 0,
-		.op = NVIF_VMM_RAW_V0_SPARSE,
-		.addr = addr,
-		.size = size,
-		.ref = ref,
-	};
-
-	return nvif_object_mthd(&vmm->object, NVIF_VMM_V0_RAW,
-				&args, sizeof(args));
+	return vmm->impl->raw.sparse(vmm->priv, addr, size, ref);
 }
 
 void
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c +4 -28
index 7c8a7a5dc3f9..079ebaa64668 100644
@@ -29,8 +29,6 @@
 #include <nvif/if000c.h>
 #include <nvif/unpack.h>
 
-#define nvkm_uvmm nvif_vmm_priv
-
 struct nvif_vmm_priv {
 	struct nvkm_object object;
 	struct nvkm_vmm *vmm;
@@ -348,36 +346,14 @@ nvkm_uvmm_raw_unmap(struct nvif_vmm_priv *uvmm, u8 shift, u64 addr, u64 size, bo
 }
 
 static int
-nvkm_uvmm_mthd_raw_sparse(struct nvkm_uvmm *uvmm, struct nvif_vmm_raw_v0 *args)
+nvkm_uvmm_raw_sparse(struct nvif_vmm_priv *uvmm, u64 addr, u64 size, bool ref)
 {
 	struct nvkm_vmm *vmm = uvmm->vmm;
 
-	if (!nvkm_vmm_in_managed_range(vmm, args->addr, args->size))
-		return -EINVAL;
-
-	return nvkm_vmm_raw_sparse(vmm, args->addr, args->size, args->ref);
-}
-
-static int
-nvkm_uvmm_mthd_raw(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
-{
-	union {
-		struct nvif_vmm_raw_v0 v0;
-	} *args = argv;
-	int ret = -ENOSYS;
-
-	if (!uvmm->vmm->managed.raw)
+	if (!nvkm_vmm_in_managed_range(vmm, addr, size))
 		return -EINVAL;
 
-	if ((ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, true)))
-		return ret;
-
-	switch (args->v0.op) {
-	case NVIF_VMM_RAW_V0_SPARSE:
-		return nvkm_uvmm_mthd_raw_sparse(uvmm, &args->v0);
-	default:
-		return -EINVAL;
-	};
+	return nvkm_vmm_raw_sparse(vmm, addr, size, ref);
 }
 
 static int
@@ -385,7 +361,6 @@ nvkm_uvmm_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
 {
 	struct nvif_vmm_priv *uvmm = container_of(object, typeof(*uvmm), object);
 	switch (mthd) {
-	case NVIF_VMM_V0_RAW   : return nvkm_uvmm_mthd_raw   (uvmm, argv, argc);
 	case NVIF_VMM_V0_MTHD(0x00) ... NVIF_VMM_V0_MTHD(0x7f):
 		if (uvmm->vmm->func->mthd) {
 			return uvmm->vmm->func->mthd(uvmm->vmm,
@@ -420,6 +395,7 @@ nvkm_uvmm_impl = {
 	.raw.put = nvkm_uvmm_raw_put,
 	.raw.map = nvkm_uvmm_raw_map,
 	.raw.unmap = nvkm_uvmm_raw_unmap,
+	.raw.sparse = nvkm_uvmm_raw_sparse,
 };
 
 static void *
Signature · 1 line
2.41.0
author
#95 lore raw

PATCH 94/156 drm/nouveau/nvif: rework vmm "fault replay"/"fault cancel" apis

In reply to Ben Skeggs

- transition from "ioctl" interfaces

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  5 ++
 drivers/gpu/drm/nouveau/include/nvif/if000c.h |  6 --
 drivers/gpu/drm/nouveau/include/nvif/if000d.h |  1 -
 drivers/gpu/drm/nouveau/include/nvif/if500d.h |  1 -
 drivers/gpu/drm/nouveau/include/nvif/if900d.h |  1 -
 drivers/gpu/drm/nouveau/include/nvif/ifb00d.h |  1 -
 drivers/gpu/drm/nouveau/include/nvif/ifc00d.h |  1 -
 drivers/gpu/drm/nouveau/nouveau_dmem.c        |  1 -
 drivers/gpu/drm/nouveau/nouveau_svm.c         | 18 ++---
 drivers/gpu/drm/nouveau/nouveau_uvmm.c        |  1 -
 drivers/gpu/drm/nouveau/nvif/vmm.c            |  2 -
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 43 ++++++------
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.h |  8 ++-
 .../drm/nouveau/nvkm/subdev/mmu/vmmgp100.c    | 68 ++++++-------------
 .../drm/nouveau/nvkm/subdev/mmu/vmmgp10b.c    |  2 +-
 .../drm/nouveau/nvkm/subdev/mmu/vmmgv100.c    |  2 +-
 .../drm/nouveau/nvkm/subdev/mmu/vmmtu102.c    |  2 +-
 17 files changed, 60 insertions(+), 103 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if000c.h
drivers/gpu/drm/nouveau/include/nvif/driverif.h +5 -0
index da5760df9e20..425c3184ff14 100644
@@ -144,6 +144,11 @@ struct nvif_vmm_impl {
 		int (*unmap)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size, bool sparse);
 		int (*sparse)(struct nvif_vmm_priv *, u64 addr, u64 size, bool ref);
 	} raw;
+
+	struct {
+		void (*replay)(struct nvif_vmm_priv *);
+		void (*cancel)(struct nvif_vmm_priv *, u64 inst, u8 hub, u8 gpc, u8 client);
+	} fault;
 };
 
 struct nvif_mmu_impl {
drivers/gpu/drm/nouveau/include/nvif/if000c.h deleted +0 -6
deleted file mode 100644
index 61a12396e996..000000000000
@@ -1,6 +0,0 @@
-#ifndef __NVIF_IF000C_H__
-#define __NVIF_IF000C_H__
-
-#define NVIF_VMM_V0_MTHD(i)                                         ((i) + 0x80)
-
-#endif
drivers/gpu/drm/nouveau/include/nvif/if000d.h +0 -1
index 516ec9401401..dff2d0f838e7 100644
@@ -1,6 +1,5 @@
 #ifndef __NVIF_IF000D_H__
 #define __NVIF_IF000D_H__
-#include "if000c.h"
 
 struct nv04_vmm_vn {
 	/* nvif_vmm_vX ... */
drivers/gpu/drm/nouveau/include/nvif/if500d.h +0 -1
index c29a7822b363..c76433af0489 100644
@@ -1,6 +1,5 @@
 #ifndef __NVIF_IF500D_H__
 #define __NVIF_IF500D_H__
-#include "if000c.h"
 
 struct nv50_vmm_vn {
 	/* nvif_vmm_vX ... */
drivers/gpu/drm/nouveau/include/nvif/if900d.h +0 -1
index 49aa50583c3d..5a9d798b5619 100644
@@ -1,6 +1,5 @@
 #ifndef __NVIF_IF900D_H__
 #define __NVIF_IF900D_H__
-#include "if000c.h"
 
 struct gf100_vmm_vn {
 	/* nvif_vmm_vX ... */
drivers/gpu/drm/nouveau/include/nvif/ifb00d.h +0 -1
index a0e419830595..a0aedf37e91d 100644
@@ -1,6 +1,5 @@
 #ifndef __NVIF_IFB00D_H__
 #define __NVIF_IFB00D_H__
-#include "if000c.h"
 
 struct gm200_vmm_vn {
 	/* nvif_vmm_vX ... */
drivers/gpu/drm/nouveau/include/nvif/ifc00d.h +0 -1
index 4cabd613a280..700d4ab4369f 100644
@@ -1,6 +1,5 @@
 #ifndef __NVIF_IFC00D_H__
 #define __NVIF_IFC00D_H__
-#include "if000c.h"
 
 struct gp100_vmm_vn {
 	/* nvif_vmm_vX ... */
drivers/gpu/drm/nouveau/nouveau_dmem.c +0 -1
index a2369841353d..fed91756846f 100644
@@ -30,7 +30,6 @@
 #include <nvif/class.h>
 #include <nvif/object.h>
 #include <nvif/push906f.h>
-#include <nvif/if000c.h>
 #include <nvif/if500b.h>
 #include <nvif/if900b.h>
 
drivers/gpu/drm/nouveau/nouveau_svm.c +6 -12
index ab02bcc034fb..07fa00afe5b8 100644
@@ -379,11 +379,10 @@ nouveau_svmm_init(struct drm_device *dev, void *data,
 static void
 nouveau_svm_fault_replay(struct nouveau_svm *svm)
 {
+	struct nvif_vmm *vmm = &svm->drm->cli.vmm.vmm;
+
 	SVM_DBG(svm, "replay");
-	WARN_ON(nvif_object_mthd(&svm->drm->client.vmm.vmm.object,
-				 GP100_VMM_VN_FAULT_REPLAY,
-				 &(struct gp100_vmm_fault_replay_vn) {},
-				 sizeof(struct gp100_vmm_fault_replay_vn)));
+	vmm->impl->fault.replay(vmm->priv);
 }
 
 /* Cancel a replayable fault that could not be handled.
@@ -395,15 +394,10 @@ static void
 nouveau_svm_fault_cancel(struct nouveau_svm *svm,
 			 u64 inst, u8 hub, u8 gpc, u8 client)
 {
+	struct nvif_vmm *vmm = &svm->drm->cli.vmm.vmm;
+
 	SVM_DBG(svm, "cancel %016llx %d %02x %02x", inst, hub, gpc, client);
-	WARN_ON(nvif_object_mthd(&svm->drm->client.vmm.vmm.object,
-				 GP100_VMM_VN_FAULT_CANCEL,
-				 &(struct gp100_vmm_fault_cancel_v0) {
-					.hub = hub,
-					.gpc = gpc,
-					.client = client,
-					.inst = inst,
-				 }, sizeof(struct gp100_vmm_fault_cancel_v0)));
+	vmm->impl->fault.cancel(vmm->priv, inst, hub, gpc, client);
 }
 
 static void
drivers/gpu/drm/nouveau/nouveau_uvmm.c +0 -1
index 1340138bbc13..9589fdd09e22 100644
@@ -29,7 +29,6 @@
 #include <nvif/mem.h>
 
 #include <nvif/class.h>
-#include <nvif/if000c.h>
 #include <nvif/if900d.h>
 
 #define NOUVEAU_VA_SPACE_BITS		47 /* FIXME */
drivers/gpu/drm/nouveau/nvif/vmm.c +0 -2
index c3005f16a32e..fe342828ce8c 100644
@@ -24,8 +24,6 @@
 #include <nvif/mem.h>
 #include <nvif/printf.h>
 
-#include <nvif/if000c.h>
-
 int
 nvif_vmm_unmap(struct nvif_vmm *vmm, u64 addr)
 {
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c +21 -22

73 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.h +5 -3
index f9bc30cdb2b3..a48ba1c95847 100644
@@ -145,8 +145,10 @@ struct nvkm_vmm_func {
 		     struct nvkm_vmm_map *);
 	void (*flush)(struct nvkm_vmm *, int depth);
 
-	int (*mthd)(struct nvkm_vmm *, struct nvkm_client *,
-		    u32 mthd, void *argv, u32 argc);
+	const struct nvkm_vmm_func_fault {
+		void (*replay)(struct nvkm_vmm *);
+		void (*cancel)(struct nvkm_vmm *, u64 inst, u8 hub, u8 gpc, u8 client);
+	} *fault;
 
 	void (*invalidate_pdb)(struct nvkm_vmm *, u64 addr);
 
@@ -249,7 +251,7 @@ int gp100_vmm_new_(const struct nvkm_vmm_func *,
 int gp100_vmm_join(struct nvkm_vmm *, struct nvkm_memory *);
 int gp100_vmm_valid(struct nvkm_vmm *, void *, u32, struct nvkm_vmm_map *);
 void gp100_vmm_flush(struct nvkm_vmm *, int);
-int gp100_vmm_mthd(struct nvkm_vmm *, struct nvkm_client *, u32, void *, u32);
+extern const struct nvkm_vmm_func_fault gp100_vmm_fault;
 void gp100_vmm_invalidate_pdb(struct nvkm_vmm *, u64 addr);
 
 int gv100_vmm_join(struct nvkm_vmm *, struct nvkm_memory *);
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c +20 -48

97 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp10b.c +1 -1
index e081239afe58..d03f3761cb3f 100644
@@ -28,7 +28,7 @@ gp10b_vmm = {
 	.aper = gk20a_vmm_aper,
 	.valid = gp100_vmm_valid,
 	.flush = gp100_vmm_flush,
-	.mthd = gp100_vmm_mthd,
+	.fault = &gp100_vmm_fault,
 	.invalidate_pdb = gp100_vmm_invalidate_pdb,
 	.page = {
 		{ 47, &gp100_vmm_desc_16[4], NVKM_VMM_PAGE_Sxxx },
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgv100.c +1 -1
index f0e21f63253a..a68b7dbe8613 100644
@@ -66,7 +66,7 @@ gv100_vmm = {
 	.aper = gf100_vmm_aper,
 	.valid = gp100_vmm_valid,
 	.flush = gp100_vmm_flush,
-	.mthd = gp100_vmm_mthd,
+	.fault = &gp100_vmm_fault,
 	.invalidate_pdb = gp100_vmm_invalidate_pdb,
 	.page = {
 		{ 47, &gp100_vmm_desc_16[4], NVKM_VMM_PAGE_Sxxx },
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c +1 -1
index 8379e72d77ab..21cd1fe999da 100644
@@ -57,7 +57,7 @@ tu102_vmm = {
 	.aper = gf100_vmm_aper,
 	.valid = gp100_vmm_valid,
 	.flush = tu102_vmm_flush,
-	.mthd = gp100_vmm_mthd,
+	.fault = &gp100_vmm_fault,
 	.page = {
 		{ 47, &gp100_vmm_desc_16[4], NVKM_VMM_PAGE_Sxxx },
 		{ 38, &gp100_vmm_desc_16[3], NVKM_VMM_PAGE_Sxxx },
Signature · 1 line
2.41.0
author
#96 lore raw

PATCH 95/156 drm/nouveau/nvif: rework device "new fault buffer" api

In reply to Ben Skeggs

- transition from "ioctl" interfaces

---
 drivers/gpu/drm/nouveau/include/nvif/clb069.h |  7 ---
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 12 +++++
 drivers/gpu/drm/nouveau/nouveau_svm.c         | 27 ++++++----
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 28 +++++++----
 .../gpu/drm/nouveau/nvkm/subdev/fault/base.c  |  1 -
 .../gpu/drm/nouveau/nvkm/subdev/fault/priv.h  |  3 --
 .../gpu/drm/nouveau/nvkm/subdev/fault/user.c  | 49 +++++++++++++------
 .../gpu/drm/nouveau/nvkm/subdev/fault/user.h  |  9 ++++
 8 files changed, 91 insertions(+), 45 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.h
drivers/gpu/drm/nouveau/include/nvif/clb069.h +0 -7
index d7689de35ab2..67bf579ced18 100644
@@ -1,12 +1,5 @@
 #ifndef __NVIF_CLB069_H__
 #define __NVIF_CLB069_H__
-struct nvif_clb069_v0 {
-	__u8  version;
-	__u8  pad01[3];
-	__u32 entries;
-	__u32 get;
-	__u32 put;
-};
 
 union nvif_clb069_event_args {
 	struct nvif_clb069_event_vn {
drivers/gpu/drm/nouveau/include/nvif/driverif.h +12 -0
index 425c3184ff14..a1aab5735146 100644
@@ -8,6 +8,7 @@ struct nvif_usermode_priv;
 struct nvif_mmu_priv;
 struct nvif_mem_priv;
 struct nvif_vmm_priv;
+struct nvif_faultbuf_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -194,6 +195,14 @@ struct nvif_mmu_impl {
 	} vmm;
 };
 
+struct nvif_faultbuf_impl {
+	void (*del)(struct nvif_faultbuf_priv *);
+
+	u32 entries;
+	u32 get;
+	u32 put;
+};
+
 struct nvif_device_impl {
 	void (*del)(struct nvif_device_priv *);
 
@@ -254,6 +263,9 @@ struct nvif_device_impl {
 
 	struct {
 		s32 oclass;
+		int (*new)(struct nvif_device_priv *,
+			   const struct nvif_faultbuf_impl **, struct nvif_faultbuf_priv **,
+			   u64 handle);
 	} faultbuf;
 
 	struct {
drivers/gpu/drm/nouveau/nouveau_svm.c +17 -10
index 07fa00afe5b8..83702a86da1d 100644
@@ -44,8 +44,11 @@ struct nouveau_svm {
 	struct list_head inst;
 
 	struct nouveau_svm_fault_buffer {
-		int id;
+		const struct nvif_faultbuf_impl *impl;
+		struct nvif_faultbuf_priv *priv;
 		struct nvif_object object;
+
+		int id;
 		u32 entries;
 		u32 getaddr;
 		u32 putaddr;
@@ -960,7 +963,11 @@ nouveau_svm_fault_buffer_dtor(struct nouveau_svm *svm, int id)
 	}
 
 	nvif_event_dtor(&buffer->notify);
-	nvif_object_dtor(&buffer->object);
+
+	if (buffer->impl) {
+		buffer->impl->del(buffer->priv);
+		buffer->impl = NULL;
+	}
 }
 
 static int
@@ -968,23 +975,23 @@ nouveau_svm_fault_buffer_ctor(struct nouveau_svm *svm, s32 oclass, int id)
 {
 	struct nouveau_svm_fault_buffer *buffer = &svm->buffer[id];
 	struct nouveau_drm *drm = svm->drm;
-	struct nvif_object *device = &drm->client.device.object;
-	struct nvif_clb069_v0 args = {};
 	int ret;
 
 	buffer->id = id;
 
-	ret = nvif_object_ctor(device, "svmFaultBuffer", 0, oclass, &args,
-			       sizeof(args), &buffer->object);
-	if (ret < 0) {
+	ret = drm->device.impl->faultbuf.new(drm->device.priv, &buffer->impl, &buffer->priv,
+					     nvif_handle(&buffer->object));
+	if (ret) {
 		SVM_ERR(svm, "Fault buffer allocation failed: %d", ret);
 		return ret;
 	}
 
+	nvif_object_ctor(&drm->device.object, "svmFaultBuffer", id, oclass, &buffer->object);
+	buffer->entries = buffer->impl->entries;
+	buffer->getaddr = buffer->impl->get;
+	buffer->putaddr = buffer->impl->put;
+
 	nvif_object_map(&buffer->object, NULL, 0);
-	buffer->entries = args.entries;
-	buffer->getaddr = args.get;
-	buffer->putaddr = args.put;
 	INIT_WORK(&buffer->work, nouveau_svm_fault);
 
 	ret = nvif_event_ctor(&buffer->object, "svmFault", id, nouveau_svm_event, true, NULL, 0,
drivers/gpu/drm/nouveau/nvkm/device/user.c +19 -9
index e63462188f2a..b4604ce1fcbb 100644
@@ -26,6 +26,7 @@
 #include "ctrl.h"
 
 #include <core/client.h>
+#include <subdev/fault/user.h>
 #include <subdev/fb.h>
 #include <subdev/instmem.h>
 #include <subdev/timer.h>
@@ -41,6 +42,21 @@ struct nvif_device_priv {
 	struct nvif_device_impl impl;
 };
 
+static int
+nvkm_udevice_fault_new(struct nvif_device_priv *udev,
+		       const struct nvif_faultbuf_impl **pimpl, struct nvif_faultbuf_priv **ppriv,
+		       u64 handle)
+{
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_ufault_new(udev->device, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+}
+
 static int
 nvkm_udevice_usermode_new(struct nvif_device_priv *udev, const struct nvif_usermode_impl **pimpl,
 			  struct nvif_usermode_priv **ppriv)
@@ -183,15 +199,8 @@ nvkm_udevice_child_get(struct nvkm_object *object, int index,
 		index -= engine->func->base.sclass(oclass, index, &sclass);
 	}
 
-	if (!sclass) {
-		if (device->fault && index-- == 0)
-			sclass = &device->fault->user;
-		else
-			return -EINVAL;
-
-		oclass->base = sclass->base;
-		oclass->engine = NULL;
-	}
+	if (!sclass)
+		return -EINVAL;
 
 	oclass->ctor = nvkm_udevice_child_new;
 	oclass->priv = sclass;
@@ -303,6 +312,7 @@ nvkm_udevice_new(struct nvkm_device *device,
 
 	if (device->fault) {
 		udev->impl.faultbuf.oclass = device->fault->user.base.oclass;
+		udev->impl.faultbuf.new = nvkm_udevice_fault_new;
 	}
 
 	if (device->disp) {
drivers/gpu/drm/nouveau/nvkm/subdev/fault/base.c +0 -1
index b53ac9a2552f..68611f83ab8a 100644
@@ -160,7 +160,6 @@ nvkm_fault_new_(const struct nvkm_fault_func *func, struct nvkm_device *device,
 		return -ENOMEM;
 	nvkm_subdev_ctor(&nvkm_fault, device, type, inst, &fault->subdev);
 	fault->func = func;
-	fault->user.ctor = nvkm_ufault_new;
 	fault->user.base = func->user.base;
 	return 0;
 }
drivers/gpu/drm/nouveau/nvkm/subdev/fault/priv.h +0 -3
index 3c26e76d1d3c..b49b4e3b7660 100644
@@ -52,7 +52,4 @@ void gp100_fault_intr(struct nvkm_fault *);
 u64 gp10b_fault_buffer_pin(struct nvkm_fault_buffer *);
 
 int gv100_fault_oneinit(struct nvkm_fault *);
-
-int nvkm_ufault_new(struct nvkm_device *, const struct nvkm_oclass *,
-		    void *, u32, struct nvkm_object **);
 #endif
drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c +34 -15

83 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.h new file +9 -0
new file mode 100644
index 000000000000..2408aa3ec91c
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_UFAULT_H__
+#define __NVKM_UFAULT_H__
+#include <subdev/fault.h>
+#include <nvif/driverif.h>
+
+int nvkm_ufault_new(struct nvkm_device *, const struct nvif_faultbuf_impl **,
+		    struct nvif_faultbuf_priv **, struct nvkm_object **);
+#endif
Signature · 1 line
2.41.0
author
#97 lore raw

PATCH 96/156 drm/nouveau/nvif: rework fault buffer "map" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  1 +
 drivers/gpu/drm/nouveau/nouveau_svm.c         | 26 +++++++++++--------
 .../gpu/drm/nouveau/nvkm/subdev/fault/user.c  | 16 +++---------
 3 files changed, 19 insertions(+), 24 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +1 -0
index a1aab5735146..ba987233ec74 100644
@@ -198,6 +198,7 @@ struct nvif_mmu_impl {
 struct nvif_faultbuf_impl {
 	void (*del)(struct nvif_faultbuf_priv *);
 
+	struct nvif_mapinfo map;
 	u32 entries;
 	u32 get;
 	u32 put;
drivers/gpu/drm/nouveau/nouveau_svm.c +15 -11
index 83702a86da1d..43218da5d0f3 100644
@@ -47,6 +47,7 @@ struct nouveau_svm {
 		const struct nvif_faultbuf_impl *impl;
 		struct nvif_faultbuf_priv *priv;
 		struct nvif_object object;
+		struct nvif_map map;
 
 		int id;
 		u32 entries;
@@ -449,15 +450,14 @@ static void
 nouveau_svm_fault_cache(struct nouveau_svm *svm,
 			struct nouveau_svm_fault_buffer *buffer, u32 offset)
 {
-	struct nvif_object *memory = &buffer->object;
-	const u32 instlo = nvif_rd32(memory, offset + 0x00);
-	const u32 insthi = nvif_rd32(memory, offset + 0x04);
-	const u32 addrlo = nvif_rd32(memory, offset + 0x08);
-	const u32 addrhi = nvif_rd32(memory, offset + 0x0c);
-	const u32 timelo = nvif_rd32(memory, offset + 0x10);
-	const u32 timehi = nvif_rd32(memory, offset + 0x14);
-	const u32 engine = nvif_rd32(memory, offset + 0x18);
-	const u32   info = nvif_rd32(memory, offset + 0x1c);
+	const u32 instlo = nvif_rd32(buffer, offset + 0x00);
+	const u32 insthi = nvif_rd32(buffer, offset + 0x04);
+	const u32 addrlo = nvif_rd32(buffer, offset + 0x08);
+	const u32 addrhi = nvif_rd32(buffer, offset + 0x0c);
+	const u32 timelo = nvif_rd32(buffer, offset + 0x10);
+	const u32 timehi = nvif_rd32(buffer, offset + 0x14);
+	const u32 engine = nvif_rd32(buffer, offset + 0x18);
+	const u32   info = nvif_rd32(buffer, offset + 0x1c);
 	const u64   inst = (u64)insthi << 32 | instlo;
 	const u8     gpc = (info & 0x1f000000) >> 24;
 	const u8     hub = (info & 0x00100000) >> 20;
@@ -468,7 +468,7 @@ nouveau_svm_fault_cache(struct nouveau_svm *svm,
 	if (WARN_ON(!(info & 0x80000000)))
 		return;
 
-	nvif_mask(memory, offset + 0x1c, 0x80000000, 0x00000000);
+	nvif_mask(buffer, offset + 0x1c, 0x80000000, 0x00000000);
 
 	if (!buffer->fault[buffer->fault_nr]) {
 		fault = kmalloc(sizeof(*fault), GFP_KERNEL);
@@ -965,6 +965,7 @@ nouveau_svm_fault_buffer_dtor(struct nouveau_svm *svm, int id)
 	nvif_event_dtor(&buffer->notify);
 
 	if (buffer->impl) {
+		nvif_object_unmap_cpu(&buffer->map);
 		buffer->impl->del(buffer->priv);
 		buffer->impl = NULL;
 	}
@@ -991,7 +992,10 @@ nouveau_svm_fault_buffer_ctor(struct nouveau_svm *svm, s32 oclass, int id)
 	buffer->getaddr = buffer->impl->get;
 	buffer->putaddr = buffer->impl->put;
 
-	nvif_object_map(&buffer->object, NULL, 0);
+	ret = nvif_object_map_cpu(&buffer->object, &buffer->impl->map, &buffer->map);
+	if (ret)
+		return ret;
+
 	INIT_WORK(&buffer->work, nouveau_svm_fault);
 
 	ret = nvif_event_ctor(&buffer->object, "svmFault", id, nouveau_svm_event, true, NULL, 0,
drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c +3 -13
index e6eb6df1f982..de7a79607eff 100644
@@ -51,18 +51,6 @@ nvkm_ufault_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm
 			       NVKM_FAULT_BUFFER_EVENT_PENDING, NULL);
 }
 
-static int
-nvkm_ufault_map(struct nvkm_object *object, void *argv, u32 argc,
-		enum nvkm_object_map *type, u64 *addr, u64 *size)
-{
-	struct nvkm_fault_buffer *buffer = container_of(object, struct nvif_faultbuf_priv, object)->buffer;
-	struct nvkm_device *device = buffer->fault->subdev.device;
-	*type = NVKM_OBJECT_MAP_IO;
-	*addr = device->func->resource_addr(device, 3) + buffer->addr;
-	*size = nvkm_memory_size(buffer->mem);
-	return 0;
-}
-
 static void
 nvkm_ufault_del(struct nvif_faultbuf_priv *ufault)
 {
@@ -108,7 +96,6 @@ nvkm_ufault = {
 	.dtor = nvkm_ufault_dtor,
 	.init = nvkm_ufault_init,
 	.fini = nvkm_ufault_fini,
-	.map = nvkm_ufault_map,
 	.uevent = nvkm_ufault_uevent,
 };
 
@@ -134,6 +121,9 @@ nvkm_ufault_new(struct nvkm_device *device, const struct nvif_faultbuf_impl **pi
 	}
 
 	ufault->impl = nvkm_ufault_impl;
+	ufault->impl.map.type = NVIF_MAP_IO;
+	ufault->impl.map.handle = device->func->resource_addr(device, 3) + ufault->buffer->addr;
+	ufault->impl.map.length = nvkm_memory_size(ufault->buffer->mem);
 	ufault->impl.entries = ufault->buffer->entries;
 	ufault->impl.get = ufault->buffer->get;
 	ufault->impl.put = ufault->buffer->put;
Signature · 1 line
2.41.0
author
#98 lore raw

PATCH 97/156 drm/nouveau/nvif: rework fault buffer "new event" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 drivers/gpu/drm/nouveau/include/nvif/clb069.h |  8 ---
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 12 ++++
 drivers/gpu/drm/nouveau/include/nvif/event.h  |  3 +
 .../gpu/drm/nouveau/include/nvkm/core/event.h |  9 ++-
 drivers/gpu/drm/nouveau/nouveau_svm.c         |  8 ++-
 drivers/gpu/drm/nouveau/nvif/event.c          | 33 ++++++++--
 drivers/gpu/drm/nouveau/nvkm/core/uevent.c    | 65 +++++++++++++++++++
 .../gpu/drm/nouveau/nvkm/subdev/fault/user.c  | 20 ++----
 8 files changed, 126 insertions(+), 32 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/clb069.h
drivers/gpu/drm/nouveau/include/nvif/clb069.h deleted +0 -8
deleted file mode 100644
index 67bf579ced18..000000000000
@@ -1,8 +0,0 @@
-#ifndef __NVIF_CLB069_H__
-#define __NVIF_CLB069_H__
-
-union nvif_clb069_event_args {
-	struct nvif_clb069_event_vn {
-	} vn;
-};
-#endif
drivers/gpu/drm/nouveau/include/nvif/driverif.h +12 -0
index ba987233ec74..81375819c787 100644
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: MIT */
 #ifndef __NVIF_DRIVERIF_H__
 #define __NVIF_DRIVERIF_H__
+struct nvif_event_priv;
 struct nvif_client_priv;
 struct nvif_device_priv;
 struct nvif_control_priv;
@@ -19,6 +20,12 @@ struct nvif_driver {
 	void (*unmap)(struct nvif_client_priv *, void __iomem *ptr, u32 size);
 };
 
+struct nvif_event_impl {
+	void (*del)(struct nvif_event_priv *);
+	int (*allow)(struct nvif_event_priv *);
+	int (*block)(struct nvif_event_priv *);
+};
+
 struct nvif_mapinfo {
 	enum nvif_map_type {
 		NVIF_MAP_IO,
@@ -202,6 +209,11 @@ struct nvif_faultbuf_impl {
 	u32 entries;
 	u32 get;
 	u32 put;
+
+	struct {
+		int (*new)(struct nvif_faultbuf_priv *, u64 token,
+			   const struct nvif_event_impl **, struct nvif_event_priv **);
+	} event;
 };
 
 struct nvif_device_impl {
drivers/gpu/drm/nouveau/include/nvif/event.h +3 -0
index 1683e138c7f8..338082bdc67c 100644
@@ -10,7 +10,10 @@ struct nvif_event;
 typedef int (*nvif_event_func)(struct nvif_event *, void *repv, u32 repc);
 
 struct nvif_event {
+	const struct nvif_event_impl *impl;
+	struct nvif_event_priv *priv;
 	struct nvif_object object;
+
 	nvif_event_func func;
 };
 
drivers/gpu/drm/nouveau/include/nvkm/core/event.h +7 -2
index 460459af272d..f31f0f30732a 100644
@@ -4,7 +4,6 @@
 #include <core/os.h>
 struct nvkm_object;
 struct nvkm_oclass;
-struct nvkm_uevent;
 
 struct nvkm_event {
 	const struct nvkm_event_func *func;
@@ -72,6 +71,12 @@ void nvkm_event_ntfy_block(struct nvkm_event_ntfy *);
 
 typedef int (*nvkm_uevent_func)(struct nvkm_object *, u64 token, u32 bits);
 
+struct nvif_event_impl;
+struct nvif_event_priv;
+int nvkm_uevent_new_(struct nvkm_object *parent, u64 handle, struct nvkm_event *event,
+		     bool wait, int id, u32 bits, nvkm_uevent_func,
+		     const struct nvif_event_impl **, struct nvif_event_priv **);
 int nvkm_uevent_new(const struct nvkm_oclass *, void *argv, u32 argc, struct nvkm_object **);
-int nvkm_uevent_add(struct nvkm_uevent *, struct nvkm_event *, int id, u32 bits, nvkm_uevent_func);
+int nvkm_uevent_add(struct nvif_event_priv *, struct nvkm_event *, int id, u32 bits,
+		    nvkm_uevent_func);
 #endif
drivers/gpu/drm/nouveau/nouveau_svm.c +5 -3
index 43218da5d0f3..382f886e4130 100644
@@ -29,7 +29,6 @@
 #include <nvif/vmm.h>
 
 #include <nvif/class.h>
-#include <nvif/clb069.h>
 #include <nvif/ifc00d.h>
 
 #include <linux/sched/mm.h>
@@ -998,11 +997,14 @@ nouveau_svm_fault_buffer_ctor(struct nouveau_svm *svm, s32 oclass, int id)
 
 	INIT_WORK(&buffer->work, nouveau_svm_fault);
 
-	ret = nvif_event_ctor(&buffer->object, "svmFault", id, nouveau_svm_event, true, NULL, 0,
-			      &buffer->notify);
+	ret = buffer->impl->event.new(buffer->priv, nvif_handle(&buffer->notify.object),
+				      &buffer->notify.impl, &buffer->notify.priv);
 	if (ret)
 		return ret;
 
+	nvif_event_ctor(&buffer->object, "svmFaultEvent", buffer->id, nouveau_svm_event,
+			&buffer->notify);
+
 	buffer->fault = kvcalloc(buffer->entries, sizeof(*buffer->fault), GFP_KERNEL);
 	if (!buffer->fault)
 		return -ENOMEM;
drivers/gpu/drm/nouveau/nvif/event.c +28 -5
index 61ff4d6eba9f..5b8ec641703b 100644
@@ -20,6 +20,7 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 #include <nvif/event.h>
+#include <nvif/driverif.h>
 #include <nvif/printf.h>
 
 #include <nvif/class.h>
@@ -28,29 +29,51 @@
 int
 nvif_event_block(struct nvif_event *event)
 {
-	if (nvif_event_constructed(event)) {
+	int ret;
+
+	if (!event->impl && nvif_event_constructed(event)) {
 		int ret = nvif_mthd(&event->object, NVIF_EVENT_V0_BLOCK, NULL, 0);
 		NVIF_ERRON(ret, &event->object, "[BLOCK]");
 		return ret;
 	}
-	return 0;
+
+	if (!event->impl)
+		return 0;
+
+	ret = event->impl->block(event->priv);
+	NVIF_ERRON(ret, &event->object, "[BLOCK]");
+	return ret;
 }
 
 int
 nvif_event_allow(struct nvif_event *event)
 {
-	if (nvif_event_constructed(event)) {
+	int ret;
+
+	if (!event->impl && nvif_event_constructed(event)) {
 		int ret = nvif_mthd(&event->object, NVIF_EVENT_V0_ALLOW, NULL, 0);
 		NVIF_ERRON(ret, &event->object, "[ALLOW]");
 		return ret;
 	}
-	return 0;
+
+	if (!event->impl)
+		return 0;
+
+	ret = event->impl->allow(event->priv);
+	NVIF_ERRON(ret, &event->object, "[ALLOW]");
+	return ret;
 }
 
 void
 nvif_event_dtor(struct nvif_event *event)
 {
-	nvif_object_dtor(&event->object);
+	if (!event->impl) {
+		nvif_object_dtor(&event->object);
+		return;
+	}
+
+	event->impl->del(event->priv);
+	event->impl = NULL;
 }
 
 int
drivers/gpu/drm/nouveau/nvkm/core/uevent.c +65 -0

80 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/subdev/fault/user.c +6 -14
index de7a79607eff..cbe1ead00a02 100644
@@ -26,9 +26,6 @@
 #include <core/event.h>
 #include <subdev/mmu.h>
 
-#include <nvif/clb069.h>
-#include <nvif/unpack.h>
-
 struct nvif_faultbuf_priv {
 	struct nvkm_object object;
 	struct nvkm_fault_buffer *buffer;
@@ -37,18 +34,13 @@ struct nvif_faultbuf_priv {
 };
 
 static int
-nvkm_ufault_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_uevent *uevent)
+nvkm_ufault_event_new(struct nvif_faultbuf_priv *ufault, u64 token,
+		      const struct nvif_event_impl **pimpl, struct nvif_event_priv **ppriv)
 {
-	struct nvkm_fault_buffer *buffer = container_of(object, struct nvif_faultbuf_priv, object)->buffer;
-	union nvif_clb069_event_args *args = argv;
-
-	if (!uevent)
-		return 0;
-	if (argc != sizeof(args->vn))
-		return -ENOSYS;
+	struct nvkm_fault_buffer *buffer = ufault->buffer;
 
-	return nvkm_uevent_add(uevent, &buffer->fault->event, buffer->id,
-			       NVKM_FAULT_BUFFER_EVENT_PENDING, NULL);
+	return nvkm_uevent_new_(&ufault->object, token, &buffer->fault->event, true, buffer->id,
+				NVKM_FAULT_BUFFER_EVENT_PENDING, NULL, pimpl, ppriv);
 }
 
 static void
@@ -63,6 +55,7 @@ nvkm_ufault_del(struct nvif_faultbuf_priv *ufault)
 static const struct nvif_faultbuf_impl
 nvkm_ufault_impl = {
 	.del = nvkm_ufault_del,
+	.event.new = nvkm_ufault_event_new,
 };
 
 static int
@@ -96,7 +89,6 @@ nvkm_ufault = {
 	.dtor = nvkm_ufault_dtor,
 	.init = nvkm_ufault_init,
 	.fini = nvkm_ufault_fini,
-	.uevent = nvkm_ufault_uevent,
 };
 
 int
Signature · 1 line
2.41.0
author
#99 lore raw

PATCH 98/156 drm/nouveau/nvif: remove fault buffer from object rb

In reply to Ben Skeggs

- no more users

---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h | 3 +--
 drivers/gpu/drm/nouveau/nouveau_svm.c           | 3 +--
 drivers/gpu/drm/nouveau/nvkm/device/user.c      | 6 +++---
 3 files changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +1 -2
index 81375819c787..42e6324ddfe3 100644
@@ -277,8 +277,7 @@ struct nvif_device_impl {
 	struct {
 		s32 oclass;
 		int (*new)(struct nvif_device_priv *,
-			   const struct nvif_faultbuf_impl **, struct nvif_faultbuf_priv **,
-			   u64 handle);
+			   const struct nvif_faultbuf_impl **, struct nvif_faultbuf_priv **);
 	} faultbuf;
 
 	struct {
drivers/gpu/drm/nouveau/nouveau_svm.c +1 -2
index 382f886e4130..534448f82daa 100644
@@ -979,8 +979,7 @@ nouveau_svm_fault_buffer_ctor(struct nouveau_svm *svm, s32 oclass, int id)
 
 	buffer->id = id;
 
-	ret = drm->device.impl->faultbuf.new(drm->device.priv, &buffer->impl, &buffer->priv,
-					     nvif_handle(&buffer->object));
+	ret = drm->device.impl->faultbuf.new(drm->device.priv, &buffer->impl, &buffer->priv);
 	if (ret) {
 		SVM_ERR(svm, "Fault buffer allocation failed: %d", ret);
 		return ret;
drivers/gpu/drm/nouveau/nvkm/device/user.c +3 -3
index b4604ce1fcbb..eb33ab81d7e1 100644
@@ -44,8 +44,7 @@ struct nvif_device_priv {
 
 static int
 nvkm_udevice_fault_new(struct nvif_device_priv *udev,
-		       const struct nvif_faultbuf_impl **pimpl, struct nvif_faultbuf_priv **ppriv,
-		       u64 handle)
+		       const struct nvif_faultbuf_impl **pimpl, struct nvif_faultbuf_priv **ppriv)
 {
 	struct nvkm_object *object;
 	int ret;
@@ -54,7 +53,8 @@ nvkm_udevice_fault_new(struct nvif_device_priv *udev,
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+	nvkm_object_link(&udev->object, object);
+	return 0;
 }
 
 static int
Signature · 1 line
2.41.0
author
#100 lore raw

PATCH 99/156 drm/nouveau/nvif: rework device "new disp" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 drivers/gpu/drm/nouveau/include/nvif/disp.h   |  5 ++
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 20 ++++++++
 drivers/gpu/drm/nouveau/include/nvif/if0010.h | 14 -----
 drivers/gpu/drm/nouveau/include/nvif/object.h | 16 ------
 drivers/gpu/drm/nouveau/nvif/disp.c           | 26 +++++-----
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 20 +++++++-
 .../gpu/drm/nouveau/nvkm/engine/disp/base.c   | 27 ----------
 .../gpu/drm/nouveau/nvkm/engine/disp/priv.h   |  1 -
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.c  | 51 +++++++++++++------
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.h  |  6 +++
 10 files changed, 97 insertions(+), 89 deletions(-)
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0010.h
drivers/gpu/drm/nouveau/include/nvif/disp.h +5 -0
index c4f428f268ea..06f56cc63893 100644
@@ -4,7 +4,12 @@
 struct nvif_device;
 
 struct nvif_disp {
+	const struct nvif_disp_impl *impl;
+	struct nvif_disp_priv *priv;
 	struct nvif_object object;
+
+	struct nvif_device *device;
+
 	unsigned long conn_mask;
 	unsigned long outp_mask;
 	unsigned long head_mask;
drivers/gpu/drm/nouveau/include/nvif/driverif.h +20 -0
index 42e6324ddfe3..e479e8114605 100644
@@ -10,6 +10,7 @@ struct nvif_mmu_priv;
 struct nvif_mem_priv;
 struct nvif_vmm_priv;
 struct nvif_faultbuf_priv;
+struct nvif_disp_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -216,6 +217,22 @@ struct nvif_faultbuf_impl {
 	} event;
 };
 
+struct nvif_disp_impl {
+	void (*del)(struct nvif_disp_priv *);
+
+	struct {
+		u32 mask;
+	} conn;
+
+	struct {
+		u32 mask;
+	} outp;
+
+	struct {
+		u32 mask;
+	} head;
+};
+
 struct nvif_device_impl {
 	void (*del)(struct nvif_device_priv *);
 
@@ -282,6 +299,9 @@ struct nvif_device_impl {
 
 	struct {
 		s32 oclass;
+		int (*new)(struct nvif_device_priv *,
+			   const struct nvif_disp_impl **, struct nvif_disp_priv **,
+			   u64 handle);
 	} disp;
 
 	struct nvif_device_impl_fifo {
drivers/gpu/drm/nouveau/include/nvif/if0010.h deleted +0 -14
deleted file mode 100644
index 4c835bbe6fe3..000000000000
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVIF_IF0010_H__
-#define __NVIF_IF0010_H__
-
-union nvif_disp_args {
-	struct nvif_disp_v0 {
-		__u8 version;
-		__u8 pad01[3];
-		__u32 conn_mask;
-		__u32 outp_mask;
-		__u32 head_mask;
-	} v0;
-};
-#endif
drivers/gpu/drm/nouveau/include/nvif/object.h +0 -16
index b3e66425f310..819ae1c9729d 100644
@@ -111,22 +111,6 @@ struct nvif_mclass {
 	ret;                                                                   \
 })
 
-#define nvif_sclass(o,m,u) ({                                                  \
-	const typeof(m[0]) *_mclass = (m);                                     \
-	s32 _oclass = (u);                                                     \
-	int _cid;                                                              \
-	if (_oclass) {                                                         \
-		for (_cid = 0; _mclass[_cid].oclass; _cid++) {                 \
-			if (_mclass[_cid].oclass == _oclass)                   \
-				break;                                         \
-		}                                                              \
-		_cid = _mclass[_cid].oclass ? _cid : -ENOSYS;                  \
-	} else {                                                               \
-		_cid = nvif_mclass((o), _mclass);                              \
-	}                                                                      \
-	_cid;                                                                  \
-})
-
 #define NVIF_RD32_(p,o,dr)   nvif_rd32((p), (o) + (dr))
 #define NVIF_WR32_(p,o,dr,f) nvif_wr32((p), (o) + (dr), (f))
 #define NVIF_RD32(p,A...) DRF_RD(NVIF_RD32_,                  (p), 0, ##A)
drivers/gpu/drm/nouveau/nvif/disp.c +12 -14
index 875c63877468..f3c425daf7d5 100644
@@ -24,23 +24,23 @@
 #include <nvif/printf.h>
 
 #include <nvif/class.h>
-#include <nvif/if0010.h>
 
 void
 nvif_disp_dtor(struct nvif_disp *disp)
 {
-	nvif_object_dtor(&disp->object);
+	if (!disp->impl)
+		return;
+
+	disp->impl->del(disp->priv);
+	disp->impl = NULL;
 }
 
 int
 nvif_disp_ctor(struct nvif_device *device, const char *name, struct nvif_disp *disp)
 {
 	const u32 oclass = device->impl->disp.oclass;
-	struct nvif_disp_v0 args;
 	int ret;
 
-	disp->object.client = NULL;
-
 	switch (oclass) {
 	case AD102_DISP:
 	case GA102_DISP:
@@ -65,18 +65,16 @@ nvif_disp_ctor(struct nvif_device *device, const char *name, struct nvif_disp *d
 		return -ENODEV;
 	}
 
-	args.version = 0;
-
-	ret = nvif_object_ctor(&device->object, name ?: "nvifDisp", 0,
-			       oclass, &args, sizeof(args), &disp->object);
+	ret = device->impl->disp.new(device->priv, &disp->impl, &disp->priv,
+				     nvif_handle(&disp->object));
 	NVIF_ERRON(ret, &device->object, "[NEW disp%04x]", oclass);
 	if (ret)
 		return ret;
 
-	NVIF_DEBUG(&disp->object, "[NEW] conn_mask:%08x outp_mask:%08x head_mask:%08x",
-		   args.conn_mask, args.outp_mask, args.head_mask);
-	disp->conn_mask = args.conn_mask;
-	disp->outp_mask = args.outp_mask;
-	disp->head_mask = args.head_mask;
+	nvif_object_ctor(&device->object, name ?: "nvifDisp", 0, oclass, &disp->object);
+	disp->device = device;
+	disp->conn_mask = disp->impl->conn.mask;
+	disp->outp_mask = disp->impl->outp.mask;
+	disp->head_mask = disp->impl->head.mask;
 	return 0;
 }
drivers/gpu/drm/nouveau/nvkm/device/user.c +18 -2
index eb33ab81d7e1..3c7c0d1e6adb 100644
@@ -33,6 +33,7 @@
 #include <subdev/mmu/ummu.h>
 #include <subdev/vfn/uvfn.h>
 #include <engine/disp/priv.h>
+#include <engine/disp/udisp.h>
 #include <engine/fifo/ufifo.h>
 
 struct nvif_device_priv {
@@ -93,6 +94,21 @@ nvkm_udevice_time(struct nvif_device_priv *udev)
 	return nvkm_timer_read(udev->device->timer);
 }
 
+static int
+nvkm_udevice_disp_new(struct nvif_device_priv *udev,
+		      const struct nvif_disp_impl **pimpl, struct nvif_disp_priv **ppriv,
+		      u64 handle)
+{
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_udisp_new(udev->device, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+}
+
 static int
 nvkm_udevice_mmu_new(struct nvif_device_priv *udev,
 		     const struct nvif_mmu_impl **pimpl, struct nvif_mmu_priv **ppriv)
@@ -185,8 +201,7 @@ nvkm_udevice_child_get(struct nvkm_object *object, int index,
 	struct nvkm_device *device = udev->device;
 	struct nvkm_engine *engine;
 	u64 mask = (1ULL << NVKM_ENGINE_DMAOBJ) |
-		   (1ULL << NVKM_ENGINE_FIFO) |
-		   (1ULL << NVKM_ENGINE_DISP);
+		   (1ULL << NVKM_ENGINE_FIFO);
 	const struct nvkm_device_oclass *sclass = NULL;
 	int i;
 
@@ -317,6 +332,7 @@ nvkm_udevice_new(struct nvkm_device *device,
 
 	if (device->disp) {
 		udev->impl.disp.oclass = device->disp->func->user.root.oclass;
+		udev->impl.disp.new = nvkm_udevice_disp_new;
 	}
 
 	if (device->fifo) {
drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c +0 -27
index 6850c703ff2d..dab603f17e2d 100644
@@ -65,32 +65,6 @@ nvkm_disp_vblank(struct nvkm_disp *disp, int head)
 	nvkm_event_ntfy(&disp->vblank, head, NVKM_DISP_HEAD_EVENT_VBLANK);
 }
 
-static int
-nvkm_disp_class_new(struct nvkm_device *device,
-		    const struct nvkm_oclass *oclass, void *data, u32 size,
-		    struct nvkm_object **pobject)
-{
-	return nvkm_udisp_new(oclass, data, size, pobject);
-}
-
-static const struct nvkm_device_oclass
-nvkm_disp_sclass = {
-	.ctor = nvkm_disp_class_new,
-};
-
-static int
-nvkm_disp_class_get(struct nvkm_oclass *oclass, int index,
-		    const struct nvkm_device_oclass **class)
-{
-	struct nvkm_disp *disp = nvkm_disp(oclass->engine);
-	if (index == 0) {
-		oclass->base = (struct nvkm_sclass) { 0, 0, disp->func->user.root.oclass };
-		*class = &nvkm_disp_sclass;
-		return 0;
-	}
-	return 1;
-}
-
 static void
 nvkm_disp_intr(struct nvkm_engine *engine)
 {
@@ -222,7 +196,6 @@ nvkm_disp = {
 	.init = nvkm_disp_init,
 	.fini = nvkm_disp_fini,
 	.intr = nvkm_disp_intr,
-	.base.sclass = nvkm_disp_class_get,
 };
 
 int
drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h +0 -1
index 82b16cc9212a..324a7971a0eb 100644
@@ -90,7 +90,6 @@ 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_udisp_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
 int nvkm_uconn_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
 int nvkm_uoutp_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
 int nvkm_uhead_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c +36 -15

104 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.h +6 -0
index 2918ecbca5d3..5baf1fe35f88 100644
@@ -3,9 +3,15 @@
 #define __NVKM_UDISP_H__
 #include <core/object.h>
 #include "priv.h"
+#include <nvif/driverif.h>
 
 struct nvif_disp_priv {
 	struct nvkm_object object;
 	struct nvkm_disp *disp;
+
+	struct nvif_disp_impl impl;
 };
+
+int nvkm_udisp_new(struct nvkm_device *, const struct nvif_disp_impl **, struct nvif_disp_priv **,
+		   struct nvkm_object **);
 #endif
Signature · 1 line
2.41.0
author
#101 lore raw

PATCH 100/156 drm/nouveau/nvif: rework disp "sclass" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 drivers/gpu/drm/nouveau/dispnv50/base.c       | 33 +++++--------
 drivers/gpu/drm/nouveau/dispnv50/core.c       | 49 ++++++++-----------
 drivers/gpu/drm/nouveau/dispnv50/curs.c       | 35 ++++++-------
 drivers/gpu/drm/nouveau/dispnv50/oimm.c       | 29 +++++------
 drivers/gpu/drm/nouveau/dispnv50/ovly.c       | 32 +++++-------
 drivers/gpu/drm/nouveau/dispnv50/wimm.c       | 25 ++++------
 drivers/gpu/drm/nouveau/dispnv50/wndw.c       | 27 ++++------
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 18 +++++++
 drivers/gpu/drm/nouveau/include/nvif/object.h | 29 -----------
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.c  | 20 ++++++++
 10 files changed, 129 insertions(+), 168 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/base.c +13 -20
index 7c752acf2b48..db0b42c6243e 100644
@@ -26,28 +26,21 @@
 int
 nv50_base_new(struct nouveau_drm *drm, int head, struct nv50_wndw **pwndw)
 {
-	struct {
-		s32 oclass;
-		int version;
-		int (*new)(struct nouveau_drm *, int, s32, struct nv50_wndw **);
-	} bases[] = {
-		{ GK110_DISP_BASE_CHANNEL_DMA, 0, base917c_new },
-		{ GK104_DISP_BASE_CHANNEL_DMA, 0, base917c_new },
-		{ GF110_DISP_BASE_CHANNEL_DMA, 0, base907c_new },
-		{ GT214_DISP_BASE_CHANNEL_DMA, 0, base827c_new },
-		{ GT200_DISP_BASE_CHANNEL_DMA, 0, base827c_new },
-		{   G82_DISP_BASE_CHANNEL_DMA, 0, base827c_new },
-		{  NV50_DISP_BASE_CHANNEL_DMA, 0, base507c_new },
-		{}
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
-	int cid;
+	int (*ctor)(struct nouveau_drm *, int, s32, struct nv50_wndw **);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 
-	cid = nvif_mclass(&disp->disp->object, bases);
-	if (cid < 0) {
+	switch (disp->impl->chan.base.oclass) {
+	case GK110_DISP_BASE_CHANNEL_DMA: ctor = base917c_new; break;
+	case GK104_DISP_BASE_CHANNEL_DMA: ctor = base917c_new; break;
+	case GF110_DISP_BASE_CHANNEL_DMA: ctor = base907c_new; break;
+	case GT214_DISP_BASE_CHANNEL_DMA: ctor = base827c_new; break;
+	case GT200_DISP_BASE_CHANNEL_DMA: ctor = base827c_new; break;
+	case   G82_DISP_BASE_CHANNEL_DMA: ctor = base827c_new; break;
+	case  NV50_DISP_BASE_CHANNEL_DMA: ctor = base507c_new; break;
+	default:
 		NV_ERROR(drm, "No supported base class\n");
-		return cid;
+		return -ENODEV;
 	}
 
-	return bases[cid].new(drm, head, bases[cid].oclass, pwndw);
+	return ctor(drm, head, disp->impl->chan.base.oclass, pwndw);
 }
drivers/gpu/drm/nouveau/dispnv50/core.c +21 -28

62 lines not on this page · raw message

drivers/gpu/drm/nouveau/dispnv50/curs.c +14 -21
index 31d8b2e4791d..8d1026c6baec 100644
@@ -26,29 +26,22 @@
 int
 nv50_curs_new(struct nouveau_drm *drm, int head, struct nv50_wndw **pwndw)
 {
-	struct {
-		s32 oclass;
-		int version;
-		int (*new)(struct nouveau_drm *, int, s32, struct nv50_wndw **);
-	} curses[] = {
-		{ GA102_DISP_CURSOR, 0, cursc37a_new },
-		{ TU102_DISP_CURSOR, 0, cursc37a_new },
-		{ GV100_DISP_CURSOR, 0, cursc37a_new },
-		{ GK104_DISP_CURSOR, 0, curs907a_new },
-		{ GF110_DISP_CURSOR, 0, curs907a_new },
-		{ GT214_DISP_CURSOR, 0, curs507a_new },
-		{   G82_DISP_CURSOR, 0, curs507a_new },
-		{  NV50_DISP_CURSOR, 0, curs507a_new },
-		{}
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
-	int cid;
+	int (*ctor)(struct nouveau_drm *, int, s32, struct nv50_wndw **);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 
-	cid = nvif_mclass(&disp->disp->object, curses);
-	if (cid < 0) {
+	switch (disp->impl->chan.curs.oclass) {
+	case GA102_DISP_CURSOR: ctor = cursc37a_new; break;
+	case TU102_DISP_CURSOR: ctor = cursc37a_new; break;
+	case GV100_DISP_CURSOR: ctor = cursc37a_new; break;
+	case GK104_DISP_CURSOR: ctor = curs907a_new; break;
+	case GF110_DISP_CURSOR: ctor = curs907a_new; break;
+	case GT214_DISP_CURSOR: ctor = curs507a_new; break;
+	case   G82_DISP_CURSOR: ctor = curs507a_new; break;
+	case  NV50_DISP_CURSOR: ctor = curs507a_new; break;
+	default:
 		NV_ERROR(drm, "No supported cursor immediate class\n");
-		return cid;
+		return -ENODEV;
 	}
 
-	return curses[cid].new(drm, head, curses[cid].oclass, pwndw);
+	return ctor(drm, head, disp->impl->chan.curs.oclass, pwndw);
 }
drivers/gpu/drm/nouveau/dispnv50/oimm.c +11 -18
index 2a2841d344c8..4a06cd293cb5 100644
@@ -26,26 +26,19 @@
 int
 nv50_oimm_init(struct nouveau_drm *drm, struct nv50_wndw *wndw)
 {
-	static const struct {
-		s32 oclass;
-		int version;
-		int (*init)(struct nouveau_drm *, s32, struct nv50_wndw *);
-	} oimms[] = {
-		{ GK104_DISP_OVERLAY, 0, oimm507b_init },
-		{ GF110_DISP_OVERLAY, 0, oimm507b_init },
-		{ GT214_DISP_OVERLAY, 0, oimm507b_init },
-		{   G82_DISP_OVERLAY, 0, oimm507b_init },
-		{  NV50_DISP_OVERLAY, 0, oimm507b_init },
-		{}
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
-	int cid;
+	int (*ctor)(struct nouveau_drm *, s32, struct nv50_wndw *);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 
-	cid = nvif_mclass(&disp->disp->object, oimms);
-	if (cid < 0) {
+	switch (disp->impl->chan.oimm.oclass) {
+	case GK104_DISP_OVERLAY: ctor = oimm507b_init; break;
+	case GF110_DISP_OVERLAY: ctor = oimm507b_init; break;
+	case GT214_DISP_OVERLAY: ctor = oimm507b_init; break;
+	case   G82_DISP_OVERLAY: ctor = oimm507b_init; break;
+	case  NV50_DISP_OVERLAY: ctor = oimm507b_init; break;
+	default:
 		NV_ERROR(drm, "No supported overlay immediate class\n");
-		return cid;
+		return -ENODEV;
 	}
 
-	return oimms[cid].init(drm, oimms[cid].oclass, wndw);
+	return ctor(drm, disp->impl->chan.oimm.oclass, wndw);
 }
drivers/gpu/drm/nouveau/dispnv50/ovly.c +13 -19
index 90c246d47604..029c86a53c1f 100644
@@ -27,29 +27,23 @@
 int
 nv50_ovly_new(struct nouveau_drm *drm, int head, struct nv50_wndw **pwndw)
 {
-	static const struct {
-		s32 oclass;
-		int version;
-		int (*new)(struct nouveau_drm *, int, s32, struct nv50_wndw **);
-	} ovlys[] = {
-		{ GK104_DISP_OVERLAY_CONTROL_DMA, 0, ovly917e_new },
-		{ GF110_DISP_OVERLAY_CONTROL_DMA, 0, ovly907e_new },
-		{ GT214_DISP_OVERLAY_CHANNEL_DMA, 0, ovly827e_new },
-		{ GT200_DISP_OVERLAY_CHANNEL_DMA, 0, ovly827e_new },
-		{   G82_DISP_OVERLAY_CHANNEL_DMA, 0, ovly827e_new },
-		{  NV50_DISP_OVERLAY_CHANNEL_DMA, 0, ovly507e_new },
-		{}
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
-	int cid, ret;
+	int (*ctor)(struct nouveau_drm *, int, s32, struct nv50_wndw **);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
+	int ret;
 
-	cid = nvif_mclass(&disp->disp->object, ovlys);
-	if (cid < 0) {
+	switch (disp->impl->chan.ovly.oclass) {
+	case GK104_DISP_OVERLAY_CONTROL_DMA: ctor = ovly917e_new; break;
+	case GF110_DISP_OVERLAY_CONTROL_DMA: ctor = ovly907e_new; break;
+	case GT214_DISP_OVERLAY_CHANNEL_DMA: ctor = ovly827e_new; break;
+	case GT200_DISP_OVERLAY_CHANNEL_DMA: ctor = ovly827e_new; break;
+	case   G82_DISP_OVERLAY_CHANNEL_DMA: ctor = ovly827e_new; break;
+	case  NV50_DISP_OVERLAY_CHANNEL_DMA: ctor = ovly507e_new; break;
+	default:
 		NV_ERROR(drm, "No supported overlay class\n");
-		return cid;
+		return -ENODEV;
 	}
 
-	ret = ovlys[cid].new(drm, head, ovlys[cid].oclass, pwndw);
+	ret = ctor(drm, head, disp->impl->chan.ovly.oclass, pwndw);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/nouveau/dispnv50/wimm.c +9 -16
index 566fbddfc8d7..c94830cf07cb 100644
@@ -26,24 +26,17 @@
 int
 nv50_wimm_init(struct nouveau_drm *drm, struct nv50_wndw *wndw)
 {
-	struct {
-		s32 oclass;
-		int version;
-		int (*init)(struct nouveau_drm *, s32, struct nv50_wndw *);
-	} wimms[] = {
-		{ GA102_DISP_WINDOW_IMM_CHANNEL_DMA, 0, wimmc37b_init },
-		{ TU102_DISP_WINDOW_IMM_CHANNEL_DMA, 0, wimmc37b_init },
-		{ GV100_DISP_WINDOW_IMM_CHANNEL_DMA, 0, wimmc37b_init },
-		{}
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
-	int cid;
+	int (*ctor)(struct nouveau_drm *, s32, struct nv50_wndw *);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 
-	cid = nvif_mclass(&disp->disp->object, wimms);
-	if (cid < 0) {
+	switch (disp->impl->chan.wimm.oclass) {
+	case GA102_DISP_WINDOW_IMM_CHANNEL_DMA: ctor = wimmc37b_init; break;
+	case TU102_DISP_WINDOW_IMM_CHANNEL_DMA: ctor = wimmc37b_init; break;
+	case GV100_DISP_WINDOW_IMM_CHANNEL_DMA: ctor = wimmc37b_init; break;
+	default:
 		NV_ERROR(drm, "No supported window immediate class\n");
-		return cid;
+		return -ENODEV;
 	}
 
-	return wimms[cid].init(drm, wimms[cid].oclass, wndw);
+	return ctor(drm, disp->impl->chan.wimm.oclass, wndw);
 }
drivers/gpu/drm/nouveau/dispnv50/wndw.c +10 -17
index 19606755daf5..6fb6d2252e15 100644
@@ -810,27 +810,20 @@ int
 nv50_wndw_new(struct nouveau_drm *drm, enum drm_plane_type type, int index,
 	      struct nv50_wndw **pwndw)
 {
-	struct {
-		s32 oclass;
-		int version;
-		int (*new)(struct nouveau_drm *, enum drm_plane_type,
-			   int, s32, struct nv50_wndw **);
-	} wndws[] = {
-		{ GA102_DISP_WINDOW_CHANNEL_DMA, 0, wndwc67e_new },
-		{ TU102_DISP_WINDOW_CHANNEL_DMA, 0, wndwc57e_new },
-		{ GV100_DISP_WINDOW_CHANNEL_DMA, 0, wndwc37e_new },
-		{}
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
-	int cid, ret;
+	int (*ctor)(struct nouveau_drm *, enum drm_plane_type, int, s32, struct nv50_wndw **);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
+	int ret;
 
-	cid = nvif_mclass(&disp->disp->object, wndws);
-	if (cid < 0) {
+	switch (disp->impl->chan.wndw.oclass) {
+	case GA102_DISP_WINDOW_CHANNEL_DMA: ctor = wndwc67e_new; break;
+	case TU102_DISP_WINDOW_CHANNEL_DMA: ctor = wndwc57e_new; break;
+	case GV100_DISP_WINDOW_CHANNEL_DMA: ctor = wndwc37e_new; break;
+	default:
 		NV_ERROR(drm, "No supported window class\n");
-		return cid;
+		return -ENODEV;
 	}
 
-	ret = wndws[cid].new(drm, type, index, wndws[cid].oclass, pwndw);
+	ret = ctor(drm, type, index, disp->impl->chan.wndw.oclass, pwndw);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/nouveau/include/nvif/driverif.h +18 -0
index e479e8114605..f96638ce4b12 100644
@@ -220,6 +220,10 @@ struct nvif_faultbuf_impl {
 struct nvif_disp_impl {
 	void (*del)(struct nvif_disp_priv *);
 
+	struct {
+		u32 oclass;
+	} caps;
+
 	struct {
 		u32 mask;
 	} conn;
@@ -231,6 +235,20 @@ struct nvif_disp_impl {
 	struct {
 		u32 mask;
 	} head;
+
+	struct {
+		struct nvif_disp_impl_core {
+			s32 oclass;
+		} core;
+
+		struct nvif_disp_impl_dmac {
+			s32 oclass;
+		} base, ovly, wndw, wimm;
+
+		struct nvif_disp_impl_pioc {
+			s32 oclass;
+		} curs, oimm;
+	} chan;
 };
 
 struct nvif_device_impl {
drivers/gpu/drm/nouveau/include/nvif/object.h +0 -29
index 819ae1c9729d..10a8f3e1ea81 100644
@@ -82,35 +82,6 @@ void nvif_object_unmap(struct nvif_object *);
 
 #define nvif_mthd(a,b,c,d) nvif_object_mthd((a), (b), (c), (d))
 
-struct nvif_mclass {
-	s32 oclass;
-	int version;
-};
-
-#define nvif_mclass(o,m) ({                                                    \
-	struct nvif_object *object = (o);                                      \
-	struct nvif_sclass *sclass;                                            \
-	typeof(m[0]) *mclass = (m);                                            \
-	int ret = -ENODEV;                                                     \
-	int cnt, i, j;                                                         \
-                                                                               \
-	cnt = nvif_object_sclass_get(object, &sclass);                         \
-	if (cnt >= 0) {                                                        \
-		for (i = 0; ret < 0 && mclass[i].oclass; i++) {                \
-			for (j = 0; j < cnt; j++) {                            \
-				if (mclass[i].oclass  == sclass[j].oclass &&   \
-				    mclass[i].version >= sclass[j].minver &&   \
-				    mclass[i].version <= sclass[j].maxver) {   \
-					ret = i;                               \
-					break;                                 \
-				}                                              \
-			}                                                      \
-		}                                                              \
-		nvif_object_sclass_put(&sclass);                               \
-	}                                                                      \
-	ret;                                                                   \
-})
-
 #define NVIF_RD32_(p,o,dr)   nvif_rd32((p), (o) + (dr))
 #define NVIF_WR32_(p,o,dr,f) nvif_wr32((p), (o) + (dr), (f))
 #define NVIF_RD32(p,A...) DRF_RD(NVIF_RD32_,                  (p), 0, ##A)
drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c +20 -0
index 06e465edf3e9..fd8590514c7e 100644
@@ -171,6 +171,10 @@ nvkm_udisp_new(struct nvkm_device *device, const struct nvif_disp_impl **pimpl,
 	udisp->disp = disp;
 	udisp->impl = nvkm_udisp_impl;
 
+	if (disp->func->user.caps.oclass) {
+		udisp->impl.caps.oclass = disp->func->user.caps.oclass;
+	}
+
 	list_for_each_entry(conn, &disp->conns, head)
 		udisp->impl.conn.mask |= BIT(conn->index);
 
@@ -180,6 +184,22 @@ nvkm_udisp_new(struct nvkm_device *device, const struct nvif_disp_impl **pimpl,
 	list_for_each_entry(head, &disp->heads, head)
 		udisp->impl.head.mask |= BIT(head->id);
 
+	if (disp->func->user.core.oclass) {
+		udisp->impl.chan.core.oclass = disp->func->user.core.oclass;
+		udisp->impl.chan.curs.oclass = disp->func->user.curs.oclass;
+
+		if (!disp->func->user.wndw.oclass) {
+			/* EVO */
+			udisp->impl.chan.base.oclass = disp->func->user.base.oclass;
+			udisp->impl.chan.ovly.oclass = disp->func->user.ovly.oclass;
+			udisp->impl.chan.oimm.oclass = disp->func->user.oimm.oclass;
+		} else {
+			/* NVDisplay (GV100-) */
+			udisp->impl.chan.wndw.oclass = disp->func->user.wndw.oclass;
+			udisp->impl.chan.wimm.oclass = disp->func->user.wimm.oclass;
+		}
+	}
+
 	*pimpl = &udisp->impl;
 	*ppriv = udisp;
 	*pobject = &udisp->object;
Signature · 1 line
2.41.0
author
#102 lore raw

PATCH 101/156 drm/nouveau/nvif: rework disp "new caps" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 drivers/gpu/drm/nouveau/dispnv50/corec37d.c   | 11 +--
 drivers/gpu/drm/nouveau/dispnv50/disp.c       |  3 +-
 drivers/gpu/drm/nouveau/dispnv50/disp.h       |  2 +-
 drivers/gpu/drm/nouveau/include/nvif/disp.h   | 11 +++
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  8 +++
 drivers/gpu/drm/nouveau/nvif/disp.c           | 32 +++++++++
 .../gpu/drm/nouveau/nvkm/engine/disp/Kbuild   |  1 +
 .../gpu/drm/nouveau/nvkm/engine/disp/ad102.c  |  2 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/ga102.c  |  2 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/gv100.c  | 42 ++---------
 .../gpu/drm/nouveau/nvkm/engine/disp/priv.h   |  5 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/tu102.c  |  2 +-
 .../gpu/drm/nouveau/nvkm/engine/disp/ucaps.c  | 70 +++++++++++++++++++
 .../gpu/drm/nouveau/nvkm/engine/disp/ucaps.h  |  9 +++
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.c  | 23 ++++--
 15 files changed, 161 insertions(+), 62 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/disp/ucaps.c
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/disp/ucaps.h
drivers/gpu/drm/nouveau/dispnv50/corec37d.c +1 -10
index 9525fd30c8fc..60535526ac89 100644
@@ -104,8 +104,7 @@ int corec37d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
 {
 	int ret;
 
-	ret = nvif_object_ctor(&disp->disp->object, "dispCaps", 0,
-			       GV100_DISP_CAPS, NULL, 0, &disp->caps);
+	ret = nvif_disp_caps_ctor(disp->disp, "dispCaps", &disp->caps);
 	if (ret) {
 		NV_ERROR(drm,
 			 "Failed to init notifier caps region: %d\n",
@@ -113,14 +112,6 @@ int corec37d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
 		return ret;
 	}
 
-	ret = nvif_object_map(&disp->caps, NULL, 0);
-	if (ret) {
-		NV_ERROR(drm,
-			 "Failed to map notifier caps region: %d\n",
-			 ret);
-		return ret;
-	}
-
 	return 0;
 }
 
drivers/gpu/drm/nouveau/dispnv50/disp.c +1 -2
index b89a8f4ee506..802dccace624 100644
@@ -2788,8 +2788,7 @@ nv50_display_destroy(struct drm_device *dev)
 
 	nv50_audio_component_fini(nouveau_drm(dev));
 
-	nvif_object_unmap(&disp->caps);
-	nvif_object_dtor(&disp->caps);
+	nvif_disp_caps_dtor(&disp->caps);
 	nv50_core_del(&disp->core);
 
 	nouveau_bo_unmap(disp->sync);
drivers/gpu/drm/nouveau/dispnv50/disp.h +1 -1
index 9485f8c90cac..39aaa385cd6a 100644
@@ -12,7 +12,7 @@ struct nouveau_encoder;
 struct nv50_disp {
 	struct nvif_disp *disp;
 	struct nv50_core *core;
-	struct nvif_object caps;
+	struct nvif_disp_caps caps;
 
 #define NV50_DISP_SYNC(c, o)                                ((c) * 0x040 + (o))
 #define NV50_DISP_CORE_NTFY                       NV50_DISP_SYNC(0      , 0x00)
drivers/gpu/drm/nouveau/include/nvif/disp.h +11 -0
index 06f56cc63893..b41ff8c091b1 100644
@@ -17,4 +17,15 @@ struct nvif_disp {
 
 int nvif_disp_ctor(struct nvif_device *, const char *name, struct nvif_disp *);
 void nvif_disp_dtor(struct nvif_disp *);
+
+struct nvif_disp_caps {
+	const struct nvif_disp_caps_impl *impl;
+	struct nvif_disp_caps_priv *priv;
+
+	struct nvif_object object;
+	struct nvif_map map;
+};
+
+int nvif_disp_caps_ctor(struct nvif_disp *, const char *name, struct nvif_disp_caps *);
+void nvif_disp_caps_dtor(struct nvif_disp_caps *);
 #endif
drivers/gpu/drm/nouveau/include/nvif/driverif.h +8 -0
index f96638ce4b12..412b2dff3a74 100644
@@ -11,6 +11,7 @@ struct nvif_mem_priv;
 struct nvif_vmm_priv;
 struct nvif_faultbuf_priv;
 struct nvif_disp_priv;
+struct nvif_disp_caps_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -217,11 +218,18 @@ struct nvif_faultbuf_impl {
 	} event;
 };
 
+struct nvif_disp_caps_impl {
+	void (*del)(struct nvif_disp_caps_priv *);
+	struct nvif_mapinfo map;
+};
+
 struct nvif_disp_impl {
 	void (*del)(struct nvif_disp_priv *);
 
 	struct {
 		u32 oclass;
+		int (*new)(struct nvif_disp_priv *,
+			   const struct nvif_disp_caps_impl **, struct nvif_disp_caps_priv **);
 	} caps;
 
 	struct {
drivers/gpu/drm/nouveau/nvif/disp.c +32 -0
index f3c425daf7d5..d2824e4d29f8 100644
@@ -25,6 +25,38 @@
 
 #include <nvif/class.h>
 
+void
+nvif_disp_caps_dtor(struct nvif_disp_caps *caps)
+{
+	if (!caps->impl)
+		return;
+
+	nvif_object_unmap_cpu(&caps->map);
+
+	caps->impl->del(caps->priv);
+	caps->impl = NULL;
+}
+
+int
+nvif_disp_caps_ctor(struct nvif_disp *disp, const char *name, struct nvif_disp_caps *caps)
+{
+	const u32 oclass = disp->impl->caps.oclass;
+	int ret;
+
+	ret = disp->impl->caps.new(disp->priv, &caps->impl, &caps->priv);
+	NVIF_ERRON(ret, &disp->object, "[NEW caps%04x]", oclass);
+	if (ret)
+		return ret;
+
+	nvif_object_ctor(&disp->object, name ?: "nvifDispCaps", 0, oclass, &caps->object);
+
+	ret = nvif_object_map_cpu(&caps->object, &caps->impl->map, &caps->map);
+	if (ret)
+		nvif_disp_caps_dtor(caps);
+
+	return ret;
+}
+
 void
 nvif_disp_dtor(struct nvif_disp *disp)
 {
drivers/gpu/drm/nouveau/nvkm/engine/disp/Kbuild +1 -0
index e346e924fee8..f0856423af91 100644
@@ -32,6 +32,7 @@ nvkm-y += nvkm/engine/disp/ad102.o
 nvkm-y += nvkm/engine/disp/r535.o
 
 nvkm-y += nvkm/engine/disp/udisp.o
+nvkm-y += nvkm/engine/disp/ucaps.o
 nvkm-y += nvkm/engine/disp/uconn.o
 nvkm-y += nvkm/engine/disp/uoutp.o
 nvkm-y += nvkm/engine/disp/uhead.o
drivers/gpu/drm/nouveau/nvkm/engine/disp/ad102.c +1 -1
index f818828e3f04..190aa0303fd3 100644
@@ -32,7 +32,7 @@ ad102_disp = {
 	.ramht_size = 0x2000,
 	.user = {
 		.root = { AD102_DISP },
-		.caps = { GV100_DISP_CAPS                  ,  gv100_disp_caps_new },
+		.caps = { GV100_DISP_CAPS                  ,  gv100_disp_caps },
 		.curs = { GA102_DISP_CURSOR                , &gv100_disp_curs },
 		.wimm = { GA102_DISP_WINDOW_IMM_CHANNEL_DMA, &gv100_disp_wimm },
 		.core = { AD102_DISP_CORE_CHANNEL_DMA      , &gv100_disp_core },
drivers/gpu/drm/nouveau/nvkm/engine/disp/ga102.c +1 -1
index c6b77e4d08a0..7712e6a5caac 100644
@@ -135,7 +135,7 @@ ga102_disp = {
 	.ramht_size = 0x2000,
 	.user = {
 		.root = { GA102_DISP },
-		.caps = { GV100_DISP_CAPS                  ,  gv100_disp_caps_new },
+		.caps = { GV100_DISP_CAPS                  ,  gv100_disp_caps },
 		.curs = { GA102_DISP_CURSOR                , &gv100_disp_curs },
 		.wimm = { GA102_DISP_WINDOW_IMM_CHANNEL_DMA, &gv100_disp_wimm },
 		.core = { GA102_DISP_CORE_CHANNEL_DMA      , &gv100_disp_core },
drivers/gpu/drm/nouveau/nvkm/engine/disp/gv100.c +5 -37

57 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h +2 -3
index 324a7971a0eb..822c4ffe5a38 100644
@@ -42,8 +42,7 @@ struct nvkm_disp_func {
 
 		struct {
 			s32 oclass;
-			int (*ctor)(const struct nvkm_oclass *, void *argv, u32 argc,
-				    struct nvkm_object **);
+			void (*addr)(struct nvkm_disp *, u64 *addr, u64 *size);
 		} caps;
 
 		struct nvkm_disp_func_chan {
@@ -76,7 +75,7 @@ void gv100_disp_fini(struct nvkm_disp *, bool suspend);
 void gv100_disp_intr(struct nvkm_disp *);
 void gv100_disp_super(struct work_struct *);
 int gv100_disp_wndw_cnt(struct nvkm_disp *, unsigned long *);
-int gv100_disp_caps_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
+void gv100_disp_caps(struct nvkm_disp *, u64 *addr, u64 *size);
 
 int tu102_disp_init(struct nvkm_disp *);
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c +1 -1
index 21b945a88823..6d0806da18ef 100644
@@ -221,7 +221,7 @@ tu102_disp = {
 	.ramht_size = 0x2000,
 	.user = {
 		.root = { TU102_DISP },
-		.caps = { GV100_DISP_CAPS                  ,  gv100_disp_caps_new },
+		.caps = { GV100_DISP_CAPS                  ,  gv100_disp_caps },
 		.curs = { TU102_DISP_CURSOR                , &gv100_disp_curs },
 		.wimm = { TU102_DISP_WINDOW_IMM_CHANNEL_DMA, &gv100_disp_wimm },
 		.core = { TU102_DISP_CORE_CHANNEL_DMA      , &gv100_disp_core },
drivers/gpu/drm/nouveau/nvkm/engine/disp/ucaps.c new file +70 -0

70 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/disp/ucaps.h new file +9 -0
new file mode 100644
index 000000000000..690a92930363
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_UCAPS_H__
+#define __NVKM_UCAPS_H__
+#include "priv.h"
+#include <nvif/driverif.h>
+
+int nvkm_ucaps_new(struct nvkm_disp *, const struct nvif_disp_caps_impl **,
+		   struct nvif_disp_caps_priv **, struct nvkm_object **);
+#endif
drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c +17 -6
index fd8590514c7e..cef8427cca91 100644
@@ -20,6 +20,7 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 #include "udisp.h"
+#include "ucaps.h"
 #include "chan.h"
 #include "conn.h"
 #include "head.h"
@@ -50,12 +51,6 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 		return 0;
 	}
 
-	if (disp->func->user.caps.oclass && index-- == 0) {
-		sclass->base = (struct nvkm_sclass) { -1, -1, disp->func->user.caps.oclass };
-		sclass->ctor = disp->func->user.caps.ctor;
-		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;
@@ -101,6 +96,21 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 	return -EINVAL;
 }
 
+static int
+nvkm_udisp_caps_new(struct nvif_disp_priv *udisp,
+		    const struct nvif_disp_caps_impl **pimpl, struct nvif_disp_caps_priv **ppriv)
+{
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_ucaps_new(udisp->disp, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	nvkm_object_link(&udisp->object, object);
+	return 0;
+}
+
 static void
 nvkm_udisp_del(struct nvif_disp_priv *udisp)
 {
@@ -173,6 +183,7 @@ nvkm_udisp_new(struct nvkm_device *device, const struct nvif_disp_impl **pimpl,
 
 	if (disp->func->user.caps.oclass) {
 		udisp->impl.caps.oclass = disp->func->user.caps.oclass;
+		udisp->impl.caps.new = nvkm_udisp_caps_new;
 	}
 
 	list_for_each_entry(conn, &disp->conns, head)
Signature · 1 line
2.41.0
author
#103 lore raw

PATCH 102/156 drm/nouveau/nvif: rework disp "new conn" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 drivers/gpu/drm/nouveau/include/nvif/conn.h   | 18 ++-----
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 20 +++++++
 drivers/gpu/drm/nouveau/include/nvif/if0011.h | 18 -------
 drivers/gpu/drm/nouveau/nouveau_connector.c   |  2 +-
 drivers/gpu/drm/nouveau/nvif/conn.c           | 32 +++---------
 .../gpu/drm/nouveau/nvkm/engine/disp/priv.h   |  1 -
 .../gpu/drm/nouveau/nvkm/engine/disp/uconn.c  | 52 ++++++++++++-------
 .../gpu/drm/nouveau/nvkm/engine/disp/uconn.h  |  3 ++
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.c  | 24 ++++++---
 9 files changed, 87 insertions(+), 83 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/conn.h +4 -14
index 406c12a111f9..0f0ca002fe47 100644
@@ -2,26 +2,16 @@
 #ifndef __NVIF_CONN_H__
 #define __NVIF_CONN_H__
 #include <nvif/object.h>
+#include <nvif/driverif.h>
 #include <nvif/event.h>
 struct nvif_disp;
 
 struct nvif_conn {
+	const struct nvif_conn_impl *impl;
+	struct nvif_conn_priv *priv;
 	struct nvif_object object;
-	u32 id;
 
-	struct {
-		enum {
-			NVIF_CONN_VGA,
-			NVIF_CONN_TV,
-			NVIF_CONN_DVI_I,
-			NVIF_CONN_DVI_D,
-			NVIF_CONN_LVDS,
-			NVIF_CONN_LVDS_SPWG,
-			NVIF_CONN_HDMI,
-			NVIF_CONN_DP,
-			NVIF_CONN_EDP,
-		} type;
-	} info;
+	u32 id;
 };
 
 int nvif_conn_ctor(struct nvif_disp *, const char *name, int id, struct nvif_conn *);
drivers/gpu/drm/nouveau/include/nvif/driverif.h +20 -0
index 412b2dff3a74..fb741c7293f6 100644
@@ -12,6 +12,7 @@ struct nvif_vmm_priv;
 struct nvif_faultbuf_priv;
 struct nvif_disp_priv;
 struct nvif_disp_caps_priv;
+struct nvif_conn_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -223,6 +224,22 @@ struct nvif_disp_caps_impl {
 	struct nvif_mapinfo map;
 };
 
+struct nvif_conn_impl {
+	void (*del)(struct nvif_conn_priv *);
+
+	enum nvif_conn_type {
+		NVIF_CONN_VGA,
+		NVIF_CONN_TV,
+		NVIF_CONN_DVI_I,
+		NVIF_CONN_DVI_D,
+		NVIF_CONN_HDMI,
+		NVIF_CONN_LVDS,
+		NVIF_CONN_LVDS_SPWG,
+		NVIF_CONN_DP,
+		NVIF_CONN_EDP,
+	} type;
+};
+
 struct nvif_disp_impl {
 	void (*del)(struct nvif_disp_priv *);
 
@@ -234,6 +251,9 @@ struct nvif_disp_impl {
 
 	struct {
 		u32 mask;
+		int (*new)(struct nvif_disp_priv *, u8 id,
+			   const struct nvif_conn_impl **, struct nvif_conn_priv **,
+			   u64 handle);
 	} conn;
 
 	struct {
drivers/gpu/drm/nouveau/include/nvif/if0011.h +0 -18
index 3ed0ddd75bd8..6e717445d10a 100644
@@ -2,24 +2,6 @@
 #ifndef __NVIF_IF0011_H__
 #define __NVIF_IF0011_H__
 
-union nvif_conn_args {
-	struct nvif_conn_v0 {
-		__u8 version;
-		__u8 id;	/* DCB connector table index. */
-		__u8 pad02[6];
-#define NVIF_CONN_V0_VGA       0x00
-#define NVIF_CONN_V0_TV        0x01
-#define NVIF_CONN_V0_DVI_I     0x02
-#define NVIF_CONN_V0_DVI_D     0x03
-#define NVIF_CONN_V0_LVDS      0x04
-#define NVIF_CONN_V0_LVDS_SPWG 0x05
-#define NVIF_CONN_V0_HDMI      0x06
-#define NVIF_CONN_V0_DP        0x07
-#define NVIF_CONN_V0_EDP       0x08
-		__u8 type;
-	} v0;
-};
-
 union nvif_conn_event_args {
 	struct nvif_conn_event_v0 {
 		__u8 version;
drivers/gpu/drm/nouveau/nouveau_connector.c +1 -1
index 856b3ef5edb8..b1bd8264b703 100644
@@ -1311,7 +1311,7 @@ nouveau_connector_create(struct drm_device *dev, int index)
 			return ERR_PTR(ret);
 		}
 
-		switch (nv_connector->conn.info.type) {
+		switch (nv_connector->conn.impl->type) {
 		case NVIF_CONN_VGA      : type = DCB_CONNECTOR_VGA; break;
 		case NVIF_CONN_DVI_I    : type = DCB_CONNECTOR_DVI_I; break;
 		case NVIF_CONN_DVI_D    : type = DCB_CONNECTOR_DVI_D; break;
drivers/gpu/drm/nouveau/nvif/conn.c +8 -24
index 9ee18cb99264..48927282a7ce 100644
@@ -23,7 +23,6 @@
 #include <nvif/disp.h>
 #include <nvif/printf.h>
 
-#include <nvif/class.h>
 #include <nvif/if0011.h>
 
 int
@@ -48,40 +47,25 @@ nvif_conn_event_ctor(struct nvif_conn *conn, const char *name, nvif_event_func f
 void
 nvif_conn_dtor(struct nvif_conn *conn)
 {
-	nvif_object_dtor(&conn->object);
+	if (!conn->impl)
+		return;
+
+	conn->impl->del(conn->priv);
+	conn->impl = NULL;
 }
 
 int
 nvif_conn_ctor(struct nvif_disp *disp, const char *name, int id, struct nvif_conn *conn)
 {
-	struct nvif_conn_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.id = id;
-
-	ret = nvif_object_ctor(&disp->object, name ?: "nvifConn", id, NVIF_CLASS_CONN,
-			       &args, sizeof(args), &conn->object);
+	ret = disp->impl->conn.new(disp->priv, id, &conn->impl, &conn->priv,
+				   nvif_handle(&conn->object));
 	NVIF_ERRON(ret, &disp->object, "[NEW conn id:%d]", id);
 	if (ret)
 		return ret;
 
+	nvif_object_ctor(&disp->object, name ?: "nvifConn", id, 0, &conn->object);
 	conn->id = id;
-
-	switch (args.type) {
-	case NVIF_CONN_V0_VGA      : conn->info.type = NVIF_CONN_VGA; break;
-	case NVIF_CONN_V0_TV       : conn->info.type = NVIF_CONN_TV; break;
-	case NVIF_CONN_V0_DVI_I    : conn->info.type = NVIF_CONN_DVI_I; break;
-	case NVIF_CONN_V0_DVI_D    : conn->info.type = NVIF_CONN_DVI_D; break;
-	case NVIF_CONN_V0_LVDS     : conn->info.type = NVIF_CONN_LVDS; break;
-	case NVIF_CONN_V0_LVDS_SPWG: conn->info.type = NVIF_CONN_LVDS_SPWG; break;
-	case NVIF_CONN_V0_HDMI     : conn->info.type = NVIF_CONN_HDMI; break;
-	case NVIF_CONN_V0_DP       : conn->info.type = NVIF_CONN_DP; break;
-	case NVIF_CONN_V0_EDP      : conn->info.type = NVIF_CONN_EDP; break;
-	default:
-		break;
-	}
-
 	return 0;
-
 }
drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h +0 -1
index 822c4ffe5a38..890cfb23da77 100644
@@ -89,7 +89,6 @@ 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_uconn_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
 int nvkm_uoutp_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
 int nvkm_uhead_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
 #endif
drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c +34 -18

99 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.h +3 -0
index f53d151e5b09..736d24951b12 100644
@@ -2,5 +2,8 @@
 #ifndef __NVKM_UCONN_H__
 #define __NVKM_UCONN_H__
 #include "conn.h"
+#include <nvif/driverif.h>
 
+int nvkm_uconn_new(struct nvkm_disp *, u8 id, const struct nvif_conn_impl **,
+		   struct nvif_conn_priv **, struct nvkm_object **);
 #endif
drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c +17 -7
index cef8427cca91..01333ded466b 100644
@@ -22,7 +22,7 @@
 #include "udisp.h"
 #include "ucaps.h"
 #include "chan.h"
-#include "conn.h"
+#include "uconn.h"
 #include "head.h"
 #include "outp.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_CONN };
-		sclass->ctor = nvkm_uconn_new;
-		return 0;
-	}
-
 	if (index-- == 0) {
 		sclass->base = (struct nvkm_sclass) { 0, 0, NVIF_CLASS_OUTP };
 		sclass->ctor = nvkm_uoutp_new;
@@ -96,6 +90,21 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 	return -EINVAL;
 }
 
+static int
+nvkm_udisp_conn_new(struct nvif_disp_priv *udisp, u8 id,
+		    const struct nvif_conn_impl **pimpl, struct nvif_conn_priv **ppriv,
+		    u64 handle)
+{
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_uconn_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_caps_new(struct nvif_disp_priv *udisp,
 		    const struct nvif_disp_caps_impl **pimpl, struct nvif_disp_caps_priv **ppriv)
@@ -123,6 +132,7 @@ nvkm_udisp_del(struct nvif_disp_priv *udisp)
 static const struct nvif_disp_impl
 nvkm_udisp_impl = {
 	.del = nvkm_udisp_del,
+	.conn.new = nvkm_udisp_conn_new,
 };
 
 static void *
Signature · 1 line
2.41.0
author
#104 lore raw

PATCH 103/156 drm/nouveau/nvif: rework conn "new event" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 drivers/gpu/drm/nouveau/include/nvif/conn.h   |  6 ---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  3 ++
 drivers/gpu/drm/nouveau/nvif/conn.c           | 22 ++++----
 .../gpu/drm/nouveau/nvkm/engine/disp/uconn.c  | 50 ++++++++-----------
 4 files changed, 35 insertions(+), 46 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/conn.h +0 -6
index 0f0ca002fe47..40c6424d82bf 100644
@@ -17,12 +17,6 @@ struct nvif_conn {
 int nvif_conn_ctor(struct nvif_disp *, const char *name, int id, struct nvif_conn *);
 void nvif_conn_dtor(struct nvif_conn *);
 
-static inline int
-nvif_conn_id(struct nvif_conn *conn)
-{
-	return conn->object.handle;
-}
-
 int nvif_conn_event_ctor(struct nvif_conn *, const char *name, nvif_event_func, u8 types,
 			 struct nvif_event *);
 #endif
drivers/gpu/drm/nouveau/include/nvif/driverif.h +3 -0
index fb741c7293f6..489f50d6ee00 100644
@@ -238,6 +238,9 @@ struct nvif_conn_impl {
 		NVIF_CONN_DP,
 		NVIF_CONN_EDP,
 	} type;
+
+	int (*event)(struct nvif_conn_priv *, u64 handle, u8 types,
+		     const struct nvif_event_impl **, struct nvif_event_priv **);
 };
 
 struct nvif_disp_impl {
drivers/gpu/drm/nouveau/nvif/conn.c +10 -12
index 48927282a7ce..d4e9f0275d1e 100644
@@ -23,25 +23,23 @@
 #include <nvif/disp.h>
 #include <nvif/printf.h>
 
-#include <nvif/if0011.h>
-
 int
 nvif_conn_event_ctor(struct nvif_conn *conn, const char *name, nvif_event_func func, u8 types,
 		     struct nvif_event *event)
 {
-	struct {
-		struct nvif_event_v0 base;
-		struct nvif_conn_event_v0 conn;
-	} args;
 	int ret;
 
-	args.conn.version = 0;
-	args.conn.types = types;
+	if (!conn->impl->event)
+		return -ENODEV;
 
-	ret = nvif_event_ctor_(&conn->object, name ?: "nvifConnHpd", nvif_conn_id(conn),
-			       func, true, &args.base, sizeof(args), false, event);
-	NVIF_DEBUG(&conn->object, "[NEW EVENT:HPD types:%02x]", types);
-	return ret;
+	ret = conn->impl->event(conn->priv, nvif_handle(&event->object), types,
+				&event->impl, &event->priv);
+	NVIF_ERRON(ret, &conn->object, "[NEW EVENT:HPD types:%02x]", types);
+	if (ret)
+		return ret;
+
+	nvif_event_ctor(&conn->object, name ?: "nvifConnHpd", conn->id, func, event);
+	return 0;
 }
 
 void
drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c +22 -28

92 lines not on this page · raw message

Signature · 1 line
2.41.0
author
#105 lore raw

PATCH 104/156 drm/nouveau/nvif: remove conn from object rb

In reply to Ben Skeggs

- no more users

---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h  | 3 +--
 drivers/gpu/drm/nouveau/nvif/conn.c              | 3 +--
 drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c | 6 +++---
 3 files changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +1 -2
index 489f50d6ee00..e59d2a4ec4d0 100644
@@ -255,8 +255,7 @@ struct nvif_disp_impl {
 	struct {
 		u32 mask;
 		int (*new)(struct nvif_disp_priv *, u8 id,
-			   const struct nvif_conn_impl **, struct nvif_conn_priv **,
-			   u64 handle);
+			   const struct nvif_conn_impl **, struct nvif_conn_priv **);
 	} conn;
 
 	struct {
drivers/gpu/drm/nouveau/nvif/conn.c +1 -2
index d4e9f0275d1e..8894f65d6028 100644
@@ -57,8 +57,7 @@ nvif_conn_ctor(struct nvif_disp *disp, const char *name, int id, struct nvif_con
 {
 	int ret;
 
-	ret = disp->impl->conn.new(disp->priv, id, &conn->impl, &conn->priv,
-				   nvif_handle(&conn->object));
+	ret = disp->impl->conn.new(disp->priv, id, &conn->impl, &conn->priv);
 	NVIF_ERRON(ret, &disp->object, "[NEW conn id:%d]", id);
 	if (ret)
 		return ret;
drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c +3 -3
index 01333ded466b..65e8b3fec655 100644
@@ -92,8 +92,7 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 
 static int
 nvkm_udisp_conn_new(struct nvif_disp_priv *udisp, u8 id,
-		    const struct nvif_conn_impl **pimpl, struct nvif_conn_priv **ppriv,
-		    u64 handle)
+		    const struct nvif_conn_impl **pimpl, struct nvif_conn_priv **ppriv)
 {
 	struct nvkm_object *object;
 	int ret;
@@ -102,7 +101,8 @@ nvkm_udisp_conn_new(struct nvif_disp_priv *udisp, u8 id,
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(udisp->object.client, &udisp->object, handle, object);
+	nvkm_object_link(&udisp->object, object);
+	return 0;
 }
 
 static int
Signature · 1 line
2.41.0
author
#106 lore raw

PATCH 105/156 drm/nouveau/nvif: rework disp "new outp" api

In reply to Ben Skeggs
---
 drivers/gpu/drm/nouveau/dispnv50/disp.c       | 40 ++++----
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 47 ++++++++++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 37 --------
 drivers/gpu/drm/nouveau/include/nvif/outp.h   | 43 +--------
 drivers/gpu/drm/nouveau/nvif/outp.c           | 59 ++----------
 .../gpu/drm/nouveau/nvkm/engine/disp/priv.h   |  1 -
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.c  | 24 +++--
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 92 +++++++++++--------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.h  |  3 +
 9 files changed, 152 insertions(+), 194 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/disp.c +20 -20
index 802dccace624..e2d71916326f 100644
@@ -1608,7 +1608,7 @@ nv50_sor_dp_watermark_sst(struct nouveau_encoder *outp,
 	u64 NumBlankingLinkClocks;
 	u32 MinHBlank;
 
-	if (outp->outp.info.dp.increased_wm) {
+	if (outp->outp.impl->dp.increased_wm) {
 		watermarkAdjust = DP_CONFIG_INCREASED_WATERMARK_ADJUST;
 		watermarkMinimum = DP_CONFIG_INCREASED_WATERMARK_LIMIT;
 	}
@@ -1822,7 +1822,7 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *sta
 	}
 
 	if (head->func->display_id)
-		head->func->display_id(head, BIT(nv_encoder->outp.id));
+		head->func->display_id(head, BIT(nv_encoder->outp.impl->id));
 
 	nv_encoder->update(nv_encoder, nv_crtc->index, asyh, proto, depth);
 }
@@ -1906,7 +1906,7 @@ nv50_sor_create(struct nouveau_encoder *nv_encoder)
 			nv_encoder->i2c = &nv_connector->aux.ddc;
 		}
 
-		if (nv_connector->type != DCB_CONNECTOR_eDP && nv_encoder->outp.info.dp.mst) {
+		if (nv_connector->type != DCB_CONNECTOR_eDP && nv_encoder->outp.impl->dp.mst) {
 			ret = nv50_mstm_new(nv_encoder, &nv_connector->aux,
 					    16, nv_connector->base.base.id,
 					    &nv_encoder->dp.mstm);
@@ -1914,7 +1914,7 @@ nv50_sor_create(struct nouveau_encoder *nv_encoder)
 				return ret;
 		}
 	} else
-	if (nv_encoder->outp.info.ddc != NVIF_OUTP_DDC_INVALID) {
+	if (nv_encoder->outp.impl->ddc != NVIF_OUTP_DDC_INVALID) {
 		struct nvkm_i2c_bus *bus =
 			nvkm_i2c_bus_find(i2c, dcbe->i2c_index);
 		if (bus)
@@ -2037,12 +2037,12 @@ nv50_pior_create(struct nouveau_encoder *nv_encoder)
 
 	switch (dcbe->type) {
 	case DCB_OUTPUT_TMDS:
-		bus  = nvkm_i2c_bus_find(i2c, nv_encoder->outp.info.ddc);
+		bus  = nvkm_i2c_bus_find(i2c, nv_encoder->outp.impl->ddc);
 		ddc  = bus ? &bus->i2c : NULL;
 		type = DRM_MODE_ENCODER_TMDS;
 		break;
 	case DCB_OUTPUT_DP:
-		aux  = nvkm_i2c_aux_find(i2c, nv_encoder->outp.info.dp.aux);
+		aux  = nvkm_i2c_aux_find(i2c, nv_encoder->outp.impl->dp.aux);
 		ddc  = aux ? &aux->i2c : NULL;
 		type = DRM_MODE_ENCODER_TMDS;
 		break;
@@ -2897,14 +2897,14 @@ nv50_display_create(struct drm_device *dev)
 			continue;
 		}
 
-		connector = nouveau_connector_create(dev, outp->outp.info.conn);
+		connector = nouveau_connector_create(dev, outp->outp.impl->conn);
 		if (IS_ERR(connector)) {
 			nvif_outp_dtor(&outp->outp);
 			kfree(outp);
 			continue;
 		}
 
-		outp->base.base.possible_crtcs = outp->outp.info.heads;
+		outp->base.base.possible_crtcs = outp->outp.impl->heads;
 		outp->base.base.possible_clones = 0;
 		outp->conn = nouveau_connector(connector);
 
@@ -2912,24 +2912,24 @@ nv50_display_create(struct drm_device *dev)
 		if (!outp->dcb)
 			break;
 
-		switch (outp->outp.info.proto) {
+		switch (outp->outp.impl->proto) {
 		case NVIF_OUTP_RGB_CRT:
 			outp->dcb->type = DCB_OUTPUT_ANALOG;
-			outp->dcb->crtconf.maxfreq = outp->outp.info.rgb_crt.freq_max;
+			outp->dcb->crtconf.maxfreq = outp->outp.impl->rgb_crt.freq_max;
 			break;
 		case NVIF_OUTP_TMDS:
 			outp->dcb->type = DCB_OUTPUT_TMDS;
-			outp->dcb->duallink_possible = outp->outp.info.tmds.dual;
+			outp->dcb->duallink_possible = outp->outp.impl->tmds.dual;
 			break;
 		case NVIF_OUTP_LVDS:
 			outp->dcb->type = DCB_OUTPUT_LVDS;
-			outp->dcb->lvdsconf.use_acpi_for_edid = outp->outp.info.lvds.acpi_edid;
+			outp->dcb->lvdsconf.use_acpi_for_edid = outp->outp.impl->lvds.acpi_edid;
 			break;
 		case NVIF_OUTP_DP:
 			outp->dcb->type = DCB_OUTPUT_DP;
-			outp->dcb->dpconf.link_nr = outp->outp.info.dp.link_nr;
-			outp->dcb->dpconf.link_bw = outp->outp.info.dp.link_bw;
-			if (outp->outp.info.dp.mst)
+			outp->dcb->dpconf.link_nr = outp->outp.impl->dp.link_nr;
+			outp->dcb->dpconf.link_bw = outp->outp.impl->dp.link_bw;
+			if (outp->outp.impl->dp.mst)
 				has_mst = true;
 			break;
 		default:
@@ -2937,11 +2937,11 @@ nv50_display_create(struct drm_device *dev)
 			continue;
 		}
 
-		outp->dcb->heads = outp->outp.info.heads;
-		outp->dcb->connector = outp->outp.info.conn;
-		outp->dcb->i2c_index = outp->outp.info.ddc;
+		outp->dcb->heads = outp->outp.impl->heads;
+		outp->dcb->connector = outp->outp.impl->conn;
+		outp->dcb->i2c_index = outp->outp.impl->ddc;
 
-		switch (outp->outp.info.type) {
+		switch (outp->outp.impl->type) {
 		case NVIF_OUTP_DAC : ret = nv50_dac_create(outp); break;
 		case NVIF_OUTP_SOR : ret = nv50_sor_create(outp); break;
 		case NVIF_OUTP_PIOR: ret = nv50_pior_create(outp); break;
@@ -2952,7 +2952,7 @@ nv50_display_create(struct drm_device *dev)
 
 		if (ret) {
 			NV_WARN(drm, "failed to create encoder %d/%d/%d: %d\n",
-				i, outp->outp.info.type, outp->outp.info.proto, ret);
+				i, outp->outp.impl->type, outp->outp.impl->proto, ret);
 		}
 	}
 
drivers/gpu/drm/nouveau/include/nvif/driverif.h +47 -0

65 lines not on this page · raw message

drivers/gpu/drm/nouveau/include/nvif/if0012.h +0 -37
index bde9bfae8d11..d1e2f0ff8965 100644
@@ -4,43 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-union nvif_outp_args {
-	struct nvif_outp_v0 {
-		__u8 version;
-		__u8 id;	/* DCB device index. */
-#define NVIF_OUTP_V0_TYPE_DAC  0x00
-#define NVIF_OUTP_V0_TYPE_SOR  0x01
-#define NVIF_OUTP_V0_TYPE_PIOR 0x02
-		__u8 type;
-#define NVIF_OUTP_V0_PROTO_RGB_CRT 0x00
-#define NVIF_OUTP_V0_PROTO_TMDS    0x01
-#define NVIF_OUTP_V0_PROTO_LVDS    0x02
-#define NVIF_OUTP_V0_PROTO_DP      0x03
-	        __u8 proto;
-	        __u8 heads;
-	        __u8 ddc;
-	        __u8 conn;
-		union {
-			struct {
-				__u32 freq_max;
-			} rgb_crt;
-			struct {
-				__u8  dual;
-			} tmds;
-			struct {
-				__u8  acpi_edid;
-			} lvds;
-			struct {
-				__u8  aux;
-				__u8  mst;
-				__u8  increased_wm;
-				__u8  link_nr;
-				__u32 link_bw;
-			} dp;
-		};
-	} v0;
-};
-
 #define NVIF_OUTP_V0_DETECT        0x00
 #define NVIF_OUTP_V0_EDID_GET      0x01
 
drivers/gpu/drm/nouveau/include/nvif/outp.h +3 -40

55 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvif/outp.c +8 -51

76 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h +0 -1
index 890cfb23da77..0163660f215d 100644
@@ -89,6 +89,5 @@ 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_uoutp_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
 int nvkm_uhead_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
 #endif
drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c +17 -7
index 65e8b3fec655..678121ab469f 100644
@@ -24,7 +24,7 @@
 #include "chan.h"
 #include "uconn.h"
 #include "head.h"
-#include "outp.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_OUTP };
-		sclass->ctor = nvkm_uoutp_new;
-		return 0;
-	}
-
 	if (index-- == 0) {
 		sclass->base = (struct nvkm_sclass) { 0, 0, NVIF_CLASS_HEAD };
 		sclass->ctor = nvkm_uhead_new;
@@ -90,6 +84,21 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 	return -EINVAL;
 }
 
+static int
+nvkm_udisp_outp_new(struct nvif_disp_priv *udisp, u8 id,
+		    const struct nvif_outp_impl **pimpl, struct nvif_outp_priv **ppriv,
+		    u64 handle)
+{
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_uoutp_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_conn_new(struct nvif_disp_priv *udisp, u8 id,
 		    const struct nvif_conn_impl **pimpl, struct nvif_conn_priv **ppriv)
@@ -133,6 +142,7 @@ static const struct nvif_disp_impl
 nvkm_udisp_impl = {
 	.del = nvkm_udisp_del,
 	.conn.new = nvkm_udisp_conn_new,
+	.outp.new = nvkm_udisp_outp_new,
 };
 
 static void *
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +54 -38

150 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.h +3 -0
index 37ecd2891a1a..3455aedd7bbe 100644
@@ -2,5 +2,8 @@
 #ifndef __NVKM_UOUTP_H__
 #define __NVKM_UOUTP_H__
 #include "outp.h"
+#include <nvif/driverif.h>
 
+int nvkm_uoutp_new(struct nvkm_disp *, u8 id, const struct nvif_outp_impl **,
+		   struct nvif_outp_priv **, struct nvkm_object **);
 #endif
Signature · 1 line
2.41.0
author
#107 lore raw

PATCH 106/156 drm/nouveau/nvif: rework outp "detect" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  8 ++++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 11 -----
 drivers/gpu/drm/nouveau/include/nvif/outp.h   |  6 ---
 drivers/gpu/drm/nouveau/nouveau_connector.c   |  6 +--
 drivers/gpu/drm/nouveau/nouveau_dp.c          |  2 +-
 drivers/gpu/drm/nouveau/nvif/outp.c           | 21 ++-------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 47 ++++++++++++++-----
 7 files changed, 53 insertions(+), 48 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +8 -0
index 8d00ed58323f..fd05065374fe 100644
@@ -244,6 +244,12 @@ struct nvif_conn_impl {
 		     const struct nvif_event_impl **, struct nvif_event_priv **);
 };
 
+enum nvif_outp_detect_status {
+	NVIF_OUTP_DETECT_NOT_PRESENT,
+	NVIF_OUTP_DETECT_PRESENT,
+	NVIF_OUTP_DETECT_UNKNOWN,
+};
+
 struct nvif_outp_impl {
 	void (*del)(struct nvif_outp_priv *);
 
@@ -267,6 +273,8 @@ struct nvif_outp_impl {
 	u8 ddc;
 	u8 conn;
 
+	int (*detect)(struct nvif_outp_priv *, enum nvif_outp_detect_status *);
+
 	struct {
 		u32 freq_max;
 	} rgb_crt;
drivers/gpu/drm/nouveau/include/nvif/if0012.h +0 -11
index d1e2f0ff8965..c0c13cb64994 100644
@@ -4,7 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_DETECT        0x00
 #define NVIF_OUTP_V0_EDID_GET      0x01
 
 #define NVIF_OUTP_V0_INHERIT       0x10
@@ -33,16 +32,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_detect_args {
-	struct nvif_outp_detect_v0 {
-		__u8 version;
-#define NVIF_OUTP_DETECT_V0_NOT_PRESENT 0x00
-#define NVIF_OUTP_DETECT_V0_PRESENT     0x01
-#define NVIF_OUTP_DETECT_V0_UNKNOWN     0x02
-		__u8 status;
-	} v0;
-};
-
 union nvif_outp_edid_get_args {
 	struct nvif_outp_edid_get_v0 {
 		__u8  version;
drivers/gpu/drm/nouveau/include/nvif/outp.h +0 -6
index 56bfbc41a576..7a64a7d2ac97 100644
@@ -21,12 +21,6 @@ struct nvif_outp {
 int nvif_outp_ctor(struct nvif_disp *, const char *name, int id, struct nvif_outp *);
 void nvif_outp_dtor(struct nvif_outp *);
 
-enum nvif_outp_detect_status {
-	NOT_PRESENT,
-	PRESENT,
-	UNKNOWN,
-};
-
 enum nvif_outp_detect_status nvif_outp_detect(struct nvif_outp *);
 int nvif_outp_edid_get(struct nvif_outp *, u8 **pedid);
 
drivers/gpu/drm/nouveau/nouveau_connector.c +3 -3
index b1bd8264b703..3063ef792023 100644
@@ -434,11 +434,11 @@ nouveau_connector_ddc_detect(struct drm_connector *connector)
 			} else {
 				status = nvif_outp_detect(&nv_encoder->outp);
 				switch (status) {
-				case PRESENT:
+				case NVIF_OUTP_DETECT_PRESENT:
 					return nv_encoder;
-				case NOT_PRESENT:
+				case NVIF_OUTP_DETECT_NOT_PRESENT:
 					continue;
-				case UNKNOWN:
+				case NVIF_OUTP_DETECT_UNKNOWN:
 					break;
 				default:
 					WARN_ON(1);
drivers/gpu/drm/nouveau/nouveau_dp.c +1 -1
index a72c45809484..cf196af96609 100644
@@ -256,7 +256,7 @@ nouveau_dp_detect(struct nouveau_connector *nv_connector,
 	}
 
 	hpd = nvif_outp_detect(&nv_encoder->outp);
-	if (hpd == NOT_PRESENT) {
+	if (hpd == NVIF_OUTP_DETECT_NOT_PRESENT) {
 		nvif_outp_dp_aux_pwr(&nv_encoder->outp, false);
 		goto out;
 	}
drivers/gpu/drm/nouveau/nvif/outp.c +5 -16
index a8012a71a50c..b704886c1bb6 100644
@@ -467,26 +467,15 @@ nvif_outp_edid_get(struct nvif_outp *outp, u8 **pedid)
 enum nvif_outp_detect_status
 nvif_outp_detect(struct nvif_outp *outp)
 {
-	struct nvif_outp_detect_v0 args;
+	enum nvif_outp_detect_status status;
 	int ret;
 
-	args.version = 0;
-
-	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_DETECT, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[DETECT] status:%02x", args.status);
+	ret = outp->impl->detect(outp->priv, &status);
+	NVIF_ERRON(ret, &outp->object, "[DETECT] status:%02x", status);
 	if (ret)
-		return UNKNOWN;
-
-	switch (args.status) {
-	case NVIF_OUTP_DETECT_V0_NOT_PRESENT: return NOT_PRESENT;
-	case NVIF_OUTP_DETECT_V0_PRESENT: return PRESENT;
-	case NVIF_OUTP_DETECT_V0_UNKNOWN: return UNKNOWN;
-	default:
-		WARN_ON(1);
-		break;
-	}
+		return NVIF_OUTP_DETECT_UNKNOWN;
 
-	return UNKNOWN;
+	return status;
 }
 
 void
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +36 -11

77 lines not on this page · raw message

Signature · 1 line
2.41.0
author
#108 lore raw

PATCH 107/156 drm/nouveau/nvif: rework outp "edid get" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  1 +
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 11 -----------
 drivers/gpu/drm/nouveau/nvif/outp.c           | 19 +++++++++----------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 19 +++++++++----------
 4 files changed, 19 insertions(+), 31 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +1 -0
index fd05065374fe..966a9bb543d1 100644
@@ -274,6 +274,7 @@ struct nvif_outp_impl {
 	u8 conn;
 
 	int (*detect)(struct nvif_outp_priv *, enum nvif_outp_detect_status *);
+	int (*edid_get)(struct nvif_outp_priv *, u8 *data, u16 *size);
 
 	struct {
 		u32 freq_max;
drivers/gpu/drm/nouveau/include/nvif/if0012.h +0 -11
index c0c13cb64994..80c4da3e8aa5 100644
@@ -4,8 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_EDID_GET      0x01
-
 #define NVIF_OUTP_V0_INHERIT       0x10
 #define NVIF_OUTP_V0_ACQUIRE       0x11
 #define NVIF_OUTP_V0_RELEASE       0x12
@@ -32,15 +30,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_edid_get_args {
-	struct nvif_outp_edid_get_v0 {
-		__u8  version;
-		__u8  pad01;
-		__u16 size;
-		__u8  data[2048];
-	} v0;
-};
-
 union nvif_outp_load_detect_args {
 	struct nvif_outp_load_detect_v0 {
 		__u8  version;
drivers/gpu/drm/nouveau/nvif/outp.c +9 -10
index b704886c1bb6..56441763e3da 100644
@@ -438,29 +438,28 @@ nvif_outp_load_detect(struct nvif_outp *outp, u32 loadval)
 int
 nvif_outp_edid_get(struct nvif_outp *outp, u8 **pedid)
 {
-	struct nvif_outp_edid_get_v0 *args;
+	u16 size = 2048;
+	u8 *data;
 	int ret;
 
-	args = kmalloc(sizeof(*args), GFP_KERNEL);
-	if (!args)
+	data = kmalloc(size, GFP_KERNEL);
+	if (!data)
 		return -ENOMEM;
 
-	args->version = 0;
-
-	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_EDID_GET, args, sizeof(*args));
-	NVIF_ERRON(ret, &outp->object, "[EDID_GET] size:%d", args->size);
+	ret = outp->impl->edid_get(outp->priv, data, &size);
+	NVIF_ERRON(ret, &outp->object, "[EDID_GET] size:%d", size);
 	if (ret)
 		goto done;
 
-	*pedid = kmemdup(args->data, args->size, GFP_KERNEL);
+	*pedid = kmemdup(data, size, GFP_KERNEL);
 	if (!*pedid) {
 		ret = -ENOMEM;
 		goto done;
 	}
 
-	ret = args->size;
+	ret = size;
 done:
-	kfree(args);
+	kfree(data);
 	return ret;
 }
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +9 -10
index 2324549787b6..37521fa2cbfe 100644
@@ -491,17 +491,15 @@ nvkm_uoutp_mthd_load_detect(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_edid_get(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_edid_get(struct nvif_outp_priv *uoutp, u8 *data, u16 *size)
 {
-	union nvif_outp_edid_get_args *args = argv;
-
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (!outp->func->edid_get)
-		return -EINVAL;
+	struct nvkm_outp *outp = uoutp->outp;
+	int ret;
 
-	args->v0.size = ARRAY_SIZE(args->v0.data);
-	return outp->func->edid_get(outp, args->v0.data, &args->v0.size);
+	nvkm_uoutp_lock(uoutp);
+	ret = outp->func->edid_get(outp, data, size);
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
@@ -551,7 +549,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_EDID_GET   : return nvkm_uoutp_mthd_edid_get   (outp, argv, argc);
 	case NVIF_OUTP_V0_INHERIT    : return nvkm_uoutp_mthd_inherit    (outp, argv, argc);
 	case NVIF_OUTP_V0_ACQUIRE    : return nvkm_uoutp_mthd_acquire    (outp, argv, argc);
 	case NVIF_OUTP_V0_LOAD_DETECT: return nvkm_uoutp_mthd_load_detect(outp, argv, argc);
@@ -651,6 +648,8 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 
 	if (outp->func->detect)
 		uoutp->impl.detect = nvkm_uoutp_detect;
+	if (outp->func->edid_get)
+		uoutp->impl.edid_get = nvkm_uoutp_edid_get;
 
 	switch (outp->info.type) {
 	case DCB_OUTPUT_ANALOG:
Signature · 1 line
2.41.0
author
#109 lore raw

PATCH 108/156 drm/nouveau/nvif: rework outp "load detect" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h  |  2 ++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h    | 11 -----------
 drivers/gpu/drm/nouveau/nvif/outp.c              | 11 ++++-------
 drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c | 15 ++++++++-------
 4 files changed, 14 insertions(+), 25 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +2 -0
index 966a9bb543d1..39b0e8d002f8 100644
@@ -276,6 +276,8 @@ struct nvif_outp_impl {
 	int (*detect)(struct nvif_outp_priv *, enum nvif_outp_detect_status *);
 	int (*edid_get)(struct nvif_outp_priv *, u8 *data, u16 *size);
 
+	int (*load_detect)(struct nvif_outp_priv *, u32 loadval, u8 *load);
+
 	struct {
 		u32 freq_max;
 	} rgb_crt;
drivers/gpu/drm/nouveau/include/nvif/if0012.h +0 -11
index 80c4da3e8aa5..586b44fa8814 100644
@@ -8,8 +8,6 @@
 #define NVIF_OUTP_V0_ACQUIRE       0x11
 #define NVIF_OUTP_V0_RELEASE       0x12
 
-#define NVIF_OUTP_V0_LOAD_DETECT   0x20
-
 #define NVIF_OUTP_V0_BL_GET        0x30
 #define NVIF_OUTP_V0_BL_SET        0x31
 
@@ -30,15 +28,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_load_detect_args {
-	struct nvif_outp_load_detect_v0 {
-		__u8  version;
-		__u8  load;
-		__u8  pad02[2];
-		__u32 data; /*TODO: move vbios loadval parsing into nvkm */
-	} v0;
-};
-
 union nvif_outp_acquire_args {
 	struct nvif_outp_acquire_v0 {
 		__u8 version;
drivers/gpu/drm/nouveau/nvif/outp.c +4 -7
index 56441763e3da..59499eebc5ac 100644
@@ -424,15 +424,12 @@ nvif_outp_inherit_rgb_crt(struct nvif_outp *outp, u8 *proto_out)
 int
 nvif_outp_load_detect(struct nvif_outp *outp, u32 loadval)
 {
-	struct nvif_outp_load_detect_v0 args;
+	u8 load;
 	int ret;
 
-	args.version = 0;
-	args.data = loadval;
-
-	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_LOAD_DETECT, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[LOAD_DETECT data:%08x] load:%02x", args.data, args.load);
-	return ret < 0 ? ret : args.load;
+	ret = outp->impl->load_detect(outp->priv, loadval, &load);
+	NVIF_ERRON(ret, &outp->object, "[LOAD_DETECT data:%08x] load:%02x", loadval, load);
+	return ret < 0 ? ret : load;
 }
 
 int
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +8 -7
index 37521fa2cbfe..d3f69d6a10f3 100644
@@ -468,25 +468,25 @@ nvkm_uoutp_mthd_inherit(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_load_detect(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_load_detect(struct nvif_outp_priv *uoutp, u32 loadval, u8 *load)
 {
-	union nvif_outp_load_detect_args *args = argv;
+	struct nvkm_outp *outp = uoutp->outp;
 	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
+	nvkm_uoutp_lock(uoutp);
 
 	ret = nvkm_outp_acquire_or(outp, NVKM_OUTP_PRIV, false);
 	if (ret == 0) {
 		if (outp->ior->func->sense) {
-			ret = outp->ior->func->sense(outp->ior, args->v0.data);
-			args->v0.load = ret < 0 ? 0 : ret;
+			ret = outp->ior->func->sense(outp->ior, loadval);
+			*load = ret < 0 ? 0 : ret;
 		} else {
 			ret = -EINVAL;
 		}
 		nvkm_outp_release_or(outp, NVKM_OUTP_PRIV);
 	}
 
+	nvkm_uoutp_unlock(uoutp);
 	return ret;
 }
 
@@ -551,7 +551,6 @@ nvkm_uoutp_mthd_noacquire(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc
 	switch (mthd) {
 	case NVIF_OUTP_V0_INHERIT    : return nvkm_uoutp_mthd_inherit    (outp, argv, argc);
 	case NVIF_OUTP_V0_ACQUIRE    : return nvkm_uoutp_mthd_acquire    (outp, argv, argc);
-	case NVIF_OUTP_V0_LOAD_DETECT: return nvkm_uoutp_mthd_load_detect(outp, argv, argc);
 	case NVIF_OUTP_V0_BL_GET     : return nvkm_uoutp_mthd_bl_get     (outp, argv, argc);
 	case NVIF_OUTP_V0_BL_SET     : return nvkm_uoutp_mthd_bl_set     (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_AUX_PWR : return nvkm_uoutp_mthd_dp_aux_pwr (outp, argv, argc);
@@ -651,6 +650,8 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 	if (outp->func->edid_get)
 		uoutp->impl.edid_get = nvkm_uoutp_edid_get;
 
+	uoutp->impl.load_detect = nvkm_uoutp_load_detect;
+
 	switch (outp->info.type) {
 	case DCB_OUTPUT_ANALOG:
 		uoutp->impl.type = NVIF_OUTP_DAC;
Signature · 1 line
2.41.0
author
#110 lore raw

PATCH 109/156 drm/nouveau/nvif: rework outp "inherit" apis

In reply to Ben Skeggs

- transition from "ioctl" interfaces

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  3 ++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 23 ---------
 drivers/gpu/drm/nouveau/nvif/outp.c           | 40 +++++++--------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 50 +++++++++----------
 4 files changed, 45 insertions(+), 71 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +3 -0
index 39b0e8d002f8..9ab54de43ba3 100644
@@ -276,6 +276,9 @@ struct nvif_outp_impl {
 	int (*detect)(struct nvif_outp_priv *, enum nvif_outp_detect_status *);
 	int (*edid_get)(struct nvif_outp_priv *, u8 *data, u16 *size);
 
+	int (*inherit)(struct nvif_outp_priv *, enum nvif_outp_proto,
+		       u8 *or, u8 *link, u8 *head, u8 *proto_evo);
+
 	int (*load_detect)(struct nvif_outp_priv *, u32 loadval, u8 *load);
 
 	struct {
drivers/gpu/drm/nouveau/include/nvif/if0012.h +0 -23
index 586b44fa8814..09e2f61673a8 100644
@@ -4,7 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_INHERIT       0x10
 #define NVIF_OUTP_V0_ACQUIRE       0x11
 #define NVIF_OUTP_V0_RELEASE       0x12
 
@@ -46,28 +45,6 @@ union nvif_outp_acquire_args {
 	} v0;
 };
 
-union nvif_outp_inherit_args {
-	struct nvif_outp_inherit_v0 {
-		__u8 version;
-#define NVIF_OUTP_INHERIT_V0_RGB_CRT 0x00
-#define NVIF_OUTP_INHERIT_V0_TV      0x01
-#define NVIF_OUTP_INHERIT_V0_TMDS    0x02
-#define NVIF_OUTP_INHERIT_V0_LVDS    0x03
-#define NVIF_OUTP_INHERIT_V0_DP      0x04
-		// In/out. Input is one of the above values, output is the actual hw protocol
-		__u8 proto;
-		__u8 or;
-		__u8 link;
-		__u8 head;
-		union {
-			struct {
-				// TODO: Figure out padding, and whether we even want this field
-				__u8 hda;
-			} tmds;
-		};
-	} v0;
-};
-
 union nvif_outp_release_args {
 	struct nvif_outp_release_vn {
 	} vn;
drivers/gpu/drm/nouveau/nvif/outp.c +17 -23
index 59499eebc5ac..c98af48b4b33 100644
@@ -354,71 +354,65 @@ nvif_outp_acquire_dac(struct nvif_outp *outp)
 }
 
 static int
-nvif_outp_inherit(struct nvif_outp *outp,
-		  u8 proto,
-		  struct nvif_outp_inherit_v0 *args,
-		  u8 *proto_out)
+nvif_outp_inherit(struct nvif_outp *outp, enum nvif_outp_proto proto, u8 *head, u8 *proto_evo)
 {
+	u8 or, link;
 	int ret;
 
-	args->version = 0;
-	args->proto = proto;
-
-	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_INHERIT, args, sizeof(*args));
+	ret = outp->impl->inherit(outp->priv, proto, &or, &link, head, proto_evo);
 	if (ret)
 		return ret;
 
-	outp->or.id = args->or;
-	outp->or.link = args->link;
-	*proto_out = args->proto;
+	outp->or.id = or;
+	outp->or.link = link;
 	return 0;
 }
 
 int
 nvif_outp_inherit_lvds(struct nvif_outp *outp, u8 *proto_out)
 {
-	struct nvif_outp_inherit_v0 args;
+	u8 head;
 	int ret;
 
-	ret = nvif_outp_inherit(outp, NVIF_OUTP_INHERIT_V0_LVDS, &args, proto_out);
+	ret = nvif_outp_inherit(outp, NVIF_OUTP_LVDS, &head, proto_out);
 	NVIF_ERRON(ret && ret != -ENODEV, &outp->object, "[INHERIT proto:LVDS] ret:%d", ret);
-	return ret ?: args.head;
+	return ret ?: head;
 }
 
 int
 nvif_outp_inherit_tmds(struct nvif_outp *outp, u8 *proto_out)
 {
-	struct nvif_outp_inherit_v0 args;
+	u8 head;
 	int ret;
 
-	ret = nvif_outp_inherit(outp, NVIF_OUTP_INHERIT_V0_TMDS, &args, proto_out);
+	ret = nvif_outp_inherit(outp, NVIF_OUTP_TMDS, &head, proto_out);
 	NVIF_ERRON(ret && ret != -ENODEV, &outp->object, "[INHERIT proto:TMDS] ret:%d", ret);
-	return ret ?: args.head;
+	return ret ?: head;
 }
 
 int
 nvif_outp_inherit_dp(struct nvif_outp *outp, u8 *proto_out)
 {
-	struct nvif_outp_inherit_v0 args;
+	u8 head;
 	int ret;
 
-	ret = nvif_outp_inherit(outp, NVIF_OUTP_INHERIT_V0_DP, &args, proto_out);
+	ret = nvif_outp_inherit(outp, NVIF_OUTP_DP, &head, proto_out);
 	NVIF_ERRON(ret && ret != -ENODEV, &outp->object, "[INHERIT proto:DP] ret:%d", ret);
 
 	// TODO: Get current link info
 
-	return ret ?: args.head;
+	return ret ?: head;
 }
 
 int
 nvif_outp_inherit_rgb_crt(struct nvif_outp *outp, u8 *proto_out)
 {
-	struct nvif_outp_inherit_v0 args;
+	u8 head;
 	int ret;
 
-	ret = nvif_outp_inherit(outp, NVIF_OUTP_INHERIT_V0_RGB_CRT, &args, proto_out);
+	ret = nvif_outp_inherit(outp, NVIF_OUTP_RGB_CRT, &head, proto_out);
 	NVIF_ERRON(ret && ret != -ENODEV, &outp->object, "[INHERIT proto:RGB_CRT] ret:%d", ret);
-	return ret ?: args.head;
+	return ret ?: head;
 }
 
 int
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +25 -25

100 lines not on this page · raw message

Signature · 1 line
2.41.0
author
#111 lore raw

PATCH 110/156 drm/nouveau/nvif: rework outp "acquire" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  1 +
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 19 ----------
 drivers/gpu/drm/nouveau/nvif/outp.c           | 29 ++++++---------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 35 ++++++++++---------
 4 files changed, 31 insertions(+), 53 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +1 -0
index 9ab54de43ba3..a2e0423f76c2 100644
@@ -278,6 +278,7 @@ struct nvif_outp_impl {
 
 	int (*inherit)(struct nvif_outp_priv *, enum nvif_outp_proto,
 		       u8 *or, u8 *link, u8 *head, u8 *proto_evo);
+	int (*acquire)(struct nvif_outp_priv *, enum nvif_outp_type, bool hda, u8 *or, u8 *link);
 
 	int (*load_detect)(struct nvif_outp_priv *, u32 loadval, u8 *load);
 
drivers/gpu/drm/nouveau/include/nvif/if0012.h +0 -19
index 09e2f61673a8..3cbdb5fc4757 100644
@@ -4,7 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_ACQUIRE       0x11
 #define NVIF_OUTP_V0_RELEASE       0x12
 
 #define NVIF_OUTP_V0_BL_GET        0x30
@@ -27,24 +26,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_acquire_args {
-	struct nvif_outp_acquire_v0 {
-		__u8 version;
-#define NVIF_OUTP_ACQUIRE_V0_DAC  0x00
-#define NVIF_OUTP_ACQUIRE_V0_SOR  0x01
-#define NVIF_OUTP_ACQUIRE_V0_PIOR 0x02
-		__u8 type;
-		__u8 or;
-		__u8 link;
-		__u8 pad04[4];
-		union {
-			struct {
-				__u8 hda;
-			} sor;
-		};
-	} v0;
-};
-
 union nvif_outp_release_args {
 	struct nvif_outp_release_vn {
 	} vn;
drivers/gpu/drm/nouveau/nvif/outp.c +11 -18
index c98af48b4b33..ddcd2b9d69f3 100644
@@ -302,54 +302,47 @@ nvif_outp_release(struct nvif_outp *outp)
 }
 
 static inline int
-nvif_outp_acquire(struct nvif_outp *outp, u8 type, struct nvif_outp_acquire_v0 *args)
+nvif_outp_acquire(struct nvif_outp *outp, enum nvif_outp_type type, bool hda)
 {
+	u8 or, link;
 	int ret;
 
-	args->version = 0;
-	args->type = type;
-
-	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_ACQUIRE, args, sizeof(*args));
+	ret = outp->impl->acquire(outp->priv, type, hda, &or, &link);
 	if (ret)
 		return ret;
 
-	outp->or.id = args->or;
-	outp->or.link = args->link;
+	outp->or.id = or;
+	outp->or.link = link;
 	return 0;
 }
 
 int
 nvif_outp_acquire_pior(struct nvif_outp *outp)
 {
-	struct nvif_outp_acquire_v0 args;
 	int ret;
 
-	ret = nvif_outp_acquire(outp, NVIF_OUTP_ACQUIRE_V0_PIOR, &args);
-	NVIF_ERRON(ret, &outp->object, "[ACQUIRE PIOR] or:%d", args.or);
+	ret = nvif_outp_acquire(outp, NVIF_OUTP_PIOR, false);
+	NVIF_ERRON(ret, &outp->object, "[ACQUIRE PIOR] or:%d", outp->or.id);
 	return ret;
 }
 
 int
 nvif_outp_acquire_sor(struct nvif_outp *outp, bool hda)
 {
-	struct nvif_outp_acquire_v0 args;
 	int ret;
 
-	args.sor.hda = hda;
-
-	ret = nvif_outp_acquire(outp, NVIF_OUTP_ACQUIRE_V0_SOR, &args);
-	NVIF_ERRON(ret, &outp->object, "[ACQUIRE SOR] or:%d link:%d", args.or, args.link);
+	ret = nvif_outp_acquire(outp, NVIF_OUTP_SOR, hda);
+	NVIF_ERRON(ret, &outp->object, "[ACQUIRE SOR] or:%d link:%d", outp->or.id, outp->or.link);
 	return ret;
 }
 
 int
 nvif_outp_acquire_dac(struct nvif_outp *outp)
 {
-	struct nvif_outp_acquire_v0 args;
 	int ret;
 
-	ret = nvif_outp_acquire(outp, NVIF_OUTP_ACQUIRE_V0_DAC, &args);
-	NVIF_ERRON(ret, &outp->object, "[ACQUIRE DAC] or:%d", args.or);
+	ret = nvif_outp_acquire(outp, NVIF_OUTP_DAC, false);
+	NVIF_ERRON(ret, &outp->object, "[ACQUIRE DAC] or:%d", outp->or.id);
 	return ret;
 }
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +19 -16
index 3f242a03f77b..46ca915f0206 100644
@@ -373,35 +373,38 @@ nvkm_uoutp_mthd_release(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_acquire(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_acquire(struct nvif_outp_priv *uoutp, enum nvif_outp_type type, bool hda,
+		   u8 *or, u8 *link)
 {
-	union nvif_outp_acquire_args *args = argv;
+	struct nvkm_outp *outp = uoutp->outp;
 	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (outp->ior && args->v0.type <= NVIF_OUTP_ACQUIRE_V0_PIOR)
+	nvkm_uoutp_lock(uoutp);
+	if (outp->ior) {
+		nvkm_uoutp_unlock(uoutp);
 		return -EBUSY;
+	}
 
-	switch (args->v0.type) {
-	case NVIF_OUTP_ACQUIRE_V0_DAC:
-	case NVIF_OUTP_ACQUIRE_V0_PIOR:
+	switch (type) {
+	case NVIF_OUTP_DAC:
+	case NVIF_OUTP_PIOR:
 		ret = outp->func->acquire(outp, false);
 		break;
-	case NVIF_OUTP_ACQUIRE_V0_SOR:
-		ret = outp->func->acquire(outp, args->v0.sor.hda);
+	case NVIF_OUTP_SOR:
+		ret = outp->func->acquire(outp, hda);
 		break;
 	default:
 		ret = -EINVAL;
 		break;
 	}
 
-	if (ret)
-		return ret;
+	if (ret == 0) {
+		*or = outp->ior->id;
+		*link = outp->ior->asy.link;
+	}
 
-	args->v0.or = outp->ior->id;
-	args->v0.link = outp->ior->asy.link;
-	return 0;
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
@@ -549,7 +552,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_ACQUIRE    : return nvkm_uoutp_mthd_acquire    (outp, argv, argc);
 	case NVIF_OUTP_V0_BL_GET     : return nvkm_uoutp_mthd_bl_get     (outp, argv, argc);
 	case NVIF_OUTP_V0_BL_SET     : return nvkm_uoutp_mthd_bl_set     (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_AUX_PWR : return nvkm_uoutp_mthd_dp_aux_pwr (outp, argv, argc);
@@ -599,6 +601,7 @@ static const struct nvif_outp_impl
 nvkm_uoutp_impl = {
 	.del = nvkm_uoutp_del,
 	.inherit = nvkm_uoutp_inherit,
+	.acquire = nvkm_uoutp_acquire,
 };
 
 static void *
Signature · 1 line
2.41.0
author
#112 lore raw

PATCH 111/156 drm/nouveau/nvif: rework outp "release" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h  |  1 +
 drivers/gpu/drm/nouveau/include/nvif/if0012.h    |  7 -------
 drivers/gpu/drm/nouveau/nvif/outp.c              |  2 +-
 drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c | 15 ++++++++-------
 4 files changed, 10 insertions(+), 15 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +1 -0
index a2e0423f76c2..2b29ac64e5cd 100644
@@ -279,6 +279,7 @@ struct nvif_outp_impl {
 	int (*inherit)(struct nvif_outp_priv *, enum nvif_outp_proto,
 		       u8 *or, u8 *link, u8 *head, u8 *proto_evo);
 	int (*acquire)(struct nvif_outp_priv *, enum nvif_outp_type, bool hda, u8 *or, u8 *link);
+	int (*release)(struct nvif_outp_priv *);
 
 	int (*load_detect)(struct nvif_outp_priv *, u32 loadval, u8 *load);
 
drivers/gpu/drm/nouveau/include/nvif/if0012.h +0 -7
index 3cbdb5fc4757..1a8f0720c14a 100644
@@ -4,8 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_RELEASE       0x12
-
 #define NVIF_OUTP_V0_BL_GET        0x30
 #define NVIF_OUTP_V0_BL_SET        0x31
 
@@ -26,11 +24,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_release_args {
-	struct nvif_outp_release_vn {
-	} vn;
-};
-
 union nvif_outp_bl_get_args {
 	struct nvif_outp_bl_get_v0 {
 		__u8  version;
drivers/gpu/drm/nouveau/nvif/outp.c +1 -1
index ddcd2b9d69f3..efdcc1c28874 100644
@@ -296,7 +296,7 @@ nvif_outp_bl_get(struct nvif_outp *outp)
 void
 nvif_outp_release(struct nvif_outp *outp)
 {
-	int ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_RELEASE, NULL, 0);
+	int ret = outp->impl->release(outp->priv);
 	NVIF_ERRON(ret, &outp->object, "[RELEASE]");
 	outp->or.id = -1;
 }
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +8 -7
index 46ca915f0206..f5d3b3647dac 100644
@@ -359,16 +359,17 @@ nvkm_uoutp_mthd_bl_get(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_release(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_release(struct nvif_outp_priv *uoutp)
 {
-	union nvif_outp_release_args *args = argv;
+	struct nvkm_outp *outp = uoutp->outp;
+	int ret;
 
-	if (argc != sizeof(args->vn))
-		return -ENOSYS;
-	if (!outp->ior)
-		return -EINVAL;
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
 
 	outp->func->release(outp);
+	nvkm_uoutp_unlock(uoutp);
 	return 0;
 }
 
@@ -530,7 +531,6 @@ static int
 nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_RELEASE      : return nvkm_uoutp_mthd_release      (outp, argv, argc);
 	case NVIF_OUTP_V0_LVDS         : return nvkm_uoutp_mthd_lvds         (outp, argv, argc);
 	case NVIF_OUTP_V0_HDMI         : return nvkm_uoutp_mthd_hdmi         (outp, argv, argc);
 	case NVIF_OUTP_V0_INFOFRAME    : return nvkm_uoutp_mthd_infoframe    (outp, argv, argc);
@@ -602,6 +602,7 @@ nvkm_uoutp_impl = {
 	.del = nvkm_uoutp_del,
 	.inherit = nvkm_uoutp_inherit,
 	.acquire = nvkm_uoutp_acquire,
+	.release = nvkm_uoutp_release,
 };
 
 static void *
Signature · 1 line
2.41.0
author
#113 lore raw

PATCH 112/156 drm/nouveau/nvif: rework outp "bl get"/"bl set" apis

In reply to Ben Skeggs

- transition from "ioctl" interfaces

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  5 +++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 17 --------
 drivers/gpu/drm/nouveau/nvif/outp.c           | 18 +++-----
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 43 ++++++++-----------
 4 files changed, 29 insertions(+), 54 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +5 -0
index 2b29ac64e5cd..7c4e3df12a8e 100644
@@ -295,6 +295,11 @@ struct nvif_outp_impl {
 		u8 acpi_edid;
 	} lvds;
 
+	struct {
+		int (*get)(struct nvif_outp_priv *, u8 *level);
+		int (*set)(struct nvif_outp_priv *, u8 level);
+	} bl;
+
 	struct {
 		u8 aux;
 		u8 mst;
drivers/gpu/drm/nouveau/include/nvif/if0012.h +0 -17
index 1a8f0720c14a..0bdd8ddc65d3 100644
@@ -4,9 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_BL_GET        0x30
-#define NVIF_OUTP_V0_BL_SET        0x31
-
 #define NVIF_OUTP_V0_LVDS          0x40
 
 #define NVIF_OUTP_V0_HDMI          0x50
@@ -24,20 +21,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_bl_get_args {
-	struct nvif_outp_bl_get_v0 {
-		__u8  version;
-		__u8  level;
-	} v0;
-};
-
-union nvif_outp_bl_set_args {
-	struct nvif_outp_bl_set_v0 {
-		__u8  version;
-		__u8  level;
-	} v0;
-};
-
 union nvif_outp_lvds_args {
 	struct nvif_outp_lvds_v0 {
 		__u8  version;
drivers/gpu/drm/nouveau/nvif/outp.c +6 -12
index efdcc1c28874..7929dc896b6b 100644
@@ -269,28 +269,22 @@ nvif_outp_lvds(struct nvif_outp *outp, bool dual, bool bpc8)
 int
 nvif_outp_bl_set(struct nvif_outp *outp, int level)
 {
-	struct nvif_outp_bl_set_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.level = level;
-
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_BL_SET, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[BL_SET level:%d]", args.level);
+	ret = outp->impl->bl.set(outp->priv, level);
+	NVIF_ERRON(ret, &outp->object, "[BL_SET level:%d]", level);
 	return ret;
 }
 
 int
 nvif_outp_bl_get(struct nvif_outp *outp)
 {
-	struct nvif_outp_bl_get_v0 args;
+	u8 level;
 	int ret;
 
-	args.version = 0;
-
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_BL_GET, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[BL_GET level:%d]", args.level);
-	return ret ? ret : args.level;
+	ret = outp->impl->bl.get(outp->priv, &level);
+	NVIF_ERRON(ret, &outp->object, "[BL_GET level:%d]", level);
+	return ret ? ret : level;
 }
 
 void
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +18 -25

71 lines not on this page · raw message

Signature · 1 line
2.41.0
author
#114 lore raw

PATCH 113/156 drm/nouveau/nvif: rework outp "lvds config" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  2 ++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 10 ----------
 drivers/gpu/drm/nouveau/nvif/outp.c           |  9 ++-------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 19 ++++++++++---------
 4 files changed, 14 insertions(+), 26 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +2 -0
index 7c4e3df12a8e..1eec40976a70 100644
@@ -293,6 +293,8 @@ struct nvif_outp_impl {
 
 	struct {
 		u8 acpi_edid;
+
+		int (*config)(struct nvif_outp_priv *, bool dual, bool bpc8);
 	} lvds;
 
 	struct {
drivers/gpu/drm/nouveau/include/nvif/if0012.h +0 -10
index 0bdd8ddc65d3..d8c6e84cf5ae 100644
@@ -4,8 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_LVDS          0x40
-
 #define NVIF_OUTP_V0_HDMI          0x50
 
 #define NVIF_OUTP_V0_INFOFRAME     0x60
@@ -21,14 +19,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_lvds_args {
-	struct nvif_outp_lvds_v0 {
-		__u8  version;
-		__u8  dual;
-		__u8  bpc8;
-	} v0;
-};
-
 union nvif_outp_hdmi_args {
 	struct nvif_outp_hdmi_v0 {
 		__u8 version;
drivers/gpu/drm/nouveau/nvif/outp.c +2 -7
index 7929dc896b6b..edcb5598efac 100644
@@ -254,15 +254,10 @@ nvif_outp_hdmi(struct nvif_outp *outp, int head, bool enable, u8 max_ac_packet,
 int
 nvif_outp_lvds(struct nvif_outp *outp, bool dual, bool bpc8)
 {
-	struct nvif_outp_lvds_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.dual = dual;
-	args.bpc8 = bpc8;
-
-	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_LVDS, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[LVDS dual:%d 8bpc:%d]", args.dual, args.bpc8);
+	ret = outp->impl->lvds.config(outp->priv, dual, bpc8);
+	NVIF_ERRON(ret, &outp->object, "[LVDS dual:%d 8bpc:%d]", dual, bpc8);
 	return ret;
 }
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +10 -9
index 5483ca37ca0e..93de3990554e 100644
@@ -305,17 +305,18 @@ nvkm_uoutp_mthd_hdmi(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_lvds(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_lvds(struct nvif_outp_priv *uoutp, bool dual, bool bpc8)
 {
-	union nvif_outp_lvds_args *args = argv;
+	struct nvkm_outp *outp = uoutp->outp;
+	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (outp->info.type != DCB_OUTPUT_LVDS)
-		return -EINVAL;
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
 
-	outp->lvds.dual = !!args->v0.dual;
-	outp->lvds.bpc8 = !!args->v0.bpc8;
+	outp->lvds.dual = dual;
+	outp->lvds.bpc8 = bpc8;
+	nvkm_uoutp_unlock(uoutp);
 	return 0;
 }
 
@@ -521,7 +522,6 @@ static int
 nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_LVDS         : return nvkm_uoutp_mthd_lvds         (outp, argv, argc);
 	case NVIF_OUTP_V0_HDMI         : return nvkm_uoutp_mthd_hdmi         (outp, argv, argc);
 	case NVIF_OUTP_V0_INFOFRAME    : return nvkm_uoutp_mthd_infoframe    (outp, argv, argc);
 	case NVIF_OUTP_V0_HDA_ELD      : return nvkm_uoutp_mthd_hda_eld      (outp, argv, argc);
@@ -664,6 +664,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		uoutp->impl.type = NVIF_OUTP_SOR;
 		uoutp->impl.proto = NVIF_OUTP_LVDS;
 		uoutp->impl.lvds.acpi_edid = outp->info.lvdsconf.use_acpi_for_edid;
+		uoutp->impl.lvds.config = nvkm_uoutp_lvds;
 		break;
 	case DCB_OUTPUT_DP:
 		if (!outp->info.location) {
Signature · 1 line
2.41.0
author
#115 lore raw

PATCH 114/156 drm/nouveau/nvif: rework outp "hdmi config" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  6 +++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 16 -------
 drivers/gpu/drm/nouveau/nvif/outp.c           | 18 ++-----
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 47 ++++++++++++-------
 4 files changed, 39 insertions(+), 48 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +6 -0
index 1eec40976a70..6f1ec831b4d7 100644
@@ -291,6 +291,12 @@ struct nvif_outp_impl {
 		u8 dual;
 	} tmds;
 
+	struct {
+		int (*config)(struct nvif_outp_priv *, u8 head, bool enable, u8 max_ac_packet,
+			      u8 rekey, u32 khz, bool scdc, bool scdc_scrambling,
+			      bool scdc_low_rates);
+	} hdmi;
+
 	struct {
 		u8 acpi_edid;
 
drivers/gpu/drm/nouveau/include/nvif/if0012.h +0 -16
index d8c6e84cf5ae..c2a3af721116 100644
@@ -4,8 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_HDMI          0x50
-
 #define NVIF_OUTP_V0_INFOFRAME     0x60
 #define NVIF_OUTP_V0_HDA_ELD       0x61
 
@@ -19,20 +17,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_hdmi_args {
-	struct nvif_outp_hdmi_v0 {
-		__u8 version;
-		__u8 head;
-		__u8 enable;
-		__u8 max_ac_packet;
-		__u8 rekey;
-		__u8 scdc;
-		__u8 scdc_scrambling;
-		__u8 scdc_low_rates;
-		__u32 khz;
-	} v0;
-};
-
 union nvif_outp_infoframe_args {
 	struct nvif_outp_infoframe_v0 {
 		__u8 version;
drivers/gpu/drm/nouveau/nvif/outp.c +4 -14
index edcb5598efac..99a1e0073166 100644
@@ -229,25 +229,15 @@ int
 nvif_outp_hdmi(struct nvif_outp *outp, int head, bool enable, u8 max_ac_packet, u8 rekey,
 	       u32 khz, bool scdc, bool scdc_scrambling, bool scdc_low_rates)
 {
-	struct nvif_outp_hdmi_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.head = head;
-	args.enable = enable;
-	args.max_ac_packet = max_ac_packet;
-	args.rekey = rekey;
-	args.khz = khz;
-	args.scdc = scdc;
-	args.scdc_scrambling = scdc_scrambling;
-	args.scdc_low_rates = scdc_low_rates;
-
-	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_HDMI, &args, sizeof(args));
+	ret = outp->impl->hdmi.config(outp->priv, head, enable, max_ac_packet, rekey, khz,
+				      scdc, scdc_scrambling, scdc_low_rates);
 	NVIF_ERRON(ret, &outp->object,
 		   "[HDMI head:%d enable:%d max_ac_packet:%d rekey:%d khz:%d scdc:%d "
 		   "scdc_scrambling:%d scdc_low_rates:%d]",
-		   args.head, args.enable, args.max_ac_packet, args.rekey, args.khz,
-		   args.scdc, args.scdc_scrambling, args.scdc_low_rates);
+		   head, enable, max_ac_packet, rekey, khz,
+		   scdc, scdc_scrambling, scdc_low_rates);
 	return ret;
 }
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +29 -18

78 lines not on this page · raw message

Signature · 1 line
2.41.0
author
#116 lore raw

PATCH 115/156 drm/nouveau/nvif: rework outp "infoframe" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 drivers/gpu/drm/nouveau/dispnv50/disp.c       | 18 +++------
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  7 ++++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 13 -------
 drivers/gpu/drm/nouveau/include/nvif/outp.h   |  3 +-
 drivers/gpu/drm/nouveau/nvif/outp.c           |  7 ++--
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 38 +++++++++++--------
 6 files changed, 40 insertions(+), 46 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/disp.c +6 -12
index e2d71916326f..0bac0e813184 100644
@@ -755,10 +755,7 @@ nv50_hdmi_enable(struct drm_encoder *encoder, struct nouveau_crtc *nv_crtc,
 	union hdmi_infoframe infoframe = { 0 };
 	const u8 rekey = 56; /* binary driver, and tegra, constant */
 	u32 max_ac_packet;
-	struct {
-		struct nvif_outp_infoframe_v0 infoframe;
-		u8 data[17];
-	} args = { 0 };
+	u8 data[17] = {};
 	int ret, size;
 
 	max_ac_packet  = mode->htotal - mode->hdisplay;
@@ -795,29 +792,26 @@ nv50_hdmi_enable(struct drm_encoder *encoder, struct nouveau_crtc *nv_crtc,
 		return;
 
 	/* AVI InfoFrame. */
-	args.infoframe.version = 0;
-	args.infoframe.head = nv_crtc->index;
-
 	if (!drm_hdmi_avi_infoframe_from_display_mode(&infoframe.avi, &nv_connector->base, mode)) {
 		drm_hdmi_avi_infoframe_quant_range(&infoframe.avi, &nv_connector->base, mode,
 						   HDMI_QUANTIZATION_RANGE_FULL);
 
-		size = hdmi_infoframe_pack(&infoframe, args.data, ARRAY_SIZE(args.data));
+		size = hdmi_infoframe_pack(&infoframe, data, ARRAY_SIZE(data));
 	} else {
 		size = 0;
 	}
 
-	nvif_outp_infoframe(&nv_encoder->outp, NVIF_OUTP_INFOFRAME_V0_AVI, &args.infoframe, size);
+	nvif_outp_infoframe(&nv_encoder->outp, nv_crtc->index, NVIF_OUTP_INFOFRAME_AVI, data, size);
 
 	/* Vendor InfoFrame. */
-	memset(&args.data, 0, sizeof(args.data));
+	memset(data, 0, sizeof(data));
 	if (!drm_hdmi_vendor_infoframe_from_display_mode(&infoframe.vendor.hdmi,
 							 &nv_connector->base, mode))
-		size = hdmi_infoframe_pack(&infoframe, args.data, ARRAY_SIZE(args.data));
+		size = hdmi_infoframe_pack(&infoframe, data, ARRAY_SIZE(data));
 	else
 		size = 0;
 
-	nvif_outp_infoframe(&nv_encoder->outp, NVIF_OUTP_INFOFRAME_V0_VSI, &args.infoframe, size);
+	nvif_outp_infoframe(&nv_encoder->outp, nv_crtc->index, NVIF_OUTP_INFOFRAME_VSI, data, size);
 
 	nv_encoder->hdmi.enabled = true;
 }
drivers/gpu/drm/nouveau/include/nvif/driverif.h +7 -0
index 6f1ec831b4d7..cef19e04f208 100644
@@ -244,6 +244,11 @@ struct nvif_conn_impl {
 		     const struct nvif_event_impl **, struct nvif_event_priv **);
 };
 
+enum nvif_outp_infoframe_type {
+	NVIF_OUTP_INFOFRAME_AVI,
+	NVIF_OUTP_INFOFRAME_VSI,
+};
+
 enum nvif_outp_detect_status {
 	NVIF_OUTP_DETECT_NOT_PRESENT,
 	NVIF_OUTP_DETECT_PRESENT,
@@ -295,6 +300,8 @@ struct nvif_outp_impl {
 		int (*config)(struct nvif_outp_priv *, u8 head, bool enable, u8 max_ac_packet,
 			      u8 rekey, u32 khz, bool scdc, bool scdc_scrambling,
 			      bool scdc_low_rates);
+		int (*infoframe)(struct nvif_outp_priv *, u8 head, enum nvif_outp_infoframe_type,
+				 u8 *data, u8 size);
 	} hdmi;
 
 	struct {
drivers/gpu/drm/nouveau/include/nvif/if0012.h +0 -13
index c2a3af721116..a045c66fc1ca 100644
@@ -4,7 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_INFOFRAME     0x60
 #define NVIF_OUTP_V0_HDA_ELD       0x61
 
 #define NVIF_OUTP_V0_DP_AUX_PWR    0x70
@@ -17,18 +16,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_infoframe_args {
-	struct nvif_outp_infoframe_v0 {
-		__u8 version;
-#define NVIF_OUTP_INFOFRAME_V0_AVI 0
-#define NVIF_OUTP_INFOFRAME_V0_VSI 1
-		__u8 type;
-		__u8 head;
-		__u8 pad03[5];
-		__u8 data[];
-	} v0;
-};
-
 union nvif_outp_hda_eld_args {
 	struct nvif_outp_hda_eld_v0 {
 		__u8  version;
drivers/gpu/drm/nouveau/include/nvif/outp.h +2 -1
index 7a64a7d2ac97..8be799c88aff 100644
@@ -49,7 +49,8 @@ int nvif_outp_lvds(struct nvif_outp *, bool dual, bool bpc8);
 int nvif_outp_hdmi(struct nvif_outp *, int head, bool enable, u8 max_ac_packet, u8 rekey, u32 khz,
 		   bool scdc, bool scdc_scrambling, bool scdc_low_rates);
 
-int nvif_outp_infoframe(struct nvif_outp *, u8 type, struct nvif_outp_infoframe_v0 *, u32 size);
+int nvif_outp_infoframe(struct nvif_outp *, int head, enum nvif_outp_infoframe_type,
+			u8 *data, u8 size);
 int nvif_outp_hda_eld(struct nvif_outp *, int head, void *data, u32 size);
 
 int nvif_outp_dp_aux_pwr(struct nvif_outp *, bool enable);
drivers/gpu/drm/nouveau/nvif/outp.c +3 -4
index 99a1e0073166..4ecdc44eb84a 100644
@@ -214,13 +214,12 @@ nvif_outp_hda_eld(struct nvif_outp *outp, int head, void *data, u32 size)
 }
 
 int
-nvif_outp_infoframe(struct nvif_outp *outp, u8 type, struct nvif_outp_infoframe_v0 *args, u32 size)
+nvif_outp_infoframe(struct nvif_outp *outp, int head, enum nvif_outp_infoframe_type type,
+		    u8 *data, u8 size)
 {
 	int ret;
 
-	args->type = type;
-
-	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_INFOFRAME, args, sizeof(*args) + size);
+	ret = outp->impl->hdmi.infoframe(outp->priv, head, type, data, size);
 	NVIF_ERRON(ret, &outp->object, "[INFOFRAME type:%d size:%d]", type, size);
 	return ret;
 }
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +22 -16
index 325af91075ab..a694a43fd495 100644
@@ -245,29 +245,35 @@ nvkm_uoutp_mthd_hda_eld(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_infoframe(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_infoframe(struct nvif_outp_priv *uoutp, u8 head,
+		     enum nvif_outp_infoframe_type type, u8 *data, u8 size)
 {
-	struct nvkm_ior *ior = outp->ior;
-	union nvif_outp_infoframe_args *args = argv;
-	ssize_t size = argc - sizeof(*args);
+	struct nvkm_ior *ior;
+	int ret;
 
-	if (argc < sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (!nvkm_head_find(outp->disp, args->v0.head))
+	if (!nvkm_head_find(uoutp->outp->disp, head))
 		return -EINVAL;
 
-	switch (ior->func->hdmi ? args->v0.type : 0xff) {
-	case NVIF_OUTP_INFOFRAME_V0_AVI:
-		ior->func->hdmi->infoframe_avi(ior, args->v0.head, &args->v0.data, size);
-		return 0;
-	case NVIF_OUTP_INFOFRAME_V0_VSI:
-		ior->func->hdmi->infoframe_vsi(ior, args->v0.head, &args->v0.data, size);
-		return 0;
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
+
+	ior = uoutp->outp->ior;
+
+	switch (ior->func->hdmi ? type : 0xff) {
+	case NVIF_OUTP_INFOFRAME_AVI:
+		ior->func->hdmi->infoframe_avi(ior, head, data, size);
+		break;
+	case NVIF_OUTP_INFOFRAME_VSI:
+		ior->func->hdmi->infoframe_vsi(ior, head, data, size);
+		break;
 	default:
+		ret = -EINVAL;
 		break;
 	}
 
-	return -EINVAL;
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
@@ -533,7 +539,6 @@ static int
 nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_INFOFRAME    : return nvkm_uoutp_mthd_infoframe    (outp, argv, argc);
 	case NVIF_OUTP_V0_HDA_ELD      : return nvkm_uoutp_mthd_hda_eld      (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_TRAIN     : return nvkm_uoutp_mthd_dp_train     (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_DRIVE     : return nvkm_uoutp_mthd_dp_drive     (outp, argv, argc);
@@ -670,6 +675,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		}
 		uoutp->impl.proto = NVIF_OUTP_TMDS;
 		uoutp->impl.hdmi.config = nvkm_uoutp_hdmi;
+		uoutp->impl.hdmi.infoframe = nvkm_uoutp_infoframe;
 		break;
 	case DCB_OUTPUT_LVDS:
 		uoutp->impl.type = NVIF_OUTP_SOR;
Signature · 1 line
2.41.0
author
#117 lore raw

PATCH 116/156 drm/nouveau/nvif: rework outp "hda eld" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  4 ++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 11 -----
 drivers/gpu/drm/nouveau/nvif/outp.c           | 13 +-----
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 45 +++++++++++--------
 4 files changed, 32 insertions(+), 41 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +4 -0
index cef19e04f208..742cf0e1678b 100644
@@ -304,6 +304,10 @@ struct nvif_outp_impl {
 				 u8 *data, u8 size);
 	} hdmi;
 
+	struct {
+		int (*eld)(struct nvif_outp_priv *, u8 head, u8 *data, u8 size);
+	} hda;
+
 	struct {
 		u8 acpi_edid;
 
drivers/gpu/drm/nouveau/include/nvif/if0012.h +0 -11
index a045c66fc1ca..160387dfc2a0 100644
@@ -4,8 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_HDA_ELD       0x61
-
 #define NVIF_OUTP_V0_DP_AUX_PWR    0x70
 #define NVIF_OUTP_V0_DP_AUX_XFER   0x71
 #define NVIF_OUTP_V0_DP_RATES      0x72
@@ -16,15 +14,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_hda_eld_args {
-	struct nvif_outp_hda_eld_v0 {
-		__u8  version;
-		__u8  head;
-		__u8  pad02[6];
-		__u8  data[];
-	} v0;
-};
-
 union nvif_outp_dp_aux_pwr_args {
 	struct nvif_outp_dp_aux_pwr_v0 {
 		__u8 version;
drivers/gpu/drm/nouveau/nvif/outp.c +1 -12
index 4ecdc44eb84a..cf79c56aae0c 100644
@@ -195,20 +195,9 @@ nvif_outp_dp_aux_pwr(struct nvif_outp *outp, bool enable)
 int
 nvif_outp_hda_eld(struct nvif_outp *outp, int head, void *data, u32 size)
 {
-	struct {
-		struct nvif_outp_hda_eld_v0 mthd;
-		u8 data[128];
-	} args;
 	int ret;
 
-	if (WARN_ON(size > ARRAY_SIZE(args.data)))
-		return -EINVAL;
-
-	args.mthd.version = 0;
-	args.mthd.head = head;
-
-	memcpy(args.data, data, size);
-	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_HDA_ELD, &args, sizeof(args.mthd) + size);
+	ret = outp->impl->hda.eld(outp->priv, head, data, size);
 	NVIF_ERRON(ret, &outp->object, "[HDA_ELD head:%d size:%d]", head, size);
 	return ret;
 }
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +27 -18

85 lines not on this page · raw message

Signature · 1 line
2.41.0
author
#118 lore raw

PATCH 117/156 drm/nouveau/nvif: rework outp "dp aux pwr" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h |  2 ++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h   |  9 ---------
 drivers/gpu/drm/nouveau/nvif/outp.c             |  8 ++------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c    | 17 ++++++++---------
 4 files changed, 12 insertions(+), 24 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +2 -0
index 742cf0e1678b..0dd85d4fa9ab 100644
@@ -325,6 +325,8 @@ struct nvif_outp_impl {
 		u8 increased_wm;
 		u8 link_nr;
 		u32 link_bw;
+
+		int (*aux_pwr)(struct nvif_outp_priv *, bool enable);
 	} dp;
 };
 
drivers/gpu/drm/nouveau/include/nvif/if0012.h +0 -9
index 160387dfc2a0..c0981a5f9e87 100644
@@ -4,7 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_DP_AUX_PWR    0x70
 #define NVIF_OUTP_V0_DP_AUX_XFER   0x71
 #define NVIF_OUTP_V0_DP_RATES      0x72
 #define NVIF_OUTP_V0_DP_TRAIN      0x73
@@ -14,14 +13,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_dp_aux_pwr_args {
-	struct nvif_outp_dp_aux_pwr_v0 {
-		__u8 version;
-		__u8 state;
-		__u8 pad02[6];
-	} v0;
-};
-
 union nvif_outp_dp_aux_xfer_args {
 	struct nvif_outp_dp_aux_xfer_v0 {
 		__u8  version;
drivers/gpu/drm/nouveau/nvif/outp.c +2 -6
index cf79c56aae0c..8b09a7ae9876 100644
@@ -181,14 +181,10 @@ nvif_outp_dp_aux_xfer(struct nvif_outp *outp, u8 type, u8 *psize, u32 addr, u8 *
 int
 nvif_outp_dp_aux_pwr(struct nvif_outp *outp, bool enable)
 {
-	struct nvif_outp_dp_aux_pwr_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.state = enable;
-
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_DP_AUX_PWR, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[DP_AUX_PWR state:%d]", args.state);
+	ret = outp->impl->dp.aux_pwr(outp->priv, enable);
+	NVIF_ERRON(ret, &outp->object, "[DP_AUX_PWR state:%d]", enable);
 	return ret;
 }
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +8 -9
index 7184f13f39f5..36b4ea9a10fd 100644
@@ -195,16 +195,15 @@ nvkm_uoutp_mthd_dp_aux_xfer(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_dp_aux_pwr(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_dp_aux_pwr(struct nvif_outp_priv *uoutp, bool enable)
 {
-	union nvif_outp_dp_aux_pwr_args *args = argv;
-
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (!outp->func->dp.aux_pwr)
-		return -EINVAL;
+	struct nvkm_outp *outp = uoutp->outp;
+	int ret;
 
-	return outp->func->dp.aux_pwr(outp, !!args->v0.state);
+	nvkm_uoutp_lock(uoutp);
+	ret = outp->func->dp.aux_pwr(outp, enable);
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
@@ -564,7 +563,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_PWR : return nvkm_uoutp_mthd_dp_aux_pwr (outp, argv, argc);
 	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:
@@ -705,6 +703,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		uoutp->impl.dp.increased_wm = outp->dp.increased_wm;
 		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;
 		break;
 	default:
 		WARN_ON(1);
Signature · 1 line
2.41.0
author
#119 lore raw

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

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../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(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +1 -0
index 0dd85d4fa9ab..2069eedde843 100644
@@ -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;
 };
 
drivers/gpu/drm/nouveau/include/nvif/if0012.h +0 -12
index c0981a5f9e87..b036197aadea 100644
@@ -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;
drivers/gpu/drm/nouveau/nvif/outp.c +3 -11
index 8b09a7ae9876..602362aa0203 100644
@@ -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;
 }
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +8 -10
index 36b4ea9a10fd..f7226bcb9ef4 100644
@@ -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);
Signature · 1 line
2.41.0
author
#120 lore raw

PATCH 119/156 drm/nouveau/nvif: rework outp "dp rates" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  6 +++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 13 -------
 drivers/gpu/drm/nouveau/include/nvif/outp.h   |  5 ---
 drivers/gpu/drm/nouveau/nvif/outp.c           | 17 ++------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 39 ++++++-------------
 5 files changed, 20 insertions(+), 60 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +6 -0
index 2069eedde843..9395ddad65bf 100644
@@ -255,6 +255,11 @@ enum nvif_outp_detect_status {
 	NVIF_OUTP_DETECT_UNKNOWN,
 };
 
+struct nvif_outp_dp_rate {
+	int dpcd; /* -1 for non-indexed rates */
+	u32 rate;
+};
+
 struct nvif_outp_impl {
 	void (*del)(struct nvif_outp_priv *);
 
@@ -328,6 +333,7 @@ struct nvif_outp_impl {
 
 		int (*aux_pwr)(struct nvif_outp_priv *, bool enable);
 		int (*aux_xfer)(struct nvif_outp_priv *, u8 type, u32 addr, u8 *data, u8 *size);
+		int (*rates)(struct nvif_outp_priv *, struct nvif_outp_dp_rate *, u8 rates);
 	} dp;
 };
 
drivers/gpu/drm/nouveau/include/nvif/if0012.h +0 -13
index b036197aadea..327ff9aa3ae0 100644
@@ -4,7 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_DP_RATES      0x72
 #define NVIF_OUTP_V0_DP_TRAIN      0x73
 #define NVIF_OUTP_V0_DP_DRIVE      0x74
 #define NVIF_OUTP_V0_DP_SST        0x75
@@ -12,18 +11,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_dp_rates_args {
-	struct nvif_outp_dp_rates_v0 {
-		__u8  version;
-		__u8  pad01[6];
-		__u8  rates;
-		struct {
-			__s8  dpcd;
-			__u32 rate;
-		} rate[8];
-	} v0;
-};
-
 union nvif_outp_dp_train_args {
 	struct nvif_outp_dp_train_v0 {
 		__u8  version;
drivers/gpu/drm/nouveau/include/nvif/outp.h +0 -5
index 8be799c88aff..7f7620ec1487 100644
@@ -56,11 +56,6 @@ int nvif_outp_hda_eld(struct nvif_outp *, int head, void *data, u32 size);
 int nvif_outp_dp_aux_pwr(struct nvif_outp *, bool enable);
 int nvif_outp_dp_aux_xfer(struct nvif_outp *, u8 type, u8 *size, u32 addr, u8 *data);
 
-struct nvif_outp_dp_rate {
-	int dpcd; /* -1 for non-indexed rates */
-	u32 rate;
-};
-
 int nvif_outp_dp_rates(struct nvif_outp *, struct nvif_outp_dp_rate *rate, int rate_nr);
 int nvif_outp_dp_train(struct nvif_outp *, u8 dpcd[DP_RECEIVER_CAP_SIZE],
 		       u8 lttprs, u8 link_nr, u32 link_bw, bool mst, bool post_lt_adj,
drivers/gpu/drm/nouveau/nvif/outp.c +3 -14
index 602362aa0203..68af891505d1 100644
@@ -134,23 +134,12 @@ nvif_outp_dp_train(struct nvif_outp *outp, u8 dpcd[DP_RECEIVER_CAP_SIZE], u8 ltt
 }
 
 int
-nvif_outp_dp_rates(struct nvif_outp *outp, struct nvif_outp_dp_rate *rate, int rate_nr)
+nvif_outp_dp_rates(struct nvif_outp *outp, struct nvif_outp_dp_rate *rate, int rates)
 {
-	struct nvif_outp_dp_rates_v0 args;
 	int ret;
 
-	if (rate_nr > ARRAY_SIZE(args.rate))
-		return -EINVAL;
-
-	args.version = 0;
-	args.rates = rate_nr;
-	for (int i = 0; i < args.rates; i++, rate++) {
-		args.rate[i].dpcd = rate->dpcd;
-		args.rate[i].rate = rate->rate;
-	}
-
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_DP_RATES, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[DP_RATES rates:%d]", args.rates);
+	ret = outp->impl->dp.rates(outp->priv, rate, rates);
+	NVIF_ERRON(ret, &outp->object, "[DP_RATES rates:%d]", rates);
 	return ret;
 }
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +11 -28
index f7226bcb9ef4..00b66d400f68 100644
@@ -158,25 +158,26 @@ nvkm_uoutp_mthd_dp_train(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_dp_rates(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_dp_rates(struct nvif_outp_priv *uoutp, struct nvif_outp_dp_rate *rate, u8 rates)
 {
-	union nvif_outp_dp_rates_args *args = argv;
+	struct nvkm_outp *outp = uoutp->outp;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (args->v0.rates > ARRAY_SIZE(outp->dp.rate))
+	if (rates > ARRAY_SIZE(outp->dp.rate))
 		return -EINVAL;
 
-	for (int i = 0; i < args->v0.rates; i++) {
-		outp->dp.rate[i].dpcd = args->v0.rate[i].dpcd;
-		outp->dp.rate[i].rate = args->v0.rate[i].rate;
+	nvkm_uoutp_lock(uoutp);
+
+	for (int i = 0; i < rates; i++) {
+		outp->dp.rate[i].dpcd = rate[i].dpcd;
+		outp->dp.rate[i].rate = rate[i].rate;
 	}
 
-	outp->dp.rates = args->v0.rates;
+	outp->dp.rates = rates;
 
 	if (outp->func->dp.rates)
 		outp->func->dp.rates(outp);
 
+	nvkm_uoutp_unlock(uoutp);
 	return 0;
 }
 
@@ -557,39 +558,20 @@ nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
 	return -EINVAL;
 }
 
-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_RATES   : return nvkm_uoutp_mthd_dp_rates   (outp, argv, argc);
-	default:
-		break;
-	}
-
-	*invalid = true;
-	return 0;
-}
-
 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;
-	bool invalid = false;
 	int ret;
 
 	mutex_lock(&disp->super.mutex);
 
-	ret = nvkm_uoutp_mthd_noacquire(outp, mthd, argv, argc, &invalid);
-	if (!invalid)
-		goto done;
-
 	if (outp->ior)
 		ret = nvkm_uoutp_mthd_acquired(outp, mthd, argv, argc);
 	else
 		ret = -EIO;
 
-done:
 	mutex_unlock(&disp->super.mutex);
 	return ret;
 }
@@ -702,6 +684,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		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;
+		uoutp->impl.dp.rates = nvkm_uoutp_dp_rates;
 		break;
 	default:
 		WARN_ON(1);
Signature · 1 line
2.41.0
author
#121 lore raw

PATCH 120/156 drm/nouveau/nvif: rework outp "dp train" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  4 +++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 14 --------
 drivers/gpu/drm/nouveau/nvif/outp.c           | 16 ++-------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 33 ++++++++++---------
 4 files changed, 25 insertions(+), 42 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +4 -0
index 9395ddad65bf..2660f37c5443 100644
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: MIT */
 #ifndef __NVIF_DRIVERIF_H__
 #define __NVIF_DRIVERIF_H__
+#include <drm/display/drm_dp.h>
+
 struct nvif_event_priv;
 struct nvif_client_priv;
 struct nvif_device_priv;
@@ -334,6 +336,8 @@ struct nvif_outp_impl {
 		int (*aux_pwr)(struct nvif_outp_priv *, bool enable);
 		int (*aux_xfer)(struct nvif_outp_priv *, u8 type, u32 addr, u8 *data, u8 *size);
 		int (*rates)(struct nvif_outp_priv *, struct nvif_outp_dp_rate *, u8 rates);
+		int (*train)(struct nvif_outp_priv *, u8 dpcd[DP_RECEIVER_CAP_SIZE], u8 lttprs,
+			     u8 link_nr, u32 link_bw, bool mst, bool post_lt_adj, bool retrain);
 	} dp;
 };
 
drivers/gpu/drm/nouveau/include/nvif/if0012.h +0 -14
index 327ff9aa3ae0..5db1f718e82c 100644
@@ -4,26 +4,12 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_DP_TRAIN      0x73
 #define NVIF_OUTP_V0_DP_DRIVE      0x74
 #define NVIF_OUTP_V0_DP_SST        0x75
 #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_train_args {
-	struct nvif_outp_dp_train_v0 {
-		__u8  version;
-		__u8  retrain;
-		__u8  mst;
-		__u8  lttprs;
-		__u8  post_lt_adj;
-		__u8  link_nr;
-		__u32 link_bw;
-		__u8 dpcd[DP_RECEIVER_CAP_SIZE];
-	} v0;
-};
-
 union nvif_outp_dp_drive_args {
 	struct nvif_outp_dp_drive_v0 {
 		__u8  version;
drivers/gpu/drm/nouveau/nvif/outp.c +3 -13
index 68af891505d1..f20846a7f487 100644
@@ -113,23 +113,13 @@ int
 nvif_outp_dp_train(struct nvif_outp *outp, u8 dpcd[DP_RECEIVER_CAP_SIZE], u8 lttprs,
 		   u8 link_nr, u32 link_bw, bool mst, bool post_lt_adj, bool retrain)
 {
-	struct nvif_outp_dp_train_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.retrain = retrain;
-	args.mst = mst;
-	args.lttprs = lttprs;
-	args.post_lt_adj = post_lt_adj;
-	args.link_nr = link_nr;
-	args.link_bw = link_bw;
-	memcpy(args.dpcd, dpcd, sizeof(args.dpcd));
-
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_DP_TRAIN, &args, sizeof(args));
+	ret = outp->impl->dp.train(outp->priv, dpcd, lttprs, link_nr, link_bw, mst,
+				   post_lt_adj, retrain);
 	NVIF_ERRON(ret, &outp->object,
 		   "[DP_TRAIN retrain:%d mst:%d lttprs:%d post_lt_adj:%d nr:%d bw:%d]",
-		   args.retrain, args.mst, args.lttprs, args.post_lt_adj, args.link_nr,
-		   args.link_bw);
+		   retrain, mst, lttprs, post_lt_adj, link_nr, link_bw);
 	return ret;
 }
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +18 -15
index 00b66d400f68..673c8c10c782 100644
@@ -136,25 +136,28 @@ nvkm_uoutp_mthd_dp_drive(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_dp_train(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_dp_train(struct nvif_outp_priv *uoutp, u8 dpcd[DP_RECEIVER_CAP_SIZE], u8 lttprs,
+		    u8 link_nr, u32 link_bw, bool mst, bool post_lt_adj, bool retrain)
 {
-	union nvif_outp_dp_train_args *args = argv;
+	struct nvkm_outp *outp = uoutp->outp;
+	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (!outp->func->dp.train)
-		return -EINVAL;
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
 
-	if (!args->v0.retrain) {
-		memcpy(outp->dp.dpcd, args->v0.dpcd, sizeof(outp->dp.dpcd));
-		outp->dp.lttprs = args->v0.lttprs;
-		outp->dp.lt.nr = args->v0.link_nr;
-		outp->dp.lt.bw = args->v0.link_bw / 27000;
-		outp->dp.lt.mst = args->v0.mst;
-		outp->dp.lt.post_adj = args->v0.post_lt_adj;
+	if (!retrain) {
+		memcpy(outp->dp.dpcd, dpcd, sizeof(outp->dp.dpcd));
+		outp->dp.lttprs = lttprs;
+		outp->dp.lt.nr = link_nr;
+		outp->dp.lt.bw = link_bw / 27000;
+		outp->dp.lt.mst = mst;
+		outp->dp.lt.post_adj = post_lt_adj;
 	}
 
-	return outp->func->dp.train(outp, args->v0.retrain);
+	ret = outp->func->dp.train(outp, retrain);
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
@@ -545,7 +548,6 @@ static int
 nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_DP_TRAIN     : return nvkm_uoutp_mthd_dp_train     (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_DRIVE     : return nvkm_uoutp_mthd_dp_drive     (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_SST       : return nvkm_uoutp_mthd_dp_sst       (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_MST_ID_GET: return nvkm_uoutp_mthd_dp_mst_id_get(outp, argv, argc);
@@ -685,6 +687,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		uoutp->impl.dp.aux_pwr = nvkm_uoutp_dp_aux_pwr;
 		uoutp->impl.dp.aux_xfer = nvkm_uoutp_dp_aux_xfer;
 		uoutp->impl.dp.rates = nvkm_uoutp_dp_rates;
+		uoutp->impl.dp.train = nvkm_uoutp_dp_train;
 		break;
 	default:
 		WARN_ON(1);
Signature · 1 line
2.41.0
author
#122 lore raw

PATCH 121/156 drm/nouveau/nvif: rework outp "dp drive" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h    |  1 +
 drivers/gpu/drm/nouveau/include/nvif/if0012.h  | 13 -------------
 drivers/gpu/drm/nouveau/nvif/outp.c            | 12 +++---------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c   | 18 ++++++++++--------
 4 files changed, 14 insertions(+), 30 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +1 -0
index 2660f37c5443..db6fb1347b72 100644
@@ -338,6 +338,7 @@ struct nvif_outp_impl {
 		int (*rates)(struct nvif_outp_priv *, struct nvif_outp_dp_rate *, u8 rates);
 		int (*train)(struct nvif_outp_priv *, u8 dpcd[DP_RECEIVER_CAP_SIZE], u8 lttprs,
 			     u8 link_nr, u32 link_bw, bool mst, bool post_lt_adj, bool retrain);
+		int (*drive)(struct nvif_outp_priv *, u8 lanes, u8 pe[4], u8 vs[4]);
 	} dp;
 };
 
drivers/gpu/drm/nouveau/include/nvif/if0012.h +0 -13
index 5db1f718e82c..8b0f90327187 100644
@@ -2,24 +2,11 @@
 #ifndef __NVIF_IF0012_H__
 #define __NVIF_IF0012_H__
 
-#include <drm/display/drm_dp.h>
-
-#define NVIF_OUTP_V0_DP_DRIVE      0x74
 #define NVIF_OUTP_V0_DP_SST        0x75
 #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_drive_args {
-	struct nvif_outp_dp_drive_v0 {
-		__u8  version;
-		__u8  pad01[2];
-		__u8  lanes;
-		__u8  pe[4];
-		__u8  vs[4];
-	} v0;
-};
-
 union nvif_outp_dp_sst_args {
 	struct nvif_outp_dp_sst_v0 {
 		__u8  version;
drivers/gpu/drm/nouveau/nvif/outp.c +3 -9
index f20846a7f487..3d4461e3a2cd 100644
@@ -94,18 +94,12 @@ nvif_outp_dp_sst(struct nvif_outp *outp, int head, u32 watermark, u32 hblanksym,
 }
 
 int
-nvif_outp_dp_drive(struct nvif_outp *outp, u8 link_nr, u8 pe[4], u8 vs[4])
+nvif_outp_dp_drive(struct nvif_outp *outp, u8 lanes, u8 pe[4], u8 vs[4])
 {
-	struct nvif_outp_dp_drive_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.lanes   = link_nr;
-	memcpy(args.pe, pe, sizeof(args.pe));
-	memcpy(args.vs, vs, sizeof(args.vs));
-
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_DP_DRIVE, &args, sizeof(args));
-	NVIF_ERRON(ret, &outp->object, "[DP_DRIVE lanes:%d]", args.lanes);
+	ret = outp->impl->dp.drive(outp->priv, lanes, pe, vs);
+	NVIF_ERRON(ret, &outp->object, "[DP_DRIVE lanes:%d]", lanes);
 	return ret;
 }
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +10 -8
index 673c8c10c782..3d5b6cee97bc 100644
@@ -123,16 +123,18 @@ nvkm_uoutp_mthd_dp_sst(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_dp_drive(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_dp_drive(struct nvif_outp_priv *uoutp, u8 lanes, u8 pe[4], u8 vs[4])
 {
-	union nvif_outp_dp_drive_args *args = argv;
+	struct nvkm_outp *outp;
+	int ret;
 
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (!outp->func->dp.drive)
-		return -EINVAL;
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
 
-	return outp->func->dp.drive(outp, args->v0.lanes, args->v0.pe, args->v0.vs);
+	ret = outp->func->dp.drive(outp, lanes, pe, vs);
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
@@ -548,7 +550,6 @@ static int
 nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_DP_DRIVE     : return nvkm_uoutp_mthd_dp_drive     (outp, argv, argc);
 	case NVIF_OUTP_V0_DP_SST       : return nvkm_uoutp_mthd_dp_sst       (outp, argv, argc);
 	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);
@@ -688,6 +689,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		uoutp->impl.dp.aux_xfer = nvkm_uoutp_dp_aux_xfer;
 		uoutp->impl.dp.rates = nvkm_uoutp_dp_rates;
 		uoutp->impl.dp.train = nvkm_uoutp_dp_train;
+		uoutp->impl.dp.drive = nvkm_uoutp_dp_drive;
 		break;
 	default:
 		WARN_ON(1);
Signature · 1 line
2.41.0
author
#123 lore raw

PATCH 122/156 drm/nouveau/nvif: rework outp "dp sst" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  2 ++
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 12 -------
 drivers/gpu/drm/nouveau/nvif/outp.c           | 10 ++----
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 34 ++++++++++++-------
 4 files changed, 25 insertions(+), 33 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +2 -0
index db6fb1347b72..dc103d2a20a9 100644
@@ -339,6 +339,8 @@ struct nvif_outp_impl {
 		int (*train)(struct nvif_outp_priv *, u8 dpcd[DP_RECEIVER_CAP_SIZE], u8 lttprs,
 			     u8 link_nr, u32 link_bw, bool mst, bool post_lt_adj, bool retrain);
 		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);
 	} dp;
 };
 
drivers/gpu/drm/nouveau/include/nvif/if0012.h +0 -12
index 8b0f90327187..92c4988101eb 100644
@@ -2,22 +2,10 @@
 #ifndef __NVIF_IF0012_H__
 #define __NVIF_IF0012_H__
 
-#define NVIF_OUTP_V0_DP_SST        0x75
 #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_sst_args {
-	struct nvif_outp_dp_sst_v0 {
-		__u8  version;
-		__u8  head;
-		__u8  pad02[2];
-		__u32 watermark;
-		__u32 hblanksym;
-		__u32 vblanksym;
-	} v0;
-};
-
 union nvif_outp_dp_mst_id_put_args {
 	struct nvif_outp_dp_mst_id_put_v0 {
 		__u8  version;
drivers/gpu/drm/nouveau/nvif/outp.c +2 -8
index 3d4461e3a2cd..f56485c2ad2c 100644
@@ -78,18 +78,12 @@ nvif_outp_dp_mst_id_get(struct nvif_outp *outp, u32 *id)
 int
 nvif_outp_dp_sst(struct nvif_outp *outp, int head, u32 watermark, u32 hblanksym, u32 vblanksym)
 {
-	struct nvif_outp_dp_sst_v0 args;
 	int ret;
 
-	args.version = 0;
-	args.head = head;
-	args.watermark = watermark;
-	args.hblanksym = hblanksym;
-	args.vblanksym = vblanksym;
-	ret = nvif_object_mthd(&outp->object, NVIF_OUTP_V0_DP_SST, &args, sizeof(args));
+	ret = outp->impl->dp.sst(outp->priv, head, watermark, hblanksym, vblanksym);
 	NVIF_ERRON(ret, &outp->object,
 		   "[DP_SST head:%d watermark:%d hblanksym:%d vblanksym:%d]",
-		   args.head, args.watermark, args.hblanksym, args.vblanksym);
+		   head, watermark, hblanksym, vblanksym);
 	return ret;
 }
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +21 -13
index 3d5b6cee97bc..cfa386c1bbeb 100644
@@ -103,23 +103,31 @@ nvkm_uoutp_mthd_dp_mst_id_get(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_dp_sst(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_dp_sst(struct nvif_outp_priv *uoutp, u8 head,
+		  u32 watermark, u32 hblanksym, u32 vblanksym)
 {
-	union nvif_outp_dp_sst_args *args = argv;
+	struct nvkm_outp *outp = uoutp->outp;
 	struct nvkm_disp *disp = outp->disp;
-	struct nvkm_ior *ior = outp->ior;
-
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
+	struct nvkm_ior *ior;
+	int ret;
 
-	if (!ior->func->dp || !nvkm_head_find(disp, args->v0.head))
+	if (!nvkm_head_find(disp, head))
 		return -EINVAL;
-	if (!ior->func->dp->sst)
-		return 0;
 
-	return ior->func->dp->sst(ior, args->v0.head,
-				  outp->dp.dpcd[DPCD_RC02] & DPCD_RC02_ENHANCED_FRAME_CAP,
-				  args->v0.watermark, args->v0.hblanksym, args->v0.vblanksym);
+	ret = nvkm_uoutp_lock_acquired(uoutp);
+	if (ret)
+		return ret;
+
+	ior = outp->ior;
+
+	if (ior->func->dp->sst) {
+		ret = ior->func->dp->sst(ior, head,
+					 outp->dp.dpcd[DPCD_RC02] & DPCD_RC02_ENHANCED_FRAME_CAP,
+					 watermark, hblanksym, vblanksym);
+	}
+
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
@@ -550,7 +558,6 @@ static int
 nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_DP_SST       : return nvkm_uoutp_mthd_dp_sst       (outp, argv, argc);
 	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);
@@ -690,6 +697,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 		uoutp->impl.dp.rates = nvkm_uoutp_dp_rates;
 		uoutp->impl.dp.train = nvkm_uoutp_dp_train;
 		uoutp->impl.dp.drive = nvkm_uoutp_dp_drive;
+		uoutp->impl.dp.sst = nvkm_uoutp_dp_sst;
 		break;
 	default:
 		WARN_ON(1);
Signature · 1 line
2.41.0
author
#124 lore raw

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

In reply to Ben Skeggs

- transition from "ioctl" interfaces

---
 .../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(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +2 -0
index dc103d2a20a9..e2123ba48fc7 100644
@@ -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;
 };
 
drivers/gpu/drm/nouveau/include/nvif/if0012.h +0 -18
index 92c4988101eb..3c74cd17a3a7 100644
@@ -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;
drivers/gpu/drm/nouveau/nvif/outp.c +5 -14
index f56485c2ad2c..cca1c28671f4 100644
@@ -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
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +22 -16
index cfa386c1bbeb..eead485fe0e2 100644
@@ -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);
Signature · 1 line
2.41.0
author
#125 lore raw

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

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 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
drivers/gpu/drm/nouveau/dispnv50/disp.c +0 -1
index 0bac0e813184..5e12de0aabb6 100644
@@ -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>
 
drivers/gpu/drm/nouveau/include/nvif/driverif.h +2 -0
index e2123ba48fc7..f7c7a98089b3 100644
@@ -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;
 };
 
drivers/gpu/drm/nouveau/include/nvif/if0012.h deleted +0 -17
deleted file mode 100644
index 3c74cd17a3a7..000000000000
@@ -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
drivers/gpu/drm/nouveau/include/nvif/outp.h +0 -1
index 7f7620ec1487..ea4d2d4f11f8 100644
@@ -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;
 
drivers/gpu/drm/nouveau/nvif/outp.c +2 -10
index cca1c28671f4..f04154e7a7b4 100644
@@ -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;
 }
 
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +13 -41

88 lines not on this page · raw message

Signature · 1 line
2.41.0
author
#126 lore raw

PATCH 125/156 drm/nouveau/nvif: remove outp from object rb

In reply to Ben Skeggs

- no more users

---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h  | 2 +-
 drivers/gpu/drm/nouveau/nvif/outp.c              | 3 +--
 drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c | 6 +++---
 3 files changed, 5 insertions(+), 6 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +1 -1
index f7c7a98089b3..57ad5022a534 100644
@@ -366,7 +366,7 @@ struct nvif_disp_impl {
 	struct {
 		u32 mask;
 		int (*new)(struct nvif_disp_priv *, u8 id,
-			   const struct nvif_outp_impl **, struct nvif_outp_priv **, u64 handle);
+			   const struct nvif_outp_impl **, struct nvif_outp_priv **);
 	} outp;
 
 	struct {
drivers/gpu/drm/nouveau/nvif/outp.c +1 -2
index f04154e7a7b4..65c4b8539b55 100644
@@ -381,8 +381,7 @@ nvif_outp_ctor(struct nvif_disp *disp, const char *name, int id, struct nvif_out
 {
 	int ret;
 
-	ret = disp->impl->outp.new(disp->priv, id, &outp->impl, &outp->priv,
-				   nvif_handle(&outp->object));
+	ret = disp->impl->outp.new(disp->priv, id, &outp->impl, &outp->priv);
 	NVIF_ERRON(ret, &disp->object, "[NEW outp id:%d]", id);
 	if (ret)
 		return ret;
drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c +3 -3
index 678121ab469f..0be6b28c79b8 100644
@@ -86,8 +86,7 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 
 static int
 nvkm_udisp_outp_new(struct nvif_disp_priv *udisp, u8 id,
-		    const struct nvif_outp_impl **pimpl, struct nvif_outp_priv **ppriv,
-		    u64 handle)
+		    const struct nvif_outp_impl **pimpl, struct nvif_outp_priv **ppriv)
 {
 	struct nvkm_object *object;
 	int ret;
@@ -96,7 +95,8 @@ nvkm_udisp_outp_new(struct nvif_disp_priv *udisp, u8 id,
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(udisp->object.client, &udisp->object, handle, object);
+	nvkm_object_link(&udisp->object, object);
+	return 0;
 }
 
 static int
Signature · 1 line
2.41.0
author
#127 lore raw

PATCH 126/156 drm/nouveau/nvif: rework disp "new head" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../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(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +8 -0
index 57ad5022a534..83acedd108bb 100644
@@ -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 {
drivers/gpu/drm/nouveau/include/nvif/head.h +2 -0
index 3ec36999e956..fb25cd60987a 100644
@@ -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;
 };
 
drivers/gpu/drm/nouveau/include/nvif/if0013.h +0 -8
index 6756c7467ae4..751f75bf7e59 100644
@@ -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;
drivers/gpu/drm/nouveau/nvif/head.c +13 -8
index f00e01d232db..777f12f3236f 100644
@@ -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;
 }
drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h +0 -2
index 0163660f215d..d16b47b2a9d6 100644
@@ -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
drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c +17 -7
index 0be6b28c79b8..6a65b3bffc19 100644
@@ -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 *
drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c +20 -8
index 3be82e01a59a..3456e988f9b3 100644
@@ -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;
 }
drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.h +3 -0
index f19c9ae33707..1291f8c3874e 100644
@@ -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
Signature · 1 line
2.41.0
author
#128 lore raw

PATCH 127/156 drm/nouveau/nvif: rework head "scanoutpos" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  4 ++
 drivers/gpu/drm/nouveau/include/nvif/if0013.h | 18 --------
 drivers/gpu/drm/nouveau/nouveau_display.c     | 20 +++++----
 .../gpu/drm/nouveau/nvkm/engine/disp/uhead.c  | 43 +++++++------------
 4 files changed, 30 insertions(+), 55 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +4 -0
index 83acedd108bb..927d0d75dd29 100644
@@ -351,6 +351,10 @@ struct nvif_outp_impl {
 
 struct nvif_head_impl {
 	void (*del)(struct nvif_head_priv *);
+
+	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);
 };
 
 struct nvif_disp_impl {
drivers/gpu/drm/nouveau/include/nvif/if0013.h +0 -18
index 751f75bf7e59..f2b39f86a9cc 100644
@@ -6,22 +6,4 @@ union nvif_head_event_args {
 	struct nvif_head_event_vn {
 	} vn;
 };
-
-#define NVIF_HEAD_V0_SCANOUTPOS 0x00
-
-union nvif_head_scanoutpos_args {
-	struct nvif_head_scanoutpos_v0 {
-		__u8  version;
-		__u8  pad01[7];
-		__s64 time[2];
-		__u16 vblanks;
-		__u16 vblanke;
-		__u16 vtotal;
-		__u16 vline;
-		__u16 hblanks;
-		__u16 hblanke;
-		__u16 htotal;
-		__u16 hline;
-	} v0;
-};
 #endif
drivers/gpu/drm/nouveau/nouveau_display.c +11 -9
index 27b69032fd9e..0d2dae7a94d0 100644
@@ -85,18 +85,20 @@ nouveau_display_scanoutpos_head(struct drm_crtc *crtc, int *vpos, int *hpos,
 {
 	struct drm_vblank_crtc *vblank = &crtc->dev->vblank[drm_crtc_index(crtc)];
 	struct nvif_head *head = &nouveau_crtc(crtc)->head;
-	struct nvif_head_scanoutpos_v0 args;
+	u16 vblanks, vblanke, vtotal, vline;
+	u16 hblanks, hblanke, htotal, hline;
+	s64 time[2];
 	int retry = 20;
 	bool ret = false;
 
-	args.version = 0;
-
 	do {
-		ret = nvif_mthd(&head->object, NVIF_HEAD_V0_SCANOUTPOS, &args, sizeof(args));
+		ret = head->impl->scanoutpos(head->priv, time,
+					     &vblanks, &vblanke, &vtotal, &vline,
+					     &hblanks, &hblanke, &htotal, &hline);
 		if (ret != 0)
 			return false;
 
-		if (args.vline) {
+		if (vline) {
 			ret = true;
 			break;
 		}
@@ -104,10 +106,10 @@ nouveau_display_scanoutpos_head(struct drm_crtc *crtc, int *vpos, int *hpos,
 		if (retry) ndelay(vblank->linedur_ns);
 	} while (retry--);
 
-	*hpos = args.hline;
-	*vpos = calc(args.vblanks, args.vblanke, args.vtotal, args.vline);
-	if (stime) *stime = ns_to_ktime(args.time[0]);
-	if (etime) *etime = ns_to_ktime(args.time[1]);
+	*hpos = hline;
+	*vpos = calc(vblanks, vblanke, vtotal, vline);
+	if (stime) *stime = ns_to_ktime(time[0]);
+	if (etime) *etime = ns_to_ktime(time[1]);
 
 	return ret;
 }
drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c +15 -28

74 lines not on this page · raw message

Signature · 1 line
2.41.0
author
#129 lore raw

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

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 .../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
drivers/gpu/drm/nouveau/include/nvif/driverif.h +3 -0
index 927d0d75dd29..7aa44e4fe729 100644
@@ -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 {
drivers/gpu/drm/nouveau/include/nvif/if0013.h deleted +0 -9
deleted file mode 100644
index f2b39f86a9cc..000000000000
@@ -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
drivers/gpu/drm/nouveau/nouveau_display.c +0 -1
index 0d2dae7a94d0..3f75c7f33429 100644
@@ -42,7 +42,6 @@
 
 #include <nvif/class.h>
 #include <nvif/if0011.h>
-#include <nvif/if0013.h>
 #include <dispnv50/crc.h>
 
 int
drivers/gpu/drm/nouveau/nvif/head.c +9 -6
index 777f12f3236f..05f56169e6c3 100644
@@ -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
drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c +6 -13
index ebf72333ae99..0ad97094a8c7 100644
@@ -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
Signature · 1 line
2.41.0
author
#130 lore raw

PATCH 129/156 drm/nouveau/nvif: remove head from object rb

In reply to Ben Skeggs

- no more users

---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h  | 3 +--
 drivers/gpu/drm/nouveau/nvif/head.c              | 3 +--
 drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c | 6 +++---
 3 files changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +1 -2
index 7aa44e4fe729..e66d29b3db63 100644
@@ -384,8 +384,7 @@ 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);
+			   const struct nvif_head_impl **, struct nvif_head_priv **);
 	} head;
 
 	struct {
drivers/gpu/drm/nouveau/nvif/head.c +1 -2
index 05f56169e6c3..0800eebb920a 100644
@@ -55,8 +55,7 @@ nvif_head_ctor(struct nvif_disp *disp, const char *name, int id, struct nvif_hea
 {
 	int ret;
 
-	ret = disp->impl->head.new(disp->priv, id, &head->impl, &head->priv,
-				   nvif_handle(&head->object));
+	ret = disp->impl->head.new(disp->priv, id, &head->impl, &head->priv);
 	NVIF_ERRON(ret, &disp->object, "[NEW head id:%d]", id);
 	if (ret)
 		return ret;
drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c +3 -3
index 6a65b3bffc19..dc23fad17b81 100644
@@ -80,8 +80,7 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl
 
 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)
+		    const struct nvif_head_impl **pimpl, struct nvif_head_priv **ppriv)
 {
 	struct nvkm_object *object;
 	int ret;
@@ -90,7 +89,8 @@ nvkm_udisp_head_new(struct nvif_disp_priv *udisp, u8 id,
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(udisp->object.client, &udisp->object, handle, object);
+	nvkm_object_link(&udisp->object, object);
+	return 0;
 }
 
 static int
Signature · 1 line
2.41.0
author
#131 lore raw

PATCH 130/156 drm/nouveau/nvif: rework disp "new chan" apis

In reply to Ben Skeggs

- transition from "ioctl" interfaces

---
 drivers/gpu/drm/nouveau/dispnv50/base507c.c   |  21 +-
 drivers/gpu/drm/nouveau/dispnv50/core.c       |   6 +-
 drivers/gpu/drm/nouveau/dispnv50/core.h       |   4 +-
 drivers/gpu/drm/nouveau/dispnv50/core507d.c   |  27 ++-
 drivers/gpu/drm/nouveau/dispnv50/core907d.c   |   2 +-
 drivers/gpu/drm/nouveau/dispnv50/crc.c        |   2 +-
 drivers/gpu/drm/nouveau/dispnv50/curs507a.c   |  33 +--
 drivers/gpu/drm/nouveau/dispnv50/cursc37a.c   |  12 +-
 drivers/gpu/drm/nouveau/dispnv50/disp.c       | 217 +-----------------
 drivers/gpu/drm/nouveau/dispnv50/disp.h       |  18 --
 drivers/gpu/drm/nouveau/dispnv50/oimm507b.c   |  20 +-
 drivers/gpu/drm/nouveau/dispnv50/ovly507e.c   |  21 +-
 drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c   |  20 +-
 drivers/gpu/drm/nouveau/dispnv50/wndw.c       |  14 +-
 drivers/gpu/drm/nouveau/dispnv50/wndw.h       |  10 +-
 drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c   |  21 +-
 .../gpu/drm/nouveau/include/nvif/dispchan.h   |  21 ++
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  15 ++
 drivers/gpu/drm/nouveau/include/nvif/if0014.h |  13 --
 drivers/gpu/drm/nouveau/include/nvif/push.h   |   5 +-
 drivers/gpu/drm/nouveau/nouveau_chan.c        |   3 +-
 drivers/gpu/drm/nouveau/nvif/Kbuild           |   1 +
 drivers/gpu/drm/nouveau/nvif/dispchan.c       | 205 +++++++++++++++++
 .../gpu/drm/nouveau/nvkm/engine/disp/chan.c   | 132 ++++-------
 .../gpu/drm/nouveau/nvkm/engine/disp/chan.h   |   4 -
 .../gpu/drm/nouveau/nvkm/engine/disp/uchan.h  |  10 +
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.c  | 139 +++++++----
 27 files changed, 528 insertions(+), 468 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/include/nvif/dispchan.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0014.h
 create mode 100644 drivers/gpu/drm/nouveau/nvif/dispchan.c
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/disp/uchan.h
drivers/gpu/drm/nouveau/dispnv50/base507c.c +13 -8
index 0b6fb663d78e..875c013c39b0 100644
@@ -21,7 +21,6 @@
  */
 #include "base.h"
 
-#include <nvif/if0014.h>
 #include <nvif/push507c.h>
 #include <nvif/timer.h>
 
@@ -304,10 +303,7 @@ base507c_new_(const struct nv50_wndw_func *func, const u32 *format,
 	      struct nouveau_drm *drm, int head, s32 oclass, u32 interlock_data,
 	      struct nv50_wndw **pwndw)
 {
-	struct nvif_disp_chan_v0 args = {
-		.id = head,
-	};
-	struct nv50_disp *disp50 = nv50_disp(drm->dev);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 	struct nv50_wndw *wndw;
 	int ret;
 
@@ -317,9 +313,18 @@ base507c_new_(const struct nv50_wndw_func *func, const u32 *format,
 	if (*pwndw = wndw, ret)
 		return ret;
 
-	ret = nv50_dmac_create(drm,
-			       &oclass, head, &args, sizeof(args),
-			       disp50->sync->offset, &wndw->wndw);
+	ret = nvif_dispchan_ctor(disp, "kmsChanBase", head, oclass, &drm->mmu, &wndw->wndw);
+	if (ret)
+		goto done;
+
+	ret = disp->impl->chan.base.new(disp->priv, head, wndw->wndw.push.mem.priv,
+					&wndw->wndw.impl, &wndw->wndw.priv,
+					nvif_handle(&wndw->wndw.object));
+	if (ret)
+		goto done;
+
+	ret = nvif_dispchan_oneinit(&wndw->wndw);
+done:
 	if (ret) {
 		NV_ERROR(drm, "base%04x allocation failed: %d\n", oclass, ret);
 		return ret;
drivers/gpu/drm/nouveau/dispnv50/core.c +3 -3
index 7d5438355715..98ccb67fc95b 100644
@@ -34,7 +34,7 @@ nv50_core_del(struct nv50_core **pcore)
 	if (core) {
 		nvif_object_dtor(&core->sync);
 		nvif_object_dtor(&core->vram);
-		nv50_dmac_destroy(&core->chan);
+		nvif_dispchan_dtor(&core->chan);
 		kfree(*pcore);
 		*pcore = NULL;
 	}
@@ -75,7 +75,7 @@ nv50_core_new(struct nouveau_drm *drm, struct nv50_core **pcore)
 	if (ret)
 		return ret;
 
-	ret = nvif_object_ctor(&core->chan.base.user, "kmsCoreSyncCtxdma", NV50_DISP_HANDLE_SYNCBUF,
+	ret = nvif_object_ctor(&core->chan.object, "kmsCoreSyncCtxdma", NV50_DISP_HANDLE_SYNCBUF,
 			       NV_DMA_IN_MEMORY,
 			       (&(struct nv_dma_v0) {
 					.target = NV_DMA_V0_TARGET_VRAM,
@@ -87,7 +87,7 @@ nv50_core_new(struct nouveau_drm *drm, struct nv50_core **pcore)
 	if (ret)
 		return ret;
 
-	ret = nvif_object_ctor(&core->chan.base.user, "kmsCoreVramCtxdma", NV50_DISP_HANDLE_VRAM,
+	ret = nvif_object_ctor(&core->chan.object, "kmsCoreVramCtxdma", NV50_DISP_HANDLE_VRAM,
 			       NV_DMA_IN_MEMORY,
 			       (&(struct nv_dma_v0) {
 					.target = NV_DMA_V0_TARGET_VRAM,
drivers/gpu/drm/nouveau/dispnv50/core.h +3 -1
index a967c66dc7a2..1343a1d224c0 100644
@@ -5,9 +5,11 @@
 #include "crc.h"
 #include <nouveau_encoder.h>
 
+#include <nvif/dispchan.h>
+
 struct nv50_core {
 	const struct nv50_core_func *func;
-	struct nv50_dmac chan;
+	struct nvif_dispchan chan;
 
 	struct nvif_object vram;
 	struct nvif_object sync;
drivers/gpu/drm/nouveau/dispnv50/core507d.c +16 -11
index c6eee88ae99a..dab9fb984765 100644
@@ -22,7 +22,6 @@
 #include "core.h"
 #include "head.h"
 
-#include <nvif/if0014.h>
 #include <nvif/push507c.h>
 #include <nvif/timer.h>
 
@@ -115,7 +114,7 @@ core507d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
 	if (ret < 0)
 		return ret;
 
-	time = nvif_msec(core->chan.base.device, 2000ULL,
+	time = nvif_msec(core->chan.disp->device, 2000ULL,
 			 if (NVBO_TD32(bo, NV50_DISP_CORE_NTFY,
 				       NV_DISP_CORE_NOTIFIER_1, CAPABILITIES_1, DONE, ==, TRUE))
 				 break;
@@ -157,8 +156,7 @@ int
 core507d_new_(const struct nv50_core_func *func, struct nouveau_drm *drm,
 	      s32 oclass, struct nv50_core **pcore)
 {
-	struct nvif_disp_chan_v0 args = {};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 	struct nv50_core *core;
 	int ret;
 
@@ -166,15 +164,22 @@ core507d_new_(const struct nv50_core_func *func, struct nouveau_drm *drm,
 		return -ENOMEM;
 	core->func = func;
 
-	ret = nv50_dmac_create(drm,
-			       &oclass, 0, &args, sizeof(args),
-			       disp->sync->offset, &core->chan);
-	if (ret) {
+	ret = nvif_dispchan_ctor(disp, "kmsChanCore", 0, oclass, &drm->mmu, &core->chan);
+	if (ret)
+		goto done;
+
+	ret = disp->impl->chan.core.new(disp->priv, core->chan.push.mem.priv,
+					&core->chan.impl, &core->chan.priv,
+					nvif_handle(&core->chan.object));
+	if (ret)
+		goto done;
+
+	ret = nvif_dispchan_oneinit(&core->chan);
+done:
+	if (ret)
 		NV_ERROR(drm, "core%04x allocation failed: %d\n", oclass, ret);
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 int
drivers/gpu/drm/nouveau/dispnv50/core907d.c +1 -1
index 8564d4dffaff..0bff54ca5ba1 100644
@@ -44,7 +44,7 @@ core907d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
 	if (ret < 0)
 		return ret;
 
-	time = nvif_msec(core->chan.base.device, 2000ULL,
+	time = nvif_msec(core->chan.disp->device, 2000ULL,
 			 if (NVBO_TD32(bo, NV50_DISP_CORE_NTFY,
 				       NV907D_CORE_NOTIFIER_3, CAPABILITIES_4, DONE, ==, TRUE))
 				 break;
drivers/gpu/drm/nouveau/dispnv50/crc.c +1 -1
index 9482e69c3647..72ce4ada284f 100644
@@ -507,7 +507,7 @@ nv50_crc_ctx_init(struct nv50_head *head, struct nvif_mmu *mmu,
 	if (ret)
 		return ret;
 
-	ret = nvif_object_ctor(&core->chan.base.user, "kmsCrcNtfyCtxDma",
+	ret = nvif_object_ctor(&core->chan.object, "kmsCrcNtfyCtxDma",
 			       NV50_DISP_HANDLE_CRC_CTX(head, idx),
 			       NV_DMA_IN_MEMORY,
 			       (&(struct nv_dma_v0) {
drivers/gpu/drm/nouveau/dispnv50/curs507a.c +18 -15
index 7292d1554dba..8017cd0bd636 100644
@@ -23,7 +23,6 @@
 #include "core.h"
 #include "head.h"
 
-#include <nvif/if0014.h>
 #include <nvif/timer.h>
 
 #include <nvhw/class/cl507a.h>
@@ -35,7 +34,7 @@ bool
 curs507a_space(struct nv50_wndw *wndw)
 {
 	nvif_msec(&nouveau_drm(wndw->plane.dev)->client.device, 100,
-		if (NVIF_TV32(&wndw->wimm.base.user, NV507A, FREE, COUNT, >=, 4))
+		if (NVIF_TV32(&wndw->wimm, NV507A, FREE, COUNT, >=, 4))
 			return true;
 	);
 
@@ -46,10 +45,10 @@ curs507a_space(struct nv50_wndw *wndw)
 static int
 curs507a_update(struct nv50_wndw *wndw, u32 *interlock)
 {
-	struct nvif_object *user = &wndw->wimm.base.user;
-	int ret = nvif_chan_wait(&wndw->wimm, 1);
+	struct nvif_dispchan *chan = &wndw->wimm;
+	int ret = nvif_chan_wait(chan, 1);
 	if (ret == 0) {
-		NVIF_WR32(user, NV507A, UPDATE,
+		NVIF_WR32(chan, NV507A, UPDATE,
 			  NVDEF(NV507A, UPDATE, INTERLOCK_WITH_CORE, DISABLE));
 	}
 	return ret;
@@ -58,10 +57,10 @@ curs507a_update(struct nv50_wndw *wndw, u32 *interlock)
 static int
 curs507a_point(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_object *user = &wndw->wimm.base.user;
-	int ret = nvif_chan_wait(&wndw->wimm, 1);
+	struct nvif_dispchan *chan = &wndw->wimm;
+	int ret = nvif_chan_wait(chan, 1);
 	if (ret == 0) {
-		NVIF_WR32(user, NV507A, SET_CURSOR_HOT_SPOT_POINT_OUT,
+		NVIF_WR32(chan, NV507A, SET_CURSOR_HOT_SPOT_POINT_OUT,
 			  NVVAL(NV507A, SET_CURSOR_HOT_SPOT_POINT_OUT, X, asyw->point.x) |
 			  NVVAL(NV507A, SET_CURSOR_HOT_SPOT_POINT_OUT, Y, asyw->point.y));
 	}
@@ -170,10 +169,7 @@ curs507a_new_(const struct nv50_wimm_func *func, struct nouveau_drm *drm,
 	      int head, s32 oclass, u32 interlock_data,
 	      struct nv50_wndw **pwndw)
 {
-	struct nvif_disp_chan_v0 args = {
-		.id = head,
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 	struct nv50_wndw *wndw;
 	int ret;
 
@@ -183,14 +179,21 @@ curs507a_new_(const struct nv50_wimm_func *func, struct nouveau_drm *drm,
 	if (*pwndw = wndw, ret)
 		return ret;
 
-	ret = nvif_object_ctor(&disp->disp->object, "kmsCurs", 0, oclass,
-			       &args, sizeof(args), &wndw->wimm.base.user);
+	ret = nvif_dispchan_ctor(disp, "kmsChanCurs", wndw->id, oclass, NULL, &wndw->wimm);
+	if (ret)
+		goto done;
+
+	ret = disp->impl->chan.curs.new(disp->priv, wndw->id, &wndw->wimm.impl, &wndw->wimm.priv);
+	if (ret)
+		goto done;
+
+	ret = nvif_dispchan_oneinit(&wndw->wimm);
+done:
 	if (ret) {
 		NV_ERROR(drm, "curs%04x allocation failed: %d\n", oclass, ret);
 		return ret;
 	}
 
-	nvif_object_map(&wndw->wimm.base.user, NULL, 0);
 	wndw->immd = func;
 	wndw->ctxdma.parent = NULL;
 	return nv50_wndw_ctor(wndw);
drivers/gpu/drm/nouveau/dispnv50/cursc37a.c +6 -6
index e39d08698c63..e2c28c5716a6 100644
@@ -27,20 +27,20 @@
 static int
 cursc37a_update(struct nv50_wndw *wndw, u32 *interlock)
 {
-	struct nvif_object *user = &wndw->wimm.base.user;
-	int ret = nvif_chan_wait(&wndw->wimm, 1);
+	struct nvif_dispchan *chan = &wndw->wimm;
+	int ret = nvif_chan_wait(chan, 1);
 	if (ret == 0)
-		NVIF_WR32(user, NVC37A, UPDATE, 0x00000001);
+		NVIF_WR32(chan, NVC37A, UPDATE, 0x00000001);
 	return ret;
 }
 
 static int
 cursc37a_point(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
-	struct nvif_object *user = &wndw->wimm.base.user;
-	int ret = nvif_chan_wait(&wndw->wimm, 1);
+	struct nvif_dispchan *chan = &wndw->wimm;
+	int ret = nvif_chan_wait(chan, 1);
 	if (ret == 0) {
-		NVIF_WR32(user, NVC37A, SET_CURSOR_HOT_SPOT_POINT_OUT(0),
+		NVIF_WR32(chan, NVC37A, SET_CURSOR_HOT_SPOT_POINT_OUT(0),
 			  NVVAL(NVC37A, SET_CURSOR_HOT_SPOT_POINT_OUT, X, asyw->point.x) |
 			  NVVAL(NVC37A, SET_CURSOR_HOT_SPOT_POINT_OUT, Y, asyw->point.y));
 	}
drivers/gpu/drm/nouveau/dispnv50/disp.c +1 -216

235 lines not on this page · raw message

drivers/gpu/drm/nouveau/dispnv50/disp.h +0 -18
index 39aaa385cd6a..db9e4e5070a3 100644
@@ -1,8 +1,6 @@
 #ifndef __NV50_KMS_H__
 #define __NV50_KMS_H__
 #include <linux/workqueue.h>
-#include <nvif/mem.h>
-#include <nvif/push.h>
 
 #include "nouveau_display.h"
 
@@ -54,17 +52,6 @@ void corec37d_ntfy_init(struct nouveau_bo *, u32);
 
 void head907d_olut_load(struct drm_color_lut *, int size, void __iomem *);
 
-struct nv50_chan {
-	struct nvif_object user;
-	struct nvif_device *device;
-};
-
-struct nv50_dmac {
-	struct nv50_chan base;
-
-	struct nvif_push push;
-};
-
 struct nv50_outp_atom {
 	struct list_head head;
 
@@ -81,11 +68,6 @@ struct nv50_outp_atom {
 	} set, clr;
 };
 
-int nv50_dmac_create(struct nouveau_drm *,
-		     const s32 *oclass, u8 head, void *data, u32 size,
-		     s64 syncbuf, struct nv50_dmac *dmac);
-void nv50_dmac_destroy(struct nv50_dmac *);
-
 /*
  * For normal encoders this just returns the encoder. For active MST encoders,
  * this returns the real outp that's driving displays on the topology.
drivers/gpu/drm/nouveau/dispnv50/oimm507b.c +11 -9
index 752318cf3cf1..05b0d42c85c6 100644
@@ -21,26 +21,28 @@
  */
 #include "oimm.h"
 
-#include <nvif/if0014.h>
-
 static int
 oimm507b_init_(const struct nv50_wimm_func *func, struct nouveau_drm *drm,
 	       s32 oclass, struct nv50_wndw *wndw)
 {
-	struct nvif_disp_chan_v0 args = {
-		.id = wndw->id,
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 	int ret;
 
-	ret = nvif_object_ctor(&disp->disp->object, "kmsOvim", 0, oclass,
-			       &args, sizeof(args), &wndw->wimm.base.user);
+	ret = nvif_dispchan_ctor(disp, "kmsChanOvim", wndw->id, oclass, NULL, &wndw->wimm);
+	if (ret)
+		goto done;
+
+	ret = disp->impl->chan.oimm.new(disp->priv, wndw->id, &wndw->wimm.impl, &wndw->wimm.priv);
+	if (ret)
+		goto done;
+
+	ret = nvif_dispchan_oneinit(&wndw->wimm);
+done:
 	if (ret) {
 		NV_ERROR(drm, "oimm%04x allocation failed: %d\n", oclass, ret);
 		return ret;
 	}
 
-	nvif_object_map(&wndw->wimm.base.user, NULL, 0);
 	wndw->immd = func;
 	return 0;
 }
drivers/gpu/drm/nouveau/dispnv50/ovly507e.c +13 -8
index 4e109c5b5a1b..458c6f9e63f0 100644
@@ -25,7 +25,6 @@
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_fourcc.h>
 
-#include <nvif/if0014.h>
 #include <nvif/push507c.h>
 
 #include <nvhw/class/cl507e.h>
@@ -145,10 +144,7 @@ ovly507e_new_(const struct nv50_wndw_func *func, const u32 *format,
 	      struct nouveau_drm *drm, int head, s32 oclass, u32 interlock_data,
 	      struct nv50_wndw **pwndw)
 {
-	struct nvif_disp_chan_v0 args = {
-		.id = head,
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 	struct nv50_wndw *wndw;
 	int ret;
 
@@ -159,9 +155,18 @@ ovly507e_new_(const struct nv50_wndw_func *func, const u32 *format,
 	if (*pwndw = wndw, ret)
 		return ret;
 
-	ret = nv50_dmac_create(drm,
-			       &oclass, 0, &args, sizeof(args),
-			       disp->sync->offset, &wndw->wndw);
+	ret = nvif_dispchan_ctor(disp, "kmsChanOvly", wndw->id, oclass, &drm->mmu, &wndw->wndw);
+	if (ret)
+		goto done;
+
+	ret = disp->impl->chan.ovly.new(disp->priv, wndw->id, wndw->wndw.push.mem.priv,
+					&wndw->wndw.impl, &wndw->wndw.priv,
+					nvif_handle(&wndw->wndw.object));
+	if (ret)
+		goto done;
+
+	ret = nvif_dispchan_oneinit(&wndw->wndw);
+done:
 	if (ret) {
 		NV_ERROR(drm, "ovly%04x allocation failed: %d\n", oclass, ret);
 		return ret;
drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c +13 -7
index 7985da61aaac..2f4f0ad89b5e 100644
@@ -23,7 +23,6 @@
 #include "atom.h"
 #include "wndw.h"
 
-#include <nvif/if0014.h>
 #include <nvif/pushc37b.h>
 
 #include <nvhw/class/clc37b.h>
@@ -68,14 +67,21 @@ static int
 wimmc37b_init_(const struct nv50_wimm_func *func, struct nouveau_drm *drm,
 	       s32 oclass, struct nv50_wndw *wndw)
 {
-	struct nvif_disp_chan_v0 args = {
-		.id = wndw->id,
-	};
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 	int ret;
 
-	ret = nv50_dmac_create(drm,
-			       &oclass, 0, &args, sizeof(args), -1,
-			       &wndw->wimm);
+	ret = nvif_dispchan_ctor(disp, "kmsChanWimm", wndw->id, oclass, &drm->mmu, &wndw->wimm);
+	if (ret)
+		goto done;
+
+	ret = disp->impl->chan.wimm.new(disp->priv, wndw->id, wndw->wimm.push.mem.priv,
+					&wndw->wimm.impl, &wndw->wimm.priv,
+					nvif_handle(&wndw->wimm.object));
+	if (ret)
+		goto done;
+
+	ret = nvif_dispchan_oneinit(&wndw->wimm);
+done:
 	if (ret) {
 		NV_ERROR(drm, "wimm%04x allocation failed: %d\n", oclass, ret);
 		return ret;
drivers/gpu/drm/nouveau/dispnv50/wndw.c +7 -7
index 6fb6d2252e15..9cab8d20bc68 100644
@@ -118,7 +118,7 @@ nv50_wndw_wait_armed(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 	if (asyw->set.ntfy) {
 		return wndw->func->ntfy_wait_begun(disp->sync,
 						   asyw->ntfy.offset,
-						   wndw->wndw.base.device);
+						   wndw->wndw.disp->device);
 	}
 	return 0;
 }
@@ -644,11 +644,11 @@ nv50_wndw_destroy(struct drm_plane *plane)
 		nv50_wndw_ctxdma_del(ctxdma);
 	}
 
-	nv50_dmac_destroy(&wndw->wimm);
+	nvif_dispchan_dtor(&wndw->wimm);
 
 	nvif_object_dtor(&wndw->vram);
 	nvif_object_dtor(&wndw->sync);
-	nv50_dmac_destroy(&wndw->wndw);
+	nvif_dispchan_dtor(&wndw->wndw);
 
 	nv50_lut_fini(&wndw->ilut);
 
@@ -702,10 +702,10 @@ nv50_wndw_ctor(struct nv50_wndw *wndw)
 	struct nv50_disp *disp = nv50_disp(wndw->plane.dev);
 	int ret;
 
-	if (!nvif_object_constructed(&wndw->wndw.base.user))
+	if (!wndw->wndw.impl)
 		return 0;
 
-	ret = nvif_object_ctor(&wndw->wndw.base.user, "kmsWndwSyncCtxDma", NV50_DISP_HANDLE_SYNCBUF,
+	ret = nvif_object_ctor(&wndw->wndw.object, "kmsWndwSyncCtxDma", NV50_DISP_HANDLE_SYNCBUF,
 			       NV_DMA_IN_MEMORY,
 			       (&(struct nv_dma_v0) {
 					.target = NV_DMA_V0_TARGET_VRAM,
@@ -717,7 +717,7 @@ nv50_wndw_ctor(struct nv50_wndw *wndw)
 	if (ret)
 		return ret;
 
-	ret = nvif_object_ctor(&wndw->wndw.base.user, "kmsWndwVramCtxDma", NV50_DISP_HANDLE_VRAM,
+	ret = nvif_object_ctor(&wndw->wndw.object, "kmsWndwVramCtxDma", NV50_DISP_HANDLE_VRAM,
 			       NV_DMA_IN_MEMORY,
 			       (&(struct nv_dma_v0) {
 					.target = NV_DMA_V0_TARGET_VRAM,
@@ -754,7 +754,7 @@ nv50_wndw_prep(const struct nv50_wndw_func *func, struct drm_device *dev,
 	wndw->interlock.type = interlock_type;
 	wndw->interlock.data = interlock_data;
 
-	wndw->ctxdma.parent = &wndw->wndw.base.user;
+	wndw->ctxdma.parent = &wndw->wndw.object;
 	INIT_LIST_HEAD(&wndw->ctxdma.list);
 
 	for (nformat = 0; format[nformat]; nformat++);
drivers/gpu/drm/nouveau/dispnv50/wndw.h +6 -4
index 66a06e20a6a0..68092e6445fa 100644
@@ -5,6 +5,8 @@
 #include "atom.h"
 #include "lut.h"
 
+#include <nvif/dispchan.h>
+
 struct nv50_wndw_ctxdma {
 	struct list_head head;
 	struct nvif_object object;
@@ -25,8 +27,8 @@ struct nv50_wndw {
 
 	struct nv50_lut ilut;
 
-	struct nv50_dmac wndw;
-	struct nv50_dmac wimm;
+	struct nvif_dispchan wndw;
+	struct nvif_dispchan wimm;
 
 	struct nvif_object vram;
 	struct nvif_object sync;
@@ -104,9 +106,9 @@ extern const struct nv50_wimm_func curs507a;
 bool curs507a_space(struct nv50_wndw *);
 
 static inline __must_check int
-nvif_chan_wait(struct nv50_dmac *dmac, u32 size)
+nvif_chan_wait(struct nvif_dispchan *chan, u32 size)
 {
-	struct nv50_wndw *wndw = container_of(dmac, typeof(*wndw), wimm);
+	struct nv50_wndw *wndw = container_of(chan, typeof(*wndw), wimm);
 	return curs507a_space(wndw) ? 0 : -ETIMEDOUT;
 }
 
drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c +13 -8
index 5029dfd98443..17751110edae 100644
@@ -25,7 +25,6 @@
 #include <drm/drm_atomic_helper.h>
 #include <nouveau_bo.h>
 
-#include <nvif/if0014.h>
 #include <nvif/pushc37b.h>
 
 #include <nvhw/class/clc37e.h>
@@ -350,10 +349,7 @@ wndwc37e_new_(const struct nv50_wndw_func *func, struct nouveau_drm *drm,
 	      enum drm_plane_type type, int index, s32 oclass, u32 heads,
 	      struct nv50_wndw **pwndw)
 {
-	struct nvif_disp_chan_v0 args = {
-		.id = index,
-	};
-	struct nv50_disp *disp = nv50_disp(drm->dev);
+	struct nvif_disp *disp = nv50_disp(drm->dev)->disp;
 	struct nv50_wndw *wndw;
 	int ret;
 
@@ -363,9 +359,18 @@ wndwc37e_new_(const struct nv50_wndw_func *func, struct nouveau_drm *drm,
 	if (*pwndw = wndw, ret)
 		return ret;
 
-	ret = nv50_dmac_create(drm,
-			       &oclass, 0, &args, sizeof(args),
-			       disp->sync->offset, &wndw->wndw);
+	ret = nvif_dispchan_ctor(disp, "kmsChanWndw", wndw->id, oclass, &drm->mmu, &wndw->wndw);
+	if (ret)
+		goto done;
+
+	ret = disp->impl->chan.wndw.new(disp->priv, wndw->id, wndw->wndw.push.mem.priv,
+					&wndw->wndw.impl, &wndw->wndw.priv,
+					nvif_handle(&wndw->wndw.object));
+	if (ret)
+		goto done;
+
+	ret = nvif_dispchan_oneinit(&wndw->wndw);
+done:
 	if (ret) {
 		NV_ERROR(drm, "qndw%04x allocation failed: %d\n", oclass, ret);
 		return ret;
drivers/gpu/drm/nouveau/include/nvif/dispchan.h new file +21 -0
new file mode 100644
index 000000000000..b1d3503e054c
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVIF_DISPCHAN_H__
+#define __NVIF_DISPCHAN_H__
+#include "disp.h"
+#include "push.h"
+
+struct nvif_dispchan {
+	const struct nvif_disp_chan_impl *impl;
+	struct nvif_disp_chan_priv *priv;
+	struct nvif_object object;
+	struct nvif_map map;
+
+	struct nvif_disp *disp;
+	struct nvif_push push;
+};
+
+int nvif_dispchan_ctor(struct nvif_disp *, const char *name, u32 handle, s32 oclass,
+		       struct nvif_mmu *, struct nvif_dispchan *);
+int nvif_dispchan_oneinit(struct nvif_dispchan *);
+void nvif_dispchan_dtor(struct nvif_dispchan *);
+#endif
drivers/gpu/drm/nouveau/include/nvif/driverif.h +15 -0
index e66d29b3db63..60a3529a6594 100644
@@ -17,6 +17,7 @@ struct nvif_disp_caps_priv;
 struct nvif_conn_priv;
 struct nvif_outp_priv;
 struct nvif_head_priv;
+struct nvif_disp_chan_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -360,6 +361,11 @@ struct nvif_head_impl {
 		      const struct nvif_event_impl **, struct nvif_event_priv **);
 };
 
+struct nvif_disp_chan_impl {
+	void (*del)(struct nvif_disp_chan_priv *);
+	struct nvif_mapinfo map;
+};
+
 struct nvif_disp_impl {
 	void (*del)(struct nvif_disp_priv *);
 
@@ -390,14 +396,23 @@ struct nvif_disp_impl {
 	struct {
 		struct nvif_disp_impl_core {
 			s32 oclass;
+			int (*new)(struct nvif_disp_priv *, struct nvif_mem_priv *,
+				   const struct nvif_disp_chan_impl **,
+				   struct nvif_disp_chan_priv **, u64 handle);
 		} core;
 
 		struct nvif_disp_impl_dmac {
 			s32 oclass;
+			int (*new)(struct nvif_disp_priv *, u8 id, struct nvif_mem_priv *,
+				   const struct nvif_disp_chan_impl **,
+				   struct nvif_disp_chan_priv **, u64 handle);
 		} base, ovly, wndw, wimm;
 
 		struct nvif_disp_impl_pioc {
 			s32 oclass;
+			int (*new)(struct nvif_disp_priv *, u8 id,
+				   const struct nvif_disp_chan_impl **,
+				   struct nvif_disp_chan_priv **);
 		} curs, oimm;
 	} chan;
 };
drivers/gpu/drm/nouveau/include/nvif/if0014.h deleted +0 -13
deleted file mode 100644
index be0362805106..000000000000
@@ -1,13 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVIF_IF0014_H__
-#define __NVIF_IF0014_H__
-
-union nvif_disp_chan_args {
-	struct nvif_disp_chan_v0 {
-		__u8  version;
-		__u8  id;
-		__u8  pad02[6];
-		__u64 pushbuf;
-	} v0;
-};
-#endif
drivers/gpu/drm/nouveau/include/nvif/push.h +2 -3
index 8817947a2ea0..275bade7fab9 100644
@@ -42,7 +42,7 @@ struct nvif_push {
 	u32 *end;
 
 	int (*wait)(struct nvif_push *push, u32 size);
-	void (*kick)(struct nvif_push *push);
+	int (*kick)(struct nvif_push *push);
 };
 
 static inline __must_check int
@@ -62,8 +62,7 @@ PUSH_WAIT(struct nvif_push *push, u32 size)
 static inline int
 PUSH_KICK(struct nvif_push *push)
 {
-	push->kick(push);
-	return 0;
+	return push->kick(push);
 }
 
 #ifdef CONFIG_NOUVEAU_DEBUG_PUSH
drivers/gpu/drm/nouveau/nouveau_chan.c +2 -1
index 27c477ed6b9b..771a4b4b3f1d 100644
@@ -117,13 +117,14 @@ nouveau_channel_del(struct nouveau_channel **pchan)
 	*pchan = NULL;
 }
 
-static void
+static int
 nouveau_channel_kick(struct nvif_push *push)
 {
 	struct nouveau_channel *chan = container_of(push, typeof(*chan), chan.push);
 	chan->dma.cur = chan->dma.cur + (chan->chan.push.cur - chan->chan.push.bgn);
 	FIRE_RING(chan);
 	chan->chan.push.bgn = chan->chan.push.cur;
+	return 0;
 }
 
 static int
drivers/gpu/drm/nouveau/nvif/Kbuild +1 -0
index b7963a39dd91..8e3ed36df6b3 100644
@@ -4,6 +4,7 @@ nvif-y += nvif/client.o
 nvif-y += nvif/conn.o
 nvif-y += nvif/device.o
 nvif-y += nvif/disp.o
+nvif-y += nvif/dispchan.o
 nvif-y += nvif/driver.o
 nvif-y += nvif/event.o
 nvif-y += nvif/fifo.o
drivers/gpu/drm/nouveau/nvif/dispchan.c new file +205 -0

205 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c +49 -83

195 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.h +0 -4
index 8c212dde036f..b7d7c435b1e2 100644
@@ -29,10 +29,6 @@ struct nvkm_disp_chan {
 	} user;
 };
 
-int nvkm_disp_core_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
-int nvkm_disp_chan_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
-int nvkm_disp_wndw_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
-
 struct nvkm_disp_chan_func {
 	int (*push)(struct nvkm_disp_chan *);
 	int (*init)(struct nvkm_disp_chan *);
drivers/gpu/drm/nouveau/nvkm/engine/disp/uchan.h new file +10 -0
new file mode 100644
index 000000000000..f682d2d5e6d3
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_UDISP_CHAN_H__
+#define __NVKM_UDISP_CHAN_H__
+#include "chan.h"
+#include <nvif/driverif.h>
+
+int nvkm_disp_chan_new(struct nvkm_disp *disp, const struct nvkm_disp_func_chan *, u8 id,
+		       struct nvkm_memory *, const struct nvif_disp_chan_impl **,
+		       struct nvif_disp_chan_priv **, struct nvkm_object **);
+#endif
drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c +98 -41

183 lines not on this page · raw message

Signature · 1 line
2.41.0
author
#132 lore raw

PATCH 131/156 drm/nouveau/nvif: remove disp from object rb

In reply to Ben Skeggs

- no more users

---
 drivers/gpu/drm/nouveau/include/nvif/driverif.h | 3 +--
 drivers/gpu/drm/nouveau/nvif/disp.c             | 3 +--
 drivers/gpu/drm/nouveau/nvkm/device/user.c      | 6 +++---
 3 files changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/nouveau/include/nvif/driverif.h +1 -2
index 60a3529a6594..d317fcd29091 100644
@@ -484,8 +484,7 @@ struct nvif_device_impl {
 	struct {
 		s32 oclass;
 		int (*new)(struct nvif_device_priv *,
-			   const struct nvif_disp_impl **, struct nvif_disp_priv **,
-			   u64 handle);
+			   const struct nvif_disp_impl **, struct nvif_disp_priv **);
 	} disp;
 
 	struct nvif_device_impl_fifo {
drivers/gpu/drm/nouveau/nvif/disp.c +1 -2
index d2824e4d29f8..b0c4fae39b18 100644
@@ -97,8 +97,7 @@ nvif_disp_ctor(struct nvif_device *device, const char *name, struct nvif_disp *d
 		return -ENODEV;
 	}
 
-	ret = device->impl->disp.new(device->priv, &disp->impl, &disp->priv,
-				     nvif_handle(&disp->object));
+	ret = device->impl->disp.new(device->priv, &disp->impl, &disp->priv);
 	NVIF_ERRON(ret, &device->object, "[NEW disp%04x]", oclass);
 	if (ret)
 		return ret;
drivers/gpu/drm/nouveau/nvkm/device/user.c +3 -3
index 3c7c0d1e6adb..6a3b41004abd 100644
@@ -96,8 +96,7 @@ nvkm_udevice_time(struct nvif_device_priv *udev)
 
 static int
 nvkm_udevice_disp_new(struct nvif_device_priv *udev,
-		      const struct nvif_disp_impl **pimpl, struct nvif_disp_priv **ppriv,
-		      u64 handle)
+		      const struct nvif_disp_impl **pimpl, struct nvif_disp_priv **ppriv)
 {
 	struct nvkm_object *object;
 	int ret;
@@ -106,7 +105,8 @@ nvkm_udevice_disp_new(struct nvif_device_priv *udev,
 	if (ret)
 		return ret;
 
-	return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object);
+	nvkm_object_link(&udev->object, object);
+	return 0;
 }
 
 static int
Signature · 1 line
2.41.0
author
#133 lore raw

PATCH 132/156 drm/nouveau/nvif: rework disp chan "new ctxdma" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 drivers/gpu/drm/nouveau/dispnv50/core.c       | 36 ++++----
 drivers/gpu/drm/nouveau/dispnv50/core.h       |  5 +-
 drivers/gpu/drm/nouveau/dispnv50/core507d.c   |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/corec37d.c   |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/corec57d.c   |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/crc.c        | 22 +++--
 drivers/gpu/drm/nouveau/dispnv50/crc.h        |  3 +-
 drivers/gpu/drm/nouveau/dispnv50/crc907d.c    |  4 +-
 drivers/gpu/drm/nouveau/dispnv50/crcc37d.c    |  4 +-
 drivers/gpu/drm/nouveau/dispnv50/crcc57d.c    |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/curs507a.c   |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/head.c       |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/head507d.c   |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/wndw.c       | 50 +++++------
 drivers/gpu/drm/nouveau/dispnv50/wndw.h       |  8 +-
 drivers/gpu/drm/nouveau/include/nvif/ctxdma.h | 29 ++++++
 .../gpu/drm/nouveau/include/nvif/dispchan.h   |  4 +
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 13 +++
 drivers/gpu/drm/nouveau/nvif/dispchan.c       | 17 ++++
 .../gpu/drm/nouveau/nvkm/engine/disp/chan.c   | 89 ++++++++++---------
 .../gpu/drm/nouveau/nvkm/engine/dma/user.c    |  6 --
 .../drm/nouveau/nvkm/engine/dma/usergf100.c   |  5 --
 .../drm/nouveau/nvkm/engine/dma/usergf119.c   |  5 --
 .../drm/nouveau/nvkm/engine/dma/usergv100.c   |  5 --
 .../drm/nouveau/nvkm/engine/dma/usernv50.c    |  6 --
 25 files changed, 181 insertions(+), 144 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/include/nvif/ctxdma.h
drivers/gpu/drm/nouveau/dispnv50/core.c +16 -20
index 98ccb67fc95b..3306220003ac 100644
@@ -32,8 +32,8 @@ nv50_core_del(struct nv50_core **pcore)
 {
 	struct nv50_core *core = *pcore;
 	if (core) {
-		nvif_object_dtor(&core->sync);
-		nvif_object_dtor(&core->vram);
+		nvif_ctxdma_dtor(&core->vram);
+		nvif_ctxdma_dtor(&core->sync);
 		nvif_dispchan_dtor(&core->chan);
 		kfree(*pcore);
 		*pcore = NULL;
@@ -75,27 +75,23 @@ nv50_core_new(struct nouveau_drm *drm, struct nv50_core **pcore)
 	if (ret)
 		return ret;
 
-	ret = nvif_object_ctor(&core->chan.object, "kmsCoreSyncCtxdma", NV50_DISP_HANDLE_SYNCBUF,
-			       NV_DMA_IN_MEMORY,
-			       (&(struct nv_dma_v0) {
-					.target = NV_DMA_V0_TARGET_VRAM,
-					.access = NV_DMA_V0_ACCESS_RDWR,
-					.start = disp->sync->offset + 0x0000,
-					.limit = disp->sync->offset + 0x0fff
-			       }), sizeof(struct nv_dma_v0),
-			       &core->sync);
+	ret = nvif_dispchan_ctxdma_ctor(&core->chan, "kmsCoreSyncCtxdma", NV50_DISP_HANDLE_SYNCBUF,
+					NV_DMA_IN_MEMORY, &(struct nv_dma_v0) {
+						.target = NV_DMA_V0_TARGET_VRAM,
+						.access = NV_DMA_V0_ACCESS_RDWR,
+						.start = disp->sync->offset + 0x0000,
+						.limit = disp->sync->offset + 0x0fff,
+					}, sizeof(struct nv_dma_v0), &core->sync);
 	if (ret)
 		return ret;
 
-	ret = nvif_object_ctor(&core->chan.object, "kmsCoreVramCtxdma", NV50_DISP_HANDLE_VRAM,
-			       NV_DMA_IN_MEMORY,
-			       (&(struct nv_dma_v0) {
-					.target = NV_DMA_V0_TARGET_VRAM,
-					.access = NV_DMA_V0_ACCESS_RDWR,
-					.start = 0,
-					.limit = drm->device.info.ram_user - 1
-			       }), sizeof(struct nv_dma_v0),
-			       &core->vram);
+	ret = nvif_dispchan_ctxdma_ctor(&core->chan, "kmsCoreVramCtxdma", NV50_DISP_HANDLE_VRAM,
+					NV_DMA_IN_MEMORY, &(struct nv_dma_v0) {
+						.target = NV_DMA_V0_TARGET_VRAM,
+						.access = NV_DMA_V0_ACCESS_RDWR,
+						.start = 0,
+						.limit = drm->device.impl->ram_user - 1,
+					}, sizeof(struct nv_dma_v0), &core->vram);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/nouveau/dispnv50/core.h +3 -2
index 1343a1d224c0..f9223764a1f5 100644
@@ -5,14 +5,15 @@
 #include "crc.h"
 #include <nouveau_encoder.h>
 
+#include <nvif/ctxdma.h>
 #include <nvif/dispchan.h>
 
 struct nv50_core {
 	const struct nv50_core_func *func;
 	struct nvif_dispchan chan;
 
-	struct nvif_object vram;
-	struct nvif_object sync;
+	struct nvif_ctxdma sync;
+	struct nvif_ctxdma vram;
 
 	bool assign_windows;
 };
drivers/gpu/drm/nouveau/dispnv50/core507d.c +1 -1
index dab9fb984765..4127bc05ea80 100644
@@ -135,7 +135,7 @@ core507d_init(struct nv50_core *core)
 	if ((ret = PUSH_WAIT(push, 2)))
 		return ret;
 
-	PUSH_MTHD(push, NV507D, SET_CONTEXT_DMA_NOTIFIER, core->sync.handle);
+	PUSH_MTHD(push, NV507D, SET_CONTEXT_DMA_NOTIFIER, core->sync.object.handle);
 	return PUSH_KICK(push);
 }
 
drivers/gpu/drm/nouveau/dispnv50/corec37d.c +1 -1
index 60535526ac89..7e666c07e96a 100644
@@ -125,7 +125,7 @@ corec37d_init(struct nv50_core *core)
 	if ((ret = PUSH_WAIT(push, 2 + windows * 5)))
 		return ret;
 
-	PUSH_MTHD(push, NVC37D, SET_CONTEXT_DMA_NOTIFIER, core->sync.handle);
+	PUSH_MTHD(push, NVC37D, SET_CONTEXT_DMA_NOTIFIER, core->sync.object.handle);
 
 	for (i = 0; i < windows; i++) {
 		PUSH_MTHD(push, NVC37D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS(i),
drivers/gpu/drm/nouveau/dispnv50/corec57d.c +1 -1
index 485892c2e775..e522c1e43a64 100644
@@ -36,7 +36,7 @@ corec57d_init(struct nv50_core *core)
 	if ((ret = PUSH_WAIT(push, 2 + windows * 5)))
 		return ret;
 
-	PUSH_MTHD(push, NVC57D, SET_CONTEXT_DMA_NOTIFIER, core->sync.handle);
+	PUSH_MTHD(push, NVC57D, SET_CONTEXT_DMA_NOTIFIER, core->sync.object.handle);
 
 	for (i = 0; i < windows; i++) {
 		PUSH_MTHD(push, NVC57D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS(i),
drivers/gpu/drm/nouveau/dispnv50/crc.c +10 -12
index 72ce4ada284f..97905ec648d0 100644
@@ -507,17 +507,15 @@ nv50_crc_ctx_init(struct nv50_head *head, struct nvif_mmu *mmu,
 	if (ret)
 		return ret;
 
-	ret = nvif_object_ctor(&core->chan.object, "kmsCrcNtfyCtxDma",
-			       NV50_DISP_HANDLE_CRC_CTX(head, idx),
-			       NV_DMA_IN_MEMORY,
-			       (&(struct nv_dma_v0) {
-					.target = NV_DMA_V0_TARGET_VRAM,
-					.access = NV_DMA_V0_ACCESS_RDWR,
-					.start = ctx->mem.impl->addr,
-					.limit =  ctx->mem.impl->addr
-						+ ctx->mem.impl->size - 1,
-			       }), sizeof(struct nv_dma_v0),
-			       &ctx->ntfy);
+	ret = nvif_dispchan_ctxdma_ctor(&core->chan, "kmsCrcNtfyCtxDma",
+					NV50_DISP_HANDLE_CRC_CTX(head, idx),
+					NV_DMA_IN_MEMORY, &(struct nv_dma_v0) {
+						.target = NV_DMA_V0_TARGET_VRAM,
+						.access = NV_DMA_V0_ACCESS_RDWR,
+						.start = ctx->mem.impl->addr,
+						.limit = ctx->mem.impl->addr +
+							 ctx->mem.impl->size - 1,
+					}, sizeof(struct nv_dma_v0), &ctx->ntfy);
 	if (ret)
 		goto fail_fini;
 
@@ -531,7 +529,7 @@ nv50_crc_ctx_init(struct nv50_head *head, struct nvif_mmu *mmu,
 static inline void
 nv50_crc_ctx_fini(struct nv50_crc_notifier_ctx *ctx)
 {
-	nvif_object_dtor(&ctx->ntfy);
+	nvif_ctxdma_dtor(&ctx->ntfy);
 	nvif_mem_unmap_dtor(&ctx->mem, &ctx->map);
 }
 
drivers/gpu/drm/nouveau/dispnv50/crc.h +2 -1
index 48564ceddb97..2b722135af87 100644
@@ -6,6 +6,7 @@
 #include <drm/drm_crtc.h>
 #include <drm/drm_vblank_work.h>
 
+#include <nvif/ctxdma.h>
 #include <nvif/mem.h>
 #include <nvkm/subdev/bios.h>
 #include "nouveau_encoder.h"
@@ -41,7 +42,7 @@ enum nv50_crc_source_type {
 struct nv50_crc_notifier_ctx {
 	struct nvif_mem mem;
 	struct nvif_map map;
-	struct nvif_object ntfy;
+	struct nvif_ctxdma ntfy;
 };
 
 struct nv50_crc_atom {
drivers/gpu/drm/nouveau/dispnv50/crc907d.c +2 -2
index 998978967c4c..0da9ed49017e 100644
@@ -61,7 +61,7 @@ crc907d_set_src(struct nv50_head *head, int or, enum nv50_crc_source_type source
 		return ret;
 
 	if (source) {
-		PUSH_MTHD(push, NV907D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx->ntfy.handle);
+		PUSH_MTHD(push, NV907D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx->ntfy.object.handle);
 		PUSH_MTHD(push, NV907D, HEAD_SET_CRC_CONTROL(i), crc_args);
 	} else {
 		PUSH_MTHD(push, NV907D, HEAD_SET_CRC_CONTROL(i), crc_args);
@@ -81,7 +81,7 @@ crc907d_set_ctx(struct nv50_head *head, struct nv50_crc_notifier_ctx *ctx)
 	if ((ret = PUSH_WAIT(push, 2)))
 		return ret;
 
-	PUSH_MTHD(push, NV907D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx ? ctx->ntfy.handle : 0);
+	PUSH_MTHD(push, NV907D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx ? ctx->ntfy.object.handle : 0);
 	return 0;
 }
 
drivers/gpu/drm/nouveau/dispnv50/crcc37d.c +2 -2
index 6af15f3232d9..87d54616cb11 100644
@@ -41,7 +41,7 @@ crcc37d_set_src(struct nv50_head *head, int or, enum nv50_crc_source_type source
 		return ret;
 
 	if (source) {
-		PUSH_MTHD(push, NVC37D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx->ntfy.handle);
+		PUSH_MTHD(push, NVC37D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx->ntfy.object.handle);
 		PUSH_MTHD(push, NVC37D, HEAD_SET_CRC_CONTROL(i), crc_args);
 	} else {
 		PUSH_MTHD(push, NVC37D, HEAD_SET_CRC_CONTROL(i), 0);
@@ -60,7 +60,7 @@ int crcc37d_set_ctx(struct nv50_head *head, struct nv50_crc_notifier_ctx *ctx)
 	if ((ret = PUSH_WAIT(push, 2)))
 		return ret;
 
-	PUSH_MTHD(push, NVC37D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx ? ctx->ntfy.handle : 0);
+	PUSH_MTHD(push, NVC37D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx ? ctx->ntfy.object.handle : 0);
 	return 0;
 }
 
drivers/gpu/drm/nouveau/dispnv50/crcc57d.c +1 -1
index ad591dcb0bc9..803275a3dd31 100644
@@ -37,7 +37,7 @@ static int crcc57d_set_src(struct nv50_head *head, int or, enum nv50_crc_source_
 		return ret;
 
 	if (source) {
-		PUSH_MTHD(push, NVC57D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx->ntfy.handle);
+		PUSH_MTHD(push, NVC57D, HEAD_SET_CONTEXT_DMA_CRC(i), ctx->ntfy.object.handle);
 		PUSH_MTHD(push, NVC57D, HEAD_SET_CRC_CONTROL(i), crc_args);
 	} else {
 		PUSH_MTHD(push, NVC57D, HEAD_SET_CRC_CONTROL(i), 0);
drivers/gpu/drm/nouveau/dispnv50/curs507a.c +1 -1
index 8017cd0bd636..58bfaf036bbb 100644
@@ -77,7 +77,7 @@ static void
 curs507a_prepare(struct nv50_wndw *wndw, struct nv50_head_atom *asyh,
 		 struct nv50_wndw_atom *asyw)
 {
-	u32 handle = nv50_disp(wndw->plane.dev)->core->vram.handle;
+	u32 handle = nv50_disp(wndw->plane.dev)->core->vram.object.handle;
 	u32 offset = asyw->image.offset[0];
 	if (asyh->curs.handle != handle || asyh->curs.offset != offset) {
 		asyh->curs.handle = handle;
drivers/gpu/drm/nouveau/dispnv50/head.c +1 -1
index 007857ac8542..3a192dd8635a 100644
@@ -274,7 +274,7 @@ nv50_head_atomic_check_lut(struct nv50_head *head,
 			  size, crtc->base.id, crtc->name);
 		return -EINVAL;
 	}
-	asyh->olut.handle = disp->core->vram.handle;
+	asyh->olut.handle = disp->core->vram.object.handle;
 	asyh->olut.buffer = !asyh->olut.buffer;
 
 	return 0;
drivers/gpu/drm/nouveau/dispnv50/head507d.c +1 -1
index 634f6166f38d..dc3847f1f1dc 100644
@@ -265,7 +265,7 @@ head507d_core_calc(struct nv50_head *head, struct nv50_head_atom *asyh)
 		asyh->core.w = asyh->state.mode.hdisplay;
 		asyh->core.h = asyh->state.mode.vdisplay;
 	}
-	asyh->core.handle = disp->core->vram.handle;
+	asyh->core.handle = disp->core->vram.object.handle;
 	asyh->core.offset = 0;
 	asyh->core.format = NV507D_HEAD_SET_PARAMS_FORMAT_A8R8G8B8;
 	asyh->core.kind = NV507D_HEAD_SET_PARAMS_KIND_KIND_PITCH;
drivers/gpu/drm/nouveau/dispnv50/wndw.c +23 -27

101 lines not on this page · raw message

drivers/gpu/drm/nouveau/dispnv50/wndw.h +5 -3
index 68092e6445fa..3efad1f3282f 100644
@@ -5,11 +5,13 @@
 #include "atom.h"
 #include "lut.h"
 
+#include <nvif/ctxdma.h>
 #include <nvif/dispchan.h>
 
 struct nv50_wndw_ctxdma {
 	struct list_head head;
-	struct nvif_object object;
+
+	struct nvif_ctxdma ctxdma;
 };
 
 struct nv50_wndw {
@@ -30,8 +32,8 @@ struct nv50_wndw {
 	struct nvif_dispchan wndw;
 	struct nvif_dispchan wimm;
 
-	struct nvif_object vram;
-	struct nvif_object sync;
+	struct nvif_ctxdma vram;
+	struct nvif_ctxdma sync;
 
 	u16 ntfy;
 	u16 sema;
drivers/gpu/drm/nouveau/include/nvif/ctxdma.h new file +29 -0
new file mode 100644
index 000000000000..ff80db834bd1
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVIF_CTXDMA_H__
+#define __NVIF_CTXDMA_H__
+#include <nvif/object.h>
+#include <nvif/driverif.h>
+
+struct nvif_ctxdma {
+	const struct nvif_ctxdma_impl *impl;
+	struct nvif_ctxdma_priv *priv;
+	struct nvif_object object;
+};
+
+static inline void
+nvif_ctxdma_ctor(struct nvif_object *parent, const char *name, u32 handle, s32 oclass,
+		 struct nvif_ctxdma *ctxdma)
+{
+	nvif_object_ctor(parent, name, handle, oclass, &ctxdma->object);
+}
+
+static inline void
+nvif_ctxdma_dtor(struct nvif_ctxdma *ctxdma)
+{
+	if (!ctxdma->impl)
+		return;
+
+	ctxdma->impl->del(ctxdma->priv);
+	ctxdma->impl = NULL;
+}
+#endif
drivers/gpu/drm/nouveau/include/nvif/dispchan.h +4 -0
index b1d3503e054c..d76eb35bc1c6 100644
@@ -3,6 +3,7 @@
 #define __NVIF_DISPCHAN_H__
 #include "disp.h"
 #include "push.h"
+struct nvif_ctxdma;
 
 struct nvif_dispchan {
 	const struct nvif_disp_chan_impl *impl;
@@ -18,4 +19,7 @@ int nvif_dispchan_ctor(struct nvif_disp *, const char *name, u32 handle, s32 ocl
 		       struct nvif_mmu *, struct nvif_dispchan *);
 int nvif_dispchan_oneinit(struct nvif_dispchan *);
 void nvif_dispchan_dtor(struct nvif_dispchan *);
+
+int nvif_dispchan_ctxdma_ctor(struct nvif_dispchan *, const char *name, u32 handle, s32 oclass,
+			      void *argv, u32 argc, struct nvif_ctxdma *ctxdma);
 #endif
drivers/gpu/drm/nouveau/include/nvif/driverif.h +13 -0
index d317fcd29091..8ae50be82a02 100644
@@ -18,6 +18,7 @@ struct nvif_conn_priv;
 struct nvif_outp_priv;
 struct nvif_head_priv;
 struct nvif_disp_chan_priv;
+struct nvif_ctxdma_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -361,9 +362,21 @@ struct nvif_head_impl {
 		      const struct nvif_event_impl **, struct nvif_event_priv **);
 };
 
+#include <nvif/cl0002.h>
+
+struct nvif_ctxdma_impl {
+	void (*del)(struct nvif_ctxdma_priv *);
+};
+
 struct nvif_disp_chan_impl {
 	void (*del)(struct nvif_disp_chan_priv *);
 	struct nvif_mapinfo map;
+
+	struct {
+		int (*new)(struct nvif_disp_chan_priv *, u32 handle, s32 oclass,
+			   struct nv_dma_v0 *argv, u32 argc,
+			   const struct nvif_ctxdma_impl **, struct nvif_ctxdma_priv **);
+	} ctxdma;
 };
 
 struct nvif_disp_impl {
drivers/gpu/drm/nouveau/nvif/dispchan.c +17 -0
index fc4f50da1a43..03738de5d791 100644
@@ -20,6 +20,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 #include <nvif/dispchan.h>
+#include <nvif/ctxdma.h>
 #include <nvif/device.h>
 #include <nvif/driverif.h>
 #include <nvif/push507c.h>
@@ -28,6 +29,22 @@
 #include <nvif/class.h>
 #include <nvhw/class/cl507c.h>
 
+int
+nvif_dispchan_ctxdma_ctor(struct nvif_dispchan *chan, const char *name, u32 handle, s32 oclass,
+			  void *argv, u32 argc, struct nvif_ctxdma *ctxdma)
+{
+	int ret;
+
+	ret = chan->impl->ctxdma.new(chan->priv, handle, oclass, argv, argc,
+				     &ctxdma->impl, &ctxdma->priv);
+	NVIF_ERRON(ret, &chan->object, "[NEW ctxdma%04x handle:%08x]", oclass, handle);
+	if (ret)
+		return ret;
+
+	nvif_ctxdma_ctor(&chan->object, name ?: "nvifDispChanCtxdma", handle, oclass, ctxdma);
+	return 0;
+}
+
 static int
 nvif_dispchan_kick(struct nvif_push *push)
 {
drivers/gpu/drm/nouveau/nvkm/engine/disp/chan.c +48 -41

138 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c +0 -6
index 797131ed7d67..463600e4f368 100644
@@ -71,7 +71,6 @@ nvkm_dmaobj_ctor(const struct nvkm_dmaobj_func *func, struct nvkm_dma *dma,
 	union {
 		struct nv_dma_v0 v0;
 	} *args = *pdata;
-	struct nvkm_object *parent = oclass->parent;
 	void *data = *pdata;
 	u32 size = *psize;
 	int ret = -ENOSYS;
@@ -80,12 +79,7 @@ nvkm_dmaobj_ctor(const struct nvkm_dmaobj_func *func, struct nvkm_dma *dma,
 	dmaobj->func = func;
 	dmaobj->dma = dma;
 
-	nvif_ioctl(parent, "create dma size %d\n", *psize);
 	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
-		nvif_ioctl(parent, "create dma vers %d target %d access %d "
-				   "start %016llx limit %016llx\n",
-			   args->v0.version, args->v0.target, args->v0.access,
-			   args->v0.start, args->v0.limit);
 		dmaobj->target = args->v0.target;
 		dmaobj->access = args->v0.access;
 		dmaobj->start  = args->v0.start;
drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf100.c +0 -5
index ef7ac360101e..23f7c275dd3b 100644
@@ -73,7 +73,6 @@ gf100_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
 	union {
 		struct gf100_dma_v0 v0;
 	} *args;
-	struct nvkm_object *parent = oclass->parent;
 	struct gf100_dmaobj *dmaobj;
 	u32 kind, user, unkn;
 	int ret;
@@ -90,11 +89,7 @@ gf100_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
 	ret  = -ENOSYS;
 	args = data;
 
-	nvif_ioctl(parent, "create gf100 dma size %d\n", size);
 	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(parent,
-			   "create gf100 dma vers %d priv %d kind %02x\n",
-			   args->v0.version, args->v0.priv, args->v0.kind);
 		kind = args->v0.kind;
 		user = args->v0.priv;
 		unkn = 0;
drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf119.c +0 -5
index c068cee34588..5b0f3d39c226 100644
@@ -71,7 +71,6 @@ gf119_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
 	union {
 		struct gf119_dma_v0 v0;
 	} *args;
-	struct nvkm_object *parent = oclass->parent;
 	struct gf119_dmaobj *dmaobj;
 	u32 kind, page;
 	int ret;
@@ -88,11 +87,7 @@ gf119_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
 	ret  = -ENOSYS;
 	args = data;
 
-	nvif_ioctl(parent, "create gf119 dma size %d\n", size);
 	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(parent,
-			   "create gf100 dma vers %d page %d kind %02x\n",
-			   args->v0.version, args->v0.page, args->v0.kind);
 		kind = args->v0.kind;
 		page = args->v0.page;
 	} else
drivers/gpu/drm/nouveau/nvkm/engine/dma/usergv100.c +0 -5
index 39eba9fc82be..c027efbcb85b 100644
@@ -70,7 +70,6 @@ gv100_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
 	union {
 		struct gf119_dma_v0 v0;
 	} *args;
-	struct nvkm_object *parent = oclass->parent;
 	struct gv100_dmaobj *dmaobj;
 	u32 kind, page;
 	int ret;
@@ -87,11 +86,7 @@ gv100_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
 	ret  = -ENOSYS;
 	args = data;
 
-	nvif_ioctl(parent, "create gv100 dma size %d\n", size);
 	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(parent,
-			   "create gv100 dma vers %d page %d kind %02x\n",
-			   args->v0.version, args->v0.page, args->v0.kind);
 		kind = args->v0.kind != 0;
 		page = args->v0.page != 0;
 	} else
drivers/gpu/drm/nouveau/nvkm/engine/dma/usernv50.c +0 -6
index 6a85b5dea643..2c3b2e7d3c2e 100644
@@ -73,7 +73,6 @@ nv50_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
 	union {
 		struct nv50_dma_v0 v0;
 	} *args;
-	struct nvkm_object *parent = oclass->parent;
 	struct nv50_dmaobj *dmaobj;
 	u32 user, part, comp, kind;
 	int ret;
@@ -90,12 +89,7 @@ nv50_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
 	ret  = -ENOSYS;
 	args = data;
 
-	nvif_ioctl(parent, "create nv50 dma size %d\n", size);
 	if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-		nvif_ioctl(parent, "create nv50 dma vers %d priv %d part %d "
-				   "comp %d kind %02x\n", args->v0.version,
-			   args->v0.priv, args->v0.part, args->v0.comp,
-			   args->v0.kind);
 		user = args->v0.priv;
 		part = args->v0.part;
 		comp = args->v0.comp;
Signature · 1 line
2.41.0
author
#134 lore raw

PATCH 133/156 drm/nouveau/nvif: remove disp chans from object rb

In reply to Ben Skeggs

- no more users

---
 drivers/gpu/drm/nouveau/dispnv50/base507c.c   |  3 +-
 drivers/gpu/drm/nouveau/dispnv50/core507d.c   |  3 +-
 drivers/gpu/drm/nouveau/dispnv50/ovly507e.c   |  3 +-
 drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c   |  3 +-
 drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c   |  3 +-
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  4 +--
 .../gpu/drm/nouveau/nvkm/engine/disp/udisp.c  | 35 +++++++------------
 7 files changed, 20 insertions(+), 34 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/base507c.c +1 -2
index 875c013c39b0..1cf80535fcfa 100644
@@ -318,8 +318,7 @@ base507c_new_(const struct nv50_wndw_func *func, const u32 *format,
 		goto done;
 
 	ret = disp->impl->chan.base.new(disp->priv, head, wndw->wndw.push.mem.priv,
-					&wndw->wndw.impl, &wndw->wndw.priv,
-					nvif_handle(&wndw->wndw.object));
+					&wndw->wndw.impl, &wndw->wndw.priv);
 	if (ret)
 		goto done;
 
drivers/gpu/drm/nouveau/dispnv50/core507d.c +1 -2
index 4127bc05ea80..dae2b9e68ca7 100644
@@ -169,8 +169,7 @@ core507d_new_(const struct nv50_core_func *func, struct nouveau_drm *drm,
 		goto done;
 
 	ret = disp->impl->chan.core.new(disp->priv, core->chan.push.mem.priv,
-					&core->chan.impl, &core->chan.priv,
-					nvif_handle(&core->chan.object));
+					&core->chan.impl, &core->chan.priv);
 	if (ret)
 		goto done;
 
drivers/gpu/drm/nouveau/dispnv50/ovly507e.c +1 -2
index 458c6f9e63f0..ab011c38b8fb 100644
@@ -160,8 +160,7 @@ ovly507e_new_(const struct nv50_wndw_func *func, const u32 *format,
 		goto done;
 
 	ret = disp->impl->chan.ovly.new(disp->priv, wndw->id, wndw->wndw.push.mem.priv,
-					&wndw->wndw.impl, &wndw->wndw.priv,
-					nvif_handle(&wndw->wndw.object));
+					&wndw->wndw.impl, &wndw->wndw.priv);
 	if (ret)
 		goto done;
 
drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c +1 -2
index 2f4f0ad89b5e..34324b20ee0e 100644
@@ -75,8 +75,7 @@ wimmc37b_init_(const struct nv50_wimm_func *func, struct nouveau_drm *drm,
 		goto done;
 
 	ret = disp->impl->chan.wimm.new(disp->priv, wndw->id, wndw->wimm.push.mem.priv,
-					&wndw->wimm.impl, &wndw->wimm.priv,
-					nvif_handle(&wndw->wimm.object));
+					&wndw->wimm.impl, &wndw->wimm.priv);
 	if (ret)
 		goto done;
 
drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c +1 -2
index 17751110edae..c44ea1574863 100644
@@ -364,8 +364,7 @@ wndwc37e_new_(const struct nv50_wndw_func *func, struct nouveau_drm *drm,
 		goto done;
 
 	ret = disp->impl->chan.wndw.new(disp->priv, wndw->id, wndw->wndw.push.mem.priv,
-					&wndw->wndw.impl, &wndw->wndw.priv,
-					nvif_handle(&wndw->wndw.object));
+					&wndw->wndw.impl, &wndw->wndw.priv);
 	if (ret)
 		goto done;
 
drivers/gpu/drm/nouveau/include/nvif/driverif.h +2 -2
index 8ae50be82a02..6161a29fb07f 100644
@@ -411,14 +411,14 @@ struct nvif_disp_impl {
 			s32 oclass;
 			int (*new)(struct nvif_disp_priv *, struct nvif_mem_priv *,
 				   const struct nvif_disp_chan_impl **,
-				   struct nvif_disp_chan_priv **, u64 handle);
+				   struct nvif_disp_chan_priv **);
 		} core;
 
 		struct nvif_disp_impl_dmac {
 			s32 oclass;
 			int (*new)(struct nvif_disp_priv *, u8 id, struct nvif_mem_priv *,
 				   const struct nvif_disp_chan_impl **,
-				   struct nvif_disp_chan_priv **, u64 handle);
+				   struct nvif_disp_chan_priv **);
 		} base, ovly, wndw, wimm;
 
 		struct nvif_disp_impl_pioc {
drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c +13 -22
index bc15fe149a86..321b5b12515c 100644
@@ -30,8 +30,7 @@
 static int
 nvkm_udisp_chan_new(struct nvif_disp_priv *udisp, const struct nvkm_disp_func_chan *func,
 		    u8 nr, u8 id, struct nvif_mem_priv *umem,
-		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv,
-		    u64 handle)
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv)
 {
 	struct nvkm_memory *memory = NULL;
 	struct nvkm_object *object;
@@ -48,9 +47,6 @@ nvkm_udisp_chan_new(struct nvif_disp_priv *udisp, const struct nvkm_disp_func_ch
 	if (ret)
 		return ret;
 
-	if (handle)
-		return nvkm_object_link_rb(udisp->object.client, &udisp->object, handle, object);
-
 	nvkm_object_link(&udisp->object, object);
 	return 0;
 }
@@ -62,7 +58,7 @@ nvkm_udisp_oimm_new(struct nvif_disp_priv *udisp, u8 id,
 	struct nvkm_disp *disp = udisp->disp;
 
 	return nvkm_udisp_chan_new(udisp, &disp->func->user.oimm, disp->head.nr, id, NULL,
-				   pimpl, ppriv, 0);
+				   pimpl, ppriv);
 }
 
 static int
@@ -72,61 +68,56 @@ nvkm_udisp_curs_new(struct nvif_disp_priv *udisp, u8 id,
 	struct nvkm_disp *disp = udisp->disp;
 
 	return nvkm_udisp_chan_new(udisp, &disp->func->user.curs, disp->head.nr, id, NULL,
-				   pimpl, ppriv, 0);
+				   pimpl, ppriv);
 }
 
 static int
 nvkm_udisp_wimm_new(struct nvif_disp_priv *udisp, u8 id, struct nvif_mem_priv *umem,
-		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv,
-		    u64 handle)
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv)
 {
 	struct nvkm_disp *disp = udisp->disp;
 
 	return nvkm_udisp_chan_new(udisp, &disp->func->user.wimm, disp->wndw.nr, id, umem,
-				   pimpl, ppriv, 0);
+				   pimpl, ppriv);
 }
 
 static int
 nvkm_udisp_wndw_new(struct nvif_disp_priv *udisp, u8 id, struct nvif_mem_priv *umem,
-		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv,
-		    u64 handle)
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv)
 {
 	struct nvkm_disp *disp = udisp->disp;
 
 	return nvkm_udisp_chan_new(udisp, &disp->func->user.wndw, disp->wndw.nr, id, umem,
-				   pimpl, ppriv, handle);
+				   pimpl, ppriv);
 }
 
 static int
 nvkm_udisp_ovly_new(struct nvif_disp_priv *udisp, u8 id, struct nvif_mem_priv *umem,
-		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv,
-		    u64 handle)
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv)
 {
 	struct nvkm_disp *disp = udisp->disp;
 
 	return nvkm_udisp_chan_new(udisp, &disp->func->user.ovly, disp->head.nr, id, umem,
-				   pimpl, ppriv, handle);
+				   pimpl, ppriv);
 }
 
 static int
 nvkm_udisp_base_new(struct nvif_disp_priv *udisp, u8 id, struct nvif_mem_priv *umem,
-		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv,
-		    u64 handle)
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv)
 {
 	struct nvkm_disp *disp = udisp->disp;
 
 	return nvkm_udisp_chan_new(udisp, &disp->func->user.base, disp->head.nr, id, umem,
-				   pimpl, ppriv, handle);
+				   pimpl, ppriv);
 }
 
 static int
 nvkm_udisp_core_new(struct nvif_disp_priv *udisp, struct nvif_mem_priv *umem,
-		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv,
-		    u64 handle)
+		    const struct nvif_disp_chan_impl **pimpl, struct nvif_disp_chan_priv **ppriv)
 {
 	struct nvkm_disp *disp = udisp->disp;
 
-	return nvkm_udisp_chan_new(udisp, &disp->func->user.core, 1, 0, umem, pimpl, ppriv, handle);
+	return nvkm_udisp_chan_new(udisp, &disp->func->user.core, 1, 0, umem, pimpl, ppriv);
 }
 
 static int
Signature · 1 line
2.41.0
author
#135 lore raw

PATCH 134/156 drm/nouveau/nvif: rework device "new cgrp" api

In reply to Ben Skeggs

- transition from "ioctl" interface

---
 drivers/gpu/drm/nouveau/include/nvif/cgrp.h   | 17 +++++
 .../gpu/drm/nouveau/include/nvif/driverif.h   | 10 +++
 drivers/gpu/drm/nouveau/include/nvif/if0021.h | 16 -----
 drivers/gpu/drm/nouveau/nvif/Kbuild           |  1 +
 drivers/gpu/drm/nouveau/nvif/cgrp.c           | 52 ++++++++++++++
 drivers/gpu/drm/nouveau/nvkm/device/user.c    | 19 ++++++
 .../gpu/drm/nouveau/nvkm/engine/fifo/base.c   | 14 ----
 .../gpu/drm/nouveau/nvkm/engine/fifo/priv.h   |  2 -
 .../gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c  | 67 +++++++++++++------
 .../gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.h  |  9 +++
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    |  9 +++
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h    |  1 +
 12 files changed, 163 insertions(+), 54 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/include/nvif/cgrp.h
 delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0021.h
 create mode 100644 drivers/gpu/drm/nouveau/nvif/cgrp.c
 create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.h
drivers/gpu/drm/nouveau/include/nvif/cgrp.h new file +17 -0
new file mode 100644
index 000000000000..337ba67c7695
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVIF_CGRP_H__
+#define __NVIF_CGRP_H__
+#include <nvif/object.h>
+#include <nvif/driverif.h>
+struct nvif_device;
+struct nvif_vmm;
+
+struct nvif_cgrp {
+	const struct nvif_cgrp_impl *impl;
+	struct nvif_cgrp_priv *priv;
+	struct nvif_object object;
+};
+
+int nvif_cgrp_ctor(struct nvif_device *, struct nvif_vmm *, int runl, struct nvif_cgrp *);
+void nvif_cgrp_dtor(struct nvif_cgrp *);
+#endif
drivers/gpu/drm/nouveau/include/nvif/driverif.h +10 -0
index 6161a29fb07f..75168621427a 100644
@@ -19,6 +19,7 @@ struct nvif_outp_priv;
 struct nvif_head_priv;
 struct nvif_disp_chan_priv;
 struct nvif_ctxdma_priv;
+struct nvif_cgrp_priv;
 
 struct nvif_driver {
 	const char *name;
@@ -430,6 +431,12 @@ struct nvif_disp_impl {
 	} chan;
 };
 
+struct nvif_cgrp_impl {
+	void (*del)(struct nvif_cgrp_priv *);
+
+	u16 id;
+};
+
 struct nvif_device_impl {
 	void (*del)(struct nvif_device_priv *);
 
@@ -546,6 +553,9 @@ struct nvif_device_impl {
 
 		struct {
 			s32 oclass;
+			int (*new)(struct nvif_device_priv *, u8 runl, struct nvif_vmm_priv *,
+				   const char *name, const struct nvif_cgrp_impl **,
+				   struct nvif_cgrp_priv **);
 		} cgrp;
 
 		struct {
drivers/gpu/drm/nouveau/include/nvif/if0021.h deleted +0 -16
deleted file mode 100644
index 5013def90455..000000000000
@@ -1,16 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-#ifndef __NVIF_IF0021_H__
-#define __NVIF_IF0021_H__
-
-union nvif_cgrp_args {
-	struct nvif_cgrp_v0 {
-		__u8  version;
-		__u8  namelen;
-		__u8  runlist;
-		__u8  pad03[3];
-		__u16 cgid;
-		__u64 vmm;
-		__u8  name[];
-	} v0;
-};
-#endif
drivers/gpu/drm/nouveau/nvif/Kbuild +1 -0
index 8e3ed36df6b3..50489933655c 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: MIT
 nvif-y := nvif/object.o
 nvif-y += nvif/client.o
+nvif-y += nvif/cgrp.o
 nvif-y += nvif/conn.o
 nvif-y += nvif/device.o
 nvif-y += nvif/disp.o
drivers/gpu/drm/nouveau/nvif/cgrp.c new file +52 -0

52 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/device/user.c +19 -0
index 6a3b41004abd..f76861945cd0 100644
@@ -35,6 +35,7 @@
 #include <engine/disp/priv.h>
 #include <engine/disp/udisp.h>
 #include <engine/fifo/ufifo.h>
+#include <engine/fifo/ucgrp.h>
 
 struct nvif_device_priv {
 	struct nvkm_object object;
@@ -94,6 +95,22 @@ nvkm_udevice_time(struct nvif_device_priv *udev)
 	return nvkm_timer_read(udev->device->timer);
 }
 
+static int
+nvkm_udevice_cgrp_new(struct nvif_device_priv *udev, u8 runl, struct nvif_vmm_priv *uvmm,
+		      const char *name, const struct nvif_cgrp_impl **pimpl,
+		      struct nvif_cgrp_priv **ppriv)
+{
+	struct nvkm_object *object;
+	int ret;
+
+	ret = nvkm_ucgrp_new(udev->device->fifo, runl, uvmm, name, pimpl, ppriv, &object);
+	if (ret)
+		return ret;
+
+	nvkm_object_link(&udev->object, object);
+	return 0;
+}
+
 static int
 nvkm_udevice_disp_new(struct nvif_device_priv *udev,
 		      const struct nvif_disp_impl **pimpl, struct nvif_disp_priv **ppriv)
@@ -338,6 +355,8 @@ nvkm_udevice_new(struct nvkm_device *device,
 	if (device->fifo) {
 		if (!WARN_ON(nvkm_subdev_oneinit(&device->fifo->engine.subdev))) {
 			nvkm_ufifo_ctor(device->fifo, &udev->impl.fifo);
+
+			udev->impl.fifo.cgrp.new = nvkm_udevice_cgrp_new;
 		}
 	}
 
drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c +0 -14
index 6bd464da1c96..1894a2075079 100644
@@ -75,9 +75,6 @@ nvkm_fifo_class_new(struct nvkm_device *device, const struct nvkm_oclass *oclass
 {
 	struct nvkm_fifo *fifo = nvkm_fifo(oclass->engine);
 
-	if (oclass->engn == &fifo->func->cgrp.user)
-		return nvkm_ucgrp_new(fifo, oclass, argv, argc, pobject);
-
 	if (oclass->engn == &fifo->func->chan.user)
 		return nvkm_uchan_new(fifo, NULL, oclass, argv, argc, pobject);
 
@@ -94,20 +91,9 @@ static int
 nvkm_fifo_class_get(struct nvkm_oclass *oclass, int index, const struct nvkm_device_oclass **class)
 {
 	struct nvkm_fifo *fifo = nvkm_fifo(oclass->engine);
-	const struct nvkm_fifo_func_cgrp *cgrp = &fifo->func->cgrp;
 	const struct nvkm_fifo_func_chan *chan = &fifo->func->chan;
 	int c = 0;
 
-	/* *_CHANNEL_GROUP_* */
-	if (cgrp->user.oclass) {
-		if (c++ == index) {
-			oclass->base = cgrp->user;
-			oclass->engn = &fifo->func->cgrp.user;
-			*class = &nvkm_fifo_class;
-			return 0;
-		}
-	}
-
 	/* *_CHANNEL_DMA, *_CHANNEL_GPFIFO_* */
 	if (chan->user.oclass) {
 		if (c++ == index) {
drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h +0 -2
index a0f3277605a5..d1386d00fc36 100644
@@ -208,6 +208,4 @@ extern const struct nvkm_chan_func ga100_chan;
 
 int nvkm_uchan_new(struct nvkm_fifo *, struct nvkm_cgrp *, const struct nvkm_oclass *,
 		   void *argv, u32 argc, struct nvkm_object **);
-int nvkm_ucgrp_new(struct nvkm_fifo *, const struct nvkm_oclass *, void *argv, u32 argc,
-		   struct nvkm_object **);
 #endif
drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.c +45 -22

115 lines not on this page · raw message

drivers/gpu/drm/nouveau/nvkm/engine/fifo/ucgrp.h new file +9 -0
new file mode 100644
index 000000000000..97f3d9eafdfc
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef __NVKM_UCGRP_H__
+#define __NVKM_UCGRP_H__
+#include <engine/fifo.h>
+#include <nvif/driverif.h>
+
+int nvkm_ucgrp_new(struct nvkm_fifo *, u8 runl, struct nvif_vmm_priv *,  const char *name,
+		   const struct nvif_cgrp_impl **, struct nvif_cgrp_priv **, struct nvkm_object **);
+#endif
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c +9 -0
index d8e7888410c3..5fac19738815 100644
@@ -33,6 +33,15 @@ struct nvif_vmm_priv {
 	struct nvif_vmm_impl impl;
 };
 
+struct nvkm_vmm *
+nvkm_uvmm_ref(struct nvif_vmm_priv *uvmm)
+{
+	if (uvmm)
+		return nvkm_vmm_ref(uvmm->vmm);
+
+	return NULL;
+}
+
 static const struct nvkm_object_func nvkm_uvmm;
 struct nvkm_vmm *
 nvkm_uvmm_search(struct nvkm_client *client, u64 handle)
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.h +1 -0
index 51c639cd0ce0..fb2deeb01d56 100644
@@ -6,4 +6,5 @@
 int nvkm_uvmm_new(struct nvkm_mmu *mmu, u8 type, u64 addr, u64 size,
 		  void *, u32, const struct nvif_vmm_impl **, struct nvif_vmm_priv **,
 		  struct nvkm_object **);
+struct nvkm_vmm *nvkm_uvmm_ref(struct nvif_vmm_priv *);
 #endif
Signature · 1 line
2.41.0