All of lore.kernel.org
 help / color / mirror / Atom feed
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 1/2] drm/xe/sysfs: Simplify and fix sysfs registration
Date: Mon, 15 Sep 2025 17:17:11 +0200	[thread overview]
Message-ID: <aMgt994Z4Yr99mHF@black.igk.intel.com> (raw)
In-Reply-To: <20250915140614.2076-2-michal.wajdeczko@intel.com>

On Mon, Sep 15, 2025 at 04:06:13PM +0200, Michal Wajdeczko wrote:
> Instead of manually maintaining each sysfs attribute define and use
> attribute groups and register them using device managed function.
> Then use is_visible() to filter-out unsupported attributes.
> 
> This will result not only in less code and smaller footprint:
> 
>   Function                                     old     new   delta
>   late_bind_attr_is_visible                      -     183    +183
>   ____versions                               80832   80896     +64
>   vram_attr_group                                -      48     +48
>   late_bind_attr_group                           -      48     +48
>   auto_link_downgrade_attr_group                 -      48     +48
>   late_bind_attrs                                -      24     +24
>   vram_attrs                                     -      16     +16
>   __pfx_late_bind_attr_is_visible                -      16     +16
>   xe_device_sysfs_init.cold                     20      21      +1
>   __pfx_xe_device_sysfs_fini                    16       -     -16
>   xe_device_sysfs_fini.cold                     21       -     -21
>   xe_device_sysfs_fini                         271       -    -271
>   xe_device_sysfs_init                         421     135    -286
>   Total: Before=2848898, After=2848752, chg -0.01%

I find the summary to be sufficient but upto you.

> but will also fix some bad error handling that we had here.
> 
> Fixes: 0e414bf7ad01 ("drm/xe: Expose PCIe link downgrade attributes")
> Fixes: cdc36b66cd41 ("drm/xe: Expose fan control and voltage regulator version")
> 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>
> ---
>  drivers/gpu/drm/xe/xe_device_sysfs.c | 96 +++++++++++-----------------
>  1 file changed, 39 insertions(+), 57 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_device_sysfs.c b/drivers/gpu/drm/xe/xe_device_sysfs.c
> index 6ee422594b56..5b0b98ac9b17 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);
> -
> -	return ret;
> -}
> -
> -static void late_bind_remove_files(struct device *dev)
> -{
> -	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;
> -	int ret;
> -
> -	xe_pm_runtime_get(xe);
> -
> -	ret = xe_pcode_read(root, PCODE_MBOX(PCODE_LATE_BINDING, GET_CAPABILITY_STATUS, 0),
> -			    &cap, NULL);
>  	if (ret)
> -		goto out;
> +		return 0;

Should we keep the original log so we don't have to guesswork our way around
random pcode errors?

PS: I've found patience algo to generate much readable diffs but ofcourse
it's a personal preference :)

Raag

  parent reply	other threads:[~2025-09-15 15:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-15 14:06 [PATCH 0/2] drm/xe/sysfs: Fix attributes registration on VFs Michal Wajdeczko
2025-09-15 14:06 ` [PATCH 1/2] drm/xe/sysfs: Simplify and fix sysfs registration Michal Wajdeczko
2025-09-15 15:12   ` Lucas De Marchi
2025-09-15 15:33     ` Michal Wajdeczko
2025-09-16 13:52       ` Lucas De Marchi
2025-09-16 14:56         ` Michal Wajdeczko
2025-09-15 15:17   ` Raag Jadav [this message]
2025-09-15 15:51     ` Michal Wajdeczko
2025-09-15 16:03       ` Raag Jadav
2025-09-15 14:06 ` [PATCH 2/2] drm/xe/vf: Don't expose sysfs attributes not applicable for VFs Michal Wajdeczko
2025-09-15 15:18   ` Raag Jadav
2025-09-15 14:12 ` ✓ CI.KUnit: success for drm/xe/sysfs: Fix attributes registration on VFs Patchwork
2025-09-15 14:51 ` ✓ Xe.CI.BAT: " Patchwork
2025-09-15 17:44 ` ✗ 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=aMgt994Z4Yr99mHF@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.