There are two initialize statements of control BAR in 'nfp_net_init()'
and the first one is unneeded, and what it really use is the check of
NULL value of the 'mem_resource'. So we move the check of 'mem_resource'
to the start of probe logic.

Signed-off-by: Chaoyong He <[email protected]>
Reviewed-by: Peng Zhang <[email protected]>
---
 drivers/net/nfp/nfp_ethdev.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 7c5b780e82..8057452799 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -503,12 +503,6 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 
        rte_eth_copy_pci_info(eth_dev, pci_dev);
 
-       hw->ctrl_bar = pci_dev->mem_resource[0].addr;
-       if (hw->ctrl_bar == NULL) {
-               PMD_DRV_LOG(ERR, "hw->ctrl_bar is NULL. BAR0 not configured");
-               return -ENODEV;
-       }
-
        if (port == 0) {
                uint32_t min_size;
 
@@ -890,6 +884,11 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
        if (pci_dev == NULL)
                return -ENODEV;
 
+       if (pci_dev->mem_resource[0].addr == NULL) {
+               PMD_INIT_LOG(ERR, "The address of BAR0 is NULL.");
+               return -ENODEV;
+       }
+
        dev_info = nfp_dev_info_get(pci_dev->id.device_id);
        if (dev_info == NULL) {
                PMD_INIT_LOG(ERR, "Not supported device ID");
@@ -1089,6 +1088,11 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev)
        if (pci_dev == NULL)
                return -ENODEV;
 
+       if (pci_dev->mem_resource[0].addr == NULL) {
+               PMD_INIT_LOG(ERR, "The address of BAR0 is NULL.");
+               return -ENODEV;
+       }
+
        dev_info = nfp_dev_info_get(pci_dev->id.device_id);
        if (dev_info == NULL) {
                PMD_INIT_LOG(ERR, "Not supported device ID");
-- 
2.39.1

Reply via email to