Skip to contentSkip to conversation

igb_uio: fix uevent montior issue

PATCH Superseded Jeff Guo 4 participants 11 messages Jan 30, 2018 – Mar 27, 2018

lore
Share & tools
lore

Jeff Guo

author
#0 lore raw

PATCH 1/1 igb_uio: fix uevent montior issue

udev could not detect remove and add event of device when hotplug in and out devices, that related with the fix about using pointer of rte_uio_pci_dev as dev_id instead of uio_device for irq device handler, that would result igb uio irq failure when kernel version after than 3.17. so this patch correct it by use kernel version check before handle the pci interrupt.

Fixes 6b9ed026a870 ("igb_uio: fix build with kernel <= 3.17")
---
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
lib/librte_eal/linuxapp/igb_uio/igb_uio.c +16 -1
index 9f0fb5e..14ce2ea 100644
@@ -192,9 +192,14 @@ igbuio_pci_irqcontrol(struct uio_info *info, s32 irq_state)
 static irqreturn_t
 igbuio_pci_irqhandler(int irq, void *dev_id)
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
 	struct rte_uio_pci_dev *udev = (struct rte_uio_pci_dev *)dev_id;
 	struct uio_info *info = &udev->info;
-
+#else
+	struct uio_device *idev = (struct uio_device *)dev_id;
+	struct uio_info *info = idev->info;
+	struct rte_uio_pci_dev *udev = info->priv;
+#endif
 	/* Legacy mode need to mask in hardware */
 	if (udev->mode == RTE_INTR_MODE_LEGACY &&
 	    !pci_check_and_mask_intx(udev->pdev))
@@ -279,9 +284,15 @@ igbuio_pci_enable_interrupts(struct rte_uio_pci_dev *udev)
 	}
 
 	if (udev->info.irq != UIO_IRQ_NONE)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
 		err = request_irq(udev->info.irq, igbuio_pci_irqhandler,
 				  udev->info.irq_flags, udev->info.name,
 				  udev);
+#else
+		err = request_irq(udev->info.irq, igbuio_pci_irqhandler,
+				  udev->info.irq_flags, udev->info.name,
+				  udev->info.uio_dev);
+#endif
 	dev_info(&udev->pdev->dev, "uio device registered with irq %lx\n",
 		 udev->info.irq);
 
@@ -292,7 +303,11 @@ static void
 igbuio_pci_disable_interrupts(struct rte_uio_pci_dev *udev)
 {
 	if (udev->info.irq) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
 		free_irq(udev->info.irq, udev);
+#else
+		free_irq(udev->info.irq, udev->info.uio_dev);
+#endif
 		udev->info.irq = 0;
 	}
 
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines

-----Original Message-----
From: Guo, Jia
Sent: Tuesday, January 30, 2018 6:01 PM
To: Yigit, Ferruh <[email protected]>; Wu, Jingjing <[email protected]>; Tan, Jianfeng <[email protected]>
Cc: [email protected]; [email protected]; Guo, Jia <[email protected]>
Subject: [PATCH] igb_uio: fix uevent montior issue

udev could not detect remove and add event of device when hotplug in and out devices, that related with the fix about using pointer of rte_uio_pci_dev as dev_id instead of uio_device for irq device handler, that would result igb uio irq failure when kernel version after than 3.17. so this patch correct it by use kernel version check before handle the pci interrupt.

Quoted 2 lines
Fixes 6b9ed026a870 ("igb_uio: fix build with kernel <= 3.17")
#2 lore raw
In reply to Jeff Guo

30/01/2018 11:01, Jeff Guo:

Quoted 10 lines

udev could not detect remove and add event of device when hotplug in and out devices, that related with the fix about using pointer of rte_uio_pci_dev as dev_id instead of uio_device for irq device handler, that would result igb uio irq failure when kernel version after than 3.17. so this patch correct it by use kernel version check before handle the pci interrupt.

Fixes 6b9ed026a870 ("igb_uio: fix build with kernel <= 3.17")

---

lib/librte_eal/linuxapp/igb_uio/igb_uio.c igbuio_pci_irqcontrol(struct uio_info *info, s32 irq_state) · line 202

Quoted 9 lines
lib/librte_eal/linuxapp/igb_uio/igb_uio.c +6 -1
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
 	struct rte_uio_pci_dev *udev = (struct rte_uio_pci_dev *)dev_id;
 	struct uio_info *info = &udev->info;
-
+#else
+	struct uio_device *idev = (struct uio_device *)dev_id;
+	struct uio_info *info = idev->info;
+	struct rte_uio_pci_dev *udev = info->priv;
+#endif

Can we avoid checking Linux version number?
This method won't work with kernel backports.

author
#3 lore raw
Quoted 8 lines · Thomas Monjalon

30/01/2018 11:01, Jeff Guo:

Quoted 7 lines

udev could not detect remove and add event of device when hotplug in and out devices, that related with the fix about using pointer of rte_uio_pci_dev as dev_id instead of uio_device for irq device handler, that would result igb uio irq failure when kernel version after than 3.17. so this patch correct it by use kernel version check before handle the pci interrupt.

Quoted 14 lines

lib/librte_eal/linuxapp/igb_uio/igb_uio.c igbuio_pci_irqcontrol(struct uio_info *info, s32 irq_state) · line 202

Quoted 12 lines
Fixes 6b9ed026a870 ("igb_uio: fix build with kernel <= 3.17")

---

lib/librte_eal/linuxapp/igb_uio/igb_uio.c +6 -1
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
  	struct rte_uio_pci_dev *udev = (struct rte_uio_pci_dev *)dev_id;
  	struct uio_info *info = &udev->info;
-
+#else
+	struct uio_device *idev = (struct uio_device *)dev_id;
+	struct uio_info *info = idev->info;
+	struct rte_uio_pci_dev *udev = info->priv;
+#endif

Can we avoid checking Linux version number?
This method won't work with kernel backports.

i don't think that is a bug rather than a kernel feature parameter change , so i am not sure if it will definitely a chance exist for the kernel backport fix for that.

#4 lore raw

12/02/2018 09:28, Guo, Jia:

Quoted 24 lines · Thomas Monjalon
Quoted 8 lines

30/01/2018 11:01, Jeff Guo:

Quoted 7 lines

udev could not detect remove and add event of device when hotplug in and out devices, that related with the fix about using pointer of rte_uio_pci_dev as dev_id instead of uio_device for irq device handler, that would result igb uio irq failure when kernel version after than 3.17. so this patch correct it by use kernel version check before handle the pci interrupt.

Quoted 14 lines

lib/librte_eal/linuxapp/igb_uio/igb_uio.c igbuio_pci_irqcontrol(struct uio_info *info, s32 irq_state) · line 202

Quoted 12 lines
Fixes 6b9ed026a870 ("igb_uio: fix build with kernel <= 3.17")

---

lib/librte_eal/linuxapp/igb_uio/igb_uio.c +6 -1
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
  	struct rte_uio_pci_dev *udev = (struct rte_uio_pci_dev *)dev_id;
  	struct uio_info *info = &udev->info;
-
+#else
+	struct uio_device *idev = (struct uio_device *)dev_id;
+	struct uio_info *info = idev->info;
+	struct rte_uio_pci_dev *udev = info->priv;
+#endif

Can we avoid checking Linux version number?
This method won't work with kernel backports.

Quoted 3 lines

i don't think that is a bug rather than a kernel feature parameter change , so i am not sure if it will definitely a chance exist for the kernel backport fix for that.

Features are also backported in some kernels.

#5 lore raw
In reply to Guo, Jia
Quoted 25 lines · Jia
Quoted 8 lines · Thomas Monjalon

30/01/2018 11:01, Jeff Guo:

Quoted 7 lines

udev could not detect remove and add event of device when hotplug in and out devices, that related with the fix about using pointer of rte_uio_pci_dev as dev_id instead of uio_device for irq device handler, that would result igb uio irq failure when kernel version after than 3.17. so this patch correct it by use kernel version check before handle the pci interrupt.

Quoted 14 lines

lib/librte_eal/linuxapp/igb_uio/igb_uio.c igbuio_pci_irqcontrol(struct uio_info *info, s32 irq_state) · line 202

Quoted 12 lines
Fixes 6b9ed026a870 ("igb_uio: fix build with kernel <= 3.17")

---

lib/librte_eal/linuxapp/igb_uio/igb_uio.c +6 -1
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
  	struct rte_uio_pci_dev *udev = (struct rte_uio_pci_dev *)dev_id;
  	struct uio_info *info = &udev->info;
-
+#else
+	struct uio_device *idev = (struct uio_device *)dev_id;
+	struct uio_info *info = idev->info;
+	struct rte_uio_pci_dev *udev = info->priv;
+#endif

Can we avoid checking Linux version number?
This method won't work with kernel backports.

Quoted 3 lines

i don't think that is a bug rather than a kernel feature parameter change , so i am not sure if it will definitely a chance exist for the kernel backport fix for that.

Hi Jeff,

What we tend to do is add version check to compat.h and define a feature based on that check and use feature define in .c . This makes .c file more readable and if in the future we need to add more check because of backported kernels (mostly we need to do) that checks all goes into compat.h and .c file remains clean.

Thanks,
ferruh

author
#6 lore raw
Quoted 30 lines · Ferruh Yigit
Quoted 24 lines · Jia
Quoted 8 lines · Thomas Monjalon

30/01/2018 11:01, Jeff Guo:

Quoted 7 lines

udev could not detect remove and add event of device when hotplug in and out devices, that related with the fix about using pointer of rte_uio_pci_dev as dev_id instead of uio_device for irq device handler, that would result igb uio irq failure when kernel version after than 3.17. so this patch correct it by use kernel version check before handle the pci interrupt.

Quoted 14 lines

lib/librte_eal/linuxapp/igb_uio/igb_uio.c igbuio_pci_irqcontrol(struct uio_info *info, s32 irq_state) · line 202

Quoted 12 lines
Fixes 6b9ed026a870 ("igb_uio: fix build with kernel <= 3.17")

---

lib/librte_eal/linuxapp/igb_uio/igb_uio.c +6 -1
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
   	struct rte_uio_pci_dev *udev = (struct rte_uio_pci_dev *)dev_id;
   	struct uio_info *info = &udev->info;
-
+#else
+	struct uio_device *idev = (struct uio_device *)dev_id;
+	struct uio_info *info = idev->info;
+	struct rte_uio_pci_dev *udev = info->priv;
+#endif

Can we avoid checking Linux version number?
This method won't work with kernel backports.

Quoted 3 lines

i don't think that is a bug rather than a kernel feature parameter change , so i am not sure if it will definitely a chance exist for the kernel backport fix for that.

Hi Jeff,

Quoted 7 lines

What we tend to do is add version check to compat.h and define a feature based on that check and use feature define in .c . This makes .c file more readable and if in the future we need to add more check because of backported kernels (mostly we need to do) that checks all goes into compat.h and .c file remains clean.

Thanks,
ferruh

make sense, let me check the compat.h file and use it in this case.

author
#7 lore raw

PATCH v2 1/1 igb_uio: fix uevent montior issue

In reply to Jeff Guo

udev could not detect remove and add event of device when hotplug in and out devices, that related with the fix about using pointer of rte_uio_pci_dev as dev_id instead of uio_device for irq device handler, that would result igb uio irq failure when kernel version after than 3.17.

The root cause is that the older version of Linux kernel don't expose the uio_device structure, only for the kernel version after than 3.17 use uio_device. so this patch correct it by use a macro to check before handle the pci interrupt.

Fixes 6b9ed026a870 ("igb_uio: fix build with kernel <= 3.17")

---
v2->v1:
use macro in compat.h to replace of version check in .c file, benifit for future backport and make more readable.

---
 lib/librte_eal/linuxapp/igb_uio/compat.h  |  4 ++++
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 16 ++++++++++++++++
 2 files changed, 20 insertions(+)
lib/librte_eal/linuxapp/igb_uio/compat.h +4 -0
index ce456d4..2c61190 100644
@@ -132,3 +132,7 @@ static bool pci_check_and_mask_intx(struct pci_dev *pdev)
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
 #define HAVE_PCI_MSI_MASK_IRQ 1
 #endif
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(3, 17, 0)
+#define HAVE_UIO_DEVICE_STRUCTURE 1
+#endif
lib/librte_eal/linuxapp/igb_uio/igb_uio.c +16 -0
index 4cae4dd..99018f4 100644
@@ -192,8 +192,14 @@ igbuio_pci_irqcontrol(struct uio_info *info, s32 irq_state)
 static irqreturn_t
 igbuio_pci_irqhandler(int irq, void *dev_id)
 {
+#ifndef HAVE_UIO_DEVICE_STRUCTURE
 	struct rte_uio_pci_dev *udev = (struct rte_uio_pci_dev *)dev_id;
 	struct uio_info *info = &udev->info;
+#else
+	struct uio_device *idev = (struct uio_device *)dev_id;
+	struct uio_info *info = idev->info;
+	struct rte_uio_pci_dev *udev = info->priv;
+#endif
 
 	/* Legacy mode need to mask in hardware */
 	if (udev->mode == RTE_INTR_MODE_LEGACY &&
@@ -279,9 +285,15 @@ igbuio_pci_enable_interrupts(struct rte_uio_pci_dev *udev)
 	}
 
 	if (udev->info.irq != UIO_IRQ_NONE)
+#ifndef HAVE_UIO_DEVICE_STRUCTURE
 		err = request_irq(udev->info.irq, igbuio_pci_irqhandler,
 				  udev->info.irq_flags, udev->info.name,
 				  udev);
+#else
+		err = request_irq(udev->info.irq, igbuio_pci_irqhandler,
+				  udev->info.irq_flags, udev->info.name,
+				  udev->info.uio_dev);
+#endif
 	dev_info(&udev->pdev->dev, "uio device registered with irq %ld\n",
 		 udev->info.irq);
 
@@ -292,7 +304,11 @@ static void
 igbuio_pci_disable_interrupts(struct rte_uio_pci_dev *udev)
 {
 	if (udev->info.irq) {
+#ifndef HAVE_UIO_DEVICE_STRUCTURE
 		free_irq(udev->info.irq, udev);
+#else
+		free_irq(udev->info.irq, udev->info.uio_dev);
+#endif
 		udev->info.irq = 0;
 	}
 
Signature · 1 line
2.7.4
#8 lore raw
Quoted 55 lines · Jeff Guo

udev could not detect remove and add event of device when hotplug in and out devices, that related with the fix about using pointer of rte_uio_pci_dev as dev_id instead of uio_device for irq device handler, that would result igb uio irq failure when kernel version after than 3.17.

The root cause is that the older version of Linux kernel don't expose the uio_device structure, only for the kernel version after than 3.17 use uio_device. so this patch correct it by use a macro to check before handle the pci interrupt.

Fixes 6b9ed026a870 ("igb_uio: fix build with kernel <= 3.17")

---
v2->v1:
use macro in compat.h to replace of version check in .c file, benifit for future backport and make more readable.

---
 lib/librte_eal/linuxapp/igb_uio/compat.h  |  4 ++++
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 16 ++++++++++++++++
 2 files changed, 20 insertions(+)
lib/librte_eal/linuxapp/igb_uio/compat.h +4 -0
index ce456d4..2c61190 100644
@@ -132,3 +132,7 @@ static bool pci_check_and_mask_intx(struct pci_dev *pdev)
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
 #define HAVE_PCI_MSI_MASK_IRQ 1
 #endif
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(3, 17, 0)
+#define HAVE_UIO_DEVICE_STRUCTURE 1
+#endif
lib/librte_eal/linuxapp/igb_uio/igb_uio.c +6 -0
index 4cae4dd..99018f4 100644
@@ -192,8 +192,14 @@ igbuio_pci_irqcontrol(struct uio_info *info, s32 irq_state)
 static irqreturn_t
 igbuio_pci_irqhandler(int irq, void *dev_id)
 {
+#ifndef HAVE_UIO_DEVICE_STRUCTURE
 	struct rte_uio_pci_dev *udev = (struct rte_uio_pci_dev *)dev_id;
 	struct uio_info *info = &udev->info;
+#else
+	struct uio_device *idev = (struct uio_device *)dev_id;
+	struct uio_info *info = idev->info;
+	struct rte_uio_pci_dev *udev = info->priv;
+#endif
 
 	/* Legacy mode need to mask in hardware */
 	if (udev->mode == RTE_INTR_MODE_LEGACY &&
@@ -279,9 +285,15 @@ igbuio_pci_enable_interrupts(struct rte_uio_pci_dev *udev)
 	}
 

lib/librte_eal/linuxapp/igb_uio/igb_uio.c igbuio_pci_enable_interrupts(struct rte_uio_pci_dev *udev) · line 296

Quoted 10 lines
lib/librte_eal/linuxapp/igb_uio/igb_uio.c +6 -0
 	if (udev->info.irq != UIO_IRQ_NONE)
+#ifndef HAVE_UIO_DEVICE_STRUCTURE
 		err = request_irq(udev->info.irq, igbuio_pci_irqhandler,
 				  udev->info.irq_flags, udev->info.name,
 				  udev);
+#else
+		err = request_irq(udev->info.irq, igbuio_pci_irqhandler,
+				  udev->info.irq_flags, udev->info.name,
+				  udev->info.uio_dev);
+#endif

Hi Jeff,

Can you please describe how this is solving the problem. Isn't only requirement for dev_id to be unique? Why it differs to pass uio_dev instead of udev pointer?

Quoted 16 lines
lib/librte_eal/linuxapp/igb_uio/igb_uio.c +4 -0
 	dev_info(&udev->pdev->dev, "uio device registered with irq %ld\n",
 		 udev->info.irq);
 
@@ -292,7 +304,11 @@ static void
 igbuio_pci_disable_interrupts(struct rte_uio_pci_dev *udev)
 {
 	if (udev->info.irq) {
+#ifndef HAVE_UIO_DEVICE_STRUCTURE
 		free_irq(udev->info.irq, udev);
+#else
+		free_irq(udev->info.irq, udev->info.uio_dev);
+#endif
 		udev->info.irq = 0;
 	}
 
author
#9 lore raw
Quoted 68 lines · Ferruh Yigit
Quoted 55 lines · Jeff Guo

udev could not detect remove and add event of device when hotplug in and out devices, that related with the fix about using pointer of rte_uio_pci_dev as dev_id instead of uio_device for irq device handler, that would result igb uio irq failure when kernel version after than 3.17.

The root cause is that the older version of Linux kernel don't expose the uio_device structure, only for the kernel version after than 3.17 use uio_device. so this patch correct it by use a macro to check before handle the pci interrupt.

Fixes 6b9ed026a870 ("igb_uio: fix build with kernel <= 3.17")

---
v2->v1:
use macro in compat.h to replace of version check in .c file, benifit for future backport and make more readable.

---
  lib/librte_eal/linuxapp/igb_uio/compat.h  |  4 ++++
  lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 16 ++++++++++++++++
  2 files changed, 20 insertions(+)
lib/librte_eal/linuxapp/igb_uio/compat.h +4 -0
index ce456d4..2c61190 100644
@@ -132,3 +132,7 @@ static bool pci_check_and_mask_intx(struct pci_dev *pdev)
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
  #define HAVE_PCI_MSI_MASK_IRQ 1
  #endif
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(3, 17, 0)
+#define HAVE_UIO_DEVICE_STRUCTURE 1
+#endif
lib/librte_eal/linuxapp/igb_uio/igb_uio.c +6 -0
index 4cae4dd..99018f4 100644
@@ -192,8 +192,14 @@ igbuio_pci_irqcontrol(struct uio_info *info, s32 irq_state)
  static irqreturn_t
  igbuio_pci_irqhandler(int irq, void *dev_id)
  {
+#ifndef HAVE_UIO_DEVICE_STRUCTURE
  	struct rte_uio_pci_dev *udev = (struct rte_uio_pci_dev *)dev_id;
  	struct uio_info *info = &udev->info;
+#else
+	struct uio_device *idev = (struct uio_device *)dev_id;
+	struct uio_info *info = idev->info;
+	struct rte_uio_pci_dev *udev = info->priv;
+#endif
 
  	/* Legacy mode need to mask in hardware */
  	if (udev->mode == RTE_INTR_MODE_LEGACY &&
@@ -279,9 +285,15 @@ igbuio_pci_enable_interrupts(struct rte_uio_pci_dev *udev)
  	}
 

lib/librte_eal/linuxapp/igb_uio/igb_uio.c igbuio_pci_enable_interrupts(struct rte_uio_pci_dev *udev) · line 296

Quoted 10 lines
lib/librte_eal/linuxapp/igb_uio/igb_uio.c +6 -0
  	if (udev->info.irq != UIO_IRQ_NONE)
+#ifndef HAVE_UIO_DEVICE_STRUCTURE
  		err = request_irq(udev->info.irq, igbuio_pci_irqhandler,
  				  udev->info.irq_flags, udev->info.name,
  				  udev);
+#else
+		err = request_irq(udev->info.irq, igbuio_pci_irqhandler,
+				  udev->info.irq_flags, udev->info.name,
+				  udev->info.uio_dev);
+#endif

Hi Jeff,

Quoted 2 lines

Can you please describe how this is solving the problem. Isn't only requirement for dev_id to be unique? Why it differs to pass uio_dev instead of udev pointer?

Hi, ferruh

yes, this is because the uio_device definition is not exposed in kernel earlier than 3.17, you could check the history of commit (6b9ed026a8704b9e5ee5da7997617ef7cc82e114), igb_uio: fix build with kernel <= 3.17, which fix it by

use using pointer of rte_uio_pci_dev instead.

Quoted 16 lines
Quoted 16 lines
lib/librte_eal/linuxapp/igb_uio/igb_uio.c +4 -0
  	dev_info(&udev->pdev->dev, "uio device registered with irq %ld\n",
  		 udev->info.irq);
 
@@ -292,7 +304,11 @@ static void
  igbuio_pci_disable_interrupts(struct rte_uio_pci_dev *udev)
  {
  	if (udev->info.irq) {
+#ifndef HAVE_UIO_DEVICE_STRUCTURE
  		free_irq(udev->info.irq, udev);
+#else
+		free_irq(udev->info.irq, udev->info.uio_dev);
+#endif
  		udev->info.irq = 0;
  	}
 
#10 lore raw
Quoted 74 lines · Jia
Quoted 68 lines · Ferruh Yigit
Quoted 55 lines · Jeff Guo

udev could not detect remove and add event of device when hotplug in and out devices, that related with the fix about using pointer of rte_uio_pci_dev as dev_id instead of uio_device for irq device handler, that would result igb uio irq failure when kernel version after than 3.17.

The root cause is that the older version of Linux kernel don't expose the uio_device structure, only for the kernel version after than 3.17 use uio_device. so this patch correct it by use a macro to check before handle the pci interrupt.

Fixes 6b9ed026a870 ("igb_uio: fix build with kernel <= 3.17")

---
v2->v1:
use macro in compat.h to replace of version check in .c file, benifit for future backport and make more readable.

---
 lib/librte_eal/linuxapp/igb_uio/compat.h  |  4 ++++
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 16 ++++++++++++++++
 2 files changed, 20 insertions(+)
lib/librte_eal/linuxapp/igb_uio/compat.h +4 -0
index ce456d4..2c61190 100644
@@ -132,3 +132,7 @@ static bool pci_check_and_mask_intx(struct pci_dev *pdev)
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
 #define HAVE_PCI_MSI_MASK_IRQ 1
 #endif
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(3, 17, 0)
+#define HAVE_UIO_DEVICE_STRUCTURE 1
+#endif
lib/librte_eal/linuxapp/igb_uio/igb_uio.c +6 -0
index 4cae4dd..99018f4 100644
@@ -192,8 +192,14 @@ igbuio_pci_irqcontrol(struct uio_info *info, s32 irq_state)
 static irqreturn_t
 igbuio_pci_irqhandler(int irq, void *dev_id)
 {
+#ifndef HAVE_UIO_DEVICE_STRUCTURE
 	struct rte_uio_pci_dev *udev = (struct rte_uio_pci_dev *)dev_id;
 	struct uio_info *info = &udev->info;
+#else
+	struct uio_device *idev = (struct uio_device *)dev_id;
+	struct uio_info *info = idev->info;
+	struct rte_uio_pci_dev *udev = info->priv;
+#endif
 
 	/* Legacy mode need to mask in hardware */
 	if (udev->mode == RTE_INTR_MODE_LEGACY &&
@@ -279,9 +285,15 @@ igbuio_pci_enable_interrupts(struct rte_uio_pci_dev *udev)
 	}
 

lib/librte_eal/linuxapp/igb_uio/igb_uio.c igbuio_pci_enable_interrupts(struct rte_uio_pci_dev *udev) · line 296

Quoted 10 lines
lib/librte_eal/linuxapp/igb_uio/igb_uio.c +6 -0
 	if (udev->info.irq != UIO_IRQ_NONE)
+#ifndef HAVE_UIO_DEVICE_STRUCTURE
 		err = request_irq(udev->info.irq, igbuio_pci_irqhandler,
 				  udev->info.irq_flags, udev->info.name,
 				  udev);
+#else
+		err = request_irq(udev->info.irq, igbuio_pci_irqhandler,
+				  udev->info.irq_flags, udev->info.name,
+				  udev->info.uio_dev);
+#endif

Hi Jeff,

Quoted 2 lines

Can you please describe how this is solving the problem. Isn't only requirement for dev_id to be unique? Why it differs to pass uio_dev instead of udev pointer?

Quoted 7 lines

Hi, ferruh

yes, this is because the uio_device definition is not exposed in kernel earlier than 3.17,  you could check the history of commit (6b9ed026a8704b9e5ee5da7997617ef7cc82e114), igb_uio: fix build with kernel <= 3.17, which fix it by

I get this part.

The question is how this is fixing uevent monitor issue.
Isn't the last parameter of the request_irq() is "void *" that has been passed to handler.
Why and where it differs if that pointer is "struct uio_device" or not?

Quoted 20 lines

use using pointer of rte_uio_pci_dev instead.

Quoted 16 lines
Quoted 16 lines
lib/librte_eal/linuxapp/igb_uio/igb_uio.c +4 -0
 	dev_info(&udev->pdev->dev, "uio device registered with irq %ld\n",
 		 udev->info.irq);
 
@@ -292,7 +304,11 @@ static void
 igbuio_pci_disable_interrupts(struct rte_uio_pci_dev *udev)
 {
 	if (udev->info.irq) {
+#ifndef HAVE_UIO_DEVICE_STRUCTURE
 		free_irq(udev->info.irq, udev);
+#else
+		free_irq(udev->info.irq, udev->info.uio_dev);
+#endif
 		udev->info.irq = 0;
 	}