From patchwork Fri Feb 17 10:17:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lis, Tomasz" X-Patchwork-Id: 9579519 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 DB22E6049F for ; Fri, 17 Feb 2017 10:17:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C80FB28334 for ; Fri, 17 Feb 2017 10:17:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC9FE283A6; Fri, 17 Feb 2017 10:17:55 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 6FFDF28334 for ; Fri, 17 Feb 2017 10:17:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 833CE6E023; Fri, 17 Feb 2017 10:17:53 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id F33826E023 for ; Fri, 17 Feb 2017 10:17:51 +0000 (UTC) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Feb 2017 02:17:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,171,1484035200"; d="scan'208";a="66362421" Received: from gklab-178-192.igk.intel.com (HELO szara.igk.intel.com) ([172.28.178.192]) by fmsmga005.fm.intel.com with ESMTP; 17 Feb 2017 02:17:47 -0800 From: Tomasz Lis To: intel-gfx@lists.freedesktop.org Date: Fri, 17 Feb 2017 11:17:45 +0100 Message-Id: <1487326666-15789-1-git-send-email-tomasz.lis@intel.com> X-Mailer: git-send-email 2.7.4 Cc: Rodrigo Vivi Subject: [Intel-gfx] [PATCH] drm/fb: Proper support of boundary conditions in bitmasks. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP The recently introduced patch changed behavior of masks when the bit number is negative. Instead of no bits set, the new way makes all bits set. Problematic patch: drm/i915: Avoid BIT(max) - 1 and use GENMASK(max - 1, 0) This behaviour was not considered when making changes, and boundary value of count (=0) is now resulting in a mask with all bits on, since the value is directly decreased and therefore negative. Checking if all bits are set leads to infinite loop. This patch introduces an additional check to avoid empty masks. It reverts the control flow to the exact same way it worked before the problematic patch. Signed-off-by: Tomasz Lis Reviewed-by: Arkadiusz Hiler Reviewed-by: Joonas Lahtinen --- drivers/gpu/drm/i915/intel_fbdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c index e6f3eb2d..bc65ecf 100644 --- a/drivers/gpu/drm/i915/intel_fbdev.c +++ b/drivers/gpu/drm/i915/intel_fbdev.c @@ -496,7 +496,7 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper, conn_configured |= BIT(i); } - if ((conn_configured & mask) != mask) { + if (count > 0 && (conn_configured & mask) != mask) { pass++; goto retry; }