Received: by 2002:a17:90a:9103:0:0:0:0 with SMTP id k3csp11791008pjo; Thu, 2 Jan 2020 14:20:27 -0800 (PST) X-Google-Smtp-Source: APXvYqxSR9ROVKL8k/7IzUlIXQaMkPOPWYI8fWIQOwibUh5n8BwqJ2QUPBbyv8psJ/KYu8Ikq5b/ X-Received: by 2002:a9d:7cd9:: with SMTP id r25mr88377208otn.326.1578003627263; Thu, 02 Jan 2020 14:20:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578003627; cv=none; d=google.com; s=arc-20160816; b=Kn2M/GpRjMsQj+ccxqSEScFuOx69lBdAtbvybaGN648AKdJHRXJOiQndEdyseDBbTc ok1Li9zWWzxmjCKSh2i489r05ByIZfU4nrenptagArixPDcjBSDO/ZxEzgmDbPBFtYp2 DQRqOqbCWwhznlmVNMy0c2gxCrwIt+/gP/H7/H5QI7klbloY8D/txoQGDntyW2zWiSVi k41LkfI9uYVJP2/FgrUrnZoZ2KYZMY2owUS4BgSsvobQ5HcVokc4CF8j84bnLYO+OS0I jb66l07gLoRxVWRrSGDL0kEZ69dskKmswRSW110CqJrgPJ7dd7hqyrMmtQu4JKeU6Z8p ehew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IPu+nE3jKjgLgj6diS+tMBcqjqAbnk6aUaab+lqOHA8=; b=audRG0nsxLLWA3561mRHzIKoHo5aDIdfZ2/I187GazdsdSam5ZOr7lDlOczbJEXEmb F/AoO0dCdhpS4FVws/UzjyG/mZXvcSwo4h9SpUv1D558ICoI31THuQxFjYzFopDkBh9Q oNUIFxutRh5VNVTJX393OZ9ZIBxfYEpt+xo99VNpcJKsEbOnjH9tcYjMWPhBah34Lteg 97eQ+xgx+cWb7ZrdZFX/4MIhMXZ7L2BsiuRuhueSDOCmPi6VbPXp6Fbk52llM9GINJ5k tE6wj3wUWz8974DV3e6Gn8orx+rchJCNs2yqIjIBsgZsU9gI9n1asJ1C2Vlap5Xdm5yy XCiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=blRpFpW9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t25si18708071oth.246.2020.01.02.14.20.15; Thu, 02 Jan 2020 14:20:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=blRpFpW9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728633AbgABWTk (ORCPT + 99 others); Thu, 2 Jan 2020 17:19:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:36092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728467AbgABWTk (ORCPT ); Thu, 2 Jan 2020 17:19:40 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F0B3C22B48; Thu, 2 Jan 2020 22:19:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003579; bh=xhTQ3xdz1oBuLHajguPgBXuKNFb9qwF9r7qZ5NJCneY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=blRpFpW9FHF6BlEexIlwH/Ew4QtknqGdSugILm6W7j6YX9pGNdm1NT6Ou30oJ/JUY LL+GhM4L/jkmgBlWGPJPQgJl4raXhvCJsJPcq284+QSkdm3wYCsEQdVPrw5rKGz6Rs u+NcX17fPBmpjCBbSUzJxGK7UBNqYLKnbk0G9o/c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Boyd , Jeffrey Hugo , Sasha Levin Subject: [PATCH 4.19 028/114] clk: qcom: Allow constant ratio freq tables for rcg Date: Thu, 2 Jan 2020 23:06:40 +0100 Message-Id: <20200102220031.958075125@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220029.183913184@linuxfoundation.org> References: <20200102220029.183913184@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jeffrey Hugo [ Upstream commit efd164b5520afd6fb2883b68e0d408a7de29c491 ] Some RCGs (the gfx_3d_src_clk in msm8998 for example) are basically just some constant ratio from the input across the entire frequency range. It would be great if we could specify the frequency table as a single entry constant ratio instead of a long list, ie: { .src = P_GPUPLL0_OUT_EVEN, .pre_div = 3 }, { } So, lets support that. We need to fix a corner case in qcom_find_freq() where if the freq table is non-null, but has no frequencies, we end up returning an "entry" before the table array, which is bad. Then, we need ignore the freq from the table, and instead base everything on the requested freq. Suggested-by: Stephen Boyd Signed-off-by: Jeffrey Hugo Link: https://lkml.kernel.org/r/20191031185715.15504-1-jeffrey.l.hugo@gmail.com Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/qcom/clk-rcg2.c | 2 ++ drivers/clk/qcom/common.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c index 52208d4165f4..51b2388d80ac 100644 --- a/drivers/clk/qcom/clk-rcg2.c +++ b/drivers/clk/qcom/clk-rcg2.c @@ -206,6 +206,8 @@ static int _freq_tbl_determine_rate(struct clk_hw *hw, const struct freq_tbl *f, if (clk_flags & CLK_SET_RATE_PARENT) { rate = f->freq; if (f->pre_div) { + if (!rate) + rate = req->rate; rate /= 2; rate *= f->pre_div + 1; } diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c index db9b2471ac40..bfb6d6065a90 100644 --- a/drivers/clk/qcom/common.c +++ b/drivers/clk/qcom/common.c @@ -29,6 +29,9 @@ struct freq_tbl *qcom_find_freq(const struct freq_tbl *f, unsigned long rate) if (!f) return NULL; + if (!f->freq) + return f; + for (; f->freq; f++) if (rate <= f->freq) return f; -- 2.20.1