From patchwork Tue Jun 6 22:31:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13269818 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 5ED6CC77B7A for ; Tue, 6 Jun 2023 22:32:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E31C08E000A; Tue, 6 Jun 2023 18:32:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE1CD8E0007; Tue, 6 Jun 2023 18:32:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5B7A8E000A; Tue, 6 Jun 2023 18:32:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B2B2E8E0007 for ; Tue, 6 Jun 2023 18:32:30 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 86DB3120866 for ; Tue, 6 Jun 2023 22:32:30 +0000 (UTC) X-FDA: 80873773260.16.26B5B4F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 4C51A40013 for ; Tue, 6 Jun 2023 22:32:28 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VSUOpjP5; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of dakr@redhat.com designates 170.10.129.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=1686090748; 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=KBoXJE2L4euNzdKDNgG4jmojKglsUBV2/yj9x62jwEN+6//D0Aa/uJfIlOIPm/SRkrPIiP M05uYzrsTazvKAbnUUzx/5d+ZtiH0p5lcw6vJ9iOBnqdwIwgiDAAfKi9+V3LSnHO7UEosk OV5DtUsThMaHasM0nnqZhMhDswx/bHQ= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VSUOpjP5; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of dakr@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dakr@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686090748; a=rsa-sha256; cv=none; b=6g0lHaX2T3foaHsKYVjwK3y+r4cb4h04h0TYJf8o+ersmzzofRvH+Hyd1b4ts1lRqmO1my Wfh15L2xKPMEswYxVOzrZjrfxkEmN9SeMPKFfyOxL00DLq3N2/OXDcbbObtPQu90PWdYl6 aAzO1kmscSDaEmSST0KRjaRtaCdv93Y= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686090747; 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=VSUOpjP5ghZm7BUDH7AA8pBQl7fgywwxiKyavOIqxxOzim13pO9i7cLOeclHwiPRyFYR0Q KM/bWEGKExlUqD9sY0PCfwHKngshxxjpHSaHqzXhYCpyIs5jlVow/IViJ2W7IvRmKQvDMC Hr/goej4/EXX49+3ZWrq6E9PR9ecXgc= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-177-6_bVo2UVMDqgi15N-amPSw-1; Tue, 06 Jun 2023 18:32:26 -0400 X-MC-Unique: 6_bVo2UVMDqgi15N-amPSw-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-97455ea1c14so436906566b.2 for ; Tue, 06 Jun 2023 15:32:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686090745; x=1688682745; 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=K7jC1ZgWcqDIXUOAyHN8SdMwz2FfSfSRzyGkSp0YsKvg7jAlsFWb7OAR8oRMp1OeQh v33R7EsVwy0OLNS/mPUtIcRKV27KutFFgcI3Uqwmj2kJ1etjlM1DVTbyzKOUyHAGQI7f +HmUIMqSg2IDM0yiKfW5Z37mbjubg3aXknxhqqdV80YTEAi94hJS4+3jU/TVipbaOcJg RXDCz3Jdl046nwk8B9G7plodWvoR7SJU8k1tLPGV9hpvwanvaQnbCBxmezs6qDm8FZdR 8qFFFIW8qyowEtzVAakkafDooEY+xJlgs34ojtVEITzYeNaq2BpC8Z+mmH6x3318mIDO u13Q== X-Gm-Message-State: AC+VfDwe8o6wCjXLQEIAEf8Hwf7+nGvwoSmeNyGqNLUyFkR5Sw+7B3z/ k42NNO/ur6DcrH5jbkoceTDIzRb9ptJTE9oilYx/2AqGbVFvRbQ2j9lb/OmJu6sfuVqV36iFIT6 XXD3XL6h1R6pv2qh11e4= X-Received: by 2002:a17:907:6d8c:b0:977:1dae:2500 with SMTP id sb12-20020a1709076d8c00b009771dae2500mr3524991ejc.1.1686090745177; Tue, 06 Jun 2023 15:32:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5pXjStykgCRHkdCNjmAkm6vVNZZG6Y41YgQd0R/5sajw/EqO04vf8XvQY4ctgh++fIqqeaSg== X-Received: by 2002:a17:907:6d8c:b0:977:1dae:2500 with SMTP id sb12-20020a1709076d8c00b009771dae2500mr3524986ejc.1.1686090745037; Tue, 06 Jun 2023 15:32:25 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id m26-20020a17090607da00b00977d6723bd6sm3457973ejc.195.2023.06.06.15.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 15:32:24 -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 11/14] drm/nouveau: chan: provide nouveau_channel_kill() Date: Wed, 7 Jun 2023 00:31:27 +0200 Message-Id: <20230606223130.6132-12-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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Queue-Id: 4C51A40013 X-Rspam-User: X-Rspamd-Server: rspam04 X-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o6leM1FBmhvzrxZbtEew0NDNxONC5A3IqnX7cq/A49qYXeA4cAgKqcZiGyA1KVCGm05iJHLYduaREokLpvgUZ6GWSrrxRApQVTBeeOPPeWujAGR5JxBeZu3C72GdP6iHVibxEZ+Ab0kHNWYxJKP2qwZK+zxcOhIHcOE3lU6XtDooVmgnxWOQu629jQ2J2XNwwQfTO3hAem0FN+Ys6NcP2BTsngIlhZdcC0QzxYiOvFlCp7pCQzqtrZWDy0sa87Pxl1yMhTNfoLC7UO+ZvjS4yWcJzB4D+wFm64uOoksz49p1WI9xC0j1FhKkCSkFRjvCGRaCApN5yuqOimJ47/vEzTGtaszAfCuZNYBJz3yyUTlRLUv2HN/mqzzsd1Ma6bk3b46oafauOYgVd1jYQtJUYZ/4kkcqAKKkzGGwfAD+bG 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;