Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932400AbcLBXG5 (ORCPT ); Fri, 2 Dec 2016 18:06:57 -0500 Received: from mout.gmx.net ([212.227.15.18]:59182 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756631AbcLBXG3 (ORCPT ); Fri, 2 Dec 2016 18:06:29 -0500 From: Lino Sanfilippo To: bh74.an@samsung.com, ks.giri@samsung.com, vipul.pandya@samsung.com, peppe.cavallaro@st.com, alexandre.torgue@st.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Lino Sanfilippo Subject: [PATCH 2/2] net: ethernet: stmmac: do not use xmit_lock in tx completion handler Date: Sat, 3 Dec 2016 00:06:06 +0100 Message-Id: <1480719966-12839-3-git-send-email-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1480719966-12839-1-git-send-email-LinoSanfilippo@gmx.de> References: <1480719966-12839-1-git-send-email-LinoSanfilippo@gmx.de> X-Provags-ID: V03:K0:897iQE8487CcQuIbYIMT7zAAjrcbeetnFmcRik/IMImKCYHqpuR B2D7fHBUeUXX+jquqQtg0Cd51vvyFlu64fL2xN40GWCeaRe4KFLmExeJbKLoYCB+4Y1MFlS jEIdfuvSYRiHibnQP6S3Y3AmWXPPhDeTuwP5WI3AT72T6bwRghmuBJ5cUa7MUELn7Yf4YQe z6g0Kra0Q7ARBvnSuCr1g== X-UI-Out-Filterresults: notjunk:1;V01:K0:iiwtNquxsbk=:r28hsj4JkSfXlGCMMz8T3r xNhgR8HF1WpjVhfBW6j77QInT9JicuindeYXV8dA5wseS4mB6tYXYE5sfwcQTI0/IO1dWdytw e1tgbqL2Xmq/q1Rtj3sck1nlhr8PEym+WtAb5TtN9Pon6Xsgj5KgIDAmm0Ps3y/aECfhyMuNZ xXEmqiY4jndkZc55LxwnAQIP9vcnP0bZm4XKmppl7kEiwzgmj+TRi3/ldvqeOvVYubfVCMXcd vKWVBfLyXuHRAAoLa4xP1y50jo1Si9F5ZZGl4An19d4tRXYUXdvKHuWIw66jXblfsnYPw73/D h0XY7OyNevN0JTfJh3t5vSGFywnjrIiY7ARQua8NtKcZyjhGrwFDhw3t3iL0iza/Ptn7i+o+s lDXRuXOQKrfL6ewcpBiMwz8TUjssVCW5AssosMRc4WL0vNywu7By3WGl1MsUp2D4HsqfmDrvM zPO4ZOFmGD+Kkne6tVdOBLdEh1CQsD+hyVhvxCA14xB0xLxFRdFwHk0nK0y4j811/VsJog7K+ iWJ9u5VKTZLlS/evq7aZajTfYzORCdLY53wY0uUB13iGGyuv0pVyms6fVrJjCJBLN9RejOIpG XHnpLcTEX5prWo11DIAwmVbiviPnbXq4wd1/CN1Y2cUlCv84Rs9A6SDOErwDIkQPDTqw1EMXV nYzPIBya7FfXbQHq3kaZ6M7liTgqtNU8/e+yV8jlIcO9EAIj/gDGxebrGwHgFV4vH9Iitzvyk BablPcyB8kNovE8mAaoKpqiJgxunlJSwHzDvdexQQugw6ZCGCrbFybtU2xM= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1784 Lines: 44 The driver already uses its private lock for synchronization between the xmit function and the xmit completion handler, making the additional use of the xmit_lock unnecessary. Furthermore the driver does not set NETIF_F_LLTX resulting in xmit to be called with the xmit_lock held and then taking the private lock. On the other hand the xmit completion handler uses the reverse locking order, by first taking the private lock, and then the xmit_lock, which leads to the potential danger of a deadlock. Fix this issue by not taking the xmit_lock in the completion handler. By doing this also remove an unnecessary double check for a stopped tx queue. Signed-off-by: Lino Sanfilippo --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) Please note that this patch is only compile tested. diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 48a4e84..8def423 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1380,14 +1380,9 @@ static void stmmac_tx_clean(struct stmmac_priv *priv) if (unlikely(netif_queue_stopped(priv->dev) && stmmac_tx_avail(priv) > STMMAC_TX_THRESH)) { - netif_tx_lock(priv->dev); - if (netif_queue_stopped(priv->dev) && - stmmac_tx_avail(priv) > STMMAC_TX_THRESH) { - netif_dbg(priv, tx_done, priv->dev, - "%s: restart transmit\n", __func__); - netif_wake_queue(priv->dev); - } - netif_tx_unlock(priv->dev); + netif_dbg(priv, tx_done, priv->dev, + "%s: restart transmit\n", __func__); + netif_wake_queue(priv->dev); } if ((priv->eee_enabled) && (!priv->tx_path_in_lpi_mode)) { -- 1.9.1