Skip to contentSkip to conversation

event/sw: fix missing device pointer

PATCH In review Bruce Richardson 5 participants 19 messages Oct 16, 2023 – Oct 19, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 event/sw: fix missing device pointer

After calling rte_event_dev_info_get() the ".dev" field of the info structure should have a pointer to the underlying device, allowing the user to e.g. get the device name using using rte_dev_name(info.dev).

The SW eventdev info structure did not return a correct device pointer, though, instead returning NULL, which caused crashes getting "rte_dev_name". Initializing the dev pointer inside the "eventdev" struct in the device probe function fixes this by ensuring we have a valid pointer to return in info_get calls.

Fixes aaa4a221da26 ("event/sw: add new software-only eventdev driver")
---
 drivers/event/sw/sw_evdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/event/sw/sw_evdev.c +1 -0
index 6d1816b76d..bf166a8cfc 100644
@@ -1080,6 +1080,7 @@ sw_probe(struct rte_vdev_device *vdev)
 		SW_LOG_ERR("eventdev vdev init() failed");
 		return -EFAULT;
 	}
+	dev->dev = &vdev->device;
 	dev->dev_ops = &evdev_sw_ops;
 	dev->enqueue = sw_event_enqueue;
 	dev->enqueue_burst = sw_event_enqueue_burst;
Signature · 1 line
2.39.2
Acked-by on v1 1/1
#1 lore raw
Quoted 19 lines

-----Original Message-----
From: Richardson, Bruce <[email protected]>
Sent: Monday, October 16, 2023 4:17 PM
To: [email protected]
Cc: Richardson, Bruce <[email protected]>; [email protected]; Van Haaren, Harry <[email protected]>; Jerin Jacob <[email protected]>
Subject: [PATCH] event/sw: fix missing device pointer

After calling rte_event_dev_info_get() the ".dev" field of the info structure should have a pointer to the underlying device, allowing the user to e.g. get the device name using using rte_dev_name(info.dev).

The SW eventdev info structure did not return a correct device pointer, though, instead returning NULL, which caused crashes getting "rte_dev_name". Initializing the dev pointer inside the "eventdev" struct in the device probe function fixes this by ensuring we have a valid pointer to return in info_get calls.

Quoted 4 lines
Fixes aaa4a221da26 ("event/sw: add new software-only eventdev driver")
#2 lore raw

PATCH v2 1/2 event/sw: fix missing device pointer

In reply to Bruce Richardson

After calling rte_event_dev_info_get() the ".dev" field of the info structure should have a pointer to the underlying device, allowing the user to e.g. get the device name using rte_dev_name(info.dev).

The SW eventdev info structure did not return a correct device pointer, though, instead returning NULL, which caused crashes getting "rte_dev_name". Initializing the dev pointer inside the "eventdev" struct in the device probe function fixes this by ensuring we have a valid pointer to return in info_get calls.

Fixes aaa4a221da26 ("event/sw: add new software-only eventdev driver")
---
 drivers/event/sw/sw_evdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/event/sw/sw_evdev.c +1 -0
index 6d1816b76d..bf166a8cfc 100644
@@ -1080,6 +1080,7 @@ sw_probe(struct rte_vdev_device *vdev)
 		SW_LOG_ERR("eventdev vdev init() failed");
 		return -EFAULT;
 	}
+	dev->dev = &vdev->device;
 	dev->dev_ops = &evdev_sw_ops;
 	dev->enqueue = sw_event_enqueue;
 	dev->enqueue_burst = sw_event_enqueue_burst;
Signature · 1 line
2.39.2
#3 lore raw

PATCH v2 2/2 event/dsw: fix missing device pointer

After calling rte_event_dev_info_get() the ".dev" field of the info structure should have a pointer to the underlying device, allowing the user to e.g. get the device name using rte_dev_name(info.dev).

The distributed software eventdev info structure did not return a correct device pointer, though, instead returning NULL, which caused crashes getting "rte_dev_name". Initializing the dev pointer inside the "eventdev" struct in the device probe function fixes this by ensuring we have a valid pointer to return in info_get calls.

Fixes 46a186b1f0c5 ("event/dsw: add device registration and build system")
---
 drivers/event/dsw/dsw_evdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/event/dsw/dsw_evdev.c +1 -0
index 785c12f61f..44da3c60d1 100644
@@ -440,6 +440,7 @@ dsw_probe(struct rte_vdev_device *vdev)
 		return -EFAULT;
 
 	dev->dev_ops = &dsw_evdev_ops;
+	dev->dev = &vdev->device;
 	dev->enqueue = dsw_event_enqueue;
 	dev->enqueue_burst = dsw_event_enqueue_burst;
 	dev->enqueue_new_burst = dsw_event_enqueue_new_burst;
