Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp1425339rwp; Thu, 13 Jul 2023 10:36:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlGFEMxBJHRjIeZTiQb5Tvqbk37agyIm1B3AHduH5AOTi933az24o21xfqlpLNc3iHPbm27p X-Received: by 2002:a05:6870:3041:b0:1b7:2dfe:bf63 with SMTP id u1-20020a056870304100b001b72dfebf63mr3538280oau.18.1689269790296; Thu, 13 Jul 2023 10:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689269790; cv=none; d=google.com; s=arc-20160816; b=ekpUyvBZjM/Ktw+gz4FgvFmz4GT3KMy68+PIdEhnMj4hGeYWn1CycCakYc65g+MDHa 2zS9d0D4ujJcnU6E9zYXGGsaIhrb9QBvpGqsfLcAVMcL4dhI4WCmmce0/gCVUvA/4STo w5D/tZhECgZCkwg6kGUJohTrZ/JLhHASP7oHQaamPH2wZ5j6uq0v2MGKSLIg/lHHCchr f2Ur5y5GFyXg0XxSmQ/CDeAF4/1V9ty7cDsIwbwadktMvx56c5isVRS8Q8225k3cLZIs LJ/uDcP0ZxXcAF0W5gvTrkdJQE+9bkL1ggHn2CJZfWCBAnq143K7dYzbUcoXjIRFB+/R Ik/A== 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=OhcRjSdJAD7B8JiFY4weu/O+VY7c03xht8db5Jb3htY=; fh=grh6qrjW0oxu0S8zfHJMhxWLgUXiZ/TU2uoVe6KOi4w=; b=n8auyUhjUTAV/mdlqTP/dYHB5gb49P3yHNaL5xCq9UmncJNzM+kojw+DnbHVcoY9kt J+Ne7HYq9Zv3B9kBNKwnljFKk6rIUDK3geyU/d9Acd1FZeDpP1zdn6p2AbL8N9T81yEU a1Qi0V9al+LgyTt5JVjSmRXmqdtWqRWWWKtKF9U38BD7RnJjOfGb+MJowaVUIzcPruT6 Q7wsur6PPQCBMtzpYi17Fl8h9hHCOianq2rAgFEClBCaMwjx3BqNw5sQ5HcRHqBLVerP jOlX83Pv3zhUknHUAslzMcNducx+dEBboqO+mzsJRtmFOlVgmFxsN2AEva73Z6oiNzTO 0VvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=f6dh4uSD; 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 kh8-20020a170903064800b001b80de4d3f7si5193505plb.558.2023.07.13.10.36.17; Thu, 13 Jul 2023 10:36:30 -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=f6dh4uSD; 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 S232094AbjGMRG3 (ORCPT + 99 others); Thu, 13 Jul 2023 13:06:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232120AbjGMRGS (ORCPT ); Thu, 13 Jul 2023 13:06:18 -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 2C15B2D59 for ; Thu, 13 Jul 2023 10:05:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689267919; 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=OhcRjSdJAD7B8JiFY4weu/O+VY7c03xht8db5Jb3htY=; b=f6dh4uSDJszvS4PiGmMZhNhaLDP7Xt14T2OqCaKKjWioVO9FQBEafmtYVHuO5F7kOJOjbM HavOc2xmWTgszgmthQ6Ycpk/q/6AK3DCQh0lXt+e+FaIvIx8DJEHH1ycKYZGi30bWQkDkj 2Pzf9m5kAHT50MnhuVNbOzXIcORPkkg= 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-220-5rskXeIIOP-7XSr-r7Q5Bw-1; Thu, 13 Jul 2023 13:05:18 -0400 X-MC-Unique: 5rskXeIIOP-7XSr-r7Q5Bw-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-993d500699fso56224366b.1 for ; Thu, 13 Jul 2023 10:05:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689267917; x=1691859917; 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=OhcRjSdJAD7B8JiFY4weu/O+VY7c03xht8db5Jb3htY=; b=iXwHTNLTR/wndbXtfAYX4shHkDV0IPQqaBExnEdsnoQHQ/Dn4sm7DXpsRpq9knpnHV V5vl4NDqiVN7btZ7c4ZzEuO3VOIgVgGvO5JjXqDDEzhuzJ7/m0bD9/+Rf5Iy7d+AjM8f 6TnBhHXZIapR8i4K5zGnXcEJFs99hdeMoD5+spWyoJDJzgFvPQQYvEMW5bMaj2rwLUNC r18q7TmYR94UM9xRcvlBZg7PGNr4E67mojBv+aTNflyknDZalcz5X1msHuAdXuxb7HyG vMfXWn+e6HadqoQJfc25ehNhYn6piYwe0io49DOnHVq6gW5J++ZFCSUu0TvvgQiuEBl+ kH6A== X-Gm-Message-State: ABy/qLbreiiPxbAKKTbrUSPOR/Qg7oIGaroS7xCdxFcgY+CboR4CQsHc ddnm654nXZCLIw9CiB0d4TT615LF4WmbT4sRnUo2B66kv+gWrzYQMyWU2YcjawSCylO2sgWeoK5 D+RIL1ImWSMed3zLwUM45QmUC X-Received: by 2002:a17:906:cf8e:b0:992:566b:7d57 with SMTP id um14-20020a170906cf8e00b00992566b7d57mr1807165ejb.61.1689267917025; Thu, 13 Jul 2023 10:05:17 -0700 (PDT) X-Received: by 2002:a17:906:cf8e:b0:992:566b:7d57 with SMTP id um14-20020a170906cf8e00b00992566b7d57mr1807146ejb.61.1689267916859; Thu, 13 Jul 2023 10:05:16 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id z3-20020a1709063ac300b00992b3ea1ee3sm4215671ejd.159.2023.07.13.10.05.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 10:05:16 -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 Subject: [PATCH drm-next v7 10/13] drm/nouveau: chan: provide nouveau_channel_kill() Date: Thu, 13 Jul 2023 19:04:05 +0200 Message-ID: <20230713170429.2964-11-dakr@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230713170429.2964-1-dakr@redhat.com> References: <20230713170429.2964-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, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham 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. 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; -- 2.41.0