drm/amdgpu: fix xgmi perfmon a-b-a problem
Subsystems (2)
PATCH 1/3 drm/amdgpu: fix xgmi perfmon a-b-a problem
Mapping hw counters per event config will cause ABA problems so map per event instead.
v2: Discontinue starting perf counters if add fails. Make it clear what's happening with pmc_start.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_df.h | 6 +- drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c | 42 ++++++---- drivers/gpu/drm/amd/amdgpu/df_v3_6.c | 105 +++++++++++------------- 3 files changed, 78 insertions(+), 75 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_df.h +3 -3
@@ -44,11 +44,11 @@ struct amdgpu_df_funcs {void (*enable_ecc_force_par_wr_rmw)(struct amdgpu_device *adev,bool enable);int (*pmc_start)(struct amdgpu_device *adev,uint64_t config, -int is_add); +int counter_idx,int is_add);int (*pmc_stop)(struct amdgpu_device *adev,uint64_t config, -int is_remove); +int counter_idx,int is_remove);void (*pmc_get_count)(struct amdgpu_device *adev,uint64_t config, -uint64_t *count); +int counter_idx,uint64_t *count);uint64_t (*get_fica)(struct amdgpu_device *adev,uint32_t ficaa_val);void (*set_fica)(struct amdgpu_device *adev,uint32_t ficaa_val,uint32_t ficadl_val,uint32_t ficadh_val);
drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c +28 -14
100 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/df_v3_6.c +47 -58
252 lines not on this page · raw message
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/3 drm/amdgpu: add per device user friendly xgmi events for vega20
Non-outbound data metrics are non useful so mark them as legacy. Bucket new perf counters into device and not device ip.
Bind events to chip instead of IP.
Report available event counters and not number of hw counter banks. Move DF public macros to private since not needed outside of IP version.
v5: cleanup by moving per chip configs into structs
v4: After more discussion, replace *_LEGACY references with IP references to indicate concept of pmu-typed versus event-config-typed event registration.
v3: attr groups const array is global but attr groups are allocated per device which doesn't work and causes problems on memory allocation and de-allocation for pmu unregister. Switch to building const attr groups per pmu instead to simplify solution.
v2: add comments on sysfs structure and formatting.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 13 - drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c | 432 ++++++++++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.h | 26 +- drivers/gpu/drm/amd/amdgpu/df_v3_6.c | 72 +--- drivers/gpu/drm/amd/amdgpu/df_v3_6.h | 9 - 5 files changed, 408 insertions(+), 144 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -13
@@ -1279,19 +1279,6 @@ bool amdgpu_device_load_pci_state(struct pci_dev *pdev);#include "amdgpu_object.h" -/* used by df_v3_6.c and amdgpu_pmu.c */ -#define AMDGPU_PMU_ATTR (_name, _object) \ -static ssize_t \ -_name##_show(struct device *dev, \ - struct device_attribute *attr, \ - char *page) \ -{ \ - BUILD_BUG_ON(sizeof(_object) >= PAGE_SIZE - 1); \ - return sprintf(page, _object "\n"); \ -} \ - \ -static struct device_attribute pmu_attr_##_name = __ATTR_RO(_name) -static inline bool amdgpu_is_tmz (struct amdgpu_device *adev) {return adev->gmc.tmz_enabled;
drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c +375 -57
533 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.h +24 -2
@@ -26,11 +26,33 @@#ifndef _AMDGPU_PMU_H_#define _AMDGPU_PMU_H_ +/* PMU types. */ enum amdgpu_pmu_perf_type { -PERF_TYPE_AMDGPU_DF =0 , -PERF_TYPE_AMDGPU_MAX +AMDGPU_PMU_PERF_TYPE_NONE =0 , +AMDGPU_PMU_PERF_TYPE_DF , +AMDGPU_PMU_PERF_TYPE_ALL }; +/* +* PMU type AMDGPU_PMU_PERF_TYPE_ALL can hold events of different "type" +* configurations. Event config types are parsed from the 64-bit raw +* config (See EVENT_CONFIG_TYPE_SHIFT and EVENT_CONFIG_TYPE_MASK) and +* are registered into the HW perf events config_base. +* +* PMU types with only a single event configuration type +* (non-AMDGPU_PMU_PERF_TYPE_ALL) have their event config type auto generated +* when the performance counter is added. +*/ +enum amdgpu_pmu_event_config_type { +AMDGPU_PMU_EVENT_CONFIG_TYPE_NONE =0 , +AMDGPU_PMU_EVENT_CONFIG_TYPE_DF , +AMDGPU_PMU_EVENT_CONFIG_TYPE_XGMI , +AMDGPU_PMU_EVENT_CONFIG_TYPE_MAX +}; + +#define AMDGPU_PMU_EVENT_CONFIG_TYPE_SHIFT 56 +#define AMDGPU_PMU_EVENT_CONFIG_TYPE_MASK 0xff +int amdgpu_pmu_init (struct amdgpu_device *adev);void amdgpu_pmu_fini (struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/df_v3_6.c +9 -63
80 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/df_v3_6.h +0 -9
@@ -35,15 +35,6 @@ enum DF_V3_6_MGCG { DF_V3_6_MGCG_ENABLE_63_CYCLE_DELAY = 15 }; -/* Defined in global_features.h as FTI_PERFMON_VISIBLE */ -#define DF_V3_6_MAX_COUNTERS 4 - -/* get flags from df perfmon config */ -#define DF_V3_6_GET_EVENT (x) (x & 0xFFUL) -#define DF_V3_6_GET_INSTANCE (x) ((x >> 8) & 0xFFUL) -#define DF_V3_6_GET_UNITMASK (x) ((x >> 16) & 0xFFUL) -#define DF_V3_6_PERFMON_OVERFLOW 0xFFFFFFFFFFFFULL -extern const struct attribute_group *df_v3_6_attr_groups[];extern const struct amdgpu_df_funcs df_v3_6_funcs;
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/3 drm/amdgpu: add xgmi perfmons for arcturus
In reply to Jonathan KimAdd xgmi perfmons for Arcturus.
v4: Align with patch 2 with struct improvements
v3: Align with patch 2 streamlining perf types versus event config types.
v2: Resend for re-review with alignment for v3 in patch 2.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c | 49 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/df_v3_6.c | 3 ++ 2 files changed, 52 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c +49 -0
@@ -35,6 +35,9 @@#define NUM_EVENT_TYPES_VEGA20 1#define NUM_EVENTS_VEGA20_XGMI 2#define NUM_EVENTS_VEGA20_MAX NUM_EVENTS_VEGA20_XGMI +#define NUM_EVENT_TYPES_ARCTURUS 1 +#define NUM_EVENTS_ARCTURUS_XGMI 6 +#define NUM_EVENTS_ARCTURUS_MAX NUM_EVENTS_ARCTURUS_XGMIstruct amdgpu_pmu_event_attribute {struct device_attribute attr;
@@ -174,6 +177,36 @@ static struct amdgpu_pmu_config df_vega20_config = { .num_types = 0 }; +/* Arcturus events */ +static struct amdgpu_pmu_attr arcturus_events[NUM_EVENTS_ARCTURUS_MAX ] = { + { .name ="xgmi_link0_data_outbound" , + .config ="event=0x7,instance=0x4b,umask=0x2" }, + { .name ="xgmi_link1_data_outbound" , + .config ="event=0x7,instance=0x4c,umask=0x2" }, + { .name ="xgmi_link2_data_outbound" , + .config ="event=0x7,instance=0x4d,umask=0x2" }, + { .name ="xgmi_link3_data_outbound" , + .config ="event=0x7,instance=0x4e,umask=0x2" }, + { .name ="xgmi_link4_data_outbound" , + .config ="event=0x7,instance=0x4f,umask=0x2" }, + { .name ="xgmi_link5_data_outbound" , + .config ="event=0x7,instance=0x50,umask=0x2" } +}; + +static struct amdgpu_pmu_type arcturus_types[NUM_EVENT_TYPES_ARCTURUS ] = { + { .type =AMDGPU_PMU_EVENT_CONFIG_TYPE_XGMI , + .num_of_type =NUM_EVENTS_ARCTURUS_XGMI } +}; + +static struct amdgpu_pmu_config arcturus_config = { + .formats = amdgpu_pmu_formats, + .num_formats =ARRAY_SIZE (amdgpu_pmu_formats), + .events = arcturus_events, + .num_events =ARRAY_SIZE (arcturus_events), + .types = arcturus_types, + .num_types =ARRAY_SIZE (arcturus_types) +}; +/* initialize perf counter */ static int amdgpu_perf_event_init (struct perf_event *event) {
@@ -605,6 +638,22 @@ int amdgpu_pmu_init(struct amdgpu_device *adev) }break ; +case CHIP_ARCTURUS : + pmu_entry =create_pmu_entry (adev,AMDGPU_PMU_PERF_TYPE_ALL , +"" ,"amdgpu" ); +if (!pmu_entry) +return -ENOMEM ; + + ret =init_pmu_entry_by_type_and_add (pmu_entry, + &arcturus_config); + +if (ret) { +kfree (pmu_entry); +return -ENOMEM ; + } + +break ; +default :return 0 ; };
drivers/gpu/drm/amd/amdgpu/df_v3_6.c +3 -0
@@ -513,6 +513,7 @@ static int df_v3_6_pmc_start(struct amdgpu_device *adev, uint64_t config,switch (adev->asic_type) {case CHIP_VEGA20 : +case CHIP_ARCTURUS :if (is_add)return df_v3_6_pmc_add_cntr (adev, config);
@@ -554,6 +555,7 @@ static int df_v3_6_pmc_stop(struct amdgpu_device *adev, uint64_t config,switch (adev->asic_type) {case CHIP_VEGA20 : +case CHIP_ARCTURUS : ret = df_v3_6_pmc_get_ctrl_settings(adev, config, counter_idx,
@@ -590,6 +592,7 @@ static void df_v3_6_pmc_get_count(struct amdgpu_device *adev,switch (adev->asic_type) {case CHIP_VEGA20 : +case CHIP_ARCTURUS :df_v3_6_pmc_get_read_settings (adev, config, counter_idx, &lo_base_addr, &hi_base_addr);
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH 3/3] drm/amdgpu: add xgmi perfmons for arcturus
[AMD Official Use Only - Internal Distribution Only]
This series Acked-by: Harish Kasiviswanathan <[email protected]>
-----Original Message-----
From: Kim, Jonathan <[email protected]>
Sent: Friday, October 2, 2020 4:19 PM
To: [email protected]
Cc: Kasiviswanathan, Harish <[email protected]>; Kim, Jonathan <[email protected]>
Subject: [PATCH 3/3] drm/amdgpu: add xgmi perfmons for arcturus
Add xgmi perfmons for Arcturus.
v4: Align with patch 2 with struct improvements
v3: Align with patch 2 streamlining perf types versus event config types.
v2: Resend for re-review with alignment for v3 in patch 2.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c | 49 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/df_v3_6.c | 3 ++ 2 files changed, 52 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c +30 -0
@@ -35,6 +35,9 @@#define NUM_EVENT_TYPES_VEGA20 1#define NUM_EVENTS_VEGA20_XGMI 2#define NUM_EVENTS_VEGA20_MAX NUM_EVENTS_VEGA20_XGMI +#define NUM_EVENT_TYPES_ARCTURUS 1 +#define NUM_EVENTS_ARCTURUS_XGMI 6 +#define NUM_EVENTS_ARCTURUS_MAX NUM_EVENTS_ARCTURUS_XGMIstruct amdgpu_pmu_event_attribute {struct device_attribute attr;
@@ -174,6 +177,36 @@ static struct amdgpu_pmu_config df_vega20_config = { .num_types = 0 }; +/* Arcturus events */ +static struct amdgpu_pmu_attr arcturus_events[NUM_EVENTS_ARCTURUS_MAX ] = { + { .name ="xgmi_link0_data_outbound" , + .config ="event=0x7,instance=0x4b,umask=0x2" }, + { .name ="xgmi_link1_data_outbound" , + .config ="event=0x7,instance=0x4c,umask=0x2" }, + { .name ="xgmi_link2_data_outbound" , + .config ="event=0x7,instance=0x4d,umask=0x2" }, + { .name ="xgmi_link3_data_outbound" , + .config ="event=0x7,instance=0x4e,umask=0x2" }, + { .name ="xgmi_link4_data_outbound" , + .config ="event=0x7,instance=0x4f,umask=0x2" }, + { .name ="xgmi_link5_data_outbound" , + .config ="event=0x7,instance=0x50,umask=0x2" } }; + +static struct amdgpu_pmu_type arcturus_types[NUM_EVENT_TYPES_ARCTURUS ] = { + { .type =AMDGPU_PMU_EVENT_CONFIG_TYPE_XGMI , + .num_of_type =NUM_EVENTS_ARCTURUS_XGMI } }; + +static struct amdgpu_pmu_config arcturus_config = { + .formats = amdgpu_pmu_formats, + .num_formats =ARRAY_SIZE (amdgpu_pmu_formats), + .events = arcturus_events, + .num_events =ARRAY_SIZE (arcturus_events), + .types = arcturus_types, + .num_types =ARRAY_SIZE (arcturus_types) }; +/* initialize perf counter */ static int amdgpu_perf_event_init(struct perf_event *event) { @@ -605,6 +638,22 @@ int amdgpu_pmu_init(struct amdgpu_device *adev) }
break;
+ case CHIP_ARCTURUS:
+ pmu_entry = create_pmu_entry(adev, AMDGPU_PMU_PERF_TYPE_ALL,
+ "", "amdgpu");
+ if (!pmu_entry)
+ return -ENOMEM;
+
+ ret = init_pmu_entry_by_type_and_add(pmu_entry,
+ &arcturus_config);
+
+ if (ret) {
+ kfree(pmu_entry);
+ return -ENOMEM;
+ }
+
+ break;
+
default:
return 0;
};
drivers/gpu/drm/amd/amdgpu/df_v3_6.c +3 -0
@@ -513,6 +513,7 @@ static int df_v3_6_pmc_start(struct amdgpu_device *adev, uint64_t config,switch (adev->asic_type) {case CHIP_VEGA20 : +case CHIP_ARCTURUS :if (is_add)return df_v3_6_pmc_add_cntr (adev, config);
@@ -554,6 +555,7 @@ static int df_v3_6_pmc_stop(struct amdgpu_device *adev, uint64_t config,switch (adev->asic_type) {case CHIP_VEGA20 : +case CHIP_ARCTURUS : ret = df_v3_6_pmc_get_ctrl_settings(adev, config, counter_idx,
@@ -590,6 +592,7 @@ static void df_v3_6_pmc_get_count(struct amdgpu_device *adev,switch (adev->asic_type) {case CHIP_VEGA20 : +case CHIP_ARCTURUS :df_v3_6_pmc_get_read_settings (adev, config, counter_idx, &lo_base_addr, &hi_base_addr);
--
2.17.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH 3/3] drm/amdgpu: add xgmi perfmons for arcturus
In reply to Jonathan Kim[AMD Official Use Only - Internal Distribution Only]
This patch series Reviewed-By: Harish Kasiviswanathan <[email protected]>
-----Original Message-----
From: Kim, Jonathan <[email protected]>
Sent: Friday, October 2, 2020 4:19 PM
To: [email protected]
Cc: Kasiviswanathan, Harish <[email protected]>; Kim, Jonathan <[email protected]>
Subject: [PATCH 3/3] drm/amdgpu: add xgmi perfmons for arcturus
Add xgmi perfmons for Arcturus.
v4: Align with patch 2 with struct improvements
v3: Align with patch 2 streamlining perf types versus event config types.
v2: Resend for re-review with alignment for v3 in patch 2.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c | 49 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/df_v3_6.c | 3 ++ 2 files changed, 52 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c +30 -0
@@ -35,6 +35,9 @@#define NUM_EVENT_TYPES_VEGA20 1#define NUM_EVENTS_VEGA20_XGMI 2#define NUM_EVENTS_VEGA20_MAX NUM_EVENTS_VEGA20_XGMI +#define NUM_EVENT_TYPES_ARCTURUS 1 +#define NUM_EVENTS_ARCTURUS_XGMI 6 +#define NUM_EVENTS_ARCTURUS_MAX NUM_EVENTS_ARCTURUS_XGMIstruct amdgpu_pmu_event_attribute {struct device_attribute attr;
@@ -174,6 +177,36 @@ static struct amdgpu_pmu_config df_vega20_config = { .num_types = 0 }; +/* Arcturus events */ +static struct amdgpu_pmu_attr arcturus_events[NUM_EVENTS_ARCTURUS_MAX ] = { + { .name ="xgmi_link0_data_outbound" , + .config ="event=0x7,instance=0x4b,umask=0x2" }, + { .name ="xgmi_link1_data_outbound" , + .config ="event=0x7,instance=0x4c,umask=0x2" }, + { .name ="xgmi_link2_data_outbound" , + .config ="event=0x7,instance=0x4d,umask=0x2" }, + { .name ="xgmi_link3_data_outbound" , + .config ="event=0x7,instance=0x4e,umask=0x2" }, + { .name ="xgmi_link4_data_outbound" , + .config ="event=0x7,instance=0x4f,umask=0x2" }, + { .name ="xgmi_link5_data_outbound" , + .config ="event=0x7,instance=0x50,umask=0x2" } }; + +static struct amdgpu_pmu_type arcturus_types[NUM_EVENT_TYPES_ARCTURUS ] = { + { .type =AMDGPU_PMU_EVENT_CONFIG_TYPE_XGMI , + .num_of_type =NUM_EVENTS_ARCTURUS_XGMI } }; + +static struct amdgpu_pmu_config arcturus_config = { + .formats = amdgpu_pmu_formats, + .num_formats =ARRAY_SIZE (amdgpu_pmu_formats), + .events = arcturus_events, + .num_events =ARRAY_SIZE (arcturus_events), + .types = arcturus_types, + .num_types =ARRAY_SIZE (arcturus_types) }; +/* initialize perf counter */ static int amdgpu_perf_event_init(struct perf_event *event) { @@ -605,6 +638,22 @@ int amdgpu_pmu_init(struct amdgpu_device *adev) }
break;
+ case CHIP_ARCTURUS:
+ pmu_entry = create_pmu_entry(adev, AMDGPU_PMU_PERF_TYPE_ALL,
+ "", "amdgpu");
+ if (!pmu_entry)
+ return -ENOMEM;
+
+ ret = init_pmu_entry_by_type_and_add(pmu_entry,
+ &arcturus_config);
+
+ if (ret) {
+ kfree(pmu_entry);
+ return -ENOMEM;
+ }
+
+ break;
+
default:
return 0;
};
drivers/gpu/drm/amd/amdgpu/df_v3_6.c +3 -0
@@ -513,6 +513,7 @@ static int df_v3_6_pmc_start(struct amdgpu_device *adev, uint64_t config,switch (adev->asic_type) {case CHIP_VEGA20 : +case CHIP_ARCTURUS :if (is_add)return df_v3_6_pmc_add_cntr (adev, config);
@@ -554,6 +555,7 @@ static int df_v3_6_pmc_stop(struct amdgpu_device *adev, uint64_t config,switch (adev->asic_type) {case CHIP_VEGA20 : +case CHIP_ARCTURUS : ret = df_v3_6_pmc_get_ctrl_settings(adev, config, counter_idx,
@@ -590,6 +592,7 @@ static void df_v3_6_pmc_get_count(struct amdgpu_device *adev,switch (adev->asic_type) {case CHIP_VEGA20 : +case CHIP_ARCTURUS :df_v3_6_pmc_get_read_settings (adev, config, counter_idx, &lo_base_addr, &hi_base_addr);
--
2.17.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx