Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp61104pxa; Tue, 11 Aug 2020 17:20:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyncZr2ymwRVbECx05d31FnqV7+1QGvi+0UJpX8hMf37P5C0TwHrZEhB6rjpE5fHTfQsCLt X-Received: by 2002:aa7:da04:: with SMTP id r4mr27934892eds.265.1597191624396; Tue, 11 Aug 2020 17:20:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597191624; cv=none; d=google.com; s=arc-20160816; b=NkAWBy5ajBDA3jsyRkWxjszlySn6Rx90Q2uGimiTxnIR5Acp+xVwp+hjYZGeDCr/bz 2SCiethZc3kRYxQXcLhVDD5e4TRm3h8PCxPGKAcinp5WVWMuWD6lsYP0RkKiTMyVizgS 0Jtql3xSsSNpeC7oUgrnPnTtlaJDCwsT7U+anQ9ZxzCD1otPjfM4ldFiKPspzFBa9V76 9FbDXmSnJXKK13XaCZZjJfdN7sptR9IPPeES3VO8zy3CL1ganX3S1i69yOAkqb1qJyOz aecc4oyQYgjwshQux9frYwGEgT4j7JzwBaw3zhej/Eid6Y0wws0+pCQ9SViIq9SSpRTM TGQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7XO3v5AyYseHPAuYJbHPtlC6RLhhlxBPb915QBBXoYI=; b=CPf6dVNLY/UMd9R8zeFhpH6S7EHDN8T3c4++OVXklrky95zTerMurTNTpWIEIylO7z UJbpY+rq9ZzaNX4Qx84ES9rdgIlVO0p0YRsTvzicm3XIc29IGQha+LjZh5vU5pTv1zvu xPDTLbo8FR/phGv6sjV5iPS0WNy2uf3CsgLCyzaytmZDrv8xaZyYP2y9RswnizOSU8RN JTfC0DKK26A5vDglyRaM2+cxVNMqEuvIsSixs4KeGEZxd8gJhELzTHg7wXNyfPzCkpFi HpV3na4O/2FZvxH+or8Nh0hCc1XE+2fWC4CzIieRmS6DD4ZezTGbpdEaYCq+W08U7lSh 3cIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b=T1UJo69k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l21si109976ejq.594.2020.08.11.17.20.00; Tue, 11 Aug 2020 17:20:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b=T1UJo69k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726627AbgHLAPn (ORCPT + 99 others); Tue, 11 Aug 2020 20:15:43 -0400 Received: from crapouillou.net ([89.234.176.41]:52106 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726430AbgHLAPm (ORCPT ); Tue, 11 Aug 2020 20:15:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1597191321; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7XO3v5AyYseHPAuYJbHPtlC6RLhhlxBPb915QBBXoYI=; b=T1UJo69k6Tptfm1mvT//hUF9Rwt3NPqtzd+7pXyrJxIkmGLwOj2q51Rv2jTgeEGyc53v7U AWL2uapUkQD76a3COcDfBOluKxuW/E6NSf5RH+BLIoPaxyfnyb15E6IGV5NWW2gu2muKuI y30Ws/F74S03eoHn7mYpb+RlwYE+w1w= From: Paul Cercueil To: Thomas Bogendoerfer Cc: Paul Burton , Krzysztof Kozlowski , =?UTF-8?q?=E5=91=A8=E7=90=B0=E6=9D=B0?= , od@zcrc.me, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Paul Cercueil Subject: [PATCH v2 03/13] MIPS: cpu-probe: ingenic: Fix broken BUG_ON Date: Wed, 12 Aug 2020 02:15:00 +0200 Message-Id: <20200812001510.460382-4-paul@crapouillou.net> In-Reply-To: <20200812001510.460382-1-paul@crapouillou.net> References: <20200812001510.460382-1-paul@crapouillou.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 . 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 --- Notes: v2: No change 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.28.0