net: macb: Fix rx buffer cache handling
PATCH 1/1 net: macb: Fix rx buffer cache handling
With commit c6d07bf440bc ("net/macb: increase RX buffer size for GEM") ethernet support does not work any more with d-cache enabled on the AT91SAM. The reason is, that MACB_RX_BUFFER_SIZE was changed from 4096 to 128 but this change was not refected in the rx_buffer flush and invalidate functions, as these also use this macro.
This patch now fixes this by calculating the rx buffer size correctly again in those functions. With this change, ethernet works again reliably on my AT91SAM board.
--- drivers/net/macb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/macb.c +4 -2
@@ -296,13 +296,15 @@ static inline void macb_flush_ring_desc(struct macb_device *macb, bool rx)static inline void macb_flush_rx_buffer (struct macb_device *macb) {flush_dcache_range (macb->rx_buffer_dma, macb->rx_buffer_dma + -ALIGN (MACB_RX_BUFFER_SIZE ,PKTALIGN )); +ALIGN (MACB_RX_BUFFER_SIZE *MACB_RX_RING_SIZE , +PKTALIGN )); }static inline void macb_invalidate_rx_buffer (struct macb_device *macb) {invalidate_dcache_range (macb->rx_buffer_dma, macb->rx_buffer_dma + -ALIGN (MACB_RX_BUFFER_SIZE ,PKTALIGN )); +ALIGN (MACB_RX_BUFFER_SIZE *MACB_RX_RING_SIZE , +PKTALIGN )); }#if defined(CONFIG_CMD_NET )
Signature · 1 line
2.23.0
PATCH 1/1 net: macb: Fix rx buffer cache handling
Hi Stefan,
Quoted 26 lines · Stefan Roese
With commit
c6d07bf440bc("net/macb: increase RX buffer size for GEM") ethernet support does not work any more with d-cache enabled on the AT91SAM. The reason is, thatMACB_RX_BUFFER_SIZEwas changed from 4096 to 128 but this change was not refected in therx_bufferflush and invalidate functions, as these also use this macro.This patch now fixes this by calculating the rx buffer size correctly again in those functions. With this change, ethernet works again reliably on my AT91SAM board.
Signed-off-by Stefan Roese <[email protected]>Cc Ramon Fried <[email protected]>Cc Eugen Hristev <[email protected]>Cc Anup Patel <[email protected]>Cc Bin Meng <[email protected]>Cc Joe Hershberger <[email protected]>--- drivers/net/macb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/net/macb.c +0
-0
drivers/net/macb.c static inline void macb_flush_ring_desc(struct macb_device *macb, bool rx) · line 300
Quoted 6 lines
drivers/net/macb.c +2
-1@@ -296,13 +296,15 @@ static inline void macb_flush_ring_desc(struct macb_device *macb, bool rx)static inline void macb_flush_rx_buffer (struct macb_device *macb) {flush_dcache_range (macb->rx_buffer_dma, macb->rx_buffer_dma + -ALIGN (MACB_RX_BUFFER_SIZE ,PKTALIGN )); +ALIGN (MACB_RX_BUFFER_SIZE *MACB_RX_RING_SIZE , +PKTALIGN ));
This looks wrong to me.
Shouldn't it be:
flush_dcache_range(macb->rx_buffer_dma, macb->rx_buffer_dma +
ALIGN(macb->rx_buffer_size, PKTALIGN));drivers/net/macb.c static inline void macb_flush_ring_desc(struct macb_device *macb, bool rx)
Quoted 12 lines
drivers/net/macb.c +2
-2}static inline void macb_invalidate_rx_buffer (struct macb_device *macb) {invalidate_dcache_range (macb->rx_buffer_dma, macb->rx_buffer_dma + -ALIGN (MACB_RX_BUFFER_SIZE ,PKTALIGN )); +ALIGN (MACB_RX_BUFFER_SIZE *MACB_RX_RING_SIZE , +PKTALIGN )); }#if defined(CONFIG_CMD_NET ) --
Regards,
Bin
PATCH 1/1 net: macb: Fix rx buffer cache handling
Quoted 39 lines · Bin Meng
Hi Stefan,
Quoted 26 lines · Stefan Roese
With commit
c6d07bf440bc("net/macb: increase RX buffer size for GEM") ethernet support does not work any more with d-cache enabled on the AT91SAM. The reason is, thatMACB_RX_BUFFER_SIZEwas changed from 4096 to 128 but this change was not refected in therx_bufferflush and invalidate functions, as these also use this macro.This patch now fixes this by calculating the rx buffer size correctly again in those functions. With this change, ethernet works again reliably on my AT91SAM board.
Signed-off-by Stefan Roese <[email protected]>Cc Ramon Fried <[email protected]>Cc Eugen Hristev <[email protected]>Cc Anup Patel <[email protected]>Cc Bin Meng <[email protected]>Cc Joe Hershberger <[email protected]>--- drivers/net/macb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/net/macb.c +0
-0drivers/net/macb.c static inline void macb_flush_ring_desc(struct macb_device *macb, bool rx) · line 300
Quoted 6 lines
drivers/net/macb.c +2
-1@@ -296,13 +296,15 @@ static inline void macb_flush_ring_desc(struct macb_device *macb, bool rx)static inline void macb_flush_rx_buffer (struct macb_device *macb) {flush_dcache_range (macb->rx_buffer_dma, macb->rx_buffer_dma + -ALIGN (MACB_RX_BUFFER_SIZE ,PKTALIGN )); +ALIGN (MACB_RX_BUFFER_SIZE *MACB_RX_RING_SIZE , +PKTALIGN ));This looks wrong to me.
Quoted 4 lines
Shouldn't it be:
flush_dcache_range(macb->rx_buffer_dma, macb->rx_buffer_dma + ALIGN(macb->rx_buffer_size, PKTALIGN));
Ah, for MACB, looks it should be "MACB_RX_BUFFER_SIZE * MACB_RX_RING_SIZE", but for GEM, I am not sure.
Should it be:
flush_dcache_range(macb->rx_buffer_dma, macb->rx_buffer_dma +
ALIGN(macb->rx_buffer_size *MACB_RX_RING_SIZE, PKTALIGN));
Quoted 11 lines
Quoted 11 lines
drivers/net/macb.c +2
-1}static inline void macb_invalidate_rx_buffer (struct macb_device *macb) {invalidate_dcache_range (macb->rx_buffer_dma, macb->rx_buffer_dma + -ALIGN (MACB_RX_BUFFER_SIZE ,PKTALIGN )); +ALIGN (MACB_RX_BUFFER_SIZE *MACB_RX_RING_SIZE , +PKTALIGN )); }
Quoted 2 lines
drivers/net/macb.c static inline void macb_flush_ring_desc(struct macb_device *macb, bool rx)
Quoted 2 lines
drivers/net/macb.c +0
-1#if defined(CONFIG_CMD_NET ) --
Regards,
Bin
PATCH 1/1 net: macb: Fix rx buffer cache handling
Hi Bin,
Quoted 45 lines · Bin Meng
Quoted 39 lines · Bin Meng
Hi Stefan,
Quoted 26 lines · Stefan Roese
With commit
c6d07bf440bc("net/macb: increase RX buffer size for GEM") ethernet support does not work any more with d-cache enabled on the AT91SAM. The reason is, thatMACB_RX_BUFFER_SIZEwas changed from 4096 to 128 but this change was not refected in therx_bufferflush and invalidate functions, as these also use this macro.This patch now fixes this by calculating the rx buffer size correctly again in those functions. With this change, ethernet works again reliably on my AT91SAM board.
Signed-off-by Stefan Roese <[email protected]>Cc Ramon Fried <[email protected]>Cc Eugen Hristev <[email protected]>Cc Anup Patel <[email protected]>Cc Bin Meng <[email protected]>Cc Joe Hershberger <[email protected]>--- drivers/net/macb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/net/macb.c +0
-0drivers/net/macb.c static inline void macb_flush_ring_desc(struct macb_device *macb, bool rx) · line 300
Quoted 6 lines
drivers/net/macb.c +2
-1@@ -296,13 +296,15 @@ static inline void macb_flush_ring_desc(struct macb_device *macb, bool rx)static inline void macb_flush_rx_buffer (struct macb_device *macb) {flush_dcache_range (macb->rx_buffer_dma, macb->rx_buffer_dma + -ALIGN (MACB_RX_BUFFER_SIZE ,PKTALIGN )); +ALIGN (MACB_RX_BUFFER_SIZE *MACB_RX_RING_SIZE , +PKTALIGN ));This looks wrong to me.
Quoted 4 lines
Shouldn't it be:
flush_dcache_range(macb->rx_buffer_dma, macb->rx_buffer_dma + ALIGN(macb->rx_buffer_size, PKTALIGN));
Quoted 8 lines
Ah, for MACB, looks it should be "
MACB_RX_BUFFER_SIZE*MACB_RX_RING_SIZE", but for GEM, I am not sure.Should it be:
flush_dcache_range(macb->rx_buffer_dma, macb->rx_buffer_dma + ALIGN(macb->rx_buffer_size *
MACB_RX_RING_SIZE, PKTALIGN));
Yes, this looks correct. v2 will follow soon.
Thanks,
Stefan
PATCH 1/1 net: macb: Fix rx buffer cache handling
Quoted 54 lines · Stefan Roese
Hi Bin,
Quoted 50 lines · Bin Meng
Quoted 39 lines · Bin Meng
Hi Stefan,
Quoted 26 lines · Stefan Roese
With commit
c6d07bf440bc("net/macb: increase RX buffer size for GEM") ethernet support does not work any more with d-cache enabled on the AT91SAM. The reason is, thatMACB_RX_BUFFER_SIZEwas changed from 4096 to 128 but this change was not refected in therx_bufferflush and invalidate functions, as these also use this macro.This patch now fixes this by calculating the rx buffer size correctly again in those functions. With this change, ethernet works again reliably on my AT91SAM board.
Signed-off-by Stefan Roese <[email protected]>Cc Ramon Fried <[email protected]>Cc Eugen Hristev <[email protected]>Cc Anup Patel <[email protected]>Cc Bin Meng <[email protected]>Cc Joe Hershberger <[email protected]>--- drivers/net/macb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/net/macb.c +0
-0drivers/net/macb.c static inline void macb_flush_ring_desc(struct macb_device *macb, bool rx) · line 300
Quoted 6 lines
drivers/net/macb.c +2
-1@@ -296,13 +296,15 @@ static inline void macb_flush_ring_desc(struct macb_device *macb, bool rx)static inline void macb_flush_rx_buffer (struct macb_device *macb) {flush_dcache_range (macb->rx_buffer_dma, macb->rx_buffer_dma + -ALIGN (MACB_RX_BUFFER_SIZE ,PKTALIGN )); +ALIGN (MACB_RX_BUFFER_SIZE *MACB_RX_RING_SIZE , +PKTALIGN ));This looks wrong to me.
Quoted 4 lines
Shouldn't it be:
flush_dcache_range(macb->rx_buffer_dma, macb->rx_buffer_dma + ALIGN(macb->rx_buffer_size, PKTALIGN));Ah, for MACB, looks it should be "
MACB_RX_BUFFER_SIZE*MACB_RX_RING_SIZE", but for GEM, I am not sure.Should it be:
Quoted 8 lines
Quoted 3 lines
flush_dcache_range(macb->rx_buffer_dma, macb->rx_buffer_dma + ALIGN(macb->rx_buffer_size *
MACB_RX_RING_SIZE, PKTALIGN));Yes, this looks correct. v2 will follow soon.
Thanks,
Stefan
Thanks Stefan,
Can you fix your commit message to show: Fixes:...
You can use the following bash alias to generate the line: (pass c6d07bf440bc as argument)
alias gfixes='git --no-pager show -s --abbrev-commit --abbrev=12 --pretty=format:"Fixes: %h (\"%s\")%n"'
PATCH 1/1 net: macb: Fix rx buffer cache handling
Quoted 11 lines
Quoted 10 lines
Quoted 5 lines
Should it be:
flush_dcache_range(macb->rx_buffer_dma, macb->rx_buffer_dma + ALIGN(macb->rx_buffer_size *
MACB_RX_RING_SIZE, PKTALIGN));Yes, this looks correct. v2 will follow soon.
Thanks,
Stefan
The entire cache handling is broken in this driver, I will fix it in future patches.
Thanks, Ramon.
PATCH 1/1 net: macb: Fix rx buffer cache handling
In reply to Bin MengQuoted 46 lines · Bin Meng
Quoted 39 lines · Bin Meng
Hi Stefan,
Quoted 26 lines · Stefan Roese
With commit
c6d07bf440bc("net/macb: increase RX buffer size for GEM") ethernet support does not work any more with d-cache enabled on the AT91SAM. The reason is, thatMACB_RX_BUFFER_SIZEwas changed from 4096 to 128 but this change was not refected in therx_bufferflush and invalidate functions, as these also use this macro.This patch now fixes this by calculating the rx buffer size correctly again in those functions. With this change, ethernet works again reliably on my AT91SAM board.
Signed-off-by Stefan Roese <[email protected]>Cc Ramon Fried <[email protected]>Cc Eugen Hristev <[email protected]>Cc Anup Patel <[email protected]>Cc Bin Meng <[email protected]>Cc Joe Hershberger <[email protected]>--- drivers/net/macb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/net/macb.c +0
-0drivers/net/macb.c static inline void macb_flush_ring_desc(struct macb_device *macb, bool rx) · line 300
Quoted 6 lines
drivers/net/macb.c +2
-1@@ -296,13 +296,15 @@ static inline void macb_flush_ring_desc(struct macb_device *macb, bool rx)static inline void macb_flush_rx_buffer (struct macb_device *macb) {flush_dcache_range (macb->rx_buffer_dma, macb->rx_buffer_dma + -ALIGN (MACB_RX_BUFFER_SIZE ,PKTALIGN )); +ALIGN (MACB_RX_BUFFER_SIZE *MACB_RX_RING_SIZE , +PKTALIGN ));This looks wrong to me.
Quoted 4 lines
Shouldn't it be:
flush_dcache_range(macb->rx_buffer_dma, macb->rx_buffer_dma + ALIGN(macb->rx_buffer_size, PKTALIGN));
Quoted 9 lines
Ah, for MACB, looks it should be "
MACB_RX_BUFFER_SIZE*MACB_RX_RING_SIZE", but for GEM, I am not sure.Should it be:
flush_dcache_range(macb->rx_buffer_dma, macb->rx_buffer_dma + ALIGN(macb->rx_buffer_size *
MACB_RX_RING_SIZE, PKTALIGN));
Good catch !, I'll issue a fix soon.
Thanks,
Ramon
Quoted 16 lines
Quoted 11 lines
Quoted 11 lines
drivers/net/macb.c +2
-1}static inline void macb_invalidate_rx_buffer (struct macb_device *macb) {invalidate_dcache_range (macb->rx_buffer_dma, macb->rx_buffer_dma + -ALIGN (MACB_RX_BUFFER_SIZE ,PKTALIGN )); +ALIGN (MACB_RX_BUFFER_SIZE *MACB_RX_RING_SIZE , +PKTALIGN )); }Quoted 2 lines
drivers/net/macb.c static inline void macb_flush_ring_desc(struct macb_device *macb, bool rx)
Quoted 2 lines
drivers/net/macb.c +0
-1#if defined(CONFIG_CMD_NET ) --Regards,
Bin