From patchwork Mon Oct 2 13:46:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13406254 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 E9813E7849A for ; Mon, 2 Oct 2023 13:50:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A3FD910E2B3; Mon, 2 Oct 2023 13:50:50 +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 D897E10E2B4 for ; Mon, 2 Oct 2023 13:50:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696254616; 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=EdwmkXAhuMYAmQvda0CJyoP48Ajvixr20tCNHmIxrMkT0RjRFGl0Tl9HwoY82oGRTvgQHX peTxlcwDkTvI+uj7C3FzHmdhfY8NcHlxQQVEb2qDXgupIR7HIMqk/ReIRcFtsvVcqbp2g7 /o2LhfyQtNWqNVtgwxRSnZhTIcLauPA= 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-629-nPQnsTN9OHK7d-g9aSkQlg-1; Mon, 02 Oct 2023 09:50:15 -0400 X-MC-Unique: nPQnsTN9OHK7d-g9aSkQlg-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-9a9e3f703dfso128115566b.1 for ; Mon, 02 Oct 2023 06:50:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696254614; x=1696859414; 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=GMGmsavU/JY8jHoiK98KIHFCf60oApDoR8FhwIRUWmHLYRtyqcKWLXAuurLL56fYca rVuZtlmZinhulgAOVLFkg7a8e+5S3ybKGm3NNL3a6n0yMrxpLeRhl7zyqX9NTnNQovGb i9TdhHxv0F4PWTvdTzpUfGmAK9+Bg4Wli0JRT+PUUb3YMtVZMOK4f5xnRKRlGW5t8DDu UtVhK7nn1UXduJP2mBOvaVEUZ5XxUzfSmcX9VS+vgdKvuMNVPg5eYZ7DQIjQuK2Wwdvr GVYLO3LOtQZDKMwGbwLFH1+xAiew0YfV7SDkGn7pkIPl4JQGfEfrh0JNQCA6Pq+nw+Vw 8NpQ== X-Gm-Message-State: AOJu0YyQq+8piYklMqEjRLeZS/vcSsLk6JqtRBjkV/Km1UEwkRo/50oU ufkwk3Z4k1S8SFakiP4SroMKbIcXfjpwf0QUFSbw6QQjCWfU0RBm9qQKijeDW/ibmj6WIybgFfB 9mV1b2reEbRQndo36kiXTZRJ/Gbji X-Received: by 2002:a17:906:109e:b0:9ae:41db:c27f with SMTP id u30-20020a170906109e00b009ae41dbc27fmr8638377eju.10.1696254614276; Mon, 02 Oct 2023 06:50:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOyAk2A+5hPWVMwIvF1D2MQJJkYjnhQvamVR/gCygfPW4WM63DnADCGymABNWeANbu1hiwhg== X-Received: by 2002:a17:906:109e:b0:9ae:41db:c27f with SMTP id u30-20020a170906109e00b009ae41dbc27fmr8638363eju.10.1696254613994; Mon, 02 Oct 2023 06:50:13 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id j8-20020a170906050800b009934855d8f1sm16974238eja.34.2023.10.02.06.50.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 06:50:13 -0700 (PDT) From: Danilo Krummrich To: nouveau@lists.freedesktop.org, faith@gfxstrand.net Subject: [PATCH v2 1/3] drm/nouveau: chan: use struct nvif_mclass Date: Mon, 2 Oct 2023 15:46:46 +0200 Message-ID: <20231002135008.10651-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 Reviewed-by: Lyude Paul --- 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 Mon Oct 2 13:46:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13406255 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 DB436E784AD for ; Mon, 2 Oct 2023 13:50:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 37B6910E2BA; Mon, 2 Oct 2023 13:50:52 +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 DA08510E2BB for ; Mon, 2 Oct 2023 13:50:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696254620; 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=YKOQCMhm6MqVMwwMdNmsp6mfuXABhEMsxvgV0JzcN9aOwVHBj00y38GClG6i5REw+wLBkY aNfdgnogin6AQI802tBMaDxSucB0OGBJkBrWhiaVNbX/4YB3alk8m+8zqyJPgHgXPuZ9QN WN9ce42Kp+pmXOWzCDCTTNOlUK3CGn8= 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-171-zT2Jlb4oPKuAiX5MLr1asQ-1; Mon, 02 Oct 2023 09:50:19 -0400 X-MC-Unique: zT2Jlb4oPKuAiX5MLr1asQ-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-9a9d7a801a3so1447576666b.2 for ; Mon, 02 Oct 2023 06:50:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696254618; x=1696859418; 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=EfgTYG03YUM40GvyRL7bGQVe0gUhWq2p1dULpO9FhmlDlfeMD/01Cv87EEwoNpJcF9 GPr7brbwND5+CmZ2TW1szNp/cqRwwFajGvaHPeHOcxtSoRpi68i5gHdfFhGMKQ1PHL0f hqU7MU9JHBxktiBFw9hierOdl0p/HHQ2lJHQzHDzt/1g2NEbOO8w690bHqMMAGhrhn3R ZtUhbbgv0noT/gIBaFoZxAExAemUO4mrTcPC2xMPvjVP8haHeFlL5Lz+KhYpDZD+orGd rcr4CnNJJnUTYNfBJZKAynEKdm2IgK8XiFpDvHYtLZCvoNX4cKuVvwxOOBnsBNF5mQXJ gsaA== X-Gm-Message-State: AOJu0Yz+DAQtn6DB02H17+4ZXSBGwzOlVS92kyTHrdb/uaH41kBnnOID h14qaWwDhAGWRrnHg/K/H0q3sT3BUUjnD8lStIMq198MNJ0BoUdcjnrPAyDrbXNbUwgG1XRxVox J9ZMr5VRr9ZfcA9URAP0YY5NVxp/V X-Received: by 2002:a05:6402:1f0e:b0:530:7ceb:334 with SMTP id b14-20020a0564021f0e00b005307ceb0334mr11528606edb.3.1696254618541; Mon, 02 Oct 2023 06:50:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGd1NWIuOJNKo794dBiPjMLVNbO5xTqJg9iWglcHaQvaejWHQyVJof01QCvXoSO3BIM2RQpyw== X-Received: by 2002:a05:6402:1f0e:b0:530:7ceb:334 with SMTP id b14-20020a0564021f0e00b005307ceb0334mr11528588edb.3.1696254618202; Mon, 02 Oct 2023 06:50:18 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id cm15-20020a0564020c8f00b0053537ad3936sm7981444edb.21.2023.10.02.06.50.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 06:50:17 -0700 (PDT) From: Danilo Krummrich To: nouveau@lists.freedesktop.org, faith@gfxstrand.net Subject: [PATCH v2 2/3] drm/nouveau: chan: use channel class definitions Date: Mon, 2 Oct 2023 15:46:47 +0200 Message-ID: <20231002135008.10651-2-dakr@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231002135008.10651-1-dakr@redhat.com> References: <20231002135008.10651-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 Mon Oct 2 13:46:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13406256 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 EE07AE7849A for ; Mon, 2 Oct 2023 13:51:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 60BC110E2BC; Mon, 2 Oct 2023 13:50:57 +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 D9AB010E2BA for ; Mon, 2 Oct 2023 13:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696254640; 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=warhHSXgI/t+KTjVUeI2wXVbI9QG6djeQc29DPD2B7U=; b=Dhva7rE6oQwPPovGLZEMKPjp/NamD8reRHo2ZSEbr9Y15+tybR/k57MQ+aRhxLt2LjxTMI dQ7HxjTUDUtcNdrRfoF2uGT3UbkPbyuxlJ1ZkiT3z0gHNPPygGJ3H/0r4AbN6Kf0rCsY+N dvynvOXOio4gOTAcbLb8Z8215T1ysgM= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-355-Hl6CeI2AOIKkYVsg8lP3Ig-1; Mon, 02 Oct 2023 09:50:24 -0400 X-MC-Unique: Hl6CeI2AOIKkYVsg8lP3Ig-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-533d8a785a5so11157278a12.3 for ; Mon, 02 Oct 2023 06:50:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696254623; x=1696859423; 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=warhHSXgI/t+KTjVUeI2wXVbI9QG6djeQc29DPD2B7U=; b=FTFa5IWNcDQCuPzd8RcyRgn4LQ+Z0f6L3ZpvToienRW6hCqVzqUK4YnrUayEQq3y+8 Hr/tVzBDgx1MnVDmC4kQ6188htQvb6twwzDmkhxw6cHJIq1QPYzYTY0VFddR2OuXkKrr rdsWdq32iOOAjKK0PlJgLP4cF7frruAZQkOB8gsHJO7ybrwHiVWRKuJOnK10mufa0HDj sMj/BFtR/vuLT7aSFa4a7KpGSm4MVWjk66znioLDgB3FruwlTAkF2XMb5aokdNBFc7Y3 lGzSC7ASV0fhyrU2WIJM2vFZmWhOZagg3vd6Z/klBPjUR4F4d96Q/L9lcwp4LohsjeS7 mjzQ== X-Gm-Message-State: AOJu0YyxlY/8zCjt/CgZY+d0pNKdDBSvY/4IREGJkzIgncbfAUP2/fXm WpA6Vxtj9ilAhbhHf2BKWY5390xApnK7UasAUbxWLZ6hetmSLhPHi9qqDlibE9wcfH71WPR6LAV bYrDXZzFZn7lHZeLjnLvO3Lu2nX6p X-Received: by 2002:a17:906:8472:b0:9b2:ccd8:2d42 with SMTP id hx18-20020a170906847200b009b2ccd82d42mr7760062ejc.32.1696254623065; Mon, 02 Oct 2023 06:50:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYfCckFQAOMGzbEEzF3NniKUhh+9sq4q4srOCNaltqKEjSIX7WQqxZQ6OtR9QO6fwgoZ4evA== X-Received: by 2002:a17:906:8472:b0:9b2:ccd8:2d42 with SMTP id hx18-20020a170906847200b009b2ccd82d42mr7760043ejc.32.1696254622702; Mon, 02 Oct 2023 06:50:22 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id j11-20020a170906278b00b00977eec7b7e8sm17159249ejc.68.2023.10.02.06.50.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 06:50:21 -0700 (PDT) From: Danilo Krummrich To: nouveau@lists.freedesktop.org, faith@gfxstrand.net Subject: [PATCH v2 3/3] drm/nouveau: exec: report max pushs through getparam Date: Mon, 2 Oct 2023 15:46:48 +0200 Message-ID: <20231002135008.10651-3-dakr@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231002135008.10651-1-dakr@redhat.com> References: <20231002135008.10651-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: kherbst@redhat.com, dri-devel@lists.freedesktop.org, Danilo Krummrich , Faith Ekstrand 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. Acked-by: Faith Ekstrand Signed-off-by: Danilo Krummrich --- Changes in V2 ============= - consider the extra slot required by a job's HW fence --- drivers/gpu/drm/nouveau/nouveau_abi16.c | 21 +++++++++++++++++++++ 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 | 10 ++++++++++ include/uapi/drm/nouveau_drm.h | 10 ++++++++++ 6 files changed, 49 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c index 30afbec9e3b1..2edd7bb13fae 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 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,12 @@ 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: { + int ib_max = getparam_dma_ib_max(device); + + getparam->value = nouveau_exec_push_max_from_ib_max(ib_max); + 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..7a40509fa7ea 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 = nouveau_exec_push_max_from_ib_max(chan->dma.ib_max); + 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..5a8fe1208a44 100644 --- a/drivers/gpu/drm/nouveau/nouveau_exec.h +++ b/drivers/gpu/drm/nouveau/nouveau_exec.h @@ -47,4 +47,14 @@ int nouveau_exec_job_init(struct nouveau_exec_job **job, int nouveau_exec_ioctl_exec(struct drm_device *dev, void *data, struct drm_file *file_priv); +static inline unsigned int +nouveau_exec_push_max_from_ib_max(int ib_max) +{ + /* Limit the number of IBs per job to half the size of the ring in order + * to avoid the ring running dry between submissions and preserve one + * more slot for the job's HW fence. + */ + return ib_max > 1 ? ib_max / 2 - 1 : 0; +} + #endif 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;