Signature · 1 line
2.39.2
#4 lore raw

v3 cover Fix device info for SW eventdevs

In reply to Bruce Richardson

The SW-based eventdevs were missing some basic info in the returned structure from info_get, which could cause crashes if any of the null pointers were dereferenced. These 4 small patches fix these issues.

Bruce Richardson (4):
event/sw: fix missing device pointer
event/dsw: fix missing device pointer
event/skeleton: fix missing device pointer
event/skeleton: set driver name string

 drivers/event/dsw/dsw_evdev.c              | 1 +
 drivers/event/skeleton/skeleton_eventdev.c | 7 +++++--
 drivers/event/sw/sw_evdev.c                | 1 +
 3 files changed, 7 insertions(+), 2 deletions(-)

--
2.39.2

#5 lore raw

PATCH v3 1/4 event/sw: fix missing device pointer

Initialize the "dev" pointer in the eventdev structure so it can be returned in calls to "rte_event_dev_info_get()" and avoid potential crashes due to a NULL value being passed to "rte_dev_name()"

Fixes aaa4a221da26 ("event/sw: add new software-only eventdev driver")
---
 drivers/event/sw/sw_evdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/event/sw/sw_evdev.c +1 -0
index 6d1816b76d..bf166a8cfc 100644
@@ -1080,6 +1080,7 @@ sw_probe(struct rte_vdev_device *vdev)
 		SW_LOG_ERR("eventdev vdev init() failed");
 		return -EFAULT;
 	}
+	dev->dev = &vdev->device;
 	dev->dev_ops = &evdev_sw_ops;
 	dev->enqueue = sw_event_enqueue;
 	dev->enqueue_burst = sw_event_enqueue_burst;
Signature · 1 line
2.39.2
#6 lore raw

PATCH v3 2/4 event/dsw: fix missing device pointer

In reply to Bruce Richardson

Initialize the "dev" pointer in the eventdev structure so it can be returned in calls to "rte_event_dev_info_get()" and avoid potential crashes due to a NULL value being passed to "rte_dev_name()"

Fixes 46a186b1f0c5 ("event/dsw: add device registration and build system")
---
 drivers/event/dsw/dsw_evdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/event/dsw/dsw_evdev.c +1 -0
index 785c12f61f..44da3c60d1 100644
@@ -440,6 +440,7 @@ dsw_probe(struct rte_vdev_device *vdev)
 		return -EFAULT;
 
 	dev->dev_ops = &dsw_evdev_ops;
+	dev->dev = &vdev->device;
 	dev->enqueue = dsw_event_enqueue;
 	dev->enqueue_burst = dsw_event_enqueue_burst;
 	dev->enqueue_new_burst = dsw_event_enqueue_new_burst;
Signature · 1 line
2.39.2
Acked-by on v3 2/4
#7 lore raw

Re: [PATCH v3 2/4] event/dsw: fix missing device pointer

Quoted 18 lines · Bruce Richardson

Initialize the "dev" pointer in the eventdev structure so it can be returned in calls to "rte_event_dev_info_get()" and avoid potential crashes due to a NULL value being passed to "rte_dev_name()"

Fixes 46a186b1f0c5 ("event/dsw: add device registration and build system")
---
  drivers/event/dsw/dsw_evdev.c | 1 +
  1 file changed, 1 insertion(+)
drivers/event/dsw/dsw_evdev.c +0 -0
index 785c12f61f..44da3c60d1 100644

drivers/event/dsw/dsw_evdev.c dsw_probe(struct rte_vdev_device *vdev) · line 446

Quoted 7 lines
drivers/event/dsw/dsw_evdev.c +1 -0
@@ -440,6 +440,7 @@ dsw_probe(struct rte_vdev_device *vdev)
  		return -EFAULT;
 
  	dev->dev_ops = &dsw_evdev_ops;
+	dev->dev = &vdev->device;
  	dev->enqueue = dsw_event_enqueue;
  	dev->enqueue_burst = dsw_event_enqueue_burst;
  	dev->enqueue_new_burst = dsw_event_enqueue_new_burst;
#8 lore raw

PATCH v3 3/4 event/skeleton: fix missing device pointer

In reply to Bruce Richardson

Initialize the "dev" pointer in the eventdev structure so it can be returned in calls to "rte_event_dev_info_get()" and avoid potential crashes due to a NULL value being passed to "rte_dev_name()"

Fixes bbbb929da5e6 ("event/skeleton: add skeleton eventdev driver")
---
 drivers/event/skeleton/skeleton_eventdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/event/skeleton/skeleton_eventdev.c +3 -2
index dc9b131641..3aa6657f39 100644
@@ -428,7 +428,7 @@ RTE_PMD_REGISTER_PCI_TABLE(event_skeleton_pci, pci_id_skeleton_map);
 /* VDEV based event device */
 
 static int
