All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/dp: Read the tx msg state once after checking for an event
Date: Mon, 15 May 2017 14:02:49 +0200	[thread overview]
Message-ID: <20170515120249.byzs6ef4awq4yjlb@phenom.ffwll.local> (raw)
In-Reply-To: <20170513105201.17658-1-chris@chris-wilson.co.uk>

On Sat, May 13, 2017 at 11:52:00AM +0100, Chris Wilson wrote:
> Both as an exercise to document that we are reading the state outside of
> the appropriate mutex and to ensure that we only read the value once
> before the multiple comparisons, use READ_ONCE.

I think gcc could also opt to re-evalute and re-load it, resulting to
diverging control flow and hilarity. At least I don't spot any protection
against that in the wait_for macros.

Applied to drm-misc, thanks.
-Daniel

> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/drm_dp_mst_topology.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
> index d1cbb9c8f806..3bdd314f02b1 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -737,16 +737,16 @@ static void drm_dp_mst_put_payload_id(struct drm_dp_mst_topology_mgr *mgr,
>  static bool check_txmsg_state(struct drm_dp_mst_topology_mgr *mgr,
>  			      struct drm_dp_sideband_msg_tx *txmsg)
>  {
> -	bool ret;
> +	unsigned int state;
>  
>  	/*
>  	 * All updates to txmsg->state are protected by mgr->qlock, and the two
>  	 * cases we check here are terminal states. For those the barriers
>  	 * provided by the wake_up/wait_event pair are enough.
>  	 */
> -	ret = (txmsg->state == DRM_DP_SIDEBAND_TX_RX ||
> -	       txmsg->state == DRM_DP_SIDEBAND_TX_TIMEOUT);
> -	return ret;
> +	state = READ_ONCE(txmsg->state);
> +	return (state == DRM_DP_SIDEBAND_TX_RX ||
> +		state == DRM_DP_SIDEBAND_TX_TIMEOUT);
>  }
>  
>  static int drm_dp_mst_wait_tx_reply(struct drm_dp_mst_branch *mstb,
> -- 
> 2.11.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

      parent reply	other threads:[~2017-05-15 12:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-13 10:52 [PATCH 1/2] drm/dp: Read the tx msg state once after checking for an event Chris Wilson
2017-05-13 10:52 ` [PATCH 2/2] drm/dp: Wait up all outstanding tx waiters Chris Wilson
2017-05-13 11:06   ` Chris Wilson
2017-05-15 12:04   ` Daniel Vetter
2017-05-15 12:33     ` [Intel-gfx] " Ville Syrjälä
2017-05-15 13:37       ` Daniel Vetter
2017-05-15 15:02         ` [Intel-gfx] " Jani Nikula
2017-05-13 11:18 ` ✓ Fi.CI.BAT: success for series starting with [1/2] drm/dp: Read the tx msg state once after checking for an event Patchwork
2017-05-15 12:02 ` Daniel Vetter [this message]

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=20170515120249.byzs6ef4awq4yjlb@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=chris@chris-wilson.co.uk \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@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.