drm/xe: Introduce xe_pm_sysfs.c
Subsystems (2)
PATCH 1/1 drm/xe: Introduce xe_pm_sysfs.c
Introduce xe_pm_sysfs.c for Power Management knobs and move existing attributes to it.
---
This depends on BMG PCIe link downgrade series[1].
[1] https://lore.kernel.org/r/[email protected]
drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/xe_device_sysfs.c | 64 +--------------------- drivers/gpu/drm/xe/xe_device_sysfs.h | 1 - drivers/gpu/drm/xe/xe_pm.c | 2 +- drivers/gpu/drm/xe/xe_pm_sysfs.c | 81 ++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_pm_sysfs.h | 13 +++++ 6 files changed, 97 insertions(+), 65 deletions(-) create mode 100644 drivers/gpu/drm/xe/xe_pm_sysfs.c create mode 100644 drivers/gpu/drm/xe/xe_pm_sysfs.h
drivers/gpu/drm/xe/Makefile +1 -0
@@ -86,6 +86,7 @@ xe-y += xe_bb.o \ xe_pci.o \ xe_pcode.o \ xe_pm.o \ + xe_pm_sysfs.o \ xe_preempt_fence.o \ xe_pt.o \ xe_pt_walk.o \
drivers/gpu/drm/xe/xe_device_sysfs.c +1 -63
82 lines not on this page · raw message
drivers/gpu/drm/xe/xe_device_sysfs.h +0 -1
@@ -8,7 +8,6 @@struct xe_device ; -int xe_pm_sysfs_init (struct xe_device *xe);int xe_device_sysfs_init (struct xe_device *xe);#endif
drivers/gpu/drm/xe/xe_pm.c +1 -1
@@ -16,12 +16,12 @@#include "xe_bo.h" #include "xe_bo_evict.h" #include "xe_device.h" -#include "xe_device_sysfs.h" #include "xe_ggtt.h" #include "xe_gt.h" #include "xe_guc.h" #include "xe_irq.h" #include "xe_pcode.h" +#include "xe_pm_sysfs.h" #include "xe_pxp.h" #include "xe_trace.h" #include "xe_wa.h"
drivers/gpu/drm/xe/xe_pm_sysfs.c new file +81 -0
81 lines not on this page · raw message
drivers/gpu/drm/xe/xe_pm_sysfs.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2025 Intel Corporation +*/ + +#ifndef _XE_PM_SYSFS_H_ +#define _XE_PM_SYSFS_H_ + +struct xe_device ; + +int xe_pm_sysfs_init (struct xe_device *xe); + +#endif
Signature · 1 line
2.34.1
Patchwork
CI✗ CI.Patch_applied: failure for drm/xe: Introduce xe_pm_sysfs.c
== Series Details ==
== Series Details ==
Series: drm/xe: Introduce xe_pm_sysfs.c
URL : https://patchwork.freedesktop.org/series/148592/
State : failure
== Summary ==
=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: 4873543d1d3b drm-tip: 2025y-05m-05d-05h-35m-31s UTC integration manifest === git am output follows ===
error: patch failed: drivers/gpu/drm/xe/xe_device_sysfs.c:3
error: drivers/gpu/drm/xe/xe_device_sysfs.c: patch does not apply
error: patch failed: drivers/gpu/drm/xe/xe_device_sysfs.h:8
error: drivers/gpu/drm/xe/xe_device_sysfs.h: patch does not apply
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Applying: drm/xe: Introduce xe_pm_sysfs.c
Patch failed at 0001 drm/xe: Introduce xe_pm_sysfs.c
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Rodrigo Vivi
maintainerQuoted 124 lines · Raag Jadav
Introduce
xe_pm_sysfs.cfor Power Management knobs and move existing attributes to it.Signed-off-by Raag Jadav <[email protected]>---
This depends on BMG PCIe link downgrade series[1].
[1] https://lore.kernel.org/r/[email protected]drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/xe_device_sysfs.c | 64 +--------------------- drivers/gpu/drm/xe/xe_device_sysfs.h | 1 - drivers/gpu/drm/xe/xe_pm.c | 2 +- drivers/gpu/drm/xe/xe_pm_sysfs.c | 81 ++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_pm_sysfs.h | 13 +++++ 6 files changed, 97 insertions(+), 65 deletions(-) create mode 100644 drivers/gpu/drm/xe/xe_pm_sysfs.c create mode 100644 drivers/gpu/drm/xe/xe_pm_sysfs.hdrivers/gpu/drm/xe/Makefile +1
-0@@ -86,6 +86,7 @@ xe-y += xe_bb.o \ xe_pci.o \ xe_pcode.o \ xe_pm.o \ + xe_pm_sysfs.o \ xe_preempt_fence.o \ xe_pt.o \ xe_pt_walk.o \drivers/gpu/drm/xe/xe_device_sysfs.c +1
-63@@ -3,12 +3,11 @@* Copyright © 2023 Intel Corporation */ +#include <linux/device.h> #include <linux/kobject.h> #include <linux/pci.h> #include <linux/sysfs.h> -#include <drm/drm_managed.h> -#include "xe_device.h" #include "xe_device_sysfs.h" #include "xe_mmio.h" @@ -22,69 +21,8 @@* each graphics device. Considering this, we need to add sysfs attributes at device * level granularity. * These sysfs attributes will be available under pci device kobj directory. -* -* vram_d3cold_threshold - Report/change vram used threshold(in MB) below -* which vram save/restore is permissible during runtime D3cold entry/exit. */ -static ssize_t -vram_d3cold_threshold_show (struct device *dev, -struct device_attribute *attr,char *buf) -{ -struct pci_dev *pdev =to_pci_dev (dev); -struct xe_device *xe =pdev_to_xe_device (pdev); -int ret; - -xe_pm_runtime_get (xe); - ret =sysfs_emit (buf,"%d\n" , xe->d3cold.vram_threshold); -xe_pm_runtime_put (xe); - -return ret; -} - -static ssize_t -vram_d3cold_threshold_store (struct device *dev,struct device_attribute *attr, -const char *buff,size_t count) -{ -struct pci_dev *pdev =to_pci_dev (dev); -struct xe_device *xe =pdev_to_xe_device (pdev); -u32 vram_d3cold_threshold; -int ret; - - ret =kstrtou32 (buff,0 , &vram_d3cold_threshold); -if (ret) -return ret; - -drm_dbg (&xe->drm,"vram_d3cold_threshold: %u\n" , vram_d3cold_threshold); - -xe_pm_runtime_get (xe); - ret =xe_pm_set_vram_threshold (xe, vram_d3cold_threshold); -xe_pm_runtime_put (xe); - -return ret ?: count; -} - -static DEVICE_ATTR_RW (vram_d3cold_threshold); - -static void xe_pm_sysfs_fini (void *arg) -{ -struct xe_device *xe = arg; - -sysfs_remove_file (&xe->drm.dev->kobj, &dev_attr_vram_d3cold_threshold.attr); -} - -int xe_pm_sysfs_init (struct xe_device *xe) -{ -struct device *dev = xe->drm.dev; -int ret; - - ret =sysfs_create_file (&dev->kobj, &dev_attr_vram_d3cold_threshold.attr); -if (ret) -return ret; - -return devm_add_action_or_reset (dev, xe_pm_sysfs_fini, xe); -} -/** * DOC: PCIe Gen5 Limitations * drivers/gpu/drm/xe/xe_device_sysfs.h +0
-0
drivers/gpu/drm/xe/xe_device_sysfs.h line 11
Quoted 5 lines
drivers/gpu/drm/xe/xe_device_sysfs.h +0
-1@@ -8,7 +8,6 @@struct xe_device ; -int xe_pm_sysfs_init (struct xe_device *xe);int xe_device_sysfs_init (struct xe_device *xe);
yeap, clearly 'xe_pm' here is bad...
But I don't believe that making a new component make things better.
Because pm_sysfs can be many things and in many layer, device, tile or gt.
So, perhaps we add a 'xe_device_pm_sysfs, or perhaps we just kill this pm_sysfs_init functions and move that to inisde the device_sysfs_init and add the logic of creating it or not inside it.
Quoted 129 lines
drivers/gpu/drm/xe/xe_device_sysfs.h +0
-0#endif drivers/gpu/drm/xe/xe_pm.c +1
-1@@ -16,12 +16,12 @@#include "xe_bo.h" #include "xe_bo_evict.h" #include "xe_device.h" -#include "xe_device_sysfs.h" #include "xe_ggtt.h" #include "xe_gt.h" #include "xe_guc.h" #include "xe_irq.h" #include "xe_pcode.h" +#include "xe_pm_sysfs.h" #include "xe_pxp.h" #include "xe_trace.h" #include "xe_wa.h" drivers/gpu/drm/xe/xe_pm_sysfs.c new file +81
-0@@ -0,0 +1,81 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +*/ + +#include <linux/device.h> +#include <linux/kobject.h> +#include <linux/pci.h> +#include <linux/sysfs.h> + +#include "xe_device.h" +#include "xe_mmio.h" +#include "xe_pm.h" +#include "xe_pm_sysfs.h" + +/** +* DOC: Xe PM sysfs +* Xe driver requires exposing certain tunable knobs controlled by user space +* for Power Management. Considering this, we need to add sysfs attributes for +* it. These sysfs attributes will be available under pci device kobj directory. +* +* vram_d3cold_threshold - Report/change vram used threshold(in MB) below +* which vram save/restore is permissible during runtime D3cold entry/exit. +*/ + +static ssize_t +vram_d3cold_threshold_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct xe_device *xe =pdev_to_xe_device (pdev); +int ret; + +xe_pm_runtime_get (xe); + ret =sysfs_emit (buf,"%d\n" , xe->d3cold.vram_threshold); +xe_pm_runtime_put (xe); + +return ret; +} + +static ssize_t +vram_d3cold_threshold_store (struct device *dev,struct device_attribute *attr, +const char *buff,size_t count) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct xe_device *xe =pdev_to_xe_device (pdev); +u32 vram_d3cold_threshold; +int ret; + + ret =kstrtou32 (buff,0 , &vram_d3cold_threshold); +if (ret) +return ret; + +drm_dbg (&xe->drm,"vram_d3cold_threshold: %u\n" , vram_d3cold_threshold); + +xe_pm_runtime_get (xe); + ret =xe_pm_set_vram_threshold (xe, vram_d3cold_threshold); +xe_pm_runtime_put (xe); + +return ret ?: count; +} + +static DEVICE_ATTR_RW (vram_d3cold_threshold); + +static void xe_pm_sysfs_fini (void *arg) +{ +struct xe_device *xe = arg; + +sysfs_remove_file (&xe->drm.dev->kobj, &dev_attr_vram_d3cold_threshold.attr); +} + +int xe_pm_sysfs_init (struct xe_device *xe) +{ +struct device *dev = xe->drm.dev; +int ret; + + ret =sysfs_create_file (&dev->kobj, &dev_attr_vram_d3cold_threshold.attr); +if (ret) +return ret; + +return devm_add_action_or_reset (dev, xe_pm_sysfs_fini, xe); +}drivers/gpu/drm/xe/xe_pm_sysfs.h new file +13
-0@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2025 Intel Corporation +*/ + +#ifndef _XE_PM_SYSFS_H_ +#define _XE_PM_SYSFS_H_ + +struct xe_device ; + +int xe_pm_sysfs_init (struct xe_device *xe); + +#endif Signature · 1 line
2.34.1