From patchwork Thu Jun 29 22:25:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 114468 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9953459vqr; Thu, 29 Jun 2023 15:31:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlE/U4idVsZd6Oo9PmBvrkVXfq1uKCJBM+0hJMG6wVijYekxDduemgXdEYOpGtuCP0RdToQz X-Received: by 2002:a17:90a:6a87:b0:263:5c30:2cf8 with SMTP id u7-20020a17090a6a8700b002635c302cf8mr920964pjj.0.1688077881472; Thu, 29 Jun 2023 15:31:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688077881; cv=none; d=google.com; s=arc-20160816; b=LIGwFUurqou3/D4aDP6H1JRDe+MDpc2WD7URZ9RvxGh6bj8M9CM2GiDWJXvsUh9I4e ork2oKkY8yaFpD3RW45n5nsl5rt+3p+NR0/uAutWaS+5ep5Y1LHaLQaH+Mhd2wRijCeA VeZVdv2UQdX4MwdnC3lipPqewmsHpfQq84rQ2807wTYGyqK3NdnuD7u7e5tdxS/107Pd wrFpFyNuBP0gQkoET1Fw0DoTJvBYqoho1ww+IxDzWKYYyAbCKGutwF7M1brS5FN7eQcD PwTxN0A/BFesPUCKX9/nVgwquF41BTo85TScGSqfjWGby+x7k/JbUibj6c7EgU4IsSzn hagQ== 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=oJWNLif5KU//MMAojej1FrucSdQl6qHWc24CaRte2H4=; b=cu5ukTSiOoJbrsrZL58HJtbti1U0z4WJ6TTuRM5BcwtDMFTpu9RJb8lWA3kAHsWkOe JuB27hmow8fOFeBbtDviX+gfrskjSdzMFsstqbnXcDJOpzujx05SWkFyxgIVTdICf3jO xHlTdzD2xU88iPOJg54LbRGaNTTt+d7kA6F3Eg2dK2pKCn6GA1T2udwcxBnZho2s+Ryp I+BSy97wOqmtTEyGsrM9w7BJouQcLOKrxMNOqMLkvfcLjIG6aSPwW/DRMFwwZRq5Hd2+ ZJeZw5o55g0BiF56pCn4W6O0jzwh+JepwDmUX/IZORKCGCCpfYqxeNAzkheU7W1f1x2t XDVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aJE3dr77; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b19-20020a17090a489300b0025546028cbesi11056393pjh.31.2023.06.29.15.31.04; Thu, 29 Jun 2023 15:31:21 -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=aJE3dr77; 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 S232492AbjF2W34 (ORCPT + 99 others); Thu, 29 Jun 2023 18:29:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232215AbjF2W3N (ORCPT ); Thu, 29 Jun 2023 18:29:13 -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 BE22135B7 for ; Thu, 29 Jun 2023 15:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688077662; 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=aJE3dr77d5nLFzIFH0pofZmN4rJ+434Jo7kPGH3xSbFSCzrx586Pbq4sbQS7JyT92C7V+o 5PCZ1DCnTWiKfKsv+x9sCLoh19KfIaFmvUAwqF3jRy7QvXG0gL5iXe3K9vSGc8p1LezIuE UjoACNzpZCsdiAYOGjPiK4ccrWERu1g= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-657-8rDQq8GVMj6tzK4JbRE58g-1; Thu, 29 Jun 2023 18:27:40 -0400 X-MC-Unique: 8rDQq8GVMj6tzK4JbRE58g-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-313f376d2adso1511628f8f.2 for ; Thu, 29 Jun 2023 15:27:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688077659; x=1690669659; 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=iLtmR3e1k1HHrGdGnEd4knyiJVxSVficNm4YNchKfQ47x4YfQgos/RkR+AFVKZ58HH aXbV5Ko89XslE4zp2KoYE+F7VbOpMaJ3f/njJM66/+NAbw6EmFTzmgBaPELU2GAVxXFa Gu8SLigbsufkfEHLt1IcwEdW74fZeY7VhJ3mJ20Vq3eLq6N8l38yaxHz7Mgf5DaViTDK steWAZZcHjyr979fmmSBvXpow8wRpOXAYCiByz1GQ+UVitWSqfailksyji4UbOxBs4qH +rYOKXwnsTU0dX5GTCyeo7ltcpFHaQW0CIYkGQNtbsWpUNZyheMXldbLfePGPkNMWgRf Rv7A== X-Gm-Message-State: ABy/qLZ60PHB8QkMyH3FopnEAeP97xju4e9IAOaBEn85DYOFBuFhkYsK 9wPzzL2hrimZebbC975JHKlz4S3WZKixG/owSkClI2/25VhLmVgLscLowMtSM+ZRbfe735HB1kW PdO+Ix1dmrowJyIW8EZuO0BYx X-Received: by 2002:adf:f28a:0:b0:311:1568:1a27 with SMTP id k10-20020adff28a000000b0031115681a27mr722423wro.58.1688077659429; Thu, 29 Jun 2023 15:27:39 -0700 (PDT) X-Received: by 2002:adf:f28a:0:b0:311:1568:1a27 with SMTP id k10-20020adff28a000000b0031115681a27mr722418wro.58.1688077659167; Thu, 29 Jun 2023 15:27:39 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id v10-20020a5d590a000000b002fda1b12a0bsm16983121wrd.2.2023.06.29.15.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 15:27:38 -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-kernel@vger.kernel.org, Danilo Krummrich Subject: [PATCH drm-next v6 10/13] drm/nouveau: chan: provide nouveau_channel_kill() Date: Fri, 30 Jun 2023 00:25:26 +0200 Message-ID: <20230629222651.3196-11-dakr@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230629222651.3196-1-dakr@redhat.com> References: <20230629222651.3196-1-dakr@redhat.com> MIME-Version: 1.0 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_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770077953008330575?= X-GMAIL-MSGID: =?utf-8?q?1770077953008330575?= 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;