net: stmmac: make dwmac4_release_tx_desc() clear all descriptor fields
authorNiklas Cassel <niklas.cassel@axis.com>
Mon, 26 Feb 2018 21:47:09 +0000 (22:47 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 27 Feb 2018 19:28:10 +0000 (14:28 -0500)
commit1e88f6e01bc094c9fc7021cc1944d14a63257703
tree4040336591479c7be043d0c4782d3e7fd1ca03c2
parenta6b25da5e7ba212af5826a662e6a035a79bffabd
net: stmmac: make dwmac4_release_tx_desc() clear all descriptor fields

Make dwmac4_release_tx_desc() clear all descriptor fields, not just
TDES2 and TDES3.

I'm suspecting that TDES0 and TDES1 wasn't cleared because the DMA
engine uses them to store the tx hardware timestamp (if PTP is enabled).

However, stmmac_tx_clean() calls stmmac_get_tx_hwtstamp(), which reads
and saves the timestamp, before it calls release_tx_desc(), so this
is not an issue.

stmmac_xmit() and stmmac_tso_xmit() both always overwrite TDES0,
however, stmmac_tso_xmit() sometimes sets TDES1, and since neither
stmmac_xmit() nor stmmac_tso_xmit() explicitly clears TDES1, both
functions might reuse a DMA descriptor with old TDES1 data.

I haven't observed any misbehavior even though TDES1 sometimes
point to an old skb, however, explicitly clearing both TDES0 and TDES1
in dwmac4_release_tx_desc() minimizes the chances of undefined behavior.

Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c