Report the maximum number of IBs that can be pushed with a single DRM_IOCTL_NOUVEAU_EXEC through DRM_IOCTL_NOUVEAU_GETPARAM. While the maximum number of IBs per ring might vary between chipsets, the kernel will make sure that userspace can only push a fraction of the maximum number of IBs per ring per job, such that we avoid a situation where there's only a single job occupying the ring, which could potentially lead to the ring run dry. Using DRM_IOCTL_NOUVEAU_GETPARAM to report the maximum number of IBs that can be pushed with a single DRM_IOCTL_NOUVEAU_EXEC implies that all channels of a given device have the same ring size. Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Lyude Paul <lyude@redhat.com> Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com> Signed-off-by: Danilo Krummrich <dakr@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20231002135008.10651-3-dakr@redhat.com
64 lines
1.3 KiB
C
64 lines
1.3 KiB
C
/* SPDX-License-Identifier: MIT */
|
|
|
|
#ifndef __NOUVEAU_EXEC_H__
|
|
#define __NOUVEAU_EXEC_H__
|
|
|
|
#include <drm/drm_exec.h>
|
|
|
|
#include "nouveau_drv.h"
|
|
#include "nouveau_sched.h"
|
|
|
|
struct nouveau_exec_job_args {
|
|
struct drm_file *file_priv;
|
|
struct nouveau_sched_entity *sched_entity;
|
|
|
|
struct drm_exec exec;
|
|
struct nouveau_channel *chan;
|
|
|
|
struct {
|
|
struct drm_nouveau_sync *s;
|
|
u32 count;
|
|
} in_sync;
|
|
|
|
struct {
|
|
struct drm_nouveau_sync *s;
|
|
u32 count;
|
|
} out_sync;
|
|
|
|
struct {
|
|
struct drm_nouveau_exec_push *s;
|
|
u32 count;
|
|
} push;
|
|
};
|
|
|
|
struct nouveau_exec_job {
|
|
struct nouveau_job base;
|
|
struct nouveau_fence *fence;
|
|
struct nouveau_channel *chan;
|
|
|
|
struct {
|
|
struct drm_nouveau_exec_push *s;
|
|
u32 count;
|
|
} push;
|
|
};
|
|
|
|
#define to_nouveau_exec_job(job) \
|
|
container_of((job), struct nouveau_exec_job, base)
|
|
|
|
int nouveau_exec_job_init(struct nouveau_exec_job **job,
|
|
struct nouveau_exec_job_args *args);
|
|
|
|
int nouveau_exec_ioctl_exec(struct drm_device *dev, void *data,
|
|
struct drm_file *file_priv);
|
|
|
|
static inline unsigned int
|
|
nouveau_exec_push_max_from_ib_max(int ib_max)
|
|
{
|
|
/* Limit the number of IBs per job to half the size of the ring in order
|
|
* to avoid the ring running dry between submissions and preserve one
|
|
* more slot for the job's HW fence.
|
|
*/
|
|
return ib_max > 1 ? ib_max / 2 - 1 : 0;
|
|
}
|
|
|
|
#endif
|