From patchwork Tue Jan 16 22:00:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10168235 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 883C0600CA for ; Tue, 16 Jan 2018 22:00:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 713A42766D for ; Tue, 16 Jan 2018 22:00:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6632827C0B; Tue, 16 Jan 2018 22:00:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 685CE2766D for ; Tue, 16 Jan 2018 22:00:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E4E6A89E14; Tue, 16 Jan 2018 22:00:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yb0-x243.google.com (mail-yb0-x243.google.com [IPv6:2607:f8b0:4002:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id CB88589E14 for ; Tue, 16 Jan 2018 22:00:34 +0000 (UTC) Received: by mail-yb0-x243.google.com with SMTP id u35so1700849ybi.1 for ; Tue, 16 Jan 2018 14:00:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=EQMiYngxHxyouBepWvGKrbKgKKjsg9M6RdQneT/ES6U=; b=ISyb9a8q4SVhqesKf/tPkPUNiJqUgAsvKDfQZHRWdmKhBmZ/PznzUpdTiwd22UFWeH H8MM9AEwzBLVv1ojPXzntu5UgJd6B4B5y6tBv03GlR9z+hhpNx9R1aZyxR1GlgHvfGZ+ dnTU22rT1WsaGhm+6inzS9wlE7eLQjaVcOT8M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=EQMiYngxHxyouBepWvGKrbKgKKjsg9M6RdQneT/ES6U=; b=Jp8UH5PuPHtNbeW1kE61yoz/d+sbyjnAPK/bgPLRRW/XY/8npYmrX+IMb1DB+Wu+y4 J4qbs4x1y2QI5vAn0Tr+utvBjRKYg+oArOvvThBfz11VC/aJuHh4BxHEQsIcOouKsGH6 NRH81HfDS0xGEkXHRWGAy1lFgnHdqkZUL2eiIZWnkFYwJoFz/xBpxPcSYvmnWcW3mGRJ MxLeNL/oac9IEN1557bcknnthOzslpt/eXGTRxmLlrPG5nR7wxvJlk48SbZTGq3wgbEE Qq3LfNedSlLpKVCN4fs+jJ787f4p/gDLARTNd9MclgwDfdsMbztCAXxsg6c3Pc8ULuLU 9MWQ== X-Gm-Message-State: AKwxytcpEaii/A/Ei/LW4d2/5WsRDwH2TcXyA4ew5qsnvL6HltRuJCOr ZoyCqE3BT/KxV3Qdayu5/taHJA== X-Google-Smtp-Source: ACJfBovAp8+zuFmU6zsFziZCTEjTcm9+CGySr8SL+SoceTrgduonVxg8PSr6yldSySq8/lDwUnR54w== X-Received: by 10.37.133.134 with SMTP id x6mr10945980ybk.283.1516140033808; Tue, 16 Jan 2018 14:00:33 -0800 (PST) Received: from localhost ([2620:0:1013:11:d3af:69ac:1964:28e8]) by smtp.gmail.com with ESMTPSA id l126sm1235154ywb.25.2018.01.16.14.00.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jan 2018 14:00:33 -0800 (PST) Date: Tue, 16 Jan 2018 17:00:32 -0500 From: Sean Paul To: Daniel Vetter Subject: Re: [PATCH] drm/fb-helper: Fix of-by-one in setcmap_pseudo_palette Message-ID: <20180116220032.ceu2lay3jfsjncj4@art_vandelay> References: <20180112094834.26310-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Cc: Peter Rosin , David Airlie , Michel =?iso-8859-1?Q?D=E4nzer?= , DRI Development , stable , Daniel Vetter , Bill Fraser , Deposite Pirate X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Fri, Jan 12, 2018 at 10:08:49PM +0100, Daniel Vetter wrote: > On Fri, Jan 12, 2018 at 3:08 PM, Sean Paul wrote: > > On Fri, Jan 12, 2018 at 4:48 AM, Daniel Vetter wrote: > >> [Fair warning: This is pure conjecture right now.] > >> > >> In > >> > >> commit b8e2b0199cc377617dc238f5106352c06dcd3fa2 > >> Author: Peter Rosin > >> Date: Tue Jul 4 12:36:57 2017 +0200 > >> > >> drm/fb-helper: factor out pseudo-palette > >> > >> Peter extracted the pseudo palette computation, but seems to have done > >> an off-by-one. I spotted that +1, but then noticed that we've passed > >> start++ to (now gone) setcolreg function, so it seemed to all match > >> up. Except post vs. pre-increment ftw. > >> > >> Result is that the palette is off-by-one, and the forground color > >> (slot 0) ends up black, rendering a fairly unreadable console. > >> > >> What baffles me is that on some systems it still seems to work > >> somehow, which lead us all down a wild goose chase trying to add > >> load_lut calls back in in various places (which was also intentionally > >> removed, but really doesn't seem to be the real root cause). > >> > >> Fixes: b8e2b0199cc3 ("drm/fb-helper: factor out pseudo-palette") > >> Cc: Peter Rosin > >> Cc: Daniel Vetter > >> Cc: Daniel Vetter > >> Cc: Gustavo Padovan > >> Cc: Sean Paul > >> Cc: David Airlie > >> Cc: dri-devel@lists.freedesktop.org > >> Cc: # v4.14+ > >> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=198123 > >> Reported-by: Deposite Pirate > >> Reported-by: Bill Fraser > >> Cc: Deposite Pirate > >> Cc: Bill Fraser > >> Cc: Michel Dänzer > >> Signed-off-by: Daniel Vetter > >> --- > >> drivers/gpu/drm/drm_fb_helper.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c > >> index 035784ddd133..1c3a200c4a10 100644 > >> --- a/drivers/gpu/drm/drm_fb_helper.c > >> +++ b/drivers/gpu/drm/drm_fb_helper.c > >> @@ -1295,7 +1295,7 @@ static int setcmap_pseudo_palette(struct fb_cmap *cmap, struct fb_info *info) > >> mask <<= info->var.transp.offset; > >> value |= mask; > >> } > >> - palette[cmap->start + i] = value; > >> + palette[cmap->start] = value; > > > > I don't think this is equivalent to what was there before. Before > > there we set palette[cmap->start]->palette[cmap->start + cmap->len - > > 1], now we're only setting palette[cmap->start]. > > > > In the previous version (before Peter's change), we wrote > > palette[cmap->start] twice. So while there is an off-by-one bug, I > > don't think this fixes the issue. > > Well this patch is complete nonsense, no idea what I was thinking ... [Sending this out since it's in my tree and I'll forget soon] Equivalent behavior would be: > -Daniel > -- > Daniel Vetter > Software Engineer, Intel Corporation > +41 (0) 79 365 57 48 - http://blog.ffwll.ch diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 035784ddd133..df6709768723 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -1295,7 +1295,8 @@ static int setcmap_pseudo_palette(struct fb_cmap *cmap, struct fb_info *info) mask <<= info->var.transp.offset; value |= mask; } - palette[cmap->start + i] = value; + if (i > 0) + palette[cmap->start + i - 1] = value; } return 0;