From patchwork Tue Jan 9 02:03:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Liu X-Patchwork-Id: 10151173 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 C96B760223 for ; Tue, 9 Jan 2018 08:35:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB381284F6 for ; Tue, 9 Jan 2018 08:35:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFB2928571; Tue, 9 Jan 2018 08:35:49 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 69B9C28541 for ; Tue, 9 Jan 2018 08:35:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DD76D6E0BA; Tue, 9 Jan 2018 08:35:44 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 452966E065 for ; Tue, 9 Jan 2018 02:03:36 +0000 (UTC) Received: by mail-pf0-x243.google.com with SMTP id y5so3529212pff.13 for ; Mon, 08 Jan 2018 18:03:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WNM8pnRXp2oC1OZoUm7icnsa7rvTGxi0ASjK5wa+sdg=; b=nEJVDmImKIocgvf21IIemYnKYsE/SCT3n5io6mMMzhYzGDOfKfL2Ugaac8QKaHN7xD SZ4NVgY43yHtJvDWAfHvCABCxtuxyJ2LCAH40vkqnxtVfS16zQLFP0rYr4g2EdaZ8iWA vk5MYgVIrUeCIwVMZFI0eeqFbhV4wo09BV/D+IhjzIOrmuBhu2q1Nmogm6TKObOY+59K zrC3ZV4wACByhov172DGlKOpTSL6NsuOPTakWJFQQzafaNC3ld893kDdCYJIkJqNqq+o ehXkUjw9DDhVIk6rog+hCYyCqdaxerBEQBqaRTfCSPC/NmkEspO9I5/f5bxS/LQaKjDH /5cQ== 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; bh=WNM8pnRXp2oC1OZoUm7icnsa7rvTGxi0ASjK5wa+sdg=; b=hE7SV1nEkqfdVERzMZSmuBw+zwDr7BGULo7xRFWMrNebdCtoJFnGMvaiMUTnghPrS8 dyRvBv4SGd4KKoeuHWAv1A9sQrVQcP3iTi/lMevJGgGr+ZxfeE4n3dq6WGe94kMhUEdO 9E2lKnycA97fKFTiTO5qcoT56yF402mFMSHeXBb3nlnU+vGSeTO4nKq0GbBcqy7i3N2k rw+bLZdXA3ga6ZoZjo5KOOS3a/ajRvtGPaPdvotgtDW0ECsJMkABehCK/w1w5MCkic8b dJs01HlNXV84OxGt3vU60PfpCO2Ax5FGLPKz6nOhmJ1Tlc6jF1lTnaahjDxfHc7K6AC9 ZOqw== X-Gm-Message-State: AKGB3mLThS25XFwwilHkb98Z6qc3RCGPg9gI4b7+coIpf3Ede2e29tCQ 8uWjXHKJcndWcICoJKq2tWg= X-Google-Smtp-Source: ACJfBosReGFOr89KDVnY99LSNylNgYVRy9TbpY/ReyXWvug5whBxwoyArR4DGxyGatDYsgPBRyrILw== X-Received: by 10.84.138.193 with SMTP id 59mr13761525plp.254.1515463415462; Mon, 08 Jan 2018 18:03:35 -0800 (PST) Received: from 60-242-179-244.static.tpgi.com.au (60-242-179-244.static.tpgi.com.au. [60.242.179.244]) by smtp.gmail.com with ESMTPSA id p10sm14158641pfd.106.2018.01.08.18.03.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jan 2018 18:03:34 -0800 (PST) From: Jonathan Liu To: Maxime Ripard , David Airlie , Chen-Yu Tsai Subject: [PATCH v3 1/3] drm/sun4i: hdmi: Check for unset best_parent in sun4i_tmds_determine_rate Date: Tue, 9 Jan 2018 13:03:21 +1100 Message-Id: <20180109020323.11852-2-net147@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180109020323.11852-1-net147@gmail.com> References: <20180109020323.11852-1-net147@gmail.com> X-Mailman-Approved-At: Tue, 09 Jan 2018 08:35:43 +0000 Cc: linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, Jonathan Liu , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.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 It is possible that if there is no exact rate match and "rounded = clk_hw_round_rate(parent, ideal)" gives high enough values (e.g. if rounded is 2 * ideal) that the condition "abs(rate - rounded / i) < abs(rate - best_parent / best_div)" is never met and best_parent is never set. This results in req->rate and req->best_parent_rate being assigned 0. To avoid this, we set best_parent to the first calculated rate if it is unset. The sun4i_tmds_calc_divider function already has a similar check. Fixes: 9c5681011a0c ("drm/sun4i: Add HDMI support") Signed-off-by: Jonathan Liu --- drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c index dc332ea56f6c..4d235e5ea31c 100644 --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c @@ -102,7 +102,7 @@ static int sun4i_tmds_determine_rate(struct clk_hw *hw, goto out; } - if (abs(rate - rounded / i) < + if (!best_parent || abs(rate - rounded / i) < abs(rate - best_parent / best_div)) { best_parent = rounded; best_div = i;