git: 438e078d3166 - stable/13 - ice(4): Stop checking for failures from malloc(M_WAITOK)

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Mon, 30 Sep 2024 05:08:29 UTC
The branch stable/13 has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=438e078d3166feafa4e7887471faa1da3e70a74a

commit 438e078d3166feafa4e7887471faa1da3e70a74a
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2024-09-03 10:25:29 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2024-09-30 05:05:37 +0000

    ice(4): Stop checking for failures from malloc(M_WAITOK)
    
    As a consequence now ice_alloc_vsi_qmap() does not fail. Remove unneeded
    error checks.
    
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D45852
    
    (cherry picked from commit 5f97656fa334b494d70866cb1bfff406d3efd92d)
    (cherry picked from commit bb8c6f43256d234d492c267d74526fc62102b23d)
---
 sys/dev/ice/ice_lib.c      | 24 +++---------------------
 sys/dev/ice/ice_lib.h      |  2 +-
 sys/dev/ice/if_ice_iflib.c | 13 ++-----------
 3 files changed, 6 insertions(+), 33 deletions(-)

diff --git a/sys/dev/ice/ice_lib.c b/sys/dev/ice/ice_lib.c
index 0fb1ba0158f1..0f9efc3ec6cf 100644
--- a/sys/dev/ice/ice_lib.c
+++ b/sys/dev/ice/ice_lib.c
@@ -426,31 +426,21 @@ ice_setup_pf_vsi(struct ice_softc *sc)
  * all queues for this VSI are not yet assigned an index and thus,
  * not ready for use.
  *
- * Returns an error code on failure.
  */
-int
+void
 ice_alloc_vsi_qmap(struct ice_vsi *vsi, const int max_tx_queues,
 		   const int max_rx_queues)
 {
-	struct ice_softc *sc = vsi->sc;
 	int i;
 
 	MPASS(max_tx_queues > 0);
 	MPASS(max_rx_queues > 0);
 
 	/* Allocate Tx queue mapping memory */
-	if (!(vsi->tx_qmap =
-	      (u16 *) malloc(sizeof(u16) * max_tx_queues, M_ICE, M_WAITOK))) {
-		device_printf(sc->dev, "Unable to allocate Tx qmap memory\n");
-		return (ENOMEM);
-	}
+	vsi->tx_qmap = malloc(sizeof(u16) * max_tx_queues, M_ICE, M_WAITOK);
 
 	/* Allocate Rx queue mapping memory */
-	if (!(vsi->rx_qmap =
-	      (u16 *) malloc(sizeof(u16) * max_rx_queues, M_ICE, M_WAITOK))) {
-		device_printf(sc->dev, "Unable to allocate Rx qmap memory\n");
-		goto free_tx_qmap;
-	}
+	vsi->rx_qmap = malloc(sizeof(u16) * max_rx_queues, M_ICE, M_WAITOK);
 
 	/* Mark every queue map as invalid to start with */
 	for (i = 0; i < max_tx_queues; i++) {
@@ -459,14 +449,6 @@ ice_alloc_vsi_qmap(struct ice_vsi *vsi, const int max_tx_queues,
 	for (i = 0; i < max_rx_queues; i++) {
 		vsi->rx_qmap[i] = ICE_INVALID_RES_IDX;
 	}
-
-	return 0;
-
-free_tx_qmap:
-	free(vsi->tx_qmap, M_ICE);
-	vsi->tx_qmap = NULL;
-
-	return (ENOMEM);
 }
 
 /**
diff --git a/sys/dev/ice/ice_lib.h b/sys/dev/ice/ice_lib.h
index cfd848d370bb..6c010cffc0fd 100644
--- a/sys/dev/ice/ice_lib.h
+++ b/sys/dev/ice/ice_lib.h
@@ -830,7 +830,7 @@ void ice_free_bar(device_t dev, struct ice_bar_info *bar);
 void ice_set_ctrlq_len(struct ice_hw *hw);
 void ice_release_vsi(struct ice_vsi *vsi);
 struct ice_vsi *ice_alloc_vsi(struct ice_softc *sc, enum ice_vsi_type type);
-int  ice_alloc_vsi_qmap(struct ice_vsi *vsi, const int max_tx_queues,
+void ice_alloc_vsi_qmap(struct ice_vsi *vsi, const int max_tx_queues,
 		       const int max_rx_queues);
 void ice_free_vsi_qmaps(struct ice_vsi *vsi);
 int  ice_initialize_vsi(struct ice_vsi *vsi);
diff --git a/sys/dev/ice/if_ice_iflib.c b/sys/dev/ice/if_ice_iflib.c
index 05574efe62ce..455da99ea8d2 100644
--- a/sys/dev/ice/if_ice_iflib.c
+++ b/sys/dev/ice/if_ice_iflib.c
@@ -638,12 +638,8 @@ reinit_hw:
 	 */
 	ice_setup_pf_vsi(sc);
 
-	err = ice_alloc_vsi_qmap(&sc->pf_vsi, scctx->isc_ntxqsets_max,
+	ice_alloc_vsi_qmap(&sc->pf_vsi, scctx->isc_ntxqsets_max,
 	    scctx->isc_nrxqsets_max);
-	if (err) {
-		device_printf(dev, "Unable to allocate VSI Queue maps\n");
-		goto free_main_vsi;
-	}
 
 	/* Allocate MSI-X vectors (due to isc_flags IFLIB_SKIP_MSIX) */
 	err = ice_allocate_msix(sc);
@@ -3525,12 +3521,7 @@ ice_setup_mirror_vsi(struct ice_mirr_if *mif)
 	mif->vsi = vsi;
 
 	/* Reserve VSI queue allocation from PF queues */
-	ret = ice_alloc_vsi_qmap(vsi, ICE_DEFAULT_VF_QUEUES, ICE_DEFAULT_VF_QUEUES);
-	if (ret) {
-		device_printf(dev, "%s: Unable to allocate mirror VSI queue maps (%d queues): %s\n",
-		    __func__, ICE_DEFAULT_VF_QUEUES, ice_err_str(ret));
-		goto release_vsi;
-	}
+	ice_alloc_vsi_qmap(vsi, ICE_DEFAULT_VF_QUEUES, ICE_DEFAULT_VF_QUEUES);
 	vsi->num_tx_queues = vsi->num_rx_queues = ICE_DEFAULT_VF_QUEUES;
 
 	/* Assign Tx queues from PF space */