Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp632204pxa; Wed, 19 Aug 2020 10:30:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxD3JKVbYHIR0CxbXcFUtjLPFJIWxZDz8d8733AJZytgkZG4U6IDOYBifFSOi5FH+7XbUiq X-Received: by 2002:a17:906:6b87:: with SMTP id l7mr25074178ejr.198.1597858220193; Wed, 19 Aug 2020 10:30:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597858220; cv=none; d=google.com; s=arc-20160816; b=Kh9PZLDd1KA/xAvxytPsX9highbsTZOMHU326XuYf0ban1AGyUKTt9inUZ+q3dL/gV 4C+IEp1hMk7Pn9YG5yM/ZnJMEJzV+sZvgB2kbvejP1aGf4ZfzmeMAuWJ48IZw3VU9wbc zR2TTrs1hYvIjccyI4Q6fMXbttCO41yry+x/jnk9hr6yIJZjuU9c0neScOWvZqZIFR86 VjQ8l5JzytsRoiwG3MuJGb901W9ICmev8iwpP6inCQ4MOGUw4x0bIo+n9+wFo8E+q20g +FdNttymAbfR90hdlg6DvUABC6dSEYMc2go65TClJEUsWK92Qh7FfzCRC1eHMqbLTokl LSdA== 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 :user-agent:organization:references:in-reply-to:date:cc:to:reply-to :from:subject:message-id:dkim-signature; bh=2KvgaCYohQhokdvpsCdvRkGWCDtbthJZmZ4XIsksp3I=; b=DU4tOAntSAu7vSWHhnKeWH3Y1Z0aZUAWvdz+EIns2YqCWhdfRcZpzwvEViRs3GwFPg fmi/IWab08hrNDtbWGHZA5tBkYwkRVOwTVtfpiCTFbyky+9t78PHoEIOGBfZuhwFY8ub WA7owqldvXTSxCO92v/QF1ZYYeUf1koqgyyGoChbFYZ/GXBex08x5bb7XshKwp3De/Ev ocXC3lw63sLxM3bfg85D9lOrubNRMa+6I7/7PcsfiV/pgFEssuQu2+F4H4+lohm26eSx iA2vJyqvThD/gjI2SDfxlTZBoXmAHujT07Cw7/kXlSlRuT0rsL2RhMO1i6X+xDD8eicC WO/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=J00KvQn0; 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 u29si17245193edd.533.2020.08.19.10.29.52; Wed, 19 Aug 2020 10:30:20 -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=J00KvQn0; 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 S1726612AbgHSR3Q (ORCPT + 99 others); Wed, 19 Aug 2020 13:29:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:33513 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbgHSR3I (ORCPT ); Wed, 19 Aug 2020 13:29:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597858145; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2KvgaCYohQhokdvpsCdvRkGWCDtbthJZmZ4XIsksp3I=; b=J00KvQn00MPEtzdrtj7AbZEbs7JaRg0tmxNmvBqyhf57Pfr8dEpxpSc/HGGHkWHS4/ZMXs sQgzwVBcX/oSsTJFQevTWL5KfQJk4e0vohmBf8TTqmKr3pkEDe6GsFhcMPAYvhZdQS5wll 2g7PIb8n6yYBImSBAagZ7YcBeFwznag= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-254-IHmoj3mMOpePeyOay1u_dQ-1; Wed, 19 Aug 2020 13:29:00 -0400 X-MC-Unique: IHmoj3mMOpePeyOay1u_dQ-1 Received: by mail-qk1-f198.google.com with SMTP id q3so15865213qkj.10 for ; Wed, 19 Aug 2020 10:29:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:reply-to:to:cc:date :in-reply-to:references:organization:user-agent:mime-version :content-transfer-encoding; bh=2KvgaCYohQhokdvpsCdvRkGWCDtbthJZmZ4XIsksp3I=; b=db/GFsNg6+1TwFXJCd0bPenR/ezL0yZSEmaC8m3q+sr9YwfOw0rNWhrlMhkBefNlqN okW6gakwt9ZbQyI3VzVcIJWEmDbNjVzu/iasJV3lLQIvmmI/RBq1cOGR8DPBPGcBpHGS nfL09osc2TSHSkpxIM3DQpCxKjJy3hC2j+Ii+QUt1DIJosaAnsjP4cyB9DJHMhqB0sJR hCvY/Ee7TUn+WjNKDA8kw+fBmYHxwdmmi92shJmVGDAngABKDJ2QsQnkfBnC1hvyzcBn 82HkJjcnAS+iOi/u0umfEwQa2JkuuAPAq51Awl2FYU2OnlJX4CRnrTMIDxhMdtJlMn9t 6iLQ== X-Gm-Message-State: AOAM533vb3MO5tXknTEN5mSF1PU/RJZGfvQdhdkP5sc2IIjbd/+ELm7z xnjGXEG++sxz9Om8FqdngQfX8QGXhnarIx8+lSrK4k3h9dpG8cw2wbOE6HwhkUJyzZFVBqGvSyJ r8Gawxcg1NRkMCI/Q3bgHmC/w X-Received: by 2002:aed:2f44:: with SMTP id l62mr22414138qtd.207.1597858140092; Wed, 19 Aug 2020 10:29:00 -0700 (PDT) X-Received: by 2002:aed:2f44:: with SMTP id l62mr22414117qtd.207.1597858139794; Wed, 19 Aug 2020 10:28:59 -0700 (PDT) Received: from Whitewolf.lyude.net (pool-108-49-102-102.bstnma.fios.verizon.net. [108.49.102.102]) by smtp.gmail.com with ESMTPSA id t8sm28688880qtc.50.2020.08.19.10.28.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 10:28:58 -0700 (PDT) Message-ID: Subject: Re: [RFC 13/20] drm/i915/dp: Extract drm_dp_downstream_read_info() From: Lyude Paul Reply-To: lyude@redhat.com To: Sean Paul Cc: nouveau@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Thomas Zimmermann , David Airlie , Lucas De Marchi , open list , Gwan-gyeong Mun , Manasi Navare , Uma Shankar , Rodrigo Vivi , =?ISO-8859-1?Q?Jos=E9?= Roberto de Souza , Wambui Karuga Date: Wed, 19 Aug 2020 13:28:57 -0400 In-Reply-To: <20200819151547.GB46474@art_vandelay> References: <20200811200457.134743-1-lyude@redhat.com> <20200811200457.134743-14-lyude@redhat.com> <20200819151547.GB46474@art_vandelay> Organization: Red Hat Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2020-08-19 at 11:15 -0400, Sean Paul wrote: > On Tue, Aug 11, 2020 at 04:04:50PM -0400, Lyude Paul wrote: > > We're going to be doing the same probing process in nouveau for > > determining downstream DP port capabilities, so let's deduplicate the > > work by moving i915's code for handling this into a shared helper: > > drm_dp_downstream_read_info(). > > > > Note that when we do this, we also do make some functional changes while > > we're at it: > > * We always clear the downstream port info before trying to read it, > > just to make things easier for the caller > > * We skip reading downstream port info if the DPCD indicates that we > > don't support downstream port info > > * We only read as many bytes as needed for the reported number of > > downstream ports, no sense in reading the whole thing every time > > > > Signed-off-by: Lyude Paul > > --- > > drivers/gpu/drm/drm_dp_helper.c | 32 +++++++++++++++++++++++++ > > drivers/gpu/drm/i915/display/intel_dp.c | 14 ++--------- > > include/drm/drm_dp_helper.h | 3 +++ > > 3 files changed, 37 insertions(+), 12 deletions(-) > > > > diff --git a/drivers/gpu/drm/drm_dp_helper.c > > b/drivers/gpu/drm/drm_dp_helper.c > > index 4c21cf69dad5a..9703b33599c3b 100644 > > --- a/drivers/gpu/drm/drm_dp_helper.c > > +++ b/drivers/gpu/drm/drm_dp_helper.c > > @@ -423,6 +423,38 @@ bool drm_dp_send_real_edid_checksum(struct drm_dp_aux > > *aux, > > } > > EXPORT_SYMBOL(drm_dp_send_real_edid_checksum); > > > > +/** > > + * drm_dp_downstream_read_info() - read DPCD downstream port info if > > available > > + * @aux: DisplayPort AUX channel > > + * @dpcd: A cached copy of the port's DPCD > > + * @downstream_ports: buffer to store the downstream port info in > > + * > > + * Returns: 0 if either the downstream port info was read successfully or > > + * there was no downstream info to read, or a negative error code > > otherwise. > > + */ > > +int drm_dp_downstream_read_info(struct drm_dp_aux *aux, > > + const u8 dpcd[DP_RECEIVER_CAP_SIZE], > > + u8 downstream_ports[DP_MAX_DOWNSTREAM_PORTS]) > > +{ > > + int ret; > > + u8 len; > > + > > + memset(downstream_ports, 0, DP_MAX_DOWNSTREAM_PORTS); > > + > > + /* No downstream info to read */ > > + if (!drm_dp_is_branch(dpcd) || > > + dpcd[DP_DPCD_REV] < DP_DPCD_REV_10 || > > + !(dpcd[DP_DOWNSTREAMPORT_PRESENT] & DP_DWN_STRM_PORT_PRESENT)) > > + return 0; > > + > > + len = (dpcd[DP_DOWN_STREAM_PORT_COUNT] & DP_PORT_COUNT_MASK) * 4; > > I'm having a hard time rationalizing DP_MAX_DOWNSTREAM_PORTS being 16, but > only > having 4 ports worth of data in the DP_DOWNSTREAM_PORT_* registers. Do you > know > what's supposed to happen if dpcd[DP_DOWN_STREAM_PORT_COUNT] is > 4? I thought I had addressed this bit but I guess I missed some parts here. So; there's actually two different possible lengths for how long each downstream port's capabilities can be: 1 byte long (if DETAILED_CAP_INFO_AVAILABLE in the DOWN_STREAM_PORT_PRESENT is 0, e.g. 005h bit 4), and 4 bytes long if that bit is 1. What's unfortunately not as clear, is whether or not 1 byte long cap fields mean "each port has four bytes, but only one byte is used" or "each port truly only has one byte". The DP spec says: DFPX_CAP 1 byte/DFP X = DFP number. Port_x capability is stored at the DFP number’s address plus 80h Which at first seems to imply that each cap is at 80 + X, e.g. only one byte long. However, the explanation for when DETAILED_CAP_INFO_AVAILABLE == 1 says almost the same thing: DFPX_CAP X = DFP number. Port_x capability is stored at the DFP number’s address plus 80h. Although right above that unlike the previous section, they mention that DFP0 goes from 80-83, DFP1 84-87, etc... Not entirely sure what to think here since I don't really have any devices (nor do I think I've ever seen any) that have more then one DFP. As well, for the case where we have multiple DFPs (which according to the spec appears to only be something we need to worry about for SST) they're not really explicit on how to combine the downstream capabilities from each DFP. My guess is maybe you determine the max downstream clock and bpp from the lowest clock limits advertised across each port? (if you have a DP device with multiple DFPs and can test this, that would rock :), but I have a feeling you probably don't have one either) > > Sean > > > + ret = drm_dp_dpcd_read(aux, DP_DOWNSTREAM_PORT_0, downstream_ports, > > + len); > > + > > + return ret == len ? 0 : -EIO; > > +} > > +EXPORT_SYMBOL(drm_dp_downstream_read_info); > > + > > /** > > * drm_dp_downstream_max_clock() - extract branch device max > > * pixel rate for legacy VGA > > diff --git a/drivers/gpu/drm/i915/display/intel_dp.c > > b/drivers/gpu/drm/i915/display/intel_dp.c > > index 1e29d3a012856..984e49194ca31 100644 > > --- a/drivers/gpu/drm/i915/display/intel_dp.c > > +++ b/drivers/gpu/drm/i915/display/intel_dp.c > > @@ -4685,18 +4685,8 @@ intel_dp_get_dpcd(struct intel_dp *intel_dp) > > return false; > > } > > > > - if (!drm_dp_is_branch(intel_dp->dpcd)) > > - return true; /* native DP sink */ > > - > > - if (intel_dp->dpcd[DP_DPCD_REV] == 0x10) > > - return true; /* no per-port downstream info */ > > - > > - if (drm_dp_dpcd_read(&intel_dp->aux, DP_DOWNSTREAM_PORT_0, > > - intel_dp->downstream_ports, > > - DP_MAX_DOWNSTREAM_PORTS) < 0) > > - return false; /* downstream port status fetch failed */ > > - > > - return true; > > + return drm_dp_downstream_read_info(&intel_dp->aux, intel_dp->dpcd, > > + intel_dp->downstream_ports) == 0; > > } > > > > static bool > > diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h > > index 5c28199248626..1349f16564ace 100644 > > --- a/include/drm/drm_dp_helper.h > > +++ b/include/drm/drm_dp_helper.h > > @@ -1613,6 +1613,9 @@ int drm_dp_dpcd_read_link_status(struct drm_dp_aux > > *aux, > > bool drm_dp_send_real_edid_checksum(struct drm_dp_aux *aux, > > u8 real_edid_checksum); > > > > +int drm_dp_downstream_read_info(struct drm_dp_aux *aux, > > + const u8 dpcd[DP_RECEIVER_CAP_SIZE], > > + u8 downstream_ports[DP_MAX_DOWNSTREAM_PORTS]); > > int drm_dp_downstream_max_clock(const u8 dpcd[DP_RECEIVER_CAP_SIZE], > > const u8 port_cap[4]); > > int drm_dp_downstream_max_bpc(const u8 dpcd[DP_RECEIVER_CAP_SIZE], > > -- > > 2.26.2 > > > > _______________________________________________ > > dri-devel mailing list > > dri-devel@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Sincerely, Lyude Paul (she/her) Software Engineer at Red Hat