[v2,2/2] clocksource/drivers/timer-tegra186: fix watchdog self-pinging.

Message ID 20240216210258.24855-3-pohsuns@nvidia.com
State New
Headers
Series clocksource: fix Tegra234 SoC Watchdog Timer. |

Commit Message

Pohsun Su Feb. 16, 2024, 9:02 p.m. UTC
  This change removes watchdog self-pinging behavior.

The timer irq handler is triggered due to the 1st expiration,
the handler disables and enables watchdog but also implicitly
clears the expiration count so the count can only be 0 or 1.

Since this watchdog supports opened, configured, or pinged by
systemd, We remove this behavior or the watchdog may not bark
when systemd crashes since the 5th expiration never comes.

Signed-off-by: Pohsun Su <pohsuns@nvidia.com>
---
 drivers/clocksource/timer-tegra186.c | 27 ++-------------------------
 1 file changed, 2 insertions(+), 25 deletions(-)
  

Comments

Thierry Reding Feb. 19, 2024, 4:17 p.m. UTC | #1
On Fri Feb 16, 2024 at 10:02 PM CET, Pohsun Su wrote:
> This change removes watchdog self-pinging behavior.
>
> The timer irq handler is triggered due to the 1st expiration,
> the handler disables and enables watchdog but also implicitly
> clears the expiration count so the count can only be 0 or 1.
>
> Since this watchdog supports opened, configured, or pinged by
> systemd, We remove this behavior or the watchdog may not bark
> when systemd crashes since the 5th expiration never comes.
>
> Signed-off-by: Pohsun Su <pohsuns@nvidia.com>
> ---
>  drivers/clocksource/timer-tegra186.c | 27 ++-------------------------
>  1 file changed, 2 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/clocksource/timer-tegra186.c b/drivers/clocksource/timer-tegra186.c
> index 8f516366da86..acff97da138a 100644
> --- a/drivers/clocksource/timer-tegra186.c
> +++ b/drivers/clocksource/timer-tegra186.c
> @@ -175,7 +175,8 @@ static void tegra186_wdt_enable(struct tegra186_wdt *wdt)
>  		value |= WDTCR_PERIOD(1);
>  
>  		/* enable local interrupt for WDT petting */
> -		value |= WDTCR_LOCAL_INT_ENABLE;
> +		if (0)
> +			value |= WDTCR_LOCAL_INT_ENABLE;

We probably shouldn't proliferate this scheme. In retrospect I should've
removed the two other similar blocks back when I submitted the driver at
the time since they don't really serve a purpose. The intention at the
time was to keep them there and eventually replace the condition with
something that could actually be toggled, but it's been almost four
years and this hasn't happened, so I suspect that we just don't need it
at all. So perhaps you could remove this line along with the comment in
this patch and then add another patch that removes the other unused bits
so that we don't carry around stuff that we just never use.

Thierry
  
Pohsun Su Feb. 23, 2024, 11:42 p.m. UTC | #2
> On Fri Feb 16, 2024 at 10:02 PM CET, Pohsun Su wrote:
>> This change removes watchdog self-pinging behavior.
>>
>> The timer irq handler is triggered due to the 1st expiration,
>> the handler disables and enables watchdog but also implicitly
>> clears the expiration count so the count can only be 0 or 1.
>>
>> Since this watchdog supports opened, configured, or pinged by
>> systemd, We remove this behavior or the watchdog may not bark
>> when systemd crashes since the 5th expiration never comes.
>>
>> Signed-off-by: Pohsun Su <pohsuns@nvidia.com>
>> ---
>>  drivers/clocksource/timer-tegra186.c | 27 ++-------------------------
>>  1 file changed, 2 insertions(+), 25 deletions(-)
>>
>> diff --git a/drivers/clocksource/timer-tegra186.c b/drivers/clocksource/timer-tegra186.c
>> index 8f516366da86..acff97da138a 100644
>> --- a/drivers/clocksource/timer-tegra186.c
>> +++ b/drivers/clocksource/timer-tegra186.c
>> @@ -175,7 +175,8 @@ static void tegra186_wdt_enable(struct tegra186_wdt *wdt)
>>                value |= WDTCR_PERIOD(1);
>> 
>>                /* enable local interrupt for WDT petting */
>> -             value |= WDTCR_LOCAL_INT_ENABLE;
>> +             if (0)
>> +                     value |= WDTCR_LOCAL_INT_ENABLE;
>
> We probably shouldn't proliferate this scheme. In retrospect I should've
> removed the two other similar blocks back when I submitted the driver at
> the time since they don't really serve a purpose. The intention at the
> time was to keep them there and eventually replace the condition with
> something that could actually be toggled, but it's been almost four
> years and this hasn't happened, so I suspect that we just don't need it
> at all. So perhaps you could remove this line along with the comment in
> this patch and then add another patch that removes the other unused bits
> so that we don't carry around stuff that we just never use.
> 
> Thierry

Sure, removing both lines and the comment above.
will add another patch to clean unused bits.

Thanks!
--
Pohsun
  

Patch

diff --git a/drivers/clocksource/timer-tegra186.c b/drivers/clocksource/timer-tegra186.c
index 8f516366da86..acff97da138a 100644
--- a/drivers/clocksource/timer-tegra186.c
+++ b/drivers/clocksource/timer-tegra186.c
@@ -175,7 +175,8 @@  static void tegra186_wdt_enable(struct tegra186_wdt *wdt)
 		value |= WDTCR_PERIOD(1);
 
 		/* enable local interrupt for WDT petting */
-		value |= WDTCR_LOCAL_INT_ENABLE;
+		if (0)
+			value |= WDTCR_LOCAL_INT_ENABLE;
 
 		/* enable local FIQ and remote interrupt for debug dump */
 		if (0)
@@ -407,23 +408,10 @@  static int tegra186_timer_usec_init(struct tegra186_timer *tegra)
 	return clocksource_register_hz(&tegra->usec, USEC_PER_SEC);
 }
 
-static irqreturn_t tegra186_timer_irq(int irq, void *data)
-{
-	struct tegra186_timer *tegra = data;
-
-	if (watchdog_active(&tegra->wdt->base)) {
-		tegra186_wdt_disable(tegra->wdt);
-		tegra186_wdt_enable(tegra->wdt);
-	}
-
-	return IRQ_HANDLED;
-}
-
 static int tegra186_timer_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct tegra186_timer *tegra;
-	unsigned int irq;
 	int err;
 
 	tegra = devm_kzalloc(dev, sizeof(*tegra), GFP_KERNEL);
@@ -442,8 +430,6 @@  static int tegra186_timer_probe(struct platform_device *pdev)
 	if (err < 0)
 		return err;
 
-	irq = err;
-
 	/* create a watchdog using a preconfigured timer */
 	tegra->wdt = tegra186_wdt_create(tegra, 0);
 	if (IS_ERR(tegra->wdt)) {
@@ -470,17 +456,8 @@  static int tegra186_timer_probe(struct platform_device *pdev)
 		goto unregister_osc;
 	}
 
-	err = devm_request_irq(dev, irq, tegra186_timer_irq, 0,
-			       "tegra186-timer", tegra);
-	if (err < 0) {
-		dev_err(dev, "failed to request IRQ#%u: %d\n", irq, err);
-		goto unregister_usec;
-	}
-
 	return 0;
 
-unregister_usec:
-	clocksource_unregister(&tegra->usec);
 unregister_osc:
 	clocksource_unregister(&tegra->osc);
 unregister_tsc: