From nobody Thu Apr 2 01:46:31 2026 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FB2430C613 for ; Thu, 19 Feb 2026 20:06:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771531580; cv=none; b=cY2lvtX7G5sCOXhs6yo0XcFOHivVkYxMm9AJ3xdp9uGPUV0QjvIb3tGlPl1AyoLffr2WkuJ5s5kZvUKxQTgR076sHpfrVkqM505zu8/GSHe8HrE3sxu1eWIDQ4i1305m6wCwDYpbVJuCUJ5JK4l8z3zlaOVYJcMZRag27tM+uRM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771531580; c=relaxed/simple; bh=Phvr2AnkenxpqAkwkprP2tnAF8TQSTRr96FsudX9GmM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZvVrNNgYOFicDEdmkLLga2Cm1n/YDkq72msSDWctxb5DlBh+C8yPwPGv3aZXMM227twlDRQMcqIv20PxDgSrBn2VFix5dtG5E9vcKt2hIdk5vA3RPIZwWN0Z6MIfdCTo71kAS3g4liSecHfHQSAnBhAgvwZFWa0lS2mW+4b2k4w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=darkrefraction.com; spf=none smtp.mailfrom=darkrefraction.com; dkim=pass (2048-bit key) header.d=darkrefraction-com.20230601.gappssmtp.com header.i=@darkrefraction-com.20230601.gappssmtp.com header.b=t1+Opo71; arc=none smtp.client-ip=209.85.219.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=darkrefraction.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=darkrefraction.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=darkrefraction-com.20230601.gappssmtp.com header.i=@darkrefraction-com.20230601.gappssmtp.com header.b="t1+Opo71" Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-896fb37d1f0so22096156d6.2 for ; Thu, 19 Feb 2026 12:06:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=darkrefraction-com.20230601.gappssmtp.com; s=20230601; t=1771531577; x=1772136377; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=LXWvhKY40NwAh0sJpltiG5AWknO8aVooYAaWfER0QVg=; b=t1+Opo716eBrIGJAVoVhxrvjoq3pCmG9njdAOD9HL7GkNC/HHR+pyD21AfNd9L0EiK D+/MUEj3IljeNkyuE2k2eW8+b95/ZKuLEXZUBjoXZcw/PGl/K3UNXR2qVtX9mohmykNF h/7Q0GErdR6oAINFHqeFgNam0XE6pkMCm7d5zx5yacjS9xA1w5w2FKoHGkWuyz37vY7P v1oRfeQMQoGShjRCsTX9+/eCNRMZ1+RuJc5FqjV8RaQFIRFRLvhU5+J67oIRRI7BM0zg uueT/v6Gx3Kn/k7bOI2goILY8kFQIS7Cl5L5ELrg1d86Jhw9jPFCTWIMkVv44YjKHpEy HPRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771531577; x=1772136377; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=LXWvhKY40NwAh0sJpltiG5AWknO8aVooYAaWfER0QVg=; b=fGafZf/QGQlzNlP7/VDputBRx6ldYwjlZuM2VITrKJbfI2nrm+WsYB+pmQ1g2EF/Ri BI62Fx+pY4GucOwi7yvlHNvtO9ylQFj4yUNx4EDs1c4w6HhapKdN5mKPuYmwmV+Yougw deagJ1kT+MY6uR+fPOlLlHqgkm1soP8OVwHzUUehxHTUjkUrvNBFetw7/NBdOadcogoD vjTVimuyge07E/49GHur1GW+L9WZbOVRMTcTd/ePKagMBXrqnZRtJWuwP32MQykmWESq oeQnt6Qm2LwCRuHqsgErslFnpVtNWhFaN9aM/PBCpgyRnXrvTdwSKa3cCdv5YLwougO7 0LWg== X-Forwarded-Encrypted: i=1; AJvYcCU/3ouIHFf7PhtFBs/cOI50FiWZI8HHG1afbQ3zvGw1l7gRpp2udfn/GPh/bEN3V5TrQwXiY5FOP/cZVxU=@vger.kernel.org X-Gm-Message-State: AOJu0YysksHPA4pQvcN2j2eYEOJ+VicjTsn8we2/ceOguS7es5+29+13 hXzaOfvoj57dHLX00CQ56eoikJpmnGNklIup5uyYAXY/rFjKBrotSe+LwMpEYn15yS7J4yJLVRQ mp89O X-Gm-Gg: AZuq6aIA+VQRR6ueumv1ZE36r7HIyNH2K3vjy3g0ZvEqORfUWlhSudoACTbMPiqAOlO SwQwoL7CyD8PHpBFRzNndMjYztqPTZi3sDilvxnQ0fV3OtdaH7+ahaOwA6h1nbhInwqUFdsYAxR Xsz2una2qtffel7N054ABVhFiAe/u2cSbd+1GHM7J5xwVLs5lw8idpeqUoaemsAk/mPPH7IIxiL 5wYseVqvHmOSagwEEoB0L+U9eAkwJhqarCLpJzhdTkPGsc8ic9eFiF5QvgtMyohzIzmCJE1Qv2w SD5cyrKTMv2i/CJXWANUCQYaPFEzk2tf4qV7czjUiJlWhxeqR8HFx5UaXUoI2XuboeYZ9yGbXmc eTO08AOEeBaa0SDXgG1zJioK2cPThboZVwVs44UgQqwz2D3O5ZAd0GcesSOvSfS4GkaKKb6Dubh skNa0ltRNOoBVmi3pQ2EZ7RBh5LMwcN6ej0PpreTRhEwRNRfuXczPhdrLUXB6ow7t2khxVl08Sc e7S4n18Bg== X-Received: by 2002:ad4:5d66:0:b0:894:68fa:37e6 with SMTP id 6a1803df08f44-897404c9f34mr300821276d6.58.1771531577432; Thu, 19 Feb 2026 12:06:17 -0800 (PST) Received: from [96.232.40.90] (pool-96-232-40-90.nycmny.fios.verizon.net. [96.232.40.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8971c8e60a0sm216675066d6.0.2026.02.19.12.06.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Feb 2026 12:06:16 -0800 (PST) From: Mel Henning Date: Thu, 19 Feb 2026 15:05:54 -0500 Subject: [PATCH v3 2/2] drm/nouveau: Add DRM_IOCTL_NOUVEAU_GET_ZCULL_INFO Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260219-zcull3-v3-2-dbe6a716f104@darkrefraction.com> References: <20260219-zcull3-v3-0-dbe6a716f104@darkrefraction.com> In-Reply-To: <20260219-zcull3-v3-0-dbe6a716f104@darkrefraction.com> To: Lyude Paul , Danilo Krummrich , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Mary Guillemard Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, Mel Henning X-Mailer: b4 0.14.3 Add kernel-side support for using the zcull hardware in nvidia gpus. zcull aims to improve memory bandwidth by using an early approximate depth test, similar to hierarchical Z on an AMD card. Add a new ioctl that exposes zcull information that has been read from the hardware. Userspace uses each of these parameters either in a heuristic for determining zcull region parameters or in the calculation of a buffer size. It appears the hardware hasn't changed its structure for these values since FERMI_C (circa 2011), so the assumption is that it won't change on us too quickly, and is therefore reasonable to include in UAPI. This bypasses the nvif layer and instead accesses nvkm_gr directly, which mirrors existing usage of nvkm_gr_units(). There is no nvif object for nvkm_gr yet, and adding one is not trivial. Signed-off-by: Mel Henning --- drivers/gpu/drm/nouveau/nouveau_abi16.c | 29 +++++++++++++++ drivers/gpu/drm/nouveau/nouveau_abi16.h | 1 + drivers/gpu/drm/nouveau/nouveau_drm.c | 1 + include/uapi/drm/nouveau_drm.h | 66 +++++++++++++++++++++++++++++= ++++ 4 files changed, 97 insertions(+) diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouv= eau/nouveau_abi16.c index a3ba07fc48a0..5f3e7560a84e 100644 --- a/drivers/gpu/drm/nouveau/nouveau_abi16.c +++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c @@ -333,6 +333,35 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS) return 0; } =20 +int +nouveau_abi16_ioctl_get_zcull_info(ABI16_IOCTL_ARGS) +{ + struct nouveau_drm *drm =3D nouveau_drm(dev); + struct nvkm_gr *gr =3D nvxx_gr(drm); + struct drm_nouveau_get_zcull_info *out =3D data; + + if (gr->has_zcull_info) { + const struct nvkm_gr_zcull_info *i =3D &gr->zcull_info; + + out->width_align_pixels =3D i->width_align_pixels; + out->height_align_pixels =3D i->height_align_pixels; + out->pixel_squares_by_aliquots =3D i->pixel_squares_by_aliquots; + out->aliquot_total =3D i->aliquot_total; + out->zcull_region_byte_multiplier =3D i->zcull_region_byte_multiplier; + out->zcull_region_header_size =3D i->zcull_region_header_size; + out->zcull_subregion_header_size =3D i->zcull_subregion_header_size; + out->subregion_count =3D i->subregion_count; + out->subregion_width_align_pixels =3D i->subregion_width_align_pixels; + out->subregion_height_align_pixels =3D i->subregion_height_align_pixels; + out->ctxsw_size =3D i->ctxsw_size; + out->ctxsw_align =3D i->ctxsw_align; + + return 0; + } else { + return -ENOTTY; + } +} + int nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS) { diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.h b/drivers/gpu/drm/nouv= eau/nouveau_abi16.h index af6b4e1cefd2..134b3ab58719 100644 --- a/drivers/gpu/drm/nouveau/nouveau_abi16.h +++ b/drivers/gpu/drm/nouveau/nouveau_abi16.h @@ -6,6 +6,7 @@ struct drm_device *dev, void *data, struct drm_file *file_priv =20 int nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS); +int nouveau_abi16_ioctl_get_zcull_info(ABI16_IOCTL_ARGS); int nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS); int nouveau_abi16_ioctl_channel_free(ABI16_IOCTL_ARGS); int nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS); diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouvea= u/nouveau_drm.c index 1527b801f013..b698ac38e947 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -1272,6 +1272,7 @@ nouveau_ioctls[] =3D { DRM_IOCTL_DEF_DRV(NOUVEAU_GROBJ_ALLOC, nouveau_abi16_ioctl_grobj_alloc, D= RM_RENDER_ALLOW), DRM_IOCTL_DEF_DRV(NOUVEAU_NOTIFIEROBJ_ALLOC, nouveau_abi16_ioctl_notifier= obj_alloc, DRM_RENDER_ALLOW), DRM_IOCTL_DEF_DRV(NOUVEAU_GPUOBJ_FREE, nouveau_abi16_ioctl_gpuobj_free, D= RM_RENDER_ALLOW), + DRM_IOCTL_DEF_DRV(NOUVEAU_GET_ZCULL_INFO, nouveau_abi16_ioctl_get_zcull_i= nfo, DRM_RENDER_ALLOW), DRM_IOCTL_DEF_DRV(NOUVEAU_SVM_INIT, nouveau_svmm_init, DRM_RENDER_ALLOW), DRM_IOCTL_DEF_DRV(NOUVEAU_SVM_BIND, nouveau_svmm_bind, DRM_RENDER_ALLOW), DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_NEW, nouveau_gem_ioctl_new, DRM_RENDER_ALLO= W), diff --git a/include/uapi/drm/nouveau_drm.h b/include/uapi/drm/nouveau_drm.h index dd87f8f30793..1fa82fa6af38 100644 --- a/include/uapi/drm/nouveau_drm.h +++ b/include/uapi/drm/nouveau_drm.h @@ -432,6 +432,69 @@ struct drm_nouveau_exec { __u64 push_ptr; }; =20 +struct drm_nouveau_get_zcull_info { + /** + * @width_align_pixels: required alignment for region widths, in pixels + * (typically #TPC's * 16). + */ + __u32 width_align_pixels; + /** + * @height_align_pixels: required alignment for region heights, in + * pixels (typically 32). + */ + __u32 height_align_pixels; + /** + * @pixel_squares_by_aliquots: the pixel area covered by an aliquot + * (typically #Zcull_banks * 16 * 16). + */ + __u32 pixel_squares_by_aliquots; + /** + * @aliquot_total: the total aliquot pool available in hardware + */ + __u32 aliquot_total; + /** + * @zcull_region_byte_multiplier: the size of an aliquot in bytes, which + * is used for save/restore operations on a region + */ + __u32 zcull_region_byte_multiplier; + /** + * @zcull_region_header_size: the region header size in bytes, which is + * used for save/restore operations on a region + */ + __u32 zcull_region_header_size; + /** + * @zcull_subregion_header_size: the subregion header size in bytes, + * which is used for save/restore operations on a region + */ + __u32 zcull_subregion_header_size; + /** + * @subregion_count: the total number of subregions the hardware + * supports + */ + __u32 subregion_count; + /** + * @subregion_width_align_pixels: required alignment for subregion + * widths, in pixels (typically #TPC's * 16). + */ + __u32 subregion_width_align_pixels; + /** + * @subregion_height_align_pixels: required alignment for subregion + * heights, in pixels + */ + __u32 subregion_height_align_pixels; + + /** + * @ctxsw_size: the size, in bytes, of a zcull context switching region. + * Will be zero if the kernel does not support zcull context switching. + */ + __u32 ctxsw_size; + /** + * @ctxsw_align: the alignment, in bytes, of a zcull context switching + * region + */ + __u32 ctxsw_align; +}; + #define DRM_NOUVEAU_GETPARAM 0x00 #define DRM_NOUVEAU_SETPARAM 0x01 /* deprecated */ #define DRM_NOUVEAU_CHANNEL_ALLOC 0x02 @@ -445,6 +508,7 @@ struct drm_nouveau_exec { #define DRM_NOUVEAU_VM_INIT 0x10 #define DRM_NOUVEAU_VM_BIND 0x11 #define DRM_NOUVEAU_EXEC 0x12 +#define DRM_NOUVEAU_GET_ZCULL_INFO 0x13 #define DRM_NOUVEAU_GEM_NEW 0x40 #define DRM_NOUVEAU_GEM_PUSHBUF 0x41 #define DRM_NOUVEAU_GEM_CPU_PREP 0x42 @@ -513,6 +577,8 @@ struct drm_nouveau_svm_bind { #define DRM_IOCTL_NOUVEAU_VM_INIT DRM_IOWR(DRM_COMMAND_BASE + D= RM_NOUVEAU_VM_INIT, struct drm_nouveau_vm_init) #define DRM_IOCTL_NOUVEAU_VM_BIND DRM_IOWR(DRM_COMMAND_BASE + D= RM_NOUVEAU_VM_BIND, struct drm_nouveau_vm_bind) #define DRM_IOCTL_NOUVEAU_EXEC DRM_IOWR(DRM_COMMAND_BASE + D= RM_NOUVEAU_EXEC, struct drm_nouveau_exec) + +#define DRM_IOCTL_NOUVEAU_GET_ZCULL_INFO DRM_IOR (DRM_COMMAND_BASE + D= RM_NOUVEAU_GET_ZCULL_INFO, struct drm_nouveau_get_zcull_info) #if defined(__cplusplus) } #endif --=20 2.53.0