PCI/MSI: Re-design MSI/MSI-X interrupts enablement pattern

Currently pci_enable_msi_block() and pci_enable_msix() interfaces
return a error code in case of failure, 0 in case of success and a
positive value which indicates the number of MSI-X/MSI interrupts
that could have been allocated. The latter value should be passed
to a repeated call to the interfaces until a failure or success.

This technique proved to be confusing and error-prone. Vast share
of device drivers simply fail to follow the described guidelines.

This update converts pci_enable_msix() and pci_enable_msi_block()
interfaces to canonical kernel functions and makes them return a
error code in case of failure or 0 in case of success.

As result, device drivers will cease to use the overcomplicated
repeated fallbacks technique and resort to a straightforward
pattern - determine the number of MSI/MSI-X interrupts required
before calling pci_enable_msix() and pci_enable_msi_block()
interfaces.

Device drivers will use their knowledge of underlying hardware
to determine the number of MSI/MSI-X interrupts required.

The simplest case would be requesting all available interrupts -
to obtain that value device drivers will use pci_get_msi_cap()
interface for MSI and pci_msix_table_size() for MSI-X.

More complex cases would entail matching device capabilities
with the system environment, i.e. limiting number of hardware
queues (and hence associated MSI/MSI-X interrupts) to the number
of online CPUs.

Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
PCI/MSI: Get rid of pci_enable_msi_block_auto() interface

As result of recent re-design of MSI/MSI-X interrupts enabling
pattern pci_enable_msi_block_auto() interface became obsolete.

To enable maximum number of MSI interrupts for a device the
driver will first obtain that number from pci_get_msi_cap()
function and then call pci_enable_msi_block() interface.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
ahci: Update MSI/MSI-X interrupts enablement code

As result of recent re-design of the MSI/MSI-X interrupts enabling
pattern this driver has to be updated to use the new technique to
obtain a optimal number of MSI/MSI-X interrupts required.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
ahci: Check MRSM bit when multiple MSIs enabled

Do not trust the hardware and always check if MSI
Revert to Single Message mode was enforced. Fall
back to the single MSI mode in case it did. Not
doing so might screw up the interrupt handling.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
benet: Return -ENOSPC when not enough MSI-Xs available

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
benet: Update MSI/MSI-X interrupts enablement code

As result of recent re-design of the MSI/MSI-X interrupts enabling
pattern this driver has to be updated to use the new technique to
obtain a optimal number of MSI/MSI-X interrupts required.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
bna: Update MSI/MSI-X interrupts enablement code

As result of recent re-design of the MSI/MSI-X interrupts enabling
pattern this driver has to be updated to use the new technique to
obtain a optimal number of MSI/MSI-X interrupts required.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
bnx2x: Update MSI/MSI-X interrupts enablement code

As result of recent re-design of the MSI/MSI-X interrupts enabling
pattern this driver has to be updated to use the new technique to
obtain a optimal number of MSI/MSI-X interrupts required.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
bnx2: Update MSI/MSI-X interrupts enablement code

As result of recent re-design of the MSI/MSI-X interrupts enabling
pattern this driver has to be updated to use the new technique to
obtain a optimal number of MSI/MSI-X interrupts required.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
cciss: Update MSI/MSI-X interrupts enablement code

As result of recent re-design of the MSI/MSI-X interrupts enabling
pattern this driver has to be updated to use the new technique to
obtain a optimal number of MSI/MSI-X interrupts required.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
cciss: Update a misleading comment on interrupt usage

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
cciss: Fallback to single MSI mode in case MSI-X failed

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
csiostor: Do not call pci_disable_msix() if pci_enable_msix() failed

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
csiostor: Return -ENOSPC when not enough MSI-X vectors available

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
csiostor: Update MSI/MSI-X interrupts enablement code

As result of recent re-design of the MSI/MSI-X interrupts enabling
pattern this driver has to be updated to use the new technique to
obtain a optimal number of MSI/MSI-X interrupts required.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
cxgb3: Do not call pci_disable_msix() if pci_enable_msix() failed

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
cxgb3: Return -ENOSPC when not enough MSI-X vectors available

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
cxgb3: Update MSI/MSI-X interrupts enablement code

As result of recent re-design of the MSI/MSI-X interrupts enabling
pattern this driver has to be updated to use the new technique to
obtain a optimal number of MSI/MSI-X interrupts required.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
cxgb4: Return -ENOSPC when not enough MSI-X vectors available

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
cxgb4: Update MSI/MSI-X interrupts enablement code

As result of recent re-design of the MSI/MSI-X interrupts enabling
pattern this driver has to be updated to use the new technique to
obtain a optimal number of MSI/MSI-X interrupts required.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>