From patchwork Thu Jun 29 22:25:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 114473 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9954857vqr; Thu, 29 Jun 2023 15:34:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5gMFfILmuB49CLcjTY+C7tuTngMGzi8ET7qO+MGyTY56gBdtDWbP1RYbUw7dRD49s039A0 X-Received: by 2002:a05:6a20:1446:b0:111:ee3b:59a7 with SMTP id a6-20020a056a20144600b00111ee3b59a7mr1340893pzi.5.1688078059361; Thu, 29 Jun 2023 15:34:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688078059; cv=none; d=google.com; s=arc-20160816; b=mBLs+AQQyZg+MzZX9E85ZXnvMcNnSN3kDYFXFJG/YJtTDukF+9sskJWSjWDYFwiEOL D7ZIsdtIK/7ggJDm4jS6noRb8jjRygRvtfwYwQfXy4P/WGzZKVMn0wK1GElPe2CzKsB3 bbTkQVZAYP4fN8VDPXK7chnXhLELVeD8C3DQZqXD/xewSFpIdufLwsx6N2fQEzyue5yR aUG/7S9W18SN4d6Ty7Lck8u3E43Fv/jetsu8E6/bzW1Lv5IhScaR4L2TtN/7KWpsbbJ9 P+wk2jsVCd+CAUoF3x1MRN+tIvnGXndZodgTIaf1tntKBtPUQB206XxiVpk0ZRMlAgN2 8F1g== 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=/pp7pCNssCFdX07s9SqyoLBjaIvnkOQtt7NO/vv36Sc=; fh=oJWNLif5KU//MMAojej1FrucSdQl6qHWc24CaRte2H4=; b=lD68rv9twDOBugm2w80/ZxMNX2RSTwINkC6DaFcXU9KIMCW4IVeJ6YEUy/7kKw4Iaq FAjcRRnsX4efPx3Kpj5DQB4y1+9fKuyqxPjzddglJkuo0mpDWXw+87wYRhYqOIVfnYeF EfkFJkX+ye1yBrXVop5B3l3XR4dUJ/AwpDLmcgC/E+WwcIqiS1zgir9mxDOYHHpkcQiY Dh9o8e9P02WtJxpYeZB61j+Ce71zW+yGNv2RjR+PZE3he02zQlMZri++I67Z2NZ0uheQ NQaADIpTNfCRH3R0JZs/dxA4YsdaiNbmp1BhqnK0dK8a0iBjNojYgo8lICKLuinwKqCY J15Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XW3sD7BI; 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 t4-20020a63f344000000b0052c9fa00344si11906376pgj.625.2023.06.29.15.34.04; Thu, 29 Jun 2023 15:34:19 -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=XW3sD7BI; 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 S232206AbjF2W3s (ORCPT + 99 others); Thu, 29 Jun 2023 18:29:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232186AbjF2W3M (ORCPT ); Thu, 29 Jun 2023 18:29:12 -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 0668C35AF for ; Thu, 29 Jun 2023 15:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688077658; 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=/pp7pCNssCFdX07s9SqyoLBjaIvnkOQtt7NO/vv36Sc=; b=XW3sD7BI1xYF/dME6RfUk9chTtu1ZDKYq2GnVa6ymGhvQLdqIMbnKelQ537IvVis6LwuYX Braduh370NQ5hu93aVcL45tYRi7jMh28aVXzyp5HAsQkr3P/ktydOtsMU5vOF3gPtWr0Cb ECBpErNfn3gjVtM/TiOYWQ93vlpYVMM= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-616-ylnnXsNbP4e1nfZYLWmbTA-1; Thu, 29 Jun 2023 18:27:36 -0400 X-MC-Unique: ylnnXsNbP4e1nfZYLWmbTA-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-313f376d2adso1511554f8f.2 for ; Thu, 29 Jun 2023 15:27:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688077655; x=1690669655; 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=/pp7pCNssCFdX07s9SqyoLBjaIvnkOQtt7NO/vv36Sc=; b=LPhojg01FPn9UT8v3sS6+Te2anozMleWnQL6dpU36+3xW6hqxc+Lh14Y3rYgMkZb8e 9roQREfvLhnn4AbaR6Y1fWPqsa7HAIb8OUzKBQXhzzFXgsiP79AdtLJq1fj8Ia7TeQPB D/qNLWQNPkH1kmS04w6XkNscrlEpZTs0PkMwM48OW7RNpAJ0Of9wXEoOGmKFi/zaXlOd jmEVlf08ApyY3R/SrXqqvatqFGhTphkCsnsZcNAwZSK3gycOH7ibV5mtOUQLTupDLBNu og+bDssX1aDqtdnmKklwYErSRWYtG2FOMlbMCYwX9mvtPHiRvRp3JqdiLNN/2vNXBiD4 wWmg== X-Gm-Message-State: ABy/qLZJ7WDs8zYc8F7SzXfcToxLrWxfUKU1Rrnqgd0LxVPvBB/GAHhx 8R/nrBDfct8Onte4qGaUhbIIQ2M/Ppd2CzIH8PxL57K1omfNOY1LlPJ4gz8DPTDQ1DfRtAWnHfh mJ4B/HkBYbxsUNgiEOIgHHpgv X-Received: by 2002:a5d:525c:0:b0:313:f61c:42bd with SMTP id k28-20020a5d525c000000b00313f61c42bdmr750851wrc.59.1688077655559; Thu, 29 Jun 2023 15:27:35 -0700 (PDT) X-Received: by 2002:a5d:525c:0:b0:313:f61c:42bd with SMTP id k28-20020a5d525c000000b00313f61c42bdmr750845wrc.59.1688077655340; Thu, 29 Jun 2023 15:27:35 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id f2-20020a5d5682000000b00313ec7dd652sm13949454wrv.44.2023.06.29.15.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 15:27:34 -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 09/13] drm/nouveau: fence: fail to emit when fence context is killed Date: Fri, 30 Jun 2023 00:25:25 +0200 Message-ID: <20230629222651.3196-10-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=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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770078138970338610?= X-GMAIL-MSGID: =?utf-8?q?1770078138970338610?= The new VM_BIND UAPI implementation introduced in subsequent commits will allow asynchronous jobs processing push buffers and emitting fences. If a fence context is killed, e.g. due to a channel fault, jobs which are already queued for execution might still emit new fences. In such a case a job would hang forever. To fix that, fail to emit a new fence on a killed fence context with -ENODEV to unblock the job. Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/nouveau/nouveau_fence.c | 7 +++++++ drivers/gpu/drm/nouveau/nouveau_fence.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c index e946408f945b..77c739a55b19 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fence.c +++ b/drivers/gpu/drm/nouveau/nouveau_fence.c @@ -96,6 +96,7 @@ nouveau_fence_context_kill(struct nouveau_fence_chan *fctx, int error) if (nouveau_fence_signal(fence)) nvif_event_block(&fctx->event); } + fctx->killed = 1; spin_unlock_irqrestore(&fctx->lock, flags); } @@ -229,6 +230,12 @@ nouveau_fence_emit(struct nouveau_fence *fence, struct nouveau_channel *chan) dma_fence_get(&fence->base); spin_lock_irq(&fctx->lock); + if (unlikely(fctx->killed)) { + spin_unlock_irq(&fctx->lock); + dma_fence_put(&fence->base); + return -ENODEV; + } + if (nouveau_fence_update(chan, fctx)) nvif_event_block(&fctx->event); diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.h b/drivers/gpu/drm/nouveau/nouveau_fence.h index 7c73c7c9834a..2c72d96ef17d 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fence.h +++ b/drivers/gpu/drm/nouveau/nouveau_fence.h @@ -44,7 +44,7 @@ struct nouveau_fence_chan { char name[32]; struct nvif_event event; - int notify_ref, dead; + int notify_ref, dead, killed; }; struct nouveau_fence_priv {