Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1704655

Re: [PATCH v5 2/6] drm/bridge: Add a devm_ allocator for panel bridge.

From Noralf Trønnes <noralf@tronnes.org>
Newsgroups linux.kernel
Subject Re: [PATCH v5 2/6] drm/bridge: Add a devm_ allocator for panel bridge.
Date 2017-08-05 16:50 +0200
Message-ID <ub8yR-6hm-9@gated-at.bofh.it> (permalink)
References (1 earlier) <u4HUJ-7vU-3@gated-at.bofh.it> <uaL9f-7DN-9@gated-at.bofh.it> <uaRHH-3rS-13@gated-at.bofh.it> <uaTgu-4xE-17@gated-at.bofh.it> <ub57Y-4aH-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Den 05.08.2017 12.59, skrev Noralf Trønnes:
> (I had to switch to Daniel's Intel address to get this sent)
>
> Den 05.08.2017 00.19, skrev Ilia Mirkin:
>> On Fri, Aug 4, 2017 at 4:43 PM, Eric Anholt <eric@anholt.net> wrote:
>>> Laurent Pinchart <laurent.pinchart@ideasonboard.com> writes:
>>>
>>>> Hi Eric,
>>>>
>>>> (CC'ing Daniel)
>>>>
>>>> Thank you for the patch.
>>>>
>>>> On Tuesday 18 Jul 2017 14:05:06 Eric Anholt wrote:
>>>>> This will let drivers reduce the error cleanup they need, in
>>>>> particular the "is_panel_bridge" flag.
>>>>>
>>>>> v2: Slight cleanup of remove function by Andrzej
>>>> I just want to point out that, in the context of Daniel's work on 
>>>> hot-unplug,
>>>> 90% of the devm_* allocations are wrong and will get in the way. 
>>>> All DRM core
>>>> objects that are accessible one way or another from userspace will 
>>>> need to be
>>>> properly reference-counted and freed only when the last reference 
>>>> disappears,
>>>> which could be well after the corresponding device is removed. I 
>>>> believe this
>>>> could be one such objects :-/
>>> Sure, if you're hotplugging, your life is pain.  For non-hotpluggable
>>> devices, like our SOC platform devices (current panel-bridge 
>>> consumers),
>>> this still seems like an excellent simplification of memory management.
>> At that point you may as well make your module non-unloadable, and
>> return failure when trying to remove a device from management by the
>> driver (whatever the opposite of "probe" is, I forget). Hotplugging
>> doesn't only happen when physically removing, it can happen for all
>> kinds of reasons... and userspace may still hold references in some of
>> those cases.
>
> If drm_open() gets a ref on dev->dev and puts it in drm_release(),
> won't that delay devm_* cleanup until userspace is done?
>

It seems plausible looking at the code:

void device_initialize(struct device *dev)
{
[...]
     kobject_init(&dev->kobj, &device_ktype);
[...]
}

static struct kobj_type device_ktype = {
     .release    = device_release,
};

/**
  * device_release - free device structure.
  * @kobj: device's kobject.
  *
  * This is called once the reference count for the object
  * reaches 0. We forward the call to the device's release
  * method, which should handle actually freeing the structure.
  */
static void device_release(struct kobject *kobj)
{
[...]
     devres_release_all(dev);
[...]
}

Last put call chain:
put_device() -> kobject_put() -> kref_put() -> kobject_release() ->
kobject_cleanup() -> device_release() -> devres_release_all()

But I haven't actually tried it, so I might be mistaken.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH v5 2/6] drm/bridge: Add a devm_ allocator for panel bridge. Laurent Pinchart <laurent.pinchart@ideasonboard.com> - 2017-08-04 15:50 +0200
  Re: [PATCH v5 2/6] drm/bridge: Add a devm_ allocator for panel bridge. Laurent Pinchart <laurent.pinchart@ideasonboard.com> - 2017-08-04 17:00 +0200
  Re: [PATCH v5 2/6] drm/bridge: Add a devm_ allocator for panel bridge. Eric Anholt <eric@anholt.net> - 2017-08-04 22:50 +0200
    Re: [PATCH v5 2/6] drm/bridge: Add a devm_ allocator for panel bridge. Laurent Pinchart <laurent.pinchart@ideasonboard.com> - 2017-08-04 23:30 +0200
    Re: [PATCH v5 2/6] drm/bridge: Add a devm_ allocator for panel bridge. Ilia Mirkin <imirkin@alum.mit.edu> - 2017-08-05 00:30 +0200
      Re: [PATCH v5 2/6] drm/bridge: Add a devm_ allocator for panel  bridge. Noralf Trønnes <noralf@tronnes.org> - 2017-08-05 13:10 +0200
        Re: [PATCH v5 2/6] drm/bridge: Add a devm_ allocator for panel  bridge. Noralf Trønnes <noralf@tronnes.org> - 2017-08-05 16:50 +0200
        Re: [PATCH v5 2/6] drm/bridge: Add a devm_ allocator for panel  bridge. Daniel Vetter <daniel@ffwll.ch> - 2017-08-07 11:30 +0200
          Re: [PATCH v5 2/6] drm/bridge: Add a devm_ allocator for panel bridge. Laurent Pinchart <laurent.pinchart@ideasonboard.com> - 2017-08-07 12:30 +0200
            Re: [PATCH v5 2/6] drm/bridge: Add a devm_ allocator for panel  bridge. Noralf Trønnes <noralf@tronnes.org> - 2017-08-07 16:40 +0200
            Re: [PATCH v5 2/6] drm/bridge: Add a devm_ allocator for panel  bridge. Daniel Vetter <daniel@ffwll.ch> - 2017-08-07 17:00 +0200
              Re: [PATCH v5 2/6] drm/bridge: Add a devm_ allocator for panel bridge. Laurent Pinchart <laurent.pinchart@ideasonboard.com> - 2017-08-08 00:00 +0200

csiph-web