Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1251000rwb; Thu, 1 Dec 2022 14:41:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf7c165JYeFd58JsNPvWu6by0nC1zI4qJwvl+iDZWRwKuzhJXsRk5DqPtByRB7T/9aDkKzFz X-Received: by 2002:a17:907:8c83:b0:7bf:4ac7:56e4 with SMTP id td3-20020a1709078c8300b007bf4ac756e4mr19969401ejc.39.1669934503632; Thu, 01 Dec 2022 14:41:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669934503; cv=none; d=google.com; s=arc-20160816; b=yVi/SLvQIcuxXhCPyWZTtAIKPsYLRcrg48exBuom7r/hVvERs7d9AS+Hngg71CYHsa dfDQwy2ONX/dyXPMTOHugLqq1Ffhb03EauzX25qfKXJrO6RD1/hb/hYs4ETH030fKAdF UaUvDpHrDb0yJ+b1Frvg6Jpv3frAFZIJeVlZpaOjE22GHko9kT7yplJGfhqfnMJ02jGT 3nQvVD1293iRiroSm0ghC+mGttJ1eboasjjrdwIaEjRituxd0IWqHNoTzPZ0/eMFueaI 1ZvRlOaY7j4ocBy9NPMMKh4sc+S8BkQIHkQ0KBQV37eLyl7tlMRFHgh4bIFeMfgZnHxF 6j7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=W8nagVbuaNHLhZ29xOS6z3E+sbAaAnKmi0Qsg9Sjib8=; b=gexgJS+4rKokvPBvZNWtKtUPzcofFSTGbXLg5dnCNKFtIu32I4Ss9jRf9vgGr5YFR2 OscfICMyg9M4AzG+COdQvO++Rq3MTWvir9CuDUAZikTbdS+G2yNui59/1TQ1bRVKYLW8 ENHAVQyko4QhDYnhGMTXW1MkvXlWG7U2sU/aeGNQoe/rcnpy5kmune64dcIoTvvvD8lw fRvuhzLw5Xb1zr6g5Nv2i+rTPJGNSJt0lwVZaqb0SrE/QFTgJKpw7wgvxGhHVpXdklUF 1l72PuIPp9FPHcnnumX7EiU3ilC6wQBXK/GL1zqvcxCM+rm8HkEPdw5hrRgXxVqRC9WT MAZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=Yz9VRD8p; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z16-20020a05640235d000b00458b42ff418si5060450edc.221.2022.12.01.14.41.23; Thu, 01 Dec 2022 14:41:43 -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=@joelfernandes.org header.s=google header.b=Yz9VRD8p; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231179AbiLAWOE (ORCPT + 81 others); Thu, 1 Dec 2022 17:14:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231312AbiLAWNg (ORCPT ); Thu, 1 Dec 2022 17:13:36 -0500 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C2438FD5D for ; Thu, 1 Dec 2022 14:13:29 -0800 (PST) Received: by mail-lj1-x231.google.com with SMTP id x6so3452438lji.10 for ; Thu, 01 Dec 2022 14:13:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=W8nagVbuaNHLhZ29xOS6z3E+sbAaAnKmi0Qsg9Sjib8=; b=Yz9VRD8psXuVmSUKSqb9AiKRgnp4d/NkPwe/89vQLzZjtZojLijiRloiDR5iPfBYc9 SE1Ls1fTSE9Jq3YRxyaOU0jWJHdQqZ+JYRu3ZBNziWepLcWweRViCfUugMnS0mGKJRgG O/YxW1XiyRItOROkg4bOzn+EmxxJ3g+OEWjls= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W8nagVbuaNHLhZ29xOS6z3E+sbAaAnKmi0Qsg9Sjib8=; b=QwUOPkT4SL7UVwDtlsyznx5sVizG2YTQsW2Ghcnd8Km+xEg4kmOwb4/5pr4sazVmo3 AmDASUwSfxEgV96yVhSnTkkd8zXjaw4u+cg/oK1G/dkhmprpfwqbO63UFV7eawpgqENS s03ML5CZp4FG7bSGxMV+aC398LRCVkZPlnkrn7JatbrKm0UYiFIhK0RrzdsKr4jkW5V9 Nk+pstIr68r4gw7hkZ7TvnUTPQtErQI25goLLqFtwmGLUY/EPlqFJWnchGu0cjuwRBou bn/XP9StfwkVCYwrwr0T6nMwSuDpXrOXkrOZFW7aLSaXn6S+gT0u+NxhfEa4NiX+A9h5 BC4Q== X-Gm-Message-State: ANoB5pnYmNUUT0kZMTQz3p4pD3jnr8x359/fut4BGkmvjCPS13TGAvwH E+cWCM+cuqsiDQfFA3bE4TnAFzAu8hG9O+BrItmxdQ== X-Received: by 2002:a2e:a4b4:0:b0:26c:5cf3:cc89 with SMTP id g20-20020a2ea4b4000000b0026c5cf3cc89mr22456603ljm.483.1669932808038; Thu, 01 Dec 2022 14:13:28 -0800 (PST) MIME-Version: 1.0 References: <20221111194957.4046771-1-joel@joelfernandes.org> In-Reply-To: From: Joel Fernandes Date: Thu, 1 Dec 2022 22:13:16 +0000 Message-ID: Subject: Re: [PATCH 1/2] adreno: Shutdown the GPU properly To: Rob Clark Cc: linux-kernel@vger.kernel.org, Rob Clark , Steven Rostedt , Ricardo Ribalda , Ross Zwisler , Abhinav Kumar , Akhil P Oommen , Daniel Vetter , David Airlie , Dmitry Baryshkov , dri-devel@lists.freedesktop.org, Emma Anholt , freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Sean Paul , Vladimir Lypak Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=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 Thu, Dec 1, 2022 at 10:06 PM Rob Clark wrote: > > On Thu, Dec 1, 2022 at 12:08 PM Joel Fernandes w= rote: > > > > On Sat, Nov 12, 2022 at 6:44 PM Rob Clark wrote: > > > > > > On Fri, Nov 11, 2022 at 1:08 PM Joel Fernandes wrote: > > > > > > > > > > > > > > > > > On Nov 11, 2022, at 2:50 PM, Joel Fernandes (Google) wrote: > > > > > > > > > > =EF=BB=BFDuring kexec on ARM device, we notice that device_shutdo= wn() only calls > > > > > pm_runtime_force_suspend() while shutting down the GPU. This mean= s the GPU > > > > > kthread is still running and further, there maybe active submits. > > > > > > > > > > This causes all kinds of issues during a kexec reboot: > > > > > > > > > > Warning from shutdown path: > > > > > > > > > > [ 292.509662] WARNING: CPU: 0 PID: 6304 at [...] adreno_runtime_= suspend+0x3c/0x44 > > > > > [ 292.509863] Hardware name: Google Lazor (rev3 - 8) with LTE (D= T) > > > > > [ 292.509872] pstate: 80400009 (Nzcv daif +PAN -UAO -TCO -DIT -S= SBS BTYPE=3D--) > > > > > [ 292.509881] pc : adreno_runtime_suspend+0x3c/0x44 > > > > > [ 292.509891] lr : pm_generic_runtime_suspend+0x30/0x44 > > > > > [ 292.509905] sp : ffffffc014473bf0 > > > > > [...] > > > > > [ 292.510043] Call trace: > > > > > [ 292.510051] adreno_runtime_suspend+0x3c/0x44 > > > > > [ 292.510061] pm_generic_runtime_suspend+0x30/0x44 > > > > > [ 292.510071] pm_runtime_force_suspend+0x54/0xc8 > > > > > [ 292.510081] adreno_shutdown+0x1c/0x28 > > > > > [ 292.510090] platform_shutdown+0x2c/0x38 > > > > > [ 292.510104] device_shutdown+0x158/0x210 > > > > > [ 292.510119] kernel_restart_prepare+0x40/0x4c > > > > > > > > > > And here from GPU kthread, an SError OOPs: > > > > > > > > > > [ 192.648789] el1h_64_error+0x7c/0x80 > > > > > [ 192.648812] el1_interrupt+0x20/0x58 > > > > > [ 192.648833] el1h_64_irq_handler+0x18/0x24 > > > > > [ 192.648854] el1h_64_irq+0x7c/0x80 > > > > > [ 192.648873] local_daif_inherit+0x10/0x18 > > > > > [ 192.648900] el1h_64_sync_handler+0x48/0xb4 > > > > > [ 192.648921] el1h_64_sync+0x7c/0x80 > > > > > [ 192.648941] a6xx_gmu_set_oob+0xbc/0x1fc > > > > > [ 192.648968] a6xx_hw_init+0x44/0xe38 > > > > > [ 192.648991] msm_gpu_hw_init+0x48/0x80 > > > > > [ 192.649013] msm_gpu_submit+0x5c/0x1a8 > > > > > [ 192.649034] msm_job_run+0xb0/0x11c > > > > > [ 192.649058] drm_sched_main+0x170/0x434 > > > > > [ 192.649086] kthread+0x134/0x300 > > > > > [ 192.649114] ret_from_fork+0x10/0x20 > > > > > > > > > > Fix by calling adreno_system_suspend() in the device_shutdown() p= ath. > > > > > > > > > > Cc: Rob Clark > > > > > Cc: Steven Rostedt > > > > > Cc: Ricardo Ribalda > > > > > Cc: Ross Zwisler > > > > > Signed-off-by: Joel Fernandes (Google) > > > > > --- > > > > > drivers/gpu/drm/msm/adreno/adreno_device.c | 5 ++++- > > > > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > > > > > > > diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers= /gpu/drm/msm/adreno/adreno_device.c > > > > > index 24b489b6129a..f0cff62812c3 100644 > > > > > --- a/drivers/gpu/drm/msm/adreno/adreno_device.c > > > > > +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c > > > > > @@ -607,9 +607,12 @@ static int adreno_remove(struct platform_dev= ice *pdev) > > > > > return 0; > > > > > } > > > > > > > > > > +static int adreno_system_suspend(struct device *dev); > > > > > static void adreno_shutdown(struct platform_device *pdev) > > > > > { > > > > > - pm_runtime_force_suspend(&pdev->dev); > > > > > + struct msm_gpu *gpu =3D dev_to_gpu(&pdev->dev); > > > > > + > > > > > > > > This local variable definition should go to patch 2/2. Will fix in = v2. > > > > > > > > Thanks, > > > > > > > > - Joel > > > > > > > > > > > > > + WARN_ON_ONCE(adreno_system_suspend(&pdev->dev)); > > > > > > I think maybe adreno_unbind() needs the same treatment? Any path > > > where we yank out the power cord without ensuring the scheduler is > > > parked means we'd be racing with jobs in the scheduler queue. Ie. > > > userspace could queue a job before it is frozen, but the drm/schedule= r > > > kthread hasn't yet called the msm_job_run() callback (which does > > > various touching of the now powered off hw). So I think we need to > > > ensure that the scheduler is parked in all paths that call > > > pm_runtime_force_suspend() (as that bypasses the runpm reference that > > > would otherwise unsure the hw is powered before msm_job_run pokes at > > > registers) > > > > a6xx_gmu_remove() calls pm_runtime_force_suspend() , would that need a > > treatment too? > > > > Though, adreno_system_suspend() is a static function in adreno_device.c= c > > Naw, you get there indirectly from adreno_unbind() Ah gotcha, thanks. - Joel