drm/amdgpu: Add generic capability class
Subsystems (3)
PATCH 1/3 drm/amdgpu: Add generic capability class
From: Lijo Lazar <[email protected]>
Define a utility macro for defining capabilities and their attributes. Capability attributes are read-only, write-only, read-write.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h | 91 +++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -63,6 +63,7 @@#include "kgd_pp_interface.h" #include "amd_shared.h" +#include "amdgpu_utils.h" #include "amdgpu_mode.h" #include "amdgpu_ih.h" #include "amdgpu_irq.h"
drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h new file +91 -0
91 lines not on this page · raw message
Signature · 1 line
2.46.0
PATCH 2/3 drm/amdgpu: Add virtual device capabilities
From: Lijo Lazar <[email protected]>
Add a member to define the capabilities of virtual device.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +5 -0
@@ -256,6 +256,10 @@ struct amdgpu_virt_ras {uint64_t cper_rptr; }; +#define AMDGPU_VIRT_CAPS_LIST (X ) X(AMDGPU_VIRT_CAP_POWER_LIMIT) + +DECLARE_ATTR_CAP_CLASS (amdgpu_virt,AMDGPU_VIRT_CAPS_LIST ); +/* GPU virtualization */ struct amdgpu_virt {uint32_t caps;
@@ -274,6 +278,7 @@ struct amdgpu_virt {const struct amdgpu_virt_ops *ops;struct amdgpu_vf_error_buffer vf_errors;struct amdgpu_virt_fw_reserve fw_reserve; +struct amdgpu_virt_caps virt_caps;uint32_t gim_feature;uint32_t reg_access_mode;int req_init_data_ver;
Signature · 1 line
2.46.0
RE: [PATCH 2/3] drm/amdgpu: Add virtual device capabilities
[AMD Official Use Only - AMD Internal Distribution Only]
The patch is
Regards,
Hawking
-----Original Message-----
From: Kamal, Asad <[email protected]>
Sent: Friday, September 5, 2025 00:43
To: [email protected]; Lazar, Lijo <[email protected]>
Cc: Zhang, Hawking <[email protected]>; Ma, Le <[email protected]>; Zhang, Morris <[email protected]>; Kamal, Asad <[email protected]>; Deucher, Alexander <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu: Add virtual device capabilities
From: Lijo Lazar <[email protected]>
Add a member to define the capabilities of virtual device.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +5 -0
@@ -256,6 +256,10 @@ struct amdgpu_virt_ras {uint64_t cper_rptr; }; +#define AMDGPU_VIRT_CAPS_LIST (X ) X(AMDGPU_VIRT_CAP_POWER_LIMIT) + +DECLARE_ATTR_CAP_CLASS (amdgpu_virt,AMDGPU_VIRT_CAPS_LIST ); +/* GPU virtualization */ struct amdgpu_virt {uint32_t caps;
@@ -274,6 +278,7 @@ struct amdgpu_virt {const struct amdgpu_virt_ops *ops;struct amdgpu_vf_error_buffer vf_errors;struct amdgpu_virt_fw_reserve fw_reserve; +struct amdgpu_virt_caps virt_caps;uint32_t gim_feature;uint32_t reg_access_mode;int req_init_data_ver;
--
2.46.0
PATCH 3/3 drm/amd/pm: Allow to set power cap in vf mode
In reply to Asad KamalAllow setting power cap for smu_v13_0_6 in 1vf mode
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 7 ++++--- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +4 -3
@@ -3253,9 +3253,6 @@ static ssize_t amdgpu_hwmon_set_power_cap(struct device *dev,int err;u32 value; -if (amdgpu_sriov_vf (adev)) -return -EINVAL ; - err =kstrtou32 (buf,10 , &value);if (err)return err;
@@ -3597,6 +3594,10 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,return 0 ; } +if (attr == &sensor_dev_attr_power1_cap.dev_attr.attr && +amdgpu_virt_cap_is_rw (&adev->virt.virt_caps,AMDGPU_VIRT_CAP_POWER_LIMIT )) + effective_mode |=S_IWUSR ; +/* not implemented yet for APUs having < GC 9.3.0 (Renoir) */ if (((adev->family == AMDGPU_FAMILY_SI) || ((adev->flags & AMD_IS_APU) && (gc_ver < IP_VERSION(9, 3, 0)))) &&
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +5 -1
@@ -143,7 +143,7 @@ static const struct cmn2asic_msg_mapping smu_v13_0_6_message_map[SMU_MSG_MAX_COUMSG_MAP (GetMinDpmFreq, PPSMC_MSG_GetMinDpmFreq,1 ),MSG_MAP (GetMaxDpmFreq, PPSMC_MSG_GetMaxDpmFreq,1 ),MSG_MAP (GetDpmFreqByIndex, PPSMC_MSG_GetDpmFreqByIndex,1 ), -MSG_MAP (SetPptLimit, PPSMC_MSG_SetPptLimit,0 ), +MSG_MAP (SetPptLimit, PPSMC_MSG_SetPptLimit,1 ),MSG_MAP (GetPptLimit, PPSMC_MSG_GetPptLimit,1 ),MSG_MAP (GfxDeviceDriverReset, PPSMC_MSG_GfxDriverReset,SMU_MSG_RAS_PRI |SMU_MSG_NO_PRECHECK ), MSG_MAP(DramLogSetDramAddrHigh, PPSMC_MSG_DramLogSetDramAddrHigh, 0),
@@ -413,6 +413,10 @@ static void smu_v13_0_6_init_caps(struct smu_context *smu)smu_v13_0_6_cap_set (smu,SMU_CAP (HST_LIMIT_METRICS ));if (amdgpu_sriov_vf (adev)) { +if (fw_ver >=0x00558200 ) +amdgpu_virt_attr_set (&adev->virt.virt_caps, +AMDGPU_VIRT_CAP_POWER_LIMIT , +AMDGPU_CAP_ATTR_RW );if ((pgm ==0 && fw_ver >=0x00558000 ) || (pgm ==7 && fw_ver >=0x7551000 )) { smu_v13_0_6_cap_set(smu,
Signature · 1 line
2.46.0
RE: [PATCH 3/3] drm/amd/pm: Allow to set power cap in vf mode
[AMD Official Use Only - AMD Internal Distribution Only]
The patch is
Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Asad Kamal
Sent: Friday, September 5, 2025 00:43
To: [email protected]; Lazar, Lijo <[email protected]>
Cc: Zhang, Hawking <[email protected]>; Ma, Le <[email protected]>; Zhang, Morris <[email protected]>; Kamal, Asad <[email protected]>; Deucher, Alexander <[email protected]>
Subject: [PATCH 3/3] drm/amd/pm: Allow to set power cap in vf mode
Allow setting power cap for smu_v13_0_6 in 1vf mode
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 7 ++++--- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +4 -3
@@ -3253,9 +3253,6 @@ static ssize_t amdgpu_hwmon_set_power_cap(struct device *dev,int err;u32 value; -if (amdgpu_sriov_vf (adev)) -return -EINVAL ; - err =kstrtou32 (buf,10 , &value);if (err)return err;
@@ -3597,6 +3594,10 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,return 0 ; } +if (attr == &sensor_dev_attr_power1_cap.dev_attr.attr && +amdgpu_virt_cap_is_rw (&adev->virt.virt_caps,AMDGPU_VIRT_CAP_POWER_LIMIT )) + effective_mode |=S_IWUSR ; +/* not implemented yet for APUs having < GC 9.3.0 (Renoir) */ if (((adev->family ==AMDGPU_FAMILY_SI ) || ((adev->flags & AMD_IS_APU) && (gc_ver < IP_VERSION(9, 3, 0)))) && diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
index e37b7b5358ea..0acf574930d8 100644
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +5 -1
@@ -143,7 +143,7 @@ static const struct cmn2asic_msg_mapping smu_v13_0_6_message_map[SMU_MSG_MAX_COUMSG_MAP (GetMinDpmFreq, PPSMC_MSG_GetMinDpmFreq,1 ),MSG_MAP (GetMaxDpmFreq, PPSMC_MSG_GetMaxDpmFreq,1 ),MSG_MAP (GetDpmFreqByIndex, PPSMC_MSG_GetDpmFreqByIndex,1 ), -MSG_MAP (SetPptLimit, PPSMC_MSG_SetPptLimit,0 ), +MSG_MAP (SetPptLimit, PPSMC_MSG_SetPptLimit,1 ),MSG_MAP (GetPptLimit, PPSMC_MSG_GetPptLimit,1 ),MSG_MAP (GfxDeviceDriverReset, PPSMC_MSG_GfxDriverReset,SMU_MSG_RAS_PRI |SMU_MSG_NO_PRECHECK ), MSG_MAP(DramLogSetDramAddrHigh, PPSMC_MSG_DramLogSetDramAddrHigh, 0),
@@ -413,6 +413,10 @@ static void smu_v13_0_6_init_caps(struct smu_context *smu)smu_v13_0_6_cap_set (smu,SMU_CAP (HST_LIMIT_METRICS ));if (amdgpu_sriov_vf (adev)) { +if (fw_ver >=0x00558200 ) +amdgpu_virt_attr_set (&adev->virt.virt_caps, +AMDGPU_VIRT_CAP_POWER_LIMIT , +AMDGPU_CAP_ATTR_RW );if ((pgm ==0 && fw_ver >=0x00558000 ) || (pgm ==7 && fw_ver >=0x7551000 )) { smu_v13_0_6_cap_set(smu,
--
2.46.0
[AMD Official Use Only - AMD Internal Distribution Only]
ping
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Asad Kamal
Sent: Friday, September 5, 2025 10:13 AM
To: [email protected]; Lazar, Lijo <[email protected]>
Cc: Zhang, Hawking <[email protected]>; Ma, Le <[email protected]>; Zhang, Morris <[email protected]>; Kamal, Asad <[email protected]>; Deucher, Alexander <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: Add generic capability class
From: Lijo Lazar <[email protected]>
Define a utility macro for defining capabilities and their attributes. Capability attributes are read-only, write-only, read-write.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h | 91 +++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -63,6 +63,7 @@#include "kgd_pp_interface.h" #include "amd_shared.h" +#include "amdgpu_utils.h" #include "amdgpu_mode.h" #include "amdgpu_ih.h" #include "amdgpu_irq.h"
drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h new file +91 -0
91 lines not on this page · raw message
+static inline bool NAME##_cap_is_rw(const struct NAME##_caps *c, enum NAME##_cap_id id) \
+{ enum amdgpu_cap_attr a; return !NAME##_attr_get(c, id, &a) && a == +AMDGPU_CAP_ATTR_RW; }
+
+/* Element expander for enum creation */ #define _CAP_ENUM_ELEM(x) x, +
+/* Public macro: declare enum + helpers from an X‑macro list */
+#define DECLARE_ATTR_CAP_CLASS(NAME, LIST_MACRO) \
+ enum NAME##_cap_id { LIST_MACRO(_CAP_ENUM_ELEM) NAME##_COUNT }; \
+ DECLARE_ATTR_CAP_CLASS_HELPERS(NAME)
+
+#endif /* AMDGPU_UTILS_H_ */
--
2.46.0
[AMD Official Use Only - AMD Internal Distribution Only]
Yes, it seems there is a new hwmon/sysnode visible attribute check path, but there is already a check logic in amdgpu_pm.c now, such as checking the return value - EPONOTUPPORT. e.g: (amdgpu_dpm_get_fan_speed_pwm(adev, NULL) == -EOPNOTSUPP
We won't discuss which approach is better here, but unifying the code logic and maintaining a certain style is undoubtedly a better choice. what do you think?
Best Regards,
Kevin
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Asad Kamal
Sent: Friday, September 5, 2025 12:43 PM
To: [email protected]; Lazar, Lijo <[email protected]>
Cc: Zhang, Hawking <[email protected]>; Ma, Le <[email protected]>; Zhang, Morris <[email protected]>; Kamal, Asad <[email protected]>; Deucher, Alexander <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: Add generic capability class
From: Lijo Lazar <[email protected]>
Define a utility macro for defining capabilities and their attributes. Capability attributes are read-only, write-only, read-write.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h | 91 +++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -63,6 +63,7 @@#include "kgd_pp_interface.h" #include "amd_shared.h" +#include "amdgpu_utils.h" #include "amdgpu_mode.h" #include "amdgpu_ih.h" #include "amdgpu_irq.h"
drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h new file +91 -0
91 lines not on this page · raw message
+static inline bool NAME##_cap_is_rw(const struct NAME##_caps *c, enum NAME##_cap_id id) \
+{ enum amdgpu_cap_attr a; return !NAME##_attr_get(c, id, &a) && a == +AMDGPU_CAP_ATTR_RW; }
+
+/* Element expander for enum creation */ #define _CAP_ENUM_ELEM(x) x, +
+/* Public macro: declare enum + helpers from an X‑macro list */
+#define DECLARE_ATTR_CAP_CLASS(NAME, LIST_MACRO) \
+ enum NAME##_cap_id { LIST_MACRO(_CAP_ENUM_ELEM) NAME##_COUNT }; \
+ DECLARE_ATTR_CAP_CLASS_HELPERS(NAME)
+
+#endif /* AMDGPU_UTILS_H_ */
--
2.46.0
[Public]
The intent is to keep hwmon/sysfs attributes based on new RW capabilities of attributes as in this series and replace existing logic.
This one is kind of urgent, hence the change is specifically done inside amdgpu_virt.
Thanks,
Lijo
________________________________
From: Wang, Yang(Kevin) <[email protected]>
Sent: Tuesday, September 9, 2025 7:58:20 AM
To: Kamal, Asad <[email protected]>; [email protected] <[email protected]>; Lazar, Lijo <[email protected]>
Cc: Zhang, Hawking <[email protected]>; Ma, Le <[email protected]>; Zhang, Morris <[email protected]>; Kamal, Asad <[email protected]>; Deucher, Alexander <[email protected]>
Subject: RE: [PATCH 1/3] drm/amdgpu: Add generic capability class
[AMD Official Use Only - AMD Internal Distribution Only]
Yes, it seems there is a new hwmon/sysnode visible attribute check path, but there is already a check logic in amdgpu_pm.c now, such as checking the return value - EPONOTUPPORT. e.g: (amdgpu_dpm_get_fan_speed_pwm(adev, NULL) == -EOPNOTSUPP
We won't discuss which approach is better here, but unifying the code logic and maintaining a certain style is undoubtedly a better choice. what do you think?
Best Regards,
Kevin
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Asad Kamal
Sent: Friday, September 5, 2025 12:43 PM
To: [email protected]; Lazar, Lijo <[email protected]>
Cc: Zhang, Hawking <[email protected]>; Ma, Le <[email protected]>; Zhang, Morris <[email protected]>; Kamal, Asad <[email protected]>; Deucher, Alexander <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: Add generic capability class
From: Lijo Lazar <[email protected]>
Define a utility macro for defining capabilities and their attributes. Capability attributes are read-only, write-only, read-write.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h | 91 +++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -63,6 +63,7 @@#include "kgd_pp_interface.h" #include "amd_shared.h" +#include "amdgpu_utils.h" #include "amdgpu_mode.h" #include "amdgpu_ih.h" #include "amdgpu_irq.h"
drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h new file +91 -0
91 lines not on this page · raw message
+static inline bool NAME##_cap_is_rw(const struct NAME##_caps *c, enum NAME##_cap_id id) \
+{ enum amdgpu_cap_attr a; return !NAME##_attr_get(c, id, &a) && a == +AMDGPU_CAP_ATTR_RW; }
+
+/* Element expander for enum creation */ #define _CAP_ENUM_ELEM(x) x, +
+/* Public macro: declare enum + helpers from an X‑macro list */
+#define DECLARE_ATTR_CAP_CLASS(NAME, LIST_MACRO) \
+ enum NAME##_cap_id { LIST_MACRO(_CAP_ENUM_ELEM) NAME##_COUNT }; \
+ DECLARE_ATTR_CAP_CLASS_HELPERS(NAME)
+
+#endif /* AMDGPU_UTILS_H_ */
--
2.46.0
[Public]
Quoted 1 line
Quoted 1 line
This one is kind of urgent, hence the change is specifically done inside
amdgpu_virt.
I prefer to use the origin patch (v1) to fix it if it is an urgent issue.
And the new solution can be submitted later, and all hwmon/nodes will be managed uniformly, instead of using one method for each hwmon through patching.
Best Regards,
Kevin
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, September 9, 2025 11:16 AM
To: Wang, Yang(Kevin) <[email protected]>; Kamal, Asad <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Ma, Le <[email protected]>; Zhang, Morris <[email protected]>; Kamal, Asad <[email protected]>; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH 1/3] drm/amdgpu: Add generic capability class
[Public]
The intent is to keep hwmon/sysfs attributes based on new RW capabilities of attributes as in this series and replace existing logic.
This one is kind of urgent, hence the change is specifically done inside amdgpu_virt.
Thanks,
Lijo
________________________________
From: Wang, Yang(Kevin) <[email protected]<mailto:[email protected]>>
Sent: Tuesday, September 9, 2025 7:58:20 AM
To: Kamal, Asad <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>; Lazar, Lijo <[email protected]<mailto:[email protected]>>
Cc: Zhang, Hawking <[email protected]<mailto:[email protected]>>; Ma, Le <[email protected]<mailto:[email protected]>>; Zhang, Morris <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>
Subject: RE: [PATCH 1/3] drm/amdgpu: Add generic capability class
[AMD Official Use Only - AMD Internal Distribution Only]
Yes, it seems there is a new hwmon/sysnode visible attribute check path, but there is already a check logic in amdgpu_pm.c now, such as checking the return value - EPONOTUPPORT. e.g: (amdgpu_dpm_get_fan_speed_pwm(adev, NULL) == -EOPNOTSUPP
We won't discuss which approach is better here, but unifying the code logic and maintaining a certain style is undoubtedly a better choice. what do you think?
Best Regards,
Kevin
-----Original Message-----
From: amd-gfx <[email protected]<mailto:[email protected]>> On Behalf Of Asad Kamal
Sent: Friday, September 5, 2025 12:43 PM
To: [email protected]<mailto:[email protected]>; Lazar, Lijo <[email protected]<mailto:[email protected]>>
Cc: Zhang, Hawking <[email protected]<mailto:[email protected]>>; Ma, Le <[email protected]<mailto:[email protected]>>; Zhang, Morris <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>
Subject: [PATCH 1/3] drm/amdgpu: Add generic capability class
From: Lijo Lazar <[email protected]<mailto:[email protected]>>
Define a utility macro for defining capabilities and their attributes. Capability attributes are read-only, write-only, read-write.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h | 91 +++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -63,6 +63,7 @@#include "kgd_pp_interface.h" #include "amd_shared.h" +#include "amdgpu_utils.h" #include "amdgpu_mode.h" #include "amdgpu_ih.h" #include "amdgpu_irq.h"
drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h new file +91 -0
91 lines not on this page · raw message
+static inline bool NAME##_cap_is_rw(const struct NAME##_caps *c, enum NAME##_cap_id id) \
+{ enum amdgpu_cap_attr a; return !NAME##_attr_get(c, id, &a) && a == +AMDGPU_CAP_ATTR_RW; }
+
+/* Element expander for enum creation */ #define _CAP_ENUM_ELEM(x) x, +
+/* Public macro: declare enum + helpers from an X‑macro list */
+#define DECLARE_ATTR_CAP_CLASS(NAME, LIST_MACRO) \
+ enum NAME##_cap_id { LIST_MACRO(_CAP_ENUM_ELEM) NAME##_COUNT }; \
+ DECLARE_ATTR_CAP_CLASS_HELPERS(NAME)
+
+#endif /* AMDGPU_UTILS_H_ */
--
2.46.0
[Public]
I don’t prefer the original version as that is more rework compared to the direction of the new solution.
Thanks,
Lijo
From: Wang, Yang(Kevin) <[email protected]>
Sent: Tuesday, September 9, 2025 9:05 AM
To: Lazar, Lijo <[email protected]>; Kamal, Asad <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Ma, Le <[email protected]>; Zhang, Morris <[email protected]>; Kamal, Asad <[email protected]>; Deucher, Alexander <[email protected]>
Subject: RE: [PATCH 1/3] drm/amdgpu: Add generic capability class
[Public]
Quoted 1 line
Quoted 1 line
This one is kind of urgent, hence the change is specifically done inside
amdgpu_virt.
I prefer to use the origin patch (v1) to fix it if it is an urgent issue.
And the new solution can be submitted later, and all hwmon/nodes will be managed uniformly, instead of using one method for each hwmon through patching.
Best Regards,
Kevin
From: Lazar, Lijo <[email protected]<mailto:[email protected]>>
Sent: Tuesday, September 9, 2025 11:16 AM
To: Wang, Yang(Kevin) <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]>
Cc: Zhang, Hawking <[email protected]<mailto:[email protected]>>; Ma, Le <[email protected]<mailto:[email protected]>>; Zhang, Morris <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>
Subject: Re: [PATCH 1/3] drm/amdgpu: Add generic capability class
[Public]
The intent is to keep hwmon/sysfs attributes based on new RW capabilities of attributes as in this series and replace existing logic.
This one is kind of urgent, hence the change is specifically done inside amdgpu_virt.
Thanks,
Lijo
________________________________
From: Wang, Yang(Kevin) <[email protected]<mailto:[email protected]>>
Sent: Tuesday, September 9, 2025 7:58:20 AM
To: Kamal, Asad <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>; Lazar, Lijo <[email protected]<mailto:[email protected]>>
Cc: Zhang, Hawking <[email protected]<mailto:[email protected]>>; Ma, Le <[email protected]<mailto:[email protected]>>; Zhang, Morris <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>
Subject: RE: [PATCH 1/3] drm/amdgpu: Add generic capability class
[AMD Official Use Only - AMD Internal Distribution Only]
Yes, it seems there is a new hwmon/sysnode visible attribute check path, but there is already a check logic in amdgpu_pm.c now, such as checking the return value - EPONOTUPPORT. e.g: (amdgpu_dpm_get_fan_speed_pwm(adev, NULL) == -EOPNOTSUPP
We won't discuss which approach is better here, but unifying the code logic and maintaining a certain style is undoubtedly a better choice. what do you think?
Best Regards,
Kevin
-----Original Message-----
From: amd-gfx <[email protected]<mailto:[email protected]>> On Behalf Of Asad Kamal
Sent: Friday, September 5, 2025 12:43 PM
To: [email protected]<mailto:[email protected]>; Lazar, Lijo <[email protected]<mailto:[email protected]>>
Cc: Zhang, Hawking <[email protected]<mailto:[email protected]>>; Ma, Le <[email protected]<mailto:[email protected]>>; Zhang, Morris <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>
Subject: [PATCH 1/3] drm/amdgpu: Add generic capability class
From: Lijo Lazar <[email protected]<mailto:[email protected]>>
Define a utility macro for defining capabilities and their attributes. Capability attributes are read-only, write-only, read-write.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h | 91 +++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -63,6 +63,7 @@#include "kgd_pp_interface.h" #include "amd_shared.h" +#include "amdgpu_utils.h" #include "amdgpu_mode.h" #include "amdgpu_ih.h" #include "amdgpu_irq.h"
drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h new file +91 -0
91 lines not on this page · raw message
+static inline bool NAME##_cap_is_rw(const struct NAME##_caps *c, enum NAME##_cap_id id) \
+{ enum amdgpu_cap_attr a; return !NAME##_attr_get(c, id, &a) && a == +AMDGPU_CAP_ATTR_RW; }
+
+/* Element expander for enum creation */ #define _CAP_ENUM_ELEM(x) x, +
+/* Public macro: declare enum + helpers from an X‑macro list */
+#define DECLARE_ATTR_CAP_CLASS(NAME, LIST_MACRO) \
+ enum NAME##_cap_id { LIST_MACRO(_CAP_ENUM_ELEM) NAME##_COUNT }; \
+ DECLARE_ATTR_CAP_CLASS_HELPERS(NAME)
+
+#endif /* AMDGPU_UTILS_H_ */
--
2.46.0
[Public]
Sorry, you may have misunderstood my thoughts, what I am considering is:
1.Fix the issue first.
2.Then use a new method to unify the visible check logic of all hwmon/sysnodes to ensure code consistency.
The reason why it is currently not recommended to merge directly is that the new solution is ONLY effective for power1_cap of 1vf case so far, and there may be other limitations and differences ase in other hwmon/nodes that need to be considered uniformly to avoid repeated refactoring. The situation has become a bit more complicated now(some node is only valid on specific pmfw version), which is different from my last refactoring, so careful design is needed.
So, I hope you/we can consider all the situations of hwmon/sysnode and provide a unified solution, for asic/sriov such case. (e.g: visible, attribute permission, return Val, …)
Best Regards,
Kevin
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, September 9, 2025 11:50 AM
To: Wang, Yang(Kevin) <[email protected]>; Kamal, Asad <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Ma, Le <[email protected]>; Zhang, Morris <[email protected]>; Kamal, Asad <[email protected]>; Deucher, Alexander <[email protected]>
Subject: RE: [PATCH 1/3] drm/amdgpu: Add generic capability class
[Public]
I don’t prefer the original version as that is more rework compared to the direction of the new solution.
Thanks,
Lijo
From: Wang, Yang(Kevin) <[email protected]<mailto:[email protected]>>
Sent: Tuesday, September 9, 2025 9:05 AM
To: Lazar, Lijo <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]>
Cc: Zhang, Hawking <[email protected]<mailto:[email protected]>>; Ma, Le <[email protected]<mailto:[email protected]>>; Zhang, Morris <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>
Subject: RE: [PATCH 1/3] drm/amdgpu: Add generic capability class
[Public]
Quoted 1 line
Quoted 1 line
This one is kind of urgent, hence the change is specifically done inside
amdgpu_virt.
I prefer to use the origin patch (v1) to fix it if it is an urgent issue.
And the new solution can be submitted later, and all hwmon/nodes will be managed uniformly, instead of using one method for each hwmon through patching.
Best Regards,
Kevin
From: Lazar, Lijo <[email protected]<mailto:[email protected]>>
Sent: Tuesday, September 9, 2025 11:16 AM
To: Wang, Yang(Kevin) <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]>
Cc: Zhang, Hawking <[email protected]<mailto:[email protected]>>; Ma, Le <[email protected]<mailto:[email protected]>>; Zhang, Morris <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>
Subject: Re: [PATCH 1/3] drm/amdgpu: Add generic capability class
[Public]
The intent is to keep hwmon/sysfs attributes based on new RW capabilities of attributes as in this series and replace existing logic.
This one is kind of urgent, hence the change is specifically done inside amdgpu_virt.
Thanks,
Lijo
________________________________
From: Wang, Yang(Kevin) <[email protected]<mailto:[email protected]>>
Sent: Tuesday, September 9, 2025 7:58:20 AM
To: Kamal, Asad <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>; Lazar, Lijo <[email protected]<mailto:[email protected]>>
Cc: Zhang, Hawking <[email protected]<mailto:[email protected]>>; Ma, Le <[email protected]<mailto:[email protected]>>; Zhang, Morris <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>
Subject: RE: [PATCH 1/3] drm/amdgpu: Add generic capability class
[AMD Official Use Only - AMD Internal Distribution Only]
Yes, it seems there is a new hwmon/sysnode visible attribute check path, but there is already a check logic in amdgpu_pm.c now, such as checking the return value - EPONOTUPPORT. e.g: (amdgpu_dpm_get_fan_speed_pwm(adev, NULL) == -EOPNOTSUPP
We won't discuss which approach is better here, but unifying the code logic and maintaining a certain style is undoubtedly a better choice. what do you think?
Best Regards,
Kevin
-----Original Message-----
From: amd-gfx <[email protected]<mailto:[email protected]>> On Behalf Of Asad Kamal
Sent: Friday, September 5, 2025 12:43 PM
To: [email protected]<mailto:[email protected]>; Lazar, Lijo <[email protected]<mailto:[email protected]>>
Cc: Zhang, Hawking <[email protected]<mailto:[email protected]>>; Ma, Le <[email protected]<mailto:[email protected]>>; Zhang, Morris <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>
Subject: [PATCH 1/3] drm/amdgpu: Add generic capability class
From: Lijo Lazar <[email protected]<mailto:[email protected]>>
Define a utility macro for defining capabilities and their attributes. Capability attributes are read-only, write-only, read-write.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h | 91 +++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -63,6 +63,7 @@#include "kgd_pp_interface.h" #include "amd_shared.h" +#include "amdgpu_utils.h" #include "amdgpu_mode.h" #include "amdgpu_ih.h" #include "amdgpu_irq.h"
drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h new file +91 -0
91 lines not on this page · raw message
+static inline bool NAME##_cap_is_rw(const struct NAME##_caps *c, enum NAME##_cap_id id) \
+{ enum amdgpu_cap_attr a; return !NAME##_attr_get(c, id, &a) && a == +AMDGPU_CAP_ATTR_RW; }
+
+/* Element expander for enum creation */ #define _CAP_ENUM_ELEM(x) x, +
+/* Public macro: declare enum + helpers from an X‑macro list */
+#define DECLARE_ATTR_CAP_CLASS(NAME, LIST_MACRO) \
+ enum NAME##_cap_id { LIST_MACRO(_CAP_ENUM_ELEM) NAME##_COUNT }; \
+ DECLARE_ATTR_CAP_CLASS_HELPERS(NAME)
+
+#endif /* AMDGPU_UTILS_H_ */
--
2.46.0
[Public]
The current approach in hwmon itself is not uniform.
We have checks like this
if (((adev->family == AMDGPU_FAMILY_SI) ||
((adev->flags & AMD_IS_APU) && (gc_ver < IP_VERSION(9, 3, 0)))) &&
(attr == &sensor_dev_attr_power1_average.dev_attr.attr))
return 0;Also, checks like
if (attr == &sensor_dev_attr_power1_input.dev_attr.attr &&
amdgpu_hwmon_get_sensor_generic(adev, AMDGPU_PP_SENSOR_GPU_INPUT_POWER, (void *)&tmp) == -EOPNOTSUPP)
return 0;Version 1 relies on passing some invalid value and a set_powerlimit() call itself to check if power cap can be set on VFs. That approach is more fragile. Also, the changes to make that work need to be undone when a ‘uniform’ approach (though there is no consistent approach even now) is taken. That is why I prefer to go in this direction.
Thanks,
Lijo
From: Wang, Yang(Kevin) <[email protected]>
Sent: Tuesday, September 9, 2025 9:47 AM
To: Lazar, Lijo <[email protected]>; Kamal, Asad <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Ma, Le <[email protected]>; Zhang, Morris <[email protected]>; Kamal, Asad <[email protected]>; Deucher, Alexander <[email protected]>
Subject: RE: [PATCH 1/3] drm/amdgpu: Add generic capability class
[Public]
Sorry, you may have misunderstood my thoughts, what I am considering is:
1.Fix the issue first.
2.Then use a new method to unify the visible check logic of all hwmon/sysnodes to ensure code consistency.
The reason why it is currently not recommended to merge directly is that the new solution is ONLY effective for power1_cap of 1vf case so far, and there may be other limitations and differences ase in other hwmon/nodes that need to be considered uniformly to avoid repeated refactoring. The situation has become a bit more complicated now(some node is only valid on specific pmfw version), which is different from my last refactoring, so careful design is needed.
So, I hope you/we can consider all the situations of hwmon/sysnode and provide a unified solution, for asic/sriov such case. (e.g: visible, attribute permission, return Val, …)
Best Regards,
Kevin
From: Lazar, Lijo <[email protected]<mailto:[email protected]>>
Sent: Tuesday, September 9, 2025 11:50 AM
To: Wang, Yang(Kevin) <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]>
Cc: Zhang, Hawking <[email protected]<mailto:[email protected]>>; Ma, Le <[email protected]<mailto:[email protected]>>; Zhang, Morris <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>
Subject: RE: [PATCH 1/3] drm/amdgpu: Add generic capability class
[Public]
I don’t prefer the original version as that is more rework compared to the direction of the new solution.
Thanks,
Lijo
From: Wang, Yang(Kevin) <[email protected]<mailto:[email protected]>>
Sent: Tuesday, September 9, 2025 9:05 AM
To: Lazar, Lijo <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]>
Cc: Zhang, Hawking <[email protected]<mailto:[email protected]>>; Ma, Le <[email protected]<mailto:[email protected]>>; Zhang, Morris <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>
Subject: RE: [PATCH 1/3] drm/amdgpu: Add generic capability class
[Public]
Quoted 1 line
Quoted 1 line
This one is kind of urgent, hence the change is specifically done inside
amdgpu_virt.
I prefer to use the origin patch (v1) to fix it if it is an urgent issue.
And the new solution can be submitted later, and all hwmon/nodes will be managed uniformly, instead of using one method for each hwmon through patching.
Best Regards,
Kevin
From: Lazar, Lijo <[email protected]<mailto:[email protected]>>
Sent: Tuesday, September 9, 2025 11:16 AM
To: Wang, Yang(Kevin) <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]>
Cc: Zhang, Hawking <[email protected]<mailto:[email protected]>>; Ma, Le <[email protected]<mailto:[email protected]>>; Zhang, Morris <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>
Subject: Re: [PATCH 1/3] drm/amdgpu: Add generic capability class
[Public]
The intent is to keep hwmon/sysfs attributes based on new RW capabilities of attributes as in this series and replace existing logic.
This one is kind of urgent, hence the change is specifically done inside amdgpu_virt.
Thanks,
Lijo
________________________________
From: Wang, Yang(Kevin) <[email protected]<mailto:[email protected]>>
Sent: Tuesday, September 9, 2025 7:58:20 AM
To: Kamal, Asad <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>; Lazar, Lijo <[email protected]<mailto:[email protected]>>
Cc: Zhang, Hawking <[email protected]<mailto:[email protected]>>; Ma, Le <[email protected]<mailto:[email protected]>>; Zhang, Morris <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>
Subject: RE: [PATCH 1/3] drm/amdgpu: Add generic capability class
[AMD Official Use Only - AMD Internal Distribution Only]
Yes, it seems there is a new hwmon/sysnode visible attribute check path, but there is already a check logic in amdgpu_pm.c now, such as checking the return value - EPONOTUPPORT. e.g: (amdgpu_dpm_get_fan_speed_pwm(adev, NULL) == -EOPNOTSUPP
We won't discuss which approach is better here, but unifying the code logic and maintaining a certain style is undoubtedly a better choice. what do you think?
Best Regards,
Kevin
-----Original Message-----
From: amd-gfx <[email protected]<mailto:[email protected]>> On Behalf Of Asad Kamal
Sent: Friday, September 5, 2025 12:43 PM
To: [email protected]<mailto:[email protected]>; Lazar, Lijo <[email protected]<mailto:[email protected]>>
Cc: Zhang, Hawking <[email protected]<mailto:[email protected]>>; Ma, Le <[email protected]<mailto:[email protected]>>; Zhang, Morris <[email protected]<mailto:[email protected]>>; Kamal, Asad <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>
Subject: [PATCH 1/3] drm/amdgpu: Add generic capability class
From: Lijo Lazar <[email protected]<mailto:[email protected]>>
Define a utility macro for defining capabilities and their attributes. Capability attributes are read-only, write-only, read-write.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h | 91 +++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -63,6 +63,7 @@#include "kgd_pp_interface.h" #include "amd_shared.h" +#include "amdgpu_utils.h" #include "amdgpu_mode.h" #include "amdgpu_ih.h" #include "amdgpu_irq.h"
drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h new file +91 -0
91 lines not on this page · raw message
+static inline bool NAME##_cap_is_rw(const struct NAME##_caps *c, enum NAME##_cap_id id) \
+{ enum amdgpu_cap_attr a; return !NAME##_attr_get(c, id, &a) && a == +AMDGPU_CAP_ATTR_RW; }
+
+/* Element expander for enum creation */ #define _CAP_ENUM_ELEM(x) x, +
+/* Public macro: declare enum + helpers from an X‑macro list */
+#define DECLARE_ATTR_CAP_CLASS(NAME, LIST_MACRO) \
+ enum NAME##_cap_id { LIST_MACRO(_CAP_ENUM_ELEM) NAME##_COUNT }; \
+ DECLARE_ATTR_CAP_CLASS_HELPERS(NAME)
+
+#endif /* AMDGPU_UTILS_H_ */
--
2.46.0
[AMD Official Use Only - AMD Internal Distribution Only]
Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Asad Kamal
Sent: Friday, September 5, 2025 00:43
To: [email protected]; Lazar, Lijo <[email protected]>
Cc: Zhang, Hawking <[email protected]>; Ma, Le <[email protected]>; Zhang, Morris <[email protected]>; Kamal, Asad <[email protected]>; Deucher, Alexander <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: Add generic capability class
From: Lijo Lazar <[email protected]>
Define a utility macro for defining capabilities and their attributes. Capability attributes are read-only, write-only, read-write.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h | 91 +++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -63,6 +63,7 @@#include "kgd_pp_interface.h" #include "amd_shared.h" +#include "amdgpu_utils.h" #include "amdgpu_mode.h" #include "amdgpu_ih.h" #include "amdgpu_irq.h"
drivers/gpu/drm/amd/amdgpu/amdgpu_utils.h new file +91 -0
91 lines not on this page · raw message
+static inline bool NAME##_cap_is_rw(const struct NAME##_caps *c, enum NAME##_cap_id id) \
+{ enum amdgpu_cap_attr a; return !NAME##_attr_get(c, id, &a) && a == +AMDGPU_CAP_ATTR_RW; }
+
+/* Element expander for enum creation */ #define _CAP_ENUM_ELEM(x) x, +
+/* Public macro: declare enum + helpers from an X‑macro list */
+#define DECLARE_ATTR_CAP_CLASS(NAME, LIST_MACRO) \
+ enum NAME##_cap_id { LIST_MACRO(_CAP_ENUM_ELEM) NAME##_COUNT }; \
+ DECLARE_ATTR_CAP_CLASS_HELPERS(NAME)
+
+#endif /* AMDGPU_UTILS_H_ */
--
2.46.0