From patchwork Mon Jan 22 10:57:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 125398 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1089192ljf; Mon, 22 Jan 2018 02:58:08 -0800 (PST) X-Google-Smtp-Source: AH8x22726PQkyL2lvX6XamN4Gszhidni/uoNAGdcmZYWVHSbOWH7FsWFt9jUcH/gpeM/WyAh4iPP X-Received: by 10.99.110.10 with SMTP id j10mr6870830pgc.72.1516618688555; Mon, 22 Jan 2018 02:58:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516618688; cv=none; d=google.com; s=arc-20160816; b=phOxnqO5EuHF43HndJ5qfCJX9/ppdnYicz+hkz0+ZZkAyfZ04Np7slO01MPR2KLj5K k6UEERTLc2E+0E6wonr5SR/3lcketFK4KkHtWhCRH9pjKmbUQRUZxoQiFcwkEs1C+W1M xcHs9BEzUUfTbZqj0PFYHBIBeL3DsSq/syHXsbzI6YmKthiE0/i5ETxIjE+zgE8XVNw/ /KKna85/7Wjn93tSH6uO2IbI8SlTw9xVWlFOjrDLNcbaE1lwxsgYpKND/qy0T3ugCiB/ /n8ep+wRwn7xCJo9mcn8nq1g2gu7Rcpkkn8QeLuOUgcZazTKmgRTuthTTXcRhvAnlkxY p/yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=oRR0W7SW7yTyMkeQHwvEav7OuzUy7mh1zPoF+RCU27Y=; b=u+x+mcLZGs5c5zb5ctXvvEpdocUkMleXovhBUtbiM7pjiWb4T6aWcxan6juNsGTp0o +j1XoCKK+2LFhfi4j2cmb/XELGFuSj5XZWQU252VgO1oVlXCsoWs/OOhaDsiSVLk0Uf7 c9TYzghCKh2bLo9/yo7/PgKW3Ty3ZNR6UakdfIaot9aosdMiKexR6GOt4a3s1iyGDPap eLnwAj67Eu9jQSxVwmjAW5RH9o9/LSY1cekVeiXXf4GhuHa9jGK2YnaKjj+oRMCAbU25 JibMYGQmA9XqAaaBvDqpnqy077esPtzNlZhaGxx46nzKOYjYCghYdM4YGcM9bTYFtiy8 EHkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=CIKlWlgR; 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 t5si13695394pgb.595.2018.01.22.02.58.08; Mon, 22 Jan 2018 02:58:08 -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=CIKlWlgR; 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 S1751108AbeAVK6G (ORCPT + 28 others); Mon, 22 Jan 2018 05:58:06 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:39929 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750925AbeAVK6E (ORCPT ); Mon, 22 Jan 2018 05:58:04 -0500 Received: by mail-wr0-f196.google.com with SMTP id z48so8141806wrz.6 for ; Mon, 22 Jan 2018 02:58:04 -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; bh=oRR0W7SW7yTyMkeQHwvEav7OuzUy7mh1zPoF+RCU27Y=; b=CIKlWlgRnlZ2olt50/e/p3pzMsIFP70Bj94vgeJ4P4kAgRamINqmdelJnehqXPmOFo 6oxgiSg0c3Il8DIwy8azVNUi/Tu7OIl5lUTDe/Q2iWh15MWISqUPV6+7iqSB0BEhl4vj btzjme0Mg82zuJz97BS0Kux/2IUmvdpf3hqE7NTtmQGpW7Dl4ZmYbvPAYrWRhQqq9MWN 0v9KaObi9MwwwNuLolfVHJt/wK2G6wLDeM65GC/zqAA0VrVOdVt8gJ6s+ipx+HnZGZI/ 74vDSC18kONBcNDcJUvG86h1ULHbHNsIEfWGrud2U/9g/gn5ogUsgL+6kln1cJj1aVaj YCbg== 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; bh=oRR0W7SW7yTyMkeQHwvEav7OuzUy7mh1zPoF+RCU27Y=; b=ERergA5eUgS2swgvrb9cbDbDSqRpO5TZ7W06OWRL2ZFE5TCfcos1LDoj9YWuaZ4DiG HsYGM35M1ZrEX1Eco9pcCfzmmYcNALl76aWQI8tA5NU/c6nyVP4+Vooz7DKibYXt7KVt eMnJEVqc0sa1jhIk+P+PjyMhjBtq2OBtpN2BQowIQqBEWfeB0WrOhGVcH1z5iLHXTzgA +1CPrZtSa1eKqL86aL7Gf+LLwtBLIFMiowo6Fj/dkxSrwHqapNDDXnBwr9co03WcZI3G Yu/L7og4W0RBfERTYvwKHdScCcGtp2UXDBuQ9Eirn8jqxhJDhTq/gFlKhRrAsU6wTnbf EGvw== X-Gm-Message-State: AKwxytcxML5K0NLGk5Bam/01l3dgNjjjZNE2N7gs0Bqy0rTo6HdhROyk fqTfUFIs1BhUcKZW11JWeTEyEQ== X-Received: by 10.223.184.197 with SMTP id c5mr6179779wrg.105.1516618683442; Mon, 22 Jan 2018 02:58:03 -0800 (PST) Received: from boomer.baylibre.local ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id r64sm5952321wma.15.2018.01.22.02.58.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jan 2018 02:58:02 -0800 (PST) From: Jerome Brunet To: Stephen Boyd , Michael Turquette Cc: Jerome Brunet , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] clk: fix determine rate error with pass-through clock Date: Mon, 22 Jan 2018 11:57:59 +0100 Message-Id: <20180122105759.12206-1-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.3 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 e24968fa31db..c43d99284290 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1116,8 +1116,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);