From patchwork Thu Dec 1 20:48:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 13061797 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9C6FC43217 for ; Thu, 1 Dec 2022 20:48:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230059AbiLAUsX (ORCPT ); Thu, 1 Dec 2022 15:48:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230034AbiLAUsW (ORCPT ); Thu, 1 Dec 2022 15:48:22 -0500 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BCE82EF44 for ; Thu, 1 Dec 2022 12:48:21 -0800 (PST) Received: by mail-qv1-xf2b.google.com with SMTP id mn15so2143650qvb.13 for ; Thu, 01 Dec 2022 12:48:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=aso5bVNku9zAYWewFCI9NL0NcJ9DRJeZDy18s0IErb4=; b=OczNBDW2ESYrVq6qf5oHFwAvcjxDnqqUpF3z/8xsdkysB/nM5RdxvQTQdVD2w/4UK/ xkV2B2eQXCqPGuu1/aOEBoLL078X+xy72EmRwUCGE3os9LveWOghxGR9ETBIWBqyjiKS 8Bb/3liGvBLGSgSl4IWqq7tn/pnA0hI0Y91VM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aso5bVNku9zAYWewFCI9NL0NcJ9DRJeZDy18s0IErb4=; b=Mroc6dazLrQ02vYmLZVPPMcU2xnh3uvJZMA5tCEz0/T5/wSiPlhZG+aZSruxWVG6hB ckOTDkq7FaRd4UtYNG9IXvTZeU9xeBt2p93SmEni0910EfAuJkpy23Dh40Z88Nk/2sya lmh7Kum6FOM/D/9LAme8tDBtgdUWb8VDNNU8W/W+1aOEZuchNO/EiOtDpPGD9na30z7P SaIQMFZ4n49MZUYDmo1C1Qh/7Z73fXbkL6koBifP8X+yKRs++gKzb6E8xFQRKL/W8Rzv 6R0y3q+4qikumGGajsAxF/xxAroE2CQn+nqns5CpDq91XLDh3bBObRIOSGQn3nP1bp3R v0bQ== X-Gm-Message-State: ANoB5pntCdWOVbGtfWWKiI3Kq2rzcR6lrN7/uPk+sLktdoKC799/82C+ XFYVO5KrkLBST0el71iI8jZZRlgGdL1gx4g4 X-Google-Smtp-Source: AA0mqf7aKhJ0Nq2h1FmelRlWpb/hRz/e2rXwhWuipChh6xhW0iZR09JmYkx15JkhbgrWrv1uLLtCCw== X-Received: by 2002:a0c:c783:0:b0:4bb:58bf:7507 with SMTP id k3-20020a0cc783000000b004bb58bf7507mr45892674qvj.96.1669927700540; Thu, 01 Dec 2022 12:48:20 -0800 (PST) Received: from joelboxx.c.googlers.com.com (228.221.150.34.bc.googleusercontent.com. [34.150.221.228]) by smtp.gmail.com with ESMTPSA id o6-20020ac85546000000b003a69225c2cdsm1561851qtr.56.2022.12.01.12.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 12:48:19 -0800 (PST) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , Rob Clark , Steven Rostedt , Ricardo Ribalda , Ross Zwisler , Abhinav Kumar , Akhil P Oommen , AngeloGioacchino Del Regno , Chia-I Wu , Daniel Vetter , David Airlie , Dmitry Baryshkov , dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Konrad Dybcio , linux-arm-msm@vger.kernel.org, Rob Clark , Sean Paul Subject: [PATCH v2] adreno: Shutdown the GPU properly Date: Thu, 1 Dec 2022 20:48:12 +0000 Message-Id: <20221201204813.1470994-1-joel@joelfernandes.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org During kexec on ARM device, we notice that device_shutdown() only calls pm_runtime_force_suspend() while shutting down the GPU. This means 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 (DT) [ 292.509872] pstate: 80400009 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 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. [ Applied Rob Clark feedback on fixing adreno_unbind() similarly, also tested as above. ] 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, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c index 24b489b6129a..c7e26659ba33 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_device.c +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c @@ -551,13 +551,14 @@ static int adreno_bind(struct device *dev, struct device *master, void *data) return 0; } +static int adreno_system_suspend(struct device *dev); static void adreno_unbind(struct device *dev, struct device *master, void *data) { struct msm_drm_private *priv = dev_get_drvdata(master); struct msm_gpu *gpu = dev_to_gpu(dev); - pm_runtime_force_suspend(dev); + WARN_ON_ONCE(adreno_system_suspend(dev)); gpu->funcs->destroy(gpu); priv->gpu_pdev = NULL; @@ -609,7 +610,7 @@ static int adreno_remove(struct platform_device *pdev) static void adreno_shutdown(struct platform_device *pdev) { - pm_runtime_force_suspend(&pdev->dev); + WARN_ON_ONCE(adreno_system_suspend(&pdev->dev)); } static const struct of_device_id dt_match[] = {