Skip to contentSkip to conversation

drivers: net: cpsw: always flush cache of size PKTSIZE_ALIGN

PATCH Superseded Lokesh Vutla 3 participants 6 messages Aug 9, 2016 – Aug 11, 2016 Network drivers

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drivers: net: cpsw: always flush cache of size PKTSIZE_ALIGN

cpsw tries to flush dcache which is not in the range of PKTSIZE. Because of this the following warning comes while flushing:

CACHE: Misaligned operation at range [dffecec0, dffed016]

Fix it by flushing cache of size PKTSIZE_ALIGN as similar to what is being done in _cpsw_recv.

---
Changes since v1:
- Use PKTALIGN instead of cache line size
- Need not align start of packet buffer from the network subsystem.

 drivers/net/cpsw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/cpsw.c +1 -1
index 2ce4ec6..8ce5716 100644
@@ -907,7 +907,7 @@ static int _cpsw_send(struct cpsw_priv *priv, void *packet, int length)
 	int timeout = CPDMA_TIMEOUT;
 
 	flush_dcache_range((unsigned long)packet,
-			   (unsigned long)packet + length);
+			   (unsigned long)packet + PKTSIZE_ALIGN);
 
 	/* first reap completed packets */
 	while (timeout-- &&
Signature · 1 line
2.9.2
#1 lore raw

PATCH v2 1/1 drivers: net: cpsw: always flush cache of size PKTSIZE_ALIGN

Quoted 9 lines · Lokesh Vutla

cpsw tries to flush dcache which is not in the range of PKTSIZE. Because of this the following warning comes while flushing:

CACHE: Misaligned operation at range [dffecec0, dffed016]

Fix it by flushing cache of size PKTSIZE_ALIGN as similar to what is being done in _cpsw_recv.

Regards
Mugunthan V N

#2 lore raw

PATCH v2 1/1 drivers: net: cpsw: always flush cache of size PKTSIZE_ALIGN

In reply to Lokesh Vutla

Hi Lokesh

Quoted 22 lines · Lokesh Vutla

cpsw tries to flush dcache which is not in the range of PKTSIZE. Because of this the following warning comes while flushing:

CACHE: Misaligned operation at range [dffecec0, dffed016]

Fix it by flushing cache of size PKTSIZE_ALIGN as similar to what is being done in _cpsw_recv.

---
Changes since v1:
- Use PKTALIGN instead of cache line size
- Need not align start of packet buffer from the network subsystem.

 drivers/net/cpsw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/cpsw.c +0 -0
index 2ce4ec6..8ce5716 100644

drivers/net/cpsw.c static int _cpsw_send(struct cpsw_priv *priv, void *packet, int length) · line 910

Quoted 5 lines
drivers/net/cpsw.c +1 -1
@@ -907,7 +907,7 @@ static int _cpsw_send(struct cpsw_priv *priv, void *packet, int length)
        int timeout = CPDMA_TIMEOUT;
 
        flush_dcache_range((unsigned long)packet,
-                          (unsigned long)packet + length);
+                          (unsigned long)packet + PKTSIZE_ALIGN);

Technically you are flushing more than needed since you just need to be aligned to the cacheline beyond the size being sent, but you are flushing the maximum packet size every time. That said, it's still going to work and the code is readable. I'm fine with this, but wanted to make sure you knew this is more flushing than needed.

Quoted 9 lines
drivers/net/cpsw.c +0 -1
        /* first reap completed packets */
        while (timeout-- &&
--

2.9.2

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#3 lore raw

PATCH v2 1/1 drivers: net: cpsw: always flush cache of size PKTSIZE_ALIGN

Quoted 27 lines · Joe Hershberger

Hi Lokesh

Quoted 24 lines · Lokesh Vutla

cpsw tries to flush dcache which is not in the range of PKTSIZE. Because of this the following warning comes while flushing:

CACHE: Misaligned operation at range [dffecec0, dffed016]

Fix it by flushing cache of size PKTSIZE_ALIGN as similar to what is being done in _cpsw_recv.

---
Changes since v1:
- Use PKTALIGN instead of cache line size
- Need not align start of packet buffer from the network subsystem.

 drivers/net/cpsw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/cpsw.c +0 -0
index 2ce4ec6..8ce5716 100644
@@ -907,7 +907,7 @@ static int _cpsw_send(struct cpsw_priv *priv, void *packet, int length)
        int timeout = CPDMA_TIMEOUT;
 
Quoted 9 lines

drivers/net/cpsw.c static int _cpsw_send(struct cpsw_priv *priv, void *packet, int length) · line 910

Quoted 3 lines
drivers/net/cpsw.c +1 -1
        flush_dcache_range((unsigned long)packet,
-                          (unsigned long)packet + length);
+                          (unsigned long)packet + PKTSIZE_ALIGN);

Technically you are flushing more than needed since you just need to be aligned to the cacheline beyond the size being sent, but you are flushing the maximum packet size every time. That said, it's still going to work and the code is readable. I'm fine with this, but wanted to make sure you knew this is more flushing than needed.

