All of lore.kernel.org
 help / color / mirror / Atom feed
From: InKi Dae <daeinki@gmail.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2] DRM: add drm gem cma helper
Date: Tue, 5 Jun 2012 22:54:10 +0900	[thread overview]
Message-ID: <CAAQKjZNWmijKjCXvDJSz6K8+Zj+9QUgp9pVPApEBEi-s=S1ViQ@mail.gmail.com> (raw)
In-Reply-To: <20120605075621.GP30400@pengutronix.de>

2012/6/5 Sascha Hauer <s.hauer@pengutronix.de>:
> On Fri, Jun 01, 2012 at 12:29:47AM +0900, InKi Dae wrote:
>> Hi Sascha,
>>
>> >> +struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,
>> >> +             unsigned int size)
>> >> +{
>> >> +     struct drm_gem_cma_object *cma_obj;
>> >> +     struct drm_gem_object *gem_obj;
>> >> +     int ret;
>> >> +
>> >> +     size = round_up(size, PAGE_SIZE);
>> >> +
>> >> +     cma_obj = kzalloc(sizeof(*cma_obj), GFP_KERNEL);
>> >> +     if (!cma_obj)
>> >> +             return ERR_PTR(-ENOMEM);
>> >> +
>> >> +     cma_obj->vaddr = dma_alloc_writecombine(drm->dev, size,
>> >> +                     &cma_obj->paddr, GFP_KERNEL | __GFP_NOWARN);
>>
>> how about calling drm_gem_cma_buf_allocate() instead of
>> dma_alloc_wirtecombine() for consistency in using dma api so its call
>> flow would be "dma_gem_cma_buf_allocate() ->
>> dma_alloc_writecombine()".
>
> What do you mean? There is no drm_gem_cma_buf_allocate() function.
>

I mean have a pair with drm_gem_cma_buf_destroy() otherwise how about
removing dem_gem_cma_buf_destroy() and calling dma_free_writecombine()
directly? drm_gem_cma_buf_destroy() is just a wrapper to
dma_free_writecombine().

>> >> +     struct drm_gem_object *gem_obj;
>> >> +     struct drm_gem_cma_object *cma_obj;
>> >> +     int ret;
>> >> +
>> >> +     ret = drm_gem_mmap(filp, vma);
>> >> +     if (ret)
>> >> +             return ret;
>> >> +
>> >> +     gem_obj = vma->vm_private_data;
>> >> +     cma_obj = to_drm_gem_cma_obj(gem_obj);
>>
>> it's likely to need checking if user space size is valid or not here.
>> like this;
>> if (vma->end - vma->start > gem_obj->size) {
>>           error message;
>>          and some exceptions;
>> }
>
> This is already done in drm_gem_mmap().
>
> Sascha
>
> --
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2012-06-05 13:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-31  8:08 [PATCH v2] DRM: add drm gem cma helper Sascha Hauer
2012-05-31  9:36 ` Laurent Pinchart
2012-05-31 15:29   ` InKi Dae
2012-06-05  7:56     ` Sascha Hauer
2012-06-05 13:54       ` InKi Dae [this message]
2012-06-06  8:20         ` Sascha Hauer
2012-06-05  7:49   ` Sascha Hauer
2012-06-05  8:05     ` Laurent Pinchart
2012-06-04  9:08 ` Lars-Peter Clausen
2012-06-27 11:38 ` Laurent Pinchart
2012-06-27 13:01   ` Sascha Hauer

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='CAAQKjZNWmijKjCXvDJSz6K8+Zj+9QUgp9pVPApEBEi-s=S1ViQ@mail.gmail.com' \
    --to=daeinki@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=s.hauer@pengutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.