All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] can: m_can: m_can_{read_fifo,echo_tx_event}(): shift timestamp to full 32 bits
@ 2022-06-12 21:14 ` Marc Kleine-Budde
  2022-06-13  6:29   ` Chandrasekar R
  0 siblings, 1 reply; 2+ messages in thread
From: Marc Kleine-Budde @ 2022-06-12 21:14 UTC (permalink / raw)
  To: linux-can
  Cc: kernel, Marc Kleine-Budde, Torin Cooper-Bennun,
	Chandrasekar Ramakrishnan

In commit 1be37d3b0414 ("can: m_can: fix periph RX path: use
rx-offload to ensure skbs are sent from softirq context") the RX path
for peripheral devices was switched to RX-offload.

Received CAN frames are pushed to RX-offload together with a
timestamp. RX-offload is designed to handle overflows of the timestamp
correctly, if 32 bit timestamps are provided.

The timestamps of m_can core are only 16 bits wide. So this patch
shifts them to full 32 bit before passing them to RX-offload.

Fixes: 1be37d3b0414 ("can: m_can: fix periph RX path: use rx-offload to ensure skbs are sent from softirq context")
Cc: Torin Cooper-Bennun <torin@maxiluxsystems.com>
Cc: Chandrasekar Ramakrishnan <rcsekar@samsung.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 03a22d493cf6..7931f9c71ef3 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -529,7 +529,7 @@ static int m_can_read_fifo(struct net_device *dev, u32 rxfs)
 	/* acknowledge rx fifo 0 */
 	m_can_write(cdev, M_CAN_RXF0A, fgi);
 
-	timestamp = FIELD_GET(RX_BUF_RXTS_MASK, fifo_header.dlc);
+	timestamp = FIELD_GET(RX_BUF_RXTS_MASK, fifo_header.dlc) << 16;
 
 	m_can_receive_skb(cdev, skb, timestamp);
 
@@ -1030,7 +1030,7 @@ static int m_can_echo_tx_event(struct net_device *dev)
 		}
 
 		msg_mark = FIELD_GET(TX_EVENT_MM_MASK, txe);
-		timestamp = FIELD_GET(TX_EVENT_TXTS_MASK, txe);
+		timestamp = FIELD_GET(TX_EVENT_TXTS_MASK, txe) << 16;
 
 		/* ack txe element */
 		m_can_write(cdev, M_CAN_TXEFA, FIELD_PREP(TXEFA_EFAI_MASK,
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH] can: m_can: m_can_{read_fifo,echo_tx_event}(): shift timestamp to full 32 bits
  2022-06-12 21:14 ` [PATCH] can: m_can: m_can_{read_fifo,echo_tx_event}(): shift timestamp to full 32 bits Marc Kleine-Budde
@ 2022-06-13  6:29   ` Chandrasekar R
  0 siblings, 0 replies; 2+ messages in thread
From: Chandrasekar R @ 2022-06-13  6:29 UTC (permalink / raw)
  To: 'Marc Kleine-Budde', linux-can
  Cc: kernel, 'Torin Cooper-Bennun'



> -----Original Message-----
> From: Marc Kleine-Budde [mailto:mkl@pengutronix.de]
> Sent: Monday, June 13, 2022 2:44 AM
> To: linux-can@vger.kernel.org
> Cc: kernel@pengutronix.de; Marc Kleine-Budde <mkl@pengutronix.de>;
> Torin Cooper-Bennun <torin@maxiluxsystems.com>; Chandrasekar
> Ramakrishnan <rcsekar@samsung.com>
> Subject: [PATCH] can: m_can: m_can_{read_fifo,echo_tx_event}(): shift
> timestamp to full 32 bits
> 
> In commit 1be37d3b0414 ("can: m_can: fix periph RX path: use rx-offload to
> ensure skbs are sent from softirq context") the RX path for peripheral
> devices was switched to RX-offload.
> 
> Received CAN frames are pushed to RX-offload together with a timestamp.
> RX-offload is designed to handle overflows of the timestamp correctly, if
32
> bit timestamps are provided.
> 
> The timestamps of m_can core are only 16 bits wide. So this patch shifts
> them to full 32 bit before passing them to RX-offload.
> 
> Fixes: 1be37d3b0414 ("can: m_can: fix periph RX path: use rx-offload to
> ensure skbs are sent from softirq context")
> Cc: Torin Cooper-Bennun <torin@maxiluxsystems.com>
> Cc: Chandrasekar Ramakrishnan <rcsekar@samsung.com>
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Changes looks fine, 
Reviewed-by: Chandrasekar Ramakrishnan <rcsekar@samsung.com>
> ---
>  drivers/net/can/m_can/m_can.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/can/m_can/m_can.c
> b/drivers/net/can/m_can/m_can.c index 03a22d493cf6..7931f9c71ef3 100644
> --- a/drivers/net/can/m_can/m_can.c
> +++ b/drivers/net/can/m_can/m_can.c
> @@ -529,7 +529,7 @@ static int m_can_read_fifo(struct net_device *dev,
> u32 rxfs)
>  	/* acknowledge rx fifo 0 */
>  	m_can_write(cdev, M_CAN_RXF0A, fgi);
> 
> -	timestamp = FIELD_GET(RX_BUF_RXTS_MASK, fifo_header.dlc);
> +	timestamp = FIELD_GET(RX_BUF_RXTS_MASK, fifo_header.dlc) <<
> 16;
> 
>  	m_can_receive_skb(cdev, skb, timestamp);
> 
> @@ -1030,7 +1030,7 @@ static int m_can_echo_tx_event(struct net_device
> *dev)
>  		}
> 
>  		msg_mark = FIELD_GET(TX_EVENT_MM_MASK, txe);
> -		timestamp = FIELD_GET(TX_EVENT_TXTS_MASK, txe);
> +		timestamp = FIELD_GET(TX_EVENT_TXTS_MASK, txe) << 16;
> 
>  		/* ack txe element */
>  		m_can_write(cdev, M_CAN_TXEFA,
> FIELD_PREP(TXEFA_EFAI_MASK,
> --
> 2.35.1
> 



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-13  6:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20220612211422epcas5p2d7e6e78a0ef6b61bf7871a90e5b7ffb1@epcas5p2.samsung.com>
2022-06-12 21:14 ` [PATCH] can: m_can: m_can_{read_fifo,echo_tx_event}(): shift timestamp to full 32 bits Marc Kleine-Budde
2022-06-13  6:29   ` Chandrasekar R

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.