2017-03-04 06:59:39 +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.
|
|
|
|
*
|
|
|
|
*/
|
2017-10-16 10:29:23 +08:00
|
|
|
#include <linux/kernel.h>
|
2017-03-04 06:59:39 +08:00
|
|
|
#include <linux/firmware.h>
|
2017-04-24 12:50:21 +08:00
|
|
|
#include <drm/drmP.h>
|
2017-03-04 06:59:39 +08:00
|
|
|
#include "amdgpu.h"
|
|
|
|
#include "amdgpu_gfx.h"
|
|
|
|
#include "soc15.h"
|
|
|
|
#include "soc15d.h"
|
2018-04-20 12:31:04 +08:00
|
|
|
#include "amdgpu_atomfirmware.h"
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-11-24 10:29:00 +08:00
|
|
|
#include "gc/gc_9_0_offset.h"
|
|
|
|
#include "gc/gc_9_0_sh_mask.h"
|
2017-11-24 12:31:36 +08:00
|
|
|
#include "vega10_enum.h"
|
2017-11-15 18:09:33 +08:00
|
|
|
#include "hdp/hdp_4_0_offset.h"
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
#include "soc15_common.h"
|
|
|
|
#include "clearstate_gfx9.h"
|
|
|
|
#include "v9_structs.h"
|
|
|
|
|
2018-05-25 22:45:34 +08:00
|
|
|
#include "ivsrcid/gfx/irqsrcs_gfx_9_0.h"
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
#define GFX9_NUM_GFX_RINGS 1
|
2018-10-06 04:43:44 +08:00
|
|
|
#define GFX9_MEC_HPD_SIZE 4096
|
2017-02-10 14:37:03 +08:00
|
|
|
#define RLCG_UCODE_LOADING_START_ADDRESS 0x00002000L
|
|
|
|
#define RLC_SAVE_RESTORE_ADDR_STARTING_OFFSET 0x00000000L
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-02-10 15:13:17 +08:00
|
|
|
#define mmPWR_MISC_CNTL_STATUS 0x0183
|
|
|
|
#define mmPWR_MISC_CNTL_STATUS_BASE_IDX 0
|
|
|
|
#define PWR_MISC_CNTL_STATUS__PWR_GFX_RLC_CGPG_EN__SHIFT 0x0
|
|
|
|
#define PWR_MISC_CNTL_STATUS__PWR_GFXOFF_STATUS__SHIFT 0x1
|
|
|
|
#define PWR_MISC_CNTL_STATUS__PWR_GFX_RLC_CGPG_EN_MASK 0x00000001L
|
|
|
|
#define PWR_MISC_CNTL_STATUS__PWR_GFXOFF_STATUS_MASK 0x00000006L
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
MODULE_FIRMWARE("amdgpu/vega10_ce.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/vega10_pfp.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/vega10_me.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/vega10_mec.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/vega10_mec2.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/vega10_rlc.bin");
|
|
|
|
|
2017-09-02 14:10:18 +08:00
|
|
|
MODULE_FIRMWARE("amdgpu/vega12_ce.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/vega12_pfp.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/vega12_me.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/vega12_mec.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/vega12_mec2.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/vega12_rlc.bin");
|
|
|
|
|
2018-04-20 14:22:48 +08:00
|
|
|
MODULE_FIRMWARE("amdgpu/vega20_ce.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/vega20_pfp.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/vega20_me.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/vega20_mec.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/vega20_mec2.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/vega20_rlc.bin");
|
|
|
|
|
2016-12-13 15:58:33 +08:00
|
|
|
MODULE_FIRMWARE("amdgpu/raven_ce.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/raven_pfp.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/raven_me.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/raven_mec.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/raven_mec2.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/raven_rlc.bin");
|
|
|
|
|
2018-07-10 20:29:12 +08:00
|
|
|
MODULE_FIRMWARE("amdgpu/picasso_ce.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/picasso_pfp.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/picasso_me.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/picasso_mec.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/picasso_mec2.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/picasso_rlc.bin");
|
2018-12-05 11:07:55 +08:00
|
|
|
MODULE_FIRMWARE("amdgpu/picasso_rlc_am4.bin");
|
2018-07-10 20:29:12 +08:00
|
|
|
|
2018-01-04 18:33:49 +08:00
|
|
|
MODULE_FIRMWARE("amdgpu/raven2_ce.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/raven2_pfp.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/raven2_me.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/raven2_mec.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/raven2_mec2.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/raven2_rlc.bin");
|
|
|
|
|
2017-11-29 06:01:21 +08:00
|
|
|
static const struct soc15_reg_golden golden_settings_gc_9_0[] =
|
|
|
|
{
|
2018-07-26 12:31:34 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG2, 0xf00fffff, 0x00000400),
|
2018-10-16 14:54:46 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG3, 0x80000000, 0x80000000),
|
2017-11-29 06:01:21 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_GPU_ID, 0x0000000f, 0x00000000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_BINNER_EVENT_CNTL_3, 0x00000003, 0x82400024),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE, 0x3fffffff, 0x00000001),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSH_MEM_CONFIG, 0x00001000, 0x00001000),
|
2018-03-10 05:15:18 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_RESOURCE_RESERVE_CU_0, 0x0007ffff, 0x00000800),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_RESOURCE_RESERVE_CU_1, 0x0007ffff, 0x00000800),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_RESOURCE_RESERVE_EN_CU_0, 0x01ffffff, 0x0000ff87),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_RESOURCE_RESERVE_EN_CU_1, 0x01ffffff, 0x0000ff8f),
|
2017-11-29 06:01:21 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQC_CONFIG, 0x03000000, 0x020a2000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTA_CNTL_AUX, 0xfffffeef, 0x010b0000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_HI, 0xffffffff, 0x4a2c0e68),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_LO, 0xffffffff, 0xb5d3f197),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_CACHE_INVALIDATION, 0x3fff3af3, 0x19200000),
|
2018-03-10 05:15:18 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_GS_MAX_WAVE_ID, 0x00000fff, 0x000003ff)
|
2017-03-04 06:59:39 +08:00
|
|
|
};
|
|
|
|
|
2017-11-29 06:01:21 +08:00
|
|
|
static const struct soc15_reg_golden golden_settings_gc_9_0_vg10[] =
|
2017-03-04 06:59:39 +08:00
|
|
|
{
|
2017-11-29 06:01:21 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL, 0x0000f000, 0x00012107),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_3, 0x30000000, 0x10000000),
|
2018-07-17 14:54:23 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCPC_UTCL1_CNTL, 0x08000000, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCPF_UTCL1_CNTL, 0x08000000, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCPG_UTCL1_CNTL, 0x08000000, 0x08000080),
|
2017-11-29 06:01:21 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_ADDR_CONFIG, 0xffff77ff, 0x2a114042),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_ADDR_CONFIG_READ, 0xffff77ff, 0x2a114042),
|
2018-07-17 14:54:23 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmIA_UTCL1_CNTL, 0x08000000, 0x08000080),
|
2017-11-29 06:01:21 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_1, 0x00008000, 0x00048000),
|
2018-07-17 14:54:23 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_GPM_UTCL1_CNTL_0, 0x08000000, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_GPM_UTCL1_CNTL_1, 0x08000000, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_GPM_UTCL1_CNTL_2, 0x08000000, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_PREWALKER_UTCL1_CNTL, 0x08000000, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_UTCL1_CNTL, 0x08000000, 0x08000080),
|
2017-11-29 06:01:21 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_UTCL1_CNTL2, 0x00030000, 0x00020000),
|
2018-07-17 14:54:23 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL_1, 0x0000000f, 0x01000107),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x00001800, 0x00000800),
|
2018-10-09 11:40:31 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmWD_UTCL1_CNTL, 0x08000000, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC1_F32_INT_DIS, 0x00000000, 0x00000800),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC2_F32_INT_DIS, 0x00000000, 0x00000800),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_DEBUG, 0x00000000, 0x00008000)
|
2017-03-04 06:59:39 +08:00
|
|
|
};
|
|
|
|
|
2018-01-23 14:47:26 +08:00
|
|
|
static const struct soc15_reg_golden golden_settings_gc_9_0_vg20[] =
|
|
|
|
{
|
2018-05-24 15:36:57 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_DCC_CONFIG, 0x0f000080, 0x04000080),
|
2018-01-23 14:47:26 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_2, 0x0f000000, 0x0a000000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_3, 0x30000000, 0x10000000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_ADDR_CONFIG, 0xf3e777ff, 0x22014042),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_ADDR_CONFIG_READ, 0xf3e777ff, 0x22014042),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG2, 0x00003e00, 0x00000400),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_1, 0xff840000, 0x04040000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_UTCL1_CNTL2, 0x00030000, 0x00030000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL_1, 0xffff010f, 0x01000107),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTA_CNTL_AUX, 0x000b0000, 0x000b0000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x01000000, 0x01000000)
|
|
|
|
};
|
|
|
|
|
2017-11-29 06:01:21 +08:00
|
|
|
static const struct soc15_reg_golden golden_settings_gc_9_1[] =
|
|
|
|
{
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL, 0xfffdf3cf, 0x00014104),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCPC_UTCL1_CNTL, 0x08000000, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCPF_UTCL1_CNTL, 0x08000000, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCPG_UTCL1_CNTL, 0x08000000, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG2, 0xf00fffff, 0x00000420),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_GPU_ID, 0x0000000f, 0x00000000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmIA_UTCL1_CNTL, 0x08000000, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_BINNER_EVENT_CNTL_3, 0x00000003, 0x82400024),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE, 0x3fffffff, 0x00000001),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_GPM_UTCL1_CNTL_0, 0x08000000, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_GPM_UTCL1_CNTL_1, 0x08000000, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_GPM_UTCL1_CNTL_2, 0x08000000, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_PREWALKER_UTCL1_CNTL, 0x08000000, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_UTCL1_CNTL, 0x08000000, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTA_CNTL_AUX, 0xfffffeef, 0x010b0000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00003120),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_CACHE_INVALIDATION, 0x3fff3af3, 0x19200000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_GS_MAX_WAVE_ID, 0x00000fff, 0x000000ff),
|
2018-10-09 11:40:31 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmWD_UTCL1_CNTL, 0x08000000, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC1_F32_INT_DIS, 0x00000000, 0x00000800),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC2_F32_INT_DIS, 0x00000000, 0x00000800),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_DEBUG, 0x00000000, 0x00008000)
|
2016-12-08 10:41:58 +08:00
|
|
|
};
|
|
|
|
|
2017-11-29 06:01:21 +08:00
|
|
|
static const struct soc15_reg_golden golden_settings_gc_9_1_rv1[] =
|
2016-12-08 10:41:58 +08:00
|
|
|
{
|
2017-11-29 06:01:21 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_3, 0x30000000, 0x10000000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_ADDR_CONFIG, 0xffff77ff, 0x24000042),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_ADDR_CONFIG_READ, 0xffff77ff, 0x24000042),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_1, 0xffffffff, 0x04048000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_MODE_CNTL_1, 0x06000000, 0x06000000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_UTCL1_CNTL2, 0x00030000, 0x00020000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x01bd9f33, 0x00000800)
|
2017-03-04 06:59:39 +08:00
|
|
|
};
|
|
|
|
|
2018-01-04 18:36:40 +08:00
|
|
|
static const struct soc15_reg_golden golden_settings_gc_9_1_rv2[] =
|
|
|
|
{
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_DCC_CONFIG, 0xff7fffff, 0x04000000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL, 0xfffdf3cf, 0x00014104),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_2, 0xff7fffff, 0x0a000000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCPC_UTCL1_CNTL, 0x7f0fffff, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCPF_UTCL1_CNTL, 0xff8fffff, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCPG_UTCL1_CNTL, 0x7f8fffff, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_ADDR_CONFIG, 0xffff77ff, 0x26013041),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_ADDR_CONFIG_READ, 0xffff77ff, 0x26013041),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmIA_UTCL1_CNTL, 0x3f8fffff, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_1, 0xffffffff, 0x04040000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_GPM_UTCL1_CNTL_0, 0xff0fffff, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_GPM_UTCL1_CNTL_1, 0xff0fffff, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_GPM_UTCL1_CNTL_2, 0xff0fffff, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_PREWALKER_UTCL1_CNTL, 0xff0fffff, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_UTCL1_CNTL, 0xff0fffff, 0x08000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00000010),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x01bd9f33, 0x01000000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmWD_UTCL1_CNTL, 0x3f8fffff, 0x08000080),
|
|
|
|
};
|
|
|
|
|
2017-11-29 06:01:21 +08:00
|
|
|
static const struct soc15_reg_golden golden_settings_gc_9_x_common[] =
|
2017-11-09 16:02:55 +08:00
|
|
|
{
|
2017-11-29 06:01:21 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_CAM_INDEX, 0xffffffff, 0x00000000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_CAM_DATA, 0xffffffff, 0x2544c382)
|
2017-11-09 16:02:55 +08:00
|
|
|
};
|
|
|
|
|
2018-03-12 14:55:48 +08:00
|
|
|
static const struct soc15_reg_golden golden_settings_gc_9_2_1[] =
|
|
|
|
{
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG2, 0xf00fffff, 0x00000420),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_GPU_ID, 0x0000000f, 0x00000000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_BINNER_EVENT_CNTL_3, 0x00000003, 0x82400024),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE, 0x3fffffff, 0x00000001),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSH_MEM_CONFIG, 0x00001000, 0x00001000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_RESOURCE_RESERVE_CU_0, 0x0007ffff, 0x00000800),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_RESOURCE_RESERVE_CU_1, 0x0007ffff, 0x00000800),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_RESOURCE_RESERVE_EN_CU_0, 0x01ffffff, 0x0000ff87),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_RESOURCE_RESERVE_EN_CU_1, 0x01ffffff, 0x0000ff8f),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQC_CONFIG, 0x03000000, 0x020a2000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTA_CNTL_AUX, 0xfffffeef, 0x010b0000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_HI, 0xffffffff, 0x4a2c0e68),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_LO, 0xffffffff, 0xb5d3f197),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_CACHE_INVALIDATION, 0x3fff3af3, 0x19200000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_GS_MAX_WAVE_ID, 0x00000fff, 0x000003ff)
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct soc15_reg_golden golden_settings_gc_9_2_1_vg12[] =
|
|
|
|
{
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_DCC_CONFIG, 0x00000080, 0x04000080),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL, 0xfffdf3cf, 0x00014104),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_2, 0x0f000000, 0x0a000000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_ADDR_CONFIG, 0xffff77ff, 0x24104041),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_ADDR_CONFIG_READ, 0xffff77ff, 0x24104041),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_1, 0xffffffff, 0x04040000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL_1, 0xffff03ff, 0x01000107),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_LO, 0xffffffff, 0x76325410),
|
2018-10-09 11:40:31 +08:00
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x01bd9f33, 0x01000000),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC1_F32_INT_DIS, 0x00000000, 0x00000800),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC2_F32_INT_DIS, 0x00000000, 0x00000800),
|
|
|
|
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_DEBUG, 0x00000000, 0x00008000)
|
2018-03-12 14:55:48 +08:00
|
|
|
};
|
|
|
|
|
2017-12-21 16:13:02 +08:00
|
|
|
static const u32 GFX_RLC_SRM_INDEX_CNTL_ADDR_OFFSETS[] =
|
|
|
|
{
|
|
|
|
mmRLC_SRM_INDEX_CNTL_ADDR_0 - mmRLC_SRM_INDEX_CNTL_ADDR_0,
|
|
|
|
mmRLC_SRM_INDEX_CNTL_ADDR_1 - mmRLC_SRM_INDEX_CNTL_ADDR_0,
|
|
|
|
mmRLC_SRM_INDEX_CNTL_ADDR_2 - mmRLC_SRM_INDEX_CNTL_ADDR_0,
|
|
|
|
mmRLC_SRM_INDEX_CNTL_ADDR_3 - mmRLC_SRM_INDEX_CNTL_ADDR_0,
|
|
|
|
mmRLC_SRM_INDEX_CNTL_ADDR_4 - mmRLC_SRM_INDEX_CNTL_ADDR_0,
|
|
|
|
mmRLC_SRM_INDEX_CNTL_ADDR_5 - mmRLC_SRM_INDEX_CNTL_ADDR_0,
|
|
|
|
mmRLC_SRM_INDEX_CNTL_ADDR_6 - mmRLC_SRM_INDEX_CNTL_ADDR_0,
|
|
|
|
mmRLC_SRM_INDEX_CNTL_ADDR_7 - mmRLC_SRM_INDEX_CNTL_ADDR_0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u32 GFX_RLC_SRM_INDEX_CNTL_DATA_OFFSETS[] =
|
|
|
|
{
|
|
|
|
mmRLC_SRM_INDEX_CNTL_DATA_0 - mmRLC_SRM_INDEX_CNTL_DATA_0,
|
|
|
|
mmRLC_SRM_INDEX_CNTL_DATA_1 - mmRLC_SRM_INDEX_CNTL_DATA_0,
|
|
|
|
mmRLC_SRM_INDEX_CNTL_DATA_2 - mmRLC_SRM_INDEX_CNTL_DATA_0,
|
|
|
|
mmRLC_SRM_INDEX_CNTL_DATA_3 - mmRLC_SRM_INDEX_CNTL_DATA_0,
|
|
|
|
mmRLC_SRM_INDEX_CNTL_DATA_4 - mmRLC_SRM_INDEX_CNTL_DATA_0,
|
|
|
|
mmRLC_SRM_INDEX_CNTL_DATA_5 - mmRLC_SRM_INDEX_CNTL_DATA_0,
|
|
|
|
mmRLC_SRM_INDEX_CNTL_DATA_6 - mmRLC_SRM_INDEX_CNTL_DATA_0,
|
|
|
|
mmRLC_SRM_INDEX_CNTL_DATA_7 - mmRLC_SRM_INDEX_CNTL_DATA_0,
|
|
|
|
};
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
#define VEGA10_GB_ADDR_CONFIG_GOLDEN 0x2a114042
|
2018-03-12 14:55:48 +08:00
|
|
|
#define VEGA12_GB_ADDR_CONFIG_GOLDEN 0x24104041
|
2017-05-25 14:58:14 +08:00
|
|
|
#define RAVEN_GB_ADDR_CONFIG_GOLDEN 0x24000042
|
2018-01-04 18:36:40 +08:00
|
|
|
#define RAVEN2_GB_ADDR_CONFIG_GOLDEN 0x26013041
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
static void gfx_v9_0_set_ring_funcs(struct amdgpu_device *adev);
|
|
|
|
static void gfx_v9_0_set_irq_funcs(struct amdgpu_device *adev);
|
|
|
|
static void gfx_v9_0_set_gds_init(struct amdgpu_device *adev);
|
|
|
|
static void gfx_v9_0_set_rlc_funcs(struct amdgpu_device *adev);
|
|
|
|
static int gfx_v9_0_get_cu_info(struct amdgpu_device *adev,
|
|
|
|
struct amdgpu_cu_info *cu_info);
|
|
|
|
static uint64_t gfx_v9_0_get_gpu_clock_counter(struct amdgpu_device *adev);
|
|
|
|
static void gfx_v9_0_select_se_sh(struct amdgpu_device *adev, u32 se_num, u32 sh_num, u32 instance);
|
2017-05-01 17:05:02 +08:00
|
|
|
static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring *ring);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
static void gfx_v9_0_init_golden_registers(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
switch (adev->asic_type) {
|
|
|
|
case CHIP_VEGA10:
|
2017-11-29 06:01:21 +08:00
|
|
|
soc15_program_register_sequence(adev,
|
2017-03-04 06:59:39 +08:00
|
|
|
golden_settings_gc_9_0,
|
2017-11-03 22:59:25 +08:00
|
|
|
ARRAY_SIZE(golden_settings_gc_9_0));
|
2017-11-29 06:01:21 +08:00
|
|
|
soc15_program_register_sequence(adev,
|
2017-03-04 06:59:39 +08:00
|
|
|
golden_settings_gc_9_0_vg10,
|
2017-11-03 22:59:25 +08:00
|
|
|
ARRAY_SIZE(golden_settings_gc_9_0_vg10));
|
2017-03-04 06:59:39 +08:00
|
|
|
break;
|
2017-09-02 14:22:49 +08:00
|
|
|
case CHIP_VEGA12:
|
2018-03-12 14:55:48 +08:00
|
|
|
soc15_program_register_sequence(adev,
|
|
|
|
golden_settings_gc_9_2_1,
|
|
|
|
ARRAY_SIZE(golden_settings_gc_9_2_1));
|
|
|
|
soc15_program_register_sequence(adev,
|
|
|
|
golden_settings_gc_9_2_1_vg12,
|
|
|
|
ARRAY_SIZE(golden_settings_gc_9_2_1_vg12));
|
2017-09-02 14:22:49 +08:00
|
|
|
break;
|
2018-01-23 14:47:26 +08:00
|
|
|
case CHIP_VEGA20:
|
|
|
|
soc15_program_register_sequence(adev,
|
|
|
|
golden_settings_gc_9_0,
|
|
|
|
ARRAY_SIZE(golden_settings_gc_9_0));
|
|
|
|
soc15_program_register_sequence(adev,
|
|
|
|
golden_settings_gc_9_0_vg20,
|
|
|
|
ARRAY_SIZE(golden_settings_gc_9_0_vg20));
|
|
|
|
break;
|
2016-12-08 10:41:58 +08:00
|
|
|
case CHIP_RAVEN:
|
2018-01-04 18:36:40 +08:00
|
|
|
soc15_program_register_sequence(adev, golden_settings_gc_9_1,
|
|
|
|
ARRAY_SIZE(golden_settings_gc_9_1));
|
|
|
|
if (adev->rev_id >= 8)
|
|
|
|
soc15_program_register_sequence(adev,
|
|
|
|
golden_settings_gc_9_1_rv2,
|
|
|
|
ARRAY_SIZE(golden_settings_gc_9_1_rv2));
|
|
|
|
else
|
|
|
|
soc15_program_register_sequence(adev,
|
|
|
|
golden_settings_gc_9_1_rv1,
|
|
|
|
ARRAY_SIZE(golden_settings_gc_9_1_rv1));
|
|
|
|
break;
|
2017-03-04 06:59:39 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2017-11-09 16:02:55 +08:00
|
|
|
|
2017-11-29 06:01:21 +08:00
|
|
|
soc15_program_register_sequence(adev, golden_settings_gc_9_x_common,
|
2017-11-09 16:02:55 +08:00
|
|
|
(const u32)ARRAY_SIZE(golden_settings_gc_9_x_common));
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_scratch_init(struct amdgpu_device *adev)
|
|
|
|
{
|
2017-07-10 10:17:08 +08:00
|
|
|
adev->gfx.scratch.num_reg = 8;
|
2017-03-04 06:59:39 +08:00
|
|
|
adev->gfx.scratch.reg_base = SOC15_REG_OFFSET(GC, 0, mmSCRATCH_REG0);
|
|
|
|
adev->gfx.scratch.free_mask = (1u << adev->gfx.scratch.num_reg) - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_write_data_to_reg(struct amdgpu_ring *ring, int eng_sel,
|
|
|
|
bool wc, uint32_t reg, uint32_t val)
|
|
|
|
{
|
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
|
|
|
|
amdgpu_ring_write(ring, WRITE_DATA_ENGINE_SEL(eng_sel) |
|
|
|
|
WRITE_DATA_DST_SEL(0) |
|
|
|
|
(wc ? WR_CONFIRM : 0));
|
|
|
|
amdgpu_ring_write(ring, reg);
|
|
|
|
amdgpu_ring_write(ring, 0);
|
|
|
|
amdgpu_ring_write(ring, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_wait_reg_mem(struct amdgpu_ring *ring, int eng_sel,
|
|
|
|
int mem_space, int opt, uint32_t addr0,
|
|
|
|
uint32_t addr1, uint32_t ref, uint32_t mask,
|
|
|
|
uint32_t inv)
|
|
|
|
{
|
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_WAIT_REG_MEM, 5));
|
|
|
|
amdgpu_ring_write(ring,
|
|
|
|
/* memory (1) or register (0) */
|
|
|
|
(WAIT_REG_MEM_MEM_SPACE(mem_space) |
|
|
|
|
WAIT_REG_MEM_OPERATION(opt) | /* wait */
|
|
|
|
WAIT_REG_MEM_FUNCTION(3) | /* equal */
|
|
|
|
WAIT_REG_MEM_ENGINE(eng_sel)));
|
|
|
|
|
|
|
|
if (mem_space)
|
|
|
|
BUG_ON(addr0 & 0x3); /* Dword align */
|
|
|
|
amdgpu_ring_write(ring, addr0);
|
|
|
|
amdgpu_ring_write(ring, addr1);
|
|
|
|
amdgpu_ring_write(ring, ref);
|
|
|
|
amdgpu_ring_write(ring, mask);
|
|
|
|
amdgpu_ring_write(ring, inv); /* poll interval */
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_ring_test_ring(struct amdgpu_ring *ring)
|
|
|
|
{
|
|
|
|
struct amdgpu_device *adev = ring->adev;
|
|
|
|
uint32_t scratch;
|
|
|
|
uint32_t tmp = 0;
|
|
|
|
unsigned i;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
r = amdgpu_gfx_scratch_get(adev, &scratch);
|
2018-10-29 17:48:31 +08:00
|
|
|
if (r)
|
2017-03-04 06:59:39 +08:00
|
|
|
return r;
|
2018-10-29 17:48:31 +08:00
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
WREG32(scratch, 0xCAFEDEAD);
|
|
|
|
r = amdgpu_ring_alloc(ring, 3);
|
2018-10-29 17:48:31 +08:00
|
|
|
if (r)
|
|
|
|
goto error_free_scratch;
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_SET_UCONFIG_REG, 1));
|
|
|
|
amdgpu_ring_write(ring, (scratch - PACKET3_SET_UCONFIG_REG_START));
|
|
|
|
amdgpu_ring_write(ring, 0xDEADBEEF);
|
|
|
|
amdgpu_ring_commit(ring);
|
|
|
|
|
|
|
|
for (i = 0; i < adev->usec_timeout; i++) {
|
|
|
|
tmp = RREG32(scratch);
|
|
|
|
if (tmp == 0xDEADBEEF)
|
|
|
|
break;
|
|
|
|
DRM_UDELAY(1);
|
|
|
|
}
|
2018-10-29 17:48:31 +08:00
|
|
|
|
|
|
|
if (i >= adev->usec_timeout)
|
|
|
|
r = -ETIMEDOUT;
|
|
|
|
|
|
|
|
error_free_scratch:
|
2017-03-04 06:59:39 +08:00
|
|
|
amdgpu_gfx_scratch_free(adev, scratch);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_ring_test_ib(struct amdgpu_ring *ring, long timeout)
|
|
|
|
{
|
2018-01-23 18:29:22 +08:00
|
|
|
struct amdgpu_device *adev = ring->adev;
|
|
|
|
struct amdgpu_ib ib;
|
|
|
|
struct dma_fence *f = NULL;
|
|
|
|
|
|
|
|
unsigned index;
|
|
|
|
uint64_t gpu_addr;
|
|
|
|
uint32_t tmp;
|
|
|
|
long r;
|
|
|
|
|
|
|
|
r = amdgpu_device_wb_get(adev, &index);
|
2018-10-29 23:12:42 +08:00
|
|
|
if (r)
|
2018-01-23 18:29:22 +08:00
|
|
|
return r;
|
|
|
|
|
|
|
|
gpu_addr = adev->wb.gpu_addr + (index * 4);
|
|
|
|
adev->wb.wb[index] = cpu_to_le32(0xCAFEDEAD);
|
|
|
|
memset(&ib, 0, sizeof(ib));
|
|
|
|
r = amdgpu_ib_get(adev, NULL, 16, &ib);
|
2018-10-29 23:12:42 +08:00
|
|
|
if (r)
|
2018-01-23 18:29:22 +08:00
|
|
|
goto err1;
|
2018-10-29 23:12:42 +08:00
|
|
|
|
2018-01-23 18:29:22 +08:00
|
|
|
ib.ptr[0] = PACKET3(PACKET3_WRITE_DATA, 3);
|
|
|
|
ib.ptr[1] = WRITE_DATA_DST_SEL(5) | WR_CONFIRM;
|
|
|
|
ib.ptr[2] = lower_32_bits(gpu_addr);
|
|
|
|
ib.ptr[3] = upper_32_bits(gpu_addr);
|
|
|
|
ib.ptr[4] = 0xDEADBEEF;
|
|
|
|
ib.length_dw = 5;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2018-01-23 18:29:22 +08:00
|
|
|
r = amdgpu_ib_schedule(ring, 1, &ib, NULL, &f);
|
|
|
|
if (r)
|
|
|
|
goto err2;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2018-01-23 18:29:22 +08:00
|
|
|
r = dma_fence_wait_timeout(f, false, timeout);
|
|
|
|
if (r == 0) {
|
2018-10-29 23:12:42 +08:00
|
|
|
r = -ETIMEDOUT;
|
|
|
|
goto err2;
|
2018-01-23 18:29:22 +08:00
|
|
|
} else if (r < 0) {
|
2018-10-29 23:12:42 +08:00
|
|
|
goto err2;
|
2018-01-23 18:29:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
tmp = adev->wb.wb[index];
|
2018-10-29 23:12:42 +08:00
|
|
|
if (tmp == 0xDEADBEEF)
|
|
|
|
r = 0;
|
|
|
|
else
|
|
|
|
r = -EINVAL;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
err2:
|
2018-01-23 18:29:22 +08:00
|
|
|
amdgpu_ib_free(adev, &ib, NULL);
|
|
|
|
dma_fence_put(f);
|
2017-03-04 06:59:39 +08:00
|
|
|
err1:
|
2018-01-23 18:29:22 +08:00
|
|
|
amdgpu_device_wb_free(adev, index);
|
|
|
|
return r;
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
2017-09-19 16:09:53 +08:00
|
|
|
|
|
|
|
static void gfx_v9_0_free_microcode(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
release_firmware(adev->gfx.pfp_fw);
|
|
|
|
adev->gfx.pfp_fw = NULL;
|
|
|
|
release_firmware(adev->gfx.me_fw);
|
|
|
|
adev->gfx.me_fw = NULL;
|
|
|
|
release_firmware(adev->gfx.ce_fw);
|
|
|
|
adev->gfx.ce_fw = NULL;
|
|
|
|
release_firmware(adev->gfx.rlc_fw);
|
|
|
|
adev->gfx.rlc_fw = NULL;
|
|
|
|
release_firmware(adev->gfx.mec_fw);
|
|
|
|
adev->gfx.mec_fw = NULL;
|
|
|
|
release_firmware(adev->gfx.mec2_fw);
|
|
|
|
adev->gfx.mec2_fw = NULL;
|
|
|
|
|
|
|
|
kfree(adev->gfx.rlc.register_list_format);
|
|
|
|
}
|
|
|
|
|
2018-01-22 20:48:14 +08:00
|
|
|
static void gfx_v9_0_init_rlc_ext_microcode(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
const struct rlc_firmware_header_v2_1 *rlc_hdr;
|
|
|
|
|
|
|
|
rlc_hdr = (const struct rlc_firmware_header_v2_1 *)adev->gfx.rlc_fw->data;
|
|
|
|
adev->gfx.rlc_srlc_fw_version = le32_to_cpu(rlc_hdr->save_restore_list_cntl_ucode_ver);
|
|
|
|
adev->gfx.rlc_srlc_feature_version = le32_to_cpu(rlc_hdr->save_restore_list_cntl_feature_ver);
|
|
|
|
adev->gfx.rlc.save_restore_list_cntl_size_bytes = le32_to_cpu(rlc_hdr->save_restore_list_cntl_size_bytes);
|
|
|
|
adev->gfx.rlc.save_restore_list_cntl = (u8 *)rlc_hdr + le32_to_cpu(rlc_hdr->save_restore_list_cntl_offset_bytes);
|
|
|
|
adev->gfx.rlc_srlg_fw_version = le32_to_cpu(rlc_hdr->save_restore_list_gpm_ucode_ver);
|
|
|
|
adev->gfx.rlc_srlg_feature_version = le32_to_cpu(rlc_hdr->save_restore_list_gpm_feature_ver);
|
|
|
|
adev->gfx.rlc.save_restore_list_gpm_size_bytes = le32_to_cpu(rlc_hdr->save_restore_list_gpm_size_bytes);
|
|
|
|
adev->gfx.rlc.save_restore_list_gpm = (u8 *)rlc_hdr + le32_to_cpu(rlc_hdr->save_restore_list_gpm_offset_bytes);
|
|
|
|
adev->gfx.rlc_srls_fw_version = le32_to_cpu(rlc_hdr->save_restore_list_srm_ucode_ver);
|
|
|
|
adev->gfx.rlc_srls_feature_version = le32_to_cpu(rlc_hdr->save_restore_list_srm_feature_ver);
|
|
|
|
adev->gfx.rlc.save_restore_list_srm_size_bytes = le32_to_cpu(rlc_hdr->save_restore_list_srm_size_bytes);
|
|
|
|
adev->gfx.rlc.save_restore_list_srm = (u8 *)rlc_hdr + le32_to_cpu(rlc_hdr->save_restore_list_srm_offset_bytes);
|
|
|
|
adev->gfx.rlc.reg_list_format_direct_reg_list_length =
|
|
|
|
le32_to_cpu(rlc_hdr->reg_list_format_direct_reg_list_length);
|
|
|
|
}
|
|
|
|
|
2018-08-17 18:26:41 +08:00
|
|
|
static void gfx_v9_0_check_fw_write_wait(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
adev->gfx.me_fw_write_wait = false;
|
|
|
|
adev->gfx.mec_fw_write_wait = false;
|
|
|
|
|
|
|
|
switch (adev->asic_type) {
|
|
|
|
case CHIP_VEGA10:
|
|
|
|
if ((adev->gfx.me_fw_version >= 0x0000009c) &&
|
|
|
|
(adev->gfx.me_feature_version >= 42) &&
|
|
|
|
(adev->gfx.pfp_fw_version >= 0x000000b1) &&
|
|
|
|
(adev->gfx.pfp_feature_version >= 42))
|
|
|
|
adev->gfx.me_fw_write_wait = true;
|
|
|
|
|
|
|
|
if ((adev->gfx.mec_fw_version >= 0x00000193) &&
|
|
|
|
(adev->gfx.mec_feature_version >= 42))
|
|
|
|
adev->gfx.mec_fw_write_wait = true;
|
|
|
|
break;
|
|
|
|
case CHIP_VEGA12:
|
|
|
|
if ((adev->gfx.me_fw_version >= 0x0000009c) &&
|
|
|
|
(adev->gfx.me_feature_version >= 44) &&
|
|
|
|
(adev->gfx.pfp_fw_version >= 0x000000b2) &&
|
|
|
|
(adev->gfx.pfp_feature_version >= 44))
|
|
|
|
adev->gfx.me_fw_write_wait = true;
|
|
|
|
|
|
|
|
if ((adev->gfx.mec_fw_version >= 0x00000196) &&
|
|
|
|
(adev->gfx.mec_feature_version >= 44))
|
|
|
|
adev->gfx.mec_fw_write_wait = true;
|
|
|
|
break;
|
|
|
|
case CHIP_VEGA20:
|
|
|
|
if ((adev->gfx.me_fw_version >= 0x0000009c) &&
|
|
|
|
(adev->gfx.me_feature_version >= 44) &&
|
|
|
|
(adev->gfx.pfp_fw_version >= 0x000000b2) &&
|
|
|
|
(adev->gfx.pfp_feature_version >= 44))
|
|
|
|
adev->gfx.me_fw_write_wait = true;
|
|
|
|
|
|
|
|
if ((adev->gfx.mec_fw_version >= 0x00000197) &&
|
|
|
|
(adev->gfx.mec_feature_version >= 44))
|
|
|
|
adev->gfx.mec_fw_write_wait = true;
|
|
|
|
break;
|
|
|
|
case CHIP_RAVEN:
|
|
|
|
if ((adev->gfx.me_fw_version >= 0x0000009c) &&
|
|
|
|
(adev->gfx.me_feature_version >= 42) &&
|
|
|
|
(adev->gfx.pfp_fw_version >= 0x000000b1) &&
|
|
|
|
(adev->gfx.pfp_feature_version >= 42))
|
|
|
|
adev->gfx.me_fw_write_wait = true;
|
|
|
|
|
|
|
|
if ((adev->gfx.mec_fw_version >= 0x00000192) &&
|
|
|
|
(adev->gfx.mec_feature_version >= 42))
|
|
|
|
adev->gfx.mec_fw_write_wait = true;
|
|
|
|
break;
|
2018-08-20 20:19:18 +08:00
|
|
|
default:
|
|
|
|
break;
|
2018-08-17 18:26:41 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
static int gfx_v9_0_init_microcode(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
const char *chip_name;
|
|
|
|
char fw_name[30];
|
|
|
|
int err;
|
|
|
|
struct amdgpu_firmware_info *info = NULL;
|
|
|
|
const struct common_firmware_header *header = NULL;
|
|
|
|
const struct gfx_firmware_header_v1_0 *cp_hdr;
|
2017-02-08 18:17:44 +08:00
|
|
|
const struct rlc_firmware_header_v2_0 *rlc_hdr;
|
|
|
|
unsigned int *tmp = NULL;
|
|
|
|
unsigned int i = 0;
|
2018-01-22 20:48:14 +08:00
|
|
|
uint16_t version_major;
|
|
|
|
uint16_t version_minor;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
DRM_DEBUG("\n");
|
|
|
|
|
|
|
|
switch (adev->asic_type) {
|
|
|
|
case CHIP_VEGA10:
|
|
|
|
chip_name = "vega10";
|
|
|
|
break;
|
2017-09-02 14:10:18 +08:00
|
|
|
case CHIP_VEGA12:
|
|
|
|
chip_name = "vega12";
|
|
|
|
break;
|
2018-04-20 14:22:48 +08:00
|
|
|
case CHIP_VEGA20:
|
|
|
|
chip_name = "vega20";
|
|
|
|
break;
|
2016-12-08 10:49:37 +08:00
|
|
|
case CHIP_RAVEN:
|
2018-01-04 18:33:49 +08:00
|
|
|
if (adev->rev_id >= 8)
|
|
|
|
chip_name = "raven2";
|
2018-09-14 04:41:57 +08:00
|
|
|
else if (adev->pdev->device == 0x15d8)
|
|
|
|
chip_name = "picasso";
|
2018-01-04 18:33:49 +08:00
|
|
|
else
|
|
|
|
chip_name = "raven";
|
2016-12-08 10:49:37 +08:00
|
|
|
break;
|
2017-03-04 06:59:39 +08:00
|
|
|
default:
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_pfp.bin", chip_name);
|
|
|
|
err = request_firmware(&adev->gfx.pfp_fw, fw_name, adev->dev);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
err = amdgpu_ucode_validate(adev->gfx.pfp_fw);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.pfp_fw->data;
|
|
|
|
adev->gfx.pfp_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
|
|
|
|
adev->gfx.pfp_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version);
|
|
|
|
|
|
|
|
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_me.bin", chip_name);
|
|
|
|
err = request_firmware(&adev->gfx.me_fw, fw_name, adev->dev);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
err = amdgpu_ucode_validate(adev->gfx.me_fw);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.me_fw->data;
|
|
|
|
adev->gfx.me_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
|
|
|
|
adev->gfx.me_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version);
|
|
|
|
|
|
|
|
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ce.bin", chip_name);
|
|
|
|
err = request_firmware(&adev->gfx.ce_fw, fw_name, adev->dev);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
err = amdgpu_ucode_validate(adev->gfx.ce_fw);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.ce_fw->data;
|
|
|
|
adev->gfx.ce_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
|
|
|
|
adev->gfx.ce_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version);
|
|
|
|
|
2018-12-05 11:07:55 +08:00
|
|
|
/*
|
|
|
|
* For Picasso && AM4 SOCKET board, we use picasso_rlc_am4.bin
|
|
|
|
* instead of picasso_rlc.bin.
|
|
|
|
* Judgment method:
|
|
|
|
* PCO AM4: revision >= 0xC8 && revision <= 0xCF
|
|
|
|
* or revision >= 0xD8 && revision <= 0xDF
|
|
|
|
* otherwise is PCO FP5
|
|
|
|
*/
|
|
|
|
if (!strcmp(chip_name, "picasso") &&
|
|
|
|
(((adev->pdev->revision >= 0xC8) && (adev->pdev->revision <= 0xCF)) ||
|
|
|
|
((adev->pdev->revision >= 0xD8) && (adev->pdev->revision <= 0xDF))))
|
|
|
|
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc_am4.bin", chip_name);
|
|
|
|
else
|
|
|
|
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", chip_name);
|
2017-03-04 06:59:39 +08:00
|
|
|
err = request_firmware(&adev->gfx.rlc_fw, fw_name, adev->dev);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
err = amdgpu_ucode_validate(adev->gfx.rlc_fw);
|
2017-02-08 18:17:44 +08:00
|
|
|
rlc_hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data;
|
2018-01-22 20:48:14 +08:00
|
|
|
|
|
|
|
version_major = le16_to_cpu(rlc_hdr->header.header_version_major);
|
|
|
|
version_minor = le16_to_cpu(rlc_hdr->header.header_version_minor);
|
|
|
|
if (version_major == 2 && version_minor == 1)
|
|
|
|
adev->gfx.rlc.is_rlc_v2_1 = true;
|
|
|
|
|
2017-02-08 18:17:44 +08:00
|
|
|
adev->gfx.rlc_fw_version = le32_to_cpu(rlc_hdr->header.ucode_version);
|
|
|
|
adev->gfx.rlc_feature_version = le32_to_cpu(rlc_hdr->ucode_feature_version);
|
|
|
|
adev->gfx.rlc.save_and_restore_offset =
|
|
|
|
le32_to_cpu(rlc_hdr->save_and_restore_offset);
|
|
|
|
adev->gfx.rlc.clear_state_descriptor_offset =
|
|
|
|
le32_to_cpu(rlc_hdr->clear_state_descriptor_offset);
|
|
|
|
adev->gfx.rlc.avail_scratch_ram_locations =
|
|
|
|
le32_to_cpu(rlc_hdr->avail_scratch_ram_locations);
|
|
|
|
adev->gfx.rlc.reg_restore_list_size =
|
|
|
|
le32_to_cpu(rlc_hdr->reg_restore_list_size);
|
|
|
|
adev->gfx.rlc.reg_list_format_start =
|
|
|
|
le32_to_cpu(rlc_hdr->reg_list_format_start);
|
|
|
|
adev->gfx.rlc.reg_list_format_separate_start =
|
|
|
|
le32_to_cpu(rlc_hdr->reg_list_format_separate_start);
|
|
|
|
adev->gfx.rlc.starting_offsets_start =
|
|
|
|
le32_to_cpu(rlc_hdr->starting_offsets_start);
|
|
|
|
adev->gfx.rlc.reg_list_format_size_bytes =
|
|
|
|
le32_to_cpu(rlc_hdr->reg_list_format_size_bytes);
|
|
|
|
adev->gfx.rlc.reg_list_size_bytes =
|
|
|
|
le32_to_cpu(rlc_hdr->reg_list_size_bytes);
|
|
|
|
adev->gfx.rlc.register_list_format =
|
|
|
|
kmalloc(adev->gfx.rlc.reg_list_format_size_bytes +
|
|
|
|
adev->gfx.rlc.reg_list_size_bytes, GFP_KERNEL);
|
|
|
|
if (!adev->gfx.rlc.register_list_format) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = (unsigned int *)((uintptr_t)rlc_hdr +
|
|
|
|
le32_to_cpu(rlc_hdr->reg_list_format_array_offset_bytes));
|
2018-07-02 11:44:52 +08:00
|
|
|
for (i = 0 ; i < (adev->gfx.rlc.reg_list_format_size_bytes >> 2); i++)
|
2017-02-08 18:17:44 +08:00
|
|
|
adev->gfx.rlc.register_list_format[i] = le32_to_cpu(tmp[i]);
|
|
|
|
|
|
|
|
adev->gfx.rlc.register_restore = adev->gfx.rlc.register_list_format + i;
|
|
|
|
|
|
|
|
tmp = (unsigned int *)((uintptr_t)rlc_hdr +
|
|
|
|
le32_to_cpu(rlc_hdr->reg_list_array_offset_bytes));
|
2018-07-02 11:44:52 +08:00
|
|
|
for (i = 0 ; i < (adev->gfx.rlc.reg_list_size_bytes >> 2); i++)
|
2017-02-08 18:17:44 +08:00
|
|
|
adev->gfx.rlc.register_restore[i] = le32_to_cpu(tmp[i]);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2018-01-22 20:48:14 +08:00
|
|
|
if (adev->gfx.rlc.is_rlc_v2_1)
|
|
|
|
gfx_v9_0_init_rlc_ext_microcode(adev);
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec.bin", chip_name);
|
|
|
|
err = request_firmware(&adev->gfx.mec_fw, fw_name, adev->dev);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
err = amdgpu_ucode_validate(adev->gfx.mec_fw);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec_fw->data;
|
|
|
|
adev->gfx.mec_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
|
|
|
|
adev->gfx.mec_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version);
|
|
|
|
|
|
|
|
|
|
|
|
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec2.bin", chip_name);
|
|
|
|
err = request_firmware(&adev->gfx.mec2_fw, fw_name, adev->dev);
|
|
|
|
if (!err) {
|
|
|
|
err = amdgpu_ucode_validate(adev->gfx.mec2_fw);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
cp_hdr = (const struct gfx_firmware_header_v1_0 *)
|
|
|
|
adev->gfx.mec2_fw->data;
|
|
|
|
adev->gfx.mec2_fw_version =
|
|
|
|
le32_to_cpu(cp_hdr->header.ucode_version);
|
|
|
|
adev->gfx.mec2_feature_version =
|
|
|
|
le32_to_cpu(cp_hdr->ucode_feature_version);
|
|
|
|
} else {
|
|
|
|
err = 0;
|
|
|
|
adev->gfx.mec2_fw = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
|
|
|
|
info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_PFP];
|
|
|
|
info->ucode_id = AMDGPU_UCODE_ID_CP_PFP;
|
|
|
|
info->fw = adev->gfx.pfp_fw;
|
|
|
|
header = (const struct common_firmware_header *)info->fw->data;
|
|
|
|
adev->firmware.fw_size +=
|
|
|
|
ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
|
|
|
|
|
|
|
|
info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_ME];
|
|
|
|
info->ucode_id = AMDGPU_UCODE_ID_CP_ME;
|
|
|
|
info->fw = adev->gfx.me_fw;
|
|
|
|
header = (const struct common_firmware_header *)info->fw->data;
|
|
|
|
adev->firmware.fw_size +=
|
|
|
|
ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
|
|
|
|
|
|
|
|
info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_CE];
|
|
|
|
info->ucode_id = AMDGPU_UCODE_ID_CP_CE;
|
|
|
|
info->fw = adev->gfx.ce_fw;
|
|
|
|
header = (const struct common_firmware_header *)info->fw->data;
|
|
|
|
adev->firmware.fw_size +=
|
|
|
|
ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
|
|
|
|
|
|
|
|
info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_G];
|
|
|
|
info->ucode_id = AMDGPU_UCODE_ID_RLC_G;
|
|
|
|
info->fw = adev->gfx.rlc_fw;
|
|
|
|
header = (const struct common_firmware_header *)info->fw->data;
|
|
|
|
adev->firmware.fw_size +=
|
|
|
|
ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
|
|
|
|
|
2018-07-05 11:24:20 +08:00
|
|
|
if (adev->gfx.rlc.is_rlc_v2_1 &&
|
|
|
|
adev->gfx.rlc.save_restore_list_cntl_size_bytes &&
|
|
|
|
adev->gfx.rlc.save_restore_list_gpm_size_bytes &&
|
|
|
|
adev->gfx.rlc.save_restore_list_srm_size_bytes) {
|
2018-01-22 20:48:14 +08:00
|
|
|
info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL];
|
|
|
|
info->ucode_id = AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL;
|
|
|
|
info->fw = adev->gfx.rlc_fw;
|
|
|
|
adev->firmware.fw_size +=
|
|
|
|
ALIGN(adev->gfx.rlc.save_restore_list_cntl_size_bytes, PAGE_SIZE);
|
|
|
|
|
|
|
|
info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM];
|
|
|
|
info->ucode_id = AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM;
|
|
|
|
info->fw = adev->gfx.rlc_fw;
|
|
|
|
adev->firmware.fw_size +=
|
|
|
|
ALIGN(adev->gfx.rlc.save_restore_list_gpm_size_bytes, PAGE_SIZE);
|
|
|
|
|
|
|
|
info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM];
|
|
|
|
info->ucode_id = AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM;
|
|
|
|
info->fw = adev->gfx.rlc_fw;
|
|
|
|
adev->firmware.fw_size +=
|
|
|
|
ALIGN(adev->gfx.rlc.save_restore_list_srm_size_bytes, PAGE_SIZE);
|
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC1];
|
|
|
|
info->ucode_id = AMDGPU_UCODE_ID_CP_MEC1;
|
|
|
|
info->fw = adev->gfx.mec_fw;
|
|
|
|
header = (const struct common_firmware_header *)info->fw->data;
|
|
|
|
cp_hdr = (const struct gfx_firmware_header_v1_0 *)info->fw->data;
|
|
|
|
adev->firmware.fw_size +=
|
|
|
|
ALIGN(le32_to_cpu(header->ucode_size_bytes) - le32_to_cpu(cp_hdr->jt_size) * 4, PAGE_SIZE);
|
|
|
|
|
|
|
|
info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC1_JT];
|
|
|
|
info->ucode_id = AMDGPU_UCODE_ID_CP_MEC1_JT;
|
|
|
|
info->fw = adev->gfx.mec_fw;
|
|
|
|
adev->firmware.fw_size +=
|
|
|
|
ALIGN(le32_to_cpu(cp_hdr->jt_size) * 4, PAGE_SIZE);
|
|
|
|
|
|
|
|
if (adev->gfx.mec2_fw) {
|
|
|
|
info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC2];
|
|
|
|
info->ucode_id = AMDGPU_UCODE_ID_CP_MEC2;
|
|
|
|
info->fw = adev->gfx.mec2_fw;
|
|
|
|
header = (const struct common_firmware_header *)info->fw->data;
|
|
|
|
cp_hdr = (const struct gfx_firmware_header_v1_0 *)info->fw->data;
|
|
|
|
adev->firmware.fw_size +=
|
|
|
|
ALIGN(le32_to_cpu(header->ucode_size_bytes) - le32_to_cpu(cp_hdr->jt_size) * 4, PAGE_SIZE);
|
|
|
|
info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC2_JT];
|
|
|
|
info->ucode_id = AMDGPU_UCODE_ID_CP_MEC2_JT;
|
|
|
|
info->fw = adev->gfx.mec2_fw;
|
|
|
|
adev->firmware.fw_size +=
|
|
|
|
ALIGN(le32_to_cpu(cp_hdr->jt_size) * 4, PAGE_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2018-08-17 18:26:41 +08:00
|
|
|
gfx_v9_0_check_fw_write_wait(adev);
|
2017-03-04 06:59:39 +08:00
|
|
|
if (err) {
|
|
|
|
dev_err(adev->dev,
|
|
|
|
"gfx9: Failed to load firmware \"%s\"\n",
|
|
|
|
fw_name);
|
|
|
|
release_firmware(adev->gfx.pfp_fw);
|
|
|
|
adev->gfx.pfp_fw = NULL;
|
|
|
|
release_firmware(adev->gfx.me_fw);
|
|
|
|
adev->gfx.me_fw = NULL;
|
|
|
|
release_firmware(adev->gfx.ce_fw);
|
|
|
|
adev->gfx.ce_fw = NULL;
|
|
|
|
release_firmware(adev->gfx.rlc_fw);
|
|
|
|
adev->gfx.rlc_fw = NULL;
|
|
|
|
release_firmware(adev->gfx.mec_fw);
|
|
|
|
adev->gfx.mec_fw = NULL;
|
|
|
|
release_firmware(adev->gfx.mec2_fw);
|
|
|
|
adev->gfx.mec2_fw = NULL;
|
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2017-02-13 13:55:23 +08:00
|
|
|
static u32 gfx_v9_0_get_csb_size(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
u32 count = 0;
|
|
|
|
const struct cs_section_def *sect = NULL;
|
|
|
|
const struct cs_extent_def *ext = NULL;
|
|
|
|
|
|
|
|
/* begin clear state */
|
|
|
|
count += 2;
|
|
|
|
/* context control state */
|
|
|
|
count += 3;
|
|
|
|
|
|
|
|
for (sect = gfx9_cs_data; sect->section != NULL; ++sect) {
|
|
|
|
for (ext = sect->section; ext->extent != NULL; ++ext) {
|
|
|
|
if (sect->id == SECT_CONTEXT)
|
|
|
|
count += 2 + ext->reg_count;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* end clear state */
|
|
|
|
count += 2;
|
|
|
|
/* clear state */
|
|
|
|
count += 2;
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_get_csb_buffer(struct amdgpu_device *adev,
|
|
|
|
volatile u32 *buffer)
|
|
|
|
{
|
|
|
|
u32 count = 0, i;
|
|
|
|
const struct cs_section_def *sect = NULL;
|
|
|
|
const struct cs_extent_def *ext = NULL;
|
|
|
|
|
|
|
|
if (adev->gfx.rlc.cs_data == NULL)
|
|
|
|
return;
|
|
|
|
if (buffer == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
buffer[count++] = cpu_to_le32(PACKET3(PACKET3_PREAMBLE_CNTL, 0));
|
|
|
|
buffer[count++] = cpu_to_le32(PACKET3_PREAMBLE_BEGIN_CLEAR_STATE);
|
|
|
|
|
|
|
|
buffer[count++] = cpu_to_le32(PACKET3(PACKET3_CONTEXT_CONTROL, 1));
|
|
|
|
buffer[count++] = cpu_to_le32(0x80000000);
|
|
|
|
buffer[count++] = cpu_to_le32(0x80000000);
|
|
|
|
|
|
|
|
for (sect = adev->gfx.rlc.cs_data; sect->section != NULL; ++sect) {
|
|
|
|
for (ext = sect->section; ext->extent != NULL; ++ext) {
|
|
|
|
if (sect->id == SECT_CONTEXT) {
|
|
|
|
buffer[count++] =
|
|
|
|
cpu_to_le32(PACKET3(PACKET3_SET_CONTEXT_REG, ext->reg_count));
|
|
|
|
buffer[count++] = cpu_to_le32(ext->reg_index -
|
|
|
|
PACKET3_SET_CONTEXT_REG_START);
|
|
|
|
for (i = 0; i < ext->reg_count; i++)
|
|
|
|
buffer[count++] = cpu_to_le32(ext->extent[i]);
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer[count++] = cpu_to_le32(PACKET3(PACKET3_PREAMBLE_CNTL, 0));
|
|
|
|
buffer[count++] = cpu_to_le32(PACKET3_PREAMBLE_END_CLEAR_STATE);
|
|
|
|
|
|
|
|
buffer[count++] = cpu_to_le32(PACKET3(PACKET3_CLEAR_STATE, 0));
|
|
|
|
buffer[count++] = cpu_to_le32(0);
|
|
|
|
}
|
|
|
|
|
2018-08-24 16:40:03 +08:00
|
|
|
static void gfx_v9_0_init_always_on_cu_mask(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
struct amdgpu_cu_info *cu_info = &adev->gfx.cu_info;
|
|
|
|
uint32_t pg_always_on_cu_num = 2;
|
|
|
|
uint32_t always_on_cu_num;
|
|
|
|
uint32_t i, j, k;
|
|
|
|
uint32_t mask, cu_bitmap, counter;
|
|
|
|
|
|
|
|
if (adev->flags & AMD_IS_APU)
|
|
|
|
always_on_cu_num = 4;
|
|
|
|
else if (adev->asic_type == CHIP_VEGA12)
|
|
|
|
always_on_cu_num = 8;
|
|
|
|
else
|
|
|
|
always_on_cu_num = 12;
|
|
|
|
|
|
|
|
mutex_lock(&adev->grbm_idx_mutex);
|
|
|
|
for (i = 0; i < adev->gfx.config.max_shader_engines; i++) {
|
|
|
|
for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) {
|
|
|
|
mask = 1;
|
|
|
|
cu_bitmap = 0;
|
|
|
|
counter = 0;
|
|
|
|
gfx_v9_0_select_se_sh(adev, i, j, 0xffffffff);
|
|
|
|
|
|
|
|
for (k = 0; k < adev->gfx.config.max_cu_per_sh; k ++) {
|
|
|
|
if (cu_info->bitmap[i][j] & mask) {
|
|
|
|
if (counter == pg_always_on_cu_num)
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_PG_ALWAYS_ON_CU_MASK, cu_bitmap);
|
|
|
|
if (counter < always_on_cu_num)
|
|
|
|
cu_bitmap |= mask;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
counter++;
|
|
|
|
}
|
|
|
|
mask <<= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_LB_ALWAYS_ACTIVE_CU_MASK, cu_bitmap);
|
|
|
|
cu_info->ao_cu_bitmap[i][j] = cu_bitmap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gfx_v9_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
|
|
|
|
mutex_unlock(&adev->grbm_idx_mutex);
|
|
|
|
}
|
|
|
|
|
2017-05-26 14:26:51 +08:00
|
|
|
static void gfx_v9_0_init_lbpw(struct amdgpu_device *adev)
|
|
|
|
{
|
2017-06-12 20:45:02 +08:00
|
|
|
uint32_t data;
|
2017-05-26 14:26:51 +08:00
|
|
|
|
|
|
|
/* set mmRLC_LB_THR_CONFIG_1/2/3/4 */
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_LB_THR_CONFIG_1, 0x0000007F);
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_LB_THR_CONFIG_2, 0x0333A5A7);
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_LB_THR_CONFIG_3, 0x00000077);
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_LB_THR_CONFIG_4, (0x30 | 0x40 << 8 | 0x02FA << 16));
|
|
|
|
|
|
|
|
/* set mmRLC_LB_CNTR_INIT = 0x0000_0000 */
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_LB_CNTR_INIT, 0x00000000);
|
|
|
|
|
|
|
|
/* set mmRLC_LB_CNTR_MAX = 0x0000_0500 */
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_LB_CNTR_MAX, 0x00000500);
|
|
|
|
|
|
|
|
mutex_lock(&adev->grbm_idx_mutex);
|
|
|
|
/* set mmRLC_LB_INIT_CU_MASK thru broadcast mode to enable all SE/SH*/
|
|
|
|
gfx_v9_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_LB_INIT_CU_MASK, 0xffffffff);
|
|
|
|
|
|
|
|
/* set mmRLC_LB_PARAMS = 0x003F_1006 */
|
2017-06-12 20:45:02 +08:00
|
|
|
data = REG_SET_FIELD(0, RLC_LB_PARAMS, FIFO_SAMPLES, 0x0003);
|
|
|
|
data |= REG_SET_FIELD(data, RLC_LB_PARAMS, PG_IDLE_SAMPLES, 0x0010);
|
|
|
|
data |= REG_SET_FIELD(data, RLC_LB_PARAMS, PG_IDLE_SAMPLE_INTERVAL, 0x033F);
|
2017-05-26 14:26:51 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_LB_PARAMS, data);
|
|
|
|
|
|
|
|
/* set mmRLC_GPM_GENERAL_7[31-16] = 0x00C0 */
|
|
|
|
data = RREG32_SOC15(GC, 0, mmRLC_GPM_GENERAL_7);
|
|
|
|
data &= 0x0000FFFF;
|
|
|
|
data |= 0x00C00000;
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_GPM_GENERAL_7, data);
|
|
|
|
|
2018-09-19 19:07:19 +08:00
|
|
|
/*
|
|
|
|
* RLC_LB_ALWAYS_ACTIVE_CU_MASK = 0xF (4 CUs AON for Raven),
|
|
|
|
* programmed in gfx_v9_0_init_always_on_cu_mask()
|
|
|
|
*/
|
2017-05-26 14:26:51 +08:00
|
|
|
|
|
|
|
/* set RLC_LB_CNTL = 0x8000_0095, 31 bit is reserved,
|
|
|
|
* but used for RLC_LB_CNTL configuration */
|
|
|
|
data = RLC_LB_CNTL__LB_CNT_SPIM_ACTIVE_MASK;
|
2017-06-12 20:45:02 +08:00
|
|
|
data |= REG_SET_FIELD(data, RLC_LB_CNTL, CU_MASK_USED_OFF_HYST, 0x09);
|
|
|
|
data |= REG_SET_FIELD(data, RLC_LB_CNTL, RESERVED, 0x80000);
|
2017-05-26 14:26:51 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_LB_CNTL, data);
|
|
|
|
mutex_unlock(&adev->grbm_idx_mutex);
|
2018-09-19 19:07:19 +08:00
|
|
|
|
|
|
|
gfx_v9_0_init_always_on_cu_mask(adev);
|
2017-05-26 14:26:51 +08:00
|
|
|
}
|
|
|
|
|
2018-08-24 16:40:03 +08:00
|
|
|
static void gfx_v9_4_init_lbpw(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
uint32_t data;
|
|
|
|
|
|
|
|
/* set mmRLC_LB_THR_CONFIG_1/2/3/4 */
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_LB_THR_CONFIG_1, 0x0000007F);
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_LB_THR_CONFIG_2, 0x033388F8);
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_LB_THR_CONFIG_3, 0x00000077);
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_LB_THR_CONFIG_4, (0x10 | 0x27 << 8 | 0x02FA << 16));
|
|
|
|
|
|
|
|
/* set mmRLC_LB_CNTR_INIT = 0x0000_0000 */
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_LB_CNTR_INIT, 0x00000000);
|
|
|
|
|
|
|
|
/* set mmRLC_LB_CNTR_MAX = 0x0000_0500 */
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_LB_CNTR_MAX, 0x00000800);
|
|
|
|
|
|
|
|
mutex_lock(&adev->grbm_idx_mutex);
|
|
|
|
/* set mmRLC_LB_INIT_CU_MASK thru broadcast mode to enable all SE/SH*/
|
|
|
|
gfx_v9_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_LB_INIT_CU_MASK, 0xffffffff);
|
|
|
|
|
|
|
|
/* set mmRLC_LB_PARAMS = 0x003F_1006 */
|
|
|
|
data = REG_SET_FIELD(0, RLC_LB_PARAMS, FIFO_SAMPLES, 0x0003);
|
|
|
|
data |= REG_SET_FIELD(data, RLC_LB_PARAMS, PG_IDLE_SAMPLES, 0x0010);
|
|
|
|
data |= REG_SET_FIELD(data, RLC_LB_PARAMS, PG_IDLE_SAMPLE_INTERVAL, 0x033F);
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_LB_PARAMS, data);
|
|
|
|
|
|
|
|
/* set mmRLC_GPM_GENERAL_7[31-16] = 0x00C0 */
|
|
|
|
data = RREG32_SOC15(GC, 0, mmRLC_GPM_GENERAL_7);
|
|
|
|
data &= 0x0000FFFF;
|
|
|
|
data |= 0x00C00000;
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_GPM_GENERAL_7, data);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RLC_LB_ALWAYS_ACTIVE_CU_MASK = 0xFFF (12 CUs AON),
|
|
|
|
* programmed in gfx_v9_0_init_always_on_cu_mask()
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* set RLC_LB_CNTL = 0x8000_0095, 31 bit is reserved,
|
|
|
|
* but used for RLC_LB_CNTL configuration */
|
|
|
|
data = RLC_LB_CNTL__LB_CNT_SPIM_ACTIVE_MASK;
|
|
|
|
data |= REG_SET_FIELD(data, RLC_LB_CNTL, CU_MASK_USED_OFF_HYST, 0x09);
|
|
|
|
data |= REG_SET_FIELD(data, RLC_LB_CNTL, RESERVED, 0x80000);
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_LB_CNTL, data);
|
|
|
|
mutex_unlock(&adev->grbm_idx_mutex);
|
|
|
|
|
|
|
|
gfx_v9_0_init_always_on_cu_mask(adev);
|
|
|
|
}
|
|
|
|
|
2017-05-26 14:40:36 +08:00
|
|
|
static void gfx_v9_0_enable_lbpw(struct amdgpu_device *adev, bool enable)
|
|
|
|
{
|
2017-06-12 20:45:02 +08:00
|
|
|
WREG32_FIELD15(GC, 0, RLC_LB_CNTL, LOAD_BALANCE_ENABLE, enable ? 1 : 0);
|
2017-05-26 14:40:36 +08:00
|
|
|
}
|
|
|
|
|
2018-11-08 20:19:54 +08:00
|
|
|
static int gfx_v9_0_cp_jump_table_num(struct amdgpu_device *adev)
|
2017-02-13 13:55:23 +08:00
|
|
|
{
|
2018-11-08 20:19:54 +08:00
|
|
|
return 5;
|
2017-02-13 13:55:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_rlc_init(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
const struct cs_section_def *cs_data;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
adev->gfx.rlc.cs_data = gfx9_cs_data;
|
|
|
|
|
|
|
|
cs_data = adev->gfx.rlc.cs_data;
|
|
|
|
|
|
|
|
if (cs_data) {
|
2018-11-08 20:19:54 +08:00
|
|
|
/* init clear state block */
|
|
|
|
r = amdgpu_gfx_rlc_init_csb(adev);
|
|
|
|
if (r)
|
2017-07-27 23:24:36 +08:00
|
|
|
return r;
|
2017-02-13 13:55:23 +08:00
|
|
|
}
|
|
|
|
|
2018-09-14 04:41:57 +08:00
|
|
|
if (adev->asic_type == CHIP_RAVEN) {
|
2017-02-13 13:55:23 +08:00
|
|
|
/* TODO: double check the cp_table_size for RV */
|
|
|
|
adev->gfx.rlc.cp_table_size = ALIGN(96 * 5 * 4, 2048) + (64 * 1024); /* JT + GDS */
|
2018-11-08 20:19:54 +08:00
|
|
|
r = amdgpu_gfx_rlc_init_cpt(adev);
|
|
|
|
if (r)
|
2017-07-27 23:24:36 +08:00
|
|
|
return r;
|
2018-08-24 16:40:03 +08:00
|
|
|
}
|
2017-05-26 14:26:51 +08:00
|
|
|
|
2018-08-24 16:40:03 +08:00
|
|
|
switch (adev->asic_type) {
|
|
|
|
case CHIP_RAVEN:
|
2017-05-26 14:26:51 +08:00
|
|
|
gfx_v9_0_init_lbpw(adev);
|
2018-08-24 16:40:03 +08:00
|
|
|
break;
|
|
|
|
case CHIP_VEGA20:
|
|
|
|
gfx_v9_4_init_lbpw(adev);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2017-02-13 13:55:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-07-04 16:21:52 +08:00
|
|
|
static int gfx_v9_0_csb_vram_pin(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
|
|
|
|
r = amdgpu_bo_reserve(adev->gfx.rlc.clear_state_obj, false);
|
|
|
|
if (unlikely(r != 0))
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = amdgpu_bo_pin(adev->gfx.rlc.clear_state_obj,
|
|
|
|
AMDGPU_GEM_DOMAIN_VRAM);
|
|
|
|
if (!r)
|
|
|
|
adev->gfx.rlc.clear_state_gpu_addr =
|
|
|
|
amdgpu_bo_gpu_offset(adev->gfx.rlc.clear_state_obj);
|
|
|
|
|
|
|
|
amdgpu_bo_unreserve(adev->gfx.rlc.clear_state_obj);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_csb_vram_unpin(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
|
|
|
|
if (!adev->gfx.rlc.clear_state_obj)
|
|
|
|
return;
|
|
|
|
|
|
|
|
r = amdgpu_bo_reserve(adev->gfx.rlc.clear_state_obj, true);
|
|
|
|
if (likely(r == 0)) {
|
|
|
|
amdgpu_bo_unpin(adev->gfx.rlc.clear_state_obj);
|
|
|
|
amdgpu_bo_unreserve(adev->gfx.rlc.clear_state_obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
static void gfx_v9_0_mec_fini(struct amdgpu_device *adev)
|
|
|
|
{
|
2017-07-27 23:43:00 +08:00
|
|
|
amdgpu_bo_free_kernel(&adev->gfx.mec.hpd_eop_obj, NULL, NULL);
|
|
|
|
amdgpu_bo_free_kernel(&adev->gfx.mec.mec_fw_obj, NULL, NULL);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_mec_init(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
u32 *hpd;
|
|
|
|
const __le32 *fw_data;
|
|
|
|
unsigned fw_size;
|
|
|
|
u32 *fw;
|
2017-02-02 08:08:23 +08:00
|
|
|
size_t mec_hpd_size;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
const struct gfx_firmware_header_v1_0 *mec_hdr;
|
|
|
|
|
2017-02-02 13:38:22 +08:00
|
|
|
bitmap_zero(adev->gfx.mec.queue_bitmap, AMDGPU_MAX_COMPUTE_QUEUES);
|
|
|
|
|
|
|
|
/* take ownership of the relevant compute queues */
|
2017-06-07 23:05:26 +08:00
|
|
|
amdgpu_gfx_compute_queue_acquire(adev);
|
2017-02-02 13:38:22 +08:00
|
|
|
mec_hpd_size = adev->gfx.num_compute_rings * GFX9_MEC_HPD_SIZE;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-07-27 23:24:36 +08:00
|
|
|
r = amdgpu_bo_create_reserved(adev, mec_hpd_size, PAGE_SIZE,
|
2018-10-06 04:52:39 +08:00
|
|
|
AMDGPU_GEM_DOMAIN_VRAM,
|
2017-07-27 23:24:36 +08:00
|
|
|
&adev->gfx.mec.hpd_eop_obj,
|
|
|
|
&adev->gfx.mec.hpd_eop_gpu_addr,
|
|
|
|
(void **)&hpd);
|
2017-03-04 06:59:39 +08:00
|
|
|
if (r) {
|
2017-07-27 23:24:36 +08:00
|
|
|
dev_warn(adev->dev, "(%d) create HDP EOP bo failed\n", r);
|
2017-03-04 06:59:39 +08:00
|
|
|
gfx_v9_0_mec_fini(adev);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(hpd, 0, adev->gfx.mec.hpd_eop_obj->tbo.mem.size);
|
|
|
|
|
|
|
|
amdgpu_bo_kunmap(adev->gfx.mec.hpd_eop_obj);
|
|
|
|
amdgpu_bo_unreserve(adev->gfx.mec.hpd_eop_obj);
|
|
|
|
|
|
|
|
mec_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec_fw->data;
|
|
|
|
|
|
|
|
fw_data = (const __le32 *)
|
|
|
|
(adev->gfx.mec_fw->data +
|
|
|
|
le32_to_cpu(mec_hdr->header.ucode_array_offset_bytes));
|
|
|
|
fw_size = le32_to_cpu(mec_hdr->header.ucode_size_bytes) / 4;
|
|
|
|
|
2017-07-27 23:24:36 +08:00
|
|
|
r = amdgpu_bo_create_reserved(adev, mec_hdr->header.ucode_size_bytes,
|
|
|
|
PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT,
|
|
|
|
&adev->gfx.mec.mec_fw_obj,
|
|
|
|
&adev->gfx.mec.mec_fw_gpu_addr,
|
|
|
|
(void **)&fw);
|
2017-03-04 06:59:39 +08:00
|
|
|
if (r) {
|
2017-07-27 23:24:36 +08:00
|
|
|
dev_warn(adev->dev, "(%d) create mec firmware bo failed\n", r);
|
2017-03-04 06:59:39 +08:00
|
|
|
gfx_v9_0_mec_fini(adev);
|
|
|
|
return r;
|
|
|
|
}
|
2017-07-27 23:24:36 +08:00
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
memcpy(fw, fw_data, fw_size);
|
|
|
|
|
|
|
|
amdgpu_bo_kunmap(adev->gfx.mec.mec_fw_obj);
|
|
|
|
amdgpu_bo_unreserve(adev->gfx.mec.mec_fw_obj);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t wave_read_ind(struct amdgpu_device *adev, uint32_t simd, uint32_t wave, uint32_t address)
|
|
|
|
{
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmSQ_IND_INDEX,
|
2017-03-04 06:59:39 +08:00
|
|
|
(wave << SQ_IND_INDEX__WAVE_ID__SHIFT) |
|
|
|
|
(simd << SQ_IND_INDEX__SIMD_ID__SHIFT) |
|
|
|
|
(address << SQ_IND_INDEX__INDEX__SHIFT) |
|
|
|
|
(SQ_IND_INDEX__FORCE_READ_MASK));
|
2017-04-07 19:53:53 +08:00
|
|
|
return RREG32_SOC15(GC, 0, mmSQ_IND_DATA);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void wave_read_regs(struct amdgpu_device *adev, uint32_t simd,
|
|
|
|
uint32_t wave, uint32_t thread,
|
|
|
|
uint32_t regno, uint32_t num, uint32_t *out)
|
|
|
|
{
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmSQ_IND_INDEX,
|
2017-03-04 06:59:39 +08:00
|
|
|
(wave << SQ_IND_INDEX__WAVE_ID__SHIFT) |
|
|
|
|
(simd << SQ_IND_INDEX__SIMD_ID__SHIFT) |
|
|
|
|
(regno << SQ_IND_INDEX__INDEX__SHIFT) |
|
|
|
|
(thread << SQ_IND_INDEX__THREAD_ID__SHIFT) |
|
|
|
|
(SQ_IND_INDEX__FORCE_READ_MASK) |
|
|
|
|
(SQ_IND_INDEX__AUTO_INCR_MASK));
|
|
|
|
while (num--)
|
2017-04-07 19:53:53 +08:00
|
|
|
*(out++) = RREG32_SOC15(GC, 0, mmSQ_IND_DATA);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_read_wave_data(struct amdgpu_device *adev, uint32_t simd, uint32_t wave, uint32_t *dst, int *no_fields)
|
|
|
|
{
|
|
|
|
/* type 1 wave data */
|
|
|
|
dst[(*no_fields)++] = 1;
|
|
|
|
dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_STATUS);
|
|
|
|
dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_PC_LO);
|
|
|
|
dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_PC_HI);
|
|
|
|
dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_EXEC_LO);
|
|
|
|
dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_EXEC_HI);
|
|
|
|
dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_HW_ID);
|
|
|
|
dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_INST_DW0);
|
|
|
|
dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_INST_DW1);
|
|
|
|
dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_GPR_ALLOC);
|
|
|
|
dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_LDS_ALLOC);
|
|
|
|
dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_TRAPSTS);
|
|
|
|
dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_IB_STS);
|
|
|
|
dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_IB_DBG0);
|
|
|
|
dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_M0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_read_wave_sgprs(struct amdgpu_device *adev, uint32_t simd,
|
|
|
|
uint32_t wave, uint32_t start,
|
|
|
|
uint32_t size, uint32_t *dst)
|
|
|
|
{
|
|
|
|
wave_read_regs(
|
|
|
|
adev, simd, wave, 0,
|
|
|
|
start + SQIND_WAVE_SGPRS_OFFSET, size, dst);
|
|
|
|
}
|
|
|
|
|
2017-09-09 06:09:29 +08:00
|
|
|
static void gfx_v9_0_read_wave_vgprs(struct amdgpu_device *adev, uint32_t simd,
|
|
|
|
uint32_t wave, uint32_t thread,
|
|
|
|
uint32_t start, uint32_t size,
|
|
|
|
uint32_t *dst)
|
|
|
|
{
|
|
|
|
wave_read_regs(
|
|
|
|
adev, simd, wave, thread,
|
|
|
|
start + SQIND_WAVE_VGPRS_OFFSET, size, dst);
|
|
|
|
}
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2018-03-29 21:09:39 +08:00
|
|
|
static void gfx_v9_0_select_me_pipe_q(struct amdgpu_device *adev,
|
|
|
|
u32 me, u32 pipe, u32 q)
|
|
|
|
{
|
|
|
|
soc15_grbm_select(adev, me, pipe, q, 0);
|
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
static const struct amdgpu_gfx_funcs gfx_v9_0_gfx_funcs = {
|
|
|
|
.get_gpu_clock_counter = &gfx_v9_0_get_gpu_clock_counter,
|
|
|
|
.select_se_sh = &gfx_v9_0_select_se_sh,
|
|
|
|
.read_wave_data = &gfx_v9_0_read_wave_data,
|
|
|
|
.read_wave_sgprs = &gfx_v9_0_read_wave_sgprs,
|
2017-09-09 06:09:29 +08:00
|
|
|
.read_wave_vgprs = &gfx_v9_0_read_wave_vgprs,
|
2018-03-29 21:09:39 +08:00
|
|
|
.select_me_pipe_q = &gfx_v9_0_select_me_pipe_q
|
2017-03-04 06:59:39 +08:00
|
|
|
};
|
|
|
|
|
2018-04-20 12:31:04 +08:00
|
|
|
static int gfx_v9_0_gpu_early_init(struct amdgpu_device *adev)
|
2017-03-04 06:59:39 +08:00
|
|
|
{
|
|
|
|
u32 gb_addr_config;
|
2018-04-20 12:31:04 +08:00
|
|
|
int err;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
adev->gfx.funcs = &gfx_v9_0_gfx_funcs;
|
|
|
|
|
|
|
|
switch (adev->asic_type) {
|
|
|
|
case CHIP_VEGA10:
|
|
|
|
adev->gfx.config.max_hw_contexts = 8;
|
|
|
|
adev->gfx.config.sc_prim_fifo_size_frontend = 0x20;
|
|
|
|
adev->gfx.config.sc_prim_fifo_size_backend = 0x100;
|
|
|
|
adev->gfx.config.sc_hiz_tile_fifo_size = 0x30;
|
|
|
|
adev->gfx.config.sc_earlyz_tile_fifo_size = 0x4C0;
|
|
|
|
gb_addr_config = VEGA10_GB_ADDR_CONFIG_GOLDEN;
|
|
|
|
break;
|
2017-09-02 14:24:39 +08:00
|
|
|
case CHIP_VEGA12:
|
|
|
|
adev->gfx.config.max_hw_contexts = 8;
|
|
|
|
adev->gfx.config.sc_prim_fifo_size_frontend = 0x20;
|
|
|
|
adev->gfx.config.sc_prim_fifo_size_backend = 0x100;
|
|
|
|
adev->gfx.config.sc_hiz_tile_fifo_size = 0x30;
|
|
|
|
adev->gfx.config.sc_earlyz_tile_fifo_size = 0x4C0;
|
2018-03-12 14:55:48 +08:00
|
|
|
gb_addr_config = VEGA12_GB_ADDR_CONFIG_GOLDEN;
|
2017-09-02 14:24:39 +08:00
|
|
|
DRM_INFO("fix gfx.config for vega12\n");
|
|
|
|
break;
|
2018-04-20 14:40:11 +08:00
|
|
|
case CHIP_VEGA20:
|
|
|
|
adev->gfx.config.max_hw_contexts = 8;
|
|
|
|
adev->gfx.config.sc_prim_fifo_size_frontend = 0x20;
|
|
|
|
adev->gfx.config.sc_prim_fifo_size_backend = 0x100;
|
|
|
|
adev->gfx.config.sc_hiz_tile_fifo_size = 0x30;
|
|
|
|
adev->gfx.config.sc_earlyz_tile_fifo_size = 0x4C0;
|
|
|
|
gb_addr_config = RREG32_SOC15(GC, 0, mmGB_ADDR_CONFIG);
|
|
|
|
gb_addr_config &= ~0xf3e777ff;
|
|
|
|
gb_addr_config |= 0x22014042;
|
2018-04-20 12:31:04 +08:00
|
|
|
/* check vbios table if gpu info is not available */
|
|
|
|
err = amdgpu_atomfirmware_get_gfx_info(adev);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2018-04-20 14:40:11 +08:00
|
|
|
break;
|
2016-12-08 11:06:11 +08:00
|
|
|
case CHIP_RAVEN:
|
|
|
|
adev->gfx.config.max_hw_contexts = 8;
|
|
|
|
adev->gfx.config.sc_prim_fifo_size_frontend = 0x20;
|
|
|
|
adev->gfx.config.sc_prim_fifo_size_backend = 0x100;
|
|
|
|
adev->gfx.config.sc_hiz_tile_fifo_size = 0x30;
|
|
|
|
adev->gfx.config.sc_earlyz_tile_fifo_size = 0x4C0;
|
2018-01-04 18:36:40 +08:00
|
|
|
if (adev->rev_id >= 8)
|
|
|
|
gb_addr_config = RAVEN2_GB_ADDR_CONFIG_GOLDEN;
|
|
|
|
else
|
|
|
|
gb_addr_config = RAVEN_GB_ADDR_CONFIG_GOLDEN;
|
2016-12-08 11:06:11 +08:00
|
|
|
break;
|
2017-03-04 06:59:39 +08:00
|
|
|
default:
|
|
|
|
BUG();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
adev->gfx.config.gb_addr_config = gb_addr_config;
|
|
|
|
|
|
|
|
adev->gfx.config.gb_addr_config_fields.num_pipes = 1 <<
|
|
|
|
REG_GET_FIELD(
|
|
|
|
adev->gfx.config.gb_addr_config,
|
|
|
|
GB_ADDR_CONFIG,
|
|
|
|
NUM_PIPES);
|
2017-05-03 04:15:06 +08:00
|
|
|
|
|
|
|
adev->gfx.config.max_tile_pipes =
|
|
|
|
adev->gfx.config.gb_addr_config_fields.num_pipes;
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
adev->gfx.config.gb_addr_config_fields.num_banks = 1 <<
|
|
|
|
REG_GET_FIELD(
|
|
|
|
adev->gfx.config.gb_addr_config,
|
|
|
|
GB_ADDR_CONFIG,
|
|
|
|
NUM_BANKS);
|
|
|
|
adev->gfx.config.gb_addr_config_fields.max_compress_frags = 1 <<
|
|
|
|
REG_GET_FIELD(
|
|
|
|
adev->gfx.config.gb_addr_config,
|
|
|
|
GB_ADDR_CONFIG,
|
|
|
|
MAX_COMPRESSED_FRAGS);
|
|
|
|
adev->gfx.config.gb_addr_config_fields.num_rb_per_se = 1 <<
|
|
|
|
REG_GET_FIELD(
|
|
|
|
adev->gfx.config.gb_addr_config,
|
|
|
|
GB_ADDR_CONFIG,
|
|
|
|
NUM_RB_PER_SE);
|
|
|
|
adev->gfx.config.gb_addr_config_fields.num_se = 1 <<
|
|
|
|
REG_GET_FIELD(
|
|
|
|
adev->gfx.config.gb_addr_config,
|
|
|
|
GB_ADDR_CONFIG,
|
|
|
|
NUM_SHADER_ENGINES);
|
|
|
|
adev->gfx.config.gb_addr_config_fields.pipe_interleave_size = 1 << (8 +
|
|
|
|
REG_GET_FIELD(
|
|
|
|
adev->gfx.config.gb_addr_config,
|
|
|
|
GB_ADDR_CONFIG,
|
|
|
|
PIPE_INTERLEAVE_SIZE));
|
2018-04-20 12:31:04 +08:00
|
|
|
|
|
|
|
return 0;
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_ngg_create_buf(struct amdgpu_device *adev,
|
|
|
|
struct amdgpu_ngg_buf *ngg_buf,
|
|
|
|
int size_se,
|
|
|
|
int default_size_se)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
|
|
|
|
if (size_se < 0) {
|
|
|
|
dev_err(adev->dev, "Buffer size is invalid: %d\n", size_se);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
size_se = size_se ? size_se : default_size_se;
|
|
|
|
|
2017-05-02 04:20:42 +08:00
|
|
|
ngg_buf->size = size_se * adev->gfx.config.max_shader_engines;
|
2017-03-04 06:59:39 +08:00
|
|
|
r = amdgpu_bo_create_kernel(adev, ngg_buf->size,
|
|
|
|
PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM,
|
|
|
|
&ngg_buf->bo,
|
|
|
|
&ngg_buf->gpu_addr,
|
|
|
|
NULL);
|
|
|
|
if (r) {
|
|
|
|
dev_err(adev->dev, "(%d) failed to create NGG buffer\n", r);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
ngg_buf->bo_size = amdgpu_bo_size(ngg_buf->bo);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_ngg_fini(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < NGG_BUF_MAX; i++)
|
|
|
|
amdgpu_bo_free_kernel(&adev->gfx.ngg.buf[i].bo,
|
|
|
|
&adev->gfx.ngg.buf[i].gpu_addr,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
memset(&adev->gfx.ngg.buf[0], 0,
|
|
|
|
sizeof(struct amdgpu_ngg_buf) * NGG_BUF_MAX);
|
|
|
|
|
|
|
|
adev->gfx.ngg.init = false;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_ngg_init(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
|
|
|
|
if (!amdgpu_ngg || adev->gfx.ngg.init == true)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* GDS reserve memory: 64 bytes alignment */
|
|
|
|
adev->gfx.ngg.gds_reserve_size = ALIGN(5 * 4, 0x40);
|
|
|
|
adev->gds.mem.total_size -= adev->gfx.ngg.gds_reserve_size;
|
|
|
|
adev->gds.mem.gfx_partition_size -= adev->gfx.ngg.gds_reserve_size;
|
2018-01-10 13:45:19 +08:00
|
|
|
adev->gfx.ngg.gds_reserve_addr = RREG32_SOC15(GC, 0, mmGDS_VMID0_BASE);
|
|
|
|
adev->gfx.ngg.gds_reserve_addr += RREG32_SOC15(GC, 0, mmGDS_VMID0_SIZE);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* Primitive Buffer */
|
2017-05-04 14:49:18 +08:00
|
|
|
r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[NGG_PRIM],
|
2017-03-04 06:59:39 +08:00
|
|
|
amdgpu_prim_buf_per_se,
|
|
|
|
64 * 1024);
|
|
|
|
if (r) {
|
|
|
|
dev_err(adev->dev, "Failed to create Primitive Buffer\n");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Position Buffer */
|
2017-05-04 14:49:18 +08:00
|
|
|
r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[NGG_POS],
|
2017-03-04 06:59:39 +08:00
|
|
|
amdgpu_pos_buf_per_se,
|
|
|
|
256 * 1024);
|
|
|
|
if (r) {
|
|
|
|
dev_err(adev->dev, "Failed to create Position Buffer\n");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Control Sideband */
|
2017-05-04 14:49:18 +08:00
|
|
|
r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[NGG_CNTL],
|
2017-03-04 06:59:39 +08:00
|
|
|
amdgpu_cntl_sb_buf_per_se,
|
|
|
|
256);
|
|
|
|
if (r) {
|
|
|
|
dev_err(adev->dev, "Failed to create Control Sideband Buffer\n");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Parameter Cache, not created by default */
|
|
|
|
if (amdgpu_param_buf_per_se <= 0)
|
|
|
|
goto out;
|
|
|
|
|
2017-05-04 14:49:18 +08:00
|
|
|
r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[NGG_PARAM],
|
2017-03-04 06:59:39 +08:00
|
|
|
amdgpu_param_buf_per_se,
|
|
|
|
512 * 1024);
|
|
|
|
if (r) {
|
|
|
|
dev_err(adev->dev, "Failed to create Parameter Cache\n");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
adev->gfx.ngg.init = true;
|
|
|
|
return 0;
|
|
|
|
err:
|
|
|
|
gfx_v9_0_ngg_fini(adev);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_ngg_en(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
struct amdgpu_ring *ring = &adev->gfx.gfx_ring[0];
|
|
|
|
int r;
|
2017-08-31 20:50:23 +08:00
|
|
|
u32 data, base;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
if (!amdgpu_ngg)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Program buffer size */
|
2017-08-31 20:50:23 +08:00
|
|
|
data = REG_SET_FIELD(0, WD_BUF_RESOURCE_1, INDEX_BUF_SIZE,
|
|
|
|
adev->gfx.ngg.buf[NGG_PRIM].size >> 8);
|
|
|
|
data = REG_SET_FIELD(data, WD_BUF_RESOURCE_1, POS_BUF_SIZE,
|
|
|
|
adev->gfx.ngg.buf[NGG_POS].size >> 8);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmWD_BUF_RESOURCE_1, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-08-31 20:50:23 +08:00
|
|
|
data = REG_SET_FIELD(0, WD_BUF_RESOURCE_2, CNTL_SB_BUF_SIZE,
|
|
|
|
adev->gfx.ngg.buf[NGG_CNTL].size >> 8);
|
|
|
|
data = REG_SET_FIELD(data, WD_BUF_RESOURCE_2, PARAM_BUF_SIZE,
|
|
|
|
adev->gfx.ngg.buf[NGG_PARAM].size >> 10);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmWD_BUF_RESOURCE_2, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* Program buffer base address */
|
2017-05-04 14:49:18 +08:00
|
|
|
base = lower_32_bits(adev->gfx.ngg.buf[NGG_PRIM].gpu_addr);
|
2017-03-04 06:59:39 +08:00
|
|
|
data = REG_SET_FIELD(0, WD_INDEX_BUF_BASE, BASE, base);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmWD_INDEX_BUF_BASE, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-05-04 14:49:18 +08:00
|
|
|
base = upper_32_bits(adev->gfx.ngg.buf[NGG_PRIM].gpu_addr);
|
2017-03-04 06:59:39 +08:00
|
|
|
data = REG_SET_FIELD(0, WD_INDEX_BUF_BASE_HI, BASE_HI, base);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmWD_INDEX_BUF_BASE_HI, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-05-04 14:49:18 +08:00
|
|
|
base = lower_32_bits(adev->gfx.ngg.buf[NGG_POS].gpu_addr);
|
2017-03-04 06:59:39 +08:00
|
|
|
data = REG_SET_FIELD(0, WD_POS_BUF_BASE, BASE, base);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmWD_POS_BUF_BASE, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-05-04 14:49:18 +08:00
|
|
|
base = upper_32_bits(adev->gfx.ngg.buf[NGG_POS].gpu_addr);
|
2017-03-04 06:59:39 +08:00
|
|
|
data = REG_SET_FIELD(0, WD_POS_BUF_BASE_HI, BASE_HI, base);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmWD_POS_BUF_BASE_HI, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-05-04 14:49:18 +08:00
|
|
|
base = lower_32_bits(adev->gfx.ngg.buf[NGG_CNTL].gpu_addr);
|
2017-03-04 06:59:39 +08:00
|
|
|
data = REG_SET_FIELD(0, WD_CNTL_SB_BUF_BASE, BASE, base);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmWD_CNTL_SB_BUF_BASE, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-05-04 14:49:18 +08:00
|
|
|
base = upper_32_bits(adev->gfx.ngg.buf[NGG_CNTL].gpu_addr);
|
2017-03-04 06:59:39 +08:00
|
|
|
data = REG_SET_FIELD(0, WD_CNTL_SB_BUF_BASE_HI, BASE_HI, base);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmWD_CNTL_SB_BUF_BASE_HI, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* Clear GDS reserved memory */
|
|
|
|
r = amdgpu_ring_alloc(ring, 17);
|
|
|
|
if (r) {
|
2018-10-30 20:16:28 +08:00
|
|
|
DRM_ERROR("amdgpu: NGG failed to lock ring %s (%d).\n",
|
|
|
|
ring->name, r);
|
2017-03-04 06:59:39 +08:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx_v9_0_write_data_to_reg(ring, 0, false,
|
2017-11-29 06:01:21 +08:00
|
|
|
SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE),
|
2017-03-04 06:59:39 +08:00
|
|
|
(adev->gds.mem.total_size +
|
2018-09-14 22:06:31 +08:00
|
|
|
adev->gfx.ngg.gds_reserve_size));
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_DMA_DATA, 5));
|
|
|
|
amdgpu_ring_write(ring, (PACKET3_DMA_DATA_CP_SYNC |
|
2018-01-10 13:45:19 +08:00
|
|
|
PACKET3_DMA_DATA_DST_SEL(1) |
|
2017-03-04 06:59:39 +08:00
|
|
|
PACKET3_DMA_DATA_SRC_SEL(2)));
|
|
|
|
amdgpu_ring_write(ring, 0);
|
|
|
|
amdgpu_ring_write(ring, 0);
|
|
|
|
amdgpu_ring_write(ring, adev->gfx.ngg.gds_reserve_addr);
|
|
|
|
amdgpu_ring_write(ring, 0);
|
2018-01-10 13:45:19 +08:00
|
|
|
amdgpu_ring_write(ring, PACKET3_DMA_DATA_CMD_RAW_WAIT |
|
|
|
|
adev->gfx.ngg.gds_reserve_size);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
gfx_v9_0_write_data_to_reg(ring, 0, false,
|
2017-11-29 06:01:21 +08:00
|
|
|
SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE), 0);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
amdgpu_ring_commit(ring);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-06-05 22:58:56 +08:00
|
|
|
static int gfx_v9_0_compute_ring_init(struct amdgpu_device *adev, int ring_id,
|
|
|
|
int mec, int pipe, int queue)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
unsigned irq_type;
|
|
|
|
struct amdgpu_ring *ring = &adev->gfx.compute_ring[ring_id];
|
|
|
|
|
|
|
|
ring = &adev->gfx.compute_ring[ring_id];
|
|
|
|
|
|
|
|
/* mec0 is me1 */
|
|
|
|
ring->me = mec + 1;
|
|
|
|
ring->pipe = pipe;
|
|
|
|
ring->queue = queue;
|
|
|
|
|
|
|
|
ring->ring_obj = NULL;
|
|
|
|
ring->use_doorbell = true;
|
2018-11-20 05:20:07 +08:00
|
|
|
ring->doorbell_index = (adev->doorbell_index.mec_ring0 + ring_id) << 1;
|
2017-06-05 22:58:56 +08:00
|
|
|
ring->eop_gpu_addr = adev->gfx.mec.hpd_eop_gpu_addr
|
|
|
|
+ (ring_id * GFX9_MEC_HPD_SIZE);
|
|
|
|
sprintf(ring->name, "comp_%d.%d.%d", ring->me, ring->pipe, ring->queue);
|
|
|
|
|
|
|
|
irq_type = AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP
|
|
|
|
+ ((ring->me - 1) * adev->gfx.mec.num_pipe_per_mec)
|
|
|
|
+ ring->pipe;
|
|
|
|
|
|
|
|
/* type-2 packets are deprecated on MEC, use type-3 instead */
|
|
|
|
r = amdgpu_ring_init(adev, ring, 1024,
|
|
|
|
&adev->gfx.eop_irq, irq_type);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
static int gfx_v9_0_sw_init(void *handle)
|
|
|
|
{
|
2017-06-05 22:58:56 +08:00
|
|
|
int i, j, k, r, ring_id;
|
2017-03-04 06:59:39 +08:00
|
|
|
struct amdgpu_ring *ring;
|
2017-02-13 16:13:46 +08:00
|
|
|
struct amdgpu_kiq *kiq;
|
2017-03-04 06:59:39 +08:00
|
|
|
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
|
|
|
|
2017-06-08 02:20:21 +08:00
|
|
|
switch (adev->asic_type) {
|
|
|
|
case CHIP_VEGA10:
|
2017-09-02 14:26:09 +08:00
|
|
|
case CHIP_VEGA12:
|
2018-04-20 15:51:26 +08:00
|
|
|
case CHIP_VEGA20:
|
2017-06-08 02:20:21 +08:00
|
|
|
case CHIP_RAVEN:
|
|
|
|
adev->gfx.mec.num_mec = 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
adev->gfx.mec.num_mec = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
adev->gfx.mec.num_pipe_per_mec = 4;
|
|
|
|
adev->gfx.mec.num_queue_per_pipe = 8;
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
/* EOP Event */
|
2018-05-25 22:45:34 +08:00
|
|
|
r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_GRBM_CP, GFX_9_0__SRCID__CP_EOP_INTERRUPT, &adev->gfx.eop_irq);
|
2017-03-04 06:59:39 +08:00
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
/* Privileged reg */
|
2018-05-25 22:45:34 +08:00
|
|
|
r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_GRBM_CP, GFX_9_0__SRCID__CP_PRIV_REG_FAULT,
|
2017-03-04 06:59:39 +08:00
|
|
|
&adev->gfx.priv_reg_irq);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
/* Privileged inst */
|
2018-05-25 22:45:34 +08:00
|
|
|
r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_GRBM_CP, GFX_9_0__SRCID__CP_PRIV_INSTR_FAULT,
|
2017-03-04 06:59:39 +08:00
|
|
|
&adev->gfx.priv_inst_irq);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
adev->gfx.gfx_current_status = AMDGPU_GFX_NORMAL_MODE;
|
|
|
|
|
|
|
|
gfx_v9_0_scratch_init(adev);
|
|
|
|
|
|
|
|
r = gfx_v9_0_init_microcode(adev);
|
|
|
|
if (r) {
|
|
|
|
DRM_ERROR("Failed to load gfx firmware!\n");
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2018-09-28 19:21:23 +08:00
|
|
|
r = adev->gfx.rlc.funcs->init(adev);
|
2017-02-13 13:55:23 +08:00
|
|
|
if (r) {
|
|
|
|
DRM_ERROR("Failed to init rlc BOs!\n");
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
r = gfx_v9_0_mec_init(adev);
|
|
|
|
if (r) {
|
|
|
|
DRM_ERROR("Failed to init MEC BOs!\n");
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set up the gfx ring */
|
|
|
|
for (i = 0; i < adev->gfx.num_gfx_rings; i++) {
|
|
|
|
ring = &adev->gfx.gfx_ring[i];
|
|
|
|
ring->ring_obj = NULL;
|
2017-09-01 21:13:04 +08:00
|
|
|
if (!i)
|
|
|
|
sprintf(ring->name, "gfx");
|
|
|
|
else
|
|
|
|
sprintf(ring->name, "gfx_%d", i);
|
2017-03-04 06:59:39 +08:00
|
|
|
ring->use_doorbell = true;
|
2018-11-20 05:20:07 +08:00
|
|
|
ring->doorbell_index = adev->doorbell_index.gfx_ring0 << 1;
|
2017-03-04 06:59:39 +08:00
|
|
|
r = amdgpu_ring_init(adev, ring, 1024,
|
|
|
|
&adev->gfx.eop_irq, AMDGPU_CP_IRQ_GFX_EOP);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2017-06-05 22:58:56 +08:00
|
|
|
/* set up the compute queues - allocate horizontally across pipes */
|
|
|
|
ring_id = 0;
|
|
|
|
for (i = 0; i < adev->gfx.mec.num_mec; ++i) {
|
|
|
|
for (j = 0; j < adev->gfx.mec.num_queue_per_pipe; j++) {
|
|
|
|
for (k = 0; k < adev->gfx.mec.num_pipe_per_mec; k++) {
|
2017-06-08 00:59:29 +08:00
|
|
|
if (!amdgpu_gfx_is_mec_queue_enabled(adev, i, k, j))
|
2017-06-05 22:58:56 +08:00
|
|
|
continue;
|
|
|
|
|
|
|
|
r = gfx_v9_0_compute_ring_init(adev,
|
|
|
|
ring_id,
|
|
|
|
i, k, j);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
ring_id++;
|
|
|
|
}
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-08 01:31:32 +08:00
|
|
|
r = amdgpu_gfx_kiq_init(adev, GFX9_MEC_HPD_SIZE);
|
2017-04-18 05:51:00 +08:00
|
|
|
if (r) {
|
|
|
|
DRM_ERROR("Failed to init KIQ BOs!\n");
|
|
|
|
return r;
|
|
|
|
}
|
2017-02-13 16:13:46 +08:00
|
|
|
|
2017-04-18 05:51:00 +08:00
|
|
|
kiq = &adev->gfx.kiq;
|
2017-06-08 01:31:32 +08:00
|
|
|
r = amdgpu_gfx_kiq_init_ring(adev, &kiq->ring, &kiq->irq);
|
2017-04-18 05:51:00 +08:00
|
|
|
if (r)
|
|
|
|
return r;
|
2017-02-28 16:48:47 +08:00
|
|
|
|
2017-04-18 05:51:00 +08:00
|
|
|
/* create MQD for all compute queues as wel as KIQ for SRIOV case */
|
2017-08-19 11:52:37 +08:00
|
|
|
r = amdgpu_gfx_compute_mqd_sw_init(adev, sizeof(struct v9_mqd_allocation));
|
2017-04-18 05:51:00 +08:00
|
|
|
if (r)
|
|
|
|
return r;
|
2017-02-13 16:13:46 +08:00
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
adev->gfx.ce_ram_size = 0x8000;
|
|
|
|
|
2018-04-20 12:31:04 +08:00
|
|
|
r = gfx_v9_0_gpu_early_init(adev);
|
|
|
|
if (r)
|
|
|
|
return r;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
r = gfx_v9_0_ngg_init(adev);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int gfx_v9_0_sw_fini(void *handle)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
|
|
|
|
|
|
|
amdgpu_bo_free_kernel(&adev->gds.oa_gfx_bo, NULL, NULL);
|
|
|
|
amdgpu_bo_free_kernel(&adev->gds.gws_gfx_bo, NULL, NULL);
|
|
|
|
amdgpu_bo_free_kernel(&adev->gds.gds_gfx_bo, NULL, NULL);
|
|
|
|
|
|
|
|
for (i = 0; i < adev->gfx.num_gfx_rings; i++)
|
|
|
|
amdgpu_ring_fini(&adev->gfx.gfx_ring[i]);
|
|
|
|
for (i = 0; i < adev->gfx.num_compute_rings; i++)
|
|
|
|
amdgpu_ring_fini(&adev->gfx.compute_ring[i]);
|
|
|
|
|
2017-06-08 03:27:52 +08:00
|
|
|
amdgpu_gfx_compute_mqd_sw_fini(adev);
|
2017-06-08 01:31:32 +08:00
|
|
|
amdgpu_gfx_kiq_free_ring(&adev->gfx.kiq.ring, &adev->gfx.kiq.irq);
|
|
|
|
amdgpu_gfx_kiq_fini(adev);
|
2017-02-13 16:13:46 +08:00
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
gfx_v9_0_mec_fini(adev);
|
|
|
|
gfx_v9_0_ngg_fini(adev);
|
2017-11-14 16:55:14 +08:00
|
|
|
amdgpu_bo_free_kernel(&adev->gfx.rlc.clear_state_obj,
|
|
|
|
&adev->gfx.rlc.clear_state_gpu_addr,
|
|
|
|
(void **)&adev->gfx.rlc.cs_ptr);
|
2018-09-14 04:41:57 +08:00
|
|
|
if (adev->asic_type == CHIP_RAVEN) {
|
2017-11-14 16:55:14 +08:00
|
|
|
amdgpu_bo_free_kernel(&adev->gfx.rlc.cp_table_obj,
|
|
|
|
&adev->gfx.rlc.cp_table_gpu_addr,
|
|
|
|
(void **)&adev->gfx.rlc.cp_table_ptr);
|
|
|
|
}
|
2017-09-19 16:09:53 +08:00
|
|
|
gfx_v9_0_free_microcode(adev);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void gfx_v9_0_tiling_mode_table_init(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
/* TODO */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_select_se_sh(struct amdgpu_device *adev, u32 se_num, u32 sh_num, u32 instance)
|
|
|
|
{
|
2017-07-14 19:00:04 +08:00
|
|
|
u32 data;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-07-14 19:00:04 +08:00
|
|
|
if (instance == 0xffffffff)
|
|
|
|
data = REG_SET_FIELD(0, GRBM_GFX_INDEX, INSTANCE_BROADCAST_WRITES, 1);
|
|
|
|
else
|
|
|
|
data = REG_SET_FIELD(0, GRBM_GFX_INDEX, INSTANCE_INDEX, instance);
|
|
|
|
|
|
|
|
if (se_num == 0xffffffff)
|
2017-03-04 06:59:39 +08:00
|
|
|
data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SE_BROADCAST_WRITES, 1);
|
2017-07-14 19:00:04 +08:00
|
|
|
else
|
2017-03-04 06:59:39 +08:00
|
|
|
data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SE_INDEX, se_num);
|
2017-07-14 19:00:04 +08:00
|
|
|
|
|
|
|
if (sh_num == 0xffffffff)
|
|
|
|
data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SH_BROADCAST_WRITES, 1);
|
|
|
|
else
|
2017-03-04 06:59:39 +08:00
|
|
|
data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SH_INDEX, sh_num);
|
2017-07-14 19:00:04 +08:00
|
|
|
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmGRBM_GFX_INDEX, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static u32 gfx_v9_0_get_rb_active_bitmap(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
u32 data, mask;
|
|
|
|
|
2017-04-07 19:53:53 +08:00
|
|
|
data = RREG32_SOC15(GC, 0, mmCC_RB_BACKEND_DISABLE);
|
|
|
|
data |= RREG32_SOC15(GC, 0, mmGC_USER_RB_BACKEND_DISABLE);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
data &= CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK;
|
|
|
|
data >>= GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT;
|
|
|
|
|
2017-06-07 05:41:20 +08:00
|
|
|
mask = amdgpu_gfx_create_bitmask(adev->gfx.config.max_backends_per_se /
|
|
|
|
adev->gfx.config.max_sh_per_se);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
return (~data) & mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_setup_rb(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
int i, j;
|
2017-03-25 02:47:18 +08:00
|
|
|
u32 data;
|
2017-03-04 06:59:39 +08:00
|
|
|
u32 active_rbs = 0;
|
|
|
|
u32 rb_bitmap_width_per_sh = adev->gfx.config.max_backends_per_se /
|
|
|
|
adev->gfx.config.max_sh_per_se;
|
|
|
|
|
|
|
|
mutex_lock(&adev->grbm_idx_mutex);
|
|
|
|
for (i = 0; i < adev->gfx.config.max_shader_engines; i++) {
|
|
|
|
for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) {
|
|
|
|
gfx_v9_0_select_se_sh(adev, i, j, 0xffffffff);
|
|
|
|
data = gfx_v9_0_get_rb_active_bitmap(adev);
|
|
|
|
active_rbs |= data << ((i * adev->gfx.config.max_sh_per_se + j) *
|
|
|
|
rb_bitmap_width_per_sh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gfx_v9_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
|
|
|
|
mutex_unlock(&adev->grbm_idx_mutex);
|
|
|
|
|
|
|
|
adev->gfx.config.backend_enable_mask = active_rbs;
|
2017-03-25 02:47:18 +08:00
|
|
|
adev->gfx.config.num_rbs = hweight32(active_rbs);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define DEFAULT_SH_MEM_BASES (0x6000)
|
|
|
|
#define FIRST_COMPUTE_VMID (8)
|
|
|
|
#define LAST_COMPUTE_VMID (16)
|
|
|
|
static void gfx_v9_0_init_compute_vmid(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
uint32_t sh_mem_config;
|
|
|
|
uint32_t sh_mem_bases;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configure apertures:
|
|
|
|
* LDS: 0x60000000'00000000 - 0x60000001'00000000 (4GB)
|
|
|
|
* Scratch: 0x60000001'00000000 - 0x60000002'00000000 (4GB)
|
|
|
|
* GPUVM: 0x60010000'00000000 - 0x60020000'00000000 (1TB)
|
|
|
|
*/
|
|
|
|
sh_mem_bases = DEFAULT_SH_MEM_BASES | (DEFAULT_SH_MEM_BASES << 16);
|
|
|
|
|
|
|
|
sh_mem_config = SH_MEM_ADDRESS_MODE_64 |
|
|
|
|
SH_MEM_ALIGNMENT_MODE_UNALIGNED <<
|
2017-05-01 17:00:13 +08:00
|
|
|
SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
mutex_lock(&adev->srbm_mutex);
|
|
|
|
for (i = FIRST_COMPUTE_VMID; i < LAST_COMPUTE_VMID; i++) {
|
|
|
|
soc15_grbm_select(adev, 0, 0, 0, i);
|
|
|
|
/* CP and shaders */
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmSH_MEM_CONFIG, sh_mem_config);
|
|
|
|
WREG32_SOC15(GC, 0, mmSH_MEM_BASES, sh_mem_bases);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
soc15_grbm_select(adev, 0, 0, 0, 0);
|
|
|
|
mutex_unlock(&adev->srbm_mutex);
|
|
|
|
}
|
|
|
|
|
2018-08-28 18:20:19 +08:00
|
|
|
static void gfx_v9_0_constants_init(struct amdgpu_device *adev)
|
2017-03-04 06:59:39 +08:00
|
|
|
{
|
|
|
|
u32 tmp;
|
|
|
|
int i;
|
|
|
|
|
2017-04-05 21:16:01 +08:00
|
|
|
WREG32_FIELD15(GC, 0, GRBM_CNTL, READ_TIMEOUT, 0xff);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
gfx_v9_0_tiling_mode_table_init(adev);
|
|
|
|
|
|
|
|
gfx_v9_0_setup_rb(adev);
|
|
|
|
gfx_v9_0_get_cu_info(adev, &adev->gfx.cu_info);
|
2018-04-10 23:15:26 +08:00
|
|
|
adev->gfx.config.db_debug2 = RREG32_SOC15(GC, 0, mmDB_DEBUG2);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* XXX SH_MEM regs */
|
|
|
|
/* where to put LDS, scratch, GPUVM in FSA64 space */
|
|
|
|
mutex_lock(&adev->srbm_mutex);
|
2018-01-02 05:14:43 +08:00
|
|
|
for (i = 0; i < adev->vm_manager.id_mgr[AMDGPU_GFXHUB].num_ids; i++) {
|
2017-03-04 06:59:39 +08:00
|
|
|
soc15_grbm_select(adev, 0, 0, 0, i);
|
|
|
|
/* CP and shaders */
|
2017-12-09 04:09:20 +08:00
|
|
|
if (i == 0) {
|
|
|
|
tmp = REG_SET_FIELD(0, SH_MEM_CONFIG, ALIGNMENT_MODE,
|
|
|
|
SH_MEM_ALIGNMENT_MODE_UNALIGNED);
|
|
|
|
WREG32_SOC15(GC, 0, mmSH_MEM_CONFIG, tmp);
|
|
|
|
WREG32_SOC15(GC, 0, mmSH_MEM_BASES, 0);
|
|
|
|
} else {
|
|
|
|
tmp = REG_SET_FIELD(0, SH_MEM_CONFIG, ALIGNMENT_MODE,
|
|
|
|
SH_MEM_ALIGNMENT_MODE_UNALIGNED);
|
|
|
|
WREG32_SOC15(GC, 0, mmSH_MEM_CONFIG, tmp);
|
2018-04-18 17:12:19 +08:00
|
|
|
tmp = REG_SET_FIELD(0, SH_MEM_BASES, PRIVATE_BASE,
|
|
|
|
(adev->gmc.private_aperture_start >> 48));
|
|
|
|
tmp = REG_SET_FIELD(tmp, SH_MEM_BASES, SHARED_BASE,
|
|
|
|
(adev->gmc.shared_aperture_start >> 48));
|
2017-12-09 04:09:20 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmSH_MEM_BASES, tmp);
|
|
|
|
}
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
soc15_grbm_select(adev, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
mutex_unlock(&adev->srbm_mutex);
|
|
|
|
|
|
|
|
gfx_v9_0_init_compute_vmid(adev);
|
|
|
|
|
|
|
|
mutex_lock(&adev->grbm_idx_mutex);
|
|
|
|
/*
|
|
|
|
* making sure that the following register writes will be broadcasted
|
|
|
|
* to all the shaders
|
|
|
|
*/
|
|
|
|
gfx_v9_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
|
|
|
|
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmPA_SC_FIFO_SIZE,
|
2017-03-04 06:59:39 +08:00
|
|
|
(adev->gfx.config.sc_prim_fifo_size_frontend <<
|
|
|
|
PA_SC_FIFO_SIZE__SC_FRONTEND_PRIM_FIFO_SIZE__SHIFT) |
|
|
|
|
(adev->gfx.config.sc_prim_fifo_size_backend <<
|
|
|
|
PA_SC_FIFO_SIZE__SC_BACKEND_PRIM_FIFO_SIZE__SHIFT) |
|
|
|
|
(adev->gfx.config.sc_hiz_tile_fifo_size <<
|
|
|
|
PA_SC_FIFO_SIZE__SC_HIZ_TILE_FIFO_SIZE__SHIFT) |
|
|
|
|
(adev->gfx.config.sc_earlyz_tile_fifo_size <<
|
|
|
|
PA_SC_FIFO_SIZE__SC_EARLYZ_TILE_FIFO_SIZE__SHIFT));
|
|
|
|
mutex_unlock(&adev->grbm_idx_mutex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_wait_for_rlc_serdes(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
u32 i, j, k;
|
|
|
|
u32 mask;
|
|
|
|
|
|
|
|
mutex_lock(&adev->grbm_idx_mutex);
|
|
|
|
for (i = 0; i < adev->gfx.config.max_shader_engines; i++) {
|
|
|
|
for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) {
|
|
|
|
gfx_v9_0_select_se_sh(adev, i, j, 0xffffffff);
|
|
|
|
for (k = 0; k < adev->usec_timeout; k++) {
|
2017-04-07 19:53:53 +08:00
|
|
|
if (RREG32_SOC15(GC, 0, mmRLC_SERDES_CU_MASTER_BUSY) == 0)
|
2017-03-04 06:59:39 +08:00
|
|
|
break;
|
|
|
|
udelay(1);
|
|
|
|
}
|
2017-10-23 16:31:04 +08:00
|
|
|
if (k == adev->usec_timeout) {
|
|
|
|
gfx_v9_0_select_se_sh(adev, 0xffffffff,
|
|
|
|
0xffffffff, 0xffffffff);
|
|
|
|
mutex_unlock(&adev->grbm_idx_mutex);
|
|
|
|
DRM_INFO("Timeout wait for RLC serdes %u,%u\n",
|
|
|
|
i, j);
|
|
|
|
return;
|
|
|
|
}
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
gfx_v9_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
|
|
|
|
mutex_unlock(&adev->grbm_idx_mutex);
|
|
|
|
|
|
|
|
mask = RLC_SERDES_NONCU_MASTER_BUSY__SE_MASTER_BUSY_MASK |
|
|
|
|
RLC_SERDES_NONCU_MASTER_BUSY__GC_MASTER_BUSY_MASK |
|
|
|
|
RLC_SERDES_NONCU_MASTER_BUSY__TC0_MASTER_BUSY_MASK |
|
|
|
|
RLC_SERDES_NONCU_MASTER_BUSY__TC1_MASTER_BUSY_MASK;
|
|
|
|
for (k = 0; k < adev->usec_timeout; k++) {
|
2017-04-07 19:53:53 +08:00
|
|
|
if ((RREG32_SOC15(GC, 0, mmRLC_SERDES_NONCU_MASTER_BUSY) & mask) == 0)
|
2017-03-04 06:59:39 +08:00
|
|
|
break;
|
|
|
|
udelay(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_enable_gui_idle_interrupt(struct amdgpu_device *adev,
|
|
|
|
bool enable)
|
|
|
|
{
|
2017-04-07 19:53:53 +08:00
|
|
|
u32 tmp = RREG32_SOC15(GC, 0, mmCP_INT_CNTL_RING0);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CNTX_BUSY_INT_ENABLE, enable ? 1 : 0);
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CNTX_EMPTY_INT_ENABLE, enable ? 1 : 0);
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CMP_BUSY_INT_ENABLE, enable ? 1 : 0);
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, GFX_IDLE_INT_ENABLE, enable ? 1 : 0);
|
|
|
|
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_INT_CNTL_RING0, tmp);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
2017-02-10 14:37:03 +08:00
|
|
|
static void gfx_v9_0_init_csb(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
/* csib */
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CSIB_ADDR_HI),
|
|
|
|
adev->gfx.rlc.clear_state_gpu_addr >> 32);
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CSIB_ADDR_LO),
|
|
|
|
adev->gfx.rlc.clear_state_gpu_addr & 0xfffffffc);
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CSIB_LENGTH),
|
|
|
|
adev->gfx.rlc.clear_state_size);
|
|
|
|
}
|
|
|
|
|
2017-12-21 16:13:02 +08:00
|
|
|
static void gfx_v9_1_parse_ind_reg_list(int *register_list_format,
|
2017-02-10 14:37:03 +08:00
|
|
|
int indirect_offset,
|
|
|
|
int list_size,
|
|
|
|
int *unique_indirect_regs,
|
2018-05-29 16:31:05 +08:00
|
|
|
int unique_indirect_reg_count,
|
2017-02-10 14:37:03 +08:00
|
|
|
int *indirect_start_offsets,
|
2018-05-29 16:31:05 +08:00
|
|
|
int *indirect_start_offsets_count,
|
|
|
|
int max_start_offsets_count)
|
2017-02-10 14:37:03 +08:00
|
|
|
{
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
for (; indirect_offset < list_size; indirect_offset++) {
|
2018-05-29 16:31:05 +08:00
|
|
|
WARN_ON(*indirect_start_offsets_count >= max_start_offsets_count);
|
2017-12-21 16:13:02 +08:00
|
|
|
indirect_start_offsets[*indirect_start_offsets_count] = indirect_offset;
|
|
|
|
*indirect_start_offsets_count = *indirect_start_offsets_count + 1;
|
2017-02-10 14:37:03 +08:00
|
|
|
|
2017-12-21 16:13:02 +08:00
|
|
|
while (register_list_format[indirect_offset] != 0xFFFFFFFF) {
|
|
|
|
indirect_offset += 2;
|
2017-02-10 14:37:03 +08:00
|
|
|
|
2017-12-21 16:13:02 +08:00
|
|
|
/* look for the matching indice */
|
2018-05-29 16:31:05 +08:00
|
|
|
for (idx = 0; idx < unique_indirect_reg_count; idx++) {
|
2017-12-21 16:13:02 +08:00
|
|
|
if (unique_indirect_regs[idx] ==
|
|
|
|
register_list_format[indirect_offset] ||
|
|
|
|
!unique_indirect_regs[idx])
|
|
|
|
break;
|
|
|
|
}
|
2017-02-10 14:37:03 +08:00
|
|
|
|
2018-05-29 16:31:05 +08:00
|
|
|
BUG_ON(idx >= unique_indirect_reg_count);
|
2017-02-10 14:37:03 +08:00
|
|
|
|
2017-12-21 16:13:02 +08:00
|
|
|
if (!unique_indirect_regs[idx])
|
|
|
|
unique_indirect_regs[idx] = register_list_format[indirect_offset];
|
2017-02-10 14:37:03 +08:00
|
|
|
|
2017-12-21 16:13:02 +08:00
|
|
|
indirect_offset++;
|
2017-02-10 14:37:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-21 16:13:02 +08:00
|
|
|
static int gfx_v9_1_init_rlc_save_restore_list(struct amdgpu_device *adev)
|
2017-02-10 14:37:03 +08:00
|
|
|
{
|
|
|
|
int unique_indirect_regs[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
|
|
|
|
int unique_indirect_reg_count = 0;
|
|
|
|
|
|
|
|
int indirect_start_offsets[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
|
|
|
|
int indirect_start_offsets_count = 0;
|
|
|
|
|
|
|
|
int list_size = 0;
|
2017-12-21 16:13:02 +08:00
|
|
|
int i = 0, j = 0;
|
2017-02-10 14:37:03 +08:00
|
|
|
u32 tmp = 0;
|
|
|
|
|
|
|
|
u32 *register_list_format =
|
|
|
|
kmalloc(adev->gfx.rlc.reg_list_format_size_bytes, GFP_KERNEL);
|
|
|
|
if (!register_list_format)
|
|
|
|
return -ENOMEM;
|
|
|
|
memcpy(register_list_format, adev->gfx.rlc.register_list_format,
|
|
|
|
adev->gfx.rlc.reg_list_format_size_bytes);
|
|
|
|
|
|
|
|
/* setup unique_indirect_regs array and indirect_start_offsets array */
|
2017-12-21 16:13:02 +08:00
|
|
|
unique_indirect_reg_count = ARRAY_SIZE(unique_indirect_regs);
|
|
|
|
gfx_v9_1_parse_ind_reg_list(register_list_format,
|
|
|
|
adev->gfx.rlc.reg_list_format_direct_reg_list_length,
|
|
|
|
adev->gfx.rlc.reg_list_format_size_bytes >> 2,
|
|
|
|
unique_indirect_regs,
|
2018-05-29 16:31:05 +08:00
|
|
|
unique_indirect_reg_count,
|
2017-12-21 16:13:02 +08:00
|
|
|
indirect_start_offsets,
|
2018-05-29 16:31:05 +08:00
|
|
|
&indirect_start_offsets_count,
|
|
|
|
ARRAY_SIZE(indirect_start_offsets));
|
2017-02-10 14:37:03 +08:00
|
|
|
|
|
|
|
/* enable auto inc in case it is disabled */
|
|
|
|
tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_SRM_CNTL));
|
|
|
|
tmp |= RLC_SRM_CNTL__AUTO_INCR_ADDR_MASK;
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_SRM_CNTL), tmp);
|
|
|
|
|
|
|
|
/* write register_restore table to offset 0x0 using RLC_SRM_ARAM_ADDR/DATA */
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_SRM_ARAM_ADDR),
|
|
|
|
RLC_SAVE_RESTORE_ADDR_STARTING_OFFSET);
|
|
|
|
for (i = 0; i < adev->gfx.rlc.reg_list_size_bytes >> 2; i++)
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_SRM_ARAM_DATA),
|
|
|
|
adev->gfx.rlc.register_restore[i]);
|
|
|
|
|
|
|
|
/* load indirect register */
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_SCRATCH_ADDR),
|
|
|
|
adev->gfx.rlc.reg_list_format_start);
|
2017-12-21 16:13:02 +08:00
|
|
|
|
|
|
|
/* direct register portion */
|
|
|
|
for (i = 0; i < adev->gfx.rlc.reg_list_format_direct_reg_list_length; i++)
|
2017-02-10 14:37:03 +08:00
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_SCRATCH_DATA),
|
|
|
|
register_list_format[i]);
|
|
|
|
|
2017-12-21 16:13:02 +08:00
|
|
|
/* indirect register portion */
|
|
|
|
while (i < (adev->gfx.rlc.reg_list_format_size_bytes >> 2)) {
|
|
|
|
if (register_list_format[i] == 0xFFFFFFFF) {
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_GPM_SCRATCH_DATA, register_list_format[i++]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_GPM_SCRATCH_DATA, register_list_format[i++]);
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_GPM_SCRATCH_DATA, register_list_format[i++]);
|
|
|
|
|
|
|
|
for (j = 0; j < unique_indirect_reg_count; j++) {
|
|
|
|
if (register_list_format[i] == unique_indirect_regs[j]) {
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_GPM_SCRATCH_DATA, j);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BUG_ON(j >= unique_indirect_reg_count);
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2017-02-10 14:37:03 +08:00
|
|
|
/* set save/restore list size */
|
|
|
|
list_size = adev->gfx.rlc.reg_list_size_bytes >> 2;
|
|
|
|
list_size = list_size >> 1;
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_SCRATCH_ADDR),
|
|
|
|
adev->gfx.rlc.reg_restore_list_size);
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_SCRATCH_DATA), list_size);
|
|
|
|
|
|
|
|
/* write the starting offsets to RLC scratch ram */
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_SCRATCH_ADDR),
|
|
|
|
adev->gfx.rlc.starting_offsets_start);
|
2017-10-16 10:29:23 +08:00
|
|
|
for (i = 0; i < ARRAY_SIZE(indirect_start_offsets); i++)
|
2017-02-10 14:37:03 +08:00
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_SCRATCH_DATA),
|
2017-12-21 16:13:02 +08:00
|
|
|
indirect_start_offsets[i]);
|
2017-02-10 14:37:03 +08:00
|
|
|
|
|
|
|
/* load unique indirect regs*/
|
2017-10-16 10:29:23 +08:00
|
|
|
for (i = 0; i < ARRAY_SIZE(unique_indirect_regs); i++) {
|
2017-12-21 16:13:02 +08:00
|
|
|
if (unique_indirect_regs[i] != 0) {
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_SRM_INDEX_CNTL_ADDR_0)
|
|
|
|
+ GFX_RLC_SRM_INDEX_CNTL_ADDR_OFFSETS[i],
|
|
|
|
unique_indirect_regs[i] & 0x3FFFF);
|
|
|
|
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_SRM_INDEX_CNTL_DATA_0)
|
|
|
|
+ GFX_RLC_SRM_INDEX_CNTL_DATA_OFFSETS[i],
|
|
|
|
unique_indirect_regs[i] >> 20);
|
|
|
|
}
|
2017-02-10 14:37:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
kfree(register_list_format);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_enable_save_restore_machine(struct amdgpu_device *adev)
|
|
|
|
{
|
2017-08-31 20:59:00 +08:00
|
|
|
WREG32_FIELD15(GC, 0, RLC_SRM_CNTL, SRM_ENABLE, 1);
|
2017-02-10 14:37:03 +08:00
|
|
|
}
|
|
|
|
|
2017-02-10 15:13:17 +08:00
|
|
|
static void pwr_10_0_gfxip_control_over_cgpg(struct amdgpu_device *adev,
|
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
uint32_t data = 0;
|
|
|
|
uint32_t default_data = 0;
|
|
|
|
|
|
|
|
default_data = data = RREG32(SOC15_REG_OFFSET(PWR, 0, mmPWR_MISC_CNTL_STATUS));
|
|
|
|
if (enable == true) {
|
|
|
|
/* enable GFXIP control over CGPG */
|
|
|
|
data |= PWR_MISC_CNTL_STATUS__PWR_GFX_RLC_CGPG_EN_MASK;
|
|
|
|
if(default_data != data)
|
|
|
|
WREG32(SOC15_REG_OFFSET(PWR, 0, mmPWR_MISC_CNTL_STATUS), data);
|
|
|
|
|
|
|
|
/* update status */
|
|
|
|
data &= ~PWR_MISC_CNTL_STATUS__PWR_GFXOFF_STATUS_MASK;
|
|
|
|
data |= (2 << PWR_MISC_CNTL_STATUS__PWR_GFXOFF_STATUS__SHIFT);
|
|
|
|
if(default_data != data)
|
|
|
|
WREG32(SOC15_REG_OFFSET(PWR, 0, mmPWR_MISC_CNTL_STATUS), data);
|
|
|
|
} else {
|
|
|
|
/* restore GFXIP control over GCPG */
|
|
|
|
data &= ~PWR_MISC_CNTL_STATUS__PWR_GFX_RLC_CGPG_EN_MASK;
|
|
|
|
if(default_data != data)
|
|
|
|
WREG32(SOC15_REG_OFFSET(PWR, 0, mmPWR_MISC_CNTL_STATUS), data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_init_gfx_power_gating(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
uint32_t data = 0;
|
|
|
|
|
|
|
|
if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG |
|
|
|
|
AMD_PG_SUPPORT_GFX_SMG |
|
|
|
|
AMD_PG_SUPPORT_GFX_DMG)) {
|
|
|
|
/* init IDLE_POLL_COUNT = 60 */
|
|
|
|
data = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB_WPTR_POLL_CNTL));
|
|
|
|
data &= ~CP_RB_WPTR_POLL_CNTL__IDLE_POLL_COUNT_MASK;
|
|
|
|
data |= (0x60 << CP_RB_WPTR_POLL_CNTL__IDLE_POLL_COUNT__SHIFT);
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB_WPTR_POLL_CNTL), data);
|
|
|
|
|
|
|
|
/* init RLC PG Delay */
|
|
|
|
data = 0;
|
|
|
|
data |= (0x10 << RLC_PG_DELAY__POWER_UP_DELAY__SHIFT);
|
|
|
|
data |= (0x10 << RLC_PG_DELAY__POWER_DOWN_DELAY__SHIFT);
|
|
|
|
data |= (0x10 << RLC_PG_DELAY__CMD_PROPAGATE_DELAY__SHIFT);
|
|
|
|
data |= (0x40 << RLC_PG_DELAY__MEM_SLEEP_DELAY__SHIFT);
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_DELAY), data);
|
|
|
|
|
|
|
|
data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_DELAY_2));
|
|
|
|
data &= ~RLC_PG_DELAY_2__SERDES_CMD_DELAY_MASK;
|
|
|
|
data |= (0x4 << RLC_PG_DELAY_2__SERDES_CMD_DELAY__SHIFT);
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_DELAY_2), data);
|
|
|
|
|
|
|
|
data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_DELAY_3));
|
|
|
|
data &= ~RLC_PG_DELAY_3__CGCG_ACTIVE_BEFORE_CGPG_MASK;
|
|
|
|
data |= (0xff << RLC_PG_DELAY_3__CGCG_ACTIVE_BEFORE_CGPG__SHIFT);
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_DELAY_3), data);
|
|
|
|
|
|
|
|
data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_AUTO_PG_CTRL));
|
|
|
|
data &= ~RLC_AUTO_PG_CTRL__GRBM_REG_SAVE_GFX_IDLE_THRESHOLD_MASK;
|
|
|
|
|
|
|
|
/* program GRBM_REG_SAVE_GFX_IDLE_THRESHOLD to 0x55f0 */
|
|
|
|
data |= (0x55f0 << RLC_AUTO_PG_CTRL__GRBM_REG_SAVE_GFX_IDLE_THRESHOLD__SHIFT);
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_AUTO_PG_CTRL), data);
|
|
|
|
|
|
|
|
pwr_10_0_gfxip_control_over_cgpg(adev, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-10 15:36:34 +08:00
|
|
|
static void gfx_v9_0_enable_sck_slow_down_on_power_up(struct amdgpu_device *adev,
|
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
uint32_t data = 0;
|
|
|
|
uint32_t default_data = 0;
|
|
|
|
|
|
|
|
default_data = data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_CNTL));
|
2017-08-31 21:01:11 +08:00
|
|
|
data = REG_SET_FIELD(data, RLC_PG_CNTL,
|
|
|
|
SMU_CLK_SLOWDOWN_ON_PU_ENABLE,
|
|
|
|
enable ? 1 : 0);
|
|
|
|
if (default_data != data)
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_CNTL), data);
|
2017-02-10 15:36:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_enable_sck_slow_down_on_power_down(struct amdgpu_device *adev,
|
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
uint32_t data = 0;
|
|
|
|
uint32_t default_data = 0;
|
|
|
|
|
|
|
|
default_data = data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_CNTL));
|
2017-08-31 21:02:33 +08:00
|
|
|
data = REG_SET_FIELD(data, RLC_PG_CNTL,
|
|
|
|
SMU_CLK_SLOWDOWN_ON_PD_ENABLE,
|
|
|
|
enable ? 1 : 0);
|
|
|
|
if(default_data != data)
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_CNTL), data);
|
2017-02-10 15:36:34 +08:00
|
|
|
}
|
|
|
|
|
2017-02-10 15:47:28 +08:00
|
|
|
static void gfx_v9_0_enable_cp_power_gating(struct amdgpu_device *adev,
|
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
uint32_t data = 0;
|
|
|
|
uint32_t default_data = 0;
|
|
|
|
|
|
|
|
default_data = data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_CNTL));
|
2017-08-31 21:12:47 +08:00
|
|
|
data = REG_SET_FIELD(data, RLC_PG_CNTL,
|
|
|
|
CP_PG_DISABLE,
|
|
|
|
enable ? 0 : 1);
|
|
|
|
if(default_data != data)
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_CNTL), data);
|
2017-02-10 15:47:28 +08:00
|
|
|
}
|
|
|
|
|
2017-02-13 18:40:45 +08:00
|
|
|
static void gfx_v9_0_enable_gfx_cg_power_gating(struct amdgpu_device *adev,
|
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
uint32_t data, default_data;
|
|
|
|
|
|
|
|
default_data = data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_CNTL));
|
2017-08-31 21:14:41 +08:00
|
|
|
data = REG_SET_FIELD(data, RLC_PG_CNTL,
|
|
|
|
GFX_POWER_GATING_ENABLE,
|
|
|
|
enable ? 1 : 0);
|
2017-02-13 18:40:45 +08:00
|
|
|
if(default_data != data)
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_CNTL), data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_enable_gfx_pipeline_powergating(struct amdgpu_device *adev,
|
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
uint32_t data, default_data;
|
|
|
|
|
|
|
|
default_data = data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_CNTL));
|
2017-08-31 21:27:22 +08:00
|
|
|
data = REG_SET_FIELD(data, RLC_PG_CNTL,
|
|
|
|
GFX_PIPELINE_PG_ENABLE,
|
|
|
|
enable ? 1 : 0);
|
2017-02-13 18:40:45 +08:00
|
|
|
if(default_data != data)
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_CNTL), data);
|
|
|
|
|
|
|
|
if (!enable)
|
|
|
|
/* read any GFX register to wake up GFX */
|
|
|
|
data = RREG32(SOC15_REG_OFFSET(GC, 0, mmDB_RENDER_CONTROL));
|
|
|
|
}
|
|
|
|
|
2017-06-23 04:28:47 +08:00
|
|
|
static void gfx_v9_0_enable_gfx_static_mg_power_gating(struct amdgpu_device *adev,
|
|
|
|
bool enable)
|
2017-02-13 18:45:28 +08:00
|
|
|
{
|
|
|
|
uint32_t data, default_data;
|
|
|
|
|
|
|
|
default_data = data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_CNTL));
|
2017-08-31 21:31:01 +08:00
|
|
|
data = REG_SET_FIELD(data, RLC_PG_CNTL,
|
|
|
|
STATIC_PER_CU_PG_ENABLE,
|
|
|
|
enable ? 1 : 0);
|
2017-02-13 18:45:28 +08:00
|
|
|
if(default_data != data)
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_CNTL), data);
|
|
|
|
}
|
|
|
|
|
2017-06-23 04:28:47 +08:00
|
|
|
static void gfx_v9_0_enable_gfx_dynamic_mg_power_gating(struct amdgpu_device *adev,
|
2017-02-13 18:45:28 +08:00
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
uint32_t data, default_data;
|
|
|
|
|
|
|
|
default_data = data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_CNTL));
|
2017-08-31 21:31:23 +08:00
|
|
|
data = REG_SET_FIELD(data, RLC_PG_CNTL,
|
|
|
|
DYN_PER_CU_PG_ENABLE,
|
|
|
|
enable ? 1 : 0);
|
2017-02-13 18:45:28 +08:00
|
|
|
if(default_data != data)
|
|
|
|
WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_CNTL), data);
|
|
|
|
}
|
|
|
|
|
2017-02-10 14:37:03 +08:00
|
|
|
static void gfx_v9_0_init_pg(struct amdgpu_device *adev)
|
|
|
|
{
|
2018-07-05 11:17:48 +08:00
|
|
|
gfx_v9_0_init_csb(adev);
|
|
|
|
|
2018-07-05 11:24:20 +08:00
|
|
|
/*
|
|
|
|
* Rlc save restore list is workable since v2_1.
|
|
|
|
* And it's needed by gfxoff feature.
|
|
|
|
*/
|
|
|
|
if (adev->gfx.rlc.is_rlc_v2_1) {
|
|
|
|
gfx_v9_1_init_rlc_save_restore_list(adev);
|
|
|
|
gfx_v9_0_enable_save_restore_machine(adev);
|
|
|
|
}
|
2017-12-21 15:48:27 +08:00
|
|
|
|
2017-02-10 14:37:03 +08:00
|
|
|
if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG |
|
|
|
|
AMD_PG_SUPPORT_GFX_SMG |
|
|
|
|
AMD_PG_SUPPORT_GFX_DMG |
|
|
|
|
AMD_PG_SUPPORT_CP |
|
|
|
|
AMD_PG_SUPPORT_GDS |
|
|
|
|
AMD_PG_SUPPORT_RLC_SMU_HS)) {
|
2017-12-21 15:48:27 +08:00
|
|
|
WREG32(mmRLC_JUMP_TABLE_RESTORE,
|
|
|
|
adev->gfx.rlc.cp_table_gpu_addr >> 8);
|
|
|
|
gfx_v9_0_init_gfx_power_gating(adev);
|
2017-02-10 14:37:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
void gfx_v9_0_rlc_stop(struct amdgpu_device *adev)
|
|
|
|
{
|
2017-08-31 21:40:38 +08:00
|
|
|
WREG32_FIELD15(GC, 0, RLC_CNTL, RLC_ENABLE_F32, 0);
|
2017-03-04 06:59:39 +08:00
|
|
|
gfx_v9_0_enable_gui_idle_interrupt(adev, false);
|
|
|
|
gfx_v9_0_wait_for_rlc_serdes(adev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_rlc_reset(struct amdgpu_device *adev)
|
|
|
|
{
|
2017-04-05 21:06:13 +08:00
|
|
|
WREG32_FIELD15(GC, 0, GRBM_SOFT_RESET, SOFT_RESET_RLC, 1);
|
2017-03-04 06:59:39 +08:00
|
|
|
udelay(50);
|
2017-04-05 21:06:13 +08:00
|
|
|
WREG32_FIELD15(GC, 0, GRBM_SOFT_RESET, SOFT_RESET_RLC, 0);
|
2017-03-04 06:59:39 +08:00
|
|
|
udelay(50);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_rlc_start(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
#ifdef AMDGPU_RLC_DEBUG_RETRY
|
|
|
|
u32 rlc_ucode_ver;
|
|
|
|
#endif
|
|
|
|
|
2017-04-05 21:04:50 +08:00
|
|
|
WREG32_FIELD15(GC, 0, RLC_CNTL, RLC_ENABLE_F32, 1);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* carrizo do enable cp interrupt after cp inited */
|
|
|
|
if (!(adev->flags & AMD_IS_APU))
|
|
|
|
gfx_v9_0_enable_gui_idle_interrupt(adev, true);
|
|
|
|
|
|
|
|
udelay(50);
|
|
|
|
|
|
|
|
#ifdef AMDGPU_RLC_DEBUG_RETRY
|
|
|
|
/* RLC_GPM_GENERAL_6 : RLC Ucode version */
|
2017-04-07 19:53:53 +08:00
|
|
|
rlc_ucode_ver = RREG32_SOC15(GC, 0, mmRLC_GPM_GENERAL_6);
|
2017-03-04 06:59:39 +08:00
|
|
|
if(rlc_ucode_ver == 0x108) {
|
|
|
|
DRM_INFO("Using rlc debug ucode. mmRLC_GPM_GENERAL_6 ==0x08%x / fw_ver == %i \n",
|
|
|
|
rlc_ucode_ver, adev->gfx.rlc_fw_version);
|
|
|
|
/* RLC_GPM_TIMER_INT_3 : Timer interval in RefCLK cycles,
|
|
|
|
* default is 0x9C4 to create a 100us interval */
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_GPM_TIMER_INT_3, 0x9C4);
|
2017-03-04 06:59:39 +08:00
|
|
|
/* RLC_GPM_GENERAL_12 : Minimum gap between wptr and rptr
|
2017-05-01 17:00:13 +08:00
|
|
|
* to disable the page fault retry interrupts, default is
|
2017-03-04 06:59:39 +08:00
|
|
|
* 0x100 (256) */
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_GPM_GENERAL_12, 0x100);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_rlc_load_microcode(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
const struct rlc_firmware_header_v2_0 *hdr;
|
|
|
|
const __le32 *fw_data;
|
|
|
|
unsigned i, fw_size;
|
|
|
|
|
|
|
|
if (!adev->gfx.rlc_fw)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data;
|
|
|
|
amdgpu_ucode_print_rlc_hdr(&hdr->header);
|
|
|
|
|
|
|
|
fw_data = (const __le32 *)(adev->gfx.rlc_fw->data +
|
|
|
|
le32_to_cpu(hdr->header.ucode_array_offset_bytes));
|
|
|
|
fw_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4;
|
|
|
|
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_GPM_UCODE_ADDR,
|
2017-03-04 06:59:39 +08:00
|
|
|
RLCG_UCODE_LOADING_START_ADDRESS);
|
|
|
|
for (i = 0; i < fw_size; i++)
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_GPM_UCODE_DATA, le32_to_cpup(fw_data++));
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_GPM_UCODE_ADDR, adev->gfx.rlc_fw_version);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_rlc_resume(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
|
2017-09-15 16:58:08 +08:00
|
|
|
if (amdgpu_sriov_vf(adev)) {
|
|
|
|
gfx_v9_0_init_csb(adev);
|
2016-12-12 17:18:37 +08:00
|
|
|
return 0;
|
2017-09-15 16:58:08 +08:00
|
|
|
}
|
2016-12-12 17:18:37 +08:00
|
|
|
|
2018-09-28 19:21:23 +08:00
|
|
|
adev->gfx.rlc.funcs->stop(adev);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* disable CG */
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL, 0);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2018-09-28 19:21:23 +08:00
|
|
|
adev->gfx.rlc.funcs->reset(adev);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-02-10 14:37:03 +08:00
|
|
|
gfx_v9_0_init_pg(adev);
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) {
|
|
|
|
/* legacy rlc firmware loading */
|
|
|
|
r = gfx_v9_0_rlc_load_microcode(adev);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2018-11-09 05:34:48 +08:00
|
|
|
switch (adev->asic_type) {
|
|
|
|
case CHIP_RAVEN:
|
|
|
|
if (amdgpu_lbpw == 0)
|
|
|
|
gfx_v9_0_enable_lbpw(adev, false);
|
|
|
|
else
|
|
|
|
gfx_v9_0_enable_lbpw(adev, true);
|
|
|
|
break;
|
|
|
|
case CHIP_VEGA20:
|
|
|
|
if (amdgpu_lbpw > 0)
|
2017-05-26 14:40:36 +08:00
|
|
|
gfx_v9_0_enable_lbpw(adev, true);
|
|
|
|
else
|
|
|
|
gfx_v9_0_enable_lbpw(adev, false);
|
2018-11-09 05:34:48 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2017-05-26 14:40:36 +08:00
|
|
|
}
|
|
|
|
|
2018-09-28 19:21:23 +08:00
|
|
|
adev->gfx.rlc.funcs->start(adev);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_cp_gfx_enable(struct amdgpu_device *adev, bool enable)
|
|
|
|
{
|
|
|
|
int i;
|
2017-04-07 19:53:53 +08:00
|
|
|
u32 tmp = RREG32_SOC15(GC, 0, mmCP_ME_CNTL);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-04-05 21:03:08 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, ME_HALT, enable ? 0 : 1);
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, PFP_HALT, enable ? 0 : 1);
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, CE_HALT, enable ? 0 : 1);
|
|
|
|
if (!enable) {
|
2017-03-04 06:59:39 +08:00
|
|
|
for (i = 0; i < adev->gfx.num_gfx_rings; i++)
|
2018-10-20 04:22:48 +08:00
|
|
|
adev->gfx.gfx_ring[i].sched.ready = false;
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_ME_CNTL, tmp);
|
2017-03-04 06:59:39 +08:00
|
|
|
udelay(50);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_cp_gfx_load_microcode(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
const struct gfx_firmware_header_v1_0 *pfp_hdr;
|
|
|
|
const struct gfx_firmware_header_v1_0 *ce_hdr;
|
|
|
|
const struct gfx_firmware_header_v1_0 *me_hdr;
|
|
|
|
const __le32 *fw_data;
|
|
|
|
unsigned i, fw_size;
|
|
|
|
|
|
|
|
if (!adev->gfx.me_fw || !adev->gfx.pfp_fw || !adev->gfx.ce_fw)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
pfp_hdr = (const struct gfx_firmware_header_v1_0 *)
|
|
|
|
adev->gfx.pfp_fw->data;
|
|
|
|
ce_hdr = (const struct gfx_firmware_header_v1_0 *)
|
|
|
|
adev->gfx.ce_fw->data;
|
|
|
|
me_hdr = (const struct gfx_firmware_header_v1_0 *)
|
|
|
|
adev->gfx.me_fw->data;
|
|
|
|
|
|
|
|
amdgpu_ucode_print_gfx_hdr(&pfp_hdr->header);
|
|
|
|
amdgpu_ucode_print_gfx_hdr(&ce_hdr->header);
|
|
|
|
amdgpu_ucode_print_gfx_hdr(&me_hdr->header);
|
|
|
|
|
|
|
|
gfx_v9_0_cp_gfx_enable(adev, false);
|
|
|
|
|
|
|
|
/* PFP */
|
|
|
|
fw_data = (const __le32 *)
|
|
|
|
(adev->gfx.pfp_fw->data +
|
|
|
|
le32_to_cpu(pfp_hdr->header.ucode_array_offset_bytes));
|
|
|
|
fw_size = le32_to_cpu(pfp_hdr->header.ucode_size_bytes) / 4;
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_PFP_UCODE_ADDR, 0);
|
2017-03-04 06:59:39 +08:00
|
|
|
for (i = 0; i < fw_size; i++)
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_PFP_UCODE_DATA, le32_to_cpup(fw_data++));
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_PFP_UCODE_ADDR, adev->gfx.pfp_fw_version);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* CE */
|
|
|
|
fw_data = (const __le32 *)
|
|
|
|
(adev->gfx.ce_fw->data +
|
|
|
|
le32_to_cpu(ce_hdr->header.ucode_array_offset_bytes));
|
|
|
|
fw_size = le32_to_cpu(ce_hdr->header.ucode_size_bytes) / 4;
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_CE_UCODE_ADDR, 0);
|
2017-03-04 06:59:39 +08:00
|
|
|
for (i = 0; i < fw_size; i++)
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_CE_UCODE_DATA, le32_to_cpup(fw_data++));
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_CE_UCODE_ADDR, adev->gfx.ce_fw_version);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* ME */
|
|
|
|
fw_data = (const __le32 *)
|
|
|
|
(adev->gfx.me_fw->data +
|
|
|
|
le32_to_cpu(me_hdr->header.ucode_array_offset_bytes));
|
|
|
|
fw_size = le32_to_cpu(me_hdr->header.ucode_size_bytes) / 4;
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_ME_RAM_WADDR, 0);
|
2017-03-04 06:59:39 +08:00
|
|
|
for (i = 0; i < fw_size; i++)
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_ME_RAM_DATA, le32_to_cpup(fw_data++));
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_ME_RAM_WADDR, adev->gfx.me_fw_version);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_cp_gfx_start(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
struct amdgpu_ring *ring = &adev->gfx.gfx_ring[0];
|
|
|
|
const struct cs_section_def *sect = NULL;
|
|
|
|
const struct cs_extent_def *ext = NULL;
|
2017-08-15 17:16:08 +08:00
|
|
|
int r, i, tmp;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* init the CP */
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_MAX_CONTEXT, adev->gfx.config.max_hw_contexts - 1);
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_DEVICE_ID, 1);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
gfx_v9_0_cp_gfx_enable(adev, true);
|
|
|
|
|
2017-08-15 17:16:08 +08:00
|
|
|
r = amdgpu_ring_alloc(ring, gfx_v9_0_get_csb_size(adev) + 4 + 3);
|
2017-03-04 06:59:39 +08:00
|
|
|
if (r) {
|
|
|
|
DRM_ERROR("amdgpu: cp failed to lock ring (%d).\n", r);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0));
|
|
|
|
amdgpu_ring_write(ring, PACKET3_PREAMBLE_BEGIN_CLEAR_STATE);
|
|
|
|
|
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_CONTEXT_CONTROL, 1));
|
|
|
|
amdgpu_ring_write(ring, 0x80000000);
|
|
|
|
amdgpu_ring_write(ring, 0x80000000);
|
|
|
|
|
|
|
|
for (sect = gfx9_cs_data; sect->section != NULL; ++sect) {
|
|
|
|
for (ext = sect->section; ext->extent != NULL; ++ext) {
|
|
|
|
if (sect->id == SECT_CONTEXT) {
|
|
|
|
amdgpu_ring_write(ring,
|
|
|
|
PACKET3(PACKET3_SET_CONTEXT_REG,
|
|
|
|
ext->reg_count));
|
|
|
|
amdgpu_ring_write(ring,
|
|
|
|
ext->reg_index - PACKET3_SET_CONTEXT_REG_START);
|
|
|
|
for (i = 0; i < ext->reg_count; i++)
|
|
|
|
amdgpu_ring_write(ring, ext->extent[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0));
|
|
|
|
amdgpu_ring_write(ring, PACKET3_PREAMBLE_END_CLEAR_STATE);
|
|
|
|
|
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_CLEAR_STATE, 0));
|
|
|
|
amdgpu_ring_write(ring, 0);
|
|
|
|
|
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_SET_BASE, 2));
|
|
|
|
amdgpu_ring_write(ring, PACKET3_BASE_INDEX(CE_PARTITION_BASE));
|
|
|
|
amdgpu_ring_write(ring, 0x8000);
|
|
|
|
amdgpu_ring_write(ring, 0x8000);
|
|
|
|
|
2017-08-15 17:16:08 +08:00
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_SET_UCONFIG_REG,1));
|
|
|
|
tmp = (PACKET3_SET_UCONFIG_REG_INDEX_TYPE |
|
|
|
|
(SOC15_REG_OFFSET(GC, 0, mmVGT_INDEX_TYPE) - PACKET3_SET_UCONFIG_REG_START));
|
|
|
|
amdgpu_ring_write(ring, tmp);
|
|
|
|
amdgpu_ring_write(ring, 0);
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
amdgpu_ring_commit(ring);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_cp_gfx_resume(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
struct amdgpu_ring *ring;
|
|
|
|
u32 tmp;
|
|
|
|
u32 rb_bufsz;
|
2016-11-02 15:33:46 +08:00
|
|
|
u64 rb_addr, rptr_addr, wptr_gpu_addr;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* Set the write pointer delay */
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_RB_WPTR_DELAY, 0);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* set the RB to use vmid 0 */
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_RB_VMID, 0);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* Set ring buffer size */
|
|
|
|
ring = &adev->gfx.gfx_ring[0];
|
|
|
|
rb_bufsz = order_base_2(ring->ring_size / 8);
|
|
|
|
tmp = REG_SET_FIELD(0, CP_RB0_CNTL, RB_BUFSZ, rb_bufsz);
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_RB0_CNTL, RB_BLKSZ, rb_bufsz - 2);
|
|
|
|
#ifdef __BIG_ENDIAN
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_RB0_CNTL, BUF_SWAP, 1);
|
|
|
|
#endif
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_RB0_CNTL, tmp);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* Initialize the ring buffer's write pointers */
|
|
|
|
ring->wptr = 0;
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_RB0_WPTR, lower_32_bits(ring->wptr));
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_RB0_WPTR_HI, upper_32_bits(ring->wptr));
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* set the wb address wether it's enabled or not */
|
|
|
|
rptr_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_RB0_RPTR_ADDR, lower_32_bits(rptr_addr));
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_RB0_RPTR_ADDR_HI, upper_32_bits(rptr_addr) & CP_RB_RPTR_ADDR_HI__RB_RPTR_ADDR_HI_MASK);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2016-11-02 15:33:46 +08:00
|
|
|
wptr_gpu_addr = adev->wb.gpu_addr + (ring->wptr_offs * 4);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_RB_WPTR_POLL_ADDR_LO, lower_32_bits(wptr_gpu_addr));
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_RB_WPTR_POLL_ADDR_HI, upper_32_bits(wptr_gpu_addr));
|
2016-11-02 15:33:46 +08:00
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
mdelay(1);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_RB0_CNTL, tmp);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
rb_addr = ring->gpu_addr >> 8;
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_RB0_BASE, rb_addr);
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_RB0_BASE_HI, upper_32_bits(rb_addr));
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-04-07 19:53:53 +08:00
|
|
|
tmp = RREG32_SOC15(GC, 0, mmCP_RB_DOORBELL_CONTROL);
|
2017-03-04 06:59:39 +08:00
|
|
|
if (ring->use_doorbell) {
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_RB_DOORBELL_CONTROL,
|
|
|
|
DOORBELL_OFFSET, ring->doorbell_index);
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_RB_DOORBELL_CONTROL,
|
|
|
|
DOORBELL_EN, 1);
|
|
|
|
} else {
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_RB_DOORBELL_CONTROL, DOORBELL_EN, 0);
|
|
|
|
}
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_RB_DOORBELL_CONTROL, tmp);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
tmp = REG_SET_FIELD(0, CP_RB_DOORBELL_RANGE_LOWER,
|
|
|
|
DOORBELL_RANGE_LOWER, ring->doorbell_index);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_RB_DOORBELL_RANGE_LOWER, tmp);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_RB_DOORBELL_RANGE_UPPER,
|
2017-03-04 06:59:39 +08:00
|
|
|
CP_RB_DOORBELL_RANGE_UPPER__DOORBELL_RANGE_UPPER_MASK);
|
|
|
|
|
|
|
|
|
|
|
|
/* start the ring */
|
|
|
|
gfx_v9_0_cp_gfx_start(adev);
|
2018-10-20 04:22:48 +08:00
|
|
|
ring->sched.ready = true;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_cp_compute_enable(struct amdgpu_device *adev, bool enable)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (enable) {
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_MEC_CNTL, 0);
|
2017-03-04 06:59:39 +08:00
|
|
|
} else {
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_MEC_CNTL,
|
2017-03-04 06:59:39 +08:00
|
|
|
(CP_MEC_CNTL__MEC_ME1_HALT_MASK | CP_MEC_CNTL__MEC_ME2_HALT_MASK));
|
|
|
|
for (i = 0; i < adev->gfx.num_compute_rings; i++)
|
2018-10-20 04:22:48 +08:00
|
|
|
adev->gfx.compute_ring[i].sched.ready = false;
|
|
|
|
adev->gfx.kiq.ring.sched.ready = false;
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
udelay(50);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_cp_compute_load_microcode(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
const struct gfx_firmware_header_v1_0 *mec_hdr;
|
|
|
|
const __le32 *fw_data;
|
|
|
|
unsigned i;
|
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
if (!adev->gfx.mec_fw)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
gfx_v9_0_cp_compute_enable(adev, false);
|
|
|
|
|
|
|
|
mec_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec_fw->data;
|
|
|
|
amdgpu_ucode_print_gfx_hdr(&mec_hdr->header);
|
|
|
|
|
|
|
|
fw_data = (const __le32 *)
|
|
|
|
(adev->gfx.mec_fw->data +
|
|
|
|
le32_to_cpu(mec_hdr->header.ucode_array_offset_bytes));
|
|
|
|
tmp = 0;
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_CPC_IC_BASE_CNTL, VMID, 0);
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_CPC_IC_BASE_CNTL, CACHE_POLICY, 0);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_CPC_IC_BASE_CNTL, tmp);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_CPC_IC_BASE_LO,
|
2017-03-04 06:59:39 +08:00
|
|
|
adev->gfx.mec.mec_fw_gpu_addr & 0xFFFFF000);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_CPC_IC_BASE_HI,
|
2017-03-04 06:59:39 +08:00
|
|
|
upper_32_bits(adev->gfx.mec.mec_fw_gpu_addr));
|
2017-05-01 17:00:13 +08:00
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
/* MEC1 */
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_MEC_ME1_UCODE_ADDR,
|
2017-03-04 06:59:39 +08:00
|
|
|
mec_hdr->jt_offset);
|
|
|
|
for (i = 0; i < mec_hdr->jt_size; i++)
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_MEC_ME1_UCODE_DATA,
|
2017-03-04 06:59:39 +08:00
|
|
|
le32_to_cpup(fw_data + mec_hdr->jt_offset + i));
|
|
|
|
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_MEC_ME1_UCODE_ADDR,
|
2017-03-04 06:59:39 +08:00
|
|
|
adev->gfx.mec_fw_version);
|
|
|
|
/* Todo : Loading MEC2 firmware is only necessary if MEC2 should run different microcode than MEC1. */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-02-28 16:48:47 +08:00
|
|
|
/* KIQ functions */
|
|
|
|
static void gfx_v9_0_kiq_setting(struct amdgpu_ring *ring)
|
2017-03-04 06:59:39 +08:00
|
|
|
{
|
2017-02-28 16:48:47 +08:00
|
|
|
uint32_t tmp;
|
|
|
|
struct amdgpu_device *adev = ring->adev;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-02-28 16:48:47 +08:00
|
|
|
/* tell RLC which is KIQ queue */
|
2017-04-07 19:53:53 +08:00
|
|
|
tmp = RREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS);
|
2017-02-28 16:48:47 +08:00
|
|
|
tmp &= 0xffffff00;
|
|
|
|
tmp |= (ring->me << 5) | (ring->pipe << 3) | (ring->queue);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS, tmp);
|
2017-02-28 16:48:47 +08:00
|
|
|
tmp |= 0x80;
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS, tmp);
|
2017-02-28 16:48:47 +08:00
|
|
|
}
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-04-18 05:10:11 +08:00
|
|
|
static int gfx_v9_0_kiq_kcq_enable(struct amdgpu_device *adev)
|
2017-02-28 16:48:47 +08:00
|
|
|
{
|
2017-04-18 05:05:02 +08:00
|
|
|
struct amdgpu_ring *kiq_ring = &adev->gfx.kiq.ring;
|
2017-04-05 05:18:28 +08:00
|
|
|
uint64_t queue_mask = 0;
|
2017-04-18 04:21:52 +08:00
|
|
|
int r, i;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-04-05 05:18:28 +08:00
|
|
|
for (i = 0; i < AMDGPU_MAX_COMPUTE_QUEUES; ++i) {
|
|
|
|
if (!test_bit(i, adev->gfx.mec.queue_bitmap))
|
|
|
|
continue;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-04-05 05:18:28 +08:00
|
|
|
/* This situation may be hit in the future if a new HW
|
|
|
|
* generation exposes more than 64 queues. If so, the
|
|
|
|
* definition of queue_mask needs updating */
|
2017-07-12 03:53:29 +08:00
|
|
|
if (WARN_ON(i >= (sizeof(queue_mask)*8))) {
|
2017-04-05 05:18:28 +08:00
|
|
|
DRM_ERROR("Invalid KCQ enabled: %d\n", i);
|
|
|
|
break;
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
2017-04-05 05:18:28 +08:00
|
|
|
queue_mask |= (1ull << i);
|
|
|
|
}
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2018-08-17 16:42:35 +08:00
|
|
|
r = amdgpu_ring_alloc(kiq_ring, (7 * adev->gfx.num_compute_rings) + 8);
|
2017-04-18 04:21:52 +08:00
|
|
|
if (r) {
|
|
|
|
DRM_ERROR("Failed to lock KIQ (%d).\n", r);
|
2017-03-04 06:59:39 +08:00
|
|
|
return r;
|
2017-04-18 04:21:52 +08:00
|
|
|
}
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-04-18 05:10:11 +08:00
|
|
|
/* set resources */
|
|
|
|
amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_SET_RESOURCES, 6));
|
|
|
|
amdgpu_ring_write(kiq_ring, PACKET3_SET_RESOURCES_VMID_MASK(0) |
|
|
|
|
PACKET3_SET_RESOURCES_QUEUE_TYPE(0)); /* vmid_mask:0 queue_type:0 (KIQ) */
|
2017-04-05 05:18:28 +08:00
|
|
|
amdgpu_ring_write(kiq_ring, lower_32_bits(queue_mask)); /* queue mask lo */
|
|
|
|
amdgpu_ring_write(kiq_ring, upper_32_bits(queue_mask)); /* queue mask hi */
|
2017-04-18 05:10:11 +08:00
|
|
|
amdgpu_ring_write(kiq_ring, 0); /* gws mask lo */
|
|
|
|
amdgpu_ring_write(kiq_ring, 0); /* gws mask hi */
|
|
|
|
amdgpu_ring_write(kiq_ring, 0); /* oac mask */
|
|
|
|
amdgpu_ring_write(kiq_ring, 0); /* gds heap base:0, gds heap size:0 */
|
2017-04-18 05:05:02 +08:00
|
|
|
for (i = 0; i < adev->gfx.num_compute_rings; i++) {
|
|
|
|
struct amdgpu_ring *ring = &adev->gfx.compute_ring[i];
|
|
|
|
uint64_t mqd_addr = amdgpu_bo_gpu_offset(ring->mqd_obj);
|
|
|
|
uint64_t wptr_addr = adev->wb.gpu_addr + (ring->wptr_offs * 4);
|
|
|
|
|
|
|
|
amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_MAP_QUEUES, 5));
|
|
|
|
/* Q_sel:0, vmid:0, vidmem: 1, engine:0, num_Q:1*/
|
|
|
|
amdgpu_ring_write(kiq_ring, /* Q_sel: 0, vmid: 0, engine: 0, num_Q: 1 */
|
|
|
|
PACKET3_MAP_QUEUES_QUEUE_SEL(0) | /* Queue_Sel */
|
|
|
|
PACKET3_MAP_QUEUES_VMID(0) | /* VMID */
|
|
|
|
PACKET3_MAP_QUEUES_QUEUE(ring->queue) |
|
|
|
|
PACKET3_MAP_QUEUES_PIPE(ring->pipe) |
|
|
|
|
PACKET3_MAP_QUEUES_ME((ring->me == 1 ? 0 : 1)) |
|
|
|
|
PACKET3_MAP_QUEUES_QUEUE_TYPE(0) | /*queue_type: normal compute queue */
|
2017-11-23 18:38:59 +08:00
|
|
|
PACKET3_MAP_QUEUES_ALLOC_FORMAT(0) | /* alloc format: all_on_one_pipe */
|
2017-04-18 05:05:02 +08:00
|
|
|
PACKET3_MAP_QUEUES_ENGINE_SEL(0) | /* engine_sel: compute */
|
|
|
|
PACKET3_MAP_QUEUES_NUM_QUEUES(1)); /* num_queues: must be 1 */
|
|
|
|
amdgpu_ring_write(kiq_ring, PACKET3_MAP_QUEUES_DOORBELL_OFFSET(ring->doorbell_index));
|
|
|
|
amdgpu_ring_write(kiq_ring, lower_32_bits(mqd_addr));
|
|
|
|
amdgpu_ring_write(kiq_ring, upper_32_bits(mqd_addr));
|
|
|
|
amdgpu_ring_write(kiq_ring, lower_32_bits(wptr_addr));
|
|
|
|
amdgpu_ring_write(kiq_ring, upper_32_bits(wptr_addr));
|
|
|
|
}
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2018-10-20 04:22:48 +08:00
|
|
|
r = amdgpu_ring_test_helper(kiq_ring);
|
|
|
|
if (r)
|
2018-08-17 16:42:35 +08:00
|
|
|
DRM_ERROR("KCQ enable failed\n");
|
2017-02-28 16:48:47 +08:00
|
|
|
|
2017-04-18 04:21:52 +08:00
|
|
|
return r;
|
2017-02-28 16:48:47 +08:00
|
|
|
}
|
|
|
|
|
2017-03-24 01:05:55 +08:00
|
|
|
static int gfx_v9_0_mqd_init(struct amdgpu_ring *ring)
|
2017-02-28 16:48:47 +08:00
|
|
|
{
|
2017-03-24 00:41:59 +08:00
|
|
|
struct amdgpu_device *adev = ring->adev;
|
2017-03-24 01:05:55 +08:00
|
|
|
struct v9_mqd *mqd = ring->mqd_ptr;
|
2017-02-28 16:48:47 +08:00
|
|
|
uint64_t hqd_gpu_addr, wb_gpu_addr, eop_base_addr;
|
|
|
|
uint32_t tmp;
|
|
|
|
|
|
|
|
mqd->header = 0xC0310800;
|
|
|
|
mqd->compute_pipelinestat_enable = 0x00000001;
|
|
|
|
mqd->compute_static_thread_mgmt_se0 = 0xffffffff;
|
|
|
|
mqd->compute_static_thread_mgmt_se1 = 0xffffffff;
|
|
|
|
mqd->compute_static_thread_mgmt_se2 = 0xffffffff;
|
|
|
|
mqd->compute_static_thread_mgmt_se3 = 0xffffffff;
|
|
|
|
mqd->compute_misc_reserved = 0x00000003;
|
|
|
|
|
2017-08-19 11:52:37 +08:00
|
|
|
mqd->dynamic_cu_mask_addr_lo =
|
|
|
|
lower_32_bits(ring->mqd_gpu_addr
|
|
|
|
+ offsetof(struct v9_mqd_allocation, dynamic_cu_mask));
|
|
|
|
mqd->dynamic_cu_mask_addr_hi =
|
|
|
|
upper_32_bits(ring->mqd_gpu_addr
|
|
|
|
+ offsetof(struct v9_mqd_allocation, dynamic_cu_mask));
|
|
|
|
|
2017-03-24 00:52:23 +08:00
|
|
|
eop_base_addr = ring->eop_gpu_addr >> 8;
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_eop_base_addr_lo = eop_base_addr;
|
|
|
|
mqd->cp_hqd_eop_base_addr_hi = upper_32_bits(eop_base_addr);
|
|
|
|
|
|
|
|
/* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */
|
2017-04-07 19:53:53 +08:00
|
|
|
tmp = RREG32_SOC15(GC, 0, mmCP_HQD_EOP_CONTROL);
|
2017-02-28 16:48:47 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, CP_HQD_EOP_CONTROL, EOP_SIZE,
|
2017-04-13 04:53:50 +08:00
|
|
|
(order_base_2(GFX9_MEC_HPD_SIZE / 4) - 1));
|
2017-02-28 16:48:47 +08:00
|
|
|
|
|
|
|
mqd->cp_hqd_eop_control = tmp;
|
|
|
|
|
|
|
|
/* enable doorbell? */
|
2017-04-07 19:53:53 +08:00
|
|
|
tmp = RREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL);
|
2017-02-28 16:48:47 +08:00
|
|
|
|
|
|
|
if (ring->use_doorbell) {
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL,
|
|
|
|
DOORBELL_OFFSET, ring->doorbell_index);
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL,
|
|
|
|
DOORBELL_EN, 1);
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL,
|
|
|
|
DOORBELL_SOURCE, 0);
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL,
|
|
|
|
DOORBELL_HIT, 0);
|
2017-08-31 21:43:47 +08:00
|
|
|
} else {
|
2017-02-28 16:48:47 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL,
|
|
|
|
DOORBELL_EN, 0);
|
2017-08-31 21:43:47 +08:00
|
|
|
}
|
2017-02-28 16:48:47 +08:00
|
|
|
|
|
|
|
mqd->cp_hqd_pq_doorbell_control = tmp;
|
|
|
|
|
|
|
|
/* disable the queue if it's active */
|
|
|
|
ring->wptr = 0;
|
|
|
|
mqd->cp_hqd_dequeue_request = 0;
|
|
|
|
mqd->cp_hqd_pq_rptr = 0;
|
|
|
|
mqd->cp_hqd_pq_wptr_lo = 0;
|
|
|
|
mqd->cp_hqd_pq_wptr_hi = 0;
|
|
|
|
|
|
|
|
/* set the pointer to the MQD */
|
2017-03-24 00:41:59 +08:00
|
|
|
mqd->cp_mqd_base_addr_lo = ring->mqd_gpu_addr & 0xfffffffc;
|
|
|
|
mqd->cp_mqd_base_addr_hi = upper_32_bits(ring->mqd_gpu_addr);
|
2017-02-28 16:48:47 +08:00
|
|
|
|
|
|
|
/* set MQD vmid to 0 */
|
2017-04-07 19:53:53 +08:00
|
|
|
tmp = RREG32_SOC15(GC, 0, mmCP_MQD_CONTROL);
|
2017-02-28 16:48:47 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, CP_MQD_CONTROL, VMID, 0);
|
|
|
|
mqd->cp_mqd_control = tmp;
|
|
|
|
|
|
|
|
/* set the pointer to the HQD, this is similar CP_RB0_BASE/_HI */
|
|
|
|
hqd_gpu_addr = ring->gpu_addr >> 8;
|
|
|
|
mqd->cp_hqd_pq_base_lo = hqd_gpu_addr;
|
|
|
|
mqd->cp_hqd_pq_base_hi = upper_32_bits(hqd_gpu_addr);
|
|
|
|
|
|
|
|
/* set up the HQD, this is similar to CP_RB0_CNTL */
|
2017-04-07 19:53:53 +08:00
|
|
|
tmp = RREG32_SOC15(GC, 0, mmCP_HQD_PQ_CONTROL);
|
2017-02-28 16:48:47 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, QUEUE_SIZE,
|
|
|
|
(order_base_2(ring->ring_size / 4) - 1));
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, RPTR_BLOCK_SIZE,
|
|
|
|
((order_base_2(AMDGPU_GPU_PAGE_SIZE / 4) - 1) << 8));
|
|
|
|
#ifdef __BIG_ENDIAN
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, ENDIAN_SWAP, 1);
|
|
|
|
#endif
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, UNORD_DISPATCH, 0);
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, ROQ_PQ_IB_FLIP, 0);
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, PRIV_STATE, 1);
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, KMD_QUEUE, 1);
|
|
|
|
mqd->cp_hqd_pq_control = tmp;
|
|
|
|
|
|
|
|
/* set the wb address whether it's enabled or not */
|
|
|
|
wb_gpu_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4);
|
|
|
|
mqd->cp_hqd_pq_rptr_report_addr_lo = wb_gpu_addr & 0xfffffffc;
|
|
|
|
mqd->cp_hqd_pq_rptr_report_addr_hi =
|
|
|
|
upper_32_bits(wb_gpu_addr) & 0xffff;
|
|
|
|
|
|
|
|
/* only used if CP_PQ_WPTR_POLL_CNTL.CP_PQ_WPTR_POLL_CNTL__EN_MASK=1 */
|
|
|
|
wb_gpu_addr = adev->wb.gpu_addr + (ring->wptr_offs * 4);
|
|
|
|
mqd->cp_hqd_pq_wptr_poll_addr_lo = wb_gpu_addr & 0xfffffffc;
|
|
|
|
mqd->cp_hqd_pq_wptr_poll_addr_hi = upper_32_bits(wb_gpu_addr) & 0xffff;
|
|
|
|
|
|
|
|
tmp = 0;
|
|
|
|
/* enable the doorbell if requested */
|
|
|
|
if (ring->use_doorbell) {
|
2017-04-07 19:53:53 +08:00
|
|
|
tmp = RREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL);
|
2017-02-28 16:48:47 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL,
|
|
|
|
DOORBELL_OFFSET, ring->doorbell_index);
|
|
|
|
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL,
|
|
|
|
DOORBELL_EN, 1);
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL,
|
|
|
|
DOORBELL_SOURCE, 0);
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL,
|
|
|
|
DOORBELL_HIT, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
mqd->cp_hqd_pq_doorbell_control = tmp;
|
|
|
|
|
|
|
|
/* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */
|
|
|
|
ring->wptr = 0;
|
2017-04-18 05:30:27 +08:00
|
|
|
mqd->cp_hqd_pq_rptr = RREG32_SOC15(GC, 0, mmCP_HQD_PQ_RPTR);
|
2017-02-28 16:48:47 +08:00
|
|
|
|
|
|
|
/* set the vmid for the queue */
|
|
|
|
mqd->cp_hqd_vmid = 0;
|
|
|
|
|
2017-04-18 05:30:27 +08:00
|
|
|
tmp = RREG32_SOC15(GC, 0, mmCP_HQD_PERSISTENT_STATE);
|
2017-02-28 16:48:47 +08:00
|
|
|
tmp = REG_SET_FIELD(tmp, CP_HQD_PERSISTENT_STATE, PRELOAD_SIZE, 0x53);
|
|
|
|
mqd->cp_hqd_persistent_state = tmp;
|
|
|
|
|
2017-04-18 05:34:42 +08:00
|
|
|
/* set MIN_IB_AVAIL_SIZE */
|
|
|
|
tmp = RREG32_SOC15(GC, 0, mmCP_HQD_IB_CONTROL);
|
|
|
|
tmp = REG_SET_FIELD(tmp, CP_HQD_IB_CONTROL, MIN_IB_AVAIL_SIZE, 3);
|
|
|
|
mqd->cp_hqd_ib_control = tmp;
|
|
|
|
|
2017-02-28 16:48:47 +08:00
|
|
|
/* activate the queue */
|
|
|
|
mqd->cp_hqd_active = 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-24 01:05:55 +08:00
|
|
|
static int gfx_v9_0_kiq_init_register(struct amdgpu_ring *ring)
|
2017-02-28 16:48:47 +08:00
|
|
|
{
|
2017-03-24 00:41:59 +08:00
|
|
|
struct amdgpu_device *adev = ring->adev;
|
2017-03-24 01:05:55 +08:00
|
|
|
struct v9_mqd *mqd = ring->mqd_ptr;
|
2017-02-28 16:48:47 +08:00
|
|
|
int j;
|
|
|
|
|
|
|
|
/* disable wptr polling */
|
2017-04-05 20:59:16 +08:00
|
|
|
WREG32_FIELD15(GC, 0, CP_PQ_WPTR_POLL_CNTL, EN, 0);
|
2017-02-28 16:48:47 +08:00
|
|
|
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_EOP_BASE_ADDR,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_eop_base_addr_lo);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_EOP_BASE_ADDR_HI,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_eop_base_addr_hi);
|
|
|
|
|
|
|
|
/* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_EOP_CONTROL,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_eop_control);
|
|
|
|
|
|
|
|
/* enable doorbell? */
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_pq_doorbell_control);
|
|
|
|
|
|
|
|
/* disable the queue if it's active */
|
2017-04-07 19:53:53 +08:00
|
|
|
if (RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE) & 1) {
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_DEQUEUE_REQUEST, 1);
|
2017-02-28 16:48:47 +08:00
|
|
|
for (j = 0; j < adev->usec_timeout; j++) {
|
2017-04-07 19:53:53 +08:00
|
|
|
if (!(RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE) & 1))
|
2017-02-28 16:48:47 +08:00
|
|
|
break;
|
|
|
|
udelay(1);
|
|
|
|
}
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_DEQUEUE_REQUEST,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_dequeue_request);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PQ_RPTR,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_pq_rptr);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_LO,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_pq_wptr_lo);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_HI,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_pq_wptr_hi);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the pointer to the MQD */
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_MQD_BASE_ADDR,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_mqd_base_addr_lo);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_MQD_BASE_ADDR_HI,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_mqd_base_addr_hi);
|
|
|
|
|
|
|
|
/* set MQD vmid to 0 */
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_MQD_CONTROL,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_mqd_control);
|
|
|
|
|
|
|
|
/* set the pointer to the HQD, this is similar CP_RB0_BASE/_HI */
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PQ_BASE,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_pq_base_lo);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PQ_BASE_HI,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_pq_base_hi);
|
|
|
|
|
|
|
|
/* set up the HQD, this is similar to CP_RB0_CNTL */
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PQ_CONTROL,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_pq_control);
|
|
|
|
|
|
|
|
/* set the wb address whether it's enabled or not */
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PQ_RPTR_REPORT_ADDR,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_pq_rptr_report_addr_lo);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PQ_RPTR_REPORT_ADDR_HI,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_pq_rptr_report_addr_hi);
|
|
|
|
|
|
|
|
/* only used if CP_PQ_WPTR_POLL_CNTL.CP_PQ_WPTR_POLL_CNTL__EN_MASK=1 */
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_POLL_ADDR,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_pq_wptr_poll_addr_lo);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_POLL_ADDR_HI,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_pq_wptr_poll_addr_hi);
|
|
|
|
|
|
|
|
/* enable the doorbell if requested */
|
|
|
|
if (ring->use_doorbell) {
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_LOWER,
|
2018-11-20 05:20:07 +08:00
|
|
|
(adev->doorbell_index.kiq * 2) << 2);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_UPPER,
|
2018-11-20 05:20:07 +08:00
|
|
|
(adev->doorbell_index.userqueue_end * 2) << 2);
|
2017-02-28 16:48:47 +08:00
|
|
|
}
|
|
|
|
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_pq_doorbell_control);
|
|
|
|
|
|
|
|
/* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_LO,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_pq_wptr_lo);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_HI,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_pq_wptr_hi);
|
|
|
|
|
|
|
|
/* set the vmid for the queue */
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_VMID, mqd->cp_hqd_vmid);
|
2017-02-28 16:48:47 +08:00
|
|
|
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PERSISTENT_STATE,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_persistent_state);
|
|
|
|
|
|
|
|
/* activate the queue */
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE,
|
2017-02-28 16:48:47 +08:00
|
|
|
mqd->cp_hqd_active);
|
|
|
|
|
2017-04-05 20:59:16 +08:00
|
|
|
if (ring->use_doorbell)
|
|
|
|
WREG32_FIELD15(GC, 0, CP_PQ_STATUS, DOORBELL_ENABLE, 1);
|
2017-02-28 16:48:47 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-28 20:01:53 +08:00
|
|
|
static int gfx_v9_0_kiq_fini_register(struct amdgpu_ring *ring)
|
|
|
|
{
|
|
|
|
struct amdgpu_device *adev = ring->adev;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
/* disable the queue if it's active */
|
|
|
|
if (RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE) & 1) {
|
|
|
|
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_DEQUEUE_REQUEST, 1);
|
|
|
|
|
|
|
|
for (j = 0; j < adev->usec_timeout; j++) {
|
|
|
|
if (!(RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE) & 1))
|
|
|
|
break;
|
|
|
|
udelay(1);
|
|
|
|
}
|
|
|
|
|
2018-03-29 21:09:39 +08:00
|
|
|
if (j == AMDGPU_MAX_USEC_TIMEOUT) {
|
2018-03-28 20:01:53 +08:00
|
|
|
DRM_DEBUG("KIQ dequeue request failed.\n");
|
|
|
|
|
2018-03-29 21:09:39 +08:00
|
|
|
/* Manual disable if dequeue request times out */
|
2018-03-28 20:01:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_DEQUEUE_REQUEST,
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_IQ_TIMER, 0);
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_IB_CONTROL, 0);
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PERSISTENT_STATE, 0);
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL, 0x40000000);
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL, 0);
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PQ_RPTR, 0);
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_HI, 0);
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_LO, 0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-24 01:05:55 +08:00
|
|
|
static int gfx_v9_0_kiq_init_queue(struct amdgpu_ring *ring)
|
2017-02-28 16:48:47 +08:00
|
|
|
{
|
|
|
|
struct amdgpu_device *adev = ring->adev;
|
2017-03-24 01:05:55 +08:00
|
|
|
struct v9_mqd *mqd = ring->mqd_ptr;
|
2017-02-28 16:48:47 +08:00
|
|
|
int mqd_idx = AMDGPU_MAX_COMPUTE_RINGS;
|
|
|
|
|
2017-04-18 04:39:13 +08:00
|
|
|
gfx_v9_0_kiq_setting(ring);
|
2017-02-28 16:48:47 +08:00
|
|
|
|
2017-10-17 15:11:12 +08:00
|
|
|
if (adev->in_gpu_reset) { /* for GPU_RESET case */
|
2017-02-28 16:48:47 +08:00
|
|
|
/* reset MQD to a clean status */
|
2017-04-18 03:29:14 +08:00
|
|
|
if (adev->gfx.mec.mqd_backup[mqd_idx])
|
2017-08-19 11:52:37 +08:00
|
|
|
memcpy(mqd, adev->gfx.mec.mqd_backup[mqd_idx], sizeof(struct v9_mqd_allocation));
|
2017-02-28 16:48:47 +08:00
|
|
|
|
|
|
|
/* reset ring buffer */
|
|
|
|
ring->wptr = 0;
|
2017-04-18 04:32:12 +08:00
|
|
|
amdgpu_ring_clear_ring(ring);
|
2017-02-28 16:48:47 +08:00
|
|
|
|
2017-04-18 04:39:13 +08:00
|
|
|
mutex_lock(&adev->srbm_mutex);
|
|
|
|
soc15_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
|
|
|
|
gfx_v9_0_kiq_init_register(ring);
|
|
|
|
soc15_grbm_select(adev, 0, 0, 0, 0);
|
|
|
|
mutex_unlock(&adev->srbm_mutex);
|
2017-02-28 16:48:47 +08:00
|
|
|
} else {
|
2017-08-19 11:52:37 +08:00
|
|
|
memset((void *)mqd, 0, sizeof(struct v9_mqd_allocation));
|
|
|
|
((struct v9_mqd_allocation *)mqd)->dynamic_cu_mask = 0xFFFFFFFF;
|
|
|
|
((struct v9_mqd_allocation *)mqd)->dynamic_rb_mask = 0xFFFFFFFF;
|
2017-04-18 05:24:47 +08:00
|
|
|
mutex_lock(&adev->srbm_mutex);
|
|
|
|
soc15_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
|
|
|
|
gfx_v9_0_mqd_init(ring);
|
|
|
|
gfx_v9_0_kiq_init_register(ring);
|
|
|
|
soc15_grbm_select(adev, 0, 0, 0, 0);
|
|
|
|
mutex_unlock(&adev->srbm_mutex);
|
|
|
|
|
|
|
|
if (adev->gfx.mec.mqd_backup[mqd_idx])
|
2017-08-19 11:52:37 +08:00
|
|
|
memcpy(adev->gfx.mec.mqd_backup[mqd_idx], mqd, sizeof(struct v9_mqd_allocation));
|
2017-02-28 16:48:47 +08:00
|
|
|
}
|
|
|
|
|
2017-04-18 05:10:11 +08:00
|
|
|
return 0;
|
2017-04-18 04:39:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_kcq_init_queue(struct amdgpu_ring *ring)
|
|
|
|
{
|
|
|
|
struct amdgpu_device *adev = ring->adev;
|
|
|
|
struct v9_mqd *mqd = ring->mqd_ptr;
|
|
|
|
int mqd_idx = ring - &adev->gfx.compute_ring[0];
|
|
|
|
|
2018-09-29 15:27:02 +08:00
|
|
|
if (!adev->in_gpu_reset && !adev->in_suspend) {
|
2017-08-19 11:52:37 +08:00
|
|
|
memset((void *)mqd, 0, sizeof(struct v9_mqd_allocation));
|
|
|
|
((struct v9_mqd_allocation *)mqd)->dynamic_cu_mask = 0xFFFFFFFF;
|
|
|
|
((struct v9_mqd_allocation *)mqd)->dynamic_rb_mask = 0xFFFFFFFF;
|
2017-02-28 16:48:47 +08:00
|
|
|
mutex_lock(&adev->srbm_mutex);
|
|
|
|
soc15_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
|
2017-03-24 01:05:55 +08:00
|
|
|
gfx_v9_0_mqd_init(ring);
|
2017-02-28 16:48:47 +08:00
|
|
|
soc15_grbm_select(adev, 0, 0, 0, 0);
|
|
|
|
mutex_unlock(&adev->srbm_mutex);
|
|
|
|
|
2017-04-18 04:39:13 +08:00
|
|
|
if (adev->gfx.mec.mqd_backup[mqd_idx])
|
2017-08-19 11:52:37 +08:00
|
|
|
memcpy(adev->gfx.mec.mqd_backup[mqd_idx], mqd, sizeof(struct v9_mqd_allocation));
|
2017-10-17 15:11:12 +08:00
|
|
|
} else if (adev->in_gpu_reset) { /* for GPU_RESET case */
|
2017-02-28 16:48:47 +08:00
|
|
|
/* reset MQD to a clean status */
|
2017-04-18 04:39:13 +08:00
|
|
|
if (adev->gfx.mec.mqd_backup[mqd_idx])
|
2017-08-19 11:52:37 +08:00
|
|
|
memcpy(mqd, adev->gfx.mec.mqd_backup[mqd_idx], sizeof(struct v9_mqd_allocation));
|
2017-02-28 16:48:47 +08:00
|
|
|
|
|
|
|
/* reset ring buffer */
|
|
|
|
ring->wptr = 0;
|
2017-04-18 04:39:13 +08:00
|
|
|
amdgpu_ring_clear_ring(ring);
|
2017-04-18 05:24:47 +08:00
|
|
|
} else {
|
|
|
|
amdgpu_ring_clear_ring(ring);
|
2017-02-28 16:48:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_kiq_resume(struct amdgpu_device *adev)
|
|
|
|
{
|
2018-08-22 18:54:45 +08:00
|
|
|
struct amdgpu_ring *ring;
|
|
|
|
int r;
|
2017-02-28 16:48:47 +08:00
|
|
|
|
|
|
|
ring = &adev->gfx.kiq.ring;
|
2017-03-28 04:54:06 +08:00
|
|
|
|
|
|
|
r = amdgpu_bo_reserve(ring->mqd_obj, false);
|
|
|
|
if (unlikely(r != 0))
|
2018-08-22 18:54:45 +08:00
|
|
|
return r;
|
2017-03-28 04:54:06 +08:00
|
|
|
|
|
|
|
r = amdgpu_bo_kmap(ring->mqd_obj, (void **)&ring->mqd_ptr);
|
2018-08-22 18:54:45 +08:00
|
|
|
if (unlikely(r != 0))
|
|
|
|
return r;
|
|
|
|
|
|
|
|
gfx_v9_0_kiq_init_queue(ring);
|
|
|
|
amdgpu_bo_kunmap(ring->mqd_obj);
|
|
|
|
ring->mqd_ptr = NULL;
|
2017-03-28 04:54:06 +08:00
|
|
|
amdgpu_bo_unreserve(ring->mqd_obj);
|
2018-10-20 04:22:48 +08:00
|
|
|
ring->sched.ready = true;
|
2018-08-22 18:54:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_kcq_resume(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
struct amdgpu_ring *ring = NULL;
|
|
|
|
int r = 0, i;
|
|
|
|
|
|
|
|
gfx_v9_0_cp_compute_enable(adev, true);
|
2017-02-28 16:48:47 +08:00
|
|
|
|
|
|
|
for (i = 0; i < adev->gfx.num_compute_rings; i++) {
|
|
|
|
ring = &adev->gfx.compute_ring[i];
|
2017-03-28 04:54:06 +08:00
|
|
|
|
|
|
|
r = amdgpu_bo_reserve(ring->mqd_obj, false);
|
|
|
|
if (unlikely(r != 0))
|
|
|
|
goto done;
|
|
|
|
r = amdgpu_bo_kmap(ring->mqd_obj, (void **)&ring->mqd_ptr);
|
|
|
|
if (!r) {
|
2017-04-18 04:39:13 +08:00
|
|
|
r = gfx_v9_0_kcq_init_queue(ring);
|
2017-02-28 16:48:47 +08:00
|
|
|
amdgpu_bo_kunmap(ring->mqd_obj);
|
|
|
|
ring->mqd_ptr = NULL;
|
|
|
|
}
|
2017-03-28 04:54:06 +08:00
|
|
|
amdgpu_bo_unreserve(ring->mqd_obj);
|
|
|
|
if (r)
|
|
|
|
goto done;
|
2017-02-28 16:48:47 +08:00
|
|
|
}
|
|
|
|
|
2017-04-18 05:10:11 +08:00
|
|
|
r = gfx_v9_0_kiq_kcq_enable(adev);
|
2017-03-28 04:54:06 +08:00
|
|
|
done:
|
|
|
|
return r;
|
2017-02-28 16:48:47 +08:00
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
static int gfx_v9_0_cp_resume(struct amdgpu_device *adev)
|
|
|
|
{
|
2017-04-18 05:05:02 +08:00
|
|
|
int r, i;
|
2017-03-04 06:59:39 +08:00
|
|
|
struct amdgpu_ring *ring;
|
|
|
|
|
|
|
|
if (!(adev->flags & AMD_IS_APU))
|
|
|
|
gfx_v9_0_enable_gui_idle_interrupt(adev, false);
|
|
|
|
|
|
|
|
if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) {
|
|
|
|
/* legacy firmware loading */
|
|
|
|
r = gfx_v9_0_cp_gfx_load_microcode(adev);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = gfx_v9_0_cp_compute_load_microcode(adev);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2018-08-22 18:54:45 +08:00
|
|
|
r = gfx_v9_0_kiq_resume(adev);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
r = gfx_v9_0_cp_gfx_resume(adev);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
2018-08-22 18:54:45 +08:00
|
|
|
r = gfx_v9_0_kcq_resume(adev);
|
2017-03-04 06:59:39 +08:00
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
ring = &adev->gfx.gfx_ring[0];
|
2018-10-20 04:22:48 +08:00
|
|
|
r = amdgpu_ring_test_helper(ring);
|
|
|
|
if (r)
|
2017-03-04 06:59:39 +08:00
|
|
|
return r;
|
2017-04-18 05:51:00 +08:00
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
for (i = 0; i < adev->gfx.num_compute_rings; i++) {
|
|
|
|
ring = &adev->gfx.compute_ring[i];
|
2018-10-20 04:22:48 +08:00
|
|
|
amdgpu_ring_test_helper(ring);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gfx_v9_0_enable_gui_idle_interrupt(adev, true);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_cp_enable(struct amdgpu_device *adev, bool enable)
|
|
|
|
{
|
|
|
|
gfx_v9_0_cp_gfx_enable(adev, enable);
|
|
|
|
gfx_v9_0_cp_compute_enable(adev, enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_hw_init(void *handle)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
|
|
|
|
|
|
|
gfx_v9_0_init_golden_registers(adev);
|
|
|
|
|
2018-08-28 18:20:19 +08:00
|
|
|
gfx_v9_0_constants_init(adev);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2018-07-04 16:21:52 +08:00
|
|
|
r = gfx_v9_0_csb_vram_pin(adev);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
2018-09-28 19:21:23 +08:00
|
|
|
r = adev->gfx.rlc.funcs->resume(adev);
|
2017-03-04 06:59:39 +08:00
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = gfx_v9_0_cp_resume(adev);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = gfx_v9_0_ngg_en(adev);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:45:16 +08:00
|
|
|
static int gfx_v9_0_kcq_disable(struct amdgpu_device *adev)
|
2017-09-21 14:59:40 +08:00
|
|
|
{
|
2018-08-17 16:45:16 +08:00
|
|
|
int r, i;
|
|
|
|
struct amdgpu_ring *kiq_ring = &adev->gfx.kiq.ring;
|
2017-09-21 14:59:40 +08:00
|
|
|
|
2018-08-17 16:45:16 +08:00
|
|
|
r = amdgpu_ring_alloc(kiq_ring, 6 * adev->gfx.num_compute_rings);
|
|
|
|
if (r)
|
2017-09-21 14:59:40 +08:00
|
|
|
DRM_ERROR("Failed to lock KIQ (%d).\n", r);
|
|
|
|
|
2018-08-17 16:45:16 +08:00
|
|
|
for (i = 0; i < adev->gfx.num_compute_rings; i++) {
|
|
|
|
struct amdgpu_ring *ring = &adev->gfx.compute_ring[i];
|
|
|
|
|
|
|
|
amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_UNMAP_QUEUES, 4));
|
|
|
|
amdgpu_ring_write(kiq_ring, /* Q_sel: 0, vmid: 0, engine: 0, num_Q: 1 */
|
2017-09-21 14:59:40 +08:00
|
|
|
PACKET3_UNMAP_QUEUES_ACTION(1) | /* RESET_QUEUES */
|
|
|
|
PACKET3_UNMAP_QUEUES_QUEUE_SEL(0) |
|
|
|
|
PACKET3_UNMAP_QUEUES_ENGINE_SEL(0) |
|
|
|
|
PACKET3_UNMAP_QUEUES_NUM_QUEUES(1));
|
2018-08-17 16:45:16 +08:00
|
|
|
amdgpu_ring_write(kiq_ring, PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET0(ring->doorbell_index));
|
|
|
|
amdgpu_ring_write(kiq_ring, 0);
|
|
|
|
amdgpu_ring_write(kiq_ring, 0);
|
|
|
|
amdgpu_ring_write(kiq_ring, 0);
|
|
|
|
}
|
2018-10-20 04:22:48 +08:00
|
|
|
r = amdgpu_ring_test_helper(kiq_ring);
|
2018-08-17 16:42:35 +08:00
|
|
|
if (r)
|
|
|
|
DRM_ERROR("KCQ disable failed\n");
|
|
|
|
|
2017-09-21 14:59:40 +08:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
static int gfx_v9_0_hw_fini(void *handle)
|
|
|
|
{
|
|
|
|
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
|
|
|
|
|
|
|
amdgpu_irq_put(adev, &adev->gfx.priv_reg_irq, 0);
|
|
|
|
amdgpu_irq_put(adev, &adev->gfx.priv_inst_irq, 0);
|
2017-09-21 14:59:40 +08:00
|
|
|
|
|
|
|
/* disable KCQ to avoid CPC touch memory not valid anymore */
|
2018-08-17 16:45:16 +08:00
|
|
|
gfx_v9_0_kcq_disable(adev);
|
2017-09-21 14:59:40 +08:00
|
|
|
|
2017-02-28 16:48:47 +08:00
|
|
|
if (amdgpu_sriov_vf(adev)) {
|
2018-01-29 19:24:32 +08:00
|
|
|
gfx_v9_0_cp_gfx_enable(adev, false);
|
|
|
|
/* must disable polling for SRIOV when hw finished, otherwise
|
|
|
|
* CPC engine may still keep fetching WB address which is already
|
|
|
|
* invalid after sw finished and trigger DMAR reading error in
|
|
|
|
* hypervisor side.
|
|
|
|
*/
|
|
|
|
WREG32_FIELD15(GC, 0, CP_PQ_WPTR_POLL_CNTL, EN, 0);
|
2017-02-28 16:48:47 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2018-03-28 20:01:53 +08:00
|
|
|
|
|
|
|
/* Use deinitialize sequence from CAIL when unbinding device from driver,
|
|
|
|
* otherwise KIQ is hanging when binding back
|
|
|
|
*/
|
2018-09-29 15:27:02 +08:00
|
|
|
if (!adev->in_gpu_reset && !adev->in_suspend) {
|
2018-03-28 20:01:53 +08:00
|
|
|
mutex_lock(&adev->srbm_mutex);
|
|
|
|
soc15_grbm_select(adev, adev->gfx.kiq.ring.me,
|
|
|
|
adev->gfx.kiq.ring.pipe,
|
|
|
|
adev->gfx.kiq.ring.queue, 0);
|
|
|
|
gfx_v9_0_kiq_fini_register(&adev->gfx.kiq.ring);
|
|
|
|
soc15_grbm_select(adev, 0, 0, 0, 0);
|
|
|
|
mutex_unlock(&adev->srbm_mutex);
|
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
gfx_v9_0_cp_enable(adev, false);
|
2018-09-28 19:21:23 +08:00
|
|
|
adev->gfx.rlc.funcs->stop(adev);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2018-07-04 16:21:52 +08:00
|
|
|
gfx_v9_0_csb_vram_unpin(adev);
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_suspend(void *handle)
|
|
|
|
{
|
2018-09-29 15:27:02 +08:00
|
|
|
return gfx_v9_0_hw_fini(handle);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_resume(void *handle)
|
|
|
|
{
|
2018-09-29 15:27:02 +08:00
|
|
|
return gfx_v9_0_hw_init(handle);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool gfx_v9_0_is_idle(void *handle)
|
|
|
|
{
|
|
|
|
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
|
|
|
|
2017-04-07 19:53:53 +08:00
|
|
|
if (REG_GET_FIELD(RREG32_SOC15(GC, 0, mmGRBM_STATUS),
|
2017-03-04 06:59:39 +08:00
|
|
|
GRBM_STATUS, GUI_ACTIVE))
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_wait_for_idle(void *handle)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
|
|
|
|
|
|
|
for (i = 0; i < adev->usec_timeout; i++) {
|
2017-08-31 21:48:11 +08:00
|
|
|
if (gfx_v9_0_is_idle(handle))
|
2017-03-04 06:59:39 +08:00
|
|
|
return 0;
|
|
|
|
udelay(1);
|
|
|
|
}
|
|
|
|
return -ETIMEDOUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_soft_reset(void *handle)
|
|
|
|
{
|
|
|
|
u32 grbm_soft_reset = 0;
|
|
|
|
u32 tmp;
|
|
|
|
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
|
|
|
|
|
|
|
/* GRBM_STATUS */
|
2017-04-07 19:53:53 +08:00
|
|
|
tmp = RREG32_SOC15(GC, 0, mmGRBM_STATUS);
|
2017-03-04 06:59:39 +08:00
|
|
|
if (tmp & (GRBM_STATUS__PA_BUSY_MASK | GRBM_STATUS__SC_BUSY_MASK |
|
|
|
|
GRBM_STATUS__BCI_BUSY_MASK | GRBM_STATUS__SX_BUSY_MASK |
|
|
|
|
GRBM_STATUS__TA_BUSY_MASK | GRBM_STATUS__VGT_BUSY_MASK |
|
|
|
|
GRBM_STATUS__DB_BUSY_MASK | GRBM_STATUS__CB_BUSY_MASK |
|
|
|
|
GRBM_STATUS__GDS_BUSY_MASK | GRBM_STATUS__SPI_BUSY_MASK |
|
|
|
|
GRBM_STATUS__IA_BUSY_MASK | GRBM_STATUS__IA_BUSY_NO_DMA_MASK)) {
|
|
|
|
grbm_soft_reset = REG_SET_FIELD(grbm_soft_reset,
|
|
|
|
GRBM_SOFT_RESET, SOFT_RESET_CP, 1);
|
|
|
|
grbm_soft_reset = REG_SET_FIELD(grbm_soft_reset,
|
|
|
|
GRBM_SOFT_RESET, SOFT_RESET_GFX, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tmp & (GRBM_STATUS__CP_BUSY_MASK | GRBM_STATUS__CP_COHERENCY_BUSY_MASK)) {
|
|
|
|
grbm_soft_reset = REG_SET_FIELD(grbm_soft_reset,
|
|
|
|
GRBM_SOFT_RESET, SOFT_RESET_CP, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* GRBM_STATUS2 */
|
2017-04-07 19:53:53 +08:00
|
|
|
tmp = RREG32_SOC15(GC, 0, mmGRBM_STATUS2);
|
2017-03-04 06:59:39 +08:00
|
|
|
if (REG_GET_FIELD(tmp, GRBM_STATUS2, RLC_BUSY))
|
|
|
|
grbm_soft_reset = REG_SET_FIELD(grbm_soft_reset,
|
|
|
|
GRBM_SOFT_RESET, SOFT_RESET_RLC, 1);
|
|
|
|
|
|
|
|
|
2017-04-05 20:54:11 +08:00
|
|
|
if (grbm_soft_reset) {
|
2017-03-04 06:59:39 +08:00
|
|
|
/* stop the rlc */
|
2018-09-28 19:21:23 +08:00
|
|
|
adev->gfx.rlc.funcs->stop(adev);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* Disable GFX parsing/prefetching */
|
|
|
|
gfx_v9_0_cp_gfx_enable(adev, false);
|
|
|
|
|
|
|
|
/* Disable MEC parsing/prefetching */
|
|
|
|
gfx_v9_0_cp_compute_enable(adev, false);
|
|
|
|
|
|
|
|
if (grbm_soft_reset) {
|
2017-04-07 19:53:53 +08:00
|
|
|
tmp = RREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET);
|
2017-03-04 06:59:39 +08:00
|
|
|
tmp |= grbm_soft_reset;
|
|
|
|
dev_info(adev->dev, "GRBM_SOFT_RESET=0x%08X\n", tmp);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET, tmp);
|
|
|
|
tmp = RREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
udelay(50);
|
|
|
|
|
|
|
|
tmp &= ~grbm_soft_reset;
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET, tmp);
|
|
|
|
tmp = RREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Wait a little for things to settle down */
|
|
|
|
udelay(50);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint64_t gfx_v9_0_get_gpu_clock_counter(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
uint64_t clock;
|
|
|
|
|
|
|
|
mutex_lock(&adev->gfx.gpu_clock_mutex);
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_CAPTURE_GPU_CLOCK_COUNT, 1);
|
|
|
|
clock = (uint64_t)RREG32_SOC15(GC, 0, mmRLC_GPU_CLOCK_COUNT_LSB) |
|
|
|
|
((uint64_t)RREG32_SOC15(GC, 0, mmRLC_GPU_CLOCK_COUNT_MSB) << 32ULL);
|
2017-03-04 06:59:39 +08:00
|
|
|
mutex_unlock(&adev->gfx.gpu_clock_mutex);
|
|
|
|
return clock;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_ring_emit_gds_switch(struct amdgpu_ring *ring,
|
|
|
|
uint32_t vmid,
|
|
|
|
uint32_t gds_base, uint32_t gds_size,
|
|
|
|
uint32_t gws_base, uint32_t gws_size,
|
|
|
|
uint32_t oa_base, uint32_t oa_size)
|
|
|
|
{
|
2017-11-29 06:01:21 +08:00
|
|
|
struct amdgpu_device *adev = ring->adev;
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
/* GDS Base */
|
|
|
|
gfx_v9_0_write_data_to_reg(ring, 0, false,
|
2017-11-29 06:01:21 +08:00
|
|
|
SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_BASE) + 2 * vmid,
|
2017-03-04 06:59:39 +08:00
|
|
|
gds_base);
|
|
|
|
|
|
|
|
/* GDS Size */
|
|
|
|
gfx_v9_0_write_data_to_reg(ring, 0, false,
|
2017-11-29 06:01:21 +08:00
|
|
|
SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE) + 2 * vmid,
|
2017-03-04 06:59:39 +08:00
|
|
|
gds_size);
|
|
|
|
|
|
|
|
/* GWS */
|
|
|
|
gfx_v9_0_write_data_to_reg(ring, 0, false,
|
2017-11-29 06:01:21 +08:00
|
|
|
SOC15_REG_OFFSET(GC, 0, mmGDS_GWS_VMID0) + vmid,
|
2017-03-04 06:59:39 +08:00
|
|
|
gws_size << GDS_GWS_VMID0__SIZE__SHIFT | gws_base);
|
|
|
|
|
|
|
|
/* OA */
|
|
|
|
gfx_v9_0_write_data_to_reg(ring, 0, false,
|
2017-11-29 06:01:21 +08:00
|
|
|
SOC15_REG_OFFSET(GC, 0, mmGDS_OA_VMID0) + vmid,
|
2017-03-04 06:59:39 +08:00
|
|
|
(1 << (oa_size + oa_base)) - (1 << oa_base));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_early_init(void *handle)
|
|
|
|
{
|
|
|
|
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
|
|
|
|
|
|
|
adev->gfx.num_gfx_rings = GFX9_NUM_GFX_RINGS;
|
2017-02-02 13:38:22 +08:00
|
|
|
adev->gfx.num_compute_rings = AMDGPU_MAX_COMPUTE_RINGS;
|
2017-03-04 06:59:39 +08:00
|
|
|
gfx_v9_0_set_ring_funcs(adev);
|
|
|
|
gfx_v9_0_set_irq_funcs(adev);
|
|
|
|
gfx_v9_0_set_gds_init(adev);
|
|
|
|
gfx_v9_0_set_rlc_funcs(adev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_late_init(void *handle)
|
|
|
|
{
|
|
|
|
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
r = amdgpu_irq_get(adev, &adev->gfx.priv_reg_irq, 0);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = amdgpu_irq_get(adev, &adev->gfx.priv_inst_irq, 0);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-08 20:19:54 +08:00
|
|
|
static bool gfx_v9_0_is_rlc_enabled(struct amdgpu_device *adev)
|
2017-03-04 06:59:39 +08:00
|
|
|
{
|
2018-11-08 20:19:54 +08:00
|
|
|
uint32_t rlc_setting;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* if RLC is not enabled, do nothing */
|
2017-04-07 19:53:53 +08:00
|
|
|
rlc_setting = RREG32_SOC15(GC, 0, mmRLC_CNTL);
|
2017-03-04 06:59:39 +08:00
|
|
|
if (!(rlc_setting & RLC_CNTL__RLC_ENABLE_F32_MASK))
|
2018-11-08 20:19:54 +08:00
|
|
|
return false;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2018-11-08 20:19:54 +08:00
|
|
|
return true;
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
2018-11-08 20:19:54 +08:00
|
|
|
static void gfx_v9_0_set_safe_mode(struct amdgpu_device *adev)
|
2017-03-04 06:59:39 +08:00
|
|
|
{
|
2018-11-08 20:19:54 +08:00
|
|
|
uint32_t data;
|
|
|
|
unsigned i;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2018-11-08 20:19:54 +08:00
|
|
|
data = RLC_SAFE_MODE__CMD_MASK;
|
|
|
|
data |= (1 << RLC_SAFE_MODE__MESSAGE__SHIFT);
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_SAFE_MODE, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2018-11-08 20:19:54 +08:00
|
|
|
/* wait for RLC_SAFE_MODE */
|
|
|
|
for (i = 0; i < adev->usec_timeout; i++) {
|
|
|
|
if (!REG_GET_FIELD(RREG32_SOC15(GC, 0, mmRLC_SAFE_MODE), RLC_SAFE_MODE, CMD))
|
|
|
|
break;
|
|
|
|
udelay(1);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-08 20:19:54 +08:00
|
|
|
static void gfx_v9_0_unset_safe_mode(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
uint32_t data;
|
|
|
|
|
|
|
|
data = RLC_SAFE_MODE__CMD_MASK;
|
|
|
|
WREG32_SOC15(GC, 0, mmRLC_SAFE_MODE, data);
|
|
|
|
}
|
|
|
|
|
2017-02-13 18:40:45 +08:00
|
|
|
static void gfx_v9_0_update_gfx_cg_power_gating(struct amdgpu_device *adev,
|
|
|
|
bool enable)
|
|
|
|
{
|
2018-11-08 20:19:54 +08:00
|
|
|
amdgpu_gfx_rlc_enter_safe_mode(adev);
|
2017-02-13 18:40:45 +08:00
|
|
|
|
|
|
|
if ((adev->pg_flags & AMD_PG_SUPPORT_GFX_PG) && enable) {
|
|
|
|
gfx_v9_0_enable_gfx_cg_power_gating(adev, true);
|
|
|
|
if (adev->pg_flags & AMD_PG_SUPPORT_GFX_PIPELINE)
|
|
|
|
gfx_v9_0_enable_gfx_pipeline_powergating(adev, true);
|
|
|
|
} else {
|
|
|
|
gfx_v9_0_enable_gfx_cg_power_gating(adev, false);
|
|
|
|
gfx_v9_0_enable_gfx_pipeline_powergating(adev, false);
|
|
|
|
}
|
|
|
|
|
2018-11-08 20:19:54 +08:00
|
|
|
amdgpu_gfx_rlc_exit_safe_mode(adev);
|
2017-02-13 18:40:45 +08:00
|
|
|
}
|
|
|
|
|
2017-02-13 18:45:28 +08:00
|
|
|
static void gfx_v9_0_update_gfx_mg_power_gating(struct amdgpu_device *adev,
|
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
/* TODO: double check if we need to perform under safe mode */
|
|
|
|
/* gfx_v9_0_enter_rlc_safe_mode(adev); */
|
|
|
|
|
|
|
|
if ((adev->pg_flags & AMD_PG_SUPPORT_GFX_SMG) && enable)
|
|
|
|
gfx_v9_0_enable_gfx_static_mg_power_gating(adev, true);
|
|
|
|
else
|
|
|
|
gfx_v9_0_enable_gfx_static_mg_power_gating(adev, false);
|
|
|
|
|
|
|
|
if ((adev->pg_flags & AMD_PG_SUPPORT_GFX_DMG) && enable)
|
|
|
|
gfx_v9_0_enable_gfx_dynamic_mg_power_gating(adev, true);
|
|
|
|
else
|
|
|
|
gfx_v9_0_enable_gfx_dynamic_mg_power_gating(adev, false);
|
|
|
|
|
|
|
|
/* gfx_v9_0_exit_rlc_safe_mode(adev); */
|
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
static void gfx_v9_0_update_medium_grain_clock_gating(struct amdgpu_device *adev,
|
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
uint32_t data, def;
|
|
|
|
|
|
|
|
/* It is disabled by HW by default */
|
|
|
|
if (enable && (adev->cg_flags & AMD_CG_SUPPORT_GFX_MGCG)) {
|
|
|
|
/* 1 - RLC_CGTT_MGCG_OVERRIDE */
|
2017-04-07 19:53:53 +08:00
|
|
|
def = data = RREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE);
|
2018-07-05 10:26:48 +08:00
|
|
|
|
|
|
|
if (adev->asic_type != CHIP_VEGA12)
|
|
|
|
data &= ~RLC_CGTT_MGCG_OVERRIDE__CPF_CGTT_SCLK_OVERRIDE_MASK;
|
|
|
|
|
|
|
|
data &= ~(RLC_CGTT_MGCG_OVERRIDE__GRBM_CGTT_SCLK_OVERRIDE_MASK |
|
2017-03-04 06:59:39 +08:00
|
|
|
RLC_CGTT_MGCG_OVERRIDE__GFXIP_MGCG_OVERRIDE_MASK |
|
|
|
|
RLC_CGTT_MGCG_OVERRIDE__GFXIP_MGLS_OVERRIDE_MASK);
|
|
|
|
|
|
|
|
/* only for Vega10 & Raven1 */
|
|
|
|
data |= RLC_CGTT_MGCG_OVERRIDE__RLC_CGTT_SCLK_OVERRIDE_MASK;
|
|
|
|
|
|
|
|
if (def != data)
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* MGLS is a global flag to control all MGLS in GFX */
|
|
|
|
if (adev->cg_flags & AMD_CG_SUPPORT_GFX_MGLS) {
|
|
|
|
/* 2 - RLC memory Light sleep */
|
|
|
|
if (adev->cg_flags & AMD_CG_SUPPORT_GFX_RLC_LS) {
|
2017-04-07 19:53:53 +08:00
|
|
|
def = data = RREG32_SOC15(GC, 0, mmRLC_MEM_SLP_CNTL);
|
2017-03-04 06:59:39 +08:00
|
|
|
data |= RLC_MEM_SLP_CNTL__RLC_MEM_LS_EN_MASK;
|
|
|
|
if (def != data)
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_MEM_SLP_CNTL, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
/* 3 - CP memory Light sleep */
|
|
|
|
if (adev->cg_flags & AMD_CG_SUPPORT_GFX_CP_LS) {
|
2017-04-07 19:53:53 +08:00
|
|
|
def = data = RREG32_SOC15(GC, 0, mmCP_MEM_SLP_CNTL);
|
2017-03-04 06:59:39 +08:00
|
|
|
data |= CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK;
|
|
|
|
if (def != data)
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_MEM_SLP_CNTL, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* 1 - MGCG_OVERRIDE */
|
2017-04-07 19:53:53 +08:00
|
|
|
def = data = RREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE);
|
2018-07-05 10:26:48 +08:00
|
|
|
|
|
|
|
if (adev->asic_type != CHIP_VEGA12)
|
|
|
|
data |= RLC_CGTT_MGCG_OVERRIDE__CPF_CGTT_SCLK_OVERRIDE_MASK;
|
|
|
|
|
|
|
|
data |= (RLC_CGTT_MGCG_OVERRIDE__RLC_CGTT_SCLK_OVERRIDE_MASK |
|
2017-03-04 06:59:39 +08:00
|
|
|
RLC_CGTT_MGCG_OVERRIDE__GRBM_CGTT_SCLK_OVERRIDE_MASK |
|
|
|
|
RLC_CGTT_MGCG_OVERRIDE__GFXIP_MGCG_OVERRIDE_MASK |
|
|
|
|
RLC_CGTT_MGCG_OVERRIDE__GFXIP_MGLS_OVERRIDE_MASK);
|
2018-07-05 10:26:48 +08:00
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
if (def != data)
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* 2 - disable MGLS in RLC */
|
2017-04-07 19:53:53 +08:00
|
|
|
data = RREG32_SOC15(GC, 0, mmRLC_MEM_SLP_CNTL);
|
2017-03-04 06:59:39 +08:00
|
|
|
if (data & RLC_MEM_SLP_CNTL__RLC_MEM_LS_EN_MASK) {
|
|
|
|
data &= ~RLC_MEM_SLP_CNTL__RLC_MEM_LS_EN_MASK;
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_MEM_SLP_CNTL, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 3 - disable MGLS in CP */
|
2017-04-07 19:53:53 +08:00
|
|
|
data = RREG32_SOC15(GC, 0, mmCP_MEM_SLP_CNTL);
|
2017-03-04 06:59:39 +08:00
|
|
|
if (data & CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK) {
|
|
|
|
data &= ~CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK;
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_MEM_SLP_CNTL, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_update_3d_clock_gating(struct amdgpu_device *adev,
|
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
uint32_t data, def;
|
|
|
|
|
2018-11-08 20:19:54 +08:00
|
|
|
amdgpu_gfx_rlc_enter_safe_mode(adev);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* Enable 3D CGCG/CGLS */
|
|
|
|
if (enable && (adev->cg_flags & AMD_CG_SUPPORT_GFX_3D_CGCG)) {
|
|
|
|
/* write cmd to clear cgcg/cgls ov */
|
2017-04-07 19:53:53 +08:00
|
|
|
def = data = RREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE);
|
2017-03-04 06:59:39 +08:00
|
|
|
/* unset CGCG override */
|
|
|
|
data &= ~RLC_CGTT_MGCG_OVERRIDE__GFXIP_GFX3D_CG_OVERRIDE_MASK;
|
|
|
|
/* update CGCG and CGLS override bits */
|
|
|
|
if (def != data)
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE, data);
|
2018-07-05 10:30:36 +08:00
|
|
|
|
|
|
|
/* enable 3Dcgcg FSM(0x0000363f) */
|
2017-04-07 19:53:53 +08:00
|
|
|
def = RREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL_3D);
|
2018-07-05 10:30:36 +08:00
|
|
|
|
|
|
|
data = (0x36 << RLC_CGCG_CGLS_CTRL_3D__CGCG_GFX_IDLE_THRESHOLD__SHIFT) |
|
2017-03-04 06:59:39 +08:00
|
|
|
RLC_CGCG_CGLS_CTRL_3D__CGCG_EN_MASK;
|
|
|
|
if (adev->cg_flags & AMD_CG_SUPPORT_GFX_3D_CGLS)
|
|
|
|
data |= (0x000F << RLC_CGCG_CGLS_CTRL_3D__CGLS_REP_COMPANSAT_DELAY__SHIFT) |
|
|
|
|
RLC_CGCG_CGLS_CTRL_3D__CGLS_EN_MASK;
|
|
|
|
if (def != data)
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL_3D, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* set IDLE_POLL_COUNT(0x00900100) */
|
2017-04-07 19:53:53 +08:00
|
|
|
def = RREG32_SOC15(GC, 0, mmCP_RB_WPTR_POLL_CNTL);
|
2017-03-04 06:59:39 +08:00
|
|
|
data = (0x0100 << CP_RB_WPTR_POLL_CNTL__POLL_FREQUENCY__SHIFT) |
|
|
|
|
(0x0090 << CP_RB_WPTR_POLL_CNTL__IDLE_POLL_COUNT__SHIFT);
|
|
|
|
if (def != data)
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_RB_WPTR_POLL_CNTL, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
} else {
|
|
|
|
/* Disable CGCG/CGLS */
|
2017-04-07 19:53:53 +08:00
|
|
|
def = data = RREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL_3D);
|
2017-03-04 06:59:39 +08:00
|
|
|
/* disable cgcg, cgls should be disabled */
|
|
|
|
data &= ~(RLC_CGCG_CGLS_CTRL_3D__CGCG_EN_MASK |
|
|
|
|
RLC_CGCG_CGLS_CTRL_3D__CGLS_EN_MASK);
|
|
|
|
/* disable cgcg and cgls in FSM */
|
|
|
|
if (def != data)
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL_3D, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
2018-11-08 20:19:54 +08:00
|
|
|
amdgpu_gfx_rlc_exit_safe_mode(adev);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_update_coarse_grain_clock_gating(struct amdgpu_device *adev,
|
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
uint32_t def, data;
|
|
|
|
|
2018-11-08 20:19:54 +08:00
|
|
|
amdgpu_gfx_rlc_enter_safe_mode(adev);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
if (enable && (adev->cg_flags & AMD_CG_SUPPORT_GFX_CGCG)) {
|
2017-04-07 19:53:53 +08:00
|
|
|
def = data = RREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE);
|
2017-03-04 06:59:39 +08:00
|
|
|
/* unset CGCG override */
|
|
|
|
data &= ~RLC_CGTT_MGCG_OVERRIDE__GFXIP_CGCG_OVERRIDE_MASK;
|
|
|
|
if (adev->cg_flags & AMD_CG_SUPPORT_GFX_CGLS)
|
|
|
|
data &= ~RLC_CGTT_MGCG_OVERRIDE__GFXIP_CGLS_OVERRIDE_MASK;
|
|
|
|
else
|
|
|
|
data |= RLC_CGTT_MGCG_OVERRIDE__GFXIP_CGLS_OVERRIDE_MASK;
|
|
|
|
/* update CGCG and CGLS override bits */
|
|
|
|
if (def != data)
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2018-07-05 10:30:36 +08:00
|
|
|
/* enable cgcg FSM(0x0000363F) */
|
2017-04-07 19:53:53 +08:00
|
|
|
def = RREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL);
|
2018-07-05 10:30:36 +08:00
|
|
|
|
|
|
|
data = (0x36 << RLC_CGCG_CGLS_CTRL__CGCG_GFX_IDLE_THRESHOLD__SHIFT) |
|
2017-03-04 06:59:39 +08:00
|
|
|
RLC_CGCG_CGLS_CTRL__CGCG_EN_MASK;
|
|
|
|
if (adev->cg_flags & AMD_CG_SUPPORT_GFX_CGLS)
|
|
|
|
data |= (0x000F << RLC_CGCG_CGLS_CTRL__CGLS_REP_COMPANSAT_DELAY__SHIFT) |
|
|
|
|
RLC_CGCG_CGLS_CTRL__CGLS_EN_MASK;
|
|
|
|
if (def != data)
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* set IDLE_POLL_COUNT(0x00900100) */
|
2017-04-07 19:53:53 +08:00
|
|
|
def = RREG32_SOC15(GC, 0, mmCP_RB_WPTR_POLL_CNTL);
|
2017-03-04 06:59:39 +08:00
|
|
|
data = (0x0100 << CP_RB_WPTR_POLL_CNTL__POLL_FREQUENCY__SHIFT) |
|
|
|
|
(0x0090 << CP_RB_WPTR_POLL_CNTL__IDLE_POLL_COUNT__SHIFT);
|
|
|
|
if (def != data)
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_RB_WPTR_POLL_CNTL, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
} else {
|
2017-04-07 19:53:53 +08:00
|
|
|
def = data = RREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL);
|
2017-03-04 06:59:39 +08:00
|
|
|
/* reset CGCG/CGLS bits */
|
|
|
|
data &= ~(RLC_CGCG_CGLS_CTRL__CGCG_EN_MASK | RLC_CGCG_CGLS_CTRL__CGLS_EN_MASK);
|
|
|
|
/* disable cgcg and cgls in FSM */
|
|
|
|
if (def != data)
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL, data);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
2018-11-08 20:19:54 +08:00
|
|
|
amdgpu_gfx_rlc_exit_safe_mode(adev);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_update_gfx_clock_gating(struct amdgpu_device *adev,
|
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
if (enable) {
|
|
|
|
/* CGCG/CGLS should be enabled after MGCG/MGLS
|
|
|
|
* === MGCG + MGLS ===
|
|
|
|
*/
|
|
|
|
gfx_v9_0_update_medium_grain_clock_gating(adev, enable);
|
|
|
|
/* === CGCG /CGLS for GFX 3D Only === */
|
|
|
|
gfx_v9_0_update_3d_clock_gating(adev, enable);
|
|
|
|
/* === CGCG + CGLS === */
|
|
|
|
gfx_v9_0_update_coarse_grain_clock_gating(adev, enable);
|
|
|
|
} else {
|
|
|
|
/* CGCG/CGLS should be disabled before MGCG/MGLS
|
|
|
|
* === CGCG + CGLS ===
|
|
|
|
*/
|
|
|
|
gfx_v9_0_update_coarse_grain_clock_gating(adev, enable);
|
|
|
|
/* === CGCG /CGLS for GFX 3D Only === */
|
|
|
|
gfx_v9_0_update_3d_clock_gating(adev, enable);
|
|
|
|
/* === MGCG + MGLS === */
|
|
|
|
gfx_v9_0_update_medium_grain_clock_gating(adev, enable);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct amdgpu_rlc_funcs gfx_v9_0_rlc_funcs = {
|
2018-11-08 20:19:54 +08:00
|
|
|
.is_rlc_enabled = gfx_v9_0_is_rlc_enabled,
|
|
|
|
.set_safe_mode = gfx_v9_0_set_safe_mode,
|
|
|
|
.unset_safe_mode = gfx_v9_0_unset_safe_mode,
|
2018-09-28 19:21:23 +08:00
|
|
|
.init = gfx_v9_0_rlc_init,
|
2018-11-08 20:19:54 +08:00
|
|
|
.get_csb_size = gfx_v9_0_get_csb_size,
|
|
|
|
.get_csb_buffer = gfx_v9_0_get_csb_buffer,
|
|
|
|
.get_cp_table_num = gfx_v9_0_cp_jump_table_num,
|
2018-09-28 19:21:23 +08:00
|
|
|
.resume = gfx_v9_0_rlc_resume,
|
|
|
|
.stop = gfx_v9_0_rlc_stop,
|
|
|
|
.reset = gfx_v9_0_rlc_reset,
|
|
|
|
.start = gfx_v9_0_rlc_start
|
2017-03-04 06:59:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static int gfx_v9_0_set_powergating_state(void *handle,
|
|
|
|
enum amd_powergating_state state)
|
|
|
|
{
|
2017-02-13 18:00:43 +08:00
|
|
|
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
2017-02-13 18:40:45 +08:00
|
|
|
bool enable = (state == AMD_PG_STATE_GATE) ? true : false;
|
2017-02-13 18:00:43 +08:00
|
|
|
|
|
|
|
switch (adev->asic_type) {
|
|
|
|
case CHIP_RAVEN:
|
2018-08-14 16:54:15 +08:00
|
|
|
if (!enable) {
|
|
|
|
amdgpu_gfx_off_ctrl(adev, false);
|
|
|
|
cancel_delayed_work_sync(&adev->gfx.gfx_off_delay_work);
|
|
|
|
}
|
2017-02-13 18:00:43 +08:00
|
|
|
if (adev->pg_flags & AMD_PG_SUPPORT_RLC_SMU_HS) {
|
|
|
|
gfx_v9_0_enable_sck_slow_down_on_power_up(adev, true);
|
|
|
|
gfx_v9_0_enable_sck_slow_down_on_power_down(adev, true);
|
|
|
|
} else {
|
|
|
|
gfx_v9_0_enable_sck_slow_down_on_power_up(adev, false);
|
|
|
|
gfx_v9_0_enable_sck_slow_down_on_power_down(adev, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (adev->pg_flags & AMD_PG_SUPPORT_CP)
|
|
|
|
gfx_v9_0_enable_cp_power_gating(adev, true);
|
|
|
|
else
|
|
|
|
gfx_v9_0_enable_cp_power_gating(adev, false);
|
2017-02-13 18:40:45 +08:00
|
|
|
|
|
|
|
/* update gfx cgpg state */
|
|
|
|
gfx_v9_0_update_gfx_cg_power_gating(adev, enable);
|
2017-02-13 18:45:28 +08:00
|
|
|
|
|
|
|
/* update mgcg state */
|
|
|
|
gfx_v9_0_update_gfx_mg_power_gating(adev, enable);
|
2018-06-05 11:46:35 +08:00
|
|
|
|
2018-08-14 16:54:15 +08:00
|
|
|
if (enable)
|
|
|
|
amdgpu_gfx_off_ctrl(adev, true);
|
2018-07-04 16:44:07 +08:00
|
|
|
break;
|
|
|
|
case CHIP_VEGA12:
|
2018-08-14 16:54:15 +08:00
|
|
|
if (!enable) {
|
|
|
|
amdgpu_gfx_off_ctrl(adev, false);
|
|
|
|
cancel_delayed_work_sync(&adev->gfx.gfx_off_delay_work);
|
|
|
|
} else {
|
|
|
|
amdgpu_gfx_off_ctrl(adev, true);
|
|
|
|
}
|
2017-02-13 18:00:43 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_set_clockgating_state(void *handle,
|
|
|
|
enum amd_clockgating_state state)
|
|
|
|
{
|
|
|
|
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
|
|
|
|
2017-04-14 17:43:02 +08:00
|
|
|
if (amdgpu_sriov_vf(adev))
|
|
|
|
return 0;
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
switch (adev->asic_type) {
|
|
|
|
case CHIP_VEGA10:
|
2017-09-02 14:26:50 +08:00
|
|
|
case CHIP_VEGA12:
|
2018-01-23 15:03:36 +08:00
|
|
|
case CHIP_VEGA20:
|
2017-01-10 11:04:25 +08:00
|
|
|
case CHIP_RAVEN:
|
2017-03-04 06:59:39 +08:00
|
|
|
gfx_v9_0_update_gfx_clock_gating(adev,
|
|
|
|
state == AMD_CG_STATE_GATE ? true : false);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-24 09:58:11 +08:00
|
|
|
static void gfx_v9_0_get_clockgating_state(void *handle, u32 *flags)
|
|
|
|
{
|
|
|
|
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
|
|
|
int data;
|
|
|
|
|
|
|
|
if (amdgpu_sriov_vf(adev))
|
|
|
|
*flags = 0;
|
|
|
|
|
|
|
|
/* AMD_CG_SUPPORT_GFX_MGCG */
|
2017-04-07 19:53:53 +08:00
|
|
|
data = RREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE);
|
2017-03-24 09:58:11 +08:00
|
|
|
if (!(data & RLC_CGTT_MGCG_OVERRIDE__GFXIP_MGCG_OVERRIDE_MASK))
|
|
|
|
*flags |= AMD_CG_SUPPORT_GFX_MGCG;
|
|
|
|
|
|
|
|
/* AMD_CG_SUPPORT_GFX_CGCG */
|
2017-04-07 19:53:53 +08:00
|
|
|
data = RREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL);
|
2017-03-24 09:58:11 +08:00
|
|
|
if (data & RLC_CGCG_CGLS_CTRL__CGCG_EN_MASK)
|
|
|
|
*flags |= AMD_CG_SUPPORT_GFX_CGCG;
|
|
|
|
|
|
|
|
/* AMD_CG_SUPPORT_GFX_CGLS */
|
|
|
|
if (data & RLC_CGCG_CGLS_CTRL__CGLS_EN_MASK)
|
|
|
|
*flags |= AMD_CG_SUPPORT_GFX_CGLS;
|
|
|
|
|
|
|
|
/* AMD_CG_SUPPORT_GFX_RLC_LS */
|
2017-04-07 19:53:53 +08:00
|
|
|
data = RREG32_SOC15(GC, 0, mmRLC_MEM_SLP_CNTL);
|
2017-03-24 09:58:11 +08:00
|
|
|
if (data & RLC_MEM_SLP_CNTL__RLC_MEM_LS_EN_MASK)
|
|
|
|
*flags |= AMD_CG_SUPPORT_GFX_RLC_LS | AMD_CG_SUPPORT_GFX_MGLS;
|
|
|
|
|
|
|
|
/* AMD_CG_SUPPORT_GFX_CP_LS */
|
2017-04-07 19:53:53 +08:00
|
|
|
data = RREG32_SOC15(GC, 0, mmCP_MEM_SLP_CNTL);
|
2017-03-24 09:58:11 +08:00
|
|
|
if (data & CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK)
|
|
|
|
*flags |= AMD_CG_SUPPORT_GFX_CP_LS | AMD_CG_SUPPORT_GFX_MGLS;
|
|
|
|
|
|
|
|
/* AMD_CG_SUPPORT_GFX_3D_CGCG */
|
2017-04-07 19:53:53 +08:00
|
|
|
data = RREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL_3D);
|
2017-03-24 09:58:11 +08:00
|
|
|
if (data & RLC_CGCG_CGLS_CTRL_3D__CGCG_EN_MASK)
|
|
|
|
*flags |= AMD_CG_SUPPORT_GFX_3D_CGCG;
|
|
|
|
|
|
|
|
/* AMD_CG_SUPPORT_GFX_3D_CGLS */
|
|
|
|
if (data & RLC_CGCG_CGLS_CTRL_3D__CGLS_EN_MASK)
|
|
|
|
*flags |= AMD_CG_SUPPORT_GFX_3D_CGLS;
|
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
static u64 gfx_v9_0_ring_get_rptr_gfx(struct amdgpu_ring *ring)
|
|
|
|
{
|
|
|
|
return ring->adev->wb.wb[ring->rptr_offs]; /* gfx9 is 32bit rptr*/
|
|
|
|
}
|
|
|
|
|
|
|
|
static u64 gfx_v9_0_ring_get_wptr_gfx(struct amdgpu_ring *ring)
|
|
|
|
{
|
|
|
|
struct amdgpu_device *adev = ring->adev;
|
|
|
|
u64 wptr;
|
|
|
|
|
|
|
|
/* XXX check if swapping is necessary on BE */
|
|
|
|
if (ring->use_doorbell) {
|
|
|
|
wptr = atomic64_read((atomic64_t *)&adev->wb.wb[ring->wptr_offs]);
|
|
|
|
} else {
|
2017-04-07 19:53:53 +08:00
|
|
|
wptr = RREG32_SOC15(GC, 0, mmCP_RB0_WPTR);
|
|
|
|
wptr += (u64)RREG32_SOC15(GC, 0, mmCP_RB0_WPTR_HI) << 32;
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return wptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_ring_set_wptr_gfx(struct amdgpu_ring *ring)
|
|
|
|
{
|
|
|
|
struct amdgpu_device *adev = ring->adev;
|
|
|
|
|
|
|
|
if (ring->use_doorbell) {
|
|
|
|
/* XXX check if swapping is necessary on BE */
|
|
|
|
atomic64_set((atomic64_t*)&adev->wb.wb[ring->wptr_offs], ring->wptr);
|
|
|
|
WDOORBELL64(ring->doorbell_index, ring->wptr);
|
|
|
|
} else {
|
2017-04-07 19:53:53 +08:00
|
|
|
WREG32_SOC15(GC, 0, mmCP_RB0_WPTR, lower_32_bits(ring->wptr));
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_RB0_WPTR_HI, upper_32_bits(ring->wptr));
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_ring_emit_hdp_flush(struct amdgpu_ring *ring)
|
|
|
|
{
|
2017-11-29 06:01:21 +08:00
|
|
|
struct amdgpu_device *adev = ring->adev;
|
2017-03-04 06:59:39 +08:00
|
|
|
u32 ref_and_mask, reg_mem_engine;
|
2017-12-09 02:07:58 +08:00
|
|
|
const struct nbio_hdp_flush_reg *nbio_hf_reg = adev->nbio_funcs->hdp_flush_reg;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
if (ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE) {
|
|
|
|
switch (ring->me) {
|
|
|
|
case 1:
|
|
|
|
ref_and_mask = nbio_hf_reg->ref_and_mask_cp2 << ring->pipe;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
ref_and_mask = nbio_hf_reg->ref_and_mask_cp6 << ring->pipe;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
reg_mem_engine = 0;
|
|
|
|
} else {
|
|
|
|
ref_and_mask = nbio_hf_reg->ref_and_mask_cp0;
|
|
|
|
reg_mem_engine = 1; /* pfp */
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx_v9_0_wait_reg_mem(ring, reg_mem_engine, 0, 1,
|
2017-11-29 06:01:21 +08:00
|
|
|
adev->nbio_funcs->get_hdp_flush_req_offset(adev),
|
|
|
|
adev->nbio_funcs->get_hdp_flush_done_offset(adev),
|
2017-03-04 06:59:39 +08:00
|
|
|
ref_and_mask, ref_and_mask, 0x20);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,
|
2018-10-24 13:37:37 +08:00
|
|
|
struct amdgpu_job *job,
|
|
|
|
struct amdgpu_ib *ib,
|
|
|
|
bool ctx_switch)
|
2017-03-04 06:59:39 +08:00
|
|
|
{
|
2018-10-24 13:37:37 +08:00
|
|
|
unsigned vmid = AMDGPU_JOB_GET_VMID(job);
|
2017-05-01 17:00:13 +08:00
|
|
|
u32 header, control = 0;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-05-01 17:00:13 +08:00
|
|
|
if (ib->flags & AMDGPU_IB_FLAG_CE)
|
|
|
|
header = PACKET3(PACKET3_INDIRECT_BUFFER_CONST, 2);
|
|
|
|
else
|
|
|
|
header = PACKET3(PACKET3_INDIRECT_BUFFER, 2);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-12-19 00:08:25 +08:00
|
|
|
control |= ib->length_dw | (vmid << 24);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2017-05-01 17:05:02 +08:00
|
|
|
if (amdgpu_sriov_vf(ring->adev) && (ib->flags & AMDGPU_IB_FLAG_PREEMPT)) {
|
2017-05-01 17:00:13 +08:00
|
|
|
control |= INDIRECT_BUFFER_PRE_ENB(1);
|
2017-03-21 11:50:43 +08:00
|
|
|
|
2017-05-01 17:05:02 +08:00
|
|
|
if (!(ib->flags & AMDGPU_IB_FLAG_CE))
|
|
|
|
gfx_v9_0_ring_emit_de_meta(ring);
|
|
|
|
}
|
|
|
|
|
2017-05-01 17:00:13 +08:00
|
|
|
amdgpu_ring_write(ring, header);
|
2017-12-21 15:03:31 +08:00
|
|
|
BUG_ON(ib->gpu_addr & 0x3); /* Dword align */
|
2017-05-01 17:00:13 +08:00
|
|
|
amdgpu_ring_write(ring,
|
2017-03-04 06:59:39 +08:00
|
|
|
#ifdef __BIG_ENDIAN
|
2017-05-01 17:00:13 +08:00
|
|
|
(2 << 0) |
|
2017-03-04 06:59:39 +08:00
|
|
|
#endif
|
2017-05-01 17:00:13 +08:00
|
|
|
lower_32_bits(ib->gpu_addr));
|
|
|
|
amdgpu_ring_write(ring, upper_32_bits(ib->gpu_addr));
|
|
|
|
amdgpu_ring_write(ring, control);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_ring_emit_ib_compute(struct amdgpu_ring *ring,
|
2018-10-24 13:37:37 +08:00
|
|
|
struct amdgpu_job *job,
|
|
|
|
struct amdgpu_ib *ib,
|
|
|
|
bool ctx_switch)
|
2017-03-04 06:59:39 +08:00
|
|
|
{
|
2018-10-24 13:37:37 +08:00
|
|
|
unsigned vmid = AMDGPU_JOB_GET_VMID(job);
|
|
|
|
u32 control = INDIRECT_BUFFER_VALID | ib->length_dw | (vmid << 24);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
2018-10-24 13:37:37 +08:00
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_INDIRECT_BUFFER, 2));
|
2017-03-04 06:59:39 +08:00
|
|
|
BUG_ON(ib->gpu_addr & 0x3); /* Dword align */
|
2018-10-24 13:37:37 +08:00
|
|
|
amdgpu_ring_write(ring,
|
2017-03-04 06:59:39 +08:00
|
|
|
#ifdef __BIG_ENDIAN
|
2018-10-24 13:37:37 +08:00
|
|
|
(2 << 0) |
|
2017-03-04 06:59:39 +08:00
|
|
|
#endif
|
2018-10-24 13:37:37 +08:00
|
|
|
lower_32_bits(ib->gpu_addr));
|
|
|
|
amdgpu_ring_write(ring, upper_32_bits(ib->gpu_addr));
|
|
|
|
amdgpu_ring_write(ring, control);
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr,
|
|
|
|
u64 seq, unsigned flags)
|
|
|
|
{
|
|
|
|
bool write64bit = flags & AMDGPU_FENCE_FLAG_64BIT;
|
|
|
|
bool int_sel = flags & AMDGPU_FENCE_FLAG_INT;
|
2018-04-04 01:05:03 +08:00
|
|
|
bool writeback = flags & AMDGPU_FENCE_FLAG_TC_WB_ONLY;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* RELEASE_MEM - flush caches, send int */
|
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_RELEASE_MEM, 6));
|
2018-04-04 01:05:03 +08:00
|
|
|
amdgpu_ring_write(ring, ((writeback ? (EOP_TC_WB_ACTION_EN |
|
|
|
|
EOP_TC_NC_ACTION_EN) :
|
|
|
|
(EOP_TCL1_ACTION_EN |
|
|
|
|
EOP_TC_ACTION_EN |
|
|
|
|
EOP_TC_WB_ACTION_EN |
|
|
|
|
EOP_TC_MD_ACTION_EN)) |
|
2017-03-04 06:59:39 +08:00
|
|
|
EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT) |
|
|
|
|
EVENT_INDEX(5)));
|
|
|
|
amdgpu_ring_write(ring, DATA_SEL(write64bit ? 2 : 1) | INT_SEL(int_sel ? 2 : 0));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* the address should be Qword aligned if 64bit write, Dword
|
|
|
|
* aligned if only send 32bit data low (discard data high)
|
|
|
|
*/
|
|
|
|
if (write64bit)
|
|
|
|
BUG_ON(addr & 0x7);
|
|
|
|
else
|
|
|
|
BUG_ON(addr & 0x3);
|
|
|
|
amdgpu_ring_write(ring, lower_32_bits(addr));
|
|
|
|
amdgpu_ring_write(ring, upper_32_bits(addr));
|
|
|
|
amdgpu_ring_write(ring, lower_32_bits(seq));
|
|
|
|
amdgpu_ring_write(ring, upper_32_bits(seq));
|
|
|
|
amdgpu_ring_write(ring, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_ring_emit_pipeline_sync(struct amdgpu_ring *ring)
|
|
|
|
{
|
|
|
|
int usepfp = (ring->funcs->type == AMDGPU_RING_TYPE_GFX);
|
|
|
|
uint32_t seq = ring->fence_drv.sync_seq;
|
|
|
|
uint64_t addr = ring->fence_drv.gpu_addr;
|
|
|
|
|
|
|
|
gfx_v9_0_wait_reg_mem(ring, usepfp, 1, 0,
|
|
|
|
lower_32_bits(addr), upper_32_bits(addr),
|
|
|
|
seq, 0xffffffff, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
|
2018-02-04 17:32:35 +08:00
|
|
|
unsigned vmid, uint64_t pd_addr)
|
2017-03-04 06:59:39 +08:00
|
|
|
{
|
2018-02-04 17:32:35 +08:00
|
|
|
amdgpu_gmc_emit_flush_gpu_tlb(ring, vmid, pd_addr);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
/* compute doesn't have PFP */
|
2018-01-13 04:57:53 +08:00
|
|
|
if (ring->funcs->type == AMDGPU_RING_TYPE_GFX) {
|
2017-03-04 06:59:39 +08:00
|
|
|
/* sync PFP to ME, otherwise we might get invalid PFP reads */
|
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_PFP_SYNC_ME, 0));
|
|
|
|
amdgpu_ring_write(ring, 0x0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static u64 gfx_v9_0_ring_get_rptr_compute(struct amdgpu_ring *ring)
|
|
|
|
{
|
|
|
|
return ring->adev->wb.wb[ring->rptr_offs]; /* gfx9 hardware is 32bit rptr */
|
|
|
|
}
|
|
|
|
|
|
|
|
static u64 gfx_v9_0_ring_get_wptr_compute(struct amdgpu_ring *ring)
|
|
|
|
{
|
|
|
|
u64 wptr;
|
|
|
|
|
|
|
|
/* XXX check if swapping is necessary on BE */
|
|
|
|
if (ring->use_doorbell)
|
|
|
|
wptr = atomic64_read((atomic64_t *)&ring->adev->wb.wb[ring->wptr_offs]);
|
|
|
|
else
|
|
|
|
BUG();
|
|
|
|
return wptr;
|
|
|
|
}
|
|
|
|
|
2018-01-03 04:49:40 +08:00
|
|
|
static void gfx_v9_0_ring_set_pipe_percent(struct amdgpu_ring *ring,
|
|
|
|
bool acquire)
|
|
|
|
{
|
|
|
|
struct amdgpu_device *adev = ring->adev;
|
|
|
|
int pipe_num, tmp, reg;
|
|
|
|
int pipe_percent = acquire ? SPI_WCL_PIPE_PERCENT_GFX__VALUE_MASK : 0x1;
|
|
|
|
|
|
|
|
pipe_num = ring->me * adev->gfx.mec.num_pipe_per_mec + ring->pipe;
|
|
|
|
|
|
|
|
/* first me only has 2 entries, GFX and HP3D */
|
|
|
|
if (ring->me > 0)
|
|
|
|
pipe_num -= 2;
|
|
|
|
|
|
|
|
reg = SOC15_REG_OFFSET(GC, 0, mmSPI_WCL_PIPE_PERCENT_GFX) + pipe_num;
|
|
|
|
tmp = RREG32(reg);
|
|
|
|
tmp = REG_SET_FIELD(tmp, SPI_WCL_PIPE_PERCENT_GFX, VALUE, pipe_percent);
|
|
|
|
WREG32(reg, tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_pipe_reserve_resources(struct amdgpu_device *adev,
|
|
|
|
struct amdgpu_ring *ring,
|
|
|
|
bool acquire)
|
|
|
|
{
|
|
|
|
int i, pipe;
|
|
|
|
bool reserve;
|
|
|
|
struct amdgpu_ring *iring;
|
|
|
|
|
|
|
|
mutex_lock(&adev->gfx.pipe_reserve_mutex);
|
|
|
|
pipe = amdgpu_gfx_queue_to_bit(adev, ring->me, ring->pipe, 0);
|
|
|
|
if (acquire)
|
|
|
|
set_bit(pipe, adev->gfx.pipe_reserve_bitmap);
|
|
|
|
else
|
|
|
|
clear_bit(pipe, adev->gfx.pipe_reserve_bitmap);
|
|
|
|
|
|
|
|
if (!bitmap_weight(adev->gfx.pipe_reserve_bitmap, AMDGPU_MAX_COMPUTE_QUEUES)) {
|
|
|
|
/* Clear all reservations - everyone reacquires all resources */
|
|
|
|
for (i = 0; i < adev->gfx.num_gfx_rings; ++i)
|
|
|
|
gfx_v9_0_ring_set_pipe_percent(&adev->gfx.gfx_ring[i],
|
|
|
|
true);
|
|
|
|
|
|
|
|
for (i = 0; i < adev->gfx.num_compute_rings; ++i)
|
|
|
|
gfx_v9_0_ring_set_pipe_percent(&adev->gfx.compute_ring[i],
|
|
|
|
true);
|
|
|
|
} else {
|
|
|
|
/* Lower all pipes without a current reservation */
|
|
|
|
for (i = 0; i < adev->gfx.num_gfx_rings; ++i) {
|
|
|
|
iring = &adev->gfx.gfx_ring[i];
|
|
|
|
pipe = amdgpu_gfx_queue_to_bit(adev,
|
|
|
|
iring->me,
|
|
|
|
iring->pipe,
|
|
|
|
0);
|
|
|
|
reserve = test_bit(pipe, adev->gfx.pipe_reserve_bitmap);
|
|
|
|
gfx_v9_0_ring_set_pipe_percent(iring, reserve);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < adev->gfx.num_compute_rings; ++i) {
|
|
|
|
iring = &adev->gfx.compute_ring[i];
|
|
|
|
pipe = amdgpu_gfx_queue_to_bit(adev,
|
|
|
|
iring->me,
|
|
|
|
iring->pipe,
|
|
|
|
0);
|
|
|
|
reserve = test_bit(pipe, adev->gfx.pipe_reserve_bitmap);
|
|
|
|
gfx_v9_0_ring_set_pipe_percent(iring, reserve);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_unlock(&adev->gfx.pipe_reserve_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_hqd_set_priority(struct amdgpu_device *adev,
|
|
|
|
struct amdgpu_ring *ring,
|
|
|
|
bool acquire)
|
|
|
|
{
|
|
|
|
uint32_t pipe_priority = acquire ? 0x2 : 0x0;
|
|
|
|
uint32_t queue_priority = acquire ? 0xf : 0x0;
|
|
|
|
|
|
|
|
mutex_lock(&adev->srbm_mutex);
|
|
|
|
soc15_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
|
|
|
|
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_PIPE_PRIORITY, pipe_priority);
|
|
|
|
WREG32_SOC15(GC, 0, mmCP_HQD_QUEUE_PRIORITY, queue_priority);
|
|
|
|
|
|
|
|
soc15_grbm_select(adev, 0, 0, 0, 0);
|
|
|
|
mutex_unlock(&adev->srbm_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_ring_set_priority_compute(struct amdgpu_ring *ring,
|
|
|
|
enum drm_sched_priority priority)
|
|
|
|
{
|
|
|
|
struct amdgpu_device *adev = ring->adev;
|
|
|
|
bool acquire = priority == DRM_SCHED_PRIORITY_HIGH_HW;
|
|
|
|
|
|
|
|
if (ring->funcs->type != AMDGPU_RING_TYPE_COMPUTE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gfx_v9_0_hqd_set_priority(adev, ring, acquire);
|
|
|
|
gfx_v9_0_pipe_reserve_resources(adev, ring, acquire);
|
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
static void gfx_v9_0_ring_set_wptr_compute(struct amdgpu_ring *ring)
|
|
|
|
{
|
|
|
|
struct amdgpu_device *adev = ring->adev;
|
|
|
|
|
|
|
|
/* XXX check if swapping is necessary on BE */
|
|
|
|
if (ring->use_doorbell) {
|
|
|
|
atomic64_set((atomic64_t*)&adev->wb.wb[ring->wptr_offs], ring->wptr);
|
|
|
|
WDOORBELL64(ring->doorbell_index, ring->wptr);
|
|
|
|
} else{
|
|
|
|
BUG(); /* only DOORBELL method supported on gfx9 now */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-13 16:36:17 +08:00
|
|
|
static void gfx_v9_0_ring_emit_fence_kiq(struct amdgpu_ring *ring, u64 addr,
|
|
|
|
u64 seq, unsigned int flags)
|
|
|
|
{
|
2017-11-30 02:51:32 +08:00
|
|
|
struct amdgpu_device *adev = ring->adev;
|
|
|
|
|
2017-02-13 16:36:17 +08:00
|
|
|
/* we only allocate 32bit for each seq wb address */
|
|
|
|
BUG_ON(flags & AMDGPU_FENCE_FLAG_64BIT);
|
|
|
|
|
|
|
|
/* write fence seq to the "addr" */
|
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
|
|
|
|
amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |
|
|
|
|
WRITE_DATA_DST_SEL(5) | WR_CONFIRM));
|
|
|
|
amdgpu_ring_write(ring, lower_32_bits(addr));
|
|
|
|
amdgpu_ring_write(ring, upper_32_bits(addr));
|
|
|
|
amdgpu_ring_write(ring, lower_32_bits(seq));
|
|
|
|
|
|
|
|
if (flags & AMDGPU_FENCE_FLAG_INT) {
|
|
|
|
/* set register to trigger INT */
|
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
|
|
|
|
amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |
|
|
|
|
WRITE_DATA_DST_SEL(0) | WR_CONFIRM));
|
|
|
|
amdgpu_ring_write(ring, SOC15_REG_OFFSET(GC, 0, mmCPC_INT_STATUS));
|
|
|
|
amdgpu_ring_write(ring, 0);
|
|
|
|
amdgpu_ring_write(ring, 0x20000000); /* src_id is 178 */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
static void gfx_v9_ring_emit_sb(struct amdgpu_ring *ring)
|
|
|
|
{
|
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));
|
|
|
|
amdgpu_ring_write(ring, 0);
|
|
|
|
}
|
|
|
|
|
2017-03-07 13:56:03 +08:00
|
|
|
static void gfx_v9_0_ring_emit_ce_meta(struct amdgpu_ring *ring)
|
|
|
|
{
|
2017-09-29 08:12:53 +08:00
|
|
|
struct v9_ce_ib_state ce_payload = {0};
|
2017-03-07 13:56:03 +08:00
|
|
|
uint64_t csa_addr;
|
|
|
|
int cnt;
|
|
|
|
|
|
|
|
cnt = (sizeof(ce_payload) >> 2) + 4 - 2;
|
2018-01-22 18:25:48 +08:00
|
|
|
csa_addr = amdgpu_csa_vaddr(ring->adev);
|
2017-03-07 13:56:03 +08:00
|
|
|
|
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt));
|
|
|
|
amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(2) |
|
|
|
|
WRITE_DATA_DST_SEL(8) |
|
|
|
|
WR_CONFIRM) |
|
|
|
|
WRITE_DATA_CACHE_POLICY(0));
|
|
|
|
amdgpu_ring_write(ring, lower_32_bits(csa_addr + offsetof(struct v9_gfx_meta_data, ce_payload)));
|
|
|
|
amdgpu_ring_write(ring, upper_32_bits(csa_addr + offsetof(struct v9_gfx_meta_data, ce_payload)));
|
|
|
|
amdgpu_ring_write_multiple(ring, (void *)&ce_payload, sizeof(ce_payload) >> 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring *ring)
|
|
|
|
{
|
2017-09-29 08:12:53 +08:00
|
|
|
struct v9_de_ib_state de_payload = {0};
|
2017-03-07 13:56:03 +08:00
|
|
|
uint64_t csa_addr, gds_addr;
|
|
|
|
int cnt;
|
|
|
|
|
2018-01-22 18:25:48 +08:00
|
|
|
csa_addr = amdgpu_csa_vaddr(ring->adev);
|
2017-03-07 13:56:03 +08:00
|
|
|
gds_addr = csa_addr + 4096;
|
|
|
|
de_payload.gds_backup_addrlo = lower_32_bits(gds_addr);
|
|
|
|
de_payload.gds_backup_addrhi = upper_32_bits(gds_addr);
|
|
|
|
|
|
|
|
cnt = (sizeof(de_payload) >> 2) + 4 - 2;
|
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt));
|
|
|
|
amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) |
|
|
|
|
WRITE_DATA_DST_SEL(8) |
|
|
|
|
WR_CONFIRM) |
|
|
|
|
WRITE_DATA_CACHE_POLICY(0));
|
|
|
|
amdgpu_ring_write(ring, lower_32_bits(csa_addr + offsetof(struct v9_gfx_meta_data, de_payload)));
|
|
|
|
amdgpu_ring_write(ring, upper_32_bits(csa_addr + offsetof(struct v9_gfx_meta_data, de_payload)));
|
|
|
|
amdgpu_ring_write_multiple(ring, (void *)&de_payload, sizeof(de_payload) >> 2);
|
|
|
|
}
|
|
|
|
|
2017-06-09 15:04:49 +08:00
|
|
|
static void gfx_v9_0_ring_emit_tmz(struct amdgpu_ring *ring, bool start)
|
|
|
|
{
|
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_FRAME_CONTROL, 0));
|
|
|
|
amdgpu_ring_write(ring, FRAME_CMD(start ? 0 : 1)); /* frame_end */
|
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
static void gfx_v9_ring_emit_cntxcntl(struct amdgpu_ring *ring, uint32_t flags)
|
|
|
|
{
|
|
|
|
uint32_t dw2 = 0;
|
|
|
|
|
2017-03-07 13:56:03 +08:00
|
|
|
if (amdgpu_sriov_vf(ring->adev))
|
|
|
|
gfx_v9_0_ring_emit_ce_meta(ring);
|
|
|
|
|
2017-06-09 15:04:49 +08:00
|
|
|
gfx_v9_0_ring_emit_tmz(ring, true);
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
dw2 |= 0x80000000; /* set load_enable otherwise this package is just NOPs */
|
|
|
|
if (flags & AMDGPU_HAVE_CTX_SWITCH) {
|
|
|
|
/* set load_global_config & load_global_uconfig */
|
|
|
|
dw2 |= 0x8001;
|
|
|
|
/* set load_cs_sh_regs */
|
|
|
|
dw2 |= 0x01000000;
|
|
|
|
/* set load_per_context_state & load_gfx_sh_regs for GFX */
|
|
|
|
dw2 |= 0x10002;
|
|
|
|
|
|
|
|
/* set load_ce_ram if preamble presented */
|
|
|
|
if (AMDGPU_PREAMBLE_IB_PRESENT & flags)
|
|
|
|
dw2 |= 0x10000000;
|
|
|
|
} else {
|
|
|
|
/* still load_ce_ram if this is the first time preamble presented
|
|
|
|
* although there is no context switch happens.
|
|
|
|
*/
|
|
|
|
if (AMDGPU_PREAMBLE_IB_PRESENT_FIRST & flags)
|
|
|
|
dw2 |= 0x10000000;
|
|
|
|
}
|
|
|
|
|
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_CONTEXT_CONTROL, 1));
|
|
|
|
amdgpu_ring_write(ring, dw2);
|
|
|
|
amdgpu_ring_write(ring, 0);
|
|
|
|
}
|
|
|
|
|
2016-11-18 17:16:36 +08:00
|
|
|
static unsigned gfx_v9_0_ring_emit_init_cond_exec(struct amdgpu_ring *ring)
|
|
|
|
{
|
|
|
|
unsigned ret;
|
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_COND_EXEC, 3));
|
|
|
|
amdgpu_ring_write(ring, lower_32_bits(ring->cond_exe_gpu_addr));
|
|
|
|
amdgpu_ring_write(ring, upper_32_bits(ring->cond_exe_gpu_addr));
|
|
|
|
amdgpu_ring_write(ring, 0); /* discard following DWs if *cond_exec_gpu_addr==0 */
|
|
|
|
ret = ring->wptr & ring->buf_mask;
|
|
|
|
amdgpu_ring_write(ring, 0x55aa55aa); /* patch dummy value later */
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_ring_emit_patch_cond_exec(struct amdgpu_ring *ring, unsigned offset)
|
|
|
|
{
|
|
|
|
unsigned cur;
|
|
|
|
BUG_ON(offset > ring->buf_mask);
|
|
|
|
BUG_ON(ring->ring[offset] != 0x55aa55aa);
|
|
|
|
|
|
|
|
cur = (ring->wptr & ring->buf_mask) - 1;
|
|
|
|
if (likely(cur > offset))
|
|
|
|
ring->ring[offset] = cur - offset;
|
|
|
|
else
|
|
|
|
ring->ring[offset] = (ring->ring_size>>2) - offset + cur;
|
|
|
|
}
|
|
|
|
|
2017-02-13 16:36:17 +08:00
|
|
|
static void gfx_v9_0_ring_emit_rreg(struct amdgpu_ring *ring, uint32_t reg)
|
|
|
|
{
|
|
|
|
struct amdgpu_device *adev = ring->adev;
|
|
|
|
|
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_COPY_DATA, 4));
|
|
|
|
amdgpu_ring_write(ring, 0 | /* src: register*/
|
|
|
|
(5 << 8) | /* dst: memory */
|
|
|
|
(1 << 20)); /* write confirm */
|
|
|
|
amdgpu_ring_write(ring, reg);
|
|
|
|
amdgpu_ring_write(ring, 0);
|
|
|
|
amdgpu_ring_write(ring, lower_32_bits(adev->wb.gpu_addr +
|
|
|
|
adev->virt.reg_val_offs * 4));
|
|
|
|
amdgpu_ring_write(ring, upper_32_bits(adev->wb.gpu_addr +
|
|
|
|
adev->virt.reg_val_offs * 4));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_ring_emit_wreg(struct amdgpu_ring *ring, uint32_t reg,
|
2018-01-12 21:30:41 +08:00
|
|
|
uint32_t val)
|
2017-02-13 16:36:17 +08:00
|
|
|
{
|
2018-01-12 21:30:41 +08:00
|
|
|
uint32_t cmd = 0;
|
|
|
|
|
|
|
|
switch (ring->funcs->type) {
|
|
|
|
case AMDGPU_RING_TYPE_GFX:
|
|
|
|
cmd = WRITE_DATA_ENGINE_SEL(1) | WR_CONFIRM;
|
|
|
|
break;
|
|
|
|
case AMDGPU_RING_TYPE_KIQ:
|
|
|
|
cmd = (1 << 16); /* no inc addr */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
cmd = WR_CONFIRM;
|
|
|
|
break;
|
|
|
|
}
|
2017-02-13 16:36:17 +08:00
|
|
|
amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
|
2018-01-12 21:30:41 +08:00
|
|
|
amdgpu_ring_write(ring, cmd);
|
2017-02-13 16:36:17 +08:00
|
|
|
amdgpu_ring_write(ring, reg);
|
|
|
|
amdgpu_ring_write(ring, 0);
|
|
|
|
amdgpu_ring_write(ring, val);
|
|
|
|
}
|
|
|
|
|
2018-01-26 20:08:18 +08:00
|
|
|
static void gfx_v9_0_ring_emit_reg_wait(struct amdgpu_ring *ring, uint32_t reg,
|
|
|
|
uint32_t val, uint32_t mask)
|
|
|
|
{
|
|
|
|
gfx_v9_0_wait_reg_mem(ring, 0, 0, 0, reg, 0, val, mask, 0x20);
|
|
|
|
}
|
|
|
|
|
2018-03-28 04:07:50 +08:00
|
|
|
static void gfx_v9_0_ring_emit_reg_write_reg_wait(struct amdgpu_ring *ring,
|
|
|
|
uint32_t reg0, uint32_t reg1,
|
|
|
|
uint32_t ref, uint32_t mask)
|
|
|
|
{
|
|
|
|
int usepfp = (ring->funcs->type == AMDGPU_RING_TYPE_GFX);
|
2018-08-17 18:26:41 +08:00
|
|
|
struct amdgpu_device *adev = ring->adev;
|
|
|
|
bool fw_version_ok = (ring->funcs->type == AMDGPU_RING_TYPE_GFX) ?
|
|
|
|
adev->gfx.me_fw_write_wait : adev->gfx.mec_fw_write_wait;
|
2018-03-28 04:07:50 +08:00
|
|
|
|
2018-08-17 18:26:41 +08:00
|
|
|
if (fw_version_ok)
|
2018-04-17 20:47:42 +08:00
|
|
|
gfx_v9_0_wait_reg_mem(ring, usepfp, 0, 1, reg0, reg1,
|
|
|
|
ref, mask, 0x20);
|
|
|
|
else
|
|
|
|
amdgpu_ring_emit_reg_write_reg_wait_helper(ring, reg0, reg1,
|
|
|
|
ref, mask);
|
2018-03-28 04:07:50 +08:00
|
|
|
}
|
|
|
|
|
2018-08-22 18:04:11 +08:00
|
|
|
static void gfx_v9_0_ring_soft_recovery(struct amdgpu_ring *ring, unsigned vmid)
|
|
|
|
{
|
|
|
|
struct amdgpu_device *adev = ring->adev;
|
|
|
|
uint32_t value = 0;
|
|
|
|
|
|
|
|
value = REG_SET_FIELD(value, SQ_CMD, CMD, 0x03);
|
|
|
|
value = REG_SET_FIELD(value, SQ_CMD, MODE, 0x01);
|
|
|
|
value = REG_SET_FIELD(value, SQ_CMD, CHECK_VMID, 1);
|
|
|
|
value = REG_SET_FIELD(value, SQ_CMD, VM_ID, vmid);
|
|
|
|
WREG32(mmSQ_CMD, value);
|
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
static void gfx_v9_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev,
|
|
|
|
enum amdgpu_interrupt_state state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
|
|
|
case AMDGPU_IRQ_STATE_DISABLE:
|
|
|
|
case AMDGPU_IRQ_STATE_ENABLE:
|
2017-04-05 20:51:02 +08:00
|
|
|
WREG32_FIELD15(GC, 0, CP_INT_CNTL_RING0,
|
|
|
|
TIME_STAMP_INT_ENABLE,
|
|
|
|
state == AMDGPU_IRQ_STATE_ENABLE ? 1 : 0);
|
2017-03-04 06:59:39 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_set_compute_eop_interrupt_state(struct amdgpu_device *adev,
|
|
|
|
int me, int pipe,
|
|
|
|
enum amdgpu_interrupt_state state)
|
|
|
|
{
|
|
|
|
u32 mec_int_cntl, mec_int_cntl_reg;
|
|
|
|
|
|
|
|
/*
|
2017-06-09 20:22:31 +08:00
|
|
|
* amdgpu controls only the first MEC. That's why this function only
|
|
|
|
* handles the setting of interrupts for this specific MEC. All other
|
2017-03-04 06:59:39 +08:00
|
|
|
* pipes' interrupts are set by amdkfd.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (me == 1) {
|
|
|
|
switch (pipe) {
|
|
|
|
case 0:
|
|
|
|
mec_int_cntl_reg = SOC15_REG_OFFSET(GC, 0, mmCP_ME1_PIPE0_INT_CNTL);
|
|
|
|
break;
|
2017-06-09 20:22:31 +08:00
|
|
|
case 1:
|
|
|
|
mec_int_cntl_reg = SOC15_REG_OFFSET(GC, 0, mmCP_ME1_PIPE1_INT_CNTL);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
mec_int_cntl_reg = SOC15_REG_OFFSET(GC, 0, mmCP_ME1_PIPE2_INT_CNTL);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
mec_int_cntl_reg = SOC15_REG_OFFSET(GC, 0, mmCP_ME1_PIPE3_INT_CNTL);
|
|
|
|
break;
|
2017-03-04 06:59:39 +08:00
|
|
|
default:
|
|
|
|
DRM_DEBUG("invalid pipe %d\n", pipe);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
DRM_DEBUG("invalid me %d\n", me);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
case AMDGPU_IRQ_STATE_DISABLE:
|
|
|
|
mec_int_cntl = RREG32(mec_int_cntl_reg);
|
|
|
|
mec_int_cntl = REG_SET_FIELD(mec_int_cntl, CP_ME1_PIPE0_INT_CNTL,
|
|
|
|
TIME_STAMP_INT_ENABLE, 0);
|
|
|
|
WREG32(mec_int_cntl_reg, mec_int_cntl);
|
|
|
|
break;
|
|
|
|
case AMDGPU_IRQ_STATE_ENABLE:
|
|
|
|
mec_int_cntl = RREG32(mec_int_cntl_reg);
|
|
|
|
mec_int_cntl = REG_SET_FIELD(mec_int_cntl, CP_ME1_PIPE0_INT_CNTL,
|
|
|
|
TIME_STAMP_INT_ENABLE, 1);
|
|
|
|
WREG32(mec_int_cntl_reg, mec_int_cntl);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_set_priv_reg_fault_state(struct amdgpu_device *adev,
|
|
|
|
struct amdgpu_irq_src *source,
|
|
|
|
unsigned type,
|
|
|
|
enum amdgpu_interrupt_state state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
|
|
|
case AMDGPU_IRQ_STATE_DISABLE:
|
|
|
|
case AMDGPU_IRQ_STATE_ENABLE:
|
2017-04-05 20:49:00 +08:00
|
|
|
WREG32_FIELD15(GC, 0, CP_INT_CNTL_RING0,
|
|
|
|
PRIV_REG_INT_ENABLE,
|
|
|
|
state == AMDGPU_IRQ_STATE_ENABLE ? 1 : 0);
|
2017-03-04 06:59:39 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_set_priv_inst_fault_state(struct amdgpu_device *adev,
|
|
|
|
struct amdgpu_irq_src *source,
|
|
|
|
unsigned type,
|
|
|
|
enum amdgpu_interrupt_state state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
|
|
|
case AMDGPU_IRQ_STATE_DISABLE:
|
|
|
|
case AMDGPU_IRQ_STATE_ENABLE:
|
2017-04-05 20:46:12 +08:00
|
|
|
WREG32_FIELD15(GC, 0, CP_INT_CNTL_RING0,
|
|
|
|
PRIV_INSTR_INT_ENABLE,
|
|
|
|
state == AMDGPU_IRQ_STATE_ENABLE ? 1 : 0);
|
2017-03-04 06:59:39 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_set_eop_interrupt_state(struct amdgpu_device *adev,
|
|
|
|
struct amdgpu_irq_src *src,
|
|
|
|
unsigned type,
|
|
|
|
enum amdgpu_interrupt_state state)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case AMDGPU_CP_IRQ_GFX_EOP:
|
|
|
|
gfx_v9_0_set_gfx_eop_interrupt_state(adev, state);
|
|
|
|
break;
|
|
|
|
case AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP:
|
|
|
|
gfx_v9_0_set_compute_eop_interrupt_state(adev, 1, 0, state);
|
|
|
|
break;
|
|
|
|
case AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE1_EOP:
|
|
|
|
gfx_v9_0_set_compute_eop_interrupt_state(adev, 1, 1, state);
|
|
|
|
break;
|
|
|
|
case AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE2_EOP:
|
|
|
|
gfx_v9_0_set_compute_eop_interrupt_state(adev, 1, 2, state);
|
|
|
|
break;
|
|
|
|
case AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE3_EOP:
|
|
|
|
gfx_v9_0_set_compute_eop_interrupt_state(adev, 1, 3, state);
|
|
|
|
break;
|
|
|
|
case AMDGPU_CP_IRQ_COMPUTE_MEC2_PIPE0_EOP:
|
|
|
|
gfx_v9_0_set_compute_eop_interrupt_state(adev, 2, 0, state);
|
|
|
|
break;
|
|
|
|
case AMDGPU_CP_IRQ_COMPUTE_MEC2_PIPE1_EOP:
|
|
|
|
gfx_v9_0_set_compute_eop_interrupt_state(adev, 2, 1, state);
|
|
|
|
break;
|
|
|
|
case AMDGPU_CP_IRQ_COMPUTE_MEC2_PIPE2_EOP:
|
|
|
|
gfx_v9_0_set_compute_eop_interrupt_state(adev, 2, 2, state);
|
|
|
|
break;
|
|
|
|
case AMDGPU_CP_IRQ_COMPUTE_MEC2_PIPE3_EOP:
|
|
|
|
gfx_v9_0_set_compute_eop_interrupt_state(adev, 2, 3, state);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_eop_irq(struct amdgpu_device *adev,
|
|
|
|
struct amdgpu_irq_src *source,
|
|
|
|
struct amdgpu_iv_entry *entry)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u8 me_id, pipe_id, queue_id;
|
|
|
|
struct amdgpu_ring *ring;
|
|
|
|
|
|
|
|
DRM_DEBUG("IH: CP EOP\n");
|
|
|
|
me_id = (entry->ring_id & 0x0c) >> 2;
|
|
|
|
pipe_id = (entry->ring_id & 0x03) >> 0;
|
|
|
|
queue_id = (entry->ring_id & 0x70) >> 4;
|
|
|
|
|
|
|
|
switch (me_id) {
|
|
|
|
case 0:
|
|
|
|
amdgpu_fence_process(&adev->gfx.gfx_ring[0]);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
for (i = 0; i < adev->gfx.num_compute_rings; i++) {
|
|
|
|
ring = &adev->gfx.compute_ring[i];
|
|
|
|
/* Per-queue interrupt is supported for MEC starting from VI.
|
|
|
|
* The interrupt can only be enabled/disabled per pipe instead of per queue.
|
|
|
|
*/
|
|
|
|
if ((ring->me == me_id) && (ring->pipe == pipe_id) && (ring->queue == queue_id))
|
|
|
|
amdgpu_fence_process(ring);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-16 19:08:21 +08:00
|
|
|
static void gfx_v9_0_fault(struct amdgpu_device *adev,
|
|
|
|
struct amdgpu_iv_entry *entry)
|
|
|
|
{
|
|
|
|
u8 me_id, pipe_id, queue_id;
|
|
|
|
struct amdgpu_ring *ring;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
me_id = (entry->ring_id & 0x0c) >> 2;
|
|
|
|
pipe_id = (entry->ring_id & 0x03) >> 0;
|
|
|
|
queue_id = (entry->ring_id & 0x70) >> 4;
|
|
|
|
|
|
|
|
switch (me_id) {
|
|
|
|
case 0:
|
|
|
|
drm_sched_fault(&adev->gfx.gfx_ring[0].sched);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
for (i = 0; i < adev->gfx.num_compute_rings; i++) {
|
|
|
|
ring = &adev->gfx.compute_ring[i];
|
|
|
|
if (ring->me == me_id && ring->pipe == pipe_id &&
|
|
|
|
ring->queue == queue_id)
|
|
|
|
drm_sched_fault(&ring->sched);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
static int gfx_v9_0_priv_reg_irq(struct amdgpu_device *adev,
|
|
|
|
struct amdgpu_irq_src *source,
|
|
|
|
struct amdgpu_iv_entry *entry)
|
|
|
|
{
|
|
|
|
DRM_ERROR("Illegal register access in command stream\n");
|
2018-10-16 19:08:21 +08:00
|
|
|
gfx_v9_0_fault(adev, entry);
|
2017-03-04 06:59:39 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_priv_inst_irq(struct amdgpu_device *adev,
|
|
|
|
struct amdgpu_irq_src *source,
|
|
|
|
struct amdgpu_iv_entry *entry)
|
|
|
|
{
|
|
|
|
DRM_ERROR("Illegal instruction in command stream\n");
|
2018-10-16 19:08:21 +08:00
|
|
|
gfx_v9_0_fault(adev, entry);
|
2017-03-04 06:59:39 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-08-04 16:56:38 +08:00
|
|
|
static const struct amd_ip_funcs gfx_v9_0_ip_funcs = {
|
2017-03-04 06:59:39 +08:00
|
|
|
.name = "gfx_v9_0",
|
|
|
|
.early_init = gfx_v9_0_early_init,
|
|
|
|
.late_init = gfx_v9_0_late_init,
|
|
|
|
.sw_init = gfx_v9_0_sw_init,
|
|
|
|
.sw_fini = gfx_v9_0_sw_fini,
|
|
|
|
.hw_init = gfx_v9_0_hw_init,
|
|
|
|
.hw_fini = gfx_v9_0_hw_fini,
|
|
|
|
.suspend = gfx_v9_0_suspend,
|
|
|
|
.resume = gfx_v9_0_resume,
|
|
|
|
.is_idle = gfx_v9_0_is_idle,
|
|
|
|
.wait_for_idle = gfx_v9_0_wait_for_idle,
|
|
|
|
.soft_reset = gfx_v9_0_soft_reset,
|
|
|
|
.set_clockgating_state = gfx_v9_0_set_clockgating_state,
|
|
|
|
.set_powergating_state = gfx_v9_0_set_powergating_state,
|
2017-03-24 09:58:11 +08:00
|
|
|
.get_clockgating_state = gfx_v9_0_get_clockgating_state,
|
2017-03-04 06:59:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct amdgpu_ring_funcs gfx_v9_0_ring_funcs_gfx = {
|
|
|
|
.type = AMDGPU_RING_TYPE_GFX,
|
|
|
|
.align_mask = 0xff,
|
|
|
|
.nop = PACKET3(PACKET3_NOP, 0x3FFF),
|
|
|
|
.support_64bit_ptrs = true,
|
2017-03-30 20:49:50 +08:00
|
|
|
.vmhub = AMDGPU_GFXHUB,
|
2017-03-04 06:59:39 +08:00
|
|
|
.get_rptr = gfx_v9_0_ring_get_rptr_gfx,
|
|
|
|
.get_wptr = gfx_v9_0_ring_get_wptr_gfx,
|
|
|
|
.set_wptr = gfx_v9_0_ring_set_wptr_gfx,
|
drm/amdgpu:changes in gfx DMAframe scheme (v2)
1) Adapt to vulkan:
Now use double SWITCH BUFFER to replace the 128 nops w/a,
because when vulkan introduced, umd can insert 7 ~ 16 IBs
per submit which makes 256 DW size cannot hold the whole
DMAframe (if we still insert those 128 nops), CP team suggests
use double SWITCH_BUFFERs, instead of tricky 128 NOPs w/a.
2) To fix the CE VM fault issue when MCBP introduced:
Need one more COND_EXEC wrapping IB part (original one us
for VM switch part).
this change can fix vm fault issue caused by below scenario
without this change:
>CE passed original COND_EXEC (no MCBP issued this moment),
proceed as normal.
>DE catch up to this COND_EXEC, but this time MCBP issued,
thus DE treats all following packages as NOP. The following
VM switch packages now looks just as NOP to DE, so DE
dosen't do VM flush at all.
>Now CE proceeds to the first IBc, and triggers VM fault,
because DE didn't do VM flush for this DMAframe.
3) change estimated alloc size for gfx9.
with new DMAframe scheme, we need modify emit_frame_size
for gfx9
4) No need to insert 128 nops after gfx8 vm flush anymore
because there was double SWITCH_BUFFER append to vm flush,
and for gfx7 we already use double SWITCH_BUFFER following
after vm_flush so no change needed for it.
5) Change emit_frame_size for gfx8
v2: squash in BUG removal from Monk
Signed-off-by: Monk Liu <Monk.Liu@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-15 12:18:57 +08:00
|
|
|
.emit_frame_size = /* totally 242 maximum if 16 IBs */
|
|
|
|
5 + /* COND_EXEC */
|
|
|
|
7 + /* PIPELINE_SYNC */
|
2018-01-26 22:00:43 +08:00
|
|
|
SOC15_FLUSH_GPU_TLB_NUM_WREG * 5 +
|
|
|
|
SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 7 +
|
|
|
|
2 + /* VM_FLUSH */
|
drm/amdgpu:changes in gfx DMAframe scheme (v2)
1) Adapt to vulkan:
Now use double SWITCH BUFFER to replace the 128 nops w/a,
because when vulkan introduced, umd can insert 7 ~ 16 IBs
per submit which makes 256 DW size cannot hold the whole
DMAframe (if we still insert those 128 nops), CP team suggests
use double SWITCH_BUFFERs, instead of tricky 128 NOPs w/a.
2) To fix the CE VM fault issue when MCBP introduced:
Need one more COND_EXEC wrapping IB part (original one us
for VM switch part).
this change can fix vm fault issue caused by below scenario
without this change:
>CE passed original COND_EXEC (no MCBP issued this moment),
proceed as normal.
>DE catch up to this COND_EXEC, but this time MCBP issued,
thus DE treats all following packages as NOP. The following
VM switch packages now looks just as NOP to DE, so DE
dosen't do VM flush at all.
>Now CE proceeds to the first IBc, and triggers VM fault,
because DE didn't do VM flush for this DMAframe.
3) change estimated alloc size for gfx9.
with new DMAframe scheme, we need modify emit_frame_size
for gfx9
4) No need to insert 128 nops after gfx8 vm flush anymore
because there was double SWITCH_BUFFER append to vm flush,
and for gfx7 we already use double SWITCH_BUFFER following
after vm_flush so no change needed for it.
5) Change emit_frame_size for gfx8
v2: squash in BUG removal from Monk
Signed-off-by: Monk Liu <Monk.Liu@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-15 12:18:57 +08:00
|
|
|
8 + /* FENCE for VM_FLUSH */
|
|
|
|
20 + /* GDS switch */
|
|
|
|
4 + /* double SWITCH_BUFFER,
|
|
|
|
the first COND_EXEC jump to the place just
|
|
|
|
prior to this double SWITCH_BUFFER */
|
|
|
|
5 + /* COND_EXEC */
|
|
|
|
7 + /* HDP_flush */
|
|
|
|
4 + /* VGT_flush */
|
|
|
|
14 + /* CE_META */
|
|
|
|
31 + /* DE_META */
|
|
|
|
3 + /* CNTX_CTRL */
|
|
|
|
5 + /* HDP_INVL */
|
|
|
|
8 + 8 + /* FENCE x2 */
|
|
|
|
2, /* SWITCH_BUFFER */
|
2017-03-04 06:59:39 +08:00
|
|
|
.emit_ib_size = 4, /* gfx_v9_0_ring_emit_ib_gfx */
|
|
|
|
.emit_ib = gfx_v9_0_ring_emit_ib_gfx,
|
|
|
|
.emit_fence = gfx_v9_0_ring_emit_fence,
|
|
|
|
.emit_pipeline_sync = gfx_v9_0_ring_emit_pipeline_sync,
|
|
|
|
.emit_vm_flush = gfx_v9_0_ring_emit_vm_flush,
|
|
|
|
.emit_gds_switch = gfx_v9_0_ring_emit_gds_switch,
|
|
|
|
.emit_hdp_flush = gfx_v9_0_ring_emit_hdp_flush,
|
|
|
|
.test_ring = gfx_v9_0_ring_test_ring,
|
|
|
|
.test_ib = gfx_v9_0_ring_test_ib,
|
|
|
|
.insert_nop = amdgpu_ring_insert_nop,
|
|
|
|
.pad_ib = amdgpu_ring_generic_pad_ib,
|
|
|
|
.emit_switch_buffer = gfx_v9_ring_emit_sb,
|
|
|
|
.emit_cntxcntl = gfx_v9_ring_emit_cntxcntl,
|
2016-11-18 17:16:36 +08:00
|
|
|
.init_cond_exec = gfx_v9_0_ring_emit_init_cond_exec,
|
|
|
|
.patch_cond_exec = gfx_v9_0_ring_emit_patch_cond_exec,
|
2017-05-01 18:09:22 +08:00
|
|
|
.emit_tmz = gfx_v9_0_ring_emit_tmz,
|
2018-01-12 21:30:41 +08:00
|
|
|
.emit_wreg = gfx_v9_0_ring_emit_wreg,
|
2018-01-26 20:08:18 +08:00
|
|
|
.emit_reg_wait = gfx_v9_0_ring_emit_reg_wait,
|
2018-03-28 04:07:50 +08:00
|
|
|
.emit_reg_write_reg_wait = gfx_v9_0_ring_emit_reg_write_reg_wait,
|
2018-08-22 18:04:11 +08:00
|
|
|
.soft_recovery = gfx_v9_0_ring_soft_recovery,
|
2017-03-04 06:59:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct amdgpu_ring_funcs gfx_v9_0_ring_funcs_compute = {
|
|
|
|
.type = AMDGPU_RING_TYPE_COMPUTE,
|
|
|
|
.align_mask = 0xff,
|
|
|
|
.nop = PACKET3(PACKET3_NOP, 0x3FFF),
|
|
|
|
.support_64bit_ptrs = true,
|
2017-03-30 20:49:50 +08:00
|
|
|
.vmhub = AMDGPU_GFXHUB,
|
2017-03-04 06:59:39 +08:00
|
|
|
.get_rptr = gfx_v9_0_ring_get_rptr_compute,
|
|
|
|
.get_wptr = gfx_v9_0_ring_get_wptr_compute,
|
|
|
|
.set_wptr = gfx_v9_0_ring_set_wptr_compute,
|
|
|
|
.emit_frame_size =
|
|
|
|
20 + /* gfx_v9_0_ring_emit_gds_switch */
|
|
|
|
7 + /* gfx_v9_0_ring_emit_hdp_flush */
|
2018-01-19 22:19:16 +08:00
|
|
|
5 + /* hdp invalidate */
|
2017-03-04 06:59:39 +08:00
|
|
|
7 + /* gfx_v9_0_ring_emit_pipeline_sync */
|
2018-01-26 22:00:43 +08:00
|
|
|
SOC15_FLUSH_GPU_TLB_NUM_WREG * 5 +
|
|
|
|
SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 7 +
|
|
|
|
2 + /* gfx_v9_0_ring_emit_vm_flush */
|
2017-03-04 06:59:39 +08:00
|
|
|
8 + 8 + 8, /* gfx_v9_0_ring_emit_fence x3 for user fence, vm fence */
|
|
|
|
.emit_ib_size = 4, /* gfx_v9_0_ring_emit_ib_compute */
|
|
|
|
.emit_ib = gfx_v9_0_ring_emit_ib_compute,
|
|
|
|
.emit_fence = gfx_v9_0_ring_emit_fence,
|
|
|
|
.emit_pipeline_sync = gfx_v9_0_ring_emit_pipeline_sync,
|
|
|
|
.emit_vm_flush = gfx_v9_0_ring_emit_vm_flush,
|
|
|
|
.emit_gds_switch = gfx_v9_0_ring_emit_gds_switch,
|
|
|
|
.emit_hdp_flush = gfx_v9_0_ring_emit_hdp_flush,
|
|
|
|
.test_ring = gfx_v9_0_ring_test_ring,
|
|
|
|
.test_ib = gfx_v9_0_ring_test_ib,
|
|
|
|
.insert_nop = amdgpu_ring_insert_nop,
|
|
|
|
.pad_ib = amdgpu_ring_generic_pad_ib,
|
2018-01-03 04:49:40 +08:00
|
|
|
.set_priority = gfx_v9_0_ring_set_priority_compute,
|
2018-01-12 21:30:41 +08:00
|
|
|
.emit_wreg = gfx_v9_0_ring_emit_wreg,
|
2018-01-26 20:08:18 +08:00
|
|
|
.emit_reg_wait = gfx_v9_0_ring_emit_reg_wait,
|
2018-03-28 04:07:50 +08:00
|
|
|
.emit_reg_write_reg_wait = gfx_v9_0_ring_emit_reg_write_reg_wait,
|
2017-03-04 06:59:39 +08:00
|
|
|
};
|
|
|
|
|
2017-02-13 16:36:17 +08:00
|
|
|
static const struct amdgpu_ring_funcs gfx_v9_0_ring_funcs_kiq = {
|
|
|
|
.type = AMDGPU_RING_TYPE_KIQ,
|
|
|
|
.align_mask = 0xff,
|
|
|
|
.nop = PACKET3(PACKET3_NOP, 0x3FFF),
|
|
|
|
.support_64bit_ptrs = true,
|
2017-03-30 20:49:50 +08:00
|
|
|
.vmhub = AMDGPU_GFXHUB,
|
2017-02-13 16:36:17 +08:00
|
|
|
.get_rptr = gfx_v9_0_ring_get_rptr_compute,
|
|
|
|
.get_wptr = gfx_v9_0_ring_get_wptr_compute,
|
|
|
|
.set_wptr = gfx_v9_0_ring_set_wptr_compute,
|
|
|
|
.emit_frame_size =
|
|
|
|
20 + /* gfx_v9_0_ring_emit_gds_switch */
|
|
|
|
7 + /* gfx_v9_0_ring_emit_hdp_flush */
|
2018-01-19 22:19:16 +08:00
|
|
|
5 + /* hdp invalidate */
|
2017-02-13 16:36:17 +08:00
|
|
|
7 + /* gfx_v9_0_ring_emit_pipeline_sync */
|
2018-01-26 22:00:43 +08:00
|
|
|
SOC15_FLUSH_GPU_TLB_NUM_WREG * 5 +
|
|
|
|
SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 7 +
|
|
|
|
2 + /* gfx_v9_0_ring_emit_vm_flush */
|
2017-02-13 16:36:17 +08:00
|
|
|
8 + 8 + 8, /* gfx_v9_0_ring_emit_fence_kiq x3 for user fence, vm fence */
|
|
|
|
.emit_ib_size = 4, /* gfx_v9_0_ring_emit_ib_compute */
|
|
|
|
.emit_fence = gfx_v9_0_ring_emit_fence_kiq,
|
|
|
|
.test_ring = gfx_v9_0_ring_test_ring,
|
|
|
|
.insert_nop = amdgpu_ring_insert_nop,
|
|
|
|
.pad_ib = amdgpu_ring_generic_pad_ib,
|
|
|
|
.emit_rreg = gfx_v9_0_ring_emit_rreg,
|
|
|
|
.emit_wreg = gfx_v9_0_ring_emit_wreg,
|
2018-01-26 20:08:18 +08:00
|
|
|
.emit_reg_wait = gfx_v9_0_ring_emit_reg_wait,
|
2018-03-28 04:07:50 +08:00
|
|
|
.emit_reg_write_reg_wait = gfx_v9_0_ring_emit_reg_write_reg_wait,
|
2017-02-13 16:36:17 +08:00
|
|
|
};
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
static void gfx_v9_0_set_ring_funcs(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2017-02-13 16:36:17 +08:00
|
|
|
adev->gfx.kiq.ring.funcs = &gfx_v9_0_ring_funcs_kiq;
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
for (i = 0; i < adev->gfx.num_gfx_rings; i++)
|
|
|
|
adev->gfx.gfx_ring[i].funcs = &gfx_v9_0_ring_funcs_gfx;
|
|
|
|
|
|
|
|
for (i = 0; i < adev->gfx.num_compute_rings; i++)
|
|
|
|
adev->gfx.compute_ring[i].funcs = &gfx_v9_0_ring_funcs_compute;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct amdgpu_irq_src_funcs gfx_v9_0_eop_irq_funcs = {
|
|
|
|
.set = gfx_v9_0_set_eop_interrupt_state,
|
|
|
|
.process = gfx_v9_0_eop_irq,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct amdgpu_irq_src_funcs gfx_v9_0_priv_reg_irq_funcs = {
|
|
|
|
.set = gfx_v9_0_set_priv_reg_fault_state,
|
|
|
|
.process = gfx_v9_0_priv_reg_irq,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct amdgpu_irq_src_funcs gfx_v9_0_priv_inst_irq_funcs = {
|
|
|
|
.set = gfx_v9_0_set_priv_inst_fault_state,
|
|
|
|
.process = gfx_v9_0_priv_inst_irq,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void gfx_v9_0_set_irq_funcs(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
adev->gfx.eop_irq.num_types = AMDGPU_CP_IRQ_LAST;
|
|
|
|
adev->gfx.eop_irq.funcs = &gfx_v9_0_eop_irq_funcs;
|
|
|
|
|
|
|
|
adev->gfx.priv_reg_irq.num_types = 1;
|
|
|
|
adev->gfx.priv_reg_irq.funcs = &gfx_v9_0_priv_reg_irq_funcs;
|
|
|
|
|
|
|
|
adev->gfx.priv_inst_irq.num_types = 1;
|
|
|
|
adev->gfx.priv_inst_irq.funcs = &gfx_v9_0_priv_inst_irq_funcs;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_set_rlc_funcs(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
switch (adev->asic_type) {
|
|
|
|
case CHIP_VEGA10:
|
2017-09-02 14:26:09 +08:00
|
|
|
case CHIP_VEGA12:
|
2018-04-20 15:51:26 +08:00
|
|
|
case CHIP_VEGA20:
|
2017-01-10 11:04:25 +08:00
|
|
|
case CHIP_RAVEN:
|
2017-03-04 06:59:39 +08:00
|
|
|
adev->gfx.rlc.funcs = &gfx_v9_0_rlc_funcs;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_v9_0_set_gds_init(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
/* init asci gds info */
|
2018-10-12 18:14:32 +08:00
|
|
|
switch (adev->asic_type) {
|
|
|
|
case CHIP_VEGA10:
|
|
|
|
case CHIP_VEGA12:
|
|
|
|
case CHIP_VEGA20:
|
|
|
|
adev->gds.mem.total_size = 0x10000;
|
|
|
|
break;
|
|
|
|
case CHIP_RAVEN:
|
|
|
|
adev->gds.mem.total_size = 0x1000;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
adev->gds.mem.total_size = 0x10000;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
adev->gds.gws.total_size = 64;
|
|
|
|
adev->gds.oa.total_size = 16;
|
|
|
|
|
|
|
|
if (adev->gds.mem.total_size == 64 * 1024) {
|
|
|
|
adev->gds.mem.gfx_partition_size = 4096;
|
|
|
|
adev->gds.mem.cs_partition_size = 4096;
|
|
|
|
|
|
|
|
adev->gds.gws.gfx_partition_size = 4;
|
|
|
|
adev->gds.gws.cs_partition_size = 4;
|
|
|
|
|
|
|
|
adev->gds.oa.gfx_partition_size = 4;
|
|
|
|
adev->gds.oa.cs_partition_size = 1;
|
|
|
|
} else {
|
|
|
|
adev->gds.mem.gfx_partition_size = 1024;
|
|
|
|
adev->gds.mem.cs_partition_size = 1024;
|
|
|
|
|
|
|
|
adev->gds.gws.gfx_partition_size = 16;
|
|
|
|
adev->gds.gws.cs_partition_size = 16;
|
|
|
|
|
|
|
|
adev->gds.oa.gfx_partition_size = 4;
|
|
|
|
adev->gds.oa.cs_partition_size = 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-14 04:10:45 +08:00
|
|
|
static void gfx_v9_0_set_user_cu_inactive_bitmap(struct amdgpu_device *adev,
|
|
|
|
u32 bitmap)
|
|
|
|
{
|
|
|
|
u32 data;
|
|
|
|
|
|
|
|
if (!bitmap)
|
|
|
|
return;
|
|
|
|
|
|
|
|
data = bitmap << GC_USER_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT;
|
|
|
|
data &= GC_USER_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK;
|
|
|
|
|
|
|
|
WREG32_SOC15(GC, 0, mmGC_USER_SHADER_ARRAY_CONFIG, data);
|
|
|
|
}
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
static u32 gfx_v9_0_get_cu_active_bitmap(struct amdgpu_device *adev)
|
|
|
|
{
|
|
|
|
u32 data, mask;
|
|
|
|
|
2017-04-07 19:53:53 +08:00
|
|
|
data = RREG32_SOC15(GC, 0, mmCC_GC_SHADER_ARRAY_CONFIG);
|
|
|
|
data |= RREG32_SOC15(GC, 0, mmGC_USER_SHADER_ARRAY_CONFIG);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
data &= CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK;
|
|
|
|
data >>= CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT;
|
|
|
|
|
2017-06-07 05:41:20 +08:00
|
|
|
mask = amdgpu_gfx_create_bitmask(adev->gfx.config.max_cu_per_sh);
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
return (~data) & mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gfx_v9_0_get_cu_info(struct amdgpu_device *adev,
|
|
|
|
struct amdgpu_cu_info *cu_info)
|
|
|
|
{
|
|
|
|
int i, j, k, counter, active_cu_number = 0;
|
|
|
|
u32 mask, bitmap, ao_bitmap, ao_cu_mask = 0;
|
2017-06-14 04:10:45 +08:00
|
|
|
unsigned disable_masks[4 * 2];
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
if (!adev || !cu_info)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2017-06-14 04:10:45 +08:00
|
|
|
amdgpu_gfx_parse_disable_cu(disable_masks, 4, 2);
|
|
|
|
|
2017-03-04 06:59:39 +08:00
|
|
|
mutex_lock(&adev->grbm_idx_mutex);
|
|
|
|
for (i = 0; i < adev->gfx.config.max_shader_engines; i++) {
|
|
|
|
for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) {
|
|
|
|
mask = 1;
|
|
|
|
ao_bitmap = 0;
|
|
|
|
counter = 0;
|
|
|
|
gfx_v9_0_select_se_sh(adev, i, j, 0xffffffff);
|
2017-06-14 04:10:45 +08:00
|
|
|
if (i < 4 && j < 2)
|
|
|
|
gfx_v9_0_set_user_cu_inactive_bitmap(
|
|
|
|
adev, disable_masks[i * 2 + j]);
|
2017-03-04 06:59:39 +08:00
|
|
|
bitmap = gfx_v9_0_get_cu_active_bitmap(adev);
|
|
|
|
cu_info->bitmap[i][j] = bitmap;
|
|
|
|
|
2017-04-26 16:32:22 +08:00
|
|
|
for (k = 0; k < adev->gfx.config.max_cu_per_sh; k ++) {
|
2017-03-04 06:59:39 +08:00
|
|
|
if (bitmap & mask) {
|
2017-04-26 16:32:22 +08:00
|
|
|
if (counter < adev->gfx.config.max_cu_per_sh)
|
2017-03-04 06:59:39 +08:00
|
|
|
ao_bitmap |= mask;
|
|
|
|
counter ++;
|
|
|
|
}
|
|
|
|
mask <<= 1;
|
|
|
|
}
|
|
|
|
active_cu_number += counter;
|
2017-06-20 11:08:35 +08:00
|
|
|
if (i < 2 && j < 2)
|
|
|
|
ao_cu_mask |= (ao_bitmap << (i * 16 + j * 8));
|
|
|
|
cu_info->ao_cu_bitmap[i][j] = ao_bitmap;
|
2017-03-04 06:59:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
gfx_v9_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
|
|
|
|
mutex_unlock(&adev->grbm_idx_mutex);
|
|
|
|
|
|
|
|
cu_info->number = active_cu_number;
|
|
|
|
cu_info->ao_cu_mask = ao_cu_mask;
|
2018-04-11 05:33:01 +08:00
|
|
|
cu_info->simd_per_cu = NUM_SIMD_PER_CU;
|
2017-03-04 06:59:39 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct amdgpu_ip_block_version gfx_v9_0_ip_block =
|
|
|
|
{
|
|
|
|
.type = AMD_IP_BLOCK_TYPE_GFX,
|
|
|
|
.major = 9,
|
|
|
|
.minor = 0,
|
|
|
|
.rev = 0,
|
|
|
|
.funcs = &gfx_v9_0_ip_funcs,
|
|
|
|
};
|