lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 2 Dec 2015 09:58:23 +0100
From:	Daniel Vetter <daniel@...ll.ch>
To:	Eric Anholt <eric@...olt.net>
Cc:	dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/9] drm: Create a driver hook for allocating GEM object
 structs.

On Tue, Dec 01, 2015 at 12:35:50PM -0800, Eric Anholt wrote:
> The CMA helpers had no way for a driver to extend the struct with its
> own fields.  Since the CMA helpers are mostly "Allocate a
> drm_gem_cma_object, then fill in a few fields", it's hard to write as
> pure helpers without passing in a driver callback for the allocate
> step.
> 
> Signed-off-by: Eric Anholt <eric@...olt.net>

Yeah there's no other way to make this happen without ridiculous amounts
of boilerplate.

Reviewed-by: Daniel Vetter <daniel.vetter@...ll.ch>

> ---
>  drivers/gpu/drm/drm_gem_cma_helper.c | 10 ++++++----
>  include/drm/drmP.h                   |  7 +++++++
>  2 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
> index e109b49..0f7b00ba 100644
> --- a/drivers/gpu/drm/drm_gem_cma_helper.c
> +++ b/drivers/gpu/drm/drm_gem_cma_helper.c
> @@ -59,11 +59,13 @@ __drm_gem_cma_create(struct drm_device *drm, size_t size)
>  	struct drm_gem_object *gem_obj;
>  	int ret;
>  
> -	cma_obj = kzalloc(sizeof(*cma_obj), GFP_KERNEL);
> -	if (!cma_obj)
> +	if (drm->driver->gem_create_object)
> +		gem_obj = drm->driver->gem_create_object(drm, size);
> +	else
> +		gem_obj = kzalloc(sizeof(*cma_obj), GFP_KERNEL);
> +	if (!gem_obj)
>  		return ERR_PTR(-ENOMEM);
> -
> -	gem_obj = &cma_obj->base;
> +	cma_obj = container_of(gem_obj, struct drm_gem_cma_object, base);
>  
>  	ret = drm_gem_object_init(drm, gem_obj, size);
>  	if (ret)
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 0b921ae..22ff162 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -580,6 +580,13 @@ struct drm_driver {
>  	int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
>  	void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
>  
> +	/**
> +	 * Hook for allocating the GEM object struct, for use by core
> +	 * helpers.
> +	 */
> +	struct drm_gem_object *(*gem_create_object)(struct drm_device *dev,
> +						    size_t size);
> +
>  	/* prime: */
>  	/* export handle -> fd (see drm_gem_prime_handle_to_fd() helper) */
>  	int (*prime_handle_to_fd)(struct drm_device *dev, struct drm_file *file_priv,
> -- 
> 2.6.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@...ts.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