[PATCH 071/156] drm/nouveau/nvif: rework ctrl "pstate info" api
Ben Skeggs
bskeggs at nvidia.com
Tue Apr 16 23:38:37 UTC 2024
- transition from "ioctl" interface
Signed-off-by: Ben Skeggs <bskeggs at nvidia.com>
---
.../gpu/drm/nouveau/include/nvif/driverif.h | 17 ++++++++
drivers/gpu/drm/nouveau/include/nvif/if0001.h | 15 -------
drivers/gpu/drm/nouveau/nouveau_debugfs.c | 6 +--
drivers/gpu/drm/nouveau/nvkm/device/ctrl.c | 40 ++++++-------------
4 files changed, 32 insertions(+), 46 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index aa1061266557..ba8b5ff9fcd6 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -23,8 +23,25 @@ struct nvif_mapinfo {
u64 length;
};
+struct nvif_control_pstate_info {
+ u8 version;
+ u8 count; /* out: number of power states */
+#define NVIF_CONTROL_PSTATE_INFO_USTATE_DISABLE (-1)
+#define NVIF_CONTROL_PSTATE_INFO_USTATE_PERFMON (-2)
+ s8 ustate_ac; /* out: target pstate index */
+ s8 ustate_dc; /* out: target pstate index */
+ s8 pwrsrc; /* out: current power source */
+#define NVIF_CONTROL_PSTATE_INFO_PSTATE_UNKNOWN (-1)
+#define NVIF_CONTROL_PSTATE_INFO_PSTATE_PERFMON (-2)
+ s8 pstate; /* out: current pstate index */
+};
+
struct nvif_control_impl {
void (*del)(struct nvif_control_priv *);
+
+ struct {
+ void (*info)(struct nvif_control_priv *, struct nvif_control_pstate_info *);
+ } pstate;
};
struct nvif_device_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0001.h b/drivers/gpu/drm/nouveau/include/nvif/if0001.h
index 4ced50e98ced..9bb955500934 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0001.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0001.h
@@ -2,24 +2,9 @@
#ifndef __NVIF_IF0001_H__
#define __NVIF_IF0001_H__
-#define NVIF_CONTROL_PSTATE_INFO 0x00
#define NVIF_CONTROL_PSTATE_ATTR 0x01
#define NVIF_CONTROL_PSTATE_USER 0x02
-struct nvif_control_pstate_info_v0 {
- __u8 version;
- __u8 count; /* out: number of power states */
-#define NVIF_CONTROL_PSTATE_INFO_V0_USTATE_DISABLE (-1)
-#define NVIF_CONTROL_PSTATE_INFO_V0_USTATE_PERFMON (-2)
- __s8 ustate_ac; /* out: target pstate index */
- __s8 ustate_dc; /* out: target pstate index */
- __s8 pwrsrc; /* out: current power source */
-#define NVIF_CONTROL_PSTATE_INFO_V0_PSTATE_UNKNOWN (-1)
-#define NVIF_CONTROL_PSTATE_INFO_V0_PSTATE_PERFMON (-2)
- __s8 pstate; /* out: current pstate index */
- __u8 pad06[2];
-};
-
struct nvif_control_pstate_attr_v0 {
__u8 version;
#define NVIF_CONTROL_PSTATE_ATTR_V0_STATE_CURRENT (-1)
diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
index e061ef7a1707..caccf99f1d8a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
+++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
@@ -73,16 +73,14 @@ nouveau_debugfs_pstate_get(struct seq_file *m, void *data)
struct drm_device *drm = m->private;
struct nouveau_debugfs *debugfs = nouveau_debugfs(drm);
struct nvif_object *ctrl;
- struct nvif_control_pstate_info_v0 info = {};
+ struct nvif_control_pstate_info info = {};
int ret, i;
if (!debugfs)
return -ENODEV;
ctrl = &debugfs->ctrl;
- ret = nvif_mthd(ctrl, NVIF_CONTROL_PSTATE_INFO, &info, sizeof(info));
- if (ret)
- return ret;
+ debugfs->impl->pstate.info(debugfs->priv, &info);
for (i = 0; i < info.count + 1; i++) {
const s32 state = i < info.count ? i :
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
index 5caa93665cc9..ea38592f5557 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/ctrl.c
@@ -37,37 +37,24 @@ struct nvif_control_priv {
struct nvkm_device *device;
};
-static int
-nvkm_control_mthd_pstate_info(struct nvkm_control *ctrl, void *data, u32 size)
+static void
+nvkm_control_pstate_info(struct nvif_control_priv *ctrl, struct nvif_control_pstate_info *info)
{
- union {
- struct nvif_control_pstate_info_v0 v0;
- } *args = data;
struct nvkm_clk *clk = ctrl->device->clk;
- int ret = -ENOSYS;
-
- nvif_ioctl(&ctrl->object, "control pstate info size %d\n", size);
- if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
- nvif_ioctl(&ctrl->object, "control pstate info vers %d\n",
- args->v0.version);
- } else
- return ret;
if (clk) {
- args->v0.count = clk->state_nr;
- args->v0.ustate_ac = clk->ustate_ac;
- args->v0.ustate_dc = clk->ustate_dc;
- args->v0.pwrsrc = clk->pwrsrc;
- args->v0.pstate = clk->pstate;
+ info->count = clk->state_nr;
+ info->ustate_ac = clk->ustate_ac;
+ info->ustate_dc = clk->ustate_dc;
+ info->pwrsrc = clk->pwrsrc;
+ info->pstate = clk->pstate;
} else {
- args->v0.count = 0;
- args->v0.ustate_ac = NVIF_CONTROL_PSTATE_INFO_V0_USTATE_DISABLE;
- args->v0.ustate_dc = NVIF_CONTROL_PSTATE_INFO_V0_USTATE_DISABLE;
- args->v0.pwrsrc = -ENODEV;
- args->v0.pstate = NVIF_CONTROL_PSTATE_INFO_V0_PSTATE_UNKNOWN;
+ info->count = 0;
+ info->ustate_ac = NVIF_CONTROL_PSTATE_INFO_USTATE_DISABLE;
+ info->ustate_dc = NVIF_CONTROL_PSTATE_INFO_USTATE_DISABLE;
+ info->pwrsrc = -ENODEV;
+ info->pstate = NVIF_CONTROL_PSTATE_INFO_PSTATE_UNKNOWN;
}
-
- return 0;
}
static int
@@ -177,8 +164,6 @@ nvkm_control_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
{
struct nvif_control_priv *ctrl = container_of(object, typeof(*ctrl), object);
switch (mthd) {
- case NVIF_CONTROL_PSTATE_INFO:
- return nvkm_control_mthd_pstate_info(ctrl, data, size);
case NVIF_CONTROL_PSTATE_ATTR:
return nvkm_control_mthd_pstate_attr(ctrl, data, size);
case NVIF_CONTROL_PSTATE_USER:
@@ -205,6 +190,7 @@ nvkm_control_del(struct nvif_control_priv *ctrl)
static const struct nvif_control_impl
nvkm_control_impl = {
.del = nvkm_control_del,
+ .pstate.info = nvkm_control_pstate_info,
};
int
--
2.41.0
More information about the Nouveau
mailing list