From 2d658bfeca6adceb55153dd42cf63a661cd37baf Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Tue, 6 Aug 2024 14:21:59 +0200 Subject: [PATCH] SysFSTools: lscpi: move mdev and iommugroup check outside of verbose they should not be expensive (only reading/file checking in sysfs; the parsed vendor/id names are not required) so we should include them always. We need at least the mdev part later at a point where we're not interested in the rest of the verbose mode. Signed-off-by: Dominik Csapak Tested-by: Christoph Heiss Reviewed-by: Christoph Heiss --- src/PVE/SysFSTools.pm | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/PVE/SysFSTools.pm b/src/PVE/SysFSTools.pm index 25b2f31..0bde6d7 100644 --- a/src/PVE/SysFSTools.pm +++ b/src/PVE/SysFSTools.pm @@ -103,21 +103,21 @@ sub lspci { return; } + $res->{iommugroup} = -1; + if (-e "$devdir/iommu_group") { + my ($iommugroup) = (readlink("$devdir/iommu_group") =~ m/\/(\d+)$/); + $res->{iommugroup} = int($iommugroup); + } + + if (-d "$devdir/mdev_supported_types") { + $res->{mdev} = 1; + } elsif (-d "$devdir/nvidia") { + # nvidia driver for kernel 6.8 or higher + $res->{mdev} = 1; # for api compatibility + $res->{nvidia} = 1; + } + if ($verbose) { - $res->{iommugroup} = -1; - if (-e "$devdir/iommu_group") { - my ($iommugroup) = (readlink("$devdir/iommu_group") =~ m/\/(\d+)$/); - $res->{iommugroup} = int($iommugroup); - } - - if (-d "$devdir/mdev_supported_types") { - $res->{mdev} = 1; - } elsif (-d "$devdir/nvidia") { - # nvidia driver for kernel 6.8 or higher - $res->{mdev} = 1; # for api compatibility - $res->{nvidia} = 1; - } - my $device_hash = $ids->{$vendor}->{devices}->{$device} // {}; my $sub_vendor = file_read_firstline("$devdir/subsystem_vendor");