Skip to contentSkip to conversation

drm/vgem: implement virtual GEM

PATCH Superseded Zach Reizner 3 participants 5 messages Jan 30, 2015 – Jan 31, 2015

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/vgem: implement virtual GEM

This patch implements the virtual GEM driver with PRIME sharing which allows vgem to import a gem object from other drivers for the purpose of mmap-ing them to userspace. The mmap is done using the mmap operation exported by other drivers.

v2: remove platform_device and do not attach to dma bufs

---
 drivers/gpu/drm/Kconfig             |   9 +
 drivers/gpu/drm/Makefile            |   1 +
 drivers/gpu/drm/vgem/Makefile       |   4 +
 drivers/gpu/drm/vgem/vgem_dma_buf.c |  96 +++++++++
 drivers/gpu/drm/vgem/vgem_drv.c     | 390 ++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/vgem/vgem_drv.h     |  57 ++++++
 6 files changed, 557 insertions(+)
 create mode 100644 drivers/gpu/drm/vgem/Makefile
 create mode 100644 drivers/gpu/drm/vgem/vgem_dma_buf.c
 create mode 100644 drivers/gpu/drm/vgem/vgem_drv.c
 create mode 100644 drivers/gpu/drm/vgem/vgem_drv.h
drivers/gpu/drm/Kconfig +9 -0
index 308c104..b58f667 100644
@@ -164,6 +164,15 @@ config DRM_SAVAGE
 	  Choose this option if you have a Savage3D/4/SuperSavage/Pro/Twister
 	  chipset. If M is selected the module will be called savage.
 
+config DRM_VGEM
+	tristate "Virtual GEM provider"
+	depends on DRM
+	help
+	  Choose this option to get a virtual graphics memory manager,
+	  as used by Mesa's software renderer for enhanced performance.
+	  If M is selected the module will be called vgem.
+
+
 source "drivers/gpu/drm/exynos/Kconfig"
 
 source "drivers/gpu/drm/rockchip/Kconfig"
drivers/gpu/drm/Makefile +1 -0
index 2c239b9..7d4944e 100644
@@ -48,6 +48,7 @@ obj-$(CONFIG_DRM_SIS)   += sis/
 obj-$(CONFIG_DRM_SAVAGE)+= savage/
 obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
 obj-$(CONFIG_DRM_VIA)	+=via/
+obj-$(CONFIG_DRM_VGEM)	+= vgem/
 obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/
 obj-$(CONFIG_DRM_EXYNOS) +=exynos/
 obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/
drivers/gpu/drm/vgem/Makefile new file +4 -0
new file mode 100644
index 0000000..1055cb7
@@ -0,0 +1,4 @@
+ccflags-y := -Iinclude/drm
+vgem-y := vgem_drv.o vgem_dma_buf.o
+
+obj-$(CONFIG_DRM_VGEM)	+= vgem.o
drivers/gpu/drm/vgem/vgem_dma_buf.c new file +96 -0

96 lines not on this page · raw message

drivers/gpu/drm/vgem/vgem_drv.c new file +390 -0

390 lines not on this page · raw message

drivers/gpu/drm/vgem/vgem_drv.h new file +57 -0

57 lines not on this page · raw message

Signature · 6 lines
2.2.0.rc0.207.ga3a616c

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 11 lines · Zach Reizner

This patch implements the virtual GEM driver with PRIME sharing which allows vgem to import a gem object from other drivers for the purpose of mmap-ing them to userspace. The mmap is done using the mmap operation exported by other drivers.

v2: remove platform_device and do not attach to dma bufs

Looks good to me.

[snip]

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by on v2 1/1
#2 lore raw
In reply to Zach Reizner
Quoted 11 lines · Zach Reizner

This patch implements the virtual GEM driver with PRIME sharing which allows vgem to import a gem object from other drivers for the purpose of mmap-ing them to userspace. The mmap is done using the mmap operation exported by other drivers.

v2: remove platform_device and do not attach to dma bufs

couple small suggestions/comments below, but with those addressed,