-skeleton_eventdev_create(const char *name, int socket_id)
+skeleton_eventdev_create(const char *name, int socket_id, struct rte_vdev_device *vdev)
 {
 	struct rte_eventdev *eventdev;
 
@@ -440,6 +440,7 @@ skeleton_eventdev_create(const char *name, int socket_id)
 	}
 
 	eventdev->dev_ops       = &skeleton_eventdev_ops;
+	eventdev->dev           = &vdev->device;
 	eventdev->enqueue       = skeleton_eventdev_enqueue;
 	eventdev->enqueue_burst = skeleton_eventdev_enqueue_burst;
 	eventdev->dequeue       = skeleton_eventdev_dequeue;
@@ -459,7 +460,7 @@ skeleton_eventdev_probe(struct rte_vdev_device *vdev)
 	name = rte_vdev_device_name(vdev);
 	RTE_LOG(INFO, PMD, "Initializing %s on NUMA node %d\n", name,
 			rte_socket_id());
-	return skeleton_eventdev_create(name, rte_socket_id());
+	return skeleton_eventdev_create(name, rte_socket_id(), vdev);
 }
 
 static int
Signature · 1 line
2.39.2
#9 lore raw

PATCH v3 4/4 event/skeleton: set driver name string

In reply to Bruce Richardson

When calling rte_eventdev_info_get() the driver name string field should be populated.

Fixes bbbb929da5e6 ("event/skeleton: add skeleton eventdev driver")
---
 drivers/event/skeleton/skeleton_eventdev.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/event/skeleton/skeleton_eventdev.c +2 -0
index 3aa6657f39..ccceae22ad 100644
@@ -24,6 +24,7 @@
 
 #define EVENTDEV_NAME_SKELETON_PMD event_skeleton
 /**< Skeleton event device PMD name */
+#define EVENTDEV_NAME_STRING RTE_STR(EVENTDEV_NAME_SKELETON_PMD)
 
 static uint16_t
 skeleton_eventdev_enqueue(void *port, const struct rte_event *ev)
