Message ID | 20230223-topic-gmuwrapper-v3-4-5be55a336819@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp275251wrd; Thu, 23 Feb 2023 04:07:48 -0800 (PST) X-Google-Smtp-Source: AK7set9vBHfZfW5EtFvdVmRLByJnIoHzYeYzEwEoDt6cs+6e9geR5oeSeVp7MUI2gY7RmTZXlxl1 X-Received: by 2002:a05:6a20:8f09:b0:c7:6088:9bc7 with SMTP id b9-20020a056a208f0900b000c760889bc7mr15662498pzk.2.1677154068464; Thu, 23 Feb 2023 04:07:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677154068; cv=none; d=google.com; s=arc-20160816; b=S8fhHwUJLeYmptRQQJ7ilD0OOYJzqD/I2LFCxb3TCGOUlHCTh3ldKvYYiVzTJoikmK 6xN+a7d/KT2kJhof78ZPGbjT+FhzmSJQ88w02WVjZ8AqrM3T1MXFVh21u277jxpR4eYc aDx1DtwWgKAGvKqdvpDJac8kEYFnJ+zlY/9w7DjkReaYkrY0ZlfJcA2wfbqNo3mMOCTo +jWblhRoCAK3Pg/pOusP9XnHpHn12N9HFd3Ony5/UZAWadEjSpXq7Bd5hdsCfQHLbeLm bqvcA3xmKg6z8xwh7gWal1Kg/nYBdR/Dsljh6/RbVob23/YCL5shyoegm5vR4+Jf2Rk3 QlFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=yok0nZYCkQzxSnQH2ARjVTx35nRR0F5PEOqTZ3qXsIg=; b=HeIYoJy6ssqKW7tzucRRGwUSSygtTwmffZsk1xSrjidNWbjE0A097qDo0178SIScMu 79lsGhXhsdvlNKlg4e6BR1KKy3z/n6U1VetMeUd2887zQZ0muAu5oKBxK3qx3bfTxsbs BTdQ+LzWD5y+KTxLedfNqt+JcW4G08S5ImVcbwtOrykrlbMICGup+eIvdXxC0hkBIQU/ JkH7vuQWj65rqEyhWOsJU6vQE4I2x8Estq3wD8ysZq1H1sBze0jNnNQrgntHPdUCw3Jv 6iRA8zE4bwGXk6Wb6PLDCmHn58iUIrYbe5Yd90efTsTKS6jtGiVJDOHyV+JFfK2Y80FC Sk6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fjK9mQMH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z12-20020a170903018c00b0019950f1e1f3si14574334plg.462.2023.02.23.04.07.35; Thu, 23 Feb 2023 04:07:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fjK9mQMH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234074AbjBWMHG (ORCPT <rfc822;cambridge8321@gmail.com> + 99 others); Thu, 23 Feb 2023 07:07:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233708AbjBWMGz (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 23 Feb 2023 07:06:55 -0500 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E24A54A3D for <linux-kernel@vger.kernel.org>; Thu, 23 Feb 2023 04:06:52 -0800 (PST) Received: by mail-lj1-x233.google.com with SMTP id e9so10563563ljn.9 for <linux-kernel@vger.kernel.org>; Thu, 23 Feb 2023 04:06:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=yok0nZYCkQzxSnQH2ARjVTx35nRR0F5PEOqTZ3qXsIg=; b=fjK9mQMHjiJBcH8lJSmhfwJ1guQBiffFrAHUEesmbGMfPi/qxDnZpY3mWklZQR2i5E 9ZmXJQTOXcr7O0tCcKP+Erhi3ddwYBq213n6EZGB9LST6IfqqthXYvFXKB9iyrBGpc3w RTZJX8bVzX7Og3UDQme1cZPCp7Gg2KEKLewRMAu2I63yiU0zycPPZEkXo6NpB0UApNDr SojQ830IEskj/eMyJ3+3uYh6Apx97KNjqpHUp9YZx33s8MUEoArR7hOh+yb2q3nvHQIS IRo7XbwDrgSIVRLBrH91OEJm3E/WeMws0yKA0yXdjwOAKj6X4qwtiOalRU3SymRuNIzb OOMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yok0nZYCkQzxSnQH2ARjVTx35nRR0F5PEOqTZ3qXsIg=; b=Mcviha3HijV1BrJ4hnqD6bHq6DX9Yi53/JQrRjstSvbh5zHE29oTh4v8mzV2rffI/G /ZgSV98/3juw1mAnv3iU0iL0gcKBDH5YTB+Mki5rSqk6gdKFn4+KxwclEwykyXw/HFrY 6l/uMbASi/3g6Q4uXBUYsXAK6jMZQFYf8JEa8uU6oubHAOzPs8Drz0zxxiWGSmXifNnj yxYqkRJNOhPju3s+CpO+8zgtsUNcn32DHxY71qd/XW9l2wR5kOyR8HEmaMWuc4Hmc2Lx r074DP5aMUlVstSkTlRyhUxZm3BZzDevSsyo2N+HihEXsVw1Sqqy1saBedO+LN7utNVQ taKQ== X-Gm-Message-State: AO0yUKXqf+ZGoESCWtXV+yMO/UamBQ23zs36gPI+swGeqC8G3lqaSXkX KrJ4Y4ZYW52WmElNOjig7EJkfQ== X-Received: by 2002:a2e:9c83:0:b0:294:6b6b:a107 with SMTP id x3-20020a2e9c83000000b002946b6ba107mr4037985lji.11.1677154010724; Thu, 23 Feb 2023 04:06:50 -0800 (PST) Received: from [192.168.1.101] (abxi151.neoplus.adsl.tpnet.pl. [83.9.2.151]) by smtp.gmail.com with ESMTPSA id h23-20020a2ea497000000b0029599744c02sm414838lji.75.2023.02.23.04.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 04:06:50 -0800 (PST) From: Konrad Dybcio <konrad.dybcio@linaro.org> Date: Thu, 23 Feb 2023 13:06:38 +0100 Subject: [PATCH v3 04/15] drm/msm/a6xx: Extend and explain UBWC config MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230223-topic-gmuwrapper-v3-4-5be55a336819@linaro.org> References: <20230223-topic-gmuwrapper-v3-0-5be55a336819@linaro.org> In-Reply-To: <20230223-topic-gmuwrapper-v3-0-5be55a336819@linaro.org> To: Rob Clark <robdclark@gmail.com>, Abhinav Kumar <quic_abhinavk@quicinc.com>, Dmitry Baryshkov <dmitry.baryshkov@linaro.org>, Sean Paul <sean@poorly.run>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Bjorn Andersson <andersson@kernel.org>, Konrad Dybcio <konrad.dybcio@somainline.org>, Akhil P Oommen <quic_akhilpo@quicinc.com> Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Clark <robdclark@chromium.org>, Konrad Dybcio <konrad.dybcio@linaro.org> X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1677154003; l=3668; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=ZV6EzEXHb+xbzACmaZ/VhfWA/cvjDBSL9a0mYvB+qs0=; b=U8fHI/+kFCvPN7Wm7L36lKFckvIw+eIRkpTnbaEaoxftwLkSrzu/4cRmFI28a+6RxntgwF57AOFJ 1wiSJ9CMC3+J6psEFNrwSJbYv2TK08N8snTCel/+DC1oT+KlmbL+ X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758623504093760897?= X-GMAIL-MSGID: =?utf-8?q?1758623504093760897?= |
Series |
GMU-less A6xx support (A610, A619_holi)
|
|
Commit Message
Konrad Dybcio
Feb. 23, 2023, 12:06 p.m. UTC
Rename lower_bit to hbb_lo and explain what it signifies.
Add explanations (wherever possible to other tunables).
Sort the variable definition and assignment alphabetically.
Port setting min_access_length, ubwc_mode and hbb_hi from downstream.
Set default values for all of the tunables to zero, as they should be.
Values were validated against downstream and will be fixed up in
separate commits so as not to make this one even more messy.
A618 remains untouched (left at hw defaults) in this patch.
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 55 ++++++++++++++++++++++++++++-------
1 file changed, 45 insertions(+), 10 deletions(-)
Comments
On 2/23/2023 5:36 PM, Konrad Dybcio wrote: > Rename lower_bit to hbb_lo and explain what it signifies. > Add explanations (wherever possible to other tunables). > > Sort the variable definition and assignment alphabetically. Sorting based on decreasing order of line length is more readable, isn't it? > > Port setting min_access_length, ubwc_mode and hbb_hi from downstream. > Set default values for all of the tunables to zero, as they should be. > > Values were validated against downstream and will be fixed up in > separate commits so as not to make this one even more messy. > > A618 remains untouched (left at hw defaults) in this patch. > > Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> > --- > drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 55 ++++++++++++++++++++++++++++------- > 1 file changed, 45 insertions(+), 10 deletions(-) > > diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > index c5f5d0bb3fdc..bdae341e0a7c 100644 > --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > @@ -786,39 +786,74 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu) > static void a6xx_set_ubwc_config(struct msm_gpu *gpu) > { > struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); > - u32 lower_bit = 2; > + /* Unknown, introduced with A640/680 */ > u32 amsbc = 0; > + /* > + * The Highest Bank Bit value represents the bit of the highest DDR bank. > + * We then subtract 13 from it (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. The default values (when HBB is > + * not specified) are 0, 0. > + */ > + u32 hbb_hi = 0; > + u32 hbb_lo = 0; > + /* Whether the minimum access length is 64 bits */ > + u32 min_acc_len = 0; > + /* Unknown, introduced with A650 family, related to UBWC mode/ver 4 */ > u32 rgb565_predicator = 0; > + /* Unknown, introduced with A650 family */ > u32 uavflagprd_inv = 0; > + /* Entirely magic, per-GPU-gen value */ > + u32 ubwc_mode = 0; > > /* a618 is using the hw default values */ > if (adreno_is_a618(adreno_gpu)) > return; > > - if (adreno_is_a640_family(adreno_gpu)) > + if (adreno_is_a619(adreno_gpu)) { > + /* HBB = 14 */ > + hbb_lo = 1; > + } > + > + if (adreno_is_a630(adreno_gpu)) { > + /* HBB = 15 */ > + hbb_lo = 2; > + } > + > + if (adreno_is_a640_family(adreno_gpu)) { > amsbc = 1; > + /* HBB = 15 */ > + hbb_lo = 2; > + } > > if (adreno_is_a650(adreno_gpu) || adreno_is_a660(adreno_gpu)) { > - /* TODO: get ddr type from bootloader and use 2 for LPDDR4 */ > - lower_bit = 3; > amsbc = 1; > + /* TODO: get ddr type from bootloader and use 2 for LPDDR4 */ > + /* HBB = 16 */ > + hbb_lo = 3; > rgb565_predicator = 1; > uavflagprd_inv = 2; > } > > if (adreno_is_7c3(adreno_gpu)) { > - lower_bit = 1; > amsbc = 1; > + /* HBB is unset in downstream DTS, defaulting to 0 */ This is incorrect. For 7c3 hbb value is 14. So hbb_lo should be 1. FYI, hbb configurations were moved to the driver from DT in recent downstream kernels. -Akhil. > rgb565_predicator = 1; > uavflagprd_inv = 2; > } > > gpu_write(gpu, REG_A6XX_RB_NC_MODE_CNTL, > - rgb565_predicator << 11 | amsbc << 4 | lower_bit << 1); > - gpu_write(gpu, REG_A6XX_TPL1_NC_MODE_CNTL, lower_bit << 1); > - gpu_write(gpu, REG_A6XX_SP_NC_MODE_CNTL, > - uavflagprd_inv << 4 | lower_bit << 1); > - gpu_write(gpu, REG_A6XX_UCHE_MODE_CNTL, lower_bit << 21); > + rgb565_predicator << 11 | hbb_hi << 10 | amsbc << 4 | > + min_acc_len << 3 | hbb_lo << 1 | ubwc_mode); > + > + gpu_write(gpu, REG_A6XX_TPL1_NC_MODE_CNTL, hbb_hi << 4 | > + min_acc_len << 3 | hbb_lo << 1 | ubwc_mode); > + > + gpu_write(gpu, REG_A6XX_SP_NC_MODE_CNTL, hbb_hi << 10 | > + uavflagprd_inv << 4 | min_acc_len << 3 | > + hbb_lo << 1 | ubwc_mode); > + > + gpu_write(gpu, REG_A6XX_UCHE_MODE_CNTL, min_acc_len << 23 | hbb_lo << 21); > } > > static int a6xx_cp_init(struct msm_gpu *gpu) >
On 28.02.2023 21:23, Akhil P Oommen wrote: > On 2/23/2023 5:36 PM, Konrad Dybcio wrote: >> Rename lower_bit to hbb_lo and explain what it signifies. >> Add explanations (wherever possible to other tunables). >> >> Sort the variable definition and assignment alphabetically. > Sorting based on decreasing order of line length is more readable, isn't it? I can do that. >> >> Port setting min_access_length, ubwc_mode and hbb_hi from downstream. >> Set default values for all of the tunables to zero, as they should be. >> >> Values were validated against downstream and will be fixed up in >> separate commits so as not to make this one even more messy. >> >> A618 remains untouched (left at hw defaults) in this patch. >> >> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> >> --- >> drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 55 ++++++++++++++++++++++++++++------- >> 1 file changed, 45 insertions(+), 10 deletions(-) >> >> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >> index c5f5d0bb3fdc..bdae341e0a7c 100644 >> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >> @@ -786,39 +786,74 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu) >> static void a6xx_set_ubwc_config(struct msm_gpu *gpu) >> { >> struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); >> - u32 lower_bit = 2; >> + /* Unknown, introduced with A640/680 */ >> u32 amsbc = 0; >> + /* >> + * The Highest Bank Bit value represents the bit of the highest DDR bank. >> + * We then subtract 13 from it (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. The default values (when HBB is >> + * not specified) are 0, 0. >> + */ >> + u32 hbb_hi = 0; >> + u32 hbb_lo = 0; >> + /* Whether the minimum access length is 64 bits */ >> + u32 min_acc_len = 0; >> + /* Unknown, introduced with A650 family, related to UBWC mode/ver 4 */ >> u32 rgb565_predicator = 0; >> + /* Unknown, introduced with A650 family */ >> u32 uavflagprd_inv = 0; >> + /* Entirely magic, per-GPU-gen value */ >> + u32 ubwc_mode = 0; >> >> /* a618 is using the hw default values */ >> if (adreno_is_a618(adreno_gpu)) >> return; >> >> - if (adreno_is_a640_family(adreno_gpu)) >> + if (adreno_is_a619(adreno_gpu)) { >> + /* HBB = 14 */ >> + hbb_lo = 1; >> + } >> + >> + if (adreno_is_a630(adreno_gpu)) { >> + /* HBB = 15 */ >> + hbb_lo = 2; >> + } >> + >> + if (adreno_is_a640_family(adreno_gpu)) { >> amsbc = 1; >> + /* HBB = 15 */ >> + hbb_lo = 2; >> + } >> >> if (adreno_is_a650(adreno_gpu) || adreno_is_a660(adreno_gpu)) { >> - /* TODO: get ddr type from bootloader and use 2 for LPDDR4 */ >> - lower_bit = 3; >> amsbc = 1; >> + /* TODO: get ddr type from bootloader and use 2 for LPDDR4 */ >> + /* HBB = 16 */ >> + hbb_lo = 3; >> rgb565_predicator = 1; >> uavflagprd_inv = 2; >> } >> >> if (adreno_is_7c3(adreno_gpu)) { >> - lower_bit = 1; >> amsbc = 1; >> + /* HBB is unset in downstream DTS, defaulting to 0 */ > This is incorrect. For 7c3 hbb value is 14. So hbb_lo should be 1. FYI, hbb configurations were moved to the driver from DT in recent downstream kernels. Right, seems to have happened with msm-5.10. Though a random kernel I grabbed seems to suggest it's 15 and not 14? https://github.com/sonyxperiadev/kernel/blob/aosp/K.P.1.0.r1/drivers/gpu/msm/adreno-gpulist.h#L1710 Konrad > > -Akhil. >> rgb565_predicator = 1; >> uavflagprd_inv = 2; >> } >> >> gpu_write(gpu, REG_A6XX_RB_NC_MODE_CNTL, >> - rgb565_predicator << 11 | amsbc << 4 | lower_bit << 1); >> - gpu_write(gpu, REG_A6XX_TPL1_NC_MODE_CNTL, lower_bit << 1); >> - gpu_write(gpu, REG_A6XX_SP_NC_MODE_CNTL, >> - uavflagprd_inv << 4 | lower_bit << 1); >> - gpu_write(gpu, REG_A6XX_UCHE_MODE_CNTL, lower_bit << 21); >> + rgb565_predicator << 11 | hbb_hi << 10 | amsbc << 4 | >> + min_acc_len << 3 | hbb_lo << 1 | ubwc_mode); >> + >> + gpu_write(gpu, REG_A6XX_TPL1_NC_MODE_CNTL, hbb_hi << 4 | >> + min_acc_len << 3 | hbb_lo << 1 | ubwc_mode); >> + >> + gpu_write(gpu, REG_A6XX_SP_NC_MODE_CNTL, hbb_hi << 10 | >> + uavflagprd_inv << 4 | min_acc_len << 3 | >> + hbb_lo << 1 | ubwc_mode); >> + >> + gpu_write(gpu, REG_A6XX_UCHE_MODE_CNTL, min_acc_len << 23 | hbb_lo << 21); >> } >> >> static int a6xx_cp_init(struct msm_gpu *gpu) >> >
On 3/1/2023 2:10 AM, Konrad Dybcio wrote: > > On 28.02.2023 21:23, Akhil P Oommen wrote: >> On 2/23/2023 5:36 PM, Konrad Dybcio wrote: >>> Rename lower_bit to hbb_lo and explain what it signifies. >>> Add explanations (wherever possible to other tunables). >>> >>> Sort the variable definition and assignment alphabetically. >> Sorting based on decreasing order of line length is more readable, isn't it? > I can do that. > >>> Port setting min_access_length, ubwc_mode and hbb_hi from downstream. >>> Set default values for all of the tunables to zero, as they should be. >>> >>> Values were validated against downstream and will be fixed up in >>> separate commits so as not to make this one even more messy. >>> >>> A618 remains untouched (left at hw defaults) in this patch. >>> >>> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> >>> --- >>> drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 55 ++++++++++++++++++++++++++++------- >>> 1 file changed, 45 insertions(+), 10 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >>> index c5f5d0bb3fdc..bdae341e0a7c 100644 >>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >>> @@ -786,39 +786,74 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu) >>> static void a6xx_set_ubwc_config(struct msm_gpu *gpu) >>> { >>> struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); >>> - u32 lower_bit = 2; >>> + /* Unknown, introduced with A640/680 */ >>> u32 amsbc = 0; >>> + /* >>> + * The Highest Bank Bit value represents the bit of the highest DDR bank. >>> + * We then subtract 13 from it (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. The default values (when HBB is >>> + * not specified) are 0, 0. >>> + */ >>> + u32 hbb_hi = 0; >>> + u32 hbb_lo = 0; >>> + /* Whether the minimum access length is 64 bits */ >>> + u32 min_acc_len = 0; >>> + /* Unknown, introduced with A650 family, related to UBWC mode/ver 4 */ >>> u32 rgb565_predicator = 0; >>> + /* Unknown, introduced with A650 family */ >>> u32 uavflagprd_inv = 0; >>> + /* Entirely magic, per-GPU-gen value */ >>> + u32 ubwc_mode = 0; >>> >>> /* a618 is using the hw default values */ >>> if (adreno_is_a618(adreno_gpu)) >>> return; >>> >>> - if (adreno_is_a640_family(adreno_gpu)) >>> + if (adreno_is_a619(adreno_gpu)) { >>> + /* HBB = 14 */ >>> + hbb_lo = 1; >>> + } >>> + >>> + if (adreno_is_a630(adreno_gpu)) { >>> + /* HBB = 15 */ >>> + hbb_lo = 2; >>> + } >>> + >>> + if (adreno_is_a640_family(adreno_gpu)) { >>> amsbc = 1; >>> + /* HBB = 15 */ >>> + hbb_lo = 2; >>> + } >>> >>> if (adreno_is_a650(adreno_gpu) || adreno_is_a660(adreno_gpu)) { >>> - /* TODO: get ddr type from bootloader and use 2 for LPDDR4 */ >>> - lower_bit = 3; >>> amsbc = 1; >>> + /* TODO: get ddr type from bootloader and use 2 for LPDDR4 */ >>> + /* HBB = 16 */ >>> + hbb_lo = 3; >>> rgb565_predicator = 1; >>> uavflagprd_inv = 2; >>> } >>> >>> if (adreno_is_7c3(adreno_gpu)) { >>> - lower_bit = 1; >>> amsbc = 1; >>> + /* HBB is unset in downstream DTS, defaulting to 0 */ >> This is incorrect. For 7c3 hbb value is 14. So hbb_lo should be 1. FYI, hbb configurations were moved to the driver from DT in recent downstream kernels. > Right, seems to have happened with msm-5.10. Though a random kernel I > grabbed seems to suggest it's 15 and not 14? > > https://github.com/sonyxperiadev/kernel/blob/aosp/K.P.1.0.r1/drivers/gpu/msm/adreno-gpulist.h#L1710 We override that with 14 in a6xx_init() for LP4 platforms dynamically. Since 7c3 is only supported on LP4, we can hardcode 14 here. In the downstream kernel, there is an api (of_fdt_get_ddrtype()) to detect ddrtype. If we can get something like that in upstream, we should implement a similar logic here. -Akhil. > > Konrad >> -Akhil. >>> rgb565_predicator = 1; >>> uavflagprd_inv = 2; >>> } >>> >>> gpu_write(gpu, REG_A6XX_RB_NC_MODE_CNTL, >>> - rgb565_predicator << 11 | amsbc << 4 | lower_bit << 1); >>> - gpu_write(gpu, REG_A6XX_TPL1_NC_MODE_CNTL, lower_bit << 1); >>> - gpu_write(gpu, REG_A6XX_SP_NC_MODE_CNTL, >>> - uavflagprd_inv << 4 | lower_bit << 1); >>> - gpu_write(gpu, REG_A6XX_UCHE_MODE_CNTL, lower_bit << 21); >>> + rgb565_predicator << 11 | hbb_hi << 10 | amsbc << 4 | >>> + min_acc_len << 3 | hbb_lo << 1 | ubwc_mode); >>> + >>> + gpu_write(gpu, REG_A6XX_TPL1_NC_MODE_CNTL, hbb_hi << 4 | >>> + min_acc_len << 3 | hbb_lo << 1 | ubwc_mode); >>> + >>> + gpu_write(gpu, REG_A6XX_SP_NC_MODE_CNTL, hbb_hi << 10 | >>> + uavflagprd_inv << 4 | min_acc_len << 3 | >>> + hbb_lo << 1 | ubwc_mode); >>> + >>> + gpu_write(gpu, REG_A6XX_UCHE_MODE_CNTL, min_acc_len << 23 | hbb_lo << 21); >>> } >>> >>> static int a6xx_cp_init(struct msm_gpu *gpu) >>>
On 3/1/2023 2:14 AM, Akhil P Oommen wrote: > On 3/1/2023 2:10 AM, Konrad Dybcio wrote: >> On 28.02.2023 21:23, Akhil P Oommen wrote: >>> On 2/23/2023 5:36 PM, Konrad Dybcio wrote: >>>> Rename lower_bit to hbb_lo and explain what it signifies. >>>> Add explanations (wherever possible to other tunables). >>>> >>>> Sort the variable definition and assignment alphabetically. >>> Sorting based on decreasing order of line length is more readable, isn't it? >> I can do that. >> >>>> Port setting min_access_length, ubwc_mode and hbb_hi from downstream. >>>> Set default values for all of the tunables to zero, as they should be. >>>> >>>> Values were validated against downstream and will be fixed up in >>>> separate commits so as not to make this one even more messy. >>>> >>>> A618 remains untouched (left at hw defaults) in this patch. >>>> >>>> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> >>>> --- >>>> drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 55 ++++++++++++++++++++++++++++------- >>>> 1 file changed, 45 insertions(+), 10 deletions(-) >>>> >>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >>>> index c5f5d0bb3fdc..bdae341e0a7c 100644 >>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >>>> @@ -786,39 +786,74 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu) >>>> static void a6xx_set_ubwc_config(struct msm_gpu *gpu) >>>> { >>>> struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); >>>> - u32 lower_bit = 2; >>>> + /* Unknown, introduced with A640/680 */ >>>> u32 amsbc = 0; >>>> + /* >>>> + * The Highest Bank Bit value represents the bit of the highest DDR bank. >>>> + * We then subtract 13 from it (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. The default values (when HBB is >>>> + * not specified) are 0, 0. >>>> + */ >>>> + u32 hbb_hi = 0; >>>> + u32 hbb_lo = 0; >>>> + /* Whether the minimum access length is 64 bits */ >>>> + u32 min_acc_len = 0; >>>> + /* Unknown, introduced with A650 family, related to UBWC mode/ver 4 */ >>>> u32 rgb565_predicator = 0; >>>> + /* Unknown, introduced with A650 family */ >>>> u32 uavflagprd_inv = 0; >>>> + /* Entirely magic, per-GPU-gen value */ >>>> + u32 ubwc_mode = 0; >>>> >>>> /* a618 is using the hw default values */ >>>> if (adreno_is_a618(adreno_gpu)) >>>> return; >>>> >>>> - if (adreno_is_a640_family(adreno_gpu)) >>>> + if (adreno_is_a619(adreno_gpu)) { >>>> + /* HBB = 14 */ >>>> + hbb_lo = 1; >>>> + } >>>> + >>>> + if (adreno_is_a630(adreno_gpu)) { >>>> + /* HBB = 15 */ >>>> + hbb_lo = 2; >>>> + } >>>> + >>>> + if (adreno_is_a640_family(adreno_gpu)) { >>>> amsbc = 1; >>>> + /* HBB = 15 */ >>>> + hbb_lo = 2; >>>> + } >>>> >>>> if (adreno_is_a650(adreno_gpu) || adreno_is_a660(adreno_gpu)) { >>>> - /* TODO: get ddr type from bootloader and use 2 for LPDDR4 */ >>>> - lower_bit = 3; >>>> amsbc = 1; >>>> + /* TODO: get ddr type from bootloader and use 2 for LPDDR4 */ >>>> + /* HBB = 16 */ >>>> + hbb_lo = 3; >>>> rgb565_predicator = 1; >>>> uavflagprd_inv = 2; >>>> } >>>> >>>> if (adreno_is_7c3(adreno_gpu)) { >>>> - lower_bit = 1; >>>> amsbc = 1; >>>> + /* HBB is unset in downstream DTS, defaulting to 0 */ >>> This is incorrect. For 7c3 hbb value is 14. So hbb_lo should be 1. FYI, hbb configurations were moved to the driver from DT in recent downstream kernels. >> Right, seems to have happened with msm-5.10. Though a random kernel I >> grabbed seems to suggest it's 15 and not 14? >> >> https://github.com/sonyxperiadev/kernel/blob/aosp/K.P.1.0.r1/drivers/gpu/msm/adreno-gpulist.h#L1710 > We override that with 14 in a6xx_init() for LP4 platforms dynamically. Since 7c3 is only supported on LP4, we can hardcode 14 here. > In the downstream kernel, there is an api (of_fdt_get_ddrtype()) to detect ddrtype. If we can get something like that in upstream, we should implement a similar logic here. > > -Akhil. Also, I haven't closely reviewed other targets configuration you updated, but it is a good idea to leave the existing configurations here as it in this refactor patch. Any update should be a separate patch. -Akhil. >> Konrad >>> -Akhil. >>>> rgb565_predicator = 1; >>>> uavflagprd_inv = 2; >>>> } >>>> >>>> gpu_write(gpu, REG_A6XX_RB_NC_MODE_CNTL, >>>> - rgb565_predicator << 11 | amsbc << 4 | lower_bit << 1); >>>> - gpu_write(gpu, REG_A6XX_TPL1_NC_MODE_CNTL, lower_bit << 1); >>>> - gpu_write(gpu, REG_A6XX_SP_NC_MODE_CNTL, >>>> - uavflagprd_inv << 4 | lower_bit << 1); >>>> - gpu_write(gpu, REG_A6XX_UCHE_MODE_CNTL, lower_bit << 21); >>>> + rgb565_predicator << 11 | hbb_hi << 10 | amsbc << 4 | >>>> + min_acc_len << 3 | hbb_lo << 1 | ubwc_mode); >>>> + >>>> + gpu_write(gpu, REG_A6XX_TPL1_NC_MODE_CNTL, hbb_hi << 4 | >>>> + min_acc_len << 3 | hbb_lo << 1 | ubwc_mode); >>>> + >>>> + gpu_write(gpu, REG_A6XX_SP_NC_MODE_CNTL, hbb_hi << 10 | >>>> + uavflagprd_inv << 4 | min_acc_len << 3 | >>>> + hbb_lo << 1 | ubwc_mode); >>>> + >>>> + gpu_write(gpu, REG_A6XX_UCHE_MODE_CNTL, min_acc_len << 23 | hbb_lo << 21); >>>> } >>>> >>>> static int a6xx_cp_init(struct msm_gpu *gpu) >>>>
On 28.02.2023 21:48, Akhil P Oommen wrote: > On 3/1/2023 2:14 AM, Akhil P Oommen wrote: >> On 3/1/2023 2:10 AM, Konrad Dybcio wrote: >>> On 28.02.2023 21:23, Akhil P Oommen wrote: >>>> On 2/23/2023 5:36 PM, Konrad Dybcio wrote: >>>>> Rename lower_bit to hbb_lo and explain what it signifies. >>>>> Add explanations (wherever possible to other tunables). >>>>> >>>>> Sort the variable definition and assignment alphabetically. >>>> Sorting based on decreasing order of line length is more readable, isn't it? >>> I can do that. >>> >>>>> Port setting min_access_length, ubwc_mode and hbb_hi from downstream. >>>>> Set default values for all of the tunables to zero, as they should be. >>>>> >>>>> Values were validated against downstream and will be fixed up in >>>>> separate commits so as not to make this one even more messy. >>>>> >>>>> A618 remains untouched (left at hw defaults) in this patch. >>>>> >>>>> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> >>>>> --- >>>>> drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 55 ++++++++++++++++++++++++++++------- >>>>> 1 file changed, 45 insertions(+), 10 deletions(-) >>>>> >>>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >>>>> index c5f5d0bb3fdc..bdae341e0a7c 100644 >>>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >>>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >>>>> @@ -786,39 +786,74 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu) >>>>> static void a6xx_set_ubwc_config(struct msm_gpu *gpu) >>>>> { >>>>> struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); >>>>> - u32 lower_bit = 2; >>>>> + /* Unknown, introduced with A640/680 */ >>>>> u32 amsbc = 0; >>>>> + /* >>>>> + * The Highest Bank Bit value represents the bit of the highest DDR bank. >>>>> + * We then subtract 13 from it (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. The default values (when HBB is >>>>> + * not specified) are 0, 0. >>>>> + */ >>>>> + u32 hbb_hi = 0; >>>>> + u32 hbb_lo = 0; >>>>> + /* Whether the minimum access length is 64 bits */ >>>>> + u32 min_acc_len = 0; >>>>> + /* Unknown, introduced with A650 family, related to UBWC mode/ver 4 */ >>>>> u32 rgb565_predicator = 0; >>>>> + /* Unknown, introduced with A650 family */ >>>>> u32 uavflagprd_inv = 0; >>>>> + /* Entirely magic, per-GPU-gen value */ >>>>> + u32 ubwc_mode = 0; >>>>> >>>>> /* a618 is using the hw default values */ >>>>> if (adreno_is_a618(adreno_gpu)) >>>>> return; >>>>> >>>>> - if (adreno_is_a640_family(adreno_gpu)) >>>>> + if (adreno_is_a619(adreno_gpu)) { >>>>> + /* HBB = 14 */ >>>>> + hbb_lo = 1; >>>>> + } >>>>> + >>>>> + if (adreno_is_a630(adreno_gpu)) { >>>>> + /* HBB = 15 */ >>>>> + hbb_lo = 2; >>>>> + } >>>>> + >>>>> + if (adreno_is_a640_family(adreno_gpu)) { >>>>> amsbc = 1; >>>>> + /* HBB = 15 */ >>>>> + hbb_lo = 2; >>>>> + } >>>>> >>>>> if (adreno_is_a650(adreno_gpu) || adreno_is_a660(adreno_gpu)) { >>>>> - /* TODO: get ddr type from bootloader and use 2 for LPDDR4 */ >>>>> - lower_bit = 3; >>>>> amsbc = 1; >>>>> + /* TODO: get ddr type from bootloader and use 2 for LPDDR4 */ >>>>> + /* HBB = 16 */ >>>>> + hbb_lo = 3; >>>>> rgb565_predicator = 1; >>>>> uavflagprd_inv = 2; >>>>> } >>>>> >>>>> if (adreno_is_7c3(adreno_gpu)) { >>>>> - lower_bit = 1; >>>>> amsbc = 1; >>>>> + /* HBB is unset in downstream DTS, defaulting to 0 */ >>>> This is incorrect. For 7c3 hbb value is 14. So hbb_lo should be 1. FYI, hbb configurations were moved to the driver from DT in recent downstream kernels. >>> Right, seems to have happened with msm-5.10. Though a random kernel I >>> grabbed seems to suggest it's 15 and not 14? >>> >>> https://github.com/sonyxperiadev/kernel/blob/aosp/K.P.1.0.r1/drivers/gpu/msm/adreno-gpulist.h#L1710 >> We override that with 14 in a6xx_init() for LP4 platforms dynamically. Since 7c3 is only supported on LP4, we can hardcode 14 here. Okay, I see. >> In the downstream kernel, there is an api (of_fdt_get_ddrtype()) to detect ddrtype. If we can get something like that in upstream, we should implement a similar logic here. Yeah, I mentioned it here [1], but I doubt it'd be implemented, given what Krzysztof pointed out. >> >> -Akhil. > Also, I haven't closely reviewed other targets configuration you updated, but it is a good idea to leave the existing configurations here as it in this refactor patch. Any update should be a separate patch. Sure, will do. Konrad [1] https://github.com/devicetree-org/devicetree-specification/issues/62 > > -Akhil. >>> Konrad >>>> -Akhil. >>>>> rgb565_predicator = 1; >>>>> uavflagprd_inv = 2; >>>>> } >>>>> >>>>> gpu_write(gpu, REG_A6XX_RB_NC_MODE_CNTL, >>>>> - rgb565_predicator << 11 | amsbc << 4 | lower_bit << 1); >>>>> - gpu_write(gpu, REG_A6XX_TPL1_NC_MODE_CNTL, lower_bit << 1); >>>>> - gpu_write(gpu, REG_A6XX_SP_NC_MODE_CNTL, >>>>> - uavflagprd_inv << 4 | lower_bit << 1); >>>>> - gpu_write(gpu, REG_A6XX_UCHE_MODE_CNTL, lower_bit << 21); >>>>> + rgb565_predicator << 11 | hbb_hi << 10 | amsbc << 4 | >>>>> + min_acc_len << 3 | hbb_lo << 1 | ubwc_mode); >>>>> + >>>>> + gpu_write(gpu, REG_A6XX_TPL1_NC_MODE_CNTL, hbb_hi << 4 | >>>>> + min_acc_len << 3 | hbb_lo << 1 | ubwc_mode); >>>>> + >>>>> + gpu_write(gpu, REG_A6XX_SP_NC_MODE_CNTL, hbb_hi << 10 | >>>>> + uavflagprd_inv << 4 | min_acc_len << 3 | >>>>> + hbb_lo << 1 | ubwc_mode); >>>>> + >>>>> + gpu_write(gpu, REG_A6XX_UCHE_MODE_CNTL, min_acc_len << 23 | hbb_lo << 21); >>>>> } >>>>> >>>>> static int a6xx_cp_init(struct msm_gpu *gpu) >>>>> >
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index c5f5d0bb3fdc..bdae341e0a7c 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -786,39 +786,74 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu) static void a6xx_set_ubwc_config(struct msm_gpu *gpu) { struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); - u32 lower_bit = 2; + /* Unknown, introduced with A640/680 */ u32 amsbc = 0; + /* + * The Highest Bank Bit value represents the bit of the highest DDR bank. + * We then subtract 13 from it (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. The default values (when HBB is + * not specified) are 0, 0. + */ + u32 hbb_hi = 0; + u32 hbb_lo = 0; + /* Whether the minimum access length is 64 bits */ + u32 min_acc_len = 0; + /* Unknown, introduced with A650 family, related to UBWC mode/ver 4 */ u32 rgb565_predicator = 0; + /* Unknown, introduced with A650 family */ u32 uavflagprd_inv = 0; + /* Entirely magic, per-GPU-gen value */ + u32 ubwc_mode = 0; /* a618 is using the hw default values */ if (adreno_is_a618(adreno_gpu)) return; - if (adreno_is_a640_family(adreno_gpu)) + if (adreno_is_a619(adreno_gpu)) { + /* HBB = 14 */ + hbb_lo = 1; + } + + if (adreno_is_a630(adreno_gpu)) { + /* HBB = 15 */ + hbb_lo = 2; + } + + if (adreno_is_a640_family(adreno_gpu)) { amsbc = 1; + /* HBB = 15 */ + hbb_lo = 2; + } if (adreno_is_a650(adreno_gpu) || adreno_is_a660(adreno_gpu)) { - /* TODO: get ddr type from bootloader and use 2 for LPDDR4 */ - lower_bit = 3; amsbc = 1; + /* TODO: get ddr type from bootloader and use 2 for LPDDR4 */ + /* HBB = 16 */ + hbb_lo = 3; rgb565_predicator = 1; uavflagprd_inv = 2; } if (adreno_is_7c3(adreno_gpu)) { - lower_bit = 1; amsbc = 1; + /* HBB is unset in downstream DTS, defaulting to 0 */ rgb565_predicator = 1; uavflagprd_inv = 2; } gpu_write(gpu, REG_A6XX_RB_NC_MODE_CNTL, - rgb565_predicator << 11 | amsbc << 4 | lower_bit << 1); - gpu_write(gpu, REG_A6XX_TPL1_NC_MODE_CNTL, lower_bit << 1); - gpu_write(gpu, REG_A6XX_SP_NC_MODE_CNTL, - uavflagprd_inv << 4 | lower_bit << 1); - gpu_write(gpu, REG_A6XX_UCHE_MODE_CNTL, lower_bit << 21); + rgb565_predicator << 11 | hbb_hi << 10 | amsbc << 4 | + min_acc_len << 3 | hbb_lo << 1 | ubwc_mode); + + gpu_write(gpu, REG_A6XX_TPL1_NC_MODE_CNTL, hbb_hi << 4 | + min_acc_len << 3 | hbb_lo << 1 | ubwc_mode); + + gpu_write(gpu, REG_A6XX_SP_NC_MODE_CNTL, hbb_hi << 10 | + uavflagprd_inv << 4 | min_acc_len << 3 | + hbb_lo << 1 | ubwc_mode); + + gpu_write(gpu, REG_A6XX_UCHE_MODE_CNTL, min_acc_len << 23 | hbb_lo << 21); } static int a6xx_cp_init(struct msm_gpu *gpu)