From patchwork Fri Oct 27 18:23:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 159098 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp803036vqb; Fri, 27 Oct 2023 11:27:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEF+bckR50b7Ey894x3wDuCtntE8/ICeL/HETgTLxDj+SEPvVjEyoVMwsTuki1Jr5kzwzPS X-Received: by 2002:a05:6871:5c4c:b0:1ba:cc77:1d81 with SMTP id os12-20020a0568715c4c00b001bacc771d81mr5384251oac.46.1698431242126; Fri, 27 Oct 2023 11:27:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698431242; cv=none; d=google.com; s=arc-20160816; b=kN4Fcb7jE+uQLpiMtwUdM2C+EUKtDwD11kX7HkObTZFWv3orI8mV0tPR+PTOlYv8PI r8hR84W5EykM+2/GWFdN68Ft2kDiPELMuRao4XF7hhLEtAMm1etxs2QA5kjUj6WGrnNh KYai5wv4NcMW9f7OMppf4yd/7AedVVfZq2XFiQZ/lRANcYKT1RtX9Vt4kvr6BD2/vBuM Oa9wQZgNT2MVasqOB2SSZFfTzHFPgKEvFXRJraps+rTgZM8X0BT0/WlitHo9bn1GxEwc K4Zq7w6Y/o22TbO6/jEFe1lCZSAIW3+vO7h3jgdZysbTwSCzjYW1C3gkjBUIaYBDL5GS Oihw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=MLnvTHnblx5b8QiEPiT3MDUvMMwbN6aVHzpgMo0/s3k=; fh=cOFTVwaEIq72FhwX+CjigiTyuFgfCSrJQe3KtUFH/lU=; b=R1MiMY8kgB+F3bGMDSPKMZQL6DXQ5sgY2rVfpawe1o7yiQl44oSQcTkOA3/dpV4m+Y dPNOVGqQS16iIy4EOuUE6xXPDODp/ga5tlrEtJFJU3aM+E+r+rS1va+h+OkS/M1RGWO3 /TqeFkc7DjTI7oyQ0yy9cfqgZSpfYeZwFRR5Ry2gW3sdrez0F8arDyppmSQPUad1VYg8 ITSrHTYXyQXTlPj2AQDyOvPu/fQvdbw2yF+2noci/9C0RZzURqCIZeifl5FqoPnbkvYW rbgdUs6ndqHPx0kpmo80E4tKMydLxMrPc/nxJenH3wJucfG0aaXPdA2l+nBiGQpWc+tN b6bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=IbjhEi0j; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id d204-20020a254fd5000000b00d81504fa809si3125277ybb.112.2023.10.27.11.27.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 11:27:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=IbjhEi0j; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id BC4CB8252C6E; Fri, 27 Oct 2023 11:27:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346485AbjJ0S0L (ORCPT + 25 others); Fri, 27 Oct 2023 14:26:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346523AbjJ0S0G (ORCPT ); Fri, 27 Oct 2023 14:26:06 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 461F11BFD; Fri, 27 Oct 2023 11:23:44 -0700 (PDT) Date: Fri, 27 Oct 2023 18:23:12 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1698430993; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MLnvTHnblx5b8QiEPiT3MDUvMMwbN6aVHzpgMo0/s3k=; b=IbjhEi0jotWY6SQWbBD+J6Xd5mCSwZ8xetZZk45JhZBF/uOSJGSjfZB3L4pXWSHEI+hh31 xOEOufSsnAfc6M47bqLMWiCyMvBd7KsdhZo1e9VeW7mc9AwPS6HHnG699eO0MqUAGix/bq 2A9mykbD3+FOJg6Xi+S7iKNJjS7o+DsU9GpslSGnSBhfC3wQb/NI45irHPXiQQkUeQAVQu 1akKgMx1N8Zl6+SGyXPafP7AEya64A13XMeMrFsaqF5rlg3bC6L4KpACLWAyIjFR81mWqO uVg3RkWVU+Hm8wGRKV7uUJXRdBCWffOl0MrF70lgOAc5/2zoktweDuIWBwSTcQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1698430993; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MLnvTHnblx5b8QiEPiT3MDUvMMwbN6aVHzpgMo0/s3k=; b=ZSI0EOj0iiz4ZbG8pdi6tdnUgnvjO2X9l3CPsi56sPdx7lMjpBZJPfV/gKffn6sCfEimpH Ud4930lYKFRjS0Bw== From: "tip-bot2 for Ivaylo Dimitrov" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] drivers/clocksource/timer-ti-dm: Don't call clk_get_rate() in stop function Cc: Ivaylo Dimitrov , Tony Lindgren , Daniel Lezcano , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <1696312220-11550-1-git-send-email-ivo.g.dimitrov.75@gmail.com> References: <1696312220-11550-1-git-send-email-ivo.g.dimitrov.75@gmail.com> MIME-Version: 1.0 Message-ID: <169843099238.3135.4893694588353125382.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails 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 (fry.vger.email [0.0.0.0]); Fri, 27 Oct 2023 11:27:09 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778712350007183979 X-GMAIL-MSGID: 1780934238201348131 The following commit has been merged into the timers/core branch of tip: Commit-ID: 12590d4d0e331d3cb9e6b3494515cd61c8a6624e Gitweb: https://git.kernel.org/tip/12590d4d0e331d3cb9e6b3494515cd61c8a6624e Author: Ivaylo Dimitrov AuthorDate: Tue, 03 Oct 2023 08:50:20 +03:00 Committer: Daniel Lezcano CommitterDate: Wed, 11 Oct 2023 10:14:53 +02:00 drivers/clocksource/timer-ti-dm: Don't call clk_get_rate() in stop function clk_get_rate() might sleep, and that prevents dm-timer based PWM from being used from atomic context. Fix that by getting fclk rate in probe() and using a notifier in case rate changes. Fixes: af04aa856e93 ("ARM: OMAP: Move dmtimer driver out of plat-omap to drivers under clocksource") Signed-off-by: Ivaylo Dimitrov Reviewed-by: Tony Lindgren Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/1696312220-11550-1-git-send-email-ivo.g.dimitrov.75@gmail.com --- drivers/clocksource/timer-ti-dm.c | 36 +++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/drivers/clocksource/timer-ti-dm.c b/drivers/clocksource/timer-ti-dm.c index 09ab29c..5f60f6b 100644 --- a/drivers/clocksource/timer-ti-dm.c +++ b/drivers/clocksource/timer-ti-dm.c @@ -140,6 +140,8 @@ struct dmtimer { struct platform_device *pdev; struct list_head node; struct notifier_block nb; + struct notifier_block fclk_nb; + unsigned long fclk_rate; }; static u32 omap_reserved_systimers; @@ -253,8 +255,7 @@ static inline void __omap_dm_timer_enable_posted(struct dmtimer *timer) timer->posted = OMAP_TIMER_POSTED; } -static inline void __omap_dm_timer_stop(struct dmtimer *timer, - unsigned long rate) +static inline void __omap_dm_timer_stop(struct dmtimer *timer) { u32 l; @@ -269,7 +270,7 @@ static inline void __omap_dm_timer_stop(struct dmtimer *timer, * Wait for functional clock period x 3.5 to make sure that * timer is stopped */ - udelay(3500000 / rate + 1); + udelay(3500000 / timer->fclk_rate + 1); #endif } @@ -348,6 +349,21 @@ static int omap_timer_context_notifier(struct notifier_block *nb, return NOTIFY_OK; } +static int omap_timer_fclk_notifier(struct notifier_block *nb, + unsigned long event, void *data) +{ + struct clk_notifier_data *clk_data = data; + struct dmtimer *timer = container_of(nb, struct dmtimer, fclk_nb); + + switch (event) { + case POST_RATE_CHANGE: + timer->fclk_rate = clk_data->new_rate; + return NOTIFY_OK; + default: + return NOTIFY_DONE; + } +} + static int omap_dm_timer_reset(struct dmtimer *timer) { u32 l, timeout = 100000; @@ -754,7 +770,6 @@ static int omap_dm_timer_stop(struct omap_dm_timer *cookie) { struct dmtimer *timer; struct device *dev; - unsigned long rate = 0; timer = to_dmtimer(cookie); if (unlikely(!timer)) @@ -762,10 +777,7 @@ static int omap_dm_timer_stop(struct omap_dm_timer *cookie) dev = &timer->pdev->dev; - if (!timer->omap1) - rate = clk_get_rate(timer->fclk); - - __omap_dm_timer_stop(timer, rate); + __omap_dm_timer_stop(timer); pm_runtime_put_sync(dev); @@ -1124,6 +1136,14 @@ static int omap_dm_timer_probe(struct platform_device *pdev) timer->fclk = devm_clk_get(dev, "fck"); if (IS_ERR(timer->fclk)) return PTR_ERR(timer->fclk); + + timer->fclk_nb.notifier_call = omap_timer_fclk_notifier; + ret = devm_clk_notifier_register(dev, timer->fclk, + &timer->fclk_nb); + if (ret) + return ret; + + timer->fclk_rate = clk_get_rate(timer->fclk); } else { timer->fclk = ERR_PTR(-ENODEV); }