From nobody Thu Sep 11 00:04:13 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BC592C3257; Thu, 26 Jun 2025 09:03:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750928627; cv=none; b=pv5+DJfB1NnXTjEtRT66CeBTq31yauQAT5waQcTOCYyftPbgUefWXrLn+xNAfNaPpFH+k33aZExXTicASeTU5rx9Qg64Mwx5JI3mkI3Gt2mbhTpQ/upoqYise58KAbo+2gz1lIOGLEW8qdGO2LuHjkcYFSbX7ETU/A5Dn973src= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750928627; c=relaxed/simple; bh=TmIM0p72O2FZNkhlwbmPcq/u359hmkpIqewYPntpNE4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=b1mT7R2jX44UOF4lGhbPeXxR2nu7Z5UmLfSngyU4Ic0Z8AibXv13aF1CUwL4/wAQoQne5N2+moQot4qZ7wQazddnfng3jUgXDpEXLqMMyveQkvZK2nu1zc5ssc98ph9pVOmb/2bi67BM2S2WZNrl5GnszkLu5i3C1oFzFHBWq+E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UApeCTI8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UApeCTI8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1870C4CEEB; Thu, 26 Jun 2025 09:03:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750928627; bh=TmIM0p72O2FZNkhlwbmPcq/u359hmkpIqewYPntpNE4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UApeCTI8woGSmfFb0lfQ7WjlGpqEGM4OuGKIFujN73TaJ51hoS6TXvdrm8n31uoG7 08Tqhy+4wToS6X9sjQeTwa+VttKhHtBdyxhmmLNCDm5CGQHDjB7KtmMYaeolG+HBHd sbCRHPjOwjDkJWFXdV/G9OPnVF7nYjn3uizMiyimgrmvRf6DnxJht9J5+1ScKgeIuq 5JBaH8sHiQftdkVQ+4WC+OncmC/RgGxmlQ/viDTM8w8nRY7L+HZk7Judv/RVavDy8o gNuYhGxGwl404F/dmOnPQwlcRvVuWIuBB8wz/l03HBB8deLLSd5RFZ9qID80XyIKPE ML0nyEcvwoD/g== From: Konrad Dybcio Date: Thu, 26 Jun 2025 11:02:41 +0200 Subject: [PATCH v6 14/14] drm/msm/adreno: Switch to the common UBWC config struct Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250626-topic-ubwc_central-v6-14-c94fa9d12040@oss.qualcomm.com> References: <20250626-topic-ubwc_central-v6-0-c94fa9d12040@oss.qualcomm.com> In-Reply-To: <20250626-topic-ubwc_central-v6-0-c94fa9d12040@oss.qualcomm.com> To: Bjorn Andersson , Konrad Dybcio , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , David Airlie , Simona Vetter , Rob Clark , Abhinav Kumar , Jessica Zhang , Rob Clark , Akhil P Oommen Cc: Marijn Suijten , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Konrad Dybcio , Dmitry Baryshkov X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1750928557; l=10610; i=konrad.dybcio@oss.qualcomm.com; s=20230215; h=from:subject:message-id; bh=potIy8Dkkz/1yoAE7J/I600HrUDXJJWdkOC8tivmHWU=; b=hT+lJoC6ig2CsSsaTcCEI6KV7fXMTLr3s4QKW1YcBC/y+z3ypGyOIZruQoZw+Ipct+ELz8Uba XeBvx6L/IWLCNU+yTvpodCAHAs2y13F6j1UTx1asfGKR3Ui1KESw5+a X-Developer-Key: i=konrad.dybcio@oss.qualcomm.com; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= From: Konrad Dybcio 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 Signed-off-by: Konrad Dybcio --- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 20 ++++----- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 76 ++++++++++++++++++-----------= ---- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 6 +-- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 45 +++---------------- 4 files changed, 60 insertions(+), 87 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/ad= reno/a5xx_gpu.c index 60aef079623606bb1ae44ba59ac45e391595b0ba..6a77d130446218e81ea44330eea= 284a4abe98d3a 100644 --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c @@ -835,8 +835,8 @@ static int a5xx_hw_init(struct msm_gpu *gpu) =20 gpu_write(gpu, REG_A5XX_RBBM_AHB_CNTL2, 0x0000003F); =20 - BUG_ON(adreno_gpu->ubwc_config.highest_bank_bit < 13); - hbb =3D adreno_gpu->ubwc_config.highest_bank_bit - 13; + BUG_ON(adreno_gpu->ubwc_config->highest_bank_bit < 13); + hbb =3D adreno_gpu->ubwc_config->highest_bank_bit - 13; =20 gpu_write(gpu, REG_A5XX_TPL1_MODE_CNTL, hbb << 7); gpu_write(gpu, REG_A5XX_RB_MODE_CNTL, hbb << 1); @@ -1756,6 +1756,7 @@ struct msm_gpu *a5xx_gpu_init(struct drm_device *dev) struct msm_drm_private *priv =3D dev->dev_private; struct platform_device *pdev =3D priv->gpu_pdev; struct adreno_platform_config *config =3D pdev->dev.platform_data; + const struct qcom_ubwc_cfg_data *common_cfg; struct a5xx_gpu *a5xx_gpu =3D NULL; struct adreno_gpu *adreno_gpu; struct msm_gpu *gpu; @@ -1792,15 +1793,14 @@ struct msm_gpu *a5xx_gpu_init(struct drm_device *de= v) /* Set up the preemption specific bits and pieces for each ringbuffer */ a5xx_preempt_init(gpu); =20 - /* Set the highest bank bit */ - if (adreno_is_a540(adreno_gpu) || adreno_is_a530(adreno_gpu)) - adreno_gpu->ubwc_config.highest_bank_bit =3D 15; - else - adreno_gpu->ubwc_config.highest_bank_bit =3D 14; + /* Inherit the common config and make some necessary fixups */ + common_cfg =3D qcom_ubwc_config_get_data(); + if (IS_ERR(common_cfg)) + return ERR_CAST(common_cfg); =20 - /* a5xx only supports UBWC 1.0, these are not configurable */ - adreno_gpu->ubwc_config.macrotile_mode =3D 0; - adreno_gpu->ubwc_config.ubwc_swizzle =3D 0x7; + /* Copy the data into the internal struct to drop the const qualifier (te= mporarily) */ + adreno_gpu->_ubwc_config =3D *common_cfg; + adreno_gpu->ubwc_config =3D &adreno_gpu->_ubwc_config; =20 adreno_gpu->uche_trap_base =3D 0x0001ffffffff0000ull; =20 diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/ad= reno/a6xx_gpu.c index 6612030621b1b16c8662d39453b609c9c9ff982f..c618cebc5682fbfb21f328ca575= 6fa0ac34831d9 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -605,64 +605,70 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu) =20 static int a6xx_calc_ubwc_config(struct adreno_gpu *gpu) { - /* Inherit the common config and make some necessary fixups */ - gpu->common_ubwc_cfg =3D qcom_ubwc_config_get_data(); - if (IS_ERR(gpu->common_ubwc_cfg)) - return PTR_ERR(gpu->common_ubwc_cfg); + const struct qcom_ubwc_cfg_data *common_cfg; + struct qcom_ubwc_cfg_data *cfg =3D &gpu->_ubwc_config; =20 - gpu->ubwc_config.ubwc_swizzle =3D 0x6; - gpu->ubwc_config.macrotile_mode =3D 0; - gpu->ubwc_config.highest_bank_bit =3D 15; + /* Inherit the common config and make some necessary fixups */ + common_cfg =3D qcom_ubwc_config_get_data(); + if (IS_ERR(common_cfg)) + return PTR_ERR(common_cfg); + + /* Copy the data into the internal struct to drop the const qualifier (te= mporarily) */ + *cfg =3D *common_cfg; + + cfg->ubwc_swizzle =3D 0x6; + cfg->highest_bank_bit =3D 15; =20 if (adreno_is_a610(gpu)) { - gpu->ubwc_config.highest_bank_bit =3D 13; - gpu->ubwc_config.ubwc_swizzle =3D 0x7; + cfg->highest_bank_bit =3D 13; + cfg->ubwc_swizzle =3D 0x7; } =20 if (adreno_is_a618(gpu)) - gpu->ubwc_config.highest_bank_bit =3D 14; + cfg->highest_bank_bit =3D 14; =20 if (adreno_is_a619(gpu)) /* TODO: Should be 14 but causes corruption at e.g. 1920x1200 on DP */ - gpu->ubwc_config.highest_bank_bit =3D 13; + cfg->highest_bank_bit =3D 13; =20 if (adreno_is_a619_holi(gpu)) - gpu->ubwc_config.highest_bank_bit =3D 13; + cfg->highest_bank_bit =3D 13; =20 if (adreno_is_a621(gpu)) - gpu->ubwc_config.highest_bank_bit =3D 13; + cfg->highest_bank_bit =3D 13; =20 - if (adreno_is_a623(gpu)) { - gpu->ubwc_config.highest_bank_bit =3D 16; - gpu->ubwc_config.macrotile_mode =3D 1; - } - - if (adreno_is_a680(gpu)) - gpu->ubwc_config.macrotile_mode =3D 1; + if (adreno_is_a623(gpu)) + cfg->highest_bank_bit =3D 16; =20 if (adreno_is_a650(gpu) || adreno_is_a660(gpu) || adreno_is_a690(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 =3D 16; - gpu->ubwc_config.macrotile_mode =3D 1; + /* TODO: get ddr type from bootloader and use 15 for LPDDR4 */ + cfg->highest_bank_bit =3D 16; } =20 if (adreno_is_a663(gpu)) { - gpu->ubwc_config.highest_bank_bit =3D 13; - gpu->ubwc_config.macrotile_mode =3D 1; - gpu->ubwc_config.ubwc_swizzle =3D 0x4; + cfg->highest_bank_bit =3D 13; + cfg->ubwc_swizzle =3D 0x4; } =20 - if (adreno_is_7c3(gpu)) { - gpu->ubwc_config.highest_bank_bit =3D 14; - gpu->ubwc_config.macrotile_mode =3D 1; - } + if (adreno_is_7c3(gpu)) + cfg->highest_bank_bit =3D 14; =20 if (adreno_is_a702(gpu)) - gpu->ubwc_config.highest_bank_bit =3D 14; + cfg->highest_bank_bit =3D 14; + + if (cfg->highest_bank_bit !=3D common_cfg->highest_bank_bit) + DRM_WARN_ONCE("Inconclusive highest_bank_bit value: %u (GPU) vs %u (UBWC= _CFG)\n", + cfg->highest_bank_bit, common_cfg->highest_bank_bit); + + if (cfg->ubwc_swizzle !=3D common_cfg->ubwc_swizzle) + DRM_WARN_ONCE("Inconclusive ubwc_swizzle value: %u (GPU) vs %u (UBWC_CFG= )\n", + cfg->ubwc_swizzle, common_cfg->ubwc_swizzle); + + gpu->ubwc_config =3D &gpu->_ubwc_config; =20 return 0; } @@ -670,14 +676,14 @@ static int a6xx_calc_ubwc_config(struct adreno_gpu *g= pu) static void a6xx_set_ubwc_config(struct msm_gpu *gpu) { struct adreno_gpu *adreno_gpu =3D to_adreno_gpu(gpu); - const struct qcom_ubwc_cfg_data *cfg =3D adreno_gpu->common_ubwc_cfg; + const struct qcom_ubwc_cfg_data *cfg =3D adreno_gpu->ubwc_config; /* * 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 =3D adreno_gpu->ubwc_config.highest_bank_bit - 13; + BUG_ON(cfg->highest_bank_bit < 13); + u32 hbb =3D cfg->highest_bank_bit - 13; bool rgb565_predicator =3D cfg->ubwc_enc_version >=3D UBWC_4_0; u32 level2_swizzling_dis =3D !(cfg->ubwc_swizzle & UBWC_SWIZZLE_ENABLE_LV= L2); bool ubwc_mode =3D qcom_ubwc_get_ubwc_mode(cfg); @@ -719,7 +725,7 @@ static void a6xx_set_ubwc_config(struct msm_gpu *gpu) min_acc_len_64b << 23 | hbb_lo << 21); =20 gpu_write(gpu, REG_A6XX_RBBM_NC_MODE_CNTL, - adreno_gpu->ubwc_config.macrotile_mode); + cfg->macrotile_mode); } =20 static void a7xx_patch_pwrup_reglist(struct msm_gpu *gpu) diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/= adreno/adreno_gpu.c index 86bff915c3e793583c81a6414ee89c1f59365c58..1251ff1b4895287340c9f3809d4= 6441aded64cfd 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c @@ -420,16 +420,16 @@ int adreno_get_param(struct msm_gpu *gpu, struct msm_= file_private *ctx, *value =3D ctx->aspace->va_size; return 0; case MSM_PARAM_HIGHEST_BANK_BIT: - *value =3D adreno_gpu->ubwc_config.highest_bank_bit; + *value =3D adreno_gpu->ubwc_config->highest_bank_bit; return 0; case MSM_PARAM_RAYTRACING: *value =3D adreno_gpu->has_ray_tracing; return 0; case MSM_PARAM_UBWC_SWIZZLE: - *value =3D adreno_gpu->ubwc_config.ubwc_swizzle; + *value =3D adreno_gpu->ubwc_config->ubwc_swizzle; return 0; case MSM_PARAM_MACROTILE_MODE: - *value =3D adreno_gpu->ubwc_config.macrotile_mode; + *value =3D adreno_gpu->ubwc_config->macrotile_mode; return 0; case MSM_PARAM_UCHE_TRAP_BASE: *value =3D adreno_gpu->uche_trap_base; diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.h b/drivers/gpu/drm/msm/= adreno/adreno_gpu.h index a2a211cac147cb5bc5befdcab07559b778adc2bb..e56a39df815f100caca945576de= 7cb55664980bc 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.h +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h @@ -207,45 +207,12 @@ struct adreno_gpu { /* firmware: */ const struct firmware *fw[ADRENO_FW_MAX]; =20 - struct { - /** - * @rgb565_predicator: Unknown, introduced with A650 family, - * related to UBWC mode/ver 4 - */ - u32 rgb565_predicator; - /** @uavflagprd_inv: Unknown, introduced with A650 family */ - u32 uavflagprd_inv; - /** @min_acc_len: Whether the minimum access length is 64 bits */ - u32 min_acc_len; - /** - * @ubwc_swizzle: Whether to enable level 1, 2 & 3 bank swizzling. - * - * UBWC 1.0 always enables all three levels. - * UBWC 2.0 removes level 1 bank swizzling, leaving levels 2 & 3. - * UBWC 4.0 adds the optional ability to disable levels 2 & 3. - * - * This is a bitmask where BIT(0) enables level 1, BIT(1) - * controls level 2, and BIT(2) enables level 3. - */ - u32 ubwc_swizzle; - /** - * @highest_bank_bit: Highest Bank Bit - * - * The Highest Bank Bit value represents the bit of the highest - * DDR bank. This should ideally use DRAM type detection. - */ - u32 highest_bank_bit; - u32 amsbc; - /** - * @macrotile_mode: Macrotile Mode - * - * Whether to use 4-channel macrotiling mode or the newer - * 8-channel macrotiling mode introduced in UBWC 3.1. 0 is - * 4-channel and 1 is 8-channel. - */ - u32 macrotile_mode; - } ubwc_config; - const struct qcom_ubwc_cfg_data *common_ubwc_cfg; + /* + * The migration to the central UBWC config db is still in flight - keep + * a copy containing some local fixups until that's done. + */ + const struct qcom_ubwc_cfg_data *ubwc_config; + struct qcom_ubwc_cfg_data _ubwc_config; =20 /* * Register offsets are different between some GPUs. --=20 2.50.0