All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>,
	Sean Paul <seanpaul@chromium.org>,
	Thierry Reding <treding@nvidia.com>,
	Russell King - ARM Linux <linux@arm.linux.org.uk>,
	Ajay Kumar <ajaykumar.rs@samsung.com>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	linux-samsung-soc <linux-samsung-soc@vger.kernel.org>,
	InKi Dae <inki.dae@samsung.com>, Rob Clark <robdclark@gmail.com>,
	Ajay kumar <ajaynumb@gmail.com>, Jingoo Han <jg1.han@samsung.com>,
	sunil joshi <joshi@samsung.com>,
	Prashanth G <prashanth.g@samsung.com>
Subject: Re: [PATCH V7 03/12] drm/bridge: Add helper functions for drm_bridge
Date: Wed, 29 Oct 2014 09:57:02 +0100	[thread overview]
Message-ID: <20141029085702.GP26941@phenom.ffwll.local> (raw)
In-Reply-To: <20141029083821.GA27900@ulmo>

On Wed, Oct 29, 2014 at 09:38:23AM +0100, Thierry Reding wrote:
> On Wed, Oct 29, 2014 at 08:43:14AM +0100, Daniel Vetter wrote:
> > On Tue, Oct 28, 2014 at 03:35:50PM +0100, Thierry Reding wrote:
> > > On Mon, Oct 27, 2014 at 11:26:30PM +0100, Daniel Vetter wrote:
> > > > On Mon, Oct 27, 2014 at 11:20 PM, Daniel Vetter <daniel@ffwll.ch> wrote:
> > > > > On Mon, Oct 27, 2014 at 8:58 PM, Sean Paul <seanpaul@chromium.org> wrote:
> > > > >>>> @@ -660,8 +662,11 @@ struct drm_bridge_funcs {
> > > > >>>>   * @driver_private: pointer to the bridge driver's internal context
> > > > >>>>   */
> > > > >>>>  struct drm_bridge {
> > > > >>>> -     struct drm_device *dev;
> > > > >>>> +     struct device *dev;
> > > > >>>
> > > > >>> Please don't rename the ->dev pointer into drm. Because _all_ the other
> > > > >>> drm structures still call it ->dev. Also, can't we use struct device_node
> > > > >>> here like we do in the of helpers Russell added? See 7e435aad38083
> > > > >>>
> > > > >>
> > > > >> I think this is modeled after the naming in drm_panel, FWIW. However,
> > > > >> seems reasonable to keep the device_node instead.
> > > > >
> > > > > Hm, indeed. Tbh I vote to rename drm_panel->drm to ->dev and like with
> > > > > drm_crtc drop the struct device and go directly to a struct
> > > > > device_node. Since we don't really need the sturct device, the only
> > > > > thing we care about is the of_node. For added bonus wrap an #ifdef
> > > > > CONFIG_OF around all the various struct device_node in drm_foo.h.
> > > > > Should be all fairly simple to pull off with cocci.
> > > > >
> > > > > Thierry?
> > > > 
> > > > Looking at the of_drm_find_panel function I actually wonder how that
> > > > works - the drm_panel doesn't really need to stick around afaics.
> > > > After all panel_list is global so some other driver can unload.
> > > > Russell's of support for possible_crtcs code works differently since
> > > > it only looks at per-drm_device lists.
> > > 
> > > I don't understand. Panels are global resources that get registered by
> > > some driver that isn't tied to the DRM device until attached. It can't
> > > be in a per-DRM device list, because it's external to the device.
> > > 
> > > And yes, they can go away when a driver is unloaded, though it's not the
> > > typical use-case.
> > > 
> > > > This bridge code here though suffers from the same. So to me this
> > > > looks rather fishy.
> > > 
> > > Well, this version of the DRM bridge support was written to be close to
> > > DRM panel, so it isn't really surprising that it's similar =), but like
> > > I said, I don't really understand what you think is wrong with it.
> > 
> > You have a mutex to protect the global list of bridges/panels. But if you
> > do a lookup you don't grab a reference count on the panel, so the moment
> > you drop the list mutex the panel/bridge can go away.
> > 
> > Yes usually you don't unload a driver on a soc but soc isn't everything
> > and designing new stuff to not be hotunplug save isn't great either.
> 
> Yeah, I certainly agree that adding proper reference counting would be a
> good thing. I think perhaps we could just take a reference on the struct
> device * to prevent it from disappearing.
> 
> Although perhaps I misunderstand what you mean by "go away".

I meant the drm_panel/bridge could go away any second, since nothing
prevents a module unload of the panel/bridge driver. So in theory you
could get the unregister call right after you've done the lookup. Which
means the bridge/panel pointer you've just returned is freed memory.

I think we nee try_get_module for the code and kref on the actual data
structures. That makes the entire thing a bit non-trivial, which is why I
think it would be better as some generic helper. Which then gets embedded
or instantiated for specific cases, like dt&drm_panel or dt&drm_bridge. Or
maybe even acpi&drm_bridge, who knows ;-)
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

  reply	other threads:[~2014-10-29  8:56 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-27 14:29 [PATCH V7 00/12] drm/exynos: few patches to enhance bridge chip support Ajay Kumar
2014-08-27 14:29 ` [PATCH V7 01/12] drm/bridge: ptn3460: Few trivial cleanups Ajay Kumar
2014-08-27 14:29 ` [PATCH V7 02/12] drm/bridge: do not pass drm_bridge_funcs to drm_bridge_init Ajay Kumar
2014-10-27 19:50   ` Sean Paul
2014-08-27 14:29 ` [PATCH V7 03/12] drm/bridge: Add helper functions for drm_bridge Ajay Kumar
2014-10-27 19:01   ` Daniel Vetter
2014-10-27 19:58     ` Sean Paul
2014-10-27 22:20       ` Daniel Vetter
2014-10-27 22:26         ` Daniel Vetter
2014-10-27 23:57           ` Russell King - ARM Linux
2014-11-04  9:22             ` Philipp Zabel
2014-10-28 14:35           ` Thierry Reding
2014-10-29  7:43             ` Daniel Vetter
2014-10-29  8:38               ` Thierry Reding
2014-10-29  8:57                 ` Daniel Vetter [this message]
2014-10-29  9:14                   ` Thierry Reding
2014-10-30 10:01                     ` Andrzej Hajda
2014-10-30 10:09                       ` Russell King - ARM Linux
2014-10-31 15:54                         ` Daniel Vetter
2014-10-31 15:51                     ` Daniel Vetter
2014-11-03  8:01                       ` Thierry Reding
2014-11-03  8:26                         ` Ajay kumar
2014-10-28 14:29         ` Thierry Reding
2014-10-29  7:51           ` Daniel Vetter
2014-10-29  9:16             ` Thierry Reding
2014-10-31 15:59               ` Daniel Vetter
2014-11-03  8:06                 ` Thierry Reding
2014-11-03  8:11                   ` Daniel Vetter
2014-10-28  9:21       ` Ajay kumar
2014-10-28 10:01         ` Daniel Vetter
2014-10-28 12:28           ` Ajay kumar
2014-10-28 14:19             ` Daniel Vetter
2014-10-28 14:28               ` Sean Paul
2014-10-28 14:41               ` Thierry Reding
2014-10-28 14:46                 ` Ajay kumar
2014-10-28 15:05                   ` Thierry Reding
2014-10-29  7:58                     ` Daniel Vetter
2014-10-29  9:09                       ` Andrzej Hajda
2014-10-31 16:03                         ` Daniel Vetter
2014-10-27 20:11   ` Sean Paul
2014-10-28  9:22     ` Ajay kumar
2014-10-28  9:26     ` Ajay kumar
2014-08-27 14:29 ` [PATCH V7 04/12] drm/bridge: ptn3460: Convert to i2c driver model Ajay Kumar
2014-08-27 14:29 ` [PATCH V7 05/12] drm/exynos: dp: support drm_bridge Ajay Kumar
2014-08-27 14:29 ` [PATCH V7 06/12] drm/bridge: ptn3460: support drm_panel Ajay Kumar
2014-08-27 14:29 ` [PATCH V7 07/12] drm/bridge: ptn3460: probe connector at the end of bridge attach Ajay Kumar
2014-08-27 14:29 ` [PATCH V7 08/12] drm/bridge: ptn3460: use gpiod interface Ajay Kumar
2014-08-27 14:29 ` [PATCH V7 12/12] drm/bridge: Add i2c based driver for ps8622/ps8625 bridge Ajay Kumar
2014-09-10 13:18 ` [PATCH V7 00/12] drm/exynos: few patches to enhance bridge chip support Ajay kumar
2014-09-16 12:44 ` Javier Martinez Canillas
2014-09-16 20:11   ` Laurent Pinchart
2014-09-17  9:32   ` Ajay kumar
2014-09-20 11:27     ` Ajay kumar
2014-09-22 10:18     ` Thierry Reding

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=20141029085702.GP26941@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=ajaykumar.rs@samsung.com \
    --cc=ajaynumb@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=inki.dae@samsung.com \
    --cc=jg1.han@samsung.com \
    --cc=joshi@samsung.com \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=prashanth.g@samsung.com \
    --cc=robdclark@gmail.com \
    --cc=seanpaul@chromium.org \
    --cc=thierry.reding@gmail.com \
    --cc=treding@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.