Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp894817rdd; Wed, 10 Jan 2024 02:51:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IGcNB4pArnoHnB1inUDpAXgB2BN2wCin1fT9jike6LocviR5ItSwU3Qw3hllThKVAevOjKH X-Received: by 2002:a05:622a:3cf:b0:429:bb88:6f1f with SMTP id k15-20020a05622a03cf00b00429bb886f1fmr190878qtx.131.1704883880031; Wed, 10 Jan 2024 02:51:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704883880; cv=none; d=google.com; s=arc-20160816; b=lwcu5OesnZazcpMAD3lGYIcflQRXXQ3CfGN38SLGhuIDpAlAxsLYUeP84YGUuWYK5w 4yxx35LehA2aonHljcc8bIVgvbKa2KDQ3ejFVdlshGzMPNw8/62fqNDi4e4BMbmROKu1 FCJU0pUkImtSurXasaBiBNFTM/knYCgwm+rbKe9bMCBzatJTURUpKpytIWJzB8vAph6e vT5zezkGsnhJGkxunNocbJU6TYZCqj9BojXha8M02kSUJON0uipn5qBv0ijASBS0K+5y +ABOBoRyrfkiMMBRXbw5362ZUKPmd56LpNqmNv5LLJCyLrnq41Thzc7ttKXIL3VKkro8 c9lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=pMG+VgwiuImv+J4aaZoTzNj8WyK0Rb5bzsnLEuXbNa0=; fh=hJgkhbamHfhUyhRiskI7hLBDT5ZMpi/t/VsveCAt68E=; b=FSoi+uT/13O3GBeRsSuZInMzD1ScnlhxVMPnTaP/ldymZ6TiwxGF5jESN++1MF19rG ZdFjq15qLoOJzYierAzrd+bdVq01bx45LWu/W7BMW8her8XhcowmpxE63Z5N/XiPRR6O ezFvWk4RSQW77avvprT3+iYO/MlfuQRintJIlDXoBJgsgMl/gwlkpzAty+DOR4BebJI6 zW2Rw8RXHLsUuitTf25iU2tjS4VBnuns1IVusMmM9kq4Tne1RbiXLjEAbn67xknu8xDm ghLqgxYtddM/qKa+ymXQRak6VkECidOxMmwv95NeKlN0l+gMaQ4Ko49VAi7kCTaenb4V PrfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=ZIX2cBfx; spf=pass (google.com: domain of linux-kernel+bounces-22020-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22020-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s17-20020a05622a019100b0042962fbc5a1si4034399qtw.266.2024.01.10.02.51.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 02:51:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22020-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=@ffwll.ch header.s=google header.b=ZIX2cBfx; spf=pass (google.com: domain of linux-kernel+bounces-22020-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22020-linux.lists.archive=gmail.com@vger.kernel.org" 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 9F2751C21C65 for ; Wed, 10 Jan 2024 10:51:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E63947F5E; Wed, 10 Jan 2024 10:50:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="ZIX2cBfx" Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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 B10C047F6D for ; Wed, 10 Jan 2024 10:50:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ffwll.ch Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a29b850ec66so129538266b.1 for ; Wed, 10 Jan 2024 02:50:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; t=1704883811; x=1705488611; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=pMG+VgwiuImv+J4aaZoTzNj8WyK0Rb5bzsnLEuXbNa0=; b=ZIX2cBfxPnnW+YjfjQVPVywl/CpyKomR7fGj8KN3SsBjF7JrjcUTpPn9CF+fIJcnww aPdXFDVne38/fHPGUGRs7ZT7dPgEV2AL5oD+J0wtLz8m+iKGQggiDiK55d30Epz/+rlc TlXimReiPNYCsmLNwNixhqSlvlA2yH8QFrXIs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704883811; x=1705488611; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pMG+VgwiuImv+J4aaZoTzNj8WyK0Rb5bzsnLEuXbNa0=; b=aEq4tn40LORtnI2TMqZacrj80mN+e2cYlEQtUezG4Hoa1wZXePjPDp/oWAAiYlHzJk tFmN3jKWdZQfvq6yYGPGL8Qyjo6B9frF3vTZ7qsHCOebqKT8Bpl/yYvGtrPQstVWa3VX /iGjvq5EpFiTvJgdvcBRjpEnAq2O+9OiQAdKtr3EddVamHwDxdKmFEbcrAugzWK4A4rL Oz0TcKSFvVIN4sPJlXNjP8NwdYF0oRco97gwadUMdQLPyK7YfXYnDhzZjSSLjxHngwQu 3BiTrEs3yc9zk18wagRKmGBPeXCz1lj6zCL4j1xHyYzviIBt/NxKKtsblF4ESZm5abk1 hspA== X-Gm-Message-State: AOJu0YyHLV2fA1l3I0ivW6o4M1XICejer/Cx6agctFxaokccBZ948Ymd R3b1BI9NietUao9U+Lj6sagaosrBv+utzg== X-Received: by 2002:a17:906:c2d9:b0:a2b:d12c:ee48 with SMTP id ch25-20020a170906c2d900b00a2bd12cee48mr784942ejb.1.1704883811018; Wed, 10 Jan 2024 02:50:11 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id s24-20020a1709060c1800b00a19afc16d23sm1964347ejf.104.2024.01.10.02.50.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 02:50:10 -0800 (PST) Date: Wed, 10 Jan 2024 11:50:08 +0100 From: Daniel Vetter To: Rob Clark Cc: 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 , Daniel Vetter , open list Subject: Re: [PATCH] Revert "drm/msm/gpu: Push gpu lock down past runpm" Message-ID: Mail-Followup-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 References: <20240109182218.193804-1-robdclark@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240109182218.193804-1-robdclark@gmail.com> X-Operating-System: Linux phenom 6.5.0-4-amd64 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 from the scheduler with your own work items, that's why you can provide that) this looks like an incomplete/incorrect explanation ... ? Slightly confused -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_gpu.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 msm_gem_submit *submit) > struct msm_ringbuffer *ring = 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 = submit->hw_fence->seqno; > + > update_sw_cntrs(gpu); > > /* > @@ -781,11 +783,8 @@ void msm_gpu_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit) > gpu->funcs->submit(gpu, submit); > gpu->cur_ctx_seqno = 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 = submit->hw_fence->seqno; > - > mutex_lock(&priv->lru.lock); > > for (i = 0; i < submit->nr_bos; i++) { > @@ -35,8 +33,13 @@ static struct dma_fence *msm_job_run(struct drm_sched_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