From: "Michał Winiarski" <michal.winiarski@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH 05/13] drm/xe/guc: Add object KLV encoding helper
Date: Fri, 3 Jul 2026 16:33:54 +0200 [thread overview]
Message-ID: <akfH5zt6ejAjP8Gn@nostramo> (raw)
In-Reply-To: <20260630132633.32804-6-michal.wajdeczko@intel.com>
On Tue, Jun 30, 2026 at 03:26:24PM +0200, Michal Wajdeczko wrote:
> We plan to encode larger objects as single KLV or set of KLVs.
> Add helper for that.
>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> ---
> drivers/gpu/drm/xe/xe_guc_klv_helpers.c | 36 +++++++++++++++++++++++++
> drivers/gpu/drm/xe/xe_guc_klv_helpers.h | 2 ++
> 2 files changed, 38 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_guc_klv_helpers.c b/drivers/gpu/drm/xe/xe_guc_klv_helpers.c
> index a5fcfc4a6c37..53a8beb9af04 100644
> --- a/drivers/gpu/drm/xe/xe_guc_klv_helpers.c
> +++ b/drivers/gpu/drm/xe/xe_guc_klv_helpers.c
> @@ -274,3 +274,39 @@ u32 *xe_guc_klv_encode_string(u32 *klvs, u32 avail, u16 key, const char *s)
> strscpy_pad((void *)klvs, s, to_num_bytes(len));
> return klvs + len;
> }
> +
> +/**
> + * xe_guc_klv_encode_object() - Encode object using custom encoder as single KLV.
> + * @klvs: the buffer where to place KLV
> + * @avail: number of dwords (u32) available in the buffer
> + * @key: key to be used
> + * @obj: opaque object pointer
> + * @encoder: function pointer to the custom encoder
> + *
> + * Return: pointer to the buffer location past the encoded KLV or
> + * an ERR_PTR if there was no space to encode the KLV.
> + */
> +u32 *xe_guc_klv_encode_object(u32 *klvs, u32 avail, u16 key, const void *obj,
> + u32 *(*encoder)(u32 *klvs, u32 avail, const void *obj))
> +{
> + u32 *end;
> +
> + if (IS_ERR(klvs))
> + return klvs;
> +
> + if (avail < GUC_KLV_LEN_MIN)
> + return ERR_PTR(-ENOSPC);
> +
> + end = encoder(klvs + GUC_KLV_LEN_MIN, avail - GUC_KLV_LEN_MIN, obj);
> + if (IS_ERR(end))
> + return end;
Similar to string helper - we might want to error out if the object
would get truncated (also spotted by sashiko).
Thanks,
-Michał
> +
> + if (WARN_ON(end < klvs + GUC_KLV_LEN_MIN))
> + return ERR_PTR(-EPIPE);
> +
> + if (WARN_ON(end > klvs + avail))
> + return ERR_PTR(-EFBIG);
> +
> + *klvs = PREP_GUC_KLV(key, end - (klvs + GUC_KLV_LEN_MIN));
> + return end;
> +}
> diff --git a/drivers/gpu/drm/xe/xe_guc_klv_helpers.h b/drivers/gpu/drm/xe/xe_guc_klv_helpers.h
> index 1c576456efc5..855805f4463d 100644
> --- a/drivers/gpu/drm/xe/xe_guc_klv_helpers.h
> +++ b/drivers/gpu/drm/xe/xe_guc_klv_helpers.h
> @@ -20,6 +20,8 @@ int xe_guc_klv_count(const u32 *klvs, u32 num_dwords);
> u32 *xe_guc_klv_encode_u32(u32 *klvs, u32 avail, u16 key, u32 value);
> u32 *xe_guc_klv_encode_u64(u32 *klvs, u32 avail, u16 key, u64 value);
> u32 *xe_guc_klv_encode_string(u32 *klvs, u32 avail, u16 key, const char *s);
> +u32 *xe_guc_klv_encode_object(u32 *klvs, u32 avail, u16 key, const void *obj,
> + u32 *(*encoder)(u32 *klvs, u32 avail, const void *obj));
>
> /**
> * PREP_GUC_KLV - Prepare KLV header value based on provided key and len.
> --
> 2.47.1
>
next prev parent reply other threads:[~2026-07-03 14:35 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 13:26 [PATCH 00/13] drm/xe: Add and use more KLV helpers Michal Wajdeczko
2026-06-30 13:26 ` [PATCH 01/13] drm/xe/guc: Allow to print single KLV Michal Wajdeczko
2026-07-03 11:10 ` Michał Winiarski
2026-06-30 13:26 ` [PATCH 02/13] drm/xe/guc: Prepare to print group KLVs Michal Wajdeczko
2026-07-03 11:11 ` Michał Winiarski
2026-06-30 13:26 ` [PATCH 03/13] drm/xe/guc: Add basic KLV encoding helpers Michal Wajdeczko
2026-07-03 12:58 ` Michał Winiarski
2026-06-30 13:26 ` [PATCH 04/13] drm/xe/guc: Add string KLV encoding helper Michal Wajdeczko
2026-07-03 13:29 ` Michał Winiarski
2026-07-06 16:04 ` Michal Wajdeczko
2026-06-30 13:26 ` [PATCH 05/13] drm/xe/guc: Add object " Michal Wajdeczko
2026-07-03 14:33 ` Michał Winiarski [this message]
2026-06-30 13:26 ` [PATCH 06/13] drm/xe/guc: Add KLV parsing helper Michal Wajdeczko
2026-07-03 14:40 ` Michał Winiarski
2026-06-30 13:26 ` [PATCH 07/13] drm/xe/guc: Formalize Reserved KLVs Michal Wajdeczko
2026-07-03 13:31 ` Michał Winiarski
2026-06-30 13:26 ` [PATCH 08/13] drm/xe/tests: Add GuC KLV helpers basic tests Michal Wajdeczko
2026-07-03 14:17 ` Michał Winiarski
2026-06-30 13:26 ` [PATCH 09/13] drm/xe/tests: Add string encoding helper test Michal Wajdeczko
2026-07-03 20:40 ` Michał Winiarski
2026-06-30 13:26 ` [PATCH 10/13] drm/xe/tests: Add object " Michal Wajdeczko
2026-07-03 20:47 ` Michał Winiarski
2026-07-06 16:34 ` Michal Wajdeczko
2026-06-30 13:26 ` [PATCH 11/13] drm/xe/tests: Add GuC KLV printer test Michal Wajdeczko
2026-07-03 20:49 ` Michał Winiarski
2026-06-30 13:26 ` [PATCH 12/13] drm/xe/tests: Add migration packet test Michal Wajdeczko
2026-07-03 13:44 ` Michał Winiarski
2026-07-06 16:42 ` Michal Wajdeczko
2026-06-30 13:26 ` [PATCH 13/13] drm/xe/pf: Handle migration descriptor using KLV helpers Michal Wajdeczko
2026-07-03 20:50 ` Michał Winiarski
2026-06-30 13:47 ` ✗ CI.checkpatch: warning for drm/xe: Add and use more " Patchwork
2026-06-30 13:49 ` ✓ CI.KUnit: success " Patchwork
2026-06-30 14:42 ` ✓ Xe.CI.BAT: " Patchwork
2026-07-01 5:22 ` ✓ Xe.CI.FULL: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=akfH5zt6ejAjP8Gn@nostramo \
--to=michal.winiarski@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=michal.wajdeczko@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox