From patchwork Mon Aug 17 15:11:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 247808 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp2741734ilo; Mon, 17 Aug 2020 08:43:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdYZ39y6ncEXFBUGnzPd/n3CMJs8Skts+Hj9dmXNnohL4inPjpWxacHEbZG6EwrlI5kEWT X-Received: by 2002:a17:907:aaa:: with SMTP id bz10mr15496201ejc.304.1597679006803; Mon, 17 Aug 2020 08:43:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597679006; cv=none; d=google.com; s=arc-20160816; b=WcZ3gA4knQbEm9BqXQZZrrJmye1ofHpjG8OG5IMq1tq7e2ws6cEFN6U1VvNLIrMZxG /pvbnqRVvmoJ0Sr9LMvC11IH8Q99BPTuatLMYKVEoDVX4uF0k5arYnrfTcbNEY7Um/vF bx7l+eOAVmRcKc7PaL/lUYgFsNB/EXTIcgWijdmbbnQLPDFNPJmF7bkP7Mxr9DV+Z/7R BLmvR23e+4S5AGYNrfFd4SCU0Ki/jl/+0Q37j9pUgKgeMj9a0K3pJmuOmHNUzuL5Ulrm 1Lec9Uf1SljSeLG1CYW7Mcr/8HdMkqVZiq9z+LX9otaGwjhv0GOX42R+Mvry6JutzGwx yD+A== 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=ou7rZfZe7AFWOz+CZGqIqVteq6eI/RuNBxwRb2VP08A=; b=oiEkqczE6ksrCOXHGVonybSXA1OI7LeR2PjVZRfqgz+NFGE2NwL7MsTfCAmJe/6+x2 I0T0tcOaxjBhBr7kY/sWAGq7mj8gPR7mJxSxTgaIt8+c8G51p60Li7844ijlWbSHTcGY dC6OwuRyKQZSWYdvIQRNbRvZBCpXc/2OYAVv2uQIT7gK2Jk5UixDNGG8yfnzVsHXieb2 JqfWQKRg9e7O0WhQjgRKmtChi24M5rwBzIlgBa9iagRiR99mxGrK+5wG+MTMwss9BEg2 RvpRQ+1c91Xn5MCcusxX8QJUNA0l/rTXWVIa1RKrYqrms/NfKSp7LPJOQhhkY+uFKOtD CVVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nnGNccX3; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs9si11423695edb.396.2020.08.17.08.43.26; Mon, 17 Aug 2020 08:43:26 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nnGNccX3; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387637AbgHQPnX (ORCPT + 15 others); Mon, 17 Aug 2020 11:43:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:53482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387621AbgHQPnM (ORCPT ); Mon, 17 Aug 2020 11:43:12 -0400 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 6BF7122D74; Mon, 17 Aug 2020 15:43:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678989; bh=5FS1bRYbhh3iZG9BJtPW8I/Q7cLQiRbWaIwY811DndM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nnGNccX344tbtl4VPDPRHnKE2H86xgP7M0kfsbnWnPEl0qCkJFTndxQADzyT1uwvV jAEsHInawi5Fk/qCLQgfmVa1tnwad0kLaitaRO69MyVIZCn15Zar+bXIHnTisylbiZ ZM12IwqFbkienaE88ih2GrkcKRQYDKg15q60NQgw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Boyd , Sudeep Holla , Sasha Levin , Dien Pham Subject: [PATCH 5.7 028/393] clk: scmi: Fix min and max rate when registering clocks with discrete rates Date: Mon, 17 Aug 2020 17:11:18 +0200 Message-Id: <20200817143820.974286859@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143819.579311991@linuxfoundation.org> References: <20200817143819.579311991@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sudeep Holla [ Upstream commit fcd2e0deae50bce48450f14c8fc5611b08d7438c ] Currently we are not initializing the scmi clock with discrete rates correctly. We fetch the min_rate and max_rate value only for clocks with ranges and ignore the ones with discrete rates. This will lead to wrong initialization of rate range when clock supports discrete rate. Fix this by using the first and the last rate in the sorted list of the discrete clock rates while registering the clock. Link: https://lore.kernel.org/r/20200709081705.46084-2-sudeep.holla@arm.com Fixes: 6d6a1d82eaef7 ("clk: add support for clocks provided by SCMI") Reviewed-by: Stephen Boyd Reported-and-tested-by: Dien Pham Signed-off-by: Sudeep Holla Signed-off-by: Sasha Levin --- drivers/clk/clk-scmi.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) -- 2.25.1 diff --git a/drivers/clk/clk-scmi.c b/drivers/clk/clk-scmi.c index c491f5de0f3f4..c754dfbb73fd4 100644 --- a/drivers/clk/clk-scmi.c +++ b/drivers/clk/clk-scmi.c @@ -103,6 +103,8 @@ static const struct clk_ops scmi_clk_ops = { static int scmi_clk_ops_init(struct device *dev, struct scmi_clk *sclk) { int ret; + unsigned long min_rate, max_rate; + struct clk_init_data init = { .flags = CLK_GET_RATE_NOCACHE, .num_parents = 0, @@ -112,9 +114,23 @@ static int scmi_clk_ops_init(struct device *dev, struct scmi_clk *sclk) sclk->hw.init = &init; ret = devm_clk_hw_register(dev, &sclk->hw); - if (!ret) - clk_hw_set_rate_range(&sclk->hw, sclk->info->range.min_rate, - sclk->info->range.max_rate); + if (ret) + return ret; + + if (sclk->info->rate_discrete) { + int num_rates = sclk->info->list.num_rates; + + if (num_rates <= 0) + return -EINVAL; + + min_rate = sclk->info->list.rates[0]; + max_rate = sclk->info->list.rates[num_rates - 1]; + } else { + min_rate = sclk->info->range.min_rate; + max_rate = sclk->info->range.max_rate; + } + + clk_hw_set_rate_range(&sclk->hw, min_rate, max_rate); return ret; }