From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Roese Date: Thu, 23 Mar 2017 17:01:59 +0100 Subject: [U-Boot] [PATCH v2 33/45] net: mvpp2: Add remove function that is called before the OS is started In-Reply-To: <20170323160211.18072-1-sr@denx.de> References: <20170323160211.18072-1-sr@denx.de> Message-ID: <20170323160211.18072-34-sr@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de This patch adds a remove function to the mvpp2 ethernet driver which is called before the OS is started, doing: - Allocate the used buffers back from the buffer manager - Stop the BM activity Signed-off-by: Stefan Roese Cc: Stefan Chulski Cc: Kostya Porotchkin Cc: Nadav Haklai Acked-by: Joe Hershberger --- Changes in v2: - Added Acked-by from Joe drivers/net/mvpp2.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c index 2328c25850..e13a679e33 100644 --- a/drivers/net/mvpp2.c +++ b/drivers/net/mvpp2.c @@ -2454,6 +2454,13 @@ static void mvpp2_bm_pool_bufsize_set(struct mvpp2 *priv, static void mvpp2_bm_bufs_free(struct udevice *dev, struct mvpp2 *priv, struct mvpp2_bm_pool *bm_pool) { + int i; + + for (i = 0; i < bm_pool->buf_num; i++) { + /* Allocate buffer back from the buffer manager */ + mvpp2_read(priv, MVPP2_BM_PHY_ALLOC_REG(bm_pool->id)); + } + bm_pool->buf_num = 0; } @@ -4495,6 +4502,21 @@ static int mvpp2_probe(struct udevice *dev) return mvpp2_port_probe(dev, port, dev_of_offset(dev), priv); } +/* + * Empty BM pool and stop its activity before the OS is started + */ +static int mvpp2_remove(struct udevice *dev) +{ + struct mvpp2_port *port = dev_get_priv(dev); + struct mvpp2 *priv = port->priv; + int i; + + for (i = 0; i < MVPP2_BM_POOLS_NUM; i++) + mvpp2_bm_pool_destroy(dev, priv, &priv->bm_pools[i]); + + return 0; +} + static const struct eth_ops mvpp2_ops = { .start = mvpp2_start, .send = mvpp2_send, @@ -4506,9 +4528,11 @@ static struct driver mvpp2_driver = { .name = "mvpp2", .id = UCLASS_ETH, .probe = mvpp2_probe, + .remove = mvpp2_remove, .ops = &mvpp2_ops, .priv_auto_alloc_size = sizeof(struct mvpp2_port), .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .flags = DM_FLAG_ACTIVE_DMA, }; /* -- 2.12.1