All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shashank Balaji <shashank.mahadasyam@sony.com>
To: Sumit Gupta <sumitg@nvidia.com>
Cc: "Jon Hunter" <jonathanh@nvidia.com>,
	"Thierry Reding" <thierry.reding@kernel.org>,
	"Gary Guo" <gary@garyguo.net>,
	"Suzuki K Poulose" <suzuki.poulose@arm.com>,
	"James Clark" <james.clark@linaro.org>,
	"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Richard Cochran" <richardcochran@gmail.com>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Luis Chamberlain" <mcgrof@kernel.org>,
	"Petr Pavlu" <petr.pavlu@suse.com>,
	"Daniel Gomez" <da.gomez@kernel.org>,
	"Sami Tolvanen" <samitolvanen@google.com>,
	"Aaron Tomlin" <atomlin@atomlin.com>,
	"Mike Leach" <mike.leach@arm.com>, "Leo Yan" <leo.yan@arm.com>,
	"Rahul Bukte" <rahul.bukte@sony.com>,
	linux-kernel@vger.kernel.org, coresight@lists.linaro.org,
	linux-arm-kernel@lists.infradead.org,
	driver-core@lists.linux.dev, rust-for-linux@vger.kernel.org,
	linux-doc@vger.kernel.org,
	"Daniel Palmer" <daniel.palmer@sony.com>,
	"Tim Bird" <tim.bird@sony.com>,
	linux-modules@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: Re: [PATCH v4 1/4] kernel: param: initialize module_kset before do_initcalls()
Date: Tue, 12 May 2026 22:32:37 +0900	[thread overview]
Message-ID: <agMr9Vo3nYu623Y-@JPC00244420> (raw)
In-Reply-To: <0d9e5a78-948e-42da-9d37-78cc2a700cd6@nvidia.com>

On Tue, May 12, 2026 at 05:44:40PM +0530, Sumit Gupta wrote:
> 
> On 12/05/26 14:25, Jon Hunter wrote:
> > Hi Shashank,
> > 
> > On 12/05/2026 03:12, Shashank Balaji wrote:
> > 
> > ...
> > 
> > > > Hi Thierry and Jonathan,
> > > > 
> > > > You can find the context for this email in this patch:
> > > > https://lore.kernel.org/all/20260427-acpi_mod_name-v4-1-22b42240c9bf@sony.com/
> > > > 
> > > > 
> > > > TL;DR: tegra194_cbb_driver and tegra234_cbb_driver are the only drivers
> > > > registering themselves as early as in a pure_initcall. This is a
> > > > problem
> > > > on two fronts:
> > > > 1. Philosophical: As Gary pointed out, pure_initcalls are
> > > > intended to purely
> > > > initialize variables that couldn't be statically initialized. But these
> > > > are doing driver registrations.
> > > > 2. module_kset not initialized at pure_initcall stage: This is
> > > > needed to
> > > > set the module sysfs symlink. Since module_kset is not alive yet during
> > > > pure_initcalls, registering these drivers panics the kernel.
> > 
> > Where exactly is this panic seen? Ie. why are we not seeing this?

The panic happens as a result of this patch series. This series aims to
set .mod_name of struct device_driver for platform drivers. So that, for
built-in drivers, their module sysfs symlink can be created on the basis
of .modname. We essentially want to link a platform driver to its
module. This happens naturally if the driver is built as a loadable
module, but for this to happen for built-in modules, .mod_name needs to be set.

To go from .mod_name to the module sysfs symlink, the module_kset kset
needs to be initialized. This currently happens in a subsys_initcall.
These tegra cbb drivers register themselves in a pure_initcall, i.e.
before subsys_initcall, leading to a null dereference of module_kset.

To fix this, we want to move the module_kset creation to pure_initcall,
and tegra cbb driver registration to core_initcall, so after
pure_initcall.