Quoted 13 lines
---
 drivers/gpu/drm/Kconfig             |   9 +
 drivers/gpu/drm/Makefile            |   1 +
 drivers/gpu/drm/vgem/Makefile       |   4 +
 drivers/gpu/drm/vgem/vgem_dma_buf.c |  96 +++++++++
 drivers/gpu/drm/vgem/vgem_drv.c     | 390 ++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/vgem/vgem_drv.h     |  57 ++++++
 6 files changed, 557 insertions(+)
 create mode 100644 drivers/gpu/drm/vgem/Makefile
 create mode 100644 drivers/gpu/drm/vgem/vgem_dma_buf.c
 create mode 100644 drivers/gpu/drm/vgem/vgem_drv.c
 create mode 100644 drivers/gpu/drm/vgem/vgem_drv.h

[snip]

Quoted 48 lines
drivers/gpu/drm/vgem/vgem_drv.c new file +42 -0
new file mode 100644
index 0000000..e20f4a4
@@ -0,0 +1,390 @@
+/*
+ * Copyright 2011 Red Hat, Inc.
+ * Copyright © 2014 The Chromium OS Authors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software")
+ * to deal in the software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * them Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTIBILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *     Adam Jackson <[email protected]>
+ *     Ben Widawsky <[email protected]>
+ */
+
+/**
+ * This is vgem, a (non-hardware-backed) GEM service.  This is used by Mesa's
+ * software renderer and the X server for efficient buffer sharing.
+ */
+
+#include <linux/module.h>
+#include <linux/ramfs.h>
+#include <linux/shmem_fs.h>
+#include <linux/dma-buf.h>
+#include "vgem_drv.h"
+
+#define DRIVER_NAME    "vgem"
+#define DRIVER_DESC    "Virtual GEM provider"
+#define DRIVER_DATE    "20120112"
+#define DRIVER_MAJOR   1

drivers/gpu/drm/vgem/vgem_drv.c line 52

Quoted 10 lines
drivers/gpu/drm/vgem/vgem_drv.c new file +10 -0
+#define DRIVER_MINOR   0
+
+void vgem_gem_put_pages(struct drm_vgem_gem_object *obj)
+{
+       int num_pages = obj->base.size / PAGE_SIZE;
+       int i;
+
+       for (i = 0; i < num_pages; i++) {
+               if (obj->pages[i] == NULL)
+                       break;

seems like other than this break statement, you could use drm_gem_put_pages().. not entirely sure why you'd encounter a null page, but if there is a legit reason for that, then just add the check in drm_gem_put_pages() (plus maybe a comment) and use that..

Quoted 33 lines
drivers/gpu/drm/vgem/vgem_drv.c new file +33 -0
+               page_cache_release(obj->pages[i]);
+       }
+
+       drm_free_large(obj->pages);
+       obj->pages = NULL;
+}
+
+static void vgem_gem_free_object(struct drm_gem_object *obj)
+{
+       struct drm_vgem_gem_object *vgem_obj = to_vgem_bo(obj);
+
+       drm_gem_free_mmap_offset(obj);
+
+       if (vgem_obj->use_dma_buf && obj->dma_buf) {
+               dma_buf_put(obj->dma_buf);
+               obj->dma_buf = NULL;
+       }
+
+       drm_gem_object_release(obj);
+
+       if (vgem_obj->pages)
+               vgem_gem_put_pages(vgem_obj);
+
+       vgem_obj->pages = NULL;
+
+       kfree(vgem_obj);
+}
+
+int vgem_gem_get_pages(struct drm_vgem_gem_object *obj)
+{
+       struct address_space *mapping;
+       gfp_t gfpmask = GFP_KERNEL;
+       int num_pages, i, ret = 0;

drivers/gpu/drm/vgem/vgem_drv.c line 95

Quoted 10 lines
drivers/gpu/drm/vgem/vgem_drv.c new file +10 -0
+
+       if (obj->pages || obj->use_dma_buf)
+               return 0;
+
+       num_pages = obj->base.size / PAGE_SIZE;
+       obj->pages = drm_malloc_ab(num_pages, sizeof(struct page *));
+       if (obj->pages == NULL)
+               return -ENOMEM;
+
+       mapping = obj->base.filp->f_path.dentry->d_inode->i_mapping;

again, seems like you could use drm_gem_get_pages().. although you get the mapping in a slightly different way.. not sure if that was intentional?

BR,
-R

Quoted 10 lines
drivers/gpu/drm/vgem/vgem_drv.c new file +10 -0
+       gfpmask |= mapping_gfp_mask(mapping);
+
+       for (i = 0; i < num_pages; i++) {
+               struct page *page;
+               obj->pages[i] = NULL;
+               page = shmem_read_mapping_page_gfp(mapping, i, gfpmask);
+               if (IS_ERR(page)) {
+                       ret = PTR_ERR(page);
+                       goto err_out;
+               }

drivers/gpu/drm/vgem/vgem_drv.c line 115

Quoted 10 lines
drivers/gpu/drm/vgem/vgem_drv.c new file +10 -0
+               obj->pages[i] = page;
+       }
+
+       return ret;
+
+err_out:
+       vgem_gem_put_pages(obj);
+       return ret;
+}
+

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
Quoted 88 lines · Rob Clark
Quoted 11 lines · Zach Reizner