@@ -88,6 +89,7 @@ skeleton_eventdev_info_get(struct rte_eventdev *dev,
 
 	RTE_SET_USED(skel);
 
+	dev_info->driver_name = EVENTDEV_NAME_STRING;
 	dev_info->min_dequeue_timeout_ns = 1;
 	dev_info->max_dequeue_timeout_ns = 10000;
 	dev_info->dequeue_timeout_ns = 25;
Signature · 1 line
2.39.2
#10 lore raw

PATCH v4 1/2 event/*: set device pointer for vdev-based eventdevs

In reply to Bruce Richardson

The eventdevs based on vdevs, rather than on e.g. HW PCI devices, were, as a rule, not setting the ".dev" pointer in the eventdev structure. This caused issues as a NULL pointer was returned in calls to info_get, triggering crashes if the pointer is passed unchecked to e.g. rte_dev_name() to print out the name of an event device.

Most effective, and future-proofed fix, is to not rely on the eventdev drivers to set the pointer themselves, but to change the vdev init function to take the vdev struct as parameter, and set the "dev" pointer centrally on init. This allows us to fix all drivers in one go, enforced by compiler error if the parameter is missing.

Fixes aaa4a221da26 ("event/sw: add new software-only eventdev driver")
Fixes 46a186b1f0c5 ("event/dsw: add device registration and build system")
Fixes bbbb929da5e6 ("event/skeleton: add skeleton eventdev driver")
Fixes 3c7f3dcfb099 ("event/opdl: add PMD main body and helper function")
Fixes 9caac5dd1e7f ("event/dpaa: introduce PMD")
Fixes 8a5d7a8ec74b ("event/dpaa2: initialize device")
Fixes 34498de6000f ("event/octeontx: add octeontx eventdev driver")
---
 drivers/event/dpaa/dpaa_eventdev.c         | 6 +++---
 drivers/event/dpaa2/dpaa2_eventdev.c       | 6 +++---
 drivers/event/dsw/dsw_evdev.c              | 2 +-
 drivers/event/octeontx/ssovf_evdev.c       | 2 +-
 drivers/event/opdl/opdl_evdev.c            | 2 +-
 drivers/event/skeleton/skeleton_eventdev.c | 6 +++---
 drivers/event/sw/sw_evdev.c                | 2 +-
 lib/eventdev/eventdev_pmd_vdev.h           | 3 ++-
 8 files changed, 15 insertions(+), 14 deletions(-)
drivers/event/dpaa/dpaa_eventdev.c +3 -3
index f615da3813..46a9b88c73 100644
@@ -994,14 +994,14 @@ dpaa_event_check_flags(const char *params)
 }
 
 static int
-dpaa_event_dev_create(const char *name, const char *params)
+dpaa_event_dev_create(const char *name, const char *params, struct rte_vdev_device *vdev)
 {
 	struct rte_eventdev *eventdev;
 	struct dpaa_eventdev *priv;
 
 	eventdev = rte_event_pmd_vdev_init(name,
 					   sizeof(struct dpaa_eventdev),
-					   rte_socket_id());
+					   rte_socket_id(), vdev);
 	if (eventdev == NULL) {
 		DPAA_EVENTDEV_ERR("Failed to create eventdev vdev %s", name);
 		goto fail;
@@ -1051,7 +1051,7 @@ dpaa_event_dev_probe(struct rte_vdev_device *vdev)
 
 	params = rte_vdev_device_args(vdev);
 
-	return dpaa_event_dev_create(name, params);
+	return dpaa_event_dev_create(name, params, vdev);
 }
 
 static int
drivers/event/dpaa2/dpaa2_eventdev.c +3 -3
index ffc5550f85..dd4e64395f 100644
@@ -1086,7 +1086,7 @@ dpaa2_eventdev_setup_dpci(struct dpaa2_dpci_dev *dpci_dev,
 }
 
 static int
-dpaa2_eventdev_create(const char *name)
+dpaa2_eventdev_create(const char *name, struct rte_vdev_device *vdev)
 {
 	struct rte_eventdev *eventdev;
 	struct dpaa2_eventdev *priv;
@@ -1096,7 +1096,7 @@ dpaa2_eventdev_create(const char *name)
 
 	eventdev = rte_event_pmd_vdev_init(name,
 					   sizeof(struct dpaa2_eventdev),
-					   rte_socket_id());
+					   rte_socket_id(), vdev);
 	if (eventdev == NULL) {
 		DPAA2_EVENTDEV_ERR("Failed to create Event device %s", name);
 		goto fail;
@@ -1190,7 +1190,7 @@ dpaa2_eventdev_probe(struct rte_vdev_device *vdev)
 
 	name = rte_vdev_device_name(vdev);
 	DPAA2_EVENTDEV_INFO("Initializing %s", name);
-	return dpaa2_eventdev_create(name);
+	return dpaa2_eventdev_create(name, vdev);
 }
 
 static int
drivers/event/dsw/dsw_evdev.c +1 -1
index 785c12f61f..1209e73a9d 100644
@@ -435,7 +435,7 @@ dsw_probe(struct rte_vdev_device *vdev)
 	name = rte_vdev_device_name(vdev);
 
 	dev = rte_event_pmd_vdev_init(name, sizeof(struct dsw_evdev),
-				      rte_socket_id());
+				      rte_socket_id(), vdev);
 	if (dev == NULL)
 		return -EFAULT;
 
drivers/event/octeontx/ssovf_evdev.c +1 -1
index 0eb9358981..a16f24e088 100644
@@ -880,7 +880,7 @@ ssovf_vdev_probe(struct rte_vdev_device *vdev)
 	}
 
 	eventdev = rte_event_pmd_vdev_init(name, sizeof(struct ssovf_evdev),
-				rte_socket_id());
+				rte_socket_id(), vdev);
 	if (eventdev == NULL) {
 		ssovf_log_err("Failed to create eventdev vdev %s", name);
 		return -ENOMEM;
drivers/event/opdl/opdl_evdev.c +1 -1
index dd25749654..0cccaf7e97 100644
@@ -697,7 +697,7 @@ opdl_probe(struct rte_vdev_device *vdev)
 		}
 	}
 	dev = rte_event_pmd_vdev_init(name,
-			sizeof(struct opdl_evdev), socket_id);
+			sizeof(struct opdl_evdev), socket_id, vdev);
 
 	if (dev == NULL) {
 		PMD_DRV_LOG(ERR, "eventdev vdev init() failed");
drivers/event/skeleton/skeleton_eventdev.c +3 -3
index dc9b131641..7db1efaf14 100644
@@ -428,12 +428,12 @@ RTE_PMD_REGISTER_PCI_TABLE(event_skeleton_pci, pci_id_skeleton_map);
 /* VDEV based event device */
 
 static int
-skeleton_eventdev_create(const char *name, int socket_id)
+skeleton_eventdev_create(const char *name, int socket_id, struct rte_vdev_device *vdev)
 {
 	struct rte_eventdev *eventdev;
 
 	eventdev = rte_event_pmd_vdev_init(name,
-			sizeof(struct skeleton_eventdev), socket_id);
+			sizeof(struct skeleton_eventdev), socket_id, vdev);
 	if (eventdev == NULL) {
 		PMD_DRV_ERR("Failed to create eventdev vdev %s", name);
 		goto fail;
@@ -459,7 +459,7 @@ skeleton_eventdev_probe(struct rte_vdev_device *vdev)
 	name = rte_vdev_device_name(vdev);
 	RTE_LOG(INFO, PMD, "Initializing %s on NUMA node %d\n", name,
 			rte_socket_id());
-	return skeleton_eventdev_create(name, rte_socket_id());
+	return skeleton_eventdev_create(name, rte_socket_id(), vdev);
 }
 
 static int
drivers/event/sw/sw_evdev.c +1 -1
index 6d1816b76d..55e7735cb0 100644
@@ -1075,7 +1075,7 @@ sw_probe(struct rte_vdev_device *vdev)
 			min_burst_size, deq_burst_size, refill_once);
 
 	dev = rte_event_pmd_vdev_init(name,
-			sizeof(struct sw_evdev), socket_id);
+			sizeof(struct sw_evdev), socket_id, vdev);
 	if (dev == NULL) {
 		SW_LOG_ERR("eventdev vdev init() failed");
 		return -EFAULT;
lib/eventdev/eventdev_pmd_vdev.h +2 -1
index 5fa9d699ac..bb433ba955 100644
@@ -45,7 +45,7 @@ extern "C" {
 __rte_internal
 static inline struct rte_eventdev *
 rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
-		int socket_id)
+		int socket_id, struct rte_vdev_device *vdev)
 {
 
 	struct rte_eventdev *eventdev;
@@ -67,6 +67,7 @@ rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
 			rte_panic("Cannot allocate memzone for private device"
 					" data");
 	}
