Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nareshkumar Gollakoti" <naresh.kumar.g@intel.com>,
	intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 3/3] drm/xe: Expose CRI maximum memory frequency and bandwidth in sysfs
Date: Wed, 18 Nov 2026 06:44:16 +0000	[thread overview]
Message-ID: <sashiko-outbox-220269@kernel.org> (raw)
In-Reply-To: <20261118062301.4135537-3-naresh.kumar.g@intel.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] drm/xe: CFI violation in cri_max_freq_show() and max_bw_show()
- [Medium] drm/xe: missing skip_pcode check in
  xe_vram_config_sysfs_init()
- [Low] drm/xe: commit message names max_bw attribute as max_bw_Mbps
--

commit 2489fa624f46a75d6217603f94ec6bc55b6aa131
Author: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>

drm/xe: Expose CRI maximum memory frequency and bandwidth in sysfs

This commit exposes the maximum achievable memory frequency and bandwidth
reported by PCODE on Crescent Island via per-tile sysfs attributes and
documents them in the Xe sysfs ABI.

> Expose the maximum achievable memory frequency and bandwidth reported
> by PCODE MEMORY_CONFIG as read-only tile#/memory/max_freq (MHz) and
> tile#/memory/max_bw_Mbps (Mbps) on Crescent Island.

[Severity: Low]
The commit message refers to the bandwidth attribute as
tile#/memory/max_bw_Mbps, whereas the code and ABI documentation name it
tile<N>/memory/max_bw.

> diff --git a/drivers/gpu/drm/xe/xe_vram_config.c b/drivers/gpu/drm/xe/xe_vram_config.c
> index 31a3405c39abd..4b8661b8597ac 100644
> --- a/drivers/gpu/drm/xe/xe_vram_config.c
> +++ b/drivers/gpu/drm/xe/xe_vram_config.c

[ ... ]

> @@ -84,11 +90,81 @@ static const struct attribute_group freq_group_attrs = {
>  	.attrs = freq_attrs,
>  };
>  
> +static const struct attribute_group *pvc_memory_groups[] = {
> +	&freq_group_attrs,
> +	NULL
> +};
> +
> +static int memory_config_read(struct device *dev, u32 subcmd, u32 *val)
> +{
> +	struct xe_tile *tile = dev_to_tile(dev);
> +
> +	guard(xe_pm_runtime)(tile_to_xe(tile));
> +
> +	return xe_pcode_read(tile, PCODE_MBOX(PCODE_MEMORY_CONFIG, subcmd, 0),
> +			     val, NULL);
> +}
> +
> +static ssize_t cri_max_freq_show(struct device *dev, struct device_attribute *attr,
> +				 char *buf)
> +{
> +	u32 val = 0;
> +	int err;
> +
> +	err = memory_config_read(dev, MEMORY_CONFIG_SUBCOMMAND_READ_MAX_FREQUENCY, &val);
> +	if (err)
> +		return err;
> +
> +	return sysfs_emit(buf, "%u\n", val);
> +}
> +
> +static struct device_attribute dev_attr_cri_max_freq =
> +	__ATTR(max_freq, 0444, cri_max_freq_show, NULL);
> +
> +static ssize_t max_bw_show(struct device *dev, struct device_attribute *attr,
> +			   char *buf)
> +{
> +	u32 val = 0;
> +	int err;
> +
> +	err = memory_config_read(dev, MEMORY_CONFIG_SUBCOMMAND_READ_MAX_BANDWIDTH, &val);
> +	if (err)
> +		return err;
> +
> +	return sysfs_emit(buf, "%u\n", val);
> +}
> +static DEVICE_ATTR_RO(max_bw);

[Severity: High]
Does defining dev_attr_cri_max_freq and dev_attr_max_bw as struct
device_attribute trigger a KCFI trap when reading max_freq or max_bw on
CONFIG_CFI_CLANG kernels?

xe_vram_config_sysfs_init() attaches cri_memory_groups to a dynamic kobject
created with kobject_create_and_add("memory", tile->sysfs).  Reads on that
kobject dispatch through kobj_attr_show(), which casts the attribute to
struct kobj_attribute and calls show(struct kobject *,
struct kobj_attribute *, char *), whereas cri_max_freq_show() and
max_bw_show() take (struct device *, struct device_attribute *, char *) and
pass the bare kobject pointer to memory_config_read() as a struct device *.

These attributes should use struct kobj_attribute, matching 4ea512714c42
("drm/xe: Fix CFI violation when accessing sysfs files").

> +static struct attribute *cri_memory_attrs[] = {
> +	&dev_attr_cri_max_freq.attr,
> +	&dev_attr_max_bw.attr,
> +	NULL
> +};
> +
> +static const struct attribute_group cri_memory_group_attrs = {
> +	.attrs = cri_memory_attrs,
> +};
> +
> +static const struct attribute_group *cri_memory_groups[] = {
> +	&cri_memory_group_attrs,
> +	NULL
> +};
> +
> +static const struct attribute_group **memory_groups(struct xe_device *xe)
> +{
> +	if (xe->info.platform == XE_PVC)
> +		return pvc_memory_groups;
> +	if (xe->info.platform == XE_CRESCENTISLAND)
> +		return cri_memory_groups;
> +	return NULL;
> +}

[Severity: Medium]
Should memory_groups() or xe_vram_config_sysfs_init() check
xe->info.skip_pcode before registering these PCODE-backed attributes?

Crescent Island supports SR-IOV, and vf_update_device_info() sets
xe->info.skip_pcode = 1 on VFs.  Because pcode_mailbox_rw() returns 0
without updating the output value when skip_pcode is set, reading max_freq
and max_bw on a Crescent Island VF will silently succeed and report 0.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261118062301.4135537-1-naresh.kumar.g@intel.com?part=3

  reply	other threads:[~2026-11-18  6:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  6:22 [PATCH 1/3] drm/xe/pcode: Add MEMORY_CONFIG mailbox definitions Nareshkumar Gollakoti
2026-11-18  6:22 ` [PATCH 2/3] drm/xe: Rename xe_vram_freq to xe_vram_config Nareshkumar Gollakoti
2026-11-18  6:53   ` Nilawar, Badal
2026-11-18  6:22 ` [PATCH 3/3] drm/xe: Expose CRI maximum memory frequency and bandwidth in sysfs Nareshkumar Gollakoti
2026-11-18  6:44   ` sashiko-bot [this message]
2026-11-18  6:33 ` ✗ CI.checkpatch: warning for series starting with [1/3] drm/xe/pcode: Add MEMORY_CONFIG mailbox definitions Patchwork
2026-11-18  6:35 ` ✓ CI.KUnit: success " Patchwork
2026-11-18  6:45 ` [PATCH 1/3] " Nilawar, Badal
2026-11-18  7:10 ` ✓ Xe.CI.BAT: success for series starting with [1/3] " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2026-11-18  7:25 [PATCH 0/3] drm/xe: Expose CRI memory capability limits via sysfs Nareshkumar Gollakoti
2026-11-18  7:25 ` [PATCH 3/3] drm/xe: Expose CRI maximum memory frequency and bandwidth in sysfs Nareshkumar Gollakoti
2026-11-18  7:44   ` sashiko-bot

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=sashiko-outbox-220269@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=naresh.kumar.g@intel.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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