dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Jyri Sarha <jsarha@ti.com>
Cc: tomi.valkeinen@ti.com, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/drm_bridge: adjust bridge module's refcount
Date: Wed, 30 Nov 2016 11:03:33 +0200	[thread overview]
Message-ID: <25095847.eIfKLMc78r@avalon> (raw)
In-Reply-To: <fa066bb5-c502-fc2c-f844-d62f7ddd496b@ti.com>

Hi Jyri,

On Wednesday 30 Nov 2016 10:55:10 Jyri Sarha wrote:
> On 11/30/16 10:37, Laurent Pinchart wrote:
> >>> To fix this properly I think we need to make the bridge object
> >>> refcounted,
> >>> 
> >>>>> with a release callback to signal to the bridge driver that memory
> >>>>> can be freed. The refcount should be increased in
> >>>>> of_drm_find_bridge(), and decreased in a new drm_bridge_put() function
> >>>>> (the "fun" part will be to update drivers to call that :-S).
> >>> 
> >>> I think another option would be to find and attach the bridge object
> >>> atomically by holding the bridge_lock until the try_module_get() has
> >>> succeeded.
> >>> 
> >>> AFAIU, if the module unload is triggered while holding the bridge_lock
> >>> but before the try_module_get() call, then try_module_get() would
> >>> return false and the attach call will return failure.
> > 
> > This would require combining lookup and attach in all cases. I'm not sure
> > that would be very convenient for drivers. Keeping the two operations
> > separate would be more flexible.
> 
> That could be avoided if of_drm_find_bridge() would copy the content of
> bridge object, in stead of providing a pointer.

/me shivers

> The attach call could then search for the bridge object again before
> continuing. But still in the end the impact to individual drivers would be
> equal to adding a simple drm_bridge_put() call. Probably better to go
> forward with your suggestion.

Please :-)

> Even adding the drm_bridge_put() would not be necessary in most cases if
> we would add a devm version of getting the bridge object. In 99% of
> cases the device probe will fail if the bridge attach fails, and bridge
> object refcount would return to zero automatically.

devm_* is evil in most cases, especially the devm_kzalloc() function as it 
ties object lifetime to devices, releasing memory at unbind time when the 
object can still be referenced elsewhere. Regarding bridges, a 
devm_of_drm_find_bridge() might make sense as the bridge seems at first glance 
to (nearly) always be a resource that can be released at DRM unbind time.

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2016-11-30  9:03 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20161129211315epcas3p2a805abe8449509312f481ab7dcea96ef@epcas3p2.samsung.com>
2016-11-29 21:12 ` [PATCH] drm/drm_bridge: adjust bridge module's refcount Jyri Sarha
2016-11-29 21:30   ` Jyri Sarha
2016-11-29 22:06   ` Laurent Pinchart
2016-11-30  8:13     ` Daniel Vetter
2016-11-30  8:25       ` Laurent Pinchart
2016-11-30  9:12         ` Daniel Vetter
2016-11-30  9:56           ` Laurent Pinchart
2016-11-30 10:55             ` Daniel Vetter
2016-11-30 11:03               ` Laurent Pinchart
2016-11-30 13:09                 ` Daniel Vetter
2016-12-01  7:07                   ` Andrzej Hajda
2016-12-01  7:18                     ` Daniel Vetter
2016-12-01 13:22                       ` Andrzej Hajda
2016-12-01 15:12                         ` Daniel Vetter
2016-12-02  6:49                           ` Andrzej Hajda
2016-11-30  8:32     ` Jyri Sarha
2016-11-30  8:37       ` Laurent Pinchart
2016-11-30  8:55         ` Jyri Sarha
2016-11-30  9:03           ` Laurent Pinchart [this message]
2016-11-30  9:13             ` Jyri Sarha
2016-11-30  9:30               ` Laurent Pinchart
2016-11-30  8:11   ` Andrzej Hajda
2016-11-30  8:16     ` Laurent Pinchart
2016-11-30  9:26       ` Andrzej Hajda
2016-11-30  9:39         ` Laurent Pinchart
2016-12-01  6:50           ` Andrzej Hajda

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=25095847.eIfKLMc78r@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jsarha@ti.com \
    --cc=tomi.valkeinen@ti.com \
    /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