This patch implements the virtual GEM driver with PRIME sharing which allows vgem to import a gem object from other drivers for the purpose of mmap-ing them to userspace. The mmap is done using the mmap operation exported by other drivers.

v2: remove platform_device and do not attach to dma bufs

couple small suggestions/comments below, but with those addressed,

Quoted 13 lines
---
 drivers/gpu/drm/Kconfig             |   9 +
 drivers/gpu/drm/Makefile            |   1 +
 drivers/gpu/drm/vgem/Makefile       |   4 +
 drivers/gpu/drm/vgem/vgem_dma_buf.c |  96 +++++++++
 drivers/gpu/drm/vgem/vgem_drv.c     | 390 ++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/vgem/vgem_drv.h     |  57 ++++++
 6 files changed, 557 insertions(+)
 create mode 100644 drivers/gpu/drm/vgem/Makefile
 create mode 100644 drivers/gpu/drm/vgem/vgem_dma_buf.c
 create mode 100644 drivers/gpu/drm/vgem/vgem_drv.c
 create mode 100644 drivers/gpu/drm/vgem/vgem_drv.h

[snip]

Quoted 55 lines
drivers/gpu/drm/vgem/vgem_drv.c new file +49 -0
new file mode 100644
index 0000000..e20f4a4
@@ -0,0 +1,390 @@
+/*
+ * Copyright 2011 Red Hat, Inc.
+ * Copyright © 2014 The Chromium OS Authors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software")
+ * to deal in the software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * them Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTIBILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *     Adam Jackson <[email protected]>
+ *     Ben Widawsky <[email protected]>
+ */
+
+/**
+ * This is vgem, a (non-hardware-backed) GEM service.  This is used by Mesa's
+ * software renderer and the X server for efficient buffer sharing.
+ */
+
+#include <linux/module.h>
+#include <linux/ramfs.h>
+#include <linux/shmem_fs.h>
+#include <linux/dma-buf.h>
+#include "vgem_drv.h"
+
+#define DRIVER_NAME    "vgem"
+#define DRIVER_DESC    "Virtual GEM provider"
+#define DRIVER_DATE    "20120112"
+#define DRIVER_MAJOR   1
+#define DRIVER_MINOR   0
+
+void vgem_gem_put_pages(struct drm_vgem_gem_object *obj)
+{
+       int num_pages = obj->base.size / PAGE_SIZE;
+       int i;
+
Quoted 9 lines

drivers/gpu/drm/vgem/vgem_drv.c line 52

Quoted 3 lines
drivers/gpu/drm/vgem/vgem_drv.c new file +3 -0
+       for (i = 0; i < num_pages; i++) {
+               if (obj->pages[i] == NULL)
+                       break;

seems like other than this break statement, you could use drm_gem_put_pages().. not entirely sure why you'd encounter a null page, but if there is a legit reason for that, then just add the check in drm_gem_put_pages() (plus maybe a comment) and use that..

First, this code predated drm_gem_put_pages, so it was probably just an oversight that a consolidated function existed. As for the NULL, it's because the cleanup of failed vgem get_pages() just calls vgem put_pages() (you can't have sparsely populated entries, but the last n pointers can be NULL). If the helpers just dtrt, then it should use that.

Quoted 39 lines
Quoted 39 lines
drivers/gpu/drm/vgem/vgem_drv.c new file +39 -0
+               page_cache_release(obj->pages[i]);
+       }
+
+       drm_free_large(obj->pages);
+       obj->pages = NULL;
+}
+
+static void vgem_gem_free_object(struct drm_gem_object *obj)
+{
+       struct drm_vgem_gem_object *vgem_obj = to_vgem_bo(obj);
+
+       drm_gem_free_mmap_offset(obj);
+
+       if (vgem_obj->use_dma_buf && obj->dma_buf) {
+               dma_buf_put(obj->dma_buf);
+               obj->dma_buf = NULL;
+       }
+
+       drm_gem_object_release(obj);
+
+       if (vgem_obj->pages)
+               vgem_gem_put_pages(vgem_obj);
+
+       vgem_obj->pages = NULL;
+
+       kfree(vgem_obj);
+}
+
+int vgem_gem_get_pages(struct drm_vgem_gem_object *obj)
+{
+       struct address_space *mapping;
+       gfp_t gfpmask = GFP_KERNEL;
+       int num_pages, i, ret = 0;
+
+       if (obj->pages || obj->use_dma_buf)
+               return 0;
+
+       num_pages = obj->base.size / PAGE_SIZE;
+       obj->pages = drm_malloc_ab(num_pages, sizeof(struct page *));
Quoted 9 lines

drivers/gpu/drm/vgem/vgem_drv.c line 95

Quoted 4 lines
drivers/gpu/drm/vgem/vgem_drv.c new file +4 -0
+       if (obj->pages == NULL)
+               return -ENOMEM;
+
+       mapping = obj->base.filp->f_path.dentry->d_inode->i_mapping;

again, seems like you could use drm_gem_get_pages().. although you get the mapping in a slightly different way.. not sure if that was intentional?

Again, this predates the helpers :D My original patches on top of ajax were from Feb. 2012. Helpers seem like the right thing to do now.

Quoted 15 lines

BR,
-R

Quoted 12 lines
drivers/gpu/drm/vgem/vgem_drv.c new file +12 -0
+       gfpmask |= mapping_gfp_mask(mapping);
+
+       for (i = 0; i < num_pages; i++) {
+               struct page *page;
+               obj->pages[i] = NULL;
+               page = shmem_read_mapping_page_gfp(mapping, i, gfpmask);
+               if (IS_ERR(page)) {
+                       ret = PTR_ERR(page);
+                       goto err_out;
+               }
+               obj->pages[i] = page;
+       }
Quoted 8 lines

drivers/gpu/drm/vgem/vgem_drv.c line 115

Quoted 8 lines
drivers/gpu/drm/vgem/vgem_drv.c new file +8 -0
+
+       return ret;
+
+err_out:
+       vgem_gem_put_pages(obj);
+       return ret;
+}
+

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw
Quoted 99 lines · Ben Widawsky
Quoted 88 lines · Rob Clark
Quoted 11 lines · Zach Reizner

