diff options
author | Kent Russell <kent.russell@amd.com> | 2019-01-03 08:12:39 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2019-01-14 15:04:54 -0500 |
commit | b45e18acd394954c24943762ada5d8dada75f2b9 (patch) | |
tree | 40ffc68e9c4e6c4449edf17d4401d4dcc5a54503 /drivers/gpu/drm/amd/amdgpu/si.c | |
parent | a0bb79e2559c9330c82080d6e4f8c762d72ed0f1 (diff) |
drm/amdgpu: Add sysfs file for PCIe usage v5
Add a sysfs file that reports the number of bytes transmitted and
received in the last second. This can be used to approximate the PCIe
bandwidth usage over the last second.
v2: Clarify use of mps as estimation of bandwidth
v3: Don't make the file on APUs
v4: Early exit for APUs in the read function, change output to
display "packets-received packets-sent mps"
v5: fix missing header for si (Alex)
Signed-off-by: Kent Russell <kent.russell@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/si.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/si.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/si.c b/drivers/gpu/drm/amd/amdgpu/si.c index f8408f88cd37..7d2a48727e76 100644 --- a/drivers/gpu/drm/amd/amdgpu/si.c +++ b/drivers/gpu/drm/amd/amdgpu/si.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include "dce/dce_6_0_d.h" | 47 | #include "dce/dce_6_0_d.h" |
48 | #include "uvd/uvd_4_0_d.h" | 48 | #include "uvd/uvd_4_0_d.h" |
49 | #include "bif/bif_3_0_d.h" | 49 | #include "bif/bif_3_0_d.h" |
50 | #include "bif/bif_3_0_sh_mask.h" | ||
50 | 51 | ||
51 | static const u32 tahiti_golden_registers[] = | 52 | static const u32 tahiti_golden_registers[] = |
52 | { | 53 | { |
@@ -1323,6 +1324,52 @@ static void si_set_pcie_lanes(struct amdgpu_device *adev, int lanes) | |||
1323 | WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); | 1324 | WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); |
1324 | } | 1325 | } |
1325 | 1326 | ||
1327 | static void si_get_pcie_usage(struct amdgpu_device *adev, uint64_t *count0, | ||
1328 | uint64_t *count1) | ||
1329 | { | ||
1330 | uint32_t perfctr = 0; | ||
1331 | uint64_t cnt0_of, cnt1_of; | ||
1332 | int tmp; | ||
1333 | |||
1334 | /* This reports 0 on APUs, so return to avoid writing/reading registers | ||
1335 | * that may or may not be different from their GPU counterparts | ||
1336 | */ | ||
1337 | if (adev->flags & AMD_IS_APU) | ||
1338 | return; | ||
1339 | |||
1340 | /* Set the 2 events that we wish to watch, defined above */ | ||
1341 | /* Reg 40 is # received msgs, Reg 104 is # of posted requests sent */ | ||
1342 | perfctr = REG_SET_FIELD(perfctr, PCIE_PERF_CNTL_TXCLK, EVENT0_SEL, 40); | ||
1343 | perfctr = REG_SET_FIELD(perfctr, PCIE_PERF_CNTL_TXCLK, EVENT1_SEL, 104); | ||
1344 | |||
1345 | /* Write to enable desired perf counters */ | ||
1346 | WREG32_PCIE(ixPCIE_PERF_CNTL_TXCLK, perfctr); | ||
1347 | /* Zero out and enable the perf counters | ||
1348 | * Write 0x5: | ||
1349 | * Bit 0 = Start all counters(1) | ||
1350 | * Bit 2 = Global counter reset enable(1) | ||
1351 | */ | ||
1352 | WREG32_PCIE(ixPCIE_PERF_COUNT_CNTL, 0x00000005); | ||
1353 | |||
1354 | msleep(1000); | ||
1355 | |||
1356 | /* Load the shadow and disable the perf counters | ||
1357 | * Write 0x2: | ||
1358 | * Bit 0 = Stop counters(0) | ||
1359 | * Bit 1 = Load the shadow counters(1) | ||
1360 | */ | ||
1361 | WREG32_PCIE(ixPCIE_PERF_COUNT_CNTL, 0x00000002); | ||
1362 | |||
1363 | /* Read register values to get any >32bit overflow */ | ||
1364 | tmp = RREG32_PCIE(ixPCIE_PERF_CNTL_TXCLK); | ||
1365 | cnt0_of = REG_GET_FIELD(tmp, PCIE_PERF_CNTL_TXCLK, COUNTER0_UPPER); | ||
1366 | cnt1_of = REG_GET_FIELD(tmp, PCIE_PERF_CNTL_TXCLK, COUNTER1_UPPER); | ||
1367 | |||
1368 | /* Get the values and add the overflow */ | ||
1369 | *count0 = RREG32_PCIE(ixPCIE_PERF_COUNT0_TXCLK) | (cnt0_of << 32); | ||
1370 | *count1 = RREG32_PCIE(ixPCIE_PERF_COUNT1_TXCLK) | (cnt1_of << 32); | ||
1371 | } | ||
1372 | |||
1326 | static const struct amdgpu_asic_funcs si_asic_funcs = | 1373 | static const struct amdgpu_asic_funcs si_asic_funcs = |
1327 | { | 1374 | { |
1328 | .read_disabled_bios = &si_read_disabled_bios, | 1375 | .read_disabled_bios = &si_read_disabled_bios, |
@@ -1339,6 +1386,7 @@ static const struct amdgpu_asic_funcs si_asic_funcs = | |||
1339 | .flush_hdp = &si_flush_hdp, | 1386 | .flush_hdp = &si_flush_hdp, |
1340 | .invalidate_hdp = &si_invalidate_hdp, | 1387 | .invalidate_hdp = &si_invalidate_hdp, |
1341 | .need_full_reset = &si_need_full_reset, | 1388 | .need_full_reset = &si_need_full_reset, |
1389 | .get_pcie_usage = &si_get_pcie_usage, | ||
1342 | }; | 1390 | }; |
1343 | 1391 | ||
1344 | static uint32_t si_get_rev_id(struct amdgpu_device *adev) | 1392 | static uint32_t si_get_rev_id(struct amdgpu_device *adev) |