Message ID | 20180109020323.11852-2-net147@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org> 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 E232860210 for <patchwork-linux-arm@patchwork.kernel.org>; Tue, 9 Jan 2018 02:04:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2FEC28A82 for <patchwork-linux-arm@patchwork.kernel.org>; Tue, 9 Jan 2018 02:04:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7DDA28A86; Tue, 9 Jan 2018 02:04:50 +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.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6207E28A82 for <patchwork-linux-arm@patchwork.kernel.org>; Tue, 9 Jan 2018 02:04:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=WsDp2E0MS9EbMP5ztFy/Gi59DX/dAOnSIpFxuYyTUI0=; b=Fq5LJTUFGk28Xjy1uEiTdhA+9Y yUv7V160iLpoTIwcrKloMp/pPW6Wqtx4Tu//WNGM7ErSeLW5Ndmj4ksMhNbPWoaa0noVoSQVH1n7k HyaC9hT/bSxKd6k8YfGWU8AyRwPKL3ORlFv1s+g0N7GtlyI1sBHXzgSAXN0sjl42WkKy4/fTDKEF5 R/Km2q79BLL55XWUwcTcN4FKKTtk17/JmQYh1QMoytdPstT0Xnft8mQbtxyQKRKwmd/CeJw3101A6 u9a2oaFrjOdKDobDabgpFfSgmH9Ln+/K1q009lUwWDedgpPocbTQRqysb1d3hf5Pz/irI80us6I2z 1CQvxb6w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eYjHQ-0000ee-Ob; Tue, 09 Jan 2018 02:04:44 +0000 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eYjGX-0008QG-7O for linux-arm-kernel@lists.infradead.org; Tue, 09 Jan 2018 02:03:57 +0000 Received: by mail-pf0-x244.google.com with SMTP id t12so4597472pfg.2 for <linux-arm-kernel@lists.infradead.org>; 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=W8JQ72/O5Vtd48qlHbYLRPVppO8ejfVSD7TfLhOzznGigMnfzw0E6copdd6Yn2bR+U OrLDw6ja1z6rj1gWVxKb78lChiqgVgb9qEjZlai1Z7P748jOgHRiiG57vihrycKmKo3V bjRw9VsWLFpGkI1uL/ywm6MSnU0muSMvosmlwgtXXlIbeS6El6czvaK4pIVJgLE5K39O y5LACvElSBy1P7fq5/fxSVG9dz7dZt+BOSvlBSgY633qo2s9wQvs9SS9flea0Y78lR0p 8pw37BYm7rha4Q//yVTDt7c2uTVj86nJGAJo1B3kcmJdGwXXZx1OHjCJxL0e5iS2fAZU lPhQ== X-Gm-Message-State: AKGB3mLoPju7kvyJgvQPhIJDaYgGhJZ/hPN1BhYHPLWe1LeLVlSLOVYx 7wNJmh2JuvT/v6YYRgHZIkwazTlz 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 <net147@gmail.com> To: Maxime Ripard <maxime.ripard@free-electrons.com>, David Airlie <airlied@linux.ie>, Chen-Yu Tsai <wens@csie.org> 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180108_180349_848313_75F59CA6 X-CRM114-Status: GOOD ( 10.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Cc: linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, Jonathan Liu <net147@gmail.com>, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP |
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;
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 <net147@gmail.com> --- drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)