[PATCH 3/3] drm/vram-helper: Support struct drm_driver.gem_create_object
Sam Ravnborg
sam at ravnborg.org
Wed Dec 11 19:11:28 UTC 2019
Hi Thomas,
On Wed, Dec 11, 2019 at 07:08:32PM +0100, Thomas Zimmermann wrote:
> Drivers that what to allocate VRAM GEM objects with additional fields
> can now do this by implementing struct drm_driver.gem_create_object.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
> ---
> drivers/gpu/drm/drm_gem_vram_helper.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> index b760fd27f3c0..d475d94e2e3e 100644
> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> @@ -2,6 +2,7 @@
>
> #include <drm/drm_debugfs.h>
> #include <drm/drm_device.h>
> +#include <drm/drm_drv.h>
> #include <drm/drm_file.h>
> #include <drm/drm_framebuffer.h>
> #include <drm/drm_gem_ttm_helper.h>
> @@ -142,13 +143,19 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev,
> size_t size,
> unsigned long pg_align)
> {
> + struct drm_gem_object *gem;
> struct drm_gem_vram_object *gbo;
> int ret;
>
> - gbo = kzalloc(sizeof(*gbo), GFP_KERNEL);
> - if (!gbo)
> + if (dev->driver->gem_create_object)
> + gem = dev->driver->gem_create_object(dev, size);
> + else
> + gem = kzalloc(sizeof(*gbo), GFP_KERNEL);
The size is (*gbo) but you assume it is a gem.
Looks wrong at first glance???
Sam
> + if (!gem)
> return ERR_PTR(-ENOMEM);
>
> + gbo = drm_gem_vram_of_gem(gem);
> +
> ret = drm_gem_vram_init(dev, gbo, size, pg_align);
> if (ret < 0)
> goto err_kfree;
> --
> 2.24.0
More information about the dri-devel
mailing list