loongarch.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Xi Ruoyao <xry111@xry111.site>
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, 2 Apr 2026 08:39:13 +0200	[thread overview]
Message-ID: <b484cc9e-3582-41bf-bf5e-0a432e74a8f4@t-8ch.de> (raw)
In-Reply-To: <20260402044732.164294-2-xry111@xry111.site>

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.

> +		"beqz\t%[tmp], 1b"
> +		: [mem] "=ZB" (mem), [tmp] "=&r" (tmp)
> +		: [one] "r" (1));
> +
> +	if (mem.word[1] != 1) {
> +		pr_warn_once("Warning: sc.q is erratic on this platform, disabling for both kernel and HWCAP. Please try a firmware update.");
> +		return false;
> +	}
> +
> +	return true;
> +}

  parent reply	other threads:[~2026-04-02  6:39 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 [this message]
2026-04-02  8:05   ` Xi Ruoyao
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=b484cc9e-3582-41bf-bf5e-0a432e74a8f4@t-8ch.de \
    --to=linux@weissschuh.net \
    --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=liushuyu@aosc.io \
    --cc=liyawei@loongson.cn \
    --cc=loongarch@lists.linux.dev \
    --cc=xry111@xry111.site \
    /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).