diff options
Diffstat (limited to 'drivers/clocksource/arm_arch_timer.c')
-rw-r--r-- | drivers/clocksource/arm_arch_timer.c | 82 |
1 files changed, 42 insertions, 40 deletions
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 38bddb9a2076..94e355bb0d38 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c | |||
@@ -70,19 +70,19 @@ struct arch_timer { | |||
70 | 70 | ||
71 | static u32 arch_timer_rate; | 71 | static u32 arch_timer_rate; |
72 | 72 | ||
73 | enum ppi_nr { | 73 | enum arch_timer_ppi_nr { |
74 | PHYS_SECURE_PPI, | 74 | ARCH_TIMER_PHYS_SECURE_PPI, |
75 | PHYS_NONSECURE_PPI, | 75 | ARCH_TIMER_PHYS_NONSECURE_PPI, |
76 | VIRT_PPI, | 76 | ARCH_TIMER_VIRT_PPI, |
77 | HYP_PPI, | 77 | ARCH_TIMER_HYP_PPI, |
78 | MAX_TIMER_PPI | 78 | ARCH_TIMER_MAX_TIMER_PPI |
79 | }; | 79 | }; |
80 | 80 | ||
81 | static int arch_timer_ppi[MAX_TIMER_PPI]; | 81 | static int arch_timer_ppi[ARCH_TIMER_MAX_TIMER_PPI]; |
82 | 82 | ||
83 | static struct clock_event_device __percpu *arch_timer_evt; | 83 | static struct clock_event_device __percpu *arch_timer_evt; |
84 | 84 | ||
85 | static enum ppi_nr arch_timer_uses_ppi = VIRT_PPI; | 85 | static enum arch_timer_ppi_nr arch_timer_uses_ppi = ARCH_TIMER_VIRT_PPI; |
86 | static bool arch_timer_c3stop; | 86 | static bool arch_timer_c3stop; |
87 | static bool arch_timer_mem_use_virtual; | 87 | static bool arch_timer_mem_use_virtual; |
88 | static bool arch_counter_suspend_stop; | 88 | static bool arch_counter_suspend_stop; |
@@ -694,14 +694,14 @@ static void __arch_timer_setup(unsigned type, | |||
694 | clk->cpumask = cpumask_of(smp_processor_id()); | 694 | clk->cpumask = cpumask_of(smp_processor_id()); |
695 | clk->irq = arch_timer_ppi[arch_timer_uses_ppi]; | 695 | clk->irq = arch_timer_ppi[arch_timer_uses_ppi]; |
696 | switch (arch_timer_uses_ppi) { | 696 | switch (arch_timer_uses_ppi) { |
697 | case VIRT_PPI: | 697 | case ARCH_TIMER_VIRT_PPI: |
698 | clk->set_state_shutdown = arch_timer_shutdown_virt; | 698 | clk->set_state_shutdown = arch_timer_shutdown_virt; |
699 | clk->set_state_oneshot_stopped = arch_timer_shutdown_virt; | 699 | clk->set_state_oneshot_stopped = arch_timer_shutdown_virt; |
700 | clk->set_next_event = arch_timer_set_next_event_virt; | 700 | clk->set_next_event = arch_timer_set_next_event_virt; |
701 | break; | 701 | break; |
702 | case PHYS_SECURE_PPI: | 702 | case ARCH_TIMER_PHYS_SECURE_PPI: |
703 | case PHYS_NONSECURE_PPI: | 703 | case ARCH_TIMER_PHYS_NONSECURE_PPI: |
704 | case HYP_PPI: | 704 | case ARCH_TIMER_HYP_PPI: |
705 | clk->set_state_shutdown = arch_timer_shutdown_phys; | 705 | clk->set_state_shutdown = arch_timer_shutdown_phys; |
706 | clk->set_state_oneshot_stopped = arch_timer_shutdown_phys; | 706 | clk->set_state_oneshot_stopped = arch_timer_shutdown_phys; |
707 | clk->set_next_event = arch_timer_set_next_event_phys; | 707 | clk->set_next_event = arch_timer_set_next_event_phys; |
@@ -789,8 +789,8 @@ static void arch_counter_set_user_access(void) | |||
789 | 789 | ||
790 | static bool arch_timer_has_nonsecure_ppi(void) | 790 | static bool arch_timer_has_nonsecure_ppi(void) |
791 | { | 791 | { |
792 | return (arch_timer_uses_ppi == PHYS_SECURE_PPI && | 792 | return (arch_timer_uses_ppi == ARCH_TIMER_PHYS_SECURE_PPI && |
793 | arch_timer_ppi[PHYS_NONSECURE_PPI]); | 793 | arch_timer_ppi[ARCH_TIMER_PHYS_NONSECURE_PPI]); |
794 | } | 794 | } |
795 | 795 | ||
796 | static u32 check_ppi_trigger(int irq) | 796 | static u32 check_ppi_trigger(int irq) |
@@ -817,8 +817,9 @@ static int arch_timer_starting_cpu(unsigned int cpu) | |||
817 | enable_percpu_irq(arch_timer_ppi[arch_timer_uses_ppi], flags); | 817 | enable_percpu_irq(arch_timer_ppi[arch_timer_uses_ppi], flags); |
818 | 818 | ||
819 | if (arch_timer_has_nonsecure_ppi()) { | 819 | if (arch_timer_has_nonsecure_ppi()) { |
820 | flags = check_ppi_trigger(arch_timer_ppi[PHYS_NONSECURE_PPI]); | 820 | flags = check_ppi_trigger(arch_timer_ppi[ARCH_TIMER_PHYS_NONSECURE_PPI]); |
821 | enable_percpu_irq(arch_timer_ppi[PHYS_NONSECURE_PPI], flags); | 821 | enable_percpu_irq(arch_timer_ppi[ARCH_TIMER_PHYS_NONSECURE_PPI], |
822 | flags); | ||
822 | } | 823 | } |
823 | 824 | ||
824 | arch_counter_set_user_access(); | 825 | arch_counter_set_user_access(); |
@@ -862,7 +863,7 @@ static void arch_timer_banner(unsigned type) | |||
862 | (unsigned long)arch_timer_rate / 1000000, | 863 | (unsigned long)arch_timer_rate / 1000000, |
863 | (unsigned long)(arch_timer_rate / 10000) % 100, | 864 | (unsigned long)(arch_timer_rate / 10000) % 100, |
864 | type & ARCH_TIMER_TYPE_CP15 ? | 865 | type & ARCH_TIMER_TYPE_CP15 ? |
865 | (arch_timer_uses_ppi == VIRT_PPI) ? "virt" : "phys" : | 866 | (arch_timer_uses_ppi == ARCH_TIMER_VIRT_PPI) ? "virt" : "phys" : |
866 | "", | 867 | "", |
867 | type == (ARCH_TIMER_TYPE_CP15 | ARCH_TIMER_TYPE_MEM) ? "/" : "", | 868 | type == (ARCH_TIMER_TYPE_CP15 | ARCH_TIMER_TYPE_MEM) ? "/" : "", |
868 | type & ARCH_TIMER_TYPE_MEM ? | 869 | type & ARCH_TIMER_TYPE_MEM ? |
@@ -901,7 +902,8 @@ static void __init arch_counter_register(unsigned type) | |||
901 | 902 | ||
902 | /* Register the CP15 based counter if we have one */ | 903 | /* Register the CP15 based counter if we have one */ |
903 | if (type & ARCH_TIMER_TYPE_CP15) { | 904 | if (type & ARCH_TIMER_TYPE_CP15) { |
904 | if (IS_ENABLED(CONFIG_ARM64) || arch_timer_uses_ppi == VIRT_PPI) | 905 | if (IS_ENABLED(CONFIG_ARM64) || |
906 | arch_timer_uses_ppi == ARCH_TIMER_VIRT_PPI) | ||
905 | arch_timer_read_counter = arch_counter_get_cntvct; | 907 | arch_timer_read_counter = arch_counter_get_cntvct; |
906 | else | 908 | else |
907 | arch_timer_read_counter = arch_counter_get_cntpct; | 909 | arch_timer_read_counter = arch_counter_get_cntpct; |
@@ -930,7 +932,7 @@ static void arch_timer_stop(struct clock_event_device *clk) | |||
930 | 932 | ||
931 | disable_percpu_irq(arch_timer_ppi[arch_timer_uses_ppi]); | 933 | disable_percpu_irq(arch_timer_ppi[arch_timer_uses_ppi]); |
932 | if (arch_timer_has_nonsecure_ppi()) | 934 | if (arch_timer_has_nonsecure_ppi()) |
933 | disable_percpu_irq(arch_timer_ppi[PHYS_NONSECURE_PPI]); | 935 | disable_percpu_irq(arch_timer_ppi[ARCH_TIMER_PHYS_NONSECURE_PPI]); |
934 | 936 | ||
935 | clk->set_state_shutdown(clk); | 937 | clk->set_state_shutdown(clk); |
936 | } | 938 | } |
@@ -993,24 +995,24 @@ static int __init arch_timer_register(void) | |||
993 | 995 | ||
994 | ppi = arch_timer_ppi[arch_timer_uses_ppi]; | 996 | ppi = arch_timer_ppi[arch_timer_uses_ppi]; |
995 | switch (arch_timer_uses_ppi) { | 997 | switch (arch_timer_uses_ppi) { |
996 | case VIRT_PPI: | 998 | case ARCH_TIMER_VIRT_PPI: |
997 | err = request_percpu_irq(ppi, arch_timer_handler_virt, | 999 | err = request_percpu_irq(ppi, arch_timer_handler_virt, |
998 | "arch_timer", arch_timer_evt); | 1000 | "arch_timer", arch_timer_evt); |
999 | break; | 1001 | break; |
1000 | case PHYS_SECURE_PPI: | 1002 | case ARCH_TIMER_PHYS_SECURE_PPI: |
1001 | case PHYS_NONSECURE_PPI: | 1003 | case ARCH_TIMER_PHYS_NONSECURE_PPI: |
1002 | err = request_percpu_irq(ppi, arch_timer_handler_phys, | 1004 | err = request_percpu_irq(ppi, arch_timer_handler_phys, |
1003 | "arch_timer", arch_timer_evt); | 1005 | "arch_timer", arch_timer_evt); |
1004 | if (!err && arch_timer_ppi[PHYS_NONSECURE_PPI]) { | 1006 | if (!err && arch_timer_ppi[ARCH_TIMER_PHYS_NONSECURE_PPI]) { |
1005 | ppi = arch_timer_ppi[PHYS_NONSECURE_PPI]; | 1007 | ppi = arch_timer_ppi[ARCH_TIMER_PHYS_NONSECURE_PPI]; |
1006 | err = request_percpu_irq(ppi, arch_timer_handler_phys, | 1008 | err = request_percpu_irq(ppi, arch_timer_handler_phys, |
1007 | "arch_timer", arch_timer_evt); | 1009 | "arch_timer", arch_timer_evt); |
1008 | if (err) | 1010 | if (err) |
1009 | free_percpu_irq(arch_timer_ppi[PHYS_SECURE_PPI], | 1011 | free_percpu_irq(arch_timer_ppi[ARCH_TIMER_PHYS_SECURE_PPI], |
1010 | arch_timer_evt); | 1012 | arch_timer_evt); |
1011 | } | 1013 | } |
1012 | break; | 1014 | break; |
1013 | case HYP_PPI: | 1015 | case ARCH_TIMER_HYP_PPI: |
1014 | err = request_percpu_irq(ppi, arch_timer_handler_phys, | 1016 | err = request_percpu_irq(ppi, arch_timer_handler_phys, |
1015 | "arch_timer", arch_timer_evt); | 1017 | "arch_timer", arch_timer_evt); |
1016 | break; | 1018 | break; |
@@ -1042,7 +1044,7 @@ out_unreg_cpupm: | |||
1042 | out_unreg_notify: | 1044 | out_unreg_notify: |
1043 | free_percpu_irq(arch_timer_ppi[arch_timer_uses_ppi], arch_timer_evt); | 1045 | free_percpu_irq(arch_timer_ppi[arch_timer_uses_ppi], arch_timer_evt); |
1044 | if (arch_timer_has_nonsecure_ppi()) | 1046 | if (arch_timer_has_nonsecure_ppi()) |
1045 | free_percpu_irq(arch_timer_ppi[PHYS_NONSECURE_PPI], | 1047 | free_percpu_irq(arch_timer_ppi[ARCH_TIMER_PHYS_NONSECURE_PPI], |
1046 | arch_timer_evt); | 1048 | arch_timer_evt); |
1047 | 1049 | ||
1048 | out_free: | 1050 | out_free: |
@@ -1139,16 +1141,16 @@ static int __init arch_timer_init(void) | |||
1139 | * their CNTHP_*_EL2 counterparts, and use a different PPI | 1141 | * their CNTHP_*_EL2 counterparts, and use a different PPI |
1140 | * number. | 1142 | * number. |
1141 | */ | 1143 | */ |
1142 | if (is_hyp_mode_available() || !arch_timer_ppi[VIRT_PPI]) { | 1144 | if (is_hyp_mode_available() || !arch_timer_ppi[ARCH_TIMER_VIRT_PPI]) { |
1143 | bool has_ppi; | 1145 | bool has_ppi; |
1144 | 1146 | ||
1145 | if (is_kernel_in_hyp_mode()) { | 1147 | if (is_kernel_in_hyp_mode()) { |
1146 | arch_timer_uses_ppi = HYP_PPI; | 1148 | arch_timer_uses_ppi = ARCH_TIMER_HYP_PPI; |
1147 | has_ppi = !!arch_timer_ppi[HYP_PPI]; | 1149 | has_ppi = !!arch_timer_ppi[ARCH_TIMER_HYP_PPI]; |
1148 | } else { | 1150 | } else { |
1149 | arch_timer_uses_ppi = PHYS_SECURE_PPI; | 1151 | arch_timer_uses_ppi = ARCH_TIMER_PHYS_SECURE_PPI; |
1150 | has_ppi = (!!arch_timer_ppi[PHYS_SECURE_PPI] || | 1152 | has_ppi = (!!arch_timer_ppi[ARCH_TIMER_PHYS_SECURE_PPI] || |
1151 | !!arch_timer_ppi[PHYS_NONSECURE_PPI]); | 1153 | !!arch_timer_ppi[ARCH_TIMER_PHYS_NONSECURE_PPI]); |
1152 | } | 1154 | } |
1153 | 1155 | ||
1154 | if (!has_ppi) { | 1156 | if (!has_ppi) { |
@@ -1165,7 +1167,7 @@ static int __init arch_timer_init(void) | |||
1165 | if (ret) | 1167 | if (ret) |
1166 | return ret; | 1168 | return ret; |
1167 | 1169 | ||
1168 | arch_timer_kvm_info.virtual_irq = arch_timer_ppi[VIRT_PPI]; | 1170 | arch_timer_kvm_info.virtual_irq = arch_timer_ppi[ARCH_TIMER_VIRT_PPI]; |
1169 | 1171 | ||
1170 | return 0; | 1172 | return 0; |
1171 | } | 1173 | } |
@@ -1180,7 +1182,7 @@ static int __init arch_timer_of_init(struct device_node *np) | |||
1180 | } | 1182 | } |
1181 | 1183 | ||
1182 | arch_timers_present |= ARCH_TIMER_TYPE_CP15; | 1184 | arch_timers_present |= ARCH_TIMER_TYPE_CP15; |
1183 | for (i = PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++) | 1185 | for (i = ARCH_TIMER_PHYS_SECURE_PPI; i < ARCH_TIMER_MAX_TIMER_PPI; i++) |
1184 | arch_timer_ppi[i] = irq_of_parse_and_map(np, i); | 1186 | arch_timer_ppi[i] = irq_of_parse_and_map(np, i); |
1185 | 1187 | ||
1186 | arch_timer_detect_rate(NULL, np); | 1188 | arch_timer_detect_rate(NULL, np); |
@@ -1196,7 +1198,7 @@ static int __init arch_timer_of_init(struct device_node *np) | |||
1196 | */ | 1198 | */ |
1197 | if (IS_ENABLED(CONFIG_ARM) && | 1199 | if (IS_ENABLED(CONFIG_ARM) && |
1198 | of_property_read_bool(np, "arm,cpu-registers-not-fw-configured")) | 1200 | of_property_read_bool(np, "arm,cpu-registers-not-fw-configured")) |
1199 | arch_timer_uses_ppi = PHYS_SECURE_PPI; | 1201 | arch_timer_uses_ppi = ARCH_TIMER_PHYS_SECURE_PPI; |
1200 | 1202 | ||
1201 | /* On some systems, the counter stops ticking when in suspend. */ | 1203 | /* On some systems, the counter stops ticking when in suspend. */ |
1202 | arch_counter_suspend_stop = of_property_read_bool(np, | 1204 | arch_counter_suspend_stop = of_property_read_bool(np, |
@@ -1323,19 +1325,19 @@ static int __init arch_timer_acpi_init(struct acpi_table_header *table) | |||
1323 | 1325 | ||
1324 | arch_timers_present |= ARCH_TIMER_TYPE_CP15; | 1326 | arch_timers_present |= ARCH_TIMER_TYPE_CP15; |
1325 | 1327 | ||
1326 | arch_timer_ppi[PHYS_SECURE_PPI] = | 1328 | arch_timer_ppi[ARCH_TIMER_PHYS_SECURE_PPI] = |
1327 | map_generic_timer_interrupt(gtdt->secure_el1_interrupt, | 1329 | map_generic_timer_interrupt(gtdt->secure_el1_interrupt, |
1328 | gtdt->secure_el1_flags); | 1330 | gtdt->secure_el1_flags); |
1329 | 1331 | ||
1330 | arch_timer_ppi[PHYS_NONSECURE_PPI] = | 1332 | arch_timer_ppi[ARCH_TIMER_PHYS_NONSECURE_PPI] = |
1331 | map_generic_timer_interrupt(gtdt->non_secure_el1_interrupt, | 1333 | map_generic_timer_interrupt(gtdt->non_secure_el1_interrupt, |
1332 | gtdt->non_secure_el1_flags); | 1334 | gtdt->non_secure_el1_flags); |
1333 | 1335 | ||
1334 | arch_timer_ppi[VIRT_PPI] = | 1336 | arch_timer_ppi[ARCH_TIMER_VIRT_PPI] = |
1335 | map_generic_timer_interrupt(gtdt->virtual_timer_interrupt, | 1337 | map_generic_timer_interrupt(gtdt->virtual_timer_interrupt, |
1336 | gtdt->virtual_timer_flags); | 1338 | gtdt->virtual_timer_flags); |
1337 | 1339 | ||
1338 | arch_timer_ppi[HYP_PPI] = | 1340 | arch_timer_ppi[ARCH_TIMER_HYP_PPI] = |
1339 | map_generic_timer_interrupt(gtdt->non_secure_el2_interrupt, | 1341 | map_generic_timer_interrupt(gtdt->non_secure_el2_interrupt, |
1340 | gtdt->non_secure_el2_flags); | 1342 | gtdt->non_secure_el2_flags); |
1341 | 1343 | ||