Skip to content

Commit a83f1fc

Browse files
jonhunterthierryreding
authored andcommitted
soc/tegra: pmc: Don't probe PMC if early initialisation fails
Commit 0259f52 ('soc/tegra: pmc: Restore base address on probe failure') fixes an issue where the PMC base address pointer is not restored on probe failure. However, this fix creates another problem where if early initialisation of the PMC driver fails and an initial mapping for the PMC address space is not created, then when the PMC device is probed, the PMC base address pointer will not be valid and this will cause a crash when tegra_pmc_init() is called and attempts to access a register. Although the PMC address space is mapped a 2nd time during the probe and so this could be fixed by populating the base address pointer earlier during the probe, this adds more complexity to the code. Moreover, the PMC probe also assumes the the soc data pointer is also initialised when the device is probed and if not will also lead to a crash when calling tegra_pmc_init_tsense_reset(). Given that if the early initialisation does fail then something bad has happen, it seems acceptable to allow the PMC device probe to fail as well. Therefore, if the PMC base address pointer or soc data pointer are not valid when probing the PMC device, WARN and return an error. Fixes: 0259f52 ('soc/tegra: pmc: Restore base address on probe failure') Signed-off-by: Jon Hunter <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent b69a625 commit a83f1fc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/soc/tegra/pmc.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,14 @@ static int tegra_pmc_probe(struct platform_device *pdev)
12281228
struct resource *res;
12291229
int err;
12301230

1231+
/*
1232+
* Early initialisation should have configured an initial
1233+
* register mapping and setup the soc data pointer. If these
1234+
* are not valid then something went badly wrong!
1235+
*/
1236+
if (WARN_ON(!pmc->base || !pmc->soc))
1237+
return -ENODEV;
1238+
12311239
err = tegra_pmc_parse_dt(pmc, pdev->dev.of_node);
12321240
if (err < 0)
12331241
return err;

0 commit comments

Comments
 (0)