[PATCH 2/5] xtensa: drop platform_heartbeat

From: Max Filippov
Date: Thu Jun 08 2023 - 22:23:07 EST


platform_heartbeat is called from the timer interrupt handler, but
there may be no periodic timer interrupts on xtensa, so the frequency of
platform_heartbeat calls may be unrelated to HZ. Drop the callback and
reimplement its only user with a timer.

Signed-off-by: Max Filippov <jcmvbkbc@xxxxxxxxx>
---
arch/xtensa/include/asm/platform.h | 5 -----
arch/xtensa/kernel/platform.c | 1 -
arch/xtensa/kernel/time.c | 4 ----
arch/xtensa/platforms/xt2000/setup.c | 20 +++++++++++---------
4 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/arch/xtensa/include/asm/platform.h b/arch/xtensa/include/asm/platform.h
index 354ca942de40..3be6b4bf9763 100644
--- a/arch/xtensa/include/asm/platform.h
+++ b/arch/xtensa/include/asm/platform.h
@@ -47,11 +47,6 @@ extern void platform_power_off (void);
*/
extern void platform_idle (void);

-/*
- * platform_heartbeat is called every HZ
- */
-extern void platform_heartbeat (void);
-
/*
* platform_calibrate_ccount calibrates cpu clock freq (CONFIG_XTENSA_CALIBRATE)
*/
diff --git a/arch/xtensa/kernel/platform.c b/arch/xtensa/kernel/platform.c
index ac1e0e566995..bb4d426ebb44 100644
--- a/arch/xtensa/kernel/platform.c
+++ b/arch/xtensa/kernel/platform.c
@@ -32,7 +32,6 @@ _F(void, restart, (void), { while(1); });
_F(void, halt, (void), { while(1); });
_F(void, power_off, (void), { while(1); });
_F(void, idle, (void), { __asm__ __volatile__ ("waiti 0" ::: "memory"); });
-_F(void, heartbeat, (void), { });

#ifdef CONFIG_XTENSA_CALIBRATE_CCOUNT
_F(void, calibrate_ccount, (void),
diff --git a/arch/xtensa/kernel/time.c b/arch/xtensa/kernel/time.c
index 16b8a6273772..1c3dfea843ec 100644
--- a/arch/xtensa/kernel/time.c
+++ b/arch/xtensa/kernel/time.c
@@ -121,10 +121,6 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id)

set_linux_timer(get_linux_timer());
evt->event_handler(evt);
-
- /* Allow platform to do something useful (Wdog). */
- platform_heartbeat();
-
return IRQ_HANDLED;
}

diff --git a/arch/xtensa/platforms/xt2000/setup.c b/arch/xtensa/platforms/xt2000/setup.c
index 08bc9b0ede3e..dc187684203b 100644
--- a/arch/xtensa/platforms/xt2000/setup.c
+++ b/arch/xtensa/platforms/xt2000/setup.c
@@ -23,6 +23,7 @@
#include <linux/platform_device.h>
#include <linux/serial.h>
#include <linux/serial_8250.h>
+#include <linux/timer.h>

#include <asm/processor.h>
#include <asm/platform.h>
@@ -70,16 +71,17 @@ void __init platform_setup(char** cmdline)

/* Heartbeat. Let the LED blink. */

-void platform_heartbeat(void)
+static void xt2000_heartbeat(struct timer_list *unused);
+
+static DEFINE_TIMER(heartbeat_timer, xt2000_heartbeat);
+
+static void xt2000_heartbeat(struct timer_list *unused)
{
- static int i, t;
+ static int i;

- if (--t < 0)
- {
- t = 59;
- led_print(7, i ? ".": " ");
- i ^= 1;
- }
+ led_print(7, i ? "." : " ");
+ i ^= 1;
+ mod_timer(&heartbeat_timer, jiffies + HZ / 2);
}

//#define RS_TABLE_SIZE 2
@@ -137,7 +139,7 @@ static int __init xt2000_setup_devinit(void)
{
platform_device_register(&xt2000_serial8250_device);
platform_device_register(&xt2000_sonic_device);
-
+ mod_timer(&heartbeat_timer, jiffies + HZ / 2);
return 0;
}

--
2.30.2