Ver código fonte

PCI MSI: Add example request loop to MSI-HOWTO.txt

Encourage driver writers to think about supporting a variable number
of MSI-X interrupts, and give an example of how to do such a
request.

Acked-by: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Michael Ellerman 16 anos atrás
pai
commit
fafad5bf06
1 arquivos alterados com 22 adições e 1 exclusões
  1. 22 1
      Documentation/PCI/MSI-HOWTO.txt

+ 22 - 1
Documentation/PCI/MSI-HOWTO.txt

@@ -176,7 +176,8 @@ request_irq() for each 'vector' that it decides to use.
 If this function returns a negative number, it indicates an error and
 If this function returns a negative number, it indicates an error and
 the driver should not attempt to allocate any more MSI-X interrupts for
 the driver should not attempt to allocate any more MSI-X interrupts for
 this device.  If it returns a positive number, it indicates the maximum
 this device.  If it returns a positive number, it indicates the maximum
-number of interrupt vectors that could have been allocated.
+number of interrupt vectors that could have been allocated. See example
+below.
 
 
 This function, in contrast with pci_enable_msi(), does not adjust
 This function, in contrast with pci_enable_msi(), does not adjust
 dev->irq.  The device will not generate interrupts for this interrupt
 dev->irq.  The device will not generate interrupts for this interrupt
@@ -187,6 +188,26 @@ free them again later.
 Device drivers should normally call this function once per device
 Device drivers should normally call this function once per device
 during the initialization phase.
 during the initialization phase.
 
 
+It is ideal if drivers can cope with a variable number of MSI-X interrupts,
+there are many reasons why the platform may not be able to provide the
+exact number a driver asks for.
+
+A request loop to achieve that might look like:
+
+static 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;
+}
+
 4.3.2 pci_disable_msix
 4.3.2 pci_disable_msix
 
 
 void pci_disable_msix(struct pci_dev *dev)
 void pci_disable_msix(struct pci_dev *dev)