Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1023999rwr; Thu, 20 Apr 2023 09:02:58 -0700 (PDT) X-Google-Smtp-Source: AKy350ZeUrW7J9SEPZ/0MDONDCbAih9vo5iIygy3p4636iDi9egqqIti4Pli+qHWWgxF+Xdy8xJE X-Received: by 2002:a17:902:e807:b0:1a2:9051:f09e with SMTP id u7-20020a170902e80700b001a29051f09emr2568073plg.21.1682006578137; Thu, 20 Apr 2023 09:02:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682006578; cv=none; d=google.com; s=arc-20160816; b=b6tDLKFBwde6m5DhCK9LC2xIBBTFH9fV0eBSnncmh6m3nyLF/6T9j7pp/5okLy5P+H G3NEk3a343uYaihGBY7eB9WiDPBKcKvKdttpcv/yhEw48c/IXB/DAFZ1RfrtZWQiB5Rq dye7Abmf5qLmQNwmlIY1Rf20vKiHuLoiL+CDTGjqHm70f/xlfN1yz6ZlR7IOL/eBiLA0 1CL2JXpZB68bFtCcDjbXx2nzwPWMFXrBCkP/UBUgXbx7CouNdXSYB5rRdTE4RjsXQ55F dhah315XDKnRd0GeSZVk72MdOOkaz+zowkKq9j7Qhfyau60XIWhMyNP9+yUElo6olH4D orRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=mDAuAkMrRcu9FzvIHUS7jfDp/sgC9CK4O0dJISDMrX8=; b=1IX1sSP6YHLUqKLjVTYI/0A8G06FLEpMnmTfqHpp6zmaQ3IdQDTzOiFuSnlLWRsdIK hUjeoSAxr5VY2nOTR0dS0ExmujQNe3pAMsRJ3Pq4NPrAd0qbrL74e4N6Ug02ky3cjf8s WUM6pLBUZObtHxIOuPQxUa9hd++W15yqIFQFFFeDsSfNXUX5G0r7FWoeR+dB/SjQMCJW 7/WB+Z7t23hEh+NnfuZt04g2Is++rUzH4rX0kb7MRCDw4u+VcLlPZ1oEMcoVqArTMqVX tazCWaWvDhfN2ZLSPHVJej5TYl1lqtoFQDXZebOsfm7NMteJOoSA9rQ9mBxbp33BPrFv HooA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@panix.com header.s=panix header.b=HVK5R5D1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=panix.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q1-20020a170902dac100b001a92694cbd6si2182399plx.600.2023.04.20.09.02.15; Thu, 20 Apr 2023 09:02:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@panix.com header.s=panix header.b=HVK5R5D1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=panix.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232233AbjDTP5b (ORCPT + 99 others); Thu, 20 Apr 2023 11:57:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230491AbjDTP52 (ORCPT ); Thu, 20 Apr 2023 11:57:28 -0400 Received: from mailbackend.panix.com (mailbackend.panix.com [166.84.1.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 120A535BF for ; Thu, 20 Apr 2023 08:57:18 -0700 (PDT) Received: from localhost.localdomain (dynamic-acs-24-144-188-133.zoominternet.net [24.144.188.133]) by mailbackend.panix.com (Postfix) with ESMTPSA id 4Q2Mjm2J1Hz4DyN; Thu, 20 Apr 2023 11:57:16 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=panix.com; s=panix; t=1682006237; bh=1bK3beiIYMDkKAWr24JOp3R+9BScfdHQ8MGrq6E9XVU=; h=From:To:Cc:Subject:Date; b=HVK5R5D1YC85Uuj7e8cp2RBxrGJw1djsuQJX3r0PRcbWIhasbviD5bXG0h9y4D1ZF 25vS8oJMAqNsMELbrgWrc5guDsdyjqZs54W0YHR9WsbNbQiXcr9xnkUQqDq14aKBaS 9vXxafcHsX9ZOxC28p0G76LHpVcBb060D8HkhFwU= From: Pierre Asselin To: dri-devel@lists.freedesktop.org Cc: Pierre Asselin , Javier Martinez Canillas , Thomas Zimmermann , Daniel Vetter , Ard Biesheuvel , Hans de Goede , linux-kernel@vger.kernel.org Subject: [PATCH v3] firmware/sysfb: Fix VESA format selection Date: Thu, 20 Apr 2023 11:57:05 -0400 Message-Id: <20230420155705.21463-1-pa@panix.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some legacy BIOSes report no reserved bits in their 32-bit rgb mode, breaking the calculation of bits_per_pixel in commit f35cd3fa7729 ("firmware/sysfb: Fix EFI/VESA format selection"). However they report lfb_depth correctly for those modes. Keep the computation but set bits_per_pixel to lfb_depth if the latter is larger. v2 fixes the warnings from a max3() macro with arguments of different types; split the bits_per_pixel assignment to avoid uglyfing the code with too many casts. v3 fixes space and formatting blips pointed out by Javier, and change the bit_per_pixel assignment back to a single statement using two casts. Link: https://lore.kernel.org/r/4Psm6B6Lqkz1QXM@panix3.panix.com Link: https://lore.kernel.org/r/20230412150225.3757223-1-javierm@redhat.com Link: https://lore.kernel.org/dri-devel/20230418183325.2327-1-pa@panix.com/T/#u Link: https://lore.kernel.org/dri-devel/20230419044834.10816-1-pa@panix.com/T/#u Fixes: f35cd3fa7729 ("firmware/sysfb: Fix EFI/VESA format selection") Signed-off-by: Pierre Asselin --- drivers/firmware/sysfb_simplefb.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/firmware/sysfb_simplefb.c b/drivers/firmware/sysfb_simplefb.c index 82c64cb9f531..6f7c5d0c5090 100644 --- a/drivers/firmware/sysfb_simplefb.c +++ b/drivers/firmware/sysfb_simplefb.c @@ -51,15 +51,18 @@ __init bool sysfb_parse_mode(const struct screen_info *si, * * It's not easily possible to fix this in struct screen_info, * as this could break UAPI. The best solution is to compute - * bits_per_pixel here and ignore lfb_depth. In the loop below, + * bits_per_pixel from the color bits, reserved bits and + * reported lfb_depth, whichever is highest. In the loop below, * ignore simplefb formats with alpha bits, as EFI and VESA * don't specify alpha channels. */ if (si->lfb_depth > 8) { - bits_per_pixel = max(max3(si->red_size + si->red_pos, - si->green_size + si->green_pos, - si->blue_size + si->blue_pos), - si->rsvd_size + si->rsvd_pos); + /* max() macros args should be of the same type */ + bits_per_pixel = max3((u16)max3(si->red_size + si->red_pos, + si->green_size + si->green_pos, + si->blue_size + si->blue_pos), + (u16)(si->rsvd_size + si->rsvd_pos), + si->lfb_depth); } else { bits_per_pixel = si->lfb_depth; } base-commit: 6a8f57ae2eb07ab39a6f0ccad60c760743051026 -- 2.39.2