Subject: Re: [PATCH wireless-drivers 2/2] mt76: dma: fix buffer unmap with non-linear skbs

From: Stanislaw Gruszka <[email-masked]>
Date: Fri, 25 Oct 2019 11:02:36 +0200

On Thu, Oct 24, 2019 at 11:01:48AM +0200, Lorenzo Bianconi wrote:
> > On Thu, Oct 24, 2019 at 12:23:16AM +0200, Lorenzo Bianconi wrote:
> > > mt76 dma layer is supposed to unmap skb data buffers while keep txwi
> > > mapped on hw dma ring. At the moment mt76 wrongly unmap txwi or does
> > > not unmap data fragments in even positions for non-linear skbs. This
> > > issue may result in hw hangs with A-MSDU if the system relies on IOMMU
> > > or SWIOTLB. Fix this behaviour properly unmapping data fragments on
> > > non-linear skbs.
> > 
> > If we have to keep txwi mapped, before unmap fragments, when then
> > txwi is unmaped ?
> 
> txwi are mapped when they are crated in mt76_alloc_txwi(). Whenever we need to
> modify them we sync the DMA in mt76_dma_tx_queue_skb(). txwi are unmapped in
> mt76_tx_free() at driver unload.

So not only txwi is wrongly unmapped on runtime, but we can call
dma_sync_single_for_cpu/device() after dma_unmap_single().
That serious bug, good you spotted it and fixed!

Stanislaw