> > > > We would like to do the tegra cbb driver registration in a
> > > > core_initcall
> > > > (or some later initcall works too), and move module_kset initialization
> > > > to a pure_initcall. Like this:
> > > > 
> > > > diff --git a/drivers/soc/tegra/cbb/tegra194-cbb.c
> > > > b/drivers/soc/tegra/cbb/tegra194-cbb.c
> > > > index ab75d50cc85c..2f69e104c838 100644
> > > > --- a/drivers/soc/tegra/cbb/tegra194-cbb.c
> > > > +++ b/drivers/soc/tegra/cbb/tegra194-cbb.c
> > > > @@ -2342,7 +2342,7 @@ static int __init tegra194_cbb_init(void)
> > > >   {
> > > >          return platform_driver_register(&tegra194_cbb_driver);
> > > >   }
> > > > -pure_initcall(tegra194_cbb_init);
> > > > +core_initcall(tegra194_cbb_init);
> > > > 
> > > >   static void __exit tegra194_cbb_exit(void)
> > > >   {
> > > > diff --git a/drivers/soc/tegra/cbb/tegra234-cbb.c
> > > > b/drivers/soc/tegra/cbb/tegra234-cbb.c
> > > > index fb26f085f691..785072fa4e85 100644
> > > > --- a/drivers/soc/tegra/cbb/tegra234-cbb.c
> > > > +++ b/drivers/soc/tegra/cbb/tegra234-cbb.c
> > > > @@ -1774,7 +1774,7 @@ static int __init tegra234_cbb_init(void)
> > > >   {
> > > >          return platform_driver_register(&tegra234_cbb_driver);
> > > >   }
> > > > -pure_initcall(tegra234_cbb_init);
> > > > +core_initcall(tegra234_cbb_init);
> > > > 
> > > >   static void __exit tegra234_cbb_exit(void)
> > > >   {
> > > > 
> > > > Would this work?
> > 
> > 
> > I am adding Sumit who has been doing a lot of the Tegra CBB driver work.
> > 
> > Sumit, any concerns here? We could run this change through our internal
> > testing to confirm.
> > 
> > Jon
> > 
> 
> CBB driver can be switched to core_initcall.
> pure_initcall was originally added so its IRQ handler is registered
> before other Tegra drivers to catch and print any bad MMIO error
> during their probe.
> Looked at the current state of Tegra drivers:
>  - The other early Tegra drivers (PMC, fuse, flowctrl, ARI) all run at
>    early_initcall, before either pure_ or core_initcall.
>  - The only other Tegra core_initcall is tegra-hsp, and link order keeps
>    CBB ahead of it (drivers/soc/ links before drivers/mailbox/).
> 
> Acked-by: Sumit Gupta <sumitg@nvidia.com>

Thanks, Sumit and Jon!


  reply	other threads:[~2026-05-12 13:32 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-21  6:02 [PATCH v2 0/2] Enable sysfs module symlink for more built-in drivers Shashank Balaji
2026-04-21  6:02 ` [PATCH v2 1/2] kernel: param: handle NULL module_kset in lookup_or_create_module_kobject() Shashank Balaji
2026-04-21  6:27   ` Greg Kroah-Hartman
2026-04-21 14:59     ` Shashank Balaji
2026-04-21 15:20       ` Greg Kroah-Hartman
2026-04-21  6:02 ` [PATCH v2 2/2] driver core: platform: set mod_name in driver registration Shashank Balaji
2026-04-21  6:24   ` Greg Kroah-Hartman
2026-04-22  9:49 ` [PATCH v3 0/4] Enable sysfs module symlink for more built-in drivers Shashank Balaji
2026-04-22  9:49   ` [PATCH v3 1/4] kernel: param: initialize module_kset on-demand Shashank Balaji
2026-04-24  9:16     ` Shashank Balaji
2026-04-24 19:26     ` Gary Guo
2026-04-22  9:49   ` [PATCH v3 2/4] coresight: pass THIS_MODULE implicitly through a macro Shashank Balaji
2026-04-22  9:49   ` [PATCH v3 3/4] driver core: platform: set mod_name in driver registration Shashank Balaji
2026-04-22  9:49   ` [PATCH v3 4/4] docs: driver-api: add mod_name argument to __platform_register_drivers() Shashank Balaji
2026-04-22 11:27     ` Greg Kroah-Hartman
2026-04-27  2:41   ` [PATCH v4 0/4] Enable sysfs module symlink for more built-in drivers Shashank Balaji
2026-04-27  2:41     ` [PATCH v4 1/4] kernel: param: initialize module_kset before do_initcalls() Shashank Balaji
2026-04-27 13:29       ` Gary Guo
2026-04-28  0:37         ` Shashank Balaji
2026-04-28 11:10           ` Gary Guo
2026-04-28 13:07             ` Shashank Balaji
2026-05-12  2:12               ` Shashank Balaji
2026-05-12  8:55                 ` Jon Hunter
2026-05-12 12:14                   ` Sumit Gupta
2026-05-12 13:32                     ` Shashank Balaji [this message]
2026-04-27  2:41     ` [PATCH v4 2/4] coresight: pass THIS_MODULE implicitly through a macro Shashank Balaji
2026-04-27 10:49       ` Leo Yan
2026-04-27  2:41     ` [PATCH v4 3/4] driver core: platform: set mod_name in driver registration Shashank Balaji
2026-04-27  2:41     ` [PATCH v4 4/4] docs: driver-api: add mod_name argument to __platform_register_drivers() Shashank Balaji
2026-05-18 10:19     ` [PATCH v5 0/4] Enable sysfs module symlink for more built-in drivers Shashank Balaji
2026-05-18 10:19       ` [PATCH v5 1/4] soc/tegra: cbb: Move driver registration from pure_initcall to core_initcall Shashank Balaji
2026-05-27 11:19         ` Gary Guo
2026-05-28 21:09         ` Thierry Reding
2026-05-18 10:19       ` [PATCH v5 2/4] kernel: param: initialize module_kset in a pure_initcall Shashank Balaji
2026-05-22 13:06         ` Petr Pavlu
2026-05-23  3:24           ` Shashank Balaji
2026-06-01 10:19             ` [PATCH v6] " Shashank Balaji
2026-06-01 15:48               ` Danilo Krummrich
2026-05-27 11:19         ` [PATCH v5 2/4] " Gary Guo
2026-05-18 10:19       ` [PATCH v5 3/4] coresight: pass THIS_MODULE implicitly through a macro Shashank Balaji
2026-05-18 10:20       ` [PATCH v5 4/4] driver core: platform: set mod_name in driver registration Shashank Balaji
2026-05-18 10:27         ` Greg Kroah-Hartman
2026-05-18 10:32           ` Shashank Balaji
2026-05-18 10:49             ` Greg Kroah-Hartman
2026-05-28 21:19       ` [PATCH v5 0/4] Enable sysfs module symlink for more built-in drivers Danilo Krummrich

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=agMr9Vo3nYu623Y-@JPC00244420 \
    --to=shashank.mahadasyam@sony.com \
    --cc=a.hindborg@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=aliceryhl@google.com \
    --cc=atomlin@atomlin.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=corbet@lwn.net \
    --cc=coresight@lists.linaro.org \
    --cc=da.gomez@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.palmer@sony.com \
    --cc=driver-core@lists.linux.dev \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=james.clark@linaro.org \
    --cc=jonathanh@nvidia.com \
    --cc=leo.yan@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=mike.leach@arm.com \
    --cc=ojeda@kernel.org \
    --cc=petr.pavlu@suse.com \
    --cc=rafael@kernel.org \
    --cc=rahul.bukte@sony.com \
    --cc=richardcochran@gmail.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=samitolvanen@google.com \
    --cc=skhan@linuxfoundation.org \
    --cc=sumitg@nvidia.com \
    --cc=suzuki.poulose@arm.com \
    --cc=thierry.reding@kernel.org \
    --cc=tim.bird@sony.com \
    --cc=tmgross@umich.edu \
    /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.