Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Akhil P Oommen <quic_akhilpo@quicinc.com>
To: Connor Abbott <cwabbott0@gmail.com>
Cc: Konrad Dybcio <konradybcio@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Kees Cook <kees@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Rob Clark <robdclark@gmail.com>, Sean Paul <sean@poorly.run>,
	Abhinav Kumar <quic_abhinavk@quicinc.com>,
	"Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Dmitry Baryshkov <lumag@kernel.org>,
	Marijn Suijten <marijn.suijten@somainline.org>,
	<linux-kernel@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>,
	<linux-hardening@vger.kernel.org>,
	<dri-devel@lists.freedesktop.org>,
	<freedreno@lists.freedesktop.org>,
	Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Subject: Re: [PATCH v2 3/4] drm/msm/a6xx: Get HBB dynamically, if available
Date: Thu, 17 Apr 2025 23:20:25 +0530	[thread overview]
Message-ID: <1282bf58-e431-4a07-97e5-628437e7ce5f@quicinc.com> (raw)
In-Reply-To: <CACu1E7HDmQXDNtEQCXpHXsOKPCOgrWgo+_kcgizo9Mp1ntjDbA@mail.gmail.com>

On 4/17/2025 9:02 PM, Connor Abbott wrote:
> On Thu, Apr 17, 2025 at 3:45 AM Akhil P Oommen <quic_akhilpo@quicinc.com> wrote:
>>
>> On 4/10/2025 11:13 PM, Konrad Dybcio wrote:
>>> From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
>>>
>>> The Highest Bank address Bit value can change based on memory type used.
>>>
>>> Attempt to retrieve it dynamically, and fall back to a reasonable
>>> default (the one used prior to this change) on error.
>>>
>>> Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
>>> ---
>>>  drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 15 ++++++++++++++-
>>>  1 file changed, 14 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>> index 06465bc2d0b4b128cddfcfcaf1fe4252632b6777..a6232b382bd16319f20ae5f8f5e57f38ecc62d9f 100644
>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>> @@ -13,6 +13,7 @@
>>>  #include <linux/firmware/qcom/qcom_scm.h>
>>>  #include <linux/pm_domain.h>
>>>  #include <linux/soc/qcom/llcc-qcom.h>
>>> +#include <linux/soc/qcom/smem.h>
>>>
>>>  #define GPU_PAS_ID 13
>>>
>>> @@ -587,6 +588,8 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu)
>>>
>>>  static void a6xx_calc_ubwc_config(struct adreno_gpu *gpu)
>>>  {
>>> +     int hbb;
>>> +
>>>       gpu->ubwc_config.rgb565_predicator = 0;
>>>       gpu->ubwc_config.uavflagprd_inv = 0;
>>>       gpu->ubwc_config.min_acc_len = 0;
>>> @@ -635,7 +638,6 @@ static void a6xx_calc_ubwc_config(struct adreno_gpu *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 = 16;
>>>               gpu->ubwc_config.amsbc = 1;
>>>               gpu->ubwc_config.rgb565_predicator = 1;
>>> @@ -664,6 +666,13 @@ static void a6xx_calc_ubwc_config(struct adreno_gpu *gpu)
>>>               gpu->ubwc_config.highest_bank_bit = 14;
>>>               gpu->ubwc_config.min_acc_len = 1;
>>>       }
>>> +
>>> +     /* Attempt to retrieve the data from SMEM, keep the above defaults in case of error */
>>> +     hbb = qcom_smem_dram_get_hbb();
>>> +     if (hbb < 0)
>>> +             return;
>>> +
>>> +     gpu->ubwc_config.highest_bank_bit = hbb;
>>
>> I am worried about blindly relying on SMEM data directly for HBB for
>> legacy chipsets. There is no guarantee it is accurate on every chipset
>> and every version of firmware. Also, until recently, this value was
>> hardcoded in Mesa which matched the value in KMD.
> 
> To be clear about this, from the moment we introduced host image
> copies in Mesa we added support for querying the HBB from the kernel,
> explicitly so that we could do what this series does without Mesa ever
> breaking. Mesa will never assume the HBB unless the kernel is too old
> to support querying it. So don't let Mesa be the thing that stops us
> here.

Thanks for clarifying about Mesa. I still don't trust a data source that
is unused in production.

I have a related question about HBB. Blob driver doesn't support
host_image_copy, but it still use HBB configuration. I was under the
impression this was required for UMD for compression related
configurations. Is that not true for turnip/freedreno?

-Akhil.

> 
> Connor
> 
>> So it is better to
>> make this opt in, for newer chipsets or those which somebody can verify.
>> We can invert this logic to something like this:
>>
>> if (!gpu->ubwc_config.highest_bank_bit)
>>     gpu->ubwc_config.highest_bank_bit = qcom_smem_dram_get_hbb();
>>
>>>  }
>>>
>>>  static void a6xx_set_ubwc_config(struct msm_gpu *gpu)
>>> @@ -2467,6 +2476,10 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev)
>>>       bool is_a7xx;
>>>       int ret;
>>>
>>> +     /* We need data from SMEM to retrieve HBB in calc_ubwc_config() */
>>> +     if (!qcom_smem_is_available())
>>> +             return ERR_PTR(-EPROBE_DEFER);
>>> +
>>
>> We should add "depends on QCOM_SMEM" to Kconfig. Is SMEM device present
>> in all Qcom SoC devicetrees? I wonder if there is a scenario where there
>> might be an infinite EPROBE_DEFER here.
>>
>> -Akhil.
>>
>>>       a6xx_gpu = kzalloc(sizeof(*a6xx_gpu), GFP_KERNEL);
>>>       if (!a6xx_gpu)
>>>               return ERR_PTR(-ENOMEM);
>>>
>>


  reply	other threads:[~2025-04-17 17:50 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-10 17:43 [PATCH v2 0/4] Retrieve information about DDR from SMEM Konrad Dybcio
2025-04-10 17:43 ` [PATCH v2 1/4] soc: qcom: Expose DDR data " Konrad Dybcio
2025-04-10 17:43 ` [PATCH v2 2/4] drm/msm/a5xx: Get HBB dynamically, if available Konrad Dybcio
2025-04-10 17:43 ` [PATCH v2 3/4] drm/msm/a6xx: " Konrad Dybcio
2025-04-17  7:45   ` Akhil P Oommen
2025-04-17 15:32     ` Connor Abbott
2025-04-17 17:50       ` Akhil P Oommen [this message]
2025-04-18  1:10         ` Connor Abbott
2025-04-18 16:00           ` Akhil P Oommen
2025-04-21 20:13             ` Rob Clark
2025-04-22 23:57               ` Konrad Dybcio
2025-04-23  6:55                 ` Akhil P Oommen
2025-04-23 13:21                   ` Dmitry Baryshkov
2025-04-23 14:56                   ` Rob Clark
2025-04-23 15:07                     ` Konrad Dybcio
2025-04-23 14:55                 ` Rob Clark
2025-04-23 14:57                   ` Konrad Dybcio
2025-04-23 15:23                   ` Dmitry Baryshkov
2025-04-24 20:28                     ` Konrad Dybcio
2025-04-25 19:16                       ` Dmitry Baryshkov
2025-04-10 17:43 ` [PATCH v2 4/4] drm/msm/mdss: " Konrad Dybcio
2025-04-10 19:49 ` [PATCH v2 0/4] Retrieve information about DDR from SMEM Dmitry Baryshkov

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=1282bf58-e431-4a07-97e5-628437e7ce5f@quicinc.com \
    --to=quic_akhilpo@quicinc.com \
    --cc=airlied@gmail.com \
    --cc=andersson@kernel.org \
    --cc=cwabbott0@gmail.com \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=gustavoars@kernel.org \
    --cc=kees@kernel.org \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=konradybcio@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lumag@kernel.org \
    --cc=marijn.suijten@somainline.org \
    --cc=quic_abhinavk@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