/* 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 … #define DRM_PANTHOR_USER_MMIO_OFFSET_64BIT … #define DRM_PANTHOR_USER_MMIO_OFFSET … #define DRM_PANTHOR_USER_FLUSH_ID_MMIO_OFFSET … /** * 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_IOCTL_PANTHOR() - Build a Panthor IOCTL number * @__access: Access type. Must be R, W or RW. * @__id: One of the DRM_PANTHOR_xxx id. * @__type: Suffix of the type being passed to the IOCTL. * * Don't use this macro directly, use the DRM_IOCTL_PANTHOR_xxx * values instead. * * Return: An IOCTL number to be passed to ioctl() from userspace. */ #define DRM_IOCTL_PANTHOR(__access, __id, __type) … #define DRM_IOCTL_PANTHOR_DEV_QUERY … #define DRM_IOCTL_PANTHOR_VM_CREATE … #define DRM_IOCTL_PANTHOR_VM_DESTROY … #define DRM_IOCTL_PANTHOR_VM_BIND … #define DRM_IOCTL_PANTHOR_VM_GET_STATE … #define DRM_IOCTL_PANTHOR_BO_CREATE … #define DRM_IOCTL_PANTHOR_BO_MMAP_OFFSET … #define DRM_IOCTL_PANTHOR_GROUP_CREATE … #define DRM_IOCTL_PANTHOR_GROUP_DESTROY … #define DRM_IOCTL_PANTHOR_GROUP_SUBMIT … #define DRM_IOCTL_PANTHOR_GROUP_GET_STATE … #define DRM_IOCTL_PANTHOR_TILER_HEAP_CREATE … #define DRM_IOCTL_PANTHOR_TILER_HEAP_DESTROY … /** * 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 { … }; /** * 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) … /** * enum drm_panthor_sync_op_flags - Synchronization operation flags. */ enum drm_panthor_sync_op_flags { … }; /** * struct drm_panthor_sync_op - Synchronization operation. */ struct drm_panthor_sync_op { … }; /** * 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 { … }; /** * struct drm_panthor_gpu_info - GPU information * * Structure grouping all queryable information relating to the GPU. */ struct drm_panthor_gpu_info { … }; /** * 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 { … }; /** * struct drm_panthor_dev_query - Arguments passed to DRM_PANTHOR_IOCTL_DEV_QUERY */ struct drm_panthor_dev_query { … }; /** * struct drm_panthor_vm_create - Arguments passed to DRM_PANTHOR_IOCTL_VM_CREATE */ struct drm_panthor_vm_create { … }; /** * struct drm_panthor_vm_destroy - Arguments passed to DRM_PANTHOR_IOCTL_VM_DESTROY */ struct drm_panthor_vm_destroy { … }; /** * enum drm_panthor_vm_bind_op_flags - VM bind operation flags */ enum drm_panthor_vm_bind_op_flags { … }; /** * struct drm_panthor_vm_bind_op - VM bind operation */ struct drm_panthor_vm_bind_op { … }; /** * enum drm_panthor_vm_bind_flags - VM bind flags */ enum drm_panthor_vm_bind_flags { … }; /** * struct drm_panthor_vm_bind - Arguments passed to DRM_IOCTL_PANTHOR_VM_BIND */ struct drm_panthor_vm_bind { … }; /** * enum drm_panthor_vm_state - VM states. */ enum drm_panthor_vm_state { … }; /** * struct drm_panthor_vm_get_state - Get VM state. */ struct drm_panthor_vm_get_state { … }; /** * enum drm_panthor_bo_flags - Buffer object flags, passed at creation time. */ enum drm_panthor_bo_flags { … }; /** * struct drm_panthor_bo_create - Arguments passed to DRM_IOCTL_PANTHOR_BO_CREATE. */ struct drm_panthor_bo_create { … }; /** * struct drm_panthor_bo_mmap_offset - Arguments passed to DRM_IOCTL_PANTHOR_BO_MMAP_OFFSET. */ struct drm_panthor_bo_mmap_offset { … }; /** * struct drm_panthor_queue_create - Queue creation arguments. */ struct drm_panthor_queue_create { … }; /** * enum drm_panthor_group_priority - Scheduling group priority */ enum drm_panthor_group_priority { … }; /** * struct drm_panthor_group_create - Arguments passed to DRM_IOCTL_PANTHOR_GROUP_CREATE */ struct drm_panthor_group_create { … }; /** * struct drm_panthor_group_destroy - Arguments passed to DRM_IOCTL_PANTHOR_GROUP_DESTROY */ struct drm_panthor_group_destroy { … }; /** * struct drm_panthor_queue_submit - Job submission arguments. * * This is describing the userspace command stream to call from the kernel * command stream ring-buffer. Queue submission is always part of a group * submission, taking one or more jobs to submit to the underlying queues. */ struct drm_panthor_queue_submit { … }; /** * struct drm_panthor_group_submit - Arguments passed to DRM_IOCTL_PANTHOR_GROUP_SUBMIT */ struct drm_panthor_group_submit { … }; /** * enum drm_panthor_group_state_flags - Group state flags */ enum drm_panthor_group_state_flags { … }; /** * struct drm_panthor_group_get_state - Arguments passed to DRM_IOCTL_PANTHOR_GROUP_GET_STATE * * Used to query the state of a group and decide whether a new group should be created to * replace it. */ struct drm_panthor_group_get_state { … }; /** * struct drm_panthor_tiler_heap_create - Arguments passed to DRM_IOCTL_PANTHOR_TILER_HEAP_CREATE */ struct drm_panthor_tiler_heap_create { … }; /** * struct drm_panthor_tiler_heap_destroy - Arguments passed to DRM_IOCTL_PANTHOR_TILER_HEAP_DESTROY */ struct drm_panthor_tiler_heap_destroy { … }; #if defined(__cplusplus) } #endif #endif /* _PANTHOR_DRM_H_ */