diff mbox series

[v2,03/11] drm/dp_mst: Add kunit tests for drm_dp_get_vc_payload_bw()

Message ID 20231116131841.1588781-4-imre.deak@intel.com (mailing list archive)
State New, archived
Headers show
Series [v2,01/11] drm/dp_mst: Store the MST PBN divider value in fixed point format | expand

Commit Message

Imre Deak Nov. 16, 2023, 1:18 p.m. UTC
Add kunit test cases for drm_dp_get_vc_payload_bw() with all the DP1.4
and UHBR link configurations.

Cc: Lyude Paul <lyude@redhat.com>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 .../gpu/drm/tests/drm_dp_mst_helper_test.c    | 145 ++++++++++++++++++
 1 file changed, 145 insertions(+)

Comments

Ville Syrjälä Nov. 17, 2023, 11:04 a.m. UTC | #1
On Thu, Nov 16, 2023 at 03:18:33PM +0200, Imre Deak wrote:
> Add kunit test cases for drm_dp_get_vc_payload_bw() with all the DP1.4
> and UHBR link configurations.
> 
> Cc: Lyude Paul <lyude@redhat.com>
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
>  .../gpu/drm/tests/drm_dp_mst_helper_test.c    | 145 ++++++++++++++++++
>  1 file changed, 145 insertions(+)
> 
> diff --git a/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c b/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c
> index e3c818dfc0e6d..cafb463124f71 100644
> --- a/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c
> +++ b/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c
> @@ -68,6 +68,150 @@ static void dp_mst_calc_pbn_mode_desc(const struct drm_dp_mst_calc_pbn_mode_test
>  KUNIT_ARRAY_PARAM(drm_dp_mst_calc_pbn_mode, drm_dp_mst_calc_pbn_mode_cases,
>  		  dp_mst_calc_pbn_mode_desc);
>  
> +struct drm_dp_mst_calc_pbn_div_test {
> +	int link_rate;
> +	int lane_count;
> +	fixed20_12 expected;
> +};
> +
> +#define fp_init(__int, __frac) { \
> +	.full = (__int) * (1 << 12) + \
> +		(__frac) * (1 << 12) / 100000 \
> +}
> +
> +static const struct drm_dp_mst_calc_pbn_div_test drm_dp_mst_calc_pbn_div_dp1_4_cases[] = {
> +	/*
> +	 * DP1.4 rates:
> +	 * .expected = .link_rate * .lane_count * 0.8000 / 8 / 54 / 100
> +	 * UHBR rates:
> +	 * .expected = .link_rate * .lane_count * 0.9671 / 8 / 54 / 100
> +	 * truncated to 5 decimal places.
> +	 */
> +	{
> +		.link_rate = 162000,
> +		.lane_count = 1,
> +		.expected = fp_init(3, 0),
> +	},

Would be nice to sort this to match the tables in the spec.
A bit hard to do a quick visual comparison now.

> +	{
> +		.link_rate = 162000,
> +		.lane_count = 2,
> +		.expected = fp_init(6, 0),
> +	},
> +	{
> +		.link_rate = 162000,
> +		.lane_count = 4,
> +		.expected = fp_init(12, 0),
> +	},
> +	{
> +		.link_rate = 270000,
> +		.lane_count = 1,
> +		.expected = fp_init(5, 0),
> +	},
> +	{
> +		.link_rate = 270000,
> +		.lane_count = 2,
> +		.expected = fp_init(10, 0),
> +	},
> +	{
> +		.link_rate = 270000,
> +		.lane_count = 4,
> +		.expected = fp_init(20, 0),
> +	},
> +	{
> +		.link_rate = 540000,
> +		.lane_count = 1,
> +		.expected = fp_init(10, 0),
> +	},
> +	{
> +		.link_rate = 540000,
> +		.lane_count = 2,
> +		.expected = fp_init(20, 0),
> +	},
> +	{
> +		.link_rate = 540000,
> +		.lane_count = 4,
> +		.expected = fp_init(40, 0),
> +	},
> +	{
> +		.link_rate = 810000,
> +		.lane_count = 1,
> +		.expected = fp_init(15, 0),
> +	},
> +	{
> +		.link_rate = 810000,
> +		.lane_count = 2,
> +		.expected = fp_init(30, 0),
> +	},
> +	{
> +		.link_rate = 810000,
> +		.lane_count = 4,
> +		.expected = fp_init(60, 0),
> +	},
> +	{
> +		.link_rate = 1000000,
> +		.lane_count = 1,
> +		.expected = fp_init(22, 38657),
> +	},
> +	{
> +		.link_rate = 1000000,
> +		.lane_count = 2,
> +		.expected = fp_init(44, 77314),
> +	},
> +	{
> +		.link_rate = 1000000,
> +		.lane_count = 4,
> +		.expected = fp_init(89, 54629),
> +	},
> +	{
> +		.link_rate = 1350000,
> +		.lane_count = 1,
> +		.expected = fp_init(30, 22187),
> +	},
> +	{
> +		.link_rate = 1350000,
> +		.lane_count = 2,
> +		.expected = fp_init(60, 44375),
> +	},
> +	{
> +		.link_rate = 1350000,
> +		.lane_count = 4,
> +		.expected = fp_init(120, 88750),
> +	},
> +	{
> +		.link_rate = 2000000,
> +		.lane_count = 1,
> +		.expected = fp_init(44, 77314),
> +	},
> +	{
> +		.link_rate = 2000000,
> +		.lane_count = 2,
> +		.expected = fp_init(89, 54629),
> +	},
> +	{
> +		.link_rate = 2000000,
> +		.lane_count = 4,
> +		.expected = fp_init(179,  9259),  /* 179.09259 */
> +	},
> +};
> +
> +static void drm_test_dp_mst_calc_pbn_div(struct kunit *test)
> +{
> +	const struct drm_dp_mst_calc_pbn_div_test *params = test->param_value;
> +	/* mgr->dev is only needed by drm_dbg_kms(), but it's not called for the test cases. */
> +	struct drm_dp_mst_topology_mgr mgr = {};
> +
> +	KUNIT_EXPECT_EQ(test, drm_dp_get_vc_payload_bw(&mgr, params->link_rate, params->lane_count).full,
> +			params->expected.full);
> +}
> +
> +static void dp_mst_calc_pbn_div_desc(const struct drm_dp_mst_calc_pbn_div_test *t, char *desc)
> +{
> +	sprintf(desc, "Link rate %d lane count %d", t->link_rate, t->lane_count);
> +}
> +
> +KUNIT_ARRAY_PARAM(drm_dp_mst_calc_pbn_div, drm_dp_mst_calc_pbn_div_dp1_4_cases,
> +		  dp_mst_calc_pbn_div_desc);
> +
>  static u8 data[] = { 0xff, 0x00, 0xdd };
>  
>  struct drm_dp_mst_sideband_msg_req_test {
> @@ -416,6 +560,7 @@ KUNIT_ARRAY_PARAM(drm_dp_mst_sideband_msg_req, drm_dp_mst_sideband_msg_req_cases
>  
>  static struct kunit_case drm_dp_mst_helper_tests[] = {
>  	KUNIT_CASE_PARAM(drm_test_dp_mst_calc_pbn_mode, drm_dp_mst_calc_pbn_mode_gen_params),
> +	KUNIT_CASE_PARAM(drm_test_dp_mst_calc_pbn_div, drm_dp_mst_calc_pbn_div_gen_params),
>  	KUNIT_CASE_PARAM(drm_test_dp_mst_sideband_msg_req_decode,
>  			 drm_dp_mst_sideband_msg_req_gen_params),
>  	{ }
> -- 
> 2.39.2
Imre Deak Nov. 17, 2023, 2:35 p.m. UTC | #2
On Fri, Nov 17, 2023 at 01:04:02PM +0200, Ville Syrjälä wrote:
> On Thu, Nov 16, 2023 at 03:18:33PM +0200, Imre Deak wrote:
> > Add kunit test cases for drm_dp_get_vc_payload_bw() with all the DP1.4
> > and UHBR link configurations.
> > 
> > Cc: Lyude Paul <lyude@redhat.com>
> > Cc: dri-devel@lists.freedesktop.org
> > Signed-off-by: Imre Deak <imre.deak@intel.com>
> > ---
> >  .../gpu/drm/tests/drm_dp_mst_helper_test.c    | 145 ++++++++++++++++++
> >  1 file changed, 145 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c b/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c
> > index e3c818dfc0e6d..cafb463124f71 100644
> > --- a/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c
> > +++ b/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c
> > @@ -68,6 +68,150 @@ static void dp_mst_calc_pbn_mode_desc(const struct drm_dp_mst_calc_pbn_mode_test
> >  KUNIT_ARRAY_PARAM(drm_dp_mst_calc_pbn_mode, drm_dp_mst_calc_pbn_mode_cases,
> >  		  dp_mst_calc_pbn_mode_desc);
> >  
> > +struct drm_dp_mst_calc_pbn_div_test {
> > +	int link_rate;
> > +	int lane_count;
> > +	fixed20_12 expected;
> > +};
> > +
> > +#define fp_init(__int, __frac) { \
> > +	.full = (__int) * (1 << 12) + \
> > +		(__frac) * (1 << 12) / 100000 \
> > +}
> > +
> > +static const struct drm_dp_mst_calc_pbn_div_test drm_dp_mst_calc_pbn_div_dp1_4_cases[] = {
> > +	/*
> > +	 * DP1.4 rates:
> > +	 * .expected = .link_rate * .lane_count * 0.8000 / 8 / 54 / 100
> > +	 * UHBR rates:
> > +	 * .expected = .link_rate * .lane_count * 0.9671 / 8 / 54 / 100
> > +	 * truncated to 5 decimal places.
> > +	 */
> > +	{
> > +		.link_rate = 162000,
> > +		.lane_count = 1,
> > +		.expected = fp_init(3, 0),
> > +	},
> 
> Would be nice to sort this to match the tables in the spec.
> A bit hard to do a quick visual comparison now.

Ok, makes sense.

> > +	{
> > +		.link_rate = 162000,
> > +		.lane_count = 2,
> > +		.expected = fp_init(6, 0),
> > +	},
> > +	{
> > +		.link_rate = 162000,
> > +		.lane_count = 4,
> > +		.expected = fp_init(12, 0),
> > +	},
> > +	{
> > +		.link_rate = 270000,
> > +		.lane_count = 1,
> > +		.expected = fp_init(5, 0),
> > +	},
> > +	{
> > +		.link_rate = 270000,
> > +		.lane_count = 2,
> > +		.expected = fp_init(10, 0),
> > +	},
> > +	{
> > +		.link_rate = 270000,
> > +		.lane_count = 4,
> > +		.expected = fp_init(20, 0),
> > +	},
> > +	{
> > +		.link_rate = 540000,
> > +		.lane_count = 1,
> > +		.expected = fp_init(10, 0),
> > +	},
> > +	{
> > +		.link_rate = 540000,
> > +		.lane_count = 2,
> > +		.expected = fp_init(20, 0),
> > +	},
> > +	{
> > +		.link_rate = 540000,
> > +		.lane_count = 4,
> > +		.expected = fp_init(40, 0),
> > +	},
> > +	{
> > +		.link_rate = 810000,
> > +		.lane_count = 1,
> > +		.expected = fp_init(15, 0),
> > +	},
> > +	{
> > +		.link_rate = 810000,
> > +		.lane_count = 2,
> > +		.expected = fp_init(30, 0),
> > +	},
> > +	{
> > +		.link_rate = 810000,
> > +		.lane_count = 4,
> > +		.expected = fp_init(60, 0),
> > +	},
> > +	{
> > +		.link_rate = 1000000,
> > +		.lane_count = 1,
> > +		.expected = fp_init(22, 38657),
> > +	},
> > +	{
> > +		.link_rate = 1000000,
> > +		.lane_count = 2,
> > +		.expected = fp_init(44, 77314),
> > +	},
> > +	{
> > +		.link_rate = 1000000,
> > +		.lane_count = 4,
> > +		.expected = fp_init(89, 54629),
> > +	},
> > +	{
> > +		.link_rate = 1350000,
> > +		.lane_count = 1,
> > +		.expected = fp_init(30, 22187),
> > +	},
> > +	{
> > +		.link_rate = 1350000,
> > +		.lane_count = 2,
> > +		.expected = fp_init(60, 44375),
> > +	},
> > +	{
> > +		.link_rate = 1350000,
> > +		.lane_count = 4,
> > +		.expected = fp_init(120, 88750),
> > +	},
> > +	{
> > +		.link_rate = 2000000,
> > +		.lane_count = 1,
> > +		.expected = fp_init(44, 77314),
> > +	},
> > +	{
> > +		.link_rate = 2000000,
> > +		.lane_count = 2,
> > +		.expected = fp_init(89, 54629),
> > +	},
> > +	{
> > +		.link_rate = 2000000,
> > +		.lane_count = 4,
> > +		.expected = fp_init(179,  9259),  /* 179.09259 */
> > +	},
> > +};
> > +
> > +static void drm_test_dp_mst_calc_pbn_div(struct kunit *test)
> > +{
> > +	const struct drm_dp_mst_calc_pbn_div_test *params = test->param_value;
> > +	/* mgr->dev is only needed by drm_dbg_kms(), but it's not called for the test cases. */
> > +	struct drm_dp_mst_topology_mgr mgr = {};
> > +
> > +	KUNIT_EXPECT_EQ(test, drm_dp_get_vc_payload_bw(&mgr, params->link_rate, params->lane_count).full,
> > +			params->expected.full);
> > +}
> > +
> > +static void dp_mst_calc_pbn_div_desc(const struct drm_dp_mst_calc_pbn_div_test *t, char *desc)
> > +{
> > +	sprintf(desc, "Link rate %d lane count %d", t->link_rate, t->lane_count);
> > +}
> > +
> > +KUNIT_ARRAY_PARAM(drm_dp_mst_calc_pbn_div, drm_dp_mst_calc_pbn_div_dp1_4_cases,
> > +		  dp_mst_calc_pbn_div_desc);
> > +
> >  static u8 data[] = { 0xff, 0x00, 0xdd };
> >  
> >  struct drm_dp_mst_sideband_msg_req_test {
> > @@ -416,6 +560,7 @@ KUNIT_ARRAY_PARAM(drm_dp_mst_sideband_msg_req, drm_dp_mst_sideband_msg_req_cases
> >  
> >  static struct kunit_case drm_dp_mst_helper_tests[] = {
> >  	KUNIT_CASE_PARAM(drm_test_dp_mst_calc_pbn_mode, drm_dp_mst_calc_pbn_mode_gen_params),
> > +	KUNIT_CASE_PARAM(drm_test_dp_mst_calc_pbn_div, drm_dp_mst_calc_pbn_div_gen_params),
> >  	KUNIT_CASE_PARAM(drm_test_dp_mst_sideband_msg_req_decode,
> >  			 drm_dp_mst_sideband_msg_req_gen_params),
> >  	{ }
> > -- 
> > 2.39.2
> 
> -- 
> Ville Syrjälä
> Intel
kernel test robot Nov. 18, 2023, 11:41 p.m. UTC | #3
Hi Imre,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-tip/drm-tip]

url:    https://github.com/intel-lab-lkp/linux/commits/Imre-Deak/drm-dp_mst-Store-the-MST-PBN-divider-value-in-fixed-point-format/20231116-212936
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
patch link:    https://lore.kernel.org/r/20231116131841.1588781-4-imre.deak%40intel.com
patch subject: [Intel-gfx] [PATCH v2 03/11] drm/dp_mst: Add kunit tests for drm_dp_get_vc_payload_bw()
config: hexagon-allyesconfig (https://download.01.org/0day-ci/archive/20231119/202311190743.K2U2VXVT-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231119/202311190743.K2U2VXVT-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311190743.K2U2VXVT-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from drivers/gpu/drm/tests/drm_dp_mst_helper_test.c:10:
   In file included from include/drm/display/drm_dp_mst_helper.h:26:
   In file included from include/drm/display/drm_dp_helper.h:27:
   In file included from include/linux/i2c.h:19:
   In file included from include/linux/regulator/consumer.h:35:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:13:
   In file included from include/linux/cgroup.h:26:
   In file included from include/linux/kernel_stat.h:9:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:337:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     547 |         val = __raw_readb(PCI_IOBASE + addr);
         |                           ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     560 |         val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   In file included from drivers/gpu/drm/tests/drm_dp_mst_helper_test.c:10:
   In file included from include/drm/display/drm_dp_mst_helper.h:26:
   In file included from include/drm/display/drm_dp_helper.h:27:
   In file included from include/linux/i2c.h:19:
   In file included from include/linux/regulator/consumer.h:35:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:13:
   In file included from include/linux/cgroup.h:26:
   In file included from include/linux/kernel_stat.h:9:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:337:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     573 |         val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
      35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
         |                                                   ^
   In file included from drivers/gpu/drm/tests/drm_dp_mst_helper_test.c:10:
   In file included from include/drm/display/drm_dp_mst_helper.h:26:
   In file included from include/drm/display/drm_dp_helper.h:27:
   In file included from include/linux/i2c.h:19:
   In file included from include/linux/regulator/consumer.h:35:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:13:
   In file included from include/linux/cgroup.h:26:
   In file included from include/linux/kernel_stat.h:9:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:337:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     584 |         __raw_writeb(value, PCI_IOBASE + addr);
         |                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     594 |         __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     604 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
>> drivers/gpu/drm/tests/drm_dp_mst_helper_test.c:197:13: warning: stack frame size (1664) exceeds limit (1024) in 'drm_test_dp_mst_calc_pbn_div' [-Wframe-larger-than]
     197 | static void drm_test_dp_mst_calc_pbn_div(struct kunit *test)
         |             ^
   7 warnings generated.


vim +/drm_test_dp_mst_calc_pbn_div +197 drivers/gpu/drm/tests/drm_dp_mst_helper_test.c

   196	
 > 197	static void drm_test_dp_mst_calc_pbn_div(struct kunit *test)
   198	{
   199		const struct drm_dp_mst_calc_pbn_div_test *params = test->param_value;
   200		/* mgr->dev is only needed by drm_dbg_kms(), but it's not called for the test cases. */
   201		struct drm_dp_mst_topology_mgr mgr = {};
   202	
   203		KUNIT_EXPECT_EQ(test, drm_dp_get_vc_payload_bw(&mgr, params->link_rate, params->lane_count).full,
   204				params->expected.full);
   205	}
   206
diff mbox series

Patch

diff --git a/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c b/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c
index e3c818dfc0e6d..cafb463124f71 100644
--- a/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c
@@ -68,6 +68,150 @@  static void dp_mst_calc_pbn_mode_desc(const struct drm_dp_mst_calc_pbn_mode_test
 KUNIT_ARRAY_PARAM(drm_dp_mst_calc_pbn_mode, drm_dp_mst_calc_pbn_mode_cases,
 		  dp_mst_calc_pbn_mode_desc);
 
+struct drm_dp_mst_calc_pbn_div_test {
+	int link_rate;
+	int lane_count;
+	fixed20_12 expected;
+};
+
+#define fp_init(__int, __frac) { \
+	.full = (__int) * (1 << 12) + \
+		(__frac) * (1 << 12) / 100000 \
+}
+
+static const struct drm_dp_mst_calc_pbn_div_test drm_dp_mst_calc_pbn_div_dp1_4_cases[] = {
+	/*
+	 * DP1.4 rates:
+	 * .expected = .link_rate * .lane_count * 0.8000 / 8 / 54 / 100
+	 * UHBR rates:
+	 * .expected = .link_rate * .lane_count * 0.9671 / 8 / 54 / 100
+	 * truncated to 5 decimal places.
+	 */
+	{
+		.link_rate = 162000,
+		.lane_count = 1,
+		.expected = fp_init(3, 0),
+	},
+	{
+		.link_rate = 162000,
+		.lane_count = 2,
+		.expected = fp_init(6, 0),
+	},
+	{
+		.link_rate = 162000,
+		.lane_count = 4,
+		.expected = fp_init(12, 0),
+	},
+	{
+		.link_rate = 270000,
+		.lane_count = 1,
+		.expected = fp_init(5, 0),
+	},
+	{
+		.link_rate = 270000,
+		.lane_count = 2,
+		.expected = fp_init(10, 0),
+	},
+	{
+		.link_rate = 270000,
+		.lane_count = 4,
+		.expected = fp_init(20, 0),
+	},
+	{
+		.link_rate = 540000,
+		.lane_count = 1,
+		.expected = fp_init(10, 0),
+	},
+	{
+		.link_rate = 540000,
+		.lane_count = 2,
+		.expected = fp_init(20, 0),
+	},
+	{
+		.link_rate = 540000,
+		.lane_count = 4,
+		.expected = fp_init(40, 0),
+	},
+	{
+		.link_rate = 810000,
+		.lane_count = 1,
+		.expected = fp_init(15, 0),
+	},
+	{
+		.link_rate = 810000,
+		.lane_count = 2,
+		.expected = fp_init(30, 0),
+	},
+	{
+		.link_rate = 810000,
+		.lane_count = 4,
+		.expected = fp_init(60, 0),
+	},
+	{
+		.link_rate = 1000000,
+		.lane_count = 1,
+		.expected = fp_init(22, 38657),
+	},
+	{
+		.link_rate = 1000000,
+		.lane_count = 2,
+		.expected = fp_init(44, 77314),
+	},
+	{
+		.link_rate = 1000000,
+		.lane_count = 4,
+		.expected = fp_init(89, 54629),
+	},
+	{
+		.link_rate = 1350000,
+		.lane_count = 1,
+		.expected = fp_init(30, 22187),
+	},
+	{
+		.link_rate = 1350000,
+		.lane_count = 2,
+		.expected = fp_init(60, 44375),
+	},
+	{
+		.link_rate = 1350000,
+		.lane_count = 4,
+		.expected = fp_init(120, 88750),
+	},
+	{
+		.link_rate = 2000000,
+		.lane_count = 1,
+		.expected = fp_init(44, 77314),
+	},
+	{
+		.link_rate = 2000000,
+		.lane_count = 2,
+		.expected = fp_init(89, 54629),
+	},
+	{
+		.link_rate = 2000000,
+		.lane_count = 4,
+		.expected = fp_init(179,  9259),  /* 179.09259 */
+	},
+};
+
+static void drm_test_dp_mst_calc_pbn_div(struct kunit *test)
+{
+	const struct drm_dp_mst_calc_pbn_div_test *params = test->param_value;
+	/* mgr->dev is only needed by drm_dbg_kms(), but it's not called for the test cases. */
+	struct drm_dp_mst_topology_mgr mgr = {};
+
+	KUNIT_EXPECT_EQ(test, drm_dp_get_vc_payload_bw(&mgr, params->link_rate, params->lane_count).full,
+			params->expected.full);
+}
+
+static void dp_mst_calc_pbn_div_desc(const struct drm_dp_mst_calc_pbn_div_test *t, char *desc)
+{
+	sprintf(desc, "Link rate %d lane count %d", t->link_rate, t->lane_count);
+}
+
+KUNIT_ARRAY_PARAM(drm_dp_mst_calc_pbn_div, drm_dp_mst_calc_pbn_div_dp1_4_cases,
+		  dp_mst_calc_pbn_div_desc);
+
 static u8 data[] = { 0xff, 0x00, 0xdd };
 
 struct drm_dp_mst_sideband_msg_req_test {
@@ -416,6 +560,7 @@  KUNIT_ARRAY_PARAM(drm_dp_mst_sideband_msg_req, drm_dp_mst_sideband_msg_req_cases
 
 static struct kunit_case drm_dp_mst_helper_tests[] = {
 	KUNIT_CASE_PARAM(drm_test_dp_mst_calc_pbn_mode, drm_dp_mst_calc_pbn_mode_gen_params),
+	KUNIT_CASE_PARAM(drm_test_dp_mst_calc_pbn_div, drm_dp_mst_calc_pbn_div_gen_params),
 	KUNIT_CASE_PARAM(drm_test_dp_mst_sideband_msg_req_decode,
 			 drm_dp_mst_sideband_msg_req_gen_params),
 	{ }