From patchwork Tue Dec 4 19:24:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 10712501 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E55D13AF for ; Tue, 4 Dec 2018 19:26:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 908F1284F9 for ; Tue, 4 Dec 2018 19:26:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 843F02C01E; Tue, 4 Dec 2018 19:26:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 348662C53E for ; Tue, 4 Dec 2018 19:26:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sCOu16FdPYOsNOZCCkUlLJgtrqaf1CcN/EHOzV4VAbk=; b=nw88PqeKyABwON KbOgbfh/RcZpx0mFcHCiT5ZQhxEF51mc62VbJQ/BLpXOZeBkDZj3V+s3pFPRxPfNcFxhOILe0Zd0+ cAlbFCaN/W5cTRhYn2/ZwRxD4/mYvwAIwDTSUbst5NHy/crObL97FS62eISf3qv2gwz3hAcfsS87L /26bWtMZgKxKiDIGuObaR9TUmTxEzcpSQuIza9dIhia9SiiEFyKZ/UVVSXIpr4qMaCoWcO8V0Z3OD VO1g5nQLh+Gxlu4847wciQXl5Dac5bgIj4o//0Az03s7KruHLY+Nw3YblRId7W6LSma1qpVNSPKso NP720VFuSPbYkGfgsqHQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUGKY-0007AK-I4; Tue, 04 Dec 2018 19:26:02 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUGJb-0005Kv-VO for linux-arm-kernel@lists.infradead.org; Tue, 04 Dec 2018 19:25:07 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 2EF4C2087D; Tue, 4 Dec 2018 20:24:53 +0100 (CET) Received: from localhost.localdomain (unknown [91.224.148.103]) by mail.bootlin.com (Postfix) with ESMTPSA id 62B4B207A8; Tue, 4 Dec 2018 20:24:42 +0100 (CET) From: Miquel Raynal To: Michael Turquette , Stephen Boyd , Russell King Subject: [PATCH v3 1/4] clk: core: clarify the check for runtime PM Date: Tue, 4 Dec 2018 20:24:37 +0100 Message-Id: <20181204192440.12125-2-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181204192440.12125-1-miquel.raynal@bootlin.com> References: <20181204192440.12125-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181204_112504_190798_87822F82 X-CRM114-Status: GOOD ( 17.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Antoine Tenart , Gregory Clement , linux-kernel@vger.kernel.org, Maxime Chevallier , Nadav Haklai , Thomas Petazzoni , Miquel Raynal , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, the core->dev entry is populated only if runtime PM is enabled. Doing so prevents accessing the device structure in any case. Keep the same logic but instead of using the presence of core->dev as the only condition, also check the status of pm_runtime_enabled(). Then, we can set the core->dev pointer at any time as long as a device structure is available. This change will help supporting device links in the clock subsystem. Signed-off-by: Miquel Raynal --- drivers/clk/clk.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index af011974d4ec..b799347c5fd6 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -97,7 +97,7 @@ static int clk_pm_runtime_get(struct clk_core *core) { int ret = 0; - if (!core->dev) + if (!core->dev || !pm_runtime_enabled(core->dev)) return 0; ret = pm_runtime_get_sync(core->dev); @@ -106,7 +106,7 @@ static int clk_pm_runtime_get(struct clk_core *core) static void clk_pm_runtime_put(struct clk_core *core) { - if (!core->dev) + if (!core->dev || !pm_runtime_enabled(core->dev)) return; pm_runtime_put_sync(core->dev); @@ -226,7 +226,7 @@ static bool clk_core_is_enabled(struct clk_core *core) * taking enable spinlock, but the below check is needed if one tries * to call it from other places. */ - if (core->dev) { + if (core->dev && pm_runtime_enabled(core->dev)) { pm_runtime_get_noresume(core->dev); if (!pm_runtime_active(core->dev)) { ret = false; @@ -236,7 +236,7 @@ static bool clk_core_is_enabled(struct clk_core *core) ret = core->ops->is_enabled(core->hw); done: - if (core->dev) + if (core->dev && pm_runtime_enabled(core->dev)) pm_runtime_put(core->dev); return ret; @@ -3272,8 +3272,7 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw) } core->ops = hw->init->ops; - if (dev && pm_runtime_enabled(dev)) - core->dev = dev; + core->dev = dev; if (dev && dev->driver) core->owner = dev->driver->owner; core->hw = hw; From patchwork Tue Dec 4 19:24:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 10712503 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83C4D13BF for ; Tue, 4 Dec 2018 19:26:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 746802C01E for ; Tue, 4 Dec 2018 19:26:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 687512C53E; Tue, 4 Dec 2018 19:26:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9B4E52C44D for ; Tue, 4 Dec 2018 19:26:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cak1j561Zl7FiQELGM3utsb2Y7qdOpVtvG6vxr58FGs=; b=V2HME52estf8A7 AGR06n9G3WW+U3WBGRbIlNdqFmMAYS9d9cgsug90YHRNcYQZToewRek40IIUeRQThdJa6Y7m83D21 eNJ0cWUkOfvX+lnUaIU3ZaxyK0hv2GqNAc+B/z9uEQS0NsDtFSa6U+YnjmWSjLg/dC9CvM+S4ZkX4 nR6vOQQ+DJFDGRwnjml2X8EaXlt1IOw0rY8N4zAxAGryhwQxOzaHlivIxeFZYBDPnhSHkzmoKyen+ thrpnp60L20c1K+Oj+4MPahbIlA9QTBmUwxrE9y2iwsImzlOstw1/NC2QH2pn/EZsZ56+OEXQT/TW CEPBmaoEz8hhdvNVxMRQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUGKn-0007Tt-So; Tue, 04 Dec 2018 19:26:17 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUGJb-0005Kw-VM for linux-arm-kernel@lists.infradead.org; Tue, 04 Dec 2018 19:25:07 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id E6313207A8; Tue, 4 Dec 2018 20:24:53 +0100 (CET) Received: from localhost.localdomain (unknown [91.224.148.103]) by mail.bootlin.com (Postfix) with ESMTPSA id 2747F207AD; Tue, 4 Dec 2018 20:24:43 +0100 (CET) From: Miquel Raynal To: Michael Turquette , Stephen Boyd , Russell King Subject: [PATCH v3 2/4] clk: core: link consumer with clock driver Date: Tue, 4 Dec 2018 20:24:38 +0100 Message-Id: <20181204192440.12125-3-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181204192440.12125-1-miquel.raynal@bootlin.com> References: <20181204192440.12125-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181204_112504_407390_873F9E56 X-CRM114-Status: GOOD ( 19.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Antoine Tenart , Gregory Clement , linux-kernel@vger.kernel.org, Maxime Chevallier , Nadav Haklai , Thomas Petazzoni , Miquel Raynal , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP One major concern when, for instance, suspending/resuming a platform is to never access registers before the underlying clock has been resumed, otherwise most of the time the kernel will just crash. One solution is to use syscore operations when registering clock drivers suspend/resume callbacks. One problem of using syscore_ops is that the suspend/resume scheduling will depend on the order of the registrations, which brings (unacceptable) randomness in the process. A feature called device links has been introduced to handle such situation. It creates dependencies between consumers and providers, enforcing e.g. the suspend/resume order when needed. Such feature is already in use for regulators. Add device links support in the clock subsystem by creating/deleting the links at get/put time. Example of a boot (ESPRESSObin, A3700 SoC) with devices linked to clocks: marvell-armada-3700-tbg-clock d0013200.tbg: Linked as a consumer to d0013800.pinctrl:xtal-clk marvell-armada-3700-tbg-clock d0013200.tbg: Dropping the link to d0013800.pinctrl:xtal-clk marvell-armada-3700-tbg-clock d0013200.tbg: Linked as a consumer to d0013800.pinctrl:xtal-clk marvell-armada-3700-periph-clock d0013000.nb-periph-clk: Linked as a consumer to d0013200.tbg marvell-armada-3700-periph-clock d0013000.nb-periph-clk: Linked as a consumer to d0013800.pinctrl:xtal-clk marvell-armada-3700-periph-clock d0018000.sb-periph-clk: Linked as a consumer to d0013200.tbg mvneta d0030000.ethernet: Linked as a consumer to d0018000.sb-periph-clk xhci-hcd d0058000.usb: Linked as a consumer to d0018000.sb-periph-clk xenon-sdhci d00d0000.sdhci: Linked as a consumer to d0013000.nb-periph-clk xenon-sdhci d00d0000.sdhci: Dropping the link to d0013000.nb-periph-clk mvebu-uart d0012000.serial: Linked as a consumer to d0013800.pinctrl:xtal-clk advk-pcie d0070000.pcie: Linked as a consumer to d0018000.sb-periph-clk xenon-sdhci d00d0000.sdhci: Linked as a consumer to d0013000.nb-periph-clk xenon-sdhci d00d0000.sdhci: Linked as a consumer to regulator.1 cpu cpu0: Linked as a consumer to d0013000.nb-periph-clk cpu cpu0: Dropping the link to d0013000.nb-periph-clk cpu cpu0: Linked as a consumer to d0013000.nb-periph-clk Signed-off-by: Miquel Raynal --- drivers/clk/clk.c | 53 ++++++++++++++++++++++++++++++++++-- drivers/clk/clkdev.c | 16 +++++++++-- include/linux/clk-provider.h | 2 ++ 3 files changed, 66 insertions(+), 5 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index b799347c5fd6..0cc887b43f66 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -77,6 +77,7 @@ struct clk_core { struct hlist_node debug_node; #endif struct kref ref; + struct device_link *parent_clk_link; }; #define CREATE_TRACE_POINTS @@ -90,6 +91,7 @@ struct clk { unsigned long max_rate; unsigned int exclusive_count; struct hlist_node clks_node; + struct device_link *consumer_link; }; /*** runtime pm ***/ @@ -274,6 +276,37 @@ struct clk_hw *clk_hw_get_parent(const struct clk_hw *hw) } EXPORT_SYMBOL_GPL(clk_hw_get_parent); +void clk_link_consumer(struct device *consumer, struct clk *clk) +{ + if (consumer && clk) + clk->consumer_link = device_link_add(consumer, clk->core->dev, + DL_FLAG_STATELESS); +} +EXPORT_SYMBOL_GPL(clk_link_consumer); + +void clk_unlink_consumer(struct clk *clk) +{ + if (clk && clk->consumer_link) + device_link_del(clk->consumer_link); +} +EXPORT_SYMBOL_GPL(clk_unlink_consumer); + +static void clk_link_hierarchy(struct clk_core *consumer, + struct clk_core *provider) +{ + if (consumer && provider) + consumer->parent_clk_link = device_link_add(consumer->dev, + provider->dev, + DL_FLAG_STATELESS); +} + +static void clk_unlink_hierarchy(struct clk_core *consumer, + struct clk_core *provider) +{ + if (consumer && provider && consumer->parent_clk_link) + device_link_del(consumer->parent_clk_link); +} + static struct clk_core *__clk_lookup_subtree(const char *name, struct clk_core *core) { @@ -1542,6 +1575,9 @@ static void clk_reparent(struct clk_core *core, struct clk_core *new_parent) hlist_del(&core->child_node); + if (core->parent) + clk_unlink_hierarchy(core, core->parent); + if (new_parent) { bool becomes_orphan = new_parent->orphan; @@ -1553,6 +1589,8 @@ static void clk_reparent(struct clk_core *core, struct clk_core *new_parent) if (was_orphan != becomes_orphan) clk_core_update_orphan_status(core, becomes_orphan); + + clk_link_hierarchy(core, new_parent); } else { hlist_add_head(&core->child_node, &clk_orphan_list); if (!was_orphan) @@ -2244,12 +2282,16 @@ EXPORT_SYMBOL_GPL(clk_get_parent); static struct clk_core *__clk_init_parent(struct clk_core *core) { + struct clk_core *parent; u8 index = 0; if (core->num_parents > 1 && core->ops->get_parent) index = core->ops->get_parent(core->hw); - return clk_core_get_parent_by_index(core, index); + parent = clk_core_get_parent_by_index(core, index); + clk_link_hierarchy(core, parent); + + return parent; } static void clk_core_reparent(struct clk_core *core, @@ -3437,11 +3479,18 @@ void clk_unregister(struct clk *clk) clk->core->ops = &clk_nodrv_ops; clk_enable_unlock(flags); + clk_unlink_hierarchy(clk->core, clk->core->parent); + if (!hlist_empty(&clk->core->children)) { struct clk_core *child; struct hlist_node *t; - /* Reparent all children to the orphan list. */ + /* + * Reparent all children to the orphan list. + * + * No need to unlink the child clock manually, this will be + * handled by clk_reparent(). + */ hlist_for_each_entry_safe(child, t, &clk->core->children, child_node) clk_core_set_parent_nolock(child, NULL); diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 9ab3db8b3988..8c6e087437bf 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -112,6 +112,9 @@ EXPORT_SYMBOL(of_clk_get_by_name); #else /* defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) */ +void clk_link_consumer(struct device *consumer, struct clk *clk) {} +void clk_unlink_consumer(struct clk *clk) {} + static struct clk *__of_clk_get_by_name(struct device_node *np, const char *dev_id, const char *name) @@ -194,20 +197,27 @@ EXPORT_SYMBOL(clk_get_sys); struct clk *clk_get(struct device *dev, const char *con_id) { const char *dev_id = dev ? dev_name(dev) : NULL; - struct clk *clk; + struct clk *clk = NULL; if (dev && dev->of_node) { clk = __of_clk_get_by_name(dev->of_node, dev_id, con_id); - if (!IS_ERR(clk) || PTR_ERR(clk) == -EPROBE_DEFER) + if (PTR_ERR(clk) == -EPROBE_DEFER) return clk; } - return clk_get_sys(dev_id, con_id); + if (IS_ERR_OR_NULL(clk)) + clk = clk_get_sys(dev_id, con_id); + + if (!IS_ERR(clk)) + clk_link_consumer(dev, clk); + + return clk; } EXPORT_SYMBOL(clk_get); void clk_put(struct clk *clk) { + clk_unlink_consumer(clk); __clk_put(clk); } EXPORT_SYMBOL(clk_put); diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 60c51871b04b..721d6b55b2fa 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -781,6 +781,8 @@ void devm_clk_hw_unregister(struct device *dev, struct clk_hw *hw); const char *__clk_get_name(const struct clk *clk); const char *clk_hw_get_name(const struct clk_hw *hw); struct clk_hw *__clk_get_hw(struct clk *clk); +void clk_link_consumer(struct device *consumer, struct clk *clk); +void clk_unlink_consumer(struct clk *clk); unsigned int clk_hw_get_num_parents(const struct clk_hw *hw); struct clk_hw *clk_hw_get_parent(const struct clk_hw *hw); struct clk_hw *clk_hw_get_parent_by_index(const struct clk_hw *hw, From patchwork Tue Dec 4 19:24:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 10712497 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 63D6413BF for ; Tue, 4 Dec 2018 19:25:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 550CA295B2 for ; Tue, 4 Dec 2018 19:25:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47BF92C609; Tue, 4 Dec 2018 19:25:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ED1D52C606 for ; Tue, 4 Dec 2018 19:25:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AmH8f/j+yzS2+iQeQMWMp8SS5doEN+OEJYTYEpU23q0=; b=qa2e/ZAFsk4i5W T8zOg9en+ZDFMwxAw4JBBC7oIPUm4vctgFKhbkdVO5HakFfsDch9hIt+J8XoWBsGq9XBc5RinnPQg EFARuv5AWuwoHRrChx7tUpCcs8wF69+DQkR1/g9M54J5uu9IHDgSp1k0iVDLZHGY8w2AwUL+yBcmy he3HQ1BZ8apL/QGPg3tJ2kNbQolrIPNjNDyQVRONSAD4W1A4oBbjYNzzTumwMqG5GjFk/EQNFnZuQ gFk/NQ3dWtsbIYoqaoO2kpdyRVHj4erH9bQ8MhPGtJoKVmbP2HhWk815UMfy0zfgKacPU1Io5xeVE wY9bmESXWI7YM9LwTPrQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUGK0-0006pq-9I; Tue, 04 Dec 2018 19:25:28 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUGJb-0005Kx-VP for linux-arm-kernel@lists.infradead.org; Tue, 04 Dec 2018 19:25:05 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id A0A60207AD; Tue, 4 Dec 2018 20:24:54 +0100 (CET) Received: from localhost.localdomain (unknown [91.224.148.103]) by mail.bootlin.com (Postfix) with ESMTPSA id D8363207B0; Tue, 4 Dec 2018 20:24:43 +0100 (CET) From: Miquel Raynal To: Michael Turquette , Stephen Boyd , Russell King Subject: [PATCH v3 3/4] clk: mvebu: armada-37xx-tbg: fill the device entry when registering the clocks Date: Tue, 4 Dec 2018 20:24:39 +0100 Message-Id: <20181204192440.12125-4-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181204192440.12125-1-miquel.raynal@bootlin.com> References: <20181204192440.12125-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181204_112504_185363_73B52444 X-CRM114-Status: GOOD ( 14.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Antoine Tenart , Gregory Clement , linux-kernel@vger.kernel.org, Maxime Chevallier , Nadav Haklai , Thomas Petazzoni , Miquel Raynal , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP So far the clk_hw_register_fixed_factor() calls are not providing any device structure. While doing so is harmless for regular use, the missing device structure may be a problem for suspend to RAM support. Since, device links have been added to clocks, links created during probe will enforce the suspend/resume orders. When the device is missing during the registration, no link can be established, hence the order between parent and child clocks are not enforced. Adding the device structure here will create a link between the 4 TBG clocks (registered by this driver) and: * their parent clock: XTAL, * their child clocks: several 'periph' clock. Signed-off-by: Miquel Raynal --- drivers/clk/mvebu/armada-37xx-tbg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/clk/mvebu/armada-37xx-tbg.c b/drivers/clk/mvebu/armada-37xx-tbg.c index ee272d4d8c24..78de057a2406 100644 --- a/drivers/clk/mvebu/armada-37xx-tbg.c +++ b/drivers/clk/mvebu/armada-37xx-tbg.c @@ -116,8 +116,10 @@ static int armada_3700_tbg_clock_probe(struct platform_device *pdev) name = tbg[i].name; mult = tbg_get_mult(reg, &tbg[i]); div = tbg_get_div(reg, &tbg[i]); - hw_tbg_data->hws[i] = clk_hw_register_fixed_factor(NULL, name, - parent_name, 0, mult, div); + hw_tbg_data->hws[i] = clk_hw_register_fixed_factor(dev, name, + parent_name, + 0, mult, + div); if (IS_ERR(hw_tbg_data->hws[i])) dev_err(dev, "Can't register TBG clock %s\n", name); } From patchwork Tue Dec 4 19:24:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 10712491 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 25F5D13BF for ; Tue, 4 Dec 2018 19:25:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19800286AA for ; Tue, 4 Dec 2018 19:25:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DC442C60A; Tue, 4 Dec 2018 19:25:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B817D286AA for ; Tue, 4 Dec 2018 19:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OIbA1M7SGWQAo37Z1fBoxhOw6CsEM9IHlz/Lyr/Nz2U=; b=u48Ld4AGT0icrg wd3wI6IADRif6FaEk7RGZcdBq5mmwSkjC+XPzfiDsWpj/9eGXf14YJsguPszcPzLIwnN8NWnlUsYi OtzZtp3b16T+ugob1tbJWOoE6bKbSEthDpPESHu4bTGNfQd23zzHJHMhQmWEfgAs/1kluJGnsgz1O LCmekOZXUMSME1TG6OQ4EfOpsDx3do2QUx33CjR6podjkbYAqoDsfSx4DtFKLIbj3sPBwZGqPkoo/ P+ivg2lcmuVBxpTT2bb+dpt3qE0x3Ta5UsVVG0UAbfdn8fiMgOjwpOrL9yYEuWLCydd0DfKXZIVhJ GtKwaKRSYGX7ZG5xdDaQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUGJf-0005vH-N5; Tue, 04 Dec 2018 19:25:07 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUGJb-0005Wm-VK for linux-arm-kernel@lists.infradead.org; Tue, 04 Dec 2018 19:25:05 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 9576420A44; Tue, 4 Dec 2018 20:25:02 +0100 (CET) Received: from localhost.localdomain (unknown [91.224.148.103]) by mail.bootlin.com (Postfix) with ESMTPSA id 9E0CD207BF; Tue, 4 Dec 2018 20:24:44 +0100 (CET) From: Miquel Raynal To: Michael Turquette , Stephen Boyd , Russell King Subject: [PATCH v3 4/4] clk: mvebu: armada-37xx-xtal: fill the device entry when registering the clock Date: Tue, 4 Dec 2018 20:24:40 +0100 Message-Id: <20181204192440.12125-5-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181204192440.12125-1-miquel.raynal@bootlin.com> References: <20181204192440.12125-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181204_112504_181739_2308CBC6 X-CRM114-Status: GOOD ( 15.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Antoine Tenart , Gregory Clement , linux-kernel@vger.kernel.org, Maxime Chevallier , Nadav Haklai , Thomas Petazzoni , Miquel Raynal , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP So far the clk_hw_register_fixed_factor() call was not providing any device structure. While doing so is harmless for regular use, the missing device structure may be a problem for suspend to RAM support. Since, device links have been added to clocks, links created during probe will enforce the suspend/resume orders. When the device is missing during the registration, no link can be established, hence the order between parent and child clocks are not enforced. Adding the device structure here will create a link between the XTAL clock (this one) and the four TBG clocks that are derived from it. Signed-off-by: Miquel Raynal --- drivers/clk/mvebu/armada-37xx-xtal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/clk/mvebu/armada-37xx-xtal.c b/drivers/clk/mvebu/armada-37xx-xtal.c index e9e306d4e9af..0e74bcd83d1a 100644 --- a/drivers/clk/mvebu/armada-37xx-xtal.c +++ b/drivers/clk/mvebu/armada-37xx-xtal.c @@ -57,7 +57,8 @@ static int armada_3700_xtal_clock_probe(struct platform_device *pdev) rate = 25000000; of_property_read_string_index(np, "clock-output-names", 0, &xtal_name); - xtal_hw = clk_hw_register_fixed_rate(NULL, xtal_name, NULL, 0, rate); + xtal_hw = clk_hw_register_fixed_rate(&pdev->dev, xtal_name, NULL, 0, + rate); if (IS_ERR(xtal_hw)) return PTR_ERR(xtal_hw); ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, xtal_hw);