GPU: detect current pcie link speed

This commit is contained in:
Carter Li
2026-06-14 17:36:54 +08:00
committed by 李通洲
parent 107f39eb15
commit 22f9948497
18 changed files with 190 additions and 79 deletions
+18 -5
View File
@@ -17,6 +17,7 @@ struct FFIgclData {
FF_LIBRARY_SYMBOL(ctlEnumFrequencyDomains)
FF_LIBRARY_SYMBOL(ctlFrequencyGetProperties)
FF_LIBRARY_SYMBOL(ctlPciGetProperties)
FF_LIBRARY_SYMBOL(ctlPciGetState)
bool inited;
ctl_api_handle_t apiHandle;
@@ -45,6 +46,7 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlEnumFrequencyDomains)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlFrequencyGetProperties)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlPciGetProperties)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlPciGetState)
if (ffctlInit(&(ctl_init_args_t) {
.AppVersion = CTL_IMPL_VERSION,
@@ -229,14 +231,25 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe
ffStrbufSetS(result.name, properties.name);
}
if (result.pcieGen || result.pcieLanes) {
if (result.psMax) {
ctl_pci_properties_t pciProps = { .Size = sizeof(pciProps), .Version = 0 };
if (igclData.ffctlPciGetProperties(device, &pciProps) == CTL_RESULT_SUCCESS) {
if (result.pcieGen && pciProps.maxSpeed.gen > 0) {
*result.pcieGen = (uint16_t) pciProps.maxSpeed.gen;
if (pciProps.maxSpeed.gen > 0) {
result.psMax->gen = (uint16_t) pciProps.maxSpeed.gen;
}
if (result.pcieLanes && pciProps.maxSpeed.width > 0) {
*result.pcieLanes = (uint16_t) pciProps.maxSpeed.width;
if (pciProps.maxSpeed.width > 0) {
result.psMax->lanes = (uint16_t) pciProps.maxSpeed.width;
}
}
}
if (result.psCurr) {
ctl_pci_state_t pciState = { .Size = sizeof(pciState), .Version = 0 };
if (igclData.ffctlPciGetState(device, &pciState) == CTL_RESULT_SUCCESS) {
if (pciState.speed.gen > 0) {
result.psMax->gen = (uint16_t) pciState.speed.gen;
}
if (pciState.speed.width > 0) {
result.psMax->lanes = (uint16_t) pciState.speed.width;
}
}
}