From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <shemminger@fiji.vyatta.com>
Received: from fiji.vyatta.com (fiji.vyatta.com [76.74.103.50])
 by dpdk.org (Postfix) with ESMTP id 0C18A6889
 for <dev@dpdk.org>; Thu, 30 May 2013 19:21:28 +0200 (CEST)
Received: by fiji.vyatta.com (Postfix, from userid 1051)
 id A7534B24003; Thu, 30 May 2013 08:08:24 -0700 (PDT)
Message-Id: <20130530171627.073469876@vyatta.com>
User-Agent: quilt/0.60-1
Date: Thu, 30 May 2013 10:12:40 -0700
From: Stephen Hemminger <shemminger@vyatta.com>
To: dev@dpdk.org
References: <20130530171234.301927271@vyatta.com>
Content-Disposition: inline; filename=igb-remove-pci-lock.patch
X-Mailman-Approved-At: Thu, 30 May 2013 23:35:10 +0200
Subject: [dpdk-dev] [PATCH 6/7] igb_uio: pci_block_user_cfg_access is unsafe,
	remove it
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 30 May 2013 17:21:28 -0000

Using pci_block_user_cfg_access in IRQ context is unsafe. In fact if kernel
is compiled with option to check for might_sleep() it causes a warning
and a backtrace. The problem Intel was trying to solve here can not be
solved with these functions; better to just remove them.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>


--- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c	2013-03-28 08:50:50.234413869 -0700
+++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c	2013-05-29 16:41:30.974514849 -0700
@@ -28,15 +28,6 @@
 #include <linux/msi.h>
 #include <linux/version.h>
 
-/* 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.
@@ -170,14 +161,9 @@ igbuio_pci_irqcontrol(struct uio_info *i
 {
 	unsigned long flags;
 	struct rte_uio_pci_dev *udev = igbuio_get_uio_pci_dev(info);
-	struct pci_dev *pdev = udev->pdev;
 
 	spin_lock_irqsave(&udev->lock, flags);
-	PCI_LOCK(pdev);
-
 	igbuio_set_interrupt_mask(udev, irq_state);
-
-	PCI_UNLOCK(pdev);
 	spin_unlock_irqrestore(&udev->lock, flags);
 
 	return 0;
@@ -198,8 +184,6 @@ igbuio_pci_irqhandler(int irq, struct ui
 	uint16_t status;
 
 	spin_lock_irqsave(&udev->lock, flags);
-	/* block userspace PCI config reads/writes */
-	PCI_LOCK(pdev);
 
 	/* for legacy mode, interrupt maybe shared */
 	if (udev->mode == IGBUIO_LEGACY_INTR_MODE) {
@@ -214,7 +198,6 @@ igbuio_pci_irqhandler(int irq, struct ui
 	ret = IRQ_HANDLED;
 done:
 	/* unblock userspace PCI config reads/writes */
-	PCI_UNLOCK(pdev);
 	spin_unlock_irqrestore(&udev->lock, flags);
 	printk(KERN_INFO "irq 0x%x %s\n", irq, (ret == IRQ_HANDLED) ? "handled" : "not handled");