Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp899069rwd; Thu, 15 Jun 2023 03:47:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4LsIpxCH+vyvZhy5cVDUCGaKjJsTcSrQCIvZpPe00k1Ek0Dv6d5DDAGgLF8DOlMrzQtEAh X-Received: by 2002:a05:6a20:3ca8:b0:11a:3c7:b752 with SMTP id b40-20020a056a203ca800b0011a03c7b752mr5199238pzj.25.1686826020862; Thu, 15 Jun 2023 03:47:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686826020; cv=none; d=google.com; s=arc-20160816; b=qFtrTnDQ7j33mln6g8iPEHi1zce9qY2Md7d7vgIbeQDNrrM749MZiJ3sYZLbodJyG4 u6X0eVCvMLiS9veFlgcEiZERVUB55oN299prwSJVDHPQMJ8bCvE/IU81wjOGfh7NNeK9 ugaKDzCRFw5sDZkV0Mh8dnYaNBlkSlzudRxeUWpjOxz/6lhWJaVMWEgpoFFbsh+YAKCk 8+4mfH0S0qyOjs6dQSwxNjm8W2x0GoxQwcrzOKFruNgMhWmpU4XOK8yICmleLgguC7HC Uni/B9/ZFLmpvU2oBJL4o3jS29F3OOu1cRLjoJkf8v3NhAyGHRS+zsCplNyPblzvupMf atDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=G8QVs6IFYYIXBUDr6PLIM4vaEwCL0Jet3wwAQMko+hY=; b=o/TZeyGQcV8HNleVMRWW2IPZeGwT7AgSqWyD6ac7QeF5GYRGXgAKJUZNC4Xl6AWO+q bMSQwXEzV5HP+PzSSFYjhSxmW1RHf8n/dSfH54Zjf91GhbkdNm33l5nA6UQHPty+Hgyc 1DokPFcmllSV4Vv36t3Ed5dv4UbUYa5X4Ow0FllQ7qpOKEHnZKwf9uHwiTUxkyvV5Mf1 OKDProfIx9B5o3XjKNNg5JakZG/Z1hheCHj3dxgK08M/Sq++DFHI/6esVb4AgveFNIYJ Pm3NWDCuJl6m8oA8ka3vFYbLaDic+l1bB9XHDDny+vL450++ST2ReH70Ifc1O/0aEsHX 7u5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TYyKQmV+; 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 l189-20020a6388c6000000b0054fde1c2a9bsi2491588pgd.791.2023.06.15.03.46.49; Thu, 15 Jun 2023 03:47:00 -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=TYyKQmV+; 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 S245757AbjFOKfi (ORCPT + 99 others); Thu, 15 Jun 2023 06:35:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245538AbjFOKec (ORCPT ); Thu, 15 Jun 2023 06:34:32 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 257952942 for ; Thu, 15 Jun 2023 03:34:11 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-4f74cda5f1dso5808326e87.3 for ; Thu, 15 Jun 2023 03:34:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686825249; x=1689417249; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=G8QVs6IFYYIXBUDr6PLIM4vaEwCL0Jet3wwAQMko+hY=; b=TYyKQmV+8Q/wxVs6R4Uml9i+kL0onsHJpSQ0m6cvTbJwiGniH59jYx9ptbp1qn4JTJ dLawg1a0MgiGEVc5U/pvgihrz4Ze+rTI0ZlsTa7Mej+zmR77v7uW4E72/Ti47A0W/r9S lKzZP6PjJcb5gDqRq0hFSZQ02CkRPOMOkzACI5/YxwoXOoiY3EkjqkFU1MNzkwgCKadN gc1UUlvAdKDSD/npgg5kYy6Y2lsmSxgijCaDxu9Q6vbXuB/2JorDHOovJsw3q7uwJd20 RwgPz6wh+5aW7CU9r6MhABb1/4jZdcPwMUZFnmLESeBBAz2X9xk2Y+CXmldi+T/w0lnS GfTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686825249; x=1689417249; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=G8QVs6IFYYIXBUDr6PLIM4vaEwCL0Jet3wwAQMko+hY=; b=FeaI+ilXO9PIjBIKtdgQGvcY5VD2ui8cpnwNhAN73YuhLGpag+45DqeUMzCwKo60Pa apI25lRVxMMSKtalFLGHo/ZqIIetjl9053eG/jyO1CWI7y8haISoZbKGQ0jEtaS9bBbz WeMZz1u2t+XHuQcZCoJGbj7b7fQggRLdH5z2UlVKs3t6oo/SjeLLrCRbRm1PjcvEgnHx UVoLEiOrZdANP0XSPdf3jzpG0xixB64rExqyyxXI706uCI0rst618xWWtQyo29U6KBV8 rHApXu9kRR94hZ2ZVLtj30nTRyZkZvzAvUlKIdT35h5sbPM9PHUO+WTxcvgK3hXwYieQ 2DXw== X-Gm-Message-State: AC+VfDyADoEzCogxVkID5bN85UOdM2OkLEaj2mFzYmTpqyWaDJ0N+AM8 6a5rFQwAVMwh4TCI9Xzt1iw6WQ== X-Received: by 2002:a19:651a:0:b0:4f7:69a9:b882 with SMTP id z26-20020a19651a000000b004f769a9b882mr2538888lfb.3.1686825249292; Thu, 15 Jun 2023 03:34:09 -0700 (PDT) Received: from [192.168.1.101] (abyj190.neoplus.adsl.tpnet.pl. [83.9.29.190]) by smtp.gmail.com with ESMTPSA id u26-20020ac243da000000b004f4d5003e8dsm2505864lfl.7.2023.06.15.03.34.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Jun 2023 03:34:08 -0700 (PDT) Message-ID: <001d7571-5e9f-4f60-f6d0-35806a3e51c5@linaro.org> Date: Thu, 15 Jun 2023 12:34:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [PATCH v8 07/18] drm/msm/a6xx: Add a helper for software-resetting the GPU Content-Language: en-US To: Akhil P Oommen Cc: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Bjorn Andersson , Konrad Dybcio , Conor Dooley , 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 References: <20230223-topic-gmuwrapper-v8-0-69c68206609e@linaro.org> <20230223-topic-gmuwrapper-v8-7-69c68206609e@linaro.org> From: Konrad Dybcio In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 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 >> --- >> 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 >>