aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLe Ma <le.ma@amd.com>2019-08-08 02:54:12 -0400
committerAlex Deucher <alexander.deucher@amd.com>2019-08-12 13:47:48 -0400
commitbee7b51ac93a67c54b77cfa17c87ddde7c661988 (patch)
tree5c79432f0b783341d9c0d517bb63775f3f22da27
parentf7ee1995282c804cef69ead5d3a8ba79b371dde2 (diff)
drm/amdgpu: split athub clock gating from mmhub
Untie the bind of get/set athub CG state from mmhub, for cosmetic fix and Asic not using mmhub 1.0. Besides, also fix wrong athub CG state in amdgpu_pm_info. Signed-off-by: Le Ma <le.ma@amd.com> Reviewed-by: Feifei Xu <Feifei.Xu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/amdgpu/Makefile1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/athub_v1_0.c103
-rw-r--r--drivers/gpu/drm/amd/amdgpu/athub_v1_0.h30
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c9
-rw-r--r--drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c55
5 files changed, 154 insertions, 44 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile
index 8afa0bceb460..464bfe52745f 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -154,6 +154,7 @@ amdgpu-y += \
154 154
155# add ATHUB block 155# add ATHUB block
156amdgpu-y += \ 156amdgpu-y += \
157 athub_v1_0.o \
157 athub_v2_0.o 158 athub_v2_0.o
158 159
159# add amdkfd interfaces 160# add amdkfd interfaces
diff --git a/drivers/gpu/drm/amd/amdgpu/athub_v1_0.c b/drivers/gpu/drm/amd/amdgpu/athub_v1_0.c
new file mode 100644
index 000000000000..d9cc746af5e6
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/athub_v1_0.c
@@ -0,0 +1,103 @@
1/*
2 * Copyright 2016 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 */
23#include "amdgpu.h"
24#include "athub_v1_0.h"
25
26#include "athub/athub_1_0_offset.h"
27#include "athub/athub_1_0_sh_mask.h"
28#include "vega10_enum.h"
29
30#include "soc15_common.h"
31
32static void athub_update_medium_grain_clock_gating(struct amdgpu_device *adev,
33 bool enable)
34{
35 uint32_t def, data;
36
37 def = data = RREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL);
38
39 if (enable && (adev->cg_flags & AMD_CG_SUPPORT_MC_MGCG))
40 data |= ATHUB_MISC_CNTL__CG_ENABLE_MASK;
41 else
42 data &= ~ATHUB_MISC_CNTL__CG_ENABLE_MASK;
43
44 if (def != data)
45 WREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL, data);
46}
47
48static void athub_update_medium_grain_light_sleep(struct amdgpu_device *adev,
49 bool enable)
50{
51 uint32_t def, data;
52
53 def = data = RREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL);
54
55 if (enable && (adev->cg_flags & AMD_CG_SUPPORT_MC_LS) &&
56 (adev->cg_flags & AMD_CG_SUPPORT_HDP_LS))
57 data |= ATHUB_MISC_CNTL__CG_MEM_LS_ENABLE_MASK;
58 else
59 data &= ~ATHUB_MISC_CNTL__CG_MEM_LS_ENABLE_MASK;
60
61 if(def != data)
62 WREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL, data);
63}
64
65int athub_v1_0_set_clockgating(struct amdgpu_device *adev,
66 enum amd_clockgating_state state)
67{
68 if (amdgpu_sriov_vf(adev))
69 return 0;
70
71 switch (adev->asic_type) {
72 case CHIP_VEGA10:
73 case CHIP_VEGA12:
74 case CHIP_VEGA20:
75 case CHIP_RAVEN:
76 athub_update_medium_grain_clock_gating(adev,
77 state == AMD_CG_STATE_GATE ? true : false);
78 athub_update_medium_grain_light_sleep(adev,
79 state == AMD_CG_STATE_GATE ? true : false);
80 break;
81 default:
82 break;
83 }
84
85 return 0;
86}
87
88void athub_v1_0_get_clockgating(struct amdgpu_device *adev, u32 *flags)
89{
90 int data;
91
92 if (amdgpu_sriov_vf(adev))
93 *flags = 0;
94
95 /* AMD_CG_SUPPORT_ATHUB_MGCG */
96 data = RREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL);
97 if (data & ATHUB_MISC_CNTL__CG_ENABLE_MASK)
98 *flags |= AMD_CG_SUPPORT_ATHUB_MGCG;
99
100 /* AMD_CG_SUPPORT_ATHUB_LS */
101 if (data & ATHUB_MISC_CNTL__CG_MEM_LS_ENABLE_MASK)
102 *flags |= AMD_CG_SUPPORT_ATHUB_LS;
103}
diff --git a/drivers/gpu/drm/amd/amdgpu/athub_v1_0.h b/drivers/gpu/drm/amd/amdgpu/athub_v1_0.h
new file mode 100644
index 000000000000..b279af59e34f
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/athub_v1_0.h
@@ -0,0 +1,30 @@
1/*
2 * Copyright 2016 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 */
23#ifndef __ATHUB_V1_0_H__
24#define __ATHUB_V1_0_H__
25
26int athub_v1_0_set_clockgating(struct amdgpu_device *adev,
27 enum amd_clockgating_state state);
28void athub_v1_0_get_clockgating(struct amdgpu_device *adev, u32 *flags);
29
30#endif
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index 7206e55dfb55..cf0241ee4e6d 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -47,6 +47,7 @@
47 47
48#include "gfxhub_v1_0.h" 48#include "gfxhub_v1_0.h"
49#include "mmhub_v1_0.h" 49#include "mmhub_v1_0.h"
50#include "athub_v1_0.h"
50#include "gfxhub_v1_1.h" 51#include "gfxhub_v1_1.h"
51#include "mmhub_v9_4.h" 52#include "mmhub_v9_4.h"
52#include "umc_v6_1.h" 53#include "umc_v6_1.h"
@@ -1470,7 +1471,11 @@ static int gmc_v9_0_set_clockgating_state(void *handle,
1470 if (adev->asic_type == CHIP_ARCTURUS) 1471 if (adev->asic_type == CHIP_ARCTURUS)
1471 return 0; 1472 return 0;
1472 1473
1473 return mmhub_v1_0_set_clockgating(adev, state); 1474 mmhub_v1_0_set_clockgating(adev, state);
1475
1476 athub_v1_0_set_clockgating(adev, state);
1477
1478 return 0;
1474} 1479}
1475 1480
1476static void gmc_v9_0_get_clockgating_state(void *handle, u32 *flags) 1481static void gmc_v9_0_get_clockgating_state(void *handle, u32 *flags)
@@ -1481,6 +1486,8 @@ static void gmc_v9_0_get_clockgating_state(void *handle, u32 *flags)
1481 return; 1486 return;
1482 1487
1483 mmhub_v1_0_get_clockgating(adev, flags); 1488 mmhub_v1_0_get_clockgating(adev, flags);
1489
1490 athub_v1_0_get_clockgating(adev, flags);
1484} 1491}
1485 1492
1486static int gmc_v9_0_set_powergating_state(void *handle, 1493static int gmc_v9_0_set_powergating_state(void *handle,
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c
index fa961e0b6f2f..c3a98d964ce5 100644
--- a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c
@@ -26,8 +26,6 @@
26#include "mmhub/mmhub_1_0_offset.h" 26#include "mmhub/mmhub_1_0_offset.h"
27#include "mmhub/mmhub_1_0_sh_mask.h" 27#include "mmhub/mmhub_1_0_sh_mask.h"
28#include "mmhub/mmhub_1_0_default.h" 28#include "mmhub/mmhub_1_0_default.h"
29#include "athub/athub_1_0_offset.h"
30#include "athub/athub_1_0_sh_mask.h"
31#include "vega10_enum.h" 29#include "vega10_enum.h"
32 30
33#include "soc15_common.h" 31#include "soc15_common.h"
@@ -491,22 +489,6 @@ static void mmhub_v1_0_update_medium_grain_clock_gating(struct amdgpu_device *ad
491 WREG32_SOC15(MMHUB, 0, mmDAGB1_CNTL_MISC2, data2); 489 WREG32_SOC15(MMHUB, 0, mmDAGB1_CNTL_MISC2, data2);
492} 490}
493 491
494static void athub_update_medium_grain_clock_gating(struct amdgpu_device *adev,
495 bool enable)
496{
497 uint32_t def, data;
498
499 def = data = RREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL);
500
501 if (enable && (adev->cg_flags & AMD_CG_SUPPORT_MC_MGCG))
502 data |= ATHUB_MISC_CNTL__CG_ENABLE_MASK;
503 else
504 data &= ~ATHUB_MISC_CNTL__CG_ENABLE_MASK;
505
506 if (def != data)
507 WREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL, data);
508}
509
510static void mmhub_v1_0_update_medium_grain_light_sleep(struct amdgpu_device *adev, 492static void mmhub_v1_0_update_medium_grain_light_sleep(struct amdgpu_device *adev,
511 bool enable) 493 bool enable)
512{ 494{
@@ -523,23 +505,6 @@ static void mmhub_v1_0_update_medium_grain_light_sleep(struct amdgpu_device *ade
523 WREG32_SOC15(MMHUB, 0, mmATC_L2_MISC_CG, data); 505 WREG32_SOC15(MMHUB, 0, mmATC_L2_MISC_CG, data);
524} 506}
525 507
526static void athub_update_medium_grain_light_sleep(struct amdgpu_device *adev,
527 bool enable)
528{
529 uint32_t def, data;
530
531 def = data = RREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL);
532
533 if (enable && (adev->cg_flags & AMD_CG_SUPPORT_MC_LS) &&
534 (adev->cg_flags & AMD_CG_SUPPORT_HDP_LS))
535 data |= ATHUB_MISC_CNTL__CG_MEM_LS_ENABLE_MASK;
536 else
537 data &= ~ATHUB_MISC_CNTL__CG_MEM_LS_ENABLE_MASK;
538
539 if(def != data)
540 WREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL, data);
541}
542
543int mmhub_v1_0_set_clockgating(struct amdgpu_device *adev, 508int mmhub_v1_0_set_clockgating(struct amdgpu_device *adev,
544 enum amd_clockgating_state state) 509 enum amd_clockgating_state state)
545{ 510{
@@ -553,12 +518,8 @@ int mmhub_v1_0_set_clockgating(struct amdgpu_device *adev,
553 case CHIP_RAVEN: 518 case CHIP_RAVEN:
554 mmhub_v1_0_update_medium_grain_clock_gating(adev, 519 mmhub_v1_0_update_medium_grain_clock_gating(adev,
555 state == AMD_CG_STATE_GATE ? true : false); 520 state == AMD_CG_STATE_GATE ? true : false);
556 athub_update_medium_grain_clock_gating(adev,
557 state == AMD_CG_STATE_GATE ? true : false);
558 mmhub_v1_0_update_medium_grain_light_sleep(adev, 521 mmhub_v1_0_update_medium_grain_light_sleep(adev,
559 state == AMD_CG_STATE_GATE ? true : false); 522 state == AMD_CG_STATE_GATE ? true : false);
560 athub_update_medium_grain_light_sleep(adev,
561 state == AMD_CG_STATE_GATE ? true : false);
562 break; 523 break;
563 default: 524 default:
564 break; 525 break;
@@ -569,18 +530,26 @@ int mmhub_v1_0_set_clockgating(struct amdgpu_device *adev,
569 530
570void mmhub_v1_0_get_clockgating(struct amdgpu_device *adev, u32 *flags) 531void mmhub_v1_0_get_clockgating(struct amdgpu_device *adev, u32 *flags)
571{ 532{
572 int data; 533 int data, data1;
573 534
574 if (amdgpu_sriov_vf(adev)) 535 if (amdgpu_sriov_vf(adev))
575 *flags = 0; 536 *flags = 0;
576 537
538 data = RREG32_SOC15(MMHUB, 0, mmATC_L2_MISC_CG);
539
540 data1 = RREG32_SOC15(MMHUB, 0, mmDAGB0_CNTL_MISC2);
541
577 /* AMD_CG_SUPPORT_MC_MGCG */ 542 /* AMD_CG_SUPPORT_MC_MGCG */
578 data = RREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL); 543 if ((data & ATC_L2_MISC_CG__ENABLE_MASK) &&
579 if (data & ATHUB_MISC_CNTL__CG_ENABLE_MASK) 544 !(data1 & (DAGB0_CNTL_MISC2__DISABLE_WRREQ_CG_MASK |
545 DAGB0_CNTL_MISC2__DISABLE_WRRET_CG_MASK |
546 DAGB0_CNTL_MISC2__DISABLE_RDREQ_CG_MASK |
547 DAGB0_CNTL_MISC2__DISABLE_RDRET_CG_MASK |
548 DAGB0_CNTL_MISC2__DISABLE_TLBWR_CG_MASK |
549 DAGB0_CNTL_MISC2__DISABLE_TLBRD_CG_MASK)))
580 *flags |= AMD_CG_SUPPORT_MC_MGCG; 550 *flags |= AMD_CG_SUPPORT_MC_MGCG;
581 551
582 /* AMD_CG_SUPPORT_MC_LS */ 552 /* AMD_CG_SUPPORT_MC_LS */
583 data = RREG32_SOC15(MMHUB, 0, mmATC_L2_MISC_CG);
584 if (data & ATC_L2_MISC_CG__MEM_LS_ENABLE_MASK) 553 if (data & ATC_L2_MISC_CG__MEM_LS_ENABLE_MASK)
585 *flags |= AMD_CG_SUPPORT_MC_LS; 554 *flags |= AMD_CG_SUPPORT_MC_LS;
586} 555}