LinuxKPI: pci: implement [linuxkpi_]pcim_request_all_regions()
Factor out the pci_request_region() implementation into an internal
function and make pci_request_region() a simple wrapperaround it.
Likewise implement pcim_request_all_regions() as a loop calling
pci_request_region() for each entry.
In two cases which we returned an error before (bar index is valid but
bar is not (no len), and neither IO nor MEM) we now reutrn success
(nothing to do for us). Otherwise callers, especially
pcim_request_all_regions() would error out for the wrong reasons.
This seems to also match the expected behaviour of pci_request_region().
Sponsored by: The FreeBSD Foundation (intially)
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D52068
LinuxKPI: pci: undo the pci_resource_len() check in lkpi_pci_request_region()
Creating non-passthru SR-IOV interfaces on a mlx5en(4) failed.
The problem lies in the pci_resource_len() call but not that the BAR length
is tmeporary 0 but in that we call lkpi_pci_get_bar() with a true argument
which will create the BAR resource for us and report the approriate length
back. However, the later call to bus_alloc_resource_any() will then fail
given the resource already exists.
Restore the previous behaviour and let bus_alloc_resource_any() do the
work. Adjust the return values from -ENODEV to -EBUSY to match callers
expectations.
In linuxkpi_pcim_request_all_regions(), like in linuxkpi_pci_request_regions(),
filter out the -EBUSY errors as "not an error" and try the next bar.
This also seems to be consistent with the expectations of the callers.
PR: 290793
Reported by: David BOYER (jcduss13 gmail.com)
Tested on: mlx5en, iwlwifi, mt7921
Reviewed by: kib
Fixes: 7e21158d44cd "implement [linuxkpi_]pcim_request_all_regions()"
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53902
(cherry picked from commit 7e21158d44cd46e720395604ca6f00f2fa36b20c)
(cherry picked from commit ff31767e530abb4a54131af199fed6ec946a5fa4)
(cherry picked from commit ed29ffd396e522a45ab1980c12a75b3409b51712)
(cherry picked from commit 2032abb31cbe067d41067a81e529d91f1bace4c9)