From patchwork Tue Sep 24 12:39:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 174273 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4087845ill; Tue, 24 Sep 2019 05:40:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPMGmDwLO9dOy7Ae77+Ym5aGhr9luTNUsvPzWxZfUnKSe+6BOHkkH1xfNKasY3d6pd9nCV X-Received: by 2002:a17:906:b316:: with SMTP id n22mr2225945ejz.54.1569328817929; Tue, 24 Sep 2019 05:40:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569328817; cv=none; d=google.com; s=arc-20160816; b=e6H33tQ0efKMOvf9k3rybaVAban+ptjtfqBCpxdxqB/Sp+9nfvKKsBkyTN6AhlfdUL vEU0VdHFHDHpftU1DpAYrq2hF75PR3Zxp34a/fuhAAo19GBaXBh9+oIUrvD7foAvwFpH 8UK9g2xYwSwd/sI7jMagP0XV+bokVlHMvnKWzTYVfR1Ugv2aV9tO9Fr3R4N7vKoKKfaT xTEv+ElI1G59cFuTS1EYA7+12EWY+jl6W2RkmONSP8iZP7aeBa296l0KsQM7xKQ6XwkV h4qYNTzyrgGlaayxOsDy0FeWH7802IDKqdHCT7uGnfcRMz9KVdvlKNZ94OoKQw3lksvc 2tLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rUdTMX0LV19a/cAOPF7U+URSV6+2wG5VEFj80ZdTTHM=; b=DSDuloR11R122i4AkvJIHg56m/UDy1Y68xQNvWQQqNbc+0j6rnG074fGAz5eKMq8r7 7/GMu54F5seTRrKjT7toK9ToNx1d/zMpvB+b5QpYMk7KH/swQQR7ock3gTXTTvB+lRzj ct4PUdcSjy72BOCj3+K9gHFLfdkzGbbnbeZJfUXaf3BdICpgVlQZ+k+jpNIGQkUbLyJ8 o2exgzMYtFLpO6p2djf+/W/aT5RJiq1cdZ/0jjfeuy1jN+70DKTozcLhnqNermESaDYe /TUfkNgU1HFUH1Cxoly2+xMDCeNqW/RMq0pW5Ar5rZA4DkM8ZlZ0ORr6FXGafoqWBJys UQ7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=geVjrp9r; 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 u14si962952edq.167.2019.09.24.05.40.17; Tue, 24 Sep 2019 05:40:17 -0700 (PDT) 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=geVjrp9r; 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 S2436658AbfIXMkK (ORCPT + 26 others); Tue, 24 Sep 2019 08:40:10 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:32806 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395292AbfIXMkJ (ORCPT ); Tue, 24 Sep 2019 08:40:09 -0400 Received: by mail-wr1-f67.google.com with SMTP id b9so1782903wrs.0 for ; Tue, 24 Sep 2019 05:40:05 -0700 (PDT) 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:in-reply-to:references :mime-version:content-transfer-encoding; bh=rUdTMX0LV19a/cAOPF7U+URSV6+2wG5VEFj80ZdTTHM=; b=geVjrp9r/hIUNuo0vP2rVZicZuqtqycilc5JWitdZhYLvbk3F8QM87WCpD9Jv5WdL5 5+bCNCqBRLoRuhkuItaW1xAw2Pl2b6KISeC1S3Et2HNOy1Ug9tLhRJDpqUAzly90H6dK BUEX5UYm6DCF1zZXitjjl89KDevLAoQHiYCFMg1k4bA7lEzLLeyM4IwzYEplmCgJxZWP WZywanPjVo6vKp7B+m08RfbvNZTb38PKNr8bbl+BK8kTMJGeu9MgKJiRhD4ee7DlO2Qx gPcgsPzeU0Stk7SI6VxqWolmR4aMBYFTjgK9KRcv8MC8IJQSBaJ2IPQ/fETSw+Ns75Qu ekFA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=rUdTMX0LV19a/cAOPF7U+URSV6+2wG5VEFj80ZdTTHM=; b=eNP5gGhKab3Z4j4B0HxoIkU7Lo401yZErc6XC7gnVNlYqm/WEUNzGoTDMvSy3yqq/f Hs1cVIJdiQwpZ523hOXWzgiW/BTcBWDRwDy+kU7kUe+1WCjNFv+mtD3xUOKmH4HLPHuP SwvKaRHD6tkRRGZAaew1EsjCQpBUuxJPuKOQJ/Ne5H1d2FC2bQkc3bCfT8gxg+Si3jde 4RFLWKJTgszTdh/lqXYxeLVTmosYFPY8bhlVY46J0VmwNbi1TnEgPJDo2XNR8S+V4rHG 2H5j0UfXxsCayQZfpqxYV1XUSU8X53PEVxxt4KloEFY6QbeCcRE1U/q67dWqup5JU3MZ +s+Q== X-Gm-Message-State: APjAAAUy1bdniC7W0UdkjNwkUPDfElH16qsOORv5T/vJR9HkCSYUALB4 st38kxNVDVybmqMNDvmFgz+YiA== X-Received: by 2002:a5d:660c:: with SMTP id n12mr615084wru.286.1569328805014; Tue, 24 Sep 2019 05:40:05 -0700 (PDT) Received: from starbuck.baylibre.local (uluru.liltaz.com. [163.172.81.188]) by smtp.googlemail.com with ESMTPSA id u83sm2888165wme.0.2019.09.24.05.40.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2019 05:40:04 -0700 (PDT) From: Jerome Brunet To: Michael Turquette , Stephen Boyd Cc: Jerome Brunet , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] clk: actually call the clock init before any other callback of the clock Date: Tue, 24 Sep 2019 14:39:52 +0200 Message-Id: <20190924123954.31561-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190924123954.31561-1-jbrunet@baylibre.com> References: <20190924123954.31561-1-jbrunet@baylibre.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __clk_init_parent() will call the .get_parent() callback of the clock so .init() must run before. Fixes: 541debae0adf ("clk: call the clock init() callback before any other ops callback") Signed-off-by: Jerome Brunet --- drivers/clk/clk.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) -- 2.21.0 diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 1c677d7f7f53..232144cca6cf 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3294,6 +3294,21 @@ static int __clk_core_init(struct clk_core *core) goto out; } + /* + * optional platform-specific magic + * + * The .init callback is not used by any of the basic clock types, but + * exists for weird hardware that must perform initialization magic. + * Please consider other ways of solving initialization problems before + * using this callback, as its use is discouraged. + * + * If it exist, this callback should called before any other callback of + * the clock + */ + if (core->ops->init) + core->ops->init(core->hw); + + core->parent = __clk_init_parent(core); /* @@ -3318,17 +3333,6 @@ static int __clk_core_init(struct clk_core *core) core->orphan = true; } - /* - * optional platform-specific magic - * - * The .init callback is not used by any of the basic clock types, but - * exists for weird hardware that must perform initialization magic. - * Please consider other ways of solving initialization problems before - * using this callback, as its use is discouraged. - */ - if (core->ops->init) - core->ops->init(core->hw); - /* * Set clk's accuracy. The preferred method is to use * .recalc_accuracy. For simple clocks and lazy developers the default From patchwork Tue Sep 24 12:39:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 174275 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4088058ill; Tue, 24 Sep 2019 05:40:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxovJ1cvkd4xqN6IcTYSr9XoNGUprio8YfnfzXnp2NmLySFYQsIenggwOKzQ+5W1VXqrhDV X-Received: by 2002:a50:b685:: with SMTP id d5mr2456707ede.258.1569328827627; Tue, 24 Sep 2019 05:40:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569328827; cv=none; d=google.com; s=arc-20160816; b=NV+BuRUA/7RR/rtmj801KROOverR7LaPphA4K/DqWRAXI8w8/6lF8dzfzevxK+/h7l 2OfGTrsYW4u2sQ/EN0JGLG7ErU7DJhYnbWpa/C57qIoHabyOZlPF+FQwUxmZzgPpiS2i FdGgZD/Luhxtn2Q0xN+/TRWtBcuV0yxevh+/9N83UD0Eup6MbAtbO22//xzsyYk7qzNL TO4eqiaQaJBZthQrCNYUwZExOu/MnWrCFwjm6GopHGxX04Be4mDBoj01Hn7cGUIrySq6 oVuJT5GHFA6GLuiLzA3f1aUbHxBgo3wtQKwpie9VcLYpbHtDw+uRkf2UkP7Y8M2EnfET xU9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qi/Gc3Tpy0QJ++xo7u/xxUW782IGlDyvorHvSnC/YAU=; b=mOLQVLQbMMYMTtLxUB4dYg+ZYlmmmawTWPdL95S9E2VgD0ywSd99ZWAcZGhshyKRD1 BPWttVzyUKocXANSwVpEeUy1OlbCjshahQqKIciziMNpXkl/MoFeCDtwnbRfuZ/Kkdm+ 3YCA5aeg4z6g6bgBNMHt/BirS/yd4ZU6E8DN7Tvj7FLV7zHAGtKSOdi0xawBvNp1u1+s n+rSTz37OvgUURSoGbnVy6SfpS3mq+VbtTbQkBeUeUcHMlB0Y9IcjY8IJrB20rNXbCff 1NCGPeHJRmPD6dd+wn2idWVBa73O4xaJT9Gz3Dpp08XZaxXbr2UrixOfU4aX6xnnd9bX eM+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=xVzA8y35; 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 si9si826509ejb.97.2019.09.24.05.40.27; Tue, 24 Sep 2019 05:40:27 -0700 (PDT) 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=xVzA8y35; 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 S2440980AbfIXMkY (ORCPT + 26 others); Tue, 24 Sep 2019 08:40:24 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44737 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436675AbfIXMkR (ORCPT ); Tue, 24 Sep 2019 08:40:17 -0400 Received: by mail-wr1-f67.google.com with SMTP id i18so1754935wru.11 for ; Tue, 24 Sep 2019 05:40:14 -0700 (PDT) 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:in-reply-to:references :mime-version:content-transfer-encoding; bh=qi/Gc3Tpy0QJ++xo7u/xxUW782IGlDyvorHvSnC/YAU=; b=xVzA8y35Oii0iE40wE9lsz9FtNQqt+dg+GcigSV+Q1lf1ZrVsLY1lorxmVsgf362B6 Z33LTBKLA0eo1gKgLAJ7TOh/psIX8l2H4UnV7YhGgTeyyjApR5mfI+kvE+AjlIEyrlev 3O0NSB6O2yGLdAzSHfMDsBbOnnsdnt1z8w3ME+LPvqp0flXlA1+74sDUjTUVL5z+ZpH6 1t214qYiCHLc+QMVU1ve5Cd7pmJe+AxNKHqQesqEP9rZJRloxY0WHmSWiHcWQINBQ+Ih grkGSaFD+x3qJVrkRPNUfkhMY42VDJiSdC6705TSz7TfkFU21iNGL6FT9cXpAGWiSZ11 8p9A== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=qi/Gc3Tpy0QJ++xo7u/xxUW782IGlDyvorHvSnC/YAU=; b=em2WLB1rVkER0+wFvEZp1XIXErlulmKnfNUFDaqmxE/UN33s/fkZoUBZ/ItKfuvgly vPC0YZafFHOHGhWGC35pXEk+Gv6tqBZEkR4D+wRGKQCbqGWRq4nu/lv5rb6ICTn7QrS/ z2lCxq5RE8YUhycqf1zRi+dV/IXRNeytn6FzvF9B+3GAxN9VY8jf8kHCHc/0h5KntrjD ePxmr9yQeh8jRNtWp+vEi4ZFTFS/lsHjLfwzVcOQH8PCwLVjL3V6trt83z6AtqX9Bf7b ly1Hnm/2wlu/fWOCRAYiDD8cUC6pvjUwajLSu0+JPogD7uzXmscZio9xLu8dHb8iHcwN 1p2w== X-Gm-Message-State: APjAAAWL+MbQL+21tmDe00VcnjZg4XRRu/r6T/69iNkWi9i/uzOcNMRu s4VVGjtvwrg7jJ9sy/k0ONypDA== X-Received: by 2002:a05:6000:11cb:: with SMTP id i11mr2294992wrx.171.1569328814069; Tue, 24 Sep 2019 05:40:14 -0700 (PDT) Received: from starbuck.baylibre.local (uluru.liltaz.com. [163.172.81.188]) by smtp.googlemail.com with ESMTPSA id u83sm2888165wme.0.2019.09.24.05.40.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2019 05:40:13 -0700 (PDT) From: Jerome Brunet To: Michael Turquette , Stephen Boyd Cc: Jerome Brunet , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] clk: add terminate callback to clk_ops Date: Tue, 24 Sep 2019 14:39:54 +0200 Message-Id: <20190924123954.31561-4-jbrunet@baylibre.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190924123954.31561-1-jbrunet@baylibre.com> References: <20190924123954.31561-1-jbrunet@baylibre.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a terminate callback to the clk_ops to release the resources claimed in .init() Signed-off-by: Jerome Brunet --- drivers/clk/clk.c | 7 ++++++- include/linux/clk-provider.h | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) -- 2.21.0 diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index df853a98fad2..926f49c78b5d 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3844,6 +3844,7 @@ static void clk_core_evict_parent_cache(struct clk_core *core) void clk_unregister(struct clk *clk) { unsigned long flags; + const struct clk_ops *ops; if (!clk || WARN_ON_ONCE(IS_ERR(clk))) return; @@ -3852,7 +3853,8 @@ void clk_unregister(struct clk *clk) clk_prepare_lock(); - if (clk->core->ops == &clk_nodrv_ops) { + ops = clk->core->ops; + if (ops == &clk_nodrv_ops) { pr_err("%s: unregistered clock: %s\n", __func__, clk->core->name); goto unlock; @@ -3865,6 +3867,9 @@ void clk_unregister(struct clk *clk) clk->core->ops = &clk_nodrv_ops; clk_enable_unlock(flags); + if (ops->terminate) + ops->terminate(clk->core->hw); + if (!hlist_empty(&clk->core->children)) { struct clk_core *child; struct hlist_node *t; diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index b82ec4c4ca95..5a5a64785923 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -197,6 +197,8 @@ struct clk_duty { * such as rate or parents. * Returns 0 on success, -EERROR otherwise. * + * @terminate: Free any resource allocated by init. + * * @debug_init: Set up type-specific debugfs entries for this clock. This * is called once, after the debugfs directory entry for this * clock has been created. The dentry pointer representing that @@ -248,6 +250,7 @@ struct clk_ops { int (*set_duty_cycle)(struct clk_hw *hw, struct clk_duty *duty); int (*init)(struct clk_hw *hw); + void (*terminate)(struct clk_hw *hw); void (*debug_init)(struct clk_hw *hw, struct dentry *dentry); };