From 0c3bb15cfc0eb1b509de1b7dd9a0e8c18c0ac5e5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Wed, 25 Sep 2019 17:14:41 +0300 Subject: [PATCH] drm/dp/mst: Handle arbitrary DP_LINK_BW values MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Make drm_dp_get_vc_payload() tolerate arbitrary DP_LINK_BW_* values, just like drm_dp_bw_code_to_link_rate() does since commit 57a1b0893782 ("drm: Make the bw/link rate calculations more forgiving"). Cc: Lyude Paul Cc: Sean Paul Signed-off-by: Ville Syrjälä Link: https://patchwork.freedesktop.org/patch/msgid/20190925141442.23236-2-ville.syrjala@linux.intel.com Reviewed-by: Lyude Paul --- drivers/gpu/drm/drm_dp_mst_topology.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index dd06a50..f90f185 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -2977,30 +2977,13 @@ static int drm_dp_send_up_ack_reply(struct drm_dp_mst_topology_mgr *mgr, return 0; } -static bool drm_dp_get_vc_payload_bw(int dp_link_bw, - int dp_link_count, - int *out) +static int drm_dp_get_vc_payload_bw(u8 dp_link_bw, u8 dp_link_count) { - switch (dp_link_bw) { - default: + 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); - return false; - case DP_LINK_BW_1_62: - *out = 3 * dp_link_count; - break; - case DP_LINK_BW_2_7: - *out = 5 * dp_link_count; - break; - case DP_LINK_BW_5_4: - *out = 10 * dp_link_count; - break; - case DP_LINK_BW_8_1: - *out = 15 * dp_link_count; - break; - } - return true; + return dp_link_bw * dp_link_count / 2; } /** @@ -3032,9 +3015,9 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms goto out_unlock; } - if (!drm_dp_get_vc_payload_bw(mgr->dpcd[1], - mgr->dpcd[2] & DP_MAX_LANE_COUNT_MASK, - &mgr->pbn_div)) { + mgr->pbn_div = drm_dp_get_vc_payload_bw(mgr->dpcd[1], + mgr->dpcd[2] & DP_MAX_LANE_COUNT_MASK); + if (mgr->pbn_div == 0) { ret = -EINVAL; goto out_unlock; } -- 2.7.4