linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Paul Cercueil <paul@crapouillou.net>
Cc: Christoph Hellwig <hch@lst.de>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	Dave Airlie <airlied@linux.ie>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	DRI <dri-devel@lists.freedesktop.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>
Subject: Re: [PATCH 1/3] drm: Add and export function drm_gem_cma_create_noalloc
Date: Thu, 1 Oct 2020 10:51:44 +0200	[thread overview]
Message-ID: <20201001085144.GD438822@phenom.ffwll.local> (raw)
In-Reply-To: <20200930171644.299363-1-paul@crapouillou.net>

On Wed, Sep 30, 2020 at 07:16:42PM +0200, Paul Cercueil wrote:
> Add and export the function drm_gem_cma_create_noalloc(), which is just
> __drm_gem_cma_create() renamed.
> 
> This function can be used by drivers that need to create a GEM object
> without allocating the backing memory.
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>  drivers/gpu/drm/drm_gem_cma_helper.c | 11 ++++++-----
>  include/drm/drm_gem_cma_helper.h     |  3 +++
>  2 files changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
> index 59b9ca207b42..6abc4b306832 100644
> --- a/drivers/gpu/drm/drm_gem_cma_helper.c
> +++ b/drivers/gpu/drm/drm_gem_cma_helper.c
> @@ -34,7 +34,7 @@
>   */
>  
>  /**
> - * __drm_gem_cma_create - Create a GEM CMA object without allocating memory
> + * drm_gem_cma_create_noalloc - Create a GEM CMA object without allocating memory
>   * @drm: DRM device
>   * @size: size of the object to allocate
>   *
> @@ -45,8 +45,8 @@
>   * A struct drm_gem_cma_object * on success or an ERR_PTR()-encoded negative
>   * error code on failure.
>   */
> -static struct drm_gem_cma_object *
> -__drm_gem_cma_create(struct drm_device *drm, size_t size)
> +struct drm_gem_cma_object *
> +drm_gem_cma_create_noalloc(struct drm_device *drm, size_t size)
>  {
>  	struct drm_gem_cma_object *cma_obj;
>  	struct drm_gem_object *gem_obj;
> @@ -76,6 +76,7 @@ __drm_gem_cma_create(struct drm_device *drm, size_t size)
>  	kfree(cma_obj);
>  	return ERR_PTR(ret);
>  }
> +EXPORT_SYMBOL_GPL(drm_gem_cma_create_noalloc);

This feels a bit awkward, since for drivers who want to roll their own we
can do that already.

I think the better approach is to export a cma function which allocates
non-coherent dma memory.
-Daniel

>  
>  /**
>   * drm_gem_cma_create - allocate an object with the given size
> @@ -98,7 +99,7 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,
>  
>  	size = round_up(size, PAGE_SIZE);
>  
> -	cma_obj = __drm_gem_cma_create(drm, size);
> +	cma_obj = drm_gem_cma_create_noalloc(drm, size);
>  	if (IS_ERR(cma_obj))
>  		return cma_obj;
>  
> @@ -476,7 +477,7 @@ drm_gem_cma_prime_import_sg_table(struct drm_device *dev,
>  		return ERR_PTR(-EINVAL);
>  
>  	/* Create a CMA GEM buffer. */
> -	cma_obj = __drm_gem_cma_create(dev, attach->dmabuf->size);
> +	cma_obj = drm_gem_cma_create_noalloc(dev, attach->dmabuf->size);
>  	if (IS_ERR(cma_obj))
>  		return ERR_CAST(cma_obj);
>  
> diff --git a/include/drm/drm_gem_cma_helper.h b/include/drm/drm_gem_cma_helper.h
> index 2bfa2502607a..be2b8e3a8ab2 100644
> --- a/include/drm/drm_gem_cma_helper.h
> +++ b/include/drm/drm_gem_cma_helper.h
> @@ -83,6 +83,9 @@ int drm_gem_cma_mmap(struct file *filp, struct vm_area_struct *vma);
>  struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,
>  					      size_t size);
>  
> +struct drm_gem_cma_object *
> +drm_gem_cma_create_noalloc(struct drm_device *drm, size_t size);
> +
>  extern const struct vm_operations_struct drm_gem_cma_vm_ops;
>  
>  #ifndef CONFIG_MMU
> -- 
> 2.28.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

  reply	other threads:[~2020-10-01  8:52 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-28  3:54 linux-next: build failure after merge of the drm tree Stephen Rothwell
2020-09-28  6:04 ` Christoph Hellwig
2020-09-28  6:08   ` Dave Airlie
2020-09-28  6:14     ` Christoph Hellwig
2020-09-28 10:15   ` Paul Cercueil
2020-09-28 11:34     ` Christoph Hellwig
2020-09-28 11:46       ` Paul Cercueil
2020-09-28 12:10         ` Christoph Hellwig
2020-09-28 13:31           ` Paul Cercueil
2020-09-30  9:02             ` Christoph Hellwig
2020-09-30 13:33               ` Paul Cercueil
2020-09-30 16:11                 ` Christoph Hellwig
2020-09-30 16:39                   ` Paul Cercueil
2020-09-30 16:40                     ` Christoph Hellwig
2020-09-30 16:45                       ` Paul Cercueil
2020-09-30 16:52                         ` Christoph Hellwig
2020-09-30 17:16                           ` [PATCH 1/3] drm: Add and export function drm_gem_cma_create_noalloc Paul Cercueil
2020-10-01  8:51                             ` Daniel Vetter [this message]
2020-09-30 17:16                           ` [PATCH 2/3] drm/ingenic: Update code to mmap GEM buffers cached Paul Cercueil
2020-10-01  5:32                             ` Christoph Hellwig
2020-09-30 17:16                           ` [PATCH 3/3] drm/ingenic: Alloc cached GEM buffers with dma_alloc_noncoherent Paul Cercueil
2020-10-01  5:35                             ` Christoph Hellwig
2020-10-04 14:17                           ` [PATCH] Revert "gpu/drm: ingenic: Add option to mmap GEM buffers cached" Paul Cercueil
2020-10-04 19:59                             ` Sam Ravnborg
2020-10-04 20:11                               ` Paul Cercueil
2020-10-05 12:01                                 ` Stephen Rothwell
2020-10-05 14:05                                   ` Daniel Vetter
2020-10-05 14:47                                     ` Paul Cercueil
2020-10-05 17:38                                       ` Daniel Vetter
2020-10-05 22:31                                       ` Daniel Vetter
2020-10-06  4:30                                   ` Stephen Rothwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201001085144.GD438822@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=paul@crapouillou.net \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).