dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Joel Fernandes <joelagnelf@nvidia.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: Danilo Krummrich <dakr@kernel.org>,
	Koen Koning <koen.koning@linux.intel.com>,
	dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
	Matthew Auld <matthew.auld@intel.com>,
	Dave Airlie <airlied@redhat.com>,
	Peter Senna Tschudin <peter.senna@linux.intel.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH v3 1/3] gpu/buddy: fix module_init() usage
Date: Sun, 22 Feb 2026 19:49:11 -0500	[thread overview]
Message-ID: <cdc31857-c9a0-4d05-a243-780dc9819cb7@nvidia.com> (raw)
In-Reply-To: <2026022156-citizen-shredding-5d6d@gregkh>



On 2/21/2026 12:44 AM, Greg KH wrote:
> On Fri, Feb 20, 2026 at 08:55:52AM -0500, Joel Fernandes wrote:
>>> On Feb 20, 2026, at 5:17 AM, Danilo Krummrich <dakr@kernel.org> wrote:
>>>
>>> On Fri Feb 20, 2026 at 7:06 AM CET, Greg KH wrote:
>>>>> On Thu, Feb 19, 2026 at 10:38:56PM +0100, Koen Koning wrote:
>>>>> Use subsys_initcall() instead of module_init() (which compiles to
>>>>> device_initcall() for built-ins) for buddy, so its initialization code
>>>>> always runs before any (built-in) drivers.
>>>>> This happened to work correctly so far due to the order of linking in
>>>>> the Makefiles, but this should not be relied upon.
>>>>
>>>> Same here, Makefile order can always be relied on.
>>>
>>> I want to point out that Koen's original patch fixed the Makefile order:
>>>
>>> diff --git a/drivers/gpu/Makefile b/drivers/gpu/Makefile
>>> index 5cd54d06e262..b4e5e338efa2 100644
>>> --- a/drivers/gpu/Makefile
>>> +++ b/drivers/gpu/Makefile
>>> @@ -2,8 +2,9 @@
>>> # drm/tegra depends on host1x, so if both drivers are built-in care must be
>>> # taken to initialize them in the correct order. Link order is the only way
>>> # to ensure this currently.
>>> +# Similarly, buddy must come first since it is used by other drivers.
>>> +obj-$(CONFIG_GPU_BUDDY)    += buddy.o
>>> obj-y            += host1x/ drm/ vga/ tests/
>>> obj-$(CONFIG_IMX_IPUV3_CORE)    += ipu-v3/
>>> obj-$(CONFIG_TRACE_GPU_MEM)        += trace/
>>> obj-$(CONFIG_NOVA_CORE)        += nova-core/
>>> -obj-$(CONFIG_GPU_BUDDY)        += buddy.o
>>>
>>> He was then suggested to not rely on this and rather use subsys_initcall().
>>
>> I take the blame for the suggestion; however, I am not yet convinced it is a bad
>> idea. 
>>>
>>> When I then came across the new patch using subsys_initcall() I made it worse; I
>>> badly confused this with something else and gave a wrong advise -- sorry Koen!
>>>
>>> (Of course, since this is all within the same subsystem, without any external
>>> ordering contraints, Makefile order is sufficient.)
>>
>> If we are still going to do the link ordering by reordering in the Makefile,
>> may I ask what is the drawback of doing the alternative - that is, not
>> relying on that (and its associated potential for breakage)?
>>
>> Even if Makefile ordering can be relied on, why do we want to rely on it if
>> there is an alternative? Also module_init() compiles to device_initcall() for
>> built-ins and this is shared infra.
>>
>> We use this technique in other code paths too, no? See
>> drivers/i2c/i2c-core-base.c:
>>
>>   /* We must initialize early, because some subsystems register i2c drivers
>>    * in subsys_initcall() code, but are linked (and initialized) before i2c.
>>    */
>>   postcore_initcall(i2c_init);
>>
>> If there is a drawback I am all ears but otherwise I would prefer the new
>> patch tbh. 
> 
> The "problem" is that the init levels are very "coarse", and the link
> order is very specific.  You can play with init levels a lot, but what
> happens if another driver also sets to the same init level, or an
> earlier one to try to solve something that way?
> 
> So it can be a loosing battle for many things, choose the best and
> simplest solution, but always remember, Makefile order matters, which is
> what I was wanting to correct here.
Fair enough, the solution you are suggesting also sounds good to me.

thanks,

--
Joel Fernandes


  reply	other threads:[~2026-02-23  0:49 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-13 15:20 [PATCH] gpu: Fix uninitialized buddy for built-in drivers Koen Koning
2026-02-13 17:27 ` Joel Fernandes
2026-02-16 10:28   ` Matthew Auld
2026-02-16 11:19 ` [PATCH v2] " Koen Koning
2026-02-16 21:31   ` Joel Fernandes
2026-02-19 10:16   ` Danilo Krummrich
2026-02-19 10:38     ` Matthew Auld
2026-02-19 11:14       ` Danilo Krummrich
2026-02-19 12:44         ` Matthew Auld
2026-02-19 12:56           ` Danilo Krummrich
2026-02-19 15:32             ` Matthew Auld
2026-02-19 16:08               ` Danilo Krummrich
2026-02-19 18:28             ` Koen Koning
2026-02-19 18:34               ` Danilo Krummrich
2026-02-19 21:38   ` [PATCH v3 0/3] gpu: fix module_init() usage Koen Koning
2026-02-19 21:38     ` [PATCH v3 1/3] gpu/buddy: " Koen Koning
2026-02-20  6:06       ` Greg KH
2026-02-20 10:17         ` Danilo Krummrich
2026-02-20 13:55           ` Joel Fernandes
2026-02-21  5:44             ` Greg KH
2026-02-23  0:49               ` Joel Fernandes [this message]
2026-02-23 11:17                 ` Koen Koning
2026-02-23 11:20                   ` Danilo Krummrich
2026-02-23 13:42                     ` Joel Fernandes
2026-02-23 22:31                     ` Danilo Krummrich
2026-02-24  3:41                       ` David Airlie
2026-02-19 21:38     ` [PATCH v3 2/3] drm/sched: " Koen Koning
2026-02-20  6:06       ` Greg KH
2026-02-19 21:38     ` [PATCH v3 3/3] drm/drv: " Koen Koning
2026-02-23 22:30 ` [PATCH] gpu: Fix uninitialized buddy for 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=cdc31857-c9a0-4d05-a243-780dc9819cb7@nvidia.com \
    --to=joelagnelf@nvidia.com \
    --cc=airlied@redhat.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=koen.koning@linux.intel.com \
    --cc=matthew.auld@intel.com \
    --cc=peter.senna@linux.intel.com \
    --cc=stable@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox