net: mvpp2: fix DMA address calculation in mvpp2_txq_inc_put()
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tue, 21 Feb 2017 10:28:01 +0000 (11:28 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Mar 2017 01:57:13 +0000 (09:57 +0800)
commit 239a3b663647869330955ec59caac0100ef9b60a upstream.

When TX descriptors are filled in, the buffer DMA address is split
between the tx_desc->buf_phys_addr field (high-order bits) and
tx_desc->packet_offset field (5 low-order bits).

However, when we re-calculate the DMA address from the TX descriptor in
mvpp2_txq_inc_put(), we do not take tx_desc->packet_offset into
account. This means that when the DMA address is not aligned on a 32
bytes boundary, we end up calling dma_unmap_single() with a DMA address
that was not the one returned by dma_map_single().

This inconsistency is detected by the kernel when DMA_API_DEBUG is
enabled. We fix this problem by properly calculating the DMA address in
mvpp2_txq_inc_put().

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/marvell/mvpp2.c

index 25aba988699051506c0ae6c72416004227203554..0e67145bc418426fbeb9f3cfc2503e6be8597477 100644 (file)
@@ -993,7 +993,7 @@ static void mvpp2_txq_inc_put(struct mvpp2_txq_pcpu *txq_pcpu,
                txq_pcpu->buffs + txq_pcpu->txq_put_index;
        tx_buf->skb = skb;
        tx_buf->size = tx_desc->data_size;
-       tx_buf->phys = tx_desc->buf_phys_addr;
+       tx_buf->phys = tx_desc->buf_phys_addr + tx_desc->packet_offset;
        txq_pcpu->txq_put_index++;
        if (txq_pcpu->txq_put_index == txq_pcpu->size)
                txq_pcpu->txq_put_index = 0;