From: Raag Jadav <raag.jadav@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: intel-xe@lists.freedesktop.org,
Lucas De Marchi <lucas.demarchi@intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: Re: [PATCH v2 2/2] drm/xe/sysfs: Simplify sysfs registration
Date: Wed, 17 Sep 2025 08:18:59 +0200 [thread overview]
Message-ID: <aMpS02yLhBs5igpM@black.igk.intel.com> (raw)
In-Reply-To: <20250916170029.3313-3-michal.wajdeczko@intel.com>
On Tue, Sep 16, 2025 at 07:00:29PM +0200, Michal Wajdeczko wrote:
> Instead of manually maintaining each sysfs file define and use
> attribute groups and register them using device managed function.
> Then use is_visible() to filter-out unsupported attributes.
>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Raag Jadav <raag.jadav@intel.com>
> Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
> ---
> v2: rebased, reordered
> ---
> drivers/gpu/drm/xe/xe_device_sysfs.c | 104 +++++++++++----------------
> 1 file changed, 41 insertions(+), 63 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_device_sysfs.c b/drivers/gpu/drm/xe/xe_device_sysfs.c
> index 896484c8fbcc..c5151c86a98a 100644
> --- a/drivers/gpu/drm/xe/xe_device_sysfs.c
> +++ b/drivers/gpu/drm/xe/xe_device_sysfs.c
> @@ -71,6 +71,15 @@ vram_d3cold_threshold_store(struct device *dev, struct device_attribute *attr,
>
> static DEVICE_ATTR_RW(vram_d3cold_threshold);
>
> +static struct attribute *vram_attrs[] = {
> + &dev_attr_vram_d3cold_threshold.attr,
> + NULL
> +};
> +
> +static const struct attribute_group vram_attr_group = {
> + .attrs = vram_attrs,
> +};
> +
> static ssize_t
> lb_fan_control_version_show(struct device *dev, struct device_attribute *attr, char *buf)
> {
> @@ -149,8 +158,16 @@ lb_voltage_regulator_version_show(struct device *dev, struct device_attribute *a
> }
> static DEVICE_ATTR_ADMIN_RO(lb_voltage_regulator_version);
>
> -static int late_bind_create_files(struct device *dev)
> +static struct attribute *late_bind_attrs[] = {
> + &dev_attr_lb_fan_control_version.attr,
> + &dev_attr_lb_voltage_regulator_version.attr,
> + NULL
> +};
> +
> +static umode_t late_bind_attr_is_visible(struct kobject *kobj,
> + struct attribute *attr, int n)
> {
> + struct device *dev = kobj_to_dev(kobj);
> struct xe_device *xe = pdev_to_xe_device(to_pci_dev(dev));
> struct xe_tile *root = xe_device_get_root_tile(xe);
> u32 cap = 0;
> @@ -160,51 +177,25 @@ static int late_bind_create_files(struct device *dev)
>
> ret = xe_pcode_read(root, PCODE_MBOX(PCODE_LATE_BINDING, GET_CAPABILITY_STATUS, 0),
> &cap, NULL);
> - if (ret) {
> - if (ret == -ENXIO) {
> - drm_dbg(&xe->drm, "Late binding not supported by firmware\n");
> - ret = 0;
> - }
> - goto out;
> - }
> -
> - if (REG_FIELD_GET(V1_FAN_SUPPORTED, cap)) {
> - ret = sysfs_create_file(&dev->kobj, &dev_attr_lb_fan_control_version.attr);
> - if (ret)
> - goto out;
> - }
> -
> - if (REG_FIELD_GET(VR_PARAMS_SUPPORTED, cap))
> - ret = sysfs_create_file(&dev->kobj, &dev_attr_lb_voltage_regulator_version.attr);
> -out:
> xe_pm_runtime_put(xe);
The device is already in D0 while probing so runtime PM is probably
not needed here.
Raag
next prev parent reply other threads:[~2025-09-17 6:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-16 17:00 [PATCH v2 0/2] drm/xe/sysfs: Fix attributes registration on VFs Michal Wajdeczko
2025-09-16 17:00 ` [PATCH v2 1/2] drm/xe/vf: Don't expose sysfs attributes not applicable for VFs Michal Wajdeczko
2025-09-16 17:07 ` Lucas De Marchi
2025-09-16 17:00 ` [PATCH v2 2/2] drm/xe/sysfs: Simplify sysfs registration Michal Wajdeczko
2025-09-17 6:18 ` Raag Jadav [this message]
2025-09-17 10:24 ` Michal Wajdeczko
2025-09-17 10:52 ` Raag Jadav
2025-09-17 19:38 ` Lucas De Marchi
2025-09-18 8:14 ` Raag Jadav
2025-09-16 17:08 ` ✓ CI.KUnit: success for drm/xe/sysfs: Fix attributes registration on VFs (rev2) Patchwork
2025-09-16 17:54 ` ✓ Xe.CI.BAT: " Patchwork
2025-09-16 18:52 ` ✗ Xe.CI.Full: failure " Patchwork
2025-09-17 19:58 ` Michal Wajdeczko
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=aMpS02yLhBs5igpM@black.igk.intel.com \
--to=raag.jadav@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=lucas.demarchi@intel.com \
--cc=michal.wajdeczko@intel.com \
--cc=rodrigo.vivi@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