Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2 Let the drm driver decide what part of...
details: https://anonhg.NetBSD.org/src/rev/22e9fa758997
branches: trunk
changeset: 331010:22e9fa758997
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Jul 26 21:15:45 2014 +0000
description:
Let the drm driver decide what part of what object gets mmapped.
Pass the file around too so radeon/ttm can get at it to verify access.
Add drm_gem_or_legacy_mmap_object for drivers to choose the previous
behaviour, like i915.
diffstat:
sys/external/bsd/drm2/dist/drm/i915/i915_drv.c | 2 +
sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.c | 6 +++-
sys/external/bsd/drm2/dist/drm/radeon/radeon_ttm.c | 2 +-
sys/external/bsd/drm2/dist/include/drm/drmP.h | 8 ++++-
sys/external/bsd/drm2/drm/drm_drv.c | 24 +++++------------
sys/external/bsd/drm2/drm/drm_gem_vm.c | 30 +++++++++++++++++----
sys/external/bsd/drm2/drm/drm_vm.c | 6 ++--
7 files changed, 48 insertions(+), 30 deletions(-)
diffs (225 lines):
diff -r 68fe81ce08f2 -r 22e9fa758997 sys/external/bsd/drm2/dist/drm/i915/i915_drv.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c Sat Jul 26 21:12:43 2014 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c Sat Jul 26 21:15:45 2014 +0000
@@ -1049,6 +1049,8 @@
#endif
.gem_free_object = i915_gem_free_object,
#ifdef __NetBSD__
+ /* XXX Not clear the `or legacy' part is important here. */
+ .mmap_object = &drm_gem_or_legacy_mmap_object,
.gem_uvm_ops = &i915_gem_uvm_ops,
#else
.gem_vm_ops = &i915_gem_vm_ops,
diff -r 68fe81ce08f2 -r 22e9fa758997 sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.c
--- a/sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.c Sat Jul 26 21:12:43 2014 +0000
+++ b/sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.c Sat Jul 26 21:15:45 2014 +0000
@@ -119,7 +119,10 @@
extern bool radeon_is_px(struct drm_device *dev);
extern const struct drm_ioctl_desc radeon_ioctls_kms[];
extern int radeon_max_kms_ioctl;
-#ifndef __NetBSD__
+#ifdef __NetBSD__
+int radeon_mmap_object(struct drm_device *, off_t, size_t, vm_prot_t,
+ struct uvm_object **, voff_t *, struct file *);
+#else
int radeon_mmap(struct file *filp, struct vm_area_struct *vma);
#endif
int radeon_mode_dumb_mmap(struct drm_file *filp,
@@ -563,6 +566,7 @@
.dumb_destroy = drm_gem_dumb_destroy,
#ifdef __NetBSD__
.fops = NULL,
+ .mmap_object = &radeon_mmap_object,
.gem_uvm_ops = &radeon_gem_uvm_ops,
#else
.fops = &radeon_driver_kms_fops,
diff -r 68fe81ce08f2 -r 22e9fa758997 sys/external/bsd/drm2/dist/drm/radeon/radeon_ttm.c
--- a/sys/external/bsd/drm2/dist/drm/radeon/radeon_ttm.c Sat Jul 26 21:12:43 2014 +0000
+++ b/sys/external/bsd/drm2/dist/drm/radeon/radeon_ttm.c Sat Jul 26 21:15:45 2014 +0000
@@ -879,7 +879,7 @@
if (__predict_false((offset >> PAGE_SHIFT) < DRM_FILE_PAGE_OFFSET))
return drm_mmap_object(dev, offset, size, prot, uobjp,
- uoffsetp /* , file */);
+ uoffsetp, file);
else
return ttm_bo_mmap_object(&rdev->mman.bdev, offset, size, prot,
uobjp, uoffsetp, file);
diff -r 68fe81ce08f2 -r 22e9fa758997 sys/external/bsd/drm2/dist/include/drm/drmP.h
--- a/sys/external/bsd/drm2/dist/include/drm/drmP.h Sat Jul 26 21:12:43 2014 +0000
+++ b/sys/external/bsd/drm2/dist/include/drm/drmP.h Sat Jul 26 21:15:45 2014 +0000
@@ -1097,6 +1097,8 @@
/* Driver private ops for this object */
#ifdef __NetBSD__
+ int (*mmap_object)(struct drm_device *, off_t, size_t, int,
+ struct uvm_object **, voff_t *, struct file *);
const struct uvm_pagerops *gem_uvm_ops;
#else
const struct vm_operations_struct *gem_vm_ops;
@@ -1422,7 +1424,7 @@
/* Mapping support (drm_vm.h) */
#ifdef __NetBSD__
extern int drm_mmap_object(struct drm_device *, off_t, size_t, int,
- struct uvm_object **, voff_t *);
+ struct uvm_object **, voff_t *, struct file *);
extern paddr_t drm_mmap_paddr(struct drm_device *, off_t, int);
#else
extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
@@ -1775,7 +1777,9 @@
void drm_gem_pager_reference(struct uvm_object *);
void drm_gem_pager_detach(struct uvm_object *);
int drm_gem_mmap_object(struct drm_device *, off_t, size_t, int,
- struct uvm_object **, voff_t *);
+ struct uvm_object **, voff_t *, struct file *);
+int drm_gem_or_legacy_mmap_object(struct drm_device *, off_t, size_t, int,
+ struct uvm_object **, voff_t *, struct file *);
#else
void drm_gem_vm_open(struct vm_area_struct *vma);
void drm_gem_vm_close(struct vm_area_struct *vma);
diff -r 68fe81ce08f2 -r 22e9fa758997 sys/external/bsd/drm2/drm/drm_drv.c
--- a/sys/external/bsd/drm2/drm/drm_drv.c Sat Jul 26 21:12:43 2014 +0000
+++ b/sys/external/bsd/drm2/drm/drm_drv.c Sat Jul 26 21:15:45 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: drm_drv.c,v 1.8 2014/07/25 08:10:39 dholland Exp $ */
+/* $NetBSD: drm_drv.c,v 1.9 2014/07/26 21:15:45 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.8 2014/07/25 08:10:39 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.9 2014/07/26 21:15:45 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -754,24 +754,14 @@
return -EINVAL;
(void)addr; /* XXX ignore -- no MAP_FIXED for now */
- /* Try a GEM object mapping first. */
- ret = drm_gem_mmap_object(dev, offset, size, prot, &uobj, &uoffset);
+ ret = (*dev->driver->mmap_object)(dev, offset, size, prot, &uobj,
+ &uoffset, file->filp);
if (ret)
return ret;
- if (uobj != NULL)
- goto map;
+ if (uobj == NULL)
+ return -EINVAL;
- /* Try a traditional DRM mapping second. */
- ret = drm_mmap_object(dev, offset, size, prot, &uobj, &uoffset);
- if (ret)
- return ret;
- if (uobj != NULL)
- goto map;
-
- /* Fail. */
- return ret;
-
-map: vm_prot = ((ISSET(prot, PROT_READ)? VM_PROT_READ : 0) |
+ vm_prot = ((ISSET(prot, PROT_READ)? VM_PROT_READ : 0) |
(ISSET(prot, PROT_WRITE)? VM_PROT_WRITE : 0));
KASSERT(vm_prot == (vm_prot & vm_maxprot));
uvmflag = UVM_MAPFLAG(vm_prot, vm_maxprot, UVM_INH_COPY,
diff -r 68fe81ce08f2 -r 22e9fa758997 sys/external/bsd/drm2/drm/drm_gem_vm.c
--- a/sys/external/bsd/drm2/drm/drm_gem_vm.c Sat Jul 26 21:12:43 2014 +0000
+++ b/sys/external/bsd/drm2/drm/drm_gem_vm.c Sat Jul 26 21:15:45 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: drm_gem_vm.c,v 1.4 2014/07/16 20:56:25 riastradh Exp $ */
+/* $NetBSD: drm_gem_vm.c,v 1.5 2014/07/26 21:15:45 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_gem_vm.c,v 1.4 2014/07/16 20:56:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_gem_vm.c,v 1.5 2014/07/26 21:15:45 riastradh Exp $");
#include <sys/types.h>
@@ -40,7 +40,7 @@
#include <drm/drm_vma_manager.h>
static int drm_gem_mmap_object_locked(struct drm_device *, off_t, size_t,
- int, struct uvm_object **, voff_t *);
+ int, struct uvm_object **, voff_t *, struct file *);
void
drm_gem_pager_reference(struct uvm_object *uobj)
@@ -61,14 +61,32 @@
}
int
+drm_gem_or_legacy_mmap_object(struct drm_device *dev, off_t byte_offset,
+ size_t nbytes, int prot, struct uvm_object **uobjp, voff_t *uoffsetp,
+ struct file *file)
+{
+ int ret;
+
+ ret = drm_gem_mmap_object(dev, byte_offset, nbytes, prot, uobjp,
+ uoffsetp, file);
+ if (ret)
+ return ret;
+ if (*uobjp != NULL)
+ return 0;
+
+ return drm_mmap_object(dev, byte_offset, nbytes, prot, uobjp,
+ uoffsetp, file);
+}
+
+int
drm_gem_mmap_object(struct drm_device *dev, off_t byte_offset, size_t nbytes,
- int prot, struct uvm_object **uobjp, voff_t *uoffsetp)
+ int prot, struct uvm_object **uobjp, voff_t *uoffsetp, struct file *file)
{
int ret;
mutex_lock(&dev->struct_mutex);
ret = drm_gem_mmap_object_locked(dev, byte_offset, nbytes, prot,
- uobjp, uoffsetp);
+ uobjp, uoffsetp, file);
mutex_unlock(&dev->struct_mutex);
return ret;
@@ -77,7 +95,7 @@
static int
drm_gem_mmap_object_locked(struct drm_device *dev, off_t byte_offset,
size_t nbytes, int prot __unused, struct uvm_object **uobjp,
- voff_t *uoffsetp)
+ voff_t *uoffsetp, struct file *file __unused)
{
const unsigned long startpage = (byte_offset >> PAGE_SHIFT);
const unsigned long npages = (nbytes >> PAGE_SHIFT);
diff -r 68fe81ce08f2 -r 22e9fa758997 sys/external/bsd/drm2/drm/drm_vm.c
--- a/sys/external/bsd/drm2/drm/drm_vm.c Sat Jul 26 21:12:43 2014 +0000
+++ b/sys/external/bsd/drm2/drm/drm_vm.c Sat Jul 26 21:15:45 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: drm_vm.c,v 1.4 2014/07/16 20:56:25 riastradh Exp $ */
+/* $NetBSD: drm_vm.c,v 1.5 2014/07/26 21:15:45 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_vm.c,v 1.4 2014/07/16 20:56:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_vm.c,v 1.5 2014/07/26 21:15:45 riastradh Exp $");
#include <sys/types.h>
#include <sys/conf.h>
@@ -47,7 +47,7 @@
int
drm_mmap_object(struct drm_device *dev, off_t offset, size_t size, int prot,
- struct uvm_object **uobjp, voff_t *uoffsetp)
+ struct uvm_object **uobjp, voff_t *uoffsetp, struct file *file __unused)
{
dev_t devno = cdevsw_lookup_major(&drm_cdevsw);
struct uvm_object *uobj;
Home |
Main Index |
Thread Index |
Old Index