Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3763130pxf; Mon, 22 Mar 2021 14:35:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTUndsSZyybSoszmHPH1qfITiGWIe2x46bKmLJGdsDHEctjdhfTjUjt28KumbSpWgUOTxr X-Received: by 2002:a50:fd15:: with SMTP id i21mr1579893eds.384.1616448948441; Mon, 22 Mar 2021 14:35:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616448948; cv=none; d=google.com; s=arc-20160816; b=RRyKraen+K2hik8Y5n7UjWtI4AVGGmIjE05NGJqDX1zcF+dobzX8Bkhpv/ZLQXHX+f BqDuhlp6dI1jPMoglpPk93mi2mLD817R3ecJ5kx/6vZBuBw2r5jLJCrbaODuXiiZAGwU sRRssL3CptEfl5FHcIIojqPYuHVUD7vD36ppq15g+220at6GUiEHGaa0XLVsA5U4UdW6 24iEtq1I8s1dzneiIOzlUR1xaIIjQkNUz2AOTxRO6sHIEWR7btkKMvKa+BjZK6d36FDz WGXYIl5rKBgRdF4GbSrR+GFb3UY9lcVclShcxIKiAlYgwUatG+kyDZNAQbDQE+oMtNhS 5NpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=RyCES0euy+yDAsc27Yqqlm8eevv6OL5wk0CPEXsf8Ok=; b=tw1Wjc/BCkgu/7TqYqaSCMM02hg3SibDV1eQQxF4iND4X7G8MktPC2rLhySJNauOjr q37hiREPecWgfOZssckrwi9RbQIMLT61iaabl2fYXY/+k21zGDnid5mId6tacQt7pYVi 0a9Z25n9a6pG11iBZFb/ACm+MKbqcqPZ6orXcEv7gRXoHx50gaNWSNCqsMU4RBABAWcR Clf+qA2F0ct0L3aVNUL/cFAexUuE/aMFGHUPpClpv5CK7pGCBv/ej39WJYtAlHCOIA11 oJ77tUcfwAhi9gNdAJ0Eo8YM3fX28GSKmb0ZfLWl/CPewfQf0iVilm4opNp4QwRqHQko EP5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@libero.it header.s=s2021 header.b=i0e9HIL6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=libero.it Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i13si11973827ejy.93.2021.03.22.14.35.26; Mon, 22 Mar 2021 14:35:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@libero.it header.s=s2021 header.b=i0e9HIL6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=libero.it Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229872AbhCVVeW (ORCPT + 99 others); Mon, 22 Mar 2021 17:34:22 -0400 Received: from smtp-17.italiaonline.it ([213.209.10.17]:36980 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229591AbhCVVdu (ORCPT ); Mon, 22 Mar 2021 17:33:50 -0400 Received: from passgat-Modern-14-A10M.homenet.telecomitalia.it ([87.20.116.197]) by smtp-17.iol.local with ESMTPA id OSB9lKwj3tpGHOSBIlyOij; Mon, 22 Mar 2021 22:33:48 +0100 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2021; t=1616448828; bh=RyCES0euy+yDAsc27Yqqlm8eevv6OL5wk0CPEXsf8Ok=; h=From; b=i0e9HIL6MQaG5j2X+GTT6DhWw4sOvKrmxStXfRKCM0lPGYbtCu2YCALMWQiOTuPzn lZkwmaz7DEz/17deltFUzL8Z1AyEQ5WhwKv0+0IE1Ib6r1KzrE+cNqrYaUBCQfL7CN e6ud0VbPxaQUIo/N2aukhmpR/UUmbH4WLS2F5XZQ6NWeP+nF9lrRxOnr2W7jJDRtWD wwpNEoVIgIxJg3yEuI6AWQ3hH1w7bMr9/zJHRiNT1coLagIHNZ/nzrEwP7VUsg33Ei ffFGc/++OToKEG5Kt2iMyPrfgSDTJ/uxBNpMlykNmPHlO7wplW1btYl1yl63QWg+Xa ovmPwwQ2QLLCQ== X-CNFS-Analysis: v=2.4 cv=Q7IXX66a c=1 sm=1 tr=0 ts=60590d3c cx=a_exe a=AVqmXbCQpuNSdJmApS5GbQ==:117 a=AVqmXbCQpuNSdJmApS5GbQ==:17 a=OpddqcCamwGiTB6aXU0A:9 From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Dario Binacchi , Daniel Vetter , David Airlie , Jyri Sarha , Tomi Valkeinen , dri-devel@lists.freedesktop.org Subject: [PATCH v3 2/3] drm/tilcdc: fix LCD pixel clock setting Date: Mon, 22 Mar 2021 22:33:36 +0100 Message-Id: <20210322213337.26667-3-dariobin@libero.it> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210322213337.26667-1-dariobin@libero.it> References: <20210322213337.26667-1-dariobin@libero.it> X-CMAE-Envelope: MS4xfAC5Flr2DXI/3y8tjQP1ykuGXiiK8y/WSYfF+QIHBOHrIa43VFbF5O6hDlBQyvABFoD7VhsSNvbvNGr/O5X3Qb3axwzL/ACPN/uzXJ+Q1mLUjXDYxvwB l3pcRdEgaEhtLL9usYBgZq1mY0p3SqfCrR2uXZHtOwfff6y/ZMgyixqI3rrHwp6aL6//csBTLrqzkRX8klLcjyNgs+FHexwfWzkKLBroY4yo3hMbFtToOUUr 16TzWcpACvsG+IYd8VCNOU6oCvgN9ALx3QWdYzFyYJSNQuWYU4G7RKjVgwHsa7Lki7JiBGBheqbwNfN0IcGArO0ZMwK+xRfEk671GHNvTU7KDVKVLELixdiN 0oRBd8BY5UdzAp8gKQtRhpW9ZJA0Aek3oklwNp7KeTclmX2o2AiARcDZ8H1YS8i3VDcyfJs+ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The tilcdc_pclk_diff() compares the requested pixel clock rate to the real one, so passing it clk_rate instead of clk_rate / clkdiv caused it to fail even if the clk_rate was properly set. Adding the real_pclk_rate variable makes the code more readable. Signed-off-by: Dario Binacchi --- (no changes since v2) Changes in v2: - Rename clk_div_rate to real_pclk_rate. - Provide pixel clock rate to tilcdc_pclk_diff(). drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c index aeec5786617d..ac6228cb04d9 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c @@ -203,7 +203,7 @@ static void tilcdc_crtc_set_clk(struct drm_crtc *crtc) struct drm_device *dev = crtc->dev; struct tilcdc_drm_private *priv = dev->dev_private; struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); - unsigned long clk_rate, real_rate, pclk_rate; + unsigned long clk_rate, real_rate, real_pclk_rate, pclk_rate; unsigned int clkdiv; int ret; @@ -214,7 +214,8 @@ static void tilcdc_crtc_set_clk(struct drm_crtc *crtc) ret = clk_set_rate(priv->clk, pclk_rate * clkdiv); clk_rate = clk_get_rate(priv->clk); - if (ret < 0 || tilcdc_pclk_diff(pclk_rate, clk_rate) > 5) { + real_pclk_rate = clk_rate / clkdiv; + if (ret < 0 || tilcdc_pclk_diff(pclk_rate, real_pclk_rate) > 5) { /* * If we fail to set the clock rate (some architectures don't * use the common clock framework yet and may not implement -- 2.17.1