Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1034410rdd; Wed, 10 Jan 2024 06:55:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IHkShU/PwzmIXWl7s3joBzET0aBd0gRJn3IvZ/cXyFOc1FsYOE+4wW8iSfLxWgp1hysG/S9 X-Received: by 2002:a05:6808:2e93:b0:3bb:d1b2:a381 with SMTP id gt19-20020a0568082e9300b003bbd1b2a381mr1799330oib.74.1704898518003; Wed, 10 Jan 2024 06:55:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704898517; cv=none; d=google.com; s=arc-20160816; b=fDBHch7V+lGz6b0S9SzegJ7du8wRHr8oq/QpFRfJ7QmVMXY8LBGqxwMVSxendCBFPX HDEFkgcNN7VMfLKhBLb3gYzluAQgNH4x1NAtJw6PK2GJU3Bq6Ros3y+u/37ZpYiXpjBr SGz6n0gxYqiQRaXKQLZKHKOgCY02iAEOqRtMz/6qvV0iJZAUDB7s6zG9sZPRh40OqxPL 6RFk1UMrGUj2sACmoRBPKADsXiclGWzlPCPeAokNOUvVGNGHkn6H1FCDrQWtYMzAzpGy OoOodz3GzYDkd7oIHiFsIoFwlKArq68jZa4vRKXv7KHrI1Y1QNymH0JUY4usvHQGstKw 1xdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=5OgyR+ukWv0ZDFT7MD1S3e5qHTjIQxas4XOabhlAMc4=; fh=M+am4eKS0finpodyPCqa13/ZLmg88hp7kf0zsqkYD1s=; b=zo6nlYCmg+D3ehqdv6fM/mlvpHXwPWtJ5msxliRS40Ei9oPnMTsxwjylUAE8OsGU8e Mhgr2XWh+gfBb7MgfUyxeVz0rDOExGYpSfYnHTvwds46C62wy/1hNOqO0jZYWNSyj2QM +br67LwlyhBe1JMxofQYQb8EujSnge3rjRjMJa8CLHdevBGbmZe/8VS1bLQi2ns8RNkA DCtgpWjIbTkYhpcHjVdInEE4H1Tbmsci6CB0zsnhCYaq1nbMDBoplQUGxH+w1pi2Q8UI aewzhPgMVsa+44XaOe3U2tp+tSuazoq2nalRYsEEolbAJbDpeiRWz+gsa9xseWeSAXgo Rjpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Xz1tkqRl; spf=pass (google.com: domain of linux-kernel+bounces-22379-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22379-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. [147.75.199.223]) by mx.google.com with ESMTPS id s1-20020a0ce301000000b00680ce50b84bsi4460384qvl.567.2024.01.10.06.55.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 06:55:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22379-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Xz1tkqRl; spf=pass (google.com: domain of linux-kernel+bounces-22379-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22379-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 8AB491C21186 for ; Wed, 10 Jan 2024 14:55:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E5B24BA89; Wed, 10 Jan 2024 14:55:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Xz1tkqRl" Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (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 BF20B48CCE; Wed, 10 Jan 2024 14:55:07 +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-lj1-f174.google.com with SMTP id 38308e7fff4ca-2cd1232a2c7so49697731fa.0; Wed, 10 Jan 2024 06:55:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704898506; x=1705503306; darn=vger.kernel.org; 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=5OgyR+ukWv0ZDFT7MD1S3e5qHTjIQxas4XOabhlAMc4=; b=Xz1tkqRl0b3sFvvn1W1mOfJxhECpXK8wNH8ix+7RjLxjf3V5TjVjuYwjzQEyVgNPk5 2Ndf77AcgtF+cdzLf9k4IgqDPpFaXLLDS91tceQGBJnVgRTTpnB3iXjISpvxaz199XYM TcqkEwD8Dfg03wbQZLf2IZHe/JPgeocJ/LlxGyB/ZuTDNBtN6MHppwwhwG7XuB7co6he BRsSyZLNifDes11e+9eeSyg2UvTFLG695yFc1qY0JanwrUyDkHG37edEYVGBvRnxUzYz 7pyLmtJup+1zCvczCBuRloC7AT5WJzV6/n82JrBsO5BhoViN60ED2H2hL51Gnll7eQdx sC9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704898506; x=1705503306; 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=5OgyR+ukWv0ZDFT7MD1S3e5qHTjIQxas4XOabhlAMc4=; b=LrJppwqBwJIhnrMhV+PA5+vpbPevs03tqCHtdwpZzcaq5daKZy8Nk48nJnAyESqzuv qD2ceAEmZlGKP/N3ehRz8IVGyiCO7LAS5mPfrngG8knNqU1KJdBOMhrH9IU5byGohKbJ ox0pDgY+EHSP4N/ALWZIzreSv6aNkH8kbdjrfVT8D06a8WonpjjqxtOpWEZZ/Jw7xTN6 JYWgwkoX8DE3h+ZHYo6skghBmYyWPr7qLM4Neu6zNgDPuXcJiF3jXyPo7heCAY62F44I MplcOyaPW/TQAL6xmzmb4rBDQ4jpxBrfx+jrHdrFeUcb57YfRbC9sqgEIoZA5q0tI+Fs yq5w== X-Gm-Message-State: AOJu0YxDRjvie4xRYXhyqnKrwo5mKOFyvb7Ha8b13CpzNlfobm/kZALL lE0XwJ9IZ5HF+MzdLU0/lB6VSXcXLC2JdLtlA9jaJkUj X-Received: by 2002:a2e:9dd8:0:b0:2cd:16fe:da17 with SMTP id x24-20020a2e9dd8000000b002cd16feda17mr609164ljj.71.1704898505430; Wed, 10 Jan 2024 06:55:05 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240109182218.193804-1-robdclark@gmail.com> In-Reply-To: From: Rob Clark Date: Wed, 10 Jan 2024 06:54:53 -0800 Message-ID: Subject: Re: [PATCH] Revert "drm/msm/gpu: Push gpu lock down past runpm" To: Rob Clark , dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , open list Cc: Daniel Vetter Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jan 10, 2024 at 2:50=E2=80=AFAM Daniel Vetter wro= te: > > On Tue, Jan 09, 2024 at 10:22:17AM -0800, Rob Clark wrote: > > From: Rob Clark > > > > This reverts commit abe2023b4cea192ab266b351fd38dc9dbd846df0. > > > > Changing the locking order means that scheduler/msm_job_run() can race > > with the recovery kthread worker, with the result that the GPU gets an > > extra runpm get when we are trying to power it off. Leaving the GPU in > > an unrecovered state. > > The recovery kthread is supposed to stop all the relevant schedulers, > which should remove any possible race conditions. So unless there's more > going on, or you have your own recovery kthread (don't, reuse the one fro= m > the scheduler with your own work items, that's why you can provide that) > this looks like an incomplete/incorrect explanation ... ? > > Slightly confused msm still uses it's own recovery, which pre-dates the scheduler conversion. At one point (a yr or two back?) I started looking at integrating recovery w/ scheduler.. at the time I think you talked me out of it, but I don't remember the reason BR, -R > -Sima > > > > > I'll need to come up with a different scheme for appeasing lockdep. > > > > Signed-off-by: Rob Clark > > --- > > drivers/gpu/drm/msm/msm_gpu.c | 11 +++++------ > > drivers/gpu/drm/msm/msm_ringbuffer.c | 7 +++++-- > > 2 files changed, 10 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gp= u.c > > index 095390774f22..655002b21b0d 100644 > > --- a/drivers/gpu/drm/msm/msm_gpu.c > > +++ b/drivers/gpu/drm/msm/msm_gpu.c > > @@ -751,12 +751,14 @@ void msm_gpu_submit(struct msm_gpu *gpu, struct m= sm_gem_submit *submit) > > struct msm_ringbuffer *ring =3D submit->ring; > > unsigned long flags; > > > > - pm_runtime_get_sync(&gpu->pdev->dev); > > + WARN_ON(!mutex_is_locked(&gpu->lock)); > > > > - mutex_lock(&gpu->lock); > > + pm_runtime_get_sync(&gpu->pdev->dev); > > > > msm_gpu_hw_init(gpu); > > > > + submit->seqno =3D submit->hw_fence->seqno; > > + > > update_sw_cntrs(gpu); > > > > /* > > @@ -781,11 +783,8 @@ void msm_gpu_submit(struct msm_gpu *gpu, struct ms= m_gem_submit *submit) > > gpu->funcs->submit(gpu, submit); > > gpu->cur_ctx_seqno =3D submit->queue->ctx->seqno; > > > > - hangcheck_timer_reset(gpu); > > - > > - mutex_unlock(&gpu->lock); > > - > > pm_runtime_put(&gpu->pdev->dev); > > + hangcheck_timer_reset(gpu); > > } > > > > /* > > diff --git a/drivers/gpu/drm/msm/msm_ringbuffer.c b/drivers/gpu/drm/msm= /msm_ringbuffer.c > > index e0ed27739449..548f5266a7d3 100644 > > --- a/drivers/gpu/drm/msm/msm_ringbuffer.c > > +++ b/drivers/gpu/drm/msm/msm_ringbuffer.c > > @@ -21,8 +21,6 @@ static struct dma_fence *msm_job_run(struct drm_sched= _job *job) > > > > msm_fence_init(submit->hw_fence, fctx); > > > > - submit->seqno =3D submit->hw_fence->seqno; > > - > > mutex_lock(&priv->lru.lock); > > > > for (i =3D 0; i < submit->nr_bos; i++) { > > @@ -35,8 +33,13 @@ static struct dma_fence *msm_job_run(struct drm_sche= d_job *job) > > > > mutex_unlock(&priv->lru.lock); > > > > + /* TODO move submit path over to using a per-ring lock.. */ > > + mutex_lock(&gpu->lock); > > + > > msm_gpu_submit(gpu, submit); > > > > + mutex_unlock(&gpu->lock); > > + > > return dma_fence_get(submit->hw_fence); > > } > > > > -- > > 2.43.0 > > > > -- > Daniel Vetter > Software Engineer, Intel Corporation > http://blog.ffwll.ch