Skip to content

Commit 63347fe

Browse files
ashutoshxrodrigovivi
authored andcommitted
drm/xe/uapi: Rename xe perf layer as xe observation layer
In Xe, the perf layer allows capture of HW counter streams. These HW counters are generally performance related but don't have to be necessarily so. Also, the name "perf" is a carryover from i915 and is not preferred. Here we propose the name "observation" for this common layer which allows capture of different types of these counter streams. v2: Rename observability layer to observation layer (Lucas/Rodrigo) v3: Rename sysctl file to "observation_paranoid" (Jose) Fixes: 52c2e95 ("drm/xe/perf/uapi: "Perf" layer to support multiple perf counter stream types") Fixes: fe8929b ("drm/xe/perf/uapi: Add perf_stream_paranoid sysctl") Acked-by: Lucas De Marchi <[email protected]> Acked-by: Rodrigo Vivi <[email protected]> Signed-off-by: Ashutosh Dixit <[email protected]> Reviewed-by: Umesh Nerlige Ramappa <[email protected]> Acked-by: José Roberto de Souza <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 8169b20) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent dbf35b4 commit 63347fe

File tree

11 files changed

+190
-187
lines changed

11 files changed

+190
-187
lines changed

drivers/gpu/drm/xe/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ xe-y += xe_bb.o \
9696
xe_mocs.o \
9797
xe_module.o \
9898
xe_oa.o \
99+
xe_observation.o \
99100
xe_pat.o \
100101
xe_pci.o \
101102
xe_pcode.o \
102-
xe_perf.o \
103103
xe_pm.o \
104104
xe_preempt_fence.o \
105105
xe_pt.o \

drivers/gpu/drm/xe/xe_device.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
#include "xe_memirq.h"
4343
#include "xe_mmio.h"
4444
#include "xe_module.h"
45+
#include "xe_observation.h"
4546
#include "xe_pat.h"
4647
#include "xe_pcode.h"
47-
#include "xe_perf.h"
4848
#include "xe_pm.h"
4949
#include "xe_query.h"
5050
#include "xe_sriov.h"
@@ -142,7 +142,7 @@ static const struct drm_ioctl_desc xe_ioctls[] = {
142142
DRM_RENDER_ALLOW),
143143
DRM_IOCTL_DEF_DRV(XE_WAIT_USER_FENCE, xe_wait_user_fence_ioctl,
144144
DRM_RENDER_ALLOW),
145-
DRM_IOCTL_DEF_DRV(XE_PERF, xe_perf_ioctl, DRM_RENDER_ALLOW),
145+
DRM_IOCTL_DEF_DRV(XE_OBSERVATION, xe_observation_ioctl, DRM_RENDER_ALLOW),
146146
};
147147

148148
static long xe_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)

drivers/gpu/drm/xe/xe_device_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ struct xe_device {
463463
/** @heci_gsc: graphics security controller */
464464
struct xe_heci_gsc heci_gsc;
465465

466-
/** @oa: oa perf counter subsystem */
466+
/** @oa: oa observation subsystem */
467467
struct xe_oa oa;
468468

469469
/** @needs_flr_on_fini: requests function-reset on fini */

drivers/gpu/drm/xe/xe_gt_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ struct xe_gt {
389389
u8 instances_per_class[XE_ENGINE_CLASS_MAX];
390390
} user_engines;
391391

392-
/** @oa: oa perf counter subsystem per gt info */
392+
/** @oa: oa observation subsystem per gt info */
393393
struct xe_oa_gt oa;
394394
};
395395

drivers/gpu/drm/xe/xe_module.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "xe_drv.h"
1212
#include "xe_hw_fence.h"
1313
#include "xe_pci.h"
14-
#include "xe_perf.h"
14+
#include "xe_observation.h"
1515
#include "xe_sched_job.h"
1616

1717
struct xe_modparam xe_modparam = {
@@ -80,8 +80,8 @@ static const struct init_funcs init_funcs[] = {
8080
.exit = xe_unregister_pci_driver,
8181
},
8282
{
83-
.init = xe_perf_sysctl_register,
84-
.exit = xe_perf_sysctl_unregister,
83+
.init = xe_observation_sysctl_register,
84+
.exit = xe_observation_sysctl_unregister,
8585
},
8686
};
8787

drivers/gpu/drm/xe/xe_oa.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include "xe_macros.h"
3333
#include "xe_mmio.h"
3434
#include "xe_oa.h"
35-
#include "xe_perf.h"
35+
#include "xe_observation.h"
3636
#include "xe_pm.h"
3737
#include "xe_sched_job.h"
3838
#include "xe_sriov.h"
@@ -481,7 +481,7 @@ static int __xe_oa_read(struct xe_oa_stream *stream, char __user *buf,
481481
OASTATUS_RELEVANT_BITS, 0);
482482
/*
483483
* Signal to userspace that there is non-zero OA status to read via
484-
* @DRM_XE_PERF_IOCTL_STATUS perf fd ioctl
484+
* @DRM_XE_OBSERVATION_IOCTL_STATUS observation stream fd ioctl
485485
*/
486486
if (stream->oa_status & OASTATUS_RELEVANT_BITS)
487487
return -EIO;
@@ -1158,15 +1158,15 @@ static long xe_oa_ioctl_locked(struct xe_oa_stream *stream,
11581158
unsigned long arg)
11591159
{
11601160
switch (cmd) {
1161-
case DRM_XE_PERF_IOCTL_ENABLE:
1161+
case DRM_XE_OBSERVATION_IOCTL_ENABLE:
11621162
return xe_oa_enable_locked(stream);
1163-
case DRM_XE_PERF_IOCTL_DISABLE:
1163+
case DRM_XE_OBSERVATION_IOCTL_DISABLE:
11641164
return xe_oa_disable_locked(stream);
1165-
case DRM_XE_PERF_IOCTL_CONFIG:
1165+
case DRM_XE_OBSERVATION_IOCTL_CONFIG:
11661166
return xe_oa_config_locked(stream, arg);
1167-
case DRM_XE_PERF_IOCTL_STATUS:
1167+
case DRM_XE_OBSERVATION_IOCTL_STATUS:
11681168
return xe_oa_status_locked(stream, arg);
1169-
case DRM_XE_PERF_IOCTL_INFO:
1169+
case DRM_XE_OBSERVATION_IOCTL_INFO:
11701170
return xe_oa_info_locked(stream, arg);
11711171
}
11721172

@@ -1209,7 +1209,7 @@ static int xe_oa_release(struct inode *inode, struct file *file)
12091209
xe_oa_destroy_locked(stream);
12101210
mutex_unlock(&gt->oa.gt_lock);
12111211

1212-
/* Release the reference the perf stream kept on the driver */
1212+
/* Release the reference the OA stream kept on the driver */
12131213
drm_dev_put(&gt_to_xe(gt)->drm);
12141214

12151215
return 0;
@@ -1222,7 +1222,7 @@ static int xe_oa_mmap(struct file *file, struct vm_area_struct *vma)
12221222
unsigned long start = vma->vm_start;
12231223
int i, ret;
12241224

1225-
if (xe_perf_stream_paranoid && !perfmon_capable()) {
1225+
if (xe_observation_paranoid && !perfmon_capable()) {
12261226
drm_dbg(&stream->oa->xe->drm, "Insufficient privilege to map OA buffer\n");
12271227
return -EACCES;
12281228
}
@@ -1789,8 +1789,8 @@ static int xe_oa_user_extensions(struct xe_oa *oa, u64 extension, int ext_number
17891789
* @file: @drm_file
17901790
*
17911791
* The functions opens an OA stream. An OA stream, opened with specified
1792-
* properties, enables perf counter samples to be collected, either
1793-
* periodically (time based sampling), or on request (using perf queries)
1792+
* properties, enables OA counter samples to be collected, either
1793+
* periodically (time based sampling), or on request (using OA queries)
17941794
*/
17951795
int xe_oa_stream_open_ioctl(struct drm_device *dev, u64 data, struct drm_file *file)
17961796
{
@@ -1836,8 +1836,8 @@ int xe_oa_stream_open_ioctl(struct drm_device *dev, u64 data, struct drm_file *f
18361836
privileged_op = true;
18371837
}
18381838

1839-
if (privileged_op && xe_perf_stream_paranoid && !perfmon_capable()) {
1840-
drm_dbg(&oa->xe->drm, "Insufficient privileges to open xe perf stream\n");
1839+
if (privileged_op && xe_observation_paranoid && !perfmon_capable()) {
1840+
drm_dbg(&oa->xe->drm, "Insufficient privileges to open xe OA stream\n");
18411841
ret = -EACCES;
18421842
goto err_exec_q;
18431843
}
@@ -2097,7 +2097,7 @@ int xe_oa_add_config_ioctl(struct drm_device *dev, u64 data, struct drm_file *fi
20972097
return -ENODEV;
20982098
}
20992099

2100-
if (xe_perf_stream_paranoid && !perfmon_capable()) {
2100+
if (xe_observation_paranoid && !perfmon_capable()) {
21012101
drm_dbg(&oa->xe->drm, "Insufficient privileges to add xe OA config\n");
21022102
return -EACCES;
21032103
}
@@ -2181,7 +2181,7 @@ int xe_oa_add_config_ioctl(struct drm_device *dev, u64 data, struct drm_file *fi
21812181
/**
21822182
* xe_oa_remove_config_ioctl - Removes one OA config
21832183
* @dev: @drm_device
2184-
* @data: pointer to struct @drm_xe_perf_param
2184+
* @data: pointer to struct @drm_xe_observation_param
21852185
* @file: @drm_file
21862186
*/
21872187
int xe_oa_remove_config_ioctl(struct drm_device *dev, u64 data, struct drm_file *file)
@@ -2197,7 +2197,7 @@ int xe_oa_remove_config_ioctl(struct drm_device *dev, u64 data, struct drm_file
21972197
return -ENODEV;
21982198
}
21992199

2200-
if (xe_perf_stream_paranoid && !perfmon_capable()) {
2200+
if (xe_observation_paranoid && !perfmon_capable()) {
22012201
drm_dbg(&oa->xe->drm, "Insufficient privileges to remove xe OA config\n");
22022202
return -EACCES;
22032203
}
@@ -2381,7 +2381,7 @@ static int xe_oa_init_gt(struct xe_gt *gt)
23812381

23822382
/*
23832383
* Fused off engines can result in oa_unit's with num_engines == 0. These units
2384-
* will appear in OA unit query, but no perf streams can be opened on them.
2384+
* will appear in OA unit query, but no OA streams can be opened on them.
23852385
*/
23862386
gt->oa.num_oa_units = num_oa_units;
23872387
gt->oa.oa_unit = u;

drivers/gpu/drm/xe/xe_observation.c

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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 <drm/xe_drm.h>
10+
11+
#include "xe_oa.h"
12+
#include "xe_observation.h"
13+
14+
u32 xe_observation_paranoid = true;
15+
static struct ctl_table_header *sysctl_header;
16+
17+
static int xe_oa_ioctl(struct drm_device *dev, struct drm_xe_observation_param *arg,
18+
struct drm_file *file)
19+
{
20+
switch (arg->observation_op) {
21+
case DRM_XE_OBSERVATION_OP_STREAM_OPEN:
22+
return xe_oa_stream_open_ioctl(dev, arg->param, file);
23+
case DRM_XE_OBSERVATION_OP_ADD_CONFIG:
24+
return xe_oa_add_config_ioctl(dev, arg->param, file);
25+
case DRM_XE_OBSERVATION_OP_REMOVE_CONFIG:
26+
return xe_oa_remove_config_ioctl(dev, arg->param, file);
27+
default:
28+
return -EINVAL;
29+
}
30+
}
31+
32+
/**
33+
* xe_observation_ioctl - The top level observation layer ioctl
34+
* @dev: @drm_device
35+
* @data: pointer to struct @drm_xe_observation_param
36+
* @file: @drm_file
37+
*
38+
* The function is called for different observation streams types and
39+
* allows execution of different operations supported by those stream
40+
* types.
41+
*
42+
* Return: 0 on success or a negative error code on failure.
43+
*/
44+
int xe_observation_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
45+
{
46+
struct drm_xe_observation_param *arg = data;
47+
48+
if (arg->extensions)
49+
return -EINVAL;
50+
51+
switch (arg->observation_type) {
52+
case DRM_XE_OBSERVATION_TYPE_OA:
53+
return xe_oa_ioctl(dev, arg, file);
54+
default:
55+
return -EINVAL;
56+
}
57+
}
58+
59+
static struct ctl_table observation_ctl_table[] = {
60+
{
61+
.procname = "observation_paranoid",
62+
.data = &xe_observation_paranoid,
63+
.maxlen = sizeof(xe_observation_paranoid),
64+
.mode = 0644,
65+
.proc_handler = proc_dointvec_minmax,
66+
.extra1 = SYSCTL_ZERO,
67+
.extra2 = SYSCTL_ONE,
68+
},
69+
{}
70+
};
71+
72+
/**
73+
* xe_observation_sysctl_register - Register xe_observation_paranoid sysctl
74+
*
75+
* Normally only superuser/root can access observation stream
76+
* data. However, superuser can set xe_observation_paranoid sysctl to 0 to
77+
* allow non-privileged users to also access observation data.
78+
*
79+
* Return: always returns 0
80+
*/
81+
int xe_observation_sysctl_register(void)
82+
{
83+
sysctl_header = register_sysctl("dev/xe", observation_ctl_table);
84+
return 0;
85+
}
86+
87+
/**
88+
* xe_observation_sysctl_unregister - Unregister xe_observation_paranoid sysctl
89+
*/
90+
void xe_observation_sysctl_unregister(void)
91+
{
92+
unregister_sysctl_table(sysctl_header);
93+
}

drivers/gpu/drm/xe/xe_observation.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* SPDX-License-Identifier: MIT */
2+
/*
3+
* Copyright © 2023-2024 Intel Corporation
4+
*/
5+
6+
#ifndef _XE_OBSERVATION_H_
7+
#define _XE_OBSERVATION_H_
8+
9+
#include <linux/types.h>
10+
11+
struct drm_device;
12+
struct drm_file;
13+
14+
extern u32 xe_observation_paranoid;
15+
16+
int xe_observation_ioctl(struct drm_device *dev, void *data, struct drm_file *file);
17+
int xe_observation_sysctl_register(void);
18+
void xe_observation_sysctl_unregister(void);
19+
20+
#endif

drivers/gpu/drm/xe/xe_perf.c

Lines changed: 0 additions & 92 deletions
This file was deleted.

0 commit comments

Comments
 (0)