Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp310324ima; Thu, 31 Jan 2019 17:17:41 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibnv49kcDhGEeL/Xw0iH9sWdELoivkKnUyD6Uvm9Sseh1NVVvMb6DISxJosDNfNOkXoylsm X-Received: by 2002:a65:434d:: with SMTP id k13mr188054pgq.269.1548983861236; Thu, 31 Jan 2019 17:17:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548983861; cv=none; d=google.com; s=arc-20160816; b=wjzpH2Qivid6XWUglcR4ey+OooiELv5VaFMElaXry+cVeuzHiQS8U7ssj0kXMslrpL 8Sf2mDveAk6xyt/GWTJhD7wgvBOEO5j8Mrn5cr1w8Bqs0q4kaJ54rBBOyWPkW6L/T7jf uNKbLeNuCat33pbLs0nNNEzN6VOkEclD/7Ma8iAuJQoId0HNYhKUlzBJSHdnzFUiK6BU hRnoZGsXh7G3Dmwx4ATP05PWJA3XL6WaLvUD/mY/s+X27cXqb7xazavDBo3rCJwKy4CJ cGYVp4+WKOwUnnkg3hHus/9pGmj46GlVZ909Pntm0p4gp5vnjI8f5zqSTKnc/oJRwK2E 6p6g== 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=pEMKYMI/kWAm0NGjlX2Qmo4spqjmXA06OaBJyalawb8=; b=VELhzJJuogyC3A/o46gWmmJ2mvjCMGsgf8rdWpHgsCuEUwQMfa6O4DlksnXKn433c/ cEBBTOkOLkr9YLLX+3d0s5ejkzRmIvJC6Tc8BVMQvnB4OKl7Ko9Bl1COhNhuljDPeK6U nHUcB7H6gUCEzCawreEq+E/tz1eMGeFfpAeh0iRa3x9Iai9OExJEkJDoiJbqSxON7zWe TxyszsOpgy5BfPMajF6uAXDJbpE6ebT9+SS1fYJZjP2R7BvsC0CcNxKXgOgQ223UxWeY cg8qTboAvVm9Y0RAT1oMl8lWp5p35YVj6VV0EpDIIwcTcAXZF9+zc/S9BAJOjIr+SkGo FsSA== 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 s8si5758629pgm.508.2019.01.31.17.17.26; Thu, 31 Jan 2019 17:17:41 -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 S1727441AbfBABP6 (ORCPT + 99 others); Thu, 31 Jan 2019 20:15:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54410 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726503AbfBABP5 (ORCPT ); Thu, 31 Jan 2019 20:15:57 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3D45F7BDA9; Fri, 1 Feb 2019 01:15:57 +0000 (UTC) Received: from whitewolf.lyude.net.com (ovpn-123-198.rdu2.redhat.com [10.10.123.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6286D5C3FD; Fri, 1 Feb 2019 01:15:52 +0000 (UTC) From: Lyude Paul To: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org Cc: Daniel Vetter , Ben Skeggs , David Airlie , Ilia Mirkin , Laurent Pinchart , linux-kernel@vger.kernel.org Subject: [PATCH v2 4/4] drm/nouveau: Move PBN and VCPI allocation into nv50_head_atom Date: Thu, 31 Jan 2019 20:14:51 -0500 Message-Id: <20190201011506.21055-5-lyude@redhat.com> In-Reply-To: <20190201011506.21055-1-lyude@redhat.com> References: <20190201011506.21055-1-lyude@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 01 Feb 2019 01:15:57 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Atomic checks should never modify anything outside of the state that they're passed in. Unfortunately this appears to be exactly what we're doing in nv50_msto_atomic_check() where we update mstc->pbn every time the function is called. This hasn't caused any bugs yet, but it needs to be fixed in order to ensure that when committing an artificially duplicated state (like during system resume), that we reuse the PBN of that state to perform VCPI allocations and don't recalculate a different value from the drm connector's reported bpc. Also, move the VCPI slot allocations while we're at it as well. With this, removing a topology in suspend while using nouveau no longer causes the new atomic VCPI helpers to complain. Signed-off-by: Lyude Paul Fixes: eceae1472467 ("drm/dp_mst: Start tracking per-port VCPI allocations") Cc: Daniel Vetter --- drivers/gpu/drm/nouveau/dispnv50/atom.h | 6 ++++++ drivers/gpu/drm/nouveau/dispnv50/disp.c | 28 +++++++++++++++---------- drivers/gpu/drm/nouveau/dispnv50/head.c | 1 + 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/nouveau/dispnv50/atom.h b/drivers/gpu/drm/nouveau/dispnv50/atom.h index a194990d2b0d..b5fae5ab3fa8 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/atom.h +++ b/drivers/gpu/drm/nouveau/dispnv50/atom.h @@ -116,6 +116,12 @@ struct nv50_head_atom { u8 depth:4; } or; + /* Currently only used for MST */ + struct { + int pbn; + u8 tu:6; + } dp; + union nv50_head_atom_mask { struct { bool olut:1; diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c index 60d858c2f2ce..e8bb35f6d015 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c @@ -659,8 +659,6 @@ struct nv50_mstc { struct drm_display_mode *native; struct edid *edid; - - int pbn; }; struct nv50_msto { @@ -765,17 +763,26 @@ nv50_msto_atomic_check(struct drm_encoder *encoder, struct drm_connector *connector = conn_state->connector; struct nv50_mstc *mstc = nv50_mstc(connector); struct nv50_mstm *mstm = mstc->mstm; - int bpp = connector->display_info.bpc * 3; + struct nv50_head_atom *asyh = nv50_head_atom(crtc_state); int slots; - mstc->pbn = drm_dp_calc_pbn_mode(crtc_state->adjusted_mode.clock, - bpp); + /* When restoring duplicated states, we need to make sure that the + * bw remains the same and avoid recalculating it, as the connector's + * bpc may have changed after the state was duplicated + */ + if (!state->duplicated) + asyh->dp.pbn = + drm_dp_calc_pbn_mode(crtc_state->adjusted_mode.clock, + connector->display_info.bpc * 3); if (drm_atomic_crtc_needs_modeset(crtc_state)) { slots = drm_dp_atomic_find_vcpi_slots(state, &mstm->mgr, - mstc->port, mstc->pbn); + mstc->port, + asyh->dp.pbn); if (slots < 0) return slots; + + asyh->dp.tu = slots; } return nv50_outp_atomic_check_view(encoder, crtc_state, conn_state, @@ -786,13 +793,13 @@ static void nv50_msto_enable(struct drm_encoder *encoder) { struct nv50_head *head = nv50_head(encoder->crtc); + struct nv50_head_atom *armh = nv50_head_atom(head->base.base.state); struct nv50_msto *msto = nv50_msto(encoder); struct nv50_mstc *mstc = NULL; struct nv50_mstm *mstm = NULL; struct drm_connector *connector; struct drm_connector_list_iter conn_iter; u8 proto, depth; - int slots; bool r; drm_connector_list_iter_begin(encoder->dev, &conn_iter); @@ -808,8 +815,8 @@ nv50_msto_enable(struct drm_encoder *encoder) if (WARN_ON(!mstc)) return; - slots = drm_dp_find_vcpi_slots(&mstm->mgr, mstc->pbn); - r = drm_dp_mst_allocate_vcpi(&mstm->mgr, mstc->port, mstc->pbn, slots); + r = drm_dp_mst_allocate_vcpi(&mstm->mgr, mstc->port, armh->dp.pbn, + armh->dp.tu); WARN_ON(!r); if (!mstm->links++) @@ -827,8 +834,7 @@ nv50_msto_enable(struct drm_encoder *encoder) default: depth = 0x6; break; } - mstm->outp->update(mstm->outp, head->base.index, - nv50_head_atom(head->base.base.state), proto, depth); + mstm->outp->update(mstm->outp, head->base.index, armh, proto, depth); msto->head = head; msto->mstc = mstc; diff --git a/drivers/gpu/drm/nouveau/dispnv50/head.c b/drivers/gpu/drm/nouveau/dispnv50/head.c index ac97ebce5b35..2e7a0c347ddb 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/head.c +++ b/drivers/gpu/drm/nouveau/dispnv50/head.c @@ -413,6 +413,7 @@ nv50_head_atomic_duplicate_state(struct drm_crtc *crtc) asyh->ovly = armh->ovly; asyh->dither = armh->dither; asyh->procamp = armh->procamp; + asyh->dp = armh->dp; asyh->clr.mask = 0; asyh->set.mask = 0; return &asyh->state; -- 2.20.1