* peak_usb: timestamp issue
@ 2012-11-21 15:34 Oliver Hartkopp
2012-11-21 15:58 ` Marc Kleine-Budde
0 siblings, 1 reply; 2+ messages in thread
From: Oliver Hartkopp @ 2012-11-21 15:34 UTC (permalink / raw)
To: Stephane Grosjean; +Cc: linux-can@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 703 bytes --]
Hi Stephane,
i was working with the PEAK USB adapter today and got the problem of different
timestamps with 'candump -x -ta can0':
Timestamps of received CAN frames looked like my system 'uptime'.
Send CAN frames had the real system time.
The problem is, that you insert the hardware timestamp of the PEAK USB
adapters into skb->tstamp ...
This is wrong. For hardware timestamps (RX/TX) there's a special handling in
the Linux Kernel, see at
linux/Documentation/networking/timestamping.txt
For now i just removed the setting of your HW timestamps on my Linux box (see
attached patch).
Please fix the HW timestamp handling in your driver by supporting the HW
timstamp API correctly.
Tnx,
Oliver
[-- Attachment #2: peak_usb_ts_hack.patch --]
[-- Type: text/x-patch, Size: 2050 bytes --]
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c
index 86f26a1..4de6bf3 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb.c
@@ -520,7 +520,8 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
if (status_len & PCAN_USB_STATUSLEN_TIMESTAMP) {
peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv);
- skb->tstamp = timeval_to_ktime(tv);
+ /* HACK to disable wrongly introduced hardware timestamp */
+ //skb->tstamp = timeval_to_ktime(tv);
}
netif_rx(skb);
@@ -652,7 +653,8 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len)
/* convert timestamp into kernel time */
peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv);
- skb->tstamp = timeval_to_ktime(tv);
+ /* HACK to disable wrongly introduced hardware timestamp */
+ //skb->tstamp = timeval_to_ktime(tv);
/* push the skb */
netif_rx(skb);
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
index e1626d9..52f3743 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
@@ -549,7 +549,8 @@ static int pcan_usb_pro_handle_canmsg(struct pcan_usb_pro_interface *usb_if,
memcpy(can_frame->data, rx->data, can_frame->can_dlc);
peak_usb_get_ts_tv(&usb_if->time_ref, le32_to_cpu(rx->ts32), &tv);
- skb->tstamp = timeval_to_ktime(tv);
+ /* HACK to disable wrongly introduced hardware timestamp */
+ //skb->tstamp = timeval_to_ktime(tv);
netif_rx(skb);
netdev->stats.rx_packets++;
@@ -664,7 +665,8 @@ static int pcan_usb_pro_handle_error(struct pcan_usb_pro_interface *usb_if,
dev->can.state = new_state;
peak_usb_get_ts_tv(&usb_if->time_ref, le32_to_cpu(er->ts32), &tv);
- skb->tstamp = timeval_to_ktime(tv);
+ /* HACK to disable wrongly introduced hardware timestamp */
+ //skb->tstamp = timeval_to_ktime(tv);
netif_rx(skb);
netdev->stats.rx_packets++;
netdev->stats.rx_bytes += can_frame->can_dlc;
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: peak_usb: timestamp issue
2012-11-21 15:34 peak_usb: timestamp issue Oliver Hartkopp
@ 2012-11-21 15:58 ` Marc Kleine-Budde
0 siblings, 0 replies; 2+ messages in thread
From: Marc Kleine-Budde @ 2012-11-21 15:58 UTC (permalink / raw)
To: Oliver Hartkopp; +Cc: Stephane Grosjean, linux-can@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 1200 bytes --]
On 11/21/2012 04:34 PM, Oliver Hartkopp wrote:
> Hi Stephane,
>
> i was working with the PEAK USB adapter today and got the problem of different
> timestamps with 'candump -x -ta can0':
>
> Timestamps of received CAN frames looked like my system 'uptime'.
> Send CAN frames had the real system time.
>
> The problem is, that you insert the hardware timestamp of the PEAK USB
> adapters into skb->tstamp ...
>
> This is wrong. For hardware timestamps (RX/TX) there's a special handling in
> the Linux Kernel, see at
>
> linux/Documentation/networking/timestamping.txt
>
> For now i just removed the setting of your HW timestamps on my Linux box (see
> attached patch).
>
> Please fix the HW timestamp handling in your driver by supporting the HW
> timstamp API correctly.
Oliver can you prepare a proper patch, which removes the broken time
stamping, I'd like to get this into 3.7.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 261 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-11-21 15:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-21 15:34 peak_usb: timestamp issue Oliver Hartkopp
2012-11-21 15:58 ` Marc Kleine-Budde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).