Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757630AbcLBXGe (ORCPT ); Fri, 2 Dec 2016 18:06:34 -0500 Received: from mout.gmx.net ([212.227.15.18]:59430 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756435AbcLBXGc (ORCPT ); Fri, 2 Dec 2016 18:06:32 -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 1/2] net: ethernet: sxgbe: do not use xmit_lock in tx completion handler Date: Sat, 3 Dec 2016 00:06:05 +0100 Message-Id: <1480719966-12839-2-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:SsyHizljwv7vEc+zb3JhGCmBSCVqmCjxSo4+rlTAHcUu98zIGxn IJIxXi6N8+85Q0Ipsm7baFrh+HY9G8nHB5EFOSNflUH6kLrkwbWnayIZ1tT51ugtbSNBbw+ 7cS6KrlSGxzHkUoeLhGxZjrcv9s2Q6a4UvhhNw1e26Id/xPX8i6YzD7s2Sr9BQ4qZwrorfr YDbxEZ1PL3gblCTIwKc9Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:JkzYPP6IBQs=:GueUMGd46veU93Qd0Prc7O TBJ33vXyFIo0RAa9iZqMuIQES3EOT22IklrWRtnhHn37yjH4mKuD/XQP1pl4Nr1ZXasECgHir om9e4unN76/JQCgynlzbGHa6ygN6x7/f23rIRZQZmNgfQqr7A3ud9jgRK+aCSN9zK3886vori l+/SgnPiXtTZqrka0DZ+X9GMXRC/1eLlFu7NjFzt+75p2lxQZ8kW9kNLhazZH4Os4XUJIf2un IRuppeB7U4VK9e2wmqvx5YokuXK4xGT6IzGen41a+8pYR8UjLgwvqRs6Z/0Tp3mczvjb1YMlB OcPWjaHKibk7jt/sGHYxMgX405iwkILKXIyFqNkT5Lyau2PLiQPIuwV763Zoy/ogA7YgsuOwR mfDCOHWThWDCUupABl1YHcHQB2rJ/FR2H7kMp+rpUBEwfVtACsgWU60I+Mjsl5fzzVNAxcLDe aXIUMab4oyCsN6OInOjdXA2y+mWgxol7puHlBjF5mTxlxDcyKwbwbT2zK/qp32dmkQgvlo3dV LH1zmptki9C7EnqcHBtXCH9SvbRC1f6VKbSyrRrFf9kLfdRqwDZAYu/J6v/YF+6CzQ2KQv6N/ vL6wYyOzhYQsO8A9uBJj9q/GEDFmh7l6HTl2sZwZBP4B3fpUp5N32yfTbAwQfvXyvbQbKMpPS dViHgBvqQ4A9f1+8dM4IuV/RD8KxMn3tqs1iNnAGzyqhe8X3cqRzQuc0VSPX3ciOewDoaN5C5 M7wsiXprVqQZ072zWbKtwIAJHq7B+8fafpHYABeL/RPe6H2ugYnJdBqzU7k= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1810 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/samsung/sxgbe/sxgbe_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/samsung/sxgbe/sxgbe_main.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c index 5dbe406..578cbec 100644 --- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c +++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c @@ -782,14 +782,9 @@ static void sxgbe_tx_queue_clean(struct sxgbe_tx_queue *tqueue) /* wake up queue */ if (unlikely(netif_tx_queue_stopped(dev_txq) && sxgbe_tx_avail(tqueue, tx_rsize) > SXGBE_TX_THRESH(priv))) { - netif_tx_lock(priv->dev); - if (netif_tx_queue_stopped(dev_txq) && - sxgbe_tx_avail(tqueue, tx_rsize) > SXGBE_TX_THRESH(priv)) { - if (netif_msg_tx_done(priv)) - pr_debug("%s: restart transmit\n", __func__); - netif_tx_wake_queue(dev_txq); - } - netif_tx_unlock(priv->dev); + if (netif_msg_tx_done(priv)) + pr_debug("%s: restart transmit\n", __func__); + netif_tx_wake_queue(dev_txq); } spin_unlock(&tqueue->tx_lock); -- 1.9.1