From patchwork Mon Mar 4 18:31:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karol Herbst X-Patchwork-Id: 13580987 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 74BAEC5478C for ; Mon, 4 Mar 2024 18:32:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D70E1112472; Mon, 4 Mar 2024 18:32:30 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="M8ulxjff"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6567C112472 for ; Mon, 4 Mar 2024 18:32:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709577148; 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; bh=F9gPWxAqIxccC8AlqeFUtelqmyaQBlXMXZSupr7dlUM=; b=M8ulxjffAQZVSBEiJ51LMGD1c0/N9Eenr3cnx60aFIXQjuT6PrzOJY6mKptfSWDUL3kkFc KO2hsJylnIfqZzZRchXzSIRlsnshv2zpQkxBjnwMlwhACby9lweNzYaJtEVvayxE6UrLyc 1QMLclFhOPwbjyLt8M+zqMvGfGgM0Lg= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-44-CuQA19mXNASrqoOiEtQRnQ-1; Mon, 04 Mar 2024 13:32:27 -0500 X-MC-Unique: CuQA19mXNASrqoOiEtQRnQ-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a453e6b3021so18438266b.0 for ; Mon, 04 Mar 2024 10:32:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709577146; x=1710181946; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=F9gPWxAqIxccC8AlqeFUtelqmyaQBlXMXZSupr7dlUM=; b=EELxyv0HyeqllcATYUPoFxpJAZhGqiDoOnCv3St4UE8c7C6pGccPeGBLMplmOZ6AA2 cGKWzzuxqXFkpUfY6hKA99HtyVWYrx7u4n+6KwNrO6SpWyA+YegyziPAlK/lMem4uILw OwtwmeT0mBuz5P/zfTR9q3zFM+JHm3Myku+Jp0VNrr3MBJe6cL1iCQIFxubxKain51EW cjOVNMcOxUp1oLr/J1NUtuG5Nx0LJm/7vuEFkGNrNIOaInm4TUZzPuXWogeNFWJX1oB6 6OO0Rrv7ImSaWTGSKAJBGLDnHnRct46PP6uNfxZKbcJb2mDPuqF0kVQ0tbq1ExocY0x+ H+Fg== X-Forwarded-Encrypted: i=1; AJvYcCW3f8H06lcUhJZ8t2oEfoGYHN+6IZYc/EBJcL9K7b4H8EoXXGhnqQzYxJqaflyN5oLcDr6JHs66TnOlkIipGH4QWQ94B+ZTEMRPs7IjaiVu X-Gm-Message-State: AOJu0Yz01qewlHZJIljcSRTfOjt2ADCGxOLkkfHzqqCNy18NQM+OaLVa UKvJgIWyuWYa8adkvMoLFXz5zhN44vWBk5PysDbjSQj3chEwNqBgbcHZYUBW4XXjaPQ0bgGBFWW uaD6b2orejj3YoAMjk1bHm4bGYWiyIqK5U4mGoKXYHneOj/ASHxzhPJj6qzpBq9pgEw== X-Received: by 2002:a17:907:c787:b0:a3e:ac92:b952 with SMTP id tz7-20020a170907c78700b00a3eac92b952mr9568228ejc.5.1709577146179; Mon, 04 Mar 2024 10:32:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFsGCx4zG6do4zNtrBRrVyEOICLWH37Q9tXC93/H5tH8Kv6remnyfRjukUyyIlLyM94N97akA== X-Received: by 2002:a17:907:c787:b0:a3e:ac92:b952 with SMTP id tz7-20020a170907c78700b00a3eac92b952mr9568214ejc.5.1709577145825; Mon, 04 Mar 2024 10:32:25 -0800 (PST) Received: from kherbst.pingu ([77.20.15.65]) by smtp.gmail.com with ESMTPSA id me25-20020a170906aed900b00a44efa48c24sm2705672ejb.117.2024.03.04.10.32.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 10:32:25 -0800 (PST) From: Karol Herbst To: linux-kernel@vger.kernel.org Cc: Lyude Paul , Danilo Krummrich , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, Karol Herbst Subject: [PATCH 1/2] drm/nouveau: fix stale locked mutex in nouveau_gem_ioctl_pushbuf Date: Mon, 4 Mar 2024 19:31:56 +0100 Message-ID: <20240304183157.1587152-1-kherbst@redhat.com> X-Mailer: git-send-email 2.43.2 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" If VM_BIND is enabled on the client the legacy submission ioctl can't be used, however if a client tries to do so regardless it will return an error. In this case the clients mutex remained unlocked leading to a deadlock inside nouveau_drm_postclose or any other nouveau ioctl call. Fixes: b88baab82871 ("drm/nouveau: implement new VM_BIND uAPI") Cc: Danilo Krummrich Signed-off-by: Karol Herbst Reviewed-by: Lyude Paul Reviewed-by: Danilo Krummrich --- drivers/gpu/drm/nouveau/nouveau_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 49c2bcbef1299..5a887d67dc0e8 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -764,7 +764,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data, return -ENOMEM; if (unlikely(nouveau_cli_uvmm(cli))) - return -ENOSYS; + return nouveau_abi16_put(abi16, -ENOSYS); list_for_each_entry(temp, &abi16->channels, head) { if (temp->chan->chid == req->channel) { From patchwork Mon Mar 4 18:31:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karol Herbst X-Patchwork-Id: 13580988 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 647FEC48BF6 for ; Mon, 4 Mar 2024 18:32:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B945D112475; Mon, 4 Mar 2024 18:32:33 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="F6CFGq0A"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 65781112472 for ; Mon, 4 Mar 2024 18:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709577149; 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=5HIrnHCNtl6Z247/wJhmk+Seyt/6rCNU1N0P0o1q0xY=; b=F6CFGq0Au7pf7hhYehgWO6Vw9g6M8JPZ7Q/LVuYdISR0M4UrJd0uNNxtQdtQcRTW6D4ZPi 0Asgdy1l2UIcIvHxATewMt4G/sD/5HX/uZ+MmAlnY8xHyupq99jIlgU/Kte7hZwlxS1RS6 5Olj3gBnfW629TetOEbZpOkUEITlmyA= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-481-HD7XWihvOyO0veYglNf9EA-1; Mon, 04 Mar 2024 13:32:28 -0500 X-MC-Unique: HD7XWihvOyO0veYglNf9EA-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a3ee9c08720so52100266b.1 for ; Mon, 04 Mar 2024 10:32:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709577147; x=1710181947; 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=5HIrnHCNtl6Z247/wJhmk+Seyt/6rCNU1N0P0o1q0xY=; b=if4NHz85dE5UlfZaxeZKAqkjSdeMljaTaJpn5nmoU1+Lf4cAIUMkhz12VRDCUtAHDG EVKEoIIIhKkaDXHNY44UcOz2ZUJh2WygZhxzQ6QUDSdDVW25i3+9Wx4Q8I80o6UAU1vW x4SNePOrQFrZlr778LGgo9HtZgZGjrClnefiLyrXs7ijOsjMfDy9WCp7/am02i9bY6oS SnS/Jjbz/0hIhaV/oDxV+lNTTT4LmyD5TYb9/lb4x/KpYMEhdQQ/418IExC1HGhg0JDe 9JUeNxX9UmHeaM3rJvImRd2mnvaQ79y8qm3LQltmTpmTQN6CWBGurIX4Jli1g3MHby/s 4+VQ== X-Forwarded-Encrypted: i=1; AJvYcCVtaig0NB5xo7XvFdWQfgLkAS1SHhasMtBA49USE4WGV8V+G430ecvD+XRJtXekSiVTLp6p1+lIMzhMQg/xBO4wFT7utjhbF2UMzO2PVAlc X-Gm-Message-State: AOJu0Yx9h7DIfOuu2KVoQxCAApNHeTZeTBzFpvIrT3JyaLlax345DJyO Pwr6uk2r4HFmgcqgvA1J0ka/zqlYFaczQrlkn8Fo+kdhfolaM8oCoz4OMd12GADK9KOyKjW8tNY 6RbW/RgVfmsszYqRDyAdyhgWxmK5OgmWPjT9sU6t0MzSvmCfB2nh1tCQqCcmjKqQnVw== X-Received: by 2002:a17:907:8e8b:b0:a44:1bcf:4e8d with SMTP id tx11-20020a1709078e8b00b00a441bcf4e8dmr8867303ejc.5.1709577146862; Mon, 04 Mar 2024 10:32:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IHC/9uJQ7FdpOhZejxBiANmYZJHF+aXDDDzFon+9rcbVgig5VWeAqsBGKNqjOSPCQAW/3TuvQ== X-Received: by 2002:a17:907:8e8b:b0:a44:1bcf:4e8d with SMTP id tx11-20020a1709078e8b00b00a441bcf4e8dmr8867288ejc.5.1709577146532; Mon, 04 Mar 2024 10:32:26 -0800 (PST) Received: from kherbst.pingu ([77.20.15.65]) by smtp.gmail.com with ESMTPSA id me25-20020a170906aed900b00a44efa48c24sm2705672ejb.117.2024.03.04.10.32.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 10:32:26 -0800 (PST) From: Karol Herbst To: linux-kernel@vger.kernel.org Cc: Lyude Paul , Danilo Krummrich , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, Karol Herbst Subject: [PATCH 2/2] drm/nouveau: move more missing UAPI bits Date: Mon, 4 Mar 2024 19:31:57 +0100 Message-ID: <20240304183157.1587152-2-kherbst@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240304183157.1587152-1-kherbst@redhat.com> References: <20240304183157.1587152-1-kherbst@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Those are already de-facto UAPI, so let's just move it into the uapi header. Signed-off-by: Karol Herbst Reviewed-by: Lyude Paul Reviewed-by: Danilo Krummrich --- drivers/gpu/drm/nouveau/nouveau_abi16.c | 20 +++++++++++++++----- drivers/gpu/drm/nouveau/nouveau_abi16.h | 12 ------------ include/uapi/drm/nouveau_drm.h | 22 ++++++++++++++++++++++ 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c index cd14f993bdd1b..92f9127b284ac 100644 --- a/drivers/gpu/drm/nouveau/nouveau_abi16.c +++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c @@ -312,11 +312,21 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS) if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) { if (init->fb_ctxdma_handle == ~0) { switch (init->tt_ctxdma_handle) { - case 0x01: engine = NV_DEVICE_HOST_RUNLIST_ENGINES_GR ; break; - case 0x02: engine = NV_DEVICE_HOST_RUNLIST_ENGINES_MSPDEC; break; - case 0x04: engine = NV_DEVICE_HOST_RUNLIST_ENGINES_MSPPP ; break; - case 0x08: engine = NV_DEVICE_HOST_RUNLIST_ENGINES_MSVLD ; break; - case 0x30: engine = NV_DEVICE_HOST_RUNLIST_ENGINES_CE ; break; + case NOUVEAU_FIFO_ENGINE_GR: + engine = NV_DEVICE_HOST_RUNLIST_ENGINES_GR; + break; + case NOUVEAU_FIFO_ENGINE_VP: + engine = NV_DEVICE_HOST_RUNLIST_ENGINES_MSPDEC; + break; + case NOUVEAU_FIFO_ENGINE_PPP: + engine = NV_DEVICE_HOST_RUNLIST_ENGINES_MSPPP; + break; + case NOUVEAU_FIFO_ENGINE_BSP: + engine = NV_DEVICE_HOST_RUNLIST_ENGINES_MSVLD; + break; + case NOUVEAU_FIFO_ENGINE_CE: + engine = NV_DEVICE_HOST_RUNLIST_ENGINES_CE; + break; default: return nouveau_abi16_put(abi16, -ENOSYS); } diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.h b/drivers/gpu/drm/nouveau/nouveau_abi16.h index 11c8c4a80079b..661b901d8ecc9 100644 --- a/drivers/gpu/drm/nouveau/nouveau_abi16.h +++ b/drivers/gpu/drm/nouveau/nouveau_abi16.h @@ -50,18 +50,6 @@ struct drm_nouveau_grobj_alloc { int class; }; -struct drm_nouveau_notifierobj_alloc { - uint32_t channel; - uint32_t handle; - uint32_t size; - uint32_t offset; -}; - -struct drm_nouveau_gpuobj_free { - int channel; - uint32_t handle; -}; - struct drm_nouveau_setparam { uint64_t param; uint64_t value; diff --git a/include/uapi/drm/nouveau_drm.h b/include/uapi/drm/nouveau_drm.h index 77d7ff0d5b110..5404d4cfff4c2 100644 --- a/include/uapi/drm/nouveau_drm.h +++ b/include/uapi/drm/nouveau_drm.h @@ -73,6 +73,16 @@ struct drm_nouveau_getparam { __u64 value; }; +/* + * Those are used to support selecting the main engine used on Kepler. + * This goes into drm_nouveau_channel_alloc::tt_ctxdma_handle + */ +#define NOUVEAU_FIFO_ENGINE_GR 0x01 +#define NOUVEAU_FIFO_ENGINE_VP 0x02 +#define NOUVEAU_FIFO_ENGINE_PPP 0x04 +#define NOUVEAU_FIFO_ENGINE_BSP 0x08 +#define NOUVEAU_FIFO_ENGINE_CE 0x30 + struct drm_nouveau_channel_alloc { __u32 fb_ctxdma_handle; __u32 tt_ctxdma_handle; @@ -95,6 +105,18 @@ struct drm_nouveau_channel_free { __s32 channel; }; +struct drm_nouveau_notifierobj_alloc { + __u32 channel; + __u32 handle; + __u32 size; + __u32 offset; +}; + +struct drm_nouveau_gpuobj_free { + __s32 channel; + __u32 handle; +}; + #define NOUVEAU_GEM_DOMAIN_CPU (1 << 0) #define NOUVEAU_GEM_DOMAIN_VRAM (1 << 1) #define NOUVEAU_GEM_DOMAIN_GART (1 << 2)