Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1528989imu; Thu, 13 Dec 2018 17:28:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/W1KAbYhylaiNBsLN2RMd8n/oU1YLUIqZE/AZiZd9N3q7Ts28NAsJCfuRnY2YNyBYCzWF+a X-Received: by 2002:a63:e84c:: with SMTP id a12mr938343pgk.241.1544750915672; Thu, 13 Dec 2018 17:28:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544750915; cv=none; d=google.com; s=arc-20160816; b=Hg6xk9Zo67ELMQtT1WMFfZIHhwgIIypaPick4H8/kmLQBkE3K8bctyFdKs/FH+2YNk VwV58/DNIKI29z+yF5zZm0llqsg49MOg4mGtqG7nMW6Pv3IROSsELsTckH/HQuGwgBU/ VWOsyx9zVLDFVcEDV0gepO+U7cypoeYzKur1JUdlznza/KRuas9TuSpALqAaZ2IEVNPJ bnOyC4not2WzdmhNJR6ff4g2liY1XvI50ak7BdVKOKwTW+hTFi8gKn8ZpduZj/fjwxcD IHmP0RejHXT6lWmkEmxT42FCqbcbSfX4PU60UFBj31mdGKMdkhFgl6fPMYfcA7BKa20H zjMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=+5kTeV0xctrrnkL0RnTf3HgsYacpBFxy9pNqINKNSNY=; b=ps9dr7BmVwA2H54tuAPFrCOccVdr+CIldEL/kpVvG055pJiP2+yIKQx9ai9wROgMLd BHsAyrGT/lzg7z1eOgHJdWAo4YVQlY54tzn91fyJseQ9OnDgMXxqS5OoPv1ZzSpYgztI vmrpIjA8ApmRfggTaAONCaORhMgRdmTlvjdkKQr8rLmQcOaA7XaCZ1Cq+ktLas24qcLc hlBXuFyn6OnqWtOgeXOf/c3JQh3JAsQiIjsj6n722+uTsDz7yjxdB0mra3/H9V52m7WZ aBQwWRcE2P/GYs5jxlrOTwFj5E/QA/PGhSlBnjQoM8KOEUhJ7OL+xra2pJj6qJF+8xjm QsBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r77si2758211pfa.186.2018.12.13.17.28.20; Thu, 13 Dec 2018 17:28:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729508AbeLNB0y (ORCPT + 99 others); Thu, 13 Dec 2018 20:26:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48056 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727901AbeLNB0v (ORCPT ); Thu, 13 Dec 2018 20:26:51 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6514D4ACD6; Fri, 14 Dec 2018 01:26:51 +0000 (UTC) Received: from malachite.bss.redhat.com (dhcp-10-20-1-11.bss.redhat.com [10.20.1.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEB756012B; Fri, 14 Dec 2018 01:26:49 +0000 (UTC) From: Lyude Paul To: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Cc: Daniel Vetter , Dave Airlie , Harry Wentland , Jerry Zuo , Ben Skeggs , David Airlie , Sean Paul , Karol Herbst , Ilia Mirkin , linux-kernel@vger.kernel.org Subject: [WIP PATCH 08/15] drm/nouveau: Remove unnecessary VCPI checks in nv50_msto_cleanup() Date: Thu, 13 Dec 2018 20:25:37 -0500 Message-Id: <20181214012604.13746-9-lyude@redhat.com> In-Reply-To: <20181214012604.13746-1-lyude@redhat.com> References: <20181214012604.13746-1-lyude@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 14 Dec 2018 01:26:51 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is no need to look at the port's VCPI allocation before calling drm_dp_mst_deallocate_vcpi(), as we already have msto->disabled to let us avoid cleaning up an msto more then once. The DP MST core will never call drm_dp_mst_deallocate_vcpi() on it's own, which is presumably what these checks are meant to protect against. More importantly though, we're about to stop clearing mstc->port in the next commit, which means if we could potentially hit a use-after-free error if we tried to check mstc->port->vcpi here. So to make life easier for anyone who bisects this code in the future, use msto->disabled instead to check whether or not we need to deallocate VCPI instead. Signed-off-by: Lyude Paul --- drivers/gpu/drm/nouveau/dispnv50/disp.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c index 641252208e67..0f7d72518604 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c @@ -704,14 +704,17 @@ nv50_msto_cleanup(struct nv50_msto *msto) struct nv50_mstc *mstc = msto->mstc; struct nv50_mstm *mstm = mstc->mstm; + if (!msto->disabled) + return; + NV_ATOMIC(drm, "%s: msto cleanup\n", msto->encoder.name); - if (mstc->port && mstc->port->vcpi.vcpi > 0 && !nv50_msto_payload(msto)) + + if (mstc->port) drm_dp_mst_deallocate_vcpi(&mstm->mgr, mstc->port); - if (msto->disabled) { - msto->mstc = NULL; - msto->head = NULL; - msto->disabled = false; - } + + msto->mstc = NULL; + msto->head = NULL; + msto->disabled = false; } static void -- 2.19.2