Commit 992d38cc authored by Chris Wilson's avatar Chris Wilson Committed by Daniel Vetter

drm/dp: Read the tx msg state once after checking for an event

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.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20170513105201.17658-1-chris@chris-wilson.co.uk
parent bebc1d55
...@@ -737,16 +737,16 @@ static void drm_dp_mst_put_payload_id(struct drm_dp_mst_topology_mgr *mgr, ...@@ -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, static bool check_txmsg_state(struct drm_dp_mst_topology_mgr *mgr,
struct drm_dp_sideband_msg_tx *txmsg) 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 * All updates to txmsg->state are protected by mgr->qlock, and the two
* cases we check here are terminal states. For those the barriers * cases we check here are terminal states. For those the barriers
* provided by the wake_up/wait_event pair are enough. * provided by the wake_up/wait_event pair are enough.
*/ */
ret = (txmsg->state == DRM_DP_SIDEBAND_TX_RX || state = READ_ONCE(txmsg->state);
txmsg->state == DRM_DP_SIDEBAND_TX_TIMEOUT); return (state == DRM_DP_SIDEBAND_TX_RX ||
return ret; state == DRM_DP_SIDEBAND_TX_TIMEOUT);
} }
static int drm_dp_mst_wait_tx_reply(struct drm_dp_mst_branch *mstb, static int drm_dp_mst_wait_tx_reply(struct drm_dp_mst_branch *mstb,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment