Skip to content

Commit

Permalink
staging: vt6655: vnt_tx_packet Correct TX order of OWNED_BY_NIC
Browse files Browse the repository at this point in the history
The state of m_td0TD0.f1Owner should change after the buff_addr
has been filled otherwise the device grabs the buffer too early.

m_td0TD0.f1Owner is protected by memory barriers on both sides
of change.

iTDUsed is best incremented after MACvTransmit.

It appears that f1Owner actually polls to do the memory transfer.

A back port patch will be needed for v3.19

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Cc: <stable@vger.kernel.org> # v4.0+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Malcolm Priestley authored and Greg Kroah-Hartman committed May 8, 2015
1 parent ad3fee9 commit d65d2b2
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions drivers/staging/vt6655/device_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1206,14 +1206,6 @@ static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
if (dma_idx == TYPE_AC0DMA)
head_td->pTDInfo->byFlags = TD_FLAGS_NETIF_SKB;

priv->iTDUsed[dma_idx]++;

/* Take ownership */
wmb();
head_td->m_td0TD0.f1Owner = OWNED_BY_NIC;

/* get Next */
wmb();
priv->apCurrTD[dma_idx] = head_td->next;

spin_unlock_irqrestore(&priv->lock, flags);
Expand All @@ -1234,11 +1226,18 @@ static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)

head_td->buff_addr = cpu_to_le32(head_td->pTDInfo->skb_dma);

/* Poll Transmit the adapter */
wmb();
head_td->m_td0TD0.f1Owner = OWNED_BY_NIC;
wmb(); /* second memory barrier */

if (head_td->pTDInfo->byFlags & TD_FLAGS_NETIF_SKB)
MACvTransmitAC0(priv->PortOffset);
else
MACvTransmit0(priv->PortOffset);

priv->iTDUsed[dma_idx]++;

spin_unlock_irqrestore(&priv->lock, flags);

return 0;
Expand Down

0 comments on commit d65d2b2

Please sign in to comment.