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

From: Boris Brezillon
Date: Wed Oct 02 2024 - 04:40:26 EST


On Tue, 24 Sep 2024 00:06:23 +0100
Adrián Larumbe <adrian.larumbe@xxxxxxxxxxxxx> 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);
> +}