From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sn1nam02on0134.outbound.protection.outlook.com ([104.47.36.134]:61393 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754317AbeDIA2V (ORCPT ); Sun, 8 Apr 2018 20:28:21 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Jacob Keller , Jeff Kirsher , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 069/293] ixgbe: avoid permanent lock of *_PTP_TX_IN_PROGRESS Date: Mon, 9 Apr 2018 00:23:47 +0000 Message-ID: <20180409002239.163177-69-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Jacob Keller [ Upstream commit 5fef124d9c75942dc5c2445a3faa8ad37cbf4c82 ] The ixgbe driver uses a state bit lock to avoid handling more than one Tx timestamp request at once. This is required because hardware is limited to a single set of registers for Tx timestamps. The state bit lock is not properly cleaned up during ixgbe_xmit_frame_ring() if the transmit fails such as due to DMA or TSO failure. In some hardware this results in blocking timestamps until the service task times out. In other hardware this results in a permanent lock of the timestamp bit because we never receive an interrupt indicating the timestamp occurred, since indeed the packet was never transmitted. Fix this by checking for DMA and TSO errors in ixgbe_xmit_frame_ring() and properly cleaning up after ourselves when these occur. Reported-by: Reported-by: David Mirabito Signed-off-by: Jacob Keller Tested-by: Andrew Bowers Signed-off-by: Jeff Kirsher Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/et= hernet/intel/ixgbe/ixgbe_main.c index a5428b6abdac..4856cf83f9e4 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -7472,9 +7472,9 @@ static inline int ixgbe_maybe_stop_tx(struct ixgbe_ri= ng *tx_ring, u16 size) #define IXGBE_TXD_CMD (IXGBE_TXD_CMD_EOP | \ IXGBE_TXD_CMD_RS) =20 -static void ixgbe_tx_map(struct ixgbe_ring *tx_ring, - struct ixgbe_tx_buffer *first, - const u8 hdr_len) +static int ixgbe_tx_map(struct ixgbe_ring *tx_ring, + struct ixgbe_tx_buffer *first, + const u8 hdr_len) { struct sk_buff *skb =3D first->skb; struct ixgbe_tx_buffer *tx_buffer; @@ -7601,7 +7601,7 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring, mmiowb(); } =20 - return; + return 0; dma_error: dev_err(tx_ring->dev, "TX DMA map failed\n"); =20 @@ -7617,6 +7617,8 @@ dma_error: } =20 tx_ring->next_to_use =3D i; + + return -1; } =20 static void ixgbe_atr(struct ixgbe_ring *ring, @@ -7917,13 +7919,21 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *s= kb, #ifdef IXGBE_FCOE xmit_fcoe: #endif /* IXGBE_FCOE */ - ixgbe_tx_map(tx_ring, first, hdr_len); + if (ixgbe_tx_map(tx_ring, first, hdr_len)) + goto cleanup_tx_timestamp; =20 return NETDEV_TX_OK; =20 out_drop: dev_kfree_skb_any(first->skb); first->skb =3D NULL; +cleanup_tx_timestamp: + if (unlikely(tx_flags & IXGBE_TX_FLAGS_TSTAMP)) { + dev_kfree_skb_any(adapter->ptp_tx_skb); + adapter->ptp_tx_skb =3D NULL; + cancel_work_sync(&adapter->ptp_tx_work); + clear_bit_unlock(__IXGBE_PTP_TX_IN_PROGRESS, &adapter->state); + } =20 return NETDEV_TX_OK; } --=20 2.15.1