All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Deucher <alexdeucher@gmail.com>
To: David Herrmann <dh.herrmann@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 03/12] drm: call ->firstopen() before ->open()
Date: Thu, 24 Jul 2014 09:47:21 -0400	[thread overview]
Message-ID: <CADnq5_MoxAnMBvLeX8FFLt57ovfbqGP2PmxM+TbXH4-AJUsuXw@mail.gmail.com> (raw)
In-Reply-To: <CANq1E4TJFaBAtwJLhO-t0cR8qxKZeSf0UWMY2KTQQVd5YOgLuQ@mail.gmail.com>

On Thu, Jul 24, 2014 at 5:31 AM, David Herrmann <dh.herrmann@gmail.com> wrote:
> Hi
>
> On Wed, Jul 23, 2014 at 9:25 PM, Daniel Vetter <daniel@ffwll.ch> wrote:
>> On Wed, Jul 23, 2014 at 05:26:38PM +0200, David Herrmann wrote:
>>> Lets order things correctly:
>>>  ->load()
>>>    ->fistopen()
>>>      ->open()
>>>      ->close()
>>>    ->lastclose()
>>>  ->unload()
>>>
>>> This doesn't change much as only savage and radeon use ->firstopen() and
>>> they just do map-initialization. Therefore, the global drm mutex makes
>>> sure there cannot be any other f_op between ->open() and ->firstopen().
>>> However, once we get rid of that lock, we really want ->firstopen() to
>>> initialize the device before ->open() is called.
>>>
>>> Furthermore, this fixes the clean-up path in drm_open(). We currently
>>> don't cleanup the drm_file object if ->firstopen() fails.
>>>
>>> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
>>> ---
>>>  drivers/gpu/drm/drm_fops.c | 139 +++++++++++++++++++++------------------------
>>>  include/drm/drmP.h         |   2 +-
>>>  2 files changed, 66 insertions(+), 75 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
>>> index 021fe5d..8e73519 100644
>>> --- a/drivers/gpu/drm/drm_fops.c
>>> +++ b/drivers/gpu/drm/drm_fops.c
>>> @@ -45,7 +45,7 @@ EXPORT_SYMBOL(drm_global_mutex);
>>>
>>>  static int drm_open_helper(struct file *filp, struct drm_minor *minor);
>>>
>>> -static int drm_setup(struct drm_device * dev)
>>> +static int drm_firstopen(struct drm_device * dev)
>>
>> All the stuff in here is only for legacy drivers. Imo we should rename
>> this to drm_legacy_setup and hide it harder.
>>
>> Also touching the init ordering for ums drivers is a bit risky, I'd advise
>> against it. firstopen is officially dead for kms driver and really there's
>> nothing legit you can do in there. imx abused until they've switched over
>> to the component framework.
>>
>> I'd just drop this one tbh.
>
> I did a driver audit when writing this patch, there're only 2 drivers
> using firstopen:
>
>  * radeon_cp: sets two fields of dev_private and calls drm_addmap() on
> those. In lastclose(), it calls drm_rmmap()
>  * savage: sets several fields in dev_private, calls
> arch_phys_wc_add() for some regions and requests a drm-map for those
> via drm_addmap(). On lastclose(), it reverts exactly those steps.
>
> Taking into account that firstopen() just runs with drm_device
> context, not with drm_file context, I really think we should be
> calling it _before_ doing ->open(). I even think the drivers would
> fail horribly if we don't do this patch and some other user-context
> sneaks in between both calls (currently impossible thanks to
> drm_global_mutex).
>
> Both ->firstopen() callbacks are fairly trivial. In favor of making
> the error-paths work in drm_open() I'd really like to get this in.
> This patch is preparing for my drm_file rework that can make
> drm_dev_unregister() stop all open files immediately.
>
> But I honestly don't care much for UMS drivers, so if you NACK this,
> I'd just ignore the error code and add a comment that we don't do
> error-handling for UMS.

Well, radeon UMS support is in the kernel deprecated and hasn't been
built by default for a while and I doubt anyone has tested it in
years.  I'm not sure what the current state of savage is.  I'm fine
either way.

Alex


>
> Cheers
> David
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2014-07-24 13:47 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-23 15:26 [PATCH 00/12] DRM: Random Cleanups David Herrmann
2014-07-23 15:26 ` [PATCH 01/12] drm: remove unused "struct drm_freelist" David Herrmann
2014-07-23 19:17   ` Daniel Vetter
2014-07-23 15:26 ` [PATCH 02/12] drm: drop unused "struct drm_queue" David Herrmann
2014-07-23 19:35   ` Daniel Vetter
2014-07-24 11:35     ` David Herrmann
2014-07-23 15:26 ` [PATCH 03/12] drm: call ->firstopen() before ->open() David Herrmann
2014-07-23 19:25   ` Daniel Vetter
2014-07-24  9:31     ` David Herrmann
2014-07-24 10:18       ` Daniel Vetter
2014-07-24 13:47       ` Alex Deucher [this message]
2014-07-23 15:26 ` [PATCH 04/12] drm: extract legacy ctxbitmap flushing David Herrmann
2014-07-23 19:26   ` Daniel Vetter
2014-07-24  9:34     ` David Herrmann
2014-07-24 10:19       ` Daniel Vetter
2014-07-23 15:26 ` [PATCH 05/12] drm: drop i386 verification David Herrmann
2014-07-23 15:26 ` [PATCH 06/12] drm: fix __alpha__ PCI lookup David Herrmann
2014-07-23 19:29   ` Daniel Vetter
2014-07-23 19:36     ` Daniel Vetter
2014-07-23 15:26 ` [PATCH 07/12] drm: drop redundant drm_file->is_master David Herrmann
2014-07-24  9:52   ` Daniel Vetter
2014-07-24 21:38     ` David Herrmann
2014-07-25  7:56       ` Daniel Vetter
2014-07-28 15:26         ` David Herrmann
2014-07-23 15:26 ` [PATCH 08/12] drm: don't de-authenticate clients on master-close David Herrmann
2014-07-24  9:57   ` Daniel Vetter
2014-07-23 15:26 ` [PATCH 09/12] drm: move module initialization to drm_stub.c David Herrmann
2014-07-23 15:26 ` [PATCH 10/12] drm: merge drm_drv.c into drm_ioctl.c David Herrmann
2014-07-23 16:16   ` David Herrmann
2014-07-23 19:33   ` Daniel Vetter
2014-07-23 15:26 ` [PATCH 11/12] drm: make minor->index available early David Herrmann
2014-07-24 10:03   ` Daniel Vetter
2014-07-24 10:16     ` David Herrmann
2014-07-24 12:30       ` Daniel Vetter
2014-07-23 15:26 ` [PATCH 12/12] drm: make sysfs device always available for minors David Herrmann
2014-07-24 10:36   ` Daniel Vetter
2014-07-24 10:48     ` David Herrmann
2014-07-24 12:31       ` Daniel Vetter
2014-07-23 16:24 ` [PATCH 00/12] DRM: Random Cleanups Alex Deucher

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=CADnq5_MoxAnMBvLeX8FFLt57ovfbqGP2PmxM+TbXH4-AJUsuXw@mail.gmail.com \
    --to=alexdeucher@gmail.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dh.herrmann@gmail.com \
    --cc=dri-devel@lists.freedesktop.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 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.