Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3412414rwa; Tue, 23 Aug 2022 04:28:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR6IEOaxEvTKBmd91reGXOYL3pSb+xaiJxAwRsDmMFWf4rmlpBspvzQ8RkwwvKfYyEGtrQrt X-Received: by 2002:a63:cc51:0:b0:41f:12f5:675b with SMTP id q17-20020a63cc51000000b0041f12f5675bmr19941860pgi.69.1661254117809; Tue, 23 Aug 2022 04:28:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254117; cv=none; d=google.com; s=arc-20160816; b=IPQ7QQqggaeN5eWN3A2Friz2h2ezPl/r/Wt7K3t1bgzbazy7lU9wxeVdQsqHdaXJf/ ebyytAPDnbSpVB/luRFlKQv8tUSaReZGbz4c6MTZIPYqndmWgasMO817Z0EW1MBECCis xWMACznHqAAwkad5tkvR084YJrlnh3hkk/FugYPjDkjBbgvcQ50ZyLHow4r3cSwZPxiR ZQd0BgYChMCwZf7i/aJDT4gI9qW8mnXd06A6/6vHjxtomApMekwq/bkcu5izgP/rUob+ WZ93MXVQfoHgBz988YzG6QmtLs/7IiYfLngPG+Kt4fccMcZL1aYounKOyVvR7AqriIVs 3www== 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=7qf2eLAQkdREgmRhi5uL9al2Nk5jR8dTWl1gBxHl+9E=; b=XvlHejzwEXW6sR7LW9GsYe//0NdDFDuOVUyQwgMN8H84iqGAF8FioB/eobfIjlDPe0 MFk5RGN3WwmTe9IHYHRmeqiMarU3qLwW8ztE4mlVbhzlEdA7rgF6msYpk0PSpdB4A0VP 0IZ0d/4msIKEj1izLQgw4F37UHAtBuzZy8VXw7FJxc15P0Lua43g2ejc+VUlkz5Q6Hrm YAfTTkfwagoj50FrIecJXACAtAWg90f2l54u4OOXGpHeZN898QiW8cQeAtOqjmiWVTWl Hx42UZLlNyJM+HXC0w7w20W//Q2dbQaMPzyvWJlYqnOPyN36ZrhESj6rsHNRLPkl+q+X Q2mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pBffbx0F; 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 h192-20020a636cc9000000b0041c4d623573si16189831pgc.769.2022.08.23.04.28.26; Tue, 23 Aug 2022 04:28:37 -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=pBffbx0F; 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 S1354966AbiHWKhb (ORCPT + 99 others); Tue, 23 Aug 2022 06:37:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355048AbiHWKWr (ORCPT ); Tue, 23 Aug 2022 06:22:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 052CA65654; Tue, 23 Aug 2022 02:03:57 -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 ams.source.kernel.org (Postfix) with ESMTPS id C86E6B81C53; Tue, 23 Aug 2022 09:03:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F92EC433C1; Tue, 23 Aug 2022 09:03:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245434; bh=fKC6Eft23X6p5de7xmAaF7rYFnuHuI+SxHNNWdH0AfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pBffbx0FSteXiVu4l31wKHxABA66K2Js4UYPRPfr68Fu24S3RsEA3NpqkEmJaRCVO /sVLpuehyNHa/ClWVxI2SbiWuoam6aTe5hivkulbFxwNSXARx+2+mofLH3qqXKb1UI oH9AY1FPSGGsIb2oe8E06QOkKCYyRB6DOy37MKI0= 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 4.19 078/287] drm/vc4: dsi: Correct DSI divider calculations Date: Tue, 23 Aug 2022 10:24:07 +0200 Message-Id: <20220823080102.877281360@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@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 0c607eb33d7e..77003ce666a4 100644 --- a/drivers/gpu/drm/vc4/vc4_dsi.c +++ b/drivers/gpu/drm/vc4/vc4_dsi.c @@ -853,11 +853,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