From: Jani Nikula <jani.nikula@linux.intel.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: "André Almeida" <andrealmeid@igalia.com>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Maíra Canal" <mcanal@igalia.com>,
"Melissa Wen" <mwen@igalia.com>,
dri-devel@lists.freedesktop.org,
"Alain Volmat" <alain.volmat@foss.st.com>
Subject: Re: [PATCH 01/13] drm/debugfs: Create helper to add debugfs files to device's list
Date: Thu, 12 Jan 2023 11:25:47 +0200 [thread overview]
Message-ID: <87358ggl44.fsf@intel.com> (raw)
In-Reply-To: <Y7/O3wqumKf8269i@phenom.ffwll.local>
On Thu, 12 Jan 2023, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Thu, Jan 12, 2023 at 10:50:40AM +0200, Jani Nikula wrote:
>> On Wed, 11 Jan 2023, Maíra Canal <mcanal@igalia.com> wrote:
>> > Create a helper to encapsulate the code that adds a new debugfs file to
>> > a linked list related to a object. Moreover, the helper also provides
>> > more flexibily on the type of the object, allowing to use the helper for
>> > other types of drm_debugfs_entry.
>> >
>> > Signed-off-by: Maíra Canal <mcanal@igalia.com>
>> > ---
>> > drivers/gpu/drm/drm_debugfs.c | 20 ++++++++++++--------
>> > 1 file changed, 12 insertions(+), 8 deletions(-)
>> >
>> > diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
>> > index 4f643a490dc3..255d2068ac16 100644
>> > --- a/drivers/gpu/drm/drm_debugfs.c
>> > +++ b/drivers/gpu/drm/drm_debugfs.c
>> > @@ -316,6 +316,17 @@ void drm_debugfs_cleanup(struct drm_minor *minor)
>> > minor->debugfs_root = NULL;
>> > }
>> >
>> > +#define drm_debugfs_add_file_to_list(component) do { \
>> > + entry->file.name = name; \
>> > + entry->file.show = show; \
>> > + entry->file.data = data; \
>> > + entry->component = (component); \
>> > + \
>> > + mutex_lock(&(component)->debugfs_mutex); \
>> > + list_add(&entry->list, &(component)->debugfs_list); \
>> > + mutex_unlock(&(component)->debugfs_mutex); \
>> > + } while (0)
>>
>> In general, please don't add macros that implicitly depend on certain
>> local variable names. In this case, "entry".
>>
>> But I'm also not convinced about the usefulness of adding this kind of
>> "generics". Sure, it'll save you a few lines here and there, but I think
>> overall it's just confusing more than it's useful.
>
> So the non-generics way I guess would be to
> - pass the right pointer to the functions as an explicit parameter (struct
> drm_device|crtc|connector *, )
> - make drm_debugfs_entry and implementation detail
> - switch the pointer in there to void *, have glue show functions for each
> case which do nothing else than cast from void * to the right type
> (both for the parameter and the function pointer)
> - have a single function which takes that void *entry list and a pointer
> to the debugfs director to add them all for code sharing
>
> I think this should work for ->show, but for ->fops it becomes a rather
> big mess I fear. Maybe for ->fops (and also for ->show for now) we leave
> the explicit parameter out and just rely on seq_file->private or whatever
> it was.
Similar ideas in https://lore.kernel.org/r/878ri8glee.fsf@intel.com
I think for the more general ->fops case, the question really becomes
does drm need *all* the functionality of ->fops, or can we get away with
providing just show/write functions pointers, and wrapping it all inside
drm_debugfs.c? The question *now* is avoiding to paint ourselves in the
corner and requiring a ton of *extra* work to make that happen.
BR,
Jani.
>
> Or just copypaste, it's not that much code really :-)
> -Daniel
>
>>
>>
>> BR,
>> Jani.
>>
>> > +
>> > /**
>> > * drm_debugfs_add_file - Add a given file to the DRM device debugfs file list
>> > * @dev: drm device for the ioctl
>> > @@ -334,14 +345,7 @@ void drm_debugfs_add_file(struct drm_device *dev, const char *name,
>> > if (!entry)
>> > return;
>> >
>> > - entry->file.name = name;
>> > - entry->file.show = show;
>> > - entry->file.data = data;
>> > - entry->dev = dev;
>> > -
>> > - mutex_lock(&dev->debugfs_mutex);
>> > - list_add(&entry->list, &dev->debugfs_list);
>> > - mutex_unlock(&dev->debugfs_mutex);
>> > + drm_debugfs_add_file_to_list(dev);
>> > }
>> > EXPORT_SYMBOL(drm_debugfs_add_file);
>>
>> --
>> Jani Nikula, Intel Open Source Graphics Center
--
Jani Nikula, Intel Open Source Graphics Center
next prev parent reply other threads:[~2023-01-12 9:25 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-11 17:37 [PATCH 00/13] drm/debugfs: Create a debugfs infrastructure for kms objects Maíra Canal
2023-01-11 17:37 ` [PATCH 01/13] drm/debugfs: Create helper to add debugfs files to device's list Maíra Canal
2023-01-12 8:50 ` Jani Nikula
2023-01-12 9:11 ` Daniel Vetter
2023-01-12 9:25 ` Jani Nikula [this message]
2023-01-11 17:37 ` [PATCH 02/13] drm/debugfs: Create helper to create debugfs files from list Maíra Canal
2023-01-12 8:53 ` Jani Nikula
2023-01-11 17:37 ` [PATCH 03/13] drm/debugfs: Create a debugfs infrastructure for connectors Maíra Canal
2023-01-12 9:07 ` Jani Nikula
2023-01-12 9:14 ` Daniel Vetter
2023-01-12 9:21 ` Jani Nikula
2023-01-11 17:37 ` [PATCH 04/13] drm/debugfs: Create a debugfs infrastructure for encoders Maíra Canal
2023-01-12 9:01 ` Jani Nikula
2023-01-11 17:37 ` [PATCH 05/13] drm/debugfs: Create a debugfs infrastructure for CRTC Maíra Canal
2023-01-11 17:37 ` [PATCH 06/13] drm/vc4: Split variable instantiation of vc4_debugfs_regset32() Maíra Canal
2023-01-11 17:37 ` [PATCH 07/13] drm/vc4: Use the encoders' debugfs infrastructure Maíra Canal
2023-01-12 9:19 ` Jani Nikula
2023-01-12 9:47 ` Daniel Vetter
2023-01-11 17:37 ` [PATCH 08/13] drm/vc4: Use the crtc's " Maíra Canal
2023-01-11 17:37 ` [PATCH 09/13] drm/sti: " Maíra Canal
2023-01-11 17:37 ` [PATCH 10/13] drm/sti: Use the connectors' " Maíra Canal
2023-01-11 17:37 ` [PATCH 11/13] drm/sti: Use the encoders' " Maíra Canal
2023-01-11 17:37 ` [PATCH 12/13] drm/debugfs: Remove the debugfs late register function Maíra Canal
2023-01-11 17:37 ` [PATCH 13/13] drm/todo: Update the debugfs clean up task Maíra Canal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87358ggl44.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=alain.volmat@foss.st.com \
--cc=andrealmeid@igalia.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=mcanal@igalia.com \
--cc=mwen@igalia.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox