|
8 | 8 | #define __MIPS_ASM_MIPS_CPS_H__
|
9 | 9 |
|
10 | 10 | #include <linux/bitfield.h>
|
| 11 | +#include <linux/cpumask.h> |
11 | 12 | #include <linux/io.h>
|
12 | 13 | #include <linux/types.h>
|
13 | 14 |
|
@@ -228,4 +229,42 @@ static inline unsigned int mips_cps_numvps(unsigned int cluster, unsigned int co
|
228 | 229 | return FIELD_GET(CM_GCR_Cx_CONFIG_PVPE, cfg + 1);
|
229 | 230 | }
|
230 | 231 |
|
| 232 | +/** |
| 233 | + * mips_cps_multicluster_cpus() - Detect whether CPUs are in multiple clusters |
| 234 | + * |
| 235 | + * Determine whether the system includes CPUs in multiple clusters - ie. |
| 236 | + * whether we can treat the system as single or multi-cluster as far as CPUs |
| 237 | + * are concerned. Note that this is slightly different to simply checking |
| 238 | + * whether multiple clusters are present - it is possible for there to be |
| 239 | + * clusters which contain no CPUs, which this function will effectively ignore. |
| 240 | + * |
| 241 | + * Returns true if CPUs are spread across multiple clusters, else false. |
| 242 | + */ |
| 243 | +static inline bool mips_cps_multicluster_cpus(void) |
| 244 | +{ |
| 245 | + unsigned int first_cl, last_cl; |
| 246 | + |
| 247 | + /* |
| 248 | + * CPUs are numbered sequentially by cluster - ie. CPUs 0..X will be in |
| 249 | + * cluster 0, CPUs X+1..Y in cluster 1, CPUs Y+1..Z in cluster 2 etc. |
| 250 | + * |
| 251 | + * Thus we can detect multiple clusters trivially by checking whether |
| 252 | + * the first & last CPUs belong to the same cluster. |
| 253 | + */ |
| 254 | + first_cl = cpu_cluster(&boot_cpu_data); |
| 255 | + last_cl = cpu_cluster(&cpu_data[nr_cpu_ids - 1]); |
| 256 | + return first_cl != last_cl; |
| 257 | +} |
| 258 | + |
| 259 | +/** |
| 260 | + * mips_cps_first_online_in_cluster() - Detect if CPU is first online in cluster |
| 261 | + * |
| 262 | + * Determine whether the local CPU is the first to be brought online in its |
| 263 | + * cluster - that is, whether there are any other online CPUs in the local |
| 264 | + * cluster. |
| 265 | + * |
| 266 | + * Returns true if this CPU is first online, else false. |
| 267 | + */ |
| 268 | +extern unsigned int mips_cps_first_online_in_cluster(void); |
| 269 | + |
231 | 270 | #endif /* __MIPS_ASM_MIPS_CPS_H__ */
|
0 commit comments