diff options
author | Rob Clark <robdclark@chromium.org> | 2023-11-20 16:38:50 -0800 |
---|---|---|
committer | Rob Clark <robdclark@chromium.org> | 2023-12-10 10:38:47 -0800 |
commit | 05d249352f1ae909230c230767ca8f4e9fdf8e7b (patch) | |
tree | e9256983156f7ae4ab3888d89d90b68f4bc3b2d4 /drivers/gpu/drm/drm_exec.c | |
parent | 3a48a40387e73e1a37428b11cb3ba56d4c108571 (diff) | |
download | linux-05d249352f1ae909230c230767ca8f4e9fdf8e7b.tar.gz linux-05d249352f1ae909230c230767ca8f4e9fdf8e7b.tar.bz2 linux-05d249352f1ae909230c230767ca8f4e9fdf8e7b.zip |
drm/exec: Pass in initial # of objects
In cases where the # is known ahead of time, it is silly to do the table
resize dance.
Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Christian König <christian.koenig@amd.com>
Patchwork: https://patchwork.freedesktop.org/patch/568338/
Diffstat (limited to 'drivers/gpu/drm/drm_exec.c')
-rw-r--r-- | drivers/gpu/drm/drm_exec.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/gpu/drm/drm_exec.c b/drivers/gpu/drm/drm_exec.c index 5d2809de4517..48ee851b61d9 100644 --- a/drivers/gpu/drm/drm_exec.c +++ b/drivers/gpu/drm/drm_exec.c @@ -69,16 +69,23 @@ static void drm_exec_unlock_all(struct drm_exec *exec) * drm_exec_init - initialize a drm_exec object * @exec: the drm_exec object to initialize * @flags: controls locking behavior, see DRM_EXEC_* defines + * @nr: the initial # of objects * * Initialize the object and make sure that we can track locked objects. + * + * If nr is non-zero then it is used as the initial objects table size. + * In either case, the table will grow (be re-allocated) on demand. */ -void drm_exec_init(struct drm_exec *exec, uint32_t flags) +void drm_exec_init(struct drm_exec *exec, uint32_t flags, unsigned nr) { + if (!nr) + nr = PAGE_SIZE / sizeof(void *); + exec->flags = flags; - exec->objects = kmalloc(PAGE_SIZE, GFP_KERNEL); + exec->objects = kvmalloc_array(nr, sizeof(void *), GFP_KERNEL); /* If allocation here fails, just delay that till the first use */ - exec->max_objects = exec->objects ? PAGE_SIZE / sizeof(void *) : 0; + exec->max_objects = exec->objects ? nr : 0; exec->num_objects = 0; exec->contended = DRM_EXEC_DUMMY; exec->prelocked = NULL; |