drm/nouveau: Grab payload lock in nv50_msto_payload()
authorLyude Paul <lyude@redhat.com>
Fri, 11 Jan 2019 00:53:39 +0000 (19:53 -0500)
committerLyude Paul <lyude@redhat.com>
Fri, 11 Jan 2019 01:38:34 +0000 (20:38 -0500)
Going through the currently programmed payloads isn't safe without
holding mgr->payload_lock, so actually do that and warn if anyone tries
calling nv50_msto_payload() in the future without grabbing the right
locks.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@redhat.com>
Cc: Jerry Zuo <Jerry.Zuo@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Juston Li <juston.li@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190111005343.17443-17-lyude@redhat.com
drivers/gpu/drm/nouveau/dispnv50/disp.c

index f80750ee04eafaee9b5d3c4559a8b2b6073b161c..b39d0f96854445e98db03e5dcdf52a939a3a32fe 100644 (file)
@@ -672,6 +672,8 @@ nv50_msto_payload(struct nv50_msto *msto)
        struct nv50_mstm *mstm = mstc->mstm;
        int vcpi = mstc->port->vcpi.vcpi, i;
 
+       WARN_ON(!mutex_is_locked(&mstm->mgr.payload_lock));
+
        NV_ATOMIC(drm, "%s: vcpi %d\n", msto->encoder.name, vcpi);
        for (i = 0; i < mstm->mgr.max_payloads; i++) {
                struct drm_dp_payload *payload = &mstm->mgr.payloads[i];
@@ -725,6 +727,8 @@ nv50_msto_prepare(struct nv50_msto *msto)
                               (0x0100 << msto->head->base.index),
        };
 
+       mutex_lock(&mstm->mgr.payload_lock);
+
        NV_ATOMIC(drm, "%s: msto prepare\n", msto->encoder.name);
        if (mstc->port->vcpi.vcpi > 0) {
                struct drm_dp_payload *payload = nv50_msto_payload(msto);
@@ -740,7 +744,9 @@ nv50_msto_prepare(struct nv50_msto *msto)
                  msto->encoder.name, msto->head->base.base.name,
                  args.vcpi.start_slot, args.vcpi.num_slots,
                  args.vcpi.pbn, args.vcpi.aligned_pbn);
+
        nvif_mthd(&drm->display->disp.object, 0, &args, sizeof(args));
+       mutex_unlock(&mstm->mgr.payload_lock);
 }
 
 static int