loongarch.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: Huacai Chen <chenhuacai@kernel.org>,
	WANG Xuerui <kernel@xen0n.name>,
	 loongarch@lists.linux.dev, Zixing Liu <liushuyu@aosc.io>,
	Mingcong Bai <jeffbai@aosc.io>,
	Jiaxun Yang <jiaxun.yang@flygoat.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Yangyang Lian <lianyangyang@kylinos.cn>,
	Yawei Li <liyawei@loongson.cn>,
	George Guo <dongtai.guo@linux.dev>,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH] LoongArch: detect and disable sc.q if erratic
Date: Thu, 02 Apr 2026 16:05:05 +0800	[thread overview]
Message-ID: <6c9662c0f45131d8aa607d6962cb4237d3c7f129.camel@xry111.site> (raw)
In-Reply-To: <b484cc9e-3582-41bf-bf5e-0a432e74a8f4@t-8ch.de>

On Thu, 2026-04-02 at 08:39 +0200, Thomas Weißschuh wrote:
> On 2026-04-02 12:47:30+0800, Xi Ruoyao wrote:
> 
> (...)
> 
> > +/*
> > + * Some LoongArch has broken sc.q which incorrectly handles the upper word
> > + * when the lower word is zero. Newer firmware versions (such as the 202602
> > + * release from Loongson) seem to contain a workaround for this issue.
> > + *
> > + * Disable sc.q if erratic to ensure reliability and compatibility.
> > + */
> > +static bool sc_q_is_sane(void)
> > +{
> > +	struct {
> > +		long word[2];
> > +	} __aligned(16) mem;
> > +	register long tmp;
> > +
> > +	asm (
> > +		"1:ll.d\t$r0, %[mem]\n\t"
> > +		"move\t%[tmp], $r0\n\t"
> > +		"sc.q\t%[tmp], %[one], %[mem]\n\t"
> 
> This probably needs to be gated behind CONFIG_AS_HAS_SCQ_EXTENSION to
> avoid errors on older toolchains.

I guess I'd code the insn with .word instead...

This also affects HWCAP, and I don't want the userspace to see neither a
false positive nor a false negative simply because the kernel was built
with an old toolchain.

-- 
Xi Ruoyao <xry111@xry111.site>

  reply	other threads:[~2026-04-02  8:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-02  4:47 [PATCH] LoongArch: detect and disable sc.q if erratic Xi Ruoyao
2026-04-02  5:10 ` Mingcong Bai
2026-04-02  6:39 ` Thomas Weißschuh
2026-04-02  8:05   ` Xi Ruoyao [this message]
2026-04-07 15:21 ` kernel test robot

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=6c9662c0f45131d8aa607d6962cb4237d3c7f129.camel@xry111.site \
    --to=xry111@xry111.site \
    --cc=arnd@arndb.de \
    --cc=chenhuacai@kernel.org \
    --cc=dongtai.guo@linux.dev \
    --cc=jeffbai@aosc.io \
    --cc=jiaxun.yang@flygoat.com \
    --cc=kernel@xen0n.name \
    --cc=lianyangyang@kylinos.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=liushuyu@aosc.io \
    --cc=liyawei@loongson.cn \
    --cc=loongarch@lists.linux.dev \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).