dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Andrzej Hajda <a.hajda@samsung.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>,
	DRI Development <dri-devel@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: [PATCH 03/51] drm: add managed resources tied to drm_device
Date: Tue, 25 Feb 2020 11:27:01 +0100	[thread overview]
Message-ID: <c088ce3b-d409-3a66-1f45-72f8ee9d9784@samsung.com> (raw)
In-Reply-To: <20200221210319.2245170-4-daniel.vetter@ffwll.ch>

Hi Daniel,


The patchset looks interesting.


On 21.02.2020 22:02, Daniel Vetter wrote:
> We have lots of these. And the cleanup code tends to be of dubious
> quality. The biggest wrong pattern is that developers use devm_, which
> ties the release action to the underlying struct device, whereas
> all the userspace visible stuff attached to a drm_device can long
> outlive that one (e.g. after a hotunplug while userspace has open
> files and mmap'ed buffers). Give people what they want, but with more
> correctness.


I am not familiar with this stuff, so forgive me stupid questions.

Is it documented how uapi should behave in such case?

I guess the general rule is to return errors on most ioctls (ENODEV,
EIO?), and wait until userspace releases everything, as there is not
much more to do.

If that is true what is the point of keeping these structs anyway -
trivial functions with small context data should do the job.

I suspect I am missing something but I do not know what :)


