Re: [PATCH v8 3/5] drm/panthor: add DRM fdinfo support

Boris Brezillon
2024-10-02T08:40:13Z

On Tue, 24 Sep 2024 00:06:23 +0100
Adrián Larumbe <adrian.larumbe@collabora.com> wrote:

> +static void update_fdinfo_stats(struct panthor_job *job)
> +{
> + struct panthor_group *group = job->group;
> + struct panthor_queue *queue = group->queues[job->queue_idx];
> + struct panthor_gpu_usage *fdinfo = &group->fdinfo.data;
> + struct panthor_job_profiling_data *times;
> +
> + times = (struct panthor_job_profiling_data *)
> + ((unsigned long) queue->profiling.slots->kmap +
> + (job->profiling.slot * sizeof(struct panthor_job_profiling_data)));

The casting done here is a bit of a mess, so I replaced it by:

struct panthor_job_profiling_data *slots = queue->profiling.slots->kmap;
struct panthor_job_profiling_data *data = &slots[job->profiling.slot];

> +
> + mutex_lock(&group->fdinfo.lock);
> + if (job->profiling.mask & PANTHOR_DEVICE_PROFILING_CYCLES)
> + fdinfo->cycles += times->cycles.after - times->cycles.before;
> + if (job->profiling.mask & PANTHOR_DEVICE_PROFILING_TIMESTAMP)
> + fdinfo->time += times->time.after - times->time.before;
> + mutex_unlock(&group->fdinfo.lock);
> +}