From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Vetter Subject: Re: [PATCH] drm/i915: Document that mmap forwarding is discouraged Date: Sun, 19 Oct 2014 16:52:52 +0200 Message-ID: <20141019145252.GM26941@phenom.ffwll.local> References: <1413455298-1120-1-git-send-email-daniel.vetter@ffwll.ch> <87zjcwcmtn.fsf@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by gabe.freedesktop.org (Postfix) with ESMTP id 54CC789DA8 for ; Sun, 19 Oct 2014 07:52:45 -0700 (PDT) Received: by mail-wi0-f176.google.com with SMTP id hi2so5227165wib.9 for ; Sun, 19 Oct 2014 07:52:44 -0700 (PDT) Content-Disposition: inline In-Reply-To: <87zjcwcmtn.fsf@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Jani Nikula Cc: Daniel Vetter , Intel Graphics Development , David Herrmann List-Id: intel-gfx@lists.freedesktop.org On Thu, Oct 16, 2014 at 01:48:20PM +0300, Jani Nikula wrote: > On Thu, 16 Oct 2014, Daniel Vetter wrote: > > Too many new drm driver writers seem to look at i915 for inspiration. > > But we have two ways to do mmap, so discourage readers from the old, > > ugly version. In a new driver we'd just expose two mmap offsets per > > object, one for the gtt map and the other for the cpu map. > > > > Cc: "Cheng, Yao" > > Cc: David Herrmann > > Signed-off-by: Daniel Vetter > > --- > > drivers/gpu/drm/i915/i915_gem.c | 9 +++++++++ > > 1 file changed, 9 insertions(+) > > > > diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c > > index e9c783d55612..09d859b89aac 100644 > > --- a/drivers/gpu/drm/i915/i915_gem.c > > +++ b/drivers/gpu/drm/i915/i915_gem.c > > @@ -1466,6 +1466,15 @@ unlock: > > * > > * While the mapping holds a reference on the contents of the object, it doesn't > > * imply a ref on the object itself. > > + * > > + * IMPORTANT: > > + * > > + * DRM driver writers who look a this function as an example for how to do GEM > > + * mmap support, please don't implement mmap support like here. The modern way > > + * to implement DRM mmap support is with an mmap offset ioctl (like > > + * i915_gem_mmap_gtt) and then using the mmap syscall on the DRM fd directly. > > + * That way debug tooling like valgrind will understand what's going on, hiding > > + * the mmap call in a driver private ioctl will break that. > > Maybe a sentence here about why we're doing things differently, instead > of merely "do as I say, don't do as I do"? It smells like hysterical > raisins, but no harm in spelling it out, right? Ok, I'll add a "The i915 only does mmap this way because we didn't know better". -Daniel > > BR, > Jani. > > > */ > > int > > i915_gem_mmap_ioctl(struct drm_device *dev, void *data, > > -- > > 1.9.3 > > > > _______________________________________________ > > Intel-gfx mailing list > > Intel-gfx@lists.freedesktop.org > > http://lists.freedesktop.org/mailman/listinfo/intel-gfx > > -- > Jani Nikula, Intel Open Source Technology Center -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch