* [PATCH] drm/i915: Document that mmap forwarding is discouraged
@ 2014-10-16 10:28 Daniel Vetter
2014-10-16 10:48 ` Jani Nikula
2014-10-16 12:02 ` David Herrmann
0 siblings, 2 replies; 5+ messages in thread
From: Daniel Vetter @ 2014-10-16 10:28 UTC (permalink / raw)
To: Intel Graphics Development; +Cc: Daniel Vetter, David Herrmann
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" <yao.cheng@intel.com>
Cc: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
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.
*/
int
i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
--
1.9.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/i915: Document that mmap forwarding is discouraged
2014-10-16 10:28 [PATCH] drm/i915: Document that mmap forwarding is discouraged Daniel Vetter
@ 2014-10-16 10:48 ` Jani Nikula
2014-10-19 14:52 ` Daniel Vetter
2014-10-16 12:02 ` David Herrmann
1 sibling, 1 reply; 5+ messages in thread
From: Jani Nikula @ 2014-10-16 10:48 UTC (permalink / raw)
To: Intel Graphics Development; +Cc: Daniel Vetter, David Herrmann
On Thu, 16 Oct 2014, Daniel Vetter <daniel.vetter@ffwll.ch> 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" <yao.cheng@intel.com>
> Cc: David Herrmann <dh.herrmann@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
> 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?
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/i915: Document that mmap forwarding is discouraged
2014-10-16 10:48 ` Jani Nikula
@ 2014-10-19 14:52 ` Daniel Vetter
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Vetter @ 2014-10-19 14:52 UTC (permalink / raw)
To: Jani Nikula; +Cc: Daniel Vetter, Intel Graphics Development, David Herrmann
On Thu, Oct 16, 2014 at 01:48:20PM +0300, Jani Nikula wrote:
> On Thu, 16 Oct 2014, Daniel Vetter <daniel.vetter@ffwll.ch> 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" <yao.cheng@intel.com>
> > Cc: David Herrmann <dh.herrmann@gmail.com>
> > Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> > ---
> > 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/i915: Document that mmap forwarding is discouraged
2014-10-16 10:28 [PATCH] drm/i915: Document that mmap forwarding is discouraged Daniel Vetter
2014-10-16 10:48 ` Jani Nikula
@ 2014-10-16 12:02 ` David Herrmann
2014-10-16 14:02 ` Cheng, Yao
1 sibling, 1 reply; 5+ messages in thread
From: David Herrmann @ 2014-10-16 12:02 UTC (permalink / raw)
To: Daniel Vetter; +Cc: Intel Graphics Development
Hi
On Thu, Oct 16, 2014 at 12:28 PM, Daniel Vetter <daniel.vetter@ffwll.ch> 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.
Yes, please! (also fine with Jani's concerns)
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Thanks
David
> Cc: "Cheng, Yao" <yao.cheng@intel.com>
> Cc: David Herrmann <dh.herrmann@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
> 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.
> */
> int
> i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
> --
> 1.9.3
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/i915: Document that mmap forwarding is discouraged
2014-10-16 12:02 ` David Herrmann
@ 2014-10-16 14:02 ` Cheng, Yao
0 siblings, 0 replies; 5+ messages in thread
From: Cheng, Yao @ 2014-10-16 14:02 UTC (permalink / raw)
To: David Herrmann, Daniel Vetter; +Cc: Intel Graphics Development
Nice :) thanks for this!
> -----Original Message-----
> From: David Herrmann [mailto:dh.herrmann@gmail.com]
> Sent: Thursday, October 16, 2014 8:03 PM
> To: Daniel Vetter
> Cc: Intel Graphics Development; Cheng, Yao
> Subject: Re: [PATCH] drm/i915: Document that mmap forwarding is
> discouraged
>
> Hi
>
> On Thu, Oct 16, 2014 at 12:28 PM, Daniel Vetter <daniel.vetter@ffwll.ch>
> 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.
>
> Yes, please! (also fine with Jani's concerns)
>
> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
>
> Thanks
> David
>
> > Cc: "Cheng, Yao" <yao.cheng@intel.com>
> > Cc: David Herrmann <dh.herrmann@gmail.com>
> > Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> > ---
> > 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.
> > */
> > int
> > i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
> > --
> > 1.9.3
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-10-19 14:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-16 10:28 [PATCH] drm/i915: Document that mmap forwarding is discouraged Daniel Vetter
2014-10-16 10:48 ` Jani Nikula
2014-10-19 14:52 ` Daniel Vetter
2014-10-16 12:02 ` David Herrmann
2014-10-16 14:02 ` Cheng, Yao
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.