Skip to content

Commit 9c93ccf

Browse files
digetxthierryreding
authored andcommitted
soc/tegra: pmc: Prevent racing with cpuilde driver
Both PMC and cpuidle drivers are probed at the same init level and cpuidle depends on the PMC suspend mode. Add new default suspend mode that indicates whether PMC driver has been probed and reset the mode in a case of deferred probe of the PMC driver. Signed-off-by: Dmitry Osipenko <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 158a9b4 commit 9c93ccf

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

arch/arm/mach-tegra/pm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ static const struct platform_suspend_ops tegra_suspend_ops = {
403403
.enter = tegra_suspend_enter,
404404
};
405405

406-
void __init tegra_init_suspend(void)
406+
void tegra_pm_init_suspend(void)
407407
{
408408
enum tegra_suspend_mode mode = tegra_pmc_get_suspend_mode();
409409

arch/arm/mach-tegra/pm.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,4 @@ void tegra30_sleep_core_init(void);
2525

2626
extern void (*tegra_tear_down_cpu)(void);
2727

28-
#ifdef CONFIG_PM_SLEEP
29-
void tegra_init_suspend(void);
30-
#else
31-
static inline void tegra_init_suspend(void) {}
32-
#endif
33-
3428
#endif /* _MACH_TEGRA_PM_H_ */

arch/arm/mach-tegra/tegra.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ static void __init tegra_dt_init(void)
8484

8585
static void __init tegra_dt_init_late(void)
8686
{
87-
tegra_init_suspend();
88-
8987
if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) &&
9088
of_machine_is_compatible("compal,paz00"))
9189
tegra_paz00_wifikill_init();

drivers/soc/tegra/pmc.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ struct tegra_pmc {
436436

437437
static struct tegra_pmc *pmc = &(struct tegra_pmc) {
438438
.base = NULL,
439-
.suspend_mode = TEGRA_SUSPEND_NONE,
439+
.suspend_mode = TEGRA_SUSPEND_NOT_READY,
440440
};
441441

442442
static inline struct tegra_powergate *
@@ -1812,6 +1812,7 @@ static int tegra_pmc_parse_dt(struct tegra_pmc *pmc, struct device_node *np)
18121812
u32 value, values[2];
18131813

18141814
if (of_property_read_u32(np, "nvidia,suspend-mode", &value)) {
1815+
pmc->suspend_mode = TEGRA_SUSPEND_NONE;
18151816
} else {
18161817
switch (value) {
18171818
case 0:
@@ -2785,6 +2786,11 @@ static int tegra_pmc_regmap_init(struct tegra_pmc *pmc)
27852786
return 0;
27862787
}
27872788

2789+
static void tegra_pmc_reset_suspend_mode(void *data)
2790+
{
2791+
pmc->suspend_mode = TEGRA_SUSPEND_NOT_READY;
2792+
}
2793+
27882794
static int tegra_pmc_probe(struct platform_device *pdev)
27892795
{
27902796
void __iomem *base;
@@ -2803,6 +2809,11 @@ static int tegra_pmc_probe(struct platform_device *pdev)
28032809
if (err < 0)
28042810
return err;
28052811

2812+
err = devm_add_action_or_reset(&pdev->dev, tegra_pmc_reset_suspend_mode,
2813+
NULL);
2814+
if (err)
2815+
return err;
2816+
28062817
/* take over the memory region from the early initialization */
28072818
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
28082819
base = devm_ioremap_resource(&pdev->dev, res);
@@ -2909,6 +2920,7 @@ static int tegra_pmc_probe(struct platform_device *pdev)
29092920

29102921
tegra_pmc_clock_register(pmc, pdev->dev.of_node);
29112922
platform_set_drvdata(pdev, pmc);
2923+
tegra_pm_init_suspend();
29122924

29132925
return 0;
29142926

include/soc/tegra/pm.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ enum tegra_suspend_mode {
1414
TEGRA_SUSPEND_LP1, /* CPU voltage off, DRAM self-refresh */
1515
TEGRA_SUSPEND_LP0, /* CPU + core voltage off, DRAM self-refresh */
1616
TEGRA_MAX_SUSPEND_MODE,
17+
TEGRA_SUSPEND_NOT_READY,
1718
};
1819

1920
#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_ARM)
@@ -28,6 +29,7 @@ void tegra_pm_clear_cpu_in_lp2(void);
2829
void tegra_pm_set_cpu_in_lp2(void);
2930
int tegra_pm_enter_lp2(void);
3031
int tegra_pm_park_secondary_cpu(unsigned long cpu);
32+
void tegra_pm_init_suspend(void);
3133
#else
3234
static inline enum tegra_suspend_mode
3335
tegra_pm_validate_suspend_mode(enum tegra_suspend_mode mode)
@@ -61,6 +63,10 @@ static inline int tegra_pm_park_secondary_cpu(unsigned long cpu)
6163
{
6264
return -ENOTSUPP;
6365
}
66+
67+
static inline void tegra_pm_init_suspend(void)
68+
{
69+
}
6470
#endif /* CONFIG_PM_SLEEP */
6571

6672
#endif /* __SOC_TEGRA_PM_H__ */

0 commit comments

Comments
 (0)