wcn36xx: fix buffer commit logic on TX path
authorDaniel Mack <daniel@zonque.org>
Wed, 23 May 2018 08:14:22 +0000 (11:14 +0300)
committerKalle Valo <kvalo@codeaurora.org>
Fri, 25 May 2018 10:06:59 +0000 (13:06 +0300)
commit9a81cc23dfef24e254d3ff15c52bf46f0736f4c2
tree2ac8f3c02a9aca993d5a64db07d49c3cda9c30eb
parentcf3c0ae6a32b5c3bb19b07d48dff646fc3896e51
wcn36xx: fix buffer commit logic on TX path

When wcn36xx_dxe_tx_frame() is entered while the device is still processing
the queue asyncronously, we are racing against the firmware code with
updates to the buffer descriptors. Presumably, the firmware scans the ring
buffer that holds the descriptors and scans for a valid control descriptor,
and then assumes that the next descriptor contains the payload. If, however,
the control descriptor is marked valid, but the payload descriptor isn't,
the packet is not sent out.

Another issue with the current code is that is lacks memory barriers before
descriptors are marked valid. This is important because the CPU may reorder
writes to memory, even if it is allocated as coherent DMA area, and hence
the device may see incompletely written data.

To fix this, the code in wcn36xx_dxe_tx_frame() was restructured a bit so
that the payload descriptor is made valid before the control descriptor.
Memory barriers are added to ensure coherency of shared memory areas.

Signed-off-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ath/wcn36xx/dxe.c