From: Tony Rodriguez <unixpro1970@gmail.com>
To: davem@davemloft.net, sparclinux@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, andreas@gaisler.com,
tglx@kernel.org, thomas.weissschuh@linutronix.de,
regressions@lists.linux.dev, glaubitz@physik.fu-berlin.de,
linux@leemhuis.info, torvalds@linux-foundation.org,
Tony Rodriguez <unixpro1970@gmail.com>
Subject: [PATCH 1/1] sparc64: Fix tick/stick comparator equal-compare hazard
Date: Mon, 18 May 2026 16:56:03 -0700 [thread overview]
Message-ID: <20260518235632.5122-2-unixpro1970@gmail.com> (raw)
In-Reply-To: <20260518235632.5122-1-unixpro1970@gmail.com>
On SPARC64 the timer interrupt is generated only when the counter
equals the comparator (tick == tick_cmpr). There is a latency between
writing the comparator register and the comparator becoming active.
If the counter reaches the comparator value before the comparator is
armed, the equality moment can be missed and the hardware may not
generate the interrupt.
Previously the helper treated equality as success:
return ((long)(new_tick - (orig_tick + adj))) > 0L;
Here `exp` is the expected comparator value (orig_tick + adj). If
new_tick == exp the code considered the event scheduled, but the
hardware may already have missed the equality window. Treat equality
as failure so the caller will retry with a later expiration:
return ((long)(new_tick - (orig_tick + adj))) >= 0L;
This prevents missed timer interrupts and stalled hrtimers on affected
SPARC64 systems.
Signed-off-by: Tony Rodriguez <unixpro1970@gmail.com>
---
arch/sparc/kernel/time_64.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/sparc/kernel/time_64.c b/arch/sparc/kernel/time_64.c
index 87b267043ccd..783b60e547c4 100644
--- a/arch/sparc/kernel/time_64.c
+++ b/arch/sparc/kernel/time_64.c
@@ -146,7 +146,7 @@ static int tick_add_compare(unsigned long adj)
: "=r" (new_tick));
new_tick &= ~TICKCMP_IRQ_BIT;
- return ((long)(new_tick - (orig_tick+adj))) > 0L;
+ return ((long)(new_tick - (orig_tick+adj))) >= 0L;
}
static unsigned long tick_add_tick(unsigned long adj)
@@ -277,7 +277,7 @@ static int stick_add_compare(unsigned long adj)
: "=r" (new_tick));
new_tick &= ~TICKCMP_IRQ_BIT;
- return ((long)(new_tick - (orig_tick+adj))) > 0L;
+ return ((long)(new_tick - (orig_tick+adj))) >= 0L;
}
static unsigned long stick_get_frequency(void)
@@ -411,7 +411,7 @@ static int hbtick_add_compare(unsigned long adj)
val2 = __hbird_read_stick() & ~TICKCMP_IRQ_BIT;
- return ((long)(val2 - val)) > 0L;
+ return ((long)(val2 - val)) >= 0L;
}
static unsigned long hbtick_get_frequency(void)
--
2.53.0
next prev parent reply other threads:[~2026-05-18 23:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 23:56 [PATCH 0/1] " Tony Rodriguez
2026-05-18 23:56 ` Tony Rodriguez [this message]
2026-05-19 2:39 ` [PATCH 1/1] " Tony Rodriguez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260518235632.5122-2-unixpro1970@gmail.com \
--to=unixpro1970@gmail.com \
--cc=andreas@gaisler.com \
--cc=davem@davemloft.net \
--cc=glaubitz@physik.fu-berlin.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@leemhuis.info \
--cc=regressions@lists.linux.dev \
--cc=sparclinux@vger.kernel.org \
--cc=tglx@kernel.org \
--cc=thomas.weissschuh@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®