Michael S. Tsirkin
2009-May-07 08:28 UTC
[PATCH] msi-x: let drivers retry when not enough vectors
pci_enable_msix currently returns -EINVAL if you ask for more vectors than supported by the device, which would typically cause fallback to regular interrupts. It's better to return the table size, making the driver retry MSI-X with less vectors. Signed-off-by: Michael S. Tsirkin <mst at redhat.com> --- Hi Jesse, This came up when I was adding MSI-X support to virtio pci driver, which does not know the exact table size upfront. Could you consider this patch for 2.6.31 please? drivers/pci/msi.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 6f2e629..f5bd1c9 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -687,8 +687,8 @@ int pci_msix_table_size(struct pci_dev *dev) * indicates the successful configuration of MSI-X capability structure * with new allocated MSI-X irqs. A return of < 0 indicates a failure. * Or a return of > 0 indicates that driver request is exceeding the number - * of irqs available. Driver should use the returned value to re-send - * its request. + * of irqs or MSI-X vectors available. Driver should use the returned value to + * re-send its request. **/ int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec) { @@ -704,7 +704,7 @@ int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec) nr_entries = pci_msix_table_size(dev); if (nvec > nr_entries) - return -EINVAL; + return nr_entries; /* Check for any invalid entries */ for (i = 0; i < nvec; i++) { -- 1.6.3.rc3.1.g830204
On Thursday 07 May 2009 16:28:41 Michael S. Tsirkin wrote:> pci_enable_msix currently returns -EINVAL if you ask > for more vectors than supported by the device, which would > typically cause fallback to regular interrupts. > > It's better to return the table size, making the driver retry > MSI-X with less vectors.Hi Michael I think driver should read from capability list to know how many vector supported by this device before enable MSI-X for device, as pci_msix_table_size() did... -- regards Yang, Sheng> > Signed-off-by: Michael S. Tsirkin <mst at redhat.com> > --- > > Hi Jesse, > This came up when I was adding MSI-X support to virtio pci driver, > which does not know the exact table size upfront. > Could you consider this patch for 2.6.31 please? > > > drivers/pci/msi.c | 6 +++--- > 1 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c > index 6f2e629..f5bd1c9 100644 > --- a/drivers/pci/msi.c > +++ b/drivers/pci/msi.c > @@ -687,8 +687,8 @@ int pci_msix_table_size(struct pci_dev *dev) > * indicates the successful configuration of MSI-X capability structure > * with new allocated MSI-X irqs. A return of < 0 indicates a failure. > * Or a return of > 0 indicates that driver request is exceeding the > number - * of irqs available. Driver should use the returned value to > re-send - * its request. > + * of irqs or MSI-X vectors available. Driver should use the returned > value to + * re-send its request. > **/ > int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int > nvec) { > @@ -704,7 +704,7 @@ int pci_enable_msix(struct pci_dev* dev, struct > msix_entry *entries, int nvec) > > nr_entries = pci_msix_table_size(dev); > if (nvec > nr_entries) > - return -EINVAL; > + return nr_entries; > > /* Check for any invalid entries */ > for (i = 0; i < nvec; i++) {
Jesse Barnes
2009-Jun-11 18:28 UTC
[PATCH] msi-x: let drivers retry when not enough vectors
On Thu, 7 May 2009 11:28:41 +0300 "Michael S. Tsirkin" <mst at redhat.com> wrote:> pci_enable_msix currently returns -EINVAL if you ask > for more vectors than supported by the device, which would > typically cause fallback to regular interrupts. > > It's better to return the table size, making the driver retry > MSI-X with less vectors. > > Signed-off-by: Michael S. Tsirkin <mst at redhat.com> > --- > > Hi Jesse, > This came up when I was adding MSI-X support to virtio pci driver, > which does not know the exact table size upfront. > Could you consider this patch for 2.6.31 please?Applied this one to my linux-next branch; hopefully Rusty won't mind too much. :) -- Jesse Barnes, Intel Open Source Technology Center
Possibly Parallel Threads
- [PATCH] msi-x: let drivers retry when not enough vectors
- [RFC PATCH 09/11] PCI/MSI: refactor PCI MSI driver
- [RFC PATCH 09/11] PCI/MSI: refactor PCI MSI driver
- [RFC PATCH 10/11] PCI/MSI: Split the generic MSI code into new file
- [RFC PATCH 10/11] PCI/MSI: Split the generic MSI code into new file