From 303990f99f84220044d666da814857dc593af624 Mon Sep 17 00:00:00 2001 From: Marian-Cristian Rotariu Date: Wed, 6 May 2015 11:23:18 +0300 Subject: dpaa_eth: fix unload procedure for onic This patch fixes the module unload for onic in the context of creating the DPAA Ethernet drivers as dynamic kernel modules that can be loaded/unloaded at runtime. Change-Id: Ib813d4c99869a09875a3dc9d07f6fcb9b5bb65e2 Signed-off-by: Marian-Cristian Rotariu Reviewed-on: http://git.am.freescale.net:8181/35781 Reviewed-by: Madalin-Cristian Bucur diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth_generic.c b/drivers/net/ethernet/freescale/dpa/dpaa_eth_generic.c index 970e7c8..5bb4af0 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth_generic.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth_generic.c @@ -1347,6 +1347,46 @@ static int dpa_generic_bp_create(struct net_device *net_dev, return 0; } +static void dpa_generic_bp_free(struct dpa_generic_priv_s *priv) +{ + struct dpa_bp *bp = NULL; + int i = 0; + + /* release the rx bpools */ + for (i = 0; i < priv->rx_bp_count; i++) { + bp = &priv->rx_bp[i]; + if (!bp) + continue; + + if (!atomic_dec_and_test(&bp->refs)) + continue; + + if (bp->free_buf_cb) + dpa_bp_drain(bp); + + bman_free_pool(bp->pool); + + if (bp->dev) + platform_device_unregister(to_platform_device(bp->dev)); + } + + /* release the tx draining bpool */ + bp = priv->draining_tx_bp; + if (!bp) + return; + + if (!atomic_dec_and_test(&bp->refs)) + return; + + if (bp->free_buf_cb) + dpa_bp_drain(bp); + + bman_free_pool(bp->pool); + + if (bp->dev) + platform_device_unregister(to_platform_device(bp->dev)); +} + static int dpa_generic_remove(struct platform_device *of_dev) { int err; @@ -1363,22 +1403,11 @@ static int dpa_generic_remove(struct platform_device *of_dev) dev_set_drvdata(dev, NULL); unregister_netdev(net_dev); - /* TODO: this is for private driver; make it generic */ - err = 0; -#if 0 err = dpa_fq_free(dev, &priv->dpa_fq_list); -#endif - dpa_private_napi_del(net_dev); + dpa_generic_napi_del(net_dev); - /* TODO: this is for private dirver also; make generic */ -#if 0 - dpa_bp_free(priv); - devm_kfree(dev, priv->dpa_bp); - - if (priv->buf_layout) - devm_kfree(dev, priv->buf_layout); -#endif + dpa_generic_bp_free(priv); #ifdef CONFIG_FSL_DPAA_ETH_DEBUGFS dpa_generic_debugfs_remove(net_dev); -- cgit v0.10.2