mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konrad Dybcio <konradybcio@kernel.org>
To: Bjorn Andersson <andersson@kernel.org>,
	 Konrad Dybcio <konradybcio@kernel.org>,
	Rob Clark <robdclark@gmail.com>,
	 Abhinav Kumar <quic_abhinavk@quicinc.com>,
	 Dmitry Baryshkov <lumag@kernel.org>,
	 Akhil P Oommen <quic_akhilpo@quicinc.com>,
	Sean Paul <sean@poorly.run>,  David Airlie <airlied@gmail.com>,
	Simona Vetter <simona@ffwll.ch>
Cc: Marijn Suijten <marijn.suijten@somainline.org>,
	 linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	 dri-devel@lists.freedesktop.org,
	freedreno@lists.freedesktop.org,
	 Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Subject: [PATCH RFT 03/14] drm/msm/adreno: Offset the HBB value by 13
Date: Thu, 08 May 2025 20:12:35 +0200	[thread overview]
Message-ID: <20250508-topic-ubwc_central-v1-3-035c4c5cbe50@oss.qualcomm.com> (raw)
In-Reply-To: <20250508-topic-ubwc_central-v1-0-035c4c5cbe50@oss.qualcomm.com>

From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

The value the UBWC hardware expects is 13 less than the actual value.
To make it easier to migrate to a common UBWC configuration table,
defer that logic to the data source (which is currently a number of
if-else statements with assignments in case of this driver).

Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
---
 drivers/gpu/drm/msm/adreno/a5xx_gpu.c |  7 +++----
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 30 ++++++++++++------------------
 2 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
index 650e5bac225f372e819130b891f1d020b464f17f..67331a7ee750c0d9eeeead9440e5d08b1a09c878 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
@@ -833,8 +833,7 @@ static int a5xx_hw_init(struct msm_gpu *gpu)
 
 	gpu_write(gpu, REG_A5XX_RBBM_AHB_CNTL2, 0x0000003F);
 
-	BUG_ON(adreno_gpu->ubwc_config.highest_bank_bit < 13);
-	hbb = adreno_gpu->ubwc_config.highest_bank_bit - 13;
+	hbb = adreno_gpu->ubwc_config.highest_bank_bit;
 
 	gpu_write(gpu, REG_A5XX_TPL1_MODE_CNTL, hbb << 7);
 	gpu_write(gpu, REG_A5XX_RB_MODE_CNTL, hbb << 1);
@@ -1792,9 +1791,9 @@ struct msm_gpu *a5xx_gpu_init(struct drm_device *dev)
 
 	/* Set the highest bank bit */
 	if (adreno_is_a540(adreno_gpu) || adreno_is_a530(adreno_gpu))
-		adreno_gpu->ubwc_config.highest_bank_bit = 15;
+		adreno_gpu->ubwc_config.highest_bank_bit = 2;
 	else
-		adreno_gpu->ubwc_config.highest_bank_bit = 14;
+		adreno_gpu->ubwc_config.highest_bank_bit = 1;
 
 	/* a5xx only supports UBWC 1.0, these are not configurable */
 	adreno_gpu->ubwc_config.macrotile_mode = 0;
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index bf3758f010f4079aa86f9c658b52a70acf10b488..b161b5cd991fc645dfcd69754b82be9691775ffe 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -592,32 +592,32 @@ static void a6xx_calc_ubwc_config(struct adreno_gpu *gpu)
 	gpu->ubwc_config.min_acc_len = 0;
 	gpu->ubwc_config.ubwc_swizzle = 0x6;
 	gpu->ubwc_config.macrotile_mode = 0;
-	gpu->ubwc_config.highest_bank_bit = 15;
+	gpu->ubwc_config.highest_bank_bit = 2;
 
 	if (adreno_is_a610(gpu)) {
-		gpu->ubwc_config.highest_bank_bit = 13;
+		gpu->ubwc_config.highest_bank_bit = 0;
 		gpu->ubwc_config.min_acc_len = 1;
 		gpu->ubwc_config.ubwc_swizzle = 0x7;
 	}
 
 	if (adreno_is_a618(gpu))
