All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] soc/tegra: pmc: Use debugfs_initialized()
@ 2023-06-06 15:36 Jon Hunter
  2023-06-06 15:36 ` [PATCH 2/3] soc/tegra: pmc: Add AON SW Wake support for Tegra234 Jon Hunter
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jon Hunter @ 2023-06-06 15:36 UTC (permalink / raw)
  To: Thierry Reding
  Cc: linux-tegra, Petlozu Pravareshwar, Bharat Nihalani, Kartik, Jon Hunter

From: Bharat Nihalani <bnihalani@nvidia.com>

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.

Signed-off-by: Bharat Nihalani <bnihalani@nvidia.com>
Signed-off-by: Kartik <kkartik@nvidia.com>
Co-developed-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
 drivers/soc/tegra/pmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index 5d17799524c9..12e852a8a609 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] soc/tegra: pmc: Add AON SW Wake support for Tegra234
  2023-06-06 15:36 [PATCH 1/3] soc/tegra: pmc: Use debugfs_initialized() Jon Hunter
@ 2023-06-06 15:36 ` Jon Hunter
  2023-06-06 15:36 ` [PATCH 3/3] soc/tegra: fuse: Fix Tegra234 fuse size Jon Hunter
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Jon Hunter @ 2023-06-06 15:36 UTC (permalink / raw)
  To: Thierry Reding
  Cc: linux-tegra, Petlozu Pravareshwar, Viswanath L, Kartik, Jon Hunter

From: Viswanath L <viswanathl@nvidia.com>

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.

Signed-off-by: Viswanath L <viswanathl@nvidia.com>
Signed-off-by: Kartik <kkartik@nvidia.com>
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
 drivers/soc/tegra/pmc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index 12e852a8a609..c77ce91a369a 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -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 = {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] soc/tegra: fuse: Fix Tegra234 fuse size
  2023-06-06 15:36 [PATCH 1/3] soc/tegra: pmc: Use debugfs_initialized() Jon Hunter
  2023-06-06 15:36 ` [PATCH 2/3] soc/tegra: pmc: Add AON SW Wake support for Tegra234 Jon Hunter
@ 2023-06-06 15:36 ` Jon Hunter
  2023-06-08 16:33 ` [PATCH 1/3] soc/tegra: pmc: Use debugfs_initialized() Thierry Reding
  2023-06-08 16:36 ` (subset) " Thierry Reding
  3 siblings, 0 replies; 5+ messages in thread
From: Jon Hunter @ 2023-06-06 15:36 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-tegra, Petlozu Pravareshwar, Kartik, Jon Hunter

From: Kartik <kkartik@nvidia.com>

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.

Signed-off-by: Kartik <kkartik@nvidia.com>
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
 drivers/soc/tegra/fuse/fuse-tegra30.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/tegra/fuse/fuse-tegra30.c b/drivers/soc/tegra/fuse/fuse-tegra30.c
index 932a03c64534..c759fb7c8adc 100644
--- a/drivers/soc/tegra/fuse/fuse-tegra30.c
+++ b/drivers/soc/tegra/fuse/fuse-tegra30.c
@@ -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,
 };
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] soc/tegra: pmc: Use debugfs_initialized()
  2023-06-06 15:36 [PATCH 1/3] soc/tegra: pmc: Use debugfs_initialized() Jon Hunter
  2023-06-06 15:36 ` [PATCH 2/3] soc/tegra: pmc: Add AON SW Wake support for Tegra234 Jon Hunter
  2023-06-06 15:36 ` [PATCH 3/3] soc/tegra: fuse: Fix Tegra234 fuse size Jon Hunter
@ 2023-06-08 16:33 ` Thierry Reding
  2023-06-08 16:36 ` (subset) " Thierry Reding
  3 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2023-06-08 16:33 UTC (permalink / raw)
  To: Jon Hunter; +Cc: linux-tegra, Petlozu Pravareshwar, Bharat Nihalani, Kartik

[-- Attachment #1: Type: text/plain, Size: 3348 bytes --]

On Tue, Jun 06, 2023 at 04:36:06PM +0100, Jon Hunter wrote:
> From: Bharat Nihalani <bnihalani@nvidia.com>
> 
> 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.
> 
> Signed-off-by: Bharat Nihalani <bnihalani@nvidia.com>
> Signed-off-by: Kartik <kkartik@nvidia.com>
> Co-developed-by: Jon Hunter <jonathanh@nvidia.com>
> Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
> ---
>  drivers/soc/tegra/pmc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
> index 5d17799524c9..12e852a8a609 100644
> --- a/drivers/soc/tegra/pmc.c
> +++ b/drivers/soc/tegra/pmc.c
> @@ -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 ---
diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index 5d17799524c9..16992ddd6e04 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: (subset) [PATCH 1/3] soc/tegra: pmc: Use debugfs_initialized()
  2023-06-06 15:36 [PATCH 1/3] soc/tegra: pmc: Use debugfs_initialized() Jon Hunter
                   ` (2 preceding siblings ...)
  2023-06-08 16:33 ` [PATCH 1/3] soc/tegra: pmc: Use debugfs_initialized() Thierry Reding
@ 2023-06-08 16:36 ` Thierry Reding
  3 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2023-06-08 16:36 UTC (permalink / raw)
  To: Thierry Reding, Jon Hunter
  Cc: linux-tegra, Petlozu Pravareshwar, Bharat Nihalani, Kartik

From: Thierry Reding <treding@nvidia.com>


On Tue, 06 Jun 2023 16:36:06 +0100, Jon Hunter wrote:
> From: Bharat Nihalani <bnihalani@nvidia.com>
> 
> 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.
> 
> [...]

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: e180cf836433185d0674ade52f8db911d89f6422

Best regards,
-- 
Thierry Reding <treding@nvidia.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-06-08 16:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-06 15:36 [PATCH 1/3] soc/tegra: pmc: Use debugfs_initialized() Jon Hunter
2023-06-06 15:36 ` [PATCH 2/3] soc/tegra: pmc: Add AON SW Wake support for Tegra234 Jon Hunter
2023-06-06 15:36 ` [PATCH 3/3] soc/tegra: fuse: Fix Tegra234 fuse size Jon Hunter
2023-06-08 16:33 ` [PATCH 1/3] soc/tegra: pmc: Use debugfs_initialized() Thierry Reding
2023-06-08 16:36 ` (subset) " Thierry Reding

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.