All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Lukas Wunner <lukas@wunner.de>
Cc: William Brown <william@blackhats.net.au>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 1/6] vga_switcheroo: Add support for switching only the DDC
Date: Tue, 6 Oct 2015 13:10:00 +0200	[thread overview]
Message-ID: <20151006111000.GG3383@phenom.ffwll.local> (raw)
In-Reply-To: <20151006101048.GA15385@wunner.de>

On Tue, Oct 06, 2015 at 12:10:48PM +0200, Lukas Wunner wrote:
> Hi Daniel,
> 
> thank you for taking a look at the patch set and shepherding this
> through the review process.
> 
> On Tue, Oct 06, 2015 at 09:27:24AM +0200, Daniel Vetter wrote:
> > On Fri, Aug 14, 2015 at 06:50:15PM +0200, Lukas Wunner wrote:
> > >     Don't lock vgasr_mutex in _lock_ddc() / _unlock_ddc(), it can cause
> > >     deadlocks because (a) during switch (with vgasr_mutex already held),
> > >     GPU is woken and probes its outputs, tries to re-acquire vgasr_mutex
> > >     to lock DDC lines; (b) Likewise during switch, GPU is suspended and
> > >     calls cancel_delayed_work_sync() to stop output polling, if poll
> > >     task is running at this moment we may wait forever for it to finish.
> > > 
> > >     Instead, lock ddc_lock when unregistering the handler because the
> > >     only reason why we'd want to lock vgasr_mutex in _lock_ddc() /
> > >     _unlock_ddc() is to block the handler from disappearing while DDC
> > >     lines are switched.
> > 
> > Shouldn't we also take the new look in register_handler, for consistency?
> > I know that if you look the mux provider too late it's fairly hopeless ...
> 
> With the chosen approach that's not necessary: vga_switcheroo_lock_ddc()
> records in vgasr_priv.old_ddc_owner if there's no mux:
> 
> 	if (!vgasr_priv.handler || !vgasr_priv.handler->switch_ddc) {
> 		vgasr_priv.old_ddc_owner = -ENODEV;
> 		return -ENODEV;
> 	}
> 
> And vga_switcheroo_unlock_ddc() does nothing if vgasr_priv.old_ddc_owner
> is negative, it just releases the lock and returns:
> 
> 	if (vgasr_priv.old_ddc_owner >= 0) {
> 		id = vgasr_priv.handler->get_client_id(pdev);
> 		if (vgasr_priv.old_ddc_owner != id)
> 			ret = vgasr_priv.handler->switch_ddc(
> 						     vgasr_priv.old_ddc_owner);
> 	}
> 	mutex_unlock(&vgasr_priv.ddc_lock);
> 
> So it has no consequences if the mux registers between the calls to
> _lock_ddc() and _unlock_ddc().
> 
> 
> > Also while reading the patch I realized that the new lock really protects
> > hw state (instead of our software-side tracking and driver resume/suspend
> > code). And at least myself I have no idea what vgasr means, so what about
> > renaming it to hw_mutex? We have this pattern of low-level locks to avoid
> > concurrent hw access in a lot of places like i2c, dp_aux, and it's very
> > often called hw_lock or similar.
> 
> Hm, hw_lock sounds a bit ambiguous.
> 
> vgasr_mutex is really a catch-all that protects access to the vgasr_priv
> structure and also protects various hardware state. (Power state of each
> GPU, mux state.) Up until now this approach worked fine, it looks like
> there was no need for additional locks. We may need to move to more
> fine-grained locking as new features get added to vga_switcheroo.
> The newly introduced ddc_lock is a first step and I think is aptly
> named since it only protects the mux state for the DDC lines.

Oops sorry mixed up the names. I meant rename the ddc_lock to hw_lock
since it protects a bit more than just the ddc (it protects the entire hw
switch state since we grab it both for dcc switching and for full-blown
switching of everything).
> 
> 
> > Wrt the overall patch series, can you pls haggle driver-maintainers (gmux,
> > radeon, nouveau) for acks/reviews? scripts/get_maintainers.pl should help.
> 
> Will do.
> 
> 
> > Also, the revised docbook patch seems to be missing from this iteration,
> > please follow up with that one.
> 
> The docbook patch posted September 17 automatically picks up the
> kernel-doc for the new functions through the !E directive.

I asked for the inclusion to be moved to drm.tmpl instead of creating a
new docbook.

> However I used markdown syntax for the unsorted lists in the DOC
> sections, so it will look a bit funny unless markdown gets merged,
> which as we all know is contentious. (Which is sad, though I can
> understand Jonathan Corbet's concerns.)
> 
> 
> By the way, Jani has kindly provided a Reviewed-By: for patch 6 of
> the vga_switcheroo docs series. The patch is not dependent on the
> preceding patch 5 which is awaiting an ack from Takashi, so could
> be merged now:
> [PATCH 06/15] vga_switcheroo: Use enum vga_switcheroo_state instead
> 
> Patches 7 and 8 are similarly trivial cleanups:
> [PATCH 07/15] vga_switcheroo: Use VGA_SWITCHEROO_UNKNOWN_ID instead
> [PATCH 08/15] vga_switcheroo: Use enum vga_switcheroo_client_id
> 
> And patch 10 has gotten a Reviewed-By: from Takashi:
> [PATCH 10/15] ALSA: hda - Spell vga_switcheroo consistently

Hm those patches aren't in this series, that makes it really hard for me
to know what's still pending. I think it would be best to resend
_everything_, so including docs and cleanups and all that. Otherwise I
think this will take a lot longer than necessary to pull in.

Also when resending patches unchanged please directly add r-b tags you've
collected already - replying top-level with them all again makes it a bit
harder to sort everything our here for me. And one small nit: The usual
style for patch bombing is flat threading, not nested. It should be the
default for new-ish git, but if that's not the case please use git
send-email --no-chain-reply-to. Note also if you generate patches first
with git format-patch that has a separate knob for deep threading, you
need to disable both iirc to avoid deep threading, there it's git
format-patch --thread=shallow.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2015-10-06 11:07 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-04  9:52 [PATCH v3 0/6] Enable gpu switching on the MacBook Pro Lukas Wunner
2015-08-14 16:50 ` [PATCH v3 1/6] vga_switcheroo: Add support for switching only the DDC Lukas Wunner
2015-08-14 16:18   ` [PATCH v3 2/6] apple-gmux: Add switch_ddc support Lukas Wunner
2015-08-14 16:28     ` [PATCH v3 3/6] drm/edid: Switch DDC when reading the EDID Lukas Wunner
2015-09-11 10:40       ` [PATCH v3 4/6] drm/i915: " Lukas Wunner
2015-05-09 15:20         ` [PATCH v3 5/6] drm/nouveau: " Lukas Wunner
2015-09-12  7:44           ` [PATCH v3 6/6] drm/radeon: " Lukas Wunner
2015-10-08  3:14             ` Alex Deucher
2015-10-08 14:53               ` Lukas Wunner
2015-10-12 18:59                 ` Alex Deucher
2015-10-06  7:27   ` [PATCH v3 1/6] vga_switcheroo: Add support for switching only the DDC Daniel Vetter
2015-10-06 10:10     ` Lukas Wunner
2015-10-06 11:10       ` Daniel Vetter [this message]
2015-10-06 18:27         ` Lukas Wunner
2015-10-07  7:52           ` Daniel Vetter
2015-10-12 15:17             ` [PATCH 0/9] vga_switcheroo cleanup Lukas Wunner
2015-08-28  9:56               ` [PATCH 1/9] vga_switcheroo: Use enum vga_switcheroo_state instead of int Lukas Wunner
2015-10-12 16:09                 ` Alex Deucher
2015-08-28 10:54               ` [PATCH 3/9] vga_switcheroo: Use enum vga_switcheroo_client_id " Lukas Wunner
2015-10-12 16:10                 ` Alex Deucher
2015-08-28 11:30               ` [PATCH 2/9] vga_switcheroo: Use VGA_SWITCHEROO_UNKNOWN_ID instead of -1 Lukas Wunner
2015-10-12 16:09                 ` Alex Deucher
2015-10-13  7:28                   ` Daniel Vetter
2015-10-15 18:14                     ` Lukas Wunner
2015-10-16 14:25                       ` Daniel Vetter
2015-09-04 18:49               ` [PATCH 4/9] ALSA: hda - Spell vga_switcheroo consistently Lukas Wunner
2015-10-12  8:57               ` [PATCH 5/9] drm/i915: Drop unnecessary #include <linux/vga_switcheroo.h> Lukas Wunner
2015-10-13  7:25                 ` Daniel Vetter
2015-10-13  7:26                 ` Jani Nikula
2015-10-12  9:15               ` [PATCH 6/9] drm/radeon: " Lukas Wunner
2015-10-12  9:44               ` [PATCH 8/9] drm/radeon: Fix kernel-doc copy/paste snafu Lukas Wunner
2015-10-12 16:02                 ` Alex Deucher
2015-10-12 16:36                   ` Lukas Wunner
2015-10-12  9:54               ` [PATCH 7/9] drm/amdgpu: Drop unnecessary #include <linux/vga_switcheroo.h> Lukas Wunner
2015-10-12 16:27                 ` Alex Deucher
2015-10-12 10:00               ` [PATCH 9/9] drm/amdgpu: Fix kernel-doc copy/paste snafu Lukas Wunner
2015-10-12 16:03                 ` Alex Deucher
     [not found]           ` <20151006182744.GA15532-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2015-10-12 17:14             ` [PATCH v4 0/6] Enable gpu switching on the MacBook Pro Lukas Wunner
     [not found]               ` <cover.1444670070.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2015-05-09 15:20                 ` [PATCH v4 5/6] drm/nouveau: Switch DDC when reading the EDID Lukas Wunner
2015-08-14 16:18               ` [PATCH v4 2/6] apple-gmux: Add switch_ddc support Lukas Wunner
2015-10-12 21:07                 ` Alex Deucher
2015-10-12 21:10                   ` Alex Deucher
2015-10-13  7:32                     ` Daniel Vetter
2015-10-29 14:58                     ` Lukas Wunner
2015-10-15  4:51                 ` Darren Hart
2015-10-15  6:27                   ` Daniel Vetter
2015-08-14 16:28               ` [PATCH v4 3/6] drm/edid: Switch DDC when reading the EDID Lukas Wunner
2015-08-14 16:50               ` [PATCH v4 1/6] vga_switcheroo: Add support for switching only the DDC Lukas Wunner
2015-09-11 10:40               ` [PATCH v4 4/6] drm/i915: Switch DDC when reading the EDID Lukas Wunner
2015-09-12  7:44               ` [PATCH v4 6/6] drm/radeon: " Lukas Wunner
2015-10-05 13:23 ` [PATCH v3 0/6] Enable gpu switching on the MacBook Pro Lukas Wunner
     [not found]   ` <20151005132349.GA15130-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2015-10-05 14:15     ` Evan Foss
2015-10-05 15:17       ` [Nouveau] " Lukas Wunner
     [not found]         ` <20151005151704.GA15177-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2015-10-05 15:23           ` Evan Foss
2015-10-05 15:31             ` [Nouveau] " Lukas Wunner
     [not found]       ` <CAM2RGhT5x9GoNU4xPwzoEoiWKqVrC2pwp3ydFgaXFwtsYiBa7A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-05 15:20         ` Pierre Moreau

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=20151006111000.GG3383@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=lukas@wunner.de \
    --cc=william@blackhats.net.au \
    /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.