- transition from "ioctl" interface Signed-off-by: Ben Skeggs <bskeggs@xxxxxxxxxx> --- drivers/gpu/drm/nouveau/include/nvif/class.h | 2 -- .../gpu/drm/nouveau/include/nvif/driverif.h | 11 ++++++ drivers/gpu/drm/nouveau/nouveau_debugfs.c | 17 +++++---- drivers/gpu/drm/nouveau/nouveau_debugfs.h | 2 ++ drivers/gpu/drm/nouveau/nvkm/device/ctrl.c | 35 +++++++++++-------- drivers/gpu/drm/nouveau/nvkm/device/ctrl.h | 5 ++- drivers/gpu/drm/nouveau/nvkm/device/user.c | 20 +++++++++-- 7 files changed, 66 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvif/class.h b/drivers/gpu/drm/nouveau/include/nvif/class.h index b6bba7231750..6174999eacd3 100644 --- a/drivers/gpu/drm/nouveau/include/nvif/class.h +++ b/drivers/gpu/drm/nouveau/include/nvif/class.h @@ -3,8 +3,6 @@ #define __NVIF_CLASS_H__ /* these class numbers are made up by us, and not nvidia-assigned */ -#define NVIF_CLASS_CONTROL /* if0001.h */ -0x00000001 - #define NVIF_CLASS_SW_NV04 /* if0004.h */ -0x00000004 #define NVIF_CLASS_SW_NV10 /* if0005.h */ -0x00000005 #define NVIF_CLASS_SW_NV50 /* if0005.h */ -0x00000006 diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h index 44064b5da897..aa1061266557 100644 --- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h +++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h @@ -3,6 +3,7 @@ #define __NVIF_DRIVERIF_H__ struct nvif_client_priv; struct nvif_device_priv; +struct nvif_control_priv; struct nvif_driver { const char *name; @@ -22,6 +23,10 @@ struct nvif_mapinfo { u64 length; }; +struct nvif_control_impl { + void (*del)(struct nvif_control_priv *); +}; + struct nvif_device_impl { void (*del)(struct nvif_device_priv *); @@ -63,6 +68,12 @@ struct nvif_device_impl { u64 (*time)(struct nvif_device_priv *); + struct { + int (*new)(struct nvif_device_priv *, + const struct nvif_control_impl **, struct nvif_control_priv **, + u64 handle); + } control; + struct { s32 oclass; } usermode; diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c index e83db051e851..e061ef7a1707 100644 --- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c +++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c @@ -29,7 +29,6 @@ */ #include <linux/debugfs.h> -#include <nvif/class.h> #include <nvif/if0001.h> #include "nouveau_debugfs.h" #include "nouveau_drv.h" @@ -295,20 +294,26 @@ nouveau_drm_debugfs_init(struct drm_minor *minor) int nouveau_debugfs_init(struct nouveau_drm *drm) { + int ret; + drm->debugfs = kzalloc(sizeof(*drm->debugfs), GFP_KERNEL); if (!drm->debugfs) return -ENOMEM; - return nvif_object_ctor(&drm->client.device.object, "debugfsCtrl", 0, - NVIF_CLASS_CONTROL, NULL, 0, - &drm->debugfs->ctrl); + ret = drm->device.impl->control.new(drm->device.priv, &drm->debugfs->impl, + &drm->debugfs->priv, nvif_handle(&drm->debugfs->ctrl)); + if (ret) + return ret; + + nvif_object_ctor(&drm->device.object, "debugfsCtrl", 0, 0, &drm->debugfs->ctrl); + return 0; } void nouveau_debugfs_fini(struct nouveau_drm *drm) { - if (drm->debugfs && drm->debugfs->ctrl.priv) - nvif_object_dtor(&drm->debugfs->ctrl); + if (drm->debugfs && drm->debugfs->impl) + drm->debugfs->impl->del(drm->debugfs->priv); kfree(drm->debugfs); drm->debugfs = NULL; diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.h b/drivers/gpu/drm/nouveau/nouveau_debugfs.h index 77f0323b38ba..197e81f771d5 100644 --- a/drivers/gpu/drm/nouveau/nouveau_debugfs.h +++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.h @@ -9,6 +9,8 @@ #include "nouveau_drv.h" struct nouveau_debugfs { + const struct nvif_control_impl *impl; + struct nvif_control_priv *priv; struct nvif_object ctrl; }; diff --git a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c index a74fb78ca7ab..5caa93665cc9 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c @@ -26,7 +26,6 @@ #include <core/client.h> #include <subdev/clk.h> -#include <nvif/class.h> #include <nvif/if0001.h> #include <nvif/ioctl.h> #include <nvif/unpack.h> @@ -195,25 +194,33 @@ nvkm_control = { .mthd = nvkm_control_mthd, }; -static int -nvkm_control_new(struct nvkm_device *device, const struct nvkm_oclass *oclass, - void *data, u32 size, struct nvkm_object **pobject) +static void +nvkm_control_del(struct nvif_control_priv *ctrl) +{ + struct nvkm_object *object = &ctrl->object; + + nvkm_object_del(&object); +} + +static const struct nvif_control_impl +nvkm_control_impl = { + .del = nvkm_control_del, +}; + +int +nvkm_control_new(struct nvkm_device *device, const struct nvif_control_impl **pimpl, + struct nvif_control_priv **ppriv, struct nvkm_object **pobject) { struct nvif_control_priv *ctrl; if (!(ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL))) return -ENOMEM; - *pobject = &ctrl->object; + + nvkm_object_ctor(&nvkm_control, &(struct nvkm_oclass) {}, &ctrl->object); ctrl->device = device; - nvkm_object_ctor(&nvkm_control, oclass, &ctrl->object); + *pimpl = &nvkm_control_impl; + *ppriv = ctrl; + *pobject = &ctrl->object; return 0; } - -const struct nvkm_device_oclass -nvkm_control_oclass = { - .base.oclass = NVIF_CLASS_CONTROL, - .base.minver = -1, - .base.maxver = -1, - .ctor = nvkm_control_new, -}; diff --git a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.h b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.h index d241329a1e7a..c435ddf0a713 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.h +++ b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.h @@ -1,6 +1,9 @@ /* SPDX-License-Identifier: MIT */ #ifndef __NVKM_DEVICE_CTRL_H__ #define __NVKM_DEVICE_CTRL_H__ +#include <core/device.h> +#include <nvif/driverif.h> -extern const struct nvkm_device_oclass nvkm_control_oclass; +int nvkm_control_new(struct nvkm_device *, const struct nvif_control_impl **, + struct nvif_control_priv **, struct nvkm_object **); #endif diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c index b37c857863b8..14d548c3f6b0 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/user.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c @@ -39,6 +39,21 @@ struct nvif_device_priv { struct nvif_device_impl impl; }; +static int +nvkm_udevice_control_new(struct nvif_device_priv *udev, + const struct nvif_control_impl **pimpl, struct nvif_control_priv **ppriv, + u64 handle) +{ + struct nvkm_object *object; + int ret; + + ret = nvkm_control_new(udev->device, pimpl, ppriv, &object); + if (ret) + return ret; + + return nvkm_object_link_rb(udev->object.client, &udev->object, handle, object); +} + static u64 nvkm_udevice_time(struct nvif_device_priv *udev) { @@ -58,6 +73,7 @@ static const struct nvif_device_impl nvkm_udevice_impl = { .del = nvkm_udevice_del, .time = nvkm_udevice_time, + .control.new = nvkm_udevice_control_new, }; static int @@ -134,9 +150,7 @@ nvkm_udevice_child_get(struct nvkm_object *object, int index, } if (!sclass) { - if (index-- == 0) - sclass = &nvkm_control_oclass; - else if (device->mmu && index-- == 0) + if (device->mmu && index-- == 0) sclass = &device->mmu->user; else if (device->fault && index-- == 0) sclass = &device->fault->user; -- 2.41.0