hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/gpu/drm/nouveau/nouveau_debugfs.c
....@@ -47,6 +47,28 @@
4747 }
4848
4949 static int
50
+nouveau_debugfs_strap_peek(struct seq_file *m, void *data)
51
+{
52
+ struct drm_info_node *node = m->private;
53
+ struct nouveau_drm *drm = nouveau_drm(node->minor->dev);
54
+ int ret;
55
+
56
+ ret = pm_runtime_get_sync(drm->dev->dev);
57
+ if (ret < 0 && ret != -EACCES) {
58
+ pm_runtime_put_autosuspend(drm->dev->dev);
59
+ return ret;
60
+ }
61
+
62
+ seq_printf(m, "0x%08x\n",
63
+ nvif_rd32(&drm->client.device.object, 0x101000));
64
+
65
+ pm_runtime_mark_last_busy(drm->dev->dev);
66
+ pm_runtime_put_autosuspend(drm->dev->dev);
67
+
68
+ return 0;
69
+}
70
+
71
+static int
5072 nouveau_debugfs_pstate_get(struct seq_file *m, void *data)
5173 {
5274 struct drm_device *drm = m->private;
....@@ -189,7 +211,8 @@
189211 };
190212
191213 static struct drm_info_list nouveau_debugfs_list[] = {
192
- { "vbios.rom", nouveau_debugfs_vbios_image, 0, NULL },
214
+ { "vbios.rom", nouveau_debugfs_vbios_image, 0, NULL },
215
+ { "strap_peek", nouveau_debugfs_strap_peek, 0, NULL },
193216 };
194217 #define NOUVEAU_DEBUGFS_ENTRIES ARRAY_SIZE(nouveau_debugfs_list)
195218
....@@ -200,24 +223,33 @@
200223 {"pstate", &nouveau_pstate_fops},
201224 };
202225
203
-int
226
+void
204227 nouveau_drm_debugfs_init(struct drm_minor *minor)
205228 {
229
+ struct nouveau_drm *drm = nouveau_drm(minor->dev);
206230 struct dentry *dentry;
207231 int i;
208232
209233 for (i = 0; i < ARRAY_SIZE(nouveau_debugfs_files); i++) {
210
- dentry = debugfs_create_file(nouveau_debugfs_files[i].name,
211
- S_IRUGO | S_IWUSR,
212
- minor->debugfs_root, minor->dev,
213
- nouveau_debugfs_files[i].fops);
214
- if (!dentry)
215
- return -ENOMEM;
234
+ debugfs_create_file(nouveau_debugfs_files[i].name,
235
+ S_IRUGO | S_IWUSR,
236
+ minor->debugfs_root, minor->dev,
237
+ nouveau_debugfs_files[i].fops);
216238 }
217239
218
- return drm_debugfs_create_files(nouveau_debugfs_list,
219
- NOUVEAU_DEBUGFS_ENTRIES,
220
- minor->debugfs_root, minor);
240
+ drm_debugfs_create_files(nouveau_debugfs_list,
241
+ NOUVEAU_DEBUGFS_ENTRIES,
242
+ minor->debugfs_root, minor);
243
+
244
+ /* Set the size of the vbios since we know it, and it's confusing to
245
+ * userspace if it wants to seek() but the file has a length of 0
246
+ */
247
+ dentry = debugfs_lookup("vbios.rom", minor->debugfs_root);
248
+ if (!dentry)
249
+ return;
250
+
251
+ d_inode(dentry)->i_size = drm->vbios.length;
252
+ dput(dentry);
221253 }
222254
223255 int
....@@ -229,7 +261,7 @@
229261 if (!drm->debugfs)
230262 return -ENOMEM;
231263
232
- ret = nvif_object_init(&drm->client.device.object, 0,
264
+ ret = nvif_object_ctor(&drm->client.device.object, "debugfsCtrl", 0,
233265 NVIF_CLASS_CONTROL, NULL, 0,
234266 &drm->debugfs->ctrl);
235267 if (ret)
....@@ -242,7 +274,7 @@
242274 nouveau_debugfs_fini(struct nouveau_drm *drm)
243275 {
244276 if (drm->debugfs && drm->debugfs->ctrl.priv)
245
- nvif_object_fini(&drm->debugfs->ctrl);
277
+ nvif_object_dtor(&drm->debugfs->ctrl);
246278
247279 kfree(drm->debugfs);
248280 drm->debugfs = NULL;