From: Daniel Vetter Subject: Re: [Linaro-mm-sig] [PATCH] gpu: drm: Add helpers to allow export gem cma objects Date: Sat, 19 Oct 2013 12:44:44 +0200 Message-ID: <20131019104444.GB4830@phenom.ffwll.local> References: <1382086857-10832-1-git-send-email-benjamin.gaignard@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-ea0-f178.google.com (mail-ea0-f178.google.com [209.85.215.178]) by gabe.freedesktop.org (Postfix) with ESMTP id 519B0E61F6 for ; Sat, 19 Oct 2013 03:44:24 -0700 (PDT) Received: by mail-ea0-f178.google.com with SMTP id a15so2525629eae.37 for ; Sat, 19 Oct 2013 03:44:23 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1382086857-10832-1-git-send-email-benjamin.gaignard@linaro.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: benjamin.gaignard@linaro.org Cc: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org On Fri, Oct 18, 2013 at 11:00:57AM +0200, benjamin.gaignard@linaro.org wrote: > From: Benjamin Gaignard > > DRM already offer helpers to use CMA for dumb buffers. > This patch add helpers to export/import gem_cam objects and allow them to be mmap from userland. > The goal is to make working this kind of sequence: create_dumb, get fd from > buffer handle and then use fd (maybe in another process which may ignore it > is comming from DRM) to mmap the buffer. > > drm_gem_cma_prime_export() add O_RDWR to flags to be sure that memory > could be mmapped later with PROT_WRITE flag. > > Signed-off-by: Benjamin Gaignard [snip] > +struct dma_buf *drm_gem_cma_prime_export(struct drm_device *drm_dev, > + struct drm_gem_object *obj, int flags) > +{ > + struct drm_gem_cma_object *cma_obj = to_drm_gem_cma_obj(obj); > + > + flags |= O_RDWR; This here looks funny ... I think either we need to add more flags to the prime dma-buf exporting to also pass this flag through. Or we should just generally set this in dma_buf_export. Doing this as an exporter-specific hack feels wrong. -Daniel > + return dma_buf_export(cma_obj, &drm_gem_cma_dmabuf_ops, > + cma_obj->base.size, flags); > +} > +EXPORT_SYMBOL_GPL(drm_gem_cma_prime_export); -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch