[PATCH 03/17] drm/xe/oa/uapi: Add oa_max_sample_rate sysctl
Umesh Nerlige Ramappa
umesh.nerlige.ramappa at intel.com
Thu Dec 14 00:58:52 UTC 2023
On Thu, Dec 07, 2023 at 10:43:15PM -0800, Ashutosh Dixit wrote:
>Introduce oa_max_sample_rate sysctl to set a max limit on the frequency of
>periodic OA reports.
>
>Signed-off-by: Ashutosh Dixit <ashutosh.dixit at intel.com>
>---
> drivers/gpu/drm/xe/Makefile | 1 +
> drivers/gpu/drm/xe/xe_device.c | 7 +++++
> drivers/gpu/drm/xe/xe_module.c | 5 ++++
> drivers/gpu/drm/xe/xe_oa.c | 49 ++++++++++++++++++++++++++++++++++
> drivers/gpu/drm/xe/xe_oa.h | 16 +++++++++++
> 5 files changed, 78 insertions(+)
> create mode 100644 drivers/gpu/drm/xe/xe_oa.c
> create mode 100644 drivers/gpu/drm/xe/xe_oa.h
>
>diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
>index b719953d9d30f..cf7e0e5261f73 100644
>--- a/drivers/gpu/drm/xe/Makefile
>+++ b/drivers/gpu/drm/xe/Makefile
>@@ -98,6 +98,7 @@ xe-y += xe_bb.o \
> xe_mmio.o \
> xe_mocs.o \
> xe_module.o \
>+ xe_oa.o \
> xe_pat.o \
> xe_pci.o \
> xe_pcode.o \
>diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
>index 35616d1a81a31..744d573eb2720 100644
>--- a/drivers/gpu/drm/xe/xe_device.c
>+++ b/drivers/gpu/drm/xe/xe_device.c
>@@ -29,6 +29,7 @@
> #include "xe_irq.h"
> #include "xe_mmio.h"
> #include "xe_module.h"
>+#include "xe_oa.h"
> #include "xe_pat.h"
> #include "xe_pcode.h"
> #include "xe_perf.h"
>@@ -480,6 +481,10 @@ int xe_device_probe(struct xe_device *xe)
>
> xe_heci_gsc_init(xe);
>
>+ err = xe_oa_init(xe);
>+ if (err)
>+ goto err_irq_shutdown;
>+
> err = xe_display_init(xe);
> if (err)
> goto err_irq_shutdown;
^ this needs to do an xe_oa_fini on failure, so should be a
different/new goto label.
Umesh
>@@ -526,6 +531,8 @@ void xe_device_remove(struct xe_device *xe)
>
> xe_display_fini(xe);
>
>+ xe_oa_fini(xe);
>+
> xe_heci_gsc_fini(xe);
>
> xe_irq_shutdown(xe);
>diff --git a/drivers/gpu/drm/xe/xe_module.c b/drivers/gpu/drm/xe/xe_module.c
>index 8629330d928b0..176d3e6ec8464 100644
>--- a/drivers/gpu/drm/xe/xe_module.c
>+++ b/drivers/gpu/drm/xe/xe_module.c
>@@ -10,6 +10,7 @@
>
> #include "xe_drv.h"
> #include "xe_hw_fence.h"
>+#include "xe_oa.h"
> #include "xe_pci.h"
> #include "xe_perf.h"
> #include "xe_pmu.h"
>@@ -76,6 +77,10 @@ static const struct init_funcs init_funcs[] = {
> .init = xe_perf_sysctl_register,
> .exit = xe_perf_sysctl_unregister,
> },
>+ {
>+ .init = xe_oa_sysctl_register,
>+ .exit = xe_oa_sysctl_unregister,
>+ },
> };
>
> static int __init xe_init(void)
>diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
>new file mode 100644
>index 0000000000000..f4cacb4af47c5
>--- /dev/null
>+++ b/drivers/gpu/drm/xe/xe_oa.c
>@@ -0,0 +1,49 @@
>+// SPDX-License-Identifier: MIT
>+/*
>+ * Copyright © 2023 Intel Corporation
>+ */
>+
>+#include <linux/sysctl.h>
>+
>+#include "xe_device.h"
>+#include "xe_oa.h"
>+
>+static int xe_oa_sample_rate_hard_limit;
>+static u32 xe_oa_max_sample_rate = 100000;
>+
>+static struct ctl_table_header *sysctl_header;
>+
>+int xe_oa_init(struct xe_device *xe)
>+{
>+ /* Choose a representative limit */
>+ xe_oa_sample_rate_hard_limit = xe_root_mmio_gt(xe)->info.reference_clock / 2;
>+ return 0;
>+}
>+
>+void xe_oa_fini(struct xe_device *xe)
>+{
>+}
>+
>+static struct ctl_table oa_ctl_table[] = {
>+ {
>+ .procname = "oa_max_sample_rate",
>+ .data = &xe_oa_max_sample_rate,
>+ .maxlen = sizeof(xe_oa_max_sample_rate),
>+ .mode = 0644,
>+ .proc_handler = proc_dointvec_minmax,
>+ .extra1 = SYSCTL_ZERO,
>+ .extra2 = &xe_oa_sample_rate_hard_limit,
>+ },
>+ {}
>+};
>+
>+int xe_oa_sysctl_register(void)
>+{
>+ sysctl_header = register_sysctl("dev/xe", oa_ctl_table);
>+ return 0;
>+}
>+
>+void xe_oa_sysctl_unregister(void)
>+{
>+ unregister_sysctl_table(sysctl_header);
>+}
>diff --git a/drivers/gpu/drm/xe/xe_oa.h b/drivers/gpu/drm/xe/xe_oa.h
>new file mode 100644
>index 0000000000000..1b81330c9708b
>--- /dev/null
>+++ b/drivers/gpu/drm/xe/xe_oa.h
>@@ -0,0 +1,16 @@
>+/* SPDX-License-Identifier: MIT */
>+/*
>+ * Copyright © 2023 Intel Corporation
>+ */
>+
>+#ifndef _XE_OA_H_
>+#define _XE_OA_H_
>+
>+struct xe_device;
>+
>+int xe_oa_init(struct xe_device *xe);
>+void xe_oa_fini(struct xe_device *xe);
>+int xe_oa_sysctl_register(void);
>+void xe_oa_sysctl_unregister(void);
>+
>+#endif
>--
>2.41.0
>
More information about the Intel-xe
mailing list