soc/tegra: pmc: Use debugfs_initialized()
Jon Hunter
maintainerPATCH 1/3 soc/tegra: pmc: Use debugfs_initialized()
From: Bharat Nihalani <[email protected]>
The kernel command line parameter debugfs=off can be used to dynamically disable debugfs support at boot time. However, the Tegra PMC driver will always attempt to register debugfs entries if CONFIG_DEBUG_FS is enabled. Therefore, if CONFIG_DEBUG_FS is enabled but the user sets debugfs=off, then probing the PMC driver will fail.
Fix this by using the function debugfs_initialized() to check if debugfs support is enabled before calling any debugfs functions in the Tegra PMC driver. Note that if CONFIG_DEBUG_FS is not defined debugfs_initialized() will return false.
--- drivers/soc/tegra/pmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/tegra/pmc.c +1 -1
@@ -3026,7 +3026,7 @@ static int tegra_pmc_probe(struct platform_device *pdev)tegra_pmc_reset_sysfs_init (pmc); -if (IS_ENABLED (CONFIG_DEBUG_FS )) { +if (debugfs_initialized ()) { err =tegra_powergate_debugfs_init ();if (err <0 ) goto cleanup_sysfs;
Signature · 1 line
2.34.1
Jon Hunter
maintainerPATCH 2/3 soc/tegra: pmc: Add AON SW Wake support for Tegra234
From: Viswanath L <[email protected]>
Wake-up signal 83 on Tegra234 is triggered by software writing to WAKE_AOWAKE_SW_WAKE_TIER0_TRIGGER_0 register. This wake-up is mapped to CPU interrupt 179 and is used by the Sensor Processing Engine (SPE) in the Always-on (AON) power domain for waking up the system.
--- drivers/soc/tegra/pmc.c | 1 + 1 file changed, 1 insertion(+)
drivers/soc/tegra/pmc.c +1 -0
@@ -4250,6 +4250,7 @@ static const struct tegra_wake_event tegra234_wake_events[] = {TEGRA_WAKE_GPIO ("power" ,29 ,1 ,TEGRA234_AON_GPIO (EE ,4 )),TEGRA_WAKE_GPIO ("mgbe" ,56 ,0 ,TEGRA234_MAIN_GPIO (Y ,3 )),TEGRA_WAKE_IRQ ("rtc" ,73 ,10 ), + TEGRA_WAKE_IRQ("sw-wake", SW_WAKE_ID, 179), }; static const struct tegra_pmc_soc tegra234_pmc_soc = {
Signature · 1 line
2.34.1
Jon Hunter
maintainerPATCH 3/3 soc/tegra: fuse: Fix Tegra234 fuse size
In reply to Jon HunterFrom: Kartik <[email protected]>
The Tegra234 fuse size is incorrectly defined as 0x98c. The actual size of the Tegra234 fuses is 0xf8c and so update the size of the Tegra234 fuses to fix this.
--- drivers/soc/tegra/fuse/fuse-tegra30.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/tegra/fuse/fuse-tegra30.c +1 -1
@@ -663,7 +663,7 @@ static const struct nvmem_keepout tegra234_fuse_keepouts[] = {static const struct tegra_fuse_info tegra234_fuse_info = { .read = tegra30_fuse_read, - .size =0x98c , + .size =0xf90 , .spare =0x280 , };
Signature · 1 line
2.34.1
Quoted 26 lines · Jon Hunter
From: Bharat Nihalani <[email protected]>
The kernel command line parameter debugfs=off can be used to dynamically disable debugfs support at boot time. However, the Tegra PMC driver will always attempt to register debugfs entries if
CONFIG_DEBUG_FSis enabled. Therefore, ifCONFIG_DEBUG_FSis enabled but the user sets debugfs=off, then probing the PMC driver will fail.Fix this by using the function
debugfs_initialized()to check if debugfs support is enabled before calling any debugfs functions in the Tegra PMC driver. Note that ifCONFIG_DEBUG_FSis not defineddebugfs_initialized()will return false.Signed-off-by Bharat Nihalani <[email protected]>Signed-off-by Kartik <[email protected]>Co-developed-by Jon Hunter <[email protected]>Signed-off-by Jon Hunter <[email protected]>--- drivers/soc/tegra/pmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/soc/tegra/pmc.c +0
-0
drivers/soc/tegra/pmc.c static int tegra_pmc_probe(struct platform_device *pdev) · line 3032
Quoted 8 lines
drivers/soc/tegra/pmc.c +1
-1@@ -3026,7 +3026,7 @@ static int tegra_pmc_probe(struct platform_device *pdev)tegra_pmc_reset_sysfs_init (pmc); -if (IS_ENABLED (CONFIG_DEBUG_FS )) { +if (debugfs_initialized ()) { err =tegra_powergate_debugfs_init ();if (err <0 ) goto cleanup_sysfs;
Judging by other patches I've seen sent over the last few years, I think the more idiomatic fix would be to just ignore the error returns from debugfs calls. I think in this particular case we can probably just make tegra_powergate_debugfs_init() return void. Any subsequent calls using the pmc->debugfs pointer will ignore errors or NULL.
Can you test whether something like the below fixes the problem you were seeing as well?
--- >8 ---
drivers/soc/tegra/pmc.c +3 -11
@@ -1190,14 +1190,10 @@ static int powergate_show(struct seq_file *s, void *data)DEFINE_SHOW_ATTRIBUTE (powergate); -static int tegra_powergate_debugfs_init (void ) +static void tegra_powergate_debugfs_init (void ) { pmc->debugfs =debugfs_create_file ("powergate" ,S_IRUGO ,NULL ,NULL , &powergate_fops); -if (!pmc->debugfs) -return -ENOMEM ; - -return 0 ; } static int tegra_powergate_of_get_clks(struct tegra_powergate *pg,
@@ -3026,11 +3022,8 @@ static int tegra_pmc_probe(struct platform_device *pdev)tegra_pmc_reset_sysfs_init (pmc); -if (IS_ENABLED (CONFIG_DEBUG_FS )) { - err =tegra_powergate_debugfs_init (); -if (err <0 ) - goto cleanup_sysfs; - } +if (IS_ENABLED (CONFIG_DEBUG_FS )) +tegra_powergate_debugfs_init (); err =tegra_pmc_pinctrl_init (pmc);if (err)
@@ -3067,7 +3060,6 @@ static int tegra_pmc_probe(struct platform_device *pdev)tegra_powergate_remove_all (pdev->dev.of_node); cleanup_debugfs:debugfs_remove (pmc->debugfs); -cleanup_sysfs:device_remove_file (&pdev->dev, &dev_attr_reset_reason);device_remove_file (&pdev->dev, &dev_attr_reset_level);clk_notifier_unregister (pmc->clk, &pmc->clk_nb);
--- >8 ---
Thanks,
Thierry
Thierry Reding
AppliedRe: (subset) [PATCH 1/3] soc/tegra: pmc: Use debugfs_initialized()
In reply to Jon HunterFrom: Thierry Reding <[email protected]>
Quoted 9 lines · Jon Hunter
From: Bharat Nihalani <[email protected]>
The kernel command line parameter debugfs=off can be used to dynamically disable debugfs support at boot time. However, the Tegra PMC driver will always attempt to register debugfs entries if
CONFIG_DEBUG_FSis enabled. Therefore, ifCONFIG_DEBUG_FSis enabled but the user sets debugfs=off, then probing the PMC driver will fail.[...]
Applied, thanks!
[2/3] soc/tegra: pmc: Add AON SW Wake support for Tegra234
commit: c3a1c97c72601f8c00678f0ebafb574ec6e26d54
[3/3] soc/tegra: fuse: Fix Tegra234 fuse size
commit: e180cf836433185d0674ade52f8db911d89f6422Best regards,
Signature · 1 line
Thierry Reding <[email protected]>