All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Hao-Wen Ting <haowen.ting@realtek.com>, daniel.lezcano@linaro.org
Cc: jinn.cheng@realtek.com, edwardwu@realtek.com, phelic@realtek.com,
	shawn.huang724@realtek.com, haowen.ting@realtek.com,
	cy.huang@realtek.com, james.tai@realtek.com, cylee12@realtek.com,
	phinex@realtek.com, conor+dt@kernel.org, krzk+dt@kernel.org,
	robh@kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, stanley_chang@realtek.com
Subject: Re: [PATCH v3 2/2] clocksource: Add Realtek systimer as tick broadcast driver
Date: Mon, 17 Nov 2025 10:16:39 +0100	[thread overview]
Message-ID: <875xb981e0.ffs@tglx> (raw)
In-Reply-To: <20251117073408.428190-3-haowen.ting@realtek.com>

On Mon, Nov 17 2025 at 15:34, Hao-Wen Ting wrote:
> +static u64 rtk_ts64_read(void)
> +{
> +	u64 ts;
> +	u32 low, high;

https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#variable-declarations

> +	/* Caution: Read LSB word (TS_LW_OFST) first then MSB (TS_HW_OFST) */
> +	low = readl(systimer_base + TS_LW_OFST);
> +	high = readl(systimer_base + TS_HW_OFST);
> +
> +	pr_debug("64bit-TS:HW=0x%08x,LW=0x%08x\n", high, low);

Please get rid of these debug prints.

> +	ts = ((u64)high << 32) | low;
> +
> +	return ts;
> +}
> +
> +
> +static int rtk_syst_clkevt_next_ktime(ktime_t expires,
> +				      struct clock_event_device *clkevt)

Pointless line break. You have 100 characters

> +{
> +	u64 cmp_val;
> +	unsigned long flags;
> +	ktime_t now = ktime_get();
> +	s64 delta_ns = ktime_to_ns(ktime_sub(expires, now));
> +	u64 delta_us = delta_ns / 1000;
> +
> +	pr_debug("delta_ns = %lld, clkevt.min_delta_ns = %llu\n",
> +		 delta_ns, clkevt->min_delta_ns);
> +
> +	if (delta_ns <= (s64)clkevt->min_delta_ns) {
> +		delta_ns = clkevt->min_delta_ns;
> +		delta_us = delta_ns / 1000;
> +		pr_debug("Clamping delta_ns to min_delta_ns\n");
> +	}

Why are you using the set_next_ktime() callback instead of set_next(),
where the core code does the conversion _and_ the clamping?

> +	rtk_cmp_en_write(DSBL);
> +	local_irq_save(flags);

Pointless exercise. set_next*() is always invoked with interrupts disabled.

> +	cmp_val = rtk_ts64_read();
> +
> +	/* Set CMP value to current timestamp plus delta_us */
> +	rtk_cmp_value_write(cmp_val + delta_us);
> +	rtk_cmp_en_write(ENBL);
> +	local_irq_restore(flags);
> +	return 0;
> +}

> +static struct timer_of _to = {

What's wrong with a proper variable name instead of this made up '_to'?

> +	.flags = TIMER_OF_IRQ | TIMER_OF_BASE,
> +
> +	.clkevt = {
> +		.name = "rtk-clkevt",
> +		.rating = 300,
> +		.cpumask = cpu_possible_mask,
> +		.features = CLOCK_EVT_FEAT_DYNIRQ |
> +			    CLOCK_EVT_FEAT_ONESHOT |
> +			    CLOCK_EVT_FEAT_KTIME,
> +		.set_next_ktime = rtk_syst_clkevt_next_ktime,
> +		.set_state_oneshot = rtk_syst_shutdown,
> +		.set_state_shutdown = rtk_syst_shutdown
> +	},
> +
> +	.of_irq = {
> +		.flags = IRQF_TIMER | IRQF_IRQPOLL,
> +		.handler = rtk_ts_match_intr_handler
> +	},

https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#struct-declarations-and-initializers

Thanks,

        tglx

  reply	other threads:[~2025-11-17  9:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-17  7:34 [PATCH v3 0/2] Add Realtek System Timer driver Hao-Wen Ting
2025-11-17  7:34 ` [PATCH v3 1/2] dt-bindings: timer: Add Realtek SYSTIMER Hao-Wen Ting
2025-11-17  7:42   ` Krzysztof Kozlowski
2025-11-17  7:34 ` [PATCH v3 2/2] clocksource: Add Realtek systimer as tick broadcast driver Hao-Wen Ting
2025-11-17  9:16   ` Thomas Gleixner [this message]
2025-11-19 12:34   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875xb981e0.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=conor+dt@kernel.org \
    --cc=cy.huang@realtek.com \
    --cc=cylee12@realtek.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=edwardwu@realtek.com \
    --cc=haowen.ting@realtek.com \
    --cc=james.tai@realtek.com \
    --cc=jinn.cheng@realtek.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phelic@realtek.com \
    --cc=phinex@realtek.com \
    --cc=robh@kernel.org \
    --cc=shawn.huang724@realtek.com \
    --cc=stanley_chang@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.