iflib: Detach tasks upon device registration failure
In some error paths we would fail to detach from the iflib taskqueue groups. Also move the detach code into its own subroutine instead of duplicating it. Submitted by: Sai Rajesh Tallamraju <stallamr@netapp.com> MFC after: 2 weeks Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D27342
This commit is contained in:
parent
5b641fe78b
commit
5e0d2eed99
@ -142,6 +142,7 @@ struct iflib_ctx;
|
||||
|
||||
static void iru_init(if_rxd_update_t iru, iflib_rxq_t rxq, uint8_t flid);
|
||||
static void iflib_timer(void *arg);
|
||||
static void iflib_tqg_detach(if_ctx_t ctx);
|
||||
|
||||
typedef struct iflib_filter_info {
|
||||
driver_filter_t *ifi_filter;
|
||||
@ -4842,7 +4843,7 @@ iflib_device_register(device_t dev, void *sc, if_shared_ctx_t sctx, if_ctx_t *ct
|
||||
fail_queues:
|
||||
iflib_tx_structures_free(ctx);
|
||||
iflib_rx_structures_free(ctx);
|
||||
taskqgroup_detach(qgroup_if_config_tqg, &ctx->ifc_admin_task);
|
||||
iflib_tqg_detach(ctx);
|
||||
IFDI_DETACH(ctx);
|
||||
fail_unlock:
|
||||
CTX_UNLOCK(ctx);
|
||||
@ -5042,6 +5043,7 @@ iflib_pseudo_register(device_t dev, if_shared_ctx_t sctx, if_ctx_t *ctxp,
|
||||
fail_queues:
|
||||
iflib_tx_structures_free(ctx);
|
||||
iflib_rx_structures_free(ctx);
|
||||
iflib_tqg_detach(ctx);
|
||||
fail_iflib_detach:
|
||||
IFDI_DETACH(ctx);
|
||||
fail_unlock:
|
||||
@ -5058,11 +5060,6 @@ iflib_pseudo_deregister(if_ctx_t ctx)
|
||||
{
|
||||
if_t ifp = ctx->ifc_ifp;
|
||||
if_shared_ctx_t sctx = ctx->ifc_sctx;
|
||||
iflib_txq_t txq;
|
||||
iflib_rxq_t rxq;
|
||||
int i, j;
|
||||
struct taskqgroup *tqg;
|
||||
iflib_fl_t fl;
|
||||
|
||||
/* Unregister VLAN event handlers early */
|
||||
iflib_unregister_vlan_handlers(ctx);
|
||||
@ -5074,30 +5071,8 @@ iflib_pseudo_deregister(if_ctx_t ctx)
|
||||
} else {
|
||||
ether_ifdetach(ifp);
|
||||
}
|
||||
/* XXX drain any dependent tasks */
|
||||
tqg = qgroup_if_io_tqg;
|
||||
for (txq = ctx->ifc_txqs, i = 0; i < NTXQSETS(ctx); i++, txq++) {
|
||||
callout_drain(&txq->ift_timer);
|
||||
#ifdef DEV_NETMAP
|
||||
callout_drain(&txq->ift_netmap_timer);
|
||||
#endif /* DEV_NETMAP */
|
||||
if (txq->ift_task.gt_uniq != NULL)
|
||||
taskqgroup_detach(tqg, &txq->ift_task);
|
||||
}
|
||||
for (i = 0, rxq = ctx->ifc_rxqs; i < NRXQSETS(ctx); i++, rxq++) {
|
||||
callout_drain(&rxq->ifr_watchdog);
|
||||
if (rxq->ifr_task.gt_uniq != NULL)
|
||||
taskqgroup_detach(tqg, &rxq->ifr_task);
|
||||
|
||||
for (j = 0, fl = rxq->ifr_fl; j < rxq->ifr_nfl; j++, fl++)
|
||||
free(fl->ifl_rx_bitmap, M_IFLIB);
|
||||
}
|
||||
tqg = qgroup_if_config_tqg;
|
||||
if (ctx->ifc_admin_task.gt_uniq != NULL)
|
||||
taskqgroup_detach(tqg, &ctx->ifc_admin_task);
|
||||
if (ctx->ifc_vflr_task.gt_uniq != NULL)
|
||||
taskqgroup_detach(tqg, &ctx->ifc_vflr_task);
|
||||
|
||||
iflib_tqg_detach(ctx);
|
||||
iflib_tx_structures_free(ctx);
|
||||
iflib_rx_structures_free(ctx);
|
||||
|
||||
@ -5127,12 +5102,7 @@ int
|
||||
iflib_device_deregister(if_ctx_t ctx)
|
||||
{
|
||||
if_t ifp = ctx->ifc_ifp;
|
||||
iflib_txq_t txq;
|
||||
iflib_rxq_t rxq;
|
||||
device_t dev = ctx->ifc_dev;
|
||||
int i, j;
|
||||
struct taskqgroup *tqg;
|
||||
iflib_fl_t fl;
|
||||
|
||||
/* Make sure VLANS are not using driver */
|
||||
if (if_vlantrunkinuse(ifp)) {
|
||||
@ -5163,28 +5133,8 @@ iflib_device_deregister(if_ctx_t ctx)
|
||||
iflib_rem_pfil(ctx);
|
||||
if (ctx->ifc_led_dev != NULL)
|
||||
led_destroy(ctx->ifc_led_dev);
|
||||
/* XXX drain any dependent tasks */
|
||||
tqg = qgroup_if_io_tqg;
|
||||
for (txq = ctx->ifc_txqs, i = 0; i < NTXQSETS(ctx); i++, txq++) {
|
||||
callout_drain(&txq->ift_timer);
|
||||
#ifdef DEV_NETMAP
|
||||
callout_drain(&txq->ift_netmap_timer);
|
||||
#endif /* DEV_NETMAP */
|
||||
if (txq->ift_task.gt_uniq != NULL)
|
||||
taskqgroup_detach(tqg, &txq->ift_task);
|
||||
}
|
||||
for (i = 0, rxq = ctx->ifc_rxqs; i < NRXQSETS(ctx); i++, rxq++) {
|
||||
if (rxq->ifr_task.gt_uniq != NULL)
|
||||
taskqgroup_detach(tqg, &rxq->ifr_task);
|
||||
|
||||
for (j = 0, fl = rxq->ifr_fl; j < rxq->ifr_nfl; j++, fl++)
|
||||
free(fl->ifl_rx_bitmap, M_IFLIB);
|
||||
}
|
||||
tqg = qgroup_if_config_tqg;
|
||||
if (ctx->ifc_admin_task.gt_uniq != NULL)
|
||||
taskqgroup_detach(tqg, &ctx->ifc_admin_task);
|
||||
if (ctx->ifc_vflr_task.gt_uniq != NULL)
|
||||
taskqgroup_detach(tqg, &ctx->ifc_vflr_task);
|
||||
iflib_tqg_detach(ctx);
|
||||
CTX_LOCK(ctx);
|
||||
IFDI_DETACH(ctx);
|
||||
CTX_UNLOCK(ctx);
|
||||
@ -5207,6 +5157,35 @@ iflib_device_deregister(if_ctx_t ctx)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
iflib_tqg_detach(if_ctx_t ctx)
|
||||
{
|
||||
iflib_txq_t txq;
|
||||
iflib_rxq_t rxq;
|
||||
int i;
|
||||
struct taskqgroup *tqg;
|
||||
|
||||
/* XXX drain any dependent tasks */
|
||||
tqg = qgroup_if_io_tqg;
|
||||
for (txq = ctx->ifc_txqs, i = 0; i < NTXQSETS(ctx); i++, txq++) {
|
||||
callout_drain(&txq->ift_timer);
|
||||
#ifdef DEV_NETMAP
|
||||
callout_drain(&txq->ift_netmap_timer);
|
||||
#endif /* DEV_NETMAP */
|
||||
if (txq->ift_task.gt_uniq != NULL)
|
||||
taskqgroup_detach(tqg, &txq->ift_task);
|
||||
}
|
||||
for (i = 0, rxq = ctx->ifc_rxqs; i < NRXQSETS(ctx); i++, rxq++) {
|
||||
if (rxq->ifr_task.gt_uniq != NULL)
|
||||
taskqgroup_detach(tqg, &rxq->ifr_task);
|
||||
}
|
||||
tqg = qgroup_if_config_tqg;
|
||||
if (ctx->ifc_admin_task.gt_uniq != NULL)
|
||||
taskqgroup_detach(tqg, &ctx->ifc_admin_task);
|
||||
if (ctx->ifc_vflr_task.gt_uniq != NULL)
|
||||
taskqgroup_detach(tqg, &ctx->ifc_vflr_task);
|
||||
}
|
||||
|
||||
static void
|
||||
iflib_free_intr_mem(if_ctx_t ctx)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user