[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <DG20V5TR0ZED.2K9YN3YBEPNJE@baylibre.com>
Date: Fri, 30 Jan 2026 16:17:26 +0100
From: "Markus Schneider-Pargmann" <msp@...libre.com>
To: "Daniel Lezcano" <daniel.lezcano@...aro.org>, "Markus Schneider-Pargmann
(TI.com)" <msp@...libre.com>, "Thomas Gleixner" <tglx@...utronix.de>
Cc: "Vishal Mahaveer" <vishalm@...com>, "Kevin Hilman"
<khilman@...libre.com>, "Dhruva Gole" <d-gole@...com>, "Sebin Francis"
<sebin.francis@...com>, "Kendall Willis" <k-willis@...com>, "Akashdeep
Kaur" <a-kaur@...com>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 2/3] clocksource/drivers/timer-ti-dm: Add clocksource
support
Hi Daniel,
On Tue Jan 20, 2026 at 4:04 PM CET, Daniel Lezcano wrote:
> On 12/16/25 21:03, Markus Schneider-Pargmann (TI.com) wrote:
>> Add support for using the TI Dual-Mode Timer as a clocksource. The
>> driver automatically picks the first timer that is marked as always-on
>> on with the "ti,timer-alwon" property to be the clocksource.
>>
>> The timer can then be used for CPU independent time keeping.
>>
>> Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@...libre.com>
>> ---
>
> [ ... ]
>
>> +static int omap_dm_timer_setup_clocksource(struct dmtimer *timer)
>> +{
>> + struct device *dev = &timer->pdev->dev;
>> + struct dmtimer_clocksource *clksrc;
>> + int err;
>> +
>> + __omap_dm_timer_init_regs(timer);
>> +
>> + timer->reserved = 1;
>> +
>> + clksrc = devm_kzalloc(dev, sizeof(*clksrc), GFP_KERNEL);
>> + if (!clksrc)
>> + return -ENOMEM;
>
> [ ... ]
>
>> + clksrc->timer = timer;
>> + timer->clksrc = clksrc;
>
> This is a cyclic dependency which is not desired in general.
>
> I suggest to have struct dmtimer_clocksource containing struct dmtimer timer
Thank you! Not many timers will probably have the clocksource part
setup, so I didn't like to embed struct dmtimer into
dmtimer_clocksource. I could have used different allocation routines in
probe to use either struct dmtimer_clocksource or struct dmtimer
directly depending on the use of clocksource, but I wasn't convinced by
that either.
For the code here I am only having the timer->clksrc pointer to
unregister the clocksource in cleanup. So I found
devm_add_action_or_reset()
which can call the clocksource_unregister and eliminate the need for the
pointer. This is also already used in the timer-nxp-stm.c driver.
So if you are happy with that, I would prefer that solution.
Best
Markus
Download attachment "signature.asc" of type "application/pgp-signature" (290 bytes)
Powered by blists - more mailing lists