History

accel/ivpu: Add GEM buffer object management

Adds four types of GEM-based BOs for the VPU: - shmem - internal - prime All types are implemented as struct ivpu_bo, based on struct drm_gem_object. VPU address is allocated when buffer is created except for imported prime buffers that allocate it in BO_INFO IOCTL due to missing file_priv arg in gem_prime_import callback. Internal buffers are pinned on creation, the rest of buffers types can be pinned on demand (in SUBMIT IOCTL). Buffer VPU address, allocated pages and mappings are released when the buffer is destroyed. Eviction mechanism is planned for future versions. Add two new IOCTLs: BO_CREATE, BO_INFO

Jacek Lawrynowicz committed 3 years ago

Commit 647371a1 parent 263b2ba6 files · +977 −2Browse files

Showing the changes to include/uapi (1 of 6 files). Show all

Unified · Split

include/uapi/drm/ivpu_accel.h+94−0
@@ -17,6 +17,8 @@ extern "C" { · 16 unmodified lines
1717
1818 #define DRM_IVPU_GET_PARAM 0x00
1919 #define DRM_IVPU_SET_PARAM 0x01
20+#define DRM_IVPU_BO_CREATE 0x02
21+#define DRM_IVPU_BO_INFO 0x03
2022
2123 #define DRM_IOCTL_IVPU_GET_PARAM \
2224 DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_GET_PARAM, struct drm_ivpu_param)
@@ -24,6 +26,12 @@ extern "C" { · 1 unmodified line
2426 #define DRM_IOCTL_IVPU_SET_PARAM \
2527 DRM_IOW(DRM_COMMAND_BASE + DRM_IVPU_SET_PARAM, struct drm_ivpu_param)
2628
29+#define DRM_IOCTL_IVPU_BO_CREATE \
30+ DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_BO_CREATE, struct drm_ivpu_bo_create)
31+
32+#define DRM_IOCTL_IVPU_BO_INFO \
33+ DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_BO_INFO, struct drm_ivpu_bo_info)
34+
2735 /**
2836 * DOC: contexts
2937 *
@@ -92,6 +100,92 @@ struct drm_ivpu_param { · 62 unmodified lines
92100 __u64 value;
93101 };
94102
103+#define DRM_IVPU_BO_HIGH_MEM 0x00000001
104+#define DRM_IVPU_BO_MAPPABLE 0x00000002
105+
106+#define DRM_IVPU_BO_CACHED 0x00000000
107+#define DRM_IVPU_BO_UNCACHED 0x00010000
108+#define DRM_IVPU_BO_WC 0x00020000
109+#define DRM_IVPU_BO_CACHE_MASK 0x00030000
110+
111+#define DRM_IVPU_BO_FLAGS \
112+ (DRM_IVPU_BO_HIGH_MEM | \
113+ DRM_IVPU_BO_MAPPABLE | \
114+ DRM_IVPU_BO_CACHE_MASK)
115+
116+/**
117+ * struct drm_ivpu_bo_create - Create BO backed by SHMEM
118+ *
119+ * Create GEM buffer object allocated in SHMEM memory.
120+ */
121+struct drm_ivpu_bo_create {
122+ /** @size: The size in bytes of the allocated memory */
123+ __u64 size;
124+
125+ /**
126+ * @flags:
127+ *
128+ * Supported flags:
129+ *
130+ * %DRM_IVPU_BO_HIGH_MEM:
131+ *
132+ * Allocate VPU address from >4GB range.
133+ * Buffer object with vpu address >4GB can be always accessed by the
134+ * VPU DMA engine, but some HW generation may not be able to access
135+ * this memory from then firmware running on the VPU management processor.
136+ * Suitable for input, output and some scratch buffers.
137+ *
138+ * %DRM_IVPU_BO_MAPPABLE:
139+ *
140+ * Buffer object can be mapped using mmap().
141+ *
142+ * %DRM_IVPU_BO_CACHED:
143+ *
144+ * Allocated BO will be cached on host side (WB) and snooped on the VPU side.
145+ * This is the default caching mode.
146+ *
147+ * %DRM_IVPU_BO_UNCACHED:
148+ *
149+ * Allocated BO will not be cached on host side nor snooped on the VPU side.
150+ *
151+ * %DRM_IVPU_BO_WC:
152+ *
153+ * Allocated BO will use write combining buffer for writes but reads will be
154+ * uncached.
155+ */
156+ __u32 flags;
157+
158+ /** @handle: Returned GEM object handle */
159+ __u32 handle;
160+
161+ /** @vpu_addr: Returned VPU virtual address */
162+ __u64 vpu_addr;
163+};
164+
165+/**
166+ * struct drm_ivpu_bo_info - Query buffer object info
167+ */
168+struct drm_ivpu_bo_info {
169+ /** @handle: Handle of the queried BO */
170+ __u32 handle;
171+
172+ /** @flags: Returned flags used to create the BO */
173+ __u32 flags;
174+
175+ /** @vpu_addr: Returned VPU virtual address */
176+ __u64 vpu_addr;
177+
178+ /**
179+ * @mmap_offset:
180+ *
181+ * Returned offset to be used in mmap(). 0 in case the BO is not mappable.
182+ */
183+ __u64 mmap_offset;
184+
185+ /** @size: Returned GEM object size, aligned to PAGE_SIZE */
186+ __u64 size;
187+};
188+
95189 #if defined(__cplusplus)
96190 }
97191 #endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t