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

soc/tegra: cbb: Improve handling for per SoC fabric data

Improve handling for the per SoC fabrics and targets.
The below changes make them more flexible and ready for future SoC's.
- Added SoC prefix to Fabric_ID enums.
- Rename *lookup_target_timeout() to *sw_lookup_target_timeout() to
make it separate from HW based lookup function to be added later.
- Moved target_map within fabric_lookup table to make it easy to
check whether SW vs HW lookup is supported and handle accordingly.
- Slight improvements to some error prints.

Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>

authored by

Sumit Gupta and committed by
Thierry Reding
25de5c8f 2f2c32f9

+132 -109
+132 -109
drivers/soc/tegra/cbb/tegra234-cbb.c
··· 74 74 #define WEN 0x20000 75 75 76 76 enum tegra234_cbb_fabric_ids { 77 - CBB_FAB_ID, 78 - SCE_FAB_ID, 79 - RCE_FAB_ID, 80 - DCE_FAB_ID, 81 - AON_FAB_ID, 82 - PSC_FAB_ID, 83 - BPMP_FAB_ID, 84 - FSI_FAB_ID, 85 - MAX_FAB_ID, 77 + T234_CBB_FABRIC_ID, 78 + T234_SCE_FABRIC_ID, 79 + T234_RCE_FABRIC_ID, 80 + T234_DCE_FABRIC_ID, 81 + T234_AON_FABRIC_ID, 82 + T234_PSC_FABRIC_ID, 83 + T234_BPMP_FABRIC_ID, 84 + T234_FSI_FABRIC_ID, 85 + T234_MAX_FABRIC_ID, 86 86 }; 87 87 88 88 struct tegra234_target_lookup { ··· 90 90 unsigned int offset; 91 91 }; 92 92 93 - struct tegra234_cbb_fabric { 93 + struct tegra234_fabric_lookup { 94 94 const char *name; 95 + bool is_lookup; 96 + const struct tegra234_target_lookup *target_map; 97 + const int max_targets; 98 + }; 99 + 100 + struct tegra234_cbb_fabric { 101 + int fab_id; 95 102 phys_addr_t off_mask_erd; 96 103 phys_addr_t firewall_base; 97 104 unsigned int firewall_ctl; ··· 107 100 unsigned int notifier_offset; 108 101 const struct tegra_cbb_error *errors; 109 102 const int max_errors; 110 - const struct tegra234_target_lookup *target_map; 111 - const int max_targets; 103 + const struct tegra234_fabric_lookup *fab_list; 112 104 const u32 err_intr_enbl; 113 105 const u32 err_status_clr; 114 106 }; ··· 272 266 } 273 267 } 274 268 275 - static void tegra234_lookup_target_timeout(struct seq_file *file, struct tegra234_cbb *cbb, 276 - u8 target_id, u8 fab_id) 269 + static void tegra234_sw_lookup_target_timeout(struct seq_file *file, struct tegra234_cbb *cbb, 270 + u8 target_id, u8 fab_id) 277 271 { 278 - const struct tegra234_target_lookup *map = cbb->fabric->target_map; 272 + const struct tegra234_target_lookup *map = cbb->fabric->fab_list[fab_id].target_map; 279 273 void __iomem *addr; 274 + 275 + if (target_id >= cbb->fabric->fab_list[fab_id].max_targets) { 276 + tegra_cbb_print_err(file, "\t Invalid target_id:%d\n", target_id); 277 + return; 278 + } 280 279 281 280 /* 282 281 * 1) Get target node name and address mapping using target_id. ··· 365 354 { 366 355 u8 cache_type, prot_type, burst_length, mstr_id, grpsec, vqc, falconsec, beat_size; 367 356 u8 access_type, access_id, requester_socket_id, local_socket_id, target_id, fab_id; 368 - char fabric_name[20]; 369 357 bool is_numa = false; 370 358 u8 burst_type; 371 359 ··· 409 399 else 410 400 tegra_cbb_print_err(file, "\t Wrong type index:%u\n", cbb->type); 411 401 412 - tegra_cbb_print_err(file, "\t Initiator_Id\t\t: %s\n", cbb->fabric->initiator_id[mstr_id]); 402 + tegra_cbb_print_err(file, "\t Initiator_Id\t\t: %#x\n", mstr_id); 403 + if (cbb->fabric->initiator_id) 404 + tegra_cbb_print_err(file, "\t Initiator\t\t: %s\n", 405 + cbb->fabric->initiator_id[mstr_id]); 406 + 413 407 tegra_cbb_print_err(file, "\t Address\t\t: %#llx\n", cbb->access); 414 408 415 409 tegra_cbb_print_cache(file, cache_type); 416 410 tegra_cbb_print_prot(file, prot_type); 417 411 418 412 tegra_cbb_print_err(file, "\t Access_Type\t\t: %s", (access_type) ? "Write\n" : "Read\n"); 419 - tegra_cbb_print_err(file, "\t Access_ID\t\t: %#x", access_id); 420 - 421 - if (fab_id == PSC_FAB_ID) 422 - strcpy(fabric_name, "psc-fabric"); 423 - else if (fab_id == FSI_FAB_ID) 424 - strcpy(fabric_name, "fsi-fabric"); 425 - else 426 - strcpy(fabric_name, cbb->fabric->name); 413 + tegra_cbb_print_err(file, "\t Access_ID\t\t: %#x\n", access_id); 427 414 428 415 if (is_numa) { 429 416 tegra_cbb_print_err(file, "\t Requester_Socket_Id\t: %#x\n", ··· 431 424 num_possible_nodes()); 432 425 } 433 426 434 - tegra_cbb_print_err(file, "\t Fabric\t\t: %s\n", fabric_name); 427 + tegra_cbb_print_err(file, "\t Fabric\t\t: %s (id:%#x)\n", 428 + cbb->fabric->fab_list[fab_id].name, fab_id); 429 + 435 430 tegra_cbb_print_err(file, "\t Target_Id\t\t: %#x\n", target_id); 436 431 tegra_cbb_print_err(file, "\t Burst_length\t\t: %#x\n", burst_length); 437 432 tegra_cbb_print_err(file, "\t Burst_type\t\t: %#x\n", burst_type); ··· 442 433 tegra_cbb_print_err(file, "\t GRPSEC\t\t: %#x\n", grpsec); 443 434 tegra_cbb_print_err(file, "\t FALCONSEC\t\t: %#x\n", falconsec); 444 435 445 - if ((fab_id == PSC_FAB_ID) || (fab_id == FSI_FAB_ID)) 436 + if (!cbb->fabric->fab_list[fab_id].is_lookup) 446 437 return; 447 438 448 - if (target_id >= cbb->fabric->max_targets) { 449 - tegra_cbb_print_err(file, "\t Invalid target_id:%d\n", target_id); 450 - return; 451 - } 439 + if (!strcmp(cbb->fabric->errors[cbb->type].code, "TIMEOUT_ERR")) 440 + tegra234_sw_lookup_target_timeout(file, cbb, target_id, fab_id); 452 441 453 - if (!strcmp(cbb->fabric->errors[cbb->type].code, "TIMEOUT_ERR")) { 454 - tegra234_lookup_target_timeout(file, cbb, target_id, fab_id); 455 - return; 456 - } 457 - 458 - tegra_cbb_print_err(file, "\t Target\t\t\t: %s\n", 459 - cbb->fabric->target_map[target_id].name); 442 + return; 460 443 } 461 444 462 445 static int print_errmonX_info(struct seq_file *file, struct tegra234_cbb *cbb) ··· 509 508 510 509 pr_crit("**************************************\n"); 511 510 pr_crit("CPU:%d, Error:%s, Errmon:%d\n", smp_processor_id(), 512 - cbb->fabric->name, status); 511 + cbb->fabric->fab_list[cbb->fabric->fab_id].name, status); 513 512 514 513 while (status) { 515 514 if (status & BIT(0)) { ··· 532 531 tegra234_cbb_error_clear(&cbb->base); 533 532 if (err) 534 533 return err; 534 + tegra_cbb_print_err(file, "\t**************************************\n"); 535 535 } 536 536 537 537 status >>= 1; 538 538 index++; 539 539 } 540 540 541 - tegra_cbb_print_err(file, "\t**************************************\n"); 542 541 return 0; 543 542 } 544 543 ··· 587 586 588 587 if (status && (irq == priv->sec_irq)) { 589 588 tegra_cbb_print_err(NULL, "CPU:%d, Error: %s@0x%llx, irq=%d\n", 590 - smp_processor_id(), priv->fabric->name, 589 + smp_processor_id(), 590 + priv->fabric->fab_list[priv->fabric->fab_id].name, 591 591 priv->res->start, irq); 592 592 593 593 err = print_err_notifier(NULL, priv, status); ··· 706 704 { "CPU", 0x16000 }, 707 705 }; 708 706 709 - static const struct tegra234_cbb_fabric tegra234_aon_fabric = { 710 - .name = "aon-fabric", 711 - .initiator_id = tegra234_initiator_id, 712 - .target_map = tegra234_aon_target_map, 713 - .max_targets = ARRAY_SIZE(tegra234_aon_target_map), 714 - .errors = tegra234_cbb_errors, 715 - .max_errors = ARRAY_SIZE(tegra234_cbb_errors), 716 - .err_intr_enbl = 0x7, 717 - .err_status_clr = 0x3f, 718 - .notifier_offset = 0x17000, 719 - .firewall_base = 0x30000, 720 - .firewall_ctl = 0x8d0, 721 - .firewall_wr_ctl = 0x8c8, 722 - }; 723 - 724 707 static const struct tegra234_target_lookup tegra234_bpmp_target_map[] = { 725 708 { "AXI2APB", 0x00000 }, 726 709 { "AST0", 0x15000 }, ··· 714 727 { "CPU", 0x18000 }, 715 728 }; 716 729 717 - static const struct tegra234_cbb_fabric tegra234_bpmp_fabric = { 718 - .name = "bpmp-fabric", 719 - .initiator_id = tegra234_initiator_id, 720 - .target_map = tegra234_bpmp_target_map, 721 - .max_targets = ARRAY_SIZE(tegra234_bpmp_target_map), 722 - .errors = tegra234_cbb_errors, 723 - .max_errors = ARRAY_SIZE(tegra234_cbb_errors), 724 - .err_intr_enbl = 0xf, 725 - .err_status_clr = 0x3f, 726 - .notifier_offset = 0x19000, 727 - .firewall_base = 0x30000, 728 - .firewall_ctl = 0x8f0, 729 - .firewall_wr_ctl = 0x8e8, 730 + static const struct tegra234_target_lookup tegra234_common_target_map[] = { 731 + { "AXI2APB", 0x00000 }, 732 + { "AST0", 0x15000 }, 733 + { "AST1", 0x16000 }, 734 + { "CBB", 0x17000 }, 735 + { "RSVD", 0x00000 }, 736 + { "CPU", 0x18000 }, 730 737 }; 731 738 732 739 static const struct tegra234_target_lookup tegra234_cbb_target_map[] = { ··· 787 806 { "AXI2APB_3", 0x91000 }, 788 807 }; 789 808 790 - static const struct tegra234_cbb_fabric tegra234_cbb_fabric = { 791 - .name = "cbb-fabric", 809 + static const struct tegra234_fabric_lookup tegra234_cbb_fab_list[] = { 810 + [T234_CBB_FABRIC_ID] = { "cbb-fabric", true, 811 + tegra234_cbb_target_map, 812 + ARRAY_SIZE(tegra234_cbb_target_map) }, 813 + [T234_SCE_FABRIC_ID] = { "sce-fabric", true, 814 + tegra234_common_target_map, 815 + ARRAY_SIZE(tegra234_common_target_map) }, 816 + [T234_RCE_FABRIC_ID] = { "rce-fabric", true, 817 + tegra234_common_target_map, 818 + ARRAY_SIZE(tegra234_common_target_map) }, 819 + [T234_DCE_FABRIC_ID] = { "dce-fabric", true, 820 + tegra234_common_target_map, 821 + ARRAY_SIZE(tegra234_common_target_map) }, 822 + [T234_AON_FABRIC_ID] = { "aon-fabric", true, 823 + tegra234_aon_target_map, 824 + ARRAY_SIZE(tegra234_bpmp_target_map) }, 825 + [T234_PSC_FABRIC_ID] = { "psc-fabric" }, 826 + [T234_BPMP_FABRIC_ID] = { "bpmp-fabric", true, 827 + tegra234_bpmp_target_map, 828 + ARRAY_SIZE(tegra234_bpmp_target_map) }, 829 + [T234_FSI_FABRIC_ID] = { "fsi-fabric" }, 830 + }; 831 + 832 + static const struct tegra234_cbb_fabric tegra234_aon_fabric = { 833 + .fab_id = T234_AON_FABRIC_ID, 834 + .fab_list = tegra234_cbb_fab_list, 792 835 .initiator_id = tegra234_initiator_id, 793 - .target_map = tegra234_cbb_target_map, 794 - .max_targets = ARRAY_SIZE(tegra234_cbb_target_map), 836 + .errors = tegra234_cbb_errors, 837 + .max_errors = ARRAY_SIZE(tegra234_cbb_errors), 838 + .err_intr_enbl = 0x7, 839 + .err_status_clr = 0x3f, 840 + .notifier_offset = 0x17000, 841 + .firewall_base = 0x30000, 842 + .firewall_ctl = 0x8d0, 843 + .firewall_wr_ctl = 0x8c8, 844 + }; 845 + 846 + static const struct tegra234_cbb_fabric tegra234_bpmp_fabric = { 847 + .fab_id = T234_BPMP_FABRIC_ID, 848 + .fab_list = tegra234_cbb_fab_list, 849 + .initiator_id = tegra234_initiator_id, 850 + .errors = tegra234_cbb_errors, 851 + .max_errors = ARRAY_SIZE(tegra234_cbb_errors), 852 + .err_intr_enbl = 0xf, 853 + .err_status_clr = 0x3f, 854 + .notifier_offset = 0x19000, 855 + .firewall_base = 0x30000, 856 + .firewall_ctl = 0x8f0, 857 + .firewall_wr_ctl = 0x8e8, 858 + }; 859 + 860 + static const struct tegra234_cbb_fabric tegra234_cbb_fabric = { 861 + .fab_id = T234_CBB_FABRIC_ID, 862 + .fab_list = tegra234_cbb_fab_list, 863 + .initiator_id = tegra234_initiator_id, 795 864 .errors = tegra234_cbb_errors, 796 865 .max_errors = ARRAY_SIZE(tegra234_cbb_errors), 797 866 .err_intr_enbl = 0x7f, ··· 853 822 .firewall_wr_ctl = 0x23e8, 854 823 }; 855 824 856 - static const struct tegra234_target_lookup tegra234_common_target_map[] = { 857 - { "AXI2APB", 0x00000 }, 858 - { "AST0", 0x15000 }, 859 - { "AST1", 0x16000 }, 860 - { "CBB", 0x17000 }, 861 - { "RSVD", 0x00000 }, 862 - { "CPU", 0x18000 }, 863 - }; 864 - 865 825 static const struct tegra234_cbb_fabric tegra234_dce_fabric = { 866 - .name = "dce-fabric", 826 + .fab_id = T234_DCE_FABRIC_ID, 827 + .fab_list = tegra234_cbb_fab_list, 867 828 .initiator_id = tegra234_initiator_id, 868 - .target_map = tegra234_common_target_map, 869 - .max_targets = ARRAY_SIZE(tegra234_common_target_map), 870 829 .errors = tegra234_cbb_errors, 871 830 .max_errors = ARRAY_SIZE(tegra234_cbb_errors), 872 831 .err_intr_enbl = 0xf, ··· 868 847 }; 869 848 870 849 static const struct tegra234_cbb_fabric tegra234_rce_fabric = { 871 - .name = "rce-fabric", 850 + .fab_id = T234_RCE_FABRIC_ID, 851 + .fab_list = tegra234_cbb_fab_list, 872 852 .initiator_id = tegra234_initiator_id, 873 - .target_map = tegra234_common_target_map, 874 - .max_targets = ARRAY_SIZE(tegra234_common_target_map), 875 853 .errors = tegra234_cbb_errors, 876 854 .max_errors = ARRAY_SIZE(tegra234_cbb_errors), 877 855 .err_intr_enbl = 0xf, ··· 882 862 }; 883 863 884 864 static const struct tegra234_cbb_fabric tegra234_sce_fabric = { 885 - .name = "sce-fabric", 865 + .fab_id = T234_SCE_FABRIC_ID, 866 + .fab_list = tegra234_cbb_fab_list, 886 867 .initiator_id = tegra234_initiator_id, 887 - .target_map = tegra234_common_target_map, 888 - .max_targets = ARRAY_SIZE(tegra234_common_target_map), 889 868 .errors = tegra234_cbb_errors, 890 869 .max_errors = ARRAY_SIZE(tegra234_cbb_errors), 891 870 .err_intr_enbl = 0xf, ··· 1004 985 }, 1005 986 }; 1006 987 988 + static const struct tegra234_target_lookup tegra241_bpmp_target_map[] = { 989 + { "RSVD", 0x00000 }, 990 + { "RSVD", 0x00000 }, 991 + { "RSVD", 0x00000 }, 992 + { "CBB", 0x15000 }, 993 + { "CPU", 0x16000 }, 994 + { "AXI2APB", 0x00000 }, 995 + { "DBB0", 0x17000 }, 996 + { "DBB1", 0x18000 }, 997 + }; 998 + 1007 999 static const struct tegra234_target_lookup tegra241_cbb_target_map[] = { 1008 1000 { "RSVD", 0x00000 }, 1009 1001 { "PCIE_C8", 0x51000 }, ··· 1077 1047 { "AXI2APB_32", 0x8F000 }, 1078 1048 }; 1079 1049 1050 + static const struct tegra234_fabric_lookup tegra241_cbb_fab_list[] = { 1051 + [T234_CBB_FABRIC_ID] = { "cbb-fabric", true, 1052 + tegra241_cbb_target_map, ARRAY_SIZE(tegra241_cbb_target_map) }, 1053 + [T234_BPMP_FABRIC_ID] = { "bpmp-fabric", true, 1054 + tegra241_bpmp_target_map, ARRAY_SIZE(tegra241_cbb_target_map) }, 1055 + }; 1080 1056 static const struct tegra234_cbb_fabric tegra241_cbb_fabric = { 1081 - .name = "cbb-fabric", 1057 + .fab_id = T234_CBB_FABRIC_ID, 1058 + .fab_list = tegra241_cbb_fab_list, 1082 1059 .initiator_id = tegra241_initiator_id, 1083 - .target_map = tegra241_cbb_target_map, 1084 - .max_targets = ARRAY_SIZE(tegra241_cbb_target_map), 1085 1060 .errors = tegra241_cbb_errors, 1086 1061 .max_errors = ARRAY_SIZE(tegra241_cbb_errors), 1087 1062 .err_intr_enbl = 0x7, ··· 1098 1063 .firewall_wr_ctl = 0x2368, 1099 1064 }; 1100 1065 1101 - static const struct tegra234_target_lookup tegra241_bpmp_target_map[] = { 1102 - { "RSVD", 0x00000 }, 1103 - { "RSVD", 0x00000 }, 1104 - { "RSVD", 0x00000 }, 1105 - { "CBB", 0x15000 }, 1106 - { "CPU", 0x16000 }, 1107 - { "AXI2APB", 0x00000 }, 1108 - { "DBB0", 0x17000 }, 1109 - { "DBB1", 0x18000 }, 1110 - }; 1111 - 1112 1066 static const struct tegra234_cbb_fabric tegra241_bpmp_fabric = { 1113 - .name = "bpmp-fabric", 1067 + .fab_id = T234_BPMP_FABRIC_ID, 1068 + .fab_list = tegra241_cbb_fab_list, 1114 1069 .initiator_id = tegra241_initiator_id, 1115 - .target_map = tegra241_bpmp_target_map, 1116 - .max_targets = ARRAY_SIZE(tegra241_bpmp_target_map), 1117 1070 .errors = tegra241_cbb_errors, 1118 1071 .max_errors = ARRAY_SIZE(tegra241_cbb_errors), 1119 1072 .err_intr_enbl = 0xf, ··· 1220 1197 1221 1198 tegra234_cbb_error_enable(&cbb->base); 1222 1199 1223 - dev_dbg(dev, "%s resumed\n", cbb->fabric->name); 1200 + dev_dbg(dev, "%s resumed\n", cbb->fabric->fab_list[cbb->fabric->fab_id].name); 1224 1201 1225 1202 return 0; 1226 1203 }