Re: drm connectors, tegra, and the web they weave (was Re: [PATCH 58/59] drm/todo: Add new debugfs todo)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 18, 2019 at 05:19:38PM +0200, Greg Kroah-Hartman wrote:
> On Fri, Jun 14, 2019 at 10:36:14PM +0200, Daniel Vetter wrote:
> > Greg is busy already, but maybe he won't do everything ...
> > 
> > Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> > Signed-off-by: Daniel Vetter <daniel.vetter@xxxxxxxxx>
> > ---
> >  Documentation/gpu/todo.rst | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
> > index 9717540ee28f..026e55c517e1 100644
> > --- a/Documentation/gpu/todo.rst
> > +++ b/Documentation/gpu/todo.rst
> > @@ -375,6 +375,9 @@ There's a bunch of issues with it:
> >    this (together with the drm_minor->drm_device move) would allow us to remove
> >    debugfs_init.
> >  
> > +- Drop the return code and error checking from all debugfs functions. Greg KH is
> > +  working on this already.
> 
> 
> Part of this work was to try to delete drm_debugfs_remove_files().
> 
> There are only 4 files that currently still call this function:
> 	drivers/gpu/drm/tegra/dc.c
> 	drivers/gpu/drm/tegra/dsi.c
> 	drivers/gpu/drm/tegra/hdmi.c
> 	drivers/gpu/drm/tegra/sor.c
> 
> For dc.c, the driver wants to add debugfs files to the struct drm_crtc
> debugfs directory.  Which is fine, but it has to do some special memory
> allocation to get the debugfs callback to point not to the struct
> drm_minor pointer, but rather the drm_crtc structure.
> 
> So, to remove this call, I need to remove this special memory allocation
> and to do that, I need to somehow be able to cast from drm_minor back to
> the drm_crtc structure being used in this driver.  And I can't figure
> how they are related at all.
> 
> Any pointers here (pun intended) would be appreciated.
> 
> For the other 3 files, the situation is much the same, but I need to get
> from a 'struct drm_minor' pointer to a 'struct drm_connector' pointer.
> 
> I could just "open code" a bunch of calls to debugfs_create_file() for
> these drivers, which would solve this issue, but in a more "non-drm"
> way.  Is it worth to just do that instead of overthinking the whole
> thing and trying to squish it into the drm "model" of drm debugfs calls?

An example of "open coding" this is the patch below for the sor.c
driver.

Totally untested, not even built, but you should get the idea here.

thanks,

greg k-h

---------------

diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
index 5be5a0817dfe..3216221c77c4 100644
--- a/drivers/gpu/drm/tegra/sor.c
+++ b/drivers/gpu/drm/tegra/sor.c
@@ -414,7 +414,8 @@ struct tegra_sor {
 
 	struct drm_dp_aux *aux;
 
-	struct drm_info_list *debugfs_files;
+	struct dentry *debugfs_root;
+	struct drm_device *drm;
 
 	const struct tegra_sor_ops *ops;
 	enum tegra_io_pad pad;
@@ -1262,10 +1263,9 @@ static int tegra_sor_crc_wait(struct tegra_sor *sor, unsigned long timeout)
 
 static int tegra_sor_show_crc(struct seq_file *s, void *data)
 {
-	struct drm_info_node *node = s->private;
-	struct tegra_sor *sor = node->info_ent->data;
+	struct tegra_sor *sor = s->private;
 	struct drm_crtc *crtc = sor->output.encoder.crtc;
-	struct drm_device *drm = node->minor->dev;
+	struct drm_device *drm = sor->drm;
 	int err = 0;
 	u32 value;
 
@@ -1302,6 +1302,20 @@ static int tegra_sor_show_crc(struct seq_file *s, void *data)
 	return err;
 }
 
+static int crc_open(struct inode *inode, struct file *file)
+{
+	struct tegra_sor *sor = inode->i_private;
+	return single_open(file, tegra_sor_show_crc, sor);
+}
+
+static const struct file_operations crc_fops = {
+	.owner = THIS_MODULE,
+	.open = crc_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+};
+
 #define DEBUGFS_REG32(_name) { .name = #_name, .offset = _name }
 
 static const struct debugfs_reg32 tegra_sor_regs[] = {
@@ -1424,10 +1438,9 @@ static const struct debugfs_reg32 tegra_sor_regs[] = {
 
 static int tegra_sor_show_regs(struct seq_file *s, void *data)
 {
-	struct drm_info_node *node = s->private;
-	struct tegra_sor *sor = node->info_ent->data;
+	struct tegra_sor *sor = s->private;
 	struct drm_crtc *crtc = sor->output.encoder.crtc;
-	struct drm_device *drm = node->minor->dev;
+	struct drm_device *drm = sor->drm;
 	unsigned int i;
 	int err = 0;
 
@@ -1450,51 +1463,44 @@ static int tegra_sor_show_regs(struct seq_file *s, void *data)
 	return err;
 }
 
-static const struct drm_info_list debugfs_files[] = {
-	{ "crc", tegra_sor_show_crc, 0, NULL },
-	{ "regs", tegra_sor_show_regs, 0, NULL },
+static int regs_open(struct inode *inode, struct file *file)
+{
+	struct tegra_sor *sor = inode->i_private;
+	return single_open(file, tegra_sor_show_regs, sor);
+}
+
+static const struct file_operations crc_fops = {
+	.owner = THIS_MODULE,
+	.open = crc_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
 };
 
 static int tegra_sor_late_register(struct drm_connector *connector)
 {
-	struct tegra_output *output = connector_to_output(connector);
-	unsigned int i, count = ARRAY_SIZE(debugfs_files);
 	struct drm_minor *minor = connector->dev->primary;
-	struct dentry *root = connector->debugfs_entry;
+	struct tegra_output *output = connector_to_output(connector);
 	struct tegra_sor *sor = to_sor(output);
-	int err;
+	struct dentry *root;
 
-	sor->debugfs_files = kmemdup(debugfs_files, sizeof(debugfs_files),
-				     GFP_KERNEL);
-	if (!sor->debugfs_files)
-		return -ENOMEM;
+	sor->drm = minor->dev;
 
-	for (i = 0; i < count; i++)
-		sor->debugfs_files[i].data = sor;
+	root = debugfs_create_dir("sor", connector->debugfs_entry);
+	sor->debugfs_root = root;
 
-	err = drm_debugfs_create_files(sor->debugfs_files, count, root, minor);
-	if (err < 0)
-		goto free;
+	debugfs_create_file("crc", S_IFREG | S_IRUGO, root, sor, &crc_fops);
+	debugfs_create_file("regs", S_IFREG | S_IRUGO, root, sor, &regs_fops);
 
 	return 0;
-
-free:
-	kfree(sor->debugfs_files);
-	sor->debugfs_files = NULL;
-
-	return err;
 }
 
 static void tegra_sor_early_unregister(struct drm_connector *connector)
 {
 	struct tegra_output *output = connector_to_output(connector);
-	unsigned int count = ARRAY_SIZE(debugfs_files);
 	struct tegra_sor *sor = to_sor(output);
 
-	drm_debugfs_remove_files(sor->debugfs_files, count,
-				 connector->dev->primary);
-	kfree(sor->debugfs_files);
-	sor->debugfs_files = NULL;
+	debugfs_remove_recursive(sor->debugfs_root);
 }
 
 static void tegra_sor_connector_reset(struct drm_connector *connector)



[Index of Archives]     [ARM Kernel]     [Linux ARM]     [Linux ARM MSM]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux