All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Thomas Hellstrom <thellstrom@vmware.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	DRI Development <dri-devel@lists.freedesktop.org>,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [PATCH 06/19] drm/vmwgfx: Drop the cursor locking hack
Date: Thu, 23 Mar 2017 13:56:20 +0100	[thread overview]
Message-ID: <20170323125619.lp562tmntitxd55y@phenom.ffwll.local> (raw)
In-Reply-To: <78bb256e-7fef-7e0e-b901-8400ed8108cb@vmware.com>

On Thu, Mar 23, 2017 at 11:32:49AM +0100, Thomas Hellstrom wrote:
> On 03/23/2017 11:10 AM, Daniel Vetter wrote:
> > On Thu, Mar 23, 2017 at 09:35:25AM +0100, Thomas Hellstrom wrote:
> >> Hi, Daniel,
> >>
> >> On 03/23/2017 08:31 AM, Daniel Vetter wrote:
> >>> On Thu, Mar 23, 2017 at 08:28:32AM +0100, Daniel Vetter wrote:
> >>>> On Thu, Mar 23, 2017 at 07:22:31AM +0100, Thomas Hellstrom wrote:
> >>>>> On 03/22/2017 10:50 PM, Daniel Vetter wrote:
> >>>>>> It's been around forever, no one bothered to address the FIXME, so I
> >>>>>> presume it's all fine.
> >>>>>>
> >>>>>> Cc: Sinclair Yeh <syeh@vmware.com>
> >>>>>> Cc: Thomas Hellstrom <thellstrom@vmware.com>
> >>>>>> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> >>>>> NAK. We need to properly address this. Probably as part of the atomic
> >>>>> update.
> >>>> So could someone with vmwgfx understanding explain this? Note that the
> >>>> FIXME was originally added by me years ago, because I wasn't sure (only
> >>>> about 90%) that this is safe, and was essentially pleading for a vmwgfx
> >>>> expert to review this?
> >>>>
> >>>> Since it didn't happen I presume it's not that terribly and probably safe
> >>>> ...
> >>>>
> >>>> I'm still 90% sure that this is correct, but I'd love for a vmwgfx to
> >>>> audit it. Replying with a NAK is kinda not the response I was hoping for
> >>>> (and yes I guess I should have explained what's going on here better, but
> >>>> it's just a git blame of the FIXME comment away).
> >> So the code has been left in place because it works. Altering it now
> >> will create unnecessary merge conflicts with the atomic code, and the
> >> change isn't tested and audited which means we need to drop focus from
> >> what we're doing and audit and test code that isn't going to be used
> >> anyway for not apparent reason? But otoh put in the below context there
> >> indeed is a reason.
> >>
> >> From a quick audit of the existing code it seems like at least
> >> vmw_cursor_update_position is touching global device state so I think at
> >> a minimum we need to take a spinlock in that function. Otherwise it
> >> seems to be safe.
> > Note that you're holding the crtc lock already, which gives you exclusion
> > against concurrent page_flips, mode_sets and property changes. Note also
> > that page_flips themselves also only hold the crtc lock, so you can run
> > multiple page_flips in parallel on different crtc (iirc vmwgfx has
> > multiple crtc, if not this discussion is entirely moot).
> >
> > tbh I'd be surprised if my patch really breaks something that hasn't been
> > a pre-existing issue for a long time. The original commit which added this
> > FIXME comment is from 2012. Note also that because it's a hack, you
> > already have a pretty a real race with the core drm state keeping, and no
> > one seems to have hit that either.
> >
> > I mean I can dig through vmwgfx code and do the audit, but it'll take a
> > few hours and vmwgfx is it's own world, so much harder to understand (for
> > me).
> >
> 
> I'm thinking of the situation when someone would call a cursor_set ioctl
> in parallell
> for two crtcs at the same time and race writing the position registers?
> Note that the device has only a single global cursor.
> Admittedly the effects of a race would probably be small, but I'd rather
> see it being
> properly protected.

Hm, didn't realize you only have 1 cursor for everything together. In that
case you indeed have a problem. Not sure why that didn't come up 4 years
ago with the original patch, would be pretty easy to add a quite mutex in
v2 ... Since read-only global state is perfectly fine, having the crtc
lock gives you a read-only global state lock (for legacy drivers at least,
not for atomic).
>
> >> But I prefer if we can do that as part of the atomic update?
> > When does that vmwgfx atomic happen?
> 
> We're targeting 4.12, which means the code that is currently under
> testing will need to be sent out for review pretty soon.
> It's already in our standalone testing repo at
> 
> git://git.freedesktop.org/git/mesa/vmwgfx

Deadline is in 2 weeks for 4.12 feature work, per the discussion we've had
after the 4.11 merge window fallout with Linus. You pretty much have to
submit the patches now to have a reasonable chance of them landing in
time. Since vmwgfx has traditionally been the odd kms driver out I'd
really like to give the new atomic code at least a quick read-through, to
make sure it's aligned as much as possible with the other 20+ atomic
drivers.

> but the cursor code hasn't been fixed in that repo yet.

Well if you switched to universal planes it's pretty easy to fix with the
acquire ctx and grabbing mode_config.connection_mutex. Without that you
can just add a global cursor mutex (equally few lines) to patch it up.
> 
> BTW is this blocking some other core drm work you're doing?

Just removing lock_crtc and preventing abuse from spreading. Somehow both
tegra and tilcdc starting using it in places it was definitely not meant
for. vmwgfx (with this FIXME here) was the only legit user of this
function. So not high priority really, but something that'd be really nice
to remove from the exported set of functions to prevent future misuse by
new drivers.

Thanks, Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2017-03-23 12:56 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-22 21:50 [PATCH 00/19] wire acquire ctx through legacy modeset paths Daniel Vetter
2017-03-22 21:50 ` [PATCH 01/19] drm: Wire up proper acquire ctx for plane functions Daniel Vetter
2017-03-27 20:12   ` Harry Wentland
2017-03-28  6:23     ` Daniel Vetter
2017-03-28  6:46       ` Daniel Vetter
2017-03-28  7:02       ` Daniel Vetter
2017-03-28 14:48         ` Harry Wentland
2017-03-22 21:50 ` [PATCH 02/19] drm: Add acquire ctx parameter to ->update_plane Daniel Vetter
2017-03-22 23:03   ` Russell King - ARM Linux
2017-03-24  7:07     ` Daniel Vetter
2017-03-22 21:50 ` [PATCH 03/19] drm: drm_plane_force_disable is not for atomic drivers Daniel Vetter
2017-03-22 21:50 ` [PATCH 04/19] drm: Add acquire ctx parameter to ->plane_disable Daniel Vetter
2017-03-22 21:50 ` [PATCH 05/19] drm/atomic-helper: remove backoff hack from disable/update_plane Daniel Vetter
2017-03-22 21:50 ` [PATCH 06/19] drm/vmwgfx: Drop the cursor locking hack Daniel Vetter
2017-03-23  6:22   ` Thomas Hellstrom
2017-03-23  7:28     ` Daniel Vetter
2017-03-23  7:31       ` Daniel Vetter
2017-03-23  8:35         ` Thomas Hellstrom
2017-03-23 10:10           ` Daniel Vetter
2017-03-23 10:32             ` Thomas Hellstrom
2017-03-23 12:56               ` Daniel Vetter [this message]
2017-03-27  3:01               ` Michel Dänzer
2017-03-27  6:28                 ` Daniel Vetter
2017-03-27  8:31                   ` Thomas Hellstrom
2017-03-29  8:00                     ` Daniel Vetter
2017-03-29  8:04                       ` Thomas Hellstrom
2017-03-22 21:50 ` [PATCH 07/19] drm/tegra: Don't use modeset_lock_crtc Daniel Vetter
2017-03-27 15:50   ` Daniel Vetter
2017-03-22 21:50 ` [PATCH 08/19] drm/tilcdc: Drop calls to modeset_lock_crtc Daniel Vetter
2017-03-24  9:46   ` Tomi Valkeinen
2017-03-25 21:19     ` Daniel Vetter
2017-03-24 13:34   ` Jyri Sarha
2017-03-22 21:50 ` [PATCH 09/19] drm: Make drm_modeset_lock_crtc internal Daniel Vetter
2017-03-22 21:50 ` [PATCH 10/19] drm: Roll out acquire context for the page_flip ioctl Daniel Vetter
2017-03-22 21:50 ` [PATCH 11/19] drm: Add acquire ctx parameter to ->page_flip(_target) Daniel Vetter
2017-03-22 21:50 ` [PATCH 12/19] drm/atomic-helper: remove backoff hack from page_flip Daniel Vetter
2017-03-22 21:50 ` [PATCH 13/19] drm: simplify the locking in the GETCRTC ioctl Daniel Vetter
2017-03-28  0:13   ` Harry Wentland
2017-03-28  6:27     ` Daniel Vetter
2017-03-28  7:01   ` [PATCH] " Daniel Vetter
2017-03-28 14:41     ` Harry Wentland
2017-03-30  7:36     ` [PATCH] Revert unrelated part of "drm: simplify the locking in the GETCRTC ioctl" Maarten Lankhorst
2017-03-30  7:48       ` Pandiyan, Dhinakaran
2017-03-30  7:56         ` [Intel-gfx] " Daniel Vetter
2017-03-22 21:50 ` [PATCH 14/19] drm: Remove drm_modeset_(un)lock_crtc Daniel Vetter
2017-03-22 21:50 ` [PATCH 15/19] drm: Remove drm_modeset_legacy_acquire_ctx and crtc->acquire_ctx Daniel Vetter
2017-03-22 21:50 ` [PATCH 16/19] drm: Restrict drm_mode_set_config_internal to non-atomic drivers Daniel Vetter
2017-03-22 21:50 ` [PATCH 17/19] drm: Add explicit acquire ctx handling around ->set_config Daniel Vetter
2017-03-22 21:50 ` [PATCH 18/19] drm: Add acquire ctx parameter to ->set_config Daniel Vetter
2017-04-04  0:06   ` Sinclair Yeh
2017-03-22 21:50 ` [PATCH 19/19] drm/atomic-helper: Remove the backoff hack from set_config Daniel Vetter
2017-03-23  9:37 ` ✗ Fi.CI.BAT: warning for wire acquire ctx through legacy modeset paths Patchwork
2017-03-28  0:31 ` [PATCH 00/19] " Harry Wentland
2017-03-28  7:20 ` ✓ Fi.CI.BAT: success for wire acquire ctx through legacy modeset paths (rev2) Patchwork

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=20170323125619.lp562tmntitxd55y@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=thellstrom@vmware.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.