From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E9FEC4319B for ; Wed, 18 Oct 2023 14:26:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E31C440E54; Wed, 18 Oct 2023 14:26:29 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 017CD40261; Wed, 18 Oct 2023 14:26:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697631987; x=1729167987; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JcST8ydfMAfuesW+qsF8miwDAXHW8rfkSuyN1y6ylV4=; b=an3Szqv2qkMyX6EO0lF4mjq9yDtK4gdXDm4dcJ1PY4XJMKuxWg4+oA2q epBhrEHcIvTQHoK8gSbGejaryiFHhsfuod4RrVVOUO39YG5mqvDgU3zes fcnlsrZyg+g+DU+V19cAB9BrED16+L302LiOEHjl01kUN5hH1ff7W7fDi pfXwDACPI/kt5aaoMYHX3lUg1QJ7FSGBkX14yef080LXtTecIHLSKVJ4V gXQbYYKafZ2IfQZylOYM3QREtBP/WZoYXiogeQHHfPSRFfL26pGNXiOQa W4ufDL/rEY2XA8T7BmQnXS2p2r2mz4YopCsodcm+vm3N+1rQdV905HMfj g==; X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="388863905" X-IronPort-AV: E=Sophos;i="6.03,235,1694761200"; d="scan'208";a="388863905" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2023 05:26:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="1003789578" X-IronPort-AV: E=Sophos;i="6.03,235,1694761200"; d="scan'208";a="1003789578" Received: from unknown (HELO silpixa00401385.ir.intel.com) ([10.237.214.41]) by fmsmga006.fm.intel.com with ESMTP; 18 Oct 2023 05:26:22 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , stable@dpdk.org, Hemant Agrawal , Sachin Saxena , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= , Jerin Jacob , Liang Ma , Peter Mccarthy , Harry van Haaren , Nipun Gupta , Santosh Shukla , Gage Eads Subject: [PATCH v4 1/2] event/*: set device pointer for vdev-based eventdevs Date: Wed, 18 Oct 2023 13:25:25 +0100 Message-Id: <20231018122558.126686-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231016151713.711965-1-bruce.richardson@intel.com> References: <20231016151713.711965-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org 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") Cc: stable@dpdk.org Signed-off-by: Bruce Richardson --- 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(-) diff --git a/drivers/event/dpaa/dpaa_eventdev.c b/drivers/event/dpaa/dpaa_eventdev.c index f615da3813..46a9b88c73 100644 --- a/drivers/event/dpaa/dpaa_eventdev.c +++ b/drivers/event/dpaa/dpaa_eventdev.c @@ -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 diff --git a/drivers/event/dpaa2/dpaa2_eventdev.c b/drivers/event/dpaa2/dpaa2_eventdev.c index ffc5550f85..dd4e64395f 100644 --- a/drivers/event/dpaa2/dpaa2_eventdev.c +++ b/drivers/event/dpaa2/dpaa2_eventdev.c @@ -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 diff --git a/drivers/event/dsw/dsw_evdev.c b/drivers/event/dsw/dsw_evdev.c index 785c12f61f..1209e73a9d 100644 --- a/drivers/event/dsw/dsw_evdev.c +++ b/drivers/event/dsw/dsw_evdev.c @@ -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; diff --git a/drivers/event/octeontx/ssovf_evdev.c b/drivers/event/octeontx/ssovf_evdev.c index 0eb9358981..a16f24e088 100644 --- a/drivers/event/octeontx/ssovf_evdev.c +++ b/drivers/event/octeontx/ssovf_evdev.c @@ -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; diff --git a/drivers/event/opdl/opdl_evdev.c b/drivers/event/opdl/opdl_evdev.c index dd25749654..0cccaf7e97 100644 --- a/drivers/event/opdl/opdl_evdev.c +++ b/drivers/event/opdl/opdl_evdev.c @@ -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"); diff --git a/drivers/event/skeleton/skeleton_eventdev.c b/drivers/event/skeleton/skeleton_eventdev.c index dc9b131641..7db1efaf14 100644 --- a/drivers/event/skeleton/skeleton_eventdev.c +++ b/drivers/event/skeleton/skeleton_eventdev.c @@ -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 diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c index 6d1816b76d..55e7735cb0 100644 --- a/drivers/event/sw/sw_evdev.c +++ b/drivers/event/sw/sw_evdev.c @@ -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; diff --git a/lib/eventdev/eventdev_pmd_vdev.h b/lib/eventdev/eventdev_pmd_vdev.h index 5fa9d699ac..bb433ba955 100644 --- a/lib/eventdev/eventdev_pmd_vdev.h +++ b/lib/eventdev/eventdev_pmd_vdev.h @@ -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; } -- 2.39.2