Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp575110rdb; Wed, 17 Jan 2024 10:27:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxKwl8oOleGWg4g4HannFq0sgvWJyd+lr+/5tdrgL7VhyDO3gGpihqyrr9jZFhIJI2DEhX X-Received: by 2002:a05:6a20:5b15:b0:199:a934:db77 with SMTP id kl21-20020a056a205b1500b00199a934db77mr4262772pzb.61.1705516039399; Wed, 17 Jan 2024 10:27:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705516039; cv=pass; d=google.com; s=arc-20160816; b=B3HosM3+0uIIFzIo0JLjmH4u6weRZlHoWwugeiX4Co63LowUIw/L3eMFDp52AEDvoD sdYHGyMugWI7r3uHC4VpV+1P0Dx83PjmjdWeXjdx4iK0Uzs0ULCrm3Festb+cdP4gobf arSd7Np2ngi1jvC60828tFyXAyLVi/3nV+IDxKOy5PT++BDmGWyhqUy1zuimu1g85+Fj QiNbsNT6XHPhWCWsS/5mZRneN/fAjH4aMzydeESEN4Izr7MvuosqfDcbvWeVGQNcS3+o +0MK79/kSt3s1zNTrpAGpY7wl7tLL//6C2Nwk+GSByOYRmwvU5DLvObtmZTJyf68R3Zd kdZA== 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=7zQWgPbfKp6YM9aUfoUkYrRudM52sOmWJm/p3sD772Y=; fh=BcQbdMDYKEj3jWqzAdBhNDO1dQXbF4mu4Zo1fW9VU/k=; b=rNd94fSyd4E59LrfIM2iw2I2NCqnhHqMZc0hDc6/57w6lYps9IisGa2a2Z0PDPIxns MWOHMM0d1Q26I1DdtnCdrz2ElRcWACiqVo9S3E0kSr0UJzT4DqHVCqb4rKzKirEkmFVB 0wrGZ1F91OFwyRJq4+JtLtgweRuyftnjck5ZpPI5wO3i8Pjg8TfbYZLygK9Qcjs2aa1M Ob21HvkNgQrG+DQSWYCpFJcZxcAcApONAJFCM1j5rjIGiUdFeCqNW0y7TqAXgCuj2KAC TnfmyOF0oT7mttrXd02hIRTY0P2X6qP1sQKKERyX9dCZhF/f36arX5hmf3hDNTaY8Bf0 27Xw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PVKYpiFJ; 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-29315-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29315-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id t10-20020a62d14a000000b006db0fed5808si2115130pfl.343.2024.01.17.10.27.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 10:27:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29315-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PVKYpiFJ; 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-29315-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29315-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 65CF5B233CD for ; Wed, 17 Jan 2024 18:27:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 292F322F0D; Wed, 17 Jan 2024 18:27:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PVKYpiFJ" Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 A36CE22EE0 for ; Wed, 17 Jan 2024 18:27:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705516025; cv=none; b=AlJ0rStqArWdvYSWgEZlCQzRJ0tEFiL7Nqka57AZH2dW17GIvLU+8kiejgQDXhs8lOgV2ZnoeyQhEjlc1l+7itGuepbsIdPTQNmaafobujI8uYlYqzh0DwKqAV10Tm3qIklrZ/VYdx4StahvfjCr3H41vpN56xyX66BEsPKhFLQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705516025; c=relaxed/simple; bh=NKRHrSpmwu1CWflJUUX9OhR3Z+lO3CHJlLyiMlQ2Ms4=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:MIME-Version: References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc: Content-Type:Content-Transfer-Encoding; b=AzszYJfBxS1CdePM3Ewb2ZGYR4l2r68LKZIJ5XQbeJ+to2bcdL/cg0zIIl1JEDp4sWfFfI2GgLhrR0eORFbvQqJCLB/EN++HnzqDDE72FhOo1nK/B6ZmLYWb+45amJp1nkPZ9zzsm4YLcEl4lH4No+1cKBiMrEJBn7pZw778rpo= 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=PVKYpiFJ; arc=none smtp.client-ip=209.85.221.53 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-wr1-f53.google.com with SMTP id ffacd0b85a97d-33728f82a71so2413506f8f.1 for ; Wed, 17 Jan 2024 10:27:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705516022; x=1706120822; 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=7zQWgPbfKp6YM9aUfoUkYrRudM52sOmWJm/p3sD772Y=; b=PVKYpiFJq+zmwpI+/UqSCgEWU/MvusfHIw92upmpsKvkGyiWreYJ+S1aqrJoMVooFB 6uag8Ts7SPGCEuS84A4B9NQs1NPAkUR0Bn2x0H/QQzBv7VNqT96zFAABT05azmEimJt4 LcTPOk9CE3SjHhRtWYkL8YSvBSZIfxb3CsqiRT0EoxsydpGM6V/bsglHT0K9h4mflw0O niVzpovDJ5l1FQBPdCKVntpD/XG0OKrf28qpoYmcFGm4vcHQAfSYHPPxvlNiGwgQ0SDr 5egiTTWdvyuvWpZVrTBHcOB/5uGDRYcAVW0GFjuRkH8o0sGT9WTKf5Oi3XOg25bXCvbr rlUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705516022; x=1706120822; 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=7zQWgPbfKp6YM9aUfoUkYrRudM52sOmWJm/p3sD772Y=; b=KWjIKTWuzMPxzppq1ZR50mXaeP42vQcJvGxIh/0nXCJU46hLene6UOYm60mClZnV/E iM/keQ5WxiB3LbS6Tgsi81OBa91z4sZZVV+GWuGe+7yD8DsUK+RnyJs4bun/n8wZr/fe Pxwo1Ia1cxl6EiWDKJoTGDwQSxBDYpLkoBlfRKPCaxu2rGYZRb4Q105tANVTM90734JQ /j2MZY7b1wtlM53QIfZ8FJWHiiEXRxPl6dHkSbdSGxqY/v7Ov5xz+wuK/MCaP0QE4IVz Cf86EPj+hZ9KsDI34vIJxNDNwFeC/8SRCWPaN1KOFxqLyKVyEzEviUiO+WH1KRhGKmND cCQw== X-Gm-Message-State: AOJu0Yyl69xxGoAPIbtKgt4oZeG4J0+gjIgwXW8oloM+ExhtEnrGMCmM 6Q9IobgWP5eoJXvbb/9OzvKraR0xG8LZ2QowVvo= X-Received: by 2002:adf:f48a:0:b0:337:c536:8516 with SMTP id l10-20020adff48a000000b00337c5368516mr159173wro.6.1705516021817; Wed, 17 Jan 2024 10:27:01 -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: Vasily Khoruzhick Date: Wed, 17 Jan 2024 10:26:35 -0800 Message-ID: Subject: Re: [PATCH v1 4/6] drm/lima: handle spurious timeouts due to high irq latency To: Erico Nunes Cc: Qiang Yu , dri-devel@lists.freedesktop.org, lima@lists.freedesktop.org, 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 Tue, Jan 16, 2024 at 7:12=E2=80=AFPM 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 Reviewed-by: Vasily Khoruzhick > --- > 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; > + } > + > + /* > + * 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); > + > + 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 >