Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2255935rwl; Sat, 1 Apr 2023 04:56:23 -0700 (PDT) X-Google-Smtp-Source: AKy350b3JzwNdAX9XnmzF31h9yg4BIkmmZq6lccaQIp2duXqSSWet0QtMsOUnI6litZAbU1thh/t X-Received: by 2002:aa7:97ac:0:b0:62d:b97f:e29c with SMTP id d12-20020aa797ac000000b0062db97fe29cmr10969420pfq.16.1680350182869; Sat, 01 Apr 2023 04:56:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680350182; cv=none; d=google.com; s=arc-20160816; b=vfG6s5D1hJVt2VCUgy3y2ubtxqNb0tYyJdgvh1mTKGNi68JE6KXaKfErJGZSUX/cdL Pr34+/5ceaREuXgDXCKTXMW48Dv3fqRBWgxNqNO9405NvbI1xngO67erzUCrzaP9e/HQ /6YKcgfleBVZIeeF5majPaRVsEiQmGsEB2huqDEjhVrSlh/7vKyuSjRF70D+3lRTehtu b3dfbpR28nRLSU0+Of/4GSZuGTNR8Xb9DhTmwoSjm8TRAVGsqxqkp+oQunJ4EgEbR6ZO YbhOTt2IvdyjGSEC2T3HA/l2bIB2vq1z4CibkXTx7usXqCs+JHk6FjjHD93/4SQ8B+cK jfYw== 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=EcTVfYVJVvyjT/gmTGLxErkT9wedlUsEwNFe3X7+hGY=; b=0KdJcXXGeYTZR43WAu2FkQ9pkuVaV0WOBmqNyKd0YiPileaAwXRBrjJtg1CzEPvBWA EMY2QRQFtxrHC0TQCcCOzKE/IYTseRy402R2bE5JKiakjs7bYTKwrebEgKWIV0ZGfLQk 7+KAoPKlgSaPTwfA3Ib0Fg2icWhcTj+9OWcMCunFu5vpto97X/8iGLOFoe0Dr7av6ZWi Zs2wIduuDNw8o/hQU5Re30TbKz+NZIWuevP6Nxs4ycdC2aH60EKQ4DbU4RWnebQfMxBz Ryd2SQ9pMOP69vJuL/0hBBT3Hj3ekpSfbHLYTi6l3cQuoocDM+W4uJMnI91Abw11TQBe mXjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hka16u4/"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a4-20020a624d04000000b006280d8f703asi4775863pfb.164.2023.04.01.04.56.11; Sat, 01 Apr 2023 04:56:22 -0700 (PDT) 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="hka16u4/"; 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 S229744AbjDALzR (ORCPT + 99 others); Sat, 1 Apr 2023 07:55:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229906AbjDALzI (ORCPT ); Sat, 1 Apr 2023 07:55:08 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B1B724AFD for ; Sat, 1 Apr 2023 04:55:03 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id x17so32258261lfu.5 for ; Sat, 01 Apr 2023 04:55:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680350103; 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=EcTVfYVJVvyjT/gmTGLxErkT9wedlUsEwNFe3X7+hGY=; b=hka16u4/n+DaWI8KLthmzu7abmpNUNrh+4WYo9kw74EijqTQ+uv8BmIc5dC2/0XNTb bHWTPITrL5MNXS5B8o+sylcHX20jz0Y+uX+cTZOdirKY5oyr7urEQlInMb3m/su863rE 9QhtgRgP/fJosWhwYGL8MVvOmRz4v/tekU0+3E3jJLg7ZCywP05UTO73WdkToEWM2aVr TmKjintsJd/Se3plcrNqkiJ180wix63MKXEkZ4RtC7cC68WWZ7DISgKkgfTOxea6D9+g nv/D5hOAuVMSlgRYnAIdAU3CjxhsXgB9E8Cck4TnImz8s37pdFx365nxpKoVttMp6Gh5 V1Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680350103; 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=EcTVfYVJVvyjT/gmTGLxErkT9wedlUsEwNFe3X7+hGY=; b=Y65zqOHX19PVhUtZbnpnahZiDe01ysxwVWcClZQ+Fur+AwTsD1kFw/084IBAQHyA49 MZKV3BuvEz+l7ndo9YdKnTjOD2siwlj0aX1rPAt+ArgHQERiPnGrHF9++DvoeJXLg8BT FbgDbKDq+WJzPOwsERlV5+xoFuUqpOehqIrWwL4mtitXFFMTrj1urAVIY4X+b1G34Fx7 V0e5XhD4eELM3o6lna0QXyW8Fqn9HFqvyzKt1l8o1UXYTtQKmS71/UVaiAcpWZDgkUps pzxZ4TpP6dazgS/Z6rGtWQpBV4ujzjZYn6QHq+dDcAG5oiaiSRqVsAAzHMknpN5UZmGr nqdQ== X-Gm-Message-State: AAQBX9cQl91yHkLI4r6ORTSprkgFJXLvYfaP1CrXItUzeG7tJXG33iil w2FTf7AjyE79fbtNFTf6EmXN4g== X-Received: by 2002:ac2:4824:0:b0:4e8:487a:7c2e with SMTP id 4-20020ac24824000000b004e8487a7c2emr3686636lft.14.1680350102999; Sat, 01 Apr 2023 04:55:02 -0700 (PDT) Received: from [192.168.1.101] (abxj225.neoplus.adsl.tpnet.pl. [83.9.3.225]) by smtp.gmail.com with ESMTPSA id w8-20020ac254a8000000b004e83f386878sm786737lfk.153.2023.04.01.04.55.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 04:55:02 -0700 (PDT) From: Konrad Dybcio Date: Sat, 01 Apr 2023 13:54:42 +0200 Subject: [PATCH v6 05/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-v6-5-2034115bb60c@linaro.org> References: <20230223-topic-gmuwrapper-v6-0-2034115bb60c@linaro.org> In-Reply-To: <20230223-topic-gmuwrapper-v6-0-2034115bb60c@linaro.org> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Bjorn Andersson , Konrad Dybcio , Akhil P Oommen 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 , Marijn Suijten , Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1680350084; l=3025; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=O39lrV4yksGqUskcsqJEvIhhEigi/fA6XvvXYO4w5ps=; b=myh8HvfU5eZVgXTCg2b20N3sNNDdu2Vt9J1nGW840mDCgn7ouXLFoojuTVVlFz4Gv+4vDv130JlZ AuIMwbCbCZNPiZ/ewcioNX4dUYGWfQyHbeXMSj3a1dotlSrhM8q7 X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-Spam-Status: No, score=-0.2 required=5.0 tests=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: X-Mailing-List: linux-kernel@vger.kernel.org Rename lower_bit to hbb_lo and explain what it signifies. Add explanations (wherever possible to other tunables). Port setting min_access_length, ubwc_mode and hbb_hi from downstream. Reviewed-by: Rob Clark Signed-off-by: Konrad Dybcio --- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 39 +++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index a501654fd8bd..931f9f3b3a85 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -786,10 +786,25 @@ 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; - u32 amsbc = 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; + /* Whether the minimum access length is 64 bits */ + u32 min_acc_len = 0; + /* Entirely magic, per-GPU-gen value */ + u32 ubwc_mode = 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. This should ideally use DRAM + * type detection. + */ + u32 hbb_hi = 0; + u32 hbb_lo = 2; + /* Unknown, introduced with A640/680 */ + u32 amsbc = 0; /* a618 is using the hw default values */ if (adreno_is_a618(adreno_gpu)) @@ -800,25 +815,31 @@ static void a6xx_set_ubwc_config(struct msm_gpu *gpu) 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; + hbb_lo = 3; amsbc = 1; rgb565_predicator = 1; uavflagprd_inv = 2; } if (adreno_is_7c3(adreno_gpu)) { - lower_bit = 1; + hbb_lo = 1; amsbc = 1; 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) -- 2.40.0