-		gpu->ubwc_config.highest_bank_bit = 14;
+		gpu->ubwc_config.highest_bank_bit = 1;
 
 	if (adreno_is_a619(gpu))
 		/* TODO: Should be 14 but causes corruption at e.g. 1920x1200 on DP */
-		gpu->ubwc_config.highest_bank_bit = 13;
+		gpu->ubwc_config.highest_bank_bit = 0;
 
 	if (adreno_is_a619_holi(gpu))
-		gpu->ubwc_config.highest_bank_bit = 13;
+		gpu->ubwc_config.highest_bank_bit = 0;
 
 	if (adreno_is_a621(gpu)) {
-		gpu->ubwc_config.highest_bank_bit = 13;
+		gpu->ubwc_config.highest_bank_bit = 0;
 		gpu->ubwc_config.amsbc = 1;
 		gpu->ubwc_config.uavflagprd_inv = 2;
 	}
 
 	if (adreno_is_a623(gpu)) {
-		gpu->ubwc_config.highest_bank_bit = 16;
+		gpu->ubwc_config.highest_bank_bit = 3;
 		gpu->ubwc_config.amsbc = 1;
 		gpu->ubwc_config.rgb565_predicator = 1;
 		gpu->ubwc_config.uavflagprd_inv = 2;
@@ -636,7 +636,7 @@ static void a6xx_calc_ubwc_config(struct adreno_gpu *gpu)
 	    adreno_is_a730(gpu) ||
 	    adreno_is_a740_family(gpu)) {
 		/* TODO: get ddr type from bootloader and use 2 for LPDDR4 */
-		gpu->ubwc_config.highest_bank_bit = 16;
+		gpu->ubwc_config.highest_bank_bit = 3;
 		gpu->ubwc_config.amsbc = 1;
 		gpu->ubwc_config.rgb565_predicator = 1;
 		gpu->ubwc_config.uavflagprd_inv = 2;
@@ -644,7 +644,7 @@ static void a6xx_calc_ubwc_config(struct adreno_gpu *gpu)
 	}
 
 	if (adreno_is_a663(gpu)) {
-		gpu->ubwc_config.highest_bank_bit = 13;
+		gpu->ubwc_config.highest_bank_bit = 0;
 		gpu->ubwc_config.amsbc = 1;
 		gpu->ubwc_config.rgb565_predicator = 1;
 		gpu->ubwc_config.uavflagprd_inv = 2;
@@ -653,14 +653,14 @@ static void a6xx_calc_ubwc_config(struct adreno_gpu *gpu)
 	}
 
 	if (adreno_is_7c3(gpu)) {
-		gpu->ubwc_config.highest_bank_bit = 14;
+		gpu->ubwc_config.highest_bank_bit = 1;
 		gpu->ubwc_config.amsbc = 1;
 		gpu->ubwc_config.uavflagprd_inv = 2;
 		gpu->ubwc_config.macrotile_mode = 1;
 	}
 
 	if (adreno_is_a702(gpu)) {
-		gpu->ubwc_config.highest_bank_bit = 14;
+		gpu->ubwc_config.highest_bank_bit = 1;
 		gpu->ubwc_config.min_acc_len = 1;
 	}
 }
