From: Dipayaan Roy <[email protected]>

Remove the early return after mana_dealloc_queues() so detach continues
its device and port-context cleanup.

The return is currently unreachable: mana_dealloc_queues() only rejects
an up port, and mana_detach() clears port_is_up before calling it. This
is a robustness cleanup, not a fix for a reachable reset failure.

Make mana_detach() return void and remove the now-unreachable
error branches from reset and removal callers. Keep ndo_stop's
required integer return and the internal deallocation error log.

Signed-off-by: Dipayaan Roy <[email protected]>
Signed-off-by: Long Li <[email protected]>
Signed-off-by: Wei Hu <[email protected]>
---
 drivers/net/ethernet/microsoft/mana/mana_en.c | 27 ++++++-------------
 include/net/mana/mana.h                       |  2 +-
 2 files changed, 9 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c 
b/drivers/net/ethernet/microsoft/mana/mana_en.c
index 9e952843de14..80f16c96f16c 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -114,7 +114,9 @@ static int mana_close(struct net_device *ndev)
        if (!apc->port_is_up)
                return 0;
 
-       return mana_detach(ndev, true);
+       mana_detach(ndev, true);
+
+       return 0;
 }
 
 static void mana_link_state_handle(struct work_struct *w)
@@ -345,17 +347,12 @@ static void mana_per_port_queue_reset_work_handler(struct 
work_struct *work)
                goto clear_flag;
        }
 
-       err = mana_detach(ndev, false);
-       if (err) {
-               netdev_err(ndev, "mana_detach failed: %d\n", err);
-               goto dealloc_pre_rxbufs;
-       }
+       mana_detach(ndev, false);
 
        err = mana_attach(ndev);
        if (err)
                netdev_err(ndev, "mana_attach failed: %d\n", err);
 
-dealloc_pre_rxbufs:
        mana_pre_dealloc_rxbufs(apc);
 clear_flag:
        mutex_lock(&apc->vport_mutex);
@@ -4542,7 +4539,7 @@ void mana_free_qset(struct mana_port_context *scratch, 
struct mana_qset *qset)
        mana_qset_debugfs_publish(apc);
 }
 
-int mana_detach(struct net_device *ndev, bool from_close)
+void mana_detach(struct net_device *ndev, bool from_close)
 {
        struct mana_port_context *apc = netdev_priv(ndev);
        int err;
@@ -4553,7 +4550,7 @@ int mana_detach(struct net_device *ndev, bool from_close)
         * previously). Now skip mana detach and just retry mana_attach.
         */
        if (!from_close && !netif_device_present(ndev))
-               return 0;
+               return;
 
        apc->port_st_save = apc->port_is_up;
        apc->port_is_up = false;
@@ -4565,18 +4562,14 @@ int mana_detach(struct net_device *ndev, bool 
from_close)
 
        if (apc->port_st_save) {
                err = mana_dealloc_queues(ndev);
-               if (err) {
+               if (err)
                        netdev_err(ndev, "%s failed to deallocate queues: 
%d\n", __func__, err);
-                       return err;
-               }
        }
 
        if (!from_close) {
                netif_device_detach(ndev);
                mana_cleanup_port_context(apc);
        }
-
-       return 0;
 }
 
 static int mana_probe_port(struct mana_context *ac, int port_idx,
@@ -4988,7 +4981,6 @@ void mana_remove(struct gdma_dev *gd, bool suspending)
        struct mana_port_context *apc;
        struct device *dev;
        struct net_device *ndev;
-       int err;
        int i;
 
        if (!gc || !ac)
@@ -5019,10 +5011,7 @@ void mana_remove(struct gdma_dev *gd, bool suspending)
                 */
                rtnl_lock();
 
-               err = mana_detach(ndev, false);
-               if (err)
-                       netdev_err(ndev, "Failed to detach vPort %d: %d\n",
-                                  i, err);
+               mana_detach(ndev, false);
 
                if (suspending) {
                        /* No need to unregister the ndev. */
diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h
index e64aa6ae7a4d..fcb66029e51c 100644
--- a/include/net/mana/mana.h
+++ b/include/net/mana/mana.h
@@ -729,7 +729,7 @@ int mana_disable_vport_rx(struct mana_port_context *apc);
 
 int mana_alloc_queues(struct net_device *ndev);
 int mana_attach(struct net_device *ndev);
-int mana_detach(struct net_device *ndev, bool from_close);
+void mana_detach(struct net_device *ndev, bool from_close);
 
 struct mana_port_context *
 mana_qset_scratch_alloc(struct mana_port_context *apc);
-- 
2.43.0


Reply via email to