Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5901741rdb; Sun, 17 Sep 2023 18:41:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGBieBYImgktZku0FyQ2Vq45H19/FIdL+81FW+H5eMHMRVG83MVMWI1TttcMLuWujRj7x4Q X-Received: by 2002:a05:6a00:1a92:b0:68f:b015:ea99 with SMTP id e18-20020a056a001a9200b0068fb015ea99mr10377361pfv.10.1695001294157; Sun, 17 Sep 2023 18:41:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695001294; cv=none; d=google.com; s=arc-20160816; b=nsRZjcuFw/CHynKagXCJom/QaSFY26Clfbk639eSgYdtCqR/JgKGyzthMjLRP9UZHI fZdEMWitVK8pvdjRn+521HBChFGPETTr59UsoN546wfeatgw7zkCzOr8DP/00dvlXMh/ taI1PwigF4fMRy0vGPHuD8Sooelr/rRpEFiMdS6at2AD/1YaqK83zBcjSBuV2ksWeXVz 6hMbvALqR2y6mUl2NY7ipT13Re10TNT7R6qhaopBPA7ttm2iUS4irZyIRUuLPvNjCucg C+3ZqNwxjPXBGapOUzjNlVCd3jzY9LqWbhkQpz/s0AgZctBxwCiQ+YFws2kvYb30CQoV s7yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=gCq7gxZ6dHwUyWczpY7Vh5cbaVAZn1kPig1Zw4rFZSA=; fh=GcDD8kqSv7mGJsBEaENS9NE07tpyWHOAMcs7aovMq10=; b=xQ3IsX/8uXHIKLoY3QFT5h0q+8CCasvVJ7EjqJLOUTYoMKmFb0JHj+WvaGm8ls1QOx ZduXYysN/nVdtuLpY2HvkyTnIFpvyuQD9WldM+tOzD6lsySDyxDCivDrZv0dDWadji+8 KgIBT3mp/TgA9oNcneuixV7b38W4tAGdAI0D38QyCNz/cRDwv3K0FeQ9PmXq4hR0Zbc3 /db6D9URo1lay3wIozZaaWg2f7PUg165yGESMU3+lLu9YgW5Qt97cP1VcijD8E//WLUr dhejGQjvCf71qQZuk1BiKEpz37Yj94TausmGDnFYDhmN/o9vHPnGMXwRI16ylTgMrOYM /vXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=c3gWT+kt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id bq10-20020a056a000e0a00b00686b62a6dc4si7173275pfb.145.2023.09.17.18.41.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 18:41:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=c3gWT+kt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1596D826EB85; Sun, 17 Sep 2023 15:47:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239531AbjIQWlG (ORCPT + 99 others); Sun, 17 Sep 2023 18:41:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235283AbjIQWkm (ORCPT ); Sun, 17 Sep 2023 18:40:42 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D5D512B; Sun, 17 Sep 2023 15:40:37 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-401ec23be82so41938855e9.0; Sun, 17 Sep 2023 15:40:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694990435; x=1695595235; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=gCq7gxZ6dHwUyWczpY7Vh5cbaVAZn1kPig1Zw4rFZSA=; b=c3gWT+ktkGFTAsvVOZqhzvIAYGwF0xff0TI/tiBaHCNA7vazqV8/L27g2EaeMjg/aK 3NTGmqVBnQaxqOomdOmrLGTyVfj7eDQZgZvdqg+MXT2+J0pKSt2KQGYifZ4P5O2NqH9N 5axvBr/eVnl6T+3PfiRS3zvp90aAY26AwNx+A79wpp9WH8FzpVleuI1AGNdled55l9eO OPwjK3u2W+bjfz4hCmcT05+aQ4T9V9AH7WgtvHo3y1whLZjtiMme5iH1YhzgLHiaOY6R j8d0/GTO9oGJFfLFOUvCSqVLnIuQ6KMhYYWXCL4eCmNObAS+UiszRuytendi60ww9SeW fnyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694990435; x=1695595235; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gCq7gxZ6dHwUyWczpY7Vh5cbaVAZn1kPig1Zw4rFZSA=; b=GpC49hf3RaUZOiJolYwihUaFW9kkuG/5i4Y+c4BybYMsB3S8qJY5cxLmWHmT5LiLan IDXzbg/yMCOVgf1dzd2p7qUyr9OatxEookUnFkVGFCAXUQdgv0cjcMcAjSmqpvXRe8EG GQ82byVUtY5NFSNxYAHcygDT5cfs5Q12e7eVLAw8S/8KaNVkxbDyzklwawvCU/iT/8d1 8VjsfTsUnnIWVav3rL9OTc6fw69NewtSziAcLimQtKbA3niYZrjJNbKbgHqNKeNLY5LR 7IuASN1CV/r3C5mCwwX5j9sTO/YI3V2k22PAv0ZaGjQh0CgZg9WODY3dlsNEvcUgtCfT nIcw== X-Gm-Message-State: AOJu0YxCW3X7LRuNogG1nI4GuZSICqHz7OdCDBo8y6oRn/vTlhVVnvbi zYa2p5CRnvCdBYfbXGmfIb4= X-Received: by 2002:a05:600c:21d7:b0:3fe:d1e9:e6b8 with SMTP id x23-20020a05600c21d700b003fed1e9e6b8mr6261880wmj.12.1694990435584; Sun, 17 Sep 2023 15:40:35 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id x14-20020a1c7c0e000000b003fe2b081661sm13642931wmc.30.2023.09.17.15.40.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:40:35 -0700 (PDT) From: Benjamin Bara Date: Mon, 18 Sep 2023 00:40:01 +0200 Subject: [PATCH 05/13] clk: keep track of the trigger of an ongoing clk_set_rate MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230918-imx8mp-dtsi-v1-5-1d008b3237c0@skidata.com> References: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> In-Reply-To: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Michael Turquette , Stephen Boyd , Russell King , Abel Vesa , Peng Fan Cc: Frank Oltmanns , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Sun, 17 Sep 2023 15:47:36 -0700 (PDT) From: Benjamin Bara When we keep track of the rate change trigger, we can easily check if an affected clock is affiliated with the trigger. Additionally, the trigger is added to the notify data, so that drivers can implement workarounds that might be necessary if a shared parent changes. Signed-off-by: Benjamin Bara --- drivers/clk/clk.c | 12 ++++++++++++ include/linux/clk.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 4954d31899ce..8f4f92547768 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -33,6 +33,9 @@ static struct task_struct *enable_owner; static int prepare_refcnt; static int enable_refcnt; +/* responsible for ongoing rate change, protected by prepare_lock */ +static struct clk *rate_trigger_clk; + static HLIST_HEAD(clk_root_list); static HLIST_HEAD(clk_orphan_list); static LIST_HEAD(clk_notifier_list); @@ -1742,6 +1745,7 @@ static int __clk_notify(struct clk_core *core, unsigned long msg, cnd.old_rate = old_rate; cnd.new_rate = new_rate; + cnd.trigger = rate_trigger_clk ? : core->parent->hw->clk; list_for_each_entry(cn, &clk_notifier_list, node) { if (cn->clk->core == core) { @@ -2513,6 +2517,8 @@ int clk_set_rate(struct clk *clk, unsigned long rate) /* prevent racing with updates to the clock topology */ clk_prepare_lock(); + rate_trigger_clk = clk; + if (clk->exclusive_count) clk_core_rate_unprotect(clk->core); @@ -2521,6 +2527,8 @@ int clk_set_rate(struct clk *clk, unsigned long rate) if (clk->exclusive_count) clk_core_rate_protect(clk->core); + rate_trigger_clk = NULL; + clk_prepare_unlock(); return ret; @@ -2556,6 +2564,8 @@ int clk_set_rate_exclusive(struct clk *clk, unsigned long rate) /* prevent racing with updates to the clock topology */ clk_prepare_lock(); + rate_trigger_clk = clk; + /* * The temporary protection removal is not here, on purpose * This function is meant to be used instead of clk_rate_protect, @@ -2568,6 +2578,8 @@ int clk_set_rate_exclusive(struct clk *clk, unsigned long rate) clk->exclusive_count++; } + rate_trigger_clk = NULL; + clk_prepare_unlock(); return ret; diff --git a/include/linux/clk.h b/include/linux/clk.h index 06f1b292f8a0..f0fe78c7a0f1 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -60,6 +60,7 @@ struct clk_notifier { /** * struct clk_notifier_data - rate data to pass to the notifier callback * @clk: struct clk * being changed + * @trigger: struct clk * being responsible for the change * @old_rate: previous rate of this clk * @new_rate: new rate of this clk * @@ -70,6 +71,7 @@ struct clk_notifier { */ struct clk_notifier_data { struct clk *clk; + struct clk *trigger; unsigned long old_rate; unsigned long new_rate; }; -- 2.34.1