Pavel B. Cheblakov wrote:
> Oliver Hartkopp wrote:
>> P.B.Cheblakov wrote:
>>
>>> Hi!
>>>
>>> I have a some problem and need a help!
>>> We experiment with pulse device which is controlled via CAN.
>>> We use sja1000-based CAN-controller and BUG_ON take place periodically.
>>> I suppose that the pulse device generates breakthrough and sja1000
>>> receives can-frame with can_dlc greater than 8. And it causes a BUG_ON
>>> in can_rcv function (af_can.c):
>>> BUG_ON(skb->len != sizeof(struct can_frame) || cf->can_dlc > 8);
>>>
>> Hi Pavel,
>>
>> we already changed the BUG_ON() to WARN_ONCE() in Linux Mainline:
>>
>> http://git.kernel.org/?p=linux/kernel/git/davem/net-2.6.git;a=commitdiff;h=1758c0947605211ef953cc91d6bbdf847a21b822
>>
>> You may apply the patch to your Kernel also.
>>
> Oh, thanks for the link! I'll patch my Kernel!
> I saw some discussions about this problem earlier, but proposed solution
> wasn't good for me (and, I think, wasn't right).
As the above patch only turns the BUG_ON() into a WARN_ONCE() the received
frame is still dropped.
Please apply the attached patch to your sja1000.c to see, if we get strange
values out of the SJA1000 here. The attached patch also reduces the dlc to 8
if it's (illegally) greater than 8.
You might need to use the '-p ..' option of the tool 'patch' to apply this.
Do you have a 'real' Philips/NXP SJA1000 on your CEAxxx boards or is it a CAN
macro inside another FPGA/processor that only behaves like a SJA1000?
Best regards,
Oliver
ps. @Wolfgang: Should i send this attached patch also to netdev-ML?
diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
index 16d2ecd..988fa45 100644
--- a/drivers/net/can/sja1000/sja1000.c
+++ b/drivers/net/can/sja1000/sja1000.c
@@ -303,7 +303,18 @@ static void sja1000_rx(struct net_device *dev)
skb->protocol = htons(ETH_P_CAN);
fi = priv->read_reg(priv, REG_FI);
+
dlc = fi & 0x0F;
+ if (unlikely(dlc > 8)) {
+
+ static int print_dlc_err;
+
+ if (!print_dlc_err) {
+ dev_err(dev->dev.parent, "illegal dlc %d\n", dlc);
+ print_dlc_err = 1;
+ }
+ dlc = 8;
+ }
if (fi & FI_FF) {
/* extended frame format (EFF) */
_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core