Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/debugfs: create debugfs late register functions

Although the device-centered debugfs functions can track requests for
the addition of DRM debugfs files at any time and have them added all
at once during drm_dev_register(), they are not able to create debugfs
files for modeset components, as they are registered after the primary
and the render drm_minor are registered.

So, create a drm_debugfs_late_register() function, which is responsible
for dealing with the creation of all the debugfs files for modeset
components at once. Therefore, the functions drm_debugfs_add_file()
and drm_debugfs_add_files() can be used in late_register hooks.

Signed-off-by: Maíra Canal <mcanal@igalia.com>
Reviewed-by: Melissa Wen <mwen@igalia.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Maíra Canal <mairacanal@riseup.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20221219120621.15086-4-mcanal@igalia.com

authored by

Maíra Canal and committed by
Maíra Canal
dbb23cf5 6fd80729

+21
+14
drivers/gpu/drm/drm_debugfs.c
··· 254 254 return 0; 255 255 } 256 256 257 + void drm_debugfs_late_register(struct drm_device *dev) 258 + { 259 + struct drm_minor *minor = dev->primary; 260 + struct drm_debugfs_entry *entry, *tmp; 261 + 262 + if (!minor) 263 + return; 264 + 265 + list_for_each_entry_safe(entry, tmp, &dev->debugfs_list, list) { 266 + debugfs_create_file(entry->file.name, S_IFREG | S_IRUGO, 267 + minor->debugfs_root, entry, &drm_debugfs_entry_fops); 268 + list_del(&entry->list); 269 + } 270 + } 257 271 258 272 int drm_debugfs_remove_files(const struct drm_info_list *files, int count, 259 273 struct drm_minor *minor)
+5
drivers/gpu/drm/drm_internal.h
··· 186 186 int drm_debugfs_init(struct drm_minor *minor, int minor_id, 187 187 struct dentry *root); 188 188 void drm_debugfs_cleanup(struct drm_minor *minor); 189 + void drm_debugfs_late_register(struct drm_device *dev); 189 190 void drm_debugfs_connector_add(struct drm_connector *connector); 190 191 void drm_debugfs_connector_remove(struct drm_connector *connector); 191 192 void drm_debugfs_crtc_add(struct drm_crtc *crtc); ··· 200 199 } 201 200 202 201 static inline void drm_debugfs_cleanup(struct drm_minor *minor) 202 + { 203 + } 204 + 205 + static inline void drm_debugfs_late_register(struct drm_device *dev) 203 206 { 204 207 } 205 208
+2
drivers/gpu/drm/drm_mode_config.c
··· 54 54 if (ret) 55 55 goto err_connector; 56 56 57 + drm_debugfs_late_register(dev); 58 + 57 59 return 0; 58 60 59 61 err_connector: