[PATCH v3 1/4] drm: add devm release action
Maxime Ripard
mripard at kernel.org
Thu Apr 25 12:52:48 UTC 2024
On Wed, Apr 24, 2024 at 08:20:32AM -0400, Rodrigo Vivi wrote:
> On Wed, Apr 24, 2024 at 01:49:16PM +0200, Maxime Ripard wrote:
> > On Tue, Apr 23, 2024 at 01:42:22PM -0400, Rodrigo Vivi wrote:
> > > On Tue, Apr 23, 2024 at 02:25:06PM +0530, Aravind Iddamsetty wrote:
> > > >
> > > > On 23/04/24 02:24, Rodrigo Vivi wrote:
> > > > > On Mon, Apr 22, 2024 at 12:27:53PM +0530, Aravind Iddamsetty wrote:
> > > > >> In scenarios where drm_dev_put is directly called by driver we want to
> > > > >> release devm_drm_dev_init_release action associated with struct
> > > > >> drm_device.
> > > > >>
> > > > >> v2: Directly expose the original function, instead of introducing a
> > > > >> helper (Rodrigo)
> > > > >>
> > > > >> v3: add kernel-doc (Maxime Ripard)
> > > > >>
> > > > >> Cc: Maxime Ripard <mripard at kernel.org>
> > > > >> Cc: Thomas Hellstr_m <thomas.hellstrom at linux.intel.com>
> > > > >> Cc: Rodrigo Vivi <rodrigo.vivi at intel.com>
> > > > >>
> > > > > please avoid these empty lines here.... cc, rv-b, sign-offs, links,
> > > > > etc are all in the same block.
> > > > ok.
> > > > >
> > > > >> Reviewed-by: Rodrigo Vivi <rodrigo.vivi at intel.com>
> > > > >> Signed-off-by: Aravind Iddamsetty <aravind.iddamsetty at linux.intel.com>
> > > > >> ---
> > > > >> drivers/gpu/drm/drm_drv.c | 13 +++++++++++++
> > > > >> include/drm/drm_drv.h | 2 ++
> > > > >> 2 files changed, 15 insertions(+)
> > > > >>
> > > > >> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> > > > >> index 243cacb3575c..9d0409165f1e 100644
> > > > >> --- a/drivers/gpu/drm/drm_drv.c
> > > > >> +++ b/drivers/gpu/drm/drm_drv.c
> > > > >> @@ -714,6 +714,19 @@ static int devm_drm_dev_init(struct device *parent,
> > > > >> devm_drm_dev_init_release, dev);
> > > > >> }
> > > > >>
> > > > >> +/**
> > > > >> + * devm_drm_dev_release_action - Call the final release action of the device
> > > > > Seeing the doc here gave me a second thought....
> > > > >
> > > > > the original release should be renamed to _devm_drm_dev_release
> > > > > and this should be called devm_drm_dev_release without the 'action' word.
> > > > i believe, was suggested earlier to directly expose the main function, is
> > > > there any reason to have a __ version ?
> > >
> > > No no, just ignore me. Just remove the '_action' and don't change the other.
> > >
> > > I don't like exposing the a function with '__'. what would '__' that mean?
> > > This is what I meant on the first comment.
> > >
> > > Now, I believe that we don't need the '_action'. What does the 'action' mean?
> > >
> > > the devm_drm_dev_release should be enough. But then I got confused and
> > > I thought it would conflict with the original released function name.
> > > But I misread it.
> >
> > I don't think devm_drm_dev_release is a good name either. Just like any
> > other devm_* function that cancels what a previous one has been doing
> > (devm_kfree, devm_backlight_device_unregister, devm_nvmem_device_put,
> > etc.) it should be called devm_drm_dev_put or something similar.
>
> I see what you mean, but I don't believe the 'put' is the best option,
> for 2 reasons:
> - in general, we have put paired with gets and this has not get equivalent
Yeah, that's true. _release is fine then I guess.
> - this bypass the regular get/put mechanism and forces the releases that
> would be done only after all drm_dev_put() taking ref to zero.
I don't think it does? devm_release_action will only remove the devm
action and execute it directly, but this action here is a call to
drm_dev_put, so we might still have other references taken that would
defer the device being freed.
Maxime
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20240425/67c112c5/attachment.sig>
More information about the dri-devel
mailing list