This patch adds support for exec_queue set_property ioctl. It is derived from the original work which is part of https://patchwork.freedesktop.org/series/112188/ Currently only DRM_XE_EXEC_QUEUE_SET_PROPERTY_MULTI_QUEUE_PRIORITY property can be dynamically set. v2: Check for and update kernel-doc which property this ioctl supports (Matt Brost)
Unified · Split
| @@ -207,6 +207,8 @@ static const struct drm_ioctl_desc xe_ioctls[] = { · 206 unmodified lines | |||
| 207 | DRM_IOCTL_DEF_DRV(XE_MADVISE, xe_vm_madvise_ioctl, DRM_RENDER_ALLOW), | 207 | DRM_IOCTL_DEF_DRV(XE_MADVISE, xe_vm_madvise_ioctl, DRM_RENDER_ALLOW), |
| 208 | DRM_IOCTL_DEF_DRV(XE_VM_QUERY_MEM_RANGE_ATTRS, xe_vm_query_vmas_attrs_ioctl, | 208 | DRM_IOCTL_DEF_DRV(XE_VM_QUERY_MEM_RANGE_ATTRS, xe_vm_query_vmas_attrs_ioctl, |
| 209 | DRM_RENDER_ALLOW), | 209 | DRM_RENDER_ALLOW), |
| 210 | DRM_IOCTL_DEF_DRV(XE_EXEC_QUEUE_SET_PROPERTY, xe_exec_queue_set_property_ioctl, | ||
| 211 | DRM_RENDER_ALLOW), | ||
| 210 | }; | 212 | }; |
| 211 | 213 | ||
| 212 | static long xe_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 214 | static long xe_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
| @@ -790,6 +790,41 @@ static const xe_exec_queue_set_property_fn exec_queue_set_property_funcs[] = { · 789 unmodified lines | |||
| 790 | exec_queue_set_multi_queue_priority, | 790 | exec_queue_set_multi_queue_priority, |
| 791 | }; | 791 | }; |
| 792 | 792 | ||
| 793 | int xe_exec_queue_set_property_ioctl(struct drm_device *dev, void *data, | ||
| 794 | struct drm_file *file) | ||
| 795 | { | ||
| 796 | struct xe_device *xe = to_xe_device(dev); | ||
| 797 | struct xe_file *xef = to_xe_file(file); | ||
| 798 | struct drm_xe_exec_queue_set_property *args = data; | ||
| 799 | struct xe_exec_queue *q; | ||
| 800 | int ret; | ||
| 801 | u32 idx; | ||
| 802 | |||
| 803 | if (XE_IOCTL_DBG(xe, args->reserved[0] || args->reserved[1])) | ||
| 804 | return -EINVAL; | ||
| 805 | |||
| 806 | if (XE_IOCTL_DBG(xe, args->property != | ||
| 807 | DRM_XE_EXEC_QUEUE_SET_PROPERTY_MULTI_QUEUE_PRIORITY)) | ||
| 808 | return -EINVAL; | ||
| 809 | |||
| 810 | q = xe_exec_queue_lookup(xef, args->exec_queue_id); | ||
| 811 | if (XE_IOCTL_DBG(xe, !q)) | ||
| 812 | return -ENOENT; | ||
| 813 | |||
| 814 | idx = array_index_nospec(args->property, | ||
| 815 | ARRAY_SIZE(exec_queue_set_property_funcs)); | ||
| 816 | ret = exec_queue_set_property_funcs[idx](xe, q, args->value); | ||
| 817 | if (XE_IOCTL_DBG(xe, ret)) | ||
| 818 | goto err_post_lookup; | ||
| 819 | |||
| 820 | xe_exec_queue_put(q); | ||
| 821 | return 0; | ||
| 822 | |||
| 823 | err_post_lookup: | ||
| 824 | xe_exec_queue_put(q); | ||
| 825 | return ret; | ||
| 826 | } | ||
| 827 | |||
| 793 | static int exec_queue_user_ext_check(struct xe_exec_queue *q, u64 properties) | 828 | static int exec_queue_user_ext_check(struct xe_exec_queue *q, u64 properties) |
| 794 | { | 829 | { |
| 795 | u64 secondary_queue_valid_props = BIT_ULL(DRM_XE_EXEC_QUEUE_SET_PROPERTY_MULTI_GROUP) | | 830 | u64 secondary_queue_valid_props = BIT_ULL(DRM_XE_EXEC_QUEUE_SET_PROPERTY_MULTI_GROUP) | |
| @@ -125,6 +125,8 @@ int xe_exec_queue_destroy_ioctl(struct drm_device *dev, void *data, · 124 unmodified lines | |||
| 125 | struct drm_file *file); | 125 | struct drm_file *file); |
| 126 | int xe_exec_queue_get_property_ioctl(struct drm_device *dev, void *data, | 126 | int xe_exec_queue_get_property_ioctl(struct drm_device *dev, void *data, |
| 127 | struct drm_file *file); | 127 | struct drm_file *file); |
| 128 | int xe_exec_queue_set_property_ioctl(struct drm_device *dev, void *data, | ||
| 129 | struct drm_file *file); | ||
| 128 | enum xe_exec_queue_priority xe_exec_queue_device_get_max_priority(struct xe_device *xe); | 130 | enum xe_exec_queue_priority xe_exec_queue_device_get_max_priority(struct xe_device *xe); |
| 129 | 131 | ||
| 130 | void xe_exec_queue_last_fence_put(struct xe_exec_queue *e, struct xe_vm *vm); | 132 | void xe_exec_queue_last_fence_put(struct xe_exec_queue *e, struct xe_vm *vm); |
| @@ -106,6 +106,7 @@ extern "C" { · 105 unmodified lines | |||
| 106 | #define DRM_XE_OBSERVATION 0x0b | 106 | #define DRM_XE_OBSERVATION 0x0b |
| 107 | #define DRM_XE_MADVISE 0x0c | 107 | #define DRM_XE_MADVISE 0x0c |
| 108 | #define DRM_XE_VM_QUERY_MEM_RANGE_ATTRS 0x0d | 108 | #define DRM_XE_VM_QUERY_MEM_RANGE_ATTRS 0x0d |
| 109 | #define DRM_XE_EXEC_QUEUE_SET_PROPERTY 0x0e | ||
| 109 | 110 | ||
| 110 | /* Must be kept compact -- no holes */ | 111 | /* Must be kept compact -- no holes */ |
| 111 | 112 | ||
| @@ -123,6 +124,7 @@ extern "C" { · 11 unmodified lines | |||
| 123 | #define DRM_IOCTL_XE_OBSERVATION DRM_IOW(DRM_COMMAND_BASE + DRM_XE_OBSERVATION, struct drm_xe_observation_param) | 124 | #define DRM_IOCTL_XE_OBSERVATION DRM_IOW(DRM_COMMAND_BASE + DRM_XE_OBSERVATION, struct drm_xe_observation_param) |
| 124 | #define DRM_IOCTL_XE_MADVISE DRM_IOW(DRM_COMMAND_BASE + DRM_XE_MADVISE, struct drm_xe_madvise) | 125 | #define DRM_IOCTL_XE_MADVISE DRM_IOW(DRM_COMMAND_BASE + DRM_XE_MADVISE, struct drm_xe_madvise) |
| 125 | #define DRM_IOCTL_XE_VM_QUERY_MEM_RANGE_ATTRS DRM_IOWR(DRM_COMMAND_BASE + DRM_XE_VM_QUERY_MEM_RANGE_ATTRS, struct drm_xe_vm_query_mem_range_attr) | 126 | #define DRM_IOCTL_XE_VM_QUERY_MEM_RANGE_ATTRS DRM_IOWR(DRM_COMMAND_BASE + DRM_XE_VM_QUERY_MEM_RANGE_ATTRS, struct drm_xe_vm_query_mem_range_attr) |
| 127 | #define DRM_IOCTL_XE_EXEC_QUEUE_SET_PROPERTY DRM_IOW(DRM_COMMAND_BASE + DRM_XE_EXEC_QUEUE_SET_PROPERTY, struct drm_xe_exec_queue_set_property) | ||
| 126 | 128 | ||
| 127 | /** | 129 | /** |
| 128 | * DOC: Xe IOCTL Extensions | 130 | * DOC: Xe IOCTL Extensions |
| @@ -2315,6 +2317,30 @@ struct drm_xe_vm_query_mem_range_attr { · 2186 unmodified lines | |||
| 2315 | 2317 | ||
| 2316 | }; | 2318 | }; |
| 2317 | 2319 | ||
| 2320 | /** | ||
| 2321 | * struct drm_xe_exec_queue_set_property - exec queue set property | ||
| 2322 | * | ||
| 2323 | * Sets execution queue properties dynamically. | ||
| 2324 | * Currently only %DRM_XE_EXEC_QUEUE_SET_PROPERTY_MULTI_QUEUE_PRIORITY | ||
| 2325 | * property can be dynamically set. | ||
| 2326 | */ | ||
| 2327 | struct drm_xe_exec_queue_set_property { | ||
| 2328 | /** @extensions: Pointer to the first extension struct, if any */ | ||
| 2329 | __u64 extensions; | ||
| 2330 | |||
| 2331 | /** @exec_queue_id: Exec queue ID */ | ||
| 2332 | __u32 exec_queue_id; | ||
| 2333 | |||
| 2334 | /** @property: property to set */ | ||
| 2335 | __u32 property; | ||
| 2336 | |||
| 2337 | /** @value: property value */ | ||
| 2338 | __u64 value; | ||
| 2339 | |||
| 2340 | /** @reserved: Reserved */ | ||
| 2341 | __u64 reserved[2]; | ||
| 2342 | }; | ||
| 2343 | |||
| 2318 | #if defined(__cplusplus) | 2344 | #if defined(__cplusplus) |
| 2319 | } | 2345 | } |
| 2320 | #endif | 2346 | #endif |