@@ -606,79 +606,85 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu)
606606
607607static 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
671677static 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
726732static void a7xx_patch_pwrup_reglist (struct msm_gpu * gpu )
0 commit comments