* [PATCH V2 0/5] cpufreq: loongson3: Fix wrong behaviors on multi-node servers
@ 2026-08-28 3:11 Huacai Chen
2026-08-28 3:11 ` [PATCH V2 1/5] cpufreq: loongson3: Make this driver depend on MACH_LOONGSON64 Huacai Chen
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Huacai Chen @ 2026-08-28 3:11 UTC (permalink / raw)
To: Rafael J . Wysocki, Viresh Kumar, Huacai Chen
Cc: loongarch, linux-pm, linux-kernel, Xuerui Wang, Jiaxun Yang,
Huacai Chen, Hongliang Wang
Our server productions (e.g. Loongson-3D6000/3E6000) can have multiple
nodes in one package and SMC mailboxes are also per-node. However, the
current driver has wrong behaviors on multi-node servers, including: id
field in smc_message is too narrow, mutex is not per-node, IOCSR read/
write can only perform on the current node, etc. This series fix all the
above problems.
V1 -> V2:
1. Fix typos and add Fixes tags.
2. Fix loongson3_cpufreq_get() return values.
3. Use nid_to_addrbase() rather than hard code.
4. Guard some code with CONFIG_SMP to avoid build errors.
Hongliang Wang & Huacai Chen (5):
cpufreq: loongson3: Make this drvier depend on MACH_LOONGSON64
cpufreq: loongson3: Adjust the width of id and val in smc_message
cpufreq: loongson3: Replace per-package mutex with per-node
cpufreq: loongson3: Use global physical CPU ID in get/target callbacks
cpufreq: loongson3: Replace IOCSR read/write with MMIO ones
Signed-off-by: Hongliang Wang <wanghongliang@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
drivers/cpufreq/Kconfig | 1 +
drivers/cpufreq/loongson3_cpufreq.c | 72 ++++++++++++++++++++++++-------------
2 files changed, 48 insertions(+), 25 deletions(-)
---
2.27.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH V2 1/5] cpufreq: loongson3: Make this driver depend on MACH_LOONGSON64
2026-08-28 3:11 [PATCH V2 0/5] cpufreq: loongson3: Fix wrong behaviors on multi-node servers Huacai Chen
@ 2026-08-28 3:11 ` Huacai Chen
2026-08-28 3:11 ` [PATCH V2 2/5] cpufreq: loongson3: Adjust the width of id and val in smc_message Huacai Chen
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Huacai Chen @ 2026-08-28 3:11 UTC (permalink / raw)
To: Rafael J . Wysocki, Viresh Kumar, Huacai Chen
Cc: loongarch, linux-pm, linux-kernel, Xuerui Wang, Jiaxun Yang,
Huacai Chen, stable
32BIT Loongson machines don't have SMC and FreqCtrl registers, so make
this driver depend on MACH_LOONGSON64 (only for LoongArch based 64bit
machines currently).
Cc: stable@vger.kernel.org
Fixes: ccf51454145b ("cpufreq: Add Loongson-3 CPUFreq driver support")
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
drivers/cpufreq/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index db83f3365698..edc1299098d4 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -288,6 +288,7 @@ endif
if LOONGARCH
config LOONGSON3_CPUFREQ
tristate "Loongson3 CPUFreq Driver"
+ depends on MACH_LOONGSON64
help
This option adds a CPUFreq driver for Loongson processors which
support software configurable cpu frequency.
--
2.52.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH V2 2/5] cpufreq: loongson3: Adjust the width of id and val in smc_message
2026-08-28 3:11 [PATCH V2 0/5] cpufreq: loongson3: Fix wrong behaviors on multi-node servers Huacai Chen
2026-08-28 3:11 ` [PATCH V2 1/5] cpufreq: loongson3: Make this driver depend on MACH_LOONGSON64 Huacai Chen
@ 2026-08-28 3:11 ` Huacai Chen
2026-08-28 3:11 ` [PATCH V2 3/5] cpufreq: loongson3: Replace per-package mutex with per-node Huacai Chen
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Huacai Chen @ 2026-08-28 3:11 UTC (permalink / raw)
To: Rafael J . Wysocki, Viresh Kumar, Huacai Chen
Cc: loongarch, linux-pm, linux-kernel, Xuerui Wang, Jiaxun Yang,
Huacai Chen, stable, Hongliang Wang
The id field of smc_message is usually stand for the CPU ID. In the past
this driver was only tested for desktop and laptop productions so 4-bits
are enough. But now we have servers that can have as many as 256 cores,
so we need 8-bits CPU ID.
On the other hand, the val field is usually stand for CPU frequency so
12-bits are enough to represent 4GHz, and for higher frequencies there
is an extra bit to extend (enough for 8GHz).
In theory, this is a incompatible change, but fortunately the old SMC
firmwares are not widely shipped and can be updated on the air, thus we
can safely adjust the widths.
Cc: stable@vger.kernel.org
Fixes: ccf51454145b ("cpufreq: Add Loongson-3 CPUFreq driver support")
Signed-off-by: Hongliang Wang <wanghongliang@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
drivers/cpufreq/loongson3_cpufreq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/loongson3_cpufreq.c b/drivers/cpufreq/loongson3_cpufreq.c
index 1e8715ea1b77..630f679aa739 100644
--- a/drivers/cpufreq/loongson3_cpufreq.c
+++ b/drivers/cpufreq/loongson3_cpufreq.c
@@ -21,9 +21,9 @@
union smc_message {
u32 value;
struct {
- u32 id : 4;
+ u32 id : 8;
u32 info : 4;
- u32 val : 16;
+ u32 val : 12;
u32 cmd : 6;
u32 extra : 1;
u32 complete : 1;
--
2.52.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH V2 3/5] cpufreq: loongson3: Replace per-package mutex with per-node
2026-08-28 3:11 [PATCH V2 0/5] cpufreq: loongson3: Fix wrong behaviors on multi-node servers Huacai Chen
2026-08-28 3:11 ` [PATCH V2 1/5] cpufreq: loongson3: Make this driver depend on MACH_LOONGSON64 Huacai Chen
2026-08-28 3:11 ` [PATCH V2 2/5] cpufreq: loongson3: Adjust the width of id and val in smc_message Huacai Chen
@ 2026-08-28 3:11 ` Huacai Chen
2026-08-28 3:12 ` [PATCH V2 4/5] cpufreq: loongson3: Use global physical CPU ID in get/target callbacks Huacai Chen
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Huacai Chen @ 2026-08-28 3:11 UTC (permalink / raw)
To: Rafael J . Wysocki, Viresh Kumar, Huacai Chen
Cc: loongarch, linux-pm, linux-kernel, Xuerui Wang, Jiaxun Yang,
Huacai Chen, stable, Hongliang Wang
Our server productions (e.g. Loongson-3D6000/3E6000) can have multiple
nodes in one package and SMC mailboxes are also per-node. So replace the
per-package mutex with per-node one.
Cc: stable@vger.kernel.org
Fixes: ccf51454145b ("cpufreq: Add Loongson-3 CPUFreq driver support")
Signed-off-by: Hongliang Wang <wanghongliang@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
drivers/cpufreq/loongson3_cpufreq.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/cpufreq/loongson3_cpufreq.c b/drivers/cpufreq/loongson3_cpufreq.c
index 630f679aa739..e3cd78a5ab18 100644
--- a/drivers/cpufreq/loongson3_cpufreq.c
+++ b/drivers/cpufreq/loongson3_cpufreq.c
@@ -169,7 +169,7 @@ struct loongson3_freq_data {
struct cpufreq_frequency_table table[];
};
-static struct mutex cpufreq_mutex[MAX_PACKAGES];
+static struct mutex cpufreq_mutex[MAX_NUMNODES];
static struct cpufreq_driver loongson3_cpufreq_driver;
static DEFINE_PER_CPU(struct loongson3_freq_data *, freq_data);
@@ -177,14 +177,14 @@ static inline int do_service_request(u32 id, u32 info, u32 cmd, u32 val, u32 ext
{
int retries;
unsigned int cpu = raw_smp_processor_id();
- unsigned int package = cpu_data[cpu].package;
+ unsigned int nid = cpu_to_node(cpu);
union smc_message msg, last;
- mutex_lock(&cpufreq_mutex[package]);
+ mutex_lock(&cpufreq_mutex[nid]);
last.value = iocsr_read32(LOONGARCH_IOCSR_SMCMBX);
if (!last.complete) {
- mutex_unlock(&cpufreq_mutex[package]);
+ mutex_unlock(&cpufreq_mutex[nid]);
return -EPERM;
}
@@ -208,11 +208,11 @@ static inline int do_service_request(u32 id, u32 info, u32 cmd, u32 val, u32 ext
}
if (!msg.complete || msg.cmd != CMD_OK) {
- mutex_unlock(&cpufreq_mutex[package]);
+ mutex_unlock(&cpufreq_mutex[nid]);
return -EPERM;
}
- mutex_unlock(&cpufreq_mutex[package]);
+ mutex_unlock(&cpufreq_mutex[nid]);
return msg.val;
}
@@ -337,7 +337,7 @@ static int loongson3_cpufreq_probe(struct platform_device *pdev)
{
int i, ret;
- for (i = 0; i < MAX_PACKAGES; i++) {
+ for (i = 0; i < MAX_NUMNODES; i++) {
ret = devm_mutex_init(&pdev->dev, &cpufreq_mutex[i]);
if (ret)
return ret;
--
2.52.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH V2 4/5] cpufreq: loongson3: Use global physical CPU ID in get/target callbacks
2026-08-28 3:11 [PATCH V2 0/5] cpufreq: loongson3: Fix wrong behaviors on multi-node servers Huacai Chen
` (2 preceding siblings ...)
2026-08-28 3:11 ` [PATCH V2 3/5] cpufreq: loongson3: Replace per-package mutex with per-node Huacai Chen
@ 2026-08-28 3:12 ` Huacai Chen
2026-08-28 3:12 ` [PATCH V2 5/5] cpufreq: loongson3: Replace IOCSR read/write with MMIO ones Huacai Chen
2026-09-01 8:01 ` [PATCH V2 0/5] cpufreq: loongson3: Fix wrong behaviors on multi-node servers Zhongqiu Han
5 siblings, 0 replies; 7+ messages in thread
From: Huacai Chen @ 2026-08-28 3:12 UTC (permalink / raw)
To: Rafael J . Wysocki, Viresh Kumar, Huacai Chen
Cc: loongarch, linux-pm, linux-kernel, Xuerui Wang, Jiaxun Yang,
Huacai Chen, stable, Hongliang Wang
Our server productions (e.g. Loongson-3D6000/3E6000) can have discrete
global physical CPU IDs while the core ID inside the packages are always
continuous. In these cases we should use global physical CPU IDs to get
and set frequencies.
Cc: stable@vger.kernel.org
Fixes: ccf51454145b ("cpufreq: Add Loongson-3 CPUFreq driver support")
Signed-off-by: Hongliang Wang <wanghongliang@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
drivers/cpufreq/loongson3_cpufreq.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/drivers/cpufreq/loongson3_cpufreq.c b/drivers/cpufreq/loongson3_cpufreq.c
index e3cd78a5ab18..3a5bf970077a 100644
--- a/drivers/cpufreq/loongson3_cpufreq.c
+++ b/drivers/cpufreq/loongson3_cpufreq.c
@@ -16,6 +16,7 @@
#include <asm/idle.h>
#include <asm/loongarch.h>
#include <asm/loongson.h>
+#include <asm/smp.h>
/* Message */
union smc_message {
@@ -219,38 +219,40 @@ static inline int do_service_request(u32 id, u32 info, u32 cmd, u32 val, u32 ext
static unsigned int loongson3_cpufreq_get(unsigned int cpu)
{
- int ret;
+ int ret, core = cpu_logical_map(cpu);
- ret = do_service_request(cpu, FREQ_INFO_TYPE_FREQ, CMD_GET_FREQ_INFO, 0, 0);
+ ret = do_service_request(core, FREQ_INFO_TYPE_FREQ, CMD_GET_FREQ_INFO, 0, 0);
- return ret * KILO;
+ return (ret < 0) ? 0 : ret * KILO;
}
static int loongson3_cpufreq_target(struct cpufreq_policy *policy, unsigned int index)
{
- int ret;
+ int ret, core = cpu_logical_map(policy->cpu);
- ret = do_service_request(cpu_data[policy->cpu].core,
- FREQ_INFO_TYPE_LEVEL, CMD_SET_FREQ_INFO, index, 0);
+ ret = do_service_request(core, FREQ_INFO_TYPE_LEVEL, CMD_SET_FREQ_INFO,
+ index, 0);
return (ret >= 0) ? 0 : ret;
}
static int configure_freq_table(int cpu)
{
- int i, ret, boost_level, max_level, freq_level;
+ int i, ret, core, boost_level, max_level, freq_level;
struct platform_device *pdev = cpufreq_get_driver_data();
struct loongson3_freq_data *data;
if (per_cpu(freq_data, cpu))
return 0;
- ret = do_service_request(cpu, 0, CMD_GET_FREQ_LEVEL_NUM, 0, 0);
+ core = cpu_logical_map(cpu);
+
+ ret = do_service_request(core, 0, CMD_GET_FREQ_LEVEL_NUM, 0, 0);
if (ret < 0)
return ret;
max_level = ret;
- ret = do_service_request(cpu, 0, CMD_GET_FREQ_BOOST_LEVEL, 0, 0);
+ ret = do_service_request(core, 0, CMD_GET_FREQ_BOOST_LEVEL, 0, 0);
if (ret < 0)
return ret;
boost_level = ret;
@@ -263,7 +265,7 @@ static int configure_freq_table(int cpu)
data->def_freq_level = boost_level - 1;
for (i = 0; i < freq_level; i++) {
- ret = do_service_request(cpu, FREQ_INFO_TYPE_FREQ, CMD_GET_FREQ_LEVEL_INFO, i, 0);
+ ret = do_service_request(core, FREQ_INFO_TYPE_FREQ, CMD_GET_FREQ_LEVEL_INFO, i, 0);
if (ret < 0) {
devm_kfree(&pdev->dev, data);
return ret;
--
2.52.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH V2 5/5] cpufreq: loongson3: Replace IOCSR read/write with MMIO ones
2026-08-28 3:11 [PATCH V2 0/5] cpufreq: loongson3: Fix wrong behaviors on multi-node servers Huacai Chen
` (3 preceding siblings ...)
2026-08-28 3:12 ` [PATCH V2 4/5] cpufreq: loongson3: Use global physical CPU ID in get/target callbacks Huacai Chen
@ 2026-08-28 3:12 ` Huacai Chen
2026-09-01 8:01 ` [PATCH V2 0/5] cpufreq: loongson3: Fix wrong behaviors on multi-node servers Zhongqiu Han
5 siblings, 0 replies; 7+ messages in thread
From: Huacai Chen @ 2026-08-28 3:12 UTC (permalink / raw)
To: Rafael J . Wysocki, Viresh Kumar, Huacai Chen
Cc: loongarch, linux-pm, linux-kernel, Xuerui Wang, Jiaxun Yang,
Huacai Chen, stable, Xi Ruoyao
Our server productions (e.g. Loongson-3D6000/3E6000) can have multiple
nodes in one package and SMC mailboxes are also per-node. However, IOCSR
read/write can only perform on the current node, while sometimes we want
to perform on other nodes (e.g. when switch governor, the get and target
callbacks are not run on target core). So replace IOCSR read/write with
MMIO ones.
Cc: stable@vger.kernel.org
Fixes: ccf51454145b ("cpufreq: Add Loongson-3 CPUFreq driver support")
Tested-by: Xi Ruoyao <xry111@xry111.site>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
drivers/cpufreq/loongson3_cpufreq.c | 34 +++++++++++++++++++++++------
1 file changed, 27 insertions(+), 7 deletions(-)
diff --git a/drivers/cpufreq/loongson3_cpufreq.c b/drivers/cpufreq/loongson3_cpufreq.c
index 3a5bf970077a..dcb6c70c0def 100644
--- a/drivers/cpufreq/loongson3_cpufreq.c
+++ b/drivers/cpufreq/loongson3_cpufreq.c
@@ -16,6 +16,7 @@
#include <asm/loongarch.h>
#include <asm/loongson.h>
#include <asm/smp.h>
+#include <asm/numa.h>
/* Message */
union smc_message {
@@ -164,6 +165,12 @@ union smc_message {
#define FREQ_MAX_LEVEL 16
+#define MMIO_SMCMBX(node) \
+ ((void __iomem *)(nid_to_addrbase(node) | IO_BASE | LOONGSON_REG_BASE | LOONGARCH_IOCSR_SMCMBX))
+
+#define MMIO_MISC_FUNC(node) \
+ ((void __iomem *)(nid_to_addrbase(node) | IO_BASE | LOONGSON_REG_BASE | LOONGARCH_IOCSR_MISC_FUNC))
+
struct loongson3_freq_data {
unsigned int def_freq_level;
struct cpufreq_frequency_table table[];
@@ -176,13 +183,27 @@ static DEFINE_PER_CPU(struct loongson3_freq_data *, freq_data);
static inline int do_service_request(u32 id, u32 info, u32 cmd, u32 val, u32 extra)
{
int retries;
- unsigned int cpu = raw_smp_processor_id();
- unsigned int nid = cpu_to_node(cpu);
+ unsigned int cpu = 0, nid;
union smc_message msg, last;
+#ifdef CONFIG_SMP
+ switch (cmd) {
+ case CMD_GET_FREQ_INFO:
+ case CMD_SET_FREQ_INFO:
+ case CMD_GET_FREQ_LEVEL_NUM:
+ case CMD_GET_FREQ_LEVEL_INFO:
+ case CMD_GET_FREQ_BOOST_LEVEL:
+ cpu = cpu_number_map(id);
+ break;
+ default:
+ cpu = raw_smp_processor_id();
+ }
+#endif
+ nid = cpu_to_node(cpu);
+
mutex_lock(&cpufreq_mutex[nid]);
- last.value = iocsr_read32(LOONGARCH_IOCSR_SMCMBX);
+ last.value = readl(MMIO_SMCMBX(nid));
if (!last.complete) {
mutex_unlock(&cpufreq_mutex[nid]);
return -EPERM;
@@ -195,12 +216,11 @@ static inline int do_service_request(u32 id, u32 info, u32 cmd, u32 val, u32 ext
msg.extra = extra;
msg.complete = 0;
- iocsr_write32(msg.value, LOONGARCH_IOCSR_SMCMBX);
- iocsr_write32(iocsr_read32(LOONGARCH_IOCSR_MISC_FUNC) | IOCSR_MISC_FUNC_SOFT_INT,
- LOONGARCH_IOCSR_MISC_FUNC);
+ writel(msg.value, MMIO_SMCMBX(nid));
+ writel(readl(MMIO_MISC_FUNC(nid)) | IOCSR_MISC_FUNC_SOFT_INT, MMIO_MISC_FUNC(nid));
for (retries = 0; retries < 10000; retries++) {
- msg.value = iocsr_read32(LOONGARCH_IOCSR_SMCMBX);
+ msg.value = readl(MMIO_SMCMBX(nid));
if (msg.complete)
break;
--
2.52.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH V2 0/5] cpufreq: loongson3: Fix wrong behaviors on multi-node servers
2026-08-28 3:11 [PATCH V2 0/5] cpufreq: loongson3: Fix wrong behaviors on multi-node servers Huacai Chen
` (4 preceding siblings ...)
2026-08-28 3:12 ` [PATCH V2 5/5] cpufreq: loongson3: Replace IOCSR read/write with MMIO ones Huacai Chen
@ 2026-09-01 8:01 ` Zhongqiu Han
5 siblings, 0 replies; 7+ messages in thread
From: Zhongqiu Han @ 2026-09-01 8:01 UTC (permalink / raw)
To: Huacai Chen, Rafael J . Wysocki, Viresh Kumar, Huacai Chen
Cc: loongarch, linux-pm, linux-kernel, Xuerui Wang, Jiaxun Yang,
Hongliang Wang, zhongqiu.han
On 8/28/2026 11:11 AM, Huacai Chen wrote:
> Our server productions (e.g. Loongson-3D6000/3E6000) can have multiple
> nodes in one package and SMC mailboxes are also per-node. However, the
> current driver has wrong behaviors on multi-node servers, including: id
> field in smc_message is too narrow, mutex is not per-node, IOCSR read/
> write can only perform on the current node, etc. This series fix all the
> above problems.
>
> V1 -> V2:
> 1. Fix typos and add Fixes tags.
> 2. Fix loongson3_cpufreq_get() return values.
> 3. Use nid_to_addrbase() rather than hard code.
> 4. Guard some code with CONFIG_SMP to avoid build errors.
>
> Hongliang Wang & Huacai Chen (5):
> cpufreq: loongson3: Make this drvier depend on MACH_LOONGSON64
> cpufreq: loongson3: Adjust the width of id and val in smc_message
> cpufreq: loongson3: Replace per-package mutex with per-node
> cpufreq: loongson3: Use global physical CPU ID in get/target callbacks
> cpufreq: loongson3: Replace IOCSR read/write with MMIO ones
>
> Signed-off-by: Hongliang Wang <wanghongliang@loongson.cn>
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> ---
> drivers/cpufreq/Kconfig | 1 +
> drivers/cpufreq/loongson3_cpufreq.c | 72 ++++++++++++++++++++++++-------------
> 2 files changed, 48 insertions(+), 25 deletions(-)
The whole series looks good to me.
Reviewed-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
> ---
> 2.27.0
>
>
--
Thx and BRs,
Zhongqiu Han
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-09-01 8:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-28 3:11 [PATCH V2 0/5] cpufreq: loongson3: Fix wrong behaviors on multi-node servers Huacai Chen
2026-08-28 3:11 ` [PATCH V2 1/5] cpufreq: loongson3: Make this driver depend on MACH_LOONGSON64 Huacai Chen
2026-08-28 3:11 ` [PATCH V2 2/5] cpufreq: loongson3: Adjust the width of id and val in smc_message Huacai Chen
2026-08-28 3:11 ` [PATCH V2 3/5] cpufreq: loongson3: Replace per-package mutex with per-node Huacai Chen
2026-08-28 3:12 ` [PATCH V2 4/5] cpufreq: loongson3: Use global physical CPU ID in get/target callbacks Huacai Chen
2026-08-28 3:12 ` [PATCH V2 5/5] cpufreq: loongson3: Replace IOCSR read/write with MMIO ones Huacai Chen
2026-09-01 8:01 ` [PATCH V2 0/5] cpufreq: loongson3: Fix wrong behaviors on multi-node servers Zhongqiu Han
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox