Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2929438rwb; Mon, 15 Aug 2022 14:15:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR709xFP1c9HeGnCsEK1SzGZaGZpokQ3h4xt+WmHbmkS5gevjO1DyE8ysJShNswhVHYzUlsc X-Received: by 2002:a17:907:8a09:b0:731:610:ff8d with SMTP id sc9-20020a1709078a0900b007310610ff8dmr11447247ejc.399.1660598110185; Mon, 15 Aug 2022 14:15:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660598110; cv=none; d=google.com; s=arc-20160816; b=wYz+EbwynWv0brc/IWuLV9RKDHZP7qKOywbdmVCQ0v68LEKCu2Xb+DsTvxb6tJocrg n/igtWa1kWFQOKAeAEcrJRG/TKG24LjLCmOAAOAxBhEJydBhVjJPbjh3rBpD7JC423Gh tIcBNzg6G0qUKxNJoYR5OHuV8Hxl2MzGDLv39RhYpV3BRmkymiAoie58ph9a1QclEaIu UiiE+KVBUpKGcIq4TlzTq7rzvdHJ0wbxakMj7DSOdexee8qdxlN8j79YexKUixL1Vx6a CQ5d0nEhT3aF2cw/fBswgVd2fuaUDYn+K5+h9C0/bf3evpT7tejafg9E8spgg4FVShDD qdDA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1WWshXhyJeBaXizbBedPsm7DnpJ8e3199qNT0m5Ij4Q=; b=sxK4q89TZCP/gRtvFQpEsQga1AOdTb2jraN/zEx2PWAp+zp8sLUiKzDavTG2SCLngf oBmWrS1bBxnwrtpzIFjlVlgvxa/JF/LaKJ8Is3gGfzxF7LeCx31Hk4ivuBTP3CoJIpqg 1UiNe9lHlYuBOYr4r7g+JZxIMN2UoBebRXso1zI88XDEGUywO17Urn99rvzzrQ6vq2S3 tuMS5Lk15xNBVL80hMRcjYotAZM9ycdbskd4TEBrEeZbFbS07a2KZ7vqWprvH0sZ2xvL Z9/9J/A0J75EAFIHwrwjqD+NK9EhMyfSzuHPy8N5CveXlXN4Envd1wX8vJvunRHih0aV fLew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0sBfqoTX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q8-20020a50c348000000b0043d3489e8c9si8033603edb.208.2022.08.15.14.14.43; Mon, 15 Aug 2022 14:15:10 -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=pass header.i=@linuxfoundation.org header.s=korg header.b=0sBfqoTX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233274AbiHOVEX (ORCPT + 99 others); Mon, 15 Aug 2022 17:04:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347535AbiHOVCF (ORCPT ); Mon, 15 Aug 2022 17:02:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7A08CAC76; Mon, 15 Aug 2022 12:14:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D270E60F86; Mon, 15 Aug 2022 19:13:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D832DC433C1; Mon, 15 Aug 2022 19:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590839; bh=zJh7aVjy83OVBviyzmE9wu2gQP51nHf6qxEIm9t2EEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0sBfqoTXUNDbxin2zqgMHhn5ml54baA7ybqOpjIW0G+IgUpudsmO4vz7W217ehlpe QFNKEgMEbi5ri5X8YNM6RQ+1sFclXM89RrQA/TaRuwUi2nfS+vwDvwIvKiZhq5tmKD FvY15+YKEbASH/neLkI/sX3pYiiun8OIbAFM7nyE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dave Stevenson , Maxime Ripard , Sasha Levin Subject: [PATCH 5.18 0387/1095] drm/vc4: dsi: Correct DSI divider calculations Date: Mon, 15 Aug 2022 19:56:26 +0200 Message-Id: <20220815180445.698269581@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Dave Stevenson [ Upstream commit 3b45eee87da171caa28f61240ddb5c21170cda53 ] The divider calculations tried to find the divider just faster than the clock requested. However if it required a divider of 7 then the for loop aborted without handling the "error" case, and could end up with a clock lower than requested. The integer divider from parent PLL to DSI clock is also capable of going up to /255, not just /7 that the driver was trying. This allows for slower link frequencies on the DSI bus where the resolution permits. Correct the loop so that we always have a clock greater than requested, and covering the whole range of dividers. Fixes: 86c1b9eff3f2 ("drm/vc4: Adjust modes in DSI to work around the integer PLL divider.") Signed-off-by: Dave Stevenson Link: https://lore.kernel.org/r/20220613144800.326124-13-maxime@cerno.tech Signed-off-by: Maxime Ripard Signed-off-by: Sasha Levin --- drivers/gpu/drm/vc4/vc4_dsi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c index e82ee94cafc7..81a6c4e9576d 100644 --- a/drivers/gpu/drm/vc4/vc4_dsi.c +++ b/drivers/gpu/drm/vc4/vc4_dsi.c @@ -805,11 +805,9 @@ static bool vc4_dsi_encoder_mode_fixup(struct drm_encoder *encoder, /* Find what divider gets us a faster clock than the requested * pixel clock. */ - for (divider = 1; divider < 8; divider++) { - if (parent_rate / divider < pll_clock) { - divider--; + for (divider = 1; divider < 255; divider++) { + if (parent_rate / (divider + 1) < pll_clock) break; - } } /* Now that we've picked a PLL divider, calculate back to its -- 2.35.1