[PATCH 2/5] MIPS: CM: export the symbols needed to access the GCRs from a module

From: Vladimir Kondratiev

Date: Sun Nov 08 2026 - 08:21:48 EST


Allow modules to use the GCR and CPC accessors from asm/mips-cm.h and
asm/mips-cpc.h:

- mips_gcr_base and mips_cpc_base are the mapped register blocks;
- the CPS_ACCESSOR macros consult mips_cm_is64 on every 64-bit register
access;
- mips_cm_lock_other() / mips_cm_unlock_other() are the only way to
reach the registers of another cluster through the redirect block.

This is a prerequisite for building the CM3 PMU driver as a module.

Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@xxxxxxxxxxxx>
---
arch/mips/kernel/mips-cm.c | 5 +++++
arch/mips/kernel/mips-cpc.c | 2 ++
2 files changed, 7 insertions(+)

diff --git a/arch/mips/kernel/mips-cm.c b/arch/mips/kernel/mips-cm.c
index 7c9c5dc38823..afe0664e4dcf 100644
--- a/arch/mips/kernel/mips-cm.c
+++ b/arch/mips/kernel/mips-cm.c
@@ -5,6 +5,7 @@
*/

#include <linux/errno.h>
+#include <linux/export.h>
#include <linux/of.h>
#include <linux/percpu.h>
#include <linux/spinlock.h>
@@ -14,8 +15,10 @@
#include <asm/mipsregs.h>

void __iomem *mips_gcr_base;
+EXPORT_SYMBOL_GPL(mips_gcr_base);
void __iomem *mips_cm_l2sync_base;
int mips_cm_is64;
+EXPORT_SYMBOL_GPL(mips_cm_is64);
bool mips_cm_is_l2_hci_broken;

static char *cm2_tr[8] = {
@@ -373,6 +376,7 @@ void mips_cm_lock_other(unsigned int cluster, unsigned int core,
*/
mb();
}
+EXPORT_SYMBOL_GPL(mips_cm_lock_other);

void mips_cm_unlock_other(void)
{
@@ -389,6 +393,7 @@ void mips_cm_unlock_other(void)

preempt_enable();
}
+EXPORT_SYMBOL_GPL(mips_cm_unlock_other);

void mips_cm_error_report(void)
{
diff --git a/arch/mips/kernel/mips-cpc.c b/arch/mips/kernel/mips-cpc.c
index 3e386f7e1545..4a8bd56bc2e8 100644
--- a/arch/mips/kernel/mips-cpc.c
+++ b/arch/mips/kernel/mips-cpc.c
@@ -6,6 +6,7 @@

#include <linux/bitfield.h>
#include <linux/errno.h>
+#include <linux/export.h>
#include <linux/percpu.h>
#include <linux/of.h>
#include <linux/of_address.h>
@@ -14,6 +15,7 @@
#include <asm/mips-cps.h>

void __iomem *mips_cpc_base;
+EXPORT_SYMBOL_GPL(mips_cpc_base);

static DEFINE_PER_CPU_ALIGNED(spinlock_t, cpc_core_lock);


--
2.43.0