Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4165301pxb; Mon, 8 Feb 2021 09:24:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1ya15/agTPaG0teIcpuUvmNieMk7Q5d+ZOY76wZpCdOVKNvVF0jqVOYdtdhykXAgbDgr9 X-Received: by 2002:a17:906:cf86:: with SMTP id um6mr18521699ejb.426.1612805056541; Mon, 08 Feb 2021 09:24:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612805056; cv=none; d=google.com; s=arc-20160816; b=jzwJKe5kSAtVEYty56Wr+2AchFKnBGyyd0dnL8PtUs0cBCgtVfCH2VcqQB7PQBLsIL pjjATn3SB5InHNNEsiDcR5/30w/UrFHFFwQl+ymwfr/t2hSvWXGfVIs4MekClDisIBn0 bip+QQDX+YDyrakB/G0yWSSXBpM0bX7a7AIC590DGB9PtVIgBRXqKpfozJBvGxi8TwIR cCPeiHhnUU66iSqubMYQwxWht1C/ZLMVy5LX69OcvHs4nE81VqrVP7Tz5IevGxjp8+2g agq6cwBSthf2Vy1yMmeb9d/Ci1aJdmo3qQPMqmbS85NgYmG1W9EKoJ3EndmujhV+Fp7Y JVeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bKfW0GDSuym3NzFqgHhrSkZUunl4NWN8c7Ft05GKy54=; b=EzmYVf/SKiWbFGtAz/Hv4pdG4X8FHhTSB6rdv35lkesrc9FZejuG5HeAkecfO3hRUo /c/AoEAP7XBOcIMn96cqbrj6x6ijUCP/iB8j52lhr5uPpddQYMHScKm9ez7usb38pqNu MxPiP4l9QhfnqwEQ7NIH/g0TadKaCw42mFTicx/rbkysEMB0oX3vCnmYW8Q+rD/hNrC3 2LocVi6gla8O/X+1AjrAaC0ZFBOP0N/iQ61sD9pXhVdEoSP7zUzbwUPXGtjnsgHK+s72 5jPlSHOv3n/5aurkSSxcV/teAZ7uoNuysirQPwASwvE1AphgSiDXi9jr77heWrs09saW o1zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NmeHZ0T+; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id js10si10708726ejc.446.2021.02.08.09.23.51; Mon, 08 Feb 2021 09:24:16 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=NmeHZ0T+; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233816AbhBHRUX (ORCPT + 99 others); Mon, 8 Feb 2021 12:20:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:36394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230101AbhBHP0v (ORCPT ); Mon, 8 Feb 2021 10:26:51 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B2FA864F20; Mon, 8 Feb 2021 15:15:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612797346; bh=2ktO6u/bOQJqlEHKKcuoK+7PPWci1WCWMSoeppvCyiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NmeHZ0T+Z0eosxr9d7jdPqLOX/J7lIuBfAGL4Ud3q/BwTmXnOQipr22I+RMvEzjU1 U+XQft5Rz7Ip4RDVgMDN/hUAUTINq6Og3AnzBYNJmvUIOe9kCJTcxpC3i/XWpC1QL/ Y7JUuUwJQk1Nb7Qr6QwdFNmHFtXZaPmCuQYSbP6M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lyude Paul , Ville Syrjala , dri-devel@lists.freedesktop.org, Imre Deak , Jani Nikula Subject: [PATCH 5.10 078/120] drm/dp/mst: Export drm_dp_get_vc_payload_bw() Date: Mon, 8 Feb 2021 16:01:05 +0100 Message-Id: <20210208145821.517331268@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145818.395353822@linuxfoundation.org> References: <20210208145818.395353822@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Imre Deak commit 83404d581471775f37f85e5261ec0d09407d8bed upstream. This function will be needed by the next patch where the driver calculates the BW based on driver specific parameters, so export it. At the same time sanitize the function params, passing the more natural link rate instead of the encoding of the same rate. v2: - Fix function documentation. (Lyude) Cc: Lyude Paul Cc: Ville Syrjala Cc: Cc: dri-devel@lists.freedesktop.org Signed-off-by: Imre Deak Reviewed-by: Lyude Paul Link: https://patchwork.freedesktop.org/patch/msgid/20210125173636.1733812-1-imre.deak@intel.com (cherry picked from commit a321fc2b4e60fc1b39517d26c8104351636a6062) Signed-off-by: Jani Nikula Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/drm_dp_mst_topology.c | 24 ++++++++++++++++++------ include/drm/drm_dp_mst_helper.h | 1 + 2 files changed, 19 insertions(+), 6 deletions(-) --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -3629,14 +3629,26 @@ static int drm_dp_send_up_ack_reply(stru return 0; } -static int drm_dp_get_vc_payload_bw(u8 dp_link_bw, u8 dp_link_count) +/** + * drm_dp_get_vc_payload_bw - get the VC payload BW for an MST link + * @link_rate: link rate in 10kbits/s units + * @link_lane_count: lane count + * + * Calculate the total bandwidth of a MultiStream Transport link. The returned + * value is in units of PBNs/(timeslots/1 MTP). This value can be used to + * convert the number of PBNs required for a given stream to the number of + * timeslots this stream requires in each MTP. + */ +int drm_dp_get_vc_payload_bw(int link_rate, int link_lane_count) { - if (dp_link_bw == 0 || dp_link_count == 0) - DRM_DEBUG_KMS("invalid link bandwidth in DPCD: %x (link count: %d)\n", - dp_link_bw, dp_link_count); + if (link_rate == 0 || link_lane_count == 0) + DRM_DEBUG_KMS("invalid link rate/lane count: (%d / %d)\n", + link_rate, link_lane_count); - return dp_link_bw * dp_link_count / 2; + /* See DP v2.0 2.6.4.2, VCPayload_Bandwidth_for_OneTimeSlotPer_MTP_Allocation */ + return link_rate * link_lane_count / 54000; } +EXPORT_SYMBOL(drm_dp_get_vc_payload_bw); /** * drm_dp_read_mst_cap() - check whether or not a sink supports MST @@ -3692,7 +3704,7 @@ int drm_dp_mst_topology_mgr_set_mst(stru goto out_unlock; } - mgr->pbn_div = drm_dp_get_vc_payload_bw(mgr->dpcd[1], + mgr->pbn_div = drm_dp_get_vc_payload_bw(drm_dp_bw_code_to_link_rate(mgr->dpcd[1]), mgr->dpcd[2] & DP_MAX_LANE_COUNT_MASK); if (mgr->pbn_div == 0) { ret = -EINVAL; --- a/include/drm/drm_dp_mst_helper.h +++ b/include/drm/drm_dp_mst_helper.h @@ -783,6 +783,7 @@ drm_dp_mst_detect_port(struct drm_connec struct edid *drm_dp_mst_get_edid(struct drm_connector *connector, struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port); +int drm_dp_get_vc_payload_bw(int link_rate, int link_lane_count); int drm_dp_calc_pbn_mode(int clock, int bpp, bool dsc);