linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Maciej W. Rozycki" <macro@orcam.me.uk>
Cc: "Jiaxun Yang" <jiaxun.yang@flygoat.com>,
	linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Thomas Bogendoerfer" <tsbogend@alpha.franken.de>,
	Linux-Arch <linux-arch@vger.kernel.org>,
	"Baoquan He" <bhe@redhat.com>,
	"Huacai Chen" <chenhuacai@kernel.org>
Subject: Re: [PATCH v4] mips: add <asm-generic/io.h> including
Date: Sat, 20 May 2023 17:13:35 +0200	[thread overview]
Message-ID: <a98521a5-474a-44de-a95b-9a334b8f7fa4@app.fastmail.com> (raw)
In-Reply-To: <alpine.DEB.2.21.2305201531101.27887@angie.orcam.me.uk>

On Sat, May 20, 2023, at 16:45, Maciej W. Rozycki wrote:
> 	if (sizeof(type) != sizeof(u64) || sizeof(u64) == sizeof(long)) \
> 		*__mem = __val;						\
> 	else if (cpu_has_64bits) {					\
> 		unsigned long __flags;					\
> 		type __tmp;						\
> 									\
> 		if (irq)						\
> 			local_irq_save(__flags);			\
> 		__asm__ __volatile__(					\
> 			".set	push"		"\t\t# __writeq""\n\t"	\
> 			".set	arch=r4000"			"\n\t"	\
> 			"dsll32 %L0, %L0, 0"			"\n\t"	\
> 			"dsrl32 %L0, %L0, 0"			"\n\t"	\
> 			"dsll32 %M0, %M0, 0"			"\n\t"	\
> 			"or	%L0, %L0, %M0"			"\n\t"	\
> 			"sd	%L0, %2"			"\n\t"	\
> 			".set	pop"				"\n"	\
> 			: "=r" (__tmp)					\
> 			: "0" (__val), "m" (*__mem));			\
> 		if (irq)						\
> 			local_irq_restore(__flags);			\
> 	} else								\
> 		BUG();							\
>
> etc. so we don't actually lose atomicity, because we always use 64-bit 
> operations (SD above, store-doubleword) and we BUG if they are not there 
> (i.e. with 32-bit hardware; not a build-time check as in principle the 
> same 32-bit kernel image ought to run just fine both on 32-bit and 64-bit 
> hardware).  A few MIPS platforms do use them, e.g. SB1250, which requires 
> 64-bit unswapped accesses to SoC registers.

Ok, makes sense.

     Arnd

  reply	other threads:[~2023-05-20 15:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-19 19:51 [PATCH v4] mips: add <asm-generic/io.h> including Jiaxun Yang
2023-05-19 21:05 ` Arnd Bergmann
2023-05-19 21:41   ` Jiaxun Yang
2023-05-20 14:45   ` Maciej W. Rozycki
2023-05-20 15:13     ` Arnd Bergmann [this message]
2023-05-20  3:24 ` Baoquan He
2023-05-26  9:45 ` 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=a98521a5-474a-44de-a95b-9a334b8f7fa4@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=bhe@redhat.com \
    --cc=chenhuacai@kernel.org \
    --cc=jiaxun.yang@flygoat.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=macro@orcam.me.uk \
    --cc=tsbogend@alpha.franken.de \
    /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 NNTP newsgroup(s).