From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2ABEEC4338F for ; Thu, 19 Aug 2021 16:51:41 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DB2766101A for ; Thu, 19 Aug 2021 16:51:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DB2766101A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 11D796E9A7; Thu, 19 Aug 2021 16:51:40 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4F2BA6E9A7; Thu, 19 Aug 2021 16:51:39 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10081"; a="213476815" X-IronPort-AV: E=Sophos;i="5.84,335,1620716400"; d="scan'208";a="213476815" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2021 09:51:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,335,1620716400"; d="scan'208";a="506158658" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.171]) by orsmga001.jf.intel.com with SMTP; 19 Aug 2021 09:51:35 -0700 Received: by stinkbox (sSMTP sendmail emulation); Thu, 19 Aug 2021 19:51:35 +0300 Date: Thu, 19 Aug 2021 19:51:35 +0300 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Jani Nikula Cc: intel-gfx@lists.freedesktop.org, manasi.d.navare@intel.com, dri-devel@lists.freedesktop.org Subject: Re: [PATCH 01/17] drm/dp: add DP 2.0 UHBR link rate and bw code conversions Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Patchwork-Hint: comment X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Wed, Aug 18, 2021 at 09:10:36PM +0300, Jani Nikula wrote: > The bw code equals link_rate / 0.27 Gbps only for 8b/10b link > rates. Handle DP 2.0 UHBR rates as special cases, though this is not > pretty. Ugh. So if I'm reading the spec right the behaviour of this register now changes dynamically depending on the state of some other bit in another register? > > Cc: dri-devel@lists.freedesktop.org > Signed-off-by: Jani Nikula > --- > drivers/gpu/drm/drm_dp_helper.c | 26 ++++++++++++++++++++++---- > 1 file changed, 22 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c > index 6d0f2c447f3b..9b2a2961fca8 100644 > --- a/drivers/gpu/drm/drm_dp_helper.c > +++ b/drivers/gpu/drm/drm_dp_helper.c > @@ -207,15 +207,33 @@ EXPORT_SYMBOL(drm_dp_lttpr_link_train_channel_eq_delay); > > u8 drm_dp_link_rate_to_bw_code(int link_rate) > { > - /* Spec says link_bw = link_rate / 0.27Gbps */ > - return link_rate / 27000; > + switch (link_rate) { > + case 1000000: > + return DP_LINK_BW_10; > + case 1350000: > + return DP_LINK_BW_13_5; > + case 2000000: > + return DP_LINK_BW_20; > + default: > + /* Spec says link_bw = link_rate / 0.27Gbps */ > + return link_rate / 27000; > + } > } > EXPORT_SYMBOL(drm_dp_link_rate_to_bw_code); > > int drm_dp_bw_code_to_link_rate(u8 link_bw) > { > - /* Spec says link_rate = link_bw * 0.27Gbps */ > - return link_bw * 27000; > + switch (link_bw) { > + case DP_LINK_BW_10: > + return 1000000; > + case DP_LINK_BW_13_5: > + return 1350000; > + case DP_LINK_BW_20: > + return 2000000; > + default: > + /* Spec says link_rate = link_bw * 0.27Gbps */ > + return link_bw * 27000; > + } > } > EXPORT_SYMBOL(drm_dp_bw_code_to_link_rate); > > -- > 2.20.1 -- Ville Syrjälä Intel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE88EC4338F for ; Thu, 19 Aug 2021 16:51:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 842D660F4C for ; Thu, 19 Aug 2021 16:51:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 842D660F4C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 350B56E9AE; Thu, 19 Aug 2021 16:51:41 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4F2BA6E9A7; Thu, 19 Aug 2021 16:51:39 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10081"; a="213476815" X-IronPort-AV: E=Sophos;i="5.84,335,1620716400"; d="scan'208";a="213476815" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2021 09:51:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,335,1620716400"; d="scan'208";a="506158658" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.171]) by orsmga001.jf.intel.com with SMTP; 19 Aug 2021 09:51:35 -0700 Received: by stinkbox (sSMTP sendmail emulation); Thu, 19 Aug 2021 19:51:35 +0300 Date: Thu, 19 Aug 2021 19:51:35 +0300 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Jani Nikula Cc: intel-gfx@lists.freedesktop.org, manasi.d.navare@intel.com, dri-devel@lists.freedesktop.org Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Patchwork-Hint: comment Subject: Re: [Intel-gfx] [PATCH 01/17] drm/dp: add DP 2.0 UHBR link rate and bw code conversions X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Wed, Aug 18, 2021 at 09:10:36PM +0300, Jani Nikula wrote: > The bw code equals link_rate / 0.27 Gbps only for 8b/10b link > rates. Handle DP 2.0 UHBR rates as special cases, though this is not > pretty. Ugh. So if I'm reading the spec right the behaviour of this register now changes dynamically depending on the state of some other bit in another register? > > Cc: dri-devel@lists.freedesktop.org > Signed-off-by: Jani Nikula > --- > drivers/gpu/drm/drm_dp_helper.c | 26 ++++++++++++++++++++++---- > 1 file changed, 22 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c > index 6d0f2c447f3b..9b2a2961fca8 100644 > --- a/drivers/gpu/drm/drm_dp_helper.c > +++ b/drivers/gpu/drm/drm_dp_helper.c > @@ -207,15 +207,33 @@ EXPORT_SYMBOL(drm_dp_lttpr_link_train_channel_eq_delay); > > u8 drm_dp_link_rate_to_bw_code(int link_rate) > { > - /* Spec says link_bw = link_rate / 0.27Gbps */ > - return link_rate / 27000; > + switch (link_rate) { > + case 1000000: > + return DP_LINK_BW_10; > + case 1350000: > + return DP_LINK_BW_13_5; > + case 2000000: > + return DP_LINK_BW_20; > + default: > + /* Spec says link_bw = link_rate / 0.27Gbps */ > + return link_rate / 27000; > + } > } > EXPORT_SYMBOL(drm_dp_link_rate_to_bw_code); > > int drm_dp_bw_code_to_link_rate(u8 link_bw) > { > - /* Spec says link_rate = link_bw * 0.27Gbps */ > - return link_bw * 27000; > + switch (link_bw) { > + case DP_LINK_BW_10: > + return 1000000; > + case DP_LINK_BW_13_5: > + return 1350000; > + case DP_LINK_BW_20: > + return 2000000; > + default: > + /* Spec says link_rate = link_bw * 0.27Gbps */ > + return link_bw * 27000; > + } > } > EXPORT_SYMBOL(drm_dp_bw_code_to_link_rate); > > -- > 2.20.1 -- Ville Syrjälä Intel