{ GEN8_RBBM_SLICE_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) },
{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL, 0x00000030, BIT(PIPE_NONE) },
{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2, 0x00000030, BIT(PIPE_NONE) },
{ GEN8_RBBM_INTERFACE_HANG_INT_CNTL, 0x0fffffff, BIT(PIPE_NONE) },
{ GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 0x22122212, BIT(PIPE_NONE) },
{ GEN8_RBBM_CGC_P2S_CNTL, 0x00000040, BIT(PIPE_NONE) },
{ GEN8_SP_CHICKEN_BITS_2, 0x00820800, BIT(PIPE_NONE) },
{ GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) },
{ GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) },
/* Disable CS dead batch merge */
{ GEN8_SP_HLSQ_DBG_ECO_CNTL_2, BIT(31), BIT(PIPE_NONE) },
{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) },
{ GEN8_SP_READ_SEL, 0x0001ff00, BIT(PIPE_NONE) },
{ GEN8_TPL1_DBG_ECO_CNTL, 0x10000000, BIT(PIPE_NONE) },
/* BIT(26): Disable final clamp for bicubic filtering */
{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000720, BIT(PIPE_NONE) },
{ GEN8_UCHE_MODE_CNTL, 0x80080000, BIT(PIPE_NONE) },
{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) },
{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_LP_REQ_CNT, 0x00000020, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ 0 },
};
static const struct gen8_protected_regs gen8_1_0_protected_regs[] = {
{ GEN8_CP_PROTECT_REG_GLOBAL + 0, 0x00008, 0x003a3, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 1, 0x003b4, 0x0043f, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 2, 0x00440, 0x0045f, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 3, 0x00580, 0x005df, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 4, 0x005e0, 0x006ff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 5, 0x0074a, 0x0074f, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 6, 0x00759, 0x0077f, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 7, 0x00789, 0x00789, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 8, 0x0078c, 0x0079f, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 9, 0x00800, 0x00829, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 10, 0x0082c, 0x0082c, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 11, 0x00837, 0x008e6, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 12, 0x008e7, 0x009b0, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 13, 0x008ec, 0x009af, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 14, 0x009b1, 0x00c01, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 15, 0x00ce0, 0x00ce1, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 16, 0x00df0, 0x00df0, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 17, 0x00df1, 0x00df1, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 18, 0x00e01, 0x00e01, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 19, 0x00e03, 0x02e02, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 20, 0x03c00, 0x03cc5, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 21, 0x03cc6, 0x03cff, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 22, 0x03d00, 0x05cff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 23, 0x08600, 0x087ff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 24, 0x08e00, 0x08eff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 25, 0x08f00, 0x08f00, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 26, 0x08f01, 0x090bf, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 27, 0x09600, 0x097ff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 28, 0x0981a, 0x09aff, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 29, 0x09e00, 0x09fff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 30, 0x0a600, 0x0a7ff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 31, 0x0a82e, 0x0a82e, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 32, 0x0ae00, 0x0ae06, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 33, 0x0ae08, 0x0ae0e, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 34, 0x0ae10, 0x0aecf, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 35, 0x0aed0, 0x0aeff, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 36, 0x0af00, 0x0b17f, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 37, 0x0b600, 0x0d5ff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 38, 0x0dc00, 0x0fbff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 39, 0x0fc00, 0x11bff, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 40, 0x18400, 0x1843f, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 41, 0x18440, 0x1857f, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 42, 0x18580, 0x1a57f, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 43, 0x1b400, 0x1d3ff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 44, 0x1f400, 0x1f877, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 45, 0x1f878, 0x1fd7f, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 46, 0x1f930, 0x1fc59, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 47, 0x1fd80, 0x21d7f, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 48, 0x27800, 0x2787f, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 49, 0x27880, 0x27c05, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 50, 0x27882, 0x2788b, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 63, 0x27c06, 0x27c06, 1 },
{ 0 },
};
static const struct kgsl_regmap_list gen8_1_0_ao_hwcg_regs[] = {
{ GEN8_GMUAO_CGC_MODE_CNTL, 0x00020202 },
{ GEN8_GMUAO_CGC_DELAY_CNTL, 0x00110111 },
{ GEN8_GMUAO_CGC_HYST_CNTL, 0x00055555 },
};
extern const struct gen8_snapshot_block_list gen8_1_0_snapshot_block_list;
static const struct adreno_gen8_core adreno_gpu_core_gen8_1_0 = {
.base = {
DEFINE_ADRENO_REV(ADRENO_REV_GEN8_1_0,
UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
.features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_CONTENT_PROTECTION |
ADRENO_SOFTFUSE | ADRENO_ACD | ADRENO_PREEMPTION | ADRENO_AQE,
.gpudev = &adreno_gen8_hwsched_gpudev.base,
.perfcounters = &adreno_gen8_perfcounters,
.uche_gmem_alignment = SZ_64M,
.gmem_size = 21 * SZ_1M,
.bus_width = 32,
.snapshot_size = SZ_8M,
.num_ddr_channels = 4,
/* bits[7:4] patched at runtime with active slice count */
.chipid = 0x44070001,
.speedbins = KGSL_SPEEDBINS(
{ 0, 0 },
{ 388, 1 },
{ 357, 2 },
{ 284, 3 },
),
.ubwc_mode = 5,
.mal = 32,
.highest_bank_bit = 16,
.gpu_model = "Adreno X2-90",
},
.aqefw_name = "gen80100_aqe.fw",
.sqefw_name = "gen80100_sqe.fw",
.gmufw_name = "gen80100_gmu.bin",
.zap_name = "gen80100_zap.mbn",
.ao_hwcg = gen8_1_0_ao_hwcg_regs,
.ao_hwcg_count = ARRAY_SIZE(gen8_1_0_ao_hwcg_regs),
.gbif = gen8_0_0_gbif_cx_regs,
.gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
.hang_detect_cycles = 0xcfffff,
.protected_regs = gen8_1_0_protected_regs,
.nonctxt_regs = gen8_1_0_nonctxt_regs,
.gmu_hub_clk_freq = 200000000,
.gen8_snapshot_block_list = &gen8_1_0_snapshot_block_list,
.fast_bus_hint = true,
.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
.noc_timeout_us = 3410, /* 3.41 msec */
.ctxt_record_size = (23088 * SZ_1K),
.preempt_level = 1,
};
static const struct adreno_gen8_core adreno_gpu_core_gen8_5_0 = {
.base = {
DEFINE_ADRENO_REV(ADRENO_REV_GEN8_5_0,
UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
.compatible = "qcom,adreno-gpu-gen8-5-0",
.features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_PREEMPTION |
ADRENO_LPAC | ADRENO_AQE | ADRENO_GMU_WARMBOOT | ADRENO_IFPC |
ADRENO_CONTENT_PROTECTION | ADRENO_HW_FENCE | ADRENO_BCL |
ADRENO_GMU_AB | ADRENO_GMU_BASED_DCVS | ADRENO_GMU_THERMAL_MITIGATION |
ADRENO_DEFER_GMEM_ALLOC | ADRENO_GMU_MINBW |
ADRENO_TSENSE_DYNAMIC_PERIOD | ADRENO_DCVS_PROFILE,
.gpudev = &adreno_gen8_hwsched_gpudev.base,
.perfcounters = &adreno_gen8_2_x_perfcounters,
.uche_gmem_alignment = SZ_64M,
.gmem_size = 18 * SZ_1M,
.bus_width = 32,
.snapshot_size = SZ_8M,
.num_ddr_channels = 4,
.highest_bank_bit = 16,
},
.aqefw_name = "gen80200_aqe.fw",
.sqefw_name = "gen80200_sqe.fw",
.gmufw_name = "gen80200_gmu.bin",
.zap_name = "gen80200_zap.mbn",
.ao_hwcg = gen8_2_0_ao_hwcg_regs,
.ao_hwcg_count = ARRAY_SIZE(gen8_2_0_ao_hwcg_regs),
.gbif = gen8_0_0_gbif_cx_regs,
.gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
.hang_detect_cycles = 0xcfffff,
.protected_regs = gen8_2_0_protected_regs,
.nonctxt_regs = gen8_2_0_nonctxt_regs,
.gmu_hub_clk_freq = 150000000,
.gen8_snapshot_block_list = &gen8_2_0_snapshot_block_list,
.fast_bus_hint = true,
.bcl_data = GEN8_2_X_BCL_DATA,
.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
.noc_timeout_us = 3410, /* 3.41 msec */
.cl_no_ft_timeout_ms = 6500,
.ctxt_record_size = (19708 * SZ_1K),
.therm_cfg = &therm_mit_cfg_8_2_0,
.limits_mit_cfg = &gen8_2_0_limits_mit_cfg,
.preempt_level = 1,
.clx_tbl = &gen8_2_0_clx_table,
};
/* GEN8_4_0 noncontext register list */
static const struct gen8_nonctxt_regs gen8_4_0_nonctxt_regs[] = {
{ GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) },
{ GEN8_GRAS_DBG_ECO_CNTL, 0x00000800, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_CHICKEN_BITS_1, 0x00000003, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BR) | BIT(PIPE_BV) },
/* Disable BR throttling */
{ GEN8_PC_CHICKEN_BITS_3, 0x00400000, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_CHICKEN_BITS_4, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) },
/* Configure GBIF GX registers */
{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
/* Reset value of RBBM_GBIF_CLIENT_QOS_CNTL is 0. So, no need to program explicitly. */
/* Enable full concurrent resolve and unresolves */
{ GEN8_RB_CCU_CNTL, 0x00000068, BIT(PIPE_BR) },
{ GEN8_RB_GC_GMEM_PROTECT, 0x0c000000, BIT(PIPE_BR) },
/* Configure number of outstanding transactions to 32 */
{ GEN8_RB_RESOLVE_PREFETCH_CNTL, 0x00000007, BIT(PIPE_BR) },
/* Configure UCHE request time out to 16 cycles for CCU/UCHE arbitration */
{ GEN8_RB_CMP_DBG_ECO_CNTL, 0x00004000, BIT(PIPE_BR) },
{ GEN8_RBBM_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) },
{ GEN8_RBBM_SLICE_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) },
{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL, 0x00000030, BIT(PIPE_NONE) },
{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2, 0x00000030, BIT(PIPE_NONE) },
{ GEN8_RBBM_CGC_P2S_CNTL, 0x00000040, BIT(PIPE_NONE) },
/* Enable contribution of all shader stages to SP perfcounters */
{ GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) },
/*
* BIT(26): Limit the number of wave-slots for Eviction buffer to 1 per ALU GRP
* BIT(30): Disable LPAC auto-promotion
*/
{ GEN8_SP_CHICKEN_BITS_1, BIT(26) | BIT(30), BIT(PIPE_NONE) },
/*
* BIT(22): Disable PS out of order retire
* BIT(23): Enable half wave mode and MM instruction src&dst is half precision
*/
{ GEN8_SP_CHICKEN_BITS_2, BIT(22) | BIT(23), BIT(PIPE_NONE) },
{ GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) },
{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) },
{ GEN8_TPL1_DBG_ECO_CNTL, 0x10000000, BIT(PIPE_NONE) },
/* Enable cubemap small miplevel optimization settings */
/* BIT(26): Disable final clamp for bicubic filtering */
{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000724, BIT(PIPE_NONE) },
/* Disable tag bank id hashing */
{ GEN8_UCHE_MODE_CNTL, 0x00080000, BIT(PIPE_NONE) },
{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
/* Limit gmem number of ways for GMEM requests in each set */
{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE)},
/* Disable write slow pointer in data phase queue */
{ GEN8_UCHE_HW_DBG_CNTL, BIT(8), BIT(PIPE_NONE) },
/* Configure UCHE to CCU switchthreshold timeout cycles */
{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_VFD_CB_LP_REQ_CNT, 0x00100020, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) },
/* Disable redundant tile data optimization */
{ GEN8_VSC_KMD_DBG_ECO_CNTL, BIT(11), BIT(PIPE_NONE)},
{ 0 },
};
static const u32 gen8_4_0_gbif_client_qos_values[KGSL_PRIORITY_MAX_RB_LEVELS] = {
0x33233323,
};
static const struct adreno_gen8_core adreno_gpu_core_gen8_4_0 = {
.base = {
DEFINE_ADRENO_REV(ADRENO_REV_GEN8_4_0,
UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
.compatible = "qcom,adreno-gpu-gen8-4-0",
.features = ADRENO_APRIV | ADRENO_IOCOHERENT |
ADRENO_CONTENT_PROTECTION | ADRENO_LPAC | ADRENO_AQE |
ADRENO_GMU_WARMBOOT | ADRENO_L3_VOTE | ADRENO_IFPC |
ADRENO_BCL | ADRENO_ACD | ADRENO_HW_FENCE |
ADRENO_PREEMPTION | ADRENO_GMU_AB,
.gpudev = &adreno_gen8_hwsched_gpudev.base,
.perfcounters = &adreno_gen8_perfcounters,
.uche_gmem_alignment = SZ_64M,
.gmem_size = 12 * SZ_1M,
.bus_width = 32,
.snapshot_size = SZ_8M,
.num_ddr_channels = 4,
.highest_bank_bit = 16,
},
.aqefw_name = "gen80000_aqe.fw",
.sqefw_name = "gen80000_sqe.fw",
.gmufw_name = "gen80000_gmu.bin",
.zap_name = "gen80000_zap.mbn",
.ao_hwcg = gen8_ao_hwcg_regs,
.ao_hwcg_count = ARRAY_SIZE(gen8_ao_hwcg_regs),
.gbif = gen8_0_0_gbif_cx_regs,
.gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
.hang_detect_cycles = 0xcfffff,
.protected_regs = gen8_0_0_protected_regs,
.nonctxt_regs = gen8_4_0_nonctxt_regs,
.gmu_hub_clk_freq = 200000000,
.gen8_snapshot_block_list = &gen8_0_0_snapshot_block_list,
.qos_value = gen8_4_0_gbif_client_qos_values,
.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
.bcl_data = 1,
.preempt_level = 1,
.ctxt_record_size = (13536 * SZ_1K),
.noc_timeout_us = 3410, /* 3.41 msec */
.cl_no_ft_timeout_ms = 10000,
};
extern const struct gen8_snapshot_block_list gen8_3_0_snapshot_block_list;
static const struct kgsl_regmap_list gen8_3_0_gbif_cx_regs[] = {
{ GEN8_GBIF_QSB_SIDE0, 0x00071e20 },
{ GEN8_GBIF_QSB_SIDE1, 0x00071e20 },
{ GEN8_GBIF_QSB_SIDE2, 0x00071e20 },
{ GEN8_GBIF_QSB_SIDE3, 0x00071e20 },
{ GEN8_GBIF_CX_CONFIG, 0x20023000 },
};
static const struct kgsl_regmap_list gen8_8_0_gbif_cx_regs[] = {
{ GEN8_GBIF_QSB_SIDE0, 0x00071e20 },
{ GEN8_GBIF_QSB_SIDE1, 0x00071e20 },
{ GEN8_GBIF_QSB_SIDE2, 0x00071e20 },
{ GEN8_GBIF_QSB_SIDE3, 0x00071e20 },
{ GEN8_GBIF_CX_CONFIG, 0x40023000 },
};
/* GEN8_3_0 noncontext register list */
static const struct gen8_nonctxt_regs gen8_3_0_nonctxt_regs[] = {
{ GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) },
{ GEN8_GRAS_DBG_ECO_CNTL, 0x00f80800, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_CHICKEN_BITS_1, 0x00000003, BIT(PIPE_BR) },
{ GEN8_PC_CHICKEN_BITS_1, 0x00000023, BIT(PIPE_BV) }, /* Avoid partial waves at VFD */
{ GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_CHICKEN_BITS_3, 0x00500000, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_CHICKEN_BITS_4, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_RB_CCU_CNTL, 0x00000068, BIT(PIPE_BR) },
{ GEN8_RB_RESOLVE_PREFETCH_CNTL, 0x00000007, BIT(PIPE_BR) },
{ GEN8_RB_CMP_DBG_ECO_CNTL, 0x00004000, BIT(PIPE_BR) },
{ GEN8_RBBM_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) },
{ GEN8_RBBM_SLICE_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) },
{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL, 0x00000030, BIT(PIPE_NONE) },
{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2, 0x00000030, BIT(PIPE_NONE) },
{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
{ GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 0x22122212, BIT(PIPE_NONE) },
{ GEN8_RBBM_CGC_P2S_CNTL, 0x00000040, BIT(PIPE_NONE) },
{ GEN8_SP_CHICKEN_BITS_2, BIT(22) | BIT(23), BIT(PIPE_NONE) },
{ GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) },
{ GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) },
{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) },
{ GEN8_TPL1_DBG_ECO_CNTL, 0x10000000, BIT(PIPE_NONE) },
/* BIT(26): Disable final clamp for bicubic filtering */
{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000724, BIT(PIPE_NONE) },
{ GEN8_UCHE_MODE_CNTL, 0x00020000, BIT(PIPE_NONE) },
{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) },
/* Disable write slow pointer in data phase queue */
{ GEN8_UCHE_HW_DBG_CNTL, BIT(8), BIT(PIPE_NONE) },
{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_LP_REQ_CNT, 0x00100020, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_RB_GC_GMEM_PROTECT, 0x00900000, BIT(PIPE_BR) },
{ 0 },
};
static const struct adreno_gen8_core adreno_gpu_core_gen8_3_0 = {
.base = {
DEFINE_ADRENO_REV(ADRENO_REV_GEN8_3_0,
UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
.compatible = "qcom,adreno-gpu-gen8-3-0",
.features = ADRENO_APRIV | ADRENO_IOCOHERENT |
ADRENO_CONTENT_PROTECTION | ADRENO_IFPC | ADRENO_PREEMPTION |
ADRENO_GMU_AB,
.gpudev = &adreno_gen8_hwsched_gpudev.base,
.perfcounters = &adreno_gen8_perfcounters,
.uche_gmem_alignment = SZ_64M,
.gmem_size = (SZ_512K + SZ_64K),
.bus_width = 32,
.snapshot_size = SZ_8M,
.num_ddr_channels = 2,
.highest_bank_bit = 15,
},
.sqefw_name = "gen80300_sqe.fw",
.gmufw_name = "gen80300_gmu.bin",
.zap_name = "gen80300_zap.mbn",
.ao_hwcg = gen8_ao_hwcg_regs,
.ao_hwcg_count = ARRAY_SIZE(gen8_ao_hwcg_regs),
.gbif = gen8_3_0_gbif_cx_regs,
.gbif_count = ARRAY_SIZE(gen8_3_0_gbif_cx_regs),
.hang_detect_cycles = 0xcfffff,
.protected_regs = gen8_0_0_protected_regs, /* Reuse the protected regs list from Gen8_0_0 */
.nonctxt_regs = gen8_3_0_nonctxt_regs,
.gmu_hub_clk_freq = 200000000,
.gen8_snapshot_block_list = &gen8_3_0_snapshot_block_list,
.ctxt_record_size = (4558 * SZ_1K),
.preempt_level = 1,
};
/* GEN8_6_0 noncontext register list */
static const struct gen8_nonctxt_regs gen8_6_0_nonctxt_regs[] = {
{ GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) },
{ GEN8_GRAS_DBG_ECO_CNTL, 0x00000800, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_CHICKEN_BITS_1, 0x00000003, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_CHICKEN_BITS_3, 0x00500000, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_CHICKEN_BITS_4, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) },
/* Configure GBIF GX registers */
{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
{ GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 0x22122212, BIT(PIPE_NONE) },
/* Enable full concurrent resolve and unresolves */
{ GEN8_RB_CCU_CNTL, 0x00000068, BIT(PIPE_BR) },
{ GEN8_RB_GC_GMEM_PROTECT, 0x02600000, BIT(PIPE_BR) },
/* Configure number of outstanding transactions to 32 */
{ GEN8_RB_RESOLVE_PREFETCH_CNTL, 0x00000007, BIT(PIPE_BR) },
/* Configure UCHE request time out to 16 cycles for CCU/UCHE arbitration */
{ GEN8_RB_CMP_DBG_ECO_CNTL, 0x00004000, BIT(PIPE_BR) },
{ GEN8_RBBM_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) },
{ GEN8_RBBM_SLICE_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) },
{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL, 0x00000030, BIT(PIPE_NONE) },
{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2, 0x00000030, BIT(PIPE_NONE) },
{ GEN8_RBBM_CGC_P2S_CNTL, 0x00000040, BIT(PIPE_NONE) },
/* Enable contribution of all shader stages to SP perfcounters */
{ GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) },
/*
* BIT(26): Limit the number of wave-slots for Eviction buffer to 1 per ALU GRP
* BIT(30): Disable LPAC auto-promotion
*/
{ GEN8_SP_CHICKEN_BITS_1, BIT(26) | BIT(30), BIT(PIPE_NONE) },
/*
* BIT(22): Disable PS out of order retire
* BIT(23): Enable half wave mode and MM instruction src&dst is half precision
*/
{ GEN8_SP_CHICKEN_BITS_2, BIT(22) | BIT(23), BIT(PIPE_NONE) },
{ GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) },
{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) },
{ GEN8_TPL1_DBG_ECO_CNTL, 0x10000000, BIT(PIPE_NONE) },
/* Enable cubemap small miplevel optimization settings */
/* BIT(26): Disable final clamp for bicubic filtering */
{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000724, BIT(PIPE_NONE) },
/* Disable tag bank id hashing */
{ GEN8_UCHE_MODE_CNTL, 0x00080000, BIT(PIPE_NONE) },
{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
/* Limit gmem number of ways for GMEM requests in each set */
{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE)},
/* Disable write slow pointer in data phase queue */
{ GEN8_UCHE_HW_DBG_CNTL, BIT(8), BIT(PIPE_NONE) },
/* Configure UCHE to CCU switchthreshold timeout cycles */
{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_VFD_CB_LP_REQ_CNT, 0x00000020, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) },
/* Disable redundant tile data optimization */
{ GEN8_VSC_KMD_DBG_ECO_CNTL, BIT(11), BIT(PIPE_NONE)},
{ 0 },
};
extern const struct gen8_snapshot_block_list gen8_6_0_snapshot_block_list;
static const struct adreno_gen8_core adreno_gpu_core_gen8_6_0 = {
.base = {
DEFINE_ADRENO_REV(ADRENO_REV_GEN8_6_0,
UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
.compatible = "qcom,adreno-gpu-gen8-6-0",
.features = ADRENO_APRIV | ADRENO_IOCOHERENT |
ADRENO_CONTENT_PROTECTION | ADRENO_LPAC | ADRENO_AQE |
ADRENO_GMU_WARMBOOT | ADRENO_L3_VOTE | ADRENO_IFPC |
ADRENO_PREEMPTION | ADRENO_BCL | ADRENO_ACD | ADRENO_GMU_AB,
.gpudev = &adreno_gen8_hwsched_gpudev.base,
.perfcounters = &adreno_gen8_perfcounters,
.uche_gmem_alignment = SZ_64M,
.gmem_size = (SZ_2M + SZ_256K + SZ_128K),
.bus_width = 32,
.snapshot_size = SZ_8M,
.num_ddr_channels = 4,
.highest_bank_bit = 16,
},
.aqefw_name = "gen80000_aqe.fw",
.sqefw_name = "gen80000_sqe.fw",
.gmufw_name = "gen80600_gmu.bin",
.zap_name = "gen80000_zap.mbn",
.ao_hwcg = gen8_ao_hwcg_regs,
.ao_hwcg_count = ARRAY_SIZE(gen8_ao_hwcg_regs),
.gbif = gen8_3_0_gbif_cx_regs,
.gbif_count = ARRAY_SIZE(gen8_3_0_gbif_cx_regs),
.hang_detect_cycles = 0xcfffff,
.protected_regs = gen8_0_0_protected_regs,
.nonctxt_regs = gen8_6_0_nonctxt_regs,
.gmu_hub_clk_freq = 200000000,
.gen8_snapshot_block_list = &gen8_6_0_snapshot_block_list,
.noc_timeout_us = 6800, /* 6.8 msec */
.ctxt_record_size = (3372 * SZ_1K),
.preempt_level = 1,
.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
.bcl_data = 1,
};
static const struct adreno_gen8_core adreno_gpu_core_gen8_8_0 = {
.base = {
DEFINE_ADRENO_REV(ADRENO_REV_GEN8_8_0,
UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
.compatible = "qcom,adreno-gpu-gen8-8-0",
.features = ADRENO_APRIV | ADRENO_IOCOHERENT |
ADRENO_CONTENT_PROTECTION | ADRENO_IFPC | ADRENO_PREEMPTION |
ADRENO_HW_FENCE | ADRENO_BCL | ADRENO_GMU_AB,
.gpudev = &adreno_gen8_hwsched_gpudev.base,
.perfcounters = &adreno_gen8_perfcounters,
.uche_gmem_alignment = SZ_64M,
.gmem_size = (SZ_512K + SZ_64K),
.bus_width = 32,
.snapshot_size = SZ_8M,
.num_ddr_channels = 1,
.highest_bank_bit = 14,
},
.sqefw_name = "gen80300_sqe.fw",
.gmufw_name = "gen80800_gmu.bin",
.zap_name = "gen80300_zap.mbn",
.ao_hwcg = gen8_ao_hwcg_regs,
.ao_hwcg_count = ARRAY_SIZE(gen8_ao_hwcg_regs),
.gbif = gen8_8_0_gbif_cx_regs,
.gbif_count = ARRAY_SIZE(gen8_8_0_gbif_cx_regs),
.hang_detect_cycles = 0xcfffff,
.protected_regs = gen8_0_0_protected_regs, /* Reuse the protected regs list from Gen8_0_0 */
.nonctxt_regs = gen8_3_0_nonctxt_regs,
.gmu_hub_clk_freq = 200000000,
.gen8_snapshot_block_list = &gen8_3_0_snapshot_block_list,
.ctxt_record_size = (4558 * SZ_1K),
.preempt_level = 1,
.noc_timeout_us = 3410, /* 3.41 msec */
.bcl_data = 1,
};
/* GEN8_9_0 noncontext register list */
static const struct gen8_nonctxt_regs gen8_9_0_nonctxt_regs[] = {
{ GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 0x22122212, BIT(PIPE_NONE) },
{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL, 0x00000030, BIT(PIPE_NONE) },
{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2, 0x00000030, BIT(PIPE_NONE) },
/* Disable Dead Draw Merge scheme on RB-HLSQ */
{ GEN8_RB_RBP_CNTL, BIT(5), BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_RBBM_INTERFACE_HANG_INT_CNTL, 0x0fffffff, BIT(PIPE_NONE) },
{ GEN8_RBBM_POWER_UP_RESET_SW_OVERRIDE, 0x70809060, BIT(PIPE_NONE) },
{ GEN8_RBBM_POWER_UP_RESET_SW_BV_OVERRIDE, 0x30000000, BIT(PIPE_NONE) },
{ GEN8_RBBM_CGC_P2S_CNTL, 0x00000040, BIT(PIPE_NONE) },
/* Disable mode_switch optimization in UMAS */
{ GEN8_SP_CHICKEN_BITS, BIT(26), BIT(PIPE_NONE) },
/* Disable LPAC large-LM mode */
{ GEN8_SP_SS_CHICKEN_BITS_0, BIT(3), BIT(PIPE_NONE) },
/* Disable PS out of order retire */
{ GEN8_SP_CHICKEN_BITS_2, 0xc21800, BIT(PIPE_NONE) },
{ GEN8_RBBM_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) },
{ GEN8_RBBM_SLICE_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) },
{ GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) },
{ GEN8_UCHE_MODE_CNTL, 0x80080000, BIT(PIPE_NONE) },
{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) },
{ GEN8_GRAS_TSEFE_DBG_ECO_CNTL, 0x00200000, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_GRAS_DBG_ECO_CNTL, 0x00000800, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_RB_CCU_CNTL, 0x00000068, BIT(PIPE_BR) },
{ GEN8_RB_CCU_DBG_ECO_CNTL, 0x00002200, BIT(PIPE_BR) },
{ GEN8_RB_GC_GMEM_PROTECT, 0x02600000, BIT(PIPE_BR) },
{ GEN8_RB_RESOLVE_PREFETCH_CNTL, 0x00000007, BIT(PIPE_BR) },
{ GEN8_RB_CMP_DBG_ECO_CNTL, 0x00004000, BIT(PIPE_BR) },
{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_CHICKEN_BITS_3, 0x00500000, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_CHICKEN_BITS_4, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_CHICKEN_BITS_1, 0x00000003, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_VFD_CB_LP_REQ_CNT, 0x00000020, BIT(PIPE_BR) | BIT(PIPE_BV) },
{ GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) },
{ GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) },
/* Ignore HLSQ shared constant feedback from SP */
{ GEN8_SP_HLSQ_DBG_ECO_CNTL_1, BIT(17), BIT(PIPE_NONE) },
/* Disable CS dead batch merge */
{ GEN8_SP_HLSQ_DBG_ECO_CNTL_2, BIT(24), BIT(PIPE_NONE) },
{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) },
{ GEN8_SP_READ_SEL, 0x0001ff00, BIT(PIPE_NONE) },
{ GEN8_TPL1_DBG_ECO_CNTL, 0x10100000, BIT(PIPE_NONE) },
{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000720, BIT(PIPE_NONE) },
{ 0 },
};
extern const struct gen8_snapshot_block_list gen8_9_0_snapshot_block_list;
static const struct adreno_gen8_core adreno_gpu_core_gen8_9_0 = {
.base = {
DEFINE_ADRENO_REV(ADRENO_REV_GEN8_9_0,
UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
.compatible = "qcom,adreno-gpu-gen8-9-0",
.features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_LPAC |
ADRENO_GMU_WARMBOOT | ADRENO_AQE | ADRENO_IFPC |
ADRENO_CONTENT_PROTECTION | ADRENO_GMU_BASED_DCVS |
ADRENO_DEFER_GMEM_ALLOC | ADRENO_PREEMPTION | ADRENO_GMU_AB |
ADRENO_GMU_THERMAL_MITIGATION | ADRENO_HW_FENCE |
ADRENO_DCVS_PROFILE | ADRENO_GMU_MINBW |
ADRENO_BCL | ADRENO_ACD,
.gpudev = &adreno_gen8_hwsched_gpudev.base,
.perfcounters = &adreno_gen8_perfcounters,
.uche_gmem_alignment = SZ_64M,
.gmem_size = 2432 * SZ_1K,
.bus_width = 32,
.snapshot_size = SZ_8M,
.num_ddr_channels = 4,
.highest_bank_bit = 16,
},
.aqefw_name = "gen80900_aqe.fw",
.sqefw_name = "gen80900_sqe.fw",
.gmufw_name = "gen80900_gmu.bin",
.zap_name = "gen80900_zap.mbn",
.ao_hwcg = gen8_2_0_ao_hwcg_regs,
.ao_hwcg_count = ARRAY_SIZE(gen8_2_0_ao_hwcg_regs),
.gbif = gen8_0_0_gbif_cx_regs,
.gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
.hang_detect_cycles = 0xcfffff,
.protected_regs = gen8_2_0_protected_regs,
.nonctxt_regs = gen8_9_0_nonctxt_regs,
.gmu_hub_clk_freq = 200000000,
.gen8_snapshot_block_list = &gen8_9_0_snapshot_block_list,
.fast_bus_hint = true,
.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
.noc_timeout_us = 3410, /* 3.41 msec */
.cl_no_ft_timeout_ms = 6500,
.ctxt_record_size = (3708 * SZ_1K),
.preempt_level = 1,
.therm_cfg = &therm_mit_cfg_8_2_0,
.bcl_data = 1,
};
static const struct adreno_a6xx_core adreno_gpu_core_a623 = {
.base = {
DEFINE_ADRENO_REV(ADRENO_REV_A623, 6, 2, 3, ANY_ID),
.features = ADRENO_APRIV |
ADRENO_IOCOHERENT | ADRENO_CONTENT_PROTECTION |
ADRENO_PREEMPTION | ADRENO_ACD,
.gpudev = &adreno_a6xx_gmu_gpudev.base,
.perfcounters = &adreno_a6xx_perfcounters,
.uche_gmem_alignment = SZ_1M + SZ_512K,
.gmem_size = SZ_512K,
.bus_width = 32,
.snapshot_size = SZ_2M,
.chipid = 0x06020300,
.speedbins = KGSL_SPEEDBINS(
{ 0, 0 },
{ 185, 0 },
{ 127, 1 },
),
.ubwc_mode = 4,
.mal = 32,
.highest_bank_bit = 16,
},
.prim_fifo_threshold = 0x0010000,
.gmu_major = 2,
.gmu_minor = 0,
.sqefw_name = "a650_sqe.fw",
.gmufw_name = "a623_gmu.bin",
.zap_name = "a623_zap.mbn",
.hwcg = a620_hwcg_regs,
.hwcg_count = ARRAY_SIZE(a620_hwcg_regs),
.vbif = a650_gbif_regs,
.vbif_count = ARRAY_SIZE(a650_gbif_regs),
.hang_detect_cycles = 0xc3ffff,
.veto_fal10 = true,
.protected_regs = a620_protected_regs,
.disable_tseskip = true,
.pdc_in_aop = true,
.ctxt_record_size = 2496 * 1024,
};
extern const struct gen8_snapshot_block_list gen8_10_0_snapshot_block_list;
static const struct adreno_gen8_core adreno_gpu_core_gen8_10_0 = {
.base = {
DEFINE_ADRENO_REV(ADRENO_REV_GEN8_10_0,
UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
.features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_BCL | ADRENO_ACD
| ADRENO_IFPC | ADRENO_CONTENT_PROTECTION | ADRENO_PREEMPTION,
.features_standard = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_PREEMPTION |
ADRENO_CONTENT_PROTECTION | ADRENO_SOFTFUSE,
.compatible = "qcom,adreno-gpu-gen8-10-0",
.gpudev = &adreno_gen8_hwsched_gpudev.base,
.perfcounters = &adreno_gen8_perfcounters,
.uche_gmem_alignment = SZ_64M,
.gmem_size = (15 * SZ_1M + 768 * SZ_1K),
.bus_width = 32,
.snapshot_size = SZ_8M,
.num_ddr_channels = 8,
.chipid = 0x44060000,
.speedbins = KGSL_SPEEDBINS(
{ 0, 0 },
{ 388, 1 },
{ 357, 2 },
{ 284, 3 },
),
.ubwc_mode = 5,
.mal = 32,
.highest_bank_bit = 16,
.gpu_model = "Adreno X2-85",
},
.aqefw_name = "gen80100_aqe.fw",
.sqefw_name = "gen80100_sqe.fw",
.gmufw_name = "gen80100_gmu.bin",
.zap_name = "gen80100_zap.mbn",
.ao_hwcg = gen8_1_0_ao_hwcg_regs,
.ao_hwcg_count = ARRAY_SIZE(gen8_1_0_ao_hwcg_regs),
.gbif = gen8_0_0_gbif_cx_regs,
.gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
.hang_detect_cycles = 0xcfffff,
.protected_regs = gen8_1_0_protected_regs,
.nonctxt_regs = gen8_1_0_nonctxt_regs,
.gmu_hub_clk_freq = 200000000,
.fast_bus_hint = true,
.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
.noc_timeout_us = 3410, /* 3.41 msec */
.cl_no_ft_timeout_ms = 6500,
.ctxt_record_size = (23088 * SZ_1K),
.bcl_data = 1,
.gen8_snapshot_block_list = &gen8_10_0_snapshot_block_list,
.preempt_level = 1,
};
static const struct hfi_clx_table_v2_cmd gen8_11_0_clx_table = {
.version = (2 << 16) | 1,
.domain = {
/* GFX domain */
{
.data0 = CLX_DATA(60, 5, 0, 1),
.clxt = 0,
.clxh = 0,
.urgmode = 1,
.lkgen = 0,
.currbudget = 100,
},
/* MxG domain */
{
.data0 = CLX_DATA(30, 1, 1, 1),
.clxt = 0,
.clxh = 0,
.urgmode = 1,
.lkgen = 0,
.currbudget = 100,
},
},
};
static const struct hfi_clx_table_v2_cmd gen8_14_0_clx_table = {
.version = (2 << 16) | 1,
.domain = {
/* GFX domain */
{
.data0 = CLX_DATA(60, 4, 1, 1),
.clxt = 10,
.clxh = 0,
.urgmode = 1,
.lkgen = 0,
.currbudget = 100,
},
/* MxG domain */
{
.data0 = CLX_DATA(60, 1, 1, 1),
.clxt = 10,
.clxh = 0,
.urgmode = 1,
.lkgen = 0,
.currbudget = 100,
},
},
};
static const struct hfi_limits_mit_tbl gen8_11_0_limits_mit_tbl[] = {
{
.feature_id = GMU_MIT_IFF,
.domain = GMU_GX_DOMAIN,
.feature_rev = 0,
.mit_cfg = {
.enable = 1,
.msg_path = 0,
.lkgen = 0,
.mode = 0,
.sid_val = 0xC,
.mit_time = 5,
.curr_limit = 30000,
}
},
{
.feature_id = GMU_MIT_IFF,
.domain = GMU_MX_DOMAIN,
.feature_rev = 0,
.mit_cfg = {
.enable = 1,
.msg_path = 0,
.lkgen = 0,
.mode = BIT(1),
.sid_val = 0x12,
.mit_time = 2000,
.curr_limit = 5000,
}
},
{
.feature_id = GMU_MIT_PCLX,
.domain = GMU_GX_DOMAIN,
.feature_rev = 0,
.mit_cfg = {
.enable = 1,
.msg_path = 0,
.lkgen = 0,
.mode = 0,
.sid_val = 0x8,
.mit_time = 3,
.curr_limit = 30000,
}
},
{
.feature_id = GMU_MIT_PCLX,
.domain = GMU_MX_DOMAIN,
.feature_rev = 0,
.mit_cfg = {
.enable = 0,
.msg_path = 0,
.lkgen = 0,
.mode = BIT(1),
.sid_val = 0x8,
.mit_time = 3,
.curr_limit = 5000,
}
},
};
static const struct gen8_limits_mit_cfg gen8_11_0_limits_mit_cfg = {
.limits_mit_tbl = gen8_11_0_limits_mit_tbl,
.len = ARRAY_SIZE(gen8_11_0_limits_mit_tbl),
};
/* GEN8_11_0 protected register list */
static const struct gen8_protected_regs gen8_11_0_protected_regs[] = {
{ GEN8_CP_PROTECT_REG_GLOBAL + 0, 0x00008, 0x003a3, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 1, 0x003b4, 0x0043f, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 2, 0x00440, 0x0045f, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 3, 0x00580, 0x005df, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 4, 0x005e0, 0x006ff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 5, 0x0074a, 0x0074f, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 6, 0x00759, 0x00774, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 7, 0x00775, 0x0077f, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 8, 0x00789, 0x00789, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 9, 0x0078c, 0x0079f, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 10, 0x00800, 0x00829, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 11, 0x00837, 0x008e6, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 12, 0x008e7, 0x009b0, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 13, 0x008ec, 0x009af, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 14, 0x009b1, 0x00c01, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 15, 0x00c07, 0x00c0f, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 16, 0x00ce0, 0x00ce1, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 17, 0x00df0, 0x00df0, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 18, 0x00df1, 0x00df1, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 19, 0x00df5, 0x00df8, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 20, 0x00df9, 0x00e00, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 21, 0x00e01, 0x00e01, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 22, 0x00e03, 0x02e02, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 23, 0x03c00, 0x03cc5, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 24, 0x03cc6, 0x03cff, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 25, 0x03d00, 0x05cff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 26, 0x08600, 0x087ff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 27, 0x08e00, 0x08eff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 28, 0x08f00, 0x08f00, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 29, 0x08f01, 0x090bf, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 30, 0x09600, 0x097ff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 31, 0x0981a, 0x09aff, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 32, 0x09e00, 0x09fff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 33, 0x0a600, 0x0a7ff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 34, 0x0a82e, 0x0a82e, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 35, 0x0ae00, 0x0ae00, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 36, 0x0ae02, 0x0ae06, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 37, 0x0ae08, 0x0ae0e, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 38, 0x0ae10, 0x0aecf, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 39, 0x0aed0, 0x0aeff, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 40, 0x0af00, 0x0b17f, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 41, 0x0b600, 0x0d5ff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 42, 0x0dc00, 0x0fbff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 43, 0x0fc00, 0x11bff, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 44, 0x18400, 0x1843f, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 45, 0x18440, 0x1857f, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 46, 0x18580, 0x1a57f, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 47, 0x1ac00, 0x1cbff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 48, 0x1cc00, 0x1ebff, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 49, 0x1f400, 0x1f877, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 50, 0x1f878, 0x1fd7f, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 51, 0x1f930, 0x1fc59, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 52, 0x1fd80, 0x21d7f, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 53, 0x27800, 0x2787f, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 54, 0x27880, 0x27c05, 0 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 55, 0x27882, 0x278b7, 1 },
{ GEN8_CP_PROTECT_REG_GLOBAL + 63, 0x27c06, 0x27c06, 1 },
{ 0 },
};
/* GEN8_11_0 noncontext register list */
static const struct gen8_nonctxt_regs gen8_11_0_nonctxt_regs[] = {
{ GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) },
{ GEN8_CP_MULTIDRAW_CNTL, 0x00000001, BIT(PIPE_NONE) },
{ GEN8_GRAS_DBG_ECO_CNTL, 0x00000800, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_GRAS_TSEFE_DBG_ECO_CNTL, 0x00200000, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_GRAS_NC_MODE_CNTL, 0x00000220, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BV) | BIT(PIPE_BR) },
/* BIT(11): Disable skipIdx to avoid PDMA hang with restart-index draws */
{ GEN8_PC_CHICKEN_BITS_1, 0x00000803, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_CHICKEN_BITS_3, 0x00400000, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_CHICKEN_BITS_4, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
/*
* BIT(28): Disable GS Quad primitive
* BIT(30): Disable skipIdx to avoid PDMA hang with restart-index draws
*/
{ GEN8_PC_CHICKEN_BITS_5, BIT(28) | BIT(30), BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_RB_CCU_CNTL, 0x00000068, BIT(PIPE_BR) },
/*
* BIT(10): Disable sysmem nonfclear feature
* BIT(9): Disable DINT to c/z be data forwarding
*/
{ GEN8_RB_CCU_DBG_ECO_CNTL, BIT(10) | BIT(9), BIT(PIPE_BR) },
{ GEN8_RB_CCU_NC_MODE_CNTL, 0x00000002, BIT(PIPE_BR) },
{ GEN8_RB_CMP_NC_MODE_CNTL, 0x00028000, BIT(PIPE_BR) },
/* Disable early EOBlk return */
{ GEN8_RB_DBG_ECO_CNTL, BIT(17), BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_RB_GC_GMEM_PROTECT, 0x12000000, BIT(PIPE_BR) },
/* Disable pre-mvcc dead draw merge scheme on LRZ-RB */
{ GEN8_RB_RBP_CNTL, BIT(6), BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_RB_RESOLVE_PREFETCH_CNTL, 0x00000007, BIT(PIPE_BR) },
{ GEN8_RB_CMP_DBG_ECO_CNTL, 0x00004000, BIT(PIPE_BR) },
{ GEN8_RBBM_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) },
{ GEN8_RBBM_SLICE_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) },
/* Enable RB BAC strobes */
{ GEN8_RBBM_SLICE_PERFCTR_CNTL, BIT(0), BIT(PIPE_NONE) },
{ GEN8_RBBM_POWER_UP_RESET_SW_OVERRIDE, 0x70809060, BIT(PIPE_NONE) },
{ GEN8_RBBM_POWER_UP_RESET_SW_BV_OVERRIDE, 0x30000000, BIT(PIPE_NONE) },
{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL, 0x00000030, BIT(PIPE_NONE) },
{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2, 0x00000030, BIT(PIPE_NONE) },
{ GEN8_RBBM_INTERFACE_HANG_INT_CNTL, 0x0fffffff, BIT(PIPE_NONE) },
{ GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 0x22122212, BIT(PIPE_NONE) },
{ GEN8_RBBM_CGC_P2S_CNTL, 0x00000040, BIT(PIPE_NONE) },
/* Disable VS delay resource optimization */
{ GEN8_SP_CHICKEN_BITS, BIT(24), BIT(PIPE_NONE) },
{ GEN8_SP_CHICKEN_BITS_2, 0x00820800, BIT(PIPE_NONE) },
{ GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) },
/* Disable last-use skip for gpr ALU Write Enable */
{ GEN8_SP_CHICKEN_BITS_5, BIT(3), BIT(PIPE_NONE) },
{ GEN8_SP_NC_MODE_CNTL, 0x00000002, BIT(PIPE_NONE) },
{ GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) },
{ GEN8_SP_HLSQ_DBG_ECO_CNTL, 0x04000000, BIT(PIPE_NONE) },
/* HLSQ ignores the shared constant feedback from SP:MAS */
{ GEN8_SP_HLSQ_DBG_ECO_CNTL_1, BIT(17), BIT(PIPE_NONE) },
/* Disable HLSQ large instruction async mode check */
{ GEN8_SP_HLSQ_DBG_ECO_CNTL_3, BIT(1), BIT(PIPE_NONE) },
{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) },
{ GEN8_SP_READ_SEL, 0x0001ff00, BIT(PIPE_NONE) },
{ GEN8_SP_L0_PERF_TUNE, 0x00000024, BIT(PIPE_NONE) },
/* BIT(20): Disable alpha only optimization in TP */
{ GEN8_TPL1_DBG_ECO_CNTL, 0x10100000, BIT(PIPE_NONE) },
{ GEN8_TPL1_DBG_ECO_CNTL1, 0x00000720, BIT(PIPE_NONE) },
/* GEN8_TPL1_NC_MODE_CNTL explicitly set elsewhere */
{ GEN8_UCHE_MODE_CNTL, 0x80080000, BIT(PIPE_NONE) },
{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
/* Disable return data forwarding in UCHE */
{ GEN8_UCHE_DBG_ECO_CNTL_0, BIT(31), BIT(PIPE_NONE) },
/* BIT(22): Skip FullDirty flag during tag check in UCHE */
{ GEN8_UCHE_HW_DBG_CNTL, 0x01410000, BIT(PIPE_NONE) },
{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) },
{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
/* Disable VFD sideband compression */
{ GEN8_VFD_DBG_ECO_CNTL, 0x00008400, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_LP_REQ_CNT, 0x00080020, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VSC_VISIBILITY_FLUSH_CNTL, 0x00080004, BIT(PIPE_NONE) },
{ 0 },
};
extern const struct gen8_snapshot_block_list gen8_11_0_snapshot_block_list;
static const struct kgsl_regmap_list gen8_11_0_gbif_cx_regs[] = {
{ GEN8_GBIF_QSB_SIDE0, 0x00071e20 },
{ GEN8_GBIF_QSB_SIDE1, 0x00071e20 },
{ GEN8_GBIF_QSB_SIDE2, 0x00071e20 },
{ GEN8_GBIF_QSB_SIDE3, 0x00071e20 },
{ GEN8_GBIF_CX_CONFIG, 0x20023020 },
{ GEN8_GMUCX_MRC_GBIF_QOS_CTRL, 0x33 },
};
static const struct adreno_gen8_core adreno_gpu_core_gen8_11_0 = {
.base = {
DEFINE_ADRENO_REV(ADRENO_REV_GEN8_11_0,
UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
.compatible = "qcom,adreno-gpu-gen8-11-0",
.features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_CLX,
.gpudev = &adreno_gen8_hwsched_gpudev.base,
.perfcounters = &adreno_gen8_2_x_perfcounters,
.uche_gmem_alignment = SZ_64M,
.gmem_size = 18 * SZ_1M,
.bus_width = 32,
.snapshot_size = SZ_8M,
.num_ddr_channels = 4,
.highest_bank_bit = 16,
},
.aqefw_name = "gen81100_aqe.fw",
.sqefw_name = "gen81100_sqe.fw",
.gmufw_name = "gen81100_gmu.bin",
.zap_name = "gen81100_zap.mbn",
.ao_hwcg = gen8_2_0_ao_hwcg_regs,
.ao_hwcg_count = ARRAY_SIZE(gen8_2_0_ao_hwcg_regs),
.gbif = gen8_11_0_gbif_cx_regs,
.gbif_count = ARRAY_SIZE(gen8_11_0_gbif_cx_regs),
.hang_detect_cycles = 0xcfffff,
.protected_regs = gen8_11_0_protected_regs,
.nonctxt_regs = gen8_11_0_nonctxt_regs,
.gmu_hub_clk_freq = 150000000,
.gen8_snapshot_block_list = &gen8_11_0_snapshot_block_list,
.fast_bus_hint = true,
.bcl_data = 1,
.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
.noc_timeout_us = 3410, /* 3.41 msec */
.cl_no_ft_timeout_ms = 6500,
.ctxt_record_size = (19708 * SZ_1K),
.limits_mit_cfg = &gen8_11_0_limits_mit_cfg,
.preempt_level = 1,
.gmu_mx_gdsc = true,
.three_rail_memory = true,
.malu = true,
.clx_tbl = &gen8_11_0_clx_table,
};
/* GEN8_11_1 noncontext register list */
static const struct gen8_nonctxt_regs gen8_11_1_nonctxt_regs[] = {
{ GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) },
{ GEN8_CP_MULTIDRAW_CNTL, 0x00000001, BIT(PIPE_NONE) },
/* Keep the raster direction as topleft */
{ GEN8_GRAS_DBG_ECO_CNTL, 0x01000800, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_GRAS_TSEFE_DBG_ECO_CNTL, 0x00200000, BIT(PIPE_BV) | BIT(PIPE_BR) },
/* GEN8_GRAS_NC_MODE_CNTL explicitly set elsewhere */
{ GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BV) | BIT(PIPE_BR) },
/* BIT(11): Disable skipIdx to avoid PDMA hang with restart-index draws */
{ GEN8_PC_CHICKEN_BITS_1, 0x00000803, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_CHICKEN_BITS_3, 0x00400000, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_CHICKEN_BITS_4, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
/*
* BIT(28): Disable GS Quad primitive
* BIT(30): Disable skipIdx to avoid PDMA hang with restart-index draws
*/
{ GEN8_PC_CHICKEN_BITS_5, BIT(28) | BIT(30), BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_RB_CCU_CNTL, 0x00000068, BIT(PIPE_BR) },
/*
* BIT(10): Disable sysmem nonfclear feature
* BIT(9): Disable DINT to c/z be data forwarding
*/
{ GEN8_RB_CCU_DBG_ECO_CNTL, BIT(10) | BIT(9), BIT(PIPE_BR) },
/* GEN8_RB_CCU_NC_MODE_CNTL explicitly set elsewhere */
/* GEN8_RB_CMP_NC_MODE_CNTL explicitly set elsewhere */
/* Disable early EOBlk return */
{ GEN8_RB_DBG_ECO_CNTL, BIT(17), BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_RB_GC_GMEM_PROTECT, 0x12000000, BIT(PIPE_BR) },
/*
* BIT(5): Disable dead draw merge scheme on RB-HLSQ
* BIT(6): Disable pre-mvcc dead draw merge scheme on LRZ-RB
*/
{ GEN8_RB_RBP_CNTL, BIT(5) | BIT(6), BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_RB_RESOLVE_PREFETCH_CNTL, 0x00000007, BIT(PIPE_BR) },
{ GEN8_RB_CMP_DBG_ECO_CNTL, 0x00004000, BIT(PIPE_BR) },
{ GEN8_RBBM_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) },
{ GEN8_RBBM_SLICE_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) },
/* Enable RB BAC strobes */
{ GEN8_RBBM_SLICE_PERFCTR_CNTL, BIT(0), BIT(PIPE_NONE) },
{ GEN8_RBBM_POWER_UP_RESET_SW_OVERRIDE, 0x70809060, BIT(PIPE_NONE) },
{ GEN8_RBBM_POWER_UP_RESET_SW_BV_OVERRIDE, 0x30000000, BIT(PIPE_NONE) },
{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL, 0x00000030, BIT(PIPE_NONE) },
{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2, 0x00000030, BIT(PIPE_NONE) },
/* GEN8_RBBM_INTERFACE_HANG_INT_CNTL explicitly set elsewhere */
{ GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 0x22122212, BIT(PIPE_NONE) },
{ GEN8_RBBM_CGC_P2S_CNTL, 0x00000040, BIT(PIPE_NONE) },
/* Disable VS delay resource optimization */
{ GEN8_SP_CHICKEN_BITS, BIT(24), BIT(PIPE_NONE) },
{ GEN8_SP_CHICKEN_BITS_2, 0x00820800, BIT(PIPE_NONE) },
{ GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) },
/* Disable last-use skip for gpr ALU Write Enable */
{ GEN8_SP_CHICKEN_BITS_5, BIT(3), BIT(PIPE_NONE) },
/* GEN8_SP_NC_MODE_CNTL explicitly set elsewhere */
{ GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) },
{ GEN8_SP_HLSQ_DBG_ECO_CNTL, 0x04000000, BIT(PIPE_NONE) },
/* HLSQ ignores the shared constant feedback from SP:MAS */
{ GEN8_SP_HLSQ_DBG_ECO_CNTL_1, BIT(17), BIT(PIPE_NONE) },
/* Disable HLSQ large instruction async mode check */
{ GEN8_SP_HLSQ_DBG_ECO_CNTL_3, BIT(1), BIT(PIPE_NONE) },
{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) },
{ GEN8_SP_READ_SEL, 0x0001ff00, BIT(PIPE_NONE) },
{ GEN8_SP_L0_PERF_TUNE, 0x00000024, BIT(PIPE_NONE) },
/* BIT(20): Disable alpha only optimization in TP */
{ GEN8_TPL1_DBG_ECO_CNTL, 0x10100000, BIT(PIPE_NONE) },
{ GEN8_TPL1_DBG_ECO_CNTL1, 0x00000720, BIT(PIPE_NONE) },
/* GEN8_TPL1_NC_MODE_CNTL explicitly set elsewhere */
{ GEN8_UCHE_MODE_CNTL, 0x80080000, BIT(PIPE_NONE) },
{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
/* Disable return data forwarding in UCHE */
{ GEN8_UCHE_DBG_ECO_CNTL_0, BIT(31), BIT(PIPE_NONE) },
/* BIT(22): Skip FullDirty flag during tag check in UCHE */
{ GEN8_UCHE_HW_DBG_CNTL, 0x01410000, BIT(PIPE_NONE) },
{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) },
{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_LP_REQ_CNT, 0x00080020, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VSC_VISIBILITY_FLUSH_CNTL, 0x00080004, BIT(PIPE_NONE) },
{ 0 },
};
static const struct adreno_gen8_core adreno_gpu_core_gen8_11_1 = {
.base = {
DEFINE_ADRENO_REV(ADRENO_REV_GEN8_11_1,
UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
.compatible = "qcom,adreno-gpu-gen8-11-1",
.features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_LPAC | ADRENO_PREEMPTION |
ADRENO_GMU_WARMBOOT | ADRENO_GMU_BASED_DCVS | ADRENO_CLX |
ADRENO_GMU_THERMAL_MITIGATION | ADRENO_AQE | ADRENO_CONTENT_PROTECTION |
ADRENO_BCL | ADRENO_DCVS_PROFILE | ADRENO_IFPC | ADRENO_GMU_MINBW |
ADRENO_DEFER_GMEM_ALLOC | ADRENO_GMU_FAST_CONTEXT_DESTROY |
ADRENO_ACD | ADRENO_GMU_AB | ADRENO_HW_FENCE,
.features_standard = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_PREEMPTION |
ADRENO_IFPC | ADRENO_AQE | ADRENO_CONTENT_PROTECTION | ADRENO_CLX |
ADRENO_GMU_FAST_CONTEXT_DESTROY | ADRENO_GMU_BASED_DCVS | ADRENO_ACD,
.gpudev = &adreno_gen8_hwsched_gpudev.base,
.perfcounters = &adreno_gen8_2_x_perfcounters,
.uche_gmem_alignment = SZ_64M,
.gmem_size = 18 * SZ_1M,
.bus_width = 32,
.snapshot_size = SZ_8M,
.num_ddr_channels = 4,
.highest_bank_bit = 16,
.chipid = 0x44051401,
.speedbins = KGSL_SPEEDBINS(
{ 0, 0 },
{ 284, 2 },
{ 216, 3 },
),
.ubwc_mode = 7,
.mal = 32,
},
.aqefw_name = "gen81100_aqe.fw",
.sqefw_name = "gen81100_sqe.fw",
.gmufw_name = "gen81100_gmu.bin",
.zap_name = "gen81100_zap.mbn",
.ao_hwcg = gen8_2_0_ao_hwcg_regs,
.ao_hwcg_count = ARRAY_SIZE(gen8_2_0_ao_hwcg_regs),
.gbif = gen8_11_0_gbif_cx_regs,
.gbif_count = ARRAY_SIZE(gen8_11_0_gbif_cx_regs),
.hang_detect_cycles = 0xcfffff,
.protected_regs = gen8_11_0_protected_regs,
.nonctxt_regs = gen8_11_1_nonctxt_regs,
.gmu_hub_clk_freq = 150000000,
.gen8_snapshot_block_list = &gen8_11_0_snapshot_block_list,
.fast_bus_hint = true,
.bcl_data = GEN8_2_X_BCL_DATA,
.acv_perfmode_ddr_freq = MHZ_TO_KBPS(4224, 4),
.noc_timeout_us = 3410, /* 3.41 msec */
.cl_no_ft_timeout_ms = 6500,
.ctxt_record_size = (19708 * SZ_1K),
.limits_mit_cfg = &gen8_11_0_limits_mit_cfg,
.preempt_level = 1,
.gmu_mx_gdsc = true,
.three_rail_memory = true,
.malu = true,
.clx_tbl = &gen8_11_0_clx_table,
};
static const struct gen8_nonctxt_regs gen8_14_0_nonctxt_regs[] = {
{ GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) },
{ GEN8_CP_MULTIDRAW_CNTL, 0x00000001, BIT(PIPE_NONE) },
/* Keep the raster direction as topleft */
{ GEN8_GRAS_DBG_ECO_CNTL, 0x01000800, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_GRAS_TSEFE_DBG_ECO_CNTL, 0x00200000, BIT(PIPE_BV) | BIT(PIPE_BR) },
/* GEN8_GRAS_NC_MODE_CNTL explicitly set elsewhere */
{ GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BV) | BIT(PIPE_BR) },
/* BIT(11): Disable skipIdx to avoid PDMA hang with restart-index draws */
{ GEN8_PC_CHICKEN_BITS_1, 0x00000803, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_CHICKEN_BITS_3, 0x00400000, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_PC_CHICKEN_BITS_4, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
/*
* BIT(28): Disable GS Quad primitive
* BIT(30): Disable skipIdx to avoid PDMA hang with restart-index draws
*/
{ GEN8_PC_CHICKEN_BITS_5, BIT(28) | BIT(30), BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_RB_CCU_CNTL, 0x00000068, BIT(PIPE_BR) },
/*
* BIT(10): Disable sysmem nonfclear feature
* BIT(9): Disable DINT to c/z be data forwarding
*/
{ GEN8_RB_CCU_DBG_ECO_CNTL, BIT(10) | BIT(9), BIT(PIPE_BR) },
/* GEN8_RB_CCU_NC_MODE_CNTL explicitly set elsewhere */
/* GEN8_RB_CMP_NC_MODE_CNTL explicitly set elsewhere */
/* Disable early EOBlk return */
{ GEN8_RB_DBG_ECO_CNTL, BIT(17), BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_RB_GC_GMEM_PROTECT, 0xC000000, BIT(PIPE_BR) },
/*
* BIT(5): Disable dead draw merge scheme on RB-HLSQ
* BIT(6): Disable pre-mvcc dead draw merge scheme on LRZ-RB
*/
{ GEN8_RB_RBP_CNTL, BIT(5) | BIT(6), BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_RB_RESOLVE_PREFETCH_CNTL, 0x00000007, BIT(PIPE_BR) },
{ GEN8_RB_CMP_DBG_ECO_CNTL, 0x00004000, BIT(PIPE_BR) },
{ GEN8_RBBM_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) },
{ GEN8_RBBM_SLICE_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) },
{ GEN8_RBBM_POWER_UP_RESET_SW_OVERRIDE, 0x70809060, BIT(PIPE_NONE) },
{ GEN8_RBBM_POWER_UP_RESET_SW_BV_OVERRIDE, 0x30000000, BIT(PIPE_NONE) },
{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL, 0x00000030, BIT(PIPE_NONE) },
{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2, 0x00000030, BIT(PIPE_NONE) },
/* GEN8_RBBM_INTERFACE_HANG_INT_CNTL explicitly set elsewhere */
{ GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 0x22122212, BIT(PIPE_NONE) },
{ GEN8_RBBM_CGC_P2S_CNTL, 0x00000040, BIT(PIPE_NONE) },
/* Disable VS delay resource optimization */
{ GEN8_SP_CHICKEN_BITS, BIT(24), BIT(PIPE_NONE) },
{ GEN8_SP_CHICKEN_BITS_2, 0x00820800, BIT(PIPE_NONE) },
{ GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) },
/* Disable last-use skip for gpr ALU Write Enable */
{ GEN8_SP_CHICKEN_BITS_5, BIT(3), BIT(PIPE_NONE) },
/* GEN8_SP_NC_MODE_CNTL explicitly set elsewhere */
{ GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) },
{ GEN8_SP_HLSQ_DBG_ECO_CNTL, 0x04000000, BIT(PIPE_NONE) },
/* HLSQ ignores the shared constant feedback from SP:MAS */
{ GEN8_SP_HLSQ_DBG_ECO_CNTL_1, BIT(17), BIT(PIPE_NONE) },
/* Disable HLSQ large instruction async mode check */
{ GEN8_SP_HLSQ_DBG_ECO_CNTL_3, BIT(1), BIT(PIPE_NONE) },
{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) },
{ GEN8_SP_READ_SEL, 0x0001ff00, BIT(PIPE_NONE) },
{ GEN8_SP_L0_PERF_TUNE, 0x00000024, BIT(PIPE_NONE) },
/* BIT(20): Disable alpha only optimization in TP */
{ GEN8_TPL1_DBG_ECO_CNTL, 0x10100000, BIT(PIPE_NONE) },
{ GEN8_TPL1_DBG_ECO_CNTL1, 0x00000720, BIT(PIPE_NONE) },
/* GEN8_TPL1_NC_MODE_CNTL explicitly set elsewhere */
{ GEN8_UCHE_MODE_CNTL, 0x80080000, BIT(PIPE_NONE) },
{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
/* Disable return data forwarding in UCHE */
{ GEN8_UCHE_DBG_ECO_CNTL_0, BIT(31), BIT(PIPE_NONE) },
/* BIT(22): Skip FullDirty flag during tag check in UCHE */
{ GEN8_UCHE_HW_DBG_CNTL, 0x01410000, BIT(PIPE_NONE) },
{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) },
{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VFD_CB_LP_REQ_CNT, 0x00080020, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
{ GEN8_VSC_VISIBILITY_FLUSH_CNTL, 0x00080004, BIT(PIPE_NONE) },
{ 0 },
};
static const struct adreno_gen8_core adreno_gpu_core_gen8_14_0 = {
.base = {
DEFINE_ADRENO_REV(ADRENO_REV_GEN8_14_0,
UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
.compatible = "qcom,adreno-gpu-gen8-14-0",
.features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_LPAC | ADRENO_PREEMPTION |
ADRENO_GMU_WARMBOOT | ADRENO_GMU_BASED_DCVS |
ADRENO_GMU_THERMAL_MITIGATION | ADRENO_AQE | ADRENO_CONTENT_PROTECTION |
ADRENO_DCVS_PROFILE | ADRENO_IFPC | ADRENO_GMU_MINBW |
ADRENO_DEFER_GMEM_ALLOC | ADRENO_GMU_FAST_CONTEXT_DESTROY |
ADRENO_GMU_AB | ADRENO_HW_FENCE | ADRENO_CLX | ADRENO_ACD,
.features_standard = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_PREEMPTION |
ADRENO_IFPC | ADRENO_AQE | ADRENO_CONTENT_PROTECTION | ADRENO_CLX |
ADRENO_GMU_FAST_CONTEXT_DESTROY | ADRENO_GMU_BASED_DCVS,
.gpudev = &adreno_gen8_hwsched_gpudev.base,
.perfcounters = &adreno_gen8_2_x_perfcounters,
.uche_gmem_alignment = SZ_64M,
.gmem_size = 12 * SZ_1M,
.bus_width = 32,
.snapshot_size = SZ_8M,
.num_ddr_channels = 4,
.highest_bank_bit = 16,
.chipid = 0x44041400,
.speedbins = KGSL_SPEEDBINS(
{ 0, 0 },
{ 216, 0 },
{ 284, 1 },
),
.ubwc_mode = 7,
.mal = 32,
},
.aqefw_name = "gen81100_aqe.fw",
.sqefw_name = "gen81100_sqe.fw",
.gmufw_name = "gen81400_gmu.bin",
.zap_name = "gen81100_zap.mbn",
.ao_hwcg = gen8_2_0_ao_hwcg_regs,
.ao_hwcg_count = ARRAY_SIZE(gen8_2_0_ao_hwcg_regs),
.gbif = gen8_11_0_gbif_cx_regs,
.gbif_count = ARRAY_SIZE(gen8_11_0_gbif_cx_regs),
.hang_detect_cycles = 0xcfffff,
.protected_regs = gen8_11_0_protected_regs,
.nonctxt_regs = gen8_14_0_nonctxt_regs,
.gmu_hub_clk_freq = 150000000,
.gen8_snapshot_block_list = &gen8_11_0_snapshot_block_list,
.fast_bus_hint = true,
.acv_perfmode_ddr_freq = MHZ_TO_KBPS(4224, 4),
.noc_timeout_us = 3410, /* 3.41 msec */
.cl_no_ft_timeout_ms = 6500,
.ctxt_record_size = (13564 * SZ_1K),
.limits_mit_cfg = &gen8_11_0_limits_mit_cfg,
.preempt_level = 1,
.gmu_mx_gdsc = true,
.three_rail_memory = true,
.malu = false,
.clx_tbl = &gen8_14_0_clx_table,
};
static const struct adreno_gpu_core *adreno_gpulist[] = {
&adreno_gpu_core_a306, /* Deprecated */
&adreno_gpu_core_a306a, /* Deprecated */
&adreno_gpu_core_a304, /* Deprecated */
&adreno_gpu_core_a405, /* Deprecated */
&adreno_gpu_core_a418, /* Deprecated */
&adreno_gpu_core_a420, /* Deprecated */
&adreno_gpu_core_a430, /* Deprecated */
&adreno_gpu_core_a530v1, /* Deprecated */
&adreno_gpu_core_a530v2.base,
&adreno_gpu_core_a530v3.base,
&adreno_gpu_core_a505.base,
&adreno_gpu_core_a506.base,
&adreno_gpu_core_a510.base,
&adreno_gpu_core_a540v1, /* Deprecated */
&adreno_gpu_core_a540v2.base,
&adreno_gpu_core_a512.base,
&adreno_gpu_core_a508.base,
&adreno_gpu_core_a630v1, /* Deprecated */
&adreno_gpu_core_a630v2.base,
&adreno_gpu_core_a615.base,
&adreno_gpu_core_a618.base,
&adreno_gpu_core_a619.base,
&adreno_gpu_core_a619_variant.base,
&adreno_gpu_core_a620.base,
&adreno_gpu_core_a621.base,
&adreno_gpu_core_a622.base,
&adreno_gpu_core_a623.base,
&adreno_gpu_core_a640.base,
&adreno_gpu_core_a642l.base,
&adreno_gpu_core_a643.base,
&adreno_gpu_core_a650.base,
&adreno_gpu_core_a650v2.base,
&adreno_gpu_core_a660.base,
&adreno_gpu_core_a660v2.base,
&adreno_gpu_core_a663.base,
&adreno_gpu_core_a680.base,
&adreno_gpu_core_a612.base,
&adreno_gpu_core_a616.base,
&adreno_gpu_core_a610.base,
&adreno_gpu_core_a611.base,
&adreno_gpu_core_a660_shima.base,
&adreno_gpu_core_gen6_3_26_0.base,
&adreno_gpu_core_a702.base,
&adreno_gpu_core_a704.base,
&adreno_gpu_core_gen7_0_0.base,
&adreno_gpu_core_gen7_0_1.base,
&adreno_gpu_core_a662.base,
&adreno_gpu_core_gen7_2_0.base,
&adreno_gpu_core_gen7_2_1.base,
&adreno_gpu_core_gen7_3_0.base,
&adreno_gpu_core_gen7_4_0.base,
&adreno_gpu_core_gen7_5_0.base,
&adreno_gpu_core_gen7_6_0.base,
&adreno_gpu_core_gen7_9_0.base,
&adreno_gpu_core_gen7_9_1.base,
&adreno_gpu_core_gen7_13_0.base,
&adreno_gpu_core_gen7_14_0.base,
&adreno_gpu_core_gen7_11_0.base,
&adreno_gpu_core_gen7_15_0.base,
&adreno_gpu_core_gen7_17_0.base,
&adreno_gpu_core_gen8_0_0.base,
&adreno_gpu_core_gen8_0_1.base,
&adreno_gpu_core_gen8_1_0.base,
&adreno_gpu_core_gen8_2_0.base,
&adreno_gpu_core_gen8_2_1.base,
&adreno_gpu_core_gen8_3_0.base,
&adreno_gpu_core_gen8_4_0.base,
&adreno_gpu_core_gen8_5_0.base,
&adreno_gpu_core_gen8_6_0.base,
&adreno_gpu_core_gen8_8_0.base,
&adreno_gpu_core_gen8_9_0.base,
&adreno_gpu_core_gen8_10_0.base,
&adreno_gpu_core_gen8_11_0.base,
&adreno_gpu_core_gen8_11_1.base,
&adreno_gpu_core_gen8_14_0.base,
};
==========================================================================================
FILE: adreno.c
LINES: 5142 | BYTES: 146831
==========================================================================================
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2002,2007-2021, The Linux Foundation. All rights reserved.
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/
#include <linux/component.h>
#include <linux/delay.h>
#include <linux/devfreq.h>
#include <linux/firmware.h>
#include <linux/input.h>
#include <linux/interconnect.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/of_fdt.h>
#include <linux/module.h>
#include <linux/msm_kgsl.h>
#include <linux/regulator/consumer.h>
#include <linux/nvmem-consumer.h>
#include <linux/pm_domain.h>
#include <linux/reset.h>
#include <linux/soc/qcom/mdt_loader.h>
#include <linux/trace.h>
#include <linux/units.h>
#include <linux/version.h>
#include <soc/qcom/dcvs.h>
#include <soc/qcom/socinfo.h>
#include <linux/suspend.h>
#if (KERNEL_VERSION(6, 10, 0) <= LINUX_VERSION_CODE)
#include <linux/soc/qcom/socinfo.h>
#endif
#if (KERNEL_VERSION(6, 17, 0) <= LINUX_VERSION_CODE)
#include <linux/soc/qcom/ubwc.h>
#endif
#include "adreno.h"
#include "adreno_a6xx.h"
#include "adreno_compat.h"
#include "adreno_pm4types.h"
#include "adreno_trace.h"
#include "kgsl_bus.h"
#include "kgsl_gmu_core.h"
#include "kgsl_power_trace.h"
#include "kgsl_reclaim.h"
#include "kgsl_trace.h"
#include "kgsl_util.h"
/* Include the master list of GPU cores that are supported */
#include "adreno-gpulist.h"
#define HOSTADDR_IN_MEMDESC(_addr, _memdesc) \
(((_addr) >= (_memdesc)->hostptr) && \
((_addr) < ((_memdesc)->hostptr + (_memdesc)->size)))
/* Indicates that the context record table is present in CP ucode */
#define CTXT_RECORD_TBL_MAGIC 0xADDED
#define CTXT_RECORD_MAGIC_OFFSET 5
#define CTXT_TBL_OFFSET 6
/* Mask for extracting the instruction payload from ucode instructions */
#define CTXT_RECORD_PAYLOAD_MASK GENMASK(23, 0)
/**
* struct gpu_ctxt_record - Information about GPU context record, defined per GPU.
* If a ucode is shared by multiple targets, there will be multiple instances
* of this structure embedded in the ucode. Instances of this structure will be
* present immediately after ctxt_record_info.
*/
struct gpu_ctxt_record {
/**
* @hw_version: GPU hardware version
* [15:0]: Step, should be 0.
* [27:16]: Minor
* [31:28]: Major
*/
u32 hw_version;
/** @ctxt_record_size: Size of preemption record in KB */
u32 ctxt_record_size;
/** aqe_size: Size of AQE in preemption record in KB */
u32 aqe_size;
} __packed;
struct ctxt_record_info {
/**
* @version: Version of the ctxt_record_info structure
* [11:0]: Minor, [31:12]: Major.
* Major version changes whenever a true incompatibility is generated.
*/
u32 version;
/** @dwords_per_gpu: DWORD size of struct gpu_ctxt_record */
u16 dwords_per_gpu;
/** @num_gpus: For targets that share same ucode binary, num_gpus > 1, otherwise 1 */
u16 num_gpus;
/** @reserved: for future use */
u32 reserved[2];
} __packed;
static void adreno_unbind(struct device *dev);
static void adreno_input_work(struct work_struct *work);
static int adreno_soft_reset(struct kgsl_device *device);
static unsigned int counter_delta(struct kgsl_device *device,
unsigned int reg, unsigned int *counter);
static struct device_node *
adreno_get_gpu_model_node(struct platform_device *pdev);
static struct adreno_device device_3d0;
static bool adreno_preemption_enable;
static u32 kgsl_gpu_sku_override = U32_MAX;
static u32 kgsl_gpu_speed_bin_override = U32_MAX;
u32 adreno_slice_mask_override = U32_MAX;
/* Nice level for the higher priority GPU start thread */
int adreno_wake_nice = -7;
/* Number of milliseconds to stay active after a wake on touch */
unsigned int adreno_wake_timeout = 100;
static u32 get_ucode_version(const u32 *data)
{
u32 version;
version = data[1];
if ((version & 0xf) != 0xa)
return version;
version &= ~0xfff;
return version | ((data[3] & 0xfff000) >> 12);
}
int adreno_populate_ctxt_record_size(struct adreno_device *adreno_dev)
{
struct kgsl_memdesc *memdesc = ADRENO_FW(adreno_dev, ADRENO_FW_SQE)->memdesc;
struct ctxt_record_info *info;
u32 *hostptr;
int i;
if (!memdesc)
return -ENODEV;
hostptr = (u32 *)memdesc->hostptr;
/*
* SQE firmware inserts context record magic at offset 5.
* The pointer to context record table is stored at offset 6.
* The values are stored at [23:0].
*/
if ((hostptr[CTXT_RECORD_MAGIC_OFFSET] &
CTXT_RECORD_PAYLOAD_MASK) != CTXT_RECORD_TBL_MAGIC)
return -ENODEV;
/* Calculate the address of the context record table */
hostptr += (hostptr[CTXT_TBL_OFFSET] & CTXT_RECORD_PAYLOAD_MASK);
info = (struct ctxt_record_info *) hostptr;
hostptr += (sizeof(*info) >> 2);
/* Validate that the entire context record table is within mapped range */
if (!HOSTADDR_IN_MEMDESC((void *)(hostptr +
((u64) info->num_gpus * (u64) info->dwords_per_gpu)), memdesc))
return -EACCES;
for (i = 0; i < info->num_gpus; i++) {
struct gpu_ctxt_record *record = (struct gpu_ctxt_record *) hostptr;
u32 major, minor;
/* Compare the GPU revision to determine context record size */
major = FIELD_GET(GENMASK(31, 28), record->hw_version);
minor = FIELD_GET(GENMASK(27, 16), record->hw_version);
if ((ADRENO_REV_MAJOR(ADRENO_GPUREV(adreno_dev)) == major) &&
(ADRENO_REV_MINOR(ADRENO_GPUREV(adreno_dev)) == minor)) {
adreno_dev->total_ctxt_record_sz = record->ctxt_record_size * SZ_1K;
/* From v0.2, GMEM size is not exposed through ucode binary */
if ((info->version & GENMASK(11, 0)) >= 2)
adreno_dev->total_ctxt_record_sz += adreno_gmem_size(adreno_dev);
adreno_dev->aqe_ctxt_record_sz = record->aqe_size * SZ_1K;
return 0;
}
hostptr += info->dwords_per_gpu;
}
return -ENOENT;
}
struct adreno_fw_work {
struct work_struct work;
const struct firmware **fw;
const char *name;
struct device *device;
int ret;
};
static void adreno_fw_load_worker(struct work_struct *work)
{
struct adreno_fw_work *fw_work =
container_of(work, struct adreno_fw_work, work);
fw_work->ret = firmware_request_nowarn(fw_work->fw, fw_work->name, fw_work->device);
}
static int adreno_fw_dispatch(struct adreno_fw_work *work)
{
queue_work(kgsl_driver.lockless_workqueue, &work->work);
flush_work(&work->work);
return work->ret;
}
/*
* Dispatch firmware_request_nowarn() to a workqueue thread rather than calling
* it directly. When the GPU device is first opened, request_firmware() would
* otherwise be called from within the path_openat() call chain
* (open -> kgsl_open -> ... -> adreno_request_firmware). The kernel tracks
* symlink traversal depth in current->nameidata->total_link_count, which is
* never reset between nested path_openat() calls. With multiple firmware files,
* compressed variants, and symlinks in the firmware search paths (e.g.
* /lib -> /usr/lib), total_link_count can reach MAXSYMLINKS (40), causing
* request_firmware() to fail with -ELOOP. A workqueue thread has
* current->nameidata == NULL, so total_link_count is reset for every lookup.
*/
int adreno_request_firmware(const struct firmware **fw, const char *name,
struct device *device, bool log_error)
{
struct adreno_fw_work work = {
.fw = fw, .name = name, .device = device,
};
int ret;
INIT_WORK_ONSTACK(&work.work, adreno_fw_load_worker);
ret = adreno_fw_dispatch(&work);
if (!ret)
goto out;
work.name = kasprintf(GFP_KERNEL, "qcom/%s", name);
if (!work.name) {
ret = -ENOMEM;
goto out;
}
ret = adreno_fw_dispatch(&work);
if (ret && log_error)
dev_err(device, "Firmware request for %s failed with error %d\n",
name, ret);
kfree(work.name);
out:
destroy_work_on_stack(&work.work);
return ret;
}
int adreno_get_firmware(struct adreno_device *adreno_dev,
const char *fwfile, struct adreno_firmware *firmware)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
const struct firmware *fw = NULL;
int ret;
if (!IS_ERR_OR_NULL(firmware->memdesc))
return 0;
ret = adreno_request_firmware(&fw, fwfile, &device->pdev->dev, true);
if (ret)
return ret;
firmware->memdesc = kgsl_allocate_global(device, fw->size - 4, 0,
KGSL_MEMFLAGS_GPUREADONLY, KGSL_MEMDESC_UCODE,
"ucode");
ret = PTR_ERR_OR_ZERO(firmware->memdesc);
if (!ret) {
memcpy(firmware->memdesc->hostptr, &fw->data[4], fw->size - 4);
firmware->size = (fw->size - 4) / sizeof(u32);
firmware->version = get_ucode_version((u32 *)fw->data);
}
release_firmware(fw);
return ret;
}
/*
* The PASID has stayed consistent across all targets thus far so we are
* cautiously optimistic that we can hard code it
*/
#define GPU_PASID 13
/* True when zap-shader is present */
static bool adreno_check_zap_enabled(struct kgsl_device *device)
{
struct device_node *np = of_get_child_by_name(device->pdev->dev.of_node,
"zap-shader");
bool present = of_device_is_available(np);
of_node_put(np);
return present;
}
int adreno_zap_shader_load(struct adreno_device *adreno_dev,
const char *name)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
struct device_node *np, *mem_np;
struct device *dev = &device->pdev->dev;
const char *firmware_name = NULL;
const struct firmware *fw;
void *mem_region = NULL;
phys_addr_t mem_phys;
struct resource res;
ssize_t mem_size;
int ret;
if (adreno_dev->zap_loaded || IS_ENABLED(CONFIG_QCOM_KVM_ENABLED) ||
!adreno_dev->zap_enabled)
return 0;
np = of_get_child_by_name(dev->of_node, "zap-shader");
if (!np)
return -ENODEV;
/*
* While loading the zap firmware, follow the priority order below to determine
* the firmware name:
* 1. Check the "firmware-name" property in the device tree to identify the
* firmware path.
* 2. If not specified, fall back to the zap entry defined in the GPU list.
* 3. If both are missing, skip zap fw loading and use direct register write
* to switch secure state.
*/
of_property_read_string(np, "firmware-name", &firmware_name);
firmware_name = firmware_name ?: name;
if (!firmware_name) {
of_node_put(np);
return 0;
}
if (!np) {
dev_err(device->dev, "zap-shader node not found. Please update the device tree\n");
of_node_put(np);
return -ENODEV;
}
mem_np = of_parse_phandle(np, "memory-region", 0);
of_node_put(np);
if (!mem_np) {
dev_err(dev, "Couldn't parse the mem-region from the zap-shader node\n");
return -EINVAL;
}
ret = of_address_to_resource(mem_np, 0, &res);
of_node_put(mem_np);
if (ret)
return ret;
ret = adreno_request_firmware(&fw, firmware_name, dev, true);
if (ret)
return ret;
mem_size = qcom_mdt_get_size(fw);
if (mem_size < 0) {
ret = mem_size;
goto out;
}
if (mem_size > resource_size(&res)) {
ret = -E2BIG;
goto out;
}
mem_phys = res.start;
mem_region = memremap(mem_phys, mem_size, MEMREMAP_WC);
if (!mem_region) {
ret = -ENOMEM;
goto out;
}
ret = qcom_mdt_load(dev, fw, firmware_name, GPU_PASID, mem_region,
mem_phys, mem_size, NULL);
if (ret) {
dev_err(dev, "Error %d while loading the MDT\n", ret);
goto out;
}
ret = kgsl_pas_auth_and_reset(GPU_PASID);
out:
if (mem_region)
memunmap(mem_region);
release_firmware(fw);
if (!ret)
adreno_dev->zap_loaded = true;
return ret;
}
#if (IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION) || IS_ENABLED(CONFIG_DEEPSLEEP))
static void adreno_zap_shader_unload(struct adreno_device *adreno_dev)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
int ret;
if (adreno_dev->zap_loaded) {
ret = kgsl_pas_shutdown(GPU_PASID);
if (ret)
dev_err(&device->pdev->dev, "Error %d while PAS shutdown\n", ret);
else
adreno_dev->zap_loaded = false;
}
}
#endif
/**
* adreno_readreg64() - Read a 64bit register by getting its offset from the
* offset array defined in gpudev node
* @adreno_dev: Pointer to the adreno device
* @lo: lower 32bit register enum that is to be read
* @hi: higher 32bit register enum that is to be read
* @val: 64 bit Register value read is placed here
*/
void adreno_readreg64(struct adreno_device *adreno_dev,
enum adreno_regs lo, enum adreno_regs hi, uint64_t *val)
{
const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
unsigned int val_lo = 0, val_hi = 0;
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
if (adreno_checkreg_off(adreno_dev, lo))
kgsl_regread(device, gpudev->reg_offsets[lo], &val_lo);
if (adreno_checkreg_off(adreno_dev, hi))
kgsl_regread(device, gpudev->reg_offsets[hi], &val_hi);
*val = (val_lo | ((uint64_t)val_hi << 32));
}
/**
* adreno_get_rptr() - Get the current ringbuffer read pointer
* @rb: Pointer the ringbuffer to query
*
* Get the latest rptr
*/
unsigned int adreno_get_rptr(struct adreno_ringbuffer *rb)
{
struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
u32 rptr = 0;
kgsl_sharedmem_readl(device->scratch, &rptr,
SCRATCH_RB_OFFSET(rb->id, rptr));
return rptr;
}
static void adreno_touch_wakeup(struct adreno_device *adreno_dev)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
/*
* Don't schedule adreno_start in a high priority workqueue, we are
* already in a workqueue which should be sufficient
*/
kgsl_pwrctrl_change_state(device, KGSL_STATE_ACTIVE);
/*
* When waking up from a touch event we want to stay active long enough
* for the user to send a draw command. The default idle timer timeout
* is shorter than we want so go ahead and push the idle timer out
* further for this special case
*/
mod_timer(&device->idle_timer,
jiffies + msecs_to_jiffies(adreno_wake_timeout));
}
/*
* A workqueue callback responsible for actually turning on the GPU after a
* touch event. kgsl_pwrctrl_change_state(ACTIVE) is used without any
* active_count protection to avoid the need to maintain state. Either
* somebody will start using the GPU or the idle timer will fire and put the
* GPU back into slumber.
*/
static void adreno_input_work(struct work_struct *work)
{
struct adreno_device *adreno_dev = container_of(work,
struct adreno_device, input_work);
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);
kgsl_mutex_lock(&device->mutex);
device->pwrctrl.wake_on_touch = true;
ops->touch_wakeup(adreno_dev);
kgsl_mutex_unlock(&device->mutex);
}
/* Wake up the touch event kworker to initiate GPU wakeup */
void adreno_touch_wake(struct kgsl_device *device)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
/*
* Don't do anything if anything hasn't been rendered since we've been
* here before
*/
if (device->pwrctrl.wake_on_touch)
return;
if (device->state == KGSL_STATE_SLUMBER)
schedule_work(&adreno_dev->input_work);
}
/*
* Process input events and schedule work if needed. At this point we are only
* interested in groking EV_ABS touchscreen events
*/
static void adreno_input_event(struct input_handle *handle, unsigned int type,
unsigned int code, int value)
{
struct kgsl_device *device = handle->handler->private;
/* Only consider EV_ABS (touch) events */
if (type == EV_ABS)
adreno_touch_wake(device);
}
#ifdef CONFIG_INPUT
static int adreno_input_connect(struct input_handler *handler,
struct input_dev *dev, const struct input_device_id *id)
{
struct input_handle *handle;
int ret;
handle = kzalloc(sizeof(*handle), GFP_KERNEL);
if (handle == NULL)
return -ENOMEM;
handle->dev = dev;
handle->handler = handler;
handle->name = handler->name;
ret = input_register_handle(handle);
if (ret) {
kfree(handle);
return ret;
}
ret = input_open_device(handle);
if (ret) {
input_unregister_handle(handle);
kfree(handle);
}
return ret;
}
static void adreno_input_disconnect(struct input_handle *handle)
{
input_close_device(handle);
input_unregister_handle(handle);
kfree(handle);
}
#else
static int adreno_input_connect(struct input_handler *handler,
struct input_dev *dev, const struct input_device_id *id)
{
return 0;
}
static void adreno_input_disconnect(struct input_handle *handle) {}
#endif
/*
* We are only interested in EV_ABS events so only register handlers for those
* input devices that have EV_ABS events
*/
static const struct input_device_id adreno_input_ids[] = {
{
.flags = INPUT_DEVICE_ID_MATCH_EVBIT,
.evbit = { BIT_MASK(EV_ABS) },
/* assumption: MT_.._X & MT_.._Y are in the same long */
.absbit = { [BIT_WORD(ABS_MT_POSITION_X)] =
BIT_MASK(ABS_MT_POSITION_X) |
BIT_MASK(ABS_MT_POSITION_Y) },
},
{ },
};
static struct input_handler adreno_input_handler = {
.event = adreno_input_event,
.connect = adreno_input_connect,
.disconnect = adreno_input_disconnect,
.name = "kgsl",
.id_table = adreno_input_ids,
};
/*
* _soft_reset() - Soft reset GPU
* @adreno_dev: Pointer to adreno device
*
* Soft reset the GPU by doing a AHB write of value 1 to RBBM_SW_RESET
* register. This is used when we want to reset the GPU without
* turning off GFX power rail. The reset when asserted resets
* all the HW logic, restores GPU registers to default state and
* flushes out pending VBIF transactions.
*/
static void _soft_reset(struct adreno_device *adreno_dev)
{
const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
unsigned int reg;
adreno_writereg(adreno_dev, ADRENO_REG_RBBM_SW_RESET_CMD, 1);
/*
* Do a dummy read to get a brief read cycle delay for the
* reset to take effect
*/
adreno_readreg(adreno_dev, ADRENO_REG_RBBM_SW_RESET_CMD, ®);
adreno_writereg(adreno_dev, ADRENO_REG_RBBM_SW_RESET_CMD, 0);
/* The SP/TP regulator gets turned off after a soft reset */
clear_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED, &adreno_dev->priv);
if (gpudev->regulator_enable)
gpudev->regulator_enable(adreno_dev);
}
/**
* adreno_irqctrl() - Enables/disables the RBBM interrupt mask
* @adreno_dev: Pointer to an adreno_device
* @state: 1 for masked or 0 for unmasked
* Power: The caller of this function must make sure to use OOBs
* so that we know that the GPU is powered on
*/
void adreno_irqctrl(struct adreno_device *adreno_dev, int state)
{
const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
if (!adreno_dev->irq_mask)
return;
adreno_writereg(adreno_dev, ADRENO_REG_RBBM_INT_0_MASK,
state ? adreno_dev->irq_mask : 0);
if (gpudev->swfuse_irqctrl)
gpudev->swfuse_irqctrl(adreno_dev, state);
}
/*
* adreno_hang_int_callback() - Isr for fatal interrupts that hang GPU
* @adreno_dev: Pointer to device
* @bit: Interrupt bit
*/
void adreno_hang_int_callback(struct adreno_device *adreno_dev, int bit)
{
dev_crit_ratelimited(KGSL_DEVICE(adreno_dev)->dev,
"MISC: GPU hang detected\n");
adreno_irqctrl(adreno_dev, 0);
/* Trigger a fault in the dispatcher - this will effect a restart */
adreno_scheduler_fault(adreno_dev, ADRENO_HARD_FAULT);
}
/*
* adreno_cp_callback() - CP interrupt handler
* @adreno_dev: Adreno device pointer
* @irq: irq number
*
* Handle the cp interrupt generated by GPU.
*/
void adreno_cp_callback(struct adreno_device *adreno_dev, int bit)
{
adreno_scheduler_queue(adreno_dev);
}
static irqreturn_t adreno_irq_handler(int irq, void *data)
{
struct kgsl_device *device = data;
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
irqreturn_t ret;
atomic_inc(&adreno_dev->pending_irq_refcnt);
/* Ensure this increment is done before the IRQ status is updated */
smp_mb__after_atomic();
ret = gpudev->irq_handler(adreno_dev);
/* Make sure the regwrites are done before the decrement */
smp_mb__before_atomic();
atomic_dec(&adreno_dev->pending_irq_refcnt);
/* Ensure other CPUs see the decrement */
smp_mb__after_atomic();
return ret;
}
static irqreturn_t adreno_freq_limiter_irq_handler(int irq, void *data)
{
struct kgsl_device *device = data;
KGSL_PWRCTRL_LOG_FREQLIM(device);
reset_control_reset(device->freq_limiter_irq_clear);
return IRQ_HANDLED;
}
irqreturn_t adreno_irq_callbacks(struct adreno_device *adreno_dev,
const struct adreno_irq_funcs *funcs, u32 status)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
irqreturn_t ret = IRQ_NONE;
/* Loop through all set interrupts and call respective handlers */
while (status) {
int i = fls(status) - 1;
if (funcs[i].func) {
if (adreno_dev->irq_mask & BIT(i))
funcs[i].func(adreno_dev, i);
} else
dev_crit_ratelimited(device->dev,
"Unhandled interrupt bit %x\n", i);
ret = IRQ_HANDLED;
status &= ~BIT(i);
}
return ret;
}
static int adreno_get_chipid(struct platform_device *pdev, u32 *chipid);
static inline bool _rev_match(unsigned int id, unsigned int entry)
{
return (entry == ANY_ID || entry == id);
}
static const struct adreno_gpu_core *
_get_gpu_core_standard(struct platform_device *pdev, u32 *chipid)
{
const char *compat;
u32 core, major, minor, patchid;
u32 lookup_chipid = 0;
int i;
if (of_property_read_string_index(pdev->dev.of_node, "compatible", 0, &compat)) {
dev_err(&pdev->dev, "Failed to read compatible string\n");
return NULL;
}
/*
* Match "qcom,adreno-<core><major><minor>.<patch>" or version-style
* "qcom,adreno-<chipid>"; Extract chip ID and search the GPU list entry.
*/
if (sscanf(compat, "qcom,adreno-%1u%1u%1u.%u", &core, &major, &minor, &patchid) == 4)
lookup_chipid = (core << 24) | (major << 16) | (minor << 8) | patchid;
else if (sscanf(compat, "qcom,adreno-%08x", &lookup_chipid) != 1)
return NULL;
for (i = 0; i < ARRAY_SIZE(adreno_gpulist); i++) {
if (adreno_gpulist[i]->chipid == lookup_chipid) {
*chipid = adreno_gpulist[i]->chipid;
return adreno_gpulist[i];
}
}
return NULL;
}
static const struct adreno_gpu_core *
_get_gpu_core(struct platform_device *pdev, u32 *chipid)
{
int i;
struct device_node *node;
const struct adreno_gpu_core *core;
*chipid = 0;
core = _get_gpu_core_standard(pdev, chipid);
if (core)
return core;
/*
* When "qcom,gpu-models" is defined, use gpu model node to match
* on a compatible string, otherwise match using legacy way.
*/
node = adreno_get_gpu_model_node(pdev);
if (!node || !of_find_property(node, "compatible", NULL))
node = pdev->dev.of_node;
/* Check to see if any of the entries match on a compatible string */
for (i = 0; i < ARRAY_SIZE(adreno_gpulist); i++) {
if (adreno_gpulist[i]->compatible &&
of_device_is_compatible(node,
adreno_gpulist[i]->compatible)) {
/*
* We matched compat string, set chipid based on
* dtsi, else fail.
*/
if (!adreno_get_chipid(pdev, chipid))
return adreno_gpulist[i];
dev_crit(&pdev->dev,
"No chipid associated with %s\n",
adreno_gpulist[i]->compatible);
return NULL;
}
}
/* No compatible string so try and match on chipid */
if (!adreno_get_chipid(pdev, chipid)) {
unsigned int core = ADRENO_CHIPID_CORE(*chipid);
unsigned int major = ADRENO_CHIPID_MAJOR(*chipid);
unsigned int minor = ADRENO_CHIPID_MINOR(*chipid);
unsigned int patchid = ADRENO_CHIPID_PATCH(*chipid);
for (i = 0; i < ARRAY_SIZE(adreno_gpulist); i++) {
if (core == adreno_gpulist[i]->core &&
_rev_match(major, adreno_gpulist[i]->major) &&
_rev_match(minor, adreno_gpulist[i]->minor) &&
_rev_match(patchid, adreno_gpulist[i]->patchid))
return adreno_gpulist[i];
}
}
dev_crit(&pdev->dev, "Unknown GPU chip ID %8.8x\n", *chipid);
return NULL;
}
static struct {
unsigned int quirk;
const char *prop;
} adreno_quirks[] = {
{ ADRENO_QUIRK_TWO_PASS_USE_WFI, "qcom,gpu-quirk-two-pass-use-wfi" },
{ ADRENO_QUIRK_CRITICAL_PACKETS, "qcom,gpu-quirk-critical-packets" },
{ ADRENO_QUIRK_FAULT_DETECT_MASK, "qcom,gpu-quirk-fault-detect-mask" },
{ ADRENO_QUIRK_DISABLE_RB_DP2CLOCKGATING,
"qcom,gpu-quirk-dp2clockgating-disable" },
{ ADRENO_QUIRK_DISABLE_LMLOADKILL,
"qcom,gpu-quirk-lmloadkill-disable" },
{ ADRENO_QUIRK_HFI_USE_REG, "qcom,gpu-quirk-hfi-use-reg" },
{ ADRENO_QUIRK_SECVID_SET_ONCE, "qcom,gpu-quirk-secvid-set-once" },
{ ADRENO_QUIRK_LIMIT_UCHE_GBIF_RW,
"qcom,gpu-quirk-limit-uche-gbif-rw" },
{ ADRENO_QUIRK_CX_GDSC, "qcom,gpu-quirk-cx-gdsc" },
};
static int adreno_get_chipid(struct platform_device *pdev, u32 *chipid)
{
u32 id;
if (!of_property_read_u32(pdev->dev.of_node, "qcom,chipid", chipid))
return 0;
id = socinfo_get_partinfo_chip_id(SOCINFO_PART_GPU);
if (id)
*chipid = id;
return id ? 0 : -EINVAL;
}
static void
adreno_update_soc_hw_revision_quirks(struct adreno_device *adreno_dev,
struct platform_device *pdev)
{
struct device_node *node = pdev->dev.of_node;
int i;
/* update quirk */
for (i = 0; i < ARRAY_SIZE(adreno_quirks); i++) {
if (of_property_read_bool(node, adreno_quirks[i].prop))
adreno_dev->quirks |= adreno_quirks[i].quirk;
}
}
static const struct adreno_gpu_core *
adreno_identify_gpu(struct platform_device *pdev, u32 *chipid)
{
const struct adreno_gpu_core *gpucore;
gpucore = _get_gpu_core(pdev, chipid);
if (!gpucore)
return ERR_PTR(-ENODEV);
/*
* Identify non-longer supported targets and spins and print a helpful
* message
*/
if (gpucore->features & ADRENO_DEPRECATED) {
if (gpucore->compatible)
dev_err(&pdev->dev,
"Support for GPU %s has been deprecated\n",
gpucore->compatible);
else
dev_err(&pdev->dev,
"Support for GPU %x.%d.%x.%d has been deprecated\n",
gpucore->core, gpucore->major,
gpucore->minor, gpucore->patchid);
return ERR_PTR(-ENODEV);
}
return gpucore;
}
static const struct of_device_id adreno_match_table[] = {
{ .compatible = "qcom,kgsl-3d0", .data = &device_3d0 },
{ .compatible = "qcom,kgsl", .data = &device_3d0 },
{ .compatible = "qcom,adreno", .data = &device_3d0 },
{ },
};
MODULE_DEVICE_TABLE(of, adreno_match_table);
/* Read the fuse through the new and fancy nvmem method */
static int adreno_read_speed_bin(struct platform_device *pdev, u32 *speedbin)
{
struct nvmem_cell *cell = nvmem_cell_get(&pdev->dev, "speed_bin");
int ret = PTR_ERR_OR_ZERO(cell);
void *buf;
int val = 0;
size_t len;
if (ret)
return ret;
buf = nvmem_cell_read(cell, &len);
nvmem_cell_put(cell);
if (IS_ERR(buf))
return PTR_ERR(buf);
memcpy(&val, buf, min(len, sizeof(val)));
kfree(buf);
*speedbin = val;
return 0;
}
static u32 fuse_to_supp_hw(const struct adreno_gpu_core *gpucore, u32 fuse)
{
int i;
if (!gpucore->speedbins)
return UINT_MAX;
for (i = 0; gpucore->speedbins[i].fuse != SHRT_MAX; i++)
if (gpucore->speedbins[i].fuse == fuse)
return BIT(gpucore->speedbins[i].speedbin);
return UINT_MAX;
}
static int adreno_setup_speedbin(struct kgsl_device *device)
{
struct platform_device *pdev = device->pdev;
struct device_node *node;
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
const struct adreno_gpu_core *gpucore = adreno_dev->gpucore;
const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
u32 supp_hw, speedbin;
int ret;
/* Use speedbin fuse if present. Otherwise, fallback to softfuse */
ret = adreno_read_speed_bin(pdev, &speedbin);
/*
* -ENOENT means that the platform doesn't support speedbin which is
* fine.
*/
if (ret == -ENOENT) {
/*
* For ADRENO_SOFTFUSE targets the actual speedbin is read from
* GPU_CX_MISC_SW_FUSE_FREQ_LIMIT_STATUS.
*/
if (ADRENO_FEATURE(adreno_dev, ADRENO_SOFTFUSE)) {
if (!gpudev->read_speedbin)
return -ENODEV;
gpudev->read_speedbin(adreno_dev, &speedbin);
} else {
device->speed_bin = 0;
return 0;
}
} else if (ret)
return ret;
device->speed_bin = speedbin;
node = of_parse_phandle(pdev->dev.of_node, "operating-points-v2", 0);
if (!node)
return 0;
supp_hw = fuse_to_supp_hw(gpucore, device->speed_bin);
if (supp_hw == UINT_MAX) {
dev_err(&pdev->dev,
"missing support for speed-bin: %u. Some OPPs may not be supported by hardware\n",
device->speed_bin);
supp_hw = BIT(0); /* Default */
}
ret = devm_pm_opp_set_supported_hw(&pdev->dev, &supp_hw, 1);
of_node_put(node);
return ret;
}
/* Dynamically build the OPP table for the GPU device */
static void adreno_build_opp_table(struct device *dev, struct kgsl_pwrctrl *pwr)
{
int i;
/* Skip if the table has already been populated */
if (dev_pm_opp_get_opp_count(dev) > 0)
return;
/* Add all the supported frequencies into the tree */
for (i = 0; i < pwr->num_pwrlevels; i++)
dev_pm_opp_add(dev, pwr->pwrlevels[i].gpu_freq, 0);
}
static int adreno_of_parse_legacy_pwrlevels(struct adreno_device *adreno_dev,
struct device_node *node)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
struct kgsl_pwrctrl *pwr = &device->pwrctrl;
struct device_node *child;
int ret;
pwr->num_pwrlevels = 0;
for_each_child_of_node(node, child) {
u32 index, freq = 0, voltage, bus;
struct kgsl_pwrlevel *level;
ret = of_property_read_u32(child, "reg", &index);
if (ret) {
dev_err(device->dev, "%pOF: powerlevel index not found\n",
child);
goto out;
}
ret = of_property_read_u32(child, "qcom,gpu-freq", &freq);
if (ret) {
dev_err(device->dev, "%pOF: Unable to read qcom,gpu-freq\n",
child);
goto out;
}
/* Ignore "zero" powerlevels */
if (!freq)
continue;
ret = of_property_read_u32(child, "qcom,level", &voltage);
if (ret) {
dev_err(device->dev, "%pOF: Unable to read qcom,level\n",
child);
goto out;
}
ret = kgsl_of_property_read_ddrtype(child, "qcom,bus-freq",
&bus);
if (ret) {
dev_err(device->dev, "%pOF:Unable to read qcom,bus-freq\n",
child);
goto out;
}
if (index >= ARRAY_SIZE(pwr->pwrlevels)) {
dev_err(device->dev, "%pOF: Pwrlevel index %d is out of range\n",
child, index);
continue;
}
if (index >= pwr->num_pwrlevels)
pwr->num_pwrlevels = index + 1;
level = &pwr->pwrlevels[index];
level->gpu_freq = freq;
level->bus_freq = bus;
level->voltage_level = voltage;
level->cx_level = 0xffffffff;
of_property_read_u32(child, "qcom,acd-level",
&level->acd_level);
of_property_read_u32(child, "qcom,cx-level",
&level->cx_level);
level->bus_min = level->bus_freq;
kgsl_of_property_read_ddrtype(child,
"qcom,bus-min", &level->bus_min);
level->bus_max = level->bus_freq;
kgsl_of_property_read_ddrtype(child,
"qcom,bus-max", &level->bus_max);
}
adreno_build_opp_table(&device->pdev->dev, pwr);
return 0;
out:
of_node_put(child);
return ret;
}
static void adreno_of_get_initial_pwrlevels(struct kgsl_pwrctrl *pwr,
struct device_node *node)
{
int level;
/* Get and set the initial power level */
if (WARN_ON(of_property_read_u32(node, "qcom,initial-pwrlevel", &level) ||
level < 0 || level >= pwr->num_pwrlevels))
level = 1;
pwr->active_pwrlevel = level;
pwr->default_pwrlevel = level;
/* Set the max power level */
pwr->max_pwrlevel = 0;
/* Get and set the min power level */
if (of_property_read_u32(node, "qcom,initial-min-pwrlevel", &level))
level = pwr->num_pwrlevels - 1;
if (level < 0 || level >= pwr->num_pwrlevels || level < pwr->default_pwrlevel)
level = pwr->num_pwrlevels - 1;
pwr->min_render_pwrlevel = level;
pwr->min_pwrlevel = level;
}
static void adreno_of_get_limits(struct adreno_device *adreno_dev,
struct device_node *node)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
struct kgsl_pwrctrl *pwrctrl = &device->pwrctrl;
unsigned int throttle_level;
if (!ADRENO_FEATURE(adreno_dev, ADRENO_LM) || of_property_read_u32(node,
"qcom,throttle-pwrlevel", &throttle_level))
return;
throttle_level = min(throttle_level, pwrctrl->num_pwrlevels - 1);
pwrctrl->throttle_mask = GENMASK(pwrctrl->num_pwrlevels - 1,
pwrctrl->num_pwrlevels - 1 - throttle_level);
adreno_dev->lm_enabled = true;
}
static int adreno_of_get_legacy_pwrlevels(struct adreno_device *adreno_dev,
struct device_node *parent)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
struct device_node *node;
int ret;
node = of_find_node_by_name(parent, "qcom,gpu-pwrlevels");
if (node == NULL) {
dev_err(&device->pdev->dev,
"Unable to find 'qcom,gpu-pwrlevels'\n");
return -EINVAL;
}
ret = adreno_of_parse_legacy_pwrlevels(adreno_dev, node);
if (!ret) {
adreno_of_get_initial_pwrlevels(&device->pwrctrl, parent);
adreno_of_get_limits(adreno_dev, parent);
}
of_node_put(node);
return ret;
}
static int adreno_parse_ib_votes(struct kgsl_device *device,
struct dev_pm_opp *opp, struct kgsl_pwrlevel *level)
{
struct kgsl_pwrctrl *pwr = &device->pwrctrl;
struct device_node *child;
u32 bus_freq;
int ret, i;
child = dev_pm_opp_get_of_node(opp);
/* Initialize bus_freq, bus_min, and bus_max using "qcom,bus-freq" if available.
* If not, fall back to "opp-peak-kBps" and map it to ddr_table index.
* Return error if neither property is found or if mapping fails.
*/
ret = kgsl_of_property_read_ddrtype(child, "qcom,bus-freq", &bus_freq);
if (!ret) {
level->bus_freq = bus_freq;
level->bus_min = bus_freq;
kgsl_of_property_read_ddrtype(child, "qcom,bus-min", &level->bus_min);
level->bus_max = bus_freq;
kgsl_of_property_read_ddrtype(child, "qcom,bus-max", &level->bus_max);
of_node_put(child);
return 0;
}
ret = of_property_read_u32(child, "opp-peak-kBps", &bus_freq);
if (!ret) {
for (i = 0; i < pwr->ddr_table_count && pwr->ddr_table[i] != bus_freq; i++)
;
if (i == pwr->ddr_table_count) {
dev_err(device->dev, "%pOF: bus_freq %u not found in ddr_table\n",
child, bus_freq);
return -EINVAL;
}
level->bus_freq = i;
level->bus_min = i;
level->bus_max = i;
of_node_put(child);
return 0;
}
/* Neither "qcom,bus-freq" nor "opp-peak-kBps" was found */
dev_err(device->dev, "%pOF: Missing bus frequency properties\n", child);
of_node_put(child);
return -EINVAL;
}
static int adreno_parse_opp_node(struct kgsl_device *device,
struct dev_pm_opp *opp, struct kgsl_pwrlevel *level)
{
int ret;
level->opp = opp;
level->voltage_level = dev_pm_opp_get_level(opp);
if (level->voltage_level == U32_MAX)
level->voltage_level = dev_pm_opp_get_required_pstate(opp, 0);
if (level->voltage_level == U32_MAX) {
dev_err(device->dev, "Failed to get valid voltage level from OPP\n");
return -EINVAL;
}
level->cx_level = 0xffffffff;
of_property_read_u32(dev_pm_opp_get_of_node(opp), "qcom,opp-acd-level", &level->acd_level);
ret = adreno_parse_ib_votes(device, opp, level);
if (ret)
return ret;
return 0;
}
static int adreno_of_parse_pwrlevels(struct adreno_device *adreno_dev)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
struct kgsl_pwrctrl *pwr = &device->pwrctrl;
struct device *dev = &device->pdev->dev;
struct dev_pm_opp *opp;
u32 index = 0, count = 0, i;
unsigned long freq = ULONG_MAX;
int ret;
/* Only handle the core clock for no GMU and RGMU targets */
if (is_gmu_wrapper_available() || ADRENO_GPUREV(adreno_dev) == ADRENO_REV_A612) {
/*
* This can only be done before devm_pm_opp_of_add_table(), or
* dev_pm_opp_set_config() will WARN_ON()
*/
if (IS_ERR(devm_clk_get(dev, "core"))) {
/*
* If "core" is absent, go for the legacy clock name.
* If we got this far in probing, it's a given one of
* them exists.
*/
ret = devm_pm_opp_set_clkname(dev, "core_clk");
} else
ret = devm_pm_opp_set_clkname(dev, "core");
if (ret) {
dev_err(dev, "Failed to set OPP clock name, ret: %d\n", ret);
return ret;
}
}
ret = devm_pm_opp_of_add_table(&device->pdev->dev);
if (ret) {
dev_err(dev, "Unable to initialize opp table from device tree\n");
return ret;
}
ret = dev_pm_opp_of_find_icc_paths(dev, NULL);
if (ret) {
dev_err(dev, "Unable to fetch the interconnects from device tree\n");
return ret;
}
count = dev_pm_opp_get_opp_count(dev);
if (count <= 0) {
dev_err(dev, "No OPPs found for device\n");
return -ENODEV;
}
for (i = 0; i < count && index < KGSL_MAX_PWRLEVELS; i++) {
struct kgsl_pwrlevel *level = &pwr->pwrlevels[index];
opp = dev_pm_opp_find_freq_floor(dev, &freq);
if (IS_ERR(opp))
break;
level->gpu_freq = (u32)freq;
adreno_parse_opp_node(device, opp, level);
dev_pm_opp_put(opp);
freq--;
index++;
}
pwr->num_pwrlevels = index;
/* Set the initial power level */
pwr->active_pwrlevel = pwr->num_pwrlevels - 1;
pwr->default_pwrlevel = pwr->num_pwrlevels - 1;
/* Set the max power level */
pwr->max_pwrlevel = 0;
/* Set the min power level and min render power level */
pwr->min_pwrlevel = pwr->num_pwrlevels - 1;
pwr->min_render_pwrlevel = pwr->num_pwrlevels - 1;
return 0;
}
static int adreno_of_get_legacy_pwrlevels_bins(struct adreno_device *adreno_dev,
struct device_node *parent)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
struct device_node *node, *child;
node = of_find_node_by_name(parent, "qcom,gpu-pwrlevel-bins");
if (node == NULL)
return adreno_of_get_legacy_pwrlevels(adreno_dev, parent);
for_each_child_of_node(node, child) {
bool match = false;
int tbl_size;
u32 bin = 0;
/* Check if the bin has a speed-bin requirement */
if (!of_property_read_u32(child, "qcom,speed-bin", &bin))
match = (bin == device->speed_bin);
/* Check if the bin has a sku-code requirement */
if (of_get_property(child, "qcom,sku-codes", &tbl_size)) {
int num_codes = tbl_size / sizeof(u32);
int i;
u32 sku_code;
/*
* If we have a speed-bin requirement that did not match
* keep searching.
*/
if (bin && !match)
continue;
/* Check if the soc_code matches any of the sku codes */
match = false;
for (i = 0; i < num_codes; i++) {
if (!of_property_read_u32_index(child, "qcom,sku-codes",
i, &sku_code) &&
(sku_code == 0 || device->soc_code == sku_code)) {
match = true;
break;
}
}
}
if (match) {
int ret;
ret = adreno_of_parse_legacy_pwrlevels(adreno_dev, child);
if (ret) {
of_node_put(child);
return ret;
}
adreno_of_get_initial_pwrlevels(&device->pwrctrl, child);
/*
* Check for global throttle-pwrlevel first and override
* with speedbin specific one if found.
*/
adreno_of_get_limits(adreno_dev, parent);
adreno_of_get_limits(adreno_dev, child);
of_node_put(child);
return 0;
}
}
dev_err(&device->pdev->dev,
"No match for speed_bin:%d and soc_code:0x%x\n",
device->speed_bin, device->soc_code);
return -ENODEV;
}
static int register_l3_voter(struct kgsl_device *device)
{
int ret = 0;
/*
* The L3 vote setup is performed only once. Once set up is done, it is
* safe to access num_l3_pwrlevels without acquiring the device mutex.
* Therefore, an early check can be added without taking the mutex.
*/
if (READ_ONCE(device->num_l3_pwrlevels))
return ret;
kgsl_mutex_lock(&device->mutex);
if (!device->l3_vote)
goto done;
/* Verify again if the L3 vote is set up to handle races */
if (device->num_l3_pwrlevels)
goto done;
memset(device->l3_freq, 0x0, sizeof(device->l3_freq));
ret = qcom_dcvs_register_voter(KGSL_L3_DEVICE, DCVS_L3, DCVS_SLOW_PATH);
if (ret) {
dev_err_once(&device->pdev->dev,
"Unable to register l3 dcvs voter: %d\n", ret);
goto done;
}
ret = qcom_dcvs_hw_minmax_get(DCVS_L3, &device->l3_freq[1],
&device->l3_freq[2]);
if (ret) {
dev_err_once(&device->pdev->dev,
"Unable to get min/max for l3 dcvs: %d\n", ret);
qcom_dcvs_unregister_voter(KGSL_L3_DEVICE, DCVS_L3,
DCVS_SLOW_PATH);
memset(device->l3_freq, 0x0, sizeof(device->l3_freq));
goto done;
}
WRITE_ONCE(device->num_l3_pwrlevels, 3);
done:
kgsl_mutex_unlock(&device->mutex);
return ret;
}
static int adreno_of_get_power(struct adreno_device *adreno_dev,
struct platform_device *pdev)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
struct device_node *node;
int ret;
node = of_parse_phandle(pdev->dev.of_node, "operating-points-v2", 0);
if (node && of_device_is_compatible(node, "operating-points-v2")) {
ret = adreno_of_parse_pwrlevels(adreno_dev);
if (!ret)
adreno_of_get_limits(adreno_dev, node);
} else
ret = adreno_of_get_legacy_pwrlevels_bins(adreno_dev, pdev->dev.of_node);
if (ret)
return ret;
atomic64_set(&device->pwrctrl.interval_timeout, CONFIG_QCOM_KGSL_IDLE_TIMEOUT);
return 0;
}
/* Read the fuse through the new and fancy nvmem method */
static int adreno_read_fuse(struct platform_device *pdev, const char *fuse)
{
struct nvmem_cell *cell = nvmem_cell_get(&pdev->dev, fuse);
int ret = PTR_ERR_OR_ZERO(cell);
void *buf;
int val = 0;
size_t len;
if (ret) {
if (ret == -ENOENT)
return 0;
return ret;
}
buf = nvmem_cell_read(cell, &len);
nvmem_cell_put(cell);
if (IS_ERR(buf))
return PTR_ERR(buf);
memcpy(&val, buf, min(len, sizeof(val)));
kfree(buf);
return val;
}
static void adreno_read_soc_code(struct kgsl_device *device)
{
int feature_code, pcode;
bool internal_sku;
feature_code = max_t(int, socinfo_get_feature_code(), SOCINFO_FC_UNKNOWN);
internal_sku = (((feature_code >= SOCINFO_FC_W0) &&
(feature_code < SOCINFO_FC_SUBPART_RESERVE)) ||
((feature_code >= SOCINFO_FC_Y0) &&
(feature_code < SOCINFO_FC_INT_RESERVE)));
/* Pcode is significant only for internal SKUs */
pcode = internal_sku ? max_t(int, socinfo_get_pcode(), SOCINFO_PCODE_UNKNOWN) :
SOCINFO_PCODE_UNKNOWN;
device->soc_code = FIELD_PREP(GENMASK(31, 16), pcode) |
FIELD_PREP(GENMASK(15, 0), feature_code);
/* Override soc_code and speed_bin for internal feature codes only */
if (internal_sku) {
if (kgsl_gpu_sku_override != U32_MAX)
device->soc_code = kgsl_gpu_sku_override;
if (kgsl_gpu_speed_bin_override != U32_MAX)
device->speed_bin = kgsl_gpu_speed_bin_override;
}
}
static int adreno_read_gpu_model_fuse(struct platform_device *pdev)
{
struct nvmem_cell *cell = nvmem_cell_get(&pdev->dev, "gpu_model");
void *buf;
int val = 0;
size_t len;
if (IS_ERR(cell))
return PTR_ERR(cell);
buf = nvmem_cell_read(cell, &len);
nvmem_cell_put(cell);
if (IS_ERR(buf))
return PTR_ERR(buf);
memcpy(&val, buf, min(len, sizeof(val)));
kfree(buf);
return val;
}
static struct device_node *
adreno_get_gpu_model_node(struct platform_device *pdev)
{
struct device_node *node, *child;
int fuse_model = adreno_read_gpu_model_fuse(pdev);
if (fuse_model < 0)
return NULL;
node = of_find_node_by_name(pdev->dev.of_node, "qcom,gpu-models");
if (node == NULL)
return NULL;
for_each_child_of_node(node, child) {
u32 model;
if (of_property_read_u32(child, "qcom,gpu-model-id", &model))
continue;
if (model == fuse_model) {
of_node_put(node);
return child;
}
}
of_node_put(node);
return NULL;
}
const char *adreno_get_gpu_model(struct kgsl_device *device)
{
struct device_node *node;
static char gpu_model[32];
const char *model;
int ret;
if (strlen(gpu_model))
return gpu_model;
node = adreno_get_gpu_model_node(device->pdev);
if (!node)
node = of_node_get(device->pdev->dev.of_node);
ret = of_property_read_string(node, "qcom,gpu-model", &model);
of_node_put(node);
if (!ret)
goto done;
model = socinfo_get_partinfo_part_name(SOCINFO_PART_GPU);
if (model)
goto done;
model = ADRENO_DEVICE(device)->gpucore->gpu_model;
if (model)
goto done;
scnprintf(gpu_model, sizeof(gpu_model), "Adreno%u%u%uv%u",
(u32)ADRENO_CHIPID_CORE(ADRENO_DEVICE(device)->chipid),
(u32)ADRENO_CHIPID_MAJOR(ADRENO_DEVICE(device)->chipid),
(u32)ADRENO_CHIPID_MINOR(ADRENO_DEVICE(device)->chipid),
(u32)ADRENO_CHIPID_PATCH(ADRENO_DEVICE(device)->chipid) + 1);
return gpu_model;
done:
strscpy(gpu_model, model, sizeof(gpu_model));
return gpu_model;
}
static u32 adreno_get_vk_device_id(struct kgsl_device *device)
{
struct device_node *node;
static u32 device_id;
u32 vk_id;
int ret;
if (device_id)
return device_id;
node = adreno_get_gpu_model_node(device->pdev);
if (!node)
node = of_node_get(device->pdev->dev.of_node);
ret = of_property_read_u32(node, "qcom,vk-device-id", &device_id);
of_node_put(node);
if (!ret)
return device_id;
vk_id = socinfo_get_partinfo_vulkan_id(SOCINFO_PART_GPU);
device_id = vk_id ? vk_id : ADRENO_DEVICE(device)->chipid;
return device_id;
}
#if IS_ENABLED(CONFIG_QCOM_LLCC)
static int adreno_probe_llcc(struct adreno_device *adreno_dev,
struct platform_device *pdev)
{
struct device_node *node;
int ret;
/*
* Unlike some non-standard kernels, the llcc_slice_getd API
* in the standard kernel does not check for the cache-controller
* node in the device tree and returns EPROBE_DEFER for targets
* without LLCC support. Therefore, explicitly check for the node
* and return early in the LLCC probe.
*/
node = of_find_node_by_name(NULL, "system-cache-controller");
if (!node)
return 0;
if (!of_device_is_available(node)) {
of_node_put(node);
return 0;
}
of_node_put(node);
/* Get the system cache slice descriptor for GPU */
adreno_dev->gpu_llc_slice = llcc_slice_getd(LLCC_GPU);
ret = PTR_ERR_OR_ZERO(adreno_dev->gpu_llc_slice);
if (ret) {
/* Propagate EPROBE_DEFER back to the probe function */
if (ret == -EPROBE_DEFER)
return ret;
if (ret != -ENOENT)
dev_warn(&pdev->dev,
"Unable to get the GPU LLC slice: %d\n", ret);
} else
adreno_dev->gpu_llc_slice_enable = true;
/* Get the system cache slice descriptor for GPU pagetables */
adreno_dev->gpuhtw_llc_slice = llcc_slice_getd(LLCC_GPUHTW);
ret = PTR_ERR_OR_ZERO(adreno_dev->gpuhtw_llc_slice);
if (ret) {
if (ret == -EPROBE_DEFER) {
llcc_slice_putd(adreno_dev->gpu_llc_slice);
return ret;
}
if (ret != -ENOENT)
dev_warn(&pdev->dev,
"Unable to get GPU HTW LLC slice: %d\n", ret);
} else
adreno_dev->gpuhtw_llc_slice_enable = true;
#if (KERNEL_VERSION(6, 1, 0) == LINUX_VERSION_CODE)
if (adreno_is_a621(adreno_dev)) {
/* Get the system cache slice descriptor for GPU MV grid buffer */
adreno_dev->gpumv_llc_slice = llcc_slice_getd(LLCC_GPUMV);
ret = PTR_ERR_OR_ZERO(adreno_dev->gpumv_llc_slice);
if (ret) {
if (ret == -EPROBE_DEFER) {
llcc_slice_putd(adreno_dev->gpu_llc_slice);
llcc_slice_putd(adreno_dev->gpuhtw_llc_slice);
return ret;
}
if (ret != -ENOENT)
dev_warn(&pdev->dev, "Unable to get GPUMV buffer slice: %d\n", ret);
} else {
adreno_dev->gpumv_llc_slice_enable = true;
}
}
#endif
return 0;
}
#else
static int adreno_probe_llcc(struct adreno_device *adreno_dev,
struct platform_device *pdev)
{
return 0;
}
#endif
const char *hfi_feature_to_string(u32 feature)
{
switch (feature) {
case HFI_FEATURE_HWSCHED:
return "HWSCHED";
case HFI_FEATURE_PREEMPTION:
return "PREEMPTION";
case HFI_FEATURE_LM:
return "LM";
case HFI_FEATURE_IFPC:
return "IFPC";
case HFI_FEATURE_BCL:
return "BCL";
case HFI_FEATURE_ACD:
return "ACD";
case HFI_FEATURE_KPROF:
return "KPROF";
case HFI_FEATURE_BAIL_OUT_TIMER:
return "BAIL_OUT_TIMER";
case HFI_FEATURE_GMU_STATS:
return "GMU_STATS";
case HFI_FEATURE_CLX:
return "CLX";
case HFI_FEATURE_LSR:
return "LSR";
case HFI_FEATURE_LPAC:
return "LPAC";
case HFI_FEATURE_HW_FENCE:
return "HW_FENCE";
case HFI_FEATURE_PERF_NORETAIN:
return "PERF_NORETAIN";
case HFI_FEATURE_DMS:
return "DMS";
case HFI_FEATURE_AQE:
return "AQE";
case HFI_FEATURE_FAST_CONTEXT_DESTROY:
return "FAST_CONTEXT_DESTROY";
}
return "unknown";
}
static void adreno_regmap_op_preaccess(struct kgsl_regmap_region *region)
{
struct kgsl_device *device = region->priv;
/*
* kgsl panic notifier will be called in atomic context to get
* GPU snapshot. Also panic handler will skip snapshot dumping
* incase GPU is in SLUMBER state. So we can safely ignore the
* kgsl_pre_hwaccess().
*/
if (!device->snapshot_atomic && !in_interrupt())
kgsl_pre_hwaccess(device);
}
static const struct kgsl_regmap_ops adreno_regmap_ops = {
.preaccess = adreno_regmap_op_preaccess,
};
static const struct kgsl_functable adreno_functable;
static void adreno_setup_device(struct adreno_device *adreno_dev)
{
u32 i;
adreno_dev->dev.name = "kgsl-3d0";
adreno_dev->dev.ftbl = &adreno_functable;
init_completion(&adreno_dev->dev.hwaccess_gate);
init_completion(&adreno_dev->dev.halt_gate);
init_completion(&adreno_dev->suspend_recovery_gate);
complete_all(&adreno_dev->suspend_recovery_gate);
idr_init(&adreno_dev->dev.context_idr);
kgsl_mutex_init(&adreno_dev->dev.mutex);
mutex_init(&adreno_dev->dev.file_mutex);
mutex_init(&adreno_dev->fault_recovery_mutex);
mutex_init(&adreno_dev->dcvs_tuning_mutex);
INIT_LIST_HEAD(&adreno_dev->dev.globals);
/* Set the fault tolerance policy to replay, skip, throttle */
adreno_dev->ft_policy = BIT(KGSL_FT_REPLAY) |
BIT(KGSL_FT_SKIPCMD) | BIT(KGSL_FT_THROTTLE);
/* Enable command timeouts by default */
adreno_dev->long_ib_detect = true;
INIT_WORK(&adreno_dev->input_work, adreno_input_work);
INIT_LIST_HEAD(&adreno_dev->active_list);
spin_lock_init(&adreno_dev->active_list_lock);
rwlock_init(&adreno_dev->fault_stats_lock);
for (i = 0; i < ARRAY_SIZE(adreno_dev->ringbuffers); i++) {
struct adreno_ringbuffer *rb = &adreno_dev->ringbuffers[i];
INIT_LIST_HEAD(&rb->events.group);
}
/*
* Some GPUs needs specific alignment for UCHE GMEM base address.
* Configure UCHE GMEM base based on GMEM size and align it accordingly.
* This needs to be done based on GMEM size to avoid overlap between
* RB and UCHE GMEM range.
*/
if (adreno_dev->gpucore->uche_gmem_alignment)
adreno_dev->uche_gmem_base =
ALIGN(adreno_dev->gpucore->gmem_size,
adreno_dev->gpucore->uche_gmem_alignment);
}
static const struct of_device_id adreno_component_match[] = {
{ .compatible = "qcom,adreno-gmu" },
{ .compatible = "qcom,adreno-rgmu" },
{},
};
static const struct of_device_id adreno_component_match_legacy[] = {
{ .compatible = "qcom,gen8-gmu" },
{ .compatible = "qcom,gen7-gmu" },
{ .compatible = "qcom,gpu-gmu" },
{ .compatible = "qcom,gpu-rgmu" },
/* Legacy components for kgsl-smmu */
{ .compatible = "qcom,kgsl-smmu-v2" },
{ .compatible = "qcom,smmu-kgsl-cb" },
{},
};
static int adreno_irq_setup(struct platform_device *pdev,
struct adreno_device *adreno_dev)
{
if (!adreno_dev->irq_mask)
return 0;
/*
* Try to get the irq based on gpu irq name (i.e. "kgsl_3d0_irq") else fall back
* to requesting it by index.
* Note: kgsl_3d0_irq should always be the first in the gpu irq list.
*/
return kgsl_request_irq(pdev, "kgsl_3d0_irq", NULL, 0, adreno_irq_handler,
KGSL_DEVICE(adreno_dev));
}
static int adreno_pm_notifier(struct notifier_block *nb, unsigned long event, void *unused)
{
struct adreno_device *adreno_dev = container_of(nb, struct adreno_device, pm_nb);
struct kgsl_pwrctrl *pwr = &adreno_dev->dev.pwrctrl;
struct generic_pm_domain *pd = NULL;
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
if ((event != PM_SUSPEND_PREPARE) && (event != PM_POST_SUSPEND))
return NOTIFY_DONE;
if (pwr->gx_pd) {
pd = container_of(pwr->gx_pd->pm_domain, struct generic_pm_domain, domain);
if (pd->prepared_count) {
dev_err_ratelimited(device->dev,
"unexpected gx pd prepared_count:%d event:%lu\n",
pd->prepared_count, event);
return NOTIFY_BAD;
}
}
if (pwr->gmu_cx_pd) {
pd = container_of(pwr->gmu_cx_pd->pm_domain, struct generic_pm_domain, domain);
if (pd->prepared_count) {
dev_err_ratelimited(device->dev,
"unexpected cx pd prepared_count:%d event:%lu\n",
pd->prepared_count, event);
return NOTIFY_BAD;
}
}
if (event == PM_SUSPEND_PREPARE) {
/*
* In presence of a hardware fault, cancel system suspend (by returning NOTIFY_BAD)
* here to make sure system suspend doesn't increment the pd prepared_count. This
* ensures that cx and gx gdscs can be toggled successfully during fault recovery.
*/
if (adreno_gpu_fault(adreno_dev)) {
dev_err_ratelimited(device->dev, "cancelling suspend because of fault\n");
complete_all(&adreno_dev->suspend_recovery_gate);
adreno_scheduler_queue(adreno_dev);
return NOTIFY_BAD;
}
reinit_completion(&adreno_dev->suspend_recovery_gate);
return NOTIFY_DONE;
}
/*
* We get PM_POST_SUSPEND if we failed kgsl suspend in the presence of a hardware fault,
* or when system resume finishes. In either case, this means the system has come out of
* suspend and has put back the power domain prepared_count. This means we are safe to
* perform fault recovery.
*/
if (event == PM_POST_SUSPEND) {
complete_all(&adreno_dev->suspend_recovery_gate);
/*
* Queue the gpu scheduler to proceed with fault recovery in case there was a
* fault
*/
adreno_scheduler_queue(adreno_dev);
}
return NOTIFY_DONE;
}
static void validate_pwrlevels(struct kgsl_device *device)
{
struct kgsl_pwrctrl *pwr = &device->pwrctrl;
int i, count = pwr->ddr_table_count;
for (i = 0; i < pwr->num_pwrlevels - 1; i++) {
struct kgsl_pwrlevel *pwrlevel = &pwr->pwrlevels[i];
if (pwrlevel->bus_freq >= count) {
dev_err(device->dev, "Bus setting for GPU freq %d is out of bounds\n",
pwrlevel->gpu_freq);
pwrlevel->bus_freq = count - 1;
}
if (pwrlevel->bus_max >= count) {
dev_err(device->dev, "Bus max for GPU freq %d is out of bounds\n",
pwrlevel->gpu_freq);
pwrlevel->bus_max = count - 1;
}
if (pwrlevel->bus_min >= count) {
dev_err(device->dev, "Bus min for GPU freq %d is out of bounds\n",
pwrlevel->gpu_freq);
pwrlevel->bus_min = count - 1;
}
if (pwrlevel->bus_min > pwrlevel->bus_max) {
dev_err(device->dev, "Bus min is bigger than bus max for GPU freq %d\n",
pwrlevel->gpu_freq);
pwrlevel->bus_min = pwrlevel->bus_max;
}
}
}
static int adreno_init_ubwc_legacy(struct adreno_device *adreno_dev)
{
if (adreno_dev->gpucore->ubwc_mode)
adreno_dev->ubwc_mode = adreno_dev->gpucore->ubwc_mode;
else {
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
int status;
status = of_property_read_u32(device->pdev->dev.of_node,
"qcom,ubwc-mode", &adreno_dev->ubwc_mode);
if (status) {
dev_err(device->dev, "Failed to get ubwc-mode\n");
return status;
}
}
adreno_dev->highest_bank_bit = adreno_dev->gpucore->highest_bank_bit;
if (kgsl_get_ddrtype() != 0x7)
return 0;
/* If the memory type is DDR 4, override the existing configuration */
if (adreno_is_gen8(adreno_dev) || adreno_is_gen7(adreno_dev) ||
adreno_is_a660_shima(adreno_dev) || adreno_is_a642l(adreno_dev) ||
adreno_is_a643(adreno_dev) || adreno_is_a662(adreno_dev) ||
adreno_is_gen6_3_26_0(adreno_dev))
adreno_dev->highest_bank_bit = 14;
else if (adreno_is_a650(adreno_dev) || adreno_is_a660(adreno_dev))
adreno_dev->highest_bank_bit = 15;
return 0;
}
static void adreno_init_mal_legacy(struct adreno_device *adreno_dev)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
if (adreno_dev->gpucore->mal)
adreno_dev->mal = adreno_dev->gpucore->mal;
else if (of_property_read_u32(device->pdev->dev.of_node,
"qcom,min-access-length", &adreno_dev->mal))
adreno_dev->mal = 32;
}
#if (KERNEL_VERSION(7, 1, 0) <= LINUX_VERSION_CODE)
static void adreno_init_mal(struct adreno_device *adreno_dev)
{
const struct qcom_ubwc_cfg_data *cfg = adreno_dev->ubwc_cfg_data;
if (cfg)
adreno_dev->mal = qcom_ubwc_min_acc_length_64b(cfg) ? 64 : 32;
else
adreno_init_mal_legacy(adreno_dev);
}
#else
static void adreno_init_mal(struct adreno_device *adreno_dev)
{
adreno_init_mal_legacy(adreno_dev);
}
#endif
#if (KERNEL_VERSION(6, 17, 0) <= LINUX_VERSION_CODE)
static int adreno_init_ubwc(struct adreno_device *adreno_dev)
{
struct qcom_ubwc_cfg_data *cfg = qcom_ubwc_config_get_data();
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
/* Extract the UBWC major version from ubwc_enc_version[31:28].
* If cfg is NULL, default to KGSL_UBWC_NONE.
*/
u32 ubwc_mode = cfg ? cfg->ubwc_enc_version >> 28 : KGSL_UBWC_NONE;
int ret = 0;
if (ubwc_mode != KGSL_UBWC_NONE) {
adreno_dev->ubwc_cfg_data = cfg;
adreno_dev->ubwc_mode = ubwc_mode;
adreno_dev->highest_bank_bit = cfg->highest_bank_bit;
} else {
ret = adreno_init_ubwc_legacy(adreno_dev);
}
adreno_init_mal(adreno_dev);
if (!adreno_dev->highest_bank_bit)
dev_warn(device->dev, "Invalid highest bank bit\n");
return ret;
}
#else
static int adreno_init_ubwc(struct adreno_device *adreno_dev)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
int ret;
ret = adreno_init_ubwc_legacy(adreno_dev);
adreno_init_mal_legacy(adreno_dev);
if (!adreno_dev->highest_bank_bit)
dev_warn(device->dev, "Invalid highest bank bit\n");
return ret;
}
#endif
static int adreno_bind_components(struct device *dev)
{
/*
* Bind components before performing the KGSL platform probe.
* Note: with standard DT bindings, there are no components to bind
* for no GMU targets, so skip invoking component_bind_all in this case.
*/
if (!is_gmu_wrapper_available())
return component_bind_all(dev, NULL);
return 0;
}
int adreno_device_probe(struct platform_device *pdev,
struct adreno_device *adreno_dev)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
struct device *dev = &pdev->dev;
struct resource *res;
unsigned int priv = 0;
int status;
u32 size;
KGSL_BOOT_MARKER("GPU Init");
/* Initialize the adreno device structure */
adreno_setup_device(adreno_dev);
dev_set_drvdata(dev, device);
device->pdev = pdev;
adreno_dev->zap_enabled = adreno_check_zap_enabled(device);
adreno_update_soc_hw_revision_quirks(adreno_dev, pdev);
/*
* Add kgsl_3d0_reg_memory and cx_mem/cx_misc region early
* to access softSKU register inside adreno_setup_speedbin().
*/
status = kgsl_regmap_init(pdev, &device->regmap, "kgsl_3d0_reg_memory",
&adreno_regmap_ops, device);
if (status)
goto err;
/* Try to probe the optional "cx_mem" resource, fallback to legacy "cx_misc" if not found */
status = kgsl_regmap_add_region(&device->regmap, pdev, "cx_mem", -EINVAL, NULL, NULL);
if (status)
kgsl_regmap_add_region(&device->regmap, pdev, "cx_misc", -EINVAL, NULL, NULL);
status = adreno_setup_speedbin(device);
if (status)
goto err;
status = kgsl_bus_init(device, pdev);
if (status)
goto err;
status = adreno_of_get_power(adreno_dev, pdev);
if (status)
goto err;
validate_pwrlevels(device);
/*
* The SMMU APIs use unsigned long for virtual addresses which means
* that we cannot use 64 bit virtual addresses on a 32 bit kernel even
* though the hardware and the rest of the KGSL driver supports it.
*/
if (adreno_support_64bit(adreno_dev))
kgsl_mmu_set_feature(device, KGSL_MMU_64BIT);
/*
* Set the SMMU aperture on A6XX/Gen7 targets to use per-process
* pagetables.
*/
if (ADRENO_GPUREV(adreno_dev) >= 600)
kgsl_mmu_set_feature(device, KGSL_MMU_SMMU_APERTURE);
if (ADRENO_FEATURE(adreno_dev, ADRENO_IOCOHERENT))
kgsl_mmu_set_feature(device, KGSL_MMU_IO_COHERENT);
/*
* Support VBOs on hardware where HLOS has access to PRR registers
* configuration.
*/
if (!adreno_is_a650(adreno_dev))
kgsl_mmu_set_feature(device, KGSL_MMU_SUPPORT_VBO);
if (adreno_preemption_enable)
adreno_dev->preempt_override = true;
device->pwrctrl.bus_width = adreno_dev->gpucore->bus_width;
device->mmu.secured = (IS_ENABLED(CONFIG_QCOM_SECURE_BUFFER) &&
ADRENO_FEATURE(adreno_dev, ADRENO_CONTENT_PROTECTION) &&
adreno_dev->zap_enabled);
/* Probe the LLCC - this could return -EPROBE_DEFER */
status = adreno_probe_llcc(adreno_dev, pdev);
if (status)
goto err_bus_close;
/*
* IF the GPU HTW slice was successsful set the MMU feature so the
* domain can set the appropriate attributes
*/
if (!IS_ERR_OR_NULL(adreno_dev->gpuhtw_llc_slice))
kgsl_mmu_set_feature(device, KGSL_MMU_LLCC_ENABLE);
/*
* Force no write allocate for A5x, A6x and all gen7 targets
* except gen_7_9_x and gen_7_14_0_family. gen_7_9_x and gen_7_14_0_family
* use write allocate.
*/
if (adreno_is_a5xx(adreno_dev) || adreno_is_a6xx(adreno_dev) ||
(adreno_is_gen7(adreno_dev) && !adreno_is_gen7_9_x(adreno_dev) &&
!adreno_is_gen7_14_0_family(adreno_dev)))
kgsl_mmu_set_feature(device, KGSL_MMU_FORCE_LLCC_NWA);
status = adreno_bind_components(dev);
if (status)
goto err_remove_llcc;
status = adreno_irq_setup(pdev, adreno_dev);
if (status < 0)
goto err_unbind;
device->pwrctrl.interrupt_num = status;
device->freq_limiter_intr_num = kgsl_request_irq_optional(pdev, "freq_limiter_irq",
adreno_freq_limiter_irq_handler, device);
device->freq_limiter_irq_clear =
devm_reset_control_get(&pdev->dev, "freq_limiter_irq_clear");
status = kgsl_device_platform_probe(device);
if (status)
goto err_unbind;
adreno_fence_trace_array_init(device);
/* Add CX_DBGC block to the regmap*/
kgsl_regmap_add_region(&device->regmap, pdev, "cx_dbgc", -EINVAL, NULL, NULL);
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "aperture");
if (res) {
device->smmu_aperture_virt = devm_ioremap(dev, res->start,
resource_size(res));
if (!device->smmu_aperture_virt)
dev_warn(dev, "aperture ioremap failed\n");
}
if (kgsl_regmap_add_region(&device->regmap, pdev, "isense_cntl", -EINVAL, NULL, NULL) == 0)
adreno_dev->isense_reg_mapped = true;
/* Allocate the memstore for storing timestamps and other useful info */
if (ADRENO_FEATURE(adreno_dev, ADRENO_APRIV))
priv |= KGSL_MEMDESC_PRIVILEGED;
kgsl_mutex_lock(&device->mutex);
device->memstore = kgsl_allocate_global(device,
KGSL_MEMSTORE_SIZE, 0, 0, priv, "memstore");
adreno_profile_init(adreno_dev);
kgsl_mutex_unlock(&device->mutex);
status = PTR_ERR_OR_ZERO(device->memstore);
if (status) {
trace_array_put(device->fence_trace_array);
kgsl_device_platform_remove(device);
goto err_unbind;
}
/* Initialize UBWC mode and HBB */
status = adreno_init_ubwc(adreno_dev);
if (status) {
trace_array_put(device->fence_trace_array);
kgsl_device_platform_remove(device);
goto err_unbind;
}
/* Initialize the snapshot engine */
size = adreno_dev->gpucore->snapshot_size;
/*
* Use a default size if one wasn't specified, but print a warning so
* the developer knows to fix it
*/
if (WARN(!size, "The snapshot size was not specified in the gpucore\n"))
size = SZ_1M;
kgsl_device_snapshot_probe(device, size);
adreno_debugfs_init(adreno_dev);
adreno_dev->perfcounter = false;
adreno_sysfs_init(adreno_dev);
if (!ADRENO_FEATURE(adreno_dev, ADRENO_GMU_BASED_DCVS))
device->host_based_dcvs = true;
else if (ADRENO_FEATURE(adreno_dev, ADRENO_DCVS_PROFILE))
adreno_dev->dcvs_profile_enabled = true;
kgsl_pwrscale_init(device, pdev);
if (ADRENO_FEATURE(adreno_dev, ADRENO_L3_VOTE))
device->l3_vote = true;
#ifdef CONFIG_INPUT
if (!of_property_read_bool(pdev->dev.of_node,
"qcom,disable-wake-on-touch")) {
adreno_input_handler.private = device;
/*
* It isn't fatal if we cannot register the input handler. Sad,
* perhaps, but not fatal
*/
if (input_register_handler(&adreno_input_handler)) {
adreno_input_handler.private = NULL;
dev_err(device->dev,
"Unable to register the input handler\n");
}
}
#endif
/*
* With power domains, we cannot perform recovery during a concurrent system suspend because
* system suspend path increments power domain prepared_count, which prevents successful
* toggling of the power domain gdsc while system is in suspend path. Hence, get
* notifications when system has come out of suspend completely, so that we can perform
* fault recovery.
*/
if (device->pwrctrl.gx_pd || device->pwrctrl.gmu_cx_pd) {
adreno_dev->pm_nb.notifier_call = adreno_pm_notifier;
register_pm_notifier(&adreno_dev->pm_nb);
}
kgsl_qcom_va_md_register(device);
KGSL_BOOT_MARKER("GPU Ready");
return 0;
err_unbind:
component_unbind_all(dev, NULL);
err_remove_llcc:
if (!IS_ERR_OR_NULL(adreno_dev->gpu_llc_slice))
llcc_slice_putd(adreno_dev->gpu_llc_slice);
if (!IS_ERR_OR_NULL(adreno_dev->gpuhtw_llc_slice))
llcc_slice_putd(adreno_dev->gpuhtw_llc_slice);
err_bus_close:
kgsl_bus_close(device);
err:
device->pdev = NULL;
dev_err_probe(&pdev->dev, status, "adreno device probe failed\n");
return status;
}
static int adreno_bind(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
const struct adreno_gpu_core *gpucore;
int ret;
u32 chipid;
gpucore = adreno_identify_gpu(pdev, &chipid);
if (IS_ERR(gpucore))
return PTR_ERR(gpucore);
ret = gpucore->gpudev->probe(pdev, chipid, gpucore);
if (!ret) {
struct kgsl_device *device = dev_get_drvdata(dev);
device->pdev_loaded = true;
srcu_init_notifier_head(&device->nh);
} else {
/*
* Handle resource clean up through unbind, instead of a
* lengthy goto error path.
*/
adreno_unbind(dev);
}
return ret;
}
static void adreno_unbind(struct device *dev)
{
struct adreno_device *adreno_dev;
struct kgsl_device *device;
const struct adreno_gpudev *gpudev;
device = dev_get_drvdata(dev);
if (!device)
return;
/* Return if cleanup happens in adreno_device_probe */
if (!device->pdev)
return;
if (device->pdev_loaded) {
srcu_cleanup_notifier_head(&device->nh);
device->pdev_loaded = false;
}
adreno_dev = ADRENO_DEVICE(device);
gpudev = ADRENO_GPU_DEVICE(adreno_dev);
trace_array_put(device->fence_trace_array);
if (gpudev->remove != NULL)
gpudev->remove(adreno_dev);
#ifdef CONFIG_INPUT
if (adreno_input_handler.private)
input_unregister_handler(&adreno_input_handler);
#endif
kgsl_qcom_va_md_unregister(device);
adreno_coresight_remove(adreno_dev);
adreno_profile_close(adreno_dev);
/* Release the system cache slice descriptor */
if (!IS_ERR_OR_NULL(adreno_dev->gpu_llc_slice))
llcc_slice_putd(adreno_dev->gpu_llc_slice);
if (!IS_ERR_OR_NULL(adreno_dev->gpuhtw_llc_slice))
llcc_slice_putd(adreno_dev->gpuhtw_llc_slice);
if (!IS_ERR_OR_NULL(adreno_dev->gpumv_llc_slice))
llcc_slice_putd(adreno_dev->gpumv_llc_slice);
kgsl_pwrscale_close(device);
if (adreno_dev->dispatch_ops && adreno_dev->dispatch_ops->close)
adreno_dev->dispatch_ops->close(adreno_dev);
kgsl_device_platform_remove(device);
component_unbind_all(dev, NULL);
kgsl_bus_close(device);
device->pdev = NULL;
if (device->num_l3_pwrlevels != 0)
qcom_dcvs_unregister_voter(KGSL_L3_DEVICE, DCVS_L3,
DCVS_SLOW_PATH);
clear_bit(ADRENO_DEVICE_PWRON_FIXUP, &adreno_dev->priv);
clear_bit(ADRENO_DEVICE_INITIALIZED, &adreno_dev->priv);
}
static void adreno_resume(struct adreno_device *adreno_dev)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
if (device->state == KGSL_STATE_SUSPEND) {
adreno_put_gpu_halt(adreno_dev);
kgsl_pwrctrl_change_state(device, KGSL_STATE_SLUMBER);
} else if (device->state != KGSL_STATE_INIT) {
/*
* This is an error situation so wait for the device to idle and
* then put the device in SLUMBER state. This will get us to
* the right place when we resume.
*/
if (device->state == KGSL_STATE_ACTIVE)
adreno_wait_idle(device);
kgsl_pwrctrl_change_state(device, KGSL_STATE_SLUMBER);
dev_err(device->dev, "resume invoked without a suspend\n");
}
}
static int adreno_pm_resume(struct device *dev)
{
struct kgsl_device *device = dev_get_drvdata(dev);
struct adreno_device *adreno_dev;
const struct adreno_power_ops *ops;
if (!device)
return 0;
adreno_dev = ADRENO_DEVICE(device);
ops = ADRENO_POWER_OPS(adreno_dev);
kgsl_mutex_lock(&device->mutex);
#if IS_ENABLED(CONFIG_DEEPSLEEP)
if (pm_suspend_via_firmware())
device->mmu.iommu.smmu_aperture_set = false;
#endif
ops->pm_resume(adreno_dev);
kgsl_mutex_unlock(&device->mutex);
kgsl_reclaim_start();
return 0;
}
static int adreno_suspend(struct adreno_device *adreno_dev)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
int status = kgsl_pwrctrl_change_state(device, KGSL_STATE_SUSPEND);
if (!status && device->state == KGSL_STATE_SUSPEND)
adreno_get_gpu_halt(adreno_dev);
return status;
}
static int adreno_pm_suspend(struct device *dev)
{
struct kgsl_device *device = dev_get_drvdata(dev);
struct adreno_device *adreno_dev;
const struct adreno_power_ops *ops;
int status;
if (!device)
return 0;
adreno_dev = ADRENO_DEVICE(device);
ops = ADRENO_POWER_OPS(adreno_dev);
/* Return early if fault recovery is in progress */
if (!mutex_trylock(&adreno_dev->fault_recovery_mutex))
return -EDEADLK;
kgsl_mutex_lock(&device->mutex);
status = ops->pm_suspend(adreno_dev);
#if IS_ENABLED(CONFIG_DEEPSLEEP)
if (!status && pm_suspend_via_firmware())
adreno_zap_shader_unload(adreno_dev);
#endif
kgsl_mutex_unlock(&device->mutex);
mutex_unlock(&adreno_dev->fault_recovery_mutex);
if (status)
return status;
/*
* When the device enters in suspend state, the CX can be collapsed causing
* the GPU CX timer to pause. Clear the ADRENO_DEVICE_CX_TIMER_INITIALIZED
* flag to ensure that the CX timer is reseeded during resume.
*/
clear_bit(ADRENO_DEVICE_CX_TIMER_INITIALIZED, &adreno_dev->priv);
kgsl_reclaim_close();
kthread_flush_worker(device->events_worker);
flush_workqueue(kgsl_driver.lockless_workqueue);
return status;
}
void adreno_create_profile_buffer(struct adreno_device *adreno_dev)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
unsigned int priv = 0;
if (ADRENO_FEATURE(adreno_dev, ADRENO_APRIV))
priv = KGSL_MEMDESC_PRIVILEGED;
adreno_allocate_global(device, &adreno_dev->profile_buffer,
PAGE_SIZE, 0, 0, priv, "alwayson");
adreno_dev->profile_index = 0;
if (!IS_ERR(adreno_dev->profile_buffer))
set_bit(ADRENO_DEVICE_DRAWOBJ_PROFILE,
&adreno_dev->priv);
}
static int adreno_init(struct kgsl_device *device)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
int ret;
ret = kgsl_pwrctrl_change_state(device, KGSL_STATE_INIT);
if (ret)
return ret;
/*
* initialization only needs to be done once initially until
* device is shutdown
*/
if (test_bit(ADRENO_DEVICE_INITIALIZED, &adreno_dev->priv))
return 0;
ret = gpudev->init(adreno_dev);
if (ret)
return ret;
set_bit(ADRENO_DEVICE_INITIALIZED, &adreno_dev->priv);
return 0;
}
static bool gdscs_left_on(struct kgsl_device *device)
{
struct kgsl_pwrctrl *pwr = &device->pwrctrl;
if (gmu_core_gpmu_isenabled(device))
return false;
if (pwr->cx_regulator)
return regulator_is_enabled(pwr->cx_regulator);
if (pwr->gx_regulator)
return regulator_is_enabled(pwr->gx_regulator);
if (pwr->gmu_cx_pd)
return kgsl_genpd_is_enabled(pwr->gmu_cx_pd);
if (pwr->gx_pd)
return kgsl_genpd_is_enabled(pwr->gx_pd);
return false;
}
void adreno_set_active_ctxs_null(struct adreno_device *adreno_dev)
{
int i;
struct adreno_ringbuffer *rb;
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
if (rb->drawctxt_active)
kgsl_context_put(&(rb->drawctxt_active->base));
rb->drawctxt_active = NULL;
kgsl_sharedmem_writel(device->scratch,
SCRATCH_RB_OFFSET(rb->id, current_rb_ptname),
0);
}
}
static int adreno_open(struct adreno_device *adreno_dev)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
int ret;
/*
* active_cnt special case: we are starting up for the first
* time, so use this sequence instead of the kgsl_pwrctrl_wake()
* which will be called by adreno_active_count_get().
*/
atomic_inc(&device->active_cnt);
memset(device->memstore->hostptr, 0, device->memstore->size);
ret = adreno_init(device);
if (ret)
goto err;
ret = adreno_start(device, 0);
if (ret)
goto err;
complete_all(&device->hwaccess_gate);
set_bit(ADRENO_DEVICE_FIRST_BOOT_DONE, &adreno_dev->priv);
kgsl_pwrctrl_change_state(device, KGSL_STATE_ACTIVE);
adreno_active_count_put(adreno_dev);
return 0;
err:
kgsl_pwrctrl_change_state(device, KGSL_STATE_INIT);
atomic_dec(&device->active_cnt);
return ret;
}
static int adreno_first_open(struct kgsl_device *device)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);
if (!device->pdev_loaded)
return -ENODEV;
return ops->first_open(adreno_dev);
}
static int adreno_close(struct adreno_device *adreno_dev)
{
return kgsl_pwrctrl_change_state(KGSL_DEVICE(adreno_dev),
KGSL_STATE_INIT);
}
static int adreno_last_close(struct kgsl_device *device)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);
/*
* Wait up to 1 second for the active count to go low
* and then start complaining about it
*/
if (kgsl_active_count_wait(device, 0, HZ)) {
dev_err(device->dev,
"Waiting for the active count to become 0\n");
while (kgsl_active_count_wait(device, 0, HZ))
dev_err(device->dev,
"Still waiting for the active count\n");
}
return ops->last_close(adreno_dev);
}
static int adreno_pwrctrl_active_count_get(struct adreno_device *adreno_dev)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
int ret = 0;
if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
return -EINVAL;
if ((atomic_read(&device->active_cnt) == 0) &&
(device->state != KGSL_STATE_ACTIVE)) {
kgsl_mutex_unlock(&device->mutex);
wait_for_completion(&device->hwaccess_gate);
kgsl_mutex_lock(&device->mutex);
device->pwrctrl.superfast = true;
ret = kgsl_pwrctrl_change_state(device, KGSL_STATE_ACTIVE);
}
if (ret == 0)
atomic_inc(&device->active_cnt);
trace_kgsl_active_count(device,
(unsigned long) __builtin_return_address(0));
return ret;
}
void adreno_active_count_put(struct adreno_device *adreno_dev)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
return;
if (WARN(atomic_read(&device->active_cnt) == 0,
"Unbalanced get/put calls to KGSL active count\n"))
return;
if (atomic_dec_and_test(&device->active_cnt)) {
const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
if (!device->host_based_dcvs)
gpudev->power_feature_stats(adreno_dev);
kgsl_pwrscale_update_stats(device);
kgsl_pwrscale_update(device);
kgsl_start_idle_timer(device);
}
trace_kgsl_active_count(device,
(unsigned long) __builtin_return_address(0));
wake_up(&device->active_cnt_wq);
}
int adreno_active_count_get(struct adreno_device *adreno_dev)
{
const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);
return ops->active_count_get(adreno_dev);
}
void adreno_get_bus_counters(struct adreno_device *adreno_dev)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
int ret = 0;
if (!device->pwrctrl.bus_control)
return;
/* VBIF waiting for RAM */
ret |= adreno_perfcounter_kernel_get(adreno_dev,
KGSL_PERFCOUNTER_GROUP_VBIF_PWR, 0,
&adreno_dev->starved_ram_lo, NULL);
/* Target has GBIF */
if (adreno_is_gen8(adreno_dev) || adreno_is_gen7(adreno_dev) ||
(adreno_is_a6xx(adreno_dev) && !adreno_is_a630(adreno_dev))) {
ret |= adreno_perfcounter_kernel_get(adreno_dev,
KGSL_PERFCOUNTER_GROUP_VBIF_PWR, 1,
&adreno_dev->starved_ram_lo_ch1, NULL);
ret |= adreno_perfcounter_kernel_get(adreno_dev,
KGSL_PERFCOUNTER_GROUP_VBIF,
GBIF_AXI0_READ_DATA_TOTAL_BEATS,
&adreno_dev->ram_cycles_lo, NULL);
ret |= adreno_perfcounter_kernel_get(adreno_dev,
KGSL_PERFCOUNTER_GROUP_VBIF,
GBIF_AXI1_READ_DATA_TOTAL_BEATS,
&adreno_dev->ram_cycles_lo_ch1_read, NULL);
ret |= adreno_perfcounter_kernel_get(adreno_dev,
KGSL_PERFCOUNTER_GROUP_VBIF,
GBIF_AXI0_WRITE_DATA_TOTAL_BEATS,
&adreno_dev->ram_cycles_lo_ch0_write, NULL);
ret |= adreno_perfcounter_kernel_get(adreno_dev,
KGSL_PERFCOUNTER_GROUP_VBIF,
GBIF_AXI1_WRITE_DATA_TOTAL_BEATS,
&adreno_dev->ram_cycles_lo_ch1_write, NULL);
} else {
/* VBIF DDR cycles */
ret |= adreno_perfcounter_kernel_get(adreno_dev,
KGSL_PERFCOUNTER_GROUP_VBIF,
VBIF_AXI_TOTAL_BEATS,
&adreno_dev->ram_cycles_lo, NULL);
}
if (ret)
dev_err(KGSL_DEVICE(adreno_dev)->dev,
"Unable to get perf counters for bus DCVS\n");
}
#define ADRENO_AHB_MIN_TIMEOUT_VAL_USEC 1000
u32 adreno_get_ahb_timeout_val(struct adreno_device *adreno_dev, u32 noc_timeout_us)
{
u64 cycles, hub_clk_freq = adreno_dev->gmu_hub_clk_freq;
u32 timeout_val;
if (!noc_timeout_us)
return 0;
do_div(hub_clk_freq, HZ_PER_MHZ);
cycles = hub_clk_freq * noc_timeout_us;
/*
* Get max possible AHB timeout value which is less than the GPU NOC timeout value.
* When cycles are exact power of two, the calculated AHB timeout value will be same
* as GPU config NOC timeout. Just reduce one cycle to make sure we do not program AHB
* timeout same as GPU config NOC timeout.
*/
if (is_power_of_2(cycles))
cycles -= 1;
timeout_val = ilog2(cycles);
/*
* Make sure, AHB timeout value fits into bit fields and it is not too low
* which can cause false timeouts.
*/
if ((timeout_val > GENMASK(4, 0)) ||
((ADRENO_AHB_MIN_TIMEOUT_VAL_USEC * hub_clk_freq) > (1 << timeout_val))) {
dev_warn(adreno_dev->dev.dev, "Invalid AHB timeout_val %u\n", timeout_val);
return 0;
}
/*
* Return (timeout_val - 1). Based on timeout_val programmed, a timeout will occur if
* an AHB transaction is not completed in 2 ^ (timeout_val + 1) cycles.
*/
return (timeout_val - 1);
}
/**
* _adreno_start - Power up the GPU and prepare to accept commands
* @adreno_dev: Pointer to an adreno_device structure
*
* The core function that powers up and initalizes the GPU. This function is
* called at init and after coming out of SLUMBER
*/
static int _adreno_start(struct adreno_device *adreno_dev)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
int status;
unsigned int state = device->state;
bool gdsc_left_on;
/* make sure ADRENO_DEVICE_STARTED is not set here */
WARN_ON(test_bit(ADRENO_DEVICE_STARTED, &adreno_dev->priv));
gdsc_left_on = gdscs_left_on(device);
/* Clear any GPU faults that might have been left over */
adreno_clear_gpu_fault(adreno_dev);
/* Put the GPU in a responsive state */
status = kgsl_pwrctrl_change_state(device, KGSL_STATE_AWARE);
if (status)
goto error_pwr_off;
/* Set any stale active contexts to NULL */
adreno_set_active_ctxs_null(adreno_dev);
/* Set the bit to indicate that we've just powered on */
set_bit(ADRENO_DEVICE_PWRON, &adreno_dev->priv);
/* Clear the busy_data stats - we're starting over from scratch */
memset(&adreno_dev->busy_data, 0, sizeof(adreno_dev->busy_data));
/* Soft reset the GPU if a regulator is stuck on*/
if (gdsc_left_on)
_soft_reset(adreno_dev);
/* Start the GPU */
status = gpudev->start(adreno_dev);
if (status)
goto error_pwr_off;
/* Re-initialize the coresight registers if applicable */
adreno_coresight_start(adreno_dev);
adreno_irqctrl(adreno_dev, 1);
adreno_perfcounter_start(adreno_dev);
/* Clear FSR here in case it is set from a previous pagefault */
kgsl_mmu_clear_fsr(&device->mmu);
status = gpudev->rb_start(adreno_dev);
if (status)
goto error_pwr_off;
/*
* At this point it is safe to assume that we recovered. Setting
* this field allows us to take a new snapshot for the next failure
* if we are prioritizing the first unrecoverable snapshot.
*/
if (device->snapshot)
device->snapshot->recovered = true;
/* Start the dispatcher */
adreno_dispatcher_start(device);
device->reset_counter++;
set_bit(ADRENO_DEVICE_STARTED, &adreno_dev->priv);
/*
* There is a possible deadlock scenario during kgsl firmware reading
* (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl
* device mutex is held and then firmware_request_nowarn is called for reading
* firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock.
* Whereas in case of devfreq update calls triggered by thermal/bcl or
* devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then
* tries to take kgsl device mutex as part of get_dev_status/target
* calls. This results in deadlock when both thread are unable to acquire
* the mutex held by other thread. Enable devfreq updates now as we are
* done reading all firmware files.
*/
device->pwrscale.devfreq_enabled = true;
return 0;
error_pwr_off:
/* set the state back to original state */
kgsl_pwrctrl_change_state(device, state);
return status;
}
/**
* adreno_start() - Power up and initialize the GPU
* @device: Pointer to the KGSL device to power up
* @priority: Boolean flag to specify of the start should be scheduled in a low
* latency work queue
*
* Power up the GPU and initialize it. If priority is specified then elevate
* the thread priority for the duration of the start operation
*/
int adreno_start(struct kgsl_device *device, int priority)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
int nice = task_nice(current);
int ret;
if (priority && (adreno_wake_nice < nice))
set_user_nice(current, adreno_wake_nice);
ret = _adreno_start(adreno_dev);
if (priority)
set_user_nice(current, nice);
return ret;
}
static int adreno_stop(struct kgsl_device *device)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
int error = 0;
if (!test_bit(ADRENO_DEVICE_STARTED, &adreno_dev->priv))
return 0;
kgsl_pwrscale_update_stats(device);
adreno_irqctrl(adreno_dev, 0);
/* Save active coresight registers if applicable */
adreno_coresight_stop(adreno_dev);
/* Save physical performance counter values before GPU power down*/
adreno_perfcounter_save(adreno_dev);
if (gpudev->clear_pending_transactions)
gpudev->clear_pending_transactions(adreno_dev);
adreno_dispatcher_stop(adreno_dev);
adreno_ringbuffer_stop(adreno_dev);
adreno_llcc_slice_deactivate(adreno_dev);
adreno_set_active_ctxs_null(adreno_dev);
clear_bit(ADRENO_DEVICE_STARTED, &adreno_dev->priv);
return error;
}
/**
* adreno_reset() - Helper function to reset the GPU
* @device: Pointer to the KGSL device structure for the GPU
* @fault: Type of fault. Needed to skip soft reset for MMU fault
*
* Try to reset the GPU to recover from a fault. First, try to do a low latency
* soft reset. If the soft reset fails for some reason, then bring out the big
* guns and toggle the footswitch.
*/
int adreno_reset(struct kgsl_device *device, int fault)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
int ret = -EINVAL;
int i;
if (gpudev->reset)
return adreno_gpudev_reset(adreno_dev);
/*
* Try soft reset first Do not do soft reset for a IOMMU fault (because
* the IOMMU hardware needs a reset too)
*/
if (!(fault & ADRENO_IOMMU_STALL_ON_PAGE_FAULT))
ret = adreno_soft_reset(device);
if (ret) {
/* If soft reset failed/skipped, then pull the power */
kgsl_pwrctrl_change_state(device, KGSL_STATE_INIT);
/* since device is officially off now clear start bit */
clear_bit(ADRENO_DEVICE_STARTED, &adreno_dev->priv);
/* Try to reset the device */
ret = adreno_start(device, 0);
for (i = 0; ret && i < 4; i++) {
msleep(20);
ret = adreno_start(device, 0);
}
if (ret)
return ret;
if (i != 0)
dev_warn(device->dev,
"Device hard reset tried %d tries\n", i);
}
/*
* If active_cnt is non-zero then the system was active before
* going into a reset - put it back in that state
*/
if (atomic_read(&device->active_cnt))
kgsl_pwrctrl_change_state(device, KGSL_STATE_ACTIVE);
return ret;
}
static int copy_prop(struct kgsl_device_getproperty *param,
void *src, size_t size)
{
if (copy_to_user(param->value, src,
min_t(u32, size, param->sizebytes)))
return -EFAULT;
return 0;
}
static int adreno_prop_device_info(struct kgsl_device *device,
struct kgsl_device_getproperty *param)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
struct kgsl_devinfo devinfo = {
.device_id = device->id + 1,
.chip_id = adreno_dev->chipid,
.mmu_enabled = kgsl_mmu_has_feature(device, KGSL_MMU_PAGED),
.gmem_gpubaseaddr = 0,
.gmem_sizebytes = adreno_gmem_size(adreno_dev),
};
return copy_prop(param, &devinfo, sizeof(devinfo));
}
static int adreno_prop_gpu_model(struct kgsl_device *device,
struct kgsl_device_getproperty *param)
{
struct kgsl_gpu_model model = {0};
strscpy(model.gpu_model, adreno_get_gpu_model(device),
sizeof(model.gpu_model));
return copy_prop(param, &model, sizeof(model));
}
static int adreno_prop_device_shadow(struct kgsl_device *device,
struct kgsl_device_getproperty *param)
{
struct kgsl_shadowprop shadowprop = { 0 };
if (device->memstore->hostptr) {
/* Pass a dummy address to identify memstore */
shadowprop.gpuaddr = KGSL_MEMSTORE_TOKEN_ADDRESS;
shadowprop.size = device->memstore->size;
shadowprop.flags = KGSL_FLAGS_INITIALIZED |
KGSL_FLAGS_PER_CONTEXT_TIMESTAMPS;
}
return copy_prop(param, &shadowprop, sizeof(shadowprop));
}
static int adreno_prop_device_qdss_stm(struct kgsl_device *device,
struct kgsl_device_getproperty *param)
{
struct kgsl_qdss_stm_prop qdssprop = {0};
if (!IS_ERR_OR_NULL(device->qdss_desc)) {
qdssprop.gpuaddr = device->qdss_desc->gpuaddr;
qdssprop.size = device->qdss_desc->size;
}
return copy_prop(param, &qdssprop, sizeof(qdssprop));
}
static int adreno_prop_device_qtimer(struct kgsl_device *device,
struct kgsl_device_getproperty *param)
{
struct kgsl_qtimer_prop qtimerprop = {0};
if (!IS_ERR_OR_NULL(device->qtimer_desc)) {
qtimerprop.gpuaddr = device->qtimer_desc->gpuaddr;
qtimerprop.size = device->qtimer_desc->size;
}
return copy_prop(param, &qtimerprop, sizeof(qtimerprop));
}
static int adreno_prop_s32(struct kgsl_device *device,
struct kgsl_device_getproperty *param)
{
int val = 0;
if (param->type == KGSL_PROP_MMU_ENABLE)
val = kgsl_mmu_has_feature(device, KGSL_MMU_PAGED);
else if (param->type == KGSL_PROP_INTERRUPT_WAITS)
val = 1;
return copy_prop(param, &val, sizeof(val));
}
static int adreno_prop_uche_gmem_addr(struct kgsl_device *device,
struct kgsl_device_getproperty *param)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
return copy_prop(param, &adreno_dev->uche_gmem_base,
sizeof(adreno_dev->uche_gmem_base));
}
static int adreno_prop_ucode_version(struct kgsl_device *device,
struct kgsl_device_getproperty *param)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
struct kgsl_ucode_version ucode = {
.pfp = adreno_dev->fw[ADRENO_FW_PFP].version,
.pm4 = adreno_dev->fw[ADRENO_FW_PM4].version,
};
return copy_prop(param, &ucode, sizeof(ucode));
}
static int adreno_prop_gaming_bin(struct kgsl_device *device,
struct kgsl_device_getproperty *param)
{
void *buf;
size_t len;
int ret;
struct nvmem_cell *cell;
cell = nvmem_cell_get(&device->pdev->dev, "gaming_bin");
if (IS_ERR(cell))
return -EINVAL;
buf = nvmem_cell_read(cell, &len);
nvmem_cell_put(cell);
if (!IS_ERR(buf)) {
ret = copy_prop(param, buf, len);
kfree(buf);
return ret;
}
dev_err(device->dev, "failed to read gaming_bin nvmem cell\n");
return -EINVAL;
}
static int adreno_prop_u32(struct kgsl_device *device,
struct kgsl_device_getproperty *param)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
u32 val = 0;
if (param->type == KGSL_PROP_HIGHEST_BANK_BIT) {
val = adreno_dev->highest_bank_bit;
} else if (param->type == KGSL_PROP_MIN_ACCESS_LENGTH)
val = adreno_dev->mal;
else if (param->type == KGSL_PROP_UBWC_MODE)
val = adreno_dev->ubwc_mode;
else if (param->type == KGSL_PROP_DEVICE_BITNESS)
val = adreno_support_64bit(adreno_dev) ? 48 : 32;
else if (param->type == KGSL_PROP_SPEED_BIN)
val = device->speed_bin;
else if (param->type == KGSL_PROP_VK_DEVICE_ID)
val = adreno_get_vk_device_id(device);
else if (param->type == KGSL_PROP_IS_LPAC_ENABLED)
val = adreno_dev->lpac_enabled ? 1 : 0;
else if (param->type == KGSL_PROP_IS_RAYTRACING_ENABLED)
val = adreno_dev->raytracing_enabled ? 1 : 0;
else if (param->type == KGSL_PROP_IS_FASTBLEND_ENABLED)
val = adreno_dev->fastblend_enabled ? 1 : 0;
else if (param->type == KGSL_PROP_IS_AQE_ENABLED)
val = ADRENO_FEATURE(adreno_dev, ADRENO_AQE) ? 1 : 0;
else if (param->type == KGSL_PROP_MULTIDRAW_MODE)
val = adreno_dev->multidraw_mode;
else if (param->type == KGSL_PROP_VIZ_FLUSH_DRAW_COUNT)
val = adreno_dev->viz_flush_draw_count;
else if (param->type == KGSL_PROP_VIZ_FLUSH_PRIM_COUNT)
val = adreno_dev->viz_flush_prim_count;
else if (param->type == KGSL_PROP_IS_MALU_ENABLED)
val = adreno_dev->malu_enabled ? 1 : 0;
return copy_prop(param, &val, sizeof(val));
}
static int adreno_prop_uche_trap_base(struct kgsl_device *device,
struct kgsl_device_getproperty *param)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
u64 val = 0;
if (!gpudev->get_uche_trap_base)
return -EINVAL;
val = gpudev->get_uche_trap_base();
return copy_prop(param, &val, sizeof(val));
}
static const struct {
int type;
int (*func)(struct kgsl_device *device,
struct kgsl_device_getproperty *param);
} adreno_property_funcs[] = {
{ KGSL_PROP_DEVICE_INFO, adreno_prop_device_info },
{ KGSL_PROP_DEVICE_SHADOW, adreno_prop_device_shadow },
{ KGSL_PROP_DEVICE_QDSS_STM, adreno_prop_device_qdss_stm },
{ KGSL_PROP_DEVICE_QTIMER, adreno_prop_device_qtimer },
{ KGSL_PROP_MMU_ENABLE, adreno_prop_s32 },
{ KGSL_PROP_INTERRUPT_WAITS, adreno_prop_s32 },
{ KGSL_PROP_UCHE_GMEM_VADDR, adreno_prop_uche_gmem_addr },
{ KGSL_PROP_UCODE_VERSION, adreno_prop_ucode_version },
{ KGSL_PROP_HIGHEST_BANK_BIT, adreno_prop_u32 },
{ KGSL_PROP_MIN_ACCESS_LENGTH, adreno_prop_u32 },
{ KGSL_PROP_UBWC_MODE, adreno_prop_u32 },
{ KGSL_PROP_DEVICE_BITNESS, adreno_prop_u32 },
{ KGSL_PROP_SPEED_BIN, adreno_prop_u32 },
{ KGSL_PROP_GAMING_BIN, adreno_prop_gaming_bin },
{ KGSL_PROP_GPU_MODEL, adreno_prop_gpu_model},
{ KGSL_PROP_VK_DEVICE_ID, adreno_prop_u32},
{ KGSL_PROP_IS_LPAC_ENABLED, adreno_prop_u32 },
{ KGSL_PROP_IS_RAYTRACING_ENABLED, adreno_prop_u32},
{ KGSL_PROP_IS_FASTBLEND_ENABLED, adreno_prop_u32},
{ KGSL_PROP_UCHE_TRAP_BASE, adreno_prop_uche_trap_base },
{ KGSL_PROP_IS_AQE_ENABLED, adreno_prop_u32 },
{ KGSL_PROP_MULTIDRAW_MODE, adreno_prop_u32 },
{ KGSL_PROP_VIZ_FLUSH_DRAW_COUNT, adreno_prop_u32 },
{ KGSL_PROP_VIZ_FLUSH_PRIM_COUNT, adreno_prop_u32 },
};
static int adreno_getproperty(struct kgsl_device *device,
struct kgsl_device_getproperty *param)
{
int i;
for (i = 0; i < ARRAY_SIZE(adreno_property_funcs); i++) {
if (param->type == adreno_property_funcs[i].type)
return adreno_property_funcs[i].func(device, param);
}
return -ENODEV;
}
static int adreno_query_property_list(struct kgsl_device *device, u32 *list,
u32 count)
{
int i;
if (!list)
return ARRAY_SIZE(adreno_property_funcs);
for (i = 0; i < count && i < ARRAY_SIZE(adreno_property_funcs); i++)
list[i] = adreno_property_funcs[i].type;
return i;
}
static int adreno_gmu_based_dcvs_pwr_ops(struct kgsl_device *device, u32 arg,
enum gpu_pwrlevel_op op)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);
if (device->host_based_dcvs)
return -EOPNOTSUPP;
if (ops->gmu_based_dcvs_pwr_ops)
ops->gmu_based_dcvs_pwr_ops(adreno_dev, arg, op);
return 0;
}
int adreno_set_constraint(struct kgsl_device *device,
struct kgsl_context *context,
struct kgsl_device_constraint *constraint)
{
int status = 0;
switch (constraint->type) {
case KGSL_CONSTRAINT_PWRLEVEL: {
struct kgsl_device_constraint_pwrlevel pwr;
u32 max_supported_level;
if (constraint->size != sizeof(pwr)) {
status = -EINVAL;
break;
}
if (copy_from_user(&pwr,
(void __user *)constraint->data,
sizeof(pwr))) {
status = -EFAULT;
break;
}
max_supported_level = (device->host_based_dcvs) ?
KGSL_CONSTRAINT_PWR_MAXLEVELS - 1 : KGSL_CONSTRAINT_PWR_PERC_MAX;
if (pwr.level > max_supported_level) {
status = -EINVAL;
break;
}
context->pwr_constraint.type =
KGSL_CONSTRAINT_PWRLEVEL;
context->pwr_constraint.sub_type = pwr.level;
adreno_gmu_based_dcvs_pwr_ops(device, context->id, GPU_PWRLEVEL_OP_PERF_HINT);
trace_kgsl_user_pwrlevel_constraint(device,
context->id,
context->pwr_constraint.type,
context->pwr_constraint.sub_type);
}
break;
case KGSL_CONSTRAINT_NONE: {
if (context->pwr_constraint.type == KGSL_CONSTRAINT_PWRLEVEL) {
trace_kgsl_user_pwrlevel_constraint(device,
context->id,
KGSL_CONSTRAINT_NONE,
context->pwr_constraint.sub_type);
context->pwr_constraint.type = KGSL_CONSTRAINT_NONE;
adreno_gmu_based_dcvs_pwr_ops(device, context->id,
GPU_PWRLEVEL_OP_PERF_HINT);
} else {
context->pwr_constraint.type = KGSL_CONSTRAINT_NONE;
}
}
break;
case KGSL_CONSTRAINT_L3_PWRLEVEL: {
struct kgsl_device_constraint_pwrlevel pwr;
if (constraint->size != sizeof(pwr)) {
status = -EINVAL;
break;
}
if (copy_from_user(&pwr, constraint->data, sizeof(pwr))) {
status = -EFAULT;
break;
}
status = register_l3_voter(device);
if (status)
break;
if (pwr.level >= KGSL_CONSTRAINT_PWR_MAXLEVELS)
pwr.level = KGSL_CONSTRAINT_PWR_MAXLEVELS - 1;
context->l3_pwr_constraint.type = KGSL_CONSTRAINT_L3_PWRLEVEL;
context->l3_pwr_constraint.sub_type = pwr.level;
trace_kgsl_user_pwrlevel_constraint(device, context->id,
context->l3_pwr_constraint.type,
context->l3_pwr_constraint.sub_type);
}
break;
case KGSL_CONSTRAINT_L3_NONE: {
unsigned int type = context->l3_pwr_constraint.type;
if (type == KGSL_CONSTRAINT_L3_PWRLEVEL)
trace_kgsl_user_pwrlevel_constraint(device, context->id,
KGSL_CONSTRAINT_L3_NONE,
context->l3_pwr_constraint.sub_type);
context->l3_pwr_constraint.type = KGSL_CONSTRAINT_L3_NONE;
}
break;
default:
status = -EINVAL;
break;
}
/* If a new constraint has been set for a context, cancel the old one */
if ((status == 0) &&
(context->id == device->pwrctrl.constraint.owner_id)) {
trace_kgsl_constraint(device, device->pwrctrl.constraint.type,
device->pwrctrl.active_pwrlevel, 0, 0);
device->pwrctrl.constraint.type = KGSL_CONSTRAINT_NONE;
}
return status;
}
static int adreno_default_setproperty(struct kgsl_device_private *dev_priv,
u32 type, void __user *value, u32 sizebytes)
{
struct kgsl_device *device = dev_priv->device;
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
u32 enable;
if (type != KGSL_PROP_PWRCTRL)
return -ENODEV;
if (sizebytes != sizeof(enable))
return -EINVAL;
if (copy_from_user(&enable, value, sizeof(enable)))
return -EFAULT;
kgsl_mutex_lock(&device->mutex);
if (enable) {
if (gmu_core_isenabled(device))
clear_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags);
else
device->pwrctrl.ctrl_flags = 0;
if (device->host_based_dcvs)
kgsl_pwrscale_governor_enable(device);
else
device->ftbl->gmu_based_dcvs_pwr_ops(device, enable,
GPU_PWRLEVEL_OP_DCVS_ENABLE);
} else {
if (gmu_core_isenabled(device)) {
set_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags);
if (!adreno_active_count_get(adreno_dev))
adreno_active_count_put(adreno_dev);
} else {
kgsl_pwrctrl_change_state(device, KGSL_STATE_ACTIVE);
device->pwrctrl.ctrl_flags = KGSL_PWR_ON;
}
if (device->host_based_dcvs) {
kgsl_pwrscale_governor_disable(device, true);
} else {
device->ftbl->gmu_based_dcvs_pwr_ops(device, enable,
GPU_PWRLEVEL_OP_DCVS_ENABLE);
device->ftbl->gmu_based_dcvs_pwr_ops(device, 0, GPU_PWRLEVEL_OP_GPUCLK);
}
}
kgsl_mutex_unlock(&device->mutex);
return 0;
}
static void adreno_alloc_dcvs_profile_memory(struct kgsl_device *device,
struct kgsl_process_private *proc_priv)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
struct kgsl_memdesc *md = &proc_priv->profile.md;
u32 sizebytes;
if (!ADRENO_FEATURE(adreno_dev, ADRENO_DCVS_PROFILE))
return;
if (!gmu_core_alloc_kernel_block(device, md,
SZ_4K, GMU_NONCACHED_KERNEL,
IOMMU_READ | IOMMU_WRITE | IOMMU_PRIV)) {
/* KMD need to initialize KGSL region to KGSL_DCVS_ATTR_UNUSED for
* torn state handling as per design and second half region to 0 so that
* if there is no profile ever registered for a process, GMU can skip
* tracking for this profile.
*/
sizebytes = md->size >> 1;
memset(md->hostptr, KGSL_DCVS_ATTR_UNUSED, sizebytes);
memset(md->hostptr + sizebytes, 0, sizebytes);
}
}
static int adreno_set_dcvs_profile(struct kgsl_device_private *dev_priv,
void __user *data, u32 sizebytes)
{
struct kgsl_device *device = dev_priv->device;
struct kgsl_process_private *proc_priv = dev_priv->process_priv;
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
const struct adreno_hwsched_ops *hwsched_ops = adreno_dev->hwsched.hwsched_ops;
struct kgsl_memdesc *md = &proc_priv->profile.md;
struct kgsl_dcvs_profile param = {0};
struct kgsl_dcvs_attrs attrs;
u32 size;
int ret = 0;
if (!ADRENO_FEATURE(adreno_dev, ADRENO_DCVS_PROFILE))
return -EOPNOTSUPP;
/* Restrict to one profile per process */
mutex_lock(&proc_priv->profile.profile_mutex);
if (proc_priv->profile.user_profile_registered) {
ret = -EINVAL;
goto done;
}
/* Not enough allocated GMU memory */
if ((!md->hostptr) || (sizeof(attrs) > (md->size >> 1))) {
ret = -ENOMEM;
goto done;
}
size = min_t(u32, sizeof(param), sizebytes);
if (copy_from_user(¶m, data, size)) {
ret = -EFAULT;
goto done;
}
/*
* Divide shared buffer into two equal parts and first part addresses
* should be reserved for KGSL to copy profile buffer and second
* part addresses for GMU Internal usage.
*/
size = min_t(u32, sizeof(attrs), param.attrs_size);
if (copy_from_user(md->hostptr, u64_to_user_ptr(param.attrs), size)) {
memset(md->hostptr, KGSL_DCVS_ATTR_UNUSED, size);
ret = -EFAULT;
goto done;
}
========== PART_03.txt ==========
if (hwsched_ops->set_dcvs_profile && adreno_dev->dcvs_profile_enabled) {
kgsl_mutex_lock(&device->mutex);
ret = hwsched_ops->set_dcvs_profile(adreno_dev, proc_priv);
kgsl_mutex_unlock(&device->mutex);
}
done:
mutex_unlock(&proc_priv->profile.profile_mutex);
return ret;
}