1329 lines · 38.0 KB · C
RawDownload
/* SPDX-License-Identifier: MIT *//* Copyright (C) 2023 Collabora ltd. */#ifndef _PANTHOR_DRM_H_#define _PANTHOR_DRM_H_ #include "drm.h" #if defined(__cplusplus)extern "C" {#endif /** * DOC: Introduction * * This documentation describes the Panthor IOCTLs. * * Just a few generic rules about the data passed to the Panthor IOCTLs: * * - Structures must be aligned on 64-bit/8-byte. If the object is not *   naturally aligned, a padding field must be added. * - Fields must be explicitly aligned to their natural type alignment with *   pad[0..N] fields. * - All padding fields will be checked by the driver to make sure they are *   zeroed. * - Flags can be added, but not removed/replaced. * - New fields can be added to the main structures (the structures *   directly passed to the ioctl). Those fields can be added at the end of *   the structure, or replace existing padding fields. Any new field being *   added must preserve the behavior that existed before those fields were *   added when a value of zero is passed. * - New fields can be added to indirect objects (objects pointed by the *   main structure), iff those objects are passed a size to reflect the *   size known by the userspace driver (see drm_panthor_obj_array::stride *   or drm_panthor_dev_query::size). * - If the kernel driver is too old to know some fields, those will be *   ignored if zero, and otherwise rejected (and so will be zero on output). * - If userspace is too old to know some fields, those will be zeroed *   (input) before the structure is parsed by the kernel driver. * - Each new flag/field addition must come with a driver version update so *   the userspace driver doesn't have to trial and error to know which *   flags are supported. * - Structures should not contain unions, as this would defeat the *   extensibility of such structures. * - IOCTLs can't be removed or replaced. New IOCTL IDs should be placed *   at the end of the drm_panthor_ioctl_id enum. */ /** * DOC: MMIO regions exposed to userspace. * * .. c:macro:: DRM_PANTHOR_USER_MMIO_OFFSET * * File offset for all MMIO regions being exposed to userspace. Don't use * this value directly, use DRM_PANTHOR_USER_<name>_OFFSET values instead. * pgoffset passed to mmap2() is an unsigned long, which forces us to use a * different offset on 32-bit and 64-bit systems. * * .. c:macro:: DRM_PANTHOR_USER_FLUSH_ID_MMIO_OFFSET * * File offset for the LATEST_FLUSH_ID register. The Userspace driver controls * GPU cache flushing through CS instructions, but the flush reduction * mechanism requires a flush_id. This flush_id could be queried with an * ioctl, but Arm provides a well-isolated register page containing only this * read-only register, so let's expose this page through a static mmap offset * and allow direct mapping of this MMIO region so we can avoid the * user <-> kernel round-trip. */#define DRM_PANTHOR_USER_MMIO_OFFSET_32BIT	(1ull << 43)#define DRM_PANTHOR_USER_MMIO_OFFSET_64BIT	(1ull << 56)#define DRM_PANTHOR_USER_MMIO_OFFSET		(sizeof(unsigned long) < 8 ? \						 DRM_PANTHOR_USER_MMIO_OFFSET_32BIT : \						 DRM_PANTHOR_USER_MMIO_OFFSET_64BIT)#define DRM_PANTHOR_USER_FLUSH_ID_MMIO_OFFSET	(DRM_PANTHOR_USER_MMIO_OFFSET | 0) /** * DOC: IOCTL IDs * * enum drm_panthor_ioctl_id - IOCTL IDs * * Place new ioctls at the end, don't re-order, don't replace or remove entries. * * These IDs are not meant to be used directly. Use the DRM_IOCTL_PANTHOR_xxx * definitions instead. */enum drm_panthor_ioctl_id {	/** @DRM_PANTHOR_DEV_QUERY: Query device information. */	DRM_PANTHOR_DEV_QUERY = 0, 	/** @DRM_PANTHOR_VM_CREATE: Create a VM. */	DRM_PANTHOR_VM_CREATE, 	/** @DRM_PANTHOR_VM_DESTROY: Destroy a VM. */	DRM_PANTHOR_VM_DESTROY, 	/** @DRM_PANTHOR_VM_BIND: Bind/unbind memory to a VM. */	DRM_PANTHOR_VM_BIND, 	/** @DRM_PANTHOR_VM_GET_STATE: Get VM state. */	DRM_PANTHOR_VM_GET_STATE, 	/** @DRM_PANTHOR_BO_CREATE: Create a buffer object. */	DRM_PANTHOR_BO_CREATE, 	/**	 * @DRM_PANTHOR_BO_MMAP_OFFSET: Get the file offset to pass to	 * mmap to map a GEM object.	 */	DRM_PANTHOR_BO_MMAP_OFFSET, 	/** @DRM_PANTHOR_GROUP_CREATE: Create a scheduling group. */	DRM_PANTHOR_GROUP_CREATE, 	/** @DRM_PANTHOR_GROUP_DESTROY: Destroy a scheduling group. */	DRM_PANTHOR_GROUP_DESTROY, 	/**	 * @DRM_PANTHOR_GROUP_SUBMIT: Submit jobs to queues belonging	 * to a specific scheduling group.	 */	DRM_PANTHOR_GROUP_SUBMIT, 	/** @DRM_PANTHOR_GROUP_GET_STATE: Get the state of a scheduling group. */	DRM_PANTHOR_GROUP_GET_STATE, 	/** @DRM_PANTHOR_TILER_HEAP_CREATE: Create a tiler heap. */	DRM_PANTHOR_TILER_HEAP_CREATE, 	/** @DRM_PANTHOR_TILER_HEAP_DESTROY: Destroy a tiler heap. */	DRM_PANTHOR_TILER_HEAP_DESTROY, 	/** @DRM_PANTHOR_BO_SET_LABEL: Label a BO. */	DRM_PANTHOR_BO_SET_LABEL, 	/**	 * @DRM_PANTHOR_SET_USER_MMIO_OFFSET: Set the offset to use as the user MMIO offset.	 *	 * The default behavior is to pick the MMIO offset based on the size of the pgoff_t	 * type seen by the process that manipulates the FD, such that a 32-bit process can	 * always map the user MMIO ranges. But this approach doesn't work well for emulators	 * like FEX, where the emulator is an 64-bit binary which might be executing 32-bit	 * code. In that case, the kernel thinks it's the 64-bit process and assumes	 * DRM_PANTHOR_USER_MMIO_OFFSET_64BIT is in use, but the UMD library expects	 * DRM_PANTHOR_USER_MMIO_OFFSET_32BIT, because it can't mmap() anything above the	 * pgoff_t size.	 */	DRM_PANTHOR_SET_USER_MMIO_OFFSET, 	/** @DRM_PANTHOR_BO_SYNC: Sync BO data to/from the device */	DRM_PANTHOR_BO_SYNC, 	/**	 * @DRM_PANTHOR_BO_QUERY_INFO: Query information about a BO.	 *	 * This is useful for imported BOs.	 */	DRM_PANTHOR_BO_QUERY_INFO,}; /** * DOC: IOCTL arguments */ /** * struct drm_panthor_obj_array - Object array. * * This object is used to pass an array of objects whose size is subject to changes in * future versions of the driver. In order to support this mutability, we pass a stride * describing the size of the object as known by userspace. * * You shouldn't fill drm_panthor_obj_array fields directly. You should instead use * the DRM_PANTHOR_OBJ_ARRAY() macro that takes care of initializing the stride to * the object size. */struct drm_panthor_obj_array {	/** @stride: Stride of object struct. Used for versioning. */	__u32 stride; 	/** @count: Number of objects in the array. */	__u32 count; 	/** @array: User pointer to an array of objects. */	__u64 array;}; /** * DRM_PANTHOR_OBJ_ARRAY() - Initialize a drm_panthor_obj_array field. * @cnt: Number of elements in the array. * @ptr: Pointer to the array to pass to the kernel. * * Macro initializing a drm_panthor_obj_array based on the object size as known * by userspace. */#define DRM_PANTHOR_OBJ_ARRAY(cnt, ptr) \	{ .stride = sizeof((ptr)[0]), .count = (cnt), .array = (__u64)(uintptr_t)(ptr) } /** * enum drm_panthor_sync_op_flags - Synchronization operation flags. */enum drm_panthor_sync_op_flags {	/** @DRM_PANTHOR_SYNC_OP_HANDLE_TYPE_MASK: Synchronization handle type mask. */	DRM_PANTHOR_SYNC_OP_HANDLE_TYPE_MASK = 0xff, 	/** @DRM_PANTHOR_SYNC_OP_HANDLE_TYPE_SYNCOBJ: Synchronization object type. */	DRM_PANTHOR_SYNC_OP_HANDLE_TYPE_SYNCOBJ = 0, 	/**	 * @DRM_PANTHOR_SYNC_OP_HANDLE_TYPE_TIMELINE_SYNCOBJ: Timeline synchronization	 * object type.	 */	DRM_PANTHOR_SYNC_OP_HANDLE_TYPE_TIMELINE_SYNCOBJ = 1, 	/** @DRM_PANTHOR_SYNC_OP_WAIT: Wait operation. */	DRM_PANTHOR_SYNC_OP_WAIT = 0 << 31, 	/** @DRM_PANTHOR_SYNC_OP_SIGNAL: Signal operation. */	DRM_PANTHOR_SYNC_OP_SIGNAL = (int)(1u << 31),}; /** * struct drm_panthor_sync_op - Synchronization operation. */struct drm_panthor_sync_op {	/** @flags: Synchronization operation flags. Combination of DRM_PANTHOR_SYNC_OP values. */	__u32 flags; 	/** @handle: Sync handle. */	__u32 handle; 	/**	 * @timeline_value: MBZ if	 * (flags & DRM_PANTHOR_SYNC_OP_HANDLE_TYPE_MASK) !=	 * DRM_PANTHOR_SYNC_OP_HANDLE_TYPE_TIMELINE_SYNCOBJ.	 */	__u64 timeline_value;}; /** * enum drm_panthor_dev_query_type - Query type * * Place new types at the end, don't re-order, don't remove or replace. */enum drm_panthor_dev_query_type {	/** @DRM_PANTHOR_DEV_QUERY_GPU_INFO: Query GPU information. */	DRM_PANTHOR_DEV_QUERY_GPU_INFO = 0, 	/** @DRM_PANTHOR_DEV_QUERY_CSIF_INFO: Query command-stream interface information. */	DRM_PANTHOR_DEV_QUERY_CSIF_INFO, 	/** @DRM_PANTHOR_DEV_QUERY_TIMESTAMP_INFO: Query timestamp information. */	DRM_PANTHOR_DEV_QUERY_TIMESTAMP_INFO, 	/**	 * @DRM_PANTHOR_DEV_QUERY_GROUP_PRIORITIES_INFO: Query allowed group priorities information.	 */	DRM_PANTHOR_DEV_QUERY_GROUP_PRIORITIES_INFO, 	/** @DRM_PANTHOR_DEV_QUERY_MMU_INFO: Query MMU information. */	DRM_PANTHOR_DEV_QUERY_MMU_INFO,}; /** * enum drm_panthor_gpu_coherency: Type of GPU coherency */enum drm_panthor_gpu_coherency {	/**	 * @DRM_PANTHOR_GPU_COHERENCY_ACE_LITE: ACE Lite coherency.	 */	DRM_PANTHOR_GPU_COHERENCY_ACE_LITE = 0, 	/**	 * @DRM_PANTHOR_GPU_COHERENCY_ACE: ACE coherency.	 */	DRM_PANTHOR_GPU_COHERENCY_ACE = 1, 	/**	 * @DRM_PANTHOR_GPU_COHERENCY_NONE: No coherency.	 */	DRM_PANTHOR_GPU_COHERENCY_NONE = 31,}; /** * struct drm_panthor_gpu_info - GPU information * * Structure grouping all queryable information relating to the GPU. */struct drm_panthor_gpu_info {	/** @gpu_id : GPU ID. */	__u32 gpu_id;#define DRM_PANTHOR_ARCH_MAJOR(x)		((x) >> 28)#define DRM_PANTHOR_ARCH_MINOR(x)		(((x) >> 24) & 0xf)#define DRM_PANTHOR_ARCH_REV(x)			(((x) >> 20) & 0xf)#define DRM_PANTHOR_PRODUCT_MAJOR(x)		(((x) >> 16) & 0xf)#define DRM_PANTHOR_VERSION_MAJOR(x)		(((x) >> 12) & 0xf)#define DRM_PANTHOR_VERSION_MINOR(x)		(((x) >> 4) & 0xff)#define DRM_PANTHOR_VERSION_STATUS(x)		((x) & 0xf) 	/** @gpu_rev: GPU revision. */	__u32 gpu_rev; 	/** @csf_id: Command stream frontend ID. */	__u32 csf_id;#define DRM_PANTHOR_CSHW_MAJOR(x)		(((x) >> 26) & 0x3f)#define DRM_PANTHOR_CSHW_MINOR(x)		(((x) >> 20) & 0x3f)#define DRM_PANTHOR_CSHW_REV(x)			(((x) >> 16) & 0xf)#define DRM_PANTHOR_MCU_MAJOR(x)		(((x) >> 10) & 0x3f)#define DRM_PANTHOR_MCU_MINOR(x)		(((x) >> 4) & 0x3f)#define DRM_PANTHOR_MCU_REV(x)			((x) & 0xf) 	/** @l2_features: L2-cache features. */	__u32 l2_features; 	/** @tiler_features: Tiler features. */	__u32 tiler_features; 	/** @mem_features: Memory features. */	__u32 mem_features; 	/** @mmu_features: MMU features. */	__u32 mmu_features;#define DRM_PANTHOR_MMU_VA_BITS(x)		((x) & 0xff) 	/** @thread_features: Thread features. */	__u32 thread_features; 	/** @max_threads: Maximum number of threads. */	__u32 max_threads; 	/** @thread_max_workgroup_size: Maximum workgroup size. */	__u32 thread_max_workgroup_size; 	/**	 * @thread_max_barrier_size: Maximum number of threads that can wait	 * simultaneously on a barrier.	 */	__u32 thread_max_barrier_size; 	/**	 * @coherency_features: Coherency features.	 *	 * Combination of drm_panthor_gpu_coherency flags.	 *	 * Note that this is just what the coherency protocols supported by the	 * GPU, but the actual coherency in place depends on the SoC	 * integration and is reflected by	 * drm_panthor_gpu_info::selected_coherency.	 */	__u32 coherency_features; 	/** @texture_features: Texture features. */	__u32 texture_features[4]; 	/** @as_present: Bitmask encoding the number of address-space exposed by the MMU. */	__u32 as_present; 	/**	 * @selected_coherency: Coherency selected for this device.	 *	 * One of drm_panthor_gpu_coherency.	 */	__u32 selected_coherency; 	/** @shader_present: Bitmask encoding the shader cores exposed by the GPU. */	__u64 shader_present; 	/** @l2_present: Bitmask encoding the L2 caches exposed by the GPU. */	__u64 l2_present; 	/** @tiler_present: Bitmask encoding the tiler units exposed by the GPU. */	__u64 tiler_present; 	/** @core_features: Used to discriminate core variants when they exist. */	__u32 core_features; 	/** @pad: MBZ. */	__u32 pad; 	/** @gpu_features: Bitmask describing supported GPU-wide features */	__u64 gpu_features;}; /** * struct drm_panthor_csif_info - Command stream interface information * * Structure grouping all queryable information relating to the command stream interface. */struct drm_panthor_csif_info {	/** @csg_slot_count: Number of command stream group slots exposed by the firmware. */	__u32 csg_slot_count; 	/** @cs_slot_count: Number of command stream slots per group. */	__u32 cs_slot_count; 	/** @cs_reg_count: Number of command stream registers. */	__u32 cs_reg_count; 	/** @scoreboard_slot_count: Number of scoreboard slots. */	__u32 scoreboard_slot_count; 	/**	 * @unpreserved_cs_reg_count: Number of command stream registers reserved by	 * the kernel driver to call a userspace command stream.	 *	 * All registers can be used by a userspace command stream, but the	 * [cs_slot_count - unpreserved_cs_reg_count .. cs_slot_count] registers are	 * used by the kernel when DRM_PANTHOR_IOCTL_GROUP_SUBMIT is called.	 */	__u32 unpreserved_cs_reg_count; 	/**	 * @pad: Padding field, set to zero.	 */	__u32 pad;}; /** * enum drm_panthor_timestamp_info_flags - drm_panthor_timestamp_info.flags */enum drm_panthor_timestamp_info_flags {	/** @DRM_PANTHOR_TIMESTAMP_GPU: Query GPU time. */	DRM_PANTHOR_TIMESTAMP_GPU = 1 << 0, 	/** @DRM_PANTHOR_TIMESTAMP_CPU_NONE: Don't query CPU time. */	DRM_PANTHOR_TIMESTAMP_CPU_NONE = 0 << 1, 	/** @DRM_PANTHOR_TIMESTAMP_CPU_MONOTONIC: Query CPU time using CLOCK_MONOTONIC. */	DRM_PANTHOR_TIMESTAMP_CPU_MONOTONIC = 1 << 1, 	/** @DRM_PANTHOR_TIMESTAMP_CPU_MONOTONIC_RAW: Query CPU time using CLOCK_MONOTONIC_RAW. */	DRM_PANTHOR_TIMESTAMP_CPU_MONOTONIC_RAW = 2 << 1, 	/** @DRM_PANTHOR_TIMESTAMP_CPU_TYPE_MASK: Space reserved for CPU clock type. */	DRM_PANTHOR_TIMESTAMP_CPU_TYPE_MASK = 7 << 1, 	/** @DRM_PANTHOR_TIMESTAMP_GPU_OFFSET: Query GPU offset. */	DRM_PANTHOR_TIMESTAMP_GPU_OFFSET = 1 << 4, 	/** @DRM_PANTHOR_TIMESTAMP_GPU_CYCLE_COUNT: Query GPU cycle count. */	DRM_PANTHOR_TIMESTAMP_GPU_CYCLE_COUNT = 1 << 5, 	/** @DRM_PANTHOR_TIMESTAMP_FREQ: Query timestamp frequency. */	DRM_PANTHOR_TIMESTAMP_FREQ = 1 << 6, 	/** @DRM_PANTHOR_TIMESTAMP_DURATION: Return duration of time query. */	DRM_PANTHOR_TIMESTAMP_DURATION = 1 << 7,}; /** * struct drm_panthor_timestamp_info - Timestamp information * * Structure grouping all queryable information relating to the GPU timestamp. */struct drm_panthor_timestamp_info {	/**	 * @timestamp_frequency: The frequency of the timestamp timer or 0 if	 * unknown.	 */	__u64 timestamp_frequency; 	/** @current_timestamp: The current GPU timestamp. */	__u64 current_timestamp; 	/** @timestamp_offset: The offset of the GPU timestamp timer. */	__u64 timestamp_offset; 	/**	 * @flags: Bitmask of drm_panthor_timestamp_info_flags.	 *	 * If set to 0, then it is interpreted as:	 *  DRM_PANTHOR_TIMESTAMP_GPU |	 *  DRM_PANTHOR_TIMESTAMP_GPU_OFFSET |	 *  DRM_PANTHOR_TIMESTAMP_FREQ	 *	 * Note: these flags are exclusive to each other (only one can be used):	 * - DRM_PANTHOR_TIMESTAMP_CPU_NONE	 * - DRM_PANTHOR_TIMESTAMP_CPU_MONOTONIC	 * - DRM_PANTHOR_TIMESTAMP_CPU_MONOTONIC_RAW	 */	__u32 flags; 	/** @duration_nsec: Duration of time query. */	__u32 duration_nsec; 	/** @cycle_count: Value of GPU_CYCLE_COUNT. */	__u64 cycle_count; 	/** @cpu_timestamp_sec: Seconds part of CPU timestamp. */	__u64 cpu_timestamp_sec; 	/** @cpu_timestamp_nsec: Nanseconds part of CPU timestamp. */	__u64 cpu_timestamp_nsec;}; /** * struct drm_panthor_mmu_info - MMU information * * Structure grouping all queryable information relating to the MMU. */struct drm_panthor_mmu_info {	/** @page_size_bitmap: Allowed page sizes */	__u64 page_size_bitmap;

Lines 1–500 of 1329.

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