Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5616897e authored by Paul Burton's avatar Paul Burton Committed by Ralf Baechle
Browse files

MIPS: Add CPU cluster number accessors



Introduce cpu_cluster() & cpu_set_cluster() accessor functions in the
same vein as cpu_core(), cpu_vpe_id() & their set variants. These will
be used in further patches to allow users to get or set a CPUs cluster
number.

Signed-off-by: default avatarPaul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/17012/


Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent fe7a38c6
Loading
Loading
Loading
Loading
+11 −0
Original line number Original line Diff line number Diff line
@@ -139,6 +139,16 @@ struct proc_cpuinfo_notifier_args {
	unsigned long n;
	unsigned long n;
};
};


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)
static inline unsigned int cpu_core(struct cpuinfo_mips *cpuinfo)
{
{
	return (cpuinfo->globalnumber & MIPS_GLOBALNUMBER_CORE) >>
	return (cpuinfo->globalnumber & MIPS_GLOBALNUMBER_CORE) >>
@@ -155,6 +165,7 @@ static inline unsigned int cpu_vpe_id(struct cpuinfo_mips *cpuinfo)
		MIPS_GLOBALNUMBER_VP_SHF;
		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_core(struct cpuinfo_mips *cpuinfo, unsigned int core);
extern void cpu_set_vpe_id(struct cpuinfo_mips *cpuinfo, unsigned int vpe);
extern void cpu_set_vpe_id(struct cpuinfo_mips *cpuinfo, unsigned int vpe);


+10 −0
Original line number Original line Diff line number Diff line
@@ -2099,6 +2099,16 @@ void cpu_report(void)
		pr_info("MSA revision is: %08x\n", c->msa_id);
		pr_info("MSA revision is: %08x\n", c->msa_id);
}
}


void cpu_set_cluster(struct cpuinfo_mips *cpuinfo, unsigned int cluster)
{
	/* Ensure the core number fits in the field */
	WARN_ON(cluster > (MIPS_GLOBALNUMBER_CLUSTER >>
			   MIPS_GLOBALNUMBER_CLUSTER_SHF));

	cpuinfo->globalnumber &= ~MIPS_GLOBALNUMBER_CLUSTER;
	cpuinfo->globalnumber |= cluster << MIPS_GLOBALNUMBER_CLUSTER_SHF;
}

void cpu_set_core(struct cpuinfo_mips *cpuinfo, unsigned int core)
void cpu_set_core(struct cpuinfo_mips *cpuinfo, unsigned int core)
{
{
	/* Ensure the core number fits in the field */
	/* Ensure the core number fits in the field */