From patchwork Tue Feb 6 11:18:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 126984 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp2816738ljc; Tue, 6 Feb 2018 03:19:10 -0800 (PST) X-Google-Smtp-Source: AH8x227gaalglTPNpLGYS53/Ky1OwSYtV2wHnnf6i0s7dKBoigxK3IJY3pfNdlIui40qvFrbaCsi X-Received: by 2002:a17:902:32a2:: with SMTP id z31-v6mr2086311plb.345.1517915950853; Tue, 06 Feb 2018 03:19:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517915950; cv=none; d=google.com; s=arc-20160816; b=OeyRJ17pB0e0ZA0KM071NyI5onfItavSYvXFapbo9PE3URz76p+BHC+WhjclVZbBR6 GW1AFNxGBO4pkxbQCMCfZDaj2+CqB+eSxPDvzCqCMsR9+BxLEkWh8wm2LPfi5GRvD+iu LNNXj7S7hIXEwyP5Uz5y8jZ81QXh3gerxyq9ZkGJ9b4QN/tjzNPDvcmyn1F7umev9nmV RfU0iCVhIAtwYrNs+l+HQed61S7c25AouOMO8/HfS5h5WOEkYat3+diadUfHNMqFFnxy IIyzX1jHUJLQOpLdODnx/CUcMbNmw3IYxwQqkVfWlQjaKWA+ufU/0fq6zSdmZFhDiYKh /6pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=RfVzQ6ZmXKcoa82BrG2th4KJxAmFkbhoWD/naKQs070=; b=wZGqqWh6XmjsFJ/q/CGvz4sfu48IWxtg4OC50usZo2pbpHkpTxoTDGcdsLmVMzcW90 LKC1lpuMA/vbeJzYfdb8zPG2eLJfuc1SAf32K8PusfQ2QvwB2ca0cnV8COgJFqPcGJS9 kShckiybCVZZ/27BovvHdD6LcSE8DyLUwRxN7MrI7PMvmYYBQdzi6wEs+Bc5SLkxk4a6 UVhwWjeTOvM+zumjoGbi+Zj7LF1cFbO1ajJMNllG145iaRFIQtg78fYOYvH5Ww5/ifBy Ior2kZY5ABtNoCKM4aA/ZWBYpwYriXS9iCAXoMBw2BvBbUA53X8M7PM9+rID5GTvB10/ 46SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=F8GAyVjd; 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 o4-v6si2394460plk.582.2018.02.06.03.19.10; Tue, 06 Feb 2018 03:19:10 -0800 (PST) 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=F8GAyVjd; 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 S1752715AbeBFLTI (ORCPT + 22 others); Tue, 6 Feb 2018 06:19:08 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:51581 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752278AbeBFLS7 (ORCPT ); Tue, 6 Feb 2018 06:18:59 -0500 Received: by mail-wm0-f68.google.com with SMTP id r71so3056288wmd.1 for ; Tue, 06 Feb 2018 03:18:59 -0800 (PST) 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; bh=RfVzQ6ZmXKcoa82BrG2th4KJxAmFkbhoWD/naKQs070=; b=F8GAyVjddUjzkrWlFeXcbZqKNQ1FKyqA9yKvr6YbqHHH01r7i4xYQgcFsOJrBEaj+k gTfbfL0CyCgv8FWwt7P+IctPXr083MZ8Dr1+WfW2PcroPLGDDfD7053KkS9OyBIThpDO D2GXxBYexC2d6RNwHGQR2I4DYfsdvFJ9I/3Lz9E4VneNYIa4Qutuotqk6Pwfp/ilACoR aNnZCO3qh1So0R5sd121FAnyPHHAttFBShc/pMf7TK2pC1RTJJ2AQu9UUdhTIBtADcxj QyESKqJGB2elt+MU6bUyrNYI2CC1TsPZtA16D1foXHFRgnCvue1nyrS2UaUGxJCOyLLb 2ung== 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; bh=RfVzQ6ZmXKcoa82BrG2th4KJxAmFkbhoWD/naKQs070=; b=T/pqbytYkBiELD7gp0TUKI6Zf6fWbVjHefKxgNTpxesWHnnCIhKDEX1RYGo04Q7hsq mQF41wMjFFTWoC1SdCJQHl820DyZNpLcTf5bCCNsHKV7RgKNcXzg6AJqiD+7XHi03/WC zkiEW8fBxfYvWlvYy4FiO7+p91/MKeSbwuw1fGWIuvv1mQJWxb6BX3C5AWGsrW0mA+ok vMpH136My28jGEjiiQyv+hnTxrcMaD3CD5GYS6En14sAhmurt7gaWyJTgQDQ8KfxvOWx ZvKVNjnCz3jNVo3xrqmekEC8dao/RcqZOQz5niFPPDw1nus2wEcDzf+kk73JHfTvWxTh W0sQ== X-Gm-Message-State: APf1xPA8NpsUuwDtijYUrnwUgYqhHuUSFV/2T7O3zYKpFR6CFe1gAdvl JNjJ5omWMSnmC0fBvTX87jqYtg== X-Received: by 10.28.116.4 with SMTP id p4mr1490912wmc.82.1517915938604; Tue, 06 Feb 2018 03:18:58 -0800 (PST) Received: from boomer.baylibre.local ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id z12sm10769028wrz.20.2018.02.06.03.18.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2018 03:18:57 -0800 (PST) From: Jerome Brunet To: Stephen Boyd , Michael Turquette Cc: Jerome Brunet , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Neil Armstrong Subject: [PATCH] clk: call the clock init() callback before any other ops callback Date: Tue, 6 Feb 2018 12:18:55 +0100 Message-Id: <20180206111855.18827-1-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some clocks may need to initialize things, whatever it is, before being able to properly operate. Move the .init() call before any other callback, such recalc_rate() or get_phase(), so the clock is properly setup before being used. Signed-off-by: Jerome Brunet --- Hi Stephen, Mike, This change is addressing a problem I have with clock driver I'm working on. This driver needs the .init() callback to run first is order to answer correctly .get_phase(). It does not address an existing issue, not one that I'm aware of at least, which is why I did not put a Fixes tag. In any case, it makes sense to run init before running anything else. Since this changes the same region, this patch applies top of [0] [0]: https://lkml.kernel.org/r/20180206105404.13086-1-jbrunet@baylibre.com drivers/clk/clk.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) -- 2.14.3 diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index cca05ea2c058..9d56be6ead39 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2929,6 +2929,17 @@ 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 @@ -3006,17 +3017,6 @@ static int __clk_core_init(struct clk_core *core) } } - /* - * 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); - kref_init(&core->ref); out: clk_pm_runtime_put(core);