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

Configure Feed

Select the types of activity you want to include in your feed.

thunderbolt: Add test case for 3 DisplayPort tunnels

Intel Barlow Ridge Thunderbolt controller has 3 DP IN adapters. This
allows 3 simultaneus DisplayPort tunnels through either one or two USB4
downstream ports (in any possible configuration). Add test case for
this.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>

+83
+83
drivers/thunderbolt/test.c
··· 170 170 return sw; 171 171 } 172 172 173 + static struct tb_switch *alloc_host_br(struct kunit *test) 174 + { 175 + struct tb_switch *sw; 176 + 177 + sw = alloc_host_usb4(test); 178 + if (!sw) 179 + return NULL; 180 + 181 + sw->ports[10].config.type = TB_TYPE_DP_HDMI_IN; 182 + sw->ports[10].config.max_in_hop_id = 9; 183 + sw->ports[10].config.max_out_hop_id = 9; 184 + sw->ports[10].cap_adap = -1; 185 + sw->ports[10].disabled = false; 186 + 187 + return sw; 188 + } 189 + 173 190 static struct tb_switch *alloc_dev_default(struct kunit *test, 174 191 struct tb_switch *parent, 175 192 u64 route, bool bonded) ··· 1600 1583 tb_tunnel_free(tunnel); 1601 1584 } 1602 1585 1586 + static void tb_test_tunnel_3dp(struct kunit *test) 1587 + { 1588 + struct tb_switch *host, *dev1, *dev2, *dev3, *dev4, *dev5; 1589 + struct tb_port *in1, *in2, *in3, *out1, *out2, *out3; 1590 + struct tb_tunnel *tunnel1, *tunnel2, *tunnel3; 1591 + 1592 + /* 1593 + * Create 3 DP tunnels from Host to Devices #2, #5 and #4. 1594 + * 1595 + * [Host] 1596 + * 3 | 1597 + * 1 | 1598 + * [Device #1] 1599 + * 3 / | 5 \ 7 1600 + * 1 / | \ 1 1601 + * [Device #2] | [Device #4] 1602 + * | 1 1603 + * [Device #3] 1604 + * | 5 1605 + * | 1 1606 + * [Device #5] 1607 + */ 1608 + host = alloc_host_br(test); 1609 + dev1 = alloc_dev_default(test, host, 0x3, true); 1610 + dev2 = alloc_dev_default(test, dev1, 0x303, true); 1611 + dev3 = alloc_dev_default(test, dev1, 0x503, true); 1612 + dev4 = alloc_dev_default(test, dev1, 0x703, true); 1613 + dev5 = alloc_dev_default(test, dev3, 0x50503, true); 1614 + 1615 + in1 = &host->ports[5]; 1616 + in2 = &host->ports[6]; 1617 + in3 = &host->ports[10]; 1618 + 1619 + out1 = &dev2->ports[13]; 1620 + out2 = &dev5->ports[13]; 1621 + out3 = &dev4->ports[14]; 1622 + 1623 + tunnel1 = tb_tunnel_alloc_dp(NULL, in1, out1, 1, 0, 0); 1624 + KUNIT_ASSERT_TRUE(test, tunnel1 != NULL); 1625 + KUNIT_EXPECT_EQ(test, tunnel1->type, TB_TUNNEL_DP); 1626 + KUNIT_EXPECT_PTR_EQ(test, tunnel1->src_port, in1); 1627 + KUNIT_EXPECT_PTR_EQ(test, tunnel1->dst_port, out1); 1628 + KUNIT_ASSERT_EQ(test, tunnel1->npaths, 3); 1629 + KUNIT_ASSERT_EQ(test, tunnel1->paths[0]->path_length, 3); 1630 + 1631 + tunnel2 = tb_tunnel_alloc_dp(NULL, in2, out2, 1, 0, 0); 1632 + KUNIT_ASSERT_TRUE(test, tunnel2 != NULL); 1633 + KUNIT_EXPECT_EQ(test, tunnel2->type, TB_TUNNEL_DP); 1634 + KUNIT_EXPECT_PTR_EQ(test, tunnel2->src_port, in2); 1635 + KUNIT_EXPECT_PTR_EQ(test, tunnel2->dst_port, out2); 1636 + KUNIT_ASSERT_EQ(test, tunnel2->npaths, 3); 1637 + KUNIT_ASSERT_EQ(test, tunnel2->paths[0]->path_length, 4); 1638 + 1639 + tunnel3 = tb_tunnel_alloc_dp(NULL, in3, out3, 1, 0, 0); 1640 + KUNIT_ASSERT_TRUE(test, tunnel3 != NULL); 1641 + KUNIT_EXPECT_EQ(test, tunnel3->type, TB_TUNNEL_DP); 1642 + KUNIT_EXPECT_PTR_EQ(test, tunnel3->src_port, in3); 1643 + KUNIT_EXPECT_PTR_EQ(test, tunnel3->dst_port, out3); 1644 + KUNIT_ASSERT_EQ(test, tunnel3->npaths, 3); 1645 + KUNIT_ASSERT_EQ(test, tunnel3->paths[0]->path_length, 3); 1646 + 1647 + tb_tunnel_free(tunnel2); 1648 + tb_tunnel_free(tunnel1); 1649 + } 1650 + 1603 1651 static void tb_test_tunnel_usb3(struct kunit *test) 1604 1652 { 1605 1653 struct tb_switch *host, *dev1, *dev2; ··· 2872 2790 KUNIT_CASE(tb_test_tunnel_dp_chain), 2873 2791 KUNIT_CASE(tb_test_tunnel_dp_tree), 2874 2792 KUNIT_CASE(tb_test_tunnel_dp_max_length), 2793 + KUNIT_CASE(tb_test_tunnel_3dp), 2875 2794 KUNIT_CASE(tb_test_tunnel_port_on_path), 2876 2795 KUNIT_CASE(tb_test_tunnel_usb3), 2877 2796 KUNIT_CASE(tb_test_tunnel_dma),