Add Ampere's Altra SMPro MFD and its child drivers
Subsystems (5)
v8 cover Add Ampere's Altra SMPro MFD and its child drivers
The SMpro co-processor on Ampere Altra processor family is to monitor and report various data included hwmon-related info, RAS errors, and other miscellaneous information. The SMPro MFD driver initializes the register map and instantiates all sub-devices. All the specifics will be handled in the child drivers.
This patch set includes support for Ampere SMpro hwmon, errmon, and misc as the child drivers. The hwmon driver supports accessing various CPU sensors provided by the SMpro co-processor including temperature, power, voltages, and current found on Ampere Altra processor family. The errmon driver supports monitoring and reporting RAS-related errors. The misc driver is to support reporting boot progress and other miscellaneous information.
Discussion for v7: https://lkml.org/lkml/2022/3/21/125
v8:
+ Insert 'break;' to avoid fall-through [kernel test robot]
+ Avoid uninitialized variable use [kernel test robot]
+ Remove unused #*_cells [Krzysztof]
+ Switch to use sysfs_emit() [Greg] + Sysfs to return single value only [Greg] + Fix KernelVerion field in Documentation/ABI/testing doc [Greg] + Change errors_* sysfs to error_* [Quan] + Add overflow_[core|mem|pcie|other]_[ce|ue] sysfs to report overflow status of each type of HW errors [Quan] + Update wording in Kconfig for smpro-errmon and smpro-misc [Quan] + Masks reserved bit when read 10-bit power value [Quan] + Add some minor refactor [Quan]
v7:
+ Add docs to Documentation/ABI/testing [Greg]
+ Re-order patches to avoid compile dependency [Lee Jones]
+ Remove regmap_acquire/release_lock() [Quan]
+ Install regmap bus->read/write() to handle multiple types of bus
access [Quan]
+ Replace i2c block read by regmap_noinc_read() [Quan]
+ Fix wrong return type of *show/store() [kernel test robot]
+ Update GPL version [Quan]
+ Add some others minor code refactor [Quan]
v6:
+ Introduced smpro-errmon, smpro-misc as smpro-mfd sub-device [Quan]
v5:
+ Introduced the smpro-mfd driver and drop the use of simple-mfd-i2c driver to avoid DT node with no resource in child device DT nodes [Rob]
+ Removed the use of reg DT property in child driver [Quan]
+ Validated ManufactureID when probing smpro-mfd drivers [Quan]
+ As child devices are instantiated by SMPro MFD driver, drop the ManufacturerID checking in child driver, ie: smpro-hwmon [Quan]
+ Revised commit messages [Quan]
v4:
+ Revised commit message [Quan]
+ Fixed build issue found by kernel test robot [Guenter]
+ Returned regmap_read() error code [Guenter]
v3:
+ Supported list of compatible string [Rob]
+ Introduced reg property in DT to specify reg offset [Rob]
+ Updated description and other minor changes in yaml file [Rob]
+ Handled negative temperature value [Guenter]
+ Returned -ENODEV if Manufacturer ID is wrong [Guenter]
+ Refactored smpro_read_string() and smpro_temp_read() [Guenter]
+ Removed smpro_write() function [Guenter]
+ Added minor refactor changes [Quan]
v2:
+ Used 'struct of_device_id's .data attribute [Lee Jones]
+ Removed "virtual" sensors [Guenter]
+ Fixed typo "mili" to "milli", "nanoWatt" to "microWatt" [Guenter]
+ Reported SOC_TDP as "Socket TDP" using max attributes [Guenter]
+ Clarified "highest" meaning in documentation [Guenter]
+ Corrected return error code when host is turn off [Guenter]
+ Reported MEM HOT Threshold for all DIMMs as temp*_crit [Guenter]
+ Removed license info as SPDX-License-Identifier existed [Guenter]
+ Added is_visible() support [Guenter]
+ Used HWMON_CHANNEL_INFO() macro and LABEL attributes [Guenter]
+ Made is_valid_id() return boolean [Guenter]
+ Returned -EPROBE_DEFER when smpro reg inaccessible [Guenter]
+ Removed unnecessary error message when dev register fail [Guenter]
+ Removed Socket TDP sensor [Quan]
+ Changed "ampere,ac01-smpro" to "ampere,smpro" [Quan]
+ Included sensor type and channel in labels [Quan]
+ Refactorized code to fix checkpatch.pl --strict complaint [Quan]
Quan Nguyen (9):
hwmon: smpro: Add Ampere's Altra smpro-hwmon driver
docs: hwmon: (smpro-hwmon) Add documentation
misc: smpro-errmon: Add Ampere's SMpro error monitor driver
docs: misc-devices: (smpro-errmon) Add documentation
misc: smpro-misc: Add Ampere's Altra SMpro misc driver
docs: misc-devices: (smpro-misc) Add documentation
dt-bindings: mfd: Add bindings for Ampere Altra SMPro MFD driver
mfd: smpro-mfd: Adds Ampere's Altra SMpro MFD driver
docs: ABI: testing: Document the Ampere Altra Family's SMpro sysfs
interfaces
.../sysfs-bus-platform-devices-ampere-smpro | 157 ++++++ .../devicetree/bindings/mfd/ampere,smpro.yaml | 42 ++ Documentation/hwmon/index.rst | 1 + Documentation/hwmon/smpro-hwmon.rst | 101 ++++ Documentation/misc-devices/index.rst | 2 + Documentation/misc-devices/smpro-errmon.rst | 198 ++++++++ Documentation/misc-devices/smpro-misc.rst | 82 +++ drivers/hwmon/Kconfig | 8 + drivers/hwmon/Makefile | 1 + drivers/hwmon/smpro-hwmon.c | 465 +++++++++++++++++ drivers/mfd/Kconfig | 12 + drivers/mfd/Makefile | 1 + drivers/mfd/smpro-mfd.c | 134 +++++ drivers/misc/Kconfig | 22 + drivers/misc/Makefile | 2 + drivers/misc/smpro-errmon.c | 477 ++++++++++++++++++ drivers/misc/smpro-misc.c | 161 ++++++ 17 files changed, 1866 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro create mode 100644 Documentation/devicetree/bindings/mfd/ampere,smpro.yaml create mode 100644 Documentation/hwmon/smpro-hwmon.rst create mode 100644 Documentation/misc-devices/smpro-errmon.rst create mode 100644 Documentation/misc-devices/smpro-misc.rst create mode 100644 drivers/hwmon/smpro-hwmon.c create mode 100644 drivers/mfd/smpro-mfd.c create mode 100644 drivers/misc/smpro-errmon.c create mode 100644 drivers/misc/smpro-misc.c
Signature · 1 line
2.35.1
PATCH v8 1/9 hwmon: smpro: Add Ampere's Altra smpro-hwmon driver
This commit adds support for Ampere SMpro hwmon driver. This driver supports accessing various CPU sensors provided by the SMpro co-processor including temperature, power, voltages, and current.
---
Changes in v8:
+ Masks reserved bit when read 10-bit power value [Quan]
+ Insert 'break;' to avoid fall-through [kernel test robot] Dear Guenter, I still keep your Reviewed-by here with these
changes, expecting you are still OK with them. Please let me know if otherwise. Thanks.
Changes in v7:
+ Update GPL version [Quan]
Changes in v6:
+ None
Changes in v5:
+ Drop ManufacturerID checking when probe as it was checked during smpro-mfd probing [Quan]
+ Drop the use of register offset [Quan]
+ Removed the use of compatible string as it is instantiated by smpro-mfd driver [Quan]
Changes in v4:
+ Returned regmap_read() error code [Guenter]
Changes in v3:
+ Handled negative temperature value [Guenter]
+ Returned -ENODEV if Manufacturer ID is wrong [Guenter]
+ Refactored smpro_read_string() and smpro_temp_read() [Guenter]
+ Removed smpro_write() function [Guenter]
+ Added minor refactor changes [Quan]
Changes in v2:
+ Removed "virtual" sensors [Guenter]
+ Reported SOC_TDP as "Socket TDP" using max attributes [Guenter]
+ Corrected return error code when host is turn off [Guenter]
+ Reported MEM HOT Threshold for all DIMMs as temp*_crit [Guenter]
+ Removed license info as SPDX-License-Identifier existed [Guenter]
+ Added is_visible() support [Guenter]
+ Used HWMON_CHANNEL_INFO() macro and LABEL attributes [Guenter]
+ Made is_valid_id() return boolean [Guenter]
+ Returned -EPROBE_DEFER when smpro reg inaccessible [Guenter]
+ Removed unnecessary error message when dev register fail [Guenter]
+ Removed Socket TDP sensor [Quan]
+ Included sensor type and channel in labels [Quan]
+ Refactorized code to fix checkpatch.pl --strict complaint [Quan]
drivers/hwmon/Kconfig | 8 + drivers/hwmon/Makefile | 1 + drivers/hwmon/smpro-hwmon.c | 465 ++++++++++++++++++++++++++++++++++++ 3 files changed, 474 insertions(+) create mode 100644 drivers/hwmon/smpro-hwmon.c
drivers/hwmon/Kconfig +8 -0
@@ -67,6 +67,14 @@ config SENSORS_ABITUGURU3 This driver can also be built as a module. If so, the module will be called abituguru3. +config SENSORS_SMPRO + tristate "Ampere's Altra SMpro hardware monitoring driver" + depends on MFD_SMPRO + help + If you say yes here you get support for the thermal, voltage, + current and power sensors of Ampere's Altra processor family SoC + with SMpro co-processor. + config SENSORS_AD7314 tristate "Analog Devices AD7314 and compatibles" depends on SPI
drivers/hwmon/Makefile +1 -0
@@ -182,6 +182,7 @@ obj-$(CONFIG_SENSORS_SHT4x) += sht4x.o obj-$(CONFIG_SENSORS_SHTC1) += shtc1.o obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o obj-$(CONFIG_SENSORS_SMM665) += smm665.o +obj-$(CONFIG_SENSORS_SMPRO) += smpro-hwmon.o obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o
drivers/hwmon/smpro-hwmon.c new file +465 -0
465 lines not on this page · raw message
Signature · 1 line
2.35.1
PATCH v8 2/9 docs: hwmon: (smpro-hwmon) Add documentation
In reply to Quan NguyenAdd documentation for the Ampere(R)'s Altra(R) SMpro hwmon driver.
---
Changes from v3=>v8:
+ None
Changes in v2:
+ Removed "virtual" sensors [Guenter]
+ Fixed typo "mili" to "milli", "nanoWatt" to "microWatt" [Guenter]
+ Reported SOC_TDP as "Socket TDP" using max attributes [Guenter]
+ Clarified "highest" meaning in documentation [Guenter]
+ Reported MEM HOT Threshold for all DIMMs as temp*_crit [Guenter]
+ Removed Socket TDP sensor [Quan]
+ Included sensor type and channel in labels [Quan]
Documentation/hwmon/index.rst | 1 + Documentation/hwmon/smpro-hwmon.rst | 101 ++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 Documentation/hwmon/smpro-hwmon.rst
Documentation/hwmon/index.rst +1 -0
@@ -184,6 +184,7 @@ Hardware Monitoring Kernel Drivers sis5595 sl28cpld smm665 + smpro-hwmon smsc47b397 smsc47m192 smsc47m1
Documentation/hwmon/smpro-hwmon.rst new file +101 -0
101 lines not on this page · raw message
Signature · 1 line
2.35.1
PATCH v8 3/9 misc: smpro-errmon: Add Ampere's SMpro error monitor driver
In reply to Quan NguyenThis commit adds Ampere's SMpro error monitor driver for monitoring and reporting RAS-related errors as reported by SMpro co-processor found on Ampere's Altra processor family.
---
Changes in v8:
+ Update wording for SMPRO_ERRMON on Kconfig file [Quan]
+ Avoid uninitialized variable use [kernel test robot]
+ Switch to use sysfs_emit() [Greg] + Make sysfs to return single value [Greg] + Change errors_* sysfs to error_* [Quan]
+ Add overflow_[core|mem|pcie|other]_[ce|ue] sysfs to report
overflow status of each type of HW errors [Quan]
+ Add some minor refactor [Quan]
Changes in v7:
+ Remove regmap_acquire/release_lock(), read_i2c_block_data() [Quan]
+ Use regmap_noinc_read() instead of errmon_read_block() [Quan]
+ Validate number of errors before read [Quan]
+ Fix wrong return type of *_show() function [kernel test robot]
+ Adjust patch order to avoid dependence with smpro-mfd [Lee Jones]
+ Use pointer instead of stack memory [Quan]
Changes in v6:
+ First introduced in v6 [Quan]
drivers/misc/Kconfig | 12 + drivers/misc/Makefile | 1 + drivers/misc/smpro-errmon.c | 477 ++++++++++++++++++++++++++++++++++++ 3 files changed, 490 insertions(+) create mode 100644 drivers/misc/smpro-errmon.c
drivers/misc/Kconfig +12 -0
@@ -176,6 +176,18 @@ config SGI_XP this feature will allow for direct communication between SSIs based on a network adapter and DMA messaging. +config SMPRO_ERRMON + tristate "Ampere Computing SMPro error monitor driver" + depends on MFD_SMPRO || COMPILE_TEST + help + Say Y here to get support for the SMpro error monitor function + provided by Ampere Computing's Altra and Altra Max SoCs. Upon + loading, the driver creates sysfs files which can be use to gather + multiple HW error data reported via read and write system calls. + + To compile this driver as a module, say M here. The driver will be + called smpro-errmon. + config CS5535_MFGPT tristate "CS5535/CS5536 Geode Multi-Function General Purpose Timer (MFGPT) support" depends on MFD_CS5535
drivers/misc/Makefile +1 -0
@@ -23,6 +23,7 @@ obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o obj-$(CONFIG_KGDB_TESTS) += kgdbts.o obj-$(CONFIG_SGI_XP) += sgi-xp/ obj-$(CONFIG_SGI_GRU) += sgi-gru/ +obj-$(CONFIG_SMPRO_ERRMON) += smpro-errmon.o obj-$(CONFIG_CS5535_MFGPT) += cs5535-mfgpt.o obj-$(CONFIG_GEHC_ACHC) += gehc-achc.o obj-$(CONFIG_HP_ILO) += hpilo.o
drivers/misc/smpro-errmon.c new file +477 -0
477 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerRe: [PATCH v8 3/9] misc: smpro-errmon: Add Ampere's SMpro error monitor driver
Quoted 74 lines · Quan Nguyen
This commit adds Ampere's SMpro error monitor driver for monitoring and reporting RAS-related errors as reported by SMpro co-processor found on Ampere's Altra processor family.
Signed-off-by Quan Nguyen <[email protected]>---
Changes in v8:
+ Update wording forSMPRO_ERRMONonKconfigfile [Quan]
+ Avoid uninitialized variable use [kernel test robot]+ Switch to use sysfs_emit() [Greg] + Make sysfs to return single value [Greg] + Change errors_* sysfs to error_* [Quan]+ Add overflow_[core|mem|pcie|other]_[ce|ue] sysfs to report
overflow status of each type of HW errors [Quan]
+ Add some minor refactor [Quan]Changes in v7:
+ Remove regmap_acquire/release_lock(),read_i2c_block_data()[Quan]
+ Useregmap_noinc_read()instead oferrmon_read_block()[Quan]
+ Validate number of errors before read [Quan]
+ Fix wrong return type of*_show()function [kernel test robot]
+ Adjust patch order to avoid dependence with smpro-mfd [Lee Jones]
+ Use pointer instead of stack memory [Quan]Changes in v6:
+ First introduced in v6 [Quan]drivers/misc/Kconfig | 12 + drivers/misc/Makefile | 1 + drivers/misc/smpro-errmon.c | 477 ++++++++++++++++++++++++++++++++++++ 3 files changed, 490 insertions(+) create mode 100644 drivers/misc/smpro-errmon.cdrivers/misc/Kconfig +12
-0@@ -176,6 +176,18 @@ config SGI_XP this feature will allow for direct communication between SSIs based on a network adapter and DMA messaging. +config SMPRO_ERRMON + tristate "Ampere Computing SMPro error monitor driver" + depends on MFD_SMPRO || COMPILE_TEST + help + Say Y here to get support for the SMpro error monitor function + provided by Ampere Computing's Altra and Altra Max SoCs. Upon + loading, the driver creates sysfs files which can be use to gather + multiple HW error data reported via read and write system calls. + + To compile this driver as a module, say M here. The driver will be + called smpro-errmon. + config CS5535_MFGPT tristate "CS5535/CS5536 Geode Multi-Function General Purpose Timer (MFGPT) support" depends on MFD_CS5535drivers/misc/Makefile +1
-0@@ -23,6 +23,7 @@ obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o obj-$(CONFIG_KGDB_TESTS) += kgdbts.o obj-$(CONFIG_SGI_XP) += sgi-xp/ obj-$(CONFIG_SGI_GRU) += sgi-gru/ +obj-$(CONFIG_SMPRO_ERRMON) += smpro-errmon.o obj-$(CONFIG_CS5535_MFGPT) += cs5535-mfgpt.o obj-$(CONFIG_GEHC_ACHC) += gehc-achc.o obj-$(CONFIG_HP_ILO) += hpilo.odrivers/misc/smpro-errmon.c new file +0
-0
drivers/misc/smpro-errmon.c line 1
Quoted 1 line
drivers/misc/smpro-errmon.c new file +1
-0@@ -0,0 +1,477 @@ +// SPDX-License-Identifier: GPL-2.0+
Are you sure you mean "or any later version"? I have to ask.
drivers/misc/smpro-errmon.c line 139
Quoted 13 lines
drivers/misc/smpro-errmon.c new file +13
-0+static struct smpro_int_error_hdr list_smpro_int_error_hdr[2 ] = { + { +ERR_SMPRO_TYPE , +ERR_SMPRO_INFO_LO ,ERR_SMPRO_INFO_HI , +ERR_SMPRO_DATA_LO ,ERR_SMPRO_DATA_HI , +WARN_SMPRO_INFO_LO ,WARN_SMPRO_INFO_HI + }, + { +ERR_PMPRO_TYPE , +ERR_PMPRO_INFO_LO ,ERR_PMPRO_INFO_HI , +ERR_PMPRO_DATA_LO ,ERR_PMPRO_DATA_HI , +WARN_PMPRO_INFO_LO ,WARN_PMPRO_INFO_HI + },
Odd indentation, checkpatch did not complain?
drivers/misc/smpro-errmon.c line 170
Quoted 11 lines
drivers/misc/smpro-errmon.c new file +11
-0+static ssize_t smpro_event_data_read (struct device *dev, +struct device_attribute *da,char *buf, +int channel) +{ +struct smpro_errmon *errmon =dev_get_drvdata (dev); +s32 event_data; +int ret; + + ret =regmap_read (errmon->regmap, smpro_event_table[channel], &event_data); +if (ret) + goto done;
Just return the error here.
drivers/misc/smpro-errmon.c line 27
Quoted 2 lines
drivers/misc/smpro-errmon.c new file +2
-0+ + ret =sysfs_emit (buf,"%02x%04x\n" , channel, event_data);
sysfs rules are one value per file. You know this.
drivers/misc/smpro-errmon.c line 174
Quoted 2 lines
drivers/misc/smpro-errmon.c new file +2
-0+/* Clear event after read */ +if (event_data !=0 )
Why would it be 0? Isn't 0 a valid value?
Quoted 30 lines
drivers/misc/smpro-errmon.c new file +30
-0+regmap_write (errmon->regmap, smpro_event_table[channel], event_data); +done: +return ret; +} + +static ssize_t smpro_overflow_data_read (struct device *dev,struct device_attribute *da, +char *buf,int channel) +{ +struct smpro_errmon *errmon =dev_get_drvdata (dev); +struct smpro_error_hdr *err_info; +s32 err_count; +int ret; + + err_info = &smpro_error_table[channel]; + + ret =regmap_read (errmon->regmap, err_info->err_count, &err_count); +if (ret) +return ret; + +/* Bit 8 indicates the overflow status */ +return sysfs_emit (buf,"%d\n" , (err_count &BIT (8 )) ?1 :0 ); +} + +static ssize_t smpro_error_data_read (struct device *dev,struct device_attribute *da, +char *buf,int channel) +{ +struct smpro_errmon *errmon =dev_get_drvdata (dev); +unsigned char err_data[MAX_READ_BLOCK_LENGTH ]; +struct smpro_error_hdr *err_info; +s32 err_count, err_length;
drivers/misc/smpro-errmon.c line 214
Quoted 10 lines
drivers/misc/smpro-errmon.c new file +10
-0+int count =0 ; +int ret; + + err_info = &smpro_error_table[channel]; + + ret =regmap_read (errmon->regmap, err_info->err_count, &err_count); +/* Error count is the low byte */ + err_count &=0xff ; +if (ret || !err_count || err_count > err_info->max_err_cnt) + goto done;
Just return the error.
drivers/misc/smpro-errmon.c line 218
Quoted 4 lines
drivers/misc/smpro-errmon.c new file +4
-0+ + ret =regmap_read (errmon->regmap, err_info->err_len, &err_length); +if (ret || err_length <=0 ) + goto done;
return the error.
Wait, you could return 0 here, are you sure about that?
drivers/misc/smpro-errmon.c line 226
Quoted 8 lines
drivers/misc/smpro-errmon.c new file +8
-0+ +if (err_length >MAX_READ_BLOCK_LENGTH ) + err_length =MAX_READ_BLOCK_LENGTH ; + +memset (err_data,0x00 ,MAX_READ_BLOCK_LENGTH ); + ret =regmap_noinc_read (errmon->regmap, err_info->err_data, err_data, err_length); +if (ret <0 ) + goto done;
return the error, no need for a goto in this function.
Quoted 50 lines
drivers/misc/smpro-errmon.c new file +50
-0+ +/* +* The output of Core/Memory/PCIe/Others UE/CE errors follows below format: +* <Error Type><Error SubType><Instance><Error Status>\ +* <Error Address><Error Misc 0><Error Misc 1><Error Misc2><Error Misc 3> +* Where: +* + Error Type: The hardwares cause the errors. (1 byte) +* + SubType: Sub type of error in the specified hardware error. (1 byte) +* + Instance: Combination of the socket, channel, +* slot cause the error. (2 bytes) +* + Error Status: Encode of error status. (4 bytes) +* + Error Address: The address in device causes the errors. (8 bytes) +* + Error Misc 0/1/2/3: Addition info about the errors. (8 bytes for each) +* Reference Altra SOC BMC Interface specification. +*/ + count =sysfs_emit (buf,"%02x%02x%04x%08x%016llx%016llx%016llx%016llx%016llx\n" , + err_data[0 ], err_data[1 ], *(u16 *)&err_data[2 ], + *(u32 *)&err_data[4 ], *(u64 *)&err_data[8 ], + *(u64 *)&err_data[16 ], *(u64 *)&err_data[24 ], + *(u64 *)&err_data[32 ], *(u64 *)&err_data[40 ]); + +/* go to next error */ + ret =regmap_write (errmon->regmap, err_info->err_count,0x100 ); +done: +return ret ? ret : count; +} + +/* +* Output format: +* <errType><image><dir><Location><errorCode><data> +* Where: +* + errType: SCP Error Type (3 bits) +* 1: Warning +* 2: Error +* 4: Error with data +* + image: SCP Image Code (8 bits) +* + dir: Direction (1 bit) +* 0: Enter +* 1: Exit +* + location: SCP Module Location Code (8 bits) +* + errorCode: SCP Error Code (16 bits) +* + data : Extensive data (32 bits) +* All bits are 0 when errType is warning or error. +*/ +static ssize_t smpro_internal_err_read (struct device *dev,struct device_attribute *da, +char *buf,int channel) +{ +struct smpro_errmon *errmon =dev_get_drvdata (dev); +struct smpro_int_error_hdr *err_info; +unsigned int data_lo =0 , data_hi =0 ;
drivers/misc/smpro-errmon.c line 286
Quoted 10 lines
drivers/misc/smpro-errmon.c new file +10
-0+unsigned int ret_hi, ret_lo; +unsigned int err_type; +unsigned int value; +int count =0 ; +int ret; + +/* read error status */ + ret =regmap_read (errmon->regmap,GPI_RAS_ERR , &value); +if (ret) + goto done;
Same mess here, just return the error.
drivers/misc/smpro-errmon.c line 290
Quoted 4 lines
drivers/misc/smpro-errmon.c new file +4
-0+ +if (!((channel ==RAS_SMPRO_ERRS && (value &BIT (0 ))) || + (channel ==RAS_PMPRO_ERRS && (value &BIT (1 ))))) + goto done;
No error? Are you sure?
Quoted 129 lines
drivers/misc/smpro-errmon.c new file +129
-0+ + err_info = &list_smpro_int_error_hdr[channel]; + ret =regmap_read (errmon->regmap, err_info->err_type, &err_type); +if (ret) + goto done; + + ret =regmap_read (errmon->regmap, err_info->err_info_low, &ret_lo); +if (ret) + goto done; + + ret =regmap_read (errmon->regmap, err_info->err_info_high, &ret_hi); +if (ret) + goto done; + +if (err_type &BIT (2 )) { +/* Error with data type */ + ret =regmap_read (errmon->regmap, err_info->err_data_low, &data_lo); +if (ret) + goto done; + + ret =regmap_read (errmon->regmap, err_info->err_data_high, &data_hi); +if (ret) + goto done; + + count =sysfs_emit (buf,"%01x%02x%01x%02x%04x%04x%04x\n" , +4 , (ret_hi &0xf000 ) >>12 , (ret_hi &0x0800 ) >>11 , + ret_hi &0xff , ret_lo, data_hi, data_lo); +/* clear the read errors */ + ret =regmap_write (errmon->regmap, err_info->err_type,BIT (2 )); + + }else if (err_type &BIT (1 )) { +/* Error type */ + count =sysfs_emit (buf,"%01x%02x%01x%02x%04x%04x%04x\n" , +2 , (ret_hi &0xf000 ) >>12 , (ret_hi &0x0800 ) >>11 , + ret_hi &0xff , ret_lo, data_hi, data_lo); +/* clear the read errors */ + ret =regmap_write (errmon->regmap, err_info->err_type,BIT (1 )); + + }else if (err_type &BIT (0 )) { +/* Warning type */ + count =sysfs_emit (buf,"%01x%02x%01x%02x%04x%04x%04x\n" , +1 , (ret_hi &0xf000 ) >>12 , (ret_hi &0x0800 ) >>11 , + ret_hi &0xff , ret_lo, data_hi, data_lo); +/* clear the read errors */ + ret =regmap_write (errmon->regmap, err_info->err_type,BIT (0 )); + } +done: +return ret ? ret : count; +} + +#define ERROR_OVERFLOW_RO (_error, _index) \ + static ssize_t overflow_##_error##_show(struct device *dev, \ + struct device_attribute *da, \ + char *buf) \ + { \ + return smpro_overflow_data_read(dev, da, buf, _index); \ + } \ + static DEVICE_ATTR_RO(overflow_##_error) + +ERROR_OVERFLOW_RO (core_ce,CORE_CE_ERRS ); +ERROR_OVERFLOW_RO (core_ue,CORE_UE_ERRS ); +ERROR_OVERFLOW_RO (mem_ce,MEM_CE_ERRS ); +ERROR_OVERFLOW_RO (mem_ue,MEM_UE_ERRS ); +ERROR_OVERFLOW_RO (pcie_ce,PCIE_CE_ERRS ); +ERROR_OVERFLOW_RO (pcie_ue,PCIE_UE_ERRS ); +ERROR_OVERFLOW_RO (other_ce,OTHER_CE_ERRS ); +ERROR_OVERFLOW_RO (other_ue,OTHER_UE_ERRS ); + +#define ERROR_RO (_error, _index) \ + static ssize_t error_##_error##_show(struct device *dev, \ + struct device_attribute *da, \ + char *buf) \ + { \ + return smpro_error_data_read(dev, da, buf, _index); \ + } \ + static DEVICE_ATTR_RO(error_##_error) + +ERROR_RO (core_ce,CORE_CE_ERRS ); +ERROR_RO (core_ue,CORE_UE_ERRS ); +ERROR_RO (mem_ce,MEM_CE_ERRS ); +ERROR_RO (mem_ue,MEM_UE_ERRS ); +ERROR_RO (pcie_ce,PCIE_CE_ERRS ); +ERROR_RO (pcie_ue,PCIE_UE_ERRS ); +ERROR_RO (other_ce,OTHER_CE_ERRS ); +ERROR_RO (other_ue,OTHER_UE_ERRS ); + +static ssize_t error_smpro_show (struct device *dev,struct device_attribute *da,char *buf) +{ +return smpro_internal_err_read (dev, da, buf,RAS_SMPRO_ERRS ); +} +static DEVICE_ATTR_RO (error_smpro); + +static ssize_t error_pmpro_show (struct device *dev,struct device_attribute *da,char *buf) +{ +return smpro_internal_err_read (dev, da, buf,RAS_PMPRO_ERRS ); +} +static DEVICE_ATTR_RO (error_pmpro); + +#define EVENT_RO (_event, _index) \ + static ssize_t event_##_event##_show(struct device *dev, \ + struct device_attribute *da, \ + char *buf) \ + { \ + return smpro_event_data_read(dev, da, buf, _index); \ + } \ + static DEVICE_ATTR_RO(event_##_event) + +EVENT_RO (vrd_warn_fault,VRD_WARN_FAULT_EVENTS ); +EVENT_RO (vrd_hot,VRD_HOT_EVENTS ); +EVENT_RO (dimm_hot,DIMM_HOT_EVENTS ); + +static struct attribute *smpro_errmon_attrs[] = { + &dev_attr_overflow_core_ce.attr, + &dev_attr_overflow_core_ue.attr, + &dev_attr_overflow_mem_ce.attr, + &dev_attr_overflow_mem_ue.attr, + &dev_attr_overflow_pcie_ce.attr, + &dev_attr_overflow_pcie_ue.attr, + &dev_attr_overflow_other_ce.attr, + &dev_attr_overflow_other_ue.attr, + &dev_attr_error_core_ce.attr, + &dev_attr_error_core_ue.attr, + &dev_attr_error_mem_ce.attr, + &dev_attr_error_mem_ue.attr, + &dev_attr_error_pcie_ce.attr, + &dev_attr_error_pcie_ue.attr, + &dev_attr_error_other_ce.attr, + &dev_attr_error_other_ue.attr, + &dev_attr_error_smpro.attr,
drivers/misc/smpro-errmon.c line 429
Quoted 10 lines
drivers/misc/smpro-errmon.c new file +10
-0+ &dev_attr_error_pmpro.attr, + &dev_attr_event_vrd_warn_fault.attr, + &dev_attr_event_vrd_hot.attr, + &dev_attr_event_dimm_hot.attr, + NULL +}; + +static const struct attribute_group smpro_errmon_attr_group = { + .attrs = smpro_errmon_attrs +};
ATTRIBUTE_GROUPS()?
Quoted 7 lines
drivers/misc/smpro-errmon.c new file +7
-0+ +static int smpro_errmon_probe (struct platform_device *pdev) +{ +struct smpro_errmon *errmon; +int ret; + + errmon =devm_kzalloc (&pdev->dev,sizeof (struct smpro_errmon ),GFP_KERNEL );
drivers/misc/smpro-errmon.c line 446
Quoted 10 lines
drivers/misc/smpro-errmon.c new file +10
-0+if (!errmon) +return -ENOMEM ; + +platform_set_drvdata (pdev, errmon); + + errmon->regmap =dev_get_regmap (pdev->dev.parent,NULL ); +if (!errmon->regmap) +return -ENODEV ; + + ret =sysfs_create_group (&pdev->dev.kobj, &smpro_errmon_attr_group);
You just raced with userspace and lost :(
Always use the default groups of the platform driver for this. That way you do not have to do anything special and your files will be created properly.
drivers/misc/smpro-errmon.c line 456
Quoted 10 lines
drivers/misc/smpro-errmon.c new file +10
-0+if (ret) +dev_err (&pdev->dev,"SMPro errmon sysfs registration failed\n" ); + +return 0 ; +} + +static int smpro_errmon_remove (struct platform_device *pdev) +{ +sysfs_remove_group (&pdev->dev.kobj, &smpro_errmon_attr_group); +pr_info ("SMPro errmon sysfs entries removed" );
Drivers are quiet when all is working properly.
If you set the pointer properly as asked above, you do not have to remove the group on your own.
Huge hint, if you ever call sysfs_* from a driver, something is probably wrong.
Same goes for the other drivers in this series, please fix them all up this way.
thanks,
greg k-h
Re: [PATCH v8 3/9] misc: smpro-errmon: Add Ampere's SMpro error monitor driver
Quoted 70 lines · Greg Kroah-Hartman
Quoted 69 lines · Quan Nguyen
This commit adds Ampere's SMpro error monitor driver for monitoring and reporting RAS-related errors as reported by SMpro co-processor found on Ampere's Altra processor family.
Signed-off-by Quan Nguyen <[email protected]>---
Changes in v8:
+ Update wording forSMPRO_ERRMONonKconfigfile [Quan]
+ Avoid uninitialized variable use [kernel test robot]+ Switch to use sysfs_emit() [Greg] + Make sysfs to return single value [Greg] + Change errors_* sysfs to error_* [Quan]+ Add overflow_[core|mem|pcie|other]_[ce|ue] sysfs to report
overflow status of each type of HW errors [Quan]
+ Add some minor refactor [Quan]Changes in v7:
+ Remove regmap_acquire/release_lock(),read_i2c_block_data()[Quan]
+ Useregmap_noinc_read()instead oferrmon_read_block()[Quan]
+ Validate number of errors before read [Quan]
+ Fix wrong return type of*_show()function [kernel test robot]
+ Adjust patch order to avoid dependence with smpro-mfd [Lee Jones]
+ Use pointer instead of stack memory [Quan]Changes in v6:
+ First introduced in v6 [Quan]drivers/misc/Kconfig | 12 + drivers/misc/Makefile | 1 + drivers/misc/smpro-errmon.c | 477 ++++++++++++++++++++++++++++++++++++ 3 files changed, 490 insertions(+)create mode 100644
drivers/misc/smpro-errmon.cdrivers/misc/Kconfig +12
-0@@ -176,6 +176,18 @@ config SGI_XP this feature will allow for direct communication between SSIs based on a network adapter and DMA messaging. +config SMPRO_ERRMON + tristate "Ampere Computing SMPro error monitor driver" + depends on MFD_SMPRO || COMPILE_TEST + help + Say Y here to get support for the SMpro error monitor function + provided by Ampere Computing's Altra and Altra Max SoCs. Upon + loading, the driver creates sysfs files which can be use to gather + multiple HW error data reported via read and write system calls. + + To compile this driver as a module, say M here. The driver will be + called smpro-errmon. + config CS5535_MFGPT tristate "CS5535/CS5536 Geode Multi-Function General Purpose Timer (MFGPT) support" depends on MFD_CS5535drivers/misc/Makefile +1
-0@@ -23,6 +23,7 @@ obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o obj-$(CONFIG_KGDB_TESTS) += kgdbts.o obj-$(CONFIG_SGI_XP) += sgi-xp/ obj-$(CONFIG_SGI_GRU) += sgi-gru/ +obj-$(CONFIG_SMPRO_ERRMON) += smpro-errmon.o obj-$(CONFIG_CS5535_MFGPT) += cs5535-mfgpt.o obj-$(CONFIG_GEHC_ACHC) += gehc-achc.o obj-$(CONFIG_HP_ILO) += hpilo.odrivers/misc/smpro-errmon.c +0
-0
Quoted 9 lines
drivers/misc/smpro-errmon.c line 1
Quoted 6 lines
new file mode 100644
index 000000000000..df7d8fc4ff3fdrivers/misc/smpro-errmon.c new file +1
-0@@ -0,0 +1,477 @@ +// SPDX-License-Identifier: GPL-2.0+ Are you sure you mean "or any later version"? I have to ask.
Thank Greg for the review.
Will change all to SPDX-License-Identifier: GPL-2.0-or-later in next version.
Quoted 7 lines
Quoted 7 lines
drivers/misc/smpro-errmon.c new file +7
-0+static struct smpro_int_error_hdr list_smpro_int_error_hdr[2 ] = { + { +ERR_SMPRO_TYPE , +ERR_SMPRO_INFO_LO ,ERR_SMPRO_INFO_HI , +ERR_SMPRO_DATA_LO ,ERR_SMPRO_DATA_HI , +WARN_SMPRO_INFO_LO ,WARN_SMPRO_INFO_HI + },
Quoted 9 lines
drivers/misc/smpro-errmon.c line 139
Quoted 6 lines
drivers/misc/smpro-errmon.c new file +6
-0+ { +ERR_PMPRO_TYPE , +ERR_PMPRO_INFO_LO ,ERR_PMPRO_INFO_HI , +ERR_PMPRO_DATA_LO ,ERR_PMPRO_DATA_HI , +WARN_PMPRO_INFO_LO ,WARN_PMPRO_INFO_HI + },Odd indentation, checkpatch did not complain?
No, checkpatch.pl did not complain. But let me check to see if there is better indentation.
Quoted 5 lines
Quoted 5 lines
drivers/misc/smpro-errmon.c new file +5
-0+static ssize_t smpro_event_data_read (struct device *dev, +struct device_attribute *da,char *buf, +int channel) +{ +struct smpro_errmon *errmon =dev_get_drvdata (dev);
Quoted 9 lines
drivers/misc/smpro-errmon.c line 170
Quoted 6 lines
drivers/misc/smpro-errmon.c new file +6
-0+s32 event_data; +int ret; + + ret =regmap_read (errmon->regmap, smpro_event_table[channel], &event_data); +if (ret) + goto done;Just return the error here.
Will fix in next version
Quoted 5 lines
drivers/misc/smpro-errmon.c line 27
Quoted 2 lines
drivers/misc/smpro-errmon.c new file +2
-0+ + ret =sysfs_emit (buf,"%02x%04x\n" , channel, event_data);sysfs rules are one value per file. You know this.
Yes, I will address this in my next version. The "channel" could be removed as the sysfs file name itself is enough to identify the channel.
Quoted 6 lines
drivers/misc/smpro-errmon.c line 174
Quoted 2 lines
drivers/misc/smpro-errmon.c new file +2
-0+/* Clear event after read */ +if (event_data !=0 )Why would it be 0? Isn't 0 a valid value?
0 means it is good and there is no event, but if it is not 0, that mean there is an event and need to be written back to clear that event.
Quoted 34 lines
Quoted 34 lines
drivers/misc/smpro-errmon.c new file +34
-0+regmap_write (errmon->regmap, smpro_event_table[channel], event_data); +done: +return ret; +} + +static ssize_t smpro_overflow_data_read (struct device *dev,struct device_attribute *da, +char *buf,int channel) +{ +struct smpro_errmon *errmon =dev_get_drvdata (dev); +struct smpro_error_hdr *err_info; +s32 err_count; +int ret; + + err_info = &smpro_error_table[channel]; + + ret =regmap_read (errmon->regmap, err_info->err_count, &err_count); +if (ret) +return ret; + +/* Bit 8 indicates the overflow status */ +return sysfs_emit (buf,"%d\n" , (err_count &BIT (8 )) ?1 :0 ); +} + +static ssize_t smpro_error_data_read (struct device *dev,struct device_attribute *da, +char *buf,int channel) +{ +struct smpro_errmon *errmon =dev_get_drvdata (dev); +unsigned char err_data[MAX_READ_BLOCK_LENGTH ]; +struct smpro_error_hdr *err_info; +s32 err_count, err_length; +int count =0 ; +int ret; + + err_info = &smpro_error_table[channel];
Quoted 9 lines
drivers/misc/smpro-errmon.c line 214
Quoted 6 lines
drivers/misc/smpro-errmon.c new file +6
-0+ + ret =regmap_read (errmon->regmap, err_info->err_count, &err_count); +/* Error count is the low byte */ + err_count &=0xff ; +if (ret || !err_count || err_count > err_info->max_err_cnt) + goto done;Just return the error.
Will fix in next version.
Quoted 9 lines
drivers/misc/smpro-errmon.c line 218
Quoted 4 lines
drivers/misc/smpro-errmon.c new file +4
-0+ + ret =regmap_read (errmon->regmap, err_info->err_len, &err_length); +if (ret || err_length <=0 ) + goto done;return the error.
Wait, you could return 0 here, are you sure about that?
Yes, that is our intention.
If ret != 0 then return the error
Otherwise, if ret == 0 then return 0 if there is no error and/or err_length invalid.
Quoted 11 lines
drivers/misc/smpro-errmon.c line 226
Quoted 8 lines
drivers/misc/smpro-errmon.c new file +8
-0+ +if (err_length >MAX_READ_BLOCK_LENGTH ) + err_length =MAX_READ_BLOCK_LENGTH ; + +memset (err_data,0x00 ,MAX_READ_BLOCK_LENGTH ); + ret =regmap_noinc_read (errmon->regmap, err_info->err_data, err_data, err_length); +if (ret <0 ) + goto done;return the error, no need for a goto in this function.
Agree, will fix this and any other places as well.
Quoted 54 lines
Quoted 54 lines
drivers/misc/smpro-errmon.c new file +54
-0+ +/* +* The output of Core/Memory/PCIe/Others UE/CE errors follows below format: +* <Error Type><Error SubType><Instance><Error Status>\ +* <Error Address><Error Misc 0><Error Misc 1><Error Misc2><Error Misc 3> +* Where: +* + Error Type: The hardwares cause the errors. (1 byte) +* + SubType: Sub type of error in the specified hardware error. (1 byte) +* + Instance: Combination of the socket, channel, +* slot cause the error. (2 bytes) +* + Error Status: Encode of error status. (4 bytes) +* + Error Address: The address in device causes the errors. (8 bytes) +* + Error Misc 0/1/2/3: Addition info about the errors. (8 bytes for each) +* Reference Altra SOC BMC Interface specification. +*/ + count =sysfs_emit (buf,"%02x%02x%04x%08x%016llx%016llx%016llx%016llx%016llx\n" , + err_data[0 ], err_data[1 ], *(u16 *)&err_data[2 ], + *(u32 *)&err_data[4 ], *(u64 *)&err_data[8 ], + *(u64 *)&err_data[16 ], *(u64 *)&err_data[24 ], + *(u64 *)&err_data[32 ], *(u64 *)&err_data[40 ]); + +/* go to next error */ + ret =regmap_write (errmon->regmap, err_info->err_count,0x100 ); +done: +return ret ? ret : count; +} + +/* +* Output format: +* <errType><image><dir><Location><errorCode><data> +* Where: +* + errType: SCP Error Type (3 bits) +* 1: Warning +* 2: Error +* 4: Error with data +* + image: SCP Image Code (8 bits) +* + dir: Direction (1 bit) +* 0: Enter +* 1: Exit +* + location: SCP Module Location Code (8 bits) +* + errorCode: SCP Error Code (16 bits) +* + data : Extensive data (32 bits) +* All bits are 0 when errType is warning or error. +*/ +static ssize_t smpro_internal_err_read (struct device *dev,struct device_attribute *da, +char *buf,int channel) +{ +struct smpro_errmon *errmon =dev_get_drvdata (dev); +struct smpro_int_error_hdr *err_info; +unsigned int data_lo =0 , data_hi =0 ; +unsigned int ret_hi, ret_lo; +unsigned int err_type; +unsigned int value; +int count =0 ;
Quoted 9 lines
drivers/misc/smpro-errmon.c line 286
Quoted 6 lines
drivers/misc/smpro-errmon.c new file +6
-0+int ret; + +/* read error status */ + ret =regmap_read (errmon->regmap,GPI_RAS_ERR , &value); +if (ret) + goto done;Same mess here, just return the error.
Yes. will do.
Quoted 7 lines
drivers/misc/smpro-errmon.c line 290
Quoted 4 lines
drivers/misc/smpro-errmon.c new file +4
-0+ +if (!((channel ==RAS_SMPRO_ERRS && (value &BIT (0 ))) || + (channel ==RAS_PMPRO_ERRS && (value &BIT (1 ))))) + goto done;No error? Are you sure?
Yes, no error, but let me try to make this a bit simpler in next version.
Quoted 133 lines
Quoted 133 lines
drivers/misc/smpro-errmon.c new file +133
-0+ + err_info = &list_smpro_int_error_hdr[channel]; + ret =regmap_read (errmon->regmap, err_info->err_type, &err_type); +if (ret) + goto done; + + ret =regmap_read (errmon->regmap, err_info->err_info_low, &ret_lo); +if (ret) + goto done; + + ret =regmap_read (errmon->regmap, err_info->err_info_high, &ret_hi); +if (ret) + goto done; + +if (err_type &BIT (2 )) { +/* Error with data type */ + ret =regmap_read (errmon->regmap, err_info->err_data_low, &data_lo); +if (ret) + goto done; + + ret =regmap_read (errmon->regmap, err_info->err_data_high, &data_hi); +if (ret) + goto done; + + count =sysfs_emit (buf,"%01x%02x%01x%02x%04x%04x%04x\n" , +4 , (ret_hi &0xf000 ) >>12 , (ret_hi &0x0800 ) >>11 , + ret_hi &0xff , ret_lo, data_hi, data_lo); +/* clear the read errors */ + ret =regmap_write (errmon->regmap, err_info->err_type,BIT (2 )); + + }else if (err_type &BIT (1 )) { +/* Error type */ + count =sysfs_emit (buf,"%01x%02x%01x%02x%04x%04x%04x\n" , +2 , (ret_hi &0xf000 ) >>12 , (ret_hi &0x0800 ) >>11 , + ret_hi &0xff , ret_lo, data_hi, data_lo); +/* clear the read errors */ + ret =regmap_write (errmon->regmap, err_info->err_type,BIT (1 )); + + }else if (err_type &BIT (0 )) { +/* Warning type */ + count =sysfs_emit (buf,"%01x%02x%01x%02x%04x%04x%04x\n" , +1 , (ret_hi &0xf000 ) >>12 , (ret_hi &0x0800 ) >>11 , + ret_hi &0xff , ret_lo, data_hi, data_lo); +/* clear the read errors */ + ret =regmap_write (errmon->regmap, err_info->err_type,BIT (0 )); + } +done: +return ret ? ret : count; +} + +#define ERROR_OVERFLOW_RO (_error, _index) \ + static ssize_t overflow_##_error##_show(struct device *dev, \ + struct device_attribute *da, \ + char *buf) \ + { \ + return smpro_overflow_data_read(dev, da, buf, _index); \ + } \ + static DEVICE_ATTR_RO(overflow_##_error) + +ERROR_OVERFLOW_RO (core_ce,CORE_CE_ERRS ); +ERROR_OVERFLOW_RO (core_ue,CORE_UE_ERRS ); +ERROR_OVERFLOW_RO (mem_ce,MEM_CE_ERRS ); +ERROR_OVERFLOW_RO (mem_ue,MEM_UE_ERRS ); +ERROR_OVERFLOW_RO (pcie_ce,PCIE_CE_ERRS ); +ERROR_OVERFLOW_RO (pcie_ue,PCIE_UE_ERRS ); +ERROR_OVERFLOW_RO (other_ce,OTHER_CE_ERRS ); +ERROR_OVERFLOW_RO (other_ue,OTHER_UE_ERRS ); + +#define ERROR_RO (_error, _index) \ + static ssize_t error_##_error##_show(struct device *dev, \ + struct device_attribute *da, \ + char *buf) \ + { \ + return smpro_error_data_read(dev, da, buf, _index); \ + } \ + static DEVICE_ATTR_RO(error_##_error) + +ERROR_RO (core_ce,CORE_CE_ERRS ); +ERROR_RO (core_ue,CORE_UE_ERRS ); +ERROR_RO (mem_ce,MEM_CE_ERRS ); +ERROR_RO (mem_ue,MEM_UE_ERRS ); +ERROR_RO (pcie_ce,PCIE_CE_ERRS ); +ERROR_RO (pcie_ue,PCIE_UE_ERRS ); +ERROR_RO (other_ce,OTHER_CE_ERRS ); +ERROR_RO (other_ue,OTHER_UE_ERRS ); + +static ssize_t error_smpro_show (struct device *dev,struct device_attribute *da,char *buf) +{ +return smpro_internal_err_read (dev, da, buf,RAS_SMPRO_ERRS ); +} +static DEVICE_ATTR_RO (error_smpro); + +static ssize_t error_pmpro_show (struct device *dev,struct device_attribute *da,char *buf) +{ +return smpro_internal_err_read (dev, da, buf,RAS_PMPRO_ERRS ); +} +static DEVICE_ATTR_RO (error_pmpro); + +#define EVENT_RO (_event, _index) \ + static ssize_t event_##_event##_show(struct device *dev, \ + struct device_attribute *da, \ + char *buf) \ + { \ + return smpro_event_data_read(dev, da, buf, _index); \ + } \ + static DEVICE_ATTR_RO(event_##_event) + +EVENT_RO (vrd_warn_fault,VRD_WARN_FAULT_EVENTS ); +EVENT_RO (vrd_hot,VRD_HOT_EVENTS ); +EVENT_RO (dimm_hot,DIMM_HOT_EVENTS ); + +static struct attribute *smpro_errmon_attrs[] = { + &dev_attr_overflow_core_ce.attr, + &dev_attr_overflow_core_ue.attr, + &dev_attr_overflow_mem_ce.attr, + &dev_attr_overflow_mem_ue.attr, + &dev_attr_overflow_pcie_ce.attr, + &dev_attr_overflow_pcie_ue.attr, + &dev_attr_overflow_other_ce.attr, + &dev_attr_overflow_other_ue.attr, + &dev_attr_error_core_ce.attr, + &dev_attr_error_core_ue.attr, + &dev_attr_error_mem_ce.attr, + &dev_attr_error_mem_ue.attr, + &dev_attr_error_pcie_ce.attr, + &dev_attr_error_pcie_ue.attr, + &dev_attr_error_other_ce.attr, + &dev_attr_error_other_ue.attr, + &dev_attr_error_smpro.attr, + &dev_attr_error_pmpro.attr, + &dev_attr_event_vrd_warn_fault.attr, + &dev_attr_event_vrd_hot.attr, + &dev_attr_event_dimm_hot.attr,
Quoted 10 lines
drivers/misc/smpro-errmon.c line 429
Quoted 6 lines
drivers/misc/smpro-errmon.c new file +6
-0+ NULL +}; + +static const struct attribute_group smpro_errmon_attr_group = { + .attrs = smpro_errmon_attrs +};
ATTRIBUTE_GROUPS()?
Will use this macro in next version.
Quoted 20 lines
Quoted 7 lines
drivers/misc/smpro-errmon.c new file +7
-0+ +static int smpro_errmon_probe (struct platform_device *pdev) +{ +struct smpro_errmon *errmon; +int ret; + + errmon =devm_kzalloc (&pdev->dev,sizeof (struct smpro_errmon ),GFP_KERNEL );drivers/misc/smpro-errmon.c line 446
Quoted 10 lines
drivers/misc/smpro-errmon.c new file +10
-0+if (!errmon) +return -ENOMEM ; + +platform_set_drvdata (pdev, errmon); + + errmon->regmap =dev_get_regmap (pdev->dev.parent,NULL ); +if (!errmon->regmap) +return -ENODEV ; + + ret =sysfs_create_group (&pdev->dev.kobj, &smpro_errmon_attr_group);You just raced with userspace and lost :(
Quoted 4 lines
Always use the default groups of the platform driver for this. That way you do not have to do anything special and your files will be created properly.
And will switch to use .dev_groups follow your article at https://lwn.net/Articles/793061/
Quoted 13 lines
drivers/misc/smpro-errmon.c line 456
Quoted 10 lines
drivers/misc/smpro-errmon.c new file +10
-0+if (ret) +dev_err (&pdev->dev,"SMPro errmon sysfs registration failed\n" ); + +return 0 ; +} + +static int smpro_errmon_remove (struct platform_device *pdev) +{ +sysfs_remove_group (&pdev->dev.kobj, &smpro_errmon_attr_group); +pr_info ("SMPro errmon sysfs entries removed" );Drivers are quiet when all is working properly.
Quoted 9 lines
If you set the pointer properly as asked above, you do not have to remove the group on your own.
Huge hint, if you ever call sysfs_* from a driver, something is probably wrong.
Same goes for the other drivers in this series, please fix them all up this way.
Thanks for pointing out. Will apply all other places where applicable.
Thank you for the review,
-- Quan
Greg Kroah-Hartman
maintainerRe: [PATCH v8 3/9] misc: smpro-errmon: Add Ampere's SMpro error monitor driver
Quoted 80 lines · Quan Nguyen
Quoted 69 lines · Greg Kroah-Hartman
Quoted 68 lines · Quan Nguyen
This commit adds Ampere's SMpro error monitor driver for monitoring and reporting RAS-related errors as reported by SMpro co-processor found on Ampere's Altra processor family.
Signed-off-by Quan Nguyen <[email protected]>---
Changes in v8:
+ Update wording forSMPRO_ERRMONonKconfigfile [Quan]
+ Avoid uninitialized variable use [kernel test robot]+ Switch to use sysfs_emit() [Greg] + Make sysfs to return single value [Greg] + Change errors_* sysfs to error_* [Quan]+ Add overflow_[core|mem|pcie|other]_[ce|ue] sysfs to report
overflow status of each type of HW errors [Quan]
+ Add some minor refactor [Quan]Changes in v7:
+ Remove regmap_acquire/release_lock(),read_i2c_block_data()[Quan]
+ Useregmap_noinc_read()instead oferrmon_read_block()[Quan]
+ Validate number of errors before read [Quan]
+ Fix wrong return type of*_show()function [kernel test robot]
+ Adjust patch order to avoid dependence with smpro-mfd [Lee Jones]
+ Use pointer instead of stack memory [Quan]Changes in v6:
+ First introduced in v6 [Quan]drivers/misc/Kconfig | 12 + drivers/misc/Makefile | 1 + drivers/misc/smpro-errmon.c | 477 ++++++++++++++++++++++++++++++++++++ 3 files changed, 490 insertions(+)create mode 100644
drivers/misc/smpro-errmon.cdrivers/misc/Kconfig +12
-0@@ -176,6 +176,18 @@ config SGI_XP this feature will allow for direct communication between SSIs based on a network adapter and DMA messaging. +config SMPRO_ERRMON + tristate "Ampere Computing SMPro error monitor driver" + depends on MFD_SMPRO || COMPILE_TEST + help + Say Y here to get support for the SMpro error monitor function + provided by Ampere Computing's Altra and Altra Max SoCs. Upon + loading, the driver creates sysfs files which can be use to gather + multiple HW error data reported via read and write system calls. + + To compile this driver as a module, say M here. The driver will be + called smpro-errmon. + config CS5535_MFGPT tristate "CS5535/CS5536 Geode Multi-Function General Purpose Timer (MFGPT) support" depends on MFD_CS5535drivers/misc/Makefile +1
-0@@ -23,6 +23,7 @@ obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o obj-$(CONFIG_KGDB_TESTS) += kgdbts.o obj-$(CONFIG_SGI_XP) += sgi-xp/ obj-$(CONFIG_SGI_GRU) += sgi-gru/ +obj-$(CONFIG_SMPRO_ERRMON) += smpro-errmon.o obj-$(CONFIG_CS5535_MFGPT) += cs5535-mfgpt.o obj-$(CONFIG_GEHC_ACHC) += gehc-achc.o obj-$(CONFIG_HP_ILO) += hpilo.odrivers/misc/smpro-errmon.c +0
-0Quoted 9 lines
drivers/misc/smpro-errmon.c line 1
Quoted 6 lines
new file mode 100644
index 000000000000..df7d8fc4ff3fdrivers/misc/smpro-errmon.c new file +1
-0@@ -0,0 +1,477 @@ +// SPDX-License-Identifier: GPL-2.0+ Are you sure you mean "or any later version"? I have to ask.
Quoted 4 lines
Thank Greg for the review.
Will change all to SPDX-License-Identifier: GPL-2.0-or-later in next version.
That is not what I am asking (the SPDX tag format). I mean, do you really mean "or later" for your license as that is not the license of the kernel overall? If so, wonderful, but I have to ask that as your legal group needs to be aware of it, sorry.
thanks,
greg k-h
Re: [PATCH v8 3/9] misc: smpro-errmon: Add Ampere's SMpro error monitor driver
Quoted 83 lines · Greg Kroah-Hartman
Quoted 82 lines · Quan Nguyen
Quoted 69 lines · Greg Kroah-Hartman
Quoted 68 lines · Quan Nguyen
This commit adds Ampere's SMpro error monitor driver for monitoring and reporting RAS-related errors as reported by SMpro co-processor found on Ampere's Altra processor family.
Signed-off-by Quan Nguyen <[email protected]>---
Changes in v8:
+ Update wording forSMPRO_ERRMONonKconfigfile [Quan]
+ Avoid uninitialized variable use [kernel test robot]+ Switch to use sysfs_emit() [Greg] + Make sysfs to return single value [Greg] + Change errors_* sysfs to error_* [Quan]+ Add overflow_[core|mem|pcie|other]_[ce|ue] sysfs to report
overflow status of each type of HW errors [Quan]
+ Add some minor refactor [Quan]Changes in v7:
+ Remove regmap_acquire/release_lock(),read_i2c_block_data()[Quan]
+ Useregmap_noinc_read()instead oferrmon_read_block()[Quan]
+ Validate number of errors before read [Quan]
+ Fix wrong return type of*_show()function [kernel test robot]
+ Adjust patch order to avoid dependence with smpro-mfd [Lee Jones]
+ Use pointer instead of stack memory [Quan]Changes in v6:
+ First introduced in v6 [Quan]drivers/misc/Kconfig | 12 + drivers/misc/Makefile | 1 + drivers/misc/smpro-errmon.c | 477 ++++++++++++++++++++++++++++++++++++ 3 files changed, 490 insertions(+)create mode 100644
drivers/misc/smpro-errmon.cdrivers/misc/Kconfig +12
-0@@ -176,6 +176,18 @@ config SGI_XP this feature will allow for direct communication between SSIs based on a network adapter and DMA messaging. +config SMPRO_ERRMON + tristate "Ampere Computing SMPro error monitor driver" + depends on MFD_SMPRO || COMPILE_TEST + help + Say Y here to get support for the SMpro error monitor function + provided by Ampere Computing's Altra and Altra Max SoCs. Upon + loading, the driver creates sysfs files which can be use to gather + multiple HW error data reported via read and write system calls. + + To compile this driver as a module, say M here. The driver will be + called smpro-errmon. + config CS5535_MFGPT tristate "CS5535/CS5536 Geode Multi-Function General Purpose Timer (MFGPT) support" depends on MFD_CS5535drivers/misc/Makefile +1
-0@@ -23,6 +23,7 @@ obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o obj-$(CONFIG_KGDB_TESTS) += kgdbts.o obj-$(CONFIG_SGI_XP) += sgi-xp/ obj-$(CONFIG_SGI_GRU) += sgi-gru/ +obj-$(CONFIG_SMPRO_ERRMON) += smpro-errmon.o obj-$(CONFIG_CS5535_MFGPT) += cs5535-mfgpt.o obj-$(CONFIG_GEHC_ACHC) += gehc-achc.o obj-$(CONFIG_HP_ILO) += hpilo.odrivers/misc/smpro-errmon.c +0
-0Quoted 9 lines
drivers/misc/smpro-errmon.c line 1
Quoted 6 lines
new file mode 100644
index 000000000000..df7d8fc4ff3fdrivers/misc/smpro-errmon.c new file +1
-0@@ -0,0 +1,477 @@ +// SPDX-License-Identifier: GPL-2.0+ Are you sure you mean "or any later version"? I have to ask.
Thank Greg for the review.
Quoted 7 lines
Quoted 2 lines
Will change all to SPDX-License-Identifier: GPL-2.0-or-later in next version.
That is not what I am asking (the SPDX tag format). I mean, do you really mean "or later" for your license as that is not the license of the kernel overall? If so, wonderful, but I have to ask that as your legal group needs to be aware of it, sorry.
Generally speaking we should be sticking with the standard license for projects we engage with, in this case "GPL-2.0".
Quan, unless you have heard differently or have a specific reason to include the "+", please drop from the next version. If you do feel the "+" is required, let's have an internal conversation about that.
Apologies for missing that in earlier reviews.
Thanks,
Signature · 2 lines
Darren Hart Ampere Computing / OS and Kernel
Re: [PATCH v8 3/9] misc: smpro-errmon: Add Ampere's SMpro error monitor driver
In reply to Greg Kroah-HartmanQuoted 83 lines · Greg Kroah-Hartman
Quoted 82 lines · Quan Nguyen
Quoted 69 lines · Greg Kroah-Hartman
Quoted 68 lines · Quan Nguyen
This commit adds Ampere's SMpro error monitor driver for monitoring and reporting RAS-related errors as reported by SMpro co-processor found on Ampere's Altra processor family.
Signed-off-by Quan Nguyen <[email protected]>---
Changes in v8:
+ Update wording forSMPRO_ERRMONonKconfigfile [Quan]
+ Avoid uninitialized variable use [kernel test robot]
+ Switch to usesysfs_emit()[Greg]
+ Make sysfs to return single value [Greg]
+ Change errors_* sysfs to error_* [Quan]
+ Add overflow_[core|mem|pcie|other]_[ce|ue] sysfs to report
overflow status of each type of HW errors [Quan]
+ Add some minor refactor [Quan]Changes in v7:
+ Remove regmap_acquire/release_lock(),read_i2c_block_data()[Quan]
+ Useregmap_noinc_read()instead oferrmon_read_block()[Quan]
+ Validate number of errors before read [Quan]
+ Fix wrong return type of*_show()function [kernel test robot]
+ Adjust patch order to avoid dependence with smpro-mfd [Lee Jones]
+ Use pointer instead of stack memory [Quan]Changes in v6:
+ First introduced in v6 [Quan]drivers/misc/Kconfig | 12 + drivers/misc/Makefile | 1 + drivers/misc/smpro-errmon.c | 477 ++++++++++++++++++++++++++++++++++++ 3 files changed, 490 insertions(+)create mode 100644
drivers/misc/smpro-errmon.cdrivers/misc/Kconfig +12
-0@@ -176,6 +176,18 @@ config SGI_XP this feature will allow for direct communication between SSIs based on a network adapter and DMA messaging. +config SMPRO_ERRMON + tristate "Ampere Computing SMPro error monitor driver" + depends on MFD_SMPRO || COMPILE_TEST + help + Say Y here to get support for the SMpro error monitor function + provided by Ampere Computing's Altra and Altra Max SoCs. Upon + loading, the driver creates sysfs files which can be use to gather + multiple HW error data reported via read and write system calls. + + To compile this driver as a module, say M here. The driver will be + called smpro-errmon. + config CS5535_MFGPT tristate "CS5535/CS5536 Geode Multi-Function General Purpose Timer (MFGPT) support" depends on MFD_CS5535drivers/misc/Makefile +1
-0@@ -23,6 +23,7 @@ obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o obj-$(CONFIG_KGDB_TESTS) += kgdbts.o obj-$(CONFIG_SGI_XP) += sgi-xp/ obj-$(CONFIG_SGI_GRU) += sgi-gru/ +obj-$(CONFIG_SMPRO_ERRMON) += smpro-errmon.o obj-$(CONFIG_CS5535_MFGPT) += cs5535-mfgpt.o obj-$(CONFIG_GEHC_ACHC) += gehc-achc.o obj-$(CONFIG_HP_ILO) += hpilo.odrivers/misc/smpro-errmon.c +0
-0Quoted 9 lines
drivers/misc/smpro-errmon.c line 1
Quoted 6 lines
new file mode 100644
index 000000000000..df7d8fc4ff3fdrivers/misc/smpro-errmon.c new file +1
-0@@ -0,0 +1,477 @@ +// SPDX-License-Identifier: GPL-2.0+ Are you sure you mean "or any later version"? I have to ask.
Thank Greg for the review.
Quoted 8 lines
Quoted 2 lines
Will change all to SPDX-License-Identifier: GPL-2.0-or-later in next version.
That is not what I am asking (the SPDX tag format). I mean, do you really mean "or later" for your license as that is not the license of the kernel overall? If so, wonderful, but I have to ask that as your legal group needs to be aware of it, sorry.
Dear Greg,
My sincere thanks for bringing this up. This would need help from our legal team to recheck/review and will make appropriate change in my next version.
- Quan
Re: [PATCH v8 3/9] misc: smpro-errmon: Add Ampere's SMpro error monitor driver
In reply to Greg Kroah-HartmanQuoted 288 lines · Greg Kroah-Hartman
Quoted 74 lines · Quan Nguyen
This commit adds Ampere's SMpro error monitor driver for monitoring and reporting RAS-related errors as reported by SMpro co-processor found on Ampere's Altra processor family.
Signed-off-by Quan Nguyen <[email protected]>---
Changes in v8:
+ Update wording forSMPRO_ERRMONonKconfigfile [Quan]
+ Avoid uninitialized variable use [kernel test robot]+ Switch to use sysfs_emit() [Greg] + Make sysfs to return single value [Greg] + Change errors_* sysfs to error_* [Quan]+ Add overflow_[core|mem|pcie|other]_[ce|ue] sysfs to report
overflow status of each type of HW errors [Quan]
+ Add some minor refactor [Quan]Changes in v7:
+ Remove regmap_acquire/release_lock(),read_i2c_block_data()[Quan]
+ Useregmap_noinc_read()instead oferrmon_read_block()[Quan]
+ Validate number of errors before read [Quan]
+ Fix wrong return type of*_show()function [kernel test robot]
+ Adjust patch order to avoid dependence with smpro-mfd [Lee Jones]
+ Use pointer instead of stack memory [Quan]Changes in v6:
+ First introduced in v6 [Quan]drivers/misc/Kconfig | 12 + drivers/misc/Makefile | 1 + drivers/misc/smpro-errmon.c | 477 ++++++++++++++++++++++++++++++++++++ 3 files changed, 490 insertions(+)create mode 100644
drivers/misc/smpro-errmon.cdrivers/misc/Kconfig +12
-0@@ -176,6 +176,18 @@ config SGI_XP this feature will allow for direct communication between SSIs based on a network adapter and DMA messaging. +config SMPRO_ERRMON + tristate "Ampere Computing SMPro error monitor driver" + depends on MFD_SMPRO || COMPILE_TEST + help + Say Y here to get support for the SMpro error monitor function + provided by Ampere Computing's Altra and Altra Max SoCs. Upon + loading, the driver creates sysfs files which can be use to gather + multiple HW error data reported via read and write system calls. + + To compile this driver as a module, say M here. The driver will be + called smpro-errmon. + config CS5535_MFGPT tristate "CS5535/CS5536 Geode Multi-Function General Purpose Timer (MFGPT) support" depends on MFD_CS5535drivers/misc/Makefile +1
-0@@ -23,6 +23,7 @@ obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o obj-$(CONFIG_KGDB_TESTS) += kgdbts.o obj-$(CONFIG_SGI_XP) += sgi-xp/ obj-$(CONFIG_SGI_GRU) += sgi-gru/ +obj-$(CONFIG_SMPRO_ERRMON) += smpro-errmon.o obj-$(CONFIG_CS5535_MFGPT) += cs5535-mfgpt.o obj-$(CONFIG_GEHC_ACHC) += gehc-achc.o obj-$(CONFIG_HP_ILO) += hpilo.odrivers/misc/smpro-errmon.c new file +0
-0drivers/misc/smpro-errmon.c line 1
Quoted 1 line
drivers/misc/smpro-errmon.c new file +1
-0@@ -0,0 +1,477 @@ +// SPDX-License-Identifier: GPL-2.0+ Are you sure you mean "or any later version"? I have to ask.
drivers/misc/smpro-errmon.c line 139
Quoted 13 lines
drivers/misc/smpro-errmon.c new file +13
-0+static struct smpro_int_error_hdr list_smpro_int_error_hdr[2 ] = { + { +ERR_SMPRO_TYPE , +ERR_SMPRO_INFO_LO ,ERR_SMPRO_INFO_HI , +ERR_SMPRO_DATA_LO ,ERR_SMPRO_DATA_HI , +WARN_SMPRO_INFO_LO ,WARN_SMPRO_INFO_HI + }, + { +ERR_PMPRO_TYPE , +ERR_PMPRO_INFO_LO ,ERR_PMPRO_INFO_HI , +ERR_PMPRO_DATA_LO ,ERR_PMPRO_DATA_HI , +WARN_PMPRO_INFO_LO ,WARN_PMPRO_INFO_HI + },Odd indentation, checkpatch did not complain?
drivers/misc/smpro-errmon.c line 170
Quoted 11 lines
drivers/misc/smpro-errmon.c new file +11
-0+static ssize_t smpro_event_data_read (struct device *dev, +struct device_attribute *da,char *buf, +int channel) +{ +struct smpro_errmon *errmon =dev_get_drvdata (dev); +s32 event_data; +int ret; + + ret =regmap_read (errmon->regmap, smpro_event_table[channel], &event_data); +if (ret) + goto done;Just return the error here.
drivers/misc/smpro-errmon.c line 27
Quoted 2 lines
drivers/misc/smpro-errmon.c new file +2
-0+ + ret =sysfs_emit (buf,"%02x%04x\n" , channel, event_data);sysfs rules are one value per file. You know this.
drivers/misc/smpro-errmon.c line 174
Quoted 2 lines
drivers/misc/smpro-errmon.c new file +2
-0+/* Clear event after read */ +if (event_data !=0 )Why would it be 0? Isn't 0 a valid value?
Quoted 30 lines
drivers/misc/smpro-errmon.c new file +30
-0+regmap_write (errmon->regmap, smpro_event_table[channel], event_data); +done: +return ret; +} + +static ssize_t smpro_overflow_data_read (struct device *dev,struct device_attribute *da, +char *buf,int channel) +{ +struct smpro_errmon *errmon =dev_get_drvdata (dev); +struct smpro_error_hdr *err_info; +s32 err_count; +int ret; + + err_info = &smpro_error_table[channel]; + + ret =regmap_read (errmon->regmap, err_info->err_count, &err_count); +if (ret) +return ret; + +/* Bit 8 indicates the overflow status */ +return sysfs_emit (buf,"%d\n" , (err_count &BIT (8 )) ?1 :0 ); +} + +static ssize_t smpro_error_data_read (struct device *dev,struct device_attribute *da, +char *buf,int channel) +{ +struct smpro_errmon *errmon =dev_get_drvdata (dev); +unsigned char err_data[MAX_READ_BLOCK_LENGTH ]; +struct smpro_error_hdr *err_info; +s32 err_count, err_length;drivers/misc/smpro-errmon.c line 214
Quoted 10 lines
drivers/misc/smpro-errmon.c new file +10
-0+int count =0 ; +int ret; + + err_info = &smpro_error_table[channel]; + + ret =regmap_read (errmon->regmap, err_info->err_count, &err_count); +/* Error count is the low byte */ + err_count &=0xff ; +if (ret || !err_count || err_count > err_info->max_err_cnt) + goto done;Just return the error.
drivers/misc/smpro-errmon.c line 218
Quoted 4 lines
drivers/misc/smpro-errmon.c new file +4
-0+ + ret =regmap_read (errmon->regmap, err_info->err_len, &err_length); +if (ret || err_length <=0 ) + goto done;return the error.
Wait, you could return 0 here, are you sure about that?
drivers/misc/smpro-errmon.c line 226
Quoted 8 lines
drivers/misc/smpro-errmon.c new file +8
-0+ +if (err_length >MAX_READ_BLOCK_LENGTH ) + err_length =MAX_READ_BLOCK_LENGTH ; + +memset (err_data,0x00 ,MAX_READ_BLOCK_LENGTH ); + ret =regmap_noinc_read (errmon->regmap, err_info->err_data, err_data, err_length); +if (ret <0 ) + goto done;return the error, no need for a goto in this function.
Quoted 50 lines
drivers/misc/smpro-errmon.c new file +50
-0+ +/* +* The output of Core/Memory/PCIe/Others UE/CE errors follows below format: +* <Error Type><Error SubType><Instance><Error Status>\ +* <Error Address><Error Misc 0><Error Misc 1><Error Misc2><Error Misc 3> +* Where: +* + Error Type: The hardwares cause the errors. (1 byte) +* + SubType: Sub type of error in the specified hardware error. (1 byte) +* + Instance: Combination of the socket, channel, +* slot cause the error. (2 bytes) +* + Error Status: Encode of error status. (4 bytes) +* + Error Address: The address in device causes the errors. (8 bytes) +* + Error Misc 0/1/2/3: Addition info about the errors. (8 bytes for each) +* Reference Altra SOC BMC Interface specification. +*/ + count =sysfs_emit (buf,"%02x%02x%04x%08x%016llx%016llx%016llx%016llx%016llx\n" , + err_data[0 ], err_data[1 ], *(u16 *)&err_data[2 ], + *(u32 *)&err_data[4 ], *(u64 *)&err_data[8 ], + *(u64 *)&err_data[16 ], *(u64 *)&err_data[24 ], + *(u64 *)&err_data[32 ], *(u64 *)&err_data[40 ]); + +/* go to next error */ + ret =regmap_write (errmon->regmap, err_info->err_count,0x100 ); +done: +return ret ? ret : count; +} + +/* +* Output format: +* <errType><image><dir><Location><errorCode><data> +* Where: +* + errType: SCP Error Type (3 bits) +* 1: Warning +* 2: Error +* 4: Error with data +* + image: SCP Image Code (8 bits) +* + dir: Direction (1 bit) +* 0: Enter +* 1: Exit +* + location: SCP Module Location Code (8 bits) +* + errorCode: SCP Error Code (16 bits) +* + data : Extensive data (32 bits) +* All bits are 0 when errType is warning or error. +*/ +static ssize_t smpro_internal_err_read (struct device *dev,struct device_attribute *da, +char *buf,int channel) +{ +struct smpro_errmon *errmon =dev_get_drvdata (dev); +struct smpro_int_error_hdr *err_info; +unsigned int data_lo =0 , data_hi =0 ;drivers/misc/smpro-errmon.c line 286
Quoted 10 lines
drivers/misc/smpro-errmon.c new file +10
-0+unsigned int ret_hi, ret_lo; +unsigned int err_type; +unsigned int value; +int count =0 ; +int ret; + +/* read error status */ + ret =regmap_read (errmon->regmap,GPI_RAS_ERR , &value); +if (ret) + goto done;Same mess here, just return the error.
drivers/misc/smpro-errmon.c line 290
Quoted 4 lines
drivers/misc/smpro-errmon.c new file +4
-0+ +if (!((channel ==RAS_SMPRO_ERRS && (value &BIT (0 ))) || + (channel ==RAS_PMPRO_ERRS && (value &BIT (1 ))))) + goto done;No error? Are you sure?
Quoted 35 lines
drivers/misc/smpro-errmon.c new file +35
-0+ + err_info = &list_smpro_int_error_hdr[channel]; + ret =regmap_read (errmon->regmap, err_info->err_type, &err_type); +if (ret) + goto done; + + ret =regmap_read (errmon->regmap, err_info->err_info_low, &ret_lo); +if (ret) + goto done; + + ret =regmap_read (errmon->regmap, err_info->err_info_high, &ret_hi); +if (ret) + goto done; + +if (err_type &BIT (2 )) { +/* Error with data type */ + ret =regmap_read (errmon->regmap, err_info->err_data_low, &data_lo); +if (ret) + goto done; + + ret =regmap_read (errmon->regmap, err_info->err_data_high, &data_hi); +if (ret) + goto done; + + count =sysfs_emit (buf,"%01x%02x%01x%02x%04x%04x%04x\n" , +4 , (ret_hi &0xf000 ) >>12 , (ret_hi &0x0800 ) >>11 , + ret_hi &0xff , ret_lo, data_hi, data_lo); +/* clear the read errors */ + ret =regmap_write (errmon->regmap, err_info->err_type,BIT (2 )); + + }else if (err_type &BIT (1 )) { +/* Error type */ + count =sysfs_emit (buf,"%01x%02x%01x%02x%04x%04x%04x\n" , +2 , (ret_hi &0xf000 ) >>12 , (ret_hi &0x0800 ) >>11 , + ret_hi &0xff , ret_lo, data_hi, data_lo);
Quoted 8 lines
drivers/misc/smpro-errmon.c line 333
Quoted 8 lines
drivers/misc/smpro-errmon.c new file +8
-0+/* clear the read errors */ + ret =regmap_write (errmon->regmap, err_info->err_type,BIT (1 )); + + }else if (err_type &BIT (0 )) { +/* Warning type */ + count =sysfs_emit (buf,"%01x%02x%01x%02x%04x%04x%04x\n" , +1 , (ret_hi &0xf000 ) >>12 , (ret_hi &0x0800 ) >>11 , + ret_hi &0xff , ret_lo, data_hi, data_lo);
Hi Greg,
Since the internal representation of the internal error is split into high low chunks of the info and data values which need to be communicated atomicly, I'm treating them as "one value" here. I could dump them in a temporary array and print that, but it seems like additional complexity for the same result. Can we consider this concatenated encoding as "an array of the same type" for the purposes of this driver?"
Thanks,
- Quan
Greg Kroah-Hartman
maintainerRe: [PATCH v8 3/9] misc: smpro-errmon: Add Ampere's SMpro error monitor driver
Quoted 32 lines · Quan Nguyen
Quoted 21 lines
Quoted 21 lines
drivers/misc/smpro-errmon.c new file +21
-0+if (err_type &BIT (2 )) { +/* Error with data type */ + ret =regmap_read (errmon->regmap, err_info->err_data_low, &data_lo); +if (ret) + goto done; + + ret =regmap_read (errmon->regmap, err_info->err_data_high, &data_hi); +if (ret) + goto done; + + count =sysfs_emit (buf,"%01x%02x%01x%02x%04x%04x%04x\n" , +4 , (ret_hi &0xf000 ) >>12 , (ret_hi &0x0800 ) >>11 , + ret_hi &0xff , ret_lo, data_hi, data_lo); +/* clear the read errors */ + ret =regmap_write (errmon->regmap, err_info->err_type,BIT (2 )); + + }else if (err_type &BIT (1 )) { +/* Error type */ + count =sysfs_emit (buf,"%01x%02x%01x%02x%04x%04x%04x\n" , +2 , (ret_hi &0xf000 ) >>12 , (ret_hi &0x0800 ) >>11 , + ret_hi &0xff , ret_lo, data_hi, data_lo);Quoted 8 lines
drivers/misc/smpro-errmon.c line 333
Quoted 8 lines
drivers/misc/smpro-errmon.c new file +8
-0+/* clear the read errors */ + ret =regmap_write (errmon->regmap, err_info->err_type,BIT (1 )); + + }else if (err_type &BIT (0 )) { +/* Warning type */ + count =sysfs_emit (buf,"%01x%02x%01x%02x%04x%04x%04x\n" , +1 , (ret_hi &0xf000 ) >>12 , (ret_hi &0x0800 ) >>11 , + ret_hi &0xff , ret_lo, data_hi, data_lo);Hi Greg,
Quoted 3 lines
Since the internal representation of the internal error is split into high low chunks of the info and data values which need to be communicated atomicly, I'm treating them as "one value" here.
That is a huge "one value", that's not what this really is, it needs to be parsed by userspace, right?
And why does this have to be atomic? What happens if the values change right after you read them? What is userspace going to do with them?
Quoted 4 lines
I could dump them in a
temporary array and print that, but it seems like additional complexity for the same result. Can we consider this concatenated encoding as "an array of the same type" for the purposes of this driver?"
That's really not a good idea as sysfs files should never need to be "parsed" like this.
Again, what are you trying to do here, and why does it have to be atomic?
thanks,
greg k-h
Re: [PATCH v8 3/9] misc: smpro-errmon: Add Ampere's SMpro error monitor driver
Quoted 33 lines · Greg Kroah-Hartman
Quoted 32 lines · Quan Nguyen
Quoted 21 lines
Quoted 21 lines
drivers/misc/smpro-errmon.c new file +21
-0+if (err_type &BIT (2 )) { +/* Error with data type */ + ret =regmap_read (errmon->regmap, err_info->err_data_low, &data_lo); +if (ret) + goto done; + + ret =regmap_read (errmon->regmap, err_info->err_data_high, &data_hi); +if (ret) + goto done; + + count =sysfs_emit (buf,"%01x%02x%01x%02x%04x%04x%04x\n" , +4 , (ret_hi &0xf000 ) >>12 , (ret_hi &0x0800 ) >>11 , + ret_hi &0xff , ret_lo, data_hi, data_lo); +/* clear the read errors */ + ret =regmap_write (errmon->regmap, err_info->err_type,BIT (2 )); + + }else if (err_type &BIT (1 )) { +/* Error type */ + count =sysfs_emit (buf,"%01x%02x%01x%02x%04x%04x%04x\n" , +2 , (ret_hi &0xf000 ) >>12 , (ret_hi &0x0800 ) >>11 , + ret_hi &0xff , ret_lo, data_hi, data_lo);Quoted 8 lines
drivers/misc/smpro-errmon.c line 333
Quoted 8 lines
drivers/misc/smpro-errmon.c new file +8
-0+/* clear the read errors */ + ret =regmap_write (errmon->regmap, err_info->err_type,BIT (1 )); + + }else if (err_type &BIT (0 )) { +/* Warning type */ + count =sysfs_emit (buf,"%01x%02x%01x%02x%04x%04x%04x\n" , +1 , (ret_hi &0xf000 ) >>12 , (ret_hi &0x0800 ) >>11 , + ret_hi &0xff , ret_lo, data_hi, data_lo);Hi Greg,
Quoted 7 lines
Quoted 3 lines
Since the internal representation of the internal error is split into high low chunks of the info and data values which need to be communicated atomicly, I'm treating them as "one value" here.
That is a huge "one value", that's not what this really is, it needs to be parsed by userspace, right?
Thanks Greg for the review,
User space needs all of this "one value" to know what exactly is the error.
In our latest version, we remove all the if...else and simplify the code as below:
/*
* The internal representation of the internal error is split into high
* low chunks of the info and data values. Rather than temporarily
* dumping these into an array and printing that, skip the intermediate
* step and print them using a concatenation encoding.
*/
count = sysfs_emit(buf, "%04x%04x%04x%04x\n", info_h, info_l, data_h, data_l);
/* clear the read error */
ret = regmap_write(errmon->regmap, err_info->type, err_type); return ret ? ret : count;
Quoted 3 lines
And why does this have to be atomic? What happens if the values change right after you read them? What is userspace going to do with them?
Because the error is bigger than single register can hold so it is split into small chunks to report via multiple separate registers.
Firmware stores each error in a queue. As the error's chunks are stored in separate registers. All of these registers will need to be read out before the error is clear so that the next error in the queue can be reported. That is why we say those chunks must be read out atomically.
User space will need to parse these information themself.
Quoted 13 lines
Quoted 4 lines
I could dump them in a
temporary array and print that, but it seems like additional complexity for the same result. Can we consider this concatenated encoding as "an array of the same type" for the purposes of this driver?"That's really not a good idea as sysfs files should never need to be "parsed" like this.
Quoted 1 line
Again, what are you trying to do here, and why does it have to be
atomic?
thanks,
greg k-h
PATCH v8 4/9 docs: misc-devices: (smpro-errmon) Add documentation
In reply to Quan NguyenAdds documentation for Ampere(R)'s Altra(R) SMpro errmon driver.
---
Changes in v8:
+ Update to reflect single value per sysfs [Quan]
Changes in v7:
+ None
Changes in v6:
+ First introduced in v6 [Quan]
Documentation/misc-devices/index.rst | 1 + Documentation/misc-devices/smpro-errmon.rst | 198 ++++++++++++++++++++ 2 files changed, 199 insertions(+) create mode 100644 Documentation/misc-devices/smpro-errmon.rst
Documentation/misc-devices/index.rst +1 -0
@@ -26,6 +26,7 @@ fit into other categories. lis3lv02d max6875 pci-endpoint-test + smpro-errmon spear-pcie-gadget uacce xilinx_sdfec
Documentation/misc-devices/smpro-errmon.rst new file +198 -0
198 lines not on this page · raw message
Signature · 1 line
2.35.1
Re: [PATCH v8 4/9] docs: misc-devices: (smpro-errmon) Add documentation
Quoted 2 lines · Quan Nguyen
Adds documentation for Ampere(R)'s Altra(R) SMpro errmon driver.
Hi Quan,
Building htmldocs, I got this new warning:
/home/bagas/repo/linux-stable/Documentation/misc-devices/smpro-errmon.rst:128: WARNING: Malformed table. Column span alignment problem in table line 56.
============ ========== ========= =============== ================ Error Group Error Type Sub type Sub component Instance CPM 0 0 Snoop-Logic CPM # CPM 0 2 Armv8 Core 1 CPM # MCU 1 1 ERR1 MCU # | SLOT << 11 MCU 1 2 ERR2 MCU # | SLOT << 11 MCU 1 3 ERR3 MCU # MCU 1 4 ERR4 MCU # MCU 1 5 ERR5 MCU # MCU 1 6 ERR6 MCU # MCU 1 7 Link Error MCU # Mesh 2 0 Cross Point X | (Y << 5) | NS <<11 Mesh 2 1 Home Node(IO) X | (Y << 5) | NS <<11 Mesh 2 2 Home Node(Mem) X | (Y << 5) | NS <<11 | device<<12 Mesh 2 4 CCIX Node X | (Y << 5) | NS <<11 2P Link 3 0 N/A Altra 2P Link # GIC 5 0 ERR0 0 GIC 5 1 ERR1 0 GIC 5 2 ERR2 0 GIC 5 3 ERR3 0 GIC 5 4 ERR4 0 GIC 5 5 ERR5 0 GIC 5 6 ERR6 0 GIC 5 7 ERR7 0 GIC 5 8 ERR8 0 GIC 5 9 ERR9 0 GIC 5 10 ERR10 0 GIC 5 11 ERR11 0 GIC 5 12 ERR12 0 GIC 5 13-21 ERR13 RC# + 1 SMMU 6 TCU 100 RC # SMMU 6 TBU0 0 RC # SMMU 6 TBU1 1 RC # SMMU 6 TBU2 2 RC # SMMU 6 TBU3 3 RC # SMMU 6 TBU4 4 RC # SMMU 6 TBU5 5 RC # SMMU 6 TBU6 6 RC # SMMU 6 TBU7 7 RC # SMMU 6 TBU8 8 RC # SMMU 6 TBU9 9 RC # PCIe AER 7 Root 0 RC # PCIe AER 7 Device 1 RC # PCIe RC 8 RCA HB 0 RC # PCIe RC 8 RCB HB 1 RC # PCIe RC 8 RASDP 8 RC # OCM 9 ERR0 0 0 OCM 9 ERR1 1 0 OCM 9 ERR2 2 0 SMpro 10 ERR0 0 0 SMpro 10 ERR1 1 0 SMpro 10 MPA_ERR 2 0 PMpro 11 ERR0 0 0 PMpro 11 ERR1 1 0 PMpro 11 MPA_ERR 2 0 ============= ========== ========= =============== ================
I have applied the following fixup:
From f16c63afa2064247507762ffcb623f575043f4a6 Mon Sep 17 00:00:00 2001
From: Bagas Sanjaya <[email protected]>
Date: Fri, 22 Apr 2022 13:16:31 +0700
Subject: [PATCH] fixup for "docs: misc-devices: (smpro-errmon) Add
documentation"
Fix table syntax warning
--- Documentation/misc-devices/smpro-errmon.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/misc-devices/smpro-errmon.rst +3 -2
@@ -70,8 +70,9 @@ The format of the error lines is defended on the alert/event type. Below table defines the value of Error types, Sub Types, Sub component and instance: - ============ ========== ========= =============== ================ + ============ ========== ========= =============== ==================================== Error Group Error Type Sub type Sub component Instance + ============ ========== ========= =============== ==================================== CPM 0 0 Snoop-Logic CPM # CPM 0 2 Armv8 Core 1 CPM # MCU 1 1 ERR1 MCU # | SLOT << 11
@@ -125,7 +126,7 @@ Below table defines the value of Error types, Sub Types, Sub component and insta PMpro 11 ERR0 0 0 PMpro 11 ERR1 1 0 PMpro 11 MPA_ERR 2 0 - ============= ========== ========= =============== ================ + ============ ========== ========= =============== ==================================== 2) Type 2 for the Internal SMpro/PMpro alert types::
Signature · 10 lines
An old man doll... just what I always wanted! - Clara For consistency with the fixup, you need to format the tables so that headings will be emphasized, by adding second ='s line before first content row. Thanks. -- An old man doll... just what I always wanted! - Clara
PATCH v8 5/9 misc: smpro-misc: Add Ampere's Altra SMpro misc driver
In reply to Quan NguyenThis commit adds driver support for accessing various information reported by Ampere's SMpro co-processor such as Boot Progress and other miscellaneous data.
---
Changes in v8:
+ Update wording for SMPRO_MISC in Kconfig file [Quan]
+ Switch to use sysfs_emit() [Quan]
Changes in v7:
+ Fix wrong return type of *_show/store()
functions [kernel robot test]
+ Adjust patch order to remove dependence with
smpro-mfd [Lee Jones]
Changes in v6:
+ First introduced in v6 [Quan]
drivers/misc/Kconfig | 10 +++ drivers/misc/Makefile | 1 + drivers/misc/smpro-misc.c | 161 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 172 insertions(+) create mode 100644 drivers/misc/smpro-misc.c
drivers/misc/Kconfig +10 -0
@@ -188,6 +188,16 @@ config SMPRO_ERRMON To compile this driver as a module, say M here. The driver will be called smpro-errmon. +config SMPRO_MISC + tristate "Ampere Computing SMPro miscellaneous driver" + depends on MFD_SMPRO || COMPILE_TEST + help + Say Y here to get support for the SMpro error miscellalenous function + provided by Ampere Computing's Altra and Altra Max SoCs. + + To compile this driver as a module, say M here. The driver will be + called smpro-misc. + config CS5535_MFGPT tristate "CS5535/CS5536 Geode Multi-Function General Purpose Timer (MFGPT) support" depends on MFD_CS5535
drivers/misc/Makefile +1 -0
@@ -24,6 +24,7 @@ obj-$(CONFIG_KGDB_TESTS) += kgdbts.o obj-$(CONFIG_SGI_XP) += sgi-xp/ obj-$(CONFIG_SGI_GRU) += sgi-gru/ obj-$(CONFIG_SMPRO_ERRMON) += smpro-errmon.o +obj-$(CONFIG_SMPRO_MISC) += smpro-misc.o obj-$(CONFIG_CS5535_MFGPT) += cs5535-mfgpt.o obj-$(CONFIG_GEHC_ACHC) += gehc-achc.o obj-$(CONFIG_HP_ILO) += hpilo.o
drivers/misc/smpro-misc.c new file +161 -0
161 lines not on this page · raw message
Signature · 1 line
2.35.1
PATCH v8 6/9 docs: misc-devices: (smpro-misc) Add documentation
In reply to Quan NguyenAdds documentation for the Ampere(R)'s Altra(R) SMpro misc driver.
---
Changes in v8:
+ Update to reflect single value per sysfs [Quan]
Changes in v7:
+ None
Changes in v6:
+ First introduced in v6 [Quan]
Documentation/misc-devices/index.rst | 1 + Documentation/misc-devices/smpro-misc.rst | 82 +++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 Documentation/misc-devices/smpro-misc.rst
Documentation/misc-devices/index.rst +1 -0
@@ -27,6 +27,7 @@ fit into other categories. max6875 pci-endpoint-test smpro-errmon + smpro-misc spear-pcie-gadget uacce xilinx_sdfec
Documentation/misc-devices/smpro-misc.rst new file +82 -0
82 lines not on this page · raw message
Signature · 1 line
2.35.1
PATCH v8 7/9 dt-bindings: mfd: Add bindings for Ampere Altra SMPro MFD driver
In reply to Quan NguyenAdds device tree bindings for SMPro MFD driver found on the Mt.Jade hardware reference platform with Ampere's Altra Processor family.
The SMpro co-processor on Ampere Altra processor family is to monitor and report various data included hwmon-related info, RAS errors, and other miscellaneous information.
---
Changes in v8:
+ Removed unused #*_cells [Krzysztof]
Changes in v7:
+ None
Changes in v6:
+ None
.../devicetree/bindings/mfd/ampere,smpro.yaml | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/ampere,smpro.yaml
Documentation/devicetree/bindings/mfd/ampere,smpro.yaml new file +42 -0
@@ -0,0 +1,42 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/ampere,smpro.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Ampere Altra SMPro firmware driver + +maintainers: + - Quan Nguyen <[email protected]> + +description: | + Ampere Altra SMPro firmware may contain different blocks like hardware + monitoring, error monitoring and other miscellaneous features. + +properties: + compatible: + enum: + - ampere,smpro + + reg: + description: + I2C device address. + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + smpro@4f { + compatible = "ampere,smpro"; + reg = <0x4f>; + }; + };
Signature · 1 line
2.35.1
PATCH v8 8/9 mfd: smpro-mfd: Adds Ampere's Altra SMpro MFD driver
In reply to Quan NguyenAdds Multi-function devices driver for SMpro co-processor found on the Mt.Jade hardware reference platform with Ampere's Altra processor family.
---
Changes in v8:
+ None
Changes in v7:
+ Smpro-mfd now significant changes in compare with simple-mfd-i2c
driver, remove the copyright note about simple-mfd-i2c [Quan]
+ Install bus->read/write() to handle multiple types of bus
access. [Quan]
+ Update license to MODULE_LICENSE("GPL") [Quan]
+ Add others minor refactor the code [Quan]Changes in v6:
+ Update license part to reflect that this driver is clone from simple-mfd-i2c driver [Quan]
Changes in v5:
+ Dropped the use of simple-mfd-i2c driver [Quan]
+ Introduced drivers/mfd/smpro-mfd.c driver to instantiate sub-devices. This is to avoid DT nodes without resource issue [Quan]
+ Revised commit message [Quan]
Changes in v4:
+ Add "depends on I2C" to fix build issue found by kernel test robot [Guenter]
Changes in v3:
+ None
Changes in v2:
+ Used 'struct of_device_id's .data attribute [Lee Jones]
drivers/mfd/Kconfig | 12 ++++ drivers/mfd/Makefile | 1 + drivers/mfd/smpro-mfd.c | 134 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 drivers/mfd/smpro-mfd.c
drivers/mfd/Kconfig +12 -0
@@ -77,6 +77,18 @@ config MFD_AS3711 help Support for the AS3711 PMIC from AMS +config MFD_SMPRO + tristate "Ampere Computing MFD SMpro core driver" + depends on I2C + select MFD_CORE + select REGMAP_I2C + help + Say yes here to enable SMpro driver support for Ampere's Altra + processor family. + + Ampere's Altra SMpro exposes an I2C regmap interface that can + be accessed by child devices. + config MFD_AS3722 tristate "ams AS3722 Power Management IC" select MFD_CORE
drivers/mfd/Makefile +1 -0
@@ -266,6 +266,7 @@ obj-$(CONFIG_MFD_QCOM_PM8008) += qcom-pm8008.o obj-$(CONFIG_SGI_MFD_IOC3) += ioc3.o obj-$(CONFIG_MFD_SIMPLE_MFD_I2C) += simple-mfd-i2c.o +obj-$(CONFIG_MFD_SMPRO) += smpro-mfd.o obj-$(CONFIG_MFD_INTEL_M10_BMC) += intel-m10-bmc.o obj-$(CONFIG_MFD_ATC260X) += atc260x-core.o
drivers/mfd/smpro-mfd.c new file +134 -0
134 lines not on this page · raw message
Signature · 1 line
2.35.1
kernel test robot
build botRe: [PATCH v8 8/9] mfd: smpro-mfd: Adds Ampere's Altra SMpro MFD driver
I love your patch! Perhaps something to improve:
Hi Quan,
I love your patch! Perhaps something to improve:
[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on groeck-staging/hwmon-next lee-mfd/for-mfd-next v5.18-rc3 next-20220422] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/Quan-Nguyen/Add-Ampere-s-Altra-SMPro-MFD-and-its-child-drivers/20220422-105732 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git c50c29a806113614098efd8da9fd7b48d605ba45 config: arm-randconfig-r004-20220422 (https://download.01.org/0day-ci/archive/20220423/[email protected]/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 5bd87350a5ae429baf8f373cb226a57b62f87280)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/intel-lab-lkp/linux/commit/09ec873f0dd4611cb2df0150923d8906b9c5b2d1
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Quan-Nguyen/Add-Ampere-s-Altra-SMPro-MFD-and-its-child-drivers/20220422-105732 git checkout 09ec873f0dd4611cb2df0150923d8906b9c5b2d1
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash arch/arm/mach-at91/ drivers/hwmon/
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> drivers/hwmon/smpro-hwmon.c:376:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
default:
^
drivers/hwmon/smpro-hwmon.c:376:3: note: insert 'break;' to avoid fall-through
default:
^
break; 1 warning generated.
vim +376 drivers/hwmon/smpro-hwmon.c
e1354080fc83378 Quan Nguyen 2022-04-22 359
e1354080fc83378 Quan Nguyen 2022-04-22 360 static umode_t smpro_is_visible(const void *data, enum hwmon_sensor_types type,
e1354080fc83378 Quan Nguyen 2022-04-22 361 u32 attr, int channel)
e1354080fc83378 Quan Nguyen 2022-04-22 362 {
e1354080fc83378 Quan Nguyen 2022-04-22 363 const struct smpro_hwmon *hwmon = data;
e1354080fc83378 Quan Nguyen 2022-04-22 364 unsigned int value;
e1354080fc83378 Quan Nguyen 2022-04-22 365 int ret;
e1354080fc83378 Quan Nguyen 2022-04-22 366
e1354080fc83378 Quan Nguyen 2022-04-22 367 switch (type) {
e1354080fc83378 Quan Nguyen 2022-04-22 368 case hwmon_temp:
e1354080fc83378 Quan Nguyen 2022-04-22 369 switch (attr) {
e1354080fc83378 Quan Nguyen 2022-04-22 370 case hwmon_temp_input:
e1354080fc83378 Quan Nguyen 2022-04-22 371 case hwmon_temp_label:
e1354080fc83378 Quan Nguyen 2022-04-22 372 case hwmon_temp_crit:
e1354080fc83378 Quan Nguyen 2022-04-22 373 ret = regmap_read(hwmon->regmap, temperature[channel].reg, &value);
e1354080fc83378 Quan Nguyen 2022-04-22 374 if (ret || value == 0xFFFF)
e1354080fc83378 Quan Nguyen 2022-04-22 375 return 0;
e1354080fc83378 Quan Nguyen 2022-04-22 @376 default:
e1354080fc83378 Quan Nguyen 2022-04-22 377 break;
e1354080fc83378 Quan Nguyen 2022-04-22 378 }
e1354080fc83378 Quan Nguyen 2022-04-22 379 break;
e1354080fc83378 Quan Nguyen 2022-04-22 380 default:
e1354080fc83378 Quan Nguyen 2022-04-22 381 break;
e1354080fc83378 Quan Nguyen 2022-04-22 382 }
e1354080fc83378 Quan Nguyen 2022-04-22 383
e1354080fc83378 Quan Nguyen 2022-04-22 384 return 0444;
e1354080fc83378 Quan Nguyen 2022-04-22 385 }
e1354080fc83378 Quan Nguyen 2022-04-22 386 Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
Re: [PATCH v8 8/9] mfd: smpro-mfd: Adds Ampere's Altra SMpro MFD driver
In reply to Quan NguyenQuoted 1 line · Quan Nguyen
Adds Multi-function devices driver for SMpro co-processor found on the
Please drop the term MFD and describe the device instead.
Quoted 32 lines
Mt.Jade hardware reference platform with Ampere's Altra processor family.
Signed-off-by Quan Nguyen <[email protected]>---
Changes in v8:
+ NoneChanges in v7:
+ Smpro-mfd now significant changes in compare with simple-mfd-i2c
driver, remove the copyright note about simple-mfd-i2c [Quan]
+ Install bus->read/write() to handle multiple types of busaccess. [Quan] + Update license to MODULE_LICENSE("GPL") [Quan] + Add others minor refactor the code [Quan]Changes in v6:
+ Update license part to reflect that this driver is clone from simple-mfd-i2c driver [Quan]Changes in v5:
+ Dropped the use of simple-mfd-i2c driver [Quan]
+ Introduceddrivers/mfd/smpro-mfd.cdriver to instantiate sub-devices. This is to avoid DT nodes without resource issue [Quan]
+ Revised commit message [Quan]Changes in v4:
+ Add "depends on I2C" to fix build issue found by kernel test robot [Guenter]Changes in v3:
+ None
Quoted 6 lines
Changes in v2:
+ Used 'struct of_device_id's .data attribute [Lee Jones]drivers/mfd/Kconfig | 12 ++++ drivers/mfd/Makefile | 1 + drivers/mfd/smpro-mfd.c | 134 ++++++++++++++++++++++++++++++++++++++++
Please drop the 'mfd' part. Does 'core' work instead?
drivers/mfd/Kconfig config MFD_AS3711 · line 81
Quoted 13 lines
3 files changed, 147 insertions(+) create mode 100644 drivers/mfd/smpro-mfd.cdrivers/mfd/Kconfig +2
-0@@ -77,6 +77,18 @@ config MFD_AS3711 help Support for the AS3711 PMIC from AMS +config MFD_SMPRO + tristate "Ampere Computing MFD SMpro core driver"
Drop 'MFD'.
Quoted 31 lines
drivers/mfd/Kconfig +10
-0+ depends on I2C + select MFD_CORE + select REGMAP_I2C + help + Say yes here to enable SMpro driver support for Ampere's Altra + processor family. + + Ampere's Altra SMpro exposes an I2C regmap interface that can + be accessed by child devices. + config MFD_AS3722 tristate "ams AS3722 Power Management IC" select MFD_COREdrivers/mfd/Makefile +1
-0@@ -266,6 +266,7 @@ obj-$(CONFIG_MFD_QCOM_PM8008) += qcom-pm8008.o obj-$(CONFIG_SGI_MFD_IOC3) += ioc3.o obj-$(CONFIG_MFD_SIMPLE_MFD_I2C) += simple-mfd-i2c.o +obj-$(CONFIG_MFD_SMPRO) += smpro-mfd.o obj-$(CONFIG_MFD_INTEL_M10_BMC) += intel-m10-bmc.o obj-$(CONFIG_MFD_ATC260X) += atc260x-core.odrivers/mfd/smpro-mfd.c new file +0
-0
drivers/mfd/smpro-mfd.c line 3
Quoted 3 lines
drivers/mfd/smpro-mfd.c new file +3
-0@@ -0,0 +1,134 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Ampere Altra Family SMPro MFD - I2C
Drop 'MFD' throughout.
drivers/mfd/smpro-mfd.c line 14
Quoted 10 lines
drivers/mfd/smpro-mfd.c new file +10
-0+* Copyright (c) 2022, Ampere Computing LLC +* Author: Quan Nguyen <[email protected]> +*/ + +#include <linux/i2c.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of_platform.h> +#include <linux/mfd/core.h> +#include <linux/regmap.h>
Alphabetical.
Quoted 39 lines
drivers/mfd/smpro-mfd.c new file +39
-0+/* Identification Registers */ +#define MANUFACTURER_ID_REG 0x02 +#define AMPERE_MANUFACTURER_ID 0xCD3A + +static int smpro_mfd_write (void *context,const void *data,size_t count) +{ +struct device *dev = context; +struct i2c_client *i2c =to_i2c_client (dev); +int ret; + + ret =i2c_master_send (i2c, data, count); +if (ret == count) +return 0 ; +else if (ret <0 ) +return ret; +else +return -EIO ; +} + +static int smpro_mfd_read (void *context,const void *reg,size_t reg_size, +void *val,size_t val_size) +{ +struct device *dev = context; +struct i2c_client *i2c =to_i2c_client (dev); +struct i2c_msg xfer[2 ]; +unsigned char buf[2 ]; +int ret; + + xfer[0 ].addr = i2c->addr; + xfer[0 ].flags =0 ; + + buf[0 ] = *(u8 *)reg; + buf[1 ] = val_size; + xfer[0 ].len =2 ; + xfer[0 ].buf = buf; + + xfer[1 ].addr = i2c->addr; + xfer[1 ].flags =I2C_M_RD ; + xfer[1 ].len = val_size;
drivers/mfd/smpro-mfd.c line 64
Quoted 10 lines
drivers/mfd/smpro-mfd.c new file +10
-0+ xfer[1 ].buf = val; + + ret =i2c_transfer (i2c->adapter, xfer,2 ); +if (ret ==2 ) +return 0 ; +else if (ret <0 ) +return ret; +else +return -EIO ; +}
This looks all too familiar.
I wonder how generic these i2c call-backs actually are.
drivers/mfd/smpro-mfd.c line 75
Quoted 10 lines
drivers/mfd/smpro-mfd.c new file +10
-0+static const struct regmap_bus smpro_regmap_bus = { + .read = smpro_mfd_read, + .write = smpro_mfd_write, + .val_format_endian_default =REGMAP_ENDIAN_BIG , +}; + +static bool smpro_mfd_readable_noinc_reg (struct device *dev,unsigned int reg) +{ +return (reg ==0x82 || reg ==0x85 || reg ==0x92 || reg ==0x95 || + reg ==0xC2 || reg ==0xC5 || reg ==0xD2 || reg ==0xDA );
No magic numbers. Please define these registers.
Quoted 14 lines
drivers/mfd/smpro-mfd.c new file +14
-0+} + +static const struct regmap_config smpro_regmap_config = { + .reg_bits =8 , + .val_bits =16 , + .readable_noinc_reg = smpro_mfd_readable_noinc_reg, +}; + +static const struct mfd_cell smpro_devs[] = { +MFD_CELL_NAME ("smpro-hwmon" ), +MFD_CELL_NAME ("smpro-errmon" ), +MFD_CELL_NAME ("smpro-misc" ), +}; +
drivers/mfd/smpro-mfd.c line 99
Quoted 10 lines
drivers/mfd/smpro-mfd.c new file +10
-0+static int smpro_mfd_probe (struct i2c_client *i2c) +{ +const struct regmap_config *config; +struct regmap *regmap; +unsigned int val; +int ret; + + config =device_get_match_data (&i2c->dev); +if (!config) + config = &smpro_regmap_config;
This use-case is not currently supported.
Please return an error instead.
drivers/mfd/smpro-mfd.c line 105
Quoted 5 lines
drivers/mfd/smpro-mfd.c new file +5
-0+ regmap =devm_regmap_init (&i2c->dev, &smpro_regmap_bus, &i2c->dev, config); +if (IS_ERR (regmap)) +return PTR_ERR (regmap); + +/* Check for valid ID */
Decent #define nomenclature should render this comment superfluous.
Quoted 11 lines
drivers/mfd/smpro-mfd.c new file +11
-0+ ret =regmap_read (regmap,MANUFACTURER_ID_REG , &val); +if (ret) +return ret; + +if (val !=AMPERE_MANUFACTURER_ID ) +return -ENODEV ; + +return devm_mfd_add_devices (&i2c->dev,PLATFORM_DEVID_AUTO , + smpro_devs,ARRAY_SIZE (smpro_devs),NULL ,0 ,NULL ); +} +
drivers/mfd/smpro-mfd.c line 126
Quoted 10 lines
drivers/mfd/smpro-mfd.c new file +10
-0+static const struct of_device_id smpro_mfd_of_match[] = { + { .compatible ="ampere,smpro" , .data = &smpro_regmap_config }, + {} +}; +MODULE_DEVICE_TABLE (of, smpro_mfd_of_match); + +static struct i2c_driver smpro_mfd_driver = { + .probe_new = smpro_mfd_probe, + .driver = { + .name ="smpro-mfd-i2c" ,
"smpro-core"
Quoted 8 lines
drivers/mfd/smpro-mfd.c new file +8
-0+ .of_match_table = smpro_mfd_of_match, + }, +}; +module_i2c_driver (smpro_mfd_driver); + +MODULE_AUTHOR ("Quan Nguyen <[email protected]>" ); +MODULE_DESCRIPTION ("SMPRO MFD - I2C driver" ); +MODULE_LICENSE ("GPL" );
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v8 8/9] mfd: smpro-mfd: Adds Ampere's Altra SMpro MFD driver
In reply to Quan NguyenDear Lee Jones,
Thank you for the comment as on the link: https://lore.kernel.org/lkml/[email protected]/T/#m476dce286d806bb3713f689663fa631f5a1f0909
I'm not sure what happen (maybe due to my bad junk filter) but I could only see your email when checking the link mentioned above.
I will try to response on each of your comment inline.
Thank you very much for the comment.
- Quan
Quoted 1 line · Quan Nguyen
Adds Multi-function devices driver for SMpro co-processor found on the
[Lee] Please drop the term MFD and describe the device instead.
[Quan] Will replace MFD with "core" as your suggestion.
Quoted 32 lines
Mt.Jade hardware reference platform with Ampere's Altra processor family.
Signed-off-by Quan Nguyen <[email protected]>---
Changes in v8:
+ NoneChanges in v7:
+ Smpro-mfd now significant changes in compare with simple-mfd-i2c
driver, remove the copyright note about simple-mfd-i2c [Quan]
+ Install bus->read/write() to handle multiple types of busaccess. [Quan] + Update license to MODULE_LICENSE("GPL") [Quan] + Add others minor refactor the code [Quan]Changes in v6:
+ Update license part to reflect that this driver is clone from simple-mfd-i2c driver [Quan]Changes in v5:
+ Dropped the use of simple-mfd-i2c driver [Quan]
+ Introduceddrivers/mfd/smpro-mfd.cdriver to instantiate sub-devices. This is to avoid DT nodes without resource issue [Quan]
+ Revised commit message [Quan]Changes in v4:
+ Add "depends on I2C" to fix build issue found by kernel test robot [Guenter]Changes in v3:
+ None
Quoted 6 lines
Changes in v2:
+ Used 'struct of_device_id's .data attribute [Lee Jones]drivers/mfd/Kconfig | 12 ++++ drivers/mfd/Makefile | 1 + drivers/mfd/smpro-mfd.c | 134 ++++++++++++++++++++++++++++++++++++++++
[Lee] Please drop the 'mfd' part. Does 'core' work instead?
[Quan] Will drop the MFD thoroughly in next version.
Quoted 49 lines
3 files changed, 147 insertions(+)create mode 100644
drivers/mfd/smpro-mfd.cdrivers/mfd/Kconfig +12
-0@@ -77,6 +77,18 @@ config MFD_AS3711 help Support for the AS3711 PMIC from AMS +config MFD_SMPRO + tristate "Ampere Computing MFD SMpro core driver" + depends on I2C + select MFD_CORE + select REGMAP_I2C + help + Say yes here to enable SMpro driver support for Ampere's Altra + processor family. + + Ampere's Altra SMpro exposes an I2C regmap interface that can + be accessed by child devices. + config MFD_AS3722 tristate "ams AS3722 Power Management IC" select MFD_COREdrivers/mfd/Makefile +1
-0@@ -266,6 +266,7 @@ obj-$(CONFIG_MFD_QCOM_PM8008) += qcom-pm8008.o obj-$(CONFIG_SGI_MFD_IOC3) += ioc3.o obj-$(CONFIG_MFD_SIMPLE_MFD_I2C) += simple-mfd-i2c.o +obj-$(CONFIG_MFD_SMPRO) += smpro-mfd.o obj-$(CONFIG_MFD_INTEL_M10_BMC) += intel-m10-bmc.o obj-$(CONFIG_MFD_ATC260X) += atc260x-core.odrivers/mfd/smpro-mfd.c new file +5
-0@@ -0,0 +1,134 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Ampere Altra Family SMPro MFD - I2C +* +* Copyright (c) 2022, Ampere Computing LLC
drivers/mfd/smpro-mfd.c line 15
Quoted 10 lines
drivers/mfd/smpro-mfd.c new file +10
-0+* Author: Quan Nguyen <[email protected]> +*/ + +#include <linux/i2c.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of_platform.h> +#include <linux/mfd/core.h> +#include <linux/regmap.h> +
[Lee] Alphabetical.
[Quan] Will sort the included files follow alphbetical order in next version.
Quoted 40 lines
drivers/mfd/smpro-mfd.c new file +40
-0+/* Identification Registers */ +#define MANUFACTURER_ID_REG 0x02 +#define AMPERE_MANUFACTURER_ID 0xCD3A + +static int smpro_mfd_write (void *context,const void *data,size_t count) +{ +struct device *dev = context; +struct i2c_client *i2c =to_i2c_client (dev); +int ret; + + ret =i2c_master_send (i2c, data, count); +if (ret == count) +return 0 ; +else if (ret <0 ) +return ret; +else +return -EIO ; +} + +static int smpro_mfd_read (void *context,const void *reg,size_t reg_size, +void *val,size_t val_size) +{ +struct device *dev = context; +struct i2c_client *i2c =to_i2c_client (dev); +struct i2c_msg xfer[2 ]; +unsigned char buf[2 ]; +int ret; + + xfer[0 ].addr = i2c->addr; + xfer[0 ].flags =0 ; + + buf[0 ] = *(u8 *)reg; + buf[1 ] = val_size; + xfer[0 ].len =2 ; + xfer[0 ].buf = buf; + + xfer[1 ].addr = i2c->addr; + xfer[1 ].flags =I2C_M_RD ; + xfer[1 ].len = val_size; + xfer[1 ].buf = val;
drivers/mfd/smpro-mfd.c line 65
Quoted 10 lines
drivers/mfd/smpro-mfd.c new file +10
-0+ + ret =i2c_transfer (i2c->adapter, xfer,2 ); +if (ret ==2 ) +return 0 ; +else if (ret <0 ) +return ret; +else +return -EIO ; +} +
[Lee] This looks all too familiar.
I wonder how generic these i2c call-backs actually are.
[Quan] yes, this is similar with regmap_i2c_read() but with reg_size is force to 2. We can reuse regmap_i2c_read() but it needs to be exported from drivers/base/regmap/regmap-i2c.c
drivers/mfd/smpro-mfd.c line 76
Quoted 11 lines
drivers/mfd/smpro-mfd.c new file +11
-0+static const struct regmap_bus smpro_regmap_bus = { + .read = smpro_mfd_read, + .write = smpro_mfd_write, + .val_format_endian_default =REGMAP_ENDIAN_BIG , +}; + +static bool smpro_mfd_readable_noinc_reg (struct device *dev,unsigned int reg) +{ +return (reg ==0x82 || reg ==0x85 || reg ==0x92 || reg ==0x95 || + reg ==0xC2 || reg ==0xC5 || reg ==0xD2 || reg ==0xDA ); +}
[Lee] No magic numbers. Please define these registers.
[Quan] Will fix this in next version.
Quoted 14 lines
drivers/mfd/smpro-mfd.c new file +14
-0+ +static const struct regmap_config smpro_regmap_config = { + .reg_bits =8 , + .val_bits =16 , + .readable_noinc_reg = smpro_mfd_readable_noinc_reg, +}; + +static const struct mfd_cell smpro_devs[] = { +MFD_CELL_NAME ("smpro-hwmon" ), +MFD_CELL_NAME ("smpro-errmon" ), +MFD_CELL_NAME ("smpro-misc" ), +}; + +static int smpro_mfd_probe (struct i2c_client *i2c)
drivers/mfd/smpro-mfd.c line 100
Quoted 10 lines
drivers/mfd/smpro-mfd.c new file +10
-0+{ +const struct regmap_config *config; +struct regmap *regmap; +unsigned int val; +int ret; + + config =device_get_match_data (&i2c->dev); +if (!config) + config = &smpro_regmap_config; +
[Lee] This use-case is not currently supported.
Please return an error instead.
[Quan] Will update in next version.
drivers/mfd/smpro-mfd.c line 105
Quoted 5 lines
drivers/mfd/smpro-mfd.c new file +5
-0+ regmap =devm_regmap_init (&i2c->dev, &smpro_regmap_bus, &i2c->dev, config); +if (IS_ERR (regmap)) +return PTR_ERR (regmap); + +/* Check for valid ID */
[Lee] Decent #define nomenclature should render this comment superfluous.
[Quan] Thanks, will remove in next version.
Quoted 11 lines
drivers/mfd/smpro-mfd.c new file +11
-0+ ret =regmap_read (regmap,MANUFACTURER_ID_REG , &val); +if (ret) +return ret; + +if (val !=AMPERE_MANUFACTURER_ID ) +return -ENODEV ; + +return devm_mfd_add_devices (&i2c->dev,PLATFORM_DEVID_AUTO , + smpro_devs,ARRAY_SIZE (smpro_devs),NULL ,0 ,NULL ); +} +
drivers/mfd/smpro-mfd.c line 126
Quoted 10 lines
drivers/mfd/smpro-mfd.c new file +10
-0+static const struct of_device_id smpro_mfd_of_match[] = { + { .compatible ="ampere,smpro" , .data = &smpro_regmap_config }, + {} +}; +MODULE_DEVICE_TABLE (of, smpro_mfd_of_match); + +static struct i2c_driver smpro_mfd_driver = { + .probe_new = smpro_mfd_probe, + .driver = { + .name ="smpro-mfd-i2c" ,
[Lee] "smpro-core"
[Quan] Will change mfd to "core" thoroughly.
Thanks for the review.
Quoted 8 lines
drivers/mfd/smpro-mfd.c new file +8
-0+ .of_match_table = smpro_mfd_of_match, + }, +}; +module_i2c_driver (smpro_mfd_driver); + +MODULE_AUTHOR ("Quan Nguyen <[email protected]>" ); +MODULE_DESCRIPTION ("SMPRO MFD - I2C driver" ); +MODULE_LICENSE ("GPL" );
PATCH v8 9/9 docs: ABI: testing: Document the Ampere Altra Family's SMpro sysfs interfaces
In reply to Quan NguyenAdd documentation for the Ampere(R)'s Altra(R) SMpro sysfs interfaces
---
Changes in v8:
+ Sysfs to return single value in hex format [Greg] + Fix KernelVersion info [Greg] + Change errors_* to error_* [Quan] + Added overflow_[core|mem|pcie|other]_[ce|ue] [Quan]
Changes in v7:
+ First introduce in v7 [Greg]
.../sysfs-bus-platform-devices-ampere-smpro | 157 ++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro
Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro new file +157 -0
@@ -0,0 +1,157 @@ +What: /sys/bus/platform/devices/smpro-errmon.*/error_[core|mem|pcie|other]_[ce|ue] +KernelVersion: 5.18 +Contact: [email protected] +Description: + (RO) Contains the 48-byte Ampere (Vendor-Specific) Error Record, see [1], + printed in hex format as below: + + AABBCCCCDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD\ + DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD + Where: + AA : Error Type + BB : Subtype + CCCC : Instance + DDD...DDD: 44-byte value similar to the Arm RAS standard error record + + See [1] below for the format details. + + The detail of each sysfs entries is as below: + +-------------+---------------------------------------------------------+ + | Error | Sysfs entry | + +-------------+---------------------------------------------------------+ + | Core's CE | /sys/bus/platform/devices/smpro-errmon.*/error_core_ce | + | Core's UE | /sys/bus/platform/devices/smpro-errmon.*/error_core_ue | + | Memory's CE | /sys/bus/platform/devices/smpro-errmon.*/error_mem_ce | + | Memory's UE | /sys/bus/platform/devices/smpro-errmon.*/error_mem_ue | + | PCIe's CE | /sys/bus/platform/devices/smpro-errmon.*/error_pcie_ce | + | PCIe's UE | /sys/bus/platform/devices/smpro-errmon.*/error_pcie_ue | + | Other's CE | /sys/bus/platform/devices/smpro-errmon.*/error_other_ce| + | Other's UE | /sys/bus/platform/devices/smpro-errmon.*/error_other_ue| + +-------------+---------------------------------------------------------+ + UE: Uncorrect-able Error + CE: Correct-able Error + + [1] Section 3.3 Ampere (Vendor-Specific) Error Record Formats, + Altra Family RAS Supplement. + + +What: /sys/bus/platform/devices/smpro-errmon.*/overflow_[core|mem|pcie|other]_[ce|ue] +KernelVersion: 5.18 +Contact: [email protected] +Description: + (RO) Return the overflow status of each type HW error reported: + 0 : No overflow + 1 : There is an overflow and the oldest HW errors are dropped + + The detail of each sysfs entries is as below: + +-------------+-----------------------------------------------------------+ + | Overflow | Sysfs entry | + +-------------+-----------------------------------------------------------+ + | Core's CE | /sys/bus/platform/devices/smpro-errmon.*/overflow_core_ce | + | Core's UE | /sys/bus/platform/devices/smpro-errmon.*/overflow_core_ue | + | Memory's CE | /sys/bus/platform/devices/smpro-errmon.*/overflow_mem_ce | + | Memory's UE | /sys/bus/platform/devices/smpro-errmon.*/overflow_mem_ue | + | PCIe's CE | /sys/bus/platform/devices/smpro-errmon.*/overflow_pcie_ce | + | PCIe's UE | /sys/bus/platform/devices/smpro-errmon.*/overflow_pcie_ue | + | Other's CE | /sys/bus/platform/devices/smpro-errmon.*/overflow_other_ce| + | Other's UE | /sys/bus/platform/devices/smpro-errmon.*/overflow_other_ue| + +-------------+-----------------------------------------------------------+ + UE: Uncorrect-able Error + CE: Correct-able Error + +What: /sys/bus/platform/devices/smpro-errmon.*/error_[smpro|pmpro] +KernelVersion: 5.18 +Contact: [email protected] +Description: + (RO) Contains the internal firmware error record printed as hex format + as below: + + ABBCDDEEEEFFFFFFFF + Where: + A : Firmware Error Type + 1: Warning + 2: Error + 4: Error with data + BB : Firmware Image Code (8-bit value) + C : Direction: + 0: Enter + 1: Exit + DD : Location, firmware module location code (8-bit value) + EEEE : Error Code, firmware Error Code (16-bit value) + FFFFFFFF: Extensive data (32-bit value) + + Example: + root@mtjade:~# cat /sys/bus/platform/devices/smpro-errmon.1.auto/error_smpro + 109008000a00000000 + + The detail of each sysfs entries is as below: + +-------------+-------------------------------------------------------+ + | Error | Sysfs entry | + +-------------+-------------------------------------------------------+ + | SMpro error | /sys/bus/platform/devices/smpro-errmon.*/error_smpro | + | PMpro error | /sys/bus/platform/devices/smpro-errmon.*/error_pmpro | + +-------------+-------------------------------------------------------+ + See more details in section 5.10 RAS Internal Error Register Definitions, + Altra Family Soc BMC Interface Specification. + + +What: /sys/bus/platform/devices/smpro-errmon.*/event_[vrd_warn_fault|vrd_hot|dimm_hot] +KernelVersion: 5.18 +Contact: [email protected] +Description: + (RO) Contains the detail information in case of VRD/DIMM warning/hot events + in hex format as below: + + AABBBB + Where: + AA : The event channel + 00: VRD Warning Fault + 01: VRD Hot + 02: DIMM host + BBBB: The event detail information data + + See more details in section 5.7 GPI Status Registers, + Altra Family Soc BMC Interface Specification. + + +What: /sys/bus/platform/devices/smpro-misc.*/boot_progress +KernelVersion: 5.18 +Contact: [email protected] +Description: + (RO) Contains the boot stages information in hex as format below: + + AABBCCCCCCCC + Where: + AA : The boot stages + 00: SMpro firmware booting + 01: PMpro firmware booting + 02: ATF BL1 firmware booting + 03: DDR initialization + 04: DDR training report status + 05: ATF BL2 firmware booting + 06: ATF BL31 firmware booting + 07: ATF BL32 firmware booting + 08: UEFI firmware booting + 09: OS booting + BB : Boot status + 00: Not started + 01: Started + 02: Completed without error + 03: Failed. + CCCCCCCC: Boot status information defined for each boot stages + + See more details in section 5.11 Boot Stage Register Definitions, + and section 6. Processor Boot Progress Codes, Altra Family Soc BMC + Interface Specification. + + +What: /sys/bus/platform/devices/smpro-misc*/soc_power_limit +KernelVersion: 5.18 +Contact: [email protected] +Description: + (RW) Contains the desired SoC power limit in Watt. + Writes to this sysfs set the desired SoC power limit (W). + Reads from this register return the current SoC power limit (W). + The value ranges: + Minimum: 120 W + Maximum: Socket TDP power
Signature · 1 line
2.35.1