Initially that was my idea as well and aligned length to cache line size. As you suggested to use PKTSIZE_ALIGN and also _cpsw_recv uses the same. So, I used PKTSIZE_ALIGN.

Quoted 2 lines

Thanks and regards,
Lokesh

Quoted 10 lines
Quoted 10 lines
drivers/net/cpsw.c +0 -1
        /* first reap completed packets */
        while (timeout-- &&
--

2.9.2

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#4 lore raw

PATCH v2 1/1 drivers: net: cpsw: always flush cache of size PKTSIZE_ALIGN

Hi Lokesh,

Quoted 40 lines · Lokesh Vutla
Quoted 27 lines · Joe Hershberger

Hi Lokesh

Quoted 24 lines · Lokesh Vutla

cpsw tries to flush dcache which is not in the range of PKTSIZE. Because of this the following warning comes while flushing:

CACHE: Misaligned operation at range [dffecec0, dffed016]

Fix it by flushing cache of size PKTSIZE_ALIGN as similar to what is being done in _cpsw_recv.

---
Changes since v1:
- Use PKTALIGN instead of cache line size
- Need not align start of packet buffer from the network subsystem.

 drivers/net/cpsw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/cpsw.c +0 -0
index 2ce4ec6..8ce5716 100644
@@ -907,7 +907,7 @@ static int _cpsw_send(struct cpsw_priv *priv, void *packet, int length)
        int timeout = CPDMA_TIMEOUT;
 
Quoted 9 lines

drivers/net/cpsw.c static int _cpsw_send(struct cpsw_priv *priv, void *packet, int length) · line 910

Quoted 3 lines
drivers/net/cpsw.c +1 -1
        flush_dcache_range((unsigned long)packet,
-                          (unsigned long)packet + length);
+                          (unsigned long)packet + PKTSIZE_ALIGN);

Technically you are flushing more than needed since you just need to be aligned to the cacheline beyond the size being sent, but you are flushing the maximum packet size every time. That said, it's still going to work and the code is readable. I'm fine with this, but wanted to make sure you knew this is more flushing than needed.

Quoted 3 lines

Initially that was my idea as well and aligned length to cache line size. As you suggested to use PKTSIZE_ALIGN and also _cpsw_recv uses the same. So, I used PKTSIZE_ALIGN.

I actually recommended PKTALIGN, not PKTSIZE_ALIGN. For recv, the size for invalidate is unknown until it's received (unless you can check a descriptor after it's received but before you read it), so it's more appropriate to use PKTSIZE_ALIGN. For send, you certainly know the size before flushing.

Cheers,
-Joe

#5 lore raw

PATCH v2 1/1 drivers: net: cpsw: always flush cache of size PKTSIZE_ALIGN

Quoted 43 lines · Joe Hershberger

Hi Lokesh,

Quoted 40 lines · Lokesh Vutla
Quoted 36 lines · Joe Hershberger

Hi Lokesh

Quoted 22 lines · Lokesh Vutla

cpsw tries to flush dcache which is not in the range of PKTSIZE. Because of this the following warning comes while flushing:

CACHE: Misaligned operation at range [dffecec0, dffed016]

Fix it by flushing cache of size PKTSIZE_ALIGN as similar to what is being done in _cpsw_recv.

---
Changes since v1:
- Use PKTALIGN instead of cache line size
- Need not align start of packet buffer from the network subsystem.

 drivers/net/cpsw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/cpsw.c +0 -0
index 2ce4ec6..8ce5716 100644

drivers/net/cpsw.c static int _cpsw_send(struct cpsw_priv *priv, void *packet, int length) · line 910

Quoted 5 lines
drivers/net/cpsw.c +1 -1
@@ -907,7 +907,7 @@ static int _cpsw_send(struct cpsw_priv *priv, void *packet, int length)
        int timeout = CPDMA_TIMEOUT;
 
        flush_dcache_range((unsigned long)packet,
-                          (unsigned long)packet + length);
+                          (unsigned long)packet + PKTSIZE_ALIGN);

Technically you are flushing more than needed since you just need to be aligned to the cacheline beyond the size being sent, but you are flushing the maximum packet size every time. That said, it's still going to work and the code is readable. I'm fine with this, but wanted to make sure you knew this is more flushing than needed.

Quoted 5 lines
Quoted 3 lines

Initially that was my idea as well and aligned length to cache line size. As you suggested to use PKTSIZE_ALIGN and also _cpsw_recv uses the same. So, I used PKTSIZE_ALIGN.

I actually recommended PKTALIGN, not PKTSIZE_ALIGN. For recv, the size

Oops my bad. I totally misunderstood your previous comment. Ill resend this patch.

Thanks and regards,
Lokesh

Quoted 8 lines

for invalidate is unknown until it's received (unless you can check a descriptor after it's received but before you read it), so it's more appropriate to use PKTSIZE_ALIGN. For send, you certainly know the size before flushing.

Cheers,
-Joe