PECI device driver introduction
Subsystems (6)
v8 cover PECI device driver introduction
Introduction of the Platform Environment Control Interface (PECI) bus device driver. PECI is a one-wire bus interface that provides a communication channel from Intel processors and chipset components to external monitoring or control devices. PECI is designed to support the following sideband functions:
* Processor and DRAM thermal management
- Processor fan speed control is managed by comparing Digital Thermal Sensor (DTS) thermal readings acquired via PECI against the processor-specific fan speed control reference point, or TCONTROL. Both TCONTROL and DTS thermal readings are accessible via the processor PECI client. These variables are referenced to a common temperature, the TCC activation point, and are both defined as negative offsets from that reference.
- PECI based access to the processor package configuration space provides a means for Baseboard Management Controllers (BMC) or other platform management devices to actively manage the processor and memory power and thermal features.
* Platform Manageability
- Platform manageability functions including thermal, power, and error monitoring. Note that platform 'power' management includes monitoring and control for both the processor and DRAM subsystem to assist with data center power limiting.
- PECI allows read access to certain error registers in the processor MSR space and status monitoring registers in the PCI configuration space within the processor and downstream devices.
- PECI permits writes to certain registers in the processor PCI configuration space.
* Processor Interface Tuning and Diagnostics
- Processor interface tuning and diagnostics capabilities (Intel Interconnect BIST). The processors Intel Interconnect Built In Self Test (Intel IBIST) allows for infield diagnostic capabilities in the Intel UPI and memory controller interfaces. PECI provides a port to execute these diagnostics via its PCI Configuration read and write capabilities.
* Failure Analysis
- Output the state of the processor after a failure for analysis via Crashdump.
PECI uses a single wire for self-clocking and data transfer. The bus requires no additional control lines. The physical layer is a self-clocked one-wire bus that begins each bit with a driven, rising edge from an idle level near zero volts. The duration of the signal driven high depends on whether the bit value is a logic '0' or logic '1'. PECI also includes variable data transfer rate established with every message. In this way, it is highly flexible even though underlying logic is simple.
The interface design was optimized for interfacing between an Intel processor and chipset components in both single processor and multiple processor environments. The single wire interface provides low board routing overhead for the multiple load connections in the congested routing area near the processor and chipset components. Bus speed, error checking, and low protocol overhead provides adequate link bandwidth and reliability to transfer critical device operating conditions and configuration information.
This implementation provides the basic framework to add PECI extensions to the Linux bus and device models. A hardware specific 'Adapter' driver can be attached to the PECI bus to provide sideband functions described above. It is also possible to access all devices on an adapter from userspace through the /dev interface. A device specific 'Client' driver also can be attached to the PECI bus so each processor client's features can be supported by the 'Client' driver through an adapter connection in the bus. This patch set includes Aspeed 24xx/25xx PECI driver and PECI cputemp/dimmtemp drivers as the first implementation for both adapter and client drivers on the PECI bus framework.
Please review.
Thanks,
Jae
Changes since v7:
- Fixed a typo in the MFD_INTEL_PECI_CLIENT description.
- Made peci_unregister_device() NULL-aware.
- Converted to using %pOF instead of node full name in peci-core.
- Removed OF tables from peci-cputemp and peci-dimmtemp.
- Removed of_compatible strings from intel-peci-client.
- Added an access_ok() check into peci_ioctl in peci-core.
- Changed the DT node name of peci simple-bus from 'peci' to 'bus'.
Changes since v6:
- Dropped off unnecessary examples from dt-bindings document.
- Fixed a bug in DIMM index mask building logic.
- Modified DIMM temp label strings to match with the way in BIOS.
- Changed PECI ioctl base number from B6 to B7 to avoid conflict with fpga-dfl.
- Seperated the PECI section in MAINTAINERS into two parts - PECI subsystem and ASPEED PECI driver.
Changes since v5:
- Added more detailed descriptions for PECI client MFD documents.
- Changed PECI client MFD souce file names.
- Fixed DT example of PECI client MFD.
- Removed unnecessary debug printings.
- Moved the asm/intel-family.h inclusion place.
Changes since v4:
- Fixed an incorrect endianness handling in peci-aspeed.
- Added a comment to explain about the asm/intel-family.h inclusion.
- Added an MFD module to support multi-function PECI client devices.
Changes since v3:
- Made code more simple and compact.
- Removed unused header file inclusion.
- Fixed incorrect error return values and messages.
- Removed DTS margin temperature from the peci-cputemp.
- Made some magic numbers use defines.
- Moved peci_get_cpu_id() into peci-core as a common function.
- Replaced the cancel_delayed_work() call with a cancel_delayed_work_sync().
- Replaced AST and Aspeed uses with ASPEED.
- Simplified peci command timeout checking logic using regmap_read_poll_timeout().
- Simplified endian swap codes using endian handling macros.
- Dropped regmap read/write error checking except for the first access.
- Added a PECI reset setting in the device tree node.
- Removed unnecessary sleep from the probe context.
- Removed IRQF_SHARED flag from irq request code in the ASPEED PECI driver.
- Fixed typos in documents.
- Combined peci-bus.txt, peci-adapter.txt and peci-client.txt into peci.txt.
- Fixed and swept documents to drop some incorrect or unnecessary descriptions.
- Fixed device tree to make unit-address format use reg contents.
- Simplified bit manipulations using <linux/bitfield.h>.
- Made client CPU model checking use <asm/intel-family.h> if available.
- Modified adapter heap allocation method to use kobject reference count based.
- Added the low-level PECI xfer IOCTL again to support the Redfish requirement.
- Added PM domain attach/detach code.
- Added logic for device instantiation through sysfs.
- Fix a bug of interrupt status checking code in peci-aspeed driver.
Changes since v2:
- Divided peci-hwmon driver into two drivers, peci-cputemp and peci-dimmtemp.
- Added generic dt binding documents for PECI bus, adapter and client.
- Removed in_atomic() call from the PECI core driver.
- Improved PECI commands masking logic.
- Added permission check logic for PECI ioctls.
- Removed unnecessary type casts.
- Fixed some invalid error return codes.
- Added the mark_updated() function to improve update interval checking logic.
- Fixed a bug in populated DIMM checking function.
- Fixed some typo, grammar and style issues in documents.
- Rewrote hwmon drivers to use devm_hwmon_device_register_with_info API.
- Made peci_match_id() function as a static.
- Replaced a deprecated create_singlethread_workqueue() call with an alloc_ordered_workqueue() call.
- Reordered local variable definitions in reversed xmas tree notation.
- Listed up client CPUs that can be supported by peci-cputemp and peci-dimmtemp hwmon drivers.
- Added CPU generation detection logic which checks CPUID signature through PECI connection.
- Improved interrupt handling logic in the Aspeed PECI adapter driver.
- Fixed SPDX license identifier style in header files.
- Changed some macros in peci.h to static inline functions.
- Dropped sleepable context checking code in peci-core.
- Adjusted rt_mutex protection scope in peci-core.
- Moved adapter->xfer() checking code into peci_register_adapter().
- Improved PECI command retry checking logic.
- Changed ioctl base from 'P' to 0xb6 to avoid confiliction and updated ioctl-number.txt to reflect the ioctl number of PECI subsystem.
- Added a comment to describe PECI retry action.
- Simplified return code handling of peci_ioctl_ping().
- Changed type of peci_ioctl_fn[] to static const.
- Fixed range checking code for valid PECI commands.
- Fixed the error return code on invalid PECI commands.
- Fixed incorrect definitions of PECI ioctl and its handling logic.
Changes since v1:
- Additionally implemented a core driver to support PECI linux bus driver model.
- Modified Aspeed PECI driver to make that to be an adapter driver in PECI bus.
- Modified PECI hwmon driver to make that to be a client driver in PECI bus.
- Simplified hwmon driver attribute labels and removed redundant strings.
- Removed core_nums from device tree setting of hwmon driver and modified core number detection logic to check the resolved_core register in client CPU's local PCI configuration area.
- Removed dimm_nums from device tree setting of hwmon driver and added populated DIMM detection logic to support dynamic creation.
- Removed indexing gap on core temperature and DIMM temperature attributes.
- Improved hwmon registration and dynamic attribute creation logic.
- Fixed structure definitions in PECI uapi header to make that use __u8, __u16 and etc.
- Modified wait_for_completion_interruptible_timeout error handling logic in Aspeed PECI driver to deliver errors correctly.
- Removed low-level xfer command from ioctl and kept only high-level PECI command suite as ioctls.
- Fixed I/O timeout logic in Aspeed PECI driver using ktime.
- Added a function into hwmon driver to simplify update delay checking.
- Added a function into hwmon driver to convert 10.6 to millidegree.
- Dropped non-standard attributes in hwmon driver.
- Fixed OF table for hwmon to make it indicate as a PECI client of Intel CPU target.
- Added a maintainer of PECI subsystem into MAINTAINERS document.
Jae Hyun Yoo (12):
dt-bindings: Add a document of PECI subsystem
Documentation: ioctl: Add ioctl numbers for PECI subsystem
peci: Add support for PECI bus driver core
dt-bindings: Add a document of PECI adapter driver for ASPEED
AST24xx/25xx SoCs
ARM: dts: aspeed: peci: Add PECI node
peci: Add a PECI adapter driver for Aspeed AST24xx/AST25xx
dt-bindings: mfd: Add a document for PECI client MFD
mfd: intel-peci-client: Add PECI client MFD driver
Documentation: hwmon: Add documents for PECI hwmon client drivers
hwmon: Add PECI cputemp driver
hwmon: Add PECI dimmtemp driver
Add maintainers for the PECI subsystem
.../bindings/mfd/intel-peci-client.txt | 34 + .../devicetree/bindings/peci/peci-aspeed.txt | 55 + .../devicetree/bindings/peci/peci.txt | 43 + Documentation/hwmon/peci-cputemp | 78 + Documentation/hwmon/peci-dimmtemp | 50 + Documentation/ioctl/ioctl-number.txt | 2 + MAINTAINERS | 13 + arch/arm/boot/dts/aspeed-g4.dtsi | 26 + arch/arm/boot/dts/aspeed-g5.dtsi | 26 + drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/hwmon/Kconfig | 28 + drivers/hwmon/Makefile | 2 + drivers/hwmon/peci-cputemp.c | 392 +++++ drivers/hwmon/peci-dimmtemp.c | 286 ++++ drivers/mfd/Kconfig | 14 + drivers/mfd/Makefile | 1 + drivers/mfd/intel-peci-client.c | 181 +++ drivers/peci/Kconfig | 39 + drivers/peci/Makefile | 9 + drivers/peci/peci-aspeed.c | 498 ++++++ drivers/peci/peci-core.c | 1440 +++++++++++++++++ include/linux/mfd/intel-peci-client.h | 81 + include/linux/peci.h | 104 ++ include/uapi/linux/peci-ioctl.h | 265 +++ 25 files changed, 3670 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/intel-peci-client.txt create mode 100644 Documentation/devicetree/bindings/peci/peci-aspeed.txt create mode 100644 Documentation/devicetree/bindings/peci/peci.txt create mode 100644 Documentation/hwmon/peci-cputemp create mode 100644 Documentation/hwmon/peci-dimmtemp create mode 100644 drivers/hwmon/peci-cputemp.c create mode 100644 drivers/hwmon/peci-dimmtemp.c create mode 100644 drivers/mfd/intel-peci-client.c create mode 100644 drivers/peci/Kconfig create mode 100644 drivers/peci/Makefile create mode 100644 drivers/peci/peci-aspeed.c create mode 100644 drivers/peci/peci-core.c create mode 100644 include/linux/mfd/intel-peci-client.h create mode 100644 include/linux/peci.h create mode 100644 include/uapi/linux/peci-ioctl.h
Signature · 1 line
2.18.0
PATCH v8 1/12 dt-bindings: Add a document of PECI subsystem
This commit adds a document of generic PECI bus, adapter and client driver.
--- .../devicetree/bindings/peci/peci.txt | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Documentation/devicetree/bindings/peci/peci.txt
Documentation/devicetree/bindings/peci/peci.txt new file +43 -0
@@ -0,0 +1,43 @@ +Generic device tree configuration for PECI adapters +=================================================== + +Required properties: +- #address-cells : Should be <1>. Read more about client addresses below. +- #size-cells : Should be <0>. Read more about client addresses below. + +The cells properties above define that an address of CPU clients of a PECI bus +are described by a single value. + +Example: + peci0: peci-bus at 0 { + compatible = "vendor,soc-peci"; + reg = <0x0 0x1000>; + #address-cells = <1>; + #size-cells = <0>; + }; + +Generic device tree configuration for PECI clients +================================================== + +Required properties: +- compatible : Should contain name of PECI client. +- reg : Should contain address of a client CPU. Address range of CPU + clients starts from 0x30 based on PECI specification. + +Example: + peci-bus at 0 { + compatible = "vendor,soc-peci"; + reg = <0x0 0x1000>; + #address-cells = <1>; + #size-cells = <0>; + + peci-client at 30 { + compatible = "intel,peci-client"; + reg = <0x30>; + }; + + peci-client at 31 { + compatible = "intel,peci-client"; + reg = <0x31>; + }; + };
Signature · 1 line
2.18.0
PATCH v8 2/12 Documentation: ioctl: Add ioctl numbers for PECI subsystem
In reply to Jae Hyun YooThis commit updates ioctl-number.txt to reflect ioctl numbers used by the PECI subsystem.
--- Documentation/ioctl/ioctl-number.txt | 2 ++ 1 file changed, 2 insertions(+)
Documentation/ioctl/ioctl-number.txt +2 -0
@@ -325,6 +325,8 @@ Code Seq#(hex) Include File Comments 0xB4 00-0F linux/gpio.h <mailto:[email protected]> 0xB5 00-0F uapi/linux/rpmsg.h <mailto:[email protected]> 0xB6 all linux/fpga-dfl.h +0xB7 00-0F uapi/linux/peci-ioctl.h PECI subsystem + <mailto:[email protected]> 0xC0 00-0F linux/usb/iowarrior.h 0xCA 00-0F uapi/misc/cxl.h 0xCA 10-2F uapi/misc/ocxl.h
Signature · 1 line
2.18.0
PATCH v8 3/12 peci: Add support for PECI bus driver core
In reply to Jae Hyun YooThis commit adds driver implementation for PECI bus core into linux driver framework.
--- drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/peci/Kconfig | 12 + drivers/peci/Makefile | 6 + drivers/peci/peci-core.c | 1440 +++++++++++++++++++++++++++++++ include/linux/peci.h | 104 +++ include/uapi/linux/peci-ioctl.h | 265 ++++++ 7 files changed, 1830 insertions(+) create mode 100644 drivers/peci/Kconfig create mode 100644 drivers/peci/Makefile create mode 100644 drivers/peci/peci-core.c create mode 100644 include/linux/peci.h create mode 100644 include/uapi/linux/peci-ioctl.h
drivers/Kconfig +2 -0
@@ -219,4 +219,6 @@ source "drivers/siox/Kconfig" source "drivers/slimbus/Kconfig" +source "drivers/peci/Kconfig" + endmenu
drivers/Makefile +1 -0
@@ -186,3 +186,4 @@ obj-$(CONFIG_MULTIPLEXER) += mux/ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus/ obj-$(CONFIG_SIOX) += siox/ obj-$(CONFIG_GNSS) += gnss/ +obj-$(CONFIG_PECI) += peci/
drivers/peci/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +# +# Platform Environment Control Interface (PECI) subsystem configuration +# + +config PECI + bool "PECI support" + select RT_MUTEXES + select CRC8 + help + The Platform Environment Control Interface (PECI) is a one-wire bus + interface that provides a communication channel from Intel processors + and chipset components to external monitoring or control devices.
drivers/peci/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# +# Makefile for the PECI core and bus drivers. +# + +# Core functionality +obj-$(CONFIG_PECI) += peci-core.o
drivers/peci/peci-core.c new file +1440 -0
1,440 lines not on this page · raw message
include/linux/peci.h new file +104 -0
104 lines not on this page · raw message
include/uapi/linux/peci-ioctl.h new file +265 -0
265 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v8 4/12 dt-bindings: Add a document of PECI adapter driver for ASPEED AST24xx/25xx SoCs
In reply to Jae Hyun YooThis commit adds a dt-bindings document of PECI adapter driver for ASPEED AST24xx/25xx SoCs.
--- .../devicetree/bindings/peci/peci-aspeed.txt | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Documentation/devicetree/bindings/peci/peci-aspeed.txt
Documentation/devicetree/bindings/peci/peci-aspeed.txt new file +55 -0
@@ -0,0 +1,55 @@ +Device tree configuration for PECI buses on the AST24XX and AST25XX SoCs. + +Required properties: +- compatible : Should be one of: + "aspeed,ast2400-peci" + "aspeed,ast2500-peci" +- reg : Should contain PECI controller registers location and + length. +- #address-cells : Should be <1> required to define a client address. +- #size-cells : Should be <0> required to define a client address. +- interrupts : Should contain PECI controller interrupt. +- clocks : Should contain clock source for PECI controller. Should + reference the external oscillator clock in the second + cell. +- resets : Should contain phandle to reset controller with the reset + number in the second cell. +- clock-frequency : Should contain the operation frequency of PECI controller + in units of Hz. + 187500 ~ 24000000 + +Optional properties: +- msg-timing : Message timing negotiation period. This value will + determine the period of message timing negotiation to be + issued by PECI controller. The unit of the programmed + value is four times of PECI clock period. + 0 ~ 255 (default: 1) +- addr-timing : Address timing negotiation period. This value will + determine the period of address timing negotiation to be + issued by PECI controller. The unit of the programmed + value is four times of PECI clock period. + 0 ~ 255 (default: 1) +- rd-sampling-point : Read sampling point selection. The whole period of a bit + time will be divided into 16 time frames. This value will + determine the time frame in which the controller will + sample PECI signal for data read back. Usually in the + middle of a bit time is the best. + 0 ~ 15 (default: 8) +- cmd-timeout-ms : Command timeout in units of ms. + 1 ~ 60000 (default: 1000) + +Example: + peci0: peci-bus at 0 { + compatible = "aspeed,ast2500-peci"; + reg = <0x0 0x60>; + #address-cells = <1>; + #size-cells = <0>; + interrupts = <15>; + clocks = <&syscon ASPEED_CLK_GATE_REFCLK>; + resets = <&syscon ASPEED_RESET_PECI>; + clock-frequency = <24000000>; + msg-timing = <1>; + addr-timing = <1>; + rd-sampling-point = <8>; + cmd-timeout-ms = <1000>; + };
Signature · 1 line
2.18.0
PATCH v8 5/12 ARM: dts: aspeed: peci: Add PECI node
In reply to Jae Hyun YooThis commit adds PECI bus/adapter node of AST24xx/AST25xx into aspeed-g4 and aspeed-g5.
--- arch/arm/boot/dts/aspeed-g4.dtsi | 26 ++++++++++++++++++++++++++ arch/arm/boot/dts/aspeed-g5.dtsi | 26 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+)
arch/arm/boot/dts/aspeed-g4.dtsi +26 -0
@@ -29,6 +29,7 @@ serial3 = &uart4; serial4 = &uart5; serial5 = &vuart; + peci0 = &peci0; }; cpus {
@@ -317,6 +318,13 @@ }; }; + peci: bus at 1e78b000 { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x1e78b000 0x60>; + }; + uart2: serial at 1e78d000 { compatible = "ns16550a"; reg = <0x1e78d000 0x20>;
@@ -360,6 +368,24 @@ }; }; +&peci { + peci0: peci-bus at 0 { + compatible = "aspeed,ast2400-peci"; + reg = <0x0 0x60>; + #address-cells = <1>; + #size-cells = <0>; + interrupts = <15>; + clocks = <&syscon ASPEED_CLK_GATE_REFCLK>; + resets = <&syscon ASPEED_RESET_PECI>; + clock-frequency = <24000000>; + msg-timing = <1>; + addr-timing = <1>; + rd-sampling-point = <8>; + cmd-timeout-ms = <1000>; + status = "disabled"; + }; +}; + &i2c { i2c_ic: interrupt-controller at 0 { #interrupt-cells = <1>;
arch/arm/boot/dts/aspeed-g5.dtsi +26 -0
@@ -29,6 +29,7 @@ serial3 = &uart4; serial4 = &uart5; serial5 = &vuart; + peci0 = &peci0; }; cpus {
@@ -377,6 +378,13 @@ }; }; + peci: bus at 1e78b000 { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x1e78b000 0x60>; + }; + uart2: serial at 1e78d000 { compatible = "ns16550a"; reg = <0x1e78d000 0x20>;
@@ -420,6 +428,24 @@ }; }; +&peci { + peci0: peci-bus at 0 { + compatible = "aspeed,ast2500-peci"; + reg = <0x0 0x60>; + #address-cells = <1>; + #size-cells = <0>; + interrupts = <15>; + clocks = <&syscon ASPEED_CLK_GATE_REFCLK>; + resets = <&syscon ASPEED_RESET_PECI>; + clock-frequency = <24000000>; + msg-timing = <1>; + addr-timing = <1>; + rd-sampling-point = <8>; + cmd-timeout-ms = <1000>; + status = "disabled"; + }; +}; + &i2c { i2c_ic: interrupt-controller at 0 { #interrupt-cells = <1>;
Signature · 1 line
2.18.0
PATCH v8 6/12 peci: Add a PECI adapter driver for Aspeed AST24xx/AST25xx
In reply to Jae Hyun YooThis commit adds PECI adapter driver implementation for Aspeed AST24xx/AST25xx SoCs.
--- drivers/peci/Kconfig | 27 ++ drivers/peci/Makefile | 3 + drivers/peci/peci-aspeed.c | 498 +++++++++++++++++++++++++++++++++++++ 3 files changed, 528 insertions(+) create mode 100644 drivers/peci/peci-aspeed.c
drivers/peci/Kconfig +27 -0
@@ -10,3 +10,30 @@ config PECI The Platform Environment Control Interface (PECI) is a one-wire bus interface that provides a communication channel from Intel processors and chipset components to external monitoring or control devices. + + If you want PECI support, you should say Y here and also to the + specific driver for your bus adapter(s) below. + +if PECI + +# +# PECI hardware bus configuration +# + +menu "PECI Hardware Bus support" + +config PECI_ASPEED + tristate "ASPEED PECI support" + select REGMAP_MMIO + depends on OF + depends on ARCH_ASPEED || COMPILE_TEST + help + Say Y here if you want support for the Platform Environment Control + Interface (PECI) bus adapter driver on the ASPEED SoCs. + + This support is also available as a module. If so, the module + will be called peci-aspeed. + +endmenu + +endif # PECI
drivers/peci/Makefile +3 -0
@@ -4,3 +4,6 @@ # Core functionality obj-$(CONFIG_PECI) += peci-core.o + +# Hardware specific bus drivers +obj-$(CONFIG_PECI_ASPEED) += peci-aspeed.o
drivers/peci/peci-aspeed.c new file +498 -0
498 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v8 7/12 dt-bindings: mfd: Add a document for PECI client MFD
In reply to Jae Hyun YooThis commit adds a dt-bindings document for PECI client MFD.
--- .../bindings/mfd/intel-peci-client.txt | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/intel-peci-client.txt
Documentation/devicetree/bindings/mfd/intel-peci-client.txt new file +34 -0
@@ -0,0 +1,34 @@ +* Intel PECI client bindings + +PECI (Platform Environment Control Interface) is a one-wire bus interface that +provides a communication channel from PECI clients in Intel processors and +chipset components to external monitoring or control devices. PECI is designed +to support the following sideband functions: + +- Processor and DRAM thermal management +- Platform Manageability +- Processor Interface Tuning and Diagnostics +- Failure Analysis + +Required properties: +- compatible : Should be "intel,peci-client". +- reg : Should contain address of a client CPU. Address range of CPU + clients starts from 0x30 based on PECI specification. + +Example: + peci-bus at 0 { + compatible = "vendor,soc-peci"; + reg = <0x0 0x1000>; + #address-cells = <1>; + #size-cells = <0>; + + peci-client at 30 { + compatible = "intel,peci-client"; + reg = <0x30>; + }; + + peci-client at 31 { + compatible = "intel,peci-client"; + reg = <0x31>; + }; + };
Signature · 1 line
2.18.0
PATCH v8 8/12 mfd: intel-peci-client: Add PECI client MFD driver
In reply to Jae Hyun YooThis commit adds PECI client MFD driver.
--- drivers/mfd/Kconfig | 14 ++ drivers/mfd/Makefile | 1 + drivers/mfd/intel-peci-client.c | 181 ++++++++++++++++++++++++++ include/linux/mfd/intel-peci-client.h | 81 ++++++++++++ 4 files changed, 277 insertions(+) create mode 100644 drivers/mfd/intel-peci-client.c create mode 100644 include/linux/mfd/intel-peci-client.h
drivers/mfd/Kconfig +14 -0
@@ -595,6 +595,20 @@ config MFD_INTEL_MSIC Passage) chip. This chip embeds audio, battery, GPIO, etc. devices used in Intel Medfield platforms. +config MFD_INTEL_PECI_CLIENT + bool "Intel PECI client" + depends on (PECI || COMPILE_TEST) + select MFD_CORE + help + If you say yes to this option, support will be included for the + multi-functional Intel PECI (Platform Environment Control Interface) + client. PECI is a one-wire bus interface that provides a communication + channel from PECI clients in Intel processors and chipset components + to external monitoring or control devices. + + Additional drivers must be enabled in order to use the functionality + of the device. + config MFD_IPAQ_MICRO bool "Atmel Micro ASIC (iPAQ h3100/h3600/h3700) Support" depends on SA1100_H3100 || SA1100_H3600
drivers/mfd/Makefile +1 -0
@@ -203,6 +203,7 @@ obj-$(CONFIG_MFD_INTEL_LPSS) += intel-lpss.o obj-$(CONFIG_MFD_INTEL_LPSS_PCI) += intel-lpss-pci.o obj-$(CONFIG_MFD_INTEL_LPSS_ACPI) += intel-lpss-acpi.o obj-$(CONFIG_MFD_INTEL_MSIC) += intel_msic.o +obj-$(CONFIG_MFD_INTEL_PECI_CLIENT) += intel-peci-client.o obj-$(CONFIG_MFD_PALMAS) += palmas.o obj-$(CONFIG_MFD_VIPERBOARD) += viperboard.o obj-$(CONFIG_MFD_RC5T583) += rc5t583.o rc5t583-irq.o
drivers/mfd/intel-peci-client.c new file +181 -0
181 lines not on this page · raw message
include/linux/mfd/intel-peci-client.h new file +81 -0
81 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v8 9/12 Documentation: hwmon: Add documents for PECI hwmon client drivers
In reply to Jae Hyun YooThis commit adds hwmon documents for PECI cputemp and dimmtemp drivers.
--- Documentation/hwmon/peci-cputemp | 78 +++++++++++++++++++++++++++++++ Documentation/hwmon/peci-dimmtemp | 50 ++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 Documentation/hwmon/peci-cputemp create mode 100644 Documentation/hwmon/peci-dimmtemp
Documentation/hwmon/peci-cputemp new file +78 -0
@@ -0,0 +1,78 @@ +Kernel driver peci-cputemp +========================== + +Supported chips: + One of Intel server CPUs listed below which is connected to a PECI bus. + * Intel Xeon E5/E7 v3 server processors + Intel Xeon E5-14xx v3 family + Intel Xeon E5-24xx v3 family + Intel Xeon E5-16xx v3 family + Intel Xeon E5-26xx v3 family + Intel Xeon E5-46xx v3 family + Intel Xeon E7-48xx v3 family + Intel Xeon E7-88xx v3 family + * Intel Xeon E5/E7 v4 server processors + Intel Xeon E5-16xx v4 family + Intel Xeon E5-26xx v4 family + Intel Xeon E5-46xx v4 family + Intel Xeon E7-48xx v4 family + Intel Xeon E7-88xx v4 family + * Intel Xeon Scalable server processors + Intel Xeon Bronze family + Intel Xeon Silver family + Intel Xeon Gold family + Intel Xeon Platinum family + Addresses scanned: PECI client address 0x30 - 0x37 + Datasheet: Available from http://www.intel.com/design/literature.htm + +Author: + Jae Hyun Yoo <[email protected]> + +Description +----------- + +This driver implements a generic PECI hwmon feature which provides Digital +Thermal Sensor (DTS) thermal readings of the CPU package and CPU cores that are +accessible using the PECI Client Command Suite via the processor PECI client. + +All temperature values are given in millidegree Celsius and will be measurable +only when the target CPU is powered on. + +sysfs attributes +---------------- + +temp1_label "Die" +temp1_input Provides current die temperature of the CPU package. +temp1_max Provides thermal control temperature of the CPU package + which is also known as Tcontrol. +temp1_crit Provides shutdown temperature of the CPU package which + is also known as the maximum processor junction + temperature, Tjmax or Tprochot. +temp1_crit_hyst Provides the hysteresis value from Tcontrol to Tjmax of + the CPU package. + +temp2_label "Tcontrol" +temp2_input Provides current Tcontrol temperature of the CPU + package which is also known as Fan Temperature target. + Indicates the relative value from thermal monitor trip + temperature at which fans should be engaged. +temp2_crit Provides Tcontrol critical value of the CPU package + which is same to Tjmax. + +temp3_label "Tthrottle" +temp3_input Provides current Tthrottle temperature of the CPU + package. Used for throttling temperature. If this value + is allowed and lower than Tjmax - the throttle will + occur and reported at lower than Tjmax. + +temp4_label "Tjmax" +temp4_input Provides the maximum junction temperature, Tjmax of the + CPU package. + +temp[5-*]_label Provides string "Core X", where X is resolved core + number. +temp[5-*]_input Provides current temperature of each core. +temp[5-*]_max Provides thermal control temperature of the core. +temp[5-*]_crit Provides shutdown temperature of the core. +temp[5-*]_crit_hyst Provides the hysteresis value from Tcontrol to Tjmax of + the core.
Documentation/hwmon/peci-dimmtemp new file +50 -0
50 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v8 10/12 hwmon: Add PECI cputemp driver
In reply to Jae Hyun YooThis commit adds PECI cputemp hwmon driver.
--- drivers/hwmon/Kconfig | 14 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/peci-cputemp.c | 392 +++++++++++++++++++++++++++++++++++ 3 files changed, 407 insertions(+) create mode 100644 drivers/hwmon/peci-cputemp.c
drivers/hwmon/Kconfig +14 -0
@@ -1306,6 +1306,20 @@ config SENSORS_PCF8591 These devices are hard to detect and rarely found on mainstream hardware. If unsure, say N. +config SENSORS_PECI_CPUTEMP + tristate "PECI CPU temperature monitoring support" + depends on PECI + select MFD_INTEL_PECI_CLIENT + help + If you say yes here you get support for the generic Intel PECI + cputemp driver which provides Digital Thermal Sensor (DTS) thermal + readings of the CPU package and CPU cores that are accessible using + the PECI Client Command Suite via the processor PECI client. + Check Documentation/hwmon/peci-cputemp for details. + + This driver can also be built as a module. If so, the module + will be called peci-cputemp. + source drivers/hwmon/pmbus/Kconfig config SENSORS_PWM_FAN
drivers/hwmon/Makefile +1 -0
@@ -141,6 +141,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR) += ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o +obj-$(CONFIG_SENSORS_PECI_CPUTEMP) += peci-cputemp.o obj-$(CONFIG_SENSORS_POWR1220) += powr1220.o obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_RASPBERRYPI_HWMON) += raspberrypi-hwmon.o
drivers/hwmon/peci-cputemp.c new file +392 -0
392 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v8 11/12 hwmon: Add PECI dimmtemp driver
In reply to Jae Hyun YooThis commit adds PECI dimmtemp hwmon driver.
--- drivers/hwmon/Kconfig | 14 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/peci-dimmtemp.c | 286 ++++++++++++++++++++++++++++++++++ 3 files changed, 301 insertions(+) create mode 100644 drivers/hwmon/peci-dimmtemp.c
drivers/hwmon/Kconfig +14 -0
@@ -1320,6 +1320,20 @@ config SENSORS_PECI_CPUTEMP This driver can also be built as a module. If so, the module will be called peci-cputemp. +config SENSORS_PECI_DIMMTEMP + tristate "PECI DIMM temperature monitoring support" + depends on PECI + select MFD_INTEL_PECI_CLIENT + help + If you say yes here you get support for the generic Intel PECI hwmon + driver which provides Digital Thermal Sensor (DTS) thermal readings of + DIMM components that are accessible using the PECI Client Command + Suite via the processor PECI client. + Check Documentation/hwmon/peci-dimmtemp for details. + + This driver can also be built as a module. If so, the module + will be called peci-dimmtemp. + source drivers/hwmon/pmbus/Kconfig config SENSORS_PWM_FAN
drivers/hwmon/Makefile +1 -0
@@ -142,6 +142,7 @@ obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o obj-$(CONFIG_SENSORS_PECI_CPUTEMP) += peci-cputemp.o +obj-$(CONFIG_SENSORS_PECI_DIMMTEMP) += peci-dimmtemp.o obj-$(CONFIG_SENSORS_POWR1220) += powr1220.o obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_RASPBERRYPI_HWMON) += raspberrypi-hwmon.o
drivers/hwmon/peci-dimmtemp.c new file +286 -0
286 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v8 12/12 Add maintainers for the PECI subsystem
In reply to Jae Hyun YooThis commit adds maintainer information for the PECI subsystem.
--- MAINTAINERS | 13 +++++++++++++ 1 file changed, 13 insertions(+)
MAINTAINERS +13 -0
@@ -11361,6 +11361,19 @@ L: platform-driver-x86 at vger.kernel.org S: Maintained F: drivers/platform/x86/peaq-wmi.c +PECI SUBSYSTEM +M: Jae Hyun Yoo <[email protected]> +M: Jason M Biils <[email protected]> +L: openbmc at lists.ozlabs.org (moderated for non-subscribers) +S: Maintained +F: Documentation/devicetree/bindings/peci/ +F: drivers/mfd/intel-peci-client.c +F: drivers/peci/ +F: drivers/hwmon/peci-*.c +F: include/linux/mfd/intel-peci-client.h +F: include/linux/peci.h +F: include/uapi/linux/peci-ioctl.h + PER-CPU MEMORY ALLOCATOR M: Dennis Zhou <[email protected]> M: Tejun Heo <[email protected]>
Signature · 1 line
2.18.0
Re: [PATCH v8 01/12] dt-bindings: Add a document of PECI subsystem
In reply to Jae Hyun YooQuoted 11 lines · Jae Hyun Yoo
This commit adds a document of generic PECI bus, adapter and client driver.
Cc Rob Herring <[email protected]>Cc Mark Rutland <[email protected]>Cc Andrew Jeffery <[email protected]>Cc Joel Stanley <[email protected]>Signed-off-by Jae Hyun Yoo <[email protected]>Reviewed-by Haiyue Wang <[email protected]>Reviewed-by James Feist <[email protected]>Reviewed-by Vernon Mauery <[email protected]>
Quoted 5 lines
--- .../devicetree/bindings/peci/peci.txt | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Documentation/devicetree/bindings/peci/peci.txt
Re: [PATCH v8 07/12] dt-bindings: mfd: Add a document for PECI client MFD
In reply to Jae Hyun YooQuoted 11 lines · Jae Hyun Yoo
This commit adds a dt-bindings document for PECI client MFD.
Cc Lee Jones <[email protected]>Cc Rob Herring <[email protected]>Cc Mark Rutland <[email protected]>Cc Andrew Jeffery <[email protected]>Cc James Feist <[email protected]>Cc Jason M Biils <[email protected]>Cc Joel Stanley <[email protected]>Cc Vernon Mauery <[email protected]>Signed-off-by Jae Hyun Yoo <[email protected]>
Quoted 5 lines
--- .../bindings/mfd/intel-peci-client.txt | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/intel-peci-client.txt
Re: [PATCH v8 01/12] dt-bindings: Add a document of PECI subsystem
In reply to Rob HerringQuoted 18 lines · Rob Herring
Quoted 11 lines · Jae Hyun Yoo
This commit adds a document of generic PECI bus, adapter and client driver.
Cc Rob Herring <[email protected]>Cc Mark Rutland <[email protected]>Cc Andrew Jeffery <[email protected]>Cc Joel Stanley <[email protected]>Signed-off-by Jae Hyun Yoo <[email protected]>Reviewed-by Haiyue Wang <[email protected]>Reviewed-by James Feist <[email protected]>Reviewed-by Vernon Mauery <[email protected]>Quoted 5 lines
--- .../devicetree/bindings/peci/peci.txt | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+)create mode 100644
Documentation/devicetree/bindings/peci/peci.txt
Quoted 2 lines
Reviewed-by Rob Herring <[email protected]>
Thanks for the review, Rob!
Re: [PATCH v8 07/12] dt-bindings: mfd: Add a document for PECI client MFD
In reply to Rob HerringQuoted 18 lines · Rob Herring
Quoted 11 lines · Jae Hyun Yoo
This commit adds a dt-bindings document for PECI client MFD.
Cc Lee Jones <[email protected]>Cc Rob Herring <[email protected]>Cc Mark Rutland <[email protected]>Cc Andrew Jeffery <[email protected]>Cc James Feist <[email protected]>Cc Jason M Biils <[email protected]>Cc Joel Stanley <[email protected]>Cc Vernon Mauery <[email protected]>Signed-off-by Jae Hyun Yoo <[email protected]>Quoted 5 lines
--- .../bindings/mfd/intel-peci-client.txt | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+)create mode 100644
Documentation/devicetree/bindings/mfd/intel-peci-client.txt
Quoted 2 lines
Reviewed-by Rob Herring <[email protected]>
Thanks for the review, Rob!
Re: [PATCH v8 07/12] dt-bindings: mfd: Add a document for PECI client MFD
In reply to Jae Hyun YooQuoted 28 lines · Jae Hyun Yoo
This commit adds a dt-bindings document for PECI client MFD.
Cc Lee Jones <[email protected]>Cc Rob Herring <[email protected]>Cc Mark Rutland <[email protected]>Cc Andrew Jeffery <[email protected]>Cc James Feist <[email protected]>Cc Jason M Biils <[email protected]>Cc Joel Stanley <[email protected]>Cc Vernon Mauery <[email protected]>Signed-off-by Jae Hyun Yoo <[email protected]>--- .../bindings/mfd/intel-peci-client.txt | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/intel-peci-client.txtDocumentation/devicetree/bindings/mfd/intel-peci-client.txt new file +6
-0@@ -0,0 +1,34 @@ +* Intel PECI client bindings + +PECI (Platform Environment Control Interface) is a one-wire bus interface that +provides a communication channel from PECI clients in Intel processors and +chipset components to external monitoring or control devices. PECI is designed +to support the following sideband functions:
Documentation/devicetree/bindings/mfd/intel-peci-client.txt line 16
Quoted 10 lines
Documentation/devicetree/bindings/mfd/intel-peci-client.txt new file +10
-0+ +- Processor and DRAM thermal management +- Platform Manageability +- Processor Interface Tuning and Diagnostics +- Failure Analysis + +Required properties: +- compatible : Should be "intel,peci-client". +- reg : Should contain address of a client CPU. Address range of CPU + clients starts from 0x30 based on PECI specification.
Nit: "start"
Would be better worded:
"According to the PECI specification client addresses start from 0x30."
Quoted 17 lines
Documentation/devicetree/bindings/mfd/intel-peci-client.txt new file +17
-0+Example: + peci-bus at 0 { + compatible = "vendor,soc-peci"; + reg = <0x0 0x1000>; + #address-cells = <1>; + #size-cells = <0>; + + peci-client at 30 { + compatible = "intel,peci-client"; + reg = <0x30>; + }; + + peci-client at 31 { + compatible = "intel,peci-client"; + reg = <0x31>; + }; + };
Signature · 4 lines
Lee Jones [???] Linaro Services Technical Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v8 08/12] mfd: intel-peci-client: Add PECI client MFD driver
In reply to Jae Hyun YooQuoted 25 lines · Jae Hyun Yoo
This commit adds PECI client MFD driver.
Cc Lee Jones <[email protected]>Cc Randy Dunlap <[email protected]>Cc Rob Herring <[email protected]>Cc Andrew Jeffery <[email protected]>Cc James Feist <[email protected]>Cc Jason M Biils <[email protected]>Cc Joel Stanley <[email protected]>Cc Vernon Mauery <[email protected]>Signed-off-by Jae Hyun Yoo <[email protected]>--- drivers/mfd/Kconfig | 14 ++ drivers/mfd/Makefile | 1 + drivers/mfd/intel-peci-client.c | 181 ++++++++++++++++++++++++++ include/linux/mfd/intel-peci-client.h | 81 ++++++++++++ 4 files changed, 277 insertions(+) create mode 100644 drivers/mfd/intel-peci-client.c create mode 100644 include/linux/mfd/intel-peci-client.hdrivers/mfd/Kconfig +0
-0
drivers/mfd/Kconfig config MFD_INTEL_MSIC · line 604
Quoted 10 lines
drivers/mfd/Kconfig +7
-0@@ -595,6 +595,20 @@ config MFD_INTEL_MSIC Passage) chip. This chip embeds audio, battery, GPIO, etc. devices used in Intel Medfield platforms. +config MFD_INTEL_PECI_CLIENT + bool "Intel PECI client" + depends on (PECI || COMPILE_TEST) + select MFD_CORE + help + If you say yes to this option, support will be included for the + multi-functional Intel PECI (Platform Environment Control Interface)
Remove 'multi-functional' from this sentence.
Quoted 41 lines
drivers/mfd/Kconfig +7
-0+ client. PECI is a one-wire bus interface that provides a communication + channel from PECI clients in Intel processors and chipset components + to external monitoring or control devices. + + Additional drivers must be enabled in order to use the functionality + of the device. + config MFD_IPAQ_MICRO bool "Atmel Micro ASIC (iPAQ h3100/h3600/h3700) Support" depends on SA1100_H3100 || SA1100_H3600drivers/mfd/Makefile +1
-0@@ -203,6 +203,7 @@ obj-$(CONFIG_MFD_INTEL_LPSS) += intel-lpss.o obj-$(CONFIG_MFD_INTEL_LPSS_PCI) += intel-lpss-pci.o obj-$(CONFIG_MFD_INTEL_LPSS_ACPI) += intel-lpss-acpi.o obj-$(CONFIG_MFD_INTEL_MSIC) += intel_msic.o +obj-$(CONFIG_MFD_INTEL_PECI_CLIENT) += intel-peci-client.o obj-$(CONFIG_MFD_PALMAS) += palmas.o obj-$(CONFIG_MFD_VIPERBOARD) += viperboard.o obj-$(CONFIG_MFD_RC5T583) += rc5t583.o rc5t583-irq.odrivers/mfd/intel-peci-client.c new file +13
-0@@ -0,0 +1,181 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2018 Intel Corporation + +#include <linux/bitfield.h> +#include <linux/mfd/core.h> +#include <linux/mfd/intel-peci-client.h> +#include <linux/module.h> +#include <linux/peci.h> +#include <linux/of_device.h> + +enum cpu_gens { +CPU_GEN_HSX =0 ,/* Haswell Xeon */ +CPU_GEN_BRX ,/* Broadwell Xeon */
drivers/mfd/intel-peci-client.c line 23
Quoted 10 lines
drivers/mfd/intel-peci-client.c new file +10
-0+ CPU_GEN_SKX, /* Skylake Xeon */ +}; + +static struct mfd_cell peci_functions[] = { + { + .name ="peci-cputemp" , + }, + { + .name ="peci-dimmtemp" , + },
{ .name = "peci-cputemp", },
{ .name = "peci-dimmtemp", },Do these have 2 different drivers? Where are you putting them?
drivers/mfd/intel-peci-client.c line 24
Quoted 1 line
drivers/mfd/intel-peci-client.c new file +1
-0+/* TODO: Add additional PECI sideband functions into here */
When will this be done?
Quoted 11 lines
drivers/mfd/intel-peci-client.c new file +11
-0+}; + +static const struct cpu_gen_info cpu_gen_info_table[] = { + [CPU_GEN_HSX ] = { + .family =6 ,/* Family code */ + .model =INTEL_FAM6_HASWELL_X , + .core_max =CORE_MAX_ON_HSX , + .chan_rank_max =CHAN_RANK_MAX_ON_HSX , + .dimm_idx_max =DIMM_IDX_MAX_ON_HSX }, + [CPU_GEN_BRX ] = { + .family =6 ,/* Family code */
drivers/mfd/intel-peci-client.c line 45
Quoted 10 lines
drivers/mfd/intel-peci-client.c new file +10
-0+ .model = INTEL_FAM6_BROADWELL_X, + .core_max = CORE_MAX_ON_BDX, + .chan_rank_max = CHAN_RANK_MAX_ON_BDX, + .dimm_idx_max = DIMM_IDX_MAX_ON_BDX }, + [CPU_GEN_SKX] = { + .family = 6, /* Family code */ + .model = INTEL_FAM6_SKYLAKE_X, + .core_max = CORE_MAX_ON_SKX, + .chan_rank_max = CHAN_RANK_MAX_ON_SKX, + .dimm_idx_max = DIMM_IDX_MAX_ON_SKX },
The '},'s should go on the line below.
drivers/mfd/intel-peci-client.c line 48
Quoted 3 lines
drivers/mfd/intel-peci-client.c new file +3
-0+}; + +static int peci_client_get_cpu_gen_info (struct peci_mfd *priv)
Remove all mention of 'mfd'. It's not a thing.
Quoted 11 lines
drivers/mfd/intel-peci-client.c new file +11
-0+{ +u32 cpu_id; +int i, rc; + + rc =peci_get_cpu_id (priv->adapter, priv->addr, &cpu_id); +if (rc) +return rc; + +for (i =0 ; i <ARRAY_SIZE (cpu_gen_info_table); i++) { + if (FIELD_GET(CPU_ID_FAMILY_MASK, cpu_id) + + FIELD_GET(CPU_ID_EXT_FAMILY_MASK, cpu_id) ==
drivers/mfd/intel-peci-client.c line 69
Quoted 10 lines
drivers/mfd/intel-peci-client.c new file +10
-0+ cpu_gen_info_table[i].family && +FIELD_GET (CPU_ID_MODEL_MASK , cpu_id) == +FIELD_GET (LOWER_NIBBLE_MASK , + cpu_gen_info_table[i].model) && +FIELD_GET (CPU_ID_EXT_MODEL_MASK , cpu_id) == +FIELD_GET (UPPER_NIBBLE_MASK , + cpu_gen_info_table[i].model)) { + break; + } + }
This is really read. Please reformat it, even if you have to use local variables to make it more legible.
drivers/mfd/intel-peci-client.c line 72
Quoted 2 lines
drivers/mfd/intel-peci-client.c new file +2
-0+if (i >=ARRAY_SIZE (cpu_gen_info_table)) +return -ENODEV ;
Do you really want to fail silently?
drivers/mfd/intel-peci-client.c line 74
Quoted 1 line
drivers/mfd/intel-peci-client.c new file +1
-0+ priv->gen_info = &cpu_gen_info_table[i];
If you do this in the for(), you can then test priv->gen_info instead of seeing if the iterator maxed out. Much nicer I think.
Quoted 9 lines
drivers/mfd/intel-peci-client.c new file +9
-0+return 0 ; +} + +bool peci_temp_need_update (struct temp_data *temp) +{ +if (temp->valid && +time_before (jiffies, temp->last_updated +UPDATE_INTERVAL )) +return false; +
drivers/mfd/intel-peci-client.c line 94
Quoted 10 lines
drivers/mfd/intel-peci-client.c new file +10
-0+return true; +} +EXPORT_SYMBOL_GPL (peci_temp_need_update); + +void peci_temp_mark_updated (struct temp_data *temp) +{ + temp->valid =1 ; + temp->last_updated = jiffies; +} +EXPORT_SYMBOL_GPL (peci_temp_mark_updated);
These are probably better suited as inline functions to be placed in a header file. No need to export them, since they only use their own data.
drivers/mfd/intel-peci-client.c line 100
Quoted 5 lines
drivers/mfd/intel-peci-client.c new file +5
-0+int peci_client_command (struct peci_mfd *priv,enum peci_cmd cmd,void *vmsg) +{ +return peci_command (priv->adapter, cmd, vmsg); +} +EXPORT_SYMBOL_GPL (peci_client_command);
If you share the adaptor with the client, you can call peci_command() directly. There should also be some locking in here somewhere too.
drivers/mfd/intel-peci-client.c line 102
Quoted 1 line
drivers/mfd/intel-peci-client.c new file +1
-0+int peci_client_rd_pkg_cfg_cmd(struct peci_mfd *priv, u8 mbx_idx,
This is gobbledegook. What's rd? Read?
Quoted 7 lines
drivers/mfd/intel-peci-client.c new file +7
-0+ u16 param, u8 *data) +{ + struct peci_rd_pkg_cfg_msg msg; +int rc; + + msg.addr = priv->addr; + msg.index = mbx_idx;
drivers/mfd/intel-peci-client.c line 119
Quoted 10 lines
drivers/mfd/intel-peci-client.c new file +10
-0+ msg.param = param; + msg.rx_len =4 ; + + rc =peci_command (priv->adapter,PECI_CMD_RD_PKG_CFG , &msg); +if (!rc) +memcpy (data, msg.pkg_config,4 ); + +return rc; +} +EXPORT_SYMBOL_GPL (peci_client_rd_pkg_cfg_cmd);
This too should be set-up as an inline function, not an exported one.
drivers/mfd/intel-peci-client.c line 125
Quoted 5 lines
drivers/mfd/intel-peci-client.c new file +5
-0+static int peci_client_probe (struct peci_client *client) +{ +struct device *dev = &client->dev; +struct peci_mfd *priv; +int rc;
'ret' is more common.
drivers/mfd/intel-peci-client.c line 135
Quoted 10 lines
drivers/mfd/intel-peci-client.c new file +9
-0+ priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + +dev_set_drvdata (dev, priv); + priv->client = client; + priv->dev = dev; + priv->adapter = client->adapter; + priv->addr = client->addr;
You're already saving client. No need to save its individual attributes as well.
drivers/mfd/intel-peci-client.c line 136
Quoted 1 line
drivers/mfd/intel-peci-client.c new file +1
-0+ priv->cpu_no = client->addr -PECI_BASE_ADDR ;
This seems clunky. Does the spec say that the addresses have to be in numerical order with no gaps? What if someone chooses to implement 4 CPUs at 0x30, 0x35, 0x45 and 0x60?
What do you then do with cpu_no?
drivers/mfd/intel-peci-client.c line 147
Quoted 10 lines
drivers/mfd/intel-peci-client.c new file +10
-0+snprintf (priv->name,PECI_NAME_SIZE ,"peci_client.cpu%d" , priv->cpu_no); + + rc =peci_client_get_cpu_gen_info (priv); +if (rc) +return rc; + + rc =devm_mfd_add_devices (priv->dev, priv->cpu_no, peci_functions, +ARRAY_SIZE (peci_functions),NULL ,0 ,NULL ); +if (rc <0 ) { +dev_err (priv->dev,"devm_mfd_add_devices failed: %d\n" , rc);
This to too specific.
"Failed to register child devices"
Quoted 6 lines
drivers/mfd/intel-peci-client.c new file +6
-0+return rc; + } + +return 0 ; +} +
drivers/mfd/intel-peci-client.c line 163
Quoted 10 lines
drivers/mfd/intel-peci-client.c new file +10
-0+#ifdef CONFIG_OF +static const struct of_device_id peci_client_of_table[] = { + { .compatible ="intel,peci-client" }, + { } +}; +MODULE_DEVICE_TABLE (of, peci_client_of_table); +#endif + +static const struct peci_device_id peci_client_ids[] = { + { .name ="peci-client" , .driver_data =0 },
Remove .driver_data if you're not going to use it.
drivers/mfd/intel-peci-client.c line 176
Quoted 13 lines
drivers/mfd/intel-peci-client.c new file +13
-0+ { } +}; +MODULE_DEVICE_TABLE (peci, peci_client_ids); + +static struct peci_driver peci_client_driver = { + .probe = peci_client_probe, + .id_table = peci_client_ids, + .driver = { + .name ="peci-client" , + .of_match_table = +of_match_ptr (peci_client_of_table), + }, +};
Odd tabbing.
drivers/mfd/intel-peci-client.c line 180
Quoted 4 lines
drivers/mfd/intel-peci-client.c new file +4
-0+module_peci_driver (peci_client_driver); + +MODULE_AUTHOR ("Jae Hyun Yoo <[email protected]>" ); +MODULE_DESCRIPTION ("PECI client MFD driver" );
Remove "MFD".
Quoted 52 lines
drivers/mfd/intel-peci-client.c new file +1
-0+MODULE_LICENSE ("GPL v2" );include/linux/mfd/intel-peci-client.h new file +45
-0@@ -0,0 +1,81 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2018 Intel Corporation */ + +#ifndef __LINUX_MFD_PECI_CLIENT_H +#define __LINUX_MFD_PECI_CLIENT_H + +#include <linux/peci.h> + +#if IS_ENABLED (CONFIG_X86 ) +#include <asm/intel-family.h> +#else +/** +* Architectures other than x86 cannot include the header file so define these +* at here. These are needed for detecting type of client x86 CPUs behind a PECI +* connection. +*/ +#define INTEL_FAM6_HASWELL_X 0x3F +#define INTEL_FAM6_BROADWELL_X 0x4F +#define INTEL_FAM6_SKYLAKE_X 0x55 +#endif + +#define LOWER_NIBBLE_MASK GENMASK(3, 0) +#define UPPER_NIBBLE_MASK GENMASK(7, 4) + +#define CPU_ID_MODEL_MASK GENMASK(7, 4) +#define CPU_ID_FAMILY_MASK GENMASK(11, 8) +#define CPU_ID_EXT_MODEL_MASK GENMASK(19, 16) +#define CPU_ID_EXT_FAMILY_MASK GENMASK(27, 20) + +#define CORE_MAX_ON_HSX 18/* Max number of cores on Haswell */ +#define CHAN_RANK_MAX_ON_HSX 8/* Max number of channel ranks on Haswell */ +#define DIMM_IDX_MAX_ON_HSX 3/* Max DIMM index per channel on Haswell */ + +#define CORE_MAX_ON_BDX 24/* Max number of cores on Broadwell */ +#define CHAN_RANK_MAX_ON_BDX 4/* Max number of channel ranks on Broadwell */ +#define DIMM_IDX_MAX_ON_BDX 3/* Max DIMM index per channel on Broadwell */ + +#define CORE_MAX_ON_SKX 28/* Max number of cores on Skylake */ +#define CHAN_RANK_MAX_ON_SKX 6/* Max number of channel ranks on Skylake */ +#define DIMM_IDX_MAX_ON_SKX 2/* Max DIMM index per channel on Skylake */ + +#define CORE_NUMS_MAX CORE_MAX_ON_SKX +#define CHAN_RANK_MAX CHAN_RANK_MAX_ON_HSX +#define DIMM_IDX_MAX DIMM_IDX_MAX_ON_HSX +#define DIMM_NUMS_MAX (CHAN_RANK_MAX * DIMM_IDX_MAX)
include/linux/mfd/intel-peci-client.h line 55
Quoted 10 lines
include/linux/mfd/intel-peci-client.h new file +10
-0+ +#define TEMP_TYPE_PECI 6/* Sensor type 6: Intel PECI */ + +#define UPDATE_INTERVAL HZ + +struct temp_data { +uint valid; +s32 value; +ulong last_updated; +};
This should not live in here.
include/linux/mfd/intel-peci-client.h line 65
Quoted 9 lines
include/linux/mfd/intel-peci-client.h new file +9
-0+struct cpu_gen_info { +u16 family; +u8 model; +uint core_max; +uint chan_rank_max; +uint dimm_idx_max; +}; + +struct peci_mfd {
Remove "_mfd".
include/linux/mfd/intel-peci-client.h line 69
Quoted 4 lines
include/linux/mfd/intel-peci-client.h new file +4
-0+struct peci_client *client; +struct device *dev; +struct peci_adapter *adapter; +char name[PECI_NAME_SIZE ];
What is this used for?
include/linux/mfd/intel-peci-client.h line 72
Quoted 3 lines
include/linux/mfd/intel-peci-client.h new file +3
-0+u8 addr; +uint cpu_no; +const struct cpu_gen_info *gen_info;
Where is this used?
include/linux/mfd/intel-peci-client.h line 72
Quoted 1 line
include/linux/mfd/intel-peci-client.h new file +1
-0+};
Both of these structs need kerneldoc headers.
include/linux/mfd/intel-peci-client.h line 76
Quoted 2 lines
include/linux/mfd/intel-peci-client.h new file +2
-0+bool peci_temp_need_update (struct temp_data *temp); +void peci_temp_mark_updated (struct temp_data *temp);
These should live in a temperature driver.
Quoted 5 lines
include/linux/mfd/intel-peci-client.h new file +5
-0+int peci_client_command (struct peci_mfd *mfd,enum peci_cmd cmd,void *vmsg); +int peci_client_rd_pkg_cfg_cmd (struct peci_mfd *mfd,u8 mbx_idx, +u16 param,u8 *data); + +#endif /* __LINUX_MFD_PECI_CLIENT_H */
Signature · 4 lines
Lee Jones [???] Linaro Services Technical Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v8 07/12] dt-bindings: mfd: Add a document for PECI client MFD
In reply to Lee JonesHi Lee,
Quoted 9 lines · Lee Jones
Documentation/devicetree/bindings/mfd/intel-peci-client.txt line 16
Quoted 4 lines · Jae Hyun Yoo
Documentation/devicetree/bindings/mfd/intel-peci-client.txt new file +4
-0+Required properties: +- compatible : Should be "intel,peci-client". +- reg : Should contain address of a client CPU. Address range of CPU + clients starts from 0x30 based on PECI specification.Nit: "start"
Quoted 4 lines
Would be better worded:
"According to the PECI specification client addresses start from
0x30."
Yes, that would be better. Will fix it like you suggested.
Thanks for the review!
Jae
Re: [PATCH v8 08/12] mfd: intel-peci-client: Add PECI client MFD driver
In reply to Lee JonesHi Lee,
Quoted 4 lines · Lee Jones
Quoted 2 lines · Jae Hyun Yoo
This commit adds PECI client MFD driver.
<snip>
Quoted 10 lines
drivers/mfd/Kconfig config MFD_INTEL_MSIC · line 604
Quoted 7 lines
drivers/mfd/Kconfig +7
-0+config MFD_INTEL_PECI_CLIENT + bool "Intel PECI client" + depends on (PECI || COMPILE_TEST) + select MFD_CORE + help + If you say yes to this option, support will be included for the + multi-functional Intel PECI (Platform Environment Control Interface)Remove 'multi-functional' from this sentence.
Will remove the word.
<snip>
Quoted 11 lines
drivers/mfd/intel-peci-client.c line 23
Quoted 7 lines
drivers/mfd/intel-peci-client.c new file +7
-0+static struct mfd_cell peci_functions[] = { + { + .name ="peci-cputemp" , + }, + { + .name ="peci-dimmtemp" , + },{ .name = "peci-cputemp", }, { .name = "peci-dimmtemp", },
Will change it like you suggested.
Quoted 2 lines
Do these have 2 different drivers? Where are you putting them?
Yes, these have 2 different drivers as hwmon subsystem drivers. I submitted them into this patch series.
Patch 10/12: https://lkml.org/lkml/2018/9/18/1524
Patch 11/12: https://lkml.org/lkml/2018/9/18/1523
Quoted 4 lines
drivers/mfd/intel-peci-client.c line 24
Quoted 1 line
drivers/mfd/intel-peci-client.c new file +1
-0+/* TODO: Add additional PECI sideband functions into here */ When will this be done?
I'm hoping it will be done by the end of this year.
Quoted 15 lines
Quoted 15 lines
drivers/mfd/intel-peci-client.c new file +15
-0+}; + +static const struct cpu_gen_info cpu_gen_info_table[] = { + [CPU_GEN_HSX ] = { + .family =6 ,/* Family code */ + .model =INTEL_FAM6_HASWELL_X , + .core_max =CORE_MAX_ON_HSX , + .chan_rank_max =CHAN_RANK_MAX_ON_HSX , + .dimm_idx_max =DIMM_IDX_MAX_ON_HSX }, + [CPU_GEN_BRX ] = { + .family =6 ,/* Family code */ + .model =INTEL_FAM6_BROADWELL_X , + .core_max =CORE_MAX_ON_BDX , + .chan_rank_max =CHAN_RANK_MAX_ON_BDX , + .dimm_idx_max =DIMM_IDX_MAX_ON_BDX },
Quoted 9 lines
drivers/mfd/intel-peci-client.c line 45
Quoted 6 lines
drivers/mfd/intel-peci-client.c new file +6
-0+ [CPU_GEN_SKX] = { + .family = 6, /* Family code */ + .model = INTEL_FAM6_SKYLAKE_X, + .core_max = CORE_MAX_ON_SKX, + .chan_rank_max = CHAN_RANK_MAX_ON_SKX, + .dimm_idx_max = DIMM_IDX_MAX_ON_SKX },The '},'s should go on the line below.
Okay. Will fix it.
Quoted 6 lines
drivers/mfd/intel-peci-client.c line 48
Quoted 3 lines
drivers/mfd/intel-peci-client.c new file +3
-0+}; + +static int peci_client_get_cpu_gen_info (struct peci_mfd *priv)Remove all mention of 'mfd'. It's not a thing.
Will remove 'mfd'.
Quoted 16 lines
Quoted 16 lines
drivers/mfd/intel-peci-client.c new file +16
-0+{ + u32 cpu_id; + int i, rc; + + rc = peci_get_cpu_id(priv->adapter, priv->addr, &cpu_id); + if (rc) + return rc; + + for (i = 0; i < ARRAY_SIZE(cpu_gen_info_table); i++) { + if (FIELD_GET(CPU_ID_FAMILY_MASK, cpu_id) + + FIELD_GET(CPU_ID_EXT_FAMILY_MASK, cpu_id) == + cpu_gen_info_table[i].family && + FIELD_GET(CPU_ID_MODEL_MASK, cpu_id) == + FIELD_GET(LOWER_NIBBLE_MASK, + cpu_gen_info_table[i].model) && + FIELD_GET(CPU_ID_EXT_MODEL_MASK, cpu_id) ==
Quoted 9 lines
drivers/mfd/intel-peci-client.c line 69
Quoted 5 lines
drivers/mfd/intel-peci-client.c new file +5
-0+ FIELD_GET(UPPER_NIBBLE_MASK, + cpu_gen_info_table[i].model)) { +break ; + } + }This is really read. Please reformat it, even if you have to use local variables to make it more legible.
Will reformat it using local variables for better readability as you suggest.
Quoted 5 lines
drivers/mfd/intel-peci-client.c line 72
Quoted 2 lines
drivers/mfd/intel-peci-client.c new file +2
-0+if (i >=ARRAY_SIZE (cpu_gen_info_table)) +return -ENODEV ;Do you really want to fail silently?
No. I'll add a dev_err printing.
Quoted 5 lines
drivers/mfd/intel-peci-client.c line 74
Quoted 1 line
drivers/mfd/intel-peci-client.c new file +1
-0+ priv->gen_info = &cpu_gen_info_table[i];If you do this in the
for(), you can then testpriv->gen_infoinstead of seeing if the iterator maxed out. Much nicer I think.
Yes, that would be much nicer. Will fix it.
Quoted 15 lines
Quoted 15 lines
drivers/mfd/intel-peci-client.c new file +15
-0+return 0 ; +} + +bool peci_temp_need_update (struct temp_data *temp) +{ +if (temp->valid && +time_before (jiffies, temp->last_updated +UPDATE_INTERVAL )) +return false; + +return true; +} +EXPORT_SYMBOL_GPL (peci_temp_need_update); + +void peci_temp_mark_updated (struct temp_data *temp) +{
Quoted 9 lines
drivers/mfd/intel-peci-client.c line 94
Quoted 4 lines
drivers/mfd/intel-peci-client.c new file +4
-0+ temp->valid =1 ; + temp->last_updated = jiffies; +} +EXPORT_SYMBOL_GPL (peci_temp_mark_updated);These are probably better suited as inline functions to be placed in a header file. No need to export them, since they only use their own data.
Yes, that makes sense. I'll change these to inline functions.
Quoted 9 lines
drivers/mfd/intel-peci-client.c line 100
Quoted 5 lines
drivers/mfd/intel-peci-client.c new file +5
-0+int peci_client_command (struct peci_mfd *priv,enum peci_cmd cmd,void *vmsg) +{ +return peci_command (priv->adapter, cmd, vmsg); +} +EXPORT_SYMBOL_GPL (peci_client_command);If you share the adaptor with the client, you can call
peci_command()directly. There should also be some locking in here somewhere too.
Yes, the client->adapter can be referenced from child drivers. Will make them call peci_command() directly.
Quoted 4 lines
Quoted 1 line
+int peci_client_rd_pkg_cfg_cmd(struct
peci_mfd*priv, u8mbx_idx,This is gobbledegook. What's rd? Read?
Yes, the 'rd' means 'read'. I intended to keep command names as listed in the PECI specification such as RdPkgConfig, WrPkgConfig and so on. Should I change it to 'peci_client_read_package_config_command' ?
Quoted 11 lines
Quoted 11 lines
drivers/mfd/intel-peci-client.c new file +11
-0+ u16 param, u8 *data) +{ + struct peci_rd_pkg_cfg_msg msg; +int rc; + + msg.addr = priv->addr; + msg.index = mbx_idx; + msg.param = param; + msg.rx_len =4 ; + + rc =peci_command (priv->adapter,PECI_CMD_RD_PKG_CFG , &msg);
Quoted 9 lines
drivers/mfd/intel-peci-client.c line 119
Quoted 6 lines
drivers/mfd/intel-peci-client.c new file +6
-0+if (!rc) +memcpy (data, msg.pkg_config,4 ); + +return rc; +} +EXPORT_SYMBOL_GPL (peci_client_rd_pkg_cfg_cmd);This too should be set-up as an inline function, not an exported one.
Will change it to inline function.
Quoted 8 lines
drivers/mfd/intel-peci-client.c line 125
Quoted 5 lines
drivers/mfd/intel-peci-client.c new file +5
-0+static int peci_client_probe (struct peci_client *client) +{ +struct device *dev = &client->dev; +struct peci_mfd *priv; +int rc;'ret' is more common.
Will fix it.
Quoted 8 lines
Quoted 7 lines
drivers/mfd/intel-peci-client.c new file +7
-0+ priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + +dev_set_drvdata (dev, priv); + priv->client = client; + priv->dev = dev;
Quoted 6 lines
drivers/mfd/intel-peci-client.c line 135
Quoted 2 lines
drivers/mfd/intel-peci-client.c new file +2
-0+ priv->adapter = client->adapter; + priv->addr = client->addr;You're already saving client. No need to save its individual attributes as well.
I intended to reduce pointer referencing depth because adapter and addr are frequently used, but you are right. I'll remove adapter and addr from the struct.
Quoted 6 lines
drivers/mfd/intel-peci-client.c line 136
Quoted 1 line
drivers/mfd/intel-peci-client.c new file +1
-0+ priv->cpu_no = client->addr -PECI_BASE_ADDR ;This seems clunky. Does the spec say that the addresses have to be in numerical order with no gaps? What if someone chooses to implement 4 CPUs at
0x30,0x35,0x45and0x60?
The CPU address will be assigned by H/W strap settings in order. Also, there would be a case of using some CPU slots left empty, so gaps could be happen on the addresses but it's still acceptable.
Quoted 2 lines
What do you then do with
cpu_no?
It is being used for child device id parameter when this code calls devm_mfd_add_devices() below. Also, it is referenced from cputemp and dimmtemp hwmon drivers but it isn't needed because the hwmon drivers already know client->addr. I'll change cpu_no as a local variable in here for child device id and will change the hwmon drivers.
Quoted 13 lines
drivers/mfd/intel-peci-client.c line 147
Quoted 10 lines
drivers/mfd/intel-peci-client.c new file +10
-0+snprintf (priv->name,PECI_NAME_SIZE ,"peci_client.cpu%d" , priv->cpu_no); + + rc =peci_client_get_cpu_gen_info (priv); +if (rc) +return rc; + + rc =devm_mfd_add_devices (priv->dev, priv->cpu_no, peci_functions, +ARRAY_SIZE (peci_functions),NULL ,0 ,NULL ); +if (rc <0 ) { +dev_err (priv->dev,"devm_mfd_add_devices failed: %d\n" , rc);This to too specific.
Quoted 2 lines
"Failed to register child devices"
Will fix it like you suggested.
Quoted 10 lines
Quoted 10 lines
drivers/mfd/intel-peci-client.c new file +10
-0+return rc; + } + +return 0 ; +} + +#ifdef CONFIG_OF +static const struct of_device_id peci_client_of_table[] = { + { .compatible ="intel,peci-client" }, + { }
Quoted 9 lines
drivers/mfd/intel-peci-client.c line 163
Quoted 6 lines
drivers/mfd/intel-peci-client.c new file +6
-0+}; +MODULE_DEVICE_TABLE (of, peci_client_of_table); +#endif + +static const struct peci_device_id peci_client_ids[] = { + { .name ="peci-client" , .driver_data =0 },Remove .driver_data if you're not going to use it.
Okay. I'll remove .driver_data.
Quoted 7 lines
Quoted 7 lines
drivers/mfd/intel-peci-client.c new file +7
-0+ { } +}; +MODULE_DEVICE_TABLE (peci, peci_client_ids); + +static struct peci_driver peci_client_driver = { + .probe = peci_client_probe, + .id_table = peci_client_ids,
Quoted 9 lines
drivers/mfd/intel-peci-client.c line 176
Quoted 6 lines
drivers/mfd/intel-peci-client.c new file +6
-0+ .driver = { + .name = "peci-client", + .of_match_table = + of_match_ptr(peci_client_of_table), + }, +};Odd tabbing.
Will fix the indentation.
Quoted 7 lines
drivers/mfd/intel-peci-client.c line 180
Quoted 4 lines
drivers/mfd/intel-peci-client.c new file +4
-0+module_peci_driver (peci_client_driver); + +MODULE_AUTHOR ("Jae Hyun Yoo <[email protected]>" ); +MODULE_DESCRIPTION ("PECI client MFD driver" );Remove "MFD".
Will remove it.
Quoted 56 lines
Quoted 56 lines
drivers/mfd/intel-peci-client.c new file +1
-0+MODULE_LICENSE ("GPL v2" );include/linux/mfd/intel-peci-client.h new file +49
-0@@ -0,0 +1,81 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2018 Intel Corporation */ + +#ifndef __LINUX_MFD_PECI_CLIENT_H +#define __LINUX_MFD_PECI_CLIENT_H + +#include <linux/peci.h> + +#if IS_ENABLED (CONFIG_X86 ) +#include <asm/intel-family.h> +#else +/** +* Architectures other than x86 cannot include the header file so define these +* at here. These are needed for detecting type of client x86 CPUs behind a PECI +* connection. +*/ +#define INTEL_FAM6_HASWELL_X 0x3F +#define INTEL_FAM6_BROADWELL_X 0x4F +#define INTEL_FAM6_SKYLAKE_X 0x55 +#endif + +#define LOWER_NIBBLE_MASK GENMASK(3, 0) +#define UPPER_NIBBLE_MASK GENMASK(7, 4) + +#define CPU_ID_MODEL_MASK GENMASK(7, 4) +#define CPU_ID_FAMILY_MASK GENMASK(11, 8) +#define CPU_ID_EXT_MODEL_MASK GENMASK(19, 16) +#define CPU_ID_EXT_FAMILY_MASK GENMASK(27, 20) + +#define CORE_MAX_ON_HSX 18/* Max number of cores on Haswell */ +#define CHAN_RANK_MAX_ON_HSX 8/* Max number of channel ranks on Haswell */ +#define DIMM_IDX_MAX_ON_HSX 3/* Max DIMM index per channel on Haswell */ + +#define CORE_MAX_ON_BDX 24/* Max number of cores on Broadwell */ +#define CHAN_RANK_MAX_ON_BDX 4/* Max number of channel ranks on Broadwell */ +#define DIMM_IDX_MAX_ON_BDX 3/* Max DIMM index per channel on Broadwell */ + +#define CORE_MAX_ON_SKX 28/* Max number of cores on Skylake */ +#define CHAN_RANK_MAX_ON_SKX 6/* Max number of channel ranks on Skylake */ +#define DIMM_IDX_MAX_ON_SKX 2/* Max DIMM index per channel on Skylake */ + +#define CORE_NUMS_MAX CORE_MAX_ON_SKX +#define CHAN_RANK_MAX CHAN_RANK_MAX_ON_HSX +#define DIMM_IDX_MAX DIMM_IDX_MAX_ON_HSX +#define DIMM_NUMS_MAX (CHAN_RANK_MAX * DIMM_IDX_MAX) + +#define TEMP_TYPE_PECI 6/* Sensor type 6: Intel PECI */ + +#define UPDATE_INTERVAL HZ
Quoted 9 lines
include/linux/mfd/intel-peci-client.h line 55
Quoted 6 lines
include/linux/mfd/intel-peci-client.h new file +6
-0+ +struct temp_data { +uint valid; +s32 value; +ulong last_updated; +};This should not live in here.
Will move it.
Quoted 12 lines
include/linux/mfd/intel-peci-client.h line 65
Quoted 9 lines
include/linux/mfd/intel-peci-client.h new file +9
-0+struct cpu_gen_info { +u16 family; +u8 model; +uint core_max; +uint chan_rank_max; +uint dimm_idx_max; +}; + +struct peci_mfd {Remove "
_mfd".
Will remove 'mfd'.
Quoted 7 lines
include/linux/mfd/intel-peci-client.h line 69
Quoted 4 lines
include/linux/mfd/intel-peci-client.h new file +4
-0+struct peci_client *client; +struct device *dev; +struct peci_adapter *adapter; +char name[PECI_NAME_SIZE ];What is this used for?
This isn't needed. Thanks for your pointing out. I'll remove it.
Quoted 6 lines
include/linux/mfd/intel-peci-client.h line 72
Quoted 3 lines
include/linux/mfd/intel-peci-client.h new file +3
-0+u8 addr; +uint cpu_no; +const struct cpu_gen_info *gen_info;Where is this used?
It is referenced from cputemp and dimmtemp hwmon drivers to specify CPU generation.
Quoted 4 lines
include/linux/mfd/intel-peci-client.h line 72
Quoted 1 line
include/linux/mfd/intel-peci-client.h new file +1
-0+};Both of these structs need kerneldoc headers.
Will add kerneldoc headers.
Quoted 5 lines
include/linux/mfd/intel-peci-client.h line 76
Quoted 2 lines
include/linux/mfd/intel-peci-client.h new file +2
-0+bool peci_temp_need_update (struct temp_data *temp); +void peci_temp_mark_updated (struct temp_data *temp);These should live in a temperature driver.
Agreed. I'll move it to temperature driver.
Thanks a lot for your careful review. I'll submit a new patch set soon.
Jae
Quoted 6 lines
Quoted 5 lines
include/linux/mfd/intel-peci-client.h new file +5
-0+int peci_client_command (struct peci_mfd *mfd,enum peci_cmd cmd,void *vmsg); +int peci_client_rd_pkg_cfg_cmd (struct peci_mfd *mfd,u8 mbx_idx, +u16 param,u8 *data); + +#endif /* __LINUX_MFD_PECI_CLIENT_H */
Re: [PATCH v8 08/12] mfd: intel-peci-client: Add PECI client MFD driver
Quoted 7 lines · Jae Hyun Yoo
Quoted 4 lines · Lee Jones
Quoted 2 lines · Jae Hyun Yoo
This commit adds PECI client MFD driver.
<snip>
[...]
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/mfd/intel-peci-client.c new file +12
-0+bool peci_temp_need_update (struct temp_data *temp) +{ +if (temp->valid && +time_before (jiffies, temp->last_updated +UPDATE_INTERVAL )) +return false; + +return true; +} +EXPORT_SYMBOL_GPL (peci_temp_need_update); + +void peci_temp_mark_updated (struct temp_data *temp) +{
Quoted 8 lines
Quoted 8 lines
drivers/mfd/intel-peci-client.c line 94
Quoted 4 lines
drivers/mfd/intel-peci-client.c new file +4
-0+ temp->valid =1 ; + temp->last_updated = jiffies; +} +EXPORT_SYMBOL_GPL (peci_temp_mark_updated);These are probably better suited as inline functions to be placed in a header file. No need to export them, since they only use their own data.
Also move them into the HWMON header file.
They have no business in MFD.
[...]
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
+int peci_client_rd_pkg_cfg_cmd(struct
peci_mfd*priv, u8mbx_idx,This is gobbledegook. What's rd? Read?
Yes, the 'rd' means 'read'. I intended to keep command names as listed in the PECI specification such as RdPkgConfig, WrPkgConfig and so on. Should I change it to '
peci_client_read_package_config_command' ?
I looks/reads a lot nicer, don't you think?
[...]
Signature · 4 lines
Lee Jones [???] Linaro Services Technical Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v8 08/12] mfd: intel-peci-client: Add PECI client MFD driver
Quoted 32 lines · Lee Jones
Quoted 7 lines · Jae Hyun Yoo
Quoted 4 lines · Lee Jones
Quoted 2 lines · Jae Hyun Yoo
This commit adds PECI client MFD driver.
<snip>
[...]
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/mfd/intel-peci-client.c new file +12
-0+bool peci_temp_need_update (struct temp_data *temp) +{ +if (temp->valid && +time_before (jiffies, temp->last_updated +UPDATE_INTERVAL )) +return false; + +return true; +} +EXPORT_SYMBOL_GPL (peci_temp_need_update); + +void peci_temp_mark_updated (struct temp_data *temp) +{Quoted 8 lines
Quoted 8 lines
drivers/mfd/intel-peci-client.c line 94
Quoted 4 lines
drivers/mfd/intel-peci-client.c new file +4
-0+ temp->valid =1 ; + temp->last_updated = jiffies; +} +EXPORT_SYMBOL_GPL (peci_temp_mark_updated);These are probably better suited as inline functions to be placed in a header file. No need to export them, since they only use their own data.
Quoted 4 lines
Also move them into the HWMON header file.
They have no business in MFD.
Agreed. I'll move them into the HWMON header.
Quoted 4 lines
[...]
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
+int peci_client_rd_pkg_cfg_cmd(struct
peci_mfd*priv, u8mbx_idx,
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
This is gobbledegook. What's rd? Read?
Yes, the 'rd' means 'read'. I intended to keep command names as listed in the PECI specification such as RdPkgConfig, WrPkgConfig and so on. Should I change it to '
peci_client_read_package_config_command' ?I looks/reads a lot nicer, don't you think?
Okay. I'll change it too.
Thanks again for your review, Lee!
Jae
Quoted 2 lines
[...]