dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: "Noralf Trønnes" <noralf@tronnes.org>
Cc: sam@ravnborg.org, dri-devel@lists.freedesktop.org, david@lechnology.com
Subject: Re: [PATCH v4 3/4] drm: Add library for shmem backed GEM objects
Date: Thu, 11 Oct 2018 10:24:04 +0200	[thread overview]
Message-ID: <20181011082403.GT31561@phenom.ffwll.local> (raw)
In-Reply-To: <4945c0c5-4687-dedc-0be6-ac4f75955530@tronnes.org>

On Wed, Oct 10, 2018 at 09:14:50PM +0200, Noralf Trønnes wrote:
> Den 01.10.2018 09.46, skrev Daniel Vetter:
> > On Wed, Sep 26, 2018 at 04:59:32PM +0200, Noralf Trønnes wrote:
> > > +int drm_gem_shmem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
> > > +{
> > > +	struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);
> > > +	int ret;
> > > +
> > > +	ret = drm_gem_mmap_obj(obj, obj->size, vma);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > > +	return drm_gem_shmem_mmap_obj(shmem, vma);
> > > +}
> > If we'd use the gem vma offset manager and adjust offsets and then call
> > into the gem mmap stuff I think we could make this 100% generic. That
> > would also avoid the need to add the gem_ops->prime_mmap callback, since
> > we'll have a default that should work for everyone.
> 
> Is this what you had in mind?
> 
> int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct
> *vma)
> {
>     /* Used by drm_gem_mmap() to lookup the GEM object */
>     struct drm_file priv = {
>         .minor = obj->dev->primary,
>     };
>     struct file fil = {
>         .private_data = &priv,
>     };
>     int ret;
> 
>     ret = drm_vma_node_allow(&obj->vma_node, &priv);
>     if (ret)
>         return ret;
> 
>     vma->vm_pgoff += drm_vma_node_start(&obj->vma_node);

Yup, this offset adjusting is what I had in mind.
-Daniel

>     ret = obj->dev->driver->fops->mmap(&fil, vma);
> 
>     drm_vma_node_revoke(&obj->vma_node, &priv);
> 
>     return ret;
> }
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-10-11  8:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26 14:59 [PATCH v4 0/4] drm: Add shmem GEM library Noralf Trønnes
2018-09-26 14:59 ` [PATCH v4 1/4] drm/driver: Add defaults for .gem_prime_export/import callbacks Noralf Trønnes
2018-09-26 14:59 ` [PATCH v4 2/4] drm/gem: Add drm_gem_object_funcs Noralf Trønnes
2018-10-01  7:44   ` Daniel Vetter
2018-09-26 14:59 ` [PATCH v4 3/4] drm: Add library for shmem backed GEM objects Noralf Trønnes
2018-10-01  7:46   ` Daniel Vetter
2018-10-10 19:14     ` Noralf Trønnes
2018-10-11  8:24       ` Daniel Vetter [this message]
2018-09-26 14:59 ` [PATCH v4 4/4] drm/tinydrm: Switch from CMA to shmem buffers Noralf Trønnes
2018-10-01  7:48 ` [PATCH v4 0/4] drm: Add shmem GEM library Daniel Vetter

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=20181011082403.GT31561@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=david@lechnology.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=noralf@tronnes.org \
    --cc=sam@ravnborg.org \
    /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