Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp312505rwb; Fri, 4 Aug 2023 13:10:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNkhHXvfvRTNN2POvBSg+sphUn438gBJo6khSWPOYjUDBK11MzTP2dnhGv23cS1/Kvy+io X-Received: by 2002:a05:6402:448:b0:51d:d390:143f with SMTP id p8-20020a056402044800b0051dd390143fmr2323777edw.5.1691179811321; Fri, 04 Aug 2023 13:10:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691179811; cv=none; d=google.com; s=arc-20160816; b=fXWsHgacSVLwq71yN+0HHS4apuzx1YfWrVG3tHqwoJknR11DYJM2657tLeWsNpjADP knd/jmcbQXDPSsXGaWlyXYeA6/sh94w/XHtDovxOYQAX62lLaFPzz9EexlmDZsq3IDth iZSSZGjGlQGwcYJhcM1P5kcR7RO8jSwbH2/V2ouPYikmnFE4vHWEyS2cBbrupGwiTue6 djvmD23Idz2ZG00sKqcjpxgIYaNLd3hCD3j2F/mo51t6vMtEfFy+iYGwjdkvc4QgqPn/ iSJ6cnn49o2OQnJom0kgXAmQlWCPc0WgmctuDC1JItJaJQp+islr40nP9XwwwIyBP48r olPw== 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; bh=FPFh5xK9R3PMhoxLIZOGRTrlUVBMred7+qWqFlBzAlw=; fh=K2z4qF9vBIeudG+FAsbdmtc7khu/mu2nGw/y5mnZTR0=; b=hQ9cB3Y5w2JXFKrrqPJYh+oIlWpG5xVJbMlOdsyKw42GvWmWtkrDaLwTBT8w4ViCkG nTb8wns13VVLpd0KIMNiwB7HrkkoWUaUbcsnsu9fnl7NxQEq9fg2HJkrsDq1mJhUxi9Z JD7f9nXftsjT4cScQrmydtO7LXcXaRvr4kX6XgCCC6e54GifVTcKYLBsmCAmb3p7AWM/ Dx+ohErASAA9pCZ7xY/wqRSi4oXEYBBkL/6Hruzjs5D9UX9GtvG4qnSe686kJJrSBR5G czMzrpDpahnDejp7J/EclPGIIkd9TXMZR3RxYT6+w6w9wB9xzZueixQbfrDfHUoMX1f/ +rGw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 v22-20020a056402185600b0052313f06199si1920419edy.495.2023.08.04.13.09.46; Fri, 04 Aug 2023 13:10:11 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230518AbjHDS1S (ORCPT + 99 others); Fri, 4 Aug 2023 14:27:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230466AbjHDS0I (ORCPT ); Fri, 4 Aug 2023 14:26:08 -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 D4B714ED6 for ; Fri, 4 Aug 2023 11:25:03 -0700 (PDT) Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-327-XzlRVz4iOpGxNCRi1Vgz9w-1; Fri, 04 Aug 2023 14:24:56 -0400 X-MC-Unique: XzlRVz4iOpGxNCRi1Vgz9w-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-521a38098faso1575040a12.2 for ; Fri, 04 Aug 2023 11:24:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691173493; x=1691778293; 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=FPFh5xK9R3PMhoxLIZOGRTrlUVBMred7+qWqFlBzAlw=; b=OIZlow0dVA+2ddyYRkRqG1/rfbhbisJ7xboYp838wyNCTnCAWXgHAek2AaA+APNH4t ooqGb461NT00TqeCYGpvqdEVKFVxhwrkExCxfc9sEZQ0VPfscvoN04R69cpfrr7ql7xx BzdymAeikXKkEoyhK3Xx16Pu+oFLsWXgjAfshnYAsm5z5FcUDY/8zXRBYHZ94WDaReaW GO32cvIBma2fdIhTIT+SgQZehFqqF3WPX5EEkok+QE3hs4uWZkK4ivas5HjkdsfG00Gp Ze/VJZLtgHZ0M00IBA6M2nGwQyiTv8CAnFqpGmnwiTaGuvmvoELRwDByGhjUkBUYzJUW F3+w== X-Gm-Message-State: AOJu0YyA/b/tcqMryH619iI6rnG17JyWTKw3Dtfj8/9Q882woEvhsMzR yHBZXTWTTotn7lkP16J4gzfLYV+kqn5HGL6yonqT1bZP7FjV22KX4FBaIgwzP9STpZweN/+Duny 9zlTmFj9fiF3N17L4eoaPBNBO X-Received: by 2002:a05:6402:d7:b0:523:1e18:3a78 with SMTP id i23-20020a05640200d700b005231e183a78mr1852253edu.12.1691173492888; Fri, 04 Aug 2023 11:24:52 -0700 (PDT) X-Received: by 2002:a05:6402:d7:b0:523:1e18:3a78 with SMTP id i23-20020a05640200d700b005231e183a78mr1852238edu.12.1691173492693; Fri, 04 Aug 2023 11:24:52 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id w16-20020a50fa90000000b00522295516c4sm1551054edr.90.2023.08.04.11.24.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 11:24:52 -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, donald.robson@imgtec.com Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Danilo Krummrich , Dave Airlie Subject: [PATCH drm-misc-next v10 09/12] drm/nouveau: chan: provide nouveau_channel_kill() Date: Fri, 4 Aug 2023 20:23:49 +0200 Message-ID: <20230804182406.5222-10-dakr@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230804182406.5222-1-dakr@redhat.com> References: <20230804182406.5222-1-dakr@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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 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. Reviewed-by: Dave Airlie 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 f69be4c8f9f2..1fd5ccf41128 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 bad7466bd0d5..5de2ef4e98c2 100644 --- a/drivers/gpu/drm/nouveau/nouveau_chan.h +++ b/drivers/gpu/drm/nouveau/nouveau_chan.h @@ -66,6 +66,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; -- 2.41.0