Message ID | 20230223-topic-gmuwrapper-v8-7-69c68206609e@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1529592vqr; Mon, 29 May 2023 06:54:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5FeSAyjKWyXj24mXaM5HQ2NTwE0vUvELP76g61oFOcwIbd7tgVPm6LaZn7VhZXYi7oCWLS X-Received: by 2002:a05:6a21:7895:b0:107:1805:fef5 with SMTP id bf21-20020a056a21789500b001071805fef5mr10400840pzc.28.1685368447204; Mon, 29 May 2023 06:54:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685368447; cv=none; d=google.com; s=arc-20160816; b=NkgBCExyou6K686Z+5vXHBbKlOParlo2hJTvUS2bpKnMFtx5IftvYSxYgN/9TIrKPd pxgIrZghPZF0z0TGUyK0gMrjqN8xZD08s2CI1orV+3/uNOXvp7y13mg/nISLm9D/YAwa cc4lTZ/7HSZWXX+F19BVLXoUBZKDvI4cd95t3+7gyFTFWfWaQcoF4xX6hRq2K1w9gcCo g/VMiqwFAedkZZnS64Huq5RgYSA1sVAAn8DSIqVwhtSoVDr1MTmjdFF1V5XxFQ4LvfkN qDwSwHI2YiVXxSpYR3NyvY3Go+uxwXfYBz+WM/0BnBpFELPmtKF2Vo2RXBYp1cMUgatl ggfQ== 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=1wFIIbEoxPLhpitFzIB7VWk7qAiJQapqN1VZ4+ZRTRI=; b=Rk+ChapZsCWBbJyXDKstN4tq9TPTowvRJw5fL3gmNcJ96XBrOpAwBkCqgtc3Hxhb1J HpI9l+RhoaF8pWjv4+8jt+zYF3mvxfeIBz1QFm1Gwvfrbx2xy/rYhxP1eo+rNS/r3Uc6 XuwtVDG+sLsnoBe1ec1LWnnHzDkak61w3VnuQWbOCv+tZNBxMkYEwz1i2UFj6bP8rTr0 cDuskw8vdSI1IEH5ZuHM792Qs8MI7RbBJfygd2KUdiDwps4z818gtUe3DQ3gFPDSxEaA xdiMgTwwhiKjyMt5MVPLzDfcmshU50p2HuW1JVsgN+pjjOGonxp3MigTEyaDd1I8XI4o m1kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tJFZkGE+; 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 u14-20020a63790e000000b00530b7ef148asi3830435pgc.894.2023.05.29.06.53.53; Mon, 29 May 2023 06:54:07 -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=tJFZkGE+; 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 S230009AbjE2NxG (ORCPT <rfc822;callmefire3@gmail.com> + 99 others); Mon, 29 May 2023 09:53:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229980AbjE2Nwq (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 29 May 2023 09:52:46 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 052AE107 for <linux-kernel@vger.kernel.org>; Mon, 29 May 2023 06:52:37 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-4f3edc05aa5so3575065e87.3 for <linux-kernel@vger.kernel.org>; Mon, 29 May 2023 06:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685368355; x=1687960355; 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=1wFIIbEoxPLhpitFzIB7VWk7qAiJQapqN1VZ4+ZRTRI=; b=tJFZkGE+7K3cO4bTU2J0U0tPAkHpBMlsjrFXVKtem/gV7E/xLJGiLiradl9efECbS8 a/qHxL9Aoplc9sKCfO07aeRfUuab+TPHMKIh+x4qA9bWzl0R/SXUTK0uqfRjkrepFd5d J3wBhENOWveg0ew96zH95NosFLsHbSNbdDHtoYP8CLVfo3wvGpIdi6d/wRbv6LVFtZnA /D9cUO/5qEitqDn3JU4ASjOpkpmgx27BbATZTb0++TKCmFTDJzhFW37hss8x7qwRGdNV bVr0HWxqAgp0dfQi0ILyUUD7jHJAWU9FwH013MmuWU5PgWSCGa7HTXEsSlNa+6gSzxGV mDtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685368355; x=1687960355; 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=1wFIIbEoxPLhpitFzIB7VWk7qAiJQapqN1VZ4+ZRTRI=; b=hcZR/hZhYAft6N/CbQzRJLLAcNspwJ6WRFuYxIHjsW+Uyp7D0QaTnpK0BQ5nyb6tN/ LxpRcAwEragwmnfsQjUDzdYRVOhR0WCd9+g0sGWSR96AjeVhYHg7HaY/aMNLLIShaKJ/ eUKbwq0iL/si8eXZRbXn5znklhRajy/cLYQ1F2dlNNsQdmg8OjsDE1C9HsAGkO0SP9er Kho9Fxq8ncigq63j0ejbf1UYz58Enq1+PpSb1SMu1bxZklW3OdsUAlvB67hUrWNiTAe9 tHy+4kVKONfTTKp3ofivRRGyBNqm9z+VGc7o7IYvxAVe/2+upriUvDPWcN663nKUMaoh ag5Q== X-Gm-Message-State: AC+VfDxGSqvjQY2crgAWaLhYqtmuvOf7+VeEcC2TXI+Hj5vrtsGc0I7V zMbpgOtrsGXxhdigNik+DFKQvw== X-Received: by 2002:a19:f014:0:b0:4f3:8196:80c8 with SMTP id p20-20020a19f014000000b004f3819680c8mr2992126lfc.1.1685368355333; Mon, 29 May 2023 06:52:35 -0700 (PDT) Received: from [192.168.1.101] (abyj77.neoplus.adsl.tpnet.pl. [83.9.29.77]) by smtp.gmail.com with ESMTPSA id c16-20020ac25310000000b004f2532cfbc1sm4700lfh.81.2023.05.29.06.52.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 06:52:35 -0700 (PDT) From: Konrad Dybcio <konrad.dybcio@linaro.org> Date: Mon, 29 May 2023 15:52:26 +0200 Subject: [PATCH v8 07/18] drm/msm/a6xx: Add a helper for software-resetting the GPU MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230223-topic-gmuwrapper-v8-7-69c68206609e@linaro.org> References: <20230223-topic-gmuwrapper-v8-0-69c68206609e@linaro.org> In-Reply-To: <20230223-topic-gmuwrapper-v8-0-69c68206609e@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>, Conor Dooley <conor+dt@kernel.org> 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>, Marijn Suijten <marijn.suijten@somainline.org>, Konrad Dybcio <konrad.dybcio@linaro.org> X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1685368343; l=2525; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=mi/m4Oey75vF6uy9TLg2BuEnAAWYnXoWrcm53l1hJFY=; b=enRRVhClSkzGNyALCbuTLrsRhyxRtr6M5+NIOUmVyvTekRXXLNLpVv3mhrelTdgzg7baIKMlI E+Yn8f2qd0+B+zdudaBL8M3bwxbhoLDu2i8Do+Ity1YTSSu8q0yoyj+ 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,T_SCC_BODY_TEXT_LINE 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?1767236905077198875?= X-GMAIL-MSGID: =?utf-8?q?1767236905077198875?= |
Series |
GMU-less A6xx support (A610, A619_holi)
|
|
Commit Message
Konrad Dybcio
May 29, 2023, 1:52 p.m. UTC
Introduce a6xx_gpu_sw_reset() in preparation for adding GMU wrapper
GPUs and reuse it in a6xx_gmu_force_off().
This helper, contrary to the original usage in GMU code paths, adds
a write memory barrier which together with the necessary delay should
ensure that the reset is never deasserted too quickly due to e.g. OoO
execution going crazy.
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 3 +--
drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 11 +++++++++++
drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 +
3 files changed, 13 insertions(+), 2 deletions(-)
Comments
On Mon, May 29, 2023 at 03:52:26PM +0200, Konrad Dybcio wrote: > > Introduce a6xx_gpu_sw_reset() in preparation for adding GMU wrapper > GPUs and reuse it in a6xx_gmu_force_off(). > > This helper, contrary to the original usage in GMU code paths, adds > a write memory barrier which together with the necessary delay should > ensure that the reset is never deasserted too quickly due to e.g. OoO > execution going crazy. > > Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> > --- > drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 3 +-- > drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 11 +++++++++++ > drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + > 3 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c > index b86be123ecd0..5ba8cba69383 100644 > --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c > +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c > @@ -899,8 +899,7 @@ static void a6xx_gmu_force_off(struct a6xx_gmu *gmu) > a6xx_bus_clear_pending_transactions(adreno_gpu, true); > > /* Reset GPU core blocks */ > - gpu_write(gpu, REG_A6XX_RBBM_SW_RESET_CMD, 1); > - udelay(100); > + a6xx_gpu_sw_reset(gpu, true); > } > > static void a6xx_gmu_set_initial_freq(struct msm_gpu *gpu, struct a6xx_gmu *gmu) > diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > index e3ac3f045665..083ccb5bcb4e 100644 > --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > @@ -1634,6 +1634,17 @@ void a6xx_bus_clear_pending_transactions(struct adreno_gpu *adreno_gpu, bool gx_ > gpu_write(gpu, REG_A6XX_GBIF_HALT, 0x0); > } > > +void a6xx_gpu_sw_reset(struct msm_gpu *gpu, bool assert) > +{ > + gpu_write(gpu, REG_A6XX_RBBM_SW_RESET_CMD, assert); > + /* Add a barrier to avoid bad surprises */ Can you please make this comment a bit more clear? Highlight that we should ensure the register is posted at hw before polling. I think this barrier is required only during assert. -Akhil. > + mb(); > + > + /* The reset line needs to be asserted for at least 100 us */ > + if (assert) > + udelay(100); > +} > + > static int a6xx_pm_resume(struct msm_gpu *gpu) > { > struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); > diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > index 9580def06d45..aa70390ee1c6 100644 > --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > @@ -89,5 +89,6 @@ struct msm_gpu_state *a6xx_gpu_state_get(struct msm_gpu *gpu); > int a6xx_gpu_state_put(struct msm_gpu_state *state); > > void a6xx_bus_clear_pending_transactions(struct adreno_gpu *adreno_gpu, bool gx_off); > +void a6xx_gpu_sw_reset(struct msm_gpu *gpu, bool assert); > > #endif /* __A6XX_GPU_H__ */ > > -- > 2.40.1 >
On 6.06.2023 19:18, Akhil P Oommen wrote: > On Mon, May 29, 2023 at 03:52:26PM +0200, Konrad Dybcio wrote: >> >> Introduce a6xx_gpu_sw_reset() in preparation for adding GMU wrapper >> GPUs and reuse it in a6xx_gmu_force_off(). >> >> This helper, contrary to the original usage in GMU code paths, adds >> a write memory barrier which together with the necessary delay should >> ensure that the reset is never deasserted too quickly due to e.g. OoO >> execution going crazy. >> >> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> >> --- >> drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 3 +-- >> drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 11 +++++++++++ >> drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + >> 3 files changed, 13 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c >> index b86be123ecd0..5ba8cba69383 100644 >> --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c >> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c >> @@ -899,8 +899,7 @@ static void a6xx_gmu_force_off(struct a6xx_gmu *gmu) >> a6xx_bus_clear_pending_transactions(adreno_gpu, true); >> >> /* Reset GPU core blocks */ >> - gpu_write(gpu, REG_A6XX_RBBM_SW_RESET_CMD, 1); >> - udelay(100); >> + a6xx_gpu_sw_reset(gpu, true); >> } >> >> static void a6xx_gmu_set_initial_freq(struct msm_gpu *gpu, struct a6xx_gmu *gmu) >> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >> index e3ac3f045665..083ccb5bcb4e 100644 >> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >> @@ -1634,6 +1634,17 @@ void a6xx_bus_clear_pending_transactions(struct adreno_gpu *adreno_gpu, bool gx_ >> gpu_write(gpu, REG_A6XX_GBIF_HALT, 0x0); >> } >> >> +void a6xx_gpu_sw_reset(struct msm_gpu *gpu, bool assert) >> +{ >> + gpu_write(gpu, REG_A6XX_RBBM_SW_RESET_CMD, assert); >> + /* Add a barrier to avoid bad surprises */ > Can you please make this comment a bit more clear? Highlight that we > should ensure the register is posted at hw before polling. > > I think this barrier is required only during assert. Generally it should not be strictly required at all, but I'm thinking that it'd be good to keep it in both cases, so that: if (assert) we don't keep writing things to the GPU if it's in reset else we don't start writing things to the GPU becomes it comes out of reset Also, if you squint hard enough at the commit message, you'll notice I intended for this so only be a wmb, but for some reason generalized it.. Perhaps that's another thing I should fix! for v9.. Konrad > > -Akhil. >> + mb(); >> + >> + /* The reset line needs to be asserted for at least 100 us */ >> + if (assert) >> + udelay(100); >> +} >> + >> static int a6xx_pm_resume(struct msm_gpu *gpu) >> { >> struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); >> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h >> index 9580def06d45..aa70390ee1c6 100644 >> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h >> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h >> @@ -89,5 +89,6 @@ struct msm_gpu_state *a6xx_gpu_state_get(struct msm_gpu *gpu); >> int a6xx_gpu_state_put(struct msm_gpu_state *state); >> >> void a6xx_bus_clear_pending_transactions(struct adreno_gpu *adreno_gpu, bool gx_off); >> +void a6xx_gpu_sw_reset(struct msm_gpu *gpu, bool assert); >> >> #endif /* __A6XX_GPU_H__ */ >> >> -- >> 2.40.1 >>
On Thu, Jun 15, 2023 at 12:34:06PM +0200, Konrad Dybcio wrote: > > On 6.06.2023 19:18, Akhil P Oommen wrote: > > On Mon, May 29, 2023 at 03:52:26PM +0200, Konrad Dybcio wrote: > >> > >> Introduce a6xx_gpu_sw_reset() in preparation for adding GMU wrapper > >> GPUs and reuse it in a6xx_gmu_force_off(). > >> > >> This helper, contrary to the original usage in GMU code paths, adds > >> a write memory barrier which together with the necessary delay should > >> ensure that the reset is never deasserted too quickly due to e.g. OoO > >> execution going crazy. > >> > >> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> > >> --- > >> drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 3 +-- > >> drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 11 +++++++++++ > >> drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + > >> 3 files changed, 13 insertions(+), 2 deletions(-) > >> > >> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c > >> index b86be123ecd0..5ba8cba69383 100644 > >> --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c > >> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c > >> @@ -899,8 +899,7 @@ static void a6xx_gmu_force_off(struct a6xx_gmu *gmu) > >> a6xx_bus_clear_pending_transactions(adreno_gpu, true); > >> > >> /* Reset GPU core blocks */ > >> - gpu_write(gpu, REG_A6XX_RBBM_SW_RESET_CMD, 1); > >> - udelay(100); > >> + a6xx_gpu_sw_reset(gpu, true); > >> } > >> > >> static void a6xx_gmu_set_initial_freq(struct msm_gpu *gpu, struct a6xx_gmu *gmu) > >> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > >> index e3ac3f045665..083ccb5bcb4e 100644 > >> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > >> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > >> @@ -1634,6 +1634,17 @@ void a6xx_bus_clear_pending_transactions(struct adreno_gpu *adreno_gpu, bool gx_ > >> gpu_write(gpu, REG_A6XX_GBIF_HALT, 0x0); > >> } > >> > >> +void a6xx_gpu_sw_reset(struct msm_gpu *gpu, bool assert) > >> +{ > >> + gpu_write(gpu, REG_A6XX_RBBM_SW_RESET_CMD, assert); > >> + /* Add a barrier to avoid bad surprises */ > > Can you please make this comment a bit more clear? Highlight that we > > should ensure the register is posted at hw before polling. > > > > I think this barrier is required only during assert. > Generally it should not be strictly required at all, but I'm thinking > that it'd be good to keep it in both cases, so that: > > if (assert) > we don't keep writing things to the GPU if it's in reset > else > we don't start writing things to the GPU becomes it comes > out of reset > > Also, if you squint hard enough at the commit message, you'll notice > I intended for this so only be a wmb, but for some reason generalized > it.. Perhaps that's another thing I should fix! > for v9.. wmb() doesn't provide any ordering guarantee with the delay loop. A common practice is to just read back the same register before the loop because a readl followed by delay() is guaranteed to be ordered. -Akhil. > > Konrad > > > > -Akhil. > >> + mb(); > >> + > >> + /* The reset line needs to be asserted for at least 100 us */ > >> + if (assert) > >> + udelay(100); > >> +} > >> + > >> static int a6xx_pm_resume(struct msm_gpu *gpu) > >> { > >> struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); > >> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > >> index 9580def06d45..aa70390ee1c6 100644 > >> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > >> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > >> @@ -89,5 +89,6 @@ struct msm_gpu_state *a6xx_gpu_state_get(struct msm_gpu *gpu); > >> int a6xx_gpu_state_put(struct msm_gpu_state *state); > >> > >> void a6xx_bus_clear_pending_transactions(struct adreno_gpu *adreno_gpu, bool gx_off); > >> +void a6xx_gpu_sw_reset(struct msm_gpu *gpu, bool assert); > >> > >> #endif /* __A6XX_GPU_H__ */ > >> > >> -- > >> 2.40.1 > >>
On 15.06.2023 22:11, Akhil P Oommen wrote: > On Thu, Jun 15, 2023 at 12:34:06PM +0200, Konrad Dybcio wrote: >> >> On 6.06.2023 19:18, Akhil P Oommen wrote: >>> On Mon, May 29, 2023 at 03:52:26PM +0200, Konrad Dybcio wrote: >>>> >>>> Introduce a6xx_gpu_sw_reset() in preparation for adding GMU wrapper >>>> GPUs and reuse it in a6xx_gmu_force_off(). >>>> >>>> This helper, contrary to the original usage in GMU code paths, adds >>>> a write memory barrier which together with the necessary delay should >>>> ensure that the reset is never deasserted too quickly due to e.g. OoO >>>> execution going crazy. >>>> >>>> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> >>>> --- >>>> drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 3 +-- >>>> drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 11 +++++++++++ >>>> drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + >>>> 3 files changed, 13 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c >>>> index b86be123ecd0..5ba8cba69383 100644 >>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c >>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c >>>> @@ -899,8 +899,7 @@ static void a6xx_gmu_force_off(struct a6xx_gmu *gmu) >>>> a6xx_bus_clear_pending_transactions(adreno_gpu, true); >>>> >>>> /* Reset GPU core blocks */ >>>> - gpu_write(gpu, REG_A6XX_RBBM_SW_RESET_CMD, 1); >>>> - udelay(100); >>>> + a6xx_gpu_sw_reset(gpu, true); >>>> } >>>> >>>> static void a6xx_gmu_set_initial_freq(struct msm_gpu *gpu, struct a6xx_gmu *gmu) >>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >>>> index e3ac3f045665..083ccb5bcb4e 100644 >>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >>>> @@ -1634,6 +1634,17 @@ void a6xx_bus_clear_pending_transactions(struct adreno_gpu *adreno_gpu, bool gx_ >>>> gpu_write(gpu, REG_A6XX_GBIF_HALT, 0x0); >>>> } >>>> >>>> +void a6xx_gpu_sw_reset(struct msm_gpu *gpu, bool assert) >>>> +{ >>>> + gpu_write(gpu, REG_A6XX_RBBM_SW_RESET_CMD, assert); >>>> + /* Add a barrier to avoid bad surprises */ >>> Can you please make this comment a bit more clear? Highlight that we >>> should ensure the register is posted at hw before polling. >>> >>> I think this barrier is required only during assert. >> Generally it should not be strictly required at all, but I'm thinking >> that it'd be good to keep it in both cases, so that: >> >> if (assert) >> we don't keep writing things to the GPU if it's in reset >> else >> we don't start writing things to the GPU becomes it comes >> out of reset >> >> Also, if you squint hard enough at the commit message, you'll notice >> I intended for this so only be a wmb, but for some reason generalized >> it.. Perhaps that's another thing I should fix! >> for v9.. > > wmb() doesn't provide any ordering guarantee with the delay loop. Hm, fair.. I'm still not as fluent with memory access knowledge as I'd like to be.. > A common practice is to just read back the same register before > the loop because a readl followed by delay() is guaranteed to be ordered. So, how should I proceed? Keep the r/w barrier, or add a readback and a tiiiny (perhaps even using ndelay instead of udelay?) delay on de-assert? Konrad > > -Akhil. >> >> Konrad >>> >>> -Akhil. >>>> + mb(); >>>> + >>>> + /* The reset line needs to be asserted for at least 100 us */ >>>> + if (assert) >>>> + udelay(100); >>>> +} >>>> + >>>> static int a6xx_pm_resume(struct msm_gpu *gpu) >>>> { >>>> struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); >>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h >>>> index 9580def06d45..aa70390ee1c6 100644 >>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h >>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h >>>> @@ -89,5 +89,6 @@ struct msm_gpu_state *a6xx_gpu_state_get(struct msm_gpu *gpu); >>>> int a6xx_gpu_state_put(struct msm_gpu_state *state); >>>> >>>> void a6xx_bus_clear_pending_transactions(struct adreno_gpu *adreno_gpu, bool gx_off); >>>> +void a6xx_gpu_sw_reset(struct msm_gpu *gpu, bool assert); >>>> >>>> #endif /* __A6XX_GPU_H__ */ >>>> >>>> -- >>>> 2.40.1 >>>>
On Thu, Jun 15, 2023 at 10:59:23PM +0200, Konrad Dybcio wrote: > > On 15.06.2023 22:11, Akhil P Oommen wrote: > > On Thu, Jun 15, 2023 at 12:34:06PM +0200, Konrad Dybcio wrote: > >> > >> On 6.06.2023 19:18, Akhil P Oommen wrote: > >>> On Mon, May 29, 2023 at 03:52:26PM +0200, Konrad Dybcio wrote: > >>>> > >>>> Introduce a6xx_gpu_sw_reset() in preparation for adding GMU wrapper > >>>> GPUs and reuse it in a6xx_gmu_force_off(). > >>>> > >>>> This helper, contrary to the original usage in GMU code paths, adds > >>>> a write memory barrier which together with the necessary delay should > >>>> ensure that the reset is never deasserted too quickly due to e.g. OoO > >>>> execution going crazy. > >>>> > >>>> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> > >>>> --- > >>>> drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 3 +-- > >>>> drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 11 +++++++++++ > >>>> drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + > >>>> 3 files changed, 13 insertions(+), 2 deletions(-) > >>>> > >>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c > >>>> index b86be123ecd0..5ba8cba69383 100644 > >>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c > >>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c > >>>> @@ -899,8 +899,7 @@ static void a6xx_gmu_force_off(struct a6xx_gmu *gmu) > >>>> a6xx_bus_clear_pending_transactions(adreno_gpu, true); > >>>> > >>>> /* Reset GPU core blocks */ > >>>> - gpu_write(gpu, REG_A6XX_RBBM_SW_RESET_CMD, 1); > >>>> - udelay(100); > >>>> + a6xx_gpu_sw_reset(gpu, true); > >>>> } > >>>> > >>>> static void a6xx_gmu_set_initial_freq(struct msm_gpu *gpu, struct a6xx_gmu *gmu) > >>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > >>>> index e3ac3f045665..083ccb5bcb4e 100644 > >>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > >>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > >>>> @@ -1634,6 +1634,17 @@ void a6xx_bus_clear_pending_transactions(struct adreno_gpu *adreno_gpu, bool gx_ > >>>> gpu_write(gpu, REG_A6XX_GBIF_HALT, 0x0); > >>>> } > >>>> > >>>> +void a6xx_gpu_sw_reset(struct msm_gpu *gpu, bool assert) > >>>> +{ > >>>> + gpu_write(gpu, REG_A6XX_RBBM_SW_RESET_CMD, assert); > >>>> + /* Add a barrier to avoid bad surprises */ > >>> Can you please make this comment a bit more clear? Highlight that we > >>> should ensure the register is posted at hw before polling. > >>> > >>> I think this barrier is required only during assert. > >> Generally it should not be strictly required at all, but I'm thinking > >> that it'd be good to keep it in both cases, so that: > >> > >> if (assert) > >> we don't keep writing things to the GPU if it's in reset > >> else > >> we don't start writing things to the GPU becomes it comes > >> out of reset > >> > >> Also, if you squint hard enough at the commit message, you'll notice > >> I intended for this so only be a wmb, but for some reason generalized > >> it.. Perhaps that's another thing I should fix! > >> for v9.. > > > > wmb() doesn't provide any ordering guarantee with the delay loop. > Hm, fair.. I'm still not as fluent with memory access knowledge as I'd > like to be.. > > > A common practice is to just read back the same register before > > the loop because a readl followed by delay() is guaranteed to be ordered. > So, how should I proceed? Keep the r/w barrier, or add a readback and > a tiiiny (perhaps even using ndelay instead of udelay?) delay on de-assert? readback + delay (similar value as downstream). This path is exercised rarely. -Akhil. > > Konrad > > > > -Akhil. > >> > >> Konrad > >>> > >>> -Akhil. > >>>> + mb(); > >>>> + > >>>> + /* The reset line needs to be asserted for at least 100 us */ > >>>> + if (assert) > >>>> + udelay(100); > >>>> +} > >>>> + > >>>> static int a6xx_pm_resume(struct msm_gpu *gpu) > >>>> { > >>>> struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); > >>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > >>>> index 9580def06d45..aa70390ee1c6 100644 > >>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > >>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > >>>> @@ -89,5 +89,6 @@ struct msm_gpu_state *a6xx_gpu_state_get(struct msm_gpu *gpu); > >>>> int a6xx_gpu_state_put(struct msm_gpu_state *state); > >>>> > >>>> void a6xx_bus_clear_pending_transactions(struct adreno_gpu *adreno_gpu, bool gx_off); > >>>> +void a6xx_gpu_sw_reset(struct msm_gpu *gpu, bool assert); > >>>> > >>>> #endif /* __A6XX_GPU_H__ */ > >>>> > >>>> -- > >>>> 2.40.1 > >>>>
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c index b86be123ecd0..5ba8cba69383 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c @@ -899,8 +899,7 @@ static void a6xx_gmu_force_off(struct a6xx_gmu *gmu) a6xx_bus_clear_pending_transactions(adreno_gpu, true); /* Reset GPU core blocks */ - gpu_write(gpu, REG_A6XX_RBBM_SW_RESET_CMD, 1); - udelay(100); + a6xx_gpu_sw_reset(gpu, true); } static void a6xx_gmu_set_initial_freq(struct msm_gpu *gpu, struct a6xx_gmu *gmu) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index e3ac3f045665..083ccb5bcb4e 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -1634,6 +1634,17 @@ void a6xx_bus_clear_pending_transactions(struct adreno_gpu *adreno_gpu, bool gx_ gpu_write(gpu, REG_A6XX_GBIF_HALT, 0x0); } +void a6xx_gpu_sw_reset(struct msm_gpu *gpu, bool assert) +{ + gpu_write(gpu, REG_A6XX_RBBM_SW_RESET_CMD, assert); + /* Add a barrier to avoid bad surprises */ + mb(); + + /* The reset line needs to be asserted for at least 100 us */ + if (assert) + udelay(100); +} + static int a6xx_pm_resume(struct msm_gpu *gpu) { struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h index 9580def06d45..aa70390ee1c6 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h @@ -89,5 +89,6 @@ struct msm_gpu_state *a6xx_gpu_state_get(struct msm_gpu *gpu); int a6xx_gpu_state_put(struct msm_gpu_state *state); void a6xx_bus_clear_pending_transactions(struct adreno_gpu *adreno_gpu, bool gx_off); +void a6xx_gpu_sw_reset(struct msm_gpu *gpu, bool assert); #endif /* __A6XX_GPU_H__ */