From patchwork Tue Jun 28 14:46:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 113521 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 781B5A056B; Tue, 28 Jun 2022 16:47:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 796BE42B77; Tue, 28 Jun 2022 16:47:33 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id B9EC242B77 for ; Tue, 28 Jun 2022 16:47:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656427652; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rhc0/8qLqXVlJzGx8L8kRxEbyN8tbI6zEnyjV5G3BYs=; b=gWA1EIaojIZlV5/G1GqN+qOUI/AW+7oKqJDAtPUGcpmSSAfX21D84oVWRVjhUpQORe/5Cb +m+ELpWV98dcD1I+yRp6qHZvON9QKr6JiEw47H2EUIYwj5kKUqPPsVV5v8RSLa3t413IJk EwN2MVgfoOEzKjIK+ogddZLgUNZCSVw= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-457-5xvNciRFMmab_raPuAoxwQ-1; Tue, 28 Jun 2022 10:47:29 -0400 X-MC-Unique: 5xvNciRFMmab_raPuAoxwQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 42CD31C006DD; Tue, 28 Jun 2022 14:47:24 +0000 (UTC) Received: from fchome.redhat.com (unknown [10.40.194.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B2152166B26; Tue, 28 Jun 2022 14:47:22 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, bruce.richardson@intel.com, kevin.laatz@intel.com, Parav Pandit , Xueming Li , Hemant Agrawal , Sachin Saxena , Stephen Hemminger , Long Li Subject: [RFC PATCH 08/11] drivers/bus: remove back reference to bus objects Date: Tue, 28 Jun 2022 16:46:40 +0200 Message-Id: <20220628144643.1213026-9-david.marchand@redhat.com> In-Reply-To: <20220628144643.1213026-1-david.marchand@redhat.com> References: <20220628144643.1213026-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org There is no need for a back reference to a singleton object in the bus driver objects: each function is contextually aware of which bus object it should manipulate. Signed-off-by: David Marchand --- drivers/bus/auxiliary/auxiliary_common.c | 2 -- drivers/bus/auxiliary/rte_bus_auxiliary.h | 2 -- drivers/bus/dpaa/dpaa_bus.c | 10 +--------- drivers/bus/dpaa/rte_dpaa_bus.h | 1 - drivers/bus/fslmc/fslmc_bus.c | 10 +--------- drivers/bus/fslmc/rte_fslmc.h | 1 - drivers/bus/pci/pci_common.c | 2 -- drivers/bus/pci/rte_bus_pci.h | 1 - drivers/bus/vmbus/rte_bus_vmbus.h | 2 -- drivers/bus/vmbus/vmbus_common.c | 2 -- 10 files changed, 2 insertions(+), 31 deletions(-) diff --git a/drivers/bus/auxiliary/auxiliary_common.c b/drivers/bus/auxiliary/auxiliary_common.c index 2cf8fe672d..0b212f2d64 100644 --- a/drivers/bus/auxiliary/auxiliary_common.c +++ b/drivers/bus/auxiliary/auxiliary_common.c @@ -259,7 +259,6 @@ void rte_auxiliary_register(struct rte_auxiliary_driver *driver) { TAILQ_INSERT_TAIL(&auxiliary_bus.driver_list, driver, next); - driver->bus = &auxiliary_bus; } /* Unregister a driver */ @@ -267,7 +266,6 @@ void rte_auxiliary_unregister(struct rte_auxiliary_driver *driver) { TAILQ_REMOVE(&auxiliary_bus.driver_list, driver, next); - driver->bus = NULL; } /* Add a device to auxiliary bus */ diff --git a/drivers/bus/auxiliary/rte_bus_auxiliary.h b/drivers/bus/auxiliary/rte_bus_auxiliary.h index 93b266daf7..b19696e5e6 100644 --- a/drivers/bus/auxiliary/rte_bus_auxiliary.h +++ b/drivers/bus/auxiliary/rte_bus_auxiliary.h @@ -32,7 +32,6 @@ extern "C" { /* Forward declarations */ struct rte_auxiliary_driver; -struct rte_auxiliary_bus; struct rte_auxiliary_device; /** @@ -125,7 +124,6 @@ struct rte_auxiliary_device { struct rte_auxiliary_driver { RTE_TAILQ_ENTRY(rte_auxiliary_driver) next; /**< Next in list. */ struct rte_driver driver; /**< Inherit core driver. */ - struct rte_auxiliary_bus *bus; /**< Auxiliary bus reference. */ rte_auxiliary_match_t *match; /**< Device match function. */ rte_auxiliary_probe_t *probe; /**< Device probe function. */ rte_auxiliary_remove_t *remove; /**< Device remove function. */ diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c index e442bc4c33..2c286d5817 100644 --- a/drivers/bus/dpaa/dpaa_bus.c +++ b/drivers/bus/dpaa/dpaa_bus.c @@ -520,23 +520,15 @@ rte_dpaa_driver_register(struct rte_dpaa_driver *driver) BUS_INIT_FUNC_TRACE(); TAILQ_INSERT_TAIL(&rte_dpaa_bus.driver_list, driver, next); - /* Update Bus references */ - driver->dpaa_bus = &rte_dpaa_bus; } /* un-register a dpaa bus based dpaa driver */ void rte_dpaa_driver_unregister(struct rte_dpaa_driver *driver) { - struct rte_dpaa_bus *dpaa_bus; - BUS_INIT_FUNC_TRACE(); - dpaa_bus = driver->dpaa_bus; - - TAILQ_REMOVE(&dpaa_bus->driver_list, driver, next); - /* Update Bus references */ - driver->dpaa_bus = NULL; + TAILQ_REMOVE(&rte_dpaa_bus.driver_list, driver, next); } static int diff --git a/drivers/bus/dpaa/rte_dpaa_bus.h b/drivers/bus/dpaa/rte_dpaa_bus.h index 1f04d9ebd3..5e8f32dfbf 100644 --- a/drivers/bus/dpaa/rte_dpaa_bus.h +++ b/drivers/bus/dpaa/rte_dpaa_bus.h @@ -119,7 +119,6 @@ typedef int (*rte_dpaa_remove_t)(struct rte_dpaa_device *dpaa_dev); struct rte_dpaa_driver { TAILQ_ENTRY(rte_dpaa_driver) next; struct rte_driver driver; - struct rte_dpaa_bus *dpaa_bus; enum rte_dpaa_type drv_type; rte_dpaa_probe_t probe; rte_dpaa_remove_t remove; diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c index e9edc27e0a..f112d2afeb 100644 --- a/drivers/bus/fslmc/fslmc_bus.c +++ b/drivers/bus/fslmc/fslmc_bus.c @@ -530,27 +530,19 @@ rte_fslmc_driver_register(struct rte_dpaa2_driver *driver) RTE_VERIFY(driver); TAILQ_INSERT_TAIL(&rte_fslmc_bus.driver_list, driver, next); - /* Update Bus references */ - driver->fslmc_bus = &rte_fslmc_bus; } /*un-register a fslmc bus based dpaa2 driver */ void rte_fslmc_driver_unregister(struct rte_dpaa2_driver *driver) { - struct rte_fslmc_bus *fslmc_bus; - - fslmc_bus = driver->fslmc_bus; - /* Cleanup the PA->VA Translation table; From wherever this function * is called from. */ if (rte_eal_iova_mode() == RTE_IOVA_PA) dpaax_iova_table_depopulate(); - TAILQ_REMOVE(&fslmc_bus->driver_list, driver, next); - /* Update Bus references */ - driver->fslmc_bus = NULL; + TAILQ_REMOVE(&rte_fslmc_bus.driver_list, driver, next); } /* diff --git a/drivers/bus/fslmc/rte_fslmc.h b/drivers/bus/fslmc/rte_fslmc.h index 8c67bfba55..9c3791635c 100644 --- a/drivers/bus/fslmc/rte_fslmc.h +++ b/drivers/bus/fslmc/rte_fslmc.h @@ -146,7 +146,6 @@ typedef int (*rte_dpaa2_remove_t)(struct rte_dpaa2_device *dpaa2_dev); struct rte_dpaa2_driver { TAILQ_ENTRY(rte_dpaa2_driver) next; /**< Next in list. */ struct rte_driver driver; /**< Inherit core driver. */ - struct rte_fslmc_bus *fslmc_bus; /**< FSLMC bus reference */ uint32_t drv_flags; /**< Flags for controlling device.*/ enum rte_dpaa2_dev_type drv_type; /**< Driver Type */ rte_dpaa2_probe_t probe; diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index 37ab879779..0d61d49287 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -443,7 +443,6 @@ void rte_pci_register(struct rte_pci_driver *driver) { TAILQ_INSERT_TAIL(&rte_pci_bus.driver_list, driver, next); - driver->bus = &rte_pci_bus; } /* unregister a driver */ @@ -451,7 +450,6 @@ void rte_pci_unregister(struct rte_pci_driver *driver) { TAILQ_REMOVE(&rte_pci_bus.driver_list, driver, next); - driver->bus = NULL; } /* Add a device to PCI bus */ diff --git a/drivers/bus/pci/rte_bus_pci.h b/drivers/bus/pci/rte_bus_pci.h index 1c6a8fdd7b..1913bc111c 100644 --- a/drivers/bus/pci/rte_bus_pci.h +++ b/drivers/bus/pci/rte_bus_pci.h @@ -161,7 +161,6 @@ typedef int (pci_dma_unmap_t)(struct rte_pci_device *dev, void *addr, struct rte_pci_driver { RTE_TAILQ_ENTRY(rte_pci_driver) next; /**< Next in list. */ struct rte_driver driver; /**< Inherit core driver. */ - struct rte_pci_bus *bus; /**< PCI bus reference. */ rte_pci_probe_t *probe; /**< Device probe function. */ rte_pci_remove_t *remove; /**< Device remove function. */ pci_dma_map_t *dma_map; /**< device dma map function. */ diff --git a/drivers/bus/vmbus/rte_bus_vmbus.h b/drivers/bus/vmbus/rte_bus_vmbus.h index 4421326fe8..8d6ba26028 100644 --- a/drivers/bus/vmbus/rte_bus_vmbus.h +++ b/drivers/bus/vmbus/rte_bus_vmbus.h @@ -34,7 +34,6 @@ extern "C" { /* Forward declarations */ struct rte_vmbus_device; struct rte_vmbus_driver; -struct rte_vmbus_bus; struct vmbus_channel; struct vmbus_mon_page; @@ -95,7 +94,6 @@ typedef int (vmbus_remove_t)(struct rte_vmbus_device *); struct rte_vmbus_driver { RTE_TAILQ_ENTRY(rte_vmbus_driver) next; /**< Next in list. */ struct rte_driver driver; - struct rte_vmbus_bus *bus; /**< VM bus reference. */ vmbus_probe_t *probe; /**< Device Probe function. */ vmbus_remove_t *remove; /**< Device Remove function. */ diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c index 367727367e..0f2d878126 100644 --- a/drivers/bus/vmbus/vmbus_common.c +++ b/drivers/bus/vmbus/vmbus_common.c @@ -235,7 +235,6 @@ rte_vmbus_register(struct rte_vmbus_driver *driver) "Registered driver %s", driver->driver.name); TAILQ_INSERT_TAIL(&rte_vmbus_bus.driver_list, driver, next); - driver->bus = &rte_vmbus_bus; } /* unregister vmbus driver */ @@ -243,7 +242,6 @@ void rte_vmbus_unregister(struct rte_vmbus_driver *driver) { TAILQ_REMOVE(&rte_vmbus_bus.driver_list, driver, next); - driver->bus = NULL; } /* Add a device to VMBUS bus */