All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Mackall <mpm@selenic.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, Paul Rolland <rol@as2917.net>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	Dave Airlie <airlied@redhat.com>,
	Jesse Barnes <jbarnes@virtuousgeek.org>
Subject: Re: [PATCH] drm: Prune GEM vma entries
Date: Fri, 01 Oct 2010 19:09:56 -0500	[thread overview]
Message-ID: <1285978196.16634.1392.camel@calx> (raw)
In-Reply-To: <1285618116-10086-1-git-send-email-chris@chris-wilson.co.uk>

On Mon, 2010-09-27 at 21:08 +0100, Chris Wilson wrote:
> Hook the GEM vm open/close ops into the generic drm vm open/close so
> that the vma entries are created and destroy appropriately.
> 
> Reported-by: Matt Mackall <mpm@selenic.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

All signs point to this being the correct fix, but I won't have time to
test it while I'm in Japan.

Paul, does this work for you?

> ---
>  drivers/gpu/drm/drm_gem.c |    9 ++++++++-
>  drivers/gpu/drm/drm_vm.c  |   28 ++++++++++++++++++----------
>  include/drm/drmP.h        |    1 +
>  3 files changed, 27 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index bf92d07..6fe2cd2 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -528,6 +528,10 @@ void drm_gem_vm_open(struct vm_area_struct *vma)
>  	struct drm_gem_object *obj = vma->vm_private_data;
>  
>  	drm_gem_object_reference(obj);
> +
> +	mutex_lock(&obj->dev->struct_mutex);
> +	drm_vm_open_locked(vma);
> +	mutex_unlock(&obj->dev->struct_mutex);
>  }
>  EXPORT_SYMBOL(drm_gem_vm_open);
>  
> @@ -535,7 +539,10 @@ void drm_gem_vm_close(struct vm_area_struct *vma)
>  {
>  	struct drm_gem_object *obj = vma->vm_private_data;
>  
> -	drm_gem_object_unreference_unlocked(obj);
> +	mutex_lock(&obj->dev->struct_mutex);
> +	drm_vm_close_locked(vma);
> +	drm_gem_object_unreference(obj);
> +	mutex_unlock(&obj->dev->struct_mutex);
>  }
>  EXPORT_SYMBOL(drm_gem_vm_close);
>  
> diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
> index fda6746..5df4506 100644
> --- a/drivers/gpu/drm/drm_vm.c
> +++ b/drivers/gpu/drm/drm_vm.c
> @@ -433,15 +433,7 @@ static void drm_vm_open(struct vm_area_struct *vma)
>  	mutex_unlock(&dev->struct_mutex);
>  }
>  
> -/**
> - * \c close method for all virtual memory types.
> - *
> - * \param vma virtual memory area.
> - *
> - * Search the \p vma private data entry in drm_device::vmalist, unlink it, and
> - * free it.
> - */
> -static void drm_vm_close(struct vm_area_struct *vma)
> +void drm_vm_close_locked(struct vm_area_struct *vma)
>  {
>  	struct drm_file *priv = vma->vm_file->private_data;
>  	struct drm_device *dev = priv->minor->dev;
> @@ -451,7 +443,6 @@ static void drm_vm_close(struct vm_area_struct *vma)
>  		  vma->vm_start, vma->vm_end - vma->vm_start);
>  	atomic_dec(&dev->vma_count);
>  
> -	mutex_lock(&dev->struct_mutex);
>  	list_for_each_entry_safe(pt, temp, &dev->vmalist, head) {
>  		if (pt->vma == vma) {
>  			list_del(&pt->head);
> @@ -459,6 +450,23 @@ static void drm_vm_close(struct vm_area_struct *vma)
>  			break;
>  		}
>  	}
> +}
> +
> +/**
> + * \c close method for all virtual memory types.
> + *
> + * \param vma virtual memory area.
> + *
> + * Search the \p vma private data entry in drm_device::vmalist, unlink it, and
> + * free it.
> + */
> +static void drm_vm_close(struct vm_area_struct *vma)
> +{
> +	struct drm_file *priv = vma->vm_file->private_data;
> +	struct drm_device *dev = priv->minor->dev;
> +
> +	mutex_lock(&dev->struct_mutex);
> +	drm_vm_close_locked(vma);
>  	mutex_unlock(&dev->struct_mutex);
>  }
>  
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 7809d23..774e1d4 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -1175,6 +1175,7 @@ extern int drm_release(struct inode *inode, struct file *filp);
>  extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
>  extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma);
>  extern void drm_vm_open_locked(struct vm_area_struct *vma);
> +extern void drm_vm_close_locked(struct vm_area_struct *vma);
>  extern resource_size_t drm_core_get_map_ofs(struct drm_local_map * map);
>  extern resource_size_t drm_core_get_reg_ofs(struct drm_device *dev);
>  extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);


-- 
Mathematics is the supreme nostalgia of our time.



  parent reply	other threads:[~2010-10-02  0:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-22 23:16 [patch] slob: fix gfp flags for order-0 page allocations David Rientjes
2010-08-23  0:51 ` Christoph Lameter
2010-08-24  4:26 ` Matt Mackall
2010-08-24  4:36   ` David Rientjes
2010-08-24 15:20     ` Matt Mackall
2010-08-24 15:37       ` Christoph Lameter
2010-08-24 20:24         ` David Rientjes
2010-08-25 20:59         ` DRM-related kmalloc-32 memory leak in 2.6.35 Matt Mackall
2010-09-27 18:52           ` Andrew Morton
2010-09-27 20:08             ` [PATCH] drm: Prune GEM vma entries Chris Wilson
2010-09-27 20:08               ` Andrew Morton
2010-09-27 20:08                 ` Andrew Morton
2010-09-27 20:28                 ` Chris Wilson
2010-10-02  0:09               ` Matt Mackall [this message]
2010-10-03 18:59                 ` Paul Rolland
2010-10-04  7:07               ` Paul Rolland
2010-10-04  7:07                 ` Paul Rolland
2010-09-27 20:40             ` DRM-related kmalloc-32 memory leak in 2.6.35 David Rientjes
2010-08-24 17:44       ` [patch] slob: fix gfp flags for order-0 page allocations Pekka Enberg

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=1285978196.16634.1392.camel@calx \
    --to=mpm@selenic.com \
    --cc=airlied@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=chris@chris-wilson.co.uk \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rol@as2917.net \
    /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.