PCI/MSI: Get rid of pci_enable_msi_block_auto() interface

As result of introduction of pci_get_msi_cap() interface
pci_enable_msi_block_auto() function became superflous.

To enable maximum possible number of MSIs drivers will
first obtain that number from pci_get_msi_cap() function
and then call pci_enable_msi_block() interface.

[TODO Changelog]
It'd be nice to mention that _auto has been introduced recently and
has only single user in ahci which is updated by this patch.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Acked-by: Tejun Heo <tj@kernel.org>

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
PCI/MSI: Convert pci_msix_table_size() to a public interface

Make pci_msix_table_size() return error code if the device
does not support MSI-X. This update is needed to create a
consistent MSI-X counterpart for pci_get_msi_cap() MSI
interface.

Device drivers can use this interface to obtain maximum number
of MSI-X interrupts the device supports and i.e. use that number
in a following call to pci_enable_msix() interface.

[TODO Changelog]
Please mention that the return value of the function has been changed
in the description.  Also, do we want to rename it to
pci_get_msix_cap() for consistency?

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Reviewed-by: Tejun Heo <tj@kernel.org>
PCI/MSI: Introduce pcim_enable_msi*() family helpers

Currently many device drivers need contiguously call functions
pci_enable_msix() for MSI-X or pci_enable_msi_block() for MSI
in a loop until success or failure. This update generalizes
this usage pattern and introduces pcim_enable_msi*() family
helpers.

As result, device drivers do not have to deal with tri-state
return values from pci_enable_msix() and pci_enable_msi_block()
functions directly and expected to have more clearer and straight
code.

So i.e. the request loop described in the documentation...

	int foo_driver_enable_msix(struct foo_adapter *adapter,
				   int nvec)
	{
		while (nvec >= FOO_DRIVER_MINIMUM_NVEC) {
			rc = pci_enable_msix(adapter->pdev,
					     adapter->msix_entries,
					     nvec);
			if (rc > 0)
				nvec = rc;
			else
				return rc;
		}

		return -ENOSPC;
	}

...would turn into a single helper call....

	rc = pcim_enable_msix_range(adapter->pdev,
				    adapter->msix_entries,
				    nvec,
				    FOO_DRIVER_MINIMUM_NVEC);

Device drivers with more specific requirements (i.e. a number of
MSI-Xs which is a multiple of a certain number within a specified
range) would still need to implement the loop using the two old
functions.

[TODO Changelog]
The use of @nvec and @maxvec is a bit inconsistent.  Maybe it'd be
better to make them uniform? Also, can you please add function
comments to the new public functions?

+int pcim_enable_msi_range(struct pci_dev *dev, struct msix_entry
*entries,
+                         unsigned int nvec, unsigned int minvec)
+
+This variation on pci_enable_msi_block() call allows a device driver to
+request any number of MSIs within specified range minvec to nvec.
Whenever
+possible device drivers are encouraged to use this function rather than
+explicit request loop calling pci_enable_msi_block().

e.g. shouldn't that @nvec be @maxvec?

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Suggested-by: Ben Hutchings <bhutchings@solarflare.com>
Reviewed-by: Tejun Heo <tj@kernel.org>