stmmac: troubleshoot unexpected bits in des0 & des1
authorAlexey Brodkin <[email protected]>
Wed, 24 Jun 2015 08:47:41 +0000 (11:47 +0300)
committerDavid S. Miller <[email protected]>
Wed, 24 Jun 2015 09:38:53 +0000 (02:38 -0700)
commitf1590670ce069eefeb93916391a67643e6ad1630
treefa6e866515a1a9997d78300baff581ce08cc2394
parent34b99df4e6256ddafb663c6de0711dceceddfe0e
stmmac: troubleshoot unexpected bits in des0 & des1

Current implementation of descriptor init procedure only takes
care about setting/clearing ownership flag in "des0"/"des1"
fields while it is perfectly possible to get unexpected bits
set because of the following factors:

 [1] On driver probe underlying memory allocated with
     dma_alloc_coherent() might not be zeroed and so
     it will be filled with garbage.

 [2] During driver operation some bits could be set by SD/MMC
     controller (for example error flags etc).

And unexpected and/or randomly set flags in "des0"/"des1"
fields may lead to unpredictable behavior of GMAC DMA block.

This change addresses both items above with:

 [1] Use of dma_zalloc_coherent() instead of simple
     dma_alloc_coherent() to make sure allocated memory is
     zeroed. That shouldn't affect performance because
     this allocation only happens once on driver probe.

 [2] Do explicit zeroing of both "des0" and "des1" fields
     of all buffer descriptors during initialization of
     DMA transfer.

And while at it fixed identation of dma_free_coherent()
counterpart as well.

Signed-off-by: Alexey Brodkin <[email protected]>
Cc: Giuseppe Cavallaro <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: David Miller <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
drivers/net/ethernet/stmicro/stmmac/descs.h
drivers/net/ethernet/stmicro/stmmac/enh_desc.c
drivers/net/ethernet/stmicro/stmmac/norm_desc.c
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c