Skip to contentSkip to conversation

Patch "stmmac: troubleshoot unexpected bits in des0 & des1" has been added to the 4.1-stable tree

PATCH [email protected] 1 participant 1 message Sep 26, 2015

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

stmmac: troubleshoot unexpected bits in des0 & des1

to the 4.1-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
stmmac-troubleshoot-unexpected-bits-in-des0-des1.patch
and it can be found in the queue-4.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From f1590670ce069eefeb93916391a67643e6ad1630 Mon Sep 17 00:00:00 2001

From: Alexey Brodkin <[email protected]>
Date: Wed, 24 Jun 2015 11:47:41 +0300
Subject: stmmac: troubleshoot unexpected bits in des0 & des1

From: Alexey Brodkin <[email protected]>

commit f1590670ce069eefeb93916391a67643e6ad1630 upstream.

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.

---
 drivers/net/ethernet/stmicro/stmmac/descs.h       |    2 +
 drivers/net/ethernet/stmicro/stmmac/enh_desc.c    |    3 +
 drivers/net/ethernet/stmicro/stmmac/norm_desc.c   |    3 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |   44 +++++++++++-----------
 4 files changed, 28 insertions(+), 24 deletions(-)
drivers/net/ethernet/stmicro/stmmac/descs.h +2 -0
@@ -158,6 +158,8 @@ struct dma_desc {
 			u32 buffer2_size:13;
 			u32 reserved4:3;
 		} etx;		/* -- enhanced -- */
+
+		u64 all_flags;
 	} des01;
 	unsigned int des2;
 	unsigned int des3;
drivers/net/ethernet/stmicro/stmmac/enh_desc.c +2 -1
@@ -240,6 +240,7 @@ static int enh_desc_get_rx_status(void *
 static void enh_desc_init_rx_desc(struct dma_desc *p, int disable_rx_ic,
 				  int mode, int end)
 {
+	p->des01.all_flags = 0;
 	p->des01.erx.own = 1;
 	p->des01.erx.buffer1_size = BUF_SIZE_8KiB - 1;
 
@@ -254,7 +255,7 @@ static void enh_desc_init_rx_desc(struct
 
 static void enh_desc_init_tx_desc(struct dma_desc *p, int mode, int end)
 {
-	p->des01.etx.own = 0;
+	p->des01.all_flags = 0;
 	if (mode == STMMAC_CHAIN_MODE)
 		ehn_desc_tx_set_on_chain(p, end);
 	else
drivers/net/ethernet/stmicro/stmmac/norm_desc.c +2 -1
@@ -123,6 +123,7 @@ static int ndesc_get_rx_status(void *dat
 static void ndesc_init_rx_desc(struct dma_desc *p, int disable_rx_ic, int mode,
 			       int end)
 {
+	p->des01.all_flags = 0;
 	p->des01.rx.own = 1;
 	p->des01.rx.buffer1_size = BUF_SIZE_2KiB - 1;
 
@@ -137,7 +138,7 @@ static void ndesc_init_rx_desc(struct dm
 
 static void ndesc_init_tx_desc(struct dma_desc *p, int mode, int end)
 {
-	p->des01.tx.own = 0;
+	p->des01.all_flags = 0;
 	if (mode == STMMAC_CHAIN_MODE)
 		ndesc_tx_set_on_chain(p, end);
 	else
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +22 -22

63 lines not on this page · raw message

Patches currently in stable-queue which might be from [email protected] are

queue-4.1/stmmac-troubleshoot-unexpected-bits-in-des0-des1.patch queue-4.1/stmmac-fix-check-for-phydev-being-open.patch