From patchwork Fri Jun 14 22:47:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10996863 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1892A1515 for ; Fri, 14 Jun 2019 22:47:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0375C28795 for ; Fri, 14 Jun 2019 22:47:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB5EF287A4; Fri, 14 Jun 2019 22:47:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A088328795 for ; Fri, 14 Jun 2019 22:47:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 59A1189590; Fri, 14 Jun 2019 22:47:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7AC4489590 for ; Fri, 14 Jun 2019 22:47:55 +0000 (UTC) Received: by mail-pg1-x542.google.com with SMTP id 20so2313729pgr.4 for ; Fri, 14 Jun 2019 15:47:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=B/paYYaNElnUhrLCMfr9aofzvSpDY7fIjtUGwDwrL/w=; b=kT3OL61hUhHwGIOyV35avdQ1XtN9U5Duo7IdrImWRB6kI6mXt+V+iOEGoia4j78uby jjgugJnzubzRIfZo5cKzhKJvyaown7fW+HYNDzh07C+qGUyRiqyHsqjln8emvtx1k402 UBY1PgAs5ucRHSsX/WVhJGq7qksgO/deIJu3sE1d3m4clQ+9Vj0eWZER4TF37u2DOzAZ 0zOT2IPE+4gJFAxTgfQfTfyPIg6bd7yNINaVfuxsePYOOdw/egJlGBb0DqBWwMjb5Z3h krYcaI1AHv27prqRe0ILx1MSGSEebQ+mRoASd/Yc9JPytXM0ZEf7VOB70tS43ZIo9Rq0 Yyxw== X-Gm-Message-State: APjAAAVK+4DZqPq5X53W7H9Gcd+DQNeCwyCKkSsOHNkaMcPVHvkcpeu3 +oVS9t1A/M5LLOYRXIJLJ8NkNA== X-Google-Smtp-Source: APXvYqwCFm4zexZwb/yHk0T7k2vyRVj2XJif4vKx4gUkaC3e6ysgiT29t7k5lmVupIUZSX9ZhqMjSw== X-Received: by 2002:a63:441c:: with SMTP id r28mr37978657pga.255.1560552475017; Fri, 14 Jun 2019 15:47:55 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id x7sm3706087pfm.82.2019.06.14.15.47.54 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 15:47:54 -0700 (PDT) From: Douglas Anderson To: Sandy Huang , heiko@sntech.de, seanpaul@chromium.org Subject: [PATCH 1/2] drm/rockchip: Properly adjust to a true clock in adjusted_mode Date: Fri, 14 Jun 2019 15:47:29 -0700 Message-Id: <20190614224730.98622-1-dianders@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=B/paYYaNElnUhrLCMfr9aofzvSpDY7fIjtUGwDwrL/w=; b=ApCzoYVFWJ+gmiLTLvrC4zRCv/sxTzAUuGigYReuCPkwv8+JbQtTQ1ujJvy8eXWLqB +IQTzppqRJKhqe+8V7UEuUHo4bd+AM07L3HjWFZQQdGpjnep077mDCdlHdC1RIk2DgQq 5mJV4O++xveG92zkhvhU6kYaRMIla/IEBvu+I= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , Douglas Anderson , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, urjaman@gmail.com, linux-rockchip@lists.infradead.org, Yakir Yang , linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP When fixing up the clock in vop_crtc_mode_fixup() we're not doing it quite correctly. Specifically if we've got the true clock 266666667 Hz, we'll perform this calculation: 266666667 / 1000 => 266666 Later when we try to set the clock we'll do clk_set_rate(266666 * 1000). The common clock framework won't actually pick the proper clock in this case since it always wants clocks <= the specified one. Let's solve this by using DIV_ROUND_UP. Fixes: b59b8de31497 ("drm/rockchip: return a true clock rate to adjusted_mode") Signed-off-by: Douglas Anderson Signed-off-by: Sean Paul Reviewed-by: Yakir Yang --- Back in 2016 Mark Yao said he applied this to his drm fixes [1], but it's 2019 and it's still missing so I'm posting again. [1] https://patchwork.freedesktop.org/patch/103872/ drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index e4580d8f21e1..d124f34ab9fc 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -1006,7 +1006,8 @@ static bool vop_crtc_mode_fixup(struct drm_crtc *crtc, struct vop *vop = to_vop(crtc); adjusted_mode->clock = - clk_round_rate(vop->dclk, mode->clock * 1000) / 1000; + DIV_ROUND_UP(clk_round_rate(vop->dclk, mode->clock * 1000), + 1000); return true; } From patchwork Fri Jun 14 22:47:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10996867 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4EF1115E6 for ; Fri, 14 Jun 2019 22:48:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4077528795 for ; Fri, 14 Jun 2019 22:48:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 344EB287A4; Fri, 14 Jun 2019 22:48:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E596828795 for ; Fri, 14 Jun 2019 22:48:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F3DDA895B9; Fri, 14 Jun 2019 22:48:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7A16F89590 for ; Fri, 14 Jun 2019 22:47:56 +0000 (UTC) Received: by mail-pf1-x441.google.com with SMTP id i189so2229084pfg.10 for ; Fri, 14 Jun 2019 15:47:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0MclKa4ww/GU4h0ModhXTnU03GxDuW7aam4X/xA5H20=; b=iSo+UyCtg5VOAVmYFWDvJKzNs3qwGe8ZsF3VlPgCK0OBM8FTT4f8uBFJ/XJLrkLphp kdDi3DWOzHie6gxPWvcAE3b9IUZGIUXsMHUp6SVy29PiZgKIQBKPs6NLiY+8ejcyQX6H ADtSGho+a135qqdAirsRTmlMZYjwCxv9A9LuOhLxhgwxNOtD6vmoyXP12LhIVqYevPX5 ZBx9ruFCLvxWOPt7+kKIYjpH0rs5Adbcjy2cXk8vAv1xd4IY+QFoGAnHFcwwltk0257/ I+l3lQTM7PQf3UySaBBcDbJDN1aTE4FzrbUQG6LFh4yxM9xr+gsN8x789zdNgiPCoqTY /xJg== X-Gm-Message-State: APjAAAUIcZdxvcDJ03iFYUrZ4mlAyKILfyeDWQbhvafIm/s1MQjD6haD HllAcqZrOzkiHgYa98Ln4K/wCw== X-Google-Smtp-Source: APXvYqzZ+CMlOlPiOf2LQv6uMUwI93prqIodMDLjqSqBeZ5oaQMYW0ftolCisN3PIf4q8UD0Rzr7Vg== X-Received: by 2002:a17:90a:25af:: with SMTP id k44mr13019616pje.122.1560552476071; Fri, 14 Jun 2019 15:47:56 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id x7sm3706087pfm.82.2019.06.14.15.47.55 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 15:47:55 -0700 (PDT) From: Douglas Anderson To: Sandy Huang , heiko@sntech.de, seanpaul@chromium.org Subject: [PATCH 2/2] drm/rockchip: Base adjustments of the mode based on prev adjustments Date: Fri, 14 Jun 2019 15:47:30 -0700 Message-Id: <20190614224730.98622-2-dianders@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190614224730.98622-1-dianders@chromium.org> References: <20190614224730.98622-1-dianders@chromium.org> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0MclKa4ww/GU4h0ModhXTnU03GxDuW7aam4X/xA5H20=; b=ZHrf0zetXblEGMrSWzFuV+TI9faYuEa+jhfVW9V/m0B9O+jKxO4+WjenDITlg+aFYZ rwkn7i/eEJwwpQKHMiEq0zlBvGsHMIF45Uf+FNPktBaKA1e7aETQITS6pxCwjG88fhY0 xNrhAWXlbmUSTAcnqo9tAd0ptVAPAcMc7dGLQ= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , Douglas Anderson , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, urjaman@gmail.com, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP In vop_crtc_mode_fixup() we fixup the mode to show what we actually will be able to achieve. However we should base our adjustments on any previous adjustments that were made. As an example, the dw_hdmi driver may wish to make some small adjustments to clock rates in its atomic_check() function. If it does, it will update the adjusted_mode. We shouldn't throw away those adjustments. NOTE: the version of the dw_hdmi driver upstream doesn't _actually_ make such adjustments, but downstream in Chrome OS it does. It is plausible that one day we'll figure out how to cleanly make that happen in an upstream-friendly way, so we should prepare by using the right mode. Signed-off-by: Douglas Anderson --- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index d124f34ab9fc..09a790c2f3a1 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -1006,8 +1006,8 @@ static bool vop_crtc_mode_fixup(struct drm_crtc *crtc, struct vop *vop = to_vop(crtc); adjusted_mode->clock = - DIV_ROUND_UP(clk_round_rate(vop->dclk, mode->clock * 1000), - 1000); + DIV_ROUND_UP(clk_round_rate(vop->dclk, + adjusted_mode->clock * 1000), 1000); return true; }