>
> Mostly copied from devres.c, with types adjusted to fit drm_device and
> a few simplifications - I didn't (yet) copy over everything. Since
> the types don't match code sharing looked like a hopeless endeavour.
>
> For now it's only super simplified, no groups, you can't remove
> actions (but kfree exists, we'll need that soon). Plus all specific to
> drm_device ofc, including the logging. Which I didn't bother to make
> compile-time optional, since none of the other drm logging is compile
> time optional either.


I saw in v1 thread that copy/paste is OK and merging back devres and
drmres can be done later, but experience shows that after short time
things get de-synchronized and merging process becomes quite painful.

On the other side I guess it shouldn't be difficult to split devres into
consumer agnostic core and "struct device" helpers and then use the core
in drm.

For example currently devres uses two fields from struct device:

    spinlock_t        devres_lock;
    struct list_head    devres_head;

Lets put it into separate struct:

struct devres {

    spinlock_t        lock;
    struct list_head    head;

};

And embed this struct into "struct device".

Then convert all core devres functions to take "struct devres *"
argument instead of "struct device *" and then these core functions can
be usable in drm.

Looks quite simple separation of abstraction (devres) and its consumer
(struct device).

After such split one could think about changing name devres to something
more reliable.


Regards

Andrzej



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

  reply	other threads:[~2020-02-25 10:27 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-21 21:02 [PATCH 00/51] drm managed resources, v2 Daniel Vetter
2020-02-21 21:02 ` [PATCH 01/51] mm/sl[uo]b: export __kmalloc_track(_node)_caller Daniel Vetter
2020-02-21 21:02 ` [PATCH 02/51] drm/i915: Don't clear drvdata in ->release Daniel Vetter
2020-02-21 21:36   ` Chris Wilson
2020-02-22  9:48     ` Daniel Vetter
2020-02-22  9:50       ` Daniel Vetter
2020-02-21 21:02 ` [PATCH 03/51] drm: add managed resources tied to drm_device Daniel Vetter
2020-02-25 10:27   ` Andrzej Hajda [this message]
2020-02-25 15:03     ` Daniel Vetter
2020-02-26  9:21       ` Andrzej Hajda
2020-02-26 10:21         ` Daniel Vetter
2020-02-26 14:38           ` Andrzej Hajda
2020-02-21 21:02 ` [PATCH 04/51] drm: Set final_kfree in drm_dev_alloc Daniel Vetter
2020-02-21 21:02 ` [PATCH 05/51] drm/mipi_dbi: Use drmm_add_final_kfree in all drivers Daniel Vetter
2020-02-21 21:02 ` [PATCH 06/51] drm/udl: Use drmm_add_final_kfree Daniel Vetter
2020-02-21 21:02 ` [PATCH 07/51] drm/qxl: " Daniel Vetter
2020-02-21 21:02 ` [PATCH 08/51] drm/i915: " Daniel Vetter
2020-02-21 21:02 ` [PATCH 09/51] drm/cirrus: " Daniel Vetter
2020-02-21 21:02 ` [PATCH 10/51] drm/v3d: " Daniel Vetter
2020-02-21 21:02 ` [PATCH 11/51] drm/tidss: " Daniel Vetter
2020-02-23 18:50   ` Jyri Sarha
2020-02-21 21:02 ` [PATCH 12/51] drm/mcde: " Daniel Vetter
2020-02-21 21:02 ` [PATCH 13/51] drm/vgem: " Daniel Vetter
2020-02-21 21:02 ` [PATCH 14/51] drm/vkms: " Daniel Vetter
2020-02-21 21:02 ` [PATCH 15/51] drm/repaper: " Daniel Vetter
2020-02-21 21:02 ` [PATCH 16/51] drm/inigenic: " Daniel Vetter
2020-02-21 21:02 ` [PATCH 17/51] drm/gm12u320: " Daniel Vetter
2020-02-22 11:36   ` Hans de Goede
2020-02-21 21:02 ` [PATCH 18/51] drm/<drivers>: " Daniel Vetter
2020-02-22 15:16   ` Russell King - ARM Linux admin
2020-02-27 17:46     ` Daniel Vetter
2020-02-21 21:02 ` [PATCH 19/51] drm: Cleanups after drmm_add_final_kfree rollout Daniel Vetter
2020-02-21 21:02 ` [PATCH 20/51] drm: Handle dev->unique with drmm_ Daniel Vetter
2020-02-21 21:02 ` [PATCH 21/51] drm: Use drmm_ for drm_dev_init cleanup Daniel Vetter
2020-02-21 21:02 ` [PATCH 22/51] drm: manage drm_minor cleanup with drmm_ Daniel Vetter
2020-02-21 21:02 ` [PATCH 23/51] drm: Manage drm_gem_init " Daniel Vetter
2020-02-21 21:02 ` [PATCH 24/51] drm: Manage drm_vblank_cleanup " Daniel Vetter
2020-02-21 21:02 ` [PATCH 25/51] drm: Garbage collect drm_dev_fini Daniel Vetter
2020-02-21 21:02 ` [PATCH 26/51] drm: Manage drm_mode_config_init with drmm_ Daniel Vetter
2020-02-23 15:17   ` Noralf Trønnes
2020-02-21 21:02 ` [PATCH 27/51] drm/bochs: Remove leftover drm_atomic_helper_shutdown Daniel Vetter
2020-02-21 21:02 ` [PATCH 28/51] drm/bochs: Drop explicit drm_mode_config_cleanup Daniel Vetter
2020-02-21 21:02 ` [PATCH 29/51] drm/cirrus: Drop explicit drm_mode_config_cleanup call Daniel Vetter
2020-02-21 21:02 ` [PATCH 30/51] drm/cirrus: Fully embrace devm_ Daniel Vetter
2020-02-21 21:02 ` [PATCH 31/51] drm/ingenic: Drop explicit drm_mode_config_cleanup call Daniel Vetter
2020-02-21 21:03 ` [PATCH 32/51] drm/mcde: " Daniel Vetter
2020-02-21 21:03 ` [PATCH 33/51] drm/mcde: More devm_drm_dev_init Daniel Vetter
2020-02-21 21:03 ` [PATCH 34/51] drm/meson: Drop explicit drm_mode_config_cleanup call Daniel Vetter
2020-02-21 21:03 ` [PATCH 35/51] drm/pl111: " Daniel Vetter
2020-02-21 21:03 ` [PATCH 36/51] drm/rcar-du: " Daniel Vetter
2020-02-21 21:03 ` [PATCH 37/51] drm/rockchip: " Daniel Vetter
2020-02-24 19:13   ` Francesco Lavra
2020-02-24 20:37     ` Daniel Vetter
2020-02-21 21:03 ` [PATCH 38/51] drm/stm: " Daniel Vetter
2020-02-21 21:03 ` [PATCH 39/51] drm/shmob: " Daniel Vetter
2020-02-21 21:03 ` [PATCH 40/51] drm/mtk: " Daniel Vetter
2020-02-21 21:03 ` [PATCH 41/51] drm/tidss: " Daniel Vetter
2020-02-23 18:50   ` Jyri Sarha
2020-02-21 21:03 ` [PATCH 42/51] drm/gm12u320: More drmm_ Daniel Vetter
2020-02-22 12:10   ` Hans de Goede
2020-02-21 21:03 ` [PATCH 43/51] drm/gm12u320: Use devm_drm_dev_init Daniel Vetter
2020-02-22 12:10   ` Hans de Goede
2020-02-21 21:03 ` [PATCH 44/51] drm/gm12u320: Use helpers for shutdown/suspend/resume Daniel Vetter
2020-02-22 12:10   ` Hans de Goede
2020-02-21 21:03 ` [PATCH 45/51] drm/gm12u320: Simplify upload work Daniel Vetter
2020-02-22 12:30   ` Hans de Goede
2020-02-22 13:00     ` Daniel Vetter
2020-02-21 21:03 ` [PATCH 46/51] drm/repaper: Drop explicit drm_mode_config_cleanup call Daniel Vetter
2020-02-21 21:03 ` [PATCH 47/51] drm/mipi-dbi: Move drm_mode_config_init into mipi library Daniel Vetter
2020-02-21 21:03 ` [PATCH 48/51] drm/mipi-dbi: Drop explicit drm_mode_config_cleanup call Daniel Vetter
2020-02-21 21:03 ` [PATCH 49/51] drm/udl: " Daniel Vetter
2020-02-21 21:03 ` [PATCH 50/51] drm/udl: drop drm_driver.release hook Daniel Vetter
2020-02-21 21:03 ` [PATCH 51/51] drm: Add docs for managed resources Daniel Vetter
2020-02-27 18:14 [PATCH 00/51] drm managed resources, v3 Daniel Vetter
2020-02-27 18:14 ` [PATCH 03/51] drm: add managed resources tied to drm_device Daniel Vetter
2020-02-28 22:45   ` Sam Ravnborg
2020-02-28 23:14     ` Daniel Vetter
2020-02-29 11:17       ` Sam Ravnborg
2020-02-29 11:28         ` Daniel Vetter
2020-03-02  9:22           ` Jani Nikula
2020-03-02  9:36             ` Daniel Vetter
2020-03-02  9:39             ` Daniel Vetter
2020-03-02 16:34               ` Sam Ravnborg
2020-03-02 22:25 [PATCH 00/51] drm_device managed resources, v4 Daniel Vetter
2020-03-02 22:25 ` [PATCH 03/51] drm: add managed resources tied to drm_device Daniel Vetter
2020-03-03  8:04   ` Dan Carpenter
2020-03-03  8:25     ` Daniel Vetter
2020-03-11  9:07   ` Thomas Zimmermann
2020-03-11  9:47     ` Thomas Zimmermann
2020-03-16  8:45     ` Daniel Vetter
2020-03-11  9:14   ` Thomas Zimmermann
2020-03-16  8:50     ` Daniel Vetter
2020-03-23 14:48 [PATCH 00/51] drm_device managed resources, v5 Daniel Vetter
2020-03-23 14:49 ` [PATCH 03/51] drm: add managed resources tied to drm_device Daniel Vetter
2020-03-23 18:36   ` Sam Ravnborg

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=c088ce3b-d409-3a66-1f45-72f8ee9d9784@samsung.com \
    --to=a.hajda@samsung.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=rafael@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).