From 13dc56a6fe8d188037b57fe10d5159a460727b9a Mon Sep 17 00:00:00 2001 From: Intel Date: Thu, 20 Dec 2012 00:00:00 +0100 Subject: [PATCH] igb_uio: various updates Signed-off-by: Intel --- lib/librte_eal/linuxapp/igb_uio/Makefile | 2 +- lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 59 +++++++++++++++++------ 2 files changed, 46 insertions(+), 15 deletions(-) diff --git a/lib/librte_eal/linuxapp/igb_uio/Makefile b/lib/librte_eal/linuxapp/igb_uio/Makefile index 23e40a8901..e7a14b64de 100644 --- a/lib/librte_eal/linuxapp/igb_uio/Makefile +++ b/lib/librte_eal/linuxapp/igb_uio/Makefile @@ -41,7 +41,7 @@ MODULE_PATH = drivers/net/igb_uio # # CFLAGS # -MODULE_CFLAGS += -I$(SRCDIR) --param max-inline-insns-single=50 +MODULE_CFLAGS += -I$(SRCDIR) --param max-inline-insns-single=100 MODULE_CFLAGS += -I$(RTE_OUTPUT)/include MODULE_CFLAGS += -Winline -Wall -Werror MODULE_CFLAGS += -include $(RTE_OUTPUT)/include/rte_config.h diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c index 7b5762ee0b..18e2dd144d 100644 --- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c +++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c @@ -31,15 +31,6 @@ #include #include -/* Some function names changes between 3.2.0 and 3.3.0... */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0) -#define PCI_LOCK pci_block_user_cfg_access -#define PCI_UNLOCK pci_unblock_user_cfg_access -#else -#define PCI_LOCK pci_cfg_access_lock -#define PCI_UNLOCK pci_cfg_access_unlock -#endif - /** * MSI-X related macros, copy from linux/pci_regs.h in kernel 2.6.39, * but none of them in kernel 2.6.35. @@ -79,17 +70,46 @@ static const enum igbuio_intr_mode igbuio_intr_mode_preferred = IGBUIO_MSIX_INTR /* PCI device id table */ static struct pci_device_id igbuio_pci_ids[] = { -#define RTE_PCI_DEV_ID_DECL(vend, dev) {PCI_DEVICE(vend, dev)}, +#define RTE_PCI_DEV_ID_DECL_EM(vend, dev) {PCI_DEVICE(vend, dev)}, +#define RTE_PCI_DEV_ID_DECL_IGB(vend, dev) {PCI_DEVICE(vend, dev)}, +#define RTE_PCI_DEV_ID_DECL_IGBVF(vend, dev) {PCI_DEVICE(vend, dev)}, +#define RTE_PCI_DEV_ID_DECL_IXGBE(vend, dev) {PCI_DEVICE(vend, dev)}, +#define RTE_PCI_DEV_ID_DECL_IXGBEVF(vend, dev) {PCI_DEVICE(vend, dev)}, #include { 0, }, }; +MODULE_DEVICE_TABLE(pci, igbuio_pci_ids); + static inline struct rte_uio_pci_dev * igbuio_get_uio_pci_dev(struct uio_info *info) { return container_of(info, struct rte_uio_pci_dev, info); } +static inline int +pci_lock(struct pci_dev * pdev) +{ + /* Some function names changes between 3.2.0 and 3.3.0... */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0) + pci_block_user_cfg_access(pdev); + return 1; +#else + return pci_cfg_access_trylock(pdev); +#endif +} + +static inline void +pci_unlock(struct pci_dev * pdev) +{ + /* Some function names changes between 3.2.0 and 3.3.0... */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0) + pci_unblock_user_cfg_access(pdev); +#else + pci_cfg_access_unlock(pdev); +#endif +} + /** * It masks the msix on/off of generating MSI-X messages. */ @@ -176,11 +196,14 @@ igbuio_pci_irqcontrol(struct uio_info *info, s32 irq_state) struct pci_dev *pdev = udev->pdev; spin_lock_irqsave(&udev->lock, flags); - PCI_LOCK(pdev); + if (!pci_lock(pdev)) { + spin_unlock_irqrestore(&udev->lock, flags); + return -1; + } igbuio_set_interrupt_mask(udev, irq_state); - PCI_UNLOCK(pdev); + pci_unlock(pdev); spin_unlock_irqrestore(&udev->lock, flags); return 0; @@ -202,7 +225,8 @@ igbuio_pci_irqhandler(int irq, struct uio_info *info) spin_lock_irqsave(&udev->lock, flags); /* block userspace PCI config reads/writes */ - PCI_LOCK(pdev); + if (!pci_lock(pdev)) + goto spin_unlock; /* for legacy mode, interrupt maybe shared */ if (udev->mode == IGBUIO_LEGACY_INTR_MODE) { @@ -217,7 +241,8 @@ igbuio_pci_irqhandler(int irq, struct uio_info *info) ret = IRQ_HANDLED; done: /* unblock userspace PCI config reads/writes */ - PCI_UNLOCK(pdev); + pci_unlock(pdev); +spin_unlock: spin_unlock_irqrestore(&udev->lock, flags); printk(KERN_INFO "irq 0x%x %s\n", irq, (ret == IRQ_HANDLED) ? "handled" : "not handled"); @@ -369,7 +394,13 @@ igbuio_pci_remove(struct pci_dev *dev) { struct uio_info *info = pci_get_drvdata(dev); + if (info->priv == NULL) { + printk(KERN_DEBUG "Not igbuio device\n"); + return; + } + uio_unregister_device(info); + igbuio_pci_release_iomem(info); if (((struct rte_uio_pci_dev *)info->priv)->mode == IGBUIO_MSIX_INTR_MODE) pci_disable_msix(dev); pci_release_regions(dev); -- 2.20.1