From patchwork Tue Jun 25 18:54:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 13711825 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6BB2FC30653 for ; Tue, 25 Jun 2024 18:54:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F2C7110E724; Tue, 25 Jun 2024 18:54:53 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="jOfCcxrz"; dkim-atps=neutral Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by gabe.freedesktop.org (Postfix) with ESMTPS id E15FD10E24A for ; Tue, 25 Jun 2024 18:54:48 +0000 (UTC) Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-57d20d89748so5765376a12.0 for ; Tue, 25 Jun 2024 11:54:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719341687; x=1719946487; darn=lists.freedesktop.org; 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=xAeS4mM4aSNcoVf/kotftvMHKTcYgSCvsxfnUxg7P5Y=; b=jOfCcxrzLHHP+zo+TfpMs7Li+2wbIt0iKkXQV0H7EudKz0vtj3/RPnToXixGuBlnX/ SFJiGUGU4v8tOsrrM7wgpGl9jqG/03Ot3cuKJUN6IhO6R1R0rP9Nrmqz4G8PQApqC4GL mAfXjs6LRSMorrYntFA/nX/0wm1iHmoO+0ZhvogtNsecVhlZ3b7GZlW65/dgHj/ynth/ g/6vmyT0MHghMBx6KgwExKyzTwgd6Mr5w4wZB0oRQNg4jDMq1JbkGebx/BFjORAmc2A1 UY8gD3Hyd3Szz3FPSAeCvfu75INMVrQbUMYXi6A+sxDqBO1DinrBnmD6LVHMeqaERuK+ 85zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719341687; x=1719946487; 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=xAeS4mM4aSNcoVf/kotftvMHKTcYgSCvsxfnUxg7P5Y=; b=aDvHEBsE0mzHFBYdeWqfdMhhX7MpKyPhnAo0XmSt0mOaXhw6hTpKdcQvFcTmH15y1n uF8ZSXxvUlVRJlyAT02EIxvptKaN0MXK0hQrB3nw2Az6ksVhyBPS8WPkGTtXFnIO07CT PHWOmq/DhwQJ/qKoy+/rfMkfUul0X8+EhqeUUmQbghLHNIxuGqTN7KXNwxviFKvR8H6V O/Ba7wJLaBO/LthTr65HZuR+kTmg33gNF2+qXyHm+aXwFVRp4x+69W4tG6XEr3+7NWt3 ctC/DxyvKi4G0bsNcrE8zO05UI1/YeVds0uEhq6d8zh6WRlSm9DWRo8TUTDH23SVXg2/ sRWQ== X-Forwarded-Encrypted: i=1; AJvYcCXFOtwSKoZb/jal8GMESiXJFHwbAUE9uX+dsqOfmojjXDTaEdaz1xE3uKPDXvd4tdM8gtFADvO2aTbaVDCjmwnNZ0PAmWwI8eQ9OcauEWNw X-Gm-Message-State: AOJu0Yx4RlZpei6CGE842+GFVBFmQPz/y+nAckRjNduhq1CZupMkfVn8 1p4idBL8LOIeu6KoozHe0vV18yJsXW2UpEtnNfM5yY4zVDkb04TZ4IylCeGKypw= X-Google-Smtp-Source: AGHT+IEZrJZS1tfhyTZGHs+U9v369kOCPKFuTyDtNvE4wjV/huT/hN7vydHLOuarueDDNPJZbhY6ZA== X-Received: by 2002:a50:871a:0:b0:57a:1fef:619e with SMTP id 4fb4d7f45d1cf-57d49cba82dmr6411757a12.18.1719341686936; Tue, 25 Jun 2024 11:54:46 -0700 (PDT) Received: from [192.168.215.29] (078088045245.garwolin.vectranet.pl. [78.88.45.245]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57d30583e93sm6206332a12.96.2024.06.25.11.54.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 11:54:46 -0700 (PDT) From: Konrad Dybcio Date: Tue, 25 Jun 2024 20:54:41 +0200 Subject: [PATCH v2 1/2] drm/msm/adreno: De-spaghettify the use of memory barriers MIME-Version: 1.0 Message-Id: <20240625-adreno_barriers-v2-1-c01f2ef4b62a@linaro.org> References: <20240625-adreno_barriers-v2-0-c01f2ef4b62a@linaro.org> In-Reply-To: <20240625-adreno_barriers-v2-0-c01f2ef4b62a@linaro.org> To: Rob Clark , Sean Paul , Abhinav Kumar , Dmitry Baryshkov , David Airlie , Daniel Vetter Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Akhil P Oommen , Konrad Dybcio X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1719341683; l=2477; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=eaij4ky7Aj6Mo/9du9/Ra9OWPq/fZxhy7kMrtRpyFYE=; b=Z0KB5jk9AhXcGs1aL3QtNdOPM5K/I4gVZFo+tLfA1o/pzDBDBAHZizVeTI/hoeYeCFn8s3LVE WBYMHf66XPSAmUwwriFgo+nFF+A0QD2AX3EK7pq3QNX6nzgBgLH4q7t X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Memory barriers help ensure instruction ordering, NOT time and order of actual write arrival at other observers (e.g. memory-mapped IP). On architectures employing weak memory ordering, the latter can be a giant pain point, and it has been as part of this driver. Moreover, the gpu_/gmu_ accessors already use non-relaxed versions of readl/writel, which include r/w (respectively) barriers. Replace the barriers with a readback (or drop altogether where possible) that ensures the previous writes have exited the write buffer (as the CPU must flush the write to the register it's trying to read back). Signed-off-by: Konrad Dybcio --- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 4 +--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 10 ++++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c index 0e3dfd4c2bc8..09d640165b18 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c @@ -466,9 +466,7 @@ static int a6xx_rpmh_start(struct a6xx_gmu *gmu) int ret; u32 val; - gmu_write(gmu, REG_A6XX_GMU_RSCC_CONTROL_REQ, 1 << 1); - /* Wait for the register to finish posting */ - wmb(); + gmu_write(gmu, REG_A6XX_GMU_RSCC_CONTROL_REQ, BIT(1)); ret = gmu_poll_timeout(gmu, REG_A6XX_GMU_RSCC_CONTROL_ACK, val, val & (1 << 1), 100, 10000); diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index c98cdb1e9326..4083d0cad782 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -855,14 +855,16 @@ static int hw_init(struct msm_gpu *gpu) /* Clear GBIF halt in case GX domain was not collapsed */ if (adreno_is_a619_holi(adreno_gpu)) { gpu_write(gpu, REG_A6XX_GBIF_HALT, 0); + gpu_read(gpu, REG_A6XX_GBIF_HALT); + gpu_write(gpu, REG_A6XX_RBBM_GPR0_CNTL, 0); - /* Let's make extra sure that the GPU can access the memory.. */ - mb(); + gpu_read(gpu, REG_A6XX_RBBM_GPR0_CNTL); } else if (a6xx_has_gbif(adreno_gpu)) { gpu_write(gpu, REG_A6XX_GBIF_HALT, 0); + gpu_read(gpu, REG_A6XX_GBIF_HALT); + gpu_write(gpu, REG_A6XX_RBBM_GBIF_HALT, 0); - /* Let's make extra sure that the GPU can access the memory.. */ - mb(); + gpu_read(gpu, REG_A6XX_RBBM_GBIF_HALT); } /* Some GPUs are stubborn and take their sweet time to unhalt GBIF! */ From patchwork Tue Jun 25 18:54:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 13711824 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0CE0AC2BBCA for ; Tue, 25 Jun 2024 18:54:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D26B110E71D; Tue, 25 Jun 2024 18:54:53 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="aAbVCyd1"; dkim-atps=neutral Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 489FB10E71D for ; Tue, 25 Jun 2024 18:54:50 +0000 (UTC) Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-57d044aa5beso6817781a12.2 for ; Tue, 25 Jun 2024 11:54:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719341688; x=1719946488; darn=lists.freedesktop.org; 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=RslMOok7+SRb0tZIuuUneQKJy4llxQByohMGQm6a7lg=; b=aAbVCyd1QvPpGO0ujdxzrwWFd9p9riBZhE3UBjgPMa/OkO29Rvx9GqSGHkU/O3PIuU LQw/ECqCFpXceXjrMs9VVxkGjnUXkiqc9jCr9Yr6ywGQLjxZiSvSh0BErfwqHt4m+LB1 HfGARYfkh25eqIpXD4Mi1nslukfMHAHTD4PAF2IGhMvi4UpqWkCj3DjGEL1SeFR2NDCI BHRbR2nIbNnodXSEhEMNaoSVNF87jIUdcLkA3kC78oH9R9zHn2lTBINiVaoquy7cwEBA V9G1yn00skh8GS2Nt2TqgZV/xm1TtmtnLAlTaUJUVjpFerzXMz6aCo7XFIexmCcRhVWh bWSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719341688; x=1719946488; 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=RslMOok7+SRb0tZIuuUneQKJy4llxQByohMGQm6a7lg=; b=NZnUKTNJxjVz6ist3Qtj2NcG5n1gFq2z4Z/hMEfbILL4UUXY2gJqL3qh+Wj0IxPjw9 41YwQpWwF4Y+dsaI7GgnKIG1YwXpjA7ixCKE6RsU5i+yQRndvYG+zXYc0SIgjuIzEOou e+BinH4s7UlKUFi8PW8i+2JSN0BK3rPfE/FbMt+ehxYBfUtYY8pS0hL4yKSykIkHeGiy aOZb6wtlmJIM1CEWZFGPhurgVWy6Dew9tAMlp3aSMFIlFyLk/XD/MX+ZLBdRLnSAEaZJ Hg5quM2gOxuf0Vq6CmnBvdqa+b+GppNK/agqMK5Wrkesc+k1rUe2k7pNVZe3BQpGVJ4l DTXg== X-Forwarded-Encrypted: i=1; AJvYcCXeiKPAKti/Y+4U++kxsYT7hc4UJ5YdussDnMlsku69hgIyaLE7ZBWrVWfVf9JkqSejWwiKcZLiuV0WiMbFz9wohfBZX/mJwPjuTRdA9cjO X-Gm-Message-State: AOJu0YwQU4AUhIj3SB6cxD60if8jCOz6psLi0uxB1jCqV0+f1JNxVW/3 8cyhtkobLVsHAisaExchxN/BSgOmbULd3OkAxaqFb4+mqBxkGen/vaEr7lTnzk8= X-Google-Smtp-Source: AGHT+IGgV5XNEHZlscPIUwGZlGHAvsdbFXvfBd3MkXeqG+BdMPDfhtOjj2M3SWB0pI6uYjgg1nm5bQ== X-Received: by 2002:a50:c343:0:b0:57c:7ce3:6cd9 with SMTP id 4fb4d7f45d1cf-57d4bd8173amr6264270a12.23.1719341688229; Tue, 25 Jun 2024 11:54:48 -0700 (PDT) Received: from [192.168.215.29] (078088045245.garwolin.vectranet.pl. [78.88.45.245]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57d30583e93sm6206332a12.96.2024.06.25.11.54.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 11:54:47 -0700 (PDT) From: Konrad Dybcio Date: Tue, 25 Jun 2024 20:54:42 +0200 Subject: [PATCH v2 2/2] Revert "drm/msm/a6xx: Poll for GBIF unhalt status in hw_init" MIME-Version: 1.0 Message-Id: <20240625-adreno_barriers-v2-2-c01f2ef4b62a@linaro.org> References: <20240625-adreno_barriers-v2-0-c01f2ef4b62a@linaro.org> In-Reply-To: <20240625-adreno_barriers-v2-0-c01f2ef4b62a@linaro.org> To: Rob Clark , Sean Paul , Abhinav Kumar , Dmitry Baryshkov , David Airlie , Daniel Vetter Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Akhil P Oommen , Konrad Dybcio X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1719341683; l=1182; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=IqxT/XaY/qre3pbFCzxDe2dM3jXz5RZUhwZonz27NSw=; b=bf4fOmgiiY9wBmlPLmScoY7M3PVhXAq9z2YI3hCMleizQn83eYlbtCBhdiLjMkanneiBIOPKC IrQh0EQxtzKBYdtR/m9m5FMJSE+oheGuEHORh4MyKpSMMYSeCtNfD4f X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Commit c9707bcbd0f3 ("drm/msm/adreno: De-spaghettify the use of memory barriers") made some fixups relating to write arrival, ensuring that the GPU's memory interface has *really really really* been told to come out of reset. That in turn rendered the hacky commit being reverted no longer necessary. Get rid of it. This reverts commit b77532803d11f2b03efab2ebfd8c0061cd7f8b30. Signed-off-by: Konrad Dybcio --- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index 4083d0cad782..03e23eef5126 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -867,10 +867,6 @@ static int hw_init(struct msm_gpu *gpu) gpu_read(gpu, REG_A6XX_RBBM_GBIF_HALT); } - /* Some GPUs are stubborn and take their sweet time to unhalt GBIF! */ - if (adreno_is_a7xx(adreno_gpu) && a6xx_has_gbif(adreno_gpu)) - spin_until(!gpu_read(gpu, REG_A6XX_GBIF_HALT_ACK)); - gpu_write(gpu, REG_A6XX_RBBM_SECVID_TSB_CNTL, 0); if (adreno_is_a619_holi(adreno_gpu))