Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp276042pxa; Wed, 26 Aug 2020 10:15:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiP7RRiEyh2wGVsYj/8/OT6eRPlh6Imax2Jm14bfNdrb2F6ucljf1/U12qqVW20k9t7Td3 X-Received: by 2002:a17:906:403:: with SMTP id d3mr16512152eja.522.1598462124838; Wed, 26 Aug 2020 10:15:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598462124; cv=none; d=google.com; s=arc-20160816; b=FYZkLN/P+VtKBmNCBxu9QoyM4fQDH+ADougqjx1m2Px2w/PwswNqftTnxOwAE7Urk2 N/HX8hdN0l1sn4U9niSrq0YYXOAeY6aMzDS3YxyK4rzVY4GXX/h0+ipqapqwYoXVcNg+ RhwPd85AIyNENj6tmIUlQKUnLhOGu0+jquDCwdyn/s8nBWS81l0xsJpIhnFDWcsVaIDy eCzLRjO/eVrahH+Fbx7h4dvnFVQe1YWn9W0Mpv1BzPMop8SEmXvO7o+03bgZfM1N+6iY u7620pLk7VFKvgVsxDPwR8tKJZQHFb9FiEiYGbGCHSPRSofOScm1zo1nbZsf9CtXa530 EXFQ== 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=HNxk+EQ8wQ8tVIGqRrZql9fbdwG5Cj1VEgrvd+qiq60=; b=qwiUVWQfTuYb8qdjOuFcOo7eb/UT1a71xYu0ZR458qtrdd+h/CgCtpkOVvUEtNaf8Q HGtD7aL9qSdMV31XES2c79VOlgoMtb807kL7QN6pUCBRR2w/HawSrY5aUOfQtSw7IcbS AB/78k4WvxqNyb2jDDW9kiEfE836ZjtJhwz8Pm9v3PvMC7q/bvIUtSdKgr92m+6wXIWy PHAMkEGaXFr57/PSJtaltnsZ0w0+YtUTAVK6apSL3ybiOkoWyS0Nze1BkWNOWtY6Loi8 dQNSP/9cUOnDFFVHkjze/6dmzTT4f/KuUyPVVtPiicDOGe75h1iwFwSW229DVkQCAivc eo8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Wc5fZDZp; 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 v23si2038337ejg.705.2020.08.26.10.14.53; Wed, 26 Aug 2020 10:15:24 -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=Wc5fZDZp; 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 S1726790AbgHZRNH (ORCPT + 99 others); Wed, 26 Aug 2020 13:13:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:42864 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726802AbgHZRM6 (ORCPT ); Wed, 26 Aug 2020 13:12:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598461976; 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=HNxk+EQ8wQ8tVIGqRrZql9fbdwG5Cj1VEgrvd+qiq60=; b=Wc5fZDZp7jdCf/2ZLfB7hAsiqL761hpHzJsyIOQqTFsmdQMT9wUrXNWHnkEG5c8/3yXue1 P0JRciT3f6Yr1+xgXZd499mPdjH4d+5/mY9XnZoaJSOrh3WG1JkZwR1L91lYQ9g4BRwCng AoCvEbOqUBNHg8PzYVM8S00faXrSg4E= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-213-X-4eoZCAOf6wZmXJrCymrA-1; Wed, 26 Aug 2020 13:12:55 -0400 X-MC-Unique: X-4eoZCAOf6wZmXJrCymrA-1 Received: by mail-qv1-f69.google.com with SMTP id y12so2086571qva.8 for ; Wed, 26 Aug 2020 10:12:55 -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=HNxk+EQ8wQ8tVIGqRrZql9fbdwG5Cj1VEgrvd+qiq60=; b=dRrR5a5nPELQsdwWeLbLnXKW736b08SHL8bRNo68Xv/ziS8C/yFhXFIUdEd3XY5b7a xnmIdYlO+a7MADlXSB2FsVTa2hbmCl//rn8eF7+mhplPoS5uRAxIp3WsD9+qTA26df2U FF0UGMNG38Wtj8nTtqUVRHqkY56NXB2gV2AsETK4RNJupk+ISaoQbqCIZSvHfFBohDdV e/lbsI8FSjKegjsC7MyjcXZnxOQlfG0pKqPs4v6BOOkhWZBEYqXZh2qZJRV4GpFbTOEc szDV0VDb+SMoeYHXkcNqnTaalK8tB4p0nIjijyxq5QHjL6ROA6QVPcir+7szMuzSjdbK +qBw== X-Gm-Message-State: AOAM5306IS4PYdsxPDTG4HtaGLGWphkNXS8qSut84Uo3LKZ7LEUf/KOV vyfYGlSxqpfq0Wq90MT2L7l4PXGfHx3ChpjAURoCjLnT5iWKzfvC+5OVPdUIGXv2/0LpwAdzScz UdrQgASIDCm1g8aBWxvY1lqQj X-Received: by 2002:ac8:458a:: with SMTP id l10mr14982585qtn.345.1598461974855; Wed, 26 Aug 2020 10:12:54 -0700 (PDT) X-Received: by 2002:ac8:458a:: with SMTP id l10mr14982565qtn.345.1598461974593; Wed, 26 Aug 2020 10:12:54 -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 r73sm2063390qka.76.2020.08.26.10.12.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 10:12:54 -0700 (PDT) Message-ID: <0b9fe80d058320b4e8e4fdf51a5445eddb1b0467.camel@redhat.com> Subject: Re: [RFC v4 16/20] drm/i915/dp: Extract drm_dp_get_sink_count() From: Lyude Paul Reply-To: lyude@redhat.com To: Jani Nikula , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, nouveau@lists.freedesktop.org Cc: Sean Paul , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Joonas Lahtinen , Rodrigo Vivi , Ville =?ISO-8859-1?Q?Syrj=E4l=E4?= , =?ISO-8859-1?Q?Jos=E9?= Roberto de Souza , Manasi Navare , Uma Shankar , Gwan-gyeong Mun , Imre Deak , Wambui Karuga , Lucas De Marchi , open list Date: Wed, 26 Aug 2020 13:12:52 -0400 In-Reply-To: <87o8mx6g6a.fsf@intel.com> References: <20200825195027.74681-1-lyude@redhat.com> <20200825195027.74681-17-lyude@redhat.com> <87o8mx6g6a.fsf@intel.com> 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: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2020-08-26 at 10:05 +0300, Jani Nikula wrote: > On Tue, 25 Aug 2020, Lyude Paul wrote: > > And of course, we'll also need to read the sink count from other drivers > > as well if we're checking whether or not it's supported. So, let's > > extract the code for this into another helper. > > > > v2: > > * Fix drm_dp_dpcd_readb() ret check > > * Add back comment and move back sink_count assignment in > > intel_dp_get_dpcd() > > > > Signed-off-by: Lyude Paul > > Reviewed-by: Sean Paul > > --- > > drivers/gpu/drm/drm_dp_helper.c | 22 ++++++++++++++++++++++ > > drivers/gpu/drm/i915/display/intel_dp.c | 11 +++++------ > > include/drm/drm_dp_helper.h | 1 + > > 3 files changed, 28 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/gpu/drm/drm_dp_helper.c > > b/drivers/gpu/drm/drm_dp_helper.c > > index 863e0babc1903..67ad05eb05b7e 100644 > > --- a/drivers/gpu/drm/drm_dp_helper.c > > +++ b/drivers/gpu/drm/drm_dp_helper.c > > @@ -736,6 +736,28 @@ bool drm_dp_has_sink_count(struct drm_connector > > *connector, > > } > > EXPORT_SYMBOL(drm_dp_has_sink_count); > > > > +/** > > + * drm_dp_get_sink_count() - Retrieve the sink count for a given sink > > From the department of bikeshedding... > > Should we have a naming scheme where it's obvious whether a function > will do DPCD access, or just shuffle existing data? > > For example, drm_dp_read_foo() for anything with DPCD access > vs. drm_dp_get_foo() or even simpler for anything that only processes > pre-read data? Forgot to address this comment - yeah, I think that would be a good idea. I'll go through my previous patches and make sure that they match this naming scheme as well. > > > + * @aux: The DP AUX channel to use > > + * > > + * Returns: The current sink count reported by @aux, or a negative error > > code > > + * otherwise. > > + */ > > +int drm_dp_get_sink_count(struct drm_dp_aux *aux) > > +{ > > + u8 count; > > + int ret; > > + > > + ret = drm_dp_dpcd_readb(aux, DP_SINK_COUNT, &count); > > + if (ret < 0) > > + return ret; > > + if (ret != 1) > > + return -EIO; > > Makes me wonder if that shouldn't be at drm_dp_dpcd_read() level, for > reads returning 0..len-1 bytes. Not necessarily part of this series, but > seems silly to set a precedent to start handling that return value all > over the place. > > BR, > Jani. > > > + > > + return DP_GET_SINK_COUNT(count); > > +} > > +EXPORT_SYMBOL(drm_dp_get_sink_count); > > + > > /* > > * I2C-over-AUX implementation > > */ > > diff --git a/drivers/gpu/drm/i915/display/intel_dp.c > > b/drivers/gpu/drm/i915/display/intel_dp.c > > index 35a4779a442e2..4337321a3be4f 100644 > > --- a/drivers/gpu/drm/i915/display/intel_dp.c > > +++ b/drivers/gpu/drm/i915/display/intel_dp.c > > @@ -4648,6 +4648,8 @@ intel_dp_has_sink_count(struct intel_dp *intel_dp) > > static bool > > intel_dp_get_dpcd(struct intel_dp *intel_dp) > > { > > + int ret; > > + > > if (!intel_dp_read_dpcd(intel_dp)) > > return false; > > > > @@ -4664,11 +4666,8 @@ intel_dp_get_dpcd(struct intel_dp *intel_dp) > > } > > > > if (intel_dp_has_sink_count(intel_dp)) { > > - u8 count; > > - ssize_t r; > > - > > - r = drm_dp_dpcd_readb(&intel_dp->aux, DP_SINK_COUNT, &count); > > - if (r < 1) > > + ret = drm_dp_get_sink_count(&intel_dp->aux); > > + if (ret < 0) > > return false; > > > > /* > > @@ -4676,7 +4675,7 @@ intel_dp_get_dpcd(struct intel_dp *intel_dp) > > * a member variable in intel_dp will track any changes > > * between short pulse interrupts. > > */ > > - intel_dp->sink_count = DP_GET_SINK_COUNT(count); > > + intel_dp->sink_count = ret; > > > > /* > > * SINK_COUNT == 0 and DOWNSTREAM_PORT_PRESENT == 1 implies that > > diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h > > index a1413a531eaf4..0c141fc81aaa8 100644 > > --- a/include/drm/drm_dp_helper.h > > +++ b/include/drm/drm_dp_helper.h > > @@ -1635,6 +1635,7 @@ struct drm_dp_desc; > > bool drm_dp_has_sink_count(struct drm_connector *connector, > > const u8 dpcd[DP_RECEIVER_CAP_SIZE], > > const struct drm_dp_desc *desc); > > +int drm_dp_get_sink_count(struct drm_dp_aux *aux); > > > > void drm_dp_remote_aux_init(struct drm_dp_aux *aux); > > void drm_dp_aux_init(struct drm_dp_aux *aux); -- Sincerely, Lyude Paul (she/her) Software Engineer at Red Hat