AW: [PATCH RFC can v2] can: mcp251xfd: mcp251xfd_get_tef_len(): fix length calculation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Marc,

this looks good to me!
I have no crashes here anymore.

Regards,
   Sven

________________________________________
Von: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
Gesendet: Freitag, 25. Oktober 2024 11:57
An: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx>; Thomas Kopp <thomas.kopp@xxxxxxxxxxxxx>; Vincent Mailhol <mailhol.vincent@xxxxxxxxxx>; Sven Schuchmann <schuchmann@xxxxxxxxxxxxxxxxx>
Cc: linux-can@xxxxxxxxxxxxxxx <linux-can@xxxxxxxxxxxxxxx>; kernel@xxxxxxxxxxxxxx <kernel@xxxxxxxxxxxxxx>; Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
Betreff: [PATCH RFC can v2] can: mcp251xfd: mcp251xfd_get_tef_len(): fix length calculation
 
Reported-by: Sven Schuchmann <schuchmann@xxxxxxxxxxxxxxxxx>
Closes: https://patch.msgid.link/FR3P281MB155216711EFF900AD9791B7ED9692@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Fixes: b8e0ddd36ce9 ("can: mcp251xfd: tef: prepare to workaround broken TEF FIFO tail index erratum")
Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
---
Hello,

I got the empty check wrong and fixed it. Please test.

Marc
---
Changes in v2:
- mcp251xfd_tx_fifo_sta_empty(): fix check if TX-FIFO is empty
- Link to RFC: https://patch.msgid.link/20241001-mcp251xfd-fix-length-calculation-v1-1-598b46508d61@xxxxxxxxxxxxxx
---
 drivers/net/can/spi/mcp251xfd/mcp251xfd-tef.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-tef.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-tef.c
index f732556d233a7be3b43f6f08e0b8f25732190104..d3ac865933fdf6c4ecdd80ad4d7accbff51eb0f8 100644
--- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-tef.c
+++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-tef.c
@@ -16,9 +16,9 @@
 
 #include "mcp251xfd.h"
 
-static inline bool mcp251xfd_tx_fifo_sta_full(u32 fifo_sta)
+static inline bool mcp251xfd_tx_fifo_sta_empty(u32 fifo_sta)
 {
-       return !(fifo_sta & MCP251XFD_REG_FIFOSTA_TFNRFNIF);
+       return fifo_sta & MCP251XFD_REG_FIFOSTA_TFERFFIF;
 }
 
 static inline int
@@ -122,7 +122,11 @@ mcp251xfd_get_tef_len(struct mcp251xfd_priv *priv, u8 *len_p)
         if (err)
                 return err;
 
-       if (mcp251xfd_tx_fifo_sta_full(fifo_sta)) {
+       /* If the chip says the TX-FIFO is empty, but there are no TX
+        * buffers free in the ring, we assume all have been sent.
+        */
+       if (mcp251xfd_tx_fifo_sta_empty(fifo_sta) &&
+           mcp251xfd_get_tx_free(tx_ring) == 0) {
                 *len_p = tx_ring->obj_num;
                 return 0;
         }

---
base-commit: 9efc44fb2dba6138b0575826319200049078679a
change-id: 20241001-mcp251xfd-fix-length-calculation-09b6cc10aeb0

Best regards,
--
Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>






[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux