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 <d.csapak@proxmox.com>
Tested-by: Christoph Heiss <c.heiss@proxmox.com>
Reviewed-by: Christoph Heiss <c.heiss@proxmox.com>
This commit is contained in:
Dominik Csapak 2024-08-06 14:21:59 +02:00 committed by Thomas Lamprecht
parent dc023d60c5
commit 2d658bfeca

View File

@ -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");