Commit | Line | Data |
---|---|---|
867e359b CM |
1 | /* |
2 | * Copyright 2010 Tilera Corporation. All Rights Reserved. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU General Public License | |
6 | * as published by the Free Software Foundation, version 2. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, but | |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | |
11 | * NON INFRINGEMENT. See the GNU General Public License for | |
12 | * more details. | |
13 | */ | |
14 | ||
15 | #ifndef _ASM_TILE_SMP_H | |
16 | #define _ASM_TILE_SMP_H | |
17 | ||
18 | #ifdef CONFIG_SMP | |
19 | ||
20 | #include <asm/processor.h> | |
21 | #include <linux/cpumask.h> | |
22 | #include <linux/irqreturn.h> | |
fb702b94 | 23 | #include <hv/hypervisor.h> |
867e359b CM |
24 | |
25 | /* Set up this tile to support receiving hypervisor messages */ | |
26 | void init_messaging(void); | |
27 | ||
28 | /* Set up this tile to support receiving device interrupts and IPIs. */ | |
29 | void init_per_tile_IRQs(void); | |
30 | ||
31 | /* Send a message to processors specified in mask */ | |
32 | void send_IPI_many(const struct cpumask *mask, int tag); | |
33 | ||
34 | /* Send a message to all but the sending processor */ | |
35 | void send_IPI_allbutself(int tag); | |
36 | ||
37 | /* Send a message to a specific processor */ | |
38 | void send_IPI_single(int dest, int tag); | |
39 | ||
40 | /* Process an IPI message */ | |
41 | void evaluate_message(int tag); | |
42 | ||
867e359b CM |
43 | /* Boot a secondary cpu */ |
44 | void online_secondary(void); | |
45 | ||
867e359b CM |
46 | /* Topology of the supervisor tile grid, and coordinates of boot processor */ |
47 | extern HV_Topology smp_topology; | |
48 | ||
49 | /* Accessors for grid size */ | |
50 | #define smp_height (smp_topology.height) | |
51 | #define smp_width (smp_topology.width) | |
52 | ||
fb702b94 CM |
53 | /* Convenience functions for converting cpu <-> coords. */ |
54 | static inline int cpu_x(int cpu) | |
55 | { | |
56 | return cpu % smp_width; | |
57 | } | |
58 | static inline int cpu_y(int cpu) | |
59 | { | |
60 | return cpu / smp_width; | |
61 | } | |
62 | static inline int xy_to_cpu(int x, int y) | |
63 | { | |
64 | return y * smp_width + x; | |
65 | } | |
66 | ||
867e359b CM |
67 | /* Hypervisor message tags sent via the tile send_IPI*() routines. */ |
68 | #define MSG_TAG_START_CPU 1 | |
69 | #define MSG_TAG_STOP_CPU 2 | |
70 | #define MSG_TAG_CALL_FUNCTION_MANY 3 | |
71 | #define MSG_TAG_CALL_FUNCTION_SINGLE 4 | |
72 | ||
73 | /* Hook for the generic smp_call_function_many() routine. */ | |
74 | static inline void arch_send_call_function_ipi_mask(struct cpumask *mask) | |
75 | { | |
76 | send_IPI_many(mask, MSG_TAG_CALL_FUNCTION_MANY); | |
77 | } | |
78 | ||
79 | /* Hook for the generic smp_call_function_single() routine. */ | |
80 | static inline void arch_send_call_function_single_ipi(int cpu) | |
81 | { | |
82 | send_IPI_single(cpu, MSG_TAG_CALL_FUNCTION_SINGLE); | |
83 | } | |
84 | ||
85 | /* Print out the boot string describing which cpus were disabled. */ | |
86 | void print_disabled_cpus(void); | |
87 | ||
88 | #else /* !CONFIG_SMP */ | |
89 | ||
867e359b CM |
90 | #define smp_master_cpu 0 |
91 | #define smp_height 1 | |
92 | #define smp_width 1 | |
fb702b94 CM |
93 | #define cpu_x(cpu) 0 |
94 | #define cpu_y(cpu) 0 | |
95 | #define xy_to_cpu(x, y) 0 | |
867e359b CM |
96 | |
97 | #endif /* !CONFIG_SMP */ | |
98 | ||
99 | ||
100 | /* Which cpus may be used as the lotar in a page table entry. */ | |
101 | extern struct cpumask cpu_lotar_map; | |
102 | #define cpu_is_valid_lotar(cpu) cpumask_test_cpu((cpu), &cpu_lotar_map) | |
103 | ||
867e359b CM |
104 | /* Which processors are used for hash-for-home mapping */ |
105 | extern struct cpumask hash_for_home_map; | |
867e359b CM |
106 | |
107 | /* Which cpus can have their cache flushed by hv_flush_remote(). */ | |
108 | extern struct cpumask cpu_cacheable_map; | |
109 | #define cpu_cacheable(cpu) cpumask_test_cpu((cpu), &cpu_cacheable_map) | |
110 | ||
111 | /* Convert an HV_LOTAR value into a cpu. */ | |
112 | static inline int hv_lotar_to_cpu(HV_LOTAR lotar) | |
113 | { | |
114 | return HV_LOTAR_X(lotar) + (HV_LOTAR_Y(lotar) * smp_width); | |
115 | } | |
116 | ||
117 | /* | |
118 | * Extension of <linux/cpumask.h> functionality when you just want | |
119 | * to express a mask or suppression or inclusion region without | |
120 | * being too concerned about exactly which cpus are valid in that region. | |
121 | */ | |
122 | int bitmap_parselist_crop(const char *bp, unsigned long *maskp, int nmaskbits); | |
123 | ||
124 | #define cpulist_parse_crop(buf, dst) \ | |
125 | __cpulist_parse_crop((buf), (dst), NR_CPUS) | |
126 | static inline int __cpulist_parse_crop(const char *buf, struct cpumask *dstp, | |
127 | int nbits) | |
128 | { | |
129 | return bitmap_parselist_crop(buf, cpumask_bits(dstp), nbits); | |
130 | } | |
131 | ||
fb702b94 CM |
132 | /* Initialize the IPI subsystem. */ |
133 | void ipi_init(void); | |
134 | ||
135 | /* Function for start-cpu message to cause us to jump to. */ | |
136 | extern unsigned long start_cpu_function_addr; | |
137 | ||
867e359b | 138 | #endif /* _ASM_TILE_SMP_H */ |