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

thunderbolt: Move nfc_credits field to struct tb_path_hop

With the USB4 buffer allocation the number of credits (and non-flow
credits) may be different depending on the router buffer allocation
preferences. To allow this move the nfc_credits field to struct
tb_path_hop.

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

+19 -15
+2 -2
drivers/thunderbolt/path.c
··· 367 367 int i, res; 368 368 for (i = first_hop; i < path->path_length; i++) { 369 369 res = tb_port_add_nfc_credits(path->hops[i].in_port, 370 - -path->nfc_credits); 370 + -path->hops[i].nfc_credits); 371 371 if (res) 372 372 tb_port_warn(path->hops[i].in_port, 373 373 "nfc credits deallocation failed for hop %d\n", ··· 502 502 /* Add non flow controlled credits. */ 503 503 for (i = path->path_length - 1; i >= 0; i--) { 504 504 res = tb_port_add_nfc_credits(path->hops[i].in_port, 505 - path->nfc_credits); 505 + path->hops[i].nfc_credits); 506 506 if (res) { 507 507 __tb_path_deallocate_nfc(path, i); 508 508 goto err;
+3 -2
drivers/thunderbolt/tb.h
··· 256 256 * @next_hop_index: HopID of the packet when it is routed out from @out_port 257 257 * @initial_credits: Number of initial flow control credits allocated for 258 258 * the path 259 + * @nfc_credits: Number of non-flow controlled buffers allocated for the 260 + * @in_port. 259 261 * 260 262 * Hop configuration is always done on the IN port of a switch. 261 263 * in_port and out_port have to be on the same switch. Packets arriving on ··· 277 275 int in_counter_index; 278 276 int next_hop_index; 279 277 unsigned int initial_credits; 278 + unsigned int nfc_credits; 280 279 }; 281 280 282 281 /** ··· 300 297 * struct tb_path - a unidirectional path between two ports 301 298 * @tb: Pointer to the domain structure 302 299 * @name: Name of the path (used for debugging) 303 - * @nfc_credits: Number of non flow controlled credits allocated for the path 304 300 * @ingress_shared_buffer: Shared buffering used for ingress ports on the path 305 301 * @egress_shared_buffer: Shared buffering used for egress ports on the path 306 302 * @ingress_fc_enable: Flow control for ingress ports on the path ··· 320 318 struct tb_path { 321 319 struct tb *tb; 322 320 const char *name; 323 - int nfc_credits; 324 321 enum tb_path_port ingress_shared_buffer; 325 322 enum tb_path_port egress_shared_buffer; 326 323 enum tb_path_port ingress_fc_enable;
+14 -11
drivers/thunderbolt/tunnel.c
··· 119 119 path->priority = 3; 120 120 path->weight = 1; 121 121 path->drop_packages = 0; 122 - path->nfc_credits = 0; 123 122 path->hops[0].initial_credits = 7; 124 123 if (path->path_length > 1) 125 124 path->hops[1].initial_credits = ··· 615 616 616 617 static void tb_dp_init_video_path(struct tb_path *path, bool discover) 617 618 { 618 - u32 nfc_credits = path->hops[0].in_port->config.nfc_credits; 619 + int i; 619 620 620 621 path->egress_fc_enable = TB_PATH_NONE; 621 622 path->egress_shared_buffer = TB_PATH_NONE; ··· 624 625 path->priority = 1; 625 626 path->weight = 1; 626 627 627 - if (discover) { 628 - path->nfc_credits = nfc_credits & ADP_CS_4_NFC_BUFFERS_MASK; 629 - } else { 630 - u32 max_credits; 628 + for (i = 0; i < path->path_length; i++) { 629 + u32 nfc_credits = path->hops[i].in_port->config.nfc_credits; 631 630 632 - max_credits = (nfc_credits & ADP_CS_4_TOTAL_BUFFERS_MASK) >> 633 - ADP_CS_4_TOTAL_BUFFERS_SHIFT; 634 - /* Leave some credits for AUX path */ 635 - path->nfc_credits = min(max_credits - 2, 12U); 631 + if (discover) { 632 + path->hops[i].nfc_credits = 633 + nfc_credits & ADP_CS_4_NFC_BUFFERS_MASK; 634 + } else { 635 + u32 max_credits; 636 + 637 + max_credits = (nfc_credits & ADP_CS_4_TOTAL_BUFFERS_MASK) >> 638 + ADP_CS_4_TOTAL_BUFFERS_SHIFT; 639 + /* Leave some credits for AUX path */ 640 + path->hops[i].nfc_credits = min(max_credits - 2, 12U); 641 + } 636 642 } 637 643 } 638 644 ··· 1080 1076 path->priority = 3; 1081 1077 path->weight = 3; 1082 1078 path->drop_packages = 0; 1083 - path->nfc_credits = 0; 1084 1079 path->hops[0].initial_credits = 7; 1085 1080 if (path->path_length > 1) 1086 1081 path->hops[1].initial_credits =