Skip to content

Commit

Permalink
infra: Fix DDR5 memory issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ish-hcc committed May 10, 2024
1 parent eae49ac commit 4dcb680
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
24 changes: 23 additions & 1 deletion driver/infra/compute_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ func getKernelVersion() (string, error) {
return output, nil
}

func ddr5MemoryFix(memoryType memory.MemoryDeviceType) string {
// Reference: https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.4.0a.pdf
const DDR5 = 34
const LPDDR5 = 35

switch memoryType {
case DDR5:
return "DDR5"
case LPDDR5:
return "LPDDR5"
default:
return memory.MemoryDeviceTypeUnknown.String()
}
}

func GetComputeInfo() (infra.Compute, error) {
var compute infra.Compute

Expand Down Expand Up @@ -113,6 +128,7 @@ func GetComputeInfo() (infra.Compute, error) {
}

var memType = memory.MemoryDeviceTypeUnknown
var memTypeString string
var memSpeed = uint(0)
var memSize = uint(0)

Expand All @@ -126,6 +142,12 @@ func GetComputeInfo() (infra.Compute, error) {
}
}

if memType > memory.MemoryDeviceTypeLPDDR4 {
memTypeString = ddr5MemoryFix(memType)
} else {
memTypeString = memType.String()
}

// TODO
// storage information
//var si sysinfo.SysInfo
Expand Down Expand Up @@ -183,7 +205,7 @@ func GetComputeInfo() (infra.Compute, error) {
Threads: threads,
},
Memory: infra.Memory{
Type: memType.String(),
Type: memTypeString,
Speed: memSpeed,
Size: memSize,
},
Expand Down
24 changes: 23 additions & 1 deletion driver/infra/compute_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,21 @@ func getVirtualMachineType(dmidecode *dmidecode.Decoder) (string, error) {
return checkVirtualMachineRegistry(), nil
}

func ddr5MemoryFix(memoryType memory.MemoryDeviceType) string {
// Reference: https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.4.0a.pdf
const DDR5 = 34
const LPDDR5 = 35

switch memoryType {
case DDR5:
return "DDR5"
case LPDDR5:
return "LPDDR5"
default:
return memory.MemoryDeviceTypeUnknown.String()
}
}

func GetComputeInfo() (infra.Compute, error) {
var compute infra.Compute

Expand Down Expand Up @@ -330,6 +345,7 @@ func GetComputeInfo() (infra.Compute, error) {
}

var memType = memory.MemoryDeviceTypeUnknown
var memTypeString string
var memSpeed = uint(0)
var memSize = uint(0)

Expand All @@ -343,6 +359,12 @@ func GetComputeInfo() (infra.Compute, error) {
}
}

if memType > memory.MemoryDeviceTypeLPDDR4 {
memTypeString = ddr5MemoryFix(memType)
} else {
memTypeString = memType.String()
}

// TODO
// storage information

Expand Down Expand Up @@ -403,7 +425,7 @@ func GetComputeInfo() (infra.Compute, error) {
Threads: threads,
},
Memory: infra.Memory{
Type: memType.String(),
Type: memTypeString,
Speed: memSpeed,
Size: memSize,
},
Expand Down

0 comments on commit 4dcb680

Please sign in to comment.