Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/mst: remove mgr parameter and debug logging from drm_dp_get_vc_payload_bw()

The struct drm_dp_mst_topology_mgr *mgr parameter is only used for debug
logging in case the passed in link rate or lane count are zero. There's
no further error checking as such, and the function returns 0.

There should be no case where the parameters are zero. The returned
value is generally used as a divisor, and if we were hitting this, we'd
be seeing division by zero.

Just remove the debug logging altogether, along with the mgr parameter,
so that the function can be used in non-MST contexts without the
topology manager.

v2: Also remove drm_dp_mst_helper_tests_init as unnecessary (Imre)

Cc: Imre Deak <imre.deak@intel.com>
Cc: Lyude Paul <lyude@redhat.com>
Reviewed-by: Imre Deak <imre.deak@intel.com>
Acked-by: Maxime Ripard <mripard@kernel.org>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/72d77e7a7fe69c784e9df048b7e6f250fd7599e4.1735912293.git.jani.nikula@intel.com

+6 -30
+2 -8
drivers/gpu/drm/display/drm_dp_mst_topology.c
··· 3572 3572 } 3573 3573 3574 3574 /** 3575 - * drm_dp_get_vc_payload_bw - get the VC payload BW for an MST link 3576 - * @mgr: The &drm_dp_mst_topology_mgr to use 3575 + * drm_dp_get_vc_payload_bw - get the VC payload BW for an MTP link 3577 3576 * @link_rate: link rate in 10kbits/s units 3578 3577 * @link_lane_count: lane count 3579 3578 * ··· 3583 3584 * 3584 3585 * Returns the BW / timeslot value in 20.12 fixed point format. 3585 3586 */ 3586 - fixed20_12 drm_dp_get_vc_payload_bw(const struct drm_dp_mst_topology_mgr *mgr, 3587 - int link_rate, int link_lane_count) 3587 + fixed20_12 drm_dp_get_vc_payload_bw(int link_rate, int link_lane_count) 3588 3588 { 3589 3589 int ch_coding_efficiency = 3590 3590 drm_dp_bw_channel_coding_efficiency(drm_dp_is_uhbr_rate(link_rate)); 3591 3591 fixed20_12 ret; 3592 - 3593 - if (link_rate == 0 || link_lane_count == 0) 3594 - drm_dbg_kms(mgr->dev, "invalid link rate/lane count: (%d / %d)\n", 3595 - link_rate, link_lane_count); 3596 3592 3597 3593 /* See DP v2.0 2.6.4.2, 2.7.6.3 VCPayload_Bandwidth_for_OneTimeSlotPer_MTP_Allocation */ 3598 3594 ret.full = DIV_ROUND_DOWN_ULL(mul_u32_u32(link_rate * link_lane_count,
+1 -2
drivers/gpu/drm/i915/display/intel_dp_mst.c
··· 244 244 crtc_state->fec_enable = !intel_dp_is_uhbr(crtc_state); 245 245 } 246 246 247 - mst_state->pbn_div = drm_dp_get_vc_payload_bw(&intel_dp->mst_mgr, 248 - crtc_state->port_clock, 247 + mst_state->pbn_div = drm_dp_get_vc_payload_bw(crtc_state->port_clock, 249 248 crtc_state->lane_count); 250 249 251 250 max_dpt_bpp = intel_dp_mst_max_dpt_bpp(crtc_state, dsc);
+1 -2
drivers/gpu/drm/nouveau/dispnv50/disp.c
··· 992 992 if (!mst_state->pbn_div.full) { 993 993 struct nouveau_encoder *outp = mstc->mstm->outp; 994 994 995 - mst_state->pbn_div = drm_dp_get_vc_payload_bw(&mstm->mgr, 996 - outp->dp.link_bw, outp->dp.link_nr); 995 + mst_state->pbn_div = drm_dp_get_vc_payload_bw(outp->dp.link_bw, outp->dp.link_nr); 997 996 } 998 997 999 998 slots = drm_dp_atomic_find_time_slots(state, &mstm->mgr, mstc->port, asyh->dp.pbn);
+1 -16
drivers/gpu/drm/tests/drm_dp_mst_helper_test.c
··· 199 199 static void drm_test_dp_mst_calc_pbn_div(struct kunit *test) 200 200 { 201 201 const struct drm_dp_mst_calc_pbn_div_test *params = test->param_value; 202 - /* mgr->dev is only needed by drm_dbg_kms(), but it's not called for the test cases. */ 203 - struct drm_dp_mst_topology_mgr *mgr = test->priv; 204 202 205 - KUNIT_EXPECT_EQ(test, drm_dp_get_vc_payload_bw(mgr, params->link_rate, params->lane_count).full, 203 + KUNIT_EXPECT_EQ(test, drm_dp_get_vc_payload_bw(params->link_rate, params->lane_count).full, 206 204 params->expected.full); 207 205 } 208 206 ··· 566 568 { } 567 569 }; 568 570 569 - static int drm_dp_mst_helper_tests_init(struct kunit *test) 570 - { 571 - struct drm_dp_mst_topology_mgr *mgr; 572 - 573 - mgr = kunit_kzalloc(test, sizeof(*mgr), GFP_KERNEL); 574 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, mgr); 575 - 576 - test->priv = mgr; 577 - 578 - return 0; 579 - } 580 - 581 571 static struct kunit_suite drm_dp_mst_helper_test_suite = { 582 572 .name = "drm_dp_mst_helper", 583 - .init = drm_dp_mst_helper_tests_init, 584 573 .test_cases = drm_dp_mst_helper_tests, 585 574 }; 586 575
+1 -2
include/drm/display/drm_dp_mst_helper.h
··· 867 867 struct drm_dp_mst_topology_mgr *mgr, 868 868 struct drm_dp_mst_port *port); 869 869 870 - fixed20_12 drm_dp_get_vc_payload_bw(const struct drm_dp_mst_topology_mgr *mgr, 871 - int link_rate, int link_lane_count); 870 + fixed20_12 drm_dp_get_vc_payload_bw(int link_rate, int link_lane_count); 872 871 873 872 int drm_dp_calc_pbn_mode(int clock, int bpp); 874 873