sst: add support for TPMI interface and SST-TF#181
Conversation
4f936e8 to
78de4c7
Compare
There was a problem hiding this comment.
Pull request overview
Adds support for the newer SST TPMI (API v2+) interface and refactors the existing Mbox/MMIO (API v1) implementation into separate backend-specific files with a small dispatcher that selects the correct interface at runtime.
Changes:
- Introduce TPMI implementation (
sst_tpmi.go) and a runtime backend dispatcher insst.go(TPMI for API v2+, Mbox for v1). - Split existing Mbox/MMIO code into
sst_mbox.goand move shared helpers intosst_common.go. - Extend generated SST ioctl constants/types for TPMI and add sysfs helpers for socket/die lookup.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/sst/sysfs.go | Adds sysfs helpers to read socket/die IDs for a CPU. |
| pkg/sst/sst_types_amd64.go | Updates generated ioctl constants/types to include TPMI definitions. |
| pkg/sst/sst_tpmi.go | New TPMI backend implementation (platform info, perf levels, CP/CLOS/BF interactions). |
| pkg/sst/sst_mbox.go | New file containing the refactored Mbox/MMIO backend logic previously in sst.go. |
| pkg/sst/sst_common.go | Adds shared helper(s) used by both backends (e.g., punit core id derivation). |
| pkg/sst/sst.go | Adds backend dispatcher + routes core operations through backend; adjusts CP reset/configure flows accordingly. |
| pkg/sst/fuzz_test.go | Updates system fuzz test to call backend-specific package-info retrieval. |
| pkg/sst/_sst_types_amd64.go | Extends cgo source types/constants used to generate sst_types_amd64.go with TPMI items. |
Comments suppressed due to low confidence (1)
pkg/sst/fuzz_test.go:91
- On TPMI platforms,
backend.getSinglePackageInfo()populates only a subset ofSstClosInfofields (e.g., EPP/DesiredFreq aren’t read back), but this fuzz test compares the full struct. This will cause false failures on TPMI systems. Either compare only the fields supported by the active backend or gate/skip TPMI in this test until those fields are implemented for TPMI.
info, err := backend.getSinglePackageInfo(pkgs[pkg].pkg)
if err != nil {
t.Errorf("failed to get package info: %v", err)
}
if !cmp.Equal(info.ClosInfo[clos], *expectedInfo) {
t.Errorf("CLOS not configured correctly, expected %v, got %v", expectedInfo, info.ClosInfo[clos])
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d508d44 to
8fea0f3
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
pkg/sst/sst_if.go:42
cpuMapis a package-levelmapthat is read and written frompunitCPUwithout synchronization. If SST APIs are called concurrently (e.g., multiple goroutines callingGetPackageInfo/ClosSetup), this can trigger a "concurrent map read and map write" panic or a data race. ProtectcpuMapwith a mutex (or usesync.Map) around both the read and write paths.
// cpuMap holds the logical to punit cpu mapping table
var cpuMap = make(map[uint16]uint16)
// punitCPU returns the PUNIT CPU id corresponding a given Linux logical CPU
func punitCPU(cpu uint16) (uint16, error) {
if id, ok := cpuMap[cpu]; ok {
return id, nil
}
id, err := getCPUMapping(cpu)
if err == nil {
cpuMap[cpu] = id
}
return id, err
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c47a370 to
7587acf
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
pkg/sst/sst_if.go:41
cpuMapis a package-levelmapthat is read and written fromgetPunitCPUIdwithout any synchronization. If SST APIs are called concurrently, this can trigger a data race or even a runtime panic (concurrent map writes). Protect the cache with a mutex (or usesync.Map), or build the mapping table once up-front and treat it as immutable thereafter.
// cpuMap holds the logical to punit cpu mapping table
var cpuMap = make(map[uint16]uint16)
// getPunitCPUId returns the PUNIT CPU id corresponding a given Linux logical CPU.
func getPunitCPUId(cpu uint16) (uint16, error) {
if id, ok := cpuMap[cpu]; ok {
return id, nil
}
id, err := getCPUMapping(cpu)
if err == nil {
cpuMap[cpu] = id
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c702a59 to
8891806
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 26 changed files in this pull request and generated 2 comments.
Files not reviewed (1)
- pkg/sst/isst/types_amd64.go: Language not supported
Comments suppressed due to low confidence (1)
pkg/sst/isst/_types_priv.go:20
- The regeneration instructions in this header are incorrect:
types_priv.gois generated via//go:generate ./gen_types.shinpkg/sst/isst/isst.go, sogo generate ./pkg/sst/mbox/...will not regenerate this file. Update the comment to point at the correctgo generatepath (e.g.go generate ./pkg/sst/isst/...orgo generate ./pkg/sst/...).
8c23e00 to
b6d90cf
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 26 changed files in this pull request and generated 3 comments.
Files not reviewed (1)
- pkg/sst/isst/types_amd64.go: Language not supported
Comments suppressed due to low confidence (1)
pkg/sst/isst/_types_priv.go:19
- The regeneration hint points to the wrong package path. This file is in
pkg/sst/isstand the generator is//go:generate ./gen_types.shinpkg/sst/isst/isst.go, sogo generate ./pkg/sst/mbox/...will not updatetypes_priv.goand is misleading. Update the comment to the correctgo generateinvocation (e.g../pkg/sst/isst/...or./pkg/sst/...).
c418351 to
aeb7fa9
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 26 changed files in this pull request and generated 2 comments.
Files not reviewed (1)
- pkg/sst/isst/types_amd64.go: Language not supported
Comments suppressed due to low confidence (1)
pkg/sst/isst/_types_priv.go:20
- The regeneration instructions in this file point to
go generate ./pkg/sst/mbox/..., but thego:generatedirective that producestypes_priv.golives inpkg/sst/isst/isst.goand runs./gen_types.sh. Update the comment to reference the correct package/path so contributors can regenerate the file reliably.
This big patch contains two main changes:
1. Introduce new API, required to to cover the new TPMI kernel
interface.
2. Add support for the TPMI interface of the Linux kernel
The patch contains heavy refactoring, almost full rewrite of some parts.
It splits part of the code into separate sub-packages (mbox/ tmpi/
isst/) to make the code more maintainable.
The old SST API is marked as deprecated but is still available for
backwards compatibility. The old (deprecated) API functions are wrappers
around the new API and thus also support platforms that require the new
TPMI interface.
An outline of the new API:
Initialization:
SstSupported()
Init()
SetLogger()
Platform methods:
Platform.Packages() (get all packages)
Platform.Package() (get one package)
Platform.ClosCount()
Platform.ClosAssociate()
Platform.GetCPUClosID()
Package methods:
Package.ID()
Package.GetStatus()
Package.BFEnable()
Package.BFDisable() error
Package.CPEnable()
Package.CPDisable()
Package.CPReset()
Package.CPSetPriorityType()
Package.ClosConfigure()
Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
Add new sst client that uses the new SST API. The old cmd/sst-ctl is left untouched, as an example client to test the old deprecated API. Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 26 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- pkg/sst/isst/types_amd64.go: Language not supported
Comments suppressed due to low confidence (1)
pkg/sst/isst/_types_priv.go:19
- The regeneration instructions are incorrect: this file belongs to the
isstpackage and itsgo:generateentry point ispkg/sst/isst/isst.go(//go:generate ./gen_types.sh).go generate ./pkg/sst/mbox/...won’t regeneratetypes_priv.goand may mislead contributors. Update the comment to point at the correct package path (e.g.go generate ./pkg/sst/isst/...orgo generate ./pkg/sst/...).
| flag.Usage = usage | ||
|
|
||
| help := flag.Bool("help", false, "Display this help") | ||
| logLevel := log.NewLevelFlag(slog.LevelDebug) |
There was a problem hiding this comment.
Wondering if we could use LevelInfo as a default? (Ran sst status successfully out-of-the-box on a host, debug output was quite overwhelming.)
Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
|
Updated: added SST-TF support to the PR. I'd appreciate feedback on the API design 😊 Also on small things like XEnable()/XDisasable() vs. XSetStatus(enable bool) |
This big patch contains four main changes (split into two commits):
interface.
The first patch contains heavy refactoring, almost full rewrite of some parts. It splits part of the code into separate sub-packages (mbox/ tmpi/ isst/) to make the code more maintainable.
The old SST API is marked as deprecated but is still available for backwards compatibility. The old (deprecated) API functions are wrappers around the new API and thus also support platforms that require the new TPMI interface.
An outline of the new API:
Initialization:
Platform methods:
Package methods:
Note
The PR enables package-level controls. Punit-level controls can be added later if needed (and we're sure that's safe and sound).