From nobody Thu Apr 2 01:47:56 2026 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (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 A3B732C0F6D for ; Thu, 19 Feb 2026 20:06:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771531579; cv=none; b=VOZvCWGrJhvufQNwjfH4YQRbp06yYlV2a0TpY9BJ3ajPn06SzsWL1jVXpI48XTZfKoX0DJSNfzLLPuqRSr9Oewtt3UDPud7L/c27WFway7uEQb4wXJX1TXJPjnAZ+KWo8CJnuGH9qiYt3UgrWeCkiB5vX8IFld9yERSdqk9Zvg0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771531579; c=relaxed/simple; bh=NKl8dc59HfgDp8++Pbcvv1t8Oe0mxXnBN0yO+OojQAY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qcPx9INjpT9hZSc/mvLnLIDm/NlZE0WVJsc0YBkQ/h6IsS0HTqrqGbmYjcmJW7UID2OhrGhrgLY9PoR5ski7AS4QybfYZ4uby691EMOOb5inZH0umjjmXYBR63ecwoSlH7I40NeiXm9FY1L4TgpnmSUt3VR1dphSCIcO//I6E1o= 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=sOTPighA; arc=none smtp.client-ip=209.85.219.53 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="sOTPighA" Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-894674a4c4aso20173936d6.3 for ; Thu, 19 Feb 2026 12:06:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=darkrefraction-com.20230601.gappssmtp.com; s=20230601; t=1771531576; x=1772136376; 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=7Uncv38UxGm72QGhelQ6NKI/QxXN75cHDpbsTnqtowY=; b=sOTPighA7MI8xJlmAmXedyTfUI0LL04Hd92LuCeGs5i+YkxKmmXBOCL8ySy7FePdNx LQn+eMwhr9p9OiGwYb5yfopfSkP5WNEUq86BFlF3jDhh9xFOx6yL+dFGU8xP6AhV3yPf YZ4VTjL3o5MKpWDXnoL/9x2XDwXQbT61nUt/6xm4eDlqXtgAXUI5hYIKyqDBdzK4ASzC u7aOVNsclx5cDe/+hJJIH/XVogdL0sUx1t3gPvzE1XCxSuFnX8VI4dfX3ubd4yx0Dg84 9dw+lvGI7DwklmQ5vdtPFCRYxiPnAEffA8gGwC6PQCKGugotAP+edv1YHWOHKK3BVKqH 98iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771531576; x=1772136376; 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=7Uncv38UxGm72QGhelQ6NKI/QxXN75cHDpbsTnqtowY=; b=OpF3730xKH6C8F46/mZAUF6H9m0E3NZM4J0swGfM6rYCvYZUiIymstWhPok0J5HqI6 KyhsQ9O1hY/Lj6pR2Y7PnoP+fOFqfbK7ozk18MA+8ekrQOCdRdPP/0NeBV7TDWM8IbPm 0yJiXodRFOhdgkt8n8HqFd6ld6IQ5Y24hDdcVQEvwZZ76n0P83O4FkXY2GIzS4V6QWxT Cmk0UFlPNiot15LomDx8U+c57bJTPty0IQ+9Z0tKL0RGupq/PpD1b+BfKzxC4GV2cA1k 9lfuZE9Vazvrciwt1IW0vLdygb4syGw39jXxcNs7YhNi+WYg/da9YHWrPmlOhwSFtbQC jT3A== X-Forwarded-Encrypted: i=1; AJvYcCU2H1on+xjo30ncxl9PAwnInaM2mtmMixSn2egdf0iQbAI+jzttw69BY5VvYeU8ZzAw2rYFEvp9ARBJoGk=@vger.kernel.org X-Gm-Message-State: AOJu0Yx3uWXhOqs7X1RZEhGFH0lWz6r94vusKzLXSxb5njPp+NdyqGxW exW+SM843Mkzv/ZgviLfMMrwtiUq36enPnWXm21bBgVwKN595cp/ephuWE6FvbhcmIlqu8lks2i mOhuS X-Gm-Gg: AZuq6aI3iDMVlNFkA1si0YJqqv3n2aa1CNaGszUcldmICdC/SUa3msS1olRkoNzk1dI aCN9/UYMIuT+o3ShfOG3eGZlnKIyOd0ESDeqlR7cMoGAqdTmypaso+AzNvsZCnepCXlrxXkuYN1 VxsU8Kat+SHJjavIsjGnX72YFVYyrU3dIij6s1hKC8Dda7WpuHqhM0oyjCMJElpozCbwL8A5oCR GSwSzpTfYwZtUgakQ/5NELAx1Uxh2/TviAd+JMknzxKwvaYRTcvKYkBJ8sqc2R/qiDiCgFbfEiH gryxg/CTArgLMCE6cM0fp/1EmPNxi6ofVVHl4+oWDSJt+NN0VuiQeku9jFETc6/nambuULXUBip sCXC0mUy+jfuiejrc6CK+47QvIpm1oXD09Tqnkb1teb11fnV1/SVH2wy3kqW0UH8LhGTtD7MS0n EEYKJtuth7saEbWs0y+oGE0PgRC5LXm1UO/p71bU6uBRdDHXnCDpgERYF1G7qskEo7CiPRcfsVX swWQai9Fg== X-Received: by 2002:a05:6214:4109:b0:896:f3de:cc29 with SMTP id 6a1803df08f44-89740302432mr273211576d6.16.1771531576414; Thu, 19 Feb 2026 12:06:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Feb 2026 12:06:15 -0800 (PST) From: Mel Henning Date: Thu, 19 Feb 2026 15:05:53 -0500 Subject: [PATCH v3 1/2] drm/nouveau: Fetch zcull info from device 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-1-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 This information will be exposed to userspace in the following commit. Add struct nvkm_gr_zcull_info, which serves as abstraction layer between the corresponding uAPI (added in a subsequent patch) and the firmware structure. Extend the existing get_ctxbufs callback to also fill in zcull info. ctxsw_size and ctxsw_align come from NV2080_CTRL_CMD_INTERNAL_STATIC_KGR_GET_CONTEXT_BUFFERS_INFO, which is already called by r570_gr_get_ctxbufs, while the rest of the zcull info comes from NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_GRAPHICS_ZCULL. Adding a separate callback for zcull info would require us to either: 1) Call GET_CONTEXT_BUFFERS_INFO twice, once for each callback. This is a little slower and more verbose than calling it once. or 2) Fill out zcull_info partially in r570_gr_get_ctxbufs and partially in the new callback. Since we fill out only some of the info in each we now need to handle edge cases where one function is called but not the other as well as them being called in an arbitrary order. Because of this, it's simplest to combine them in a single call (get_ctxbufs_and_zcull_info), which avoids repeated rpc calls to the gpu without the complexity of handling partially complete states. Signed-off-by: Mel Henning --- drivers/gpu/drm/nouveau/include/nvkm/engine/gr.h | 19 ++++++++++++ .../gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/gr.c | 9 ++++-- .../gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/gr.c | 34 ++++++++++++++++++= ++-- .../drm/nouveau/nvkm/subdev/gsp/rm/r570/nvrm/gr.h | 19 ++++++++++++ drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/rm.h | 2 +- 5 files changed, 77 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvkm/engine/gr.h b/drivers/gpu= /drm/nouveau/include/nvkm/engine/gr.h index a2333cfe6955..490ce410f6cb 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/engine/gr.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/engine/gr.h @@ -3,9 +3,28 @@ #define __NVKM_GR_H__ #include =20 +struct nvkm_gr_zcull_info { + __u32 width_align_pixels; + __u32 height_align_pixels; + __u32 pixel_squares_by_aliquots; + __u32 aliquot_total; + __u32 zcull_region_byte_multiplier; + __u32 zcull_region_header_size; + __u32 zcull_subregion_header_size; + __u32 subregion_count; + __u32 subregion_width_align_pixels; + __u32 subregion_height_align_pixels; + + __u32 ctxsw_size; + __u32 ctxsw_align; +}; + struct nvkm_gr { const struct nvkm_gr_func *func; struct nvkm_engine engine; + + struct nvkm_gr_zcull_info zcull_info; + bool has_zcull_info; }; =20 u64 nvkm_gr_units(struct nvkm_gr *); diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/gr.c b/drivers= /gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/gr.c index ddb57d5e73d6..73844e1e7294 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/gr.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/gr.c @@ -249,7 +249,7 @@ r535_gr_get_ctxbuf_info(struct r535_gr *gr, int i, } =20 static int -r535_gr_get_ctxbufs_info(struct r535_gr *gr) +r535_gr_get_ctxbufs_and_zcull_info(struct r535_gr *gr) { NV2080_CTRL_INTERNAL_STATIC_GR_GET_CONTEXT_BUFFERS_INFO_PARAMS *info; struct nvkm_subdev *subdev =3D &gr->base.engine.subdev; @@ -265,6 +265,9 @@ r535_gr_get_ctxbufs_info(struct r535_gr *gr) r535_gr_get_ctxbuf_info(gr, i, &info->engineContextBuffersInfo[0].engine= [i]); =20 nvkm_gsp_rm_ctrl_done(&gsp->internal.device.subdevice, info); + + gr->base.has_zcull_info =3D false; + return 0; } =20 @@ -312,7 +315,7 @@ r535_gr_oneinit(struct nvkm_gr *base) * * Also build the information that'll be used to create channel contexts. */ - ret =3D rm->api->gr->get_ctxbufs_info(gr); + ret =3D rm->api->gr->get_ctxbufs_and_zcull_info(gr); if (ret) goto done; =20 @@ -352,5 +355,5 @@ r535_gr_dtor(struct nvkm_gr *base) =20 const struct nvkm_rm_api_gr r535_gr =3D { - .get_ctxbufs_info =3D r535_gr_get_ctxbufs_info, + .get_ctxbufs_and_zcull_info =3D r535_gr_get_ctxbufs_and_zcull_info, }; diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/gr.c b/drivers= /gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/gr.c index b6cced9b8aa1..8dd4552aeaa5 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/gr.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/gr.c @@ -164,9 +164,10 @@ r570_gr_scrubber_init(struct r535_gr *gr) } =20 static int -r570_gr_get_ctxbufs_info(struct r535_gr *gr) +r570_gr_get_ctxbufs_and_zcull_info(struct r535_gr *gr) { NV2080_CTRL_INTERNAL_STATIC_GR_GET_CONTEXT_BUFFERS_INFO_PARAMS *info; + NV2080_CTRL_GR_GET_ZCULL_INFO_PARAMS *zcull_info; struct nvkm_subdev *subdev =3D &gr->base.engine.subdev; struct nvkm_gsp *gsp =3D subdev->device->gsp; =20 @@ -179,13 +180,42 @@ r570_gr_get_ctxbufs_info(struct r535_gr *gr) for (int i =3D 0; i < ARRAY_SIZE(info->engineContextBuffersInfo[0].engine= ); i++) r535_gr_get_ctxbuf_info(gr, i, &info->engineContextBuffersInfo[0].engine= [i]); =20 + NV2080_CTRL_INTERNAL_ENGINE_CONTEXT_BUFFER_INFO zcull =3D info->engineCon= textBuffersInfo[0] + .engine[NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_GRAPHIC= S_ZCULL]; + gr->base.zcull_info.ctxsw_size =3D zcull.size; + gr->base.zcull_info.ctxsw_align =3D zcull.alignment; + nvkm_gsp_rm_ctrl_done(&gsp->internal.device.subdevice, info); + + zcull_info =3D nvkm_gsp_rm_ctrl_rd(&gsp->internal.device.subdevice, + NV2080_CTRL_CMD_GR_GET_ZCULL_INFO, + sizeof(*zcull_info)); + if (IS_ERR(zcull_info)) { + nvdev_error(gr->base.engine.subdev.device, "could not fetch zcull info\n= "); + return PTR_ERR(zcull_info); + } + + gr->base.zcull_info.width_align_pixels =3D zcull_info->widthAlignPixels; + gr->base.zcull_info.height_align_pixels =3D zcull_info->heightAlignPixels; + gr->base.zcull_info.pixel_squares_by_aliquots =3D zcull_info->pixelSquare= sByAliquots; + gr->base.zcull_info.aliquot_total =3D zcull_info->aliquotTotal; + gr->base.zcull_info.zcull_region_byte_multiplier =3D zcull_info->zcullReg= ionByteMultiplier; + gr->base.zcull_info.zcull_region_header_size =3D zcull_info->zcullRegionH= eaderSize; + gr->base.zcull_info.zcull_subregion_header_size =3D zcull_info->zcullSubr= egionHeaderSize; + gr->base.zcull_info.subregion_count =3D zcull_info->subregionCount; + gr->base.zcull_info.subregion_width_align_pixels =3D zcull_info->subregio= nWidthAlignPixels; + gr->base.zcull_info.subregion_height_align_pixels =3D zcull_info->subregi= onHeightAlignPixels; + + nvkm_gsp_rm_ctrl_done(&gsp->internal.device.subdevice, zcull_info); + + gr->base.has_zcull_info =3D true; + return 0; } =20 const struct nvkm_rm_api_gr r570_gr =3D { - .get_ctxbufs_info =3D r570_gr_get_ctxbufs_info, + .get_ctxbufs_and_zcull_info =3D r570_gr_get_ctxbufs_and_zcull_info, .scrubber.init =3D r570_gr_scrubber_init, .scrubber.fini =3D r570_gr_scrubber_fini, }; diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/nvrm/gr.h b/dr= ivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/nvrm/gr.h index feed1dabd9d2..a7a15a4de9d5 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/nvrm/gr.h +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/nvrm/gr.h @@ -76,4 +76,23 @@ typedef struct NV2080_CTRL_INTERNAL_GR_INIT_BUG4208224_W= AR_PARAMS { } NV2080_CTRL_INTERNAL_GR_INIT_BUG4208224_WAR_PARAMS; =20 #define NV2080_CTRL_CMD_INTERNAL_KGR_INIT_BUG4208224_WAR (0x20800a46) /* f= inn: Evaluated from "(FINN_NV20_SUBDEVICE_0_INTERNAL_INTERFACE_ID << 8) | N= V2080_CTRL_INTERNAL_KGR_INIT_BUG4208224_WAR_PARAMS_MESSAGE_ID" */ + +#define NV2080_CTRL_CMD_GR_GET_ZCULL_INFO (0x20801206U) /* finn= : Evaluated from "(FINN_NV20_SUBDEVICE_0_GR_INTERFACE_ID << 8) | NV2080_CTR= L_GR_GET_ZCULL_INFO_PARAMS_MESSAGE_ID" */ + +#define NV2080_CTRL_GR_GET_ZCULL_INFO_PARAMS_SUBREGION_SUPPORTED +#define NV2080_CTRL_GR_GET_ZCULL_INFO_PARAMS_MESSAGE_ID (0x6U) + +typedef struct NV2080_CTRL_GR_GET_ZCULL_INFO_PARAMS { + NvU32 widthAlignPixels; + NvU32 heightAlignPixels; + NvU32 pixelSquaresByAliquots; + NvU32 aliquotTotal; + NvU32 zcullRegionByteMultiplier; + NvU32 zcullRegionHeaderSize; + NvU32 zcullSubregionHeaderSize; + NvU32 subregionCount; + NvU32 subregionWidthAlignPixels; + NvU32 subregionHeightAlignPixels; +} NV2080_CTRL_GR_GET_ZCULL_INFO_PARAMS; + #endif diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/rm.h b/drivers/gpu/= drm/nouveau/nvkm/subdev/gsp/rm/rm.h index 393ea775941f..0fb0e67406c6 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/rm.h +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/rm.h @@ -124,7 +124,7 @@ struct nvkm_rm_api { } *ce, *nvdec, *nvenc, *nvjpg, *ofa; =20 const struct nvkm_rm_api_gr { - int (*get_ctxbufs_info)(struct r535_gr *); + int (*get_ctxbufs_and_zcull_info)(struct r535_gr *); struct { int (*init)(struct r535_gr *); void (*fini)(struct r535_gr *); --=20 2.53.0