Skip to content

Commit a452510

Browse files
quic-kdybcioRob Clark
authored andcommitted
drm/msm/adreno: Switch to the common UBWC config struct
Now that Adreno specifics are out of the way, use the common config (but leave the HBB hardcoding in place until that is wired up on the other side). Acked-by: Dmitry Baryshkov <[email protected]> Signed-off-by: Konrad Dybcio <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/660985/ Signed-off-by: Rob Clark <[email protected]>
1 parent 2728285 commit a452510

File tree

4 files changed

+59
-86
lines changed

4 files changed

+59
-86
lines changed

drivers/gpu/drm/msm/adreno/a5xx_gpu.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -835,8 +835,8 @@ static int a5xx_hw_init(struct msm_gpu *gpu)
835835

836836
gpu_write(gpu, REG_A5XX_RBBM_AHB_CNTL2, 0x0000003F);
837837

838-
BUG_ON(adreno_gpu->ubwc_config.highest_bank_bit < 13);
839-
hbb = adreno_gpu->ubwc_config.highest_bank_bit - 13;
838+
BUG_ON(adreno_gpu->ubwc_config->highest_bank_bit < 13);
839+
hbb = adreno_gpu->ubwc_config->highest_bank_bit - 13;
840840

841841
gpu_write(gpu, REG_A5XX_TPL1_MODE_CNTL, hbb << 7);
842842
gpu_write(gpu, REG_A5XX_RB_MODE_CNTL, hbb << 1);
@@ -1756,6 +1756,7 @@ struct msm_gpu *a5xx_gpu_init(struct drm_device *dev)
17561756
struct msm_drm_private *priv = dev->dev_private;
17571757
struct platform_device *pdev = priv->gpu_pdev;
17581758
struct adreno_platform_config *config = pdev->dev.platform_data;
1759+
const struct qcom_ubwc_cfg_data *common_cfg;
17591760
struct a5xx_gpu *a5xx_gpu = NULL;
17601761
struct adreno_gpu *adreno_gpu;
17611762
struct msm_gpu *gpu;
@@ -1792,15 +1793,14 @@ struct msm_gpu *a5xx_gpu_init(struct drm_device *dev)
17921793
/* Set up the preemption specific bits and pieces for each ringbuffer */
17931794
a5xx_preempt_init(gpu);
17941795

1795-
/* Set the highest bank bit */
1796-
if (adreno_is_a540(adreno_gpu) || adreno_is_a530(adreno_gpu))
1797-
adreno_gpu->ubwc_config.highest_bank_bit = 15;
1798-
else
1799-
adreno_gpu->ubwc_config.highest_bank_bit = 14;
1796+
/* Inherit the common config and make some necessary fixups */
1797+
common_cfg = qcom_ubwc_config_get_data();
1798+
if (IS_ERR(common_cfg))
1799+
return ERR_CAST(common_cfg);
18001800

1801-
/* a5xx only supports UBWC 1.0, these are not configurable */
1802-
adreno_gpu->ubwc_config.macrotile_mode = 0;
1803-
adreno_gpu->ubwc_config.ubwc_swizzle = 0x7;
1801+
/* Copy the data into the internal struct to drop the const qualifier (temporarily) */
1802+
adreno_gpu->_ubwc_config = *common_cfg;
1803+
adreno_gpu->ubwc_config = &adreno_gpu->_ubwc_config;
18041804

18051805
adreno_gpu->uche_trap_base = 0x0001ffffffff0000ull;
18061806

drivers/gpu/drm/msm/adreno/a6xx_gpu.c

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -606,79 +606,85 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu)
606606

607607
static int a6xx_calc_ubwc_config(struct adreno_gpu *gpu)
608608
{
609+
const struct qcom_ubwc_cfg_data *common_cfg;
610+
struct qcom_ubwc_cfg_data *cfg = &gpu->_ubwc_config;
611+
609612
/* Inherit the common config and make some necessary fixups */
610-
gpu->common_ubwc_cfg = qcom_ubwc_config_get_data();
611-
if (IS_ERR(gpu->common_ubwc_cfg))
612-
return PTR_ERR(gpu->common_ubwc_cfg);
613+
common_cfg = qcom_ubwc_config_get_data();
614+
if (IS_ERR(common_cfg))
615+
return PTR_ERR(common_cfg);
616+
617+
/* Copy the data into the internal struct to drop the const qualifier (temporarily) */
618+
*cfg = *common_cfg;
613619

614-
gpu->ubwc_config.ubwc_swizzle = 0x6;
615-
gpu->ubwc_config.macrotile_mode = 0;
616-
gpu->ubwc_config.highest_bank_bit = 15;
620+
cfg->ubwc_swizzle = 0x6;
621+
cfg->highest_bank_bit = 15;
617622

618623
if (adreno_is_a610(gpu)) {
619-
gpu->ubwc_config.highest_bank_bit = 13;
620-
gpu->ubwc_config.ubwc_swizzle = 0x7;
624+
cfg->highest_bank_bit = 13;
625+
cfg->ubwc_swizzle = 0x7;
621626
}
622627

623628
if (adreno_is_a618(gpu))
624-
gpu->ubwc_config.highest_bank_bit = 14;
629+
cfg->highest_bank_bit = 14;
625630

626631
if (adreno_is_a619(gpu))
627632
/* TODO: Should be 14 but causes corruption at e.g. 1920x1200 on DP */
628-
gpu->ubwc_config.highest_bank_bit = 13;
633+
cfg->highest_bank_bit = 13;
629634

630635
if (adreno_is_a619_holi(gpu))
631-
gpu->ubwc_config.highest_bank_bit = 13;
636+
cfg->highest_bank_bit = 13;
632637

633638
if (adreno_is_a621(gpu))
634-
gpu->ubwc_config.highest_bank_bit = 13;
635-
636-
if (adreno_is_a623(gpu)) {
637-
gpu->ubwc_config.highest_bank_bit = 16;
638-
gpu->ubwc_config.macrotile_mode = 1;
639-
}
639+
cfg->highest_bank_bit = 13;
640640

641-
if (adreno_is_a680(gpu))
642-
gpu->ubwc_config.macrotile_mode = 1;
641+
if (adreno_is_a623(gpu))
642+
cfg->highest_bank_bit = 16;
643643

644644
if (adreno_is_a650(gpu) ||
645645
adreno_is_a660(gpu) ||
646646
adreno_is_a690(gpu) ||
647647
adreno_is_a730(gpu) ||
648648
adreno_is_a740_family(gpu)) {
649-
/* TODO: get ddr type from bootloader and use 2 for LPDDR4 */
650-
gpu->ubwc_config.highest_bank_bit = 16;
651-
gpu->ubwc_config.macrotile_mode = 1;
649+
/* TODO: get ddr type from bootloader and use 15 for LPDDR4 */
650+
cfg->highest_bank_bit = 16;
652651
}
653652

654653
if (adreno_is_a663(gpu)) {
655-
gpu->ubwc_config.highest_bank_bit = 13;
656-
gpu->ubwc_config.macrotile_mode = 1;
657-
gpu->ubwc_config.ubwc_swizzle = 0x4;
654+
cfg->highest_bank_bit = 13;
655+
cfg->ubwc_swizzle = 0x4;
658656
}
659657

660-
if (adreno_is_7c3(gpu)) {
661-
gpu->ubwc_config.highest_bank_bit = 14;
662-
gpu->ubwc_config.macrotile_mode = 1;
663-
}
658+
if (adreno_is_7c3(gpu))
659+
cfg->highest_bank_bit = 14;
664660

665661
if (adreno_is_a702(gpu))
666-
gpu->ubwc_config.highest_bank_bit = 14;
662+
cfg->highest_bank_bit = 14;
663+
664+
if (cfg->highest_bank_bit != common_cfg->highest_bank_bit)
665+
DRM_WARN_ONCE("Inconclusive highest_bank_bit value: %u (GPU) vs %u (UBWC_CFG)\n",
666+
cfg->highest_bank_bit, common_cfg->highest_bank_bit);
667+
668+
if (cfg->ubwc_swizzle != common_cfg->ubwc_swizzle)
669+
DRM_WARN_ONCE("Inconclusive ubwc_swizzle value: %u (GPU) vs %u (UBWC_CFG)\n",
670+
cfg->ubwc_swizzle, common_cfg->ubwc_swizzle);
671+
672+
gpu->ubwc_config = &gpu->_ubwc_config;
667673

668674
return 0;
669675
}
670676

671677
static void a6xx_set_ubwc_config(struct msm_gpu *gpu)
672678
{
673679
struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
674-
const struct qcom_ubwc_cfg_data *cfg = adreno_gpu->common_ubwc_cfg;
680+
const struct qcom_ubwc_cfg_data *cfg = adreno_gpu->ubwc_config;
675681
/*
676682
* We subtract 13 from the highest bank bit (13 is the minimum value
677683
* allowed by hw) and write the lowest two bits of the remaining value
678684
* as hbb_lo and the one above it as hbb_hi to the hardware.
679685
*/
680-
BUG_ON(adreno_gpu->ubwc_config.highest_bank_bit < 13);
681-
u32 hbb = adreno_gpu->ubwc_config.highest_bank_bit - 13;
686+
BUG_ON(cfg->highest_bank_bit < 13);
687+
u32 hbb = cfg->highest_bank_bit - 13;
682688
bool rgb565_predicator = cfg->ubwc_enc_version >= UBWC_4_0;
683689
u32 level2_swizzling_dis = !(cfg->ubwc_swizzle & UBWC_SWIZZLE_ENABLE_LVL2);
684690
bool ubwc_mode = qcom_ubwc_get_ubwc_mode(cfg);
@@ -720,7 +726,7 @@ static void a6xx_set_ubwc_config(struct msm_gpu *gpu)
720726
min_acc_len_64b << 23 | hbb_lo << 21);
721727

722728
gpu_write(gpu, REG_A6XX_RBBM_NC_MODE_CNTL,
723-
adreno_gpu->ubwc_config.macrotile_mode);
729+
cfg->macrotile_mode);
724730
}
725731

726732
static void a7xx_patch_pwrup_reglist(struct msm_gpu *gpu)

drivers/gpu/drm/msm/adreno/adreno_gpu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,16 +435,16 @@ int adreno_get_param(struct msm_gpu *gpu, struct msm_context *ctx,
435435
*value = vm->mm_range;
436436
return 0;
437437
case MSM_PARAM_HIGHEST_BANK_BIT:
438-
*value = adreno_gpu->ubwc_config.highest_bank_bit;
438+
*value = adreno_gpu->ubwc_config->highest_bank_bit;
439439
return 0;
440440
case MSM_PARAM_RAYTRACING:
441441
*value = adreno_gpu->has_ray_tracing;
442442
return 0;
443443
case MSM_PARAM_UBWC_SWIZZLE:
444-
*value = adreno_gpu->ubwc_config.ubwc_swizzle;
444+
*value = adreno_gpu->ubwc_config->ubwc_swizzle;
445445
return 0;
446446
case MSM_PARAM_MACROTILE_MODE:
447-
*value = adreno_gpu->ubwc_config.macrotile_mode;
447+
*value = adreno_gpu->ubwc_config->macrotile_mode;
448448
return 0;
449449
case MSM_PARAM_UCHE_TRAP_BASE:
450450
*value = adreno_gpu->uche_trap_base;

drivers/gpu/drm/msm/adreno/adreno_gpu.h

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -206,45 +206,12 @@ struct adreno_gpu {
206206
/* firmware: */
207207
const struct firmware *fw[ADRENO_FW_MAX];
208208

209-
struct {
210-
/**
211-
* @rgb565_predicator: Unknown, introduced with A650 family,
212-
* related to UBWC mode/ver 4
213-
*/
214-
u32 rgb565_predicator;
215-
/** @uavflagprd_inv: Unknown, introduced with A650 family */
216-
u32 uavflagprd_inv;
217-
/** @min_acc_len: Whether the minimum access length is 64 bits */
218-
u32 min_acc_len;
219-
/**
220-
* @ubwc_swizzle: Whether to enable level 1, 2 & 3 bank swizzling.
221-
*
222-
* UBWC 1.0 always enables all three levels.
223-
* UBWC 2.0 removes level 1 bank swizzling, leaving levels 2 & 3.
224-
* UBWC 4.0 adds the optional ability to disable levels 2 & 3.
225-
*
226-
* This is a bitmask where BIT(0) enables level 1, BIT(1)
227-
* controls level 2, and BIT(2) enables level 3.
228-
*/
229-
u32 ubwc_swizzle;
230-
/**
231-
* @highest_bank_bit: Highest Bank Bit
232-
*
233-
* The Highest Bank Bit value represents the bit of the highest
234-
* DDR bank. This should ideally use DRAM type detection.
235-
*/
236-
u32 highest_bank_bit;
237-
u32 amsbc;
238-
/**
239-
* @macrotile_mode: Macrotile Mode
240-
*
241-
* Whether to use 4-channel macrotiling mode or the newer
242-
* 8-channel macrotiling mode introduced in UBWC 3.1. 0 is
243-
* 4-channel and 1 is 8-channel.
244-
*/
245-
u32 macrotile_mode;
246-
} ubwc_config;
247-
const struct qcom_ubwc_cfg_data *common_ubwc_cfg;
209+
/*
210+
* The migration to the central UBWC config db is still in flight - keep
211+
* a copy containing some local fixups until that's done.
212+
*/
213+
const struct qcom_ubwc_cfg_data *ubwc_config;
214+
struct qcom_ubwc_cfg_data _ubwc_config;
248215

249216
/*
250217
* Register offsets are different between some GPUs.

0 commit comments

Comments
 (0)