Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp319619pxa; Wed, 26 Aug 2020 11:28:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxATUFH6sBKidEj5iGaMbsfiQFXGe4R6uGMDYWa22HL3mtS4MRuEMsI7me2yWe5Ei5/uv+ X-Received: by 2002:a05:6402:84e:: with SMTP id b14mr15860357edz.115.1598466509442; Wed, 26 Aug 2020 11:28:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598466509; cv=none; d=google.com; s=arc-20160816; b=snuy8akFt+8YWDM5yUjmiD2WReg0i9bVDLkf2fZbXMuq0YUetNQLIel2rWy9YtIMBF DdYpTIo06+SlAhWeMDPBpLhEt/dmkYePU8vto2rVtv1XQ5BHGU46AQwiVT+DSGF530lR 2rHnLBIGmbDxiIDJSxi2NwSYRMlaoPuxAQVoo1Lp3eYkE1gahCmfP2I4WNsCL3RnBKA4 wCoGGzFUhiSL05O6bR+quAZgsThgwEXDcHyWiM4KQPQuaDMmFdqTiWIr02ml3NIh6OgK abAZKTjNeegPEXQkupR4/eoCuRb+0iC0EHPLqVtTb4Ixd4x6Y9XeDRycAWg1bK67jAZC 8fXg== 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 :dkim-signature; bh=SrQypXsB06I27AWFzq+unFDPT9ULdnzgHHger98409Y=; b=o54OhdTP3IusaOZYatz/lhMkbyViNsmpGi2ZbhBJ43ItO112B7LB4negS4uYS5Ubxz OscVjFfFvXHv/C5Wxsm+Eof8+SYlUKHcUs8ALwvjAOVKzf+q1+nApJLFjTzerFs32HZd uWSSuhDrJK/KaUeTMNGQFn+fOvZj/tnnvI7Ehih/OgkHTXf38F/pfnpF2cm0wX8gnm4C Boy6XaE2DAseApooS3bd6AKo5NKPT4dcLh86jIRUeKvnjrzCwglDHXtzYvdvZ6KsfUdM hauuK7lKiT8IJU6ysFfzBeT3MzjBSdasRSnJJ3SXZRCAu8p+nh1jmDFZQ/wzoq8p43Fs fXuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IlgQ+qq4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jx6si2131575ejb.260.2020.08.26.11.28.05; Wed, 26 Aug 2020 11:28:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IlgQ+qq4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727924AbgHZS0s (ORCPT + 99 others); Wed, 26 Aug 2020 14:26:48 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:37685 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727107AbgHZSZ6 (ORCPT ); Wed, 26 Aug 2020 14:25:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598466357; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SrQypXsB06I27AWFzq+unFDPT9ULdnzgHHger98409Y=; b=IlgQ+qq4Yo5/zGgPJDV88z5bXgxc3b2/+Ai3knU5XqpTh6EQG1KzqfuWDFMB8la7vWRk1c VbPoGs3TGgagHBP9N2A1FfXtcocEqc5EFjo3/xaga/gXgF4C//sCk74z8O5maBnMCY36T2 hPgcKw3FV9IVIyqw3m8SE/FKd01ng/E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-124-EnDZQoIPNm2QBWzx8RTYXg-1; Wed, 26 Aug 2020 14:25:55 -0400 X-MC-Unique: EnDZQoIPNm2QBWzx8RTYXg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BC8AB1DDFC; Wed, 26 Aug 2020 18:25:53 +0000 (UTC) Received: from Whitewolf.redhat.com (ovpn-119-77.rdu2.redhat.com [10.10.119.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E07D1002382; Wed, 26 Aug 2020 18:25:52 +0000 (UTC) From: Lyude Paul To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, nouveau@lists.freedesktop.org Cc: Ben Skeggs , David Airlie , Daniel Vetter , Dave Airlie , Alex Deucher , Pankaj Bharadiya , Takashi Iwai , James Jones , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 14/20] drm/nouveau/kms/nv50-: Use downstream DP clock limits for mode validation Date: Wed, 26 Aug 2020 14:24:50 -0400 Message-Id: <20200826182456.322681-15-lyude@redhat.com> In-Reply-To: <20200826182456.322681-1-lyude@redhat.com> References: <20200826182456.322681-1-lyude@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds support for querying the maximum clock rate of a downstream port on a DisplayPort connection. Generally, downstream ports refer to active dongles which can have their own pixel clock limits. Note as well, we also start marking the connector as disconnected if we can't read the DPCD, since we wouldn't be able to do anything without DPCD access anyway. Signed-off-by: Lyude Paul Reviewed-by: Ben Skeggs --- drivers/gpu/drm/nouveau/dispnv50/disp.c | 3 +++ drivers/gpu/drm/nouveau/nouveau_dp.c | 15 +++++++++++---- drivers/gpu/drm/nouveau/nouveau_encoder.h | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c index 8e1effb10425d..d2141ca16107b 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c @@ -1258,7 +1258,10 @@ nv50_mstc_detect(struct drm_connector *connector, ret = drm_dp_mst_detect_port(connector, ctx, mstc->port->mgr, mstc->port); + if (ret != connector_status_connected) + goto out; +out: pm_runtime_mark_last_busy(connector->dev->dev); pm_runtime_put_autosuspend(connector->dev->dev); return ret; diff --git a/drivers/gpu/drm/nouveau/nouveau_dp.c b/drivers/gpu/drm/nouveau/nouveau_dp.c index 005750aeb6d4f..ad852e572cfec 100644 --- a/drivers/gpu/drm/nouveau/nouveau_dp.c +++ b/drivers/gpu/drm/nouveau/nouveau_dp.c @@ -61,6 +61,11 @@ nouveau_dp_probe_dpcd(struct nouveau_connector *nv_connector, mstm->can_mst = drm_dp_read_mst_cap(aux, dpcd); } + ret = drm_dp_read_downstream_info(aux, dpcd, + outp->dp.downstream_ports); + if (ret < 0) + return connector_status_disconnected; + return connector_status_connected; } @@ -176,8 +181,6 @@ void nouveau_dp_irq(struct nouveau_drm *drm, /* TODO: * - Use the minimum possible BPC here, once we add support for the max bpc * property. - * - Validate the mode against downstream port caps (see - * drm_dp_downstream_max_clock()) * - Validate against the DP caps advertised by the GPU (we don't check these * yet) */ @@ -188,15 +191,19 @@ nv50_dp_mode_valid(struct drm_connector *connector, unsigned *out_clock) { const unsigned min_clock = 25000; - unsigned max_clock, clock; + unsigned max_clock, ds_clock, clock; enum drm_mode_status ret; if (mode->flags & DRM_MODE_FLAG_INTERLACE && !outp->caps.dp_interlace) return MODE_NO_INTERLACE; max_clock = outp->dp.link_nr * outp->dp.link_bw; - clock = mode->clock * (connector->display_info.bpc * 3) / 10; + ds_clock = drm_dp_downstream_max_clock(outp->dp.dpcd, + outp->dp.downstream_ports); + if (ds_clock) + max_clock = min(max_clock, ds_clock); + clock = mode->clock * (connector->display_info.bpc * 3) / 10; ret = nouveau_conn_mode_clock_valid(mode, min_clock, max_clock, &clock); if (out_clock) diff --git a/drivers/gpu/drm/nouveau/nouveau_encoder.h b/drivers/gpu/drm/nouveau/nouveau_encoder.h index eef4643f5f982..c1924a4529a7b 100644 --- a/drivers/gpu/drm/nouveau/nouveau_encoder.h +++ b/drivers/gpu/drm/nouveau/nouveau_encoder.h @@ -72,6 +72,7 @@ struct nouveau_encoder { struct mutex hpd_irq_lock; u8 dpcd[DP_RECEIVER_CAP_SIZE]; + u8 downstream_ports[DP_MAX_DOWNSTREAM_PORTS]; struct drm_dp_desc desc; } dp; }; -- 2.26.2