Re: [PATCH v4] accel/rocket: Report NPU usage through fdinfo
From: Tomeu Vizoso
Date: Thu Nov 05 2026 - 01:58:59 EST
I agree with Gyeyoung.
With that:
Reviewed-by: Tomeu Vizoso <tomeu@xxxxxxxxxxxxxxx>
Btw, I think we have had a backmerge already.
Thanks,
Tomeu
On Thu, Nov 5, 2026 at 4:22 AM Gyeyoung Baek <gye976@xxxxxxxxx> wrote:
>
> Hi Sidong,
>
> On Wed, Nov 4, 2026 at 12:53 AM Sidong Yang <sidong.yang@xxxxxxxxxx> wrote:
> >
> > There is no way to tell how much of the NPU a client uses. Implement the
> > DRM usage stats: account the time each job occupies a core and report
> > it per client as drm-engine-npu, along with drm_show_memory_stats() for
> > the BOs.
> >
> > The cores are identical, so they are reported as a single engine with
> > drm-engine-capacity-npu set to rdev->max_cores, the number of core
> > slots. The time is summed over all cores, with an atomic counter as the
> > cores complete jobs concurrently.
> >
> > Jobs can outlive the file that submitted them, so the counter is
> > refcounted and each job holds a reference. The time covers the whole
> > period a job owns a core, so it also includes handling the completion
> > interrupt and the gaps between the tasks of a multi-task job.
>
> nit: "the time completed jobs occupy a core" would be more accurate than
> "the whole period", as timed-out jobs are not accounted.
>
>
> > * RK3588
> > +
> > +.. _rocket-usage-stats:
> > +
> > +Rocket DRM client usage stats implementation
> > +============================================
> > +
> > +The accel/rocket driver implements the DRM client usage stats specification as
> > +documented in :ref:`drm-client-usage-stats`.
> > +
> > +The NPU cores are reported as a single engine, npu, with a capacity equal to the
> > +number of cores. The time is summed over all cores, and covers the whole period
> > +a job occupies a core.
>
> Same here
>
> > @@ -139,7 +183,28 @@ static const struct drm_ioctl_desc rocket_drm_driver_ioctls[] = {
> > ROCKET_IOCTL(FINI_BO, fini_bo),
> > };
> >
> > -DEFINE_DRM_ACCEL_FOPS(rocket_accel_driver_fops);
> > +static void rocket_show_fdinfo(struct drm_printer *p, struct drm_file *file)
> > +{
> > + struct rocket_device *rdev = to_rocket_device(file->minor->dev);
> > + struct rocket_file_priv *rocket_priv = file->driver_priv;
> > +
> > + /*
> > + * This is an estimate: the time is taken around the whole period a job
> > + * occupies a core, so it also covers handling the completion interrupt
> > + * and, for a job made of several tasks, the gaps between them.
> > + */
>
> And here.
>
> with these addressed:
>
> Tested on RK3588: no OOB access, and fdinfo reads correctly with several
> apps running concurrently.
>
> Reviewed-by: Gyeyoung Baek <gyeyoung7182@xxxxxxxxx>
> Tested-by: Gyeyoung Baek <gyeyoung7182@xxxxxxxxx>
>
> --
> Thanks,
> Gyeyoung