platform/x86/amd/hsmp: Use one DRIVER_VERSION
Subsystems (4)
PATCH v2 1/3 platform/x86/amd/hsmp: Use one DRIVER_VERSION
Use one DRIVER_VERSION for plat, hsmp and acpi modules. This simplifies userspace applications to support features based on available driver version.
---
Changes since v1:
None
(Rebased on review-ilpo-next)
drivers/platform/x86/amd/hsmp/acpi.c | 1 - drivers/platform/x86/amd/hsmp/hsmp.c | 2 -- drivers/platform/x86/amd/hsmp/hsmp.h | 2 ++ drivers/platform/x86/amd/hsmp/plat.c | 1 - 4 files changed, 2 insertions(+), 4 deletions(-)
drivers/platform/x86/amd/hsmp/acpi.c +0 -1
@@ -27,7 +27,6 @@#include "hsmp.h" #define DRIVER_NAME "amd_hsmp" -#define DRIVER_VERSION "2.3"#define ACPI_HSMP_DEVICE_HID "AMDI0097"/* These are the strings specified in ACPI table */
drivers/platform/x86/amd/hsmp/hsmp.c +0 -2
@@ -33,8 +33,6 @@#define HSMP_WR true#define HSMP_RD false -#define DRIVER_VERSION "2.4" -/* * When same message numbers are used for both GET and SET operation, * bit:31 indicates whether its SET or GET operation.
drivers/platform/x86/amd/hsmp/hsmp.h +2 -0
@@ -26,6 +26,8 @@#define HSMP_CDEV_NAME "hsmp_cdev"#define HSMP_DEVNODE_NAME "hsmp" +#define DRIVER_VERSION "2.4" +struct hsmp_mbaddr_info {u32 base_addr;u32 msg_id_off;
drivers/platform/x86/amd/hsmp/plat.c +0 -1
@@ -21,7 +21,6 @@#include "hsmp.h" #define DRIVER_NAME "amd_hsmp" -#define DRIVER_VERSION "2.3"/* * To access specific HSMP mailbox register, s/w writes the SMN address of HSMP mailbox
Signature · 1 line
2.25.1
PATCH v2 2/3 platform/x86/amd/hsmp: Report power using hwmon sensors
Expose power reading and power limits via hwmon power sensors.
---
Changes since v1:
1. Move hsmp_create_sensor() call to init_acpi() in acpi.c and init_platform_device() in plat.c
2. Pass u16 as parameter instead of void * in hsmp_create_sensor()
3. Change dev_err() print after hsmp_create_sensor()
4. Add CONFIG_HWMON dependency in Makefile
5. Add #if IS_REACHABLE(CONFIG_HWMON) condition check in hsmp.h
6. Remove hsmp_hwmon struct in hsmp.h and add hwmon_channel_info and hwmon_chip_info to hwmon.c file as static variables
7. Change argument to devm_hwmon_device_register_with_info()
8. Remove hsmp_create_power_sensor() and define power info statically. Instead of multiple channel, use single channel with different attributes.
9. Replace switch with if in hsmp_hwmon_is_visble()
10. Remove referencing channel related code in hsmp_hwmon_read() and add code for attribute checking.
11. Replace switch with if in hsmp_hwmon_read()
12. Remove hsmp_hwmon_read_label().
13. Update hsmp_hwmon_write() to remove switch and code related to channel
14. Remove int-ll64.h header
15. Update the documentation
Documentation/arch/x86/amd_hsmp.rst | 10 ++ drivers/platform/x86/amd/hsmp/Makefile | 1 + drivers/platform/x86/amd/hsmp/acpi.c | 4 + drivers/platform/x86/amd/hsmp/hsmp.h | 11 ++- drivers/platform/x86/amd/hsmp/hwmon.c | 124 +++++++++++++++++++++++++ drivers/platform/x86/amd/hsmp/plat.c | 5 + 6 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 drivers/platform/x86/amd/hsmp/hwmon.c
Documentation/arch/x86/amd_hsmp.rst +10 -0
@@ -117,6 +117,16 @@ for socket with ID00 is given below:: } +HSMP HWMON interface +================== +HSMP power sensors are registered with hwmon interface. + +One hwmon directory is created for each socket and following files with 0444 permission are created +inside the hwmon directory. +- power1_input +- power1_cap_max +- power1_cap + An example ==========
drivers/platform/x86/amd/hsmp/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_AMD_HSMP) += hsmp_common.o hsmp_common-y := hsmp.o +hsmp_common-$(CONFIG_HWMON) += hwmon.o obj-$(CONFIG_AMD_HSMP_PLAT) += amd_hsmp.o amd_hsmp-y := plat.o obj-$(CONFIG_AMD_HSMP_ACPI) += hsmp_acpi.o
drivers/platform/x86/amd/hsmp/acpi.c +4 -0
@@ -281,6 +281,10 @@ static int init_acpi(struct device *dev)dev_err (dev,"Failed to init metric table\n" ); } + ret =hsmp_create_sensor (dev, sock_ind); +if (ret) +dev_err (dev,"Failed to register HSMP sensors with hwmon\n" ); +return ret; }
drivers/platform/x86/amd/hsmp/hsmp.h +10 -1
@@ -12,6 +12,7 @@#include <linux/compiler_types.h> #include <linux/device.h> +#include <linux/hwmon.h> #include <linux/miscdevice.h> #include <linux/pci.h> #include <linux/semaphore.h>
@@ -26,7 +27,7 @@#define HSMP_CDEV_NAME "hsmp_cdev"#define HSMP_DEVNODE_NAME "hsmp" -#define DRIVER_VERSION "2.4" +#define DRIVER_VERSION "2.5"struct hsmp_mbaddr_info {u32 base_addr;
@@ -65,4 +66,12 @@ int hsmp_misc_register(struct device *dev);int hsmp_get_tbl_dram_base (u16 sock_ind);ssize_t hsmp_metric_tbl_read (struct hsmp_socket *sock,char *buf,size_t size);struct hsmp_plat_device *get_hsmp_pdev (void ); +#if IS_REACHABLE (CONFIG_HWMON ) +int hsmp_create_sensor (struct device *dev,u16 sock_ind); +#else +int hsmp_create_sensor (struct device *dev,u16 sock_ind); +{ +return 0 ; +} +#endif #endif /* HSMP_H */
drivers/platform/x86/amd/hsmp/hwmon.c new file +124 -0
124 lines not on this page · raw message
drivers/platform/x86/amd/hsmp/plat.c +5 -0
@@ -200,6 +200,11 @@ static int init_platform_device(struct device *dev)if (ret)dev_err (dev,"Failed to init metric table\n" ); } + +/* Register with hwmon interface for reporting power */ + ret =hsmp_create_sensor (dev, i); +if (ret) +dev_err (dev,"Failed to register HSMP sensors with hwmon\n" ); }return 0 ;
Signature · 1 line
2.25.1
Ilpo Järvinen
maintainerRe: [v2 2/3] platform/x86/amd/hsmp: Report power using hwmon sensors
Quoted 103 lines · Suma Hegde
Expose power reading and power limits via hwmon power sensors.
Signed-off-by Suma Hegde <[email protected]>Reviewed-by Naveen Krishna Chatradhi <[email protected]>---
Changes since v1:
1. Movehsmp_create_sensor()call toinit_acpi()inacpi.candinit_platform_device()inplat.c
2. Pass u16 as parameter instead of void * inhsmp_create_sensor()
3. Changedev_err()print afterhsmp_create_sensor()
4. AddCONFIG_HWMONdependency inMakefile
5. Add #ifIS_REACHABLE(CONFIG_HWMON)condition check inhsmp.h
6. Removehsmp_hwmonstruct inhsmp.hand addhwmon_channel_infoandhwmon_chip_infotohwmon.cfile as static variables
7. Change argument todevm_hwmon_device_register_with_info()
8. Removehsmp_create_power_sensor()and define power info statically. Instead of multiple channel, use single channel with different attributes.
9. Replace switch with if inhsmp_hwmon_is_visble()
10. Remove referencing channel related code inhsmp_hwmon_read()and add code for attribute checking.
11. Replace switch with if inhsmp_hwmon_read()
12. Removehsmp_hwmon_read_label().
13. Updatehsmp_hwmon_write()to remove switch and code related to channel
14. Removeint-ll64.hheader
15. Update the documentationDocumentation/arch/x86/amd_hsmp.rst | 10 ++ drivers/platform/x86/amd/hsmp/Makefile | 1 + drivers/platform/x86/amd/hsmp/acpi.c | 4 + drivers/platform/x86/amd/hsmp/hsmp.h | 11 ++- drivers/platform/x86/amd/hsmp/hwmon.c | 124 +++++++++++++++++++++++++ drivers/platform/x86/amd/hsmp/plat.c | 5 + 6 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 drivers/platform/x86/amd/hsmp/hwmon.cDocumentation/arch/x86/amd_hsmp.rst +10
-0@@ -117,6 +117,16 @@ for socket with ID00 is given below:: } +HSMP HWMON interface +================== +HSMP power sensors are registered with hwmon interface. + +One hwmon directory is created for each socket and following files with 0444 permission are created +inside the hwmon directory. +- power1_input +- power1_cap_max +- power1_cap + An example ==========drivers/platform/x86/amd/hsmp/Makefile +1
-0@@ -6,6 +6,7 @@ obj-$(CONFIG_AMD_HSMP) += hsmp_common.o hsmp_common-y := hsmp.o +hsmp_common-$(CONFIG_HWMON) += hwmon.o obj-$(CONFIG_AMD_HSMP_PLAT) += amd_hsmp.o amd_hsmp-y := plat.o obj-$(CONFIG_AMD_HSMP_ACPI) += hsmp_acpi.odrivers/platform/x86/amd/hsmp/acpi.c +4
-0@@ -281,6 +281,10 @@ static int init_acpi(struct device *dev)dev_err (dev,"Failed to init metric table\n" ); } + ret =hsmp_create_sensor (dev, sock_ind); +if (ret) +dev_err (dev,"Failed to register HSMP sensors with hwmon\n" ); +return ret; }drivers/platform/x86/amd/hsmp/hsmp.h +2
-1@@ -12,6 +12,7 @@#include <linux/compiler_types.h> #include <linux/device.h> +#include <linux/hwmon.h> #include <linux/miscdevice.h> #include <linux/pci.h> #include <linux/semaphore.h> @@ -26,7 +27,7 @@#define HSMP_CDEV_NAME "hsmp_cdev"#define HSMP_DEVNODE_NAME "hsmp" -#define DRIVER_VERSION "2.4" +#define DRIVER_VERSION "2.5"struct hsmp_mbaddr_info {u32 base_addr;
drivers/platform/x86/amd/hsmp/hsmp.h int hsmp_misc_register(struct device *dev); · line 75
Quoted 10 lines
drivers/platform/x86/amd/hsmp/hsmp.h +7
-0@@ -65,4 +66,12 @@ int hsmp_misc_register(struct device *dev);int hsmp_get_tbl_dram_base (u16 sock_ind);ssize_t hsmp_metric_tbl_read (struct hsmp_socket *sock,char *buf,size_t size);struct hsmp_plat_device *get_hsmp_pdev (void ); +#if IS_REACHABLE (CONFIG_HWMON ) +int hsmp_create_sensor (struct device *dev,u16 sock_ind); +#else +int hsmp_create_sensor (struct device *dev,u16 sock_ind); +{ +return 0 ; +}
Does this even compile with the extra semicolon?!? In any case, put the stub's code right after the function:
int hsmp_create_sensor(struct device *dev, u16 sock_ind) { return 0; }
Quoted 20 lines
drivers/platform/x86/amd/hsmp/hsmp.h +1
-0+#endif #endif /* HSMP_H */ drivers/platform/x86/amd/hsmp/hwmon.c new file +12
-0@@ -0,0 +1,124 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* AMD HSMP hwmon support +* Copyright (c) 2025, AMD. +* All Rights Reserved. +* +* This file provides hwmon implementation for HSMP interface. +*/ + +#include <asm/amd_hsmp.h> + +#include <linux/device.h>
drivers/platform/x86/amd/hsmp/hwmon.c line 22
Quoted 10 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +10
-0+#include <linux/hwmon.h> + +#include "hsmp.h" + +#define HSMP_HWMON_NAME "amd_hsmp_hwmon" + +static int hsmp_hwmon_write (struct device *dev,enum hwmon_sensor_types type, +u32 attr,int channel,long val) +{ +u16 sock_ind = (uintptr_t )dev_get_drvdata (dev);
Casting to intermediate type serves no purpose so why not cast directly to u16?
drivers/platform/x86/amd/hsmp/hwmon.c line 23
Quoted 1 line
drivers/platform/x86/amd/hsmp/hwmon.c new file +1
-0+
Remove extra line.
drivers/platform/x86/amd/hsmp/hwmon.c line 24
Quoted 1 line
drivers/platform/x86/amd/hsmp/hwmon.c new file +1
-0+struct hsmp_message msg = {0 };
{} is enough to initialize.
drivers/platform/x86/amd/hsmp/hwmon.c line 27
Quoted 3 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +3
-0+ +if (type != hwmon_power) +return -EOPNOTSUPP ;
Add #include.
Quoted 7 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +7
-0+ +if (attr != hwmon_power_cap) +return -EOPNOTSUPP ; + + msg.num_args =1 ; + msg.args[0 ] = val; + msg.msg_id =HSMP_SET_SOCKET_POWER_LIMIT ;
drivers/platform/x86/amd/hsmp/hwmon.c line 44
Quoted 10 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +10
-0+ msg.sock_ind = sock_ind; +return hsmp_send_message (&msg); +} + +static int hsmp_hwmon_read (struct device *dev, +enum hwmon_sensor_types type, +u32 attr,int channel,long *val) +{ +u16 sock_ind = (uintptr_t )dev_get_drvdata (dev); +struct hsmp_message msg = {0 };
Remove double cast and {}.
Quoted 38 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +38
-0+int ret; + +if (type != hwmon_power) +return -EOPNOTSUPP ; + + msg.sock_ind = sock_ind; + msg.response_sz =1 ; + +switch (attr) { +case hwmon_power_input: + msg.msg_id =HSMP_GET_SOCKET_POWER ; +break ; +case hwmon_power_cap: + msg.msg_id =HSMP_GET_SOCKET_POWER_LIMIT ; +break ; +case hwmon_power_cap_max: + msg.msg_id =HSMP_GET_SOCKET_POWER_LIMIT_MAX ; +break ; +default : +return -EOPNOTSUPP ; + } + + ret =hsmp_send_message (&msg); +if (!ret) + *val = msg.args[0 ]; + +return ret; +} + +static umode_t hsmp_hwmon_is_visble (const void *data, +enum hwmon_sensor_types type, +u32 attr,int channel) +{ +if (type != hwmon_power) +return 0 ; + +switch (attr) { +case hwmon_power_input:
drivers/platform/x86/amd/hsmp/hwmon.c line 92
Quoted 10 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +10
-0+return 0444 ; +case hwmon_power_cap: +return 0644 ; +case hwmon_power_cap_max: +return 0444 ; +default : +return 0 ; + } + +return 0 ;
Is this line required by some stupid checker???
Quoted 14 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +14
-0+} + +static const struct hwmon_ops hsmp_hwmon_ops = { + .read = hsmp_hwmon_read, + .is_visible = hsmp_hwmon_is_visble, + .write = hsmp_hwmon_write, +}; + +static const struct hwmon_channel_info *const hsmp_info[] = { +HWMON_CHANNEL_INFO (power,HWMON_P_INPUT |HWMON_P_CAP |HWMON_P_CAP_MAX ), +NULL +}; + +static const struct hwmon_chip_info hsmp_chip_info = {
drivers/platform/x86/amd/hsmp/hwmon.c line 116
Quoted 10 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +10
-0+ .ops = &hsmp_hwmon_ops, + .info = hsmp_info +}; + +int hsmp_create_sensor (struct device *dev,u16 sock_ind) +{ +struct device *hwmon_dev; + + hwmon_dev = devm_hwmon_device_register_with_info(dev, HSMP_HWMON_NAME, + (void *)(uintptr_t)(sock_ind),
Double casting seems pointless here as well. And sock_ind doesn't need parenthesis either.
drivers/platform/x86/amd/hsmp/hwmon.c line 122
Quoted 6 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +6
-0+ &hsmp_chip_info, + NULL); +if (IS_ERR (hwmon_dev)) +return PTR_ERR (hwmon_dev); + +return 0 ;
There's some err helper for this PTR_ERR_OR_ZERO() (IIRC). You also need to add #include for it (same would have applied to IS_ERR / PTR_ERR).
Quoted 19 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +2
-0+} +EXPORT_SYMBOL_NS (hsmp_create_sensor,"AMD_HSMP" );drivers/platform/x86/amd/hsmp/plat.c +5
-0@@ -200,6 +200,11 @@ static int init_platform_device(struct device *dev)if (ret)dev_err (dev,"Failed to init metric table\n" ); } + +/* Register with hwmon interface for reporting power */ + ret =hsmp_create_sensor (dev, i); +if (ret) +dev_err (dev,"Failed to register HSMP sensors with hwmon\n" ); }return 0 ;
Signature · 1 line
i.
Re: [v2 2/3] platform/x86/amd/hsmp: Report power using hwmon sensors
Hi Ilpo,
Quoted 147 lines · Ilpo Järvinen
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 103 lines · Suma Hegde
Expose power reading and power limits via hwmon power sensors.
Signed-off-by Suma Hegde <[email protected]>Reviewed-by Naveen Krishna Chatradhi <[email protected]>---
Changes since v1:
1. Movehsmp_create_sensor()call toinit_acpi()inacpi.candinit_platform_device()inplat.c
2. Pass u16 as parameter instead of void * inhsmp_create_sensor()
3. Changedev_err()print afterhsmp_create_sensor()
4. AddCONFIG_HWMONdependency inMakefile
5. Add #ifIS_REACHABLE(CONFIG_HWMON)condition check inhsmp.h
6. Removehsmp_hwmonstruct inhsmp.hand addhwmon_channel_infoandhwmon_chip_infotohwmon.cfile as static variables
7. Change argument todevm_hwmon_device_register_with_info()
8. Removehsmp_create_power_sensor()and define power info statically. Instead of multiple channel, use single channel with different attributes.
9. Replace switch with if inhsmp_hwmon_is_visble()
10. Remove referencing channel related code inhsmp_hwmon_read()and add code for attribute checking.
11. Replace switch with if inhsmp_hwmon_read()
12. Removehsmp_hwmon_read_label().
13. Updatehsmp_hwmon_write()to remove switch and code related to channel
14. Removeint-ll64.hheader
15. Update the documentationDocumentation/arch/x86/amd_hsmp.rst | 10 ++ drivers/platform/x86/amd/hsmp/Makefile | 1 + drivers/platform/x86/amd/hsmp/acpi.c | 4 + drivers/platform/x86/amd/hsmp/hsmp.h | 11 ++- drivers/platform/x86/amd/hsmp/hwmon.c | 124 +++++++++++++++++++++++++ drivers/platform/x86/amd/hsmp/plat.c | 5 + 6 files changed, 154 insertions(+), 1 deletion(-)create mode 100644
drivers/platform/x86/amd/hsmp/hwmon.cDocumentation/arch/x86/amd_hsmp.rst +10
-0@@ -117,6 +117,16 @@ for socket with ID00 is given below:: } +HSMP HWMON interface +================== +HSMP power sensors are registered with hwmon interface. + +One hwmon directory is created for each socket and following files with 0444 permission are created +inside the hwmon directory. +- power1_input +- power1_cap_max +- power1_cap + An example ==========drivers/platform/x86/amd/hsmp/Makefile +1
-0@@ -6,6 +6,7 @@ obj-$(CONFIG_AMD_HSMP) += hsmp_common.o hsmp_common-y := hsmp.o +hsmp_common-$(CONFIG_HWMON) += hwmon.o obj-$(CONFIG_AMD_HSMP_PLAT) += amd_hsmp.o amd_hsmp-y := plat.o obj-$(CONFIG_AMD_HSMP_ACPI) += hsmp_acpi.odrivers/platform/x86/amd/hsmp/acpi.c +4
-0@@ -281,6 +281,10 @@ static int init_acpi(struct device *dev)dev_err (dev,"Failed to init metric table\n" ); } + ret =hsmp_create_sensor (dev, sock_ind); +if (ret) +dev_err (dev,"Failed to register HSMP sensors with hwmon\n" ); +return ret; }drivers/platform/x86/amd/hsmp/hsmp.h +2
-1@@ -12,6 +12,7 @@#include <linux/compiler_types.h> #include <linux/device.h> +#include <linux/hwmon.h> #include <linux/miscdevice.h> #include <linux/pci.h> #include <linux/semaphore.h> @@ -26,7 +27,7 @@#define HSMP_CDEV_NAME "hsmp_cdev"#define HSMP_DEVNODE_NAME "hsmp" -#define DRIVER_VERSION "2.4" +#define DRIVER_VERSION "2.5"struct hsmp_mbaddr_info {u32 base_addr;drivers/platform/x86/amd/hsmp/hsmp.h int hsmp_misc_register(struct device *dev); · line 75
Quoted 10 lines
drivers/platform/x86/amd/hsmp/hsmp.h +7
-0@@ -65,4 +66,12 @@ int hsmp_misc_register(struct device *dev);int hsmp_get_tbl_dram_base (u16 sock_ind);ssize_t hsmp_metric_tbl_read (struct hsmp_socket *sock,char *buf,size_t size);struct hsmp_plat_device *get_hsmp_pdev (void ); +#if IS_REACHABLE (CONFIG_HWMON ) +int hsmp_create_sensor (struct device *dev,u16 sock_ind); +#else +int hsmp_create_sensor (struct device *dev,u16 sock_ind); +{ +return 0 ; +}Does this even compile with the extra semicolon?!? In any case, put the stub's code right after the function:
int
hsmp_create_sensor(struct device *dev, u16 sock_ind){ return 0; }Quoted 24 lines
drivers/platform/x86/amd/hsmp/hsmp.h +1
-0+#endif #endif /* HSMP_H */ drivers/platform/x86/amd/hsmp/hwmon.c new file +16
-0@@ -0,0 +1,124 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* AMD HSMP hwmon support +* Copyright (c) 2025, AMD. +* All Rights Reserved. +* +* This file provides hwmon implementation for HSMP interface. +*/ + +#include <asm/amd_hsmp.h> + +#include <linux/device.h> +#include <linux/hwmon.h> + +#include "hsmp.h" +
Quoted 8 lines
drivers/platform/x86/amd/hsmp/hwmon.c line 22
Quoted 6 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +6
-0+#define HSMP_HWMON_NAME "amd_hsmp_hwmon" + +static int hsmp_hwmon_write (struct device *dev,enum hwmon_sensor_types type, +u32 attr,int channel,long val) +{ +u16 sock_ind = (uintptr_t )dev_get_drvdata (dev);Casting to intermediate type serves no purpose so why not cast directly to u16?
I included uintptr_t instaed of u16 to resolve the below mentioned compiler warning.
"warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]"
Quoted 73 lines
drivers/platform/x86/amd/hsmp/hwmon.c line 23
Quoted 2 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +1
-0+Remove extra line.
drivers/platform/x86/amd/hsmp/hwmon.c line 24
Quoted 1 line
drivers/platform/x86/amd/hsmp/hwmon.c new file +1
-0+struct hsmp_message msg = {0 };{} is enough to initialize.
drivers/platform/x86/amd/hsmp/hwmon.c line 27
Quoted 3 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +3
-0+ +if (type != hwmon_power) +return -EOPNOTSUPP ;Add #include.
Quoted 7 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +7
-0+ +if (attr != hwmon_power_cap) +return -EOPNOTSUPP ; + + msg.num_args =1 ; + msg.args[0 ] = val; + msg.msg_id =HSMP_SET_SOCKET_POWER_LIMIT ;drivers/platform/x86/amd/hsmp/hwmon.c line 44
Quoted 10 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +10
-0+ msg.sock_ind = sock_ind; +return hsmp_send_message (&msg); +} + +static int hsmp_hwmon_read (struct device *dev, +enum hwmon_sensor_types type, +u32 attr,int channel,long *val) +{ +u16 sock_ind = (uintptr_t )dev_get_drvdata (dev); +struct hsmp_message msg = {0 };Remove double cast and {}.
Quoted 41 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +41
-0+int ret; + +if (type != hwmon_power) +return -EOPNOTSUPP ; + + msg.sock_ind = sock_ind; + msg.response_sz =1 ; + +switch (attr) { +case hwmon_power_input: + msg.msg_id =HSMP_GET_SOCKET_POWER ; +break ; +case hwmon_power_cap: + msg.msg_id =HSMP_GET_SOCKET_POWER_LIMIT ; +break ; +case hwmon_power_cap_max: + msg.msg_id =HSMP_GET_SOCKET_POWER_LIMIT_MAX ; +break ; +default : +return -EOPNOTSUPP ; + } + + ret =hsmp_send_message (&msg); +if (!ret) + *val = msg.args[0 ]; + +return ret; +} + +static umode_t hsmp_hwmon_is_visble (const void *data, +enum hwmon_sensor_types type, +u32 attr,int channel) +{ +if (type != hwmon_power) +return 0 ; + +switch (attr) { +case hwmon_power_input: +return 0444 ; +case hwmon_power_cap: +return 0644 ;
Quoted 8 lines
drivers/platform/x86/amd/hsmp/hwmon.c line 92
Quoted 7 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +7
-0+case hwmon_power_cap_max: +return 0444 ; +default : +return 0 ; + } + +return 0 ;Is this line required by some stupid checker???
I will remove it. checkpatch is not giving any warning .
Quoted 19 lines
Quoted 19 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +18
-0+} + +static const struct hwmon_ops hsmp_hwmon_ops = { + .read = hsmp_hwmon_read, + .is_visible = hsmp_hwmon_is_visble, + .write = hsmp_hwmon_write, +}; + +static const struct hwmon_channel_info *const hsmp_info[] = { +HWMON_CHANNEL_INFO (power,HWMON_P_INPUT |HWMON_P_CAP |HWMON_P_CAP_MAX ), +NULL +}; + +static const struct hwmon_chip_info hsmp_chip_info = { + .ops = &hsmp_hwmon_ops, + .info = hsmp_info +}; +
Quoted 8 lines
drivers/platform/x86/amd/hsmp/hwmon.c line 116
Quoted 6 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +6
-0+int hsmp_create_sensor (struct device *dev,u16 sock_ind) +{ +struct device *hwmon_dev; + + hwmon_dev = devm_hwmon_device_register_with_info(dev, HSMP_HWMON_NAME, + (void *)(uintptr_t)(sock_ind),Double casting seems pointless here as well. And
sock_inddoesn't need parenthesis either.
Added this double casting to avoid compiler warning.
Quoted 26 lines
drivers/platform/x86/amd/hsmp/hwmon.c line 122
Quoted 6 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +6
-0+ &hsmp_chip_info, + NULL); +if (IS_ERR (hwmon_dev)) +return PTR_ERR (hwmon_dev); + +return 0 ;There's some err helper for this
PTR_ERR_OR_ZERO()(IIRC). You also need to add #include for it (same would have applied toIS_ERR/PTR_ERR).Quoted 17 lines
drivers/platform/x86/amd/hsmp/hwmon.c new file +2
-0+} +EXPORT_SYMBOL_NS (hsmp_create_sensor,"AMD_HSMP" );drivers/platform/x86/amd/hsmp/plat.c +5
-0@@ -200,6 +200,11 @@ static int init_platform_device(struct device *dev)if (ret)dev_err (dev,"Failed to init metric table\n" ); } + +/* Register with hwmon interface for reporting power */ + ret =hsmp_create_sensor (dev, i); +if (ret) +dev_err (dev,"Failed to register HSMP sensors with hwmon\n" ); }
Quoted 4 lines
drivers/platform/x86/amd/hsmp/plat.c static int init_platform_device(struct device *dev) · line 210
Quoted 2 lines
drivers/platform/x86/amd/hsmp/plat.c +0
-0return 0 ;--
i.
Thanks and Regards,
Suma
Quoted 1 line
PATCH v2 3/3 platform/x86/amd/hsmp: acpi: Add sysfs files to show HSMP telemetry
In reply to Suma HegdeMake frequently fetched telemetry available via sysfs interface.
Create following sysfs files per acpi device node.
* c0_residency_input
* prochot_status
* smu_fw_version
* protocol_version
* ddr_max_bw(GB/s)
* ddr_utilised_bw_input(GB/s)
* ddr_utilised_bw_perc_input(%)
* mclk_input(MHz)
* fclk_input(MHz)
* clk_fmax(MHz)
* clk_fmin(MHz)
* cclk_freq_limit_input(MHz)
* pwr_current_active_freq_limit(MHz)
* pwr_current_active_freq_limit_source
---
Changes since v1:
1. Add linux/bitops.h
2. Define DDR_MAX_BW, DDR_UTIL_BW DDR_UTIL_BW_PERC FW_VER_MAJOR FW_VER_MINOR FW_VER_DEBUG FMAX FMIN FREQ_LIMIT FREQ_SRC_IND and use them in functions.
3. Return early in hsmp_msg_get_nargs()
4. Change while loop to for loop in hsmp_freq_limit_source_show()
5. Correct the GENMASK size in hsmp_ddr_util_bw_show()[bit 19:8, instead
of bit 20:8]
Documentation/arch/x86/amd_hsmp.rst | 31 +++- drivers/platform/x86/amd/hsmp/acpi.c | 259 +++++++++++++++++++++++++++ drivers/platform/x86/amd/hsmp/hsmp.c | 21 +++ drivers/platform/x86/amd/hsmp/hsmp.h | 1 + 4 files changed, 305 insertions(+), 7 deletions(-)
Documentation/arch/x86/amd_hsmp.rst +24 -7
@@ -71,6 +71,25 @@ Note: lseek() is not supported as entire metrics table is read. Metrics table definitions will be documented as part of Public PPR. The same is defined in the amd_hsmp.h header. +2. HSMP telemetry sysfs files + +Following sysfs file are available at /sys/devices/platform/AMDI0097:0X/. + +* c0_residency_input : percentage of cores in C0 state +* prochot_status : reports 1 if socket is in prochot, 0 otherwhile +* smu_fw_version : SMU firmware version +* protocol_version : HSMP interface version +* ddr_max_bw : theoretical maximum ddr bw in GB/s +* ddr_utilised_bw_input: current utilized ddr bw in GB/s +* ddr_utilised_bw_perc_input(%): Percentage of current utilized ddr bw +* mclk_input : memory clock in MHz +* fclk_input: fabric clock in MHz +* clk_fmax : max frequency of socket in MHz +* clk_fmin : min frequency of socket in MHz +* cclk_freq_limit_input : core clock frequency limit per socket in MHz +* pwr_current_active_freq_limit: current active frequency limit of socket in MHz +* pwr_current_active_freq_limit_source: source of current active frequency limit + ACPI device object format ========================= The ACPI object format expected from the amd_hsmp driver
@@ -119,13 +138,11 @@ for socket with ID00 is given below:: HSMP HWMON interface ================== -HSMP power sensors are registered with hwmon interface. - -One hwmon directory is created for each socket and following files with 0444 permission are created -inside the hwmon directory. -- power1_input -- power1_cap_max -- power1_cap +HSMP power sensors are registered with hwmon interface. One hwmon directory is created for each +socket and following files are created inside the hwmon directory. +- power1_input(read only) +- power1_cap_max(read only) +- power1_cap(read, write) An example ==========
drivers/platform/x86/amd/hsmp/acpi.c +259 -0
292 lines not on this page · raw message
drivers/platform/x86/amd/hsmp/hsmp.c +21 -0
@@ -229,6 +229,27 @@ int hsmp_send_message(struct hsmp_message *msg) }EXPORT_SYMBOL_NS_GPL (hsmp_send_message,"AMD_HSMP" ); +int hsmp_msg_get_nargs (u16 sock_ind,u32 msg_id,u32 *data,u8 n) +{ +struct hsmp_message msg = {0 }; +int ret; +int i; + +if (!data) +return -EINVAL ; + msg.msg_id = msg_id; + msg.sock_ind = sock_ind; + msg.response_sz = n; + + ret =hsmp_send_message (&msg); +if (!ret) { +for (i =0 ; i < n; i++) + data[i] = msg.args[i]; + } +return ret; +} +EXPORT_SYMBOL_NS_GPL (hsmp_msg_get_nargs,"AMD_HSMP" ); +int hsmp_test (u16 sock_ind,u32 value) {struct hsmp_message msg = {0 };
drivers/platform/x86/amd/hsmp/hsmp.h +1 -0
@@ -74,4 +74,5 @@ int hsmp_create_sensor(struct device *dev, u16 sock_ind);return 0 ; }#endif +int hsmp_msg_get_nargs (u16 sock_ind,u32 msg_id,u32 *data,u8 n);#endif /* HSMP_H */
Signature · 1 line
2.25.1
Ilpo Järvinen
maintainerRe: [v2 3/3] platform/x86/amd/hsmp: acpi: Add sysfs files to show HSMP telemetry
Quoted 41 lines · Suma Hegde
Make frequently fetched telemetry available via sysfs interface.
Create following sysfs files per acpi device node.
*c0_residency_input
*prochot_status
*smu_fw_version
*protocol_version
*ddr_max_bw(GB/s)
*ddr_utilised_bw_input(GB/s)
*ddr_utilised_bw_perc_input(%)
*mclk_input(MHz)
*fclk_input(MHz)
*clk_fmax(MHz)
*clk_fmin(MHz)
*cclk_freq_limit_input(MHz)
*pwr_current_active_freq_limit(MHz)
*pwr_current_active_freq_limit_sourceSigned-off-by Suma Hegde <[email protected]>Reviewed-by Naveen Krishna Chatradhi <[email protected]>---
Changes since v1:
1. Addlinux/bitops.h
2. DefineDDR_MAX_BW,DDR_UTIL_BWDDR_UTIL_BW_PERCFW_VER_MAJORFW_VER_MINORFW_VER_DEBUGFMAX FMINFREQ_LIMITFREQ_SRC_INDand use them in functions.
3. Return early inhsmp_msg_get_nargs()
4. Change while loop to for loop inhsmp_freq_limit_source_show()
5. Correct the GENMASK size in hsmp_ddr_util_bw_show()[bit 19:8, instead
of bit 20:8]Documentation/arch/x86/amd_hsmp.rst | 31 +++- drivers/platform/x86/amd/hsmp/acpi.c | 259 +++++++++++++++++++++++++++ drivers/platform/x86/amd/hsmp/hsmp.c | 21 +++ drivers/platform/x86/amd/hsmp/hsmp.h | 1 + 4 files changed, 305 insertions(+), 7 deletions(-)Documentation/arch/x86/amd_hsmp.rst +0
-0
Documentation/arch/x86/amd_hsmp.rst Note: lseek() is not supported as entire metrics table is read. · line 79
Quoted 9 lines
Documentation/arch/x86/amd_hsmp.rst +6
-0@@ -71,6 +71,25 @@ Note: lseek() is not supported as entire metrics table is read. Metrics table definitions will be documented as part of Public PPR. The same is defined in the amd_hsmp.h header. +2. HSMP telemetry sysfs files + +Following sysfs file are available at /sys/devices/platform/AMDI0097:0X/. + +* c0_residency_input : percentage of cores in C0 state +* prochot_status : reports 1 if socket is in prochot, 0 otherwhile
otherwise
What's "prochot" ?
Documentation/arch/x86/amd_hsmp.rst Note: lseek() is not supported as entire metrics table is read. · line 82
Quoted 3 lines
Documentation/arch/x86/amd_hsmp.rst +3
-0+* smu_fw_version : SMU firmware version +* protocol_version : HSMP interface version +* ddr_max_bw : theoretical maximum ddr bw in GB/s
Please capitalize comments and documentation properly.
Documentation/arch/x86/amd_hsmp.rst Note: lseek() is not supported as entire metrics table is read. · line 90
Quoted 8 lines
Documentation/arch/x86/amd_hsmp.rst +8
-0+* ddr_utilised_bw_input: current utilized ddr bw in GB/s +* ddr_utilised_bw_perc_input(%): Percentage of current utilized ddr bw +* mclk_input : memory clock in MHz +* fclk_input: fabric clock in MHz +* clk_fmax : max frequency of socket in MHz +* clk_fmin : min frequency of socket in MHz +* cclk_freq_limit_input : core clock frequency limit per socket in MHz +* pwr_current_active_freq_limit: current active frequency limit of socket in MHz
Is that "active" a meaningful word in this or would just current frequency limit suffice?
Quoted 8 lines
Documentation/arch/x86/amd_hsmp.rst +2
-0+* pwr_current_active_freq_limit_source: source of current active frequency limit + ACPI device object format ========================= The ACPI object format expected from the amd_hsmp driver@@ -119,13 +138,11 @@ for socket with ID00 is given below:: HSMP HWMON interface
Documentation/arch/x86/amd_hsmp.rst for socket with ID00 is given below:: · line 142
Quoted 10 lines
Documentation/arch/x86/amd_hsmp.rst +2
-7================== -HSMP power sensors are registered with hwmon interface. - -One hwmon directory is created for each socket and following files with 0444 permission are created -inside the hwmon directory. -- power1_input -- power1_cap_max -- power1_cap +HSMP power sensors are registered with hwmon interface. One hwmon directory is created for each +socket and following files are created inside the hwmon directory.
Please fold documentation paragraphs at 80 chars.
Documentation/arch/x86/amd_hsmp.rst for socket with ID00 is given below:: · line 145
Quoted 3 lines
Documentation/arch/x86/amd_hsmp.rst +3
-0+- power1_input(read only) +- power1_cap_max(read only) +- power1_cap(read, write)
Don't these need space in before (?
Quoted 39 lines
Documentation/arch/x86/amd_hsmp.rst +0
-0An example ==========drivers/platform/x86/amd/hsmp/acpi.c +14
-0@@ -13,6 +13,7 @@#include <asm/amd_nb.h> #include <linux/acpi.h> +#include <linux/bitops.h> #include <linux/device.h> #include <linux/dev_printk.h> #include <linux/ioport.h> @@ -36,6 +37,11 @@static struct hsmp_plat_device *hsmp_pdev; +struct hsmp_sys_attr { +struct device_attribute dattr; +u32 msg_id; +}; +static int amd_hsmp_acpi_rdwr (struct hsmp_socket *sock,u32 offset,u32 *value,bool write) {@@ -243,6 +249,214 @@ static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj,return 0 ; } +static umode_t hsmp_is_sock_dev_attr_visible (struct kobject *kobj, +struct attribute *attr,int id) +{ +return attr->mode; +} + +#define to_hsmp_sys_attr (__attr) container_of(__attr, struct hsmp_sys_attr, dattr) +
drivers/platform/x86/amd/hsmp/acpi.c static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, · line 269
Quoted 10 lines
drivers/platform/x86/amd/hsmp/acpi.c +10
-0+static ssize_t hsmp_msg_resp32_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, &data,1 ); +if (!ret)
Reverse logic and handle the error first. Only on very special occassions can it be done the other way around but the normal principle is check error and early return.
Quoted 17 lines
drivers/platform/x86/amd/hsmp/acpi.c +17
-0+return sysfs_emit (buf,"%u\n" , data); + +return ret; +} + +#define DDR_MAX_BW (data) FIELD_GET(GENMASK(31, 20), data) +#define DDR_UTIL_BW (data) FIELD_GET(GENMASK(19, 8), data) +#define DDR_UTIL_BW_PERC (data) FIELD_GET(GENMASK(7, 0), data) +#define FW_VER_MAJOR (data) FIELD_GET(GENMASK(23, 16), data) +#define FW_VER_MINOR (data) FIELD_GET(GENMASK(15, 8), data) +#define FW_VER_DEBUG (data) FIELD_GET(GENMASK(7, 0), data) +#define FMAX (data) FIELD_GET(GENMASK(31, 16), data) +#define FMIN (data) FIELD_GET(GENMASK(15, 0), data) +#define FREQ_LIMIT (data) FIELD_GET(GENMASK(31, 16), data) +#define FREQ_SRC_IND (data) FIELD_GET(GENMASK(15, 0), data) + +static ssize_t hsmp_ddr_max_bw_show(struct device *dev, struct device_attribute *attr,
drivers/platform/x86/amd/hsmp/acpi.c static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, · line 296
Quoted 10 lines
drivers/platform/x86/amd/hsmp/acpi.c +10
-0+ char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, &data,1 ); +if (!ret) +return sysfs_emit (buf,"%u\n" , (u32 )DDR_MAX_BW (data));
Why are these cast necessary?
I'd prefer naming the fields instead of making them function like macros and using FIELD_GET() here.
Quoted 123 lines
drivers/platform/x86/amd/hsmp/acpi.c +123
-0+ +return ret; +} + +static ssize_t hsmp_ddr_util_bw_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, &data,1 ); +if (!ret) +return sysfs_emit (buf,"%u\n" , (u32 )DDR_UTIL_BW (data)); +return ret; +} + +static ssize_t hsmp_ddr_util_bw_perc_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, &data,1 ); +if (!ret) +return sysfs_emit (buf,"%u\n" , (u32 )DDR_UTIL_BW_PERC (data)); + +return ret; +} + +static ssize_t hsmp_msg_fw_ver_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, &data,1 ); +if (!ret) +return sysfs_emit (buf,"%u.%u.%u\n" , (u32 )FW_VER_MAJOR (data), + (u32 )FW_VER_MINOR (data), (u32 )FW_VER_DEBUG (data)); + +return ret; +} + +static ssize_t hsmp_fclk_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data[2 ]; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, data,2 ); +if (!ret) +return sysfs_emit (buf,"%u\n" , data[0 ]); + +return ret; +} + +static ssize_t hsmp_mclk_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data[2 ]; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, data,2 ); +if (!ret) +return sysfs_emit (buf,"%u\n" , data[1 ]); + +return ret; +} + +static ssize_t hsmp_clk_fmax_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, &data,1 ); +if (!ret) +return sysfs_emit (buf,"%u\n" , (u32 )FMAX (data)); + +return ret; +} + +static ssize_t hsmp_clk_fmin_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, &data,1 ); +if (!ret) +return sysfs_emit (buf,"%u\n" , (u32 )FMIN (data)); + +return ret; +} + +static ssize_t hsmp_freq_limit_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, &data,1 ); +if (!ret) +return sysfs_emit (buf,"%u\n" , (u32 )FREQ_LIMIT (data)); + +return ret; +}
drivers/platform/x86/amd/hsmp/acpi.c static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, · line 429
Quoted 10 lines
drivers/platform/x86/amd/hsmp/acpi.c +10
-0+ +static const char *const freqlimit_srcnames[] = { +"cHTC-Active" , +"PROCHOT" , +"TDC limit" , +"PPT Limit" , +"OPN Max" , +"Reliability Limit" , +"APML Agent" , +"HSMP Agent"
Add comma.
drivers/platform/x86/amd/hsmp/acpi.c static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, · line 437
Quoted 8 lines
drivers/platform/x86/amd/hsmp/acpi.c +8
-0+}; + +static ssize_t hsmp_freq_limit_source_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 index =0 ;
Either use unsigned int or size_t. u32 is not the right type for this.
Also, why you need to initialize it??
drivers/platform/x86/amd/hsmp/acpi.c static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, · line 444
Quoted 7 lines
drivers/platform/x86/amd/hsmp/acpi.c +7
-0+int len =0 ; +u16 src_ind; +u32 data; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, &data,1 ); +if (!ret) {
Please handle error first and return early.
drivers/platform/x86/amd/hsmp/acpi.c static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, · line 445
Quoted 1 line
drivers/platform/x86/amd/hsmp/acpi.c +1
-0+ src_ind = (u16 )FREQ_SRC_IND (data);
This casting seems overkill.
drivers/platform/x86/amd/hsmp/acpi.c static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, · line 449
Quoted 4 lines
drivers/platform/x86/amd/hsmp/acpi.c +4
-0+for (index =0 ; index <ARRAY_SIZE (freqlimit_srcnames); index++) { +if (src_ind ==0 ) +break ; +if ((src_ind &1 ) ==1 )
Unnecessary == 1, and then unnecessary parenthesis.
drivers/platform/x86/amd/hsmp/acpi.c static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, · line 450
Quoted 1 line
drivers/platform/x86/amd/hsmp/acpi.c +1
-0+ len +=sysfs_emit_at (buf, len,"%s " , freqlimit_srcnames[index]);
This will output an extra " " at the end.
Quoted 79 lines
drivers/platform/x86/amd/hsmp/acpi.c +54
-0+ src_ind = src_ind >>1 ; + } + len +=sysfs_emit_at (buf, len,"\n" ); +return len; + } + +return ret; +} +static int init_acpi (struct device *dev) {u16 sock_ind;@@ -285,6 +499,8 @@ static int init_acpi(struct device *dev)if (ret)dev_err (dev,"Failed to register HSMP sensors with hwmon\n" ); +dev_set_drvdata (dev, &hsmp_pdev->sock[sock_ind]); +return ret; }@@ -299,9 +515,52 @@ static const struct bin_attribute *hsmp_attr_list[] = {NULL }; +#define HSMP_DEV_ATTR (_name, _msg_id, _show, _mode) \ +static struct hsmp_sys_attr hattr_##_name = { \ + .dattr = __ATTR(_name, _mode, _show, NULL), \ + .msg_id = _msg_id \ +} + +HSMP_DEV_ATTR (c0_residency_input,HSMP_GET_C0_PERCENT , hsmp_msg_resp32_show,0444 ); +HSMP_DEV_ATTR (prochot_status,HSMP_GET_PROC_HOT , hsmp_msg_resp32_show,0444 ); +HSMP_DEV_ATTR (smu_fw_version,HSMP_GET_SMU_VER , hsmp_msg_fw_ver_show,0444 ); +HSMP_DEV_ATTR (protocol_version,HSMP_GET_PROTO_VER , hsmp_msg_resp32_show,0444 ); +HSMP_DEV_ATTR (cclk_freq_limit_input,HSMP_GET_CCLK_THROTTLE_LIMIT , hsmp_msg_resp32_show,0444 ); +HSMP_DEV_ATTR (ddr_max_bw,HSMP_GET_DDR_BANDWIDTH , hsmp_ddr_max_bw_show,0444 ); +HSMP_DEV_ATTR (ddr_utilised_bw_input,HSMP_GET_DDR_BANDWIDTH , hsmp_ddr_util_bw_show,0444 ); +HSMP_DEV_ATTR (ddr_utilised_bw_perc_input,HSMP_GET_DDR_BANDWIDTH , hsmp_ddr_util_bw_perc_show,0444 ); +HSMP_DEV_ATTR (fclk_input,HSMP_GET_FCLK_MCLK , hsmp_fclk_show,0444 ); +HSMP_DEV_ATTR (mclk_input,HSMP_GET_FCLK_MCLK , hsmp_mclk_show,0444 ); +HSMP_DEV_ATTR (clk_fmax,HSMP_GET_SOCKET_FMAX_FMIN , hsmp_clk_fmax_show,0444 ); +HSMP_DEV_ATTR (clk_fmin,HSMP_GET_SOCKET_FMAX_FMIN , hsmp_clk_fmin_show,0444 ); +HSMP_DEV_ATTR (pwr_current_active_freq_limit,HSMP_GET_SOCKET_FREQ_LIMIT , + hsmp_freq_limit_show,0444 ); +HSMP_DEV_ATTR (pwr_current_active_freq_limit_source,HSMP_GET_SOCKET_FREQ_LIMIT , + hsmp_freq_limit_source_show,0444 ); + +static struct attribute *hsmp_dev_attr_list[] = { + &hattr_c0_residency_input.dattr.attr, + &hattr_prochot_status.dattr.attr, + &hattr_smu_fw_version.dattr.attr, + &hattr_protocol_version.dattr.attr, + &hattr_cclk_freq_limit_input.dattr.attr, + &hattr_ddr_max_bw.dattr.attr, + &hattr_ddr_utilised_bw_input.dattr.attr, + &hattr_ddr_utilised_bw_perc_input.dattr.attr, + &hattr_fclk_input.dattr.attr, + &hattr_mclk_input.dattr.attr, + &hattr_clk_fmax.dattr.attr, + &hattr_clk_fmin.dattr.attr, + &hattr_pwr_current_active_freq_limit.dattr.attr, + &hattr_pwr_current_active_freq_limit_source.dattr.attr, +NULL , +}; +static const struct attribute_group hsmp_attr_grp = { .bin_attrs_new = hsmp_attr_list, + .attrs = hsmp_dev_attr_list, .is_bin_visible = hsmp_is_sock_attr_visible, + .is_visible = hsmp_is_sock_dev_attr_visible, };static const struct attribute_group *hsmp_groups[] = {drivers/platform/x86/amd/hsmp/hsmp.c +0
-0
drivers/platform/x86/amd/hsmp/hsmp.c int hsmp_send_message(struct hsmp_message *msg) · line 236
Quoted 8 lines
drivers/platform/x86/amd/hsmp/hsmp.c +5
-0@@ -229,6 +229,27 @@ int hsmp_send_message(struct hsmp_message *msg) }EXPORT_SYMBOL_NS_GPL (hsmp_send_message,"AMD_HSMP" ); +int hsmp_msg_get_nargs (u16 sock_ind,u32 msg_id,u32 *data,u8 n) +{ +struct hsmp_message msg = {0 }; +int ret; +int i;
unsigned int.
drivers/platform/x86/amd/hsmp/hsmp.c int hsmp_send_message(struct hsmp_message *msg) · line 245
Quoted 9 lines
drivers/platform/x86/amd/hsmp/hsmp.c +9
-0+ +if (!data) +return -EINVAL ; + msg.msg_id = msg_id; + msg.sock_ind = sock_ind; + msg.response_sz = n; + + ret =hsmp_send_message (&msg); +if (!ret) {
Please return early on errors.
Quoted 16 lines
drivers/platform/x86/amd/hsmp/hsmp.c +7
-0+for (i =0 ; i < n; i++) + data[i] = msg.args[i]; + } +return ret; +} +EXPORT_SYMBOL_NS_GPL (hsmp_msg_get_nargs,"AMD_HSMP" ); +int hsmp_test (u16 sock_ind,u32 value) {struct hsmp_message msg = {0 };drivers/platform/x86/amd/hsmp/hsmp.h +0
-0
drivers/platform/x86/amd/hsmp/hsmp.h int hsmp_create_sensor(struct device *dev, u16 sock_ind); · line 78
Quoted 5 lines
drivers/platform/x86/amd/hsmp/hsmp.h +1
-0@@ -74,4 +74,5 @@ int hsmp_create_sensor(struct device *dev, u16 sock_ind);return 0 ; }#endif +int hsmp_msg_get_nargs (u16 sock_ind,u32 msg_id,u32 *data,u8 n);#endif /* HSMP_H */
I'm pretty sure I've commented some of similar cases against your other patches in the past. I'd appreciate if you try to take such coding style comments always into account in future patches too so we don't end up going back and forth on trivialities like that.
It might be helpful if you try to "review" your own patch before sending them out to see if you missed something (it might surprise how many issues you will end up catching by simply looking through your own changes before sending them, at least I find many issues that way from my own patches).
Signature · 1 line
i.
Re: [v2 3/3] platform/x86/amd/hsmp: acpi: Add sysfs files to show HSMP telemetry
Hi Ilpo,
Quoted 57 lines · Ilpo Järvinen
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 41 lines · Suma Hegde
Make frequently fetched telemetry available via sysfs interface.
Create following sysfs files per acpi device node.
*c0_residency_input
*prochot_status
*smu_fw_version
*protocol_version
*ddr_max_bw(GB/s)
*ddr_utilised_bw_input(GB/s)
*ddr_utilised_bw_perc_input(%)
*mclk_input(MHz)
*fclk_input(MHz)
*clk_fmax(MHz)
*clk_fmin(MHz)
*cclk_freq_limit_input(MHz)
*pwr_current_active_freq_limit(MHz)
*pwr_current_active_freq_limit_sourceSigned-off-by Suma Hegde<[email protected]>Reviewed-by Naveen Krishna Chatradhi<[email protected]>---
Changes since v1:
1. Addlinux/bitops.h
2. DefineDDR_MAX_BW,DDR_UTIL_BWDDR_UTIL_BW_PERCFW_VER_MAJORFW_VER_MINORFW_VER_DEBUGFMAX FMINFREQ_LIMITFREQ_SRC_INDand use them in functions.
3. Return early inhsmp_msg_get_nargs()
4. Change while loop to for loop inhsmp_freq_limit_source_show()
5. Correct the GENMASK size in hsmp_ddr_util_bw_show()[bit 19:8, insteadof bit 20:8]Documentation/arch/x86/amd_hsmp.rst | 31 +++- drivers/platform/x86/amd/hsmp/acpi.c | 259 +++++++++++++++++++++++++++ drivers/platform/x86/amd/hsmp/hsmp.c | 21 +++ drivers/platform/x86/amd/hsmp/hsmp.h | 1 + 4 files changed, 305 insertions(+), 7 deletions(-)Documentation/arch/x86/amd_hsmp.rst +0
-0Documentation/arch/x86/amd_hsmp.rst Note: lseek() is not supported as entire metrics table is read. · line 79
Quoted 9 lines
Documentation/arch/x86/amd_hsmp.rst +6
-0@@ -71,6 +71,25 @@ Note: lseek() is not supported as entire metrics table is read. Metrics table definitions will be documented as part of Public PPR. The same is defined in the amd_hsmp.h header. +2. HSMP telemetry sysfs files + +Following sysfs file are available at /sys/devices/platform/AMDI0097:0X/. + +* c0_residency_input : percentage of cores in C0 state +* prochot_status : reports 1 if socket is in prochot, 0 otherwhileotherwise
Quoted 1 line
What's "prochot" ?
prochot is a condition where processor is at thermal threshold value.
I will add this explanation in the document.
Quoted 5 lines
Documentation/arch/x86/amd_hsmp.rst Note: lseek() is not supported as entire metrics table is read. · line 82
Quoted 3 lines
Documentation/arch/x86/amd_hsmp.rst +3
-0+* smu_fw_version : SMU firmware version +* protocol_version : HSMP interface version +* ddr_max_bw : theoretical maximum ddr bw in GB/sPlease capitalize comments and documentation properly.
Quoted 10 lines
Documentation/arch/x86/amd_hsmp.rst Note: lseek() is not supported as entire metrics table is read. · line 90
Quoted 8 lines
Documentation/arch/x86/amd_hsmp.rst +8
-0+* ddr_utilised_bw_input: current utilized ddr bw in GB/s +* ddr_utilised_bw_perc_input(%): Percentage of current utilized ddr bw +* mclk_input : memory clock in MHz +* fclk_input: fabric clock in MHz +* clk_fmax : max frequency of socket in MHz +* clk_fmin : min frequency of socket in MHz +* cclk_freq_limit_input : core clock frequency limit per socket in MHz +* pwr_current_active_freq_limit: current active frequency limit of socket in MHzIs that "active" a meaningful word in this or would just current frequency limit suffice?
The term "active" is included to ensure consistency with the processor reference manual.
Quoted 97 lines
Quoted 8 lines
Documentation/arch/x86/amd_hsmp.rst +2
-0+* pwr_current_active_freq_limit_source: source of current active frequency limit + ACPI device object format ========================= The ACPI object format expected from the amd_hsmp driver@@ -119,13 +138,11 @@ for socket with ID00 is given below:: HSMP HWMON interfaceDocumentation/arch/x86/amd_hsmp.rst for socket with ID00 is given below:: · line 142
Quoted 10 lines
Documentation/arch/x86/amd_hsmp.rst +2
-7================== -HSMP power sensors are registered with hwmon interface. - -One hwmon directory is created for each socket and following files with 0444 permission are created -inside the hwmon directory. -- power1_input -- power1_cap_max -- power1_cap +HSMP power sensors are registered with hwmon interface. One hwmon directory is created for each +socket and following files are created inside the hwmon directory.Please fold documentation paragraphs at 80 chars.
Documentation/arch/x86/amd_hsmp.rst for socket with ID00 is given below:: · line 145
Quoted 3 lines
Documentation/arch/x86/amd_hsmp.rst +3
-0+- power1_input(read only) +- power1_cap_max(read only) +- power1_cap(read, write)Don't these need space in before (?
Quoted 38 lines
Documentation/arch/x86/amd_hsmp.rst +0
-0An example ==========drivers/platform/x86/amd/hsmp/acpi.c +14
-0@@ -13,6 +13,7 @@#include <asm/amd_nb.h> #include <linux/acpi.h> +#include <linux/bitops.h> #include <linux/device.h> #include <linux/dev_printk.h> #include <linux/ioport.h> @@ -36,6 +37,11 @@static struct hsmp_plat_device *hsmp_pdev; +struct hsmp_sys_attr { +struct device_attribute dattr; +u32 msg_id; +}; +static int amd_hsmp_acpi_rdwr (struct hsmp_socket *sock,u32 offset,u32 *value,bool write) {@@ -243,6 +249,214 @@ static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj,return 0 ; } +static umode_t hsmp_is_sock_dev_attr_visible (struct kobject *kobj, +struct attribute *attr,int id) +{ +return attr->mode; +} + +#define to_hsmp_sys_attr (__attr) container_of(__attr, struct hsmp_sys_attr, dattr) +drivers/platform/x86/amd/hsmp/acpi.c static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, · line 269
Quoted 10 lines
drivers/platform/x86/amd/hsmp/acpi.c +10
-0+static ssize_t hsmp_msg_resp32_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, &data,1 ); +if (!ret)Reverse logic and handle the error first. Only on very special occassions can it be done the other way around but the normal principle is check error and early return.
Quoted 20 lines
drivers/platform/x86/amd/hsmp/acpi.c +20
-0+return sysfs_emit (buf,"%u\n" , data); + +return ret; +} + +#define DDR_MAX_BW (data) FIELD_GET(GENMASK(31, 20), data) +#define DDR_UTIL_BW (data) FIELD_GET(GENMASK(19, 8), data) +#define DDR_UTIL_BW_PERC (data) FIELD_GET(GENMASK(7, 0), data) +#define FW_VER_MAJOR (data) FIELD_GET(GENMASK(23, 16), data) +#define FW_VER_MINOR (data) FIELD_GET(GENMASK(15, 8), data) +#define FW_VER_DEBUG (data) FIELD_GET(GENMASK(7, 0), data) +#define FMAX (data) FIELD_GET(GENMASK(31, 16), data) +#define FMIN (data) FIELD_GET(GENMASK(15, 0), data) +#define FREQ_LIMIT (data) FIELD_GET(GENMASK(31, 16), data) +#define FREQ_SRC_IND (data) FIELD_GET(GENMASK(15, 0), data) + +static ssize_t hsmp_ddr_max_bw_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr);
Quoted 8 lines
drivers/platform/x86/amd/hsmp/acpi.c static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, · line 296
Quoted 7 lines
drivers/platform/x86/amd/hsmp/acpi.c +7
-0+struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, &data,1 ); +if (!ret) +return sysfs_emit (buf,"%u\n" , (u32 )DDR_MAX_BW (data));Why are these cast necessary?
Since FIELD_GET() returns an unsigned long type, I used a cast to avoid compiler warning.
Quoted 297 lines
I'd prefer naming the fields instead of making them function like macros and using
FIELD_GET()here.Quoted 123 lines
drivers/platform/x86/amd/hsmp/acpi.c +123
-0+ +return ret; +} + +static ssize_t hsmp_ddr_util_bw_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, &data,1 ); +if (!ret) +return sysfs_emit (buf,"%u\n" , (u32 )DDR_UTIL_BW (data)); +return ret; +} + +static ssize_t hsmp_ddr_util_bw_perc_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, &data,1 ); +if (!ret) +return sysfs_emit (buf,"%u\n" , (u32 )DDR_UTIL_BW_PERC (data)); + +return ret; +} + +static ssize_t hsmp_msg_fw_ver_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, &data,1 ); +if (!ret) +return sysfs_emit (buf,"%u.%u.%u\n" , (u32 )FW_VER_MAJOR (data), + (u32 )FW_VER_MINOR (data), (u32 )FW_VER_DEBUG (data)); + +return ret; +} + +static ssize_t hsmp_fclk_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data[2 ]; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, data,2 ); +if (!ret) +return sysfs_emit (buf,"%u\n" , data[0 ]); + +return ret; +} + +static ssize_t hsmp_mclk_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data[2 ]; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, data,2 ); +if (!ret) +return sysfs_emit (buf,"%u\n" , data[1 ]); + +return ret; +} + +static ssize_t hsmp_clk_fmax_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, &data,1 ); +if (!ret) +return sysfs_emit (buf,"%u\n" , (u32 )FMAX (data)); + +return ret; +} + +static ssize_t hsmp_clk_fmin_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, &data,1 ); +if (!ret) +return sysfs_emit (buf,"%u\n" , (u32 )FMIN (data)); + +return ret; +} + +static ssize_t hsmp_freq_limit_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 data; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, &data,1 ); +if (!ret) +return sysfs_emit (buf,"%u\n" , (u32 )FREQ_LIMIT (data)); + +return ret; +}drivers/platform/x86/amd/hsmp/acpi.c static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, · line 429
Quoted 10 lines
drivers/platform/x86/amd/hsmp/acpi.c +10
-0+ +static const char *const freqlimit_srcnames[] = { +"cHTC-Active" , +"PROCHOT" , +"TDC limit" , +"PPT Limit" , +"OPN Max" , +"Reliability Limit" , +"APML Agent" , +"HSMP Agent" Add comma.
drivers/platform/x86/amd/hsmp/acpi.c static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, · line 437
Quoted 8 lines
drivers/platform/x86/amd/hsmp/acpi.c +8
-0+}; + +static ssize_t hsmp_freq_limit_source_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct hsmp_sys_attr *hattr =to_hsmp_sys_attr (attr); +struct hsmp_socket *sock =dev_get_drvdata (dev); +u32 index =0 ;Either use unsigned int or
size_t. u32 is not the right type for this.Also, why you need to initialize it??
drivers/platform/x86/amd/hsmp/acpi.c static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, · line 444
Quoted 7 lines
drivers/platform/x86/amd/hsmp/acpi.c +7
-0+int len =0 ; +u16 src_ind; +u32 data; +int ret; + + ret =hsmp_msg_get_nargs (sock->sock_ind, hattr->msg_id, &data,1 ); +if (!ret) {Please handle error first and return early.
drivers/platform/x86/amd/hsmp/acpi.c static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, · line 445
Quoted 1 line
drivers/platform/x86/amd/hsmp/acpi.c +1
-0+ src_ind = (u16 )FREQ_SRC_IND (data);This casting seems overkill.
drivers/platform/x86/amd/hsmp/acpi.c static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, · line 449
Quoted 4 lines
drivers/platform/x86/amd/hsmp/acpi.c +4
-0+for (index =0 ; index <ARRAY_SIZE (freqlimit_srcnames); index++) { +if (src_ind ==0 ) +break ; +if ((src_ind &1 ) ==1 )Unnecessary == 1, and then unnecessary parenthesis.
drivers/platform/x86/amd/hsmp/acpi.c static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, · line 450
Quoted 1 line
drivers/platform/x86/amd/hsmp/acpi.c +1
-0+ len +=sysfs_emit_at (buf, len,"%s " , freqlimit_srcnames[index]);This will output an extra " " at the end.
Quoted 79 lines
drivers/platform/x86/amd/hsmp/acpi.c +54
-0+ src_ind = src_ind >>1 ; + } + len +=sysfs_emit_at (buf, len,"\n" ); +return len; + } + +return ret; +} +static int init_acpi (struct device *dev) {u16 sock_ind;@@ -285,6 +499,8 @@ static int init_acpi(struct device *dev)if (ret)dev_err (dev,"Failed to register HSMP sensors with hwmon\n" ); +dev_set_drvdata (dev, &hsmp_pdev->sock[sock_ind]); +return ret; }@@ -299,9 +515,52 @@ static const struct bin_attribute *hsmp_attr_list[] = {NULL }; +#define HSMP_DEV_ATTR (_name, _msg_id, _show, _mode) \ +static struct hsmp_sys_attr hattr_##_name = { \ + .dattr = __ATTR(_name, _mode, _show, NULL), \ + .msg_id = _msg_id \ +} + +HSMP_DEV_ATTR (c0_residency_input,HSMP_GET_C0_PERCENT , hsmp_msg_resp32_show,0444 ); +HSMP_DEV_ATTR (prochot_status,HSMP_GET_PROC_HOT , hsmp_msg_resp32_show,0444 ); +HSMP_DEV_ATTR (smu_fw_version,HSMP_GET_SMU_VER , hsmp_msg_fw_ver_show,0444 ); +HSMP_DEV_ATTR (protocol_version,HSMP_GET_PROTO_VER , hsmp_msg_resp32_show,0444 ); +HSMP_DEV_ATTR (cclk_freq_limit_input,HSMP_GET_CCLK_THROTTLE_LIMIT , hsmp_msg_resp32_show,0444 ); +HSMP_DEV_ATTR (ddr_max_bw,HSMP_GET_DDR_BANDWIDTH , hsmp_ddr_max_bw_show,0444 ); +HSMP_DEV_ATTR (ddr_utilised_bw_input,HSMP_GET_DDR_BANDWIDTH , hsmp_ddr_util_bw_show,0444 ); +HSMP_DEV_ATTR (ddr_utilised_bw_perc_input,HSMP_GET_DDR_BANDWIDTH , hsmp_ddr_util_bw_perc_show,0444 ); +HSMP_DEV_ATTR (fclk_input,HSMP_GET_FCLK_MCLK , hsmp_fclk_show,0444 ); +HSMP_DEV_ATTR (mclk_input,HSMP_GET_FCLK_MCLK , hsmp_mclk_show,0444 ); +HSMP_DEV_ATTR (clk_fmax,HSMP_GET_SOCKET_FMAX_FMIN , hsmp_clk_fmax_show,0444 ); +HSMP_DEV_ATTR (clk_fmin,HSMP_GET_SOCKET_FMAX_FMIN , hsmp_clk_fmin_show,0444 ); +HSMP_DEV_ATTR (pwr_current_active_freq_limit,HSMP_GET_SOCKET_FREQ_LIMIT , + hsmp_freq_limit_show,0444 ); +HSMP_DEV_ATTR (pwr_current_active_freq_limit_source,HSMP_GET_SOCKET_FREQ_LIMIT , + hsmp_freq_limit_source_show,0444 ); + +static struct attribute *hsmp_dev_attr_list[] = { + &hattr_c0_residency_input.dattr.attr, + &hattr_prochot_status.dattr.attr, + &hattr_smu_fw_version.dattr.attr, + &hattr_protocol_version.dattr.attr, + &hattr_cclk_freq_limit_input.dattr.attr, + &hattr_ddr_max_bw.dattr.attr, + &hattr_ddr_utilised_bw_input.dattr.attr, + &hattr_ddr_utilised_bw_perc_input.dattr.attr, + &hattr_fclk_input.dattr.attr, + &hattr_mclk_input.dattr.attr, + &hattr_clk_fmax.dattr.attr, + &hattr_clk_fmin.dattr.attr, + &hattr_pwr_current_active_freq_limit.dattr.attr, + &hattr_pwr_current_active_freq_limit_source.dattr.attr, +NULL , +}; +static const struct attribute_group hsmp_attr_grp = { .bin_attrs_new = hsmp_attr_list, + .attrs = hsmp_dev_attr_list, .is_bin_visible = hsmp_is_sock_attr_visible, + .is_visible = hsmp_is_sock_dev_attr_visible, };static const struct attribute_group *hsmp_groups[] = {drivers/platform/x86/amd/hsmp/hsmp.c +0
-0drivers/platform/x86/amd/hsmp/hsmp.c int hsmp_send_message(struct hsmp_message *msg) · line 236
Quoted 8 lines
drivers/platform/x86/amd/hsmp/hsmp.c +5
-0@@ -229,6 +229,27 @@ int hsmp_send_message(struct hsmp_message *msg) }EXPORT_SYMBOL_NS_GPL (hsmp_send_message,"AMD_HSMP" ); +int hsmp_msg_get_nargs (u16 sock_ind,u32 msg_id,u32 *data,u8 n) +{ +struct hsmp_message msg = {0 }; +int ret; +int i;unsigned int.
drivers/platform/x86/amd/hsmp/hsmp.c int hsmp_send_message(struct hsmp_message *msg) · line 245
Quoted 9 lines
drivers/platform/x86/amd/hsmp/hsmp.c +9
-0+ +if (!data) +return -EINVAL ; + msg.msg_id = msg_id; + msg.sock_ind = sock_ind; + msg.response_sz = n; + + ret =hsmp_send_message (&msg); +if (!ret) {Please return early on errors.
Quoted 16 lines
drivers/platform/x86/amd/hsmp/hsmp.c +7
-0+for (i =0 ; i < n; i++) + data[i] = msg.args[i]; + } +return ret; +} +EXPORT_SYMBOL_NS_GPL (hsmp_msg_get_nargs,"AMD_HSMP" ); +int hsmp_test (u16 sock_ind,u32 value) {struct hsmp_message msg = {0 };drivers/platform/x86/amd/hsmp/hsmp.h +0
-0drivers/platform/x86/amd/hsmp/hsmp.h int hsmp_create_sensor(struct device *dev, u16 sock_ind); · line 78
Quoted 5 lines
drivers/platform/x86/amd/hsmp/hsmp.h +1
-0@@ -74,4 +74,5 @@ int hsmp_create_sensor(struct device *dev, u16 sock_ind);return 0 ; }#endif +int hsmp_msg_get_nargs (u16 sock_ind,u32 msg_id,u32 *data,u8 n);#endif /* HSMP_H */ I'm pretty sure I've commented some of similar cases against your other patches in the past. I'd appreciate if you try to take such coding style comments always into account in future patches too so we don't end up going back and forth on trivialities like that.
Quoted 7 lines
It might be helpful if you try to "review" your own patch before sending them out to see if you missed something (it might surprise how many issues you will end up catching by simply looking through your own changes before sending them, at least I find many issues that way from my own patches).
--
i.
Thanks and Regards,
Suma