drm/vc4: debugfs: Protect device resources
Our current code now mixes some resources whose lifetime are tied to the device (clocks, IO mappings, etc.) and some that are tied to the DRM device (encoder, bridge). The device one will be freed at unbind time, but the DRM one will only be freed when the last user of the DRM device closes its file handle. So we end up with a time window during which we can call the encoder hooks, but we don't have access to the underlying resources and device. Let's protect all those sections with drm_dev_enter() and drm_dev_exit() so that we bail out if we are during that window. Acked-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Maxime Ripard <maxime@cerno.tech> Link: https://lore.kernel.org/r/20220711173939.1132294-63-maxime@cerno.tech
This commit is contained in:
parent
4e06fd9c7c
commit
be919b89b2
@ -3,6 +3,8 @@
|
|||||||
* Copyright © 2014 Broadcom
|
* Copyright © 2014 Broadcom
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <drm/drm_drv.h>
|
||||||
|
|
||||||
#include <linux/seq_file.h>
|
#include <linux/seq_file.h>
|
||||||
#include <linux/circ_buf.h>
|
#include <linux/circ_buf.h>
|
||||||
#include <linux/ctype.h>
|
#include <linux/ctype.h>
|
||||||
@ -41,11 +43,18 @@ vc4_debugfs_init(struct drm_minor *minor)
|
|||||||
static int vc4_debugfs_regset32(struct seq_file *m, void *unused)
|
static int vc4_debugfs_regset32(struct seq_file *m, void *unused)
|
||||||
{
|
{
|
||||||
struct drm_info_node *node = (struct drm_info_node *)m->private;
|
struct drm_info_node *node = (struct drm_info_node *)m->private;
|
||||||
|
struct drm_device *drm = node->minor->dev;
|
||||||
struct debugfs_regset32 *regset = node->info_ent->data;
|
struct debugfs_regset32 *regset = node->info_ent->data;
|
||||||
struct drm_printer p = drm_seq_file_printer(m);
|
struct drm_printer p = drm_seq_file_printer(m);
|
||||||
|
int idx;
|
||||||
|
|
||||||
|
if (!drm_dev_enter(drm, &idx))
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
drm_print_regset32(&p, regset);
|
drm_print_regset32(&p, regset);
|
||||||
|
|
||||||
|
drm_dev_exit(idx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user