[PATCH 5/6] drm/amdgpu: add user friendly xgmi events
Jonathan Kim
jonathan.kim at amd.com
Thu Sep 3 16:21:53 UTC 2020
Non-outbound data is useless for throughput metrics. Add human readable
events and note deprecated events. New events are now per-device and not
per-device-per-ip.
Signed-off-by: Jonathan Kim <Jonathan.Kim at amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c | 38 +++++++++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.h | 1 +
2 files changed, 39 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c
index 517448aa2d50..eaa44c99d423 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c
@@ -31,6 +31,7 @@
#define PMU_NAME_SIZE 32
#define NUM_FORMATS_DF_VEGA20 3
#define NUM_EVENTS_DF_VEGA20 8
+#define NUM_EVENTS_XGMI_VEGA20 2
/* record to keep track of pmu entry per pmu type per device */
struct amdgpu_pmu_entry {
@@ -52,18 +53,33 @@ static struct attribute_group df_vega20_event_attr_group = {
.attrs = NULL
};
+static struct attribute_group xgmi_vega20_event_attr_group = {
+ .name = "events",
+ .attrs = NULL
+};
+
const struct attribute_group *df_vega20_attr_groups[] = {
&df_vega20_format_attr_group,
&df_vega20_event_attr_group,
NULL
};
+const struct attribute_group *xgmi_vega20_attr_groups[] = {
+ &df_vega20_format_attr_group,
+ &xgmi_vega20_event_attr_group,
+ NULL
+};
+
static const char *df_vega20_formats[NUM_FORMATS_DF_VEGA20][2] = {
{ "event", "config:0-7" },
{ "instance", "config:8-15" },
{ "umask", "config:16-23"}
};
+/*
+ * DF events for xGMI - DEPRECATED.
+ * Potential for non-xgmi DF counters in the future.
+ */
static const char *df_vega20_events[NUM_EVENTS_DF_VEGA20][2] = {
{ "cake0_pcsout_txdata", "event=0x7,instance=0x46,umask=0x2" },
{ "cake1_pcsout_txdata", "event=0x7,instance=0x47,umask=0x2" },
@@ -75,6 +91,11 @@ static const char *df_vega20_events[NUM_EVENTS_DF_VEGA20][2] = {
{ "cake1_ftiinstat_rspalloc", "event=0xb,instance=0x47,umask=0x8" },
};
+static const char *xgmi_vega20_events[NUM_EVENTS_XGMI_VEGA20][2] = {
+ { "xgmi_link0_data_outbound", "event=0x7,instance=0x46,umask=0x2" },
+ { "xgmi_link1_data_outbound", "event=0x7,instance=0x47,umask=0x2" }
+};
+
/* initialize perf counter */
static int amdgpu_perf_event_init(struct perf_event *event)
{
@@ -106,6 +127,7 @@ static void amdgpu_perf_start(struct perf_event *event, int flags)
switch (pe->pmu_perf_type) {
case PERF_TYPE_AMDGPU_DF:
+ case PERF_TYPE_AMDGPU_XGMI:
if (!(flags & PERF_EF_RELOAD))
pe->adev->df.funcs->pmc_start(pe->adev, hwc->config,
hwc->idx, 1);
@@ -136,6 +158,7 @@ static void amdgpu_perf_read(struct perf_event *event)
switch (pe->pmu_perf_type) {
case PERF_TYPE_AMDGPU_DF:
+ case PERF_TYPE_AMDGPU_XGMI:
pe->adev->df.funcs->pmc_get_count(pe->adev,
hwc->config, hwc->idx, &count);
break;
@@ -161,6 +184,7 @@ static void amdgpu_perf_stop(struct perf_event *event, int flags)
switch (pe->pmu_perf_type) {
case PERF_TYPE_AMDGPU_DF:
+ case PERF_TYPE_AMDGPU_XGMI:
pe->adev->df.funcs->pmc_stop(pe->adev, hwc->config, hwc->idx,
0);
break;
@@ -192,6 +216,7 @@ static int amdgpu_perf_add(struct perf_event *event, int flags)
switch (pe->pmu_perf_type) {
case PERF_TYPE_AMDGPU_DF:
+ case PERF_TYPE_AMDGPU_XGMI:
retval = pe->adev->df.funcs->pmc_start(pe->adev,
hwc->config, hwc->idx, 1);
if (retval >= 0) {
@@ -226,6 +251,7 @@ static void amdgpu_perf_del(struct perf_event *event, int flags)
switch (pe->pmu_perf_type) {
case PERF_TYPE_AMDGPU_DF:
+ case PERF_TYPE_AMDGPU_XGMI:
pe->adev->df.funcs->pmc_stop(pe->adev, hwc->config, hwc->idx,
1);
break;
@@ -346,6 +372,18 @@ int amdgpu_pmu_init(struct amdgpu_device *adev)
df_vega20_events,
&df_vega20_event_attr_group,
NUM_EVENTS_DF_VEGA20);
+ if (ret)
+ break;
+
+ /* init xgmi */
+ ret = init_pmu_by_type(adev, xgmi_vega20_attr_groups,
+ "XGMI", "amdgpu", PERF_TYPE_AMDGPU_XGMI,
+ df_vega20_formats,
+ &df_vega20_format_attr_group,
+ NUM_FORMATS_DF_VEGA20,
+ xgmi_vega20_events,
+ &xgmi_vega20_event_attr_group,
+ NUM_EVENTS_XGMI_VEGA20);
/* other pmu types go here*/
break;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.h
index 7dddb7160a11..2f1a80c42dbf 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.h
@@ -28,6 +28,7 @@
enum amdgpu_pmu_perf_type {
PERF_TYPE_AMDGPU_DF = 0,
+ PERF_TYPE_AMDGPU_XGMI,
PERF_TYPE_AMDGPU_MAX
};
--
2.17.1
More information about the amd-gfx
mailing list