Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v6.16-rc4 106 lines 2.8 kB view raw
1// SPDX-License-Identifier: MIT 2/* 3 * Copyright © 2023-2024 Intel Corporation 4 */ 5 6#include <linux/errno.h> 7#include <linux/sysctl.h> 8 9#include <uapi/drm/xe_drm.h> 10 11#include "xe_eu_stall.h" 12#include "xe_oa.h" 13#include "xe_observation.h" 14 15u32 xe_observation_paranoid = true; 16static struct ctl_table_header *sysctl_header; 17 18static int xe_oa_ioctl(struct drm_device *dev, struct drm_xe_observation_param *arg, 19 struct drm_file *file) 20{ 21 switch (arg->observation_op) { 22 case DRM_XE_OBSERVATION_OP_STREAM_OPEN: 23 return xe_oa_stream_open_ioctl(dev, arg->param, file); 24 case DRM_XE_OBSERVATION_OP_ADD_CONFIG: 25 return xe_oa_add_config_ioctl(dev, arg->param, file); 26 case DRM_XE_OBSERVATION_OP_REMOVE_CONFIG: 27 return xe_oa_remove_config_ioctl(dev, arg->param, file); 28 default: 29 return -EINVAL; 30 } 31} 32 33static int xe_eu_stall_ioctl(struct drm_device *dev, struct drm_xe_observation_param *arg, 34 struct drm_file *file) 35{ 36 switch (arg->observation_op) { 37 case DRM_XE_OBSERVATION_OP_STREAM_OPEN: 38 return xe_eu_stall_stream_open(dev, arg->param, file); 39 default: 40 return -EINVAL; 41 } 42} 43 44/** 45 * xe_observation_ioctl - The top level observation layer ioctl 46 * @dev: @drm_device 47 * @data: pointer to struct @drm_xe_observation_param 48 * @file: @drm_file 49 * 50 * The function is called for different observation streams types and 51 * allows execution of different operations supported by those stream 52 * types. 53 * 54 * Return: 0 on success or a negative error code on failure. 55 */ 56int xe_observation_ioctl(struct drm_device *dev, void *data, struct drm_file *file) 57{ 58 struct drm_xe_observation_param *arg = data; 59 60 if (arg->extensions) 61 return -EINVAL; 62 63 switch (arg->observation_type) { 64 case DRM_XE_OBSERVATION_TYPE_OA: 65 return xe_oa_ioctl(dev, arg, file); 66 case DRM_XE_OBSERVATION_TYPE_EU_STALL: 67 return xe_eu_stall_ioctl(dev, arg, file); 68 default: 69 return -EINVAL; 70 } 71} 72 73static const struct ctl_table observation_ctl_table[] = { 74 { 75 .procname = "observation_paranoid", 76 .data = &xe_observation_paranoid, 77 .maxlen = sizeof(xe_observation_paranoid), 78 .mode = 0644, 79 .proc_handler = proc_dointvec_minmax, 80 .extra1 = SYSCTL_ZERO, 81 .extra2 = SYSCTL_ONE, 82 }, 83}; 84 85/** 86 * xe_observation_sysctl_register - Register xe_observation_paranoid sysctl 87 * 88 * Normally only superuser/root can access observation stream 89 * data. However, superuser can set xe_observation_paranoid sysctl to 0 to 90 * allow non-privileged users to also access observation data. 91 * 92 * Return: always returns 0 93 */ 94int xe_observation_sysctl_register(void) 95{ 96 sysctl_header = register_sysctl("dev/xe", observation_ctl_table); 97 return 0; 98} 99 100/** 101 * xe_observation_sysctl_unregister - Unregister xe_observation_paranoid sysctl 102 */ 103void xe_observation_sysctl_unregister(void) 104{ 105 unregister_sysctl_table(sysctl_header); 106}