From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E9E7C4361B for ; Thu, 17 Dec 2020 18:26:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 51EC32389F for ; Thu, 17 Dec 2020 18:26:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730044AbgLQS0O (ORCPT ); Thu, 17 Dec 2020 13:26:14 -0500 Received: from smtprelay0196.hostedemail.com ([216.40.44.196]:59408 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727368AbgLQS0N (ORCPT ); Thu, 17 Dec 2020 13:26:13 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id 0D1FF182CF668; Thu, 17 Dec 2020 18:25:32 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: scene95_61178ef27436 X-Filterd-Recvd-Size: 4105 Received: from XPS-9350.home (unknown [47.151.137.21]) (Authenticated sender: joe@perches.com) by omf06.hostedemail.com (Postfix) with ESMTPA; Thu, 17 Dec 2020 18:25:30 +0000 (UTC) Message-ID: Subject: Re: New objtool warning.. From: Joe Perches To: Linus Torvalds , Josh Poimboeuf , Lyude Paul , Ilia Mirkin Cc: Peter Zijlstra , Linux Kernel Mailing List Date: Thu, 17 Dec 2020 10:25:29 -0800 In-Reply-To: References: <20201216044918.jdmi32dz75uboybv@treble> <20201216200158.akf356yrw44o2rlb@treble> <20201217104556.GT3040@hirez.programming.kicks-ass.net> <20201217162524.fkxiemn7aezpv7d5@treble> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2020-12-17 at 09:27 -0800, Linus Torvalds wrote: > On Thu, Dec 17, 2020 at 8:25 AM Josh Poimboeuf wrote: > > > > Oh yeah, I forgot about that. That would be another option if my patch > > doesn't work out. > > Well, one option is to just say "ok, we know gcc generates horrible > code that falls through to another function in a situation that we > claim is unreachable, so let's not claim it is unreachable". > > IOW, the problem here is that the compiler fundamentally isn't smart > enough to see that something is unreachable, and the "unreachable()" > annotation we did didn't actually really cause any code that makes it > so. So we basically have code that _if_ we ever change it, it will > simply be wrong, and we'll never see any warnings about it but it will > fall through to nonsensical code. > > So maybe the option here is simply "objtool was right before, the > unreachable() is fragile and wrong". > > We can easily write that case statement in a way that actually makes > the compiler generate better code and avoids the issue by just making > case 0x00 also be the default case. > > So I think I'll just apply this patch instead. Using default somewhere other than the bottom of a switch/case block isn't common/pretty. It's easy to visually skip/glaze over. Perhaps reorder the block. Maybe add static to the const arrays too. --- drivers/gpu/drm/drm_edid.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 74f5a3197214..53b7bb281edb 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3089,8 +3089,8 @@ static int drm_cvt_modes(struct drm_connector *connector, struct drm_display_mode *newmode; struct drm_device *dev = connector->dev; struct cvt_timing *cvt; - const int rates[] = { 60, 85, 75, 60, 50 }; - const u8 empty[3] = { 0, 0, 0 }; + static const int rates[] = { 60, 85, 75, 60, 50 }; + static const u8 empty[3] = { 0, 0, 0 }; for (i = 0; i < 4; i++) { int width, height; @@ -3102,20 +3102,18 @@ static int drm_cvt_modes(struct drm_connector *connector, height = (cvt->code[0] + ((cvt->code[1] & 0xf0) << 4) + 1) * 2; switch (cvt->code[1] & 0x0c) { - case 0x00: - width = height * 4 / 3; - break; - case 0x04: - width = height * 16 / 9; + case 0x0c: + width = height * 15 / 9; break; case 0x08: width = height * 16 / 10; break; - case 0x0c: - width = height * 15 / 9; + case 0x04: + width = height * 16 / 9; break; default: - unreachable(); + width = height * 4 / 3; + break; } for (j = 1; j < 5; j++) {