All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Maxim Kochetkov <fido_max@inbox.ru>,
	linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
	peterz@infradead.org, elver@google.com, namcao@linutronix.de,
	samuel.holland@sifive.com, daniel.lezcano@linaro.org,
	apatel@ventanamicro.com
Subject: Re: [PATCH 1/1] time/sched_clock: move sched_clock_register() out of .init section
Date: Mon, 07 Apr 2025 23:11:54 +0200	[thread overview]
Message-ID: <87wmbvvfqd.ffs@tglx> (raw)
In-Reply-To: <f57e8a74-4124-457c-b5c9-d193505ba093@inbox.ru>

On Mon, Apr 07 2025 at 10:25, Maxim Kochetkov wrote:
> 07.04.2025 09:26, Thomas Gleixner wrote:
>> On Fri, Apr 04 2025 at 08:05, Maxim Kochetkov wrote:
>>> The sched_clock_register() is widely used by clocksource timer
>>> drivers. The __init prefix forces them to be initialized using
>>> macro TIMER_OF_DECLARE with __init prefixed function.
>> 
>> No, it does not. It requires that they are built in, not more.
>
> Thank you for review.
>
> Let me explain some more. I'm trying to solve similar problem, as 
> described at 
> https://patchwork.kernel.org/project/linux-arm-kernel/patch/20240312192519.1602493-1-samuel.holland@sifive.com/#25759271
>
> I have both PLIC and clocksource module configured as Y (not m) in 
> Kconfig. So both of them are included in kernel Image binary. But I 
> still unable to probe clocksource device because it depends of PLIC irq.
> And PLIC probes much later than TIMER_OF_DECLARE part of the clocksource 
> driver.

Which is not a problem as all built-in drivers probe _before_ the init
section is discarded.

> I tried to convert clocksource driver to regular platform device and
> it works fine except warning:
>
> WARNING: modpost: vmlinux: section mismatch in reference: 
> dw_apb_timer_probe+0x136 (section: .text.unlikely) -> 
> sched_clock_register (section: .init.text)

Of course. The warning is because you invoke sched_clock_register()
from dw_apb_timer_probe(), which is regular text. See

drivers/clocksource/ingenic-ost.c
drivers/clocksource/timer-cadence-ttc.c

how to implement a builtin platform driver, which does not suffer from
that problem despite invoking sched_clock_register() from their init
functions.

> Dropping __init from sched_clock_register() helps to solve this issue.

It solves it at the wrong point for a builtin platform driver

> Anyway, this patch opens opportunity to compile clocksource drivers as 
> modules and probe them much later.

That's an orthogonal issue and needs to be discussed seperately from the
problem at hand.

Thanks,

        tglx

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

WARNING: multiple messages have this Message-ID (diff)
From: Thomas Gleixner <tglx@linutronix.de>
To: Maxim Kochetkov <fido_max@inbox.ru>,
	linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
	peterz@infradead.org, elver@google.com, namcao@linutronix.de,
	samuel.holland@sifive.com, daniel.lezcano@linaro.org,
	apatel@ventanamicro.com
Subject: Re: [PATCH 1/1] time/sched_clock: move sched_clock_register() out of .init section
Date: Mon, 07 Apr 2025 23:11:54 +0200	[thread overview]
Message-ID: <87wmbvvfqd.ffs@tglx> (raw)
In-Reply-To: <f57e8a74-4124-457c-b5c9-d193505ba093@inbox.ru>

On Mon, Apr 07 2025 at 10:25, Maxim Kochetkov wrote:
> 07.04.2025 09:26, Thomas Gleixner wrote:
>> On Fri, Apr 04 2025 at 08:05, Maxim Kochetkov wrote:
>>> The sched_clock_register() is widely used by clocksource timer
>>> drivers. The __init prefix forces them to be initialized using
>>> macro TIMER_OF_DECLARE with __init prefixed function.
>> 
>> No, it does not. It requires that they are built in, not more.
>
> Thank you for review.
>
> Let me explain some more. I'm trying to solve similar problem, as 
> described at 
> https://patchwork.kernel.org/project/linux-arm-kernel/patch/20240312192519.1602493-1-samuel.holland@sifive.com/#25759271
>
> I have both PLIC and clocksource module configured as Y (not m) in 
> Kconfig. So both of them are included in kernel Image binary. But I 
> still unable to probe clocksource device because it depends of PLIC irq.
> And PLIC probes much later than TIMER_OF_DECLARE part of the clocksource 
> driver.

Which is not a problem as all built-in drivers probe _before_ the init
section is discarded.

> I tried to convert clocksource driver to regular platform device and
> it works fine except warning:
>
> WARNING: modpost: vmlinux: section mismatch in reference: 
> dw_apb_timer_probe+0x136 (section: .text.unlikely) -> 
> sched_clock_register (section: .init.text)

Of course. The warning is because you invoke sched_clock_register()
from dw_apb_timer_probe(), which is regular text. See

drivers/clocksource/ingenic-ost.c
drivers/clocksource/timer-cadence-ttc.c

how to implement a builtin platform driver, which does not suffer from
that problem despite invoking sched_clock_register() from their init
functions.

> Dropping __init from sched_clock_register() helps to solve this issue.

It solves it at the wrong point for a builtin platform driver

> Anyway, this patch opens opportunity to compile clocksource drivers as 
> modules and probe them much later.

That's an orthogonal issue and needs to be discussed seperately from the
problem at hand.

Thanks,

        tglx

  reply	other threads:[~2025-04-07 21:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-04  5:05 [PATCH 1/1] time/sched_clock: move sched_clock_register() out of .init section Maxim Kochetkov
2025-04-04  5:05 ` Maxim Kochetkov
2025-04-07  6:26 ` Thomas Gleixner
2025-04-07  6:26   ` Thomas Gleixner
2025-04-07  7:25   ` Maxim Kochetkov
2025-04-07  7:25     ` Maxim Kochetkov
2025-04-07 21:11     ` Thomas Gleixner [this message]
2025-04-07 21:11       ` Thomas Gleixner

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=87wmbvvfqd.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=apatel@ventanamicro.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=elver@google.com \
    --cc=fido_max@inbox.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=namcao@linutronix.de \
    --cc=peterz@infradead.org \
    --cc=samuel.holland@sifive.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.