All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Cercueil <paul@crapouillou.net>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: "Paul Burton" <paulburton@kernel.org>,
	"Krzysztof Kozlowski" <krzk@kernel.org>,
	周琰杰 <zhouyanjie@wanyeetech.com>,
	od@zcrc.me, linux-kernel@vger.kernel.org,
	linux-mips@vger.kernel.org,
	"Paul Cercueil" <paul@crapouillou.net>
Subject: [PATCH 03/13] MIPS: cpu-probe: ingenic: Fix broken BUG_ON
Date: Mon,  3 Aug 2020 19:01:14 +0200	[thread overview]
Message-ID: <20200803170124.231110-4-paul@crapouillou.net> (raw)
In-Reply-To: <20200803170124.231110-1-paul@crapouillou.net>

The previous code was doing:
BUG_ON(!__builtin_constant_p(cpu_has_counter) || cpu_has_counter);

This only worked as the "cpu_has_counter" macro was overridden in
<cpu-feature-overrides.h>. The default "cpu_has_counter" macro is
non-constant, which triggered the BUG_ON() independently of the value
returned by the macro.

What we want to check here, is that *if* the macro was overridden to a
compile-time constant, then must be defined to zero, otherwise it's a
bug.

So the correct check is:
BUG_ON(__builtin_constant_p(cpu_has_counter) && cpu_has_counter);

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 arch/mips/kernel/cpu-probe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index a07e66a6e063..6be23f205e74 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -2123,7 +2123,7 @@ static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
 
 	/* XBurst does not implement the CP0 counter. */
 	c->options &= ~MIPS_CPU_COUNTER;
-	BUG_ON(!__builtin_constant_p(cpu_has_counter) || cpu_has_counter);
+	BUG_ON(__builtin_constant_p(cpu_has_counter) && cpu_has_counter);
 
 	/* XBurst has virtually tagged icache */
 	c->icache.flags |= MIPS_CACHE_VTAG;
-- 
2.27.0


  parent reply	other threads:[~2020-08-03 17:02 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-03 17:01 [PATCH 00/13] MIPS: Convert Ingenic to a generic board Paul Cercueil
2020-08-03 17:01 ` [PATCH 01/13] MIPS: cpu-probe: Set Ingenic's writecombine to _CACHE_CACHABLE_WA Paul Cercueil
2020-08-03 17:01 ` [PATCH 02/13] MIPS: cpu-probe: Mark XBurst CPU as having vtagged caches Paul Cercueil
2020-08-03 17:01 ` Paul Cercueil [this message]
2020-08-03 17:01 ` [PATCH 04/13] MIPS: Kconfig: add MIPS_GENERIC_KERNEL symbol Paul Cercueil
2020-08-03 17:01 ` [PATCH 05/13] MIPS: machine: Add get_system_type callback Paul Cercueil
2020-08-03 17:01 ` [PATCH 06/13] MIPS: generic: Call the machine's .get_system_type callback if provided Paul Cercueil
2020-08-11 12:43   ` Paul Cercueil
2020-08-03 17:01 ` [PATCH 07/13] MIPS: generic: Support booting with built-in or appended DTB Paul Cercueil
2020-08-03 17:01 ` [PATCH 08/13] MIPS: generic: Add support for zboot Paul Cercueil
2020-08-03 17:01 ` [PATCH 09/13] MIPS: generic: Increase NR_IRQS to 256 Paul Cercueil
2020-08-03 17:01 ` [PATCH 10/13] MIPS: generic: Add support for Ingenic SoCs Paul Cercueil
2020-08-03 17:01 ` [PATCH 11/13] MIPS: jz4740: Drop folder Paul Cercueil
2020-08-03 17:01 ` [PATCH 12/13] MIPS: configs: Regenerate configs of Ingenic boards Paul Cercueil
2020-08-03 17:01 ` [PATCH 13/13] MAINTAINERS: Update paths to Ingenic platform code Paul Cercueil
2020-08-07 17:22   ` Zhou Yanjie
2020-08-07 17:43     ` Zhou Yanjie
2020-08-07 16:23 ` [PATCH 00/13] MIPS: Convert Ingenic to a generic board Zhou Yanjie
2020-08-07 16:45   ` Paul Cercueil
2020-08-07 17:20     ` Zhou Yanjie
2020-08-08  2:39     ` Jiaxun Yang
2020-08-21 19:23     ` Maciej W. Rozycki
2020-08-21 23:19       ` Paul Cercueil
2020-08-22  2:29         ` Maciej W. Rozycki
2020-08-22 13:17           ` Paul Cercueil
2020-08-22 14:00             ` Maciej W. Rozycki
2020-10-26 14:25           ` Zhou Yanjie

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=20200803170124.231110-4-paul@crapouillou.net \
    --to=paul@crapouillou.net \
    --cc=krzk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=od@zcrc.me \
    --cc=paulburton@kernel.org \
    --cc=tsbogend@alpha.franken.de \
    --cc=zhouyanjie@wanyeetech.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.