Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1855342rwb; Fri, 19 Aug 2022 10:30:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR4tqXu9roX8aNu57bhIwZ15YuY1/Po+5KWONdEmMqt+WWXv6xJa5UjGigiGDyQSM/IHfofh X-Received: by 2002:a17:90a:fea:b0:1fa:c921:3f6c with SMTP id 97-20020a17090a0fea00b001fac9213f6cmr9829917pjz.2.1660930208966; Fri, 19 Aug 2022 10:30:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930208; cv=none; d=google.com; s=arc-20160816; b=gJk/x7oNq0YxII31wtkXuuD9V7AS4EXudQwsLvWSCDo/2hlihYGlM2U7lS55Rgeap5 IBPks4v4YluLrv6Nofr1Yh2MPmr34TK5CzPnU3PFY7bO6xzNglKD8leXsOK5wglbi7jU DPtEFTlnx5KtNQLimbqE92AxkHQEAieAtxXagOuSnTjHLXX2oIKdjIWSqWbw63D+j4EL JRGZ1Zn4gepoJLX3YGROPvvjuweJTMrMEDLVCwB69vWYwDeMGAeV66NLZVAr8sRBI+8+ 0chmucrAf9/MK7PhZL5FWDqDcOXc6Lu/cs0J3PGGs2g7+Z2xUfLnwMCnYsEa767gpg6I SlTQ== 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=YgWShmvmt9Bi3qjiY101Q/6Acw39E6UGcZqWao4WuLM=; b=EFA0alTqh/o1CCspQhKpa4rm0YXLVap3W33IJ7Fb7mvuWU1yXtM7cpqp/PlEwT63Sf wyItrUCDLfcgqjgn+hpvBxFH8ZzXerc44qwHEn9FwdPWFfzqk5DSYh0kX1Om61aaHTDl KH9fJU0pnEE/FOdC2gPymz7hpuxA3AgJLiHrUvUWrdmcY1l2l9qJ8vlJVEoJoAxheext Oy+46EtIIcor1EYFK/X3Kng+WkBv57mM8hQP9sR7AemciRFhFM0JCWHw2IixEeX60dVA N9YocBBGRlH2SH0KoYdZq+Yp9V/gjqNwKFlmK7yas8gHg+885qhWXjYW6ae3gN2nQ/Um t3Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jXQiRGx8; 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 q68-20020a634347000000b00429f677c808si4669811pga.518.2022.08.19.10.29.57; Fri, 19 Aug 2022 10:30:08 -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=jXQiRGx8; 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 S1351506AbiHSQIK (ORCPT + 99 others); Fri, 19 Aug 2022 12:08:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351209AbiHSQFS (ORCPT ); Fri, 19 Aug 2022 12:05:18 -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 F29F910BE3E; Fri, 19 Aug 2022 08:55:03 -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 BEE1461746; Fri, 19 Aug 2022 15:55:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3037C433C1; Fri, 19 Aug 2022 15:54:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660924500; bh=Ylk25W0Qvb7wD2w7cKz3Yfi9cpR3fwRFy1weBq2Dsdc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jXQiRGx86Fjq0jGVJik0AmyW4wf3YgXVgaDq8H4wqQBBpjW0nRTB89jSu73ulUOsG RR9tkjtIaVnyntaAkisLpXWXxdpjS0Qpq1Nk6OfDyvrjgWuYcJ4BzhLvSmc9FzA+CR cZPZAOsizBi+h4K9MfHS4yOF+qxd4hGnn4urG3VA= 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.10 191/545] drm/vc4: dsi: Correct DSI divider calculations Date: Fri, 19 Aug 2022 17:39:21 +0200 Message-Id: <20220819153837.904227965@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@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 ad84b56f4091..153ad9048db5 100644 --- a/drivers/gpu/drm/vc4/vc4_dsi.c +++ b/drivers/gpu/drm/vc4/vc4_dsi.c @@ -794,11 +794,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