From f21950ea35c86be79c293b199fe48b5152ec8311 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Sun, 14 Jun 2015 12:20:37 +1000 Subject: [PATCH] drm/nouveau/pm: stack perfdom class under perfmon Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c | 38 +++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c index 0e1536d5c777..f505a11a938a 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c @@ -576,12 +576,32 @@ nvkm_perfmon_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size) return -EINVAL; } +static struct nvkm_oclass +nvkm_perfmon_sclass[] = { + { .handle = NVIF_IOCTL_NEW_V0_PERFDOM, + .ofuncs = &nvkm_perfdom_ofuncs, + }, + {} +}; + +static int +nvkm_perfmon_ctor(struct nvkm_object *parent, struct nvkm_object *engine, + struct nvkm_oclass *oclass, void *data, u32 size, + struct nvkm_object **pobject) +{ + struct nvkm_parent *perfmon; + int ret = nvkm_parent_create(parent, engine, oclass, 0, + nvkm_perfmon_sclass, 0, &perfmon); + *pobject = perfmon ? &perfmon->object : NULL; + return ret; +} + static struct nvkm_ofuncs nvkm_perfmon_ofuncs = { - .ctor = _nvkm_object_ctor, - .dtor = nvkm_object_destroy, - .init = nvkm_object_init, - .fini = nvkm_object_fini, + .ctor = nvkm_perfmon_ctor, + .dtor = _nvkm_parent_dtor, + .init = _nvkm_parent_init, + .fini = _nvkm_parent_fini, .mthd = nvkm_perfmon_mthd, }; @@ -591,9 +611,6 @@ nvkm_pm_sclass[] = { .handle = NVIF_IOCTL_NEW_V0_PERFMON, .ofuncs = &nvkm_perfmon_ofuncs, }, - { .handle = NVIF_IOCTL_NEW_V0_PERFDOM, - .ofuncs = &nvkm_perfdom_ofuncs, - }, {}, }; @@ -622,6 +639,13 @@ nvkm_perfctx_ctor(struct nvkm_object *parent, struct nvkm_object *engine, struct nvkm_perfctx *ctx; int ret; + /* no context needed for perfdom objects... */ + if (nv_mclass(parent) != NV_DEVICE) { + atomic_inc(&parent->refcount); + *pobject = parent; + return 1; + } + ret = nvkm_engctx_create(parent, engine, oclass, NULL, 0, 0, 0, &ctx); *pobject = nv_object(ctx); if (ret) -- 2.20.1