Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Le Ma and committed by
Alex Deucher
bee7b51a f7ee1995

+154 -44
+1
drivers/gpu/drm/amd/amdgpu/Makefile
··· 154 154 155 155 # add ATHUB block 156 156 amdgpu-y += \ 157 + athub_v1_0.o \ 157 158 athub_v2_0.o 158 159 159 160 # add amdkfd interfaces
+103
drivers/gpu/drm/amd/amdgpu/athub_v1_0.c
··· 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 + 32 + static 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 + 48 + static 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 + 65 + int 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 + 88 + void 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 + }
+30
drivers/gpu/drm/amd/amdgpu/athub_v1_0.h
··· 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 + 26 + int athub_v1_0_set_clockgating(struct amdgpu_device *adev, 27 + enum amd_clockgating_state state); 28 + void athub_v1_0_get_clockgating(struct amdgpu_device *adev, u32 *flags); 29 + 30 + #endif
+8 -1
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
··· 47 47 48 48 #include "gfxhub_v1_0.h" 49 49 #include "mmhub_v1_0.h" 50 + #include "athub_v1_0.h" 50 51 #include "gfxhub_v1_1.h" 51 52 #include "mmhub_v9_4.h" 52 53 #include "umc_v6_1.h" ··· 1471 1470 if (adev->asic_type == CHIP_ARCTURUS) 1472 1471 return 0; 1473 1472 1474 - return mmhub_v1_0_set_clockgating(adev, state); 1473 + mmhub_v1_0_set_clockgating(adev, state); 1474 + 1475 + athub_v1_0_set_clockgating(adev, state); 1476 + 1477 + return 0; 1475 1478 } 1476 1479 1477 1480 static void gmc_v9_0_get_clockgating_state(void *handle, u32 *flags) ··· 1486 1481 return; 1487 1482 1488 1483 mmhub_v1_0_get_clockgating(adev, flags); 1484 + 1485 + athub_v1_0_get_clockgating(adev, flags); 1489 1486 } 1490 1487 1491 1488 static int gmc_v9_0_set_powergating_state(void *handle,
+12 -43
drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c
··· 26 26 #include "mmhub/mmhub_1_0_offset.h" 27 27 #include "mmhub/mmhub_1_0_sh_mask.h" 28 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 29 #include "vega10_enum.h" 32 30 33 31 #include "soc15_common.h" ··· 489 491 WREG32_SOC15(MMHUB, 0, mmDAGB1_CNTL_MISC2, data2); 490 492 } 491 493 492 - static void athub_update_medium_grain_clock_gating(struct amdgpu_device *adev, 493 - bool enable) 494 - { 495 - uint32_t def, data; 496 - 497 - def = data = RREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL); 498 - 499 - if (enable && (adev->cg_flags & AMD_CG_SUPPORT_MC_MGCG)) 500 - data |= ATHUB_MISC_CNTL__CG_ENABLE_MASK; 501 - else 502 - data &= ~ATHUB_MISC_CNTL__CG_ENABLE_MASK; 503 - 504 - if (def != data) 505 - WREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL, data); 506 - } 507 - 508 494 static void mmhub_v1_0_update_medium_grain_light_sleep(struct amdgpu_device *adev, 509 495 bool enable) 510 496 { ··· 505 523 WREG32_SOC15(MMHUB, 0, mmATC_L2_MISC_CG, data); 506 524 } 507 525 508 - static void athub_update_medium_grain_light_sleep(struct amdgpu_device *adev, 509 - bool enable) 510 - { 511 - uint32_t def, data; 512 - 513 - def = data = RREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL); 514 - 515 - if (enable && (adev->cg_flags & AMD_CG_SUPPORT_MC_LS) && 516 - (adev->cg_flags & AMD_CG_SUPPORT_HDP_LS)) 517 - data |= ATHUB_MISC_CNTL__CG_MEM_LS_ENABLE_MASK; 518 - else 519 - data &= ~ATHUB_MISC_CNTL__CG_MEM_LS_ENABLE_MASK; 520 - 521 - if(def != data) 522 - WREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL, data); 523 - } 524 - 525 526 int mmhub_v1_0_set_clockgating(struct amdgpu_device *adev, 526 527 enum amd_clockgating_state state) 527 528 { ··· 518 553 case CHIP_RAVEN: 519 554 mmhub_v1_0_update_medium_grain_clock_gating(adev, 520 555 state == AMD_CG_STATE_GATE ? true : false); 521 - athub_update_medium_grain_clock_gating(adev, 522 - state == AMD_CG_STATE_GATE ? true : false); 523 556 mmhub_v1_0_update_medium_grain_light_sleep(adev, 524 - state == AMD_CG_STATE_GATE ? true : false); 525 - athub_update_medium_grain_light_sleep(adev, 526 557 state == AMD_CG_STATE_GATE ? true : false); 527 558 break; 528 559 default: ··· 530 569 531 570 void mmhub_v1_0_get_clockgating(struct amdgpu_device *adev, u32 *flags) 532 571 { 533 - int data; 572 + int data, data1; 534 573 535 574 if (amdgpu_sriov_vf(adev)) 536 575 *flags = 0; 537 576 577 + data = RREG32_SOC15(MMHUB, 0, mmATC_L2_MISC_CG); 578 + 579 + data1 = RREG32_SOC15(MMHUB, 0, mmDAGB0_CNTL_MISC2); 580 + 538 581 /* AMD_CG_SUPPORT_MC_MGCG */ 539 - data = RREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL); 540 - if (data & ATHUB_MISC_CNTL__CG_ENABLE_MASK) 582 + if ((data & ATC_L2_MISC_CG__ENABLE_MASK) && 583 + !(data1 & (DAGB0_CNTL_MISC2__DISABLE_WRREQ_CG_MASK | 584 + DAGB0_CNTL_MISC2__DISABLE_WRRET_CG_MASK | 585 + DAGB0_CNTL_MISC2__DISABLE_RDREQ_CG_MASK | 586 + DAGB0_CNTL_MISC2__DISABLE_RDRET_CG_MASK | 587 + DAGB0_CNTL_MISC2__DISABLE_TLBWR_CG_MASK | 588 + DAGB0_CNTL_MISC2__DISABLE_TLBRD_CG_MASK))) 541 589 *flags |= AMD_CG_SUPPORT_MC_MGCG; 542 590 543 591 /* AMD_CG_SUPPORT_MC_LS */ 544 - data = RREG32_SOC15(MMHUB, 0, mmATC_L2_MISC_CG); 545 592 if (data & ATC_L2_MISC_CG__MEM_LS_ENABLE_MASK) 546 593 *flags |= AMD_CG_SUPPORT_MC_LS; 547 594 }