Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3487743pxb; Mon, 4 Apr 2022 18:34:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0tQiOLahgNaqOU8xPdRcNA0oO1MAPKFp70mWQcDeNBYFeHJIcbQr04kIAR5f2m/Spfs4u X-Received: by 2002:a65:41cc:0:b0:380:6f53:a550 with SMTP id b12-20020a6541cc000000b003806f53a550mr809120pgq.471.1649122485030; Mon, 04 Apr 2022 18:34:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649122485; cv=none; d=google.com; s=arc-20160816; b=hlOGGF0kFoDjf/eQc0dvbAlpQZIOIY3EMj+M2XYhAPascIjk8AQQSNeCmqyPohC4Yi sfMFrGZ8r6VIHREsljrF0BoYxUeQktsW0nn7wWpGEzNSc0/Jp20k3GT27S0GsDXa5ak5 8SGMWijyZkikhFFijupYRqfR1cedVKiS5q/LOLvXrR86cCKOXOulKPPHxhSzGB8pVawb 52lGS3bcdj+OicCmt/HMvedVINBzCoIiWXhbA4xoLbNEg1Qintly6khacX0r0iHNRhXm OnAVihlRkTAAXZL5cnsFK3W0zIuLNkatyTBJVayqpi83Shg+JUBZMrVcATaYMR4akUhj DVig== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=5cIemgPmLEn2pK5R2pG6uDUCBth/mGCGRpbafJA6UxE=; b=IDBWxomtVxw2fIz7JLOJLTP4sNZG31mBwZ6j8/SEpLH7EGlYHryRzPBnh/F2HQW1/4 btJynPn6HLZYn/vzMuY0MVVH0D/YmREd/wzo+nlyLrse7oqdfgtvYE2DX5WEpNDpldt0 aKOHnrt+7lWmooIcYWwkvVCtDKNdji/ih9ss0c3xQS/TSbOoyzXUoKLsa+uaNWbRueDB 00PX3jNHbkz97a15zR+Fd732zMB2DFNuTn3MpoyOUmVff3QB49gct9lUQEROek60djyA u2HyGIEybj8SCMLyPVV0NhGJbsg43mxK8lEE/yXJOv7LKa/edzZKb+WXMkYR5kdqtNfW dS8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="qygqY/f6"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id pc5-20020a17090b3b8500b001cac43b54c3si843222pjb.150.2022.04.04.18.34.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 18:34:45 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="qygqY/f6"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B422B1CAF34; Mon, 4 Apr 2022 17:24:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230326AbiDCCaO (ORCPT + 99 others); Sat, 2 Apr 2022 22:30:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229565AbiDCCaO (ORCPT ); Sat, 2 Apr 2022 22:30:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A42B8C05; Sat, 2 Apr 2022 19:28:20 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 21F4860E9D; Sun, 3 Apr 2022 02:28:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D548C340EE; Sun, 3 Apr 2022 02:28:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648952899; bh=nnm23szrmLAxXkfUdshG+TguQlKGlYZQUc5dMRlfJqs=; h=From:To:Cc:Subject:Date:From; b=qygqY/f6QiWvkb96YSDbAeI9UTf1WveoFoPN+knzJDXIfA1TPM2hNWr4n0tTzheu+ jyb3eOm8qHpubt/ar6jd0AqEV1EQsaZ3wspBMxYMuZlWW5yVLyDE4SEGXjwEWLAL25 SVZbLZZuNMFEs4ff7hI82Op+Tp+xusAK/j94YtP2/ywYZgiCiaw5FxxlYa+BQ4Orhr nVefTpSmFxHlyWlpnjPEis8YtIzPaYJ1KDVrC7vjzudaC59yMXT6pNCSynfQv6awcT fVbAKq+gjgUy9F94z3BQOuhiAM0DoR+nUDa3WqVlXKQiwdy7I0oPzkfq9Ywxkhd38w +xM7D4AR5JQ1Q== From: Stephen Boyd To: Michael Turquette , Stephen Boyd Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Marek Szyprowski , Tony Lindgren , Alexander Stein , Naresh Kamboju , Maxime Ripard Subject: [PATCH] Revert "clk: Drop the rate range on clk_put()" Date: Sat, 2 Apr 2022 19:28:18 -0700 Message-Id: <20220403022818.39572-1-sboyd@kernel.org> X-Mailer: git-send-email 2.35.1.1094.g7c7d902a7c-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 This reverts commit 7dabfa2bc4803eed83d6f22bd6f045495f40636b. There are multiple reports that this breaks boot on various systems. The common theme is that orphan clks are having rates set on them when that isn't expected. Let's revert it out for now so that -rc1 boots. Reported-by: Marek Szyprowski Reported-by: Tony Lindgren Reported-by: Alexander Stein Reported-by: Naresh Kamboju Link: https://lore.kernel.org/r/366a0232-bb4a-c357-6aa8-636e398e05eb@samsung.com Cc: Maxime Ripard Signed-off-by: Stephen Boyd --- drivers/clk/clk.c | 42 ++++++---------- drivers/clk/clk_test.c | 108 ----------------------------------------- 2 files changed, 14 insertions(+), 136 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 07a27b65b773..ed119182aa1b 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2332,15 +2332,19 @@ int clk_set_rate_exclusive(struct clk *clk, unsigned long rate) } EXPORT_SYMBOL_GPL(clk_set_rate_exclusive); -static int clk_set_rate_range_nolock(struct clk *clk, - unsigned long min, - unsigned long max) +/** + * clk_set_rate_range - set a rate range for a clock source + * @clk: clock source + * @min: desired minimum clock rate in Hz, inclusive + * @max: desired maximum clock rate in Hz, inclusive + * + * Returns success (0) or negative errno. + */ +int clk_set_rate_range(struct clk *clk, unsigned long min, unsigned long max) { int ret = 0; unsigned long old_min, old_max, rate; - lockdep_assert_held(&prepare_lock); - if (!clk) return 0; @@ -2353,6 +2357,8 @@ static int clk_set_rate_range_nolock(struct clk *clk, return -EINVAL; } + clk_prepare_lock(); + if (clk->exclusive_count) clk_core_rate_unprotect(clk->core); @@ -2396,28 +2402,6 @@ static int clk_set_rate_range_nolock(struct clk *clk, if (clk->exclusive_count) clk_core_rate_protect(clk->core); - return ret; -} - -/** - * clk_set_rate_range - set a rate range for a clock source - * @clk: clock source - * @min: desired minimum clock rate in Hz, inclusive - * @max: desired maximum clock rate in Hz, inclusive - * - * Return: 0 for success or negative errno on failure. - */ -int clk_set_rate_range(struct clk *clk, unsigned long min, unsigned long max) -{ - int ret; - - if (!clk) - return 0; - - clk_prepare_lock(); - - ret = clk_set_rate_range_nolock(clk, min, max); - clk_prepare_unlock(); return ret; @@ -4419,7 +4403,9 @@ void __clk_put(struct clk *clk) } hlist_del(&clk->clks_node); - clk_set_rate_range_nolock(clk, 0, ULONG_MAX); + if (clk->min_rate > clk->core->req_rate || + clk->max_rate < clk->core->req_rate) + clk_core_set_rate_nolock(clk->core, clk->core->req_rate); owner = clk->core->owner; kref_put(&clk->core->ref, __clk_release); diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index fd2339cc5898..6731a822f4e3 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -760,65 +760,9 @@ static void clk_range_test_multiple_set_range_rate_maximized(struct kunit *test) clk_put(user1); } -/* - * Test that if we have several subsequent calls to - * clk_set_rate_range(), across multiple users, the core will reevaluate - * whether a new rate is needed, including when a user drop its clock. - * - * With clk_dummy_maximize_rate_ops, this means that the rate will - * trail along the maximum as it evolves. - */ -static void clk_range_test_multiple_set_range_rate_put_maximized(struct kunit *test) -{ - struct clk_dummy_context *ctx = test->priv; - struct clk_hw *hw = &ctx->hw; - struct clk *clk = hw->clk; - struct clk *user1, *user2; - unsigned long rate; - - user1 = clk_hw_get_clk(hw, NULL); - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user1); - - user2 = clk_hw_get_clk(hw, NULL); - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user2); - - KUNIT_ASSERT_EQ(test, - clk_set_rate(clk, DUMMY_CLOCK_RATE_2 + 1000), - 0); - - KUNIT_ASSERT_EQ(test, - clk_set_rate_range(user1, - 0, - DUMMY_CLOCK_RATE_2), - 0); - - rate = clk_get_rate(clk); - KUNIT_ASSERT_GT(test, rate, 0); - KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); - - KUNIT_ASSERT_EQ(test, - clk_set_rate_range(user2, - 0, - DUMMY_CLOCK_RATE_1), - 0); - - rate = clk_get_rate(clk); - KUNIT_ASSERT_GT(test, rate, 0); - KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); - - clk_put(user2); - - rate = clk_get_rate(clk); - KUNIT_ASSERT_GT(test, rate, 0); - KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); - - clk_put(user1); -} - static struct kunit_case clk_range_maximize_test_cases[] = { KUNIT_CASE(clk_range_test_set_range_rate_maximized), KUNIT_CASE(clk_range_test_multiple_set_range_rate_maximized), - KUNIT_CASE(clk_range_test_multiple_set_range_rate_put_maximized), {} }; @@ -933,61 +877,9 @@ static void clk_range_test_multiple_set_range_rate_minimized(struct kunit *test) clk_put(user1); } -/* - * Test that if we have several subsequent calls to - * clk_set_rate_range(), across multiple users, the core will reevaluate - * whether a new rate is needed, including when a user drop its clock. - * - * With clk_dummy_minimize_rate_ops, this means that the rate will - * trail along the minimum as it evolves. - */ -static void clk_range_test_multiple_set_range_rate_put_minimized(struct kunit *test) -{ - struct clk_dummy_context *ctx = test->priv; - struct clk_hw *hw = &ctx->hw; - struct clk *clk = hw->clk; - struct clk *user1, *user2; - unsigned long rate; - - user1 = clk_hw_get_clk(hw, NULL); - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user1); - - user2 = clk_hw_get_clk(hw, NULL); - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, user2); - - KUNIT_ASSERT_EQ(test, - clk_set_rate_range(user1, - DUMMY_CLOCK_RATE_1, - ULONG_MAX), - 0); - - rate = clk_get_rate(clk); - KUNIT_ASSERT_GT(test, rate, 0); - KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); - - KUNIT_ASSERT_EQ(test, - clk_set_rate_range(user2, - DUMMY_CLOCK_RATE_2, - ULONG_MAX), - 0); - - rate = clk_get_rate(clk); - KUNIT_ASSERT_GT(test, rate, 0); - KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2); - - clk_put(user2); - - rate = clk_get_rate(clk); - KUNIT_ASSERT_GT(test, rate, 0); - KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1); - - clk_put(user1); -} - static struct kunit_case clk_range_minimize_test_cases[] = { KUNIT_CASE(clk_range_test_set_range_rate_minimized), KUNIT_CASE(clk_range_test_multiple_set_range_rate_minimized), - KUNIT_CASE(clk_range_test_multiple_set_range_rate_put_minimized), {} }; -- https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/ https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git