]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
LinuxKPI: fix pci_alloc_irq_vectors() for MSI
authorBjoern A. Zeeb <bz@FreeBSD.org>
Mon, 28 Nov 2022 18:05:48 +0000 (18:05 +0000)
committerBjoern A. Zeeb <bz@FreeBSD.org>
Fri, 13 Jan 2023 00:39:24 +0000 (00:39 +0000)
commite9715b1c4474333ff119aba3a9a74bff91f72372
treecc19a1c6b8a24af861862fc2bf74c0e0abfcd2e5
parent75388b9ca5e566fb7cbd62a37cea1f66d8203fc6
LinuxKPI: fix pci_alloc_irq_vectors() for MSI

pci_alloc_irq_vectors() is given a min and max vector value.
pci_enable_msi() will always succeed independent of these arguments as
it does not know about them.  Further it will only ever allocate
1 "vector" not supporting any other amount.
So upfront check that (a) the available pci_msi_count() can satisfy the
requested minv and (b) given the pci_enable_msi() hard coded limit check
that minv is not larger than 1.
If we cannot satisfy either requirement return an error.

This fixes problems with drivers which check that the returned value
of allocated "vectors" will match their requests and only otherwise try
to fall back to ask for 1 or deal otherwise.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: hselasky (earlier version)
Differential Revision: https://reviews.freebsd.org/D37522
sys/compat/linuxkpi/common/src/linux_pci.c