usb: gadget: udc: renesas_usb3: Fix sysfs interface of "role"
[linux-2.6-block.git] / drivers / xen / gntdev-common.h
CommitLineData
1d314567
OA
1/* SPDX-License-Identifier: GPL-2.0 */
2
3/*
4 * Common functionality of grant device.
5 *
6 * Copyright (c) 2006-2007, D G Murray.
7 * (c) 2009 Gerd Hoffmann <kraxel@redhat.com>
8 * (c) 2018 Oleksandr Andrushchenko, EPAM Systems Inc.
9 */
10
11#ifndef _GNTDEV_COMMON_H
12#define _GNTDEV_COMMON_H
13
14#include <linux/mm.h>
15#include <linux/mman.h>
16#include <linux/mmu_notifier.h>
17#include <linux/types.h>
18
932d6562
OA
19struct gntdev_dmabuf_priv;
20
1d314567
OA
21struct gntdev_priv {
22 /* Maps with visible offsets in the file descriptor. */
23 struct list_head maps;
24 /*
25 * Maps that are not visible; will be freed on munmap.
26 * Only populated if populate_freeable_maps == 1
27 */
28 struct list_head freeable_maps;
29 /* lock protects maps and freeable_maps. */
30 struct mutex lock;
31 struct mm_struct *mm;
32 struct mmu_notifier mn;
33
34#ifdef CONFIG_XEN_GRANT_DMA_ALLOC
35 /* Device for which DMA memory is allocated. */
36 struct device *dma_dev;
37#endif
932d6562
OA
38
39#ifdef CONFIG_XEN_GNTDEV_DMABUF
40 struct gntdev_dmabuf_priv *dmabuf_priv;
41#endif
1d314567
OA
42};
43
44struct gntdev_unmap_notify {
45 int flags;
46 /* Address relative to the start of the gntdev_grant_map. */
47 int addr;
48 int event;
49};
50
51struct gntdev_grant_map {
52 struct list_head next;
53 struct vm_area_struct *vma;
54 int index;
55 int count;
56 int flags;
57 refcount_t users;
58 struct gntdev_unmap_notify notify;
59 struct ioctl_gntdev_grant_ref *grants;
60 struct gnttab_map_grant_ref *map_ops;
61 struct gnttab_unmap_grant_ref *unmap_ops;
62 struct gnttab_map_grant_ref *kmap_ops;
63 struct gnttab_unmap_grant_ref *kunmap_ops;
64 struct page **pages;
65 unsigned long pages_vm_start;
66
67#ifdef CONFIG_XEN_GRANT_DMA_ALLOC
68 /*
69 * If dmabuf_vaddr is not NULL then this mapping is backed by DMA
70 * capable memory.
71 */
72
73 struct device *dma_dev;
74 /* Flags used to create this DMA buffer: GNTDEV_DMA_FLAG_XXX. */
75 int dma_flags;
76 void *dma_vaddr;
77 dma_addr_t dma_bus_addr;
78 /* Needed to avoid allocation in gnttab_dma_free_pages(). */
79 xen_pfn_t *frames;
80#endif
81};
82
83struct gntdev_grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count,
84 int dma_flags);
85
86void gntdev_add_map(struct gntdev_priv *priv, struct gntdev_grant_map *add);
87
88void gntdev_put_map(struct gntdev_priv *priv, struct gntdev_grant_map *map);
89
90bool gntdev_account_mapped_pages(int count);
91
92int gntdev_map_grant_pages(struct gntdev_grant_map *map);
93
94#endif