Skip to contentSkip to conversation

eal: Fix device registration on FreeBSD

PATCH Applied Ben Walker 3 participants 3 messages Mar 21, 2017 – Mar 27, 2017

lore
Share & tools
lore

Ben Walker

author
#0 lore raw

PATCH 1/1 eal: Fix device registration on FreeBSD

The FreeBSD implementation wasn't registering new devices with the device framework on start up. However, common code attempts to unregister them on shutdown which causes a SEGFAULT. This fix makes the FreeBSD code do the same thing as the Linux code for registration.

---
 lib/librte_eal/bsdapp/eal/eal_pci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
lib/librte_eal/bsdapp/eal/eal_pci.c +4 -2
index 3a5c315..16a1743 100644
@@ -314,6 +314,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
 
 	/* device is valid, add in list (sorted) */
 	if (TAILQ_EMPTY(&pci_device_list)) {
+		rte_eal_device_insert(&dev->device);
 		TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
 	}
 	else {
@@ -326,7 +327,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
 				continue;
 			else if (ret < 0) {
 				TAILQ_INSERT_BEFORE(dev2, dev, next);
-				return 0;
+				rte_eal_device_insert(&dev->device);
 			} else { /* already registered */
 				dev2->kdrv = dev->kdrv;
 				dev2->max_vfs = dev->max_vfs;
@@ -334,9 +335,10 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
 					dev->mem_resource,
 					sizeof(dev->mem_resource));
 				free(dev);
-				return 0;
 			}
+			return 0;
 		}
+		rte_eal_device_insert(&dev->device);
 		TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
 	}
 
Signature · 1 line
2.9.3
Acked-by on v1 1/1
#1 lore raw
Quoted 35 lines · Ben Walker

The FreeBSD implementation wasn't registering new devices with the device framework on start up. However, common code attempts to unregister them on shutdown which causes a SEGFAULT. This fix makes the FreeBSD code do the same thing as the Linux code for registration.

---
 lib/librte_eal/bsdapp/eal/eal_pci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
lib/librte_eal/bsdapp/eal/eal_pci.c +2 -1
index 3a5c315..16a1743 100644
@@ -314,6 +314,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
 
 	/* device is valid, add in list (sorted) */
 	if (TAILQ_EMPTY(&pci_device_list)) {
+		rte_eal_device_insert(&dev->device);
 		TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
 	}
 	else {
@@ -326,7 +327,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
 				continue;
 			else if (ret < 0) {
 				TAILQ_INSERT_BEFORE(dev2, dev, next);
-				return 0;
+				rte_eal_device_insert(&dev->device);
 			} else { /* already registered */
 				dev2->kdrv = dev->kdrv;
 				dev2->max_vfs = dev->max_vfs;
@@ -334,9 +335,10 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
 					dev->mem_resource,

lib/librte_eal/bsdapp/eal/eal_pci.c pci_scan_one(int dev_pci_fd, struct pci_conf *conf) · line 344

Quoted 10 lines
lib/librte_eal/bsdapp/eal/eal_pci.c +2 -1
 					sizeof(dev->mem_resource));
 				free(dev);
-				return 0;
 			}
+			return 0;
 		}
+		rte_eal_device_insert(&dev->device);
 		TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
 	}
 

I can't vouch for BSD as I don't have that environment to verify. But, the patch looks fine to me as compared to Linux changes.

so, if my Ack makes sense:

#2 lore raw

2017-03-27 11:34, Shreyansh Jain:

Quoted 12 lines · Ben Walker
Quoted 10 lines

The FreeBSD implementation wasn't registering new devices with the device framework on start up. However, common code attempts to unregister them on shutdown which causes a SEGFAULT. This fix makes the FreeBSD code do the same thing as the Linux code for registration.

---
 lib/librte_eal/bsdapp/eal/eal_pci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 6 lines

I can't vouch for BSD as I don't have that environment to verify. But, the patch looks fine to me as compared to Linux changes.

so, if my Ack makes sense:

Applied, thanks