From patchwork Tue Jun 20 00:42:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13285082 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 287C1EB64D9 for ; Tue, 20 Jun 2023 00:43:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B9A7C8D000E; Mon, 19 Jun 2023 20:43:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B4BB48D0001; Mon, 19 Jun 2023 20:43:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99D5B8D000E; Mon, 19 Jun 2023 20:43:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 8D3648D0001 for ; Mon, 19 Jun 2023 20:43:24 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6BB89804D3 for ; Tue, 20 Jun 2023 00:43:24 +0000 (UTC) X-FDA: 80921277528.05.6F2A73A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 631B580012 for ; Tue, 20 Jun 2023 00:43:22 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RcelE2jR; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.hostedemail.com: domain of dakr@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dakr@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687221802; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+GODPjGDP/v7EDtsYhu3OhDhbf8tl4sgje/Azf5bvXY=; b=6yp+C6C5ktun3ACuI8YdUtLp5s6sz3v4gH4pZkkUYniPj7VDUQZ/AhYCIQB3FzrbE/5SaL YJyIR8JCJHBYwWZFX8IhBNz96gZVGJmLF0P2FJPBjy4IwEdnfJyAp0p4gdur2GSaL4GlCH Lg0OW8j450QaEl2l5bt5bzLeixHuQsM= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RcelE2jR; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.hostedemail.com: domain of dakr@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dakr@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687221802; a=rsa-sha256; cv=none; b=NYm4hej6XbcpXs6dK01QKcnc/cKe6HXQ96nmyuptk9uilclTCzcfpVcyZQZMtxINn+MVLA vEfxjkGiCH9sJRGiHbz1PiFm2Cu1DpIamOThxbs0INNEoRU9EH0dlHmpiCaIXUS5s7xDBU X11H8jR8Sunc4T4/7VJWvRx0ZTecULI= 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-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+GODPjGDP/v7EDtsYhu3OhDhbf8tl4sgje/Azf5bvXY=; b=RcelE2jR7pVn2qq9hio0FhQgq9pcvFnLfWXCOZjqSuACQtNBov8l+mGRjEo+migCWt5Cgx P62JSWuqdSdfM+qJL1TY6Shprpw9WBA3Eh4u6xEoP708PCIkzdRHeQhmh/sIWSFd8X2Adw Rqz5uZIzILfLBCcgpxShZ7er5LzO+w8= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-296-Hs0mB0PCNESi2ix8pPCfsg-1; Mon, 19 Jun 2023 20:43:20 -0400 X-MC-Unique: Hs0mB0PCNESi2ix8pPCfsg-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-987e47d2e81so225392466b.1 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=WVDnFfmoP48wpTck3AMWDEpr0t2f2LfZt/VNHhubW0EUSOI+OtAeFvIz3bFUBJLuPu BmSAL/SWLf6bF40k+xmG+d3tMTn+Eebwj/DDCXQFGv25We2qUHgbbzLx0YaeallAvN1G K1l7TI8sv/bwzJP2gW6cMhmKio73emY2uibLbI9mGD8lYayYV7MIJRr7B+sdL5wKpQBX UVP7+AAcRQGsZjRECXdgt1OCMqLXwq9ZoQf2ATl0yh4HIJ42EGj63NFEmhUyPLRhHIHD JAY5W8sffM6O3fVWqbh27pN0d+nnBRuqbUcG//lB9ZXjdQhaNs2+6fC02Z6BnOMpof/a m2TA== X-Gm-Message-State: AC+VfDyo03MmDw7yaJhWugF93fOEOS6zzCaF4Lodq2WBAiRxpa0oxHrN duVrBfUObVKmvbq23U6GV3CRH28gtt4dYodcEMIn142ahBT7JNDS96m0/MP9vN6BlIEeQD6ro7Y +Nxcbe0yooBA= X-Received: by 2002:a17:907:9495:b0:982:a065:331d with SMTP id dm21-20020a170907949500b00982a065331dmr9791780ejc.60.1687221799667; 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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspam-User: X-Stat-Signature: f46d8sphb8cqhk3sg4uk58gyqjqhqccc X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 631B580012 X-HE-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C20Q7qBFvcQLhqRlm4ok+q8D4iBUqFU9ZiZnC1xFFFovwkM54WCVWy7FXkhA0erYBkiBY5PDYz6Av2d6CQq7bFsie3/q51XHTjkGBUSx3mKM7BMTqK79n+na9AAie5fpvgtsy7Jn6ip1UcHi7XovSB9/ZJfPHXylt+VqWGxvN52FJ6WZDFpSIKDHWSaSjigbkZh0ccV9IjAJE7gy7UIVjifsjZ0fjiDjnVKksto5m+pZfCGmDHWBQvvH22k5KE4hGYcBLlG9sun8+ID1ZMZuRK7Qw4k9+5JrZLHzlWNgX5Av64Hh4N0FOrXo/DrYaMeki0+2zhpeyYoImxcn1gDyZacgTuD5dGRwhbJ+z36CBk7IKm9+rhYAMHgcjZCpkSXbbh4x X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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/nouveau/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); +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 *repv, u32 repc) struct nouveau_cli *cli = (void *)chan->user.client; 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); return NVIF_EVENT_DROP; } diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.h b/drivers/gpu/drm/nouveau/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 nvif_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 *); extern int nouveau_vram_pushbuf;