Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp941296pxb; Wed, 6 Apr 2022 04:56:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdPAuJjWlDqSL+ifT5vyUf3EY6W6lPADc3YuIO+X1HQ2PUR9l1qNGe4smW1xm+h05/eE6s X-Received: by 2002:a17:902:708b:b0:156:1a0a:5c3d with SMTP id z11-20020a170902708b00b001561a0a5c3dmr8258520plk.18.1649246186424; Wed, 06 Apr 2022 04:56:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649246186; cv=none; d=google.com; s=arc-20160816; b=QhM2ViovAULoBIg548TW7f7Ve36ZGWIJ+zrQvZcz0lryvvlw9cFYeejbMqO9CnVaro dQbPCovQqJc5mKKEf7BO8329/fBnbSNb/23XId9T47Dz8bhLmt673G4kbVSabB2gDGHl wq0QPHzG/jYTWjiE+HbId9A97AdBN+yVoaRyGP4S0uNdn6pHbUIV+NZV3OH6PV+ofQUE zJzdmtQtGDEJM08XxfZ1uq2+mMFJTWpEzeRmQTm/46ri7SQJ1HHTbodQkLscOC+O6wF5 PJnSZSPTabFNIGGXhoY+4IX7ixXTTT7Q+RDjOoVX3uswj4KhbhlbQPeZcN4feTJLdJ8C 4k/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Zbg+XiAcDJ4bo8VtRHG3CfF3L/XaOsy1wh8hAY7Uo+Q=; b=b4xWg7r4QKz8YgtfTk5nZlbJZHVUumiCb/CnuN2D8WwK1bdxo4TG/92iUjvIh/ia3F QZhSls/50/rEiS8358GmHmG8TDzogztdF7hnh5QgHpDr/f9puHelbgJzvwuybTU2uQCu 2ofnKRZMPpDuoPr6GcaR0uZgb8V4caSVNzi732+9WYtMRAuT5rXZBWjf/2auVnKNbp1q HyYo5cEZ+CngaF2ezhvzcqmaZJeNCpxl2RUXWJ/5iZktcsYlJR/lGCewf1dlsRMySF8N 0ai5z3kJRIhXho71KSuxaMRbRPWEP68beCEGQHrWRnBgX80pZE8QH3II5Uy5OVeWIRh4 iZhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ChlkDajj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z10-20020a170903018a00b00156c0b0a429si6982592plg.116.2022.04.06.04.56.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 04:56:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ChlkDajj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0B8D0651207; Wed, 6 Apr 2022 03:18:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1842069AbiDFB04 (ORCPT + 99 others); Tue, 5 Apr 2022 21:26:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234591AbiDEKfQ (ORCPT ); Tue, 5 Apr 2022 06:35:16 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1305E3B2B7; Tue, 5 Apr 2022 03:20:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C1933B81BC5; Tue, 5 Apr 2022 10:20:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F1CBC385A1; Tue, 5 Apr 2022 10:20:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649154043; bh=iGOaU2i15VbzWQLnZXbCeWm1YGT/GMhnFIK35uqmUXc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ChlkDajjTLZ9qClQdbZ1XsvVy2qGGZ/wg7+7W9ZR2cHIQnnn3hK1DUMxhOdYpD1Jg EwUZQSr2ukc1/1iE4hRJwYRSvgxA8GjaK3+bp7Vmlzvy6tDs32eq2jVQQKVoiNz/vr 29VyxtnEC5Y1yRJd/5G+vH6njEl7BFAy/c2HTaZc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Osipenko , Maxime Ripard , Stephen Boyd , Sasha Levin Subject: [PATCH 5.10 436/599] clk: Initialize orphan req_rate Date: Tue, 5 Apr 2022 09:32:10 +0200 Message-Id: <20220405070311.806309623@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070258.802373272@linuxfoundation.org> References: <20220405070258.802373272@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maxime Ripard [ Upstream commit 5f7e2af00807f2117650e711a58b7f0e986ce1df ] When registering a clock that doesn't have a recalc_rate implementation, and doesn't have its parent registered yet, we initialize the clk_core rate and 'req_rate' fields to 0. The rate field is later updated when the parent is registered in clk_core_reparent_orphans_nolock() using __clk_recalc_rates(), but the 'req_rate' field is never updated. This leads to an issue in clk_set_rate_range() and clk_put(), since those functions will call clk_set_rate() with the content of 'req_rate' to provide drivers with the opportunity to change the rate based on the new boundaries. In this case, we would call clk_set_rate() with a rate of 0, effectively enforcing the minimum allowed for this clock whenever we would call one of those two functions, even though the actual rate might be within range. Let's fix this by setting 'req_rate' in clk_core_reparent_orphans_nolock() with the rate field content just updated by the call to __clk_recalc_rates(). Fixes: 1c8e600440c7 ("clk: Add rate constraints to clocks") Reported-by: Dmitry Osipenko Tested-by: Dmitry Osipenko # T30 Nexus7 Signed-off-by: Maxime Ripard Link: https://lore.kernel.org/r/20220325161144.1901695-2-maxime@cerno.tech [sboyd@kernel.org: Reword comment] Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/clk.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index b8a0e3d23698..92fc084203b7 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3384,6 +3384,19 @@ static void clk_core_reparent_orphans_nolock(void) __clk_set_parent_after(orphan, parent, NULL); __clk_recalc_accuracies(orphan); __clk_recalc_rates(orphan, 0); + + /* + * __clk_init_parent() will set the initial req_rate to + * 0 if the clock doesn't have clk_ops::recalc_rate and + * is an orphan when it's registered. + * + * 'req_rate' is used by clk_set_rate_range() and + * clk_put() to trigger a clk_set_rate() call whenever + * the boundaries are modified. Let's make sure + * 'req_rate' is set to something non-zero so that + * clk_set_rate_range() doesn't drop the frequency. + */ + orphan->req_rate = orphan->rate; } } } -- 2.34.1