Re: [PATCH] accel/rocket: Count a core only after it is initialized

From: Gyeyoung Baek

Date: Sun Dec 06 2026 - 07:27:07 EST


Hi Sidong,

On Sun, Dec 6, 2026 at 11:54 AM Sidong Yang <sidong.yang@xxxxxxxxxx> wrote:
>
> rocket_probe() increments rdev->num_cores before rocket_core_init() has
> called drm_sched_init() for that core, and the DRM device is registered
> when the first core probes. An open() during the probe of a later core
> therefore passes an uninitialized scheduler to drm_sched_entity_init().
> That is accepted today, but [1] is going to reject it with -EINVAL.
>
> rocket_job_open() also reads num_cores separately for allocating the
> scheduler list, for filling it and for passing it on, while a probe can
> change it in between.
>
> Count the core once rocket_core_init() has succeeded and read num_cores
> once in rocket_job_open(). A file that is opened while cores are still
> probing only gets the cores that are ready at that time.

IIUC, the root cause is that the DRM device is registered when the
first core probes,
so it is already exposed to userspace while the remaining cores are
still probing.

Could we instead defer the registration until all cores are ready?
That would remove the window for the race altogether,
without needing release/acquire or extra conditions to manage it.

The component framework can be used for this.
Roughly:

current:
probe(core0) -> drm_dev_register() -> probe(core1) -> probe(core2)

new:
probe(core0) -> probe(core1) -> probe(core2)
-> aggregate bind -> drm_dev_register()

--
Thanks,
Gyeyoung