From patchwork Wed Sep 27 01:22:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13399793 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 38C25E7F150 for ; Wed, 27 Sep 2023 01:23:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A0DB610E189; Wed, 27 Sep 2023 01:23:13 +0000 (UTC) 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 BCCDB10E189 for ; Wed, 27 Sep 2023 01:23:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695777790; 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=Nwx/VBvi2Ll0/8emzZfMoPpx/p+0CAxTL6gVB2JkPe4=; b=DRFCx3WuTb7kVy7vMpKNE3h1W5NoYczonSiGbd3rskEcUwu8OW4HilY6vXIFnIh88FwdVo ea/majK626Fg+RHISkrQ4UyrCesakuwTv52UrBwfODqcvDOdyFQZnQfptNvYzkCEosBHHv tGuFOxoa2sXfofx9Tz2SUmUdlyQG/8g= 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-36-WueFsu1zNTqPqdOoHsXCeg-1; Tue, 26 Sep 2023 21:23:09 -0400 X-MC-Unique: WueFsu1zNTqPqdOoHsXCeg-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-9a9f282713fso812632966b.3 for ; Tue, 26 Sep 2023 18:23:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695777788; x=1696382588; 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=Nwx/VBvi2Ll0/8emzZfMoPpx/p+0CAxTL6gVB2JkPe4=; b=uLFuZCnLTjGTc45rJizBh4DRx8fVkCtqj3+GzQEb8ooJaqo4uWO7Km1CJeYmcfvK8E lam1SG0sJdRhP2HmwaP36MckC1sdegzGoO47dNrPXFRRoP2ncsF76qe+ybdNdr+RzpMZ mS80tm2AUOFHNm6DVekmbkZw2vvOxWZ1hu45Q+eGd8HPAxecOkztzWdVPpysNmzv2Wed nZt/8Lg6PHJCueDXiW5CDfl1HmuyUyJUdPLMBZK40oQc5v5jbRNsIq+syJ1WSWvX/cnG mDWEmiFCQwJTAAoVtpzQDeRUcExPnQL8bQQYfgolCz7fGBD0XiOEK7y6+xzfW5ovLFHc Xhfg== X-Gm-Message-State: AOJu0YzlthuoqanunapHJA847fQKQK3nhFPlIlv1YB04ptwalImJlCzH Dfi54HBVNUR/JoJ7QQqV5KRAnWOL4rc+29vXjwG8zXY0KHYSQEeuLSAqRR1xQKRWT9/C+KlR9CP ZD6TIv1yIetioE8lManLtAJZlATqd X-Received: by 2002:a17:906:29c:b0:9ae:47c3:35a0 with SMTP id 28-20020a170906029c00b009ae47c335a0mr260777ejf.47.1695777788081; Tue, 26 Sep 2023 18:23:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEVMdOKD/X10hbOpH6qcKZOGTxacseYAaLyIaQaR5KVR5ivd9rAbFGjG2CYVzJSQkZfrIfdBQ== X-Received: by 2002:a17:906:29c:b0:9ae:47c3:35a0 with SMTP id 28-20020a170906029c00b009ae47c335a0mr260774ejf.47.1695777787846; Tue, 26 Sep 2023 18:23:07 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id rp13-20020a170906d96d00b009ada9f7217asm8429551ejb.88.2023.09.26.18.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 18:23:07 -0700 (PDT) From: Danilo Krummrich To: nouveau@lists.freedesktop.org, faith.ekstrand@collabora.com Subject: [PATCH 1/3] drm/nouveau: chan: use struct nvif_mclass Date: Wed, 27 Sep 2023 03:22:51 +0200 Message-ID: <20230927012303.23525-1-dakr@redhat.com> X-Mailer: git-send-email 2.41.0 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: , Cc: dri-devel@lists.freedesktop.org, kherbst@redhat.com, Danilo Krummrich Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use actual struct nvif_mclass instead of identical anonymous struct. Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/nouveau/nouveau_chan.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c index 1fd5ccf41128..dffbee59be6a 100644 --- a/drivers/gpu/drm/nouveau/nouveau_chan.c +++ b/drivers/gpu/drm/nouveau/nouveau_chan.c @@ -259,10 +259,7 @@ static int nouveau_channel_ctor(struct nouveau_drm *drm, struct nvif_device *device, bool priv, u64 runm, struct nouveau_channel **pchan) { - static const struct { - s32 oclass; - int version; - } hosts[] = { + const struct nvif_mclass hosts[] = { { AMPERE_CHANNEL_GPFIFO_B, 0 }, { AMPERE_CHANNEL_GPFIFO_A, 0 }, { TURING_CHANNEL_GPFIFO_A, 0 }, From patchwork Wed Sep 27 01:22:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13399794 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 B7E3CE7F14B for ; Wed, 27 Sep 2023 01:23:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E49D10E456; Wed, 27 Sep 2023 01:23:17 +0000 (UTC) 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 D784010E456 for ; Wed, 27 Sep 2023 01:23:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695777794; 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=/Nbhk/39NZ1l6uBmAD3wSLQe9P3Plz1M/2g+jaVSYB0=; b=hoIddslBpfI1TPj5mn6dpXA+XNTRF7QFam+9kYeCug1JFEuzpTVTQZpm4FxYin00j5C9eA Q6T28QRf4ooDhFjsaYwsn5aA7gFkzd+ihYzgo2Mr0EFj69AkpVk7ZMorWavLMu9y4UQ9ux Y3JrBtwN8h4Kqni8UOD/D5VA1yyEZKQ= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-259-gWHOOxF7PayZ919p1Cq0Zg-1; Tue, 26 Sep 2023 21:23:12 -0400 X-MC-Unique: gWHOOxF7PayZ919p1Cq0Zg-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-406227680a9so31067245e9.3 for ; Tue, 26 Sep 2023 18:23:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695777791; x=1696382591; 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=/Nbhk/39NZ1l6uBmAD3wSLQe9P3Plz1M/2g+jaVSYB0=; b=A8RgM1lbx6Dt+gm0deWzO16bHxCoJvvkc1Lg36OciYHr/HrtcVgUle5YL1UhSJuuSR EhB4ptpRs/P6SSX4+3YIvaAP5DTllmud1AkSjA8V1t3LYsQnHB2PoPTrl1UmorlPvQ5/ eT/aEYaK+cJr8D+pjokVjTCE+Q5AAQTgMjIUZYTSE7AmIXSgC6vxwDJAEeKkzRhktMc9 KFDNsMaezMeDKrtYk6vVa9Xfgj+iKxog8Vw3pLcWD71MWzP5lOCHgYPcadcCF/7l6x4u m1k8kyzf9zaY8KFSAxZx499g8BRMRwdTAyAMyduuC2iYHyIX87Zqu3cUZajutudDvULG 7zBg== X-Gm-Message-State: AOJu0YxfcN9UlpovAT2eBh7EAXEYAaDzyp2Y9QZ870piNVjYDjVTuIoJ jTwQKQx+VpM9NZYsMwr80zALnp8tE165NO8EOwxFQEiBv7EPZscPlM/nRLGL1jRczg/0yk58+4g g4IpQwfISZUvrGn1sgmi3Qyf346td X-Received: by 2002:a7b:c4cb:0:b0:401:b2c7:349b with SMTP id g11-20020a7bc4cb000000b00401b2c7349bmr507505wmk.7.1695777791536; Tue, 26 Sep 2023 18:23:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvmAbCdHBtbBPYY6OwA93/GuTSA2vpx2zUL7qz1gxZ/SxzZagjHJOuLVzBKH22yWaBd8jbvw== X-Received: by 2002:a7b:c4cb:0:b0:401:b2c7:349b with SMTP id g11-20020a7bc4cb000000b00401b2c7349bmr507483wmk.7.1695777791184; Tue, 26 Sep 2023 18:23:11 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id o12-20020aa7d3cc000000b005259dd903e5sm7355596edr.67.2023.09.26.18.23.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 18:23:10 -0700 (PDT) From: Danilo Krummrich To: nouveau@lists.freedesktop.org, faith.ekstrand@collabora.com Subject: [PATCH 2/3] drm/nouveau: chan: use channel class definitions Date: Wed, 27 Sep 2023 03:22:52 +0200 Message-ID: <20230927012303.23525-2-dakr@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230927012303.23525-1-dakr@redhat.com> References: <20230927012303.23525-1-dakr@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: , Cc: dri-devel@lists.freedesktop.org, kherbst@redhat.com, Danilo Krummrich Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use channel class definitions instead of magic numbers. Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/nouveau/nouveau_chan.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c index dffbee59be6a..ac56f4689ee3 100644 --- a/drivers/gpu/drm/nouveau/nouveau_chan.c +++ b/drivers/gpu/drm/nouveau/nouveau_chan.c @@ -442,9 +442,11 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart) } /* initialise dma tracking parameters */ - switch (chan->user.oclass & 0x00ff) { - case 0x006b: - case 0x006e: + switch (chan->user.oclass) { + case NV03_CHANNEL_DMA: + case NV10_CHANNEL_DMA: + case NV17_CHANNEL_DMA: + case NV40_CHANNEL_DMA: chan->user_put = 0x40; chan->user_get = 0x44; chan->dma.max = (0x10000 / 4) - 2; From patchwork Wed Sep 27 01:22:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13399795 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 A8375E7F151 for ; Wed, 27 Sep 2023 01:23:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8D75910E45D; Wed, 27 Sep 2023 01:23:25 +0000 (UTC) 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 759A710E45A for ; Wed, 27 Sep 2023 01:23:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695777797; 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=ZETDgcYvXOS2PC7AkZaizV/fB2zEHp6MDIY6hZZOccc=; b=ELAFXtbYxqLcNVZ/wL01kvwRvJu/vvdigAzjM5aMn27sf+16sAMmDXU4QJsZjHJm9XehpA Q/qCm/L4JiFSZaaSdRSQzonsxEdNyGqKEyiIXlFmUkyoWmajZs5ohx43xXd2pX2D8oQCom rXAqs4tiHA591Q1UL5V93b4n1FcgBxQ= 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-607-2327pVquNuS8Y9020CboEg-1; Tue, 26 Sep 2023 21:23:15 -0400 X-MC-Unique: 2327pVquNuS8Y9020CboEg-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-32320b9d671so4808024f8f.3 for ; Tue, 26 Sep 2023 18:23:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695777795; x=1696382595; 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=ZETDgcYvXOS2PC7AkZaizV/fB2zEHp6MDIY6hZZOccc=; b=B6ma8yTqLRf9D3aUXk1+y4xkrqGLvzOr6Pk+mJrHu6RwWxBZRympBp8y2wiPbhp1hJ EIydiKr8f2UQqQw/F4e+4d3vkn88ciejTzQDx02MaI1NKsOHL6k+QdXyBT3n/ZjJv0uO oqhSLRLTtBMQJ28HbEO54vFJwvV4ifPjTKFoS12QMjCXWICwbi7Uh/TZib3scCGaMsEp uYQH7eCkp05F8aWnhCprZP8BhAPjEQT19p+4pmNKYTBNS6tRHQoKUozyWMwqK/Qty09s wDnb4GxpbBaUx21KodIADgGCsruTv4lyPj4J++InINlOaXpfkN4twQKCYoUz9j8tsytS y8sw== X-Gm-Message-State: AOJu0YwZeXKUdQnZcQuswGbBPzwR/2+ST1je1tq9I/+dXN3KduilcmPQ JtaSrpF3O9Eun1g2hMBD6O3nquhFWgVFiHPRmmL4oAWhMY6BiMvdSV4FwbcM82KYV8syo6GOedE fMx/0Ix8/VI4R05ZDM15t9EpSs9KX X-Received: by 2002:adf:ea8f:0:b0:31f:e980:df87 with SMTP id s15-20020adfea8f000000b0031fe980df87mr290034wrm.38.1695777794812; Tue, 26 Sep 2023 18:23:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVLakBRZsPHTBTealZhSS4Mg1lASQDH5Mr2lGrw3qzjNzqiI1eKkrPUfmWnfAJkwfzn3DeGQ== X-Received: by 2002:adf:ea8f:0:b0:31f:e980:df87 with SMTP id s15-20020adfea8f000000b0031fe980df87mr290024wrm.38.1695777794592; Tue, 26 Sep 2023 18:23:14 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id bg1-20020a170906a04100b009adce1c97ccsm8495842ejb.53.2023.09.26.18.23.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 18:23:14 -0700 (PDT) From: Danilo Krummrich To: nouveau@lists.freedesktop.org, faith.ekstrand@collabora.com Subject: [PATCH 3/3] drm/nouveau: exec: report max pushs through getparam Date: Wed, 27 Sep 2023 03:22:53 +0200 Message-ID: <20230927012303.23525-3-dakr@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230927012303.23525-1-dakr@redhat.com> References: <20230927012303.23525-1-dakr@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: , Cc: dri-devel@lists.freedesktop.org, kherbst@redhat.com, Danilo Krummrich Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Report the maximum number of IBs that can be pushed with a single DRM_IOCTL_NOUVEAU_EXEC through DRM_IOCTL_NOUVEAU_GETPARAM. While the maximum number of IBs per ring might vary between chipsets, the kernel will make sure that userspace can only push a fraction of the maximum number of IBs per ring per job, such that we avoid a situation where there's only a single job occupying the ring, which could potentially lead to the ring run dry. Using DRM_IOCTL_NOUVEAU_GETPARAM to report the maximum number of IBs that can be pushed with a single DRM_IOCTL_NOUVEAU_EXEC implies that all channels of a given device have the same ring size. Signed-off-by: Danilo Krummrich Acked-by: Faith Ekstrand Reviewed-by: Dave Airlie --- drivers/gpu/drm/nouveau/nouveau_abi16.c | 19 +++++++++++++++++++ drivers/gpu/drm/nouveau/nouveau_chan.c | 2 +- drivers/gpu/drm/nouveau/nouveau_dma.h | 3 +++ drivers/gpu/drm/nouveau/nouveau_exec.c | 7 ++++--- drivers/gpu/drm/nouveau/nouveau_exec.h | 5 +++++ include/uapi/drm/nouveau_drm.h | 10 ++++++++++ 6 files changed, 42 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c index 30afbec9e3b1..1a198689b391 100644 --- a/drivers/gpu/drm/nouveau/nouveau_abi16.c +++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c @@ -31,6 +31,7 @@ #include "nouveau_drv.h" #include "nouveau_dma.h" +#include "nouveau_exec.h" #include "nouveau_gem.h" #include "nouveau_chan.h" #include "nouveau_abi16.h" @@ -183,6 +184,20 @@ nouveau_abi16_fini(struct nouveau_abi16 *abi16) cli->abi16 = NULL; } +static inline unsigned int +getparam_dma_ib_max(struct nvif_device *device) +{ + const struct nvif_mclass dmas[] = { + { NV03_CHANNEL_DMA, 0 }, + { NV10_CHANNEL_DMA, 0 }, + { NV17_CHANNEL_DMA, 0 }, + { NV40_CHANNEL_DMA, 0 }, + {} + }; + + return nvif_mclass(&device->object, dmas) < 0 ? NV50_DMA_IB_MAX : 0; +} + int nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS) { @@ -247,6 +262,10 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS) case NOUVEAU_GETPARAM_GRAPH_UNITS: getparam->value = nvkm_gr_units(gr); break; + case NOUVEAU_GETPARAM_EXEC_PUSH_MAX: + getparam->value = getparam_dma_ib_max(device) / + NOUVEAU_EXEC_PUSH_MAX_DIV; + break; default: NV_PRINTK(dbg, cli, "unknown parameter %lld\n", getparam->param); return -EINVAL; diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c index ac56f4689ee3..c3c2ab887978 100644 --- a/drivers/gpu/drm/nouveau/nouveau_chan.c +++ b/drivers/gpu/drm/nouveau/nouveau_chan.c @@ -456,7 +456,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart) chan->user_get = 0x44; chan->user_get_hi = 0x60; chan->dma.ib_base = 0x10000 / 4; - chan->dma.ib_max = (0x02000 / 8) - 1; + chan->dma.ib_max = NV50_DMA_IB_MAX; chan->dma.ib_put = 0; chan->dma.ib_free = chan->dma.ib_max - chan->dma.ib_put; chan->dma.max = chan->dma.ib_base; diff --git a/drivers/gpu/drm/nouveau/nouveau_dma.h b/drivers/gpu/drm/nouveau/nouveau_dma.h index 1744d95b233e..c52cda82353e 100644 --- a/drivers/gpu/drm/nouveau/nouveau_dma.h +++ b/drivers/gpu/drm/nouveau/nouveau_dma.h @@ -49,6 +49,9 @@ void nv50_dma_push(struct nouveau_channel *, u64 addr, u32 length, /* Maximum push buffer size. */ #define NV50_DMA_PUSH_MAX_LENGTH 0x7fffff +/* Maximum IBs per ring. */ +#define NV50_DMA_IB_MAX ((0x02000 / 8) - 1) + /* Object handles - for stuff that's doesn't use handle == oclass. */ enum { NvDmaFB = 0x80000002, diff --git a/drivers/gpu/drm/nouveau/nouveau_exec.c b/drivers/gpu/drm/nouveau/nouveau_exec.c index ba6913a3efb6..5b5c4a77b8e6 100644 --- a/drivers/gpu/drm/nouveau/nouveau_exec.c +++ b/drivers/gpu/drm/nouveau/nouveau_exec.c @@ -346,7 +346,7 @@ nouveau_exec_ioctl_exec(struct drm_device *dev, struct nouveau_channel *chan = NULL; struct nouveau_exec_job_args args = {}; struct drm_nouveau_exec *req = data; - int ret = 0; + int push_max, ret = 0; if (unlikely(!abi16)) return -ENOMEM; @@ -371,9 +371,10 @@ nouveau_exec_ioctl_exec(struct drm_device *dev, if (!chan->dma.ib_max) return nouveau_abi16_put(abi16, -ENOSYS); - if (unlikely(req->push_count > NOUVEAU_GEM_MAX_PUSH)) { + push_max = chan->dma.ib_max / NOUVEAU_EXEC_PUSH_MAX_DIV; + if (unlikely(req->push_count > push_max)) { NV_PRINTK(err, cli, "pushbuf push count exceeds limit: %d max %d\n", - req->push_count, NOUVEAU_GEM_MAX_PUSH); + req->push_count, push_max); return nouveau_abi16_put(abi16, -EINVAL); } diff --git a/drivers/gpu/drm/nouveau/nouveau_exec.h b/drivers/gpu/drm/nouveau/nouveau_exec.h index b815de2428f3..c6270452e4b5 100644 --- a/drivers/gpu/drm/nouveau/nouveau_exec.h +++ b/drivers/gpu/drm/nouveau/nouveau_exec.h @@ -6,6 +6,11 @@ #include "nouveau_drv.h" #include "nouveau_sched.h" +/* Divider to limit the number of IBs per job to half the size of the ring in + * order to avoid the ring running dry between submissions. + */ +#define NOUVEAU_EXEC_PUSH_MAX_DIV 2 + struct nouveau_exec_job_args { struct drm_file *file_priv; struct nouveau_sched_entity *sched_entity; diff --git a/include/uapi/drm/nouveau_drm.h b/include/uapi/drm/nouveau_drm.h index 8d7402c13e56..eaf9f248619f 100644 --- a/include/uapi/drm/nouveau_drm.h +++ b/include/uapi/drm/nouveau_drm.h @@ -44,6 +44,16 @@ extern "C" { #define NOUVEAU_GETPARAM_PTIMER_TIME 14 #define NOUVEAU_GETPARAM_HAS_BO_USAGE 15 #define NOUVEAU_GETPARAM_HAS_PAGEFLIP 16 + +/** + * @NOUVEAU_GETPARAM_EXEC_PUSH_MAX + * + * Query the maximum amount of IBs that can be pushed through a single + * &drm_nouveau_exec structure and hence a single &DRM_IOCTL_NOUVEAU_EXEC + * ioctl(). + */ +#define NOUVEAU_GETPARAM_EXEC_PUSH_MAX 17 + struct drm_nouveau_getparam { __u64 param; __u64 value;