From nobody Mon Feb 9 13:02:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE006EB64D9 for ; Tue, 20 Jun 2023 00:44:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229965AbjFTAoR (ORCPT ); Mon, 19 Jun 2023 20:44:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229917AbjFTAoF (ORCPT ); Mon, 19 Jun 2023 20:44:05 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92C7910F8 for ; Mon, 19 Jun 2023 17:43:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687221801; 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=+GODPjGDP/v7EDtsYhu3OhDhbf8tl4sgje/Azf5bvXY=; b=C1BBDqgdvksfySrXNTxEfQeCbQqTFsk88D1Bf8fPM0L4EzRw8KqPt4wdISo94HguQ7057s PTfAoTVg+X1TfDgDex/Snqa6YkFvDftjmc8SlLiZ9mgzpLl7y5l47niInv0126ldS9pr9v 8wf7NOlxw1UpG0aJ1ikMw39snCN1bi4= 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-296-F-aCexA5MOGy03bd3CvrmQ-1; Mon, 19 Jun 2023 20:43:20 -0400 X-MC-Unique: F-aCexA5MOGy03bd3CvrmQ-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-95847b4b4e7so321607566b.3 for ; Mon, 19 Jun 2023 17:43:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687221799; x=1689813799; 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=+GODPjGDP/v7EDtsYhu3OhDhbf8tl4sgje/Azf5bvXY=; b=ijRjSCQLoM2HuQM8WLIj7y7Y2kpIUaEIogK4ttvYiyD636Jtywo2YhcVhxrgK9Qa2A k7RLBf7rFsjotcnJkvJkkRMB2aNur4t4X+1/VPiv9vQeilFfzgtipHnhO2d1AyalofXu 9GsmwMkdA6lxR4MbrGFFF/7UjwOcodTqmRv0zl5B0JAcG/o4+8xgP8E2hvKRcNiuzfwJ fpJ/Eal7RjrQ9cnCSSWi3qTl80vjmnd72BwczEOeBLFJuP5zGD/KQd/Zbo77JXvDA6ah qBEyo0Zqn/E49zzHgcmVaIFdKbFSDo5yHIYzWX56dUxb1DlvdgDcigB5AcISr/s/XszO 57gQ== X-Gm-Message-State: AC+VfDztK9SJW4PftYFHo95HndwRcaEa51uRjZNRx3goIO+tGmJ2kzcH xE2YC4BL74oOeNpvoRxC+W3QpCwu9QKnPCbfknONpbfNykwwdhTplfIS6vD/s8e0Kdz/71ys1lO BQct9hh6IFjz5ssvTuKwU0OuZ X-Received: by 2002:a17:907:9495:b0:982:a065:331d with SMTP id dm21-20020a170907949500b00982a065331dmr9791775ejc.60.1687221799663; Mon, 19 Jun 2023 17:43:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ65fHuJnAW0DqDalRe8IFameBpvYe1u3W5keeHpov/NpqxjPQb0EmGROEVydntX30L57FauPQ== X-Received: by 2002:a17:907:9495:b0:982:a065:331d with SMTP id dm21-20020a170907949500b00982a065331dmr9791756ejc.60.1687221799456; Mon, 19 Jun 2023 17:43:19 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id rh8-20020a17090720e800b0098282bb8effsm375959ejb.196.2023.06.19.17.43.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 17:43:18 -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 v5 11/14] drm/nouveau: chan: provide nouveau_channel_kill() Date: Tue, 20 Jun 2023 02:42:14 +0200 Message-Id: <20230620004217.4700-12-dakr@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230620004217.4700-1-dakr@redhat.com> References: <20230620004217.4700-1-dakr@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The new VM_BIND UAPI implementation introduced in subsequent commits will allow asynchronous jobs processing push buffers and emitting fences. If a job times out, we need a way to recover from this situation. For now, simply kill the channel to unblock all hung up jobs and signal userspace that the device is dead on the next EXEC or VM_BIND ioctl. Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/nouveau/nouveau_chan.c | 14 +++++++++++--- drivers/gpu/drm/nouveau/nouveau_chan.h | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouve= au/nouveau_chan.c index f47c0363683c..a975f8b0e0e5 100644 --- a/drivers/gpu/drm/nouveau/nouveau_chan.c +++ b/drivers/gpu/drm/nouveau/nouveau_chan.c @@ -40,6 +40,14 @@ MODULE_PARM_DESC(vram_pushbuf, "Create DMA push buffers = in VRAM"); int nouveau_vram_pushbuf; module_param_named(vram_pushbuf, nouveau_vram_pushbuf, int, 0400); =20 +void +nouveau_channel_kill(struct nouveau_channel *chan) +{ + atomic_set(&chan->killed, 1); + if (chan->fence) + nouveau_fence_context_kill(chan->fence, -ENODEV); +} + static int nouveau_channel_killed(struct nvif_event *event, void *repv, u32 repc) { @@ -47,9 +55,9 @@ nouveau_channel_killed(struct nvif_event *event, void *re= pv, u32 repc) struct nouveau_cli *cli =3D (void *)chan->user.client; =20 NV_PRINTK(warn, cli, "channel %d killed!\n", chan->chid); - atomic_set(&chan->killed, 1); - if (chan->fence) - nouveau_fence_context_kill(chan->fence, -ENODEV); + + if (unlikely(!atomic_read(&chan->killed))) + nouveau_channel_kill(chan); =20 return NVIF_EVENT_DROP; } diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.h b/drivers/gpu/drm/nouve= au/nouveau_chan.h index e06a8ffed31a..e483f4a254da 100644 --- a/drivers/gpu/drm/nouveau/nouveau_chan.h +++ b/drivers/gpu/drm/nouveau/nouveau_chan.h @@ -65,6 +65,7 @@ int nouveau_channel_new(struct nouveau_drm *, struct nvi= f_device *, bool priv, u32 vram, u32 gart, struct nouveau_channel **); void nouveau_channel_del(struct nouveau_channel **); int nouveau_channel_idle(struct nouveau_channel *); +void nouveau_channel_kill(struct nouveau_channel *); =20 extern int nouveau_vram_pushbuf; =20 --=20 2.40.1