]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blobdiff - arch/mips/include/asm/cpu-info.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[mirror_ubuntu-focal-kernel.git] / arch / mips / include / asm / cpu-info.h
index cd6efb07c9808594c143d16fcc005c2ce9afb0ea..a41059d47d31c52d377aa39694a0da3ba3e07af5 100644 (file)
@@ -15,6 +15,8 @@
 #include <linux/cache.h>
 #include <linux/types.h>
 
+#include <asm/mipsregs.h>
+
 /*
  * Descriptor for a cache
  */
@@ -77,16 +79,9 @@ struct cpuinfo_mips {
        struct cache_desc       tcache; /* Tertiary/split secondary cache */
        int                     srsets; /* Shadow register sets */
        int                     package;/* physical package number */
-       int                     core;   /* physical core number */
+       unsigned int            globalnumber;
 #ifdef CONFIG_64BIT
        int                     vmbits; /* Virtual memory size in bits */
-#endif
-#if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_CPU_MIPSR6)
-       /*
-        * There is not necessarily a 1:1 mapping of VPE num to CPU number
-        * in particular on multi-core systems.
-        */
-       int                     vpe_id;  /* Virtual Processor number */
 #endif
        void                    *data;  /* Additional data */
        unsigned int            watch_reg_count;   /* Number that exist */
@@ -144,11 +139,52 @@ struct proc_cpuinfo_notifier_args {
        unsigned long n;
 };
 
-#if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_CPU_MIPSR6)
-# define cpu_vpe_id(cpuinfo)   ((cpuinfo)->vpe_id)
-#else
-# define cpu_vpe_id(cpuinfo)   ({ (void)cpuinfo; 0; })
-#endif
+static inline unsigned int cpu_cluster(struct cpuinfo_mips *cpuinfo)
+{
+       /* Optimisation for systems where multiple clusters aren't used */
+       if (!IS_ENABLED(CONFIG_CPU_MIPSR6))
+               return 0;
+
+       return (cpuinfo->globalnumber & MIPS_GLOBALNUMBER_CLUSTER) >>
+               MIPS_GLOBALNUMBER_CLUSTER_SHF;
+}
+
+static inline unsigned int cpu_core(struct cpuinfo_mips *cpuinfo)
+{
+       return (cpuinfo->globalnumber & MIPS_GLOBALNUMBER_CORE) >>
+               MIPS_GLOBALNUMBER_CORE_SHF;
+}
+
+static inline unsigned int cpu_vpe_id(struct cpuinfo_mips *cpuinfo)
+{
+       /* Optimisation for systems where VP(E)s aren't used */
+       if (!IS_ENABLED(CONFIG_MIPS_MT_SMP) && !IS_ENABLED(CONFIG_CPU_MIPSR6))
+               return 0;
+
+       return (cpuinfo->globalnumber & MIPS_GLOBALNUMBER_VP) >>
+               MIPS_GLOBALNUMBER_VP_SHF;
+}
+
+extern void cpu_set_cluster(struct cpuinfo_mips *cpuinfo, unsigned int cluster);
+extern void cpu_set_core(struct cpuinfo_mips *cpuinfo, unsigned int core);
+extern void cpu_set_vpe_id(struct cpuinfo_mips *cpuinfo, unsigned int vpe);
+
+static inline bool cpus_are_siblings(int cpua, int cpub)
+{
+       struct cpuinfo_mips *infoa = &cpu_data[cpua];
+       struct cpuinfo_mips *infob = &cpu_data[cpub];
+       unsigned int gnuma, gnumb;
+
+       if (infoa->package != infob->package)
+               return false;
+
+       gnuma = infoa->globalnumber & ~MIPS_GLOBALNUMBER_VP;
+       gnumb = infob->globalnumber & ~MIPS_GLOBALNUMBER_VP;
+       if (gnuma != gnumb)
+               return false;
+
+       return true;
+}
 
 static inline unsigned long cpu_asid_inc(void)
 {