Received: by 2002:a05:7412:8d06:b0:f9:332d:97f1 with SMTP id bj6csp23951rdb; Mon, 18 Dec 2023 08:00:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IGf+6nFxC43rhh9PpkgTeXDMctjzYvOUmWAEuPyfoSvgzEWA/AVX2hpTcIn1pPiyNVs9K/O X-Received: by 2002:a05:620a:261b:b0:77f:375b:903d with SMTP id z27-20020a05620a261b00b0077f375b903dmr20315120qko.71.1702915234303; Mon, 18 Dec 2023 08:00:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702915234; cv=none; d=google.com; s=arc-20160816; b=ynscFTK3V71JXKFFrzVQU9ebFZlJCApIAr6zp+zc147rQzgksV4wAFABs397FnlZKS O1MHio/Hxpj5ZHGHN6taYvDeF2ZYtK/KlNjc6dA6k5+rfPh4zEKCsQW7OeX5G5sLQIa8 jWYdsSNvxjZdJY7p2Rz8NT6rKO/k4KK0XrZltiIExqkir3MQCV1qC+leVGU7dovhLnx/ VuAAoJo0J9vrkQk6Qzk0HC3/DjBxvweoBy+JaUc+QZJUgwBKeldOVyEVv5YOz2yy4J1T 31lHv9Y7O/ayJ6n8Ms5nVP78ZQiX/A0CElGObpempc8IwJVgqihTJ4bgQEzeR3ss4/rg PaVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=X5RGGPLxL7RmqDldU4zVC+vRt1k5TON9j6VLsGbzQWQ=; fh=6xdmhNNSU+6EehOe8s60dwTS908uUpu6J98h32sibSs=; b=xZ2qUcTF6H2w1cjLY8C/rtIi+2rLxwTnvsgTVdB1fidxTcSfbRh/YtMxQ3P9gol7Kt rURNGtN4XY3UV1XjRq8NUUYpkERGhL78YanpPpHbDjaskMeWBCe7ydV8tXS1DNYSfor1 KOQNK5bsc6ys1I5kHOuoL2tLa4wIi0zlFU2lsGPpR75hpFCyHr4gTtEkZjUeGgqDPJan ADzEfUmQg9jDmx+TTt6DZIqzwBTfLetKsgUsETmocZNmwNot01TXulg1cvp4cKVPNqbs hmffuRh3N3YsvsD6US/Kem/JaQVqqynOw6LCN5wcH/4Fey54VEXRTpo+KjPe2umVJUVa lY/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XwxmF33H; spf=pass (google.com: domain of linux-kernel+bounces-4005-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4005-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f1-20020a05620a12e100b0077f06294fd1si22612497qkl.524.2023.12.18.08.00.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 08:00:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4005-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XwxmF33H; spf=pass (google.com: domain of linux-kernel+bounces-4005-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4005-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C625E1C216DC for ; Mon, 18 Dec 2023 16:00:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7189142390; Mon, 18 Dec 2023 15:59:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XwxmF33H" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FD093D546; Mon, 18 Dec 2023 15:59:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-5cd870422c8so467076a12.0; Mon, 18 Dec 2023 07:59:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702915175; x=1703519975; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=X5RGGPLxL7RmqDldU4zVC+vRt1k5TON9j6VLsGbzQWQ=; b=XwxmF33HwQigmDruhBCU8ErAmTBN4SfuYJBclrU4HfBruz5mGtS+MHbHvMK+JNNIqd kXL1BWknMhgM5sYHq2u5IUDhmk+qodhsn7+naOEDdoG31kyASMK5ZePG2fXfaK7L5Lbo NrobTXrVTyBnWFBjYwzWosY3Xv1rqka3PEA6ArRhmAEjvi11o6OWNERoHGC3Ft/f1IOG ozVWXe63E7lzgES8oPDsdFt7iOpt0mbLfpw6AHVFSDpNH96SA18A0l++L0LP+sQnHW6/ SUal4T5KmA8sUxaiYIXGP44/kB2fpL3JZUT/JJBXAjsbslN7q1BHkqn2sjz1e3q11VNz shgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702915175; x=1703519975; 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=X5RGGPLxL7RmqDldU4zVC+vRt1k5TON9j6VLsGbzQWQ=; b=xGGmiqqvyzd6wxxSwslPEMFQGZ5y1esqBofENcN4oJds0vv1tA/eS6KGBdS4sp/2cV StMKRRqPYx0bse/+JF9xi3CXe7aFUWVwewrFIvAwoFpV5rssioI3UGwHP28Tzy0wZrqY Hl2hKF9eoyWjWCnRiLat8ceirawQT7DLSkqEj0ZZEhqpB5Kgw53swcSioTnzTSQpfV3T bsbToParXveqcpuHUIOIzttoepU2X5aHeNq6e51JqvHOiDI65t4uYtCfPWSYjKuIescV /hlxlAL9Pef6xAPDc+wIVaZ5hwq03mquw8E9HpUnuSnPoqR6M/cKrCpZE36ELDrVD+uc T9Qg== X-Gm-Message-State: AOJu0Yxori0xTQBIzlkOSDtEIeIsAfXffK4o1H8NPtxtEeimI8xJELBF 8VV5e2VqFvwFzz4+N+v6i6A= X-Received: by 2002:a17:90a:bb04:b0:280:cd7b:1fa5 with SMTP id u4-20020a17090abb0400b00280cd7b1fa5mr6789760pjr.4.1702915175541; Mon, 18 Dec 2023 07:59:35 -0800 (PST) Received: from localhost ([2a00:79e1:2e00:1301:e1c5:6354:b45d:8ffc]) by smtp.gmail.com with ESMTPSA id pb7-20020a17090b3c0700b0028aea6c24bcsm6535129pjb.53.2023.12.18.07.59.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 07:59:34 -0800 (PST) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Rob Clark , David Heidelberg , Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Konrad Dybcio , Akhil P Oommen , Danylo Piliaiev , Bjorn Andersson , linux-kernel@vger.kernel.org (open list) Subject: [PATCH] drm/msm/a6xx: Fix recovery vs runpm race Date: Mon, 18 Dec 2023 07:59:24 -0800 Message-ID: <20231218155927.368881-1-robdclark@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Rob Clark a6xx_recover() is relying on the gpu lock to serialize against incoming submits doing a runpm get, as it tries to temporarily balance out the runpm gets with puts in order to power off the GPU. Unfortunately this gets worse when we (in a later patch) will move the runpm get out of the scheduler thread/work to move it out of the fence signaling path. Instead we can just simplify the whole thing by using force_suspend() / force_resume() instead of trying to be clever. Reported-by: David Heidelberg Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10272 Fixes: abe2023b4cea ("drm/msm/gpu: Push gpu lock down past runpm") Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index 268737e59131..a5660d63535b 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -1244,12 +1244,7 @@ static void a6xx_recover(struct msm_gpu *gpu) dev_pm_genpd_add_notifier(gmu->cxpd, &gmu->pd_nb); dev_pm_genpd_synced_poweroff(gmu->cxpd); - /* Drop the rpm refcount from active submits */ - if (active_submits) - pm_runtime_put(&gpu->pdev->dev); - - /* And the final one from recover worker */ - pm_runtime_put_sync(&gpu->pdev->dev); + pm_runtime_force_suspend(&gpu->pdev->dev); if (!wait_for_completion_timeout(&gmu->pd_gate, msecs_to_jiffies(1000))) DRM_DEV_ERROR(&gpu->pdev->dev, "cx gdsc didn't collapse\n"); @@ -1258,10 +1253,7 @@ static void a6xx_recover(struct msm_gpu *gpu) pm_runtime_use_autosuspend(&gpu->pdev->dev); - if (active_submits) - pm_runtime_get(&gpu->pdev->dev); - - pm_runtime_get_sync(&gpu->pdev->dev); + pm_runtime_force_resume(&gpu->pdev->dev); gpu->active_submits = active_submits; mutex_unlock(&gpu->active_lock); -- 2.43.0