Skip to content

Commit 5989950

Browse files
petegriffinkrzk
authored andcommitted
soc: samsung: exynos-pmu: enable CPU hotplug support for gs101
Some additional register writes are required when hotplugging CPUs on gs101, without these the system hangs when hotplugging. Specifically a CPU_INFORM register needs to be programmed with a hint value which is used by the EL3 firmware (el3mon) and the pmu-intr-gen registers need to be programmed. With this patch applied, and corresponding DT update CPU hotplug now works as expected. e.g. echo 0 > /sys/devices/system/cpu/cpu6/online echo 1 > /sys/devices/system/cpu/cpu6/online Note: to maintain compatibility with older DTs that didn't specify pmu-intr-gen phandle only a warning is issued if the syscon can't be obtained. Signed-off-by: Peter Griffin <[email protected]> Link: https://lore.kernel.org/r/20250506-contrib-pg-cpu-hotplug-suspend2ram-fixes-v1-v4-5-9f64a2657316@linaro.org [krzk: few blank line and white-space alignment fixes from checkpatch] Signed-off-by: Krzysztof Kozlowski <[email protected]>
1 parent 20adeac commit 5989950

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed

drivers/soc/samsung/exynos-pmu.c

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <linux/array_size.h>
99
#include <linux/arm-smccc.h>
10+
#include <linux/cpuhotplug.h>
1011
#include <linux/of.h>
1112
#include <linux/of_address.h>
1213
#include <linux/mfd/core.h>
@@ -33,6 +34,7 @@ struct exynos_pmu_context {
3334
struct device *dev;
3435
const struct exynos_pmu_data *pmu_data;
3536
struct regmap *pmureg;
37+
struct regmap *pmuintrgen;
3638
};
3739

3840
void __iomem *pmu_base_addr;
@@ -222,7 +224,8 @@ static const struct regmap_config regmap_smccfg = {
222224
};
223225

224226
static const struct exynos_pmu_data gs101_pmu_data = {
225-
.pmu_secure = true
227+
.pmu_secure = true,
228+
.pmu_cpuhp = true,
226229
};
227230

228231
/*
@@ -326,6 +329,59 @@ struct regmap *exynos_get_pmu_regmap_by_phandle(struct device_node *np,
326329
}
327330
EXPORT_SYMBOL_GPL(exynos_get_pmu_regmap_by_phandle);
328331

332+
/*
333+
* CPU_INFORM register hint values which are used by
334+
* EL3 firmware (el3mon).
335+
*/
336+
#define CPU_INFORM_CLEAR 0
337+
#define CPU_INFORM_C2 1
338+
339+
static int gs101_cpuhp_pmu_online(unsigned int cpu)
340+
{
341+
unsigned int cpuhint = smp_processor_id();
342+
u32 reg, mask;
343+
344+
/* clear cpu inform hint */
345+
regmap_write(pmu_context->pmureg, GS101_CPU_INFORM(cpuhint),
346+
CPU_INFORM_CLEAR);
347+
348+
mask = BIT(cpu);
349+
350+
regmap_update_bits(pmu_context->pmuintrgen, GS101_GRP2_INTR_BID_ENABLE,
351+
mask, (0 << cpu));
352+
353+
regmap_read(pmu_context->pmuintrgen, GS101_GRP2_INTR_BID_UPEND, &reg);
354+
355+
regmap_write(pmu_context->pmuintrgen, GS101_GRP2_INTR_BID_CLEAR,
356+
reg & mask);
357+
358+
return 0;
359+
}
360+
361+
static int gs101_cpuhp_pmu_offline(unsigned int cpu)
362+
{
363+
u32 reg, mask;
364+
unsigned int cpuhint = smp_processor_id();
365+
366+
/* set cpu inform hint */
367+
regmap_write(pmu_context->pmureg, GS101_CPU_INFORM(cpuhint),
368+
CPU_INFORM_C2);
369+
370+
mask = BIT(cpu);
371+
regmap_update_bits(pmu_context->pmuintrgen, GS101_GRP2_INTR_BID_ENABLE,
372+
mask, BIT(cpu));
373+
374+
regmap_read(pmu_context->pmuintrgen, GS101_GRP1_INTR_BID_UPEND, &reg);
375+
regmap_write(pmu_context->pmuintrgen, GS101_GRP1_INTR_BID_CLEAR,
376+
reg & mask);
377+
378+
mask = (BIT(cpu + 8));
379+
regmap_read(pmu_context->pmuintrgen, GS101_GRP1_INTR_BID_UPEND, &reg);
380+
regmap_write(pmu_context->pmuintrgen, GS101_GRP1_INTR_BID_CLEAR,
381+
reg & mask);
382+
return 0;
383+
}
384+
329385
static int exynos_pmu_probe(struct platform_device *pdev)
330386
{
331387
struct device *dev = &pdev->dev;
@@ -378,6 +434,26 @@ static int exynos_pmu_probe(struct platform_device *pdev)
378434
pmu_context->pmureg = regmap;
379435
pmu_context->dev = dev;
380436

437+
if (pmu_context->pmu_data && pmu_context->pmu_data->pmu_cpuhp) {
438+
pmu_context->pmuintrgen = syscon_regmap_lookup_by_phandle(dev->of_node,
439+
"google,pmu-intr-gen-syscon");
440+
if (IS_ERR(pmu_context->pmuintrgen)) {
441+
/*
442+
* To maintain support for older DTs that didn't specify syscon phandle
443+
* just issue a warning rather than fail to probe.
444+
*/
445+
dev_warn(&pdev->dev, "pmu-intr-gen syscon unavailable\n");
446+
} else {
447+
cpuhp_setup_state(CPUHP_BP_PREPARE_DYN,
448+
"soc/exynos-pmu:prepare",
449+
gs101_cpuhp_pmu_online, NULL);
450+
451+
cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
452+
"soc/exynos-pmu:online",
453+
NULL, gs101_cpuhp_pmu_offline);
454+
}
455+
}
456+
381457
if (pmu_context->pmu_data && pmu_context->pmu_data->pmu_init)
382458
pmu_context->pmu_data->pmu_init();
383459

drivers/soc/samsung/exynos-pmu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct exynos_pmu_data {
2222
const struct exynos_pmu_conf *pmu_config;
2323
const struct exynos_pmu_conf *pmu_config_extra;
2424
bool pmu_secure;
25+
bool pmu_cpuhp;
2526

2627
void (*pmu_init)(void);
2728
void (*powerdown_conf)(enum sys_powerdown);

include/linux/soc/samsung/exynos-regs-pmu.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,20 @@
658658
#define EXYNOS5433_PAD_RETENTION_FSYSGENIO_OPTION (0x32A8)
659659

660660
/* For Tensor GS101 */
661+
/* PMU ALIVE */
661662
#define GS101_SYSIP_DAT0 (0x810)
663+
#define GS101_CPU0_INFORM (0x860)
664+
#define GS101_CPU_INFORM(cpu) \
665+
(GS101_CPU0_INFORM + (cpu*4))
662666
#define GS101_SYSTEM_CONFIGURATION (0x3A00)
663667
#define GS101_PHY_CTRL_USB20 (0x3EB0)
664668
#define GS101_PHY_CTRL_USBDP (0x3EB4)
665669

670+
/* PMU INTR GEN */
671+
#define GS101_GRP1_INTR_BID_UPEND (0x0108)
672+
#define GS101_GRP1_INTR_BID_CLEAR (0x010c)
673+
#define GS101_GRP2_INTR_BID_ENABLE (0x0200)
674+
#define GS101_GRP2_INTR_BID_UPEND (0x0208)
675+
#define GS101_GRP2_INTR_BID_CLEAR (0x020c)
676+
666677
#endif /* __LINUX_SOC_EXYNOS_REGS_PMU_H */

0 commit comments

Comments
 (0)