+	eventdev->dev = &vdev->device;
 
 	return eventdev;
 }
Signature · 1 line
2.39.2
#11 lore raw

PATCH v4 2/2 event/skeleton: set driver name string

When calling rte_eventdev_info_get() the driver name string field should be populated.

Fixes bbbb929da5e6 ("event/skeleton: add skeleton eventdev driver")
---
 drivers/event/skeleton/skeleton_eventdev.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/event/skeleton/skeleton_eventdev.c +2 -0
index 7db1efaf14..6afb5de824 100644
@@ -24,6 +24,7 @@
 
 #define EVENTDEV_NAME_SKELETON_PMD event_skeleton
 /**< Skeleton event device PMD name */
+#define EVENTDEV_NAME_STRING RTE_STR(EVENTDEV_NAME_SKELETON_PMD)
 
 static uint16_t
 skeleton_eventdev_enqueue(void *port, const struct rte_event *ev)
@@ -88,6 +89,7 @@ skeleton_eventdev_info_get(struct rte_eventdev *dev,
 
 	RTE_SET_USED(skel);
 
+	dev_info->driver_name = EVENTDEV_NAME_STRING;
 	dev_info->min_dequeue_timeout_ns = 1;
 	dev_info->max_dequeue_timeout_ns = 10000;
 	dev_info->dequeue_timeout_ns = 25;
Signature · 1 line
2.39.2
#12 lore raw

Re: [PATCH v4 2/2] event/skeleton: set driver name string

Quoted 8 lines · Bruce Richardson

When calling rte_eventdev_info_get() the driver name string field should be populated.

Fixes bbbb929da5e6 ("event/skeleton: add skeleton eventdev driver")

event/dpaa2 seems affected too.

Can rte_eventdev_info_get() fill this based on the driver attached to the device, like ethdev does?

Something like untested:

lib/eventdev/rte_eventdev.c +0 -0
index 95373bbaad..37ccc0dc77 100644
@@ -104,6 +104,7 @@ rte_event_dev_info_get(uint8_t dev_id, struct

rte_event_dev_info *dev_info)

        dev_info->dequeue_timeout_ns = dev->data->dev_conf.dequeue_timeout_ns;

        dev_info->dev = dev->dev;

+ dev_info->driver_name = dev->dev->driver->name;

        rte_eventdev_trace_info_get(dev_id, dev_info, dev_info->dev);
Signature · 1 line
David Marchand
#13 lore raw

Re: [PATCH v4 2/2] event/skeleton: set driver name string

Quoted 6 lines · David Marchand
Quoted 4 lines · Bruce Richardson

When calling rte_eventdev_info_get() the driver name string field should be populated.

Quoted 7 lines
Quoted 4 lines
Fixes bbbb929da5e6 ("event/skeleton: add skeleton eventdev driver")

event/dpaa2 seems affected too.

Ok, hadn't noticed that. I tested all the SW drivers I could and didn't find any of them affected.

Quoted 11 lines

Can rte_eventdev_info_get() fill this based on the driver attached to the device, like ethdev does?

Something like untested:

lib/eventdev/rte_eventdev.c +0 -0
index 95373bbaad..37ccc0dc77 100644

lib/eventdev/rte_eventdev.c rte_event_dev_info_get(uint8_t dev_id, struct · line 110

Quoted 7 lines
lib/eventdev/rte_eventdev.c +1 -0
@@ -104,6 +104,7 @@ rte_event_dev_info_get(uint8_t dev_id, struct
 rte_event_dev_info *dev_info)
        dev_info->dequeue_timeout_ns = dev->data->dev_conf.dequeue_timeout_ns;
 
        dev_info->dev = dev->dev;
+       dev_info->driver_name = dev->dev->driver->name;
 
        rte_eventdev_trace_info_get(dev_id, dev_info, dev_info->dev);

Ok, let me do up and test a patch.

/Bruce

#14 lore raw

Re: [PATCH v4 2/2] event/skeleton: set driver name string

Quoted 31 lines · Bruce Richardson
Quoted 6 lines · David Marchand
Quoted 4 lines · Bruce Richardson

When calling rte_eventdev_info_get() the driver name string field should be populated.

Quoted 7 lines
Quoted 4 lines
Fixes bbbb929da5e6 ("event/skeleton: add skeleton eventdev driver")

event/dpaa2 seems affected too.

Ok, hadn't noticed that. I tested all the SW drivers I could and didn't find any of them affected.

Quoted 13 lines

Can rte_eventdev_info_get() fill this based on the driver attached to the device, like ethdev does?

Something like untested:

lib/eventdev/rte_eventdev.c +0 -0
index 95373bbaad..37ccc0dc77 100644
@@ -104,6 +104,7 @@ rte_event_dev_info_get(uint8_t dev_id, struct
 rte_event_dev_info *dev_info)
        dev_info->dequeue_timeout_ns = dev->data->dev_conf.dequeue_timeout_ns;
 
Quoted 7 lines

lib/eventdev/rte_eventdev.c rte_event_dev_info_get(uint8_t dev_id, struct · line 110

Quoted 5 lines
lib/eventdev/rte_eventdev.c +1 -0
        dev_info->dev = dev->dev;
+       dev_info->driver_name = dev->dev->driver->name;
 
        rte_eventdev_trace_info_get(dev_id, dev_info, dev_info->dev);

Ok, let me do up and test a patch.

V5 sent with this fix instead. I just added some additional conditionals around it, just in case we end up with some Null pointers in that chain (hopefully not after the previous patch, but better to check).

Testing with skeleton, sw, dsw and opdl drivers showed no issues with reporting the driver name.

/Bruce

Acked-by on v4 1/2
#15 lore raw

Re: [PATCH v4 1/2] event/*: set device pointer for vdev-based eventdevs

In reply to Bruce Richardson
Quoted 22 lines · Bruce Richardson

The eventdevs based on vdevs, rather than on e.g. HW PCI devices, were, as a rule, not setting the ".dev" pointer in the eventdev structure. This caused issues as a NULL pointer was returned in calls to info_get, triggering crashes if the pointer is passed unchecked to e.g. rte_dev_name() to print out the name of an event device.

Most effective, and future-proofed fix, is to not rely on the eventdev drivers to set the pointer themselves, but to change the vdev init function to take the vdev struct as parameter, and set the "dev" pointer centrally on init. This allows us to fix all drivers in one go, enforced by compiler error if the parameter is missing.

Fixes aaa4a221da26 ("event/sw: add new software-only eventdev driver")
Fixes 46a186b1f0c5 ("event/dsw: add device registration and build system")
Fixes bbbb929da5e6 ("event/skeleton: add skeleton eventdev driver")
Fixes 3c7f3dcfb099 ("event/opdl: add PMD main body and helper function")
Fixes 9caac5dd1e7f ("event/dpaa: introduce PMD")
Fixes 8a5d7a8ec74b ("event/dpaa2: initialize device")
Fixes 34498de6000f ("event/octeontx: add octeontx eventdev driver")
Quoted 1 line
Signature · 1 line
David Marchand
#16 lore raw

PATCH v5 1/2 eventdev: fix device pointer for vdev-based eventdevs

In reply to Bruce Richardson

The eventdevs based on vdevs, rather than on e.g. HW PCI devices, were, as a rule, not setting the ".dev" pointer in the eventdev structure. This caused issues as a NULL pointer was returned in calls to info_get, triggering crashes if the pointer is passed unchecked to e.g. rte_dev_name() to print out the name of an event device.

Most effective, and future-proofed fix, is to not rely on the eventdev drivers to set the pointer themselves, but to change the vdev init function to take the vdev struct as parameter, and set the "dev" pointer centrally on init. This allows us to fix all drivers in one go, enforced by compiler error if the parameter is missing.

Fixes aaa4a221da26 ("event/sw: add new software-only eventdev driver")
Fixes 46a186b1f0c5 ("event/dsw: add device registration and build system")
Fixes bbbb929da5e6 ("event/skeleton: add skeleton eventdev driver")
Fixes 3c7f3dcfb099 ("event/opdl: add PMD main body and helper function")
Fixes 9caac5dd1e7f ("event/dpaa: introduce PMD")
Fixes 8a5d7a8ec74b ("event/dpaa2: initialize device")
Fixes 34498de6000f ("event/octeontx: add octeontx eventdev driver")
---
 drivers/event/dpaa/dpaa_eventdev.c         | 6 +++---
 drivers/event/dpaa2/dpaa2_eventdev.c       | 6 +++---
 drivers/event/dsw/dsw_evdev.c              | 2 +-
 drivers/event/octeontx/ssovf_evdev.c       | 2 +-
 drivers/event/opdl/opdl_evdev.c            | 2 +-
 drivers/event/skeleton/skeleton_eventdev.c | 6 +++---
 drivers/event/sw/sw_evdev.c                | 2 +-
 lib/eventdev/eventdev_pmd_vdev.h           | 3 ++-
 8 files changed, 15 insertions(+), 14 deletions(-)
drivers/event/dpaa/dpaa_eventdev.c +3 -3
index f615da3813..46a9b88c73 100644
@@ -994,14 +994,14 @@ dpaa_event_check_flags(const char *params)
 }
 
 static int
-dpaa_event_dev_create(const char *name, const char *params)
+dpaa_event_dev_create(const char *name, const char *params, struct rte_vdev_device *vdev)
 {
 	struct rte_eventdev *eventdev;
 	struct dpaa_eventdev *priv;
 
 	eventdev = rte_event_pmd_vdev_init(name,
 					   sizeof(struct dpaa_eventdev),
-					   rte_socket_id());
+					   rte_socket_id(), vdev);
 	if (eventdev == NULL) {
 		DPAA_EVENTDEV_ERR("Failed to create eventdev vdev %s", name);
 		goto fail;
@@ -1051,7 +1051,7 @@ dpaa_event_dev_probe(struct rte_vdev_device *vdev)
 
 	params = rte_vdev_device_args(vdev);
 
-	return dpaa_event_dev_create(name, params);
+	return dpaa_event_dev_create(name, params, vdev);
 }
 
 static int
drivers/event/dpaa2/dpaa2_eventdev.c +3 -3
index ffc5550f85..dd4e64395f 100644
@@ -1086,7 +1086,7 @@ dpaa2_eventdev_setup_dpci(struct dpaa2_dpci_dev *dpci_dev,
 }
 
 static int
-dpaa2_eventdev_create(const char *name)
+dpaa2_eventdev_create(const char *name, struct rte_vdev_device *vdev)
 {
 	struct rte_eventdev *eventdev;
 	struct dpaa2_eventdev *priv;
@@ -1096,7 +1096,7 @@ dpaa2_eventdev_create(const char *name)
 
 	eventdev = rte_event_pmd_vdev_init(name,
 					   sizeof(struct dpaa2_eventdev),
-					   rte_socket_id());
+					   rte_socket_id(), vdev);
 	if (eventdev == NULL) {
 		DPAA2_EVENTDEV_ERR("Failed to create Event device %s", name);
 		goto fail;
@@ -1190,7 +1190,7 @@ dpaa2_eventdev_probe(struct rte_vdev_device *vdev)
 
 	name = rte_vdev_device_name(vdev);
 	DPAA2_EVENTDEV_INFO("Initializing %s", name);
-	return dpaa2_eventdev_create(name);
+	return dpaa2_eventdev_create(name, vdev);
 }
 
 static int
drivers/event/dsw/dsw_evdev.c +1 -1
index 785c12f61f..1209e73a9d 100644
@@ -435,7 +435,7 @@ dsw_probe(struct rte_vdev_device *vdev)
 	name = rte_vdev_device_name(vdev);
 
 	dev = rte_event_pmd_vdev_init(name, sizeof(struct dsw_evdev),
-				      rte_socket_id());
+				      rte_socket_id(), vdev);
 	if (dev == NULL)
 		return -EFAULT;
 
drivers/event/octeontx/ssovf_evdev.c +1 -1
index 0eb9358981..a16f24e088 100644
@@ -880,7 +880,7 @@ ssovf_vdev_probe(struct rte_vdev_device *vdev)
 	}
 
 	eventdev = rte_event_pmd_vdev_init(name, sizeof(struct ssovf_evdev),
-				rte_socket_id());
+				rte_socket_id(), vdev);
 	if (eventdev == NULL) {
 		ssovf_log_err("Failed to create eventdev vdev %s", name);
 		return -ENOMEM;
drivers/event/opdl/opdl_evdev.c +1 -1
index dd25749654..0cccaf7e97 100644
@@ -697,7 +697,7 @@ opdl_probe(struct rte_vdev_device *vdev)
 		}
 	}
 	dev = rte_event_pmd_vdev_init(name,
-			sizeof(struct opdl_evdev), socket_id);
+			sizeof(struct opdl_evdev), socket_id, vdev);
 
 	if (dev == NULL) {
 		PMD_DRV_LOG(ERR, "eventdev vdev init() failed");
drivers/event/skeleton/skeleton_eventdev.c +3 -3
index dc9b131641..7db1efaf14 100644
@@ -428,12 +428,12 @@ RTE_PMD_REGISTER_PCI_TABLE(event_skeleton_pci, pci_id_skeleton_map);
 /* VDEV based event device */
 
 static int
-skeleton_eventdev_create(const char *name, int socket_id)
+skeleton_eventdev_create(const char *name, int socket_id, struct rte_vdev_device *vdev)
 {
 	struct rte_eventdev *eventdev;
 
 	eventdev = rte_event_pmd_vdev_init(name,
-			sizeof(struct skeleton_eventdev), socket_id);
+			sizeof(struct skeleton_eventdev), socket_id, vdev);
 	if (eventdev == NULL) {
 		PMD_DRV_ERR("Failed to create eventdev vdev %s", name);
 		goto fail;
@@ -459,7 +459,7 @@ skeleton_eventdev_probe(struct rte_vdev_device *vdev)
 	name = rte_vdev_device_name(vdev);
 	RTE_LOG(INFO, PMD, "Initializing %s on NUMA node %d\n", name,
 			rte_socket_id());
-	return skeleton_eventdev_create(name, rte_socket_id());
+	return skeleton_eventdev_create(name, rte_socket_id(), vdev);
 }
 
 static int
drivers/event/sw/sw_evdev.c +1 -1
index 6d1816b76d..55e7735cb0 100644
@@ -1075,7 +1075,7 @@ sw_probe(struct rte_vdev_device *vdev)
 			min_burst_size, deq_burst_size, refill_once);
 
 	dev = rte_event_pmd_vdev_init(name,
-			sizeof(struct sw_evdev), socket_id);
+			sizeof(struct sw_evdev), socket_id, vdev);
 	if (dev == NULL) {
 		SW_LOG_ERR("eventdev vdev init() failed");
 		return -EFAULT;
lib/eventdev/eventdev_pmd_vdev.h +2 -1
index 5fa9d699ac..bb433ba955 100644
@@ -45,7 +45,7 @@ extern "C" {
 __rte_internal
 static inline struct rte_eventdev *
 rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
-		int socket_id)
+		int socket_id, struct rte_vdev_device *vdev)
 {
 
 	struct rte_eventdev *eventdev;
@@ -67,6 +67,7 @@ rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
 			rte_panic("Cannot allocate memzone for private device"
 					" data");
 	}
+	eventdev->dev = &vdev->device;
 
 	return eventdev;
 }
Signature · 1 line
2.39.2
#17 lore raw

PATCH v5 2/2 eventdev: fix missing driver names in info struct

Rather than relying on the individual drivers to always populated the driver name field in the info structure - something missed by some drivers, we can do so in the eventdev rte_event_dev_info_get() function. This fixes issues

Fixes bbbb929da5e6 ("event/skeleton: add skeleton eventdev driver")
Fixes 0ce3ce7c275c ("event/dpaa2: add configuration functions")
---
 lib/eventdev/rte_eventdev.c | 2 ++
 1 file changed, 2 insertions(+)
lib/eventdev/rte_eventdev.c +2 -0
index 95373bbaad..0ca32d6721 100644
@@ -104,6 +104,8 @@ rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info)
 	dev_info->dequeue_timeout_ns = dev->data->dev_conf.dequeue_timeout_ns;
 
 	dev_info->dev = dev->dev;
+	if (dev->dev != NULL && dev->dev->driver != NULL)
+		dev_info->driver_name = dev->dev->driver->name;
 
 	rte_eventdev_trace_info_get(dev_id, dev_info, dev_info->dev);
 
Signature · 1 line
2.39.2
#18 lore raw

Re: [PATCH v5 2/2] eventdev: fix missing driver names in info struct

Quoted 6 lines · Bruce Richardson

Rather than relying on the individual drivers to always populated the driver name field in the info structure - something missed by some drivers, we can do so in the eventdev rte_event_dev_info_get() function. This fixes issues

Quoted 6 lines
Fixes bbbb929da5e6 ("event/skeleton: add skeleton eventdev driver")
Fixes 0ce3ce7c275c ("event/dpaa2: add configuration functions")

Series applied to dpdk-next--eventdev/for-main. Thanks