Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1097517rwb; Thu, 1 Dec 2022 12:19:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf5LYcRPPYHojPJUtB/TD5JDPBdWwqIOvECvXDRMO1OcwDN69NYy1WIxmTQdGj2NHvyv+dM1 X-Received: by 2002:a17:906:a084:b0:7bd:f57f:76a4 with SMTP id q4-20020a170906a08400b007bdf57f76a4mr22259090ejy.413.1669925987888; Thu, 01 Dec 2022 12:19:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669925987; cv=none; d=google.com; s=arc-20160816; b=0bI/g8vllJHUfAa7DQTQiT7q3JMtEysxgU+xYGwmy44w3oX1Gn/zLEo1NJbgdkj2QS MbZ8QI16RhJlWkc1rBMDYHRpoGusxqzhAEky2GY7M9bLU+5Rj+1loRHvx3ICWBiil9L/ JRSeBofgOhSUjXJRGhRuD8jHTTyo123cniJKpFvUagKOS0vLCQf7ooBHhEW/v9NXBEPs b4wegF7E9N0bFwRbkU+TbYV3fdqEb9BO8b6IF4eMYD9X2dRhE6487/GF6Kv/xrti2/yl wZwK+ofJ1ejysxyQju+DpbofpZHc4iRaZeHscjLkqeTsUm7br9oKn+3Oj/FMhd0VIdm1 s/XA== 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=8rvAyrz2we2hjJpmdyVxhVn03GUPZL+2N0BOj4UW05o=; b=i3wUCRs0mZxE1dE60hqxUi7U8e0dfUKnogWU83JONpJtW8xCQJZ/yplc0G8CxK7l6F E5WWlK+rpkdAUPGL9SLhABVD5S37N93/2R1g6xH7Wt5Hukwq+N6nnxVp/oTFnA+iFXQt off0kleXBS+EpVKMy8WMKWgtcoThdx1Fi4/6U6F7GQLfFacNpnoyGT6XNFU7ejmDdjMN Zy7KSPpup/ezn4j1TZEFBvAHoXU3QWqylXTbWQCUmYP7/aknCAPaj4YCIoiH9kk/RRj5 Cuu+5+vbScdaX9tIZXQY9sx45Q5T0lkCmDsIN4s3+IUtrjnXBK47CgNOpii/wJ02cYjt T+/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=FwXAqxfQ; 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 y9-20020a056402270900b00456964d3369si4555554edd.230.2022.12.01.12.19.27; Thu, 01 Dec 2022 12:19:47 -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=FwXAqxfQ; 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 S230043AbiLAUIv (ORCPT + 82 others); Thu, 1 Dec 2022 15:08:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230420AbiLAUIu (ORCPT ); Thu, 1 Dec 2022 15:08:50 -0500 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 734D0BEC67 for ; Thu, 1 Dec 2022 12:08:49 -0800 (PST) Received: by mail-lj1-x234.google.com with SMTP id r8so3133122ljn.8 for ; Thu, 01 Dec 2022 12:08:49 -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=8rvAyrz2we2hjJpmdyVxhVn03GUPZL+2N0BOj4UW05o=; b=FwXAqxfQDTxo6xqyP7f7q1CiX6iIY7QorQvxT0hH7/gvRi7q1yERcIK+c6f/2VA9zm gVZ07BH/WcYMGuVutO71oAci8ifQZjMzYEVu6Vaf4ArbJYoFKIjCNc9ywi8pYWkyUHhy IuN/bxolCuprH6D1g1RRN2ALm80E8WPHud6sk= 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=8rvAyrz2we2hjJpmdyVxhVn03GUPZL+2N0BOj4UW05o=; b=tLmFTcMD/kTnVwDENF/0w7Z1NghKE6EKmeYVJFfSQvT9C3lHDqt28c7s520WiU8M2Q Oiv80cEUMBUC/GDMwGvWmm1XBe/3Z6hosFsxVWUraqjeXAkaVKLl/k9s6orplb/3uvJ7 FkwM3gbWL/g1lTFIJWabfVGj6uBsR6+OTaV4MgKZsvRA7k5lQoh/aHDOxlfCbSiTg72D GDrAj2sDKO0N7axiVPO397lIz4Jbx83BKyjDVPBQoqq3DyUSIejKCvi+zG/CSyGWDNi/ AQJ+ClqWPeW8Q5wVEz7GlQLGm4MlbCwIn/Wr1aLAhN4T8y2VprAKeheCtxD69nbPqB0I Brow== X-Gm-Message-State: ANoB5pkT1ErFXAtk15MYxWeVWNHHosWh7WD5Pp1VEZFPHdQD82ak42Fy TdNCAp/qBh5MUXfyEUswUCnBX5OZBJDWuCbrEx9Jww== X-Received: by 2002:a05:651c:906:b0:279:1349:b2e2 with SMTP id e6-20020a05651c090600b002791349b2e2mr20903434ljq.382.1669925327829; Thu, 01 Dec 2022 12:08:47 -0800 (PST) MIME-Version: 1.0 References: <20221111194957.4046771-1-joel@joelfernandes.org> In-Reply-To: From: Joel Fernandes Date: Thu, 1 Dec 2022 20:08:36 +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 Sat, Nov 12, 2022 at 6:44 PM Rob Clark wrote: > > On Fri, Nov 11, 2022 at 1:08 PM Joel Fernandes w= rote: > > > > > > > > > On Nov 11, 2022, at 2:50 PM, Joel Fernandes (Google) wrote: > > > > > > =EF=BB=BFDuring kexec on ARM device, we notice that device_shutdown()= only calls > > > pm_runtime_force_suspend() while shutting down the GPU. This means th= e 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_susp= end+0x3c/0x44 > > > [ 292.509863] Hardware name: Google Lazor (rev3 - 8) with LTE (DT) > > > [ 292.509872] pstate: 80400009 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS = 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() path. > > > > > > 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_device = *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/scheduler > 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.cc Thanks.