• Mika Westerberg's avatar
    net: thunderbolt: Clear finished Tx frame bus address in tbnet_tx_callback() · 86dabda4
    Mika Westerberg authored
    When Thunderbolt network interface is disabled or when the cable is
    unplugged the driver releases all allocated buffers by calling
    tbnet_free_buffers() for each ring. This function then calls
    dma_unmap_page() for each buffer it finds where bus address is non-zero.
    Now, we only clear this bus address when the Tx buffer is sent to the
    hardware so it is possible that the function finds an entry that has
    already been unmapped.
    
    Enabling DMA-API debugging catches this as well:
    
      thunderbolt 0000:06:00.0: DMA-API: device driver tries to free DMA
        memory it has not allocated [device address=0x0000000068321000] [size=4096 bytes]
    
    Fix this by clearing the bus address of a Tx frame right after we have
    unmapped the buffer.
    Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    86dabda4
thunderbolt.c 34.3 KB