On Tue, 4 Apr 2023 03:27:30 +0200 Danilo Krummrich <dakr@xxxxxxxxxx> wrote: > +/** > + * drm_gpuva_prealloc_create - creates a preallocated node to store a > + * &drm_gpuva entry. > + * > + * Returns: the &drm_gpuva_prealloc object on success, NULL on failure > + */ > +struct drm_gpuva_prealloc * > +drm_gpuva_prealloc_create(void) > +{ > + struct drm_gpuva_prealloc *pa; > + > + pa = kzalloc(sizeof(*pa), GFP_KERNEL); > + if (!pa) > + return NULL; > + > + if (mas_preallocate(&pa->mas, GFP_KERNEL)) { mas_preallocate() needs a valid tree field to calculate the number of nodes to pre-allocate. I guess we're missing a MA_STATE_INIT() here, and we need to pass a gpuva_mgr object to this helper. > + kfree(pa); > + return NULL; > + } > + > + return pa; > +} > +EXPORT_SYMBOL(drm_gpuva_prealloc_create);