From patchwork Mon Aug 8 19:29:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 9269495 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E2D2960839 for ; Mon, 8 Aug 2016 19:29:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D31B9212D8 for ; Mon, 8 Aug 2016 19:29:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C606E27FBB; Mon, 8 Aug 2016 19:29:44 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 5D942212D8 for ; Mon, 8 Aug 2016 19:29:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 56D816E1CD; Mon, 8 Aug 2016 19:29:42 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-x233.google.com (mail-qk0-x233.google.com [IPv6:2607:f8b0:400d:c09::233]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2535A6E1CD for ; Mon, 8 Aug 2016 19:29:41 +0000 (UTC) Received: by mail-qk0-x233.google.com with SMTP id v123so199681224qkh.3 for ; Mon, 08 Aug 2016 12:29:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=0lqzyKgGrVtl2hbuNt5o0CZNPNiv/05myicnGinKAFk=; b=XpKVY5CaN47HAcVB1/uVn6VD0zfZ5Ohb/WYb5IiN386w/zlbiK3txIAJwbkVraON6I EQzj7RIKSNqLapeo0KbxUQWzdaeXyzTpUiO9tAFOAv9gm9W5FhXpBQYbYuupyBO/GHcO eVLHF24CM/8B0brYILkFXSi06BXG/fOZcNibA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=0lqzyKgGrVtl2hbuNt5o0CZNPNiv/05myicnGinKAFk=; b=J1g2RQWvoWt4Hx/GBM0jj4WJ8hP0XlKd4pf5SmlKsaFNnD8Ny6IpA632b9W+hiS8i1 QaSMWPe9faSS9sG3iRVuXY1Oy8bo08tekyqeAQ4Fr9XObH79T7KDSTkkMIV54wEns6bv UHbxUH6RXr0tzrW6Y2YD9FXzY6LpiKHdXa1/JFDhxv/FYzxyM8NY69FfsvZU0kMN71A+ 6Mvc1FKngRlP67vnePLwDArGmjFK3Zk9VJ7saLymMunr+z3gM7OM6mWjNhkvGgKh8CZy nV5XX6oSO35x8zN9m8PSd/C5xtfjcPHZSBL/w9aZb29OQJazHzC537D7RdZ91qMFX92o Ybgg== X-Gm-Message-State: AEkoous/cS8vA60n9aDYM+P1QGbztfhvRf25A+0a8VfNuLFr6FO2HB3LZrQY4lkhhyZbB4sL X-Received: by 10.55.43.25 with SMTP id r25mr16438686qkh.256.1470684580260; Mon, 08 Aug 2016 12:29:40 -0700 (PDT) Received: from boxwood.roam.corp.google.com (cpe-75-189-128-87.nc.res.rr.com. [75.189.128.87]) by smtp.gmail.com with ESMTPSA id b195sm18371649qkg.9.2016.08.08.12.29.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Aug 2016 12:29:39 -0700 (PDT) From: Sean Paul To: dianders@chromium.org, mark.yao@rock-chips.com, ykk@rock-chips.com, dri-devel@lists.freedesktop.org Subject: [PATCH] drm/rockchip: Properly adjust to a true clock in adjusted_mode Date: Mon, 8 Aug 2016 15:29:31 -0400 Message-Id: <1470684571-37955-1-git-send-email-seanpaul@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 Cc: linux-rockchip@lists.infradead.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Douglas Anderson 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. Signed-off-by: Douglas Anderson Signed-off-by: Sean Paul Reviewed-by: Yakir Yang --- 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 31744fe..1bbffaf 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -891,7 +891,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; }