From patchwork Tue May 1 16:04:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 8321 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id C806223E23 for ; Tue, 1 May 2012 16:05:03 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 79D49A183E0 for ; Tue, 1 May 2012 16:05:03 +0000 (UTC) Received: by yhpp61 with SMTP id p61so2454013yhp.11 for ; Tue, 01 May 2012 09:05:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :dkim-signature:sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=GnjP+YiNpABLLb47g69WBi56XmJjfyiFw7JU+SZBiMo=; b=kqdpCKAZiOJCQOpz2eDPbHkVk9B87ropQoD7fgwZoxGiPYvJj8BPysnro/qpuzBH9z kfyfP4yIK1LGRU1YYDZTaPeXn4TCAfERYFFVOaxszffa0lq/VC+TVJCWzkkDpmkvmMcR H0js1PZA8GyZuGW8mbf7EB3ZRaZ4icItI+S7SFmPAkGY4WxFrlwbKb1ulUb4gK2tEjZ/ gFQE2TMKKAeUoqi9URKkKsDoxGMMAKWxEh6PoCSQeJeawgI9ogwE6J7A9MBQ3VWhZatQ j1Tub9buIbL35PZdeyJMhjpeQc+dlBcj/nlbEL/iWt/eIjtL9CEfAxUWlBWbZ6EIRnKP JMuw== Received: by 10.50.181.164 with SMTP id dx4mr2524807igc.1.1335888302771; Tue, 01 May 2012 09:05:02 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.137.198 with SMTP id x6csp189485ibt; Tue, 1 May 2012 09:05:01 -0700 (PDT) Received: by 10.229.134.203 with SMTP id k11mr6507610qct.67.1335888300991; Tue, 01 May 2012 09:05:00 -0700 (PDT) Received: from mail-qa0-f43.google.com (mail-qa0-f43.google.com [209.85.216.43]) by mx.google.com with ESMTPS id es10si13672892qab.93.2012.05.01.09.05.00 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 01 May 2012 09:05:00 -0700 (PDT) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.216.43 as permitted sender) client-ip=209.85.216.43; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.216.43 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass header.i=@gmail.com Received: by qadb15 with SMTP id b15so3014820qad.16 for ; Tue, 01 May 2012 09:05:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer; bh=GnjP+YiNpABLLb47g69WBi56XmJjfyiFw7JU+SZBiMo=; b=SclzVhpE3AOyXn1m3MNf7SXPaISXYcWjhC3zxfD20W5+F5IcuQxBYRPLkKxTXrXDPC pF/QFSRkBkKlZ9i/peGqx/Ldh0rcZH36dQJUxPksmqZM8UFdzSJb9jys7DVhI6A2ER9x Cx+QaSU9OXT3k+vbNoO+O+mEKLmIRBdg61VKfgTQe8AAl10z8yKfNgFJ+/iz7R1i6RQW omdhsQ/RU6CrliBpTbwlNfrLvyFS6y8cDaNo0V4uCJ8D3vRrhji7yb1PyL88Rg4IdT00 IR4MasF1q8qOKgxb5SWYxDhoyXTfx8RAn9wh+T75dpKQ7B6Cswlq3ZKjLxpM8YNetAdK Yrkg== Received: by 10.60.21.103 with SMTP id u7mr33671800oee.11.1335888300512; Tue, 01 May 2012 09:05:00 -0700 (PDT) Received: from localhost (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id tx2sm20783691obb.8.2012.05.01.09.04.58 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 01 May 2012 09:04:59 -0700 (PDT) Sender: Rob Clark From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: patches@linaro.org, linaro-mm-sig@lists.linaro.org, Rob Clark Subject: [PATCH] drm: pass dev to drm_vm_{open,close}_locked() Date: Tue, 1 May 2012 11:04:51 -0500 Message-Id: <1335888291-9311-1-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQnKHmENaEwyfCWAJpkMfvuvbC+Y7/aztR1q08gXNGYmKKQzpIIibsmuDDUCW8MlNr46+Mdm From: Rob Clark Previously these functions would assume that vma->vm_file was the drm_file. Although if in some cases if the drm driver needs to use something else for the backing file (such as the tmpfs filp) then this assumption is no longer true. But vma->vm_private_data is still the GEM object. With this change, now the drm_device comes from the GEM object rather than the drm_file so the driver is more free to play with vma->vm_file. The scenario where this comes up is for mmap'ing of cached dmabuf's for non-coherent systems, where the driver needs to use fault handling and PTE shootdown to simulate coherency. We can't use the vma->vm_file of the dmabuf, which is using anon_inode's address_space. The most straightforward thing to do is to use the GEM object's obj->filp for vma->vm_file in all cases, for which we need this patch. Signed-off-by: Rob Clark --- drivers/gpu/drm/drm_gem.c | 6 +++--- drivers/gpu/drm/drm_vm.c | 18 ++++++++---------- include/drm/drmP.h | 4 ++-- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 83114b5..475b300 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -628,7 +628,7 @@ void drm_gem_vm_open(struct vm_area_struct *vma) drm_gem_object_reference(obj); mutex_lock(&obj->dev->struct_mutex); - drm_vm_open_locked(vma); + drm_vm_open_locked(obj->dev, vma); mutex_unlock(&obj->dev->struct_mutex); } EXPORT_SYMBOL(drm_gem_vm_open); @@ -639,7 +639,7 @@ void drm_gem_vm_close(struct vm_area_struct *vma) struct drm_device *dev = obj->dev; mutex_lock(&dev->struct_mutex); - drm_vm_close_locked(vma); + drm_vm_close_locked(obj->dev, vma); drm_gem_object_unreference(obj); mutex_unlock(&dev->struct_mutex); } @@ -712,7 +712,7 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) */ drm_gem_object_reference(obj); - drm_vm_open_locked(vma); + drm_vm_open_locked(dev, vma); out_unlock: mutex_unlock(&dev->struct_mutex); diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c index 1495618..961ee08 100644 --- a/drivers/gpu/drm/drm_vm.c +++ b/drivers/gpu/drm/drm_vm.c @@ -406,10 +406,9 @@ static const struct vm_operations_struct drm_vm_sg_ops = { * Create a new drm_vma_entry structure as the \p vma private data entry and * add it to drm_device::vmalist. */ -void drm_vm_open_locked(struct vm_area_struct *vma) +void drm_vm_open_locked(struct drm_device *dev, + struct vm_area_struct *vma) { - struct drm_file *priv = vma->vm_file->private_data; - struct drm_device *dev = priv->minor->dev; struct drm_vma_entry *vma_entry; DRM_DEBUG("0x%08lx,0x%08lx\n", @@ -430,14 +429,13 @@ static void drm_vm_open(struct vm_area_struct *vma) struct drm_device *dev = priv->minor->dev; mutex_lock(&dev->struct_mutex); - drm_vm_open_locked(vma); + drm_vm_open_locked(dev, vma); mutex_unlock(&dev->struct_mutex); } -void drm_vm_close_locked(struct vm_area_struct *vma) +void drm_vm_close_locked(struct drm_device *dev, + struct vm_area_struct *vma) { - struct drm_file *priv = vma->vm_file->private_data; - struct drm_device *dev = priv->minor->dev; struct drm_vma_entry *pt, *temp; DRM_DEBUG("0x%08lx,0x%08lx\n", @@ -467,7 +465,7 @@ static void drm_vm_close(struct vm_area_struct *vma) struct drm_device *dev = priv->minor->dev; mutex_lock(&dev->struct_mutex); - drm_vm_close_locked(vma); + drm_vm_close_locked(dev, vma); mutex_unlock(&dev->struct_mutex); } @@ -519,7 +517,7 @@ static int drm_mmap_dma(struct file *filp, struct vm_area_struct *vma) vma->vm_flags |= VM_RESERVED; /* Don't swap */ vma->vm_flags |= VM_DONTEXPAND; - drm_vm_open_locked(vma); + drm_vm_open_locked(dev, vma); return 0; } @@ -670,7 +668,7 @@ int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma) vma->vm_flags |= VM_RESERVED; /* Don't swap */ vma->vm_flags |= VM_DONTEXPAND; - drm_vm_open_locked(vma); + drm_vm_open_locked(dev, vma); return 0; } diff --git a/include/drm/drmP.h b/include/drm/drmP.h index dd73104..213a85a 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -1309,8 +1309,8 @@ extern int drm_release(struct inode *inode, struct file *filp); /* Mapping support (drm_vm.h) */ 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 void drm_vm_open_locked(struct drm_device *dev, struct vm_area_struct *vma); +extern void drm_vm_close_locked(struct drm_device *dev, struct vm_area_struct *vma); extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); /* Memory management support (drm_memory.h) */