]> mj.ucw.cz Git - pciutils.git/commit
lspci: Fix detection of virtual regions
authorPali Rohár <pali@kernel.org>
Sat, 5 Mar 2022 23:22:03 +0000 (00:22 +0100)
committerPali Rohár <pali@kernel.org>
Fri, 15 Apr 2022 22:01:13 +0000 (00:01 +0200)
commit7f96c3feb701dea64c1941d27ef590cd03781b55
tree7ee5b24ba49f94c3d31be16b9cd9ce06ca0c5455
parent7eb8b9473317562e0b66bd3e8c467e127d88dac8
lspci: Fix detection of virtual regions

There are many issues with detection of virtual regions.

1. Variable for detecting virtual region is global and if one BAR is marked
   as virtual then all remaining BARs are treated as virtual too as this
   variable is not reset at next loop iteration.

2. Lower address is read from flg variable which on backends without config
   space is initialized from PCI flags, not from base address.

3. Code mixes at many places PCI flags, resource flags, PCI addresses and
   resource addresses. Some backends reports PCI flags in PCI addresses,
   some not.

Cleanup mess of ->base_addr, ->flags and PCI_BASE_ADDRESS. If backend
provides ->flags value (test via PCI_FILL_IO_FLAGS) then use it instead of
reading flags from pci config space.

Fix reading of PCI hw_lower and hw_upper addresses. If PCI_BASE_ADDRESS
reports different type than what is stored in base_addr then completely
ignore hw_lower and hw_upper values. It means that backend either provide
fiction information or provide resources in different order as they are
stored in hardware. In any case values from HW cannot be used as they do
not match values reported by backend.

And in the last case, make virtual variable local to the current BAR
processing and do not increment loop variable i when 64-bit MEM type is
detected via data from config space. It could miss some virtual resource
reported by the backend.

This change fixes displaying resources of PCI devices which have some
unset/unused BARs in the middle and OS reports virtual regions and
remaining regions without holes. E.g. HW BARs 0, 2, 5 are used and OS
reports base_addr 0, 1, 2, 3.
lspci.c