This patch implements the virtual GEM driver with PRIME sharing which allows vgem to import a gem object from other drivers for the purpose of mmap-ing them to userspace. The mmap is done using the mmap operation exported by other drivers.

v2: remove platform_device and do not attach to dma bufs

couple small suggestions/comments below, but with those addressed,

Quoted 13 lines
---
 drivers/gpu/drm/Kconfig             |   9 +
 drivers/gpu/drm/Makefile            |   1 +
 drivers/gpu/drm/vgem/Makefile       |   4 +
 drivers/gpu/drm/vgem/vgem_dma_buf.c |  96 +++++++++
 drivers/gpu/drm/vgem/vgem_drv.c     | 390 ++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/vgem/vgem_drv.h     |  57 ++++++
 6 files changed, 557 insertions(+)
 create mode 100644 drivers/gpu/drm/vgem/Makefile
 create mode 100644 drivers/gpu/drm/vgem/vgem_dma_buf.c
 create mode 100644 drivers/gpu/drm/vgem/vgem_drv.c
 create mode 100644 drivers/gpu/drm/vgem/vgem_drv.h

[snip]

Quoted 55 lines
drivers/gpu/drm/vgem/vgem_drv.c new file +49 -0
new file mode 100644
index 0000000..e20f4a4
@@ -0,0 +1,390 @@
+/*
+ * Copyright 2011 Red Hat, Inc.
+ * Copyright © 2014 The Chromium OS Authors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software")
+ * to deal in the software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * them Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTIBILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *     Adam Jackson <[email protected]>
+ *     Ben Widawsky <[email protected]>
+ */
+
+/**
+ * This is vgem, a (non-hardware-backed) GEM service.  This is used by Mesa's
+ * software renderer and the X server for efficient buffer sharing.
+ */
+
+#include <linux/module.h>
+#include <linux/ramfs.h>
+#include <linux/shmem_fs.h>
+#include <linux/dma-buf.h>
+#include "vgem_drv.h"
+
+#define DRIVER_NAME    "vgem"
+#define DRIVER_DESC    "Virtual GEM provider"
+#define DRIVER_DATE    "20120112"
+#define DRIVER_MAJOR   1
+#define DRIVER_MINOR   0
+
+void vgem_gem_put_pages(struct drm_vgem_gem_object *obj)
+{
+       int num_pages = obj->base.size / PAGE_SIZE;
+       int i;
+
Quoted 9 lines

drivers/gpu/drm/vgem/vgem_drv.c line 52

Quoted 3 lines
drivers/gpu/drm/vgem/vgem_drv.c new file +3 -0
+       for (i = 0; i < num_pages; i++) {
+               if (obj->pages[i] == NULL)
+                       break;

seems like other than this break statement, you could use drm_gem_put_pages().. not entirely sure why you'd encounter a null page, but if there is a legit reason for that, then just add the check in drm_gem_put_pages() (plus maybe a comment) and use that..

Quoted 5 lines

First, this code predated drm_gem_put_pages, so it was probably just an oversight that a consolidated function existed. As for the NULL, it's because the cleanup of failed vgem get_pages() just calls vgem put_pages() (you can't have sparsely populated entries, but the last n pointers can be NULL). If the helpers just dtrt, then it should use that.

yeah, ok, that makes sense..

The helpers dtrt.. drm_gem_get_pages() cleans up properly if it fails part way through. So should be a drop-in replacement, and make the new driver that much smaller :-)

BR,
-R

Quoted 68 lines
Quoted 40 lines
Quoted 40 lines
drivers/gpu/drm/vgem/vgem_drv.c new file +39 -0
+               page_cache_release(obj->pages[i]);
+       }
+
+       drm_free_large(obj->pages);
+       obj->pages = NULL;
+}
+
+static void vgem_gem_free_object(struct drm_gem_object *obj)
+{
+       struct drm_vgem_gem_object *vgem_obj = to_vgem_bo(obj);
+
+       drm_gem_free_mmap_offset(obj);
+
+       if (vgem_obj->use_dma_buf && obj->dma_buf) {
+               dma_buf_put(obj->dma_buf);
+               obj->dma_buf = NULL;
+       }
+
+       drm_gem_object_release(obj);
+
+       if (vgem_obj->pages)
+               vgem_gem_put_pages(vgem_obj);
+
+       vgem_obj->pages = NULL;
+
+       kfree(vgem_obj);
+}
+
+int vgem_gem_get_pages(struct drm_vgem_gem_object *obj)
+{
+       struct address_space *mapping;
+       gfp_t gfpmask = GFP_KERNEL;
+       int num_pages, i, ret = 0;
+
+       if (obj->pages || obj->use_dma_buf)
+               return 0;
+
+       num_pages = obj->base.size / PAGE_SIZE;
+       obj->pages = drm_malloc_ab(num_pages, sizeof(struct page *));
Quoted 9 lines

drivers/gpu/drm/vgem/vgem_drv.c line 95

Quoted 4 lines
drivers/gpu/drm/vgem/vgem_drv.c new file +4 -0
+       if (obj->pages == NULL)
+               return -ENOMEM;
+
+       mapping = obj->base.filp->f_path.dentry->d_inode->i_mapping;

again, seems like you could use drm_gem_get_pages().. although you get the mapping in a slightly different way.. not sure if that was intentional?

Again, this predates the helpers :D My original patches on top of ajax were from Feb. 2012. Helpers seem like the right thing to do now.

Quoted 15 lines

BR,
-R

Quoted 12 lines
drivers/gpu/drm/vgem/vgem_drv.c new file +12 -0
+       gfpmask |= mapping_gfp_mask(mapping);
+
+       for (i = 0; i < num_pages; i++) {
+               struct page *page;
+               obj->pages[i] = NULL;
+               page = shmem_read_mapping_page_gfp(mapping, i, gfpmask);
+               if (IS_ERR(page)) {
+                       ret = PTR_ERR(page);
+                       goto err_out;
+               }
+               obj->pages[i] = page;
+       }
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/vgem/vgem_drv.c line 115

Quoted 8 lines
drivers/gpu/drm/vgem/vgem_drv.c new file +8 -0
+
+       return ret;
+
+err_out:
+       vgem_gem_put_pages(obj);
+       return ret;
+}
+

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel