Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp717660rdb; Thu, 18 Jan 2024 17:43:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IHDsotPnk3wZ5OiICEGLVKUDWCBxMK5HvK6R+TfbMjLliKdt74STuIcSPuFTbtZM8o/YFWB X-Received: by 2002:ac8:5a56:0:b0:42a:2005:d03c with SMTP id o22-20020ac85a56000000b0042a2005d03cmr1436994qta.2.1705628610293; Thu, 18 Jan 2024 17:43:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705628610; cv=pass; d=google.com; s=arc-20160816; b=biyHU4RpawcQRK5NKizDyRT3SL/xM9T37V+JOSA0d6RybDGwslq82FkZ1jF7zWIDXe q/ZfQYESYma/XHcCMvC0gCYVOX8mGZ6PeRJ7XT6GmO1LCEL7Fn70h22DoEirexWtYnt5 7AdHp0ihcGkG9RCouO5LWkVKNQSAOwWj9MLJLrDHtXZbB1wxHIZ3T/uG5nhr5EngxnXD puopnHTvMz7/Se3kv3k0lMirzGiNfbWV6nNxppZgTk3ydVoqnSXfw/807H+odgdfO+d3 uyu24If8q3FII8zT73bHEkTE1fcoQFUmGzBMrKWQFQcIMV5ihwoGhNdriE2hmxa+F+1W 7GDQ== ARC-Message-Signature: i=2; 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=5Uj9bxMJboKddkDeF9s1beNT2b+6oUXT7D7uJLWJvtg=; fh=pviyXVmiWwgMDrZLYUy6r3jCkWOmPrANkCzlFT1AINw=; b=k1moXoTY7Gnyu63GspOH99dZbde1z4M8Vk1ZsCst9358UlYqJ7tBX2uHr8gxRQjw1d UQzyqwIybC16tCHpnoc+1KtMc96j7Rq0NeMGFT8eay8J+yudzJo8+KpPWIje2cnpGClP VbObhT7g7ERlUdwj2NYzScXH4+9VBJ2CDlen9Xa2m0Vl9H6r+rdQgxw93CcNNAjp4PKA RL0Dirt8yQi20N+loSAicu2O5YOMxixe9X/eriqPM60i99znDFmqjOJx+neh7ZkBCe1S NBhWKMqI8kmK8OEqBxqCWFiMcRx7GNlIpK3ZVv2ruljHTghVFZaNCzH0RY4xtcynyxVl rGFg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OxtRkBlk; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-30689-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30689-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 h13-20020a05620a284d00b007830a9a0219si16255543qkp.112.2024.01.18.17.43.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 17:43:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30689-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=OxtRkBlk; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-30689-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30689-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 BE36E1C2247F for ; Fri, 19 Jan 2024 01:43:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F85C138F; Fri, 19 Jan 2024 01:43:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OxtRkBlk" Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (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 069B41362 for ; Fri, 19 Jan 2024 01:43:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705628602; cv=none; b=KQTFJixKTOVIfjci7l7WIkq8R8v5tSVZ0uJVkRCzFhkX/genVe9lsHZNW3pKd1oM0V9cErxj+GRO/DB0HtzdlcVoge5Dbjxq01J0uRQRHncxbCC0rOXktMHpIBPZrmPuvXL79SlICIJaE/Irh4nvCylZunZnT/pzk8mM23s0Yhw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705628602; c=relaxed/simple; bh=sEdCMRDHx8TWPG1oAi+hdVIcRvmKKy2SnyQb7Jp6AYw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Qy73xA6RQo4SyiTI/51Ubk6kwdG1p4jSw3ZyeIzJM/sQM37GHWTycNitA3QghU2//juCvg+P1l3OhZY5B9HIjYhAvLQ/qP36UCECUXO5XZFLBIHZTwfdvJufkgUOvEBuBdax9mN6+BmVsQgAvZIYKeVFfP08TrIDRfurmOKywRo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OxtRkBlk; arc=none smtp.client-ip=209.85.208.45 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-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-555e07761acso267266a12.0 for ; Thu, 18 Jan 2024 17:43:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705628599; x=1706233399; 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=5Uj9bxMJboKddkDeF9s1beNT2b+6oUXT7D7uJLWJvtg=; b=OxtRkBlkyRSYGN9liIGzGhIsAB4uLOuLMDAaCJCutq8W01cT6tB7VeSphsGzY7goqo RYvohCcW3zIgtIqpO6/nZMUJp4oyUHqoLvb7V/Aalc4a7XO6OtX9au2Le1zkJCKv3Ye6 L2wwcj3TOfE56Ql0tKfDaSZYGDG5EMCSQMTZTrRlq7OmjPo2xtPYQEErB7WO7mgc5FM6 b/JgzfdSF7k3O2CSSexuBh/ApONiGNcnWy+VWGDX/3zx82yITe3XJzp723j05B/DIn9V UzJVYbhGsY2nsiTuJrQMYaUPNIGce3HoDyCpu+6XixuKUQfgy7HRstcNiOaO7oilhVmJ BNpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705628599; x=1706233399; 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=5Uj9bxMJboKddkDeF9s1beNT2b+6oUXT7D7uJLWJvtg=; b=trdtKAewIbkK8YR3/TZ9FTeABocQ8q0ufejlSTO1a17zj6EIQVky3w1mawdRSDyhbw +eesFS3M1sBxza6RirU2vg02IIcAiYJCd/9Lrufmfx+NysIU6kxaCfkbkhLmhY+lxPg3 K/c9WhSHgqsxsXkRu9jLacTC43xQUgRmALs6vjvqd7m2qa8/862VY2CS7M5e+/krUZwb koP6jTlHyY9VhyK7V0dqIpwfGuDKIKAN2l3Nnv2KN460kKKufuhbaZqbZocBI8Kc4UlC mYe75PWCo2IA4ay7Awj+rFs0vnY+LuDgYoCU5jEWqyo5hKVyMpIrsS+mLznj0djqknuJ XLBg== X-Gm-Message-State: AOJu0YxmdWB0sJstC9z9eqrsvG9TywV43Lh9MpjPRBNBHAUmXbBx5E/e Hba00dS3oUass7n4P1vVpNxPs3kgaMuaOFYgUjVTCJ/175iiJWmuKloiBAPfr11Q+M+eCPjpFxG rQmar53jlddKB6OP+/r8NC+HnKuo= X-Received: by 2002:a05:6402:34c4:b0:55a:4dfa:baa6 with SMTP id w4-20020a05640234c400b0055a4dfabaa6mr310534edc.62.1705628599081; Thu, 18 Jan 2024 17:43:19 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240117031212.1104034-1-nunes.erico@gmail.com> <20240117031212.1104034-5-nunes.erico@gmail.com> In-Reply-To: <20240117031212.1104034-5-nunes.erico@gmail.com> From: Qiang Yu Date: Fri, 19 Jan 2024 09:43:06 +0800 Message-ID: Subject: Re: [PATCH v1 4/6] drm/lima: handle spurious timeouts due to high irq latency To: Erico Nunes Cc: dri-devel@lists.freedesktop.org, lima@lists.freedesktop.org, anarsoul@gmail.com, Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Sumit Semwal , christian.koenig@amd.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jan 17, 2024 at 11:12=E2=80=AFAM Erico Nunes wrote: > > There are several unexplained and unreproduced cases of rendering > timeouts with lima, for which one theory is high IRQ latency coming from > somewhere else in the system. > This kind of occurrence may cause applications to trigger unnecessary > resets of the GPU or even applications to hang if it hits an issue in > the recovery path. > Panfrost already does some special handling to account for such > "spurious timeouts", it makes sense to have this in lima too to reduce > the chance that it hit users. > > Signed-off-by: Erico Nunes > --- > drivers/gpu/drm/lima/lima_sched.c | 32 ++++++++++++++++++++++++++----- > drivers/gpu/drm/lima/lima_sched.h | 2 ++ > 2 files changed, 29 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/lima/lima_sched.c b/drivers/gpu/drm/lima/lim= a_sched.c > index 66317296d831..9449b81bcd5b 100644 > --- a/drivers/gpu/drm/lima/lima_sched.c > +++ b/drivers/gpu/drm/lima/lima_sched.c > @@ -1,6 +1,7 @@ > // SPDX-License-Identifier: GPL-2.0 OR MIT > /* Copyright 2017-2019 Qiang Yu */ > > +#include > #include > #include > #include > @@ -223,10 +224,7 @@ static struct dma_fence *lima_sched_run_job(struct d= rm_sched_job *job) > > task->fence =3D &fence->base; > > - /* for caller usage of the fence, otherwise irq handler > - * may consume the fence before caller use it > - */ > - dma_fence_get(task->fence); > + task->done_fence =3D dma_fence_get(task->fence); > > pipe->current_task =3D task; > > @@ -401,9 +399,33 @@ static enum drm_gpu_sched_stat lima_sched_timedout_j= ob(struct drm_sched_job *job > struct lima_sched_pipe *pipe =3D to_lima_pipe(job->sched); > struct lima_sched_task *task =3D to_lima_task(job); > struct lima_device *ldev =3D pipe->ldev; > + struct lima_ip *ip =3D pipe->processor[0]; > + > + /* > + * If the GPU managed to complete this jobs fence, the timeout is > + * spurious. Bail out. > + */ > + if (dma_fence_is_signaled(task->done_fence)) { > + DRM_WARN("%s spurious timeout\n", lima_ip_name(ip)); > + return DRM_GPU_SCHED_STAT_NOMINAL; > + } > + You may just remove this check and left the check after sync irq. > + /* > + * Lima IRQ handler may take a long time to process an interrupt > + * if there is another IRQ handler hogging the processing. > + * In order to catch such cases and not report spurious Lima job > + * timeouts, synchronize the IRQ handler and re-check the fence > + * status. > + */ > + synchronize_irq(ip->irq); This should be done after drm_sched_stop() to prevent drm scheduler run more jobs. And we need to disable interrupt of GP/PP for no more running job triggered fresh INT. PP may have more than one IRQ, so we need to wait on all of them. > + > + if (dma_fence_is_signaled(task->done_fence)) { > + DRM_WARN("%s unexpectedly high interrupt latency\n", lima= _ip_name(ip)); > + return DRM_GPU_SCHED_STAT_NOMINAL; > + } > > if (!pipe->error) > - DRM_ERROR("lima job timeout\n"); > + DRM_ERROR("%s lima job timeout\n", lima_ip_name(ip)); > > drm_sched_stop(&pipe->base, &task->base); > > diff --git a/drivers/gpu/drm/lima/lima_sched.h b/drivers/gpu/drm/lima/lim= a_sched.h > index 6a11764d87b3..34050facb110 100644 > --- a/drivers/gpu/drm/lima/lima_sched.h > +++ b/drivers/gpu/drm/lima/lima_sched.h > @@ -29,6 +29,8 @@ struct lima_sched_task { > bool recoverable; > struct lima_bo *heap; > > + struct dma_fence *done_fence; > + > /* pipe fence */ > struct dma_fence *fence; > }; > -- > 2.43.0 >