From: Gustavo Sousa <gustavo.sousa@intel.com>
To: Pallavi Mishra <pallavi.mishra@intel.com>,
<intel-xe@lists.freedesktop.org>
Cc: "Matthew Brost" <matthew.brost@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>
Subject: Re: [PATCH v4 1/2] drm/xe: Store GMD_ID as a struct
Date: Tue, 17 Nov 2026 11:21:14 -0300 [thread overview]
Message-ID: <87se0z7d45.fsf@intel.com> (raw)
In-Reply-To: <20261110232328.842758-2-pallavi.mishra@intel.com>
Pallavi Mishra <pallavi.mishra@intel.com> writes:
> Replace gt->info.gmdid with struct xe_gmdid so the register value and
> subunit stay together. Read GMD_ID once before GuC upload and use the
> stored subunit instead of another MMIO read. Platforms without the
> register store zero.
I think this commit is doing 2 different things and could arguably be
split: (1) move the read/store of the GMD_ID to an earlier point in the
initialization; (2) use a struct type to represent the GMD_ID.
Note, however, that the following patch moves the read/store to happen
even earlier, making (1) unnecessary.
I think it would be better if we re-organized this into the following
patches:
(A) "drm/xe: Read GMD_ID only once", which would, similarly to patch
#2, would do the reading of the GMD_ID values during handle_gmdid()
and assign to the GT info. In this same patch, we would also drop
the extra reads of GMD_ID to use the value in the GT info.
(B) A follow-up patch to turn the u32 gmdid member into a
struct. However, as I mentioned further down, I'm not sure that's
much better than simply using a u32 value with the correct
REG_FIELD_GET() calls.
If we follow this suggestion, some of my comments below might not apply
anymore, but I thought it would be still worth sharing those
considerations. :-)
>
> Signed-off-by: Pallavi Mishra <pallavi.mishra@intel.com>
> ---
> drivers/gpu/drm/xe/xe_device.c | 6 +++---
> drivers/gpu/drm/xe/xe_gt.c | 21 +++++++++++++++------
> drivers/gpu/drm/xe/xe_gt_types.h | 17 +++++++++++++++--
> drivers/gpu/drm/xe/xe_guc.c | 12 +++++-------
> drivers/gpu/drm/xe/xe_query.c | 11 +++++------
> 5 files changed, 43 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
> index 273e2c45fea9..36d659b4eabd 100644
> --- a/drivers/gpu/drm/xe/xe_device.c
> +++ b/drivers/gpu/drm/xe/xe_device.c
> @@ -1321,9 +1321,9 @@ void xe_device_snapshot_print(struct xe_device *xe, struct drm_printer *p)
> drm_printf(p, "\tType: %s\n",
> gt->info.type == XE_GT_TYPE_MAIN ? "main" : "media");
> drm_printf(p, "\tIP ver: %u.%u.%u\n",
> - REG_FIELD_GET(GMD_ID_ARCH_MASK, gt->info.gmdid),
> - REG_FIELD_GET(GMD_ID_RELEASE_MASK, gt->info.gmdid),
> - REG_FIELD_GET(GMD_ID_REVID, gt->info.gmdid));
> + REG_FIELD_GET(GMD_ID_ARCH_MASK, gt->info.gmdid.value),
> + REG_FIELD_GET(GMD_ID_RELEASE_MASK, gt->info.gmdid.value),
> + REG_FIELD_GET(GMD_ID_REVID, gt->info.gmdid.value));
> drm_printf(p, "\tCS reference clock: %u\n", gt->info.reference_clock);
> }
> }
> diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
> index 671b87f1b9e9..becc82566457 100644
> --- a/drivers/gpu/drm/xe/xe_gt.c
> +++ b/drivers/gpu/drm/xe/xe_gt.c
> @@ -534,6 +534,19 @@ static void dump_pat_on_error(struct xe_gt *gt)
> xe_pat_dump(gt, &p);
> }
>
> +/*
> + * Store GMD_ID before GuC upload. Main GAMCTRL consumes the stored subunit
> + * field during upload. Pre-MTL platforms do not implement the register, so
I believe the first two sentences are better suited to the call site
than the function definition, since they seem to explain why the function is
called at a speficic point in time. That said, I think such an
explanation in the commit message should be enough for this case.
The last sentence could be moved to the xe_mmio_read32() call, but I
think it could be rephrased a bit: "Read GMD_ID unconditionally, since
pre-MTL platforms, without the GMD_ID register, will correctly return
zero."
> + * the read returns zero.
> + */
> +static void xe_gt_read_gmdid(struct xe_gt *gt)
> +{
> + u32 raw = xe_mmio_read32(>->mmio, GMD_ID);
> +
> + gt->info.gmdid.value = raw;
> + gt->info.gmdid.subip = REG_FIELD_GET(GMD_ID_SUBIP_FLAG_MASK, raw);
> +}
> +
> static int gt_init_with_gt_forcewake(struct xe_gt *gt)
> {
> int err;
> @@ -542,6 +555,8 @@ static int gt_init_with_gt_forcewake(struct xe_gt *gt)
> if (!fw_ref.domains)
> return -ETIMEDOUT;
>
> + xe_gt_read_gmdid(gt);
> +
> err = xe_uc_init(>->uc);
> if (err)
> return err;
> @@ -580,12 +595,6 @@ static int gt_init_with_gt_forcewake(struct xe_gt *gt)
> if (err)
> return err;
>
> - /*
> - * Stash hardware-reported version. Since this register does not exist
> - * on pre-MTL platforms, reading it there will (correctly) return 0.
> - */
> - gt->info.gmdid = xe_mmio_read32(>->mmio, GMD_ID);
> -
> if (GRAPHICS_VER(gt_to_xe(gt)) >= 20 && xe_gt_is_main_type(gt))
> gt->info.has_wmtp_disabled = !!(xe_mmio_read32(>->mmio, XEHP_FUSE4) &
> CFEG_WMTP_DISABLE);
> diff --git a/drivers/gpu/drm/xe/xe_gt_types.h b/drivers/gpu/drm/xe/xe_gt_types.h
> index c00a7c171f80..7bfcd806aac6 100644
> --- a/drivers/gpu/drm/xe/xe_gt_types.h
> +++ b/drivers/gpu/drm/xe/xe_gt_types.h
> @@ -120,6 +120,19 @@ enum xe_steering_type {
> const struct xe_gt * : (const struct xe_device *)(gt_to_tile(gt__)->xe), \
> struct xe_gt * : gt_to_tile(gt__)->xe)
>
> +/**
> + * struct xe_gmdid - GMD_ID register contents
> + *
> + * Zero on platforms that do not implement GMD_ID, matching a read of the
> + * unimplemented register.
> + */
> +struct xe_gmdid {
> + /** @value: GMD_ID register value */
> + u32 value;
> + /** @subip: GMD_ID[13:6]; subunit indicator on media version 35, else reserved */
> + u8 subip;
This is similar to what was proposed in v1 in the sense that we are
adding an extra member (namely "subip"), adding redudant data that would
also be already available in the "value" member.
If we were to create the struct xe_gmdid, I think it should have the
separate members. Something like:
struct xe_gmdid {
u32 revid:6;
u32 subip:8;
u32 rel:8;
u32 arch:10;
}
And then use the right REG_FIELD_GET() calls when defining its value
(I believe assigning the register value directly could be problematic
because of endianness issues).
That said, I'm still not sure if this is much better than simply storing
the gmdid value directly as a u32 value and using REG_FIELD_GET()
whenever needed.
Adding maintainers to the discussion here in order to get their
technical input.
> +};
> +
> /**
> * struct xe_gt - A "Graphics Technology" unit of the GPU
> *
> @@ -151,8 +164,8 @@ struct xe_gt {
> * See @user_engines.mask
> */
> u64 engine_mask;
> - /** @info.gmdid: raw GMD_ID value from hardware */
> - u32 gmdid;
> + /** @info.gmdid: GMD_ID register contents for this GT */
> + struct xe_gmdid gmdid;
> /**
> * @info.multi_queue_engine_class_mask: Bitmask of engine classes with
> * multi queue support enabled.
> diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
> index 300126e6624f..9b060aa2890e 100644
> --- a/drivers/gpu/drm/xe/xe_guc.c
> +++ b/drivers/gpu/drm/xe/xe_guc.c
> @@ -1888,18 +1888,16 @@ bool xe_guc_using_main_gamctrl_queues(struct xe_guc *guc)
> /*
> * For Xe3p media gt (35), the GuC and the CS subunits may be still Xe3
> * that lacks the Main GAMCTRL support. Reserved bits from the GMD_ID
> - * inform the IP version of the subunits.
> + * inform the IP version of the subunits. Those bits are stored in
> + * gt->info.gmdid.subip and are reserved on other IPs.
> */
> if (xe_gt_is_media_type(gt) && MEDIA_VER(gt_to_xe(gt)) == 35) {
> - u32 val = xe_mmio_read32(>->mmio, GMD_ID);
> - u32 subip = REG_FIELD_GET(GMD_ID_SUBIP_FLAG_MASK, val);
> -
> - if (!subip)
> + if (!gt->info.gmdid.subip)
> return true;
>
> - xe_gt_WARN(gt, subip != 1,
> + xe_gt_WARN(gt, gt->info.gmdid.subip != 1,
> "GMD_ID has unknown value in the SUBIP_FLAG field - 0x%x\n",
> - subip);
> + gt->info.gmdid.subip);
>
> return false;
> }
> diff --git a/drivers/gpu/drm/xe/xe_query.c b/drivers/gpu/drm/xe/xe_query.c
> index dc975f595368..ec621be77a18 100644
> --- a/drivers/gpu/drm/xe/xe_query.c
> +++ b/drivers/gpu/drm/xe/xe_query.c
> @@ -424,12 +424,11 @@ static int query_gt_list(struct xe_device *xe, struct drm_xe_device_query *query
> gt_list->gt_list[iter].near_mem_regions;
>
> gt_list->gt_list[iter].ip_ver_major =
> - REG_FIELD_GET(GMD_ID_ARCH_MASK, gt->info.gmdid);
> - gt_list->gt_list[iter].ip_ver_minor =
> - REG_FIELD_GET(GMD_ID_RELEASE_MASK, gt->info.gmdid);
> - gt_list->gt_list[iter].ip_ver_rev =
> - REG_FIELD_GET(GMD_ID_REVID, gt->info.gmdid);
> -
> + REG_FIELD_GET(GMD_ID_ARCH_MASK, gt->info.gmdid.value);
> + gt_list->gt_list[iter].ip_ver_minor =
> + REG_FIELD_GET(GMD_ID_RELEASE_MASK, gt->info.gmdid.value);
> + gt_list->gt_list[iter].ip_ver_rev =
> + REG_FIELD_GET(GMD_ID_REVID, gt->info.gmdid.value);
Indentation issues here?
--
Gustavo Sousa
> iter++;
> }
>
> --
> 2.43.0
next prev parent reply other threads:[~2026-11-17 14:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 23:23 [PATCH v4 0/2] drm/xe: Store GMD_ID subunit during GT init Pallavi Mishra
2026-11-10 23:23 ` [PATCH v4 1/2] drm/xe: Store GMD_ID as a struct Pallavi Mishra
2026-11-17 14:21 ` Gustavo Sousa [this message]
2026-11-10 23:23 ` [PATCH v4 2/2] drm/xe: Initialize GT GMD_ID from probed info Pallavi Mishra
2026-11-11 0:16 ` ✓ CI.KUnit: success for drm/xe: Store GMD_ID subunit during GT init (rev3) Patchwork
2026-11-11 0:54 ` ✓ Xe.CI.BAT: " Patchwork
2026-11-11 5:05 ` ✗ Xe.CI.FULL: failure " 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=87se0z7d45.fsf@intel.com \
--to=gustavo.sousa@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=pallavi.mishra@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=thomas.hellstrom@linux.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