Linux-MIPS Archive on
 help / color / Atom feed
From: Serge Semin <>
To: Ralf Baechle <>,
	Paul Burton <>,
	James Hogan <>
Cc: Serge Semin <>,
	Arnd Bergmann <>,
	"Vadim V . Vlasov" <>,,
Subject: [PATCH] mips: Remove q-accessors from non-64bit platforms
Date: Fri, 14 Jun 2019 09:33:42 +0300
Message-ID: <> (raw)

There are some generic drivers in the kernel, which make use of the
q-accessors or their derivatives. While at current asm/io.h the accessors
are defined, their implementation is only applicable either for 64bit
systems, or for systems with cpu_has_64bits flag set. Obviously there
are MIPS systems which are neither of these, but still need to have
those drivers supported. In this case the solution is to define some
generic versions of the q-accessors, but with a limitation to be
non-atomic. Such accessors are defined in the
io-64-nonatomic-{hi-lo,lo-hi}.h file. The drivers which utilize the
q-suffixed IO-methods are supposed to include the header file, so
in case if these accessors aren't defined for the platform, the generic
non-atomic versions are utilized. Currently the MIPS-specific asm/io.h
file provides the q-accessors for any MIPS system even for ones, which
in fact don't support them and raise BUG() in case if any of them is
called. Due to this the generic versions of the accessors are never
used while an attempt to call the IO-methods causes the kernel BUG().
In order to fix this we need to define the q-accessors only for
the MIPS systems, which actually support them, and don't define them
otherwise, so to let the corresponding drivers to use the non-atomic
q-suffixed accessors.

Signed-off-by: Serge Semin <>
Suggested-by: Arnd Bergmann <>
Cc: Vadim V. Vlasov <>
 arch/mips/include/asm/io.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index 29997e42480e..4597017f147b 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -462,7 +462,12 @@ __BUILD_MEMORY_PFX(, bwlq, type, 0)
 BUILDIO_MEM(w, u16)
 BUILDIO_MEM(l, u32)
+#ifdef CONFIG_64BIT
 BUILDIO_MEM(q, u64)
+__BUILD_MEMORY_PFX(__raw_, q, u64, 0)
+__BUILD_MEMORY_PFX(__mem_, q, u64, 0)
 #define __BUILD_IOPORT_PFX(bus, bwlq, type)				\
 	__BUILD_IOPORT_SINGLE(bus, bwlq, type, 1, 0,)			\
@@ -488,12 +493,16 @@ __BUILDIO(q, u64)
 #define readb_relaxed			__relaxed_readb
 #define readw_relaxed			__relaxed_readw
 #define readl_relaxed			__relaxed_readl
+#ifdef CONFIG_64BIT
 #define readq_relaxed			__relaxed_readq
 #define writeb_relaxed			__relaxed_writeb
 #define writew_relaxed			__relaxed_writew
 #define writel_relaxed			__relaxed_writel
+#ifdef CONFIG_64BIT
 #define writeq_relaxed			__relaxed_writeq
 #define readb_be(addr)							\
 	__raw_readb((__force unsigned *)(addr))
@@ -516,8 +525,10 @@ __BUILDIO(q, u64)
  * Some code tests for these symbols
+#ifdef CONFIG_64BIT
 #define readq				readq
 #define writeq				writeq
 #define __BUILD_MEMORY_STRING(bwlq, type)				\

             reply index

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-14  6:33 Serge Semin [this message]
2019-06-20 17:40 ` Paul Burton
2019-06-20 18:19   ` Maciej W. Rozycki
2019-06-21  9:25     ` Arnd Bergmann
2019-06-21 10:09       ` Maciej W. Rozycki
2019-06-21 11:09         ` Arnd Bergmann
2019-06-21 12:24           ` Maciej W. Rozycki
2019-06-21 14:01             ` Arnd Bergmann
2019-06-24 19:13               ` Maciej W. Rozycki
2019-06-21  6:06   ` Serge Semin
2019-06-24 21:16 ` Paul Burton

Reply instructions:

You may reply publically 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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-MIPS Archive on

Archives are clonable:
	git clone --mirror linux-mips/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mips linux-mips/ \
	public-inbox-index linux-mips

Newsgroup available over NNTP:

AGPL code for this site: git clone public-inbox