Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2951324rdd; Sat, 13 Jan 2024 08:26:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHYGsWePrTCi0s4rIcOUNJAGmCuDQelPuy/CPAhCeYYCm1/8eYSsXFaptiDtMQ+nR3iMoW X-Received: by 2002:a17:906:1146:b0:a29:25d4:1187 with SMTP id i6-20020a170906114600b00a2925d41187mr896117eja.160.1705163218192; Sat, 13 Jan 2024 08:26:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705163218; cv=none; d=google.com; s=arc-20160816; b=X3pu8ixXQy/nzJaw6GMeELobrL4B0NOUqNhN6q9Uz6HRlxwmWFfoFll5fPBrcavIdo y0xbrnVKbHhosu8Ca4HdY6jy3hMBk2U2oipLrl7UdgvwIQqMJW82vP8yDyZK6x3mcsKh bRqnktN8wAy37Ml59jtk5LwYCxD9WauZbRskD3LxIHcpYR21Av/wwAgITajrI+sbWVTC IncZwDV1JmcVdsImurlSVmeg52S7QYb3ywr5rzud0Hv4TTl0HiQebtQ/50/eMXMCl59c oBZBjFUjlKRPLzLEjkc4hRMYrnEPh6Js9Iwz67UNnfj3qnQNB8i58CB29eM4J9NgL4xa YUdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=GdYMkl2N1COAiKHn3oeIf137LtIaeglejyyPdj/AjPQ=; fh=CzmwYv/NfriQbK3OEucm0Vf2Nopg+fcdA++WZYjYOIQ=; b=jnjFJND4Eub+P8wSuZvkf4v9smi1gJHAKZJ6nAQ4F03CyajfAjOwDsGE+MbbajO8et K1qpQuUUzIv9bmmsnPysBl0VQSV27HW9jMGMOsI2rQbbPMfK2LuNhd/AD2W+PAsIB7MU Us05Mq6Fad6h1y4+LGmh8fIzl2CJfEf2maxxfusbScABc3x8YEGkvrpdGBaGZylHrVQE 0qDx0nk35C6uyI4G241FGPjEnkbOFzkkH5lg1b5sUko7broQSeQ+pcYx/g3iB9+7w1ef 2v3q307IZ3QEYfJ/qcFQV5ew9Md2T0r0sbTU6LCcgCYWcW2XNijNEq76JZ0jvEPYbqBh kSNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b="G/I/b9oK"; spf=pass (google.com: domain of linux-kernel+bounces-25335-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25335-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id m11-20020a1709066d0b00b00a28219b04desi2271825ejr.658.2024.01.13.08.26.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jan 2024 08:26:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25335-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b="G/I/b9oK"; spf=pass (google.com: domain of linux-kernel+bounces-25335-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25335-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id EBC641F221E4 for ; Sat, 13 Jan 2024 16:26:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 15E544C8B; Sat, 13 Jan 2024 16:26:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mess.org header.i=@mess.org header.b="G/I/b9oK" Received: from gofer.mess.org (gofer.mess.org [88.97.38.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9102B4C65; Sat, 13 Jan 2024 16:26:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mess.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mess.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1705163200; bh=RQlY+jEYkNLZGSgB/4+Cf47fWKFdF0+OLYk1Sb7uF+w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=G/I/b9oKpQhGjP/14desRRYG8sMKpLx0JWeRFYydyZP7r/cFiUD/Y11H2OamR/UNm OkEGffzV7F0OAAUeJQqTvGegggOR/usBXKq6LPgePZuFk525StbLlBi6+gc9+RY8gP iy/UNECCrwYRIBhq43eBj8CISLvN1l7AHeUO6fPP3DrD+7EuV4lIl5WSUe6dTc6bPW WVoV9gN74SHfkAVy3Cu9T/A9uvkA0PI/sMNePG1Hn8xsL2x3uOBysXFOhRpMJN5Imu SI1c2JtdZnP37Rq3iGD82NCNpvyKF0360mVtffbiRlqqGG3rPMRzWZov9rX1a8qlSk MTjIfaslZq4uQ== Received: by gofer.mess.org (Postfix, from userid 1000) id 6091C1000C6; Sat, 13 Jan 2024 16:26:40 +0000 (GMT) Date: Sat, 13 Jan 2024 16:26:40 +0000 From: Sean Young To: Ivaylo Dimitrov Cc: daniel.lezcano@linaro.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, tony@atomide.com, linux-pwm@vger.kernel.org Subject: Re: [PATCH] drivers/clocksource/timer-ti-dm: Don't call clk_get_rate() in stop function Message-ID: References: <1696312220-11550-1-git-send-email-ivo.g.dimitrov.75@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1696312220-11550-1-git-send-email-ivo.g.dimitrov.75@gmail.com> Hi Ivaylo, On Tue, Oct 03, 2023 at 08:50:20AM +0300, Ivaylo Dimitrov wrote: > clk_get_rate() might sleep, and that prevents dm-timer based PWM from being > used from atomic context. Now that this is merged, pwm-ir-tx can only use the pwm in atomic context if pwm-omap-timer.c sets the atomic field like the rpi pwm does here: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pwm/pwm-bcm2835.c#n175 see pwm-ir-tx here: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/media/rc/pwm-ir-tx.c#n170 It would be nice to have this tested and working properly for the n900. Thanks, Sean > > 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 > --- > 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); > } > -- > 1.9.1