Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2869677rwb; Mon, 15 Aug 2022 13:00:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR7a+qZZf0fyhK2UYq1v6tqpssZPGuYP5Xdtxn9VVg+XkSEjMMtDvIbnSqgzlAkAyTCATJ8t X-Received: by 2002:a05:6402:d05:b0:435:b2a6:94eb with SMTP id eb5-20020a0564020d0500b00435b2a694ebmr15687255edb.87.1660593638244; Mon, 15 Aug 2022 13:00:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660593638; cv=none; d=google.com; s=arc-20160816; b=h/slT/BxDYz0Lde4pkskM2odCgSpX5gbevw5d5FZWp+BuzVQoUdyq8mxiyblP8NrXC p1EMNgGp1Vv8NGbJ1Pcz9XYEEnrDrj5OpOECf5RFheKS1HbR+X1nSPlCVeQgjOn5Cuxu 1Nucjhoybn0ozApCrRlnt9dyY1FfxA9fi7EcxjGvHRp8Um2Veg8qtjIRf0omnN5xWJZj 8ylGeYyi2F2jCy5UCGZ1HE0U+2cJFbklCsTUs3a61o5R6oopUVhc5NwH2HKHgAC8Zopc stOfgVvXfZqbW+Kyg+ha1w6/Kdo+30RXYIbQ3+Czs/YqfnhT9e/B2Mj6NftEaAKduWDq BlTg== 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=FcxK2mqeljxEcrA6yZi0wiWNkPuy3UswdSU57IXmVXiW68TU4M/Xb2QzvCBK0gjQPe hOt1ZHnz86SvY/VyxklFtn3SFnKTTNC7yU6oOimQITxi+NfgyMdAgU1hevkarSmkkhbE Fh58o8Pc3c2+VtMBodVE4cHoxMH22aSA666YOrllULP3RpBEyr4NQ+dKYM5EO/qde90B BQPcn82x+QnIwRK3LFGfiCO6GICjZz/w+3F8VV9AQYLTb83lYpWm4p44aO995nLfYrJD 7S5ZSSReWtnCDIw8tQEvPkQ2eUT7XxSVdGiDEVHoutEF076p/MCczmLdNlVLuDz2uXQt lnNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ISMapfeW; 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 x19-20020a05640226d300b0043f8f566b38si9761888edd.2.2022.08.15.13.00.11; Mon, 15 Aug 2022 13:00:38 -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=ISMapfeW; 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 S244248AbiHOSxA (ORCPT + 99 others); Mon, 15 Aug 2022 14:53:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243839AbiHOSrV (ORCPT ); Mon, 15 Aug 2022 14:47:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BD59422E9; Mon, 15 Aug 2022 11:28:36 -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 A7CE160FD0; Mon, 15 Aug 2022 18:28:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96677C433D6; Mon, 15 Aug 2022 18:28:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588115; bh=zJh7aVjy83OVBviyzmE9wu2gQP51nHf6qxEIm9t2EEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ISMapfeWzUq0qVKFejpRUu8KsBlsWn7qZ6EFy/HLoSysz3BSOpJMPyIxpb98Kwfkc kugOKxQ/T1Ec5BhjMyuImSoitfrgSHLmcrTXa0PQmT2O+zsW8IPeJOIatG8IyfYJt4 tg6My+9tqq+16hLu8dC0iLkZ3+6yn9DRsuvp3TNw= 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.15 300/779] drm/vc4: dsi: Correct DSI divider calculations Date: Mon, 15 Aug 2022 19:59:04 +0200 Message-Id: <20220815180350.104564051@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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