Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7731284rwd; Tue, 6 Jun 2023 15:39:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6zDZuAeyAO9ne0noKo0KVgWhlMnj0rjNSfIZsVTQ0mdWs5oaajsctR12EZlpv/Ji8LtFEx X-Received: by 2002:ac8:7f14:0:b0:3f9:7251:3101 with SMTP id f20-20020ac87f14000000b003f972513101mr1643304qtk.8.1686091147491; Tue, 06 Jun 2023 15:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686091147; cv=none; d=google.com; s=arc-20160816; b=zx9fjpsU/f8s89VlWyjrdW+1eAMAWQzOrE7YmjllppCtPfy5ghSS3sSGr78CDvjESs VrC0s9qsquLoEgMvQs0WPU1XasG6la/5Z1bJQCvrHedVvUnRN+mN2ICrSIA1YarFYUbv uQQhJ4wZ2cjtojig/WCnq/2oWA5UBAwAs7JEe3Orp/HLKKJP2E4GALoWutTg+Zm/FGLf xLCQpVYqEccJ10MTRN/gfnRxXIko9SoYZzdyrhrhR4jFx55SUVZEUG18MFBacA56gxFw vtqahzfSeQu9+JaJ9GjqJ14271cawsFpX3LJsQIed0OpgczLdF5wamPttehOCRS+iweL FBxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=c36xFgwQHAoO1A1GCpabxO1lgFTUT+xWChVASPsKB44=; b=FbyAy6ewGSP6oUoerrR2X3D2Z27YblGH8MArCUIiluo/noosVCYXcOQWaoiCYJLc5b q40IGK3SwGD2yMSUeY8gX++CA/9BcRfCUQeRkCAdHD5dz9AzkMoI7RSjzQDkeML3Dqxo WDwQDJZWuJPMhSjcsvxfA5erD/B4knj/fBleDurKDtDNU4gzN07GccVqxkPOdLeicB6A 8bbVieio/UxEY6e+WzTFAH7hN3fG3k95QOIhWFcfFnV2cP6zIzXEaLk/qhoTWr/m9Bvj cBUtO8sYER3sC/2dArQKmV4TI3bTwjgc+rEx1Wns8la7hj81b/uJGw2hOrWqdCmrRKRO pe8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="FA/fJ0fC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n14-20020ac85a0e000000b003ef417d593fsi7317577qta.102.2023.06.06.15.38.52; Tue, 06 Jun 2023 15:39:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="FA/fJ0fC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239924AbjFFWdw (ORCPT + 99 others); Tue, 6 Jun 2023 18:33:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239909AbjFFWdQ (ORCPT ); Tue, 6 Jun 2023 18:33:16 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B38B1982 for ; Tue, 6 Jun 2023 15:32:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686090745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c36xFgwQHAoO1A1GCpabxO1lgFTUT+xWChVASPsKB44=; b=FA/fJ0fCdNS2ScfvBb4a9NJPBcSxPkTTrgMTe9EbntPBYCg9VBT4Q1qTO8+gst3iAe0j/f oqqWflxZHmb/ORWul24fXPXZ46j/o/b3rPoaPh43Lm8Hgr1i9q3qtLwNgVry2xC1amB7LU lKLJbQOSdnQsKS7g7YSgT9XpEVmHpYE= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-213-0zRC2ssRN9SHbnGUPu6gXg-1; Tue, 06 Jun 2023 18:32:21 -0400 X-MC-Unique: 0zRC2ssRN9SHbnGUPu6gXg-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-94a355c9028so515856566b.3 for ; Tue, 06 Jun 2023 15:32:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686090740; x=1688682740; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c36xFgwQHAoO1A1GCpabxO1lgFTUT+xWChVASPsKB44=; b=UqA23qEMVPYbi5JGFGFCDYMNuNTCz3eZwPl2vxXaSFDo/UFVbFN1lh5+a8zKBpMcf9 pgN6eYIJS2haDfMETJEttTTsNoHT+4MrpBVFmXjhGqsWnVtELF+9SprBV+eYwC007Svv vAaZWfWAPgKmG04bFarXlo8d9/ThzyMflEEpuNtAVwlWZOe3gqu1uIjMNytlOTYAwggh weweOQMPsyINyjCuMlSjHyTbRcjGQ4nXELraXBsbIz2UKpuG1z7vaDCN07kbWnO8lR2z Cn/8EAi8m6e8tx87SLgIYLjB2B7wQ+kjm5R1FrJpwBhQwZQpWgq/xkI1Z2zlSC1Gteev N3+Q== X-Gm-Message-State: AC+VfDzO8OS8pwvoH3+s1A3uNuNpGp9kS+rZX0Oo62/8AUTF0LVsgVu4 3jpaIMBprKwZGe3JhuLQxp7cVPIQW6WpCXLy8rTvvn2oNbRXJUnYb92EwkS24/6g2RT7n7c5yZt ycMngJd/lsqsCSi/TR7iorFB3 X-Received: by 2002:a17:907:d1a:b0:974:419d:7847 with SMTP id gn26-20020a1709070d1a00b00974419d7847mr3616084ejc.71.1686090740771; Tue, 06 Jun 2023 15:32:20 -0700 (PDT) X-Received: by 2002:a17:907:d1a:b0:974:419d:7847 with SMTP id gn26-20020a1709070d1a00b00974419d7847mr3616072ejc.71.1686090740566; Tue, 06 Jun 2023 15:32:20 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id bg11-20020a170906a04b00b0094f282fc29asm6060829ejb.207.2023.06.06.15.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 15:32:20 -0700 (PDT) From: Danilo Krummrich To: airlied@gmail.com, daniel@ffwll.ch, tzimmermann@suse.de, mripard@kernel.org, corbet@lwn.net, christian.koenig@amd.com, bskeggs@redhat.com, Liam.Howlett@oracle.com, matthew.brost@intel.com, boris.brezillon@collabora.com, alexdeucher@gmail.com, ogabbay@kernel.org, bagasdotme@gmail.com, willy@infradead.org, jason@jlekstrand.net Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Danilo Krummrich Subject: [PATCH drm-next v4 10/14] drm/nouveau: fence: fail to emit when fence context is killed Date: Wed, 7 Jun 2023 00:31:26 +0200 Message-Id: <20230606223130.6132-11-dakr@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230606223130.6132-1-dakr@redhat.com> References: <20230606223130.6132-1-dakr@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The new VM_BIND UAPI implementation introduced in subsequent commits will allow asynchronous jobs processing push buffers and emitting fences. If a fence context is killed, e.g. due to a channel fault, jobs which are already queued for execution might still emit new fences. In such a case a job would hang forever. To fix that, fail to emit a new fence on a killed fence context with -ENODEV to unblock the job. Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/nouveau/nouveau_fence.c | 7 +++++++ drivers/gpu/drm/nouveau/nouveau_fence.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c index e946408f945b..77c739a55b19 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fence.c +++ b/drivers/gpu/drm/nouveau/nouveau_fence.c @@ -96,6 +96,7 @@ nouveau_fence_context_kill(struct nouveau_fence_chan *fctx, int error) if (nouveau_fence_signal(fence)) nvif_event_block(&fctx->event); } + fctx->killed = 1; spin_unlock_irqrestore(&fctx->lock, flags); } @@ -229,6 +230,12 @@ nouveau_fence_emit(struct nouveau_fence *fence, struct nouveau_channel *chan) dma_fence_get(&fence->base); spin_lock_irq(&fctx->lock); + if (unlikely(fctx->killed)) { + spin_unlock_irq(&fctx->lock); + dma_fence_put(&fence->base); + return -ENODEV; + } + if (nouveau_fence_update(chan, fctx)) nvif_event_block(&fctx->event); diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.h b/drivers/gpu/drm/nouveau/nouveau_fence.h index 7c73c7c9834a..2c72d96ef17d 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fence.h +++ b/drivers/gpu/drm/nouveau/nouveau_fence.h @@ -44,7 +44,7 @@ struct nouveau_fence_chan { char name[32]; struct nvif_event event; - int notify_ref, dead; + int notify_ref, dead, killed; }; struct nouveau_fence_priv { -- 2.40.1