[PATCH v8 00/10] misc: Move AMD side band interface(SBI) functionality

Akshay Gupta posted 10 patches 8 months, 1 week ago
There is a newer version of this series
Documentation/misc-devices/amd-sbi.rst        |  99 ++++
Documentation/misc-devices/index.rst          |   1 +
.../userspace-api/ioctl/ioctl-number.rst      |   2 +
drivers/hwmon/Kconfig                         |  10 -
drivers/hwmon/sbrmi.c                         | 357 -------------
drivers/misc/Kconfig                          |   1 +
drivers/misc/Makefile                         |   1 +
drivers/misc/amd-sbi/Kconfig                  |  18 +
drivers/misc/amd-sbi/Makefile                 |   4 +
drivers/misc/amd-sbi/rmi-core.c               | 474 ++++++++++++++++++
drivers/misc/amd-sbi/rmi-core.h               |  74 +++
drivers/misc/amd-sbi/rmi-hwmon.c              | 120 +++++
drivers/misc/amd-sbi/rmi-i2c.c                | 133 +++++
include/uapi/misc/amd-apml.h                  | 152 ++++++
14 files changed, 1079 insertions(+), 367 deletions(-)
create mode 100644 Documentation/misc-devices/amd-sbi.rst
delete mode 100644 drivers/hwmon/sbrmi.c
create mode 100644 drivers/misc/amd-sbi/Kconfig
create mode 100644 drivers/misc/amd-sbi/Makefile
create mode 100644 drivers/misc/amd-sbi/rmi-core.c
create mode 100644 drivers/misc/amd-sbi/rmi-core.h
create mode 100644 drivers/misc/amd-sbi/rmi-hwmon.c
create mode 100644 drivers/misc/amd-sbi/rmi-i2c.c
create mode 100644 include/uapi/misc/amd-apml.h
[PATCH v8 00/10] misc: Move AMD side band interface(SBI) functionality
Posted by Akshay Gupta 8 months, 1 week ago
At present, sbrmi driver under hwmon subsystem, is probed as an i2c driver,
fetches data using APML specified protocol and reports through hwmon power sensor.

AMD provides additional information using custom protocols, which cannot be
enumerated as hwmon sensors. Hence, move the existing functionality from hwmon/
to misc/ and add support for following custom protocols
  - read Processor feature capabilities and configuration information
    through side band.
  - read Machine Check Architecture(MCA) registers over sideband.
    The information is accessed for range of MCA registers by passing
    register address and thread ID to the protocol.

NOTE: AMD defines Advanced Platform Management Link (APML) interface which provides
system management functionality access to the baseboard management
controller (BMC).

This patchset is an attempt to keep all APML core functionality in one place,
provide hwmon and IOCTL interface to user space
1. [Patch 1] Move the i2c client probe, hwmon sensors and sbrmi core functionality
   from drivers/hwmon to drivers/misc/
2. [Patch 2] Move sbrmi core functionality to new core file to export core functionality
3. [Patch 3] Move hwmon device sensor as separate entity
4. [Patch 4] Convert i2c to regmap which provides multiple benefits
   over direct smbus APIs.
    a. i2c/i3c support and
    b. 1 byte/2 byte RMI register size addressing
5. [Patch 5] Optimize wait condition with regmap API regmap_read_poll_timeout as per
   suggestion from Arnd
6. [Patch 6] Register a misc device which provides
    a. An ioctl interface through node /dev/sbrmiX
    b. Register sets is common across APML protocols. IOCTL is providing
       synchronization among protocols as transactions may create
       race condition.
7. [Subsequent patches 7, 8 and 9] add support for AMD custom protocols through additional IOCTLs
    a. CPUID
    b. MCAMSR
    c. Register xfer
8. [Patch 10] AMD side band description document

Open-sourced and widely used [1]_ will continue to provide user-space programmable API.

.. [1] https://github.com/amd/esmi_oob_library


*** BLURB HERE ***

Akshay Gupta (10):
  hwmon/misc: amd-sbi: Move core sbrmi from hwmon to misc
  misc: amd-sbi: Move protocol functionality to core file
  misc: amd-sbi: Move hwmon device sensor as separate entity
  misc: amd-sbi: Use regmap subsystem
  misc: amd-sbi: Optimize the wait condition for mailbox command
    completion
  misc: amd-sbi: Add support for AMD_SBI IOCTL
  misc: amd-sbi: Add support for CPUID protocol
  misc: amd-sbi: Add support for read MCA register protocol
  misc: amd-sbi: Add support for register xfer
  misc: amd-sbi: Add document for AMD SB IOCTL description

 Documentation/misc-devices/amd-sbi.rst        |  99 ++++
 Documentation/misc-devices/index.rst          |   1 +
 .../userspace-api/ioctl/ioctl-number.rst      |   2 +
 drivers/hwmon/Kconfig                         |  10 -
 drivers/hwmon/sbrmi.c                         | 357 -------------
 drivers/misc/Kconfig                          |   1 +
 drivers/misc/Makefile                         |   1 +
 drivers/misc/amd-sbi/Kconfig                  |  18 +
 drivers/misc/amd-sbi/Makefile                 |   4 +
 drivers/misc/amd-sbi/rmi-core.c               | 474 ++++++++++++++++++
 drivers/misc/amd-sbi/rmi-core.h               |  74 +++
 drivers/misc/amd-sbi/rmi-hwmon.c              | 120 +++++
 drivers/misc/amd-sbi/rmi-i2c.c                | 133 +++++
 include/uapi/misc/amd-apml.h                  | 152 ++++++
 14 files changed, 1079 insertions(+), 367 deletions(-)
 create mode 100644 Documentation/misc-devices/amd-sbi.rst
 delete mode 100644 drivers/hwmon/sbrmi.c
 create mode 100644 drivers/misc/amd-sbi/Kconfig
 create mode 100644 drivers/misc/amd-sbi/Makefile
 create mode 100644 drivers/misc/amd-sbi/rmi-core.c
 create mode 100644 drivers/misc/amd-sbi/rmi-core.h
 create mode 100644 drivers/misc/amd-sbi/rmi-hwmon.c
 create mode 100644 drivers/misc/amd-sbi/rmi-i2c.c
 create mode 100644 include/uapi/misc/amd-apml.h

-- 
2.25.1
Re: [PATCH v8 00/10] misc: Move AMD side band interface(SBI) functionality
Posted by Arnd Bergmann 8 months, 1 week ago
On Fri, Apr 11, 2025, at 15:31, Akshay Gupta wrote:
> At present, sbrmi driver under hwmon subsystem, is probed as an i2c 
> driver,
> fetches data using APML specified protocol and reports through hwmon 
> power sensor.
>
> AMD provides additional information using custom protocols, which cannot be
> enumerated as hwmon sensors. Hence, move the existing functionality from hwmon/
> to misc/ and add support for following custom protocols
>   - read Processor feature capabilities and configuration information
>     through side band.
>   - read Machine Check Architecture(MCA) registers over sideband.
>     The information is accessed for range of MCA registers by passing
>     register address and thread ID to the protocol.
>
> NOTE: AMD defines Advanced Platform Management Link (APML) interface 
> which provides
> system management functionality access to the baseboard management
> controller (BMC).

I think this addresses all my comments, thanks for the update.

> Open-sourced and widely used [1]_ will continue to provide user-space 
> programmable API.
>
> .. [1] https://github.com/amd/esmi_oob_library

I'm still a little uneasy about the low-level mailbox interface
being exposed in a character device, but assuming that everyone
else is fine with having that in principle, I think the way the
interface is structured in this version is good enough.

     Arnd
Re: [PATCH v8 00/10] misc: Move AMD side band interface(SBI) functionality
Posted by Gupta, Akshay 8 months, 1 week ago
On 4/11/2025 7:21 PM, Arnd Bergmann wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> On Fri, Apr 11, 2025, at 15:31, Akshay Gupta wrote:
>> At present, sbrmi driver under hwmon subsystem, is probed as an i2c
>> driver,
>> fetches data using APML specified protocol and reports through hwmon
>> power sensor.
>>
>> AMD provides additional information using custom protocols, which cannot be
>> enumerated as hwmon sensors. Hence, move the existing functionality from hwmon/
>> to misc/ and add support for following custom protocols
>>    - read Processor feature capabilities and configuration information
>>      through side band.
>>    - read Machine Check Architecture(MCA) registers over sideband.
>>      The information is accessed for range of MCA registers by passing
>>      register address and thread ID to the protocol.
>>
>> NOTE: AMD defines Advanced Platform Management Link (APML) interface
>> which provides
>> system management functionality access to the baseboard management
>> controller (BMC).
> I think this addresses all my comments, thanks for the update.
>
>> Open-sourced and widely used [1]_ will continue to provide user-space
>> programmable API.
>>
>> .. [1] https://github.com/amd/esmi_oob_library
> I'm still a little uneasy about the low-level mailbox interface
> being exposed in a character device, but assuming that everyone
> else is fine with having that in principle, I think the way the
> interface is structured in this version is good enough.
>
>       Arnd

Thank you for quick review.
I see a kernel test robot error in patch 09/10, where require to use 
"__u16" instead of "u16" in the structure. I will submit patch version 9 
to address this.

Can I add your "Reviewed-by:" for the other patches?