forked from Minki/linux
6fedafacae
Provide a utility function to create a vma corresponding to an mmap() of our device. And use it to exercise the equivalent of userspace performing a GTT mmap of our objects. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Abdiel Janulgue <abdiel.janulgue@linux.intel.com> Reviewed-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20191107180601.30815-4-chris@chris-wilson.co.uk
40 lines
817 B
C
40 lines
817 B
C
/*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
* Copyright © 2019 Intel Corporation
|
|
*/
|
|
|
|
#include <drm/drm_file.h>
|
|
|
|
#include "i915_drv.h"
|
|
#include "igt_mmap.h"
|
|
|
|
unsigned long igt_mmap_node(struct drm_i915_private *i915,
|
|
struct drm_vma_offset_node *node,
|
|
unsigned long addr,
|
|
unsigned long prot,
|
|
unsigned long flags)
|
|
{
|
|
struct file *file;
|
|
int err;
|
|
|
|
/* Pretend to open("/dev/dri/card0") */
|
|
file = mock_drm_getfile(i915->drm.primary, O_RDWR);
|
|
if (IS_ERR(file))
|
|
return PTR_ERR(file);
|
|
|
|
err = drm_vma_node_allow(node, file->private_data);
|
|
if (err) {
|
|
addr = err;
|
|
goto out_file;
|
|
}
|
|
|
|
addr = vm_mmap(file, addr, drm_vma_node_size(node) << PAGE_SHIFT,
|
|
prot, flags, drm_vma_node_offset_addr(node));
|
|
|
|
drm_vma_node_revoke(node, file->private_data);
|
|
out_file:
|
|
fput(file);
|
|
return addr;
|
|
}
|