@@ -668,13 +668,7 @@ static void a6xx_calc_ubwc_config(struct adreno_gpu *gpu)
 static void a6xx_set_ubwc_config(struct msm_gpu *gpu)
 {
 	struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
-	/*
-	 * We subtract 13 from the highest bank bit (13 is the minimum value
-	 * allowed by hw) and write the lowest two bits of the remaining value
-	 * as hbb_lo and the one above it as hbb_hi to the hardware.
-	 */
-	BUG_ON(adreno_gpu->ubwc_config.highest_bank_bit < 13);
-	u32 hbb = adreno_gpu->ubwc_config.highest_bank_bit - 13;
+	u32 hbb = adreno_gpu->ubwc_config.highest_bank_bit;
 	u32 hbb_hi = hbb >> 2;
 	u32 hbb_lo = hbb & 3;
 	u32 ubwc_mode = adreno_gpu->ubwc_config.ubwc_swizzle & 1;

-- 
2.49.0


  parent reply	other threads:[~2025-05-08 18:13 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-08 18:12 [RFT PATCH 00/14] Add a single source of truth for UBWC configuration data Konrad Dybcio
2025-05-08 18:12 ` [PATCH RFT 01/14] soc: qcom: Add UBWC config provider Konrad Dybcio
2025-05-08 20:12   ` Connor Abbott
2025-05-09 12:28     ` Konrad Dybcio
2025-05-11 21:13       ` Dmitry Baryshkov
2025-05-12  8:57         ` Dmitry Baryshkov
2025-05-11 22:21   ` Bjorn Andersson
2025-05-08 18:12 ` [PATCH RFT 02/14] drm/msm: Use the central UBWC config database Konrad Dybcio
2025-05-08 18:12 ` Konrad Dybcio [this message]
2025-05-08 19:03   ` [PATCH RFT 03/14] drm/msm/adreno: Offset the HBB value by 13 Connor Abbott
2025-05-09 12:30     ` Konrad Dybcio
2025-05-08 18:12 ` [PATCH RFT 04/14] drm/msm/a6xx: Get a handle to the common UBWC config Konrad Dybcio
2025-05-08 18:41   ` Rob Clark
2025-05-09 12:31     ` Konrad Dybcio
2025-05-09 13:52       ` Rob Clark
2025-05-09 17:00         ` Konrad Dybcio
2025-05-13 22:06           ` Rob Clark
2025-05-13 22:11             ` Konrad Dybcio
2025-05-08 18:12 ` [PATCH RFT 05/14] drm/msm/a6xx: Resolve the meaning of AMSBC Konrad Dybcio
2025-05-08 19:16   ` Connor Abbott
2025-05-09 12:31     ` Konrad Dybcio
2025-05-08 18:12 ` [PATCH RFT 06/14] drm/msm/a6xx: Simplify uavflagprd_inv detection Konrad Dybcio
2025-05-08 19:05   ` Connor Abbott
2025-05-09 12:36     ` Konrad Dybcio
2025-05-08 18:12 ` [PATCH RFT 07/14] drm/msm/a6xx: Resolve the meaning of UBWC_MODE Konrad Dybcio
2025-05-08 18:25   ` Connor Abbott
2025-05-09 12:37     ` Konrad Dybcio
2025-05-09 12:39       ` Konrad Dybcio
2025-05-08 18:12 ` [PATCH RFT 08/14] drm/msm/a6xx: Replace '2' with BIT(1) in level2_swizzling_dis calc Konrad Dybcio
2025-05-08 18:12 ` [PATCH RFT 09/14] drm/msm/a6xx: Resolve the meaning of rgb565_predicator Konrad Dybcio
2025-05-08 18:12 ` [PATCH RFT 10/14] drm/msm/a6xx: Stop tracking macrotile_mode (again) Konrad Dybcio
2025-05-08 18:33   ` Connor Abbott
2025-05-09 12:45     ` Konrad Dybcio
2025-05-09 14:52       ` Connor Abbott
2025-05-08 18:12 ` [PATCH RFT 11/14] drm/msm/a6xx: Simplify min_acc_len calculation Konrad Dybcio
2025-05-08 18:12 ` [PATCH RFT 12/14] drm/msm/adreno: Switch to the common UBWC config struct Konrad Dybcio
2025-05-08 18:12 ` [PATCH RFT 13/14] drm/msm/a6xx: Drop cfg->ubwc_swizzle override Konrad Dybcio
2025-05-08 19:26   ` Connor Abbott
2025-05-09 13:17     ` Konrad Dybcio
2025-05-09 13:37       ` Konrad Dybcio
2025-05-09 14:48         ` Connor Abbott
2025-05-09 15:52           ` Konrad Dybcio
2025-05-08 18:12 ` [PATCH RFT 14/14] drm/msm/a5xx: Use UBWC data from the common UBWC config struct Konrad Dybcio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250508-topic-ubwc_central-v1-3-035c4c5cbe50@oss.qualcomm.com \
    --to=konradybcio@kernel.org \
    --cc=airlied@gmail.com \
    --cc=andersson@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lumag@kernel.org \
    --cc=marijn.suijten@somainline.org \
    --cc=quic_abhinavk@quicinc.com \
    --cc=quic_akhilpo@quicinc.com \
    --cc=robdclark@gmail.com \
    --cc=sean@poorly.run \
    --cc=simona@ffwll.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®