From patchwork Fri Mar 24 17:16:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Pinto X-Patchwork-Id: 743292 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vqVTQ5NQnz9s7N for ; Sat, 25 Mar 2017 04:16:58 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966907AbdCXRQ6 (ORCPT ); Fri, 24 Mar 2017 13:16:58 -0400 Received: from us01smtprelay-2.synopsys.com ([198.182.47.9]:48762 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965669AbdCXRQy (ORCPT ); Fri, 24 Mar 2017 13:16:54 -0400 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 8A7DD24E1364; Fri, 24 Mar 2017 10:16:53 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 390BDBAD; Fri, 24 Mar 2017 10:16:53 -0700 (PDT) Received: from jpinto-box.internal.synopsys.com (jpinto-box.internal.synopsys.com [10.107.19.150]) by mailhost.synopsys.com (Postfix) with ESMTP id 04433B97; Fri, 24 Mar 2017 10:16:50 -0700 (PDT) From: Joao Pinto To: davem@davemloft.net Cc: peppe.cavallaro@st.com, alexandre.torgue@st.com, clabbe.montjoie@gmail.com, thierry.reding@gmail.com, sergei.shtylyov@cogentembedded.com, f.fainelli@gmail.com, niklas.cassel@axis.com, netdev@vger.kernel.org, Joao Pinto Subject: [PATCH net-next 1/2] net: stmmac: fix netdev release Date: Fri, 24 Mar 2017 17:16:44 +0000 Message-Id: X-Mailer: git-send-email 2.9.3 In-Reply-To: References: In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch fixes the kernel crash problem that happens when the driver exits. The dma resouces must be freed after netdev resouces get freed and in driver removed, multiple napi's should be deleted before removing netdev resouces or it will hang. Signed-off-by: Joao Pinto --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 4b418d2..3827952 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -2659,9 +2659,6 @@ static int stmmac_release(struct net_device *dev) /* Stop TX/RX DMA and clear the descriptors */ stmmac_stop_all_dma(priv); - /* Release and free the Rx/Tx resources */ - free_dma_desc_resources(priv); - /* Disable the MAC Rx/Tx */ stmmac_set_mac(priv->ioaddr, false); @@ -4080,7 +4077,7 @@ int stmmac_dvr_probe(struct device *device, /* Init MAC and get the capabilities */ ret = stmmac_hw_init(priv); if (ret) - goto error_hw_init; + return ret; /* Configure real RX and TX queues */ ndev->real_num_rx_queues = priv->plat->rx_queues_to_use; @@ -4207,9 +4204,8 @@ int stmmac_dvr_probe(struct device *device, netif_napi_del(&rx_q->napi); } init_dma_error: - free_dma_desc_resources(priv); -error_hw_init: free_netdev(ndev); + free_dma_desc_resources(priv); return ret; } @@ -4225,6 +4221,7 @@ int stmmac_dvr_remove(struct device *dev) { struct net_device *ndev = dev_get_drvdata(dev); struct stmmac_priv *priv = netdev_priv(ndev); + u32 queue = 0; netdev_info(priv->dev, "%s: removing driver", __func__); @@ -4241,7 +4238,15 @@ int stmmac_dvr_remove(struct device *dev) priv->hw->pcs != STMMAC_PCS_TBI && priv->hw->pcs != STMMAC_PCS_RTBI) stmmac_mdio_unregister(ndev); + + for (queue = 0; queue < priv->plat->rx_queues_to_use; queue++) { + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + + netif_napi_del(&rx_q->napi); + } + free_netdev(ndev); + free_dma_desc_resources(priv); return 0; }