diff options
author | Michael Ellerman <michael@ellerman.id.au> | 2009-03-20 00:22:12 -0400 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-03-20 14:35:04 -0400 |
commit | fafad5bf06c3a3bb8b24b28b6f065367e7411872 (patch) | |
tree | 32f88260a757d9e24e913202fddcd2cdd420eb03 | |
parent | 5546d6f56807115a035d140f7364ce5807dbcc87 (diff) |
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>
-rw-r--r-- | Documentation/PCI/MSI-HOWTO.txt | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/Documentation/PCI/MSI-HOWTO.txt b/Documentation/PCI/MSI-HOWTO.txt index 9494f6dc38eb..dcf7acc720e1 100644 --- a/Documentation/PCI/MSI-HOWTO.txt +++ b/Documentation/PCI/MSI-HOWTO.txt | |||
@@ -176,7 +176,8 @@ request_irq() for each 'vector' that it decides to use. | |||
176 | If this function returns a negative number, it indicates an error and | 176 | If this function returns a negative number, it indicates an error and |
177 | the driver should not attempt to allocate any more MSI-X interrupts for | 177 | the driver should not attempt to allocate any more MSI-X interrupts for |
178 | this device. If it returns a positive number, it indicates the maximum | 178 | this device. If it returns a positive number, it indicates the maximum |
179 | number of interrupt vectors that could have been allocated. | 179 | number of interrupt vectors that could have been allocated. See example |
180 | below. | ||
180 | 181 | ||
181 | This function, in contrast with pci_enable_msi(), does not adjust | 182 | This function, in contrast with pci_enable_msi(), does not adjust |
182 | dev->irq. The device will not generate interrupts for this interrupt | 183 | dev->irq. The device will not generate interrupts for this interrupt |
@@ -187,6 +188,26 @@ free them again later. | |||
187 | Device drivers should normally call this function once per device | 188 | Device drivers should normally call this function once per device |
188 | during the initialization phase. | 189 | during the initialization phase. |
189 | 190 | ||
191 | It is ideal if drivers can cope with a variable number of MSI-X interrupts, | ||
192 | there are many reasons why the platform may not be able to provide the | ||
193 | exact number a driver asks for. | ||
194 | |||
195 | A request loop to achieve that might look like: | ||
196 | |||
197 | static int foo_driver_enable_msix(struct foo_adapter *adapter, int nvec) | ||
198 | { | ||
199 | while (nvec >= FOO_DRIVER_MINIMUM_NVEC) { | ||
200 | rc = pci_enable_msix(adapter->pdev, | ||
201 | adapter->msix_entries, nvec); | ||
202 | if (rc > 0) | ||
203 | nvec = rc; | ||
204 | else | ||
205 | return rc; | ||
206 | } | ||
207 | |||
208 | return -ENOSPC; | ||
209 | } | ||
210 | |||
190 | 4.3.2 pci_disable_msix | 211 | 4.3.2 pci_disable_msix |
191 | 212 | ||
192 | void pci_disable_msix(struct pci_dev *dev) | 213 | void pci_disable_msix(struct pci_dev *dev) |