From patchwork Wed Feb 14 13:43:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 128349 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp625708ljc; Wed, 14 Feb 2018 05:48:07 -0800 (PST) X-Google-Smtp-Source: AH8x224OUy23cxxV0hC9wjfWwJkLfy+WFOeXGKyFiiqYbJyclW3zxc1tefuh42D5CqpOQEkv77EM X-Received: by 10.98.201.89 with SMTP id k86mr4827489pfg.105.1518616087525; Wed, 14 Feb 2018 05:48:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518616087; cv=none; d=google.com; s=arc-20160816; b=uDoX2rAS+fJzvLy20h1K9CFYU0YN8XbO9ZaphrAWiyfcV9hGvEqQ3DZJ3Qwzqo7IOS ac+POb5WIMXudSQgXrAmXM22XgkIr0pyESZTJD7bVFM9JSfxCMZPxxBuPYqPZEZjG3bg ERgrYh0xN8nkpI8Oo0Rrs4gB4xI95M8y5PV0KZGDCfdX/flzL1m3rqniwF4a9FP/ndN+ yNIYskwijF6i89uGOM7kHYGICaUY5tB+35ejDAvJvTpHwTDvb6D1M3mXkepPW6v92yki zPxdopx73BDboRag8QDXc5sQJXN6pAIlpugacLpdmdZkNuWQuWEujMuIq4AXyEz43x1I gSsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=sx8n2q0ivN7mVA6n3yyaj8Jh74CEu0575DPKFiZAaxI=; b=mm9ADtDI3sBXMTIJgmTGS43nZhvLbB8R7vvCPpO/n1VevfCkSlsdWCsbsjwstiACf7 QRqp/7/Q2fJGCouWaOulKVS/4WRHwwLL7flZv5bumGLHaJ1WmFZhqcmQ0TUR+O/Oj3XQ TadKW9f7kX6aZnUYy6U1KRvybmmJnson5o9IxkIrK4eAf2PObg0x0Oxi4TgkXtlYGoC7 2KT1jVF8BO3D2LdEzr83FYX65eqR9vsulV+HATSpx+8GR+iVJ8UVjAYoYKmUIm8Ul7C7 HOkdnjMocYLrzWvRC/bQcd9LTRsPeQpeI+SLzPPT/IyoTdZsMgaOvIUlel4Pl5D56Qd2 6iFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=HcCvjGFe; 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 j75si1714007pfk.372.2018.02.14.05.48.07; Wed, 14 Feb 2018 05:48:07 -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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=HcCvjGFe; 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 S1030493AbeBNNsD (ORCPT + 28 others); Wed, 14 Feb 2018 08:48:03 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:37143 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030301AbeBNNnt (ORCPT ); Wed, 14 Feb 2018 08:43:49 -0500 Received: by mail-wr0-f194.google.com with SMTP id k32so15704619wrk.4 for ; Wed, 14 Feb 2018 05:43:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sx8n2q0ivN7mVA6n3yyaj8Jh74CEu0575DPKFiZAaxI=; b=HcCvjGFefsF3M1+WbqcaMXjtpQXLQvNnBs2AKxRtMy8s2MtFYO/c0DPIOmME33klUe HLWQTwZNaEP/AcATXbS7leT+CliYiJcKA0R9JEwvoizmrrobZJ2I4eKYqvEqZk1P3eQ6 wWmmJ4A1CQ7A54S4OTiDlLexTtReSlqoeTsn8u+EmI/smX3eFNOe9jVitJ9/DpcOt3Jv 2T1qPTkW/B6MUlS52FdtyhiMC7SdcMNvY0fTQpgDF1Me3p6wjQpFMJGCopNTSP1d+Oln EiqY+v2kTJgVoZhsJAxKRhCpjJFEl0myyS/HaintCZI2b1mf9B4DEGJfFY3BAYxZIY31 aX3A== 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=sx8n2q0ivN7mVA6n3yyaj8Jh74CEu0575DPKFiZAaxI=; b=Pesc75keB82msdI+rtGLHUoWovIAVqfez3v/Oy5J6W9gwN/7+5kApaAHkbJ7tbWM58 ozNaIstcbLQvLpWmWOTtinjSpVnwWymVFQKJOuYeheOYhYEVBOBH8wsXe4ziTlORKLGI GwZScgri/x4O9DDVo4ehVg0oi5uUb0rmayCreRCd0iXgb+zrDhjFbxUzP/inPmou6Wrq sLYzdUQnTKovniUmD/TOMmKzCPMYgs3EakP89MB1RzHK6EUrwVGkRlvHdYOcL9qTC7jk x+NUuPQqGQel/vsviP7tzneG3Jcjf/DIbpmV2XeRkHmzqzfFUkOmnJy59bfwgu9qur8C vIlw== X-Gm-Message-State: APf1xPDe2h4yove8ivLMwwZZ2kbCcuYa9IFPoFaAmqOetvU+kNVnPEZJ go5NCsPjm5sy5ek0/2XCL0vt0w== X-Received: by 10.223.130.166 with SMTP id 35mr4857537wrc.251.1518615828006; Wed, 14 Feb 2018 05:43:48 -0800 (PST) Received: from boomer.lan (cag06-3-82-243-161-21.fbx.proxad.net. [82.243.161.21]) by smtp.googlemail.com with ESMTPSA id k5sm6337694wmg.47.2018.02.14.05.43.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2018 05:43:47 -0800 (PST) From: Jerome Brunet To: Michael Turquette , Stephen Boyd Cc: Jerome Brunet , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/8] clk: fix determine rate error with pass-through clock Date: Wed, 14 Feb 2018 14:43:35 +0100 Message-Id: <20180214134340.17242-4-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180214134340.17242-1-jbrunet@baylibre.com> References: <20180214134340.17242-1-jbrunet@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we try to determine the rate of a pass-through clock (a clock which does not implement .round_rate() nor .determine_rate()), clk_core_round_rate_nolock() will directly forward the call to the parent clock. In the particular case where the pass-through actually does not have a parent, clk_core_round_rate_nolock() will directly return 0 with the requested rate still set to the initial request structure. This is interpreted as if the rate could be exactly achieved while it actually cannot be adjusted. This become a real problem when this particular pass-through clock is the parent of a mux with the flag CLK_SET_RATE_PARENT set. The pass-through clock will always report an exact match, get picked and finally error when the rate is actually getting set. This is fixed by setting the rate inside the req to 0 when core is NULL in clk_core_round_rate_nolock() (same as in __clk_determine_rate() when hw is NULL) Fixes: 0f6cc2b8e94d ("clk: rework calls to round and determine rate callbacks") Signed-off-by: Jerome Brunet --- drivers/clk/clk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.14.3 diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 0f686a9dac3e..a4b4e4d6df5e 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1125,8 +1125,10 @@ static int clk_core_round_rate_nolock(struct clk_core *core, { lockdep_assert_held(&prepare_lock); - if (!core) + if (!core) { + req->rate = 0; return 0; + } clk_core_init_rate_req(core, req);