2017-03-10 00:36:26 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Advanced Micro Devices, Inc.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "amdgpu.h"
|
2019-08-13 15:46:03 +08:00
|
|
|
#include "amdgpu_ras.h"
|
2017-03-10 00:36:26 +08:00
|
|
|
#include "mmhub_v1_0.h"
|
|
|
|
|
2017-11-23 14:30:43 +08:00
|
|
|
#include "mmhub/mmhub_1_0_offset.h"
|
|
|
|
#include "mmhub/mmhub_1_0_sh_mask.h"
|
|
|
|
#include "mmhub/mmhub_1_0_default.h"
|
2019-08-13 15:46:03 +08:00
|
|
|
#include "mmhub/mmhub_9_4_0_offset.h"
|
2017-11-24 12:31:36 +08:00
|
|
|
#include "vega10_enum.h"
|
2017-03-10 00:36:26 +08:00
|
|
|
|
|
|
|
#include "soc15_common.h"
|
2019-08-30 13:34:38 +08:00
|
|
|
#include "amdgpu_ras.h"
|
2017-03-10 00:36:26 +08:00
|
|
|
|
2017-02-08 17:07:59 +08:00
|
|
|
#define mmDAGB0_CNTL_MISC2_RV 0x008f
|
|
|
|
#define mmDAGB0_CNTL_MISC2_RV_BASE_IDX 0
|
|
|
|
|
2019-08-13 15:46:03 +08:00
|
|
|
#define EA_EDC_CNT_MASK 0x3
|
|
|
|
#define EA_EDC_CNT_SHIFT 0x2
|
|
|
|
|
2017-03-10 00:36:26 +08:00
|
|
|
u64 mmhub_v1_0_get_fb_location(struct amdgpu_device *adev)
|
|
|
|
{
|
2017-06-01 15:30:04 +08:00
|
|
|
u64 base = RREG32_SOC15(MMHUB, 0, mmMC_VM_FB_LOCATION_BASE);
|
2018-06-20 05:11:56 +08:00
|
|
|
u64 top = RREG32_SOC15(MMHUB, 0, mmMC_VM_FB_LOCATION_TOP);
|
2017-03-10 00:36:26 +08:00
|
|
|
|
|
|
|
base &= MC_VM_FB_LOCATION_BASE__FB_BASE_MASK;
|
|
|
|
base <<= 24;
|
|
|
|
|
2018-06-20 05:11:56 +08:00
|
|
|
top &= MC_VM_FB_LOCATION_TOP__FB_TOP_MASK;
|
|
|
|
top <<= 24;
|
|
|
|
|
|
|
|
adev->gmc.fb_start = base;
|
|
|
|
adev->gmc.fb_end = top;
|
|
|
|
|
2017-03-10 00:36:26 +08:00
|
|
|
return base;
|
|
|
|
}
|
|
|
|
|
2018-10-13 03:22:46 +08:00
|
|
|
void mmhub_v1_0_setup_vm_pt_regs(struct amdgpu_device *adev, uint32_t vmid,
|
|
|
|
uint64_t page_table_base)
|
2017-05-31 16:20:48 +08:00
|
|
|
{
|
2018-10-13 03:22:46 +08:00
|
|
|
/* two registers distance between mmVM_CONTEXT0_* to mmVM_CONTEXT1_* */
|
|
|
|
int offset = mmVM_CONTEXT1_PAGE_TABLE_BASE_ADDR_LO32
|
|
|
|
- mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LO32;
|
2017-05-31 16:20:48 +08:00
|
|
|
|
2018-10-13 03:22:46 +08:00
|
|
|
WREG32_SOC15_OFFSET(MMHUB, 0, mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LO32,
|
|
|
|
offset * vmid, lower_32_bits(page_table_base));
|
2017-05-31 16:20:48 +08:00
|
|
|
|
2018-10-13 03:22:46 +08:00
|
|
|
WREG32_SOC15_OFFSET(MMHUB, 0, mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_HI32,
|
|
|
|
offset * vmid, upper_32_bits(page_table_base));
|
2017-05-31 16:20:48 +08:00
|
|
|
}
|
|
|
|
|
2017-05-31 16:40:14 +08:00
|
|
|
static void mmhub_v1_0_init_gart_aperture_regs(struct amdgpu_device *adev)
|
|
|
|
{
|
2018-10-13 03:22:46 +08:00
|
|
|
uint64_t pt_base = amdgpu_gmc_pd_addr(adev->gart.bo);
|
|
|
|
|
|
|
|
mmhub_v1_0_setup_vm_pt_regs(adev, 0, pt_base);
|
2017-05-31 16:40:14 +08:00
|
|
|
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmVM_CONTEXT0_PAGE_TABLE_START_ADDR_LO32,
|
2018-01-12 21:52:22 +08:00
|
|
|
(u32)(adev->gmc.gart_start >> 12));
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmVM_CONTEXT0_PAGE_TABLE_START_ADDR_HI32,
|
2018-01-12 21:52:22 +08:00
|
|
|
(u32)(adev->gmc.gart_start >> 44));
|
2017-06-01 15:30:04 +08:00
|
|
|
|
|
|
|
WREG32_SOC15(MMHUB, 0, mmVM_CONTEXT0_PAGE_TABLE_END_ADDR_LO32,
|
2018-01-12 21:52:22 +08:00
|
|
|
(u32)(adev->gmc.gart_end >> 12));
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmVM_CONTEXT0_PAGE_TABLE_END_ADDR_HI32,
|
2018-01-12 21:52:22 +08:00
|
|
|
(u32)(adev->gmc.gart_end >> 44));
|
2017-05-31 16:40:14 +08:00
|
|
|
}
|
|
|
|
|
2017-05-31 17:04:28 +08:00
|
|
|
static void mmhub_v1_0_init_system_aperture_regs(struct amdgpu_device *adev)
|
2017-03-10 00:36:26 +08:00
|
|
|
{
|
2017-05-31 17:04:28 +08:00
|
|
|
uint64_t value;
|
|
|
|
uint32_t tmp;
|
2017-03-10 00:36:26 +08:00
|
|
|
|
2018-08-28 00:23:11 +08:00
|
|
|
/* Program the AGP BAR */
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmMC_VM_AGP_BASE, 0);
|
2018-08-28 00:23:11 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmMC_VM_AGP_BOT, adev->gmc.agp_start >> 24);
|
|
|
|
WREG32_SOC15(MMHUB, 0, mmMC_VM_AGP_TOP, adev->gmc.agp_end >> 24);
|
2017-05-31 16:20:48 +08:00
|
|
|
|
2017-05-31 17:04:28 +08:00
|
|
|
/* Program the system aperture low logical page number. */
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmMC_VM_SYSTEM_APERTURE_LOW_ADDR,
|
2018-11-13 00:19:24 +08:00
|
|
|
min(adev->gmc.fb_start, adev->gmc.agp_start) >> 18);
|
2018-01-16 10:42:58 +08:00
|
|
|
|
|
|
|
if (adev->asic_type == CHIP_RAVEN && adev->rev_id >= 0x8)
|
|
|
|
/*
|
|
|
|
* Raven2 has a HW issue that it is unable to use the vram which
|
|
|
|
* is out of MC_VM_SYSTEM_APERTURE_HIGH_ADDR. So here is the
|
|
|
|
* workaround that increase system aperture high address (add 1)
|
|
|
|
* to get rid of the VM fault and hardware hang.
|
|
|
|
*/
|
|
|
|
WREG32_SOC15(MMHUB, 0, mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR,
|
2018-11-13 00:19:24 +08:00
|
|
|
max((adev->gmc.fb_end >> 18) + 0x1,
|
2018-09-21 18:15:01 +08:00
|
|
|
adev->gmc.agp_end >> 18));
|
2018-01-16 10:42:58 +08:00
|
|
|
else
|
|
|
|
WREG32_SOC15(MMHUB, 0, mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR,
|
2018-11-13 00:19:24 +08:00
|
|
|
max(adev->gmc.fb_end, adev->gmc.agp_end) >> 18);
|
2017-05-31 17:04:28 +08:00
|
|
|
|
2019-07-30 17:21:19 +08:00
|
|
|
if (amdgpu_sriov_vf(adev))
|
2019-03-04 12:30:58 +08:00
|
|
|
return;
|
|
|
|
|
2017-05-31 17:04:28 +08:00
|
|
|
/* Set default page address. */
|
2018-01-12 21:52:22 +08:00
|
|
|
value = adev->vram_scratch.gpu_addr - adev->gmc.vram_start +
|
2017-03-10 00:36:26 +08:00
|
|
|
adev->vm_manager.vram_base_offset;
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmMC_VM_SYSTEM_APERTURE_DEFAULT_ADDR_LSB,
|
|
|
|
(u32)(value >> 12));
|
|
|
|
WREG32_SOC15(MMHUB, 0, mmMC_VM_SYSTEM_APERTURE_DEFAULT_ADDR_MSB,
|
|
|
|
(u32)(value >> 44));
|
2017-05-31 17:04:28 +08:00
|
|
|
|
|
|
|
/* Program "protection fault". */
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmVM_L2_PROTECTION_FAULT_DEFAULT_ADDR_LO32,
|
2018-02-22 15:35:11 +08:00
|
|
|
(u32)(adev->dummy_page_addr >> 12));
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmVM_L2_PROTECTION_FAULT_DEFAULT_ADDR_HI32,
|
2018-02-22 15:35:11 +08:00
|
|
|
(u32)((u64)adev->dummy_page_addr >> 44));
|
2017-06-01 15:30:04 +08:00
|
|
|
|
|
|
|
tmp = RREG32_SOC15(MMHUB, 0, mmVM_L2_PROTECTION_FAULT_CNTL2);
|
2017-05-31 17:04:28 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL2,
|
|
|
|
ACTIVE_PAGE_MIGRATION_PTE_READ_RETRY, 1);
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmVM_L2_PROTECTION_FAULT_CNTL2, tmp);
|
2017-05-31 17:04:28 +08:00
|
|
|
}
|
|
|
|
|
2017-05-31 17:19:01 +08:00
|
|
|
static void mmhub_v1_0_init_tlb_regs(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
uint32_t tmp;
|
|
|
|
|
|
|
|
/* Setup TLB control */
|
2017-06-01 15:30:04 +08:00
|
|
|
tmp = RREG32_SOC15(MMHUB, 0, mmMC_VM_MX_L1_TLB_CNTL);
|
2017-05-31 17:19:01 +08:00
|
|
|
|
|
|
|
tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_L1_TLB, 1);
|
|
|
|
tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, SYSTEM_ACCESS_MODE, 3);
|
|
|
|
tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL,
|
|
|
|
ENABLE_ADVANCED_DRIVER_MODEL, 1);
|
|
|
|
tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL,
|
|
|
|
SYSTEM_APERTURE_UNMAPPED_ACCESS, 0);
|
|
|
|
tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ECO_BITS, 0);
|
|
|
|
tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL,
|
|
|
|
MTYPE, MTYPE_UC);/* XXX for emulation. */
|
|
|
|
tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ATC_EN, 1);
|
|
|
|
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmMC_VM_MX_L1_TLB_CNTL, tmp);
|
2017-05-31 17:19:01 +08:00
|
|
|
}
|
|
|
|
|
2017-05-31 18:07:48 +08:00
|
|
|
static void mmhub_v1_0_init_cache_regs(struct amdgpu_device *adev)
|
|
|
|
{
|
2017-08-24 14:57:57 +08:00
|
|
|
uint32_t tmp;
|
2017-05-31 18:07:48 +08:00
|
|
|
|
2019-07-30 17:21:19 +08:00
|
|
|
if (amdgpu_sriov_vf(adev))
|
2019-03-04 12:30:58 +08:00
|
|
|
return;
|
|
|
|
|
2017-05-31 18:07:48 +08:00
|
|
|
/* Setup L2 cache */
|
2017-06-01 15:30:04 +08:00
|
|
|
tmp = RREG32_SOC15(MMHUB, 0, mmVM_L2_CNTL);
|
2017-05-31 18:07:48 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_CACHE, 1);
|
2017-05-24 00:35:22 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_FRAGMENT_PROCESSING, 1);
|
2017-05-31 18:07:48 +08:00
|
|
|
/* XXX for emulation, Refer to closed source code.*/
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, L2_PDE0_CACHE_TAG_GENERATION_MODE,
|
|
|
|
0);
|
2019-02-26 06:50:43 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, PDE_FAULT_CLASSIFICATION, 0);
|
2017-05-31 18:07:48 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, CONTEXT1_IDENTITY_ACCESS_MODE, 1);
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, IDENTITY_MODE_FRAGMENT_SIZE, 0);
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmVM_L2_CNTL, tmp);
|
2017-05-31 18:07:48 +08:00
|
|
|
|
2017-06-01 15:30:04 +08:00
|
|
|
tmp = RREG32_SOC15(MMHUB, 0, mmVM_L2_CNTL2);
|
2017-05-31 18:07:48 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL2, INVALIDATE_ALL_L1_TLBS, 1);
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL2, INVALIDATE_L2_CACHE, 1);
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmVM_L2_CNTL2, tmp);
|
2017-05-31 18:07:48 +08:00
|
|
|
|
2018-01-12 21:52:22 +08:00
|
|
|
if (adev->gmc.translate_further) {
|
2017-12-05 22:23:26 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, BANK_SELECT, 12);
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3,
|
|
|
|
L2_CACHE_BIGK_FRAGMENT_SIZE, 9);
|
|
|
|
} else {
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, BANK_SELECT, 9);
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3,
|
|
|
|
L2_CACHE_BIGK_FRAGMENT_SIZE, 6);
|
|
|
|
}
|
2019-04-12 03:54:40 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmVM_L2_CNTL3, tmp);
|
2017-05-31 18:07:48 +08:00
|
|
|
|
|
|
|
tmp = mmVM_L2_CNTL4_DEFAULT;
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_PDE_REQUEST_PHYSICAL, 0);
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_PTE_REQUEST_PHYSICAL, 0);
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmVM_L2_CNTL4, tmp);
|
2017-05-31 18:07:48 +08:00
|
|
|
}
|
|
|
|
|
2017-05-31 21:39:10 +08:00
|
|
|
static void mmhub_v1_0_enable_system_domain(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
uint32_t tmp;
|
|
|
|
|
2017-06-01 15:30:04 +08:00
|
|
|
tmp = RREG32_SOC15(MMHUB, 0, mmVM_CONTEXT0_CNTL);
|
2017-05-31 21:39:10 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, VM_CONTEXT0_CNTL, ENABLE_CONTEXT, 1);
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_CONTEXT0_CNTL, PAGE_TABLE_DEPTH, 0);
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmVM_CONTEXT0_CNTL, tmp);
|
2017-05-31 21:39:10 +08:00
|
|
|
}
|
|
|
|
|
2017-05-31 21:52:00 +08:00
|
|
|
static void mmhub_v1_0_disable_identity_aperture(struct amdgpu_device *adev)
|
|
|
|
{
|
2019-07-30 17:21:19 +08:00
|
|
|
if (amdgpu_sriov_vf(adev))
|
2019-03-04 12:30:58 +08:00
|
|
|
return;
|
|
|
|
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmVM_L2_CONTEXT1_IDENTITY_APERTURE_LOW_ADDR_LO32,
|
|
|
|
0XFFFFFFFF);
|
|
|
|
WREG32_SOC15(MMHUB, 0, mmVM_L2_CONTEXT1_IDENTITY_APERTURE_LOW_ADDR_HI32,
|
|
|
|
0x0000000F);
|
|
|
|
|
|
|
|
WREG32_SOC15(MMHUB, 0,
|
|
|
|
mmVM_L2_CONTEXT1_IDENTITY_APERTURE_HIGH_ADDR_LO32, 0);
|
|
|
|
WREG32_SOC15(MMHUB, 0,
|
|
|
|
mmVM_L2_CONTEXT1_IDENTITY_APERTURE_HIGH_ADDR_HI32, 0);
|
|
|
|
|
|
|
|
WREG32_SOC15(MMHUB, 0, mmVM_L2_CONTEXT_IDENTITY_PHYSICAL_OFFSET_LO32,
|
|
|
|
0);
|
|
|
|
WREG32_SOC15(MMHUB, 0, mmVM_L2_CONTEXT_IDENTITY_PHYSICAL_OFFSET_HI32,
|
|
|
|
0);
|
2017-05-31 21:52:00 +08:00
|
|
|
}
|
|
|
|
|
2017-05-31 22:17:11 +08:00
|
|
|
static void mmhub_v1_0_setup_vmid_config(struct amdgpu_device *adev)
|
2017-05-31 17:04:28 +08:00
|
|
|
{
|
2017-12-05 22:23:26 +08:00
|
|
|
unsigned num_level, block_size;
|
2017-05-31 22:17:11 +08:00
|
|
|
uint32_t tmp;
|
2017-12-05 22:23:26 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
num_level = adev->vm_manager.num_level;
|
|
|
|
block_size = adev->vm_manager.block_size;
|
2018-01-12 21:52:22 +08:00
|
|
|
if (adev->gmc.translate_further)
|
2017-12-05 22:23:26 +08:00
|
|
|
num_level -= 1;
|
|
|
|
else
|
|
|
|
block_size -= 9;
|
2017-03-10 00:36:26 +08:00
|
|
|
|
|
|
|
for (i = 0; i <= 14; i++) {
|
2017-06-13 00:34:28 +08:00
|
|
|
tmp = RREG32_SOC15_OFFSET(MMHUB, 0, mmVM_CONTEXT1_CNTL, i);
|
2017-12-05 22:23:26 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, ENABLE_CONTEXT, 1);
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, PAGE_TABLE_DEPTH,
|
|
|
|
num_level);
|
2017-03-10 00:36:26 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
|
2017-12-05 22:23:26 +08:00
|
|
|
RANGE_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
|
2017-03-10 00:36:26 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
|
2017-12-05 22:23:26 +08:00
|
|
|
DUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT,
|
|
|
|
1);
|
2017-03-10 00:36:26 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
|
2017-12-05 22:23:26 +08:00
|
|
|
PDE0_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
|
2017-03-10 00:36:26 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
|
2017-12-05 22:23:26 +08:00
|
|
|
VALID_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
|
2017-03-10 00:36:26 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
|
2017-12-05 22:23:26 +08:00
|
|
|
READ_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
|
2017-03-10 00:36:26 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
|
2017-12-05 22:23:26 +08:00
|
|
|
WRITE_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
|
2017-03-10 00:36:26 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
|
2017-12-05 22:23:26 +08:00
|
|
|
EXECUTE_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
|
2017-03-10 00:36:26 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
|
2017-12-05 22:23:26 +08:00
|
|
|
PAGE_TABLE_BLOCK_SIZE,
|
|
|
|
block_size);
|
2017-04-27 03:51:57 +08:00
|
|
|
/* Send no-retry XNACK on fault to suppress VM fault storm. */
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
|
2019-06-22 07:50:03 +08:00
|
|
|
RETRY_PERMISSION_OR_INVALID_PAGE_FAULT,
|
|
|
|
!amdgpu_noretry);
|
2017-06-13 00:34:28 +08:00
|
|
|
WREG32_SOC15_OFFSET(MMHUB, 0, mmVM_CONTEXT1_CNTL, i, tmp);
|
|
|
|
WREG32_SOC15_OFFSET(MMHUB, 0, mmVM_CONTEXT1_PAGE_TABLE_START_ADDR_LO32, i*2, 0);
|
|
|
|
WREG32_SOC15_OFFSET(MMHUB, 0, mmVM_CONTEXT1_PAGE_TABLE_START_ADDR_HI32, i*2, 0);
|
|
|
|
WREG32_SOC15_OFFSET(MMHUB, 0, mmVM_CONTEXT1_PAGE_TABLE_END_ADDR_LO32, i*2,
|
2017-03-29 08:24:53 +08:00
|
|
|
lower_32_bits(adev->vm_manager.max_pfn - 1));
|
2017-06-13 00:34:28 +08:00
|
|
|
WREG32_SOC15_OFFSET(MMHUB, 0, mmVM_CONTEXT1_PAGE_TABLE_END_ADDR_HI32, i*2,
|
2017-03-29 08:24:53 +08:00
|
|
|
upper_32_bits(adev->vm_manager.max_pfn - 1));
|
2017-03-10 00:36:26 +08:00
|
|
|
}
|
2017-05-31 22:17:11 +08:00
|
|
|
}
|
|
|
|
|
2017-05-31 22:32:35 +08:00
|
|
|
static void mmhub_v1_0_program_invalidation(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
for (i = 0; i < 18; ++i) {
|
2017-06-13 00:34:28 +08:00
|
|
|
WREG32_SOC15_OFFSET(MMHUB, 0, mmVM_INVALIDATE_ENG0_ADDR_RANGE_LO32,
|
|
|
|
2 * i, 0xffffffff);
|
|
|
|
WREG32_SOC15_OFFSET(MMHUB, 0, mmVM_INVALIDATE_ENG0_ADDR_RANGE_HI32,
|
|
|
|
2 * i, 0x1f);
|
2017-05-31 22:32:35 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-16 21:31:43 +08:00
|
|
|
void mmhub_v1_0_update_power_gating(struct amdgpu_device *adev,
|
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
if (amdgpu_sriov_vf(adev))
|
|
|
|
return;
|
|
|
|
|
2017-06-19 14:39:02 +08:00
|
|
|
if (enable && adev->pg_flags & AMD_PG_SUPPORT_MMHUB) {
|
2018-10-19 10:46:53 +08:00
|
|
|
if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->set_powergating_by_smu)
|
2018-06-05 13:06:11 +08:00
|
|
|
amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GMC, true);
|
2018-02-07 05:21:05 +08:00
|
|
|
|
2017-06-16 21:31:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-31 22:17:11 +08:00
|
|
|
int mmhub_v1_0_gart_enable(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
if (amdgpu_sriov_vf(adev)) {
|
|
|
|
/*
|
|
|
|
* MC_VM_FB_LOCATION_BASE/TOP is NULL for VF, becuase they are
|
|
|
|
* VF copy registers so vbios post doesn't program them, for
|
|
|
|
* SRIOV driver need to program them
|
|
|
|
*/
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmMC_VM_FB_LOCATION_BASE,
|
2018-01-12 21:52:22 +08:00
|
|
|
adev->gmc.vram_start >> 24);
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmMC_VM_FB_LOCATION_TOP,
|
2018-01-12 21:52:22 +08:00
|
|
|
adev->gmc.vram_end >> 24);
|
2017-05-31 22:17:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* GART Enable. */
|
|
|
|
mmhub_v1_0_init_gart_aperture_regs(adev);
|
|
|
|
mmhub_v1_0_init_system_aperture_regs(adev);
|
|
|
|
mmhub_v1_0_init_tlb_regs(adev);
|
|
|
|
mmhub_v1_0_init_cache_regs(adev);
|
|
|
|
|
|
|
|
mmhub_v1_0_enable_system_domain(adev);
|
|
|
|
mmhub_v1_0_disable_identity_aperture(adev);
|
|
|
|
mmhub_v1_0_setup_vmid_config(adev);
|
2017-05-31 22:32:35 +08:00
|
|
|
mmhub_v1_0_program_invalidation(adev);
|
2017-03-10 00:36:26 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmhub_v1_0_gart_disable(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
u32 tmp;
|
|
|
|
u32 i;
|
|
|
|
|
|
|
|
/* Disable all tables */
|
|
|
|
for (i = 0; i < 16; i++)
|
2017-06-13 00:34:28 +08:00
|
|
|
WREG32_SOC15_OFFSET(MMHUB, 0, mmVM_CONTEXT0_CNTL, i, 0);
|
2017-03-10 00:36:26 +08:00
|
|
|
|
|
|
|
/* Setup TLB control */
|
2017-06-01 15:30:04 +08:00
|
|
|
tmp = RREG32_SOC15(MMHUB, 0, mmMC_VM_MX_L1_TLB_CNTL);
|
2017-03-10 00:36:26 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_L1_TLB, 0);
|
|
|
|
tmp = REG_SET_FIELD(tmp,
|
|
|
|
MC_VM_MX_L1_TLB_CNTL,
|
|
|
|
ENABLE_ADVANCED_DRIVER_MODEL,
|
|
|
|
0);
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmMC_VM_MX_L1_TLB_CNTL, tmp);
|
2017-03-10 00:36:26 +08:00
|
|
|
|
2019-07-30 17:21:19 +08:00
|
|
|
if (!amdgpu_sriov_vf(adev)) {
|
2019-03-04 12:30:58 +08:00
|
|
|
/* Setup L2 cache */
|
|
|
|
tmp = RREG32_SOC15(MMHUB, 0, mmVM_L2_CNTL);
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_CACHE, 0);
|
|
|
|
WREG32_SOC15(MMHUB, 0, mmVM_L2_CNTL, tmp);
|
|
|
|
WREG32_SOC15(MMHUB, 0, mmVM_L2_CNTL3, 0);
|
|
|
|
}
|
2017-03-10 00:36:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mmhub_v1_0_set_fault_enable_default - update GART/VM fault handling
|
|
|
|
*
|
|
|
|
* @adev: amdgpu_device pointer
|
|
|
|
* @value: true redirects VM faults to the default page
|
|
|
|
*/
|
|
|
|
void mmhub_v1_0_set_fault_enable_default(struct amdgpu_device *adev, bool value)
|
|
|
|
{
|
|
|
|
u32 tmp;
|
2019-03-04 12:30:58 +08:00
|
|
|
|
2019-07-30 17:21:19 +08:00
|
|
|
if (amdgpu_sriov_vf(adev))
|
2019-03-04 12:30:58 +08:00
|
|
|
return;
|
|
|
|
|
2017-06-01 15:30:04 +08:00
|
|
|
tmp = RREG32_SOC15(MMHUB, 0, mmVM_L2_PROTECTION_FAULT_CNTL);
|
2017-03-10 00:36:26 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
|
|
|
|
RANGE_PROTECTION_FAULT_ENABLE_DEFAULT, value);
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
|
|
|
|
PDE0_PROTECTION_FAULT_ENABLE_DEFAULT, value);
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
|
|
|
|
PDE1_PROTECTION_FAULT_ENABLE_DEFAULT, value);
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
|
|
|
|
PDE2_PROTECTION_FAULT_ENABLE_DEFAULT, value);
|
|
|
|
tmp = REG_SET_FIELD(tmp,
|
|
|
|
VM_L2_PROTECTION_FAULT_CNTL,
|
|
|
|
TRANSLATE_FURTHER_PROTECTION_FAULT_ENABLE_DEFAULT,
|
|
|
|
value);
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
|
|
|
|
NACK_PROTECTION_FAULT_ENABLE_DEFAULT, value);
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
|
|
|
|
DUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT, value);
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
|
|
|
|
VALID_PROTECTION_FAULT_ENABLE_DEFAULT, value);
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
|
|
|
|
READ_PROTECTION_FAULT_ENABLE_DEFAULT, value);
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
|
|
|
|
WRITE_PROTECTION_FAULT_ENABLE_DEFAULT, value);
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
|
|
|
|
EXECUTE_PROTECTION_FAULT_ENABLE_DEFAULT, value);
|
2017-07-04 16:40:58 +08:00
|
|
|
if (!value) {
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
|
|
|
|
CRASH_ON_NO_RETRY_FAULT, 1);
|
|
|
|
tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
|
|
|
|
CRASH_ON_RETRY_FAULT, 1);
|
|
|
|
}
|
|
|
|
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmVM_L2_PROTECTION_FAULT_CNTL, tmp);
|
2017-03-10 00:36:26 +08:00
|
|
|
}
|
|
|
|
|
2017-05-31 22:59:18 +08:00
|
|
|
void mmhub_v1_0_init(struct amdgpu_device *adev)
|
2017-03-10 00:36:26 +08:00
|
|
|
{
|
2019-07-17 02:29:19 +08:00
|
|
|
struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_MMHUB_0];
|
2017-03-10 00:36:26 +08:00
|
|
|
|
|
|
|
hub->ctx0_ptb_addr_lo32 =
|
|
|
|
SOC15_REG_OFFSET(MMHUB, 0,
|
|
|
|
mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LO32);
|
|
|
|
hub->ctx0_ptb_addr_hi32 =
|
|
|
|
SOC15_REG_OFFSET(MMHUB, 0,
|
|
|
|
mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_HI32);
|
|
|
|
hub->vm_inv_eng0_req =
|
|
|
|
SOC15_REG_OFFSET(MMHUB, 0, mmVM_INVALIDATE_ENG0_REQ);
|
|
|
|
hub->vm_inv_eng0_ack =
|
|
|
|
SOC15_REG_OFFSET(MMHUB, 0, mmVM_INVALIDATE_ENG0_ACK);
|
|
|
|
hub->vm_context0_cntl =
|
|
|
|
SOC15_REG_OFFSET(MMHUB, 0, mmVM_CONTEXT0_CNTL);
|
|
|
|
hub->vm_l2_pro_fault_status =
|
|
|
|
SOC15_REG_OFFSET(MMHUB, 0, mmVM_L2_PROTECTION_FAULT_STATUS);
|
|
|
|
hub->vm_l2_pro_fault_cntl =
|
|
|
|
SOC15_REG_OFFSET(MMHUB, 0, mmVM_L2_PROTECTION_FAULT_CNTL);
|
|
|
|
|
2017-05-31 22:59:18 +08:00
|
|
|
}
|
|
|
|
|
2017-03-10 00:36:26 +08:00
|
|
|
static void mmhub_v1_0_update_medium_grain_clock_gating(struct amdgpu_device *adev,
|
|
|
|
bool enable)
|
|
|
|
{
|
2017-02-08 17:07:59 +08:00
|
|
|
uint32_t def, data, def1, data1, def2 = 0, data2 = 0;
|
2017-03-10 00:36:26 +08:00
|
|
|
|
2017-06-01 15:30:04 +08:00
|
|
|
def = data = RREG32_SOC15(MMHUB, 0, mmATC_L2_MISC_CG);
|
2017-02-08 17:07:59 +08:00
|
|
|
|
2018-09-14 04:41:57 +08:00
|
|
|
if (adev->asic_type != CHIP_RAVEN) {
|
2017-06-01 15:30:04 +08:00
|
|
|
def1 = data1 = RREG32_SOC15(MMHUB, 0, mmDAGB0_CNTL_MISC2);
|
|
|
|
def2 = data2 = RREG32_SOC15(MMHUB, 0, mmDAGB1_CNTL_MISC2);
|
2017-02-08 17:07:59 +08:00
|
|
|
} else
|
2017-06-01 15:30:04 +08:00
|
|
|
def1 = data1 = RREG32_SOC15(MMHUB, 0, mmDAGB0_CNTL_MISC2_RV);
|
2017-03-10 00:36:26 +08:00
|
|
|
|
|
|
|
if (enable && (adev->cg_flags & AMD_CG_SUPPORT_MC_MGCG)) {
|
|
|
|
data |= ATC_L2_MISC_CG__ENABLE_MASK;
|
|
|
|
|
|
|
|
data1 &= ~(DAGB0_CNTL_MISC2__DISABLE_WRREQ_CG_MASK |
|
|
|
|
DAGB0_CNTL_MISC2__DISABLE_WRRET_CG_MASK |
|
|
|
|
DAGB0_CNTL_MISC2__DISABLE_RDREQ_CG_MASK |
|
|
|
|
DAGB0_CNTL_MISC2__DISABLE_RDRET_CG_MASK |
|
|
|
|
DAGB0_CNTL_MISC2__DISABLE_TLBWR_CG_MASK |
|
|
|
|
DAGB0_CNTL_MISC2__DISABLE_TLBRD_CG_MASK);
|
|
|
|
|
2018-09-14 04:41:57 +08:00
|
|
|
if (adev->asic_type != CHIP_RAVEN)
|
2017-02-08 17:07:59 +08:00
|
|
|
data2 &= ~(DAGB1_CNTL_MISC2__DISABLE_WRREQ_CG_MASK |
|
|
|
|
DAGB1_CNTL_MISC2__DISABLE_WRRET_CG_MASK |
|
|
|
|
DAGB1_CNTL_MISC2__DISABLE_RDREQ_CG_MASK |
|
|
|
|
DAGB1_CNTL_MISC2__DISABLE_RDRET_CG_MASK |
|
|
|
|
DAGB1_CNTL_MISC2__DISABLE_TLBWR_CG_MASK |
|
|
|
|
DAGB1_CNTL_MISC2__DISABLE_TLBRD_CG_MASK);
|
2017-03-10 00:36:26 +08:00
|
|
|
} else {
|
|
|
|
data &= ~ATC_L2_MISC_CG__ENABLE_MASK;
|
|
|
|
|
|
|
|
data1 |= (DAGB0_CNTL_MISC2__DISABLE_WRREQ_CG_MASK |
|
|
|
|
DAGB0_CNTL_MISC2__DISABLE_WRRET_CG_MASK |
|
|
|
|
DAGB0_CNTL_MISC2__DISABLE_RDREQ_CG_MASK |
|
|
|
|
DAGB0_CNTL_MISC2__DISABLE_RDRET_CG_MASK |
|
|
|
|
DAGB0_CNTL_MISC2__DISABLE_TLBWR_CG_MASK |
|
|
|
|
DAGB0_CNTL_MISC2__DISABLE_TLBRD_CG_MASK);
|
|
|
|
|
2018-09-14 04:41:57 +08:00
|
|
|
if (adev->asic_type != CHIP_RAVEN)
|
2017-02-08 17:07:59 +08:00
|
|
|
data2 |= (DAGB1_CNTL_MISC2__DISABLE_WRREQ_CG_MASK |
|
|
|
|
DAGB1_CNTL_MISC2__DISABLE_WRRET_CG_MASK |
|
|
|
|
DAGB1_CNTL_MISC2__DISABLE_RDREQ_CG_MASK |
|
|
|
|
DAGB1_CNTL_MISC2__DISABLE_RDRET_CG_MASK |
|
|
|
|
DAGB1_CNTL_MISC2__DISABLE_TLBWR_CG_MASK |
|
|
|
|
DAGB1_CNTL_MISC2__DISABLE_TLBRD_CG_MASK);
|
2017-03-10 00:36:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (def != data)
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmATC_L2_MISC_CG, data);
|
2017-03-10 00:36:26 +08:00
|
|
|
|
2017-02-08 17:07:59 +08:00
|
|
|
if (def1 != data1) {
|
2018-09-14 04:41:57 +08:00
|
|
|
if (adev->asic_type != CHIP_RAVEN)
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmDAGB0_CNTL_MISC2, data1);
|
2017-02-08 17:07:59 +08:00
|
|
|
else
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmDAGB0_CNTL_MISC2_RV, data1);
|
2017-02-08 17:07:59 +08:00
|
|
|
}
|
2017-03-10 00:36:26 +08:00
|
|
|
|
2018-09-14 04:41:57 +08:00
|
|
|
if (adev->asic_type != CHIP_RAVEN && def2 != data2)
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmDAGB1_CNTL_MISC2, data2);
|
2017-03-10 00:36:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mmhub_v1_0_update_medium_grain_light_sleep(struct amdgpu_device *adev,
|
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
uint32_t def, data;
|
|
|
|
|
2017-06-01 15:30:04 +08:00
|
|
|
def = data = RREG32_SOC15(MMHUB, 0, mmATC_L2_MISC_CG);
|
2017-03-10 00:36:26 +08:00
|
|
|
|
|
|
|
if (enable && (adev->cg_flags & AMD_CG_SUPPORT_MC_LS))
|
|
|
|
data |= ATC_L2_MISC_CG__MEM_LS_ENABLE_MASK;
|
|
|
|
else
|
|
|
|
data &= ~ATC_L2_MISC_CG__MEM_LS_ENABLE_MASK;
|
|
|
|
|
|
|
|
if (def != data)
|
2017-06-01 15:30:04 +08:00
|
|
|
WREG32_SOC15(MMHUB, 0, mmATC_L2_MISC_CG, data);
|
2017-03-10 00:36:26 +08:00
|
|
|
}
|
|
|
|
|
2017-05-31 23:13:34 +08:00
|
|
|
int mmhub_v1_0_set_clockgating(struct amdgpu_device *adev,
|
|
|
|
enum amd_clockgating_state state)
|
2017-03-10 00:36:26 +08:00
|
|
|
{
|
2017-04-14 17:40:57 +08:00
|
|
|
if (amdgpu_sriov_vf(adev))
|
|
|
|
return 0;
|
|
|
|
|
2017-03-10 00:36:26 +08:00
|
|
|
switch (adev->asic_type) {
|
|
|
|
case CHIP_VEGA10:
|
2017-09-02 04:39:10 +08:00
|
|
|
case CHIP_VEGA12:
|
2018-04-20 13:58:09 +08:00
|
|
|
case CHIP_VEGA20:
|
2017-02-08 17:07:59 +08:00
|
|
|
case CHIP_RAVEN:
|
2019-07-29 15:13:42 +08:00
|
|
|
case CHIP_RENOIR:
|
2017-03-10 00:36:26 +08:00
|
|
|
mmhub_v1_0_update_medium_grain_clock_gating(adev,
|
|
|
|
state == AMD_CG_STATE_GATE ? true : false);
|
|
|
|
mmhub_v1_0_update_medium_grain_light_sleep(adev,
|
|
|
|
state == AMD_CG_STATE_GATE ? true : false);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-05-31 23:35:44 +08:00
|
|
|
void mmhub_v1_0_get_clockgating(struct amdgpu_device *adev, u32 *flags)
|
2017-03-24 11:52:23 +08:00
|
|
|
{
|
2019-08-08 14:54:12 +08:00
|
|
|
int data, data1;
|
2017-03-24 11:52:23 +08:00
|
|
|
|
|
|
|
if (amdgpu_sriov_vf(adev))
|
|
|
|
*flags = 0;
|
|
|
|
|
2019-08-08 14:54:12 +08:00
|
|
|
data = RREG32_SOC15(MMHUB, 0, mmATC_L2_MISC_CG);
|
|
|
|
|
|
|
|
data1 = RREG32_SOC15(MMHUB, 0, mmDAGB0_CNTL_MISC2);
|
|
|
|
|
2017-03-24 11:52:23 +08:00
|
|
|
/* AMD_CG_SUPPORT_MC_MGCG */
|
2019-08-08 14:54:12 +08:00
|
|
|
if ((data & ATC_L2_MISC_CG__ENABLE_MASK) &&
|
|
|
|
!(data1 & (DAGB0_CNTL_MISC2__DISABLE_WRREQ_CG_MASK |
|
|
|
|
DAGB0_CNTL_MISC2__DISABLE_WRRET_CG_MASK |
|
|
|
|
DAGB0_CNTL_MISC2__DISABLE_RDREQ_CG_MASK |
|
|
|
|
DAGB0_CNTL_MISC2__DISABLE_RDRET_CG_MASK |
|
|
|
|
DAGB0_CNTL_MISC2__DISABLE_TLBWR_CG_MASK |
|
|
|
|
DAGB0_CNTL_MISC2__DISABLE_TLBRD_CG_MASK)))
|
2017-03-24 11:52:23 +08:00
|
|
|
*flags |= AMD_CG_SUPPORT_MC_MGCG;
|
|
|
|
|
|
|
|
/* AMD_CG_SUPPORT_MC_LS */
|
|
|
|
if (data & ATC_L2_MISC_CG__MEM_LS_ENABLE_MASK)
|
|
|
|
*flags |= AMD_CG_SUPPORT_MC_LS;
|
|
|
|
}
|
2019-08-06 20:15:55 +08:00
|
|
|
|
|
|
|
static void mmhub_v1_0_query_ras_error_count(struct amdgpu_device *adev,
|
|
|
|
void *ras_error_status)
|
|
|
|
{
|
2019-08-13 15:46:03 +08:00
|
|
|
int i;
|
|
|
|
uint32_t ea0_edc_cnt, ea0_edc_cnt2;
|
|
|
|
uint32_t ea1_edc_cnt, ea1_edc_cnt2;
|
|
|
|
struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status;
|
|
|
|
|
|
|
|
/* EDC CNT will be cleared automatically after read */
|
|
|
|
ea0_edc_cnt = RREG32_SOC15(MMHUB, 0, mmMMEA0_EDC_CNT_VG20);
|
|
|
|
ea0_edc_cnt2 = RREG32_SOC15(MMHUB, 0, mmMMEA0_EDC_CNT2_VG20);
|
|
|
|
ea1_edc_cnt = RREG32_SOC15(MMHUB, 0, mmMMEA1_EDC_CNT_VG20);
|
|
|
|
ea1_edc_cnt2 = RREG32_SOC15(MMHUB, 0, mmMMEA1_EDC_CNT2_VG20);
|
|
|
|
|
|
|
|
/* error count of each error type is recorded by 2 bits,
|
|
|
|
* ce and ue count in EDC_CNT
|
|
|
|
*/
|
|
|
|
for (i = 0; i < 5; i++) {
|
|
|
|
err_data->ce_count += (ea0_edc_cnt & EA_EDC_CNT_MASK);
|
|
|
|
err_data->ce_count += (ea1_edc_cnt & EA_EDC_CNT_MASK);
|
|
|
|
ea0_edc_cnt >>= EA_EDC_CNT_SHIFT;
|
|
|
|
ea1_edc_cnt >>= EA_EDC_CNT_SHIFT;
|
|
|
|
err_data->ue_count += (ea0_edc_cnt & EA_EDC_CNT_MASK);
|
|
|
|
err_data->ue_count += (ea1_edc_cnt & EA_EDC_CNT_MASK);
|
|
|
|
ea0_edc_cnt >>= EA_EDC_CNT_SHIFT;
|
|
|
|
ea1_edc_cnt >>= EA_EDC_CNT_SHIFT;
|
|
|
|
}
|
|
|
|
/* successive ue count in EDC_CNT */
|
|
|
|
for (i = 0; i < 5; i++) {
|
|
|
|
err_data->ue_count += (ea0_edc_cnt & EA_EDC_CNT_MASK);
|
|
|
|
err_data->ue_count += (ea1_edc_cnt & EA_EDC_CNT_MASK);
|
|
|
|
ea0_edc_cnt >>= EA_EDC_CNT_SHIFT;
|
|
|
|
ea1_edc_cnt >>= EA_EDC_CNT_SHIFT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ce and ue count in EDC_CNT2 */
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
err_data->ce_count += (ea0_edc_cnt2 & EA_EDC_CNT_MASK);
|
|
|
|
err_data->ce_count += (ea1_edc_cnt2 & EA_EDC_CNT_MASK);
|
|
|
|
ea0_edc_cnt2 >>= EA_EDC_CNT_SHIFT;
|
|
|
|
ea1_edc_cnt2 >>= EA_EDC_CNT_SHIFT;
|
|
|
|
err_data->ue_count += (ea0_edc_cnt2 & EA_EDC_CNT_MASK);
|
|
|
|
err_data->ue_count += (ea1_edc_cnt2 & EA_EDC_CNT_MASK);
|
|
|
|
ea0_edc_cnt2 >>= EA_EDC_CNT_SHIFT;
|
|
|
|
ea1_edc_cnt2 >>= EA_EDC_CNT_SHIFT;
|
|
|
|
}
|
|
|
|
/* successive ue count in EDC_CNT2 */
|
|
|
|
for (i = 0; i < 6; i++) {
|
|
|
|
err_data->ue_count += (ea0_edc_cnt2 & EA_EDC_CNT_MASK);
|
|
|
|
err_data->ue_count += (ea1_edc_cnt2 & EA_EDC_CNT_MASK);
|
|
|
|
ea0_edc_cnt2 >>= EA_EDC_CNT_SHIFT;
|
|
|
|
ea1_edc_cnt2 >>= EA_EDC_CNT_SHIFT;
|
|
|
|
}
|
2019-08-06 20:15:55 +08:00
|
|
|
}
|
|
|
|
|
2019-08-30 13:34:38 +08:00
|
|
|
static int mmhub_v1_0_ras_late_init(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
struct ras_ih_if mmhub_ih_info = {
|
|
|
|
.cb = NULL,
|
|
|
|
};
|
|
|
|
struct ras_fs_if mmhub_fs_info = {
|
|
|
|
.sysfs_name = "mmhub_err_count",
|
|
|
|
.debugfs_name = "mmhub_err_inject",
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!adev->gmc.mmhub_ras_if) {
|
|
|
|
adev->gmc.mmhub_ras_if = kmalloc(sizeof(struct ras_common_if), GFP_KERNEL);
|
|
|
|
if (!adev->gmc.mmhub_ras_if)
|
|
|
|
return -ENOMEM;
|
|
|
|
adev->gmc.mmhub_ras_if->block = AMDGPU_RAS_BLOCK__MMHUB;
|
|
|
|
adev->gmc.mmhub_ras_if->type = AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE;
|
|
|
|
adev->gmc.mmhub_ras_if->sub_block_index = 0;
|
|
|
|
strcpy(adev->gmc.mmhub_ras_if->name, "mmhub");
|
|
|
|
}
|
|
|
|
mmhub_ih_info.head = mmhub_fs_info.head = *adev->gmc.mmhub_ras_if;
|
|
|
|
r = amdgpu_ras_late_init(adev, adev->gmc.mmhub_ras_if,
|
|
|
|
&mmhub_fs_info, &mmhub_ih_info);
|
2019-09-03 03:16:47 +08:00
|
|
|
if (r || !amdgpu_ras_is_supported(adev, adev->gmc.mmhub_ras_if->block)) {
|
2019-08-30 13:34:38 +08:00
|
|
|
kfree(adev->gmc.mmhub_ras_if);
|
2019-09-03 03:16:47 +08:00
|
|
|
adev->gmc.mmhub_ras_if = NULL;
|
|
|
|
}
|
2019-08-30 13:34:38 +08:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2019-08-06 20:15:55 +08:00
|
|
|
const struct amdgpu_mmhub_funcs mmhub_v1_0_funcs = {
|
2019-08-30 13:34:38 +08:00
|
|
|
.ras_late_init = mmhub_v1_0_ras_late_init,
|
2019-08-06 20:15:55 +08:00
|
|
|
.query_ras_error_count = mmhub_v1_0_query_ras_error_count,
|
|
|
|
};
|