Merge tag 'io_uring-5.11-2021-01-16' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / gpu / drm / i915 / selftests / igt_mmap.c
blob583a4ff8b8c9bd58e49886f0376b93897053da66
1 /*
2 * SPDX-License-Identifier: MIT
4 * Copyright © 2019 Intel Corporation
5 */
7 #include <drm/drm_file.h>
9 #include "i915_drv.h"
10 #include "igt_mmap.h"
12 unsigned long igt_mmap_node(struct drm_i915_private *i915,
13 struct drm_vma_offset_node *node,
14 unsigned long addr,
15 unsigned long prot,
16 unsigned long flags)
18 struct file *file;
19 int err;
21 /* Pretend to open("/dev/dri/card0") */
22 file = mock_drm_getfile(i915->drm.primary, O_RDWR);
23 if (IS_ERR(file))
24 return PTR_ERR(file);
26 err = drm_vma_node_allow(node, file->private_data);
27 if (err) {
28 addr = err;
29 goto out_file;
32 addr = vm_mmap(file, addr, drm_vma_node_size(node) << PAGE_SHIFT,
33 prot, flags, drm_vma_node_offset_addr(node));
35 drm_vma_node_revoke(node, file->private_data);
36 out_file:
37 fput(file);
38 return addr;