Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3114728rwb; Mon, 15 Aug 2022 18:28:17 -0700 (PDT) X-Google-Smtp-Source: AA6agR6F/jGVvXdEC0nkpe07Gg6o9a6ht3dbLEXdAwjmWHHHncHYpluTqnTuEFXI1fibgtcCt0pJ X-Received: by 2002:a05:6402:530e:b0:443:df38:9df with SMTP id eo14-20020a056402530e00b00443df3809dfmr4391436edb.9.1660613297380; Mon, 15 Aug 2022 18:28:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660613297; cv=none; d=google.com; s=arc-20160816; b=EYfyu1/KKSptyjgOCCYjeGc6LrfIrSWrJCaCREv56O/iDM164kNWyP/sZAKGowpgVy ef/sGUCa75UdPd51RrMpIZcM9EsTgYVDD6OuQauHwff1hB1lRZDxmwLtvTrtKODE/ZtW ig6QnsuZrE1BcBN2Mvq+X+T2kmbcKqwX/6c+bZaZ4ycVz6R2b+OyiYuqP7K+xnAXUq4e QKwj4gWABPcIAvJp9fYxoZCviUyw898VKpe+fUKxf1+PDCjlU3ujc3cZwWDnfl0SeJsl Zt3dj6pGeiIJENIIPGQbJ+DYYlXmFyxfA4LFIWkHrtPAFqEPiavbI0dVXoAba/TsHgkt hAqA== 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=Z+qwxquIFhU2wTy8aovFRSWyxWkxECkQbr3RA8tddCLrYHIiZ+rOZCLqoPfuGxjPTl tD959I8JVB8ESCYXFYiFRnKv4ZBsApX+N5gMXbNrEYmFpMMX76vG58c9ckq75LGGW8w5 VN5Se2wcC5N2QuTdlM9ypf29v/sEph14mRgIKnohNxeAtF77Q8NrZ7CRRmMZsHHmGX+e 538g9Ik8zaAVxeu5/e8cY/v67J41WkyeRAOYPBp7VQocV36quQysoj6d7CWL/0QqbTzf cXnQyCRqoC+zgdX2g0GbtlJFTdGeXeTFMIfpiVJyJGucl9wNZ3ejT677cMD4HS2G9sSh 5a5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KxZIXbBf; 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 cr10-20020a056402222a00b0043cc4d599f8si7486979edb.161.2022.08.15.18.27.52; Mon, 15 Aug 2022 18:28:17 -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=KxZIXbBf; 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 S244244AbiHOXpQ (ORCPT + 99 others); Mon, 15 Aug 2022 19:45:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354286AbiHOXls (ORCPT ); Mon, 15 Aug 2022 19:41:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BC37DF92; Mon, 15 Aug 2022 13:11:37 -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 CD3B26077B; Mon, 15 Aug 2022 20:11:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC606C433C1; Mon, 15 Aug 2022 20:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594296; bh=zJh7aVjy83OVBviyzmE9wu2gQP51nHf6qxEIm9t2EEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KxZIXbBfoLzPTQAdQ79ET1V6o7OScZyp54lr45B6umd1DoN6AIUWWGXIP3jACSFwq VgRg9Mqt++gICxEdv6sqLndn3jFwTB+E5lINtrjyoRbmua3+pn4KoUPzDvKWx3WXlj rkQKg2PII+pIyalAKAru8U04Nd4FZF/xrukqkFL8= 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.19 0410/1157] drm/vc4: dsi: Correct DSI divider calculations Date: Mon, 15 Aug 2022 19:56:06 +0200 Message-Id: <20220815180456.055982552@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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