WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 4/9] Have pci_frontend_enable_[msi|msix] save PIRQ va

Previously the PIRQ values obtained from do_pci_op would be saved in the
dev->irq (for MSI) or entries[i]->vector (for MSI-X). Unify it to save
those values in an array passed in as an argument.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
---
 arch/x86/include/asm/xen/pci.h |    8 ++++----
 drivers/pci/xen-pcifront.c     |   26 +++++++++++++++-----------
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/xen/pci.h b/arch/x86/include/asm/xen/pci.h
index 4774ae0..8adb33a 100644
--- a/arch/x86/include/asm/xen/pci.h
+++ b/arch/x86/include/asm/xen/pci.h
@@ -35,19 +35,19 @@ static inline int xen_setup_msi_irqs(struct pci_dev *dev, 
int nvec, int type)
 #endif
 #if defined(CONFIG_PCI_MSI) && defined(CONFIG_XEN_PCIDEV_FRONTEND)
 /* Defined in drivers/pci/xen-pcifront.c */
-int pci_frontend_enable_msi(struct pci_dev *dev, int *pirq);
+int pci_frontend_enable_msi(struct pci_dev *dev, int **vectors);
 void pci_frontend_disable_msi(struct pci_dev *dev);
 int pci_frontend_enable_msix(struct pci_dev *dev,
-                            struct msix_entry *entries, int nvec);
+                            int **vectors, int nvec);
 void pci_frontend_disable_msix(struct pci_dev *dev);
 #else
-static inline int pci_frontend_enable_msi(struct pci_dev *dev, int *pirq)
+static inline int pci_frontend_enable_msi(struct pci_dev *dev, int **vectors)
 {
        return -1;
 }
 static inline void pci_frontend_disable_msi(struct pci_dev *dev) { }
 static inline int pci_frontend_enable_msix(struct pci_dev *dev,
-                                          struct msix_entry *entries, int nvec)
+                                          int **vectors, int nvec)
 {
        return -1;
 }
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index adef0c3..1120034 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -12,6 +12,8 @@
 #include <xen/page.h>
 #include <linux/spinlock.h>
 #include <linux/pci.h>
+#include <asm/xen/pci.h>
+#include <linux/msi.h>
 #include <xen/xenbus.h>
 #include <xen/interface/io/pciif.h>
 #include <linux/interrupt.h>
@@ -255,8 +257,7 @@ struct pci_ops pcifront_bus_ops = {
 
 #ifdef CONFIG_PCI_MSI
 int pci_frontend_enable_msix(struct pci_dev *dev,
-               struct msix_entry *entries,
-               int nvec)
+               int **vector, int nvec)
 {
        int err;
        int i;
@@ -269,24 +270,28 @@ int pci_frontend_enable_msix(struct pci_dev *dev,
        };
        struct pcifront_sd *sd = dev->bus->sysdata;
        struct pcifront_device *pdev = pcifront_get_pdev(sd);
+       struct msi_desc *entry;
 
        if (nvec > SH_INFO_MAX_VEC) {
                printk(KERN_ERR "too much vector for pci frontend%x\n", nvec);
                return -EINVAL;
        }
 
-       for (i = 0; i < nvec; i++) {
-               op.msix_entries[i].entry = entries[i].entry;
-               op.msix_entries[i].vector = entries[i].vector;
+       i = 0;
+       list_for_each_entry(entry, &dev->msi_list, list) {
+               op.msix_entries[i].entry = entry->msi_attrib.entry_nr;
+               /* Vector is useless at this point. */
+               op.msix_entries[i].vector = -1;
+               i++;
        }
 
        err = do_pci_op(pdev, &op);
 
-       if (!err) {
-               if (!op.value) {
+       if (likely(!err)) {
+               if (likely(!op.value)) {
                        /* we get the result */
                        for (i = 0; i < nvec; i++)
-                               entries[i].vector = op.msix_entries[i].vector;
+                               *vector[i] = op.msix_entries[i].vector;
                        return 0;
                } else {
                        printk(KERN_DEBUG "enable msix get value %x\n",
@@ -320,7 +325,7 @@ void pci_frontend_disable_msix(struct pci_dev *dev)
 }
 EXPORT_SYMBOL_GPL(pci_frontend_disable_msix);
 
-int pci_frontend_enable_msi(struct pci_dev *dev, int *pirq)
+int pci_frontend_enable_msi(struct pci_dev *dev, int **vector)
 {
        int err;
        struct xen_pci_op op = {
@@ -332,10 +337,9 @@ int pci_frontend_enable_msi(struct pci_dev *dev, int *pirq)
        struct pcifront_sd *sd = dev->bus->sysdata;
        struct pcifront_device *pdev = pcifront_get_pdev(sd);
 
-       *pirq = -1;
        err = do_pci_op(pdev, &op);
        if (likely(!err)) {
-               *pirq = op.value;
+               *vector[0] = op.value;
        } else {
                printk(KERN_ERR "pci frontend enable msi failed for dev %x:%x 
\n",
                                op.bus, op.devfn);
-- 
1.6.2.5


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel