imx28 rtcan flexcan system freezes
Hi all,
I use two rtcan flexcan on imx28-evk board.
If both rtcan devices receive a data at the same time, this cause a freeze. After investigation, i found that if I replace in flexcan_rx_interrupt these instructions :
- *(__be32 *)(cf->data + 0) =
- cpu_to_be32(flexcan_read(&mb->data[0]));
- *(__be32 *)(cf->data + 4) =
- cpu_to_be32(flexcan_read(&mb->data[1]));
by these
+ data0 = flexcan_read(&mb->data[0]);
+ data1 = flexcan_read(&mb->data[1]);
+
+ cf->data[3]=((data0 >> 0) & 0xFF) ; + cf->data[2]=((data0 >> 8) & 0xFF) ; + cf->data[1]=((data0 >> 16) & 0xFF) ; + cf->data[0]=((data0 >> 24) & 0xFF) ; + cf->data[7]=((data1 >> 0) & 0xFF) ; + cf->data[6]=((data1 >> 8) & 0xFF) ; + cf->data[5]=((data1 >> 16) & 0xFF) ; + cf->data[4]=((data1 >> 24) & 0xFF) ;
rtcan flexcan works perfectly.
is anyone know what is the problem with first instructions ?
My config : xenomai 2.6.3, linux 3.8.13,
Quoted 26 lines · Alexandre COFFIGNAL
Hi all,
I use two rtcan flexcan on imx28-evk board.
If both rtcan devices receive a data at the same time, this cause a freeze. After investigation, i found that if I replace in
flexcan_rx_interruptthese instructions :(quoted diff) +0
-4- *(__be32 *)(cf->data + 0) = - cpu_to_be32(flexcan_read(&mb->data[0])); - *(__be32 *)(cf->data + 4) = - cpu_to_be32(flexcan_read(&mb->data[1]));by these
(quoted diff) +11
-0+ data0 = flexcan_read(&mb->data[0]); + data1 = flexcan_read(&mb->data[1]); + + cf->data[3]=((data0 >> 0) & 0xFF) ; + cf->data[2]=((data0 >> 8) & 0xFF) ; + cf->data[1]=((data0 >> 16) & 0xFF) ; + cf->data[0]=((data0 >> 24) & 0xFF) ; + cf->data[7]=((data1 >> 0) & 0xFF) ; + cf->data[6]=((data1 >> 8) & 0xFF) ; + cf->data[5]=((data1 >> 16) & 0xFF) ; + cf->data[4]=((data1 >> 24) & 0xFF) ;
Quoted 2 lines
rtcan flexcan works perfectly.
is anyone know what is the problem with first instructions ?
Probably mb->data does not have the right alignment. Could you not arrange to get it properly aligned? Failing that, you should use put_unaligned instead of open coding it.
Signature · 1 line
Gilles.
Quoted 27 lines · Gilles Chanteperdrix
Quoted 26 lines · Alexandre COFFIGNAL
Hi all,
I use two rtcan flexcan on imx28-evk board.
If both rtcan devices receive a data at the same time, this cause a freeze. After investigation, i found that if I replace in
flexcan_rx_interruptthese instructions :(quoted diff) +0
-4- *(__be32 *)(cf->data + 0) = - cpu_to_be32(flexcan_read(&mb->data[0])); - *(__be32 *)(cf->data + 4) = - cpu_to_be32(flexcan_read(&mb->data[1]));by these
(quoted diff) +11
-0+ data0 = flexcan_read(&mb->data[0]); + data1 = flexcan_read(&mb->data[1]); + + cf->data[3]=((data0 >> 0) & 0xFF) ; + cf->data[2]=((data0 >> 8) & 0xFF) ; + cf->data[1]=((data0 >> 16) & 0xFF) ; + cf->data[0]=((data0 >> 24) & 0xFF) ; + cf->data[7]=((data1 >> 0) & 0xFF) ; + cf->data[6]=((data1 >> 8) & 0xFF) ; + cf->data[5]=((data1 >> 16) & 0xFF) ; + cf->data[4]=((data1 >> 24) & 0xFF) ;
Quoted 7 lines
Quoted 2 lines
rtcan flexcan works perfectly.
is anyone know what is the problem with first instructions ?Probably
mb->datadoes not have the right alignment. Could you not arrange to get it properly aligned? Failing that, you should useput_unalignedinstead of open coding it.
here structures used in flexcan driver, it seem to be aligned
/* Structure of the message buffer */
struct flexcan_mb {
u32 can_ctrl;
u32 can_id;
u32 data[2];
};/* Structure of the hardware registers */
struct flexcan_regs {
u32 mcr; /* 0x00 */
u32 ctrl; /* 0x04 */
u32 timer; /* 0x08 */
u32 _reserved1; /* 0x0c */
u32 rxgmask; /* 0x10 */
u32 rx14mask; /* 0x14 */
u32 rx15mask; /* 0x18 */
u32 ecr; /* 0x1c */
u32 esr; /* 0x20 */
u32 imask2; /* 0x24 */
u32 imask1; /* 0x28 */
u32 iflag2; /* 0x2c */
u32 iflag1; /* 0x30 */
u32 crl2; /* 0x34 */
u32 esr2; /* 0x38 */
u32 _reserved2[2];
u32 crcr; /* 0x44 */
u32 rxfgmask; /* 0x48 */
u32 rxfir; /* 0x4c */
u32 _reserved3[12];
struct flexcan_mb cantxfg[64];
};Quoted 9 lines · Alexandre COFFIGNAL
Quoted 9 lines
Quoted 9 lines
(quoted diff) +8
-0+ cf->data[3]=((data0 >> 0) & 0xFF) ; + cf->data[2]=((data0 >> 8) & 0xFF) ; + cf->data[1]=((data0 >> 16) & 0xFF) ; + cf->data[0]=((data0 >> 24) & 0xFF) ; + cf->data[7]=((data1 >> 0) & 0xFF) ; + cf->data[6]=((data1 >> 8) & 0xFF) ; + cf->data[5]=((data1 >> 16) & 0xFF) ; + cf->data[4]=((data1 >> 24) & 0xFF) ;
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
rtcan flexcan works perfectly.
is anyone know what is the problem with first instructions ?Probably
mb->datadoes not have the right alignment. Could you not arrange to get it properly aligned? Failing that, you should useput_unalignedinstead of open coding it.here structures used in flexcan driver, it seem to be aligned
I am talking about the alignment of cf->data, since obviously, that is the one which is causing problems.
Signature · 1 line
Gilles.
Quoted 12 lines · Gilles Chanteperdrix
Quoted 11 lines · Alexandre COFFIGNAL
Quoted 11 lines
Quoted 11 lines
(quoted diff) +8
-0+ cf->data[3]=((data0 >> 0) & 0xFF) ; + cf->data[2]=((data0 >> 8) & 0xFF) ; + cf->data[1]=((data0 >> 16) & 0xFF) ; + cf->data[0]=((data0 >> 24) & 0xFF) ; + cf->data[7]=((data1 >> 0) & 0xFF) ; + cf->data[6]=((data1 >> 8) & 0xFF) ; + cf->data[5]=((data1 >> 16) & 0xFF) ; + cf->data[4]=((data1 >> 24) & 0xFF) ;rtcan flexcan works perfectly.
is anyone know what is the problem with first instructions ?
Quoted 10 lines
Quoted 6 lines
Quoted 5 lines
Probably
mb->datadoes not have the right alignment. Could you not arrange to get it properly aligned? Failing that, you should useput_unalignedinstead of open coding it.here structures used in flexcan driver, it seem to be aligned
I am talking about the alignment of
cf->data, since obviously, that is the one which is causing problems.
Thank a lot, put_unaligned fix this issue if you want, i can send a path
Quoted 19 lines · Alexandre COFFIGNAL
Quoted 17 lines · Gilles Chanteperdrix
Quoted 16 lines · Alexandre COFFIGNAL
Quoted 16 lines
Quoted 11 lines
(quoted diff) +8
-0+ cf->data[3]=((data0 >> 0) & 0xFF) ; + cf->data[2]=((data0 >> 8) & 0xFF) ; + cf->data[1]=((data0 >> 16) & 0xFF) ; + cf->data[0]=((data0 >> 24) & 0xFF) ; + cf->data[7]=((data1 >> 0) & 0xFF) ; + cf->data[6]=((data1 >> 8) & 0xFF) ; + cf->data[5]=((data1 >> 16) & 0xFF) ; + cf->data[4]=((data1 >> 24) & 0xFF) ;rtcan flexcan works perfectly.
is anyone know what is the problem with first instructions ?Probably
mb->datadoes not have the right alignment. Could you not arrange to get it properly aligned? Failing that, you should useput_unalignedinstead of open coding it.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
here structures used in flexcan driver, it seem to be aligned
I am talking about the alignment of
cf->data, since obviously, that is the one which is causing problems.Thank a lot,
put_unalignedfix this issue if you want, i can send a path
The other solution (getting cf->data to be properly aligned) would be more efficient, why is not it possible to get cf->data properly aligned?
Signature · 1 line
Gilles.
Quoted 22 lines · Gilles Chanteperdrix
Quoted 21 lines · Alexandre COFFIGNAL
Quoted 19 lines · Gilles Chanteperdrix
Quoted 17 lines · Alexandre COFFIGNAL
Quoted 9 lines
Quoted 9 lines
(quoted diff) +8
-0+ cf->data[3]=((data0 >> 0) & 0xFF) ; + cf->data[2]=((data0 >> 8) & 0xFF) ; + cf->data[1]=((data0 >> 16) & 0xFF) ; + cf->data[0]=((data0 >> 24) & 0xFF) ; + cf->data[7]=((data1 >> 0) & 0xFF) ; + cf->data[6]=((data1 >> 8) & 0xFF) ; + cf->data[5]=((data1 >> 16) & 0xFF) ; + cf->data[4]=((data1 >> 24) & 0xFF) ;Quoted 7 lines
Quoted 2 lines
rtcan flexcan works perfectly.
is anyone know what is the problem with first instructions ?Probably
mb->datadoes not have the right alignment. Could you not arrange to get it properly aligned? Failing that, you should useput_unalignedinstead of open coding it.here structures used in flexcan driver, it seem to be aligned
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
I am talking about the alignment of
cf->data, since obviously, that is the one which is causing problems.Thank a lot,
put_unalignedfix this issue if you want, i can send a pathThe other solution (getting
cf->datato be properly aligned) would be more efficient, why is not it possible to getcf->dataproperly aligned?
I think, i can't get cf->data to be properly aligned because "cf" is receive internal frame representation within the ring buffer of a struct rtcan_socket and struct rtcan_rb_frame is a generic structure used in all rtcan drivers .
Quoted 31 lines · Alexandre COFFIGNAL
Quoted 29 lines · Gilles Chanteperdrix
Quoted 27 lines · Alexandre COFFIGNAL
Quoted 17 lines · Gilles Chanteperdrix
Quoted 16 lines · Alexandre COFFIGNAL
Quoted 16 lines
Quoted 11 lines
(quoted diff) +8
-0+ cf->data[3]=((data0 >> 0) & 0xFF) ; + cf->data[2]=((data0 >> 8) & 0xFF) ; + cf->data[1]=((data0 >> 16) & 0xFF) ; + cf->data[0]=((data0 >> 24) & 0xFF) ; + cf->data[7]=((data1 >> 0) & 0xFF) ; + cf->data[6]=((data1 >> 8) & 0xFF) ; + cf->data[5]=((data1 >> 16) & 0xFF) ; + cf->data[4]=((data1 >> 24) & 0xFF) ;rtcan flexcan works perfectly.
is anyone know what is the problem with first instructions ?Probably
mb->datadoes not have the right alignment. Could you not arrange to get it properly aligned? Failing that, you should useput_unalignedinstead of open coding it.Quoted 6 lines
Quoted 1 line
here structures used in flexcan driver, it seem to be aligned
I am talking about the alignment of
cf->data, since obviously, that is the one which is causing problems.Thank a lot,
put_unalignedfix this issue if you want, i can send a path
Quoted 7 lines
Quoted 3 lines
The other solution (getting
cf->datato be properly aligned) would be more efficient, why is not it possible to getcf->dataproperly aligned?I think, i can't get
cf->datato be properly aligned because "cf" is receive internal frame representation within the ring buffer of a structrtcan_socketand structrtcan_rb_frameis a generic structure used in all rtcan drivers .
Well, if you fix rtcan_rb_frame to be aligned, it will be aligned for all drivers, so that looks like a worthwile improvement...
Signature · 1 line
Gilles.
Quoted 35 lines · Gilles Chanteperdrix
Quoted 34 lines · Alexandre COFFIGNAL
Quoted 32 lines · Gilles Chanteperdrix
Quoted 19 lines · Alexandre COFFIGNAL
Quoted 17 lines · Gilles Chanteperdrix
Quoted 16 lines · Alexandre COFFIGNAL
Quoted 16 lines
Quoted 11 lines
(quoted diff) +8
-0+ cf->data[3]=((data0 >> 0) & 0xFF) ; + cf->data[2]=((data0 >> 8) & 0xFF) ; + cf->data[1]=((data0 >> 16) & 0xFF) ; + cf->data[0]=((data0 >> 24) & 0xFF) ; + cf->data[7]=((data1 >> 0) & 0xFF) ; + cf->data[6]=((data1 >> 8) & 0xFF) ; + cf->data[5]=((data1 >> 16) & 0xFF) ; + cf->data[4]=((data1 >> 24) & 0xFF) ;rtcan flexcan works perfectly.
is anyone know what is the problem with first instructions ?Probably
mb->datadoes not have the right alignment. Could you not arrange to get it properly aligned? Failing that, you should useput_unalignedinstead of open coding it.Quoted 8 lines
Quoted 6 lines
Quoted 1 line
here structures used in flexcan driver, it seem to be aligned
I am talking about the alignment of
cf->data, since obviously, that is the one which is causing problems.Thank a lot,
put_unalignedfix this issue if you want, i can send a pathThe other solution (getting
cf->datato be properly aligned) would be more efficient, why is not it possible to getcf->dataproperly aligned?
Quoted 9 lines
Quoted 4 lines
I think, i can't get
cf->datato be properly aligned because "cf" is receive internal frame representation within the ring buffer of a structrtcan_socketand structrtcan_rb_frameis a generic structure used in all rtcan drivers .Well, if you fix
rtcan_rb_frameto be aligned, it will be aligned for all drivers, so that looks like a worthwile improvement...
Wolfgang, what do you think? Should we change the alignment of rtcan_rb_frame::data, or use put_unaligned on ARM?
Signature · 1 line
Gilles.
Hi Gilles,
On Thu, 23 Jan 2014 11:04:44 +0100, Gilles Chanteperdrix
Quoted 34 lines · <[email protected]> wrote:
Quoted 31 lines · Gilles Chanteperdrix
Quoted 29 lines · Alexandre COFFIGNAL
Quoted 25 lines · Gilles Chanteperdrix
Quoted 23 lines · Alexandre COFFIGNAL
Quoted 19 lines · Gilles Chanteperdrix
Quoted 17 lines · Alexandre COFFIGNAL
Quoted 17 lines
Quoted 17 lines
(quoted diff) +8
-0+ cf->data[3]=((data0 >> 0) & 0xFF) ; + cf->data[2]=((data0 >> 8) & 0xFF) ; + cf->data[1]=((data0 >> 16) & 0xFF) ; + cf->data[0]=((data0 >> 24) & 0xFF) ; + cf->data[7]=((data1 >> 0) & 0xFF) ; + cf->data[6]=((data1 >> 8) & 0xFF) ; + cf->data[5]=((data1 >> 16) & 0xFF) ; + cf->data[4]=((data1 >> 24) & 0xFF) ;
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
rtcan flexcan works perfectly.
is anyone know what is the problem with first instructions ?
Probably
mb->datadoes not have the right alignment. Could you
not
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
arrange to get it properly aligned? Failing that, you should use
put_unalignedinstead of open coding it.
How are unaligned accesses handled on your system? Alexandre,
what does "cat /proc/cpu/alignment" report? Aligned access
would be better, I agree.
Quoted 54 lines
Quoted 40 lines
Quoted 39 lines
Quoted 26 lines
Quoted 18 lines
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
here structures used in flexcan driver, it seem to be aligned
Quoted 9 lines
I am talking about the alignment of
cf->data, since obviously, thatis
the one which is causing problems.
Quoted 5 lines
Thank a lot,
put_unalignedfix this issue if you want, i can send apath
Quoted 7 lines
The other solution (getting
cf->datato be properly aligned) would bemore efficient, why is not it possible to get
cf->dataproperlyaligned?
I think, i can't get
cf->datato be properly aligned because "cf" isreceive internal frame representation within the ring buffer
of a struct
rtcan_socketand structrtcan_rb_frameis a genericQuoted 11 lines
Quoted 1 line
structure used in all rtcan drivers .
Well, if you fix
rtcan_rb_frameto be aligned, it will be aligned forall drivers, so that looks like a worthwile improvement...
Quoted 3 lines
Wolfgang, what do you think? Should we change the alignment of
rtcan_rb_frame::data, or useput_unalignedon ARM?
I realized the mail and wonder why this problem does not show up with
vanilla
Linux. Maybe we need to port over some patch from there. I will have a
closer
look this even or over the weekend.
Wolfgang.
Quoted 5 lines · Wolfgang Grandegger
How are unaligned accesses handled on your system? Alexandre,
what does "cat
/proc/cpu/alignment" report? Aligned accesswould be better, I agree.
The imx28 can not support unaligned accesses in hardware. The unaligned access causes an exception, /proc/cpu/alignment thus only allow choosing how the exception is handled.
Quoted 9 lines
Quoted 3 lines
Wolfgang, what do you think? Should we change the alignment of
rtcan_rb_frame::data, or useput_unalignedon ARM?I realized the mail and wonder why this problem does not show up with
vanilla
Vanilla handles the alignment trap by emulating the faulting instruction. Last time I checked, there were some problems related to running the emulation over xenomai domain, though looking at the code now, I see nothing which would prevent us from doing it.
Signature · 1 line
Gilles.
On Thu, 23 Jan 2014 13:05:40 +0100, Gilles Chanteperdrix
Quoted 46 lines · <[email protected]> wrote:
Quoted 9 lines · Wolfgang Grandegger
How are unaligned accesses handled on your system? Alexandre,
what does "cat
/proc/cpu/alignment" report? Aligned accesswould be better, I agree.
The imx28 can not support unaligned accesses in hardware. The unaligned
access causes an exception,
/proc/cpu/alignmentthus only allow choosinghow the exception is handled.
Quoted 12 lines
Quoted 5 lines
Wolfgang, what do you think? Should we change the alignment of
rtcan_rb_frame::data, or useput_unalignedon ARM?Quoted 5 lines
I realized the mail and wonder why this problem does not show up with
vanilla
Quoted 7 lines
Vanilla handles the alignment trap by emulating the faulting
instruction. Last time I checked, there were some problems related to
running the emulation over xenomai domain, though looking at the code
now, I see nothing which would prevent us from doing it.
Yes, I know. But the handling of unaligned accesses via trap handler must
be
enabled by the user and I'm not aware that this is needed for vanilla
Linux.
Wolfgang.
Quoted 10 lines · Wolfgang Grandegger
Quoted 7 lines
Vanilla handles the alignment trap by emulating the faulting
instruction. Last time I checked, there were some problems related to
running the emulation over xenomai domain, though looking at the code
now, I see nothing which would prevent us from doing it.
Quoted 7 lines
Yes, I know. But the handling of unaligned accesses via trap handler must
be
enabled by the user and I'm not aware that this is needed for vanilla
Linux.
I remember reading on the LAKML that the alignment trap is needed for kernel operations, notably for the IP stack.
Signature · 1 line
Gilles.
Quoted 70 lines · Wolfgang Grandegger
Hi Gilles,
On Thu, 23 Jan 2014 11:04:44 +0100, Gilles Chanteperdrix
Quoted 16 lines · <[email protected]> wrote:
Quoted 15 lines · Gilles Chanteperdrix
Quoted 14 lines · Alexandre COFFIGNAL
Quoted 13 lines · Gilles Chanteperdrix
Quoted 12 lines · Alexandre COFFIGNAL
Quoted 11 lines · Gilles Chanteperdrix
Quoted 10 lines · Alexandre COFFIGNAL
Quoted 10 lines
Quoted 10 lines
(quoted diff) +8
-0+ cf->data[3]=((data0 >> 0) & 0xFF) ; + cf->data[2]=((data0 >> 8) & 0xFF) ; + cf->data[1]=((data0 >> 16) & 0xFF) ; + cf->data[0]=((data0 >> 24) & 0xFF) ; + cf->data[7]=((data1 >> 0) & 0xFF) ; + cf->data[6]=((data1 >> 8) & 0xFF) ; + cf->data[5]=((data1 >> 16) & 0xFF) ; + cf->data[4]=((data1 >> 24) & 0xFF) ;rtcan flexcan works perfectly.
is anyone know what is the problem with first instructions ?Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Probably
mb->datadoes not have the right alignment. Could younot
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
arrange to get it properly aligned? Failing that, you should use
put_unalignedinstead of open coding it.How are unaligned accesses handled on your system? Alexandre,
what does "cat
/proc/cpu/alignment" report? Aligned accesswould be better, I agree.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
here structures used in flexcan driver, it seem to be aligned
I am talking about the alignment of
cf->data, since obviously, that is
the one which is causing problems.Thank a lot,
put_unalignedfix this issue if you want, i can send a pathThe other solution (getting
cf->datato be properly aligned) would be more efficient, why is not it possible to getcf->dataproperly aligned?Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
I think, i can't get
cf->datato be properly aligned because "cf" is receive internal frame representation within the ring buffer of a structrtcan_socketand structrtcan_rb_frameis a generic structure used in all rtcan drivers .Well, if you fix
rtcan_rb_frameto be aligned, it will be aligned for all drivers, so that looks like a worthwile improvement...Wolfgang, what do you think? Should we change the alignment of
rtcan_rb_frame::data, or useput_unalignedon ARM?I realized the mail and wonder why this problem does not show up with
vanilla
Linux. Maybe we need to port over some patch from there. I will have a
closer
look this even or over the weekend.
Quoted 8 lines
Wolfgang.
_______________________________________________
Xenomai mailing list
[email protected]
http://www.xenomai.org/mailman/listinfo/xenomai
Hi,
"cat /proc/cpu/alignment" report
User: 0 System: 0 Skipped: 0 Half: 0 Word: 0 DWord: 0 Multi: 0 User faults: 0 (ignored)
something wrong with that ?
Alexandre.
Quoted 5 lines · Gilles Chanteperdrix
Vanilla handles the alignment trap by emulating the faulting instruction. Last time I checked, there were some problems related to running the emulation over xenomai domain, though looking at the code now, I see nothing which would prevent us from doing it.
Correction: the emulation code would require changing probe_kernel_address to be able to run over non-linux stacks.
Signature · 1 line
Gilles.
Quoted 95 lines · Alexandre COFFIGNAL
Quoted 70 lines · Wolfgang Grandegger
Hi Gilles,
On Thu, 23 Jan 2014 11:04:44 +0100, Gilles Chanteperdrix
Quoted 16 lines · <[email protected]> wrote:
Quoted 15 lines · Gilles Chanteperdrix
Quoted 14 lines · Alexandre COFFIGNAL
Quoted 13 lines · Gilles Chanteperdrix
Quoted 12 lines · Alexandre COFFIGNAL
Quoted 11 lines · Gilles Chanteperdrix
Quoted 10 lines · Alexandre COFFIGNAL
Quoted 10 lines
Quoted 10 lines
+ cf->data[3]=((data0 >> 0) &
0xFF) ;(quoted diff) +7
-0+ cf->data[2]=((data0 >> 8) & 0xFF) ; + cf->data[1]=((data0 >> 16) & 0xFF) ; + cf->data[0]=((data0 >> 24) & 0xFF) ; + cf->data[7]=((data1 >> 0) & 0xFF) ; + cf->data[6]=((data1 >> 8) & 0xFF) ; + cf->data[5]=((data1 >> 16) & 0xFF) ; + cf->data[4]=((data1 >> 24) & 0xFF) ;rtcan flexcan works perfectly.
is anyone know what is the problem with first instructions ?Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Probably
mb->datadoes not have the right alignment. Could younot
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
arrange to get it properly aligned? Failing that, you should use
put_unalignedinstead of open coding it.How are unaligned accesses handled on your system? Alexandre,
what does "cat
/proc/cpu/alignment" report? Aligned accesswould be better, I agree.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
here structures used in flexcan driver, it seem to be aligned
I am talking about the alignment of
cf->data, since obviously, that is
the one which is causing problems.Thank a lot,
put_unalignedfix this issue if you want, i can send a pathThe other solution (getting
cf->datato be properly aligned) would be more efficient, why is not it possible to getcf->dataproperly aligned?Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
I think, i can't get
cf->datato be properly aligned because "cf" is receive internal frame representation within the ring buffer of a structrtcan_socketand structrtcan_rb_frameis a generic structure used in all rtcan drivers .Well, if you fix
rtcan_rb_frameto be aligned, it will be aligned for all drivers, so that looks like a worthwile improvement...Wolfgang, what do you think? Should we change the alignment of
rtcan_rb_frame::data, or useput_unalignedon ARM?I realized the mail and wonder why this problem does not show up with
vanilla
Linux. Maybe we need to port over some patch from there. I will have a
closer
look this even or over the weekend.
Quoted 8 lines
Wolfgang.
_______________________________________________
Xenomai mailing list
[email protected]
http://www.xenomai.org/mailman/listinfo/xenomaiHi,
"cat
/proc/cpu/alignment" reportUser: 0 System: 0 Skipped: 0 Half: 0 Word: 0 DWord: 0 Multi: 0 User faults: 0 (ignored)something wrong with that ?
Quoted 7 lines
Alexandre.
_______________________________________________
Xenomai mailing list
[email protected]
http://www.xenomai.org/mailman/listinfo/xenomai
For your information :
Actualy my kernel is linux 3.8.13 vanilla from https://www.kernel.org/pub/linux/kernel/v3.x/"
with Adeos/Xenomai Real-time patch 2.6.3 from download.gna.org/xenomai/stable/xenomai-2.6.3.tar.bz2
Quoted 31 lines · Alexandre COFFIGNAL
Quoted 29 lines · Gilles Chanteperdrix
Quoted 27 lines · Alexandre COFFIGNAL
Quoted 17 lines · Gilles Chanteperdrix
Quoted 16 lines · Alexandre COFFIGNAL
Quoted 16 lines
Quoted 11 lines
(quoted diff) +8
-0+ cf->data[3]=((data0 >> 0) & 0xFF) ; + cf->data[2]=((data0 >> 8) & 0xFF) ; + cf->data[1]=((data0 >> 16) & 0xFF) ; + cf->data[0]=((data0 >> 24) & 0xFF) ; + cf->data[7]=((data1 >> 0) & 0xFF) ; + cf->data[6]=((data1 >> 8) & 0xFF) ; + cf->data[5]=((data1 >> 16) & 0xFF) ; + cf->data[4]=((data1 >> 24) & 0xFF) ;rtcan flexcan works perfectly.
is anyone know what is the problem with first instructions ?Probably
mb->datadoes not have the right alignment. Could you not arrange to get it properly aligned? Failing that, you should useput_unalignedinstead of open coding it.Quoted 6 lines
Quoted 1 line
here structures used in flexcan driver, it seem to be aligned
I am talking about the alignment of
cf->data, since obviously, that is the one which is causing problems.Thank a lot,
put_unalignedfix this issue if you want, i can send a path
Quoted 7 lines
Quoted 3 lines
The other solution (getting
cf->datato be properly aligned) would be more efficient, why is not it possible to getcf->dataproperly aligned?I think, i can't get
cf->datato be properly aligned because "cf" is receive internal frame representation within the ring buffer of a structrtcan_socketand structrtcan_rb_frameis a generic structure used in all rtcan drivers .
Hi Alexandr,
Could you try the following patch?
(quoted diff) +0 -0
b/ksrc/drivers/can/rtcan_socket.h
index e0a395d..8984121 100644
ksrc/drivers/can/rtcan_socket.h +1 -0
@@ -77,6 +77,7 @@ struct rtcan_rb_frame {* existence of a timestamp is indicated by the RTCAN_HAS_TIMESTAMP * bit. */ unsigned char can_dlc; +unsigned short pad;/* Data bytes */ uint8_t data[8 ];
Regards.
Signature · 1 line
Gilles.
Quoted 36 lines · Gilles Chanteperdrix
Quoted 35 lines · Alexandre COFFIGNAL
Quoted 33 lines · Gilles Chanteperdrix
Quoted 19 lines · Alexandre COFFIGNAL
Quoted 17 lines · Gilles Chanteperdrix
Quoted 16 lines · Alexandre COFFIGNAL
Quoted 16 lines
Quoted 11 lines
(quoted diff) +8
-0+ cf->data[3]=((data0 >> 0) & 0xFF) ; + cf->data[2]=((data0 >> 8) & 0xFF) ; + cf->data[1]=((data0 >> 16) & 0xFF) ; + cf->data[0]=((data0 >> 24) & 0xFF) ; + cf->data[7]=((data1 >> 0) & 0xFF) ; + cf->data[6]=((data1 >> 8) & 0xFF) ; + cf->data[5]=((data1 >> 16) & 0xFF) ; + cf->data[4]=((data1 >> 24) & 0xFF) ;rtcan flexcan works perfectly.
is anyone know what is the problem with first instructions ?Probably
mb->datadoes not have the right alignment. Could you not arrange to get it properly aligned? Failing that, you should useput_unalignedinstead of open coding it.Quoted 9 lines
Quoted 6 lines
Quoted 1 line
here structures used in flexcan driver, it seem to be aligned
I am talking about the alignment of
cf->data, since obviously, that is the one which is causing problems.Thank a lot,
put_unalignedfix this issue if you want, i can send a pathThe other solution (getting
cf->datato be properly aligned) would be more efficient, why is not it possible to getcf->dataproperly aligned?
Quoted 7 lines
Quoted 4 lines
I think, i can't get
cf->datato be properly aligned because "cf" is receive internal frame representation within the ring buffer of a structrtcan_socketand structrtcan_rb_frameis a generic structure used in all rtcan drivers .Well, if you fix
rtcan_rb_frameto be aligned, it will be aligned for all drivers, so that looks like a worthwile improvement...
I had a closer look. The CAN message (frame) queuing is optimized for size to get as much as possible messages into the queue. Therefore the CAN data are copied using memcpy, but only the real bytes. Directly behind the real data is the 64 bit timestamp, if requested, which is also not aligned. Therefore I suggest to use memcpy or byte accesses in the flexcan driver as well. If this was a good decision is another question.
Wolfgang.
Quoted 45 lines · Wolfgang Grandegger
Quoted 36 lines · Gilles Chanteperdrix
Quoted 35 lines · Alexandre COFFIGNAL
Quoted 33 lines · Gilles Chanteperdrix
Quoted 19 lines · Alexandre COFFIGNAL
Quoted 17 lines · Gilles Chanteperdrix
Quoted 16 lines · Alexandre COFFIGNAL
Quoted 16 lines
Quoted 11 lines
(quoted diff) +8
-0+ cf->data[3]=((data0 >> 0) & 0xFF) ; + cf->data[2]=((data0 >> 8) & 0xFF) ; + cf->data[1]=((data0 >> 16) & 0xFF) ; + cf->data[0]=((data0 >> 24) & 0xFF) ; + cf->data[7]=((data1 >> 0) & 0xFF) ; + cf->data[6]=((data1 >> 8) & 0xFF) ; + cf->data[5]=((data1 >> 16) & 0xFF) ; + cf->data[4]=((data1 >> 24) & 0xFF) ;rtcan flexcan works perfectly.
is anyone know what is the problem with first instructions ?Probably
mb->datadoes not have the right alignment. Could you not arrange to get it properly aligned? Failing that, you should useput_unalignedinstead of open coding it.Quoted 9 lines
Quoted 6 lines
Quoted 1 line
here structures used in flexcan driver, it seem to be aligned
I am talking about the alignment of
cf->data, since obviously, that is the one which is causing problems.Thank a lot,
put_unalignedfix this issue if you want, i can send a pathThe other solution (getting
cf->datato be properly aligned) would be more efficient, why is not it possible to getcf->dataproperly aligned?Quoted 7 lines
Quoted 4 lines
I think, i can't get
cf->datato be properly aligned because "cf" is receive internal frame representation within the ring buffer of a structrtcan_socketand structrtcan_rb_frameis a generic structure used in all rtcan drivers .Well, if you fix
rtcan_rb_frameto be aligned, it will be aligned for all drivers, so that looks like a worthwile improvement...
Quoted 6 lines
I had a closer look. The CAN message (frame) queuing is optimized for size to get as much as possible messages into the queue. Therefore the CAN data are copied using memcpy, but only the real bytes. Directly behind the real data is the 64 bit timestamp, if requested, which is also not aligned. Therefore I suggest to use memcpy or byte accesses in the flexcan driver as well. If this was a good decision is another question.
Aligning the data begining costs 2 bytes by struct rtcan_rb_frame. How many such structures are there for a typical driver?
Signature · 1 line
Gilles.
Quoted 53 lines · Gilles Chanteperdrix
Quoted 45 lines · Wolfgang Grandegger
Quoted 36 lines · Gilles Chanteperdrix
Quoted 35 lines · Alexandre COFFIGNAL
Quoted 33 lines · Gilles Chanteperdrix
Quoted 19 lines · Alexandre COFFIGNAL
Quoted 17 lines · Gilles Chanteperdrix
Quoted 16 lines · Alexandre COFFIGNAL
Quoted 16 lines
Quoted 11 lines
(quoted diff) +8
-0+ cf->data[3]=((data0 >> 0) & 0xFF) ; + cf->data[2]=((data0 >> 8) & 0xFF) ; + cf->data[1]=((data0 >> 16) & 0xFF) ; + cf->data[0]=((data0 >> 24) & 0xFF) ; + cf->data[7]=((data1 >> 0) & 0xFF) ; + cf->data[6]=((data1 >> 8) & 0xFF) ; + cf->data[5]=((data1 >> 16) & 0xFF) ; + cf->data[4]=((data1 >> 24) & 0xFF) ;rtcan flexcan works perfectly.
is anyone know what is the problem with first instructions ?Probably
mb->datadoes not have the right alignment. Could you not arrange to get it properly aligned? Failing that, you should useput_unalignedinstead of open coding it.Quoted 9 lines
Quoted 6 lines
Quoted 1 line
here structures used in flexcan driver, it seem to be aligned
I am talking about the alignment of
cf->data, since obviously, that is the one which is causing problems.Thank a lot,
put_unalignedfix this issue if you want, i can send a pathThe other solution (getting
cf->datato be properly aligned) would be more efficient, why is not it possible to getcf->dataproperly aligned?Quoted 7 lines
Quoted 4 lines
I think, i can't get
cf->datato be properly aligned because "cf" is receive internal frame representation within the ring buffer of a structrtcan_socketand structrtcan_rb_frameis a generic structure used in all rtcan drivers .Well, if you fix
rtcan_rb_frameto be aligned, it will be aligned for all drivers, so that looks like a worthwile improvement...Quoted 6 lines
I had a closer look. The CAN message (frame) queuing is optimized for size to get as much as possible messages into the queue. Therefore the CAN data are copied using memcpy, but only the real bytes. Directly behind the real data is the 64 bit timestamp, if requested, which is also not aligned. Therefore I suggest to use memcpy or byte accesses in the flexcan driver as well. If this was a good decision is another question.
Quoted 2 lines
Aligning the data begining costs 2 bytes by struct
rtcan_rb_frame. How many such structures are there for a typical driver?
Any message in the queue will require two bytes more. I did not say that optimizing for size is necessary, but that's how it was implemented long time ago. And I do not see a need to break that just because of the Flexcan driver.
Wolfgang.
Quoted 2 lines
Quoted 54 lines · Wolfgang Grandegger
Quoted 53 lines · Gilles Chanteperdrix
Quoted 51 lines · Wolfgang Grandegger
Quoted 36 lines · Gilles Chanteperdrix
Quoted 35 lines · Alexandre COFFIGNAL
Quoted 33 lines · Gilles Chanteperdrix
Quoted 19 lines · Alexandre COFFIGNAL
Quoted 17 lines · Gilles Chanteperdrix
Quoted 16 lines · Alexandre COFFIGNAL
Quoted 16 lines
Quoted 11 lines
(quoted diff) +8
-0+ cf->data[3]=((data0 >> 0) & 0xFF) ; + cf->data[2]=((data0 >> 8) & 0xFF) ; + cf->data[1]=((data0 >> 16) & 0xFF) ; + cf->data[0]=((data0 >> 24) & 0xFF) ; + cf->data[7]=((data1 >> 0) & 0xFF) ; + cf->data[6]=((data1 >> 8) & 0xFF) ; + cf->data[5]=((data1 >> 16) & 0xFF) ; + cf->data[4]=((data1 >> 24) & 0xFF) ;rtcan flexcan works perfectly.
is anyone know what is the problem with first instructions ?Probably
mb->datadoes not have the right alignment. Could you not arrange to get it properly aligned? Failing that, you should useput_unalignedinstead of open coding it.Quoted 9 lines
Quoted 6 lines
Quoted 1 line
here structures used in flexcan driver, it seem to be aligned
I am talking about the alignment of
cf->data, since obviously, that is the one which is causing problems.Thank a lot,
put_unalignedfix this issue if you want, i can send a pathThe other solution (getting
cf->datato be properly aligned) would be more efficient, why is not it possible to getcf->dataproperly aligned?Quoted 7 lines
Quoted 4 lines
I think, i can't get
cf->datato be properly aligned because "cf" is receive internal frame representation within the ring buffer of a structrtcan_socketand structrtcan_rb_frameis a generic structure used in all rtcan drivers .Well, if you fix
rtcan_rb_frameto be aligned, it will be aligned for all drivers, so that looks like a worthwile improvement...I had a closer look. The CAN message (frame) queuing is optimized for size to get as much as possible messages into the queue. Therefore the CAN data are copied using memcpy, but only the real bytes. Directly behind the real data is the 64 bit timestamp, if requested, which is also not aligned. Therefore I suggest to use memcpy or byte accesses in the flexcan driver as well. If this was a good decision is another question.
Quoted 7 lines
Quoted 2 lines
Aligning the data begining costs 2 bytes by struct
rtcan_rb_frame. How many such structures are there for a typical driver?Any message in the queue will require two bytes more. I did not say that optimizing for size is necessary, but that's how it was implemented long time ago. And I do not see a need to break that just because of the Flexcan driver.
IMO, it is not just for the flexcan driver, it will avoid unaligned accesses for all drivers which access data 4 bytes at a time. And I do not think it "breaks" anything. What I do not know is:
- how many struct rtcan_rb_frame are typically in use? If only a few, then adding 2 bytes should not be a problem.
- do all drivers access data 4 bytes at a time? or only the flexcan driver?
Regards.
Signature · 1 line
Gilles.
On Sun, 26 Jan 2014 21:56:10 +0100, Gilles Chanteperdrix
Quoted 42 lines · <[email protected]> wrote:
Quoted 39 lines · Wolfgang Grandegger
Quoted 37 lines · Gilles Chanteperdrix
Quoted 35 lines · Wolfgang Grandegger
Quoted 33 lines · Gilles Chanteperdrix
Quoted 31 lines · Alexandre COFFIGNAL
Quoted 27 lines · Gilles Chanteperdrix
Quoted 25 lines · Alexandre COFFIGNAL
Quoted 21 lines · Gilles Chanteperdrix
Quoted 19 lines · Alexandre COFFIGNAL
Quoted 19 lines
Quoted 19 lines
(quoted diff) +8
-0+ cf->data[3]=((data0 >> 0) & 0xFF) ; + cf->data[2]=((data0 >> 8) & 0xFF) ; + cf->data[1]=((data0 >> 16) & 0xFF) ; + cf->data[0]=((data0 >> 24) & 0xFF) ; + cf->data[7]=((data1 >> 0) & 0xFF) ; + cf->data[6]=((data1 >> 8) & 0xFF) ; + cf->data[5]=((data1 >> 16) & 0xFF) ; + cf->data[4]=((data1 >> 24) & 0xFF) ;rtcan flexcan works perfectly.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
is anyone know what is the problem with first instructions ?
Probably
mb->datadoes not have the right alignment. Could younot
arrange to get it properly aligned? Failing that, you should
use
Quoted 14 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 7 lines
Quoted 5 lines
put_unalignedinstead of open coding it.here structures used in flexcan driver, it seem to be aligned
I am talking about the alignment of
cf->data, since obviously,that is
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
the one which is causing problems.
Thank a lot,
put_unalignedfix this issue if you want, i can send
a
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
path
The other solution (getting
cf->datato be properly aligned) wouldbe
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
more efficient, why is not it possible to get
cf->dataproperlyaligned?
I think, i can't get
cf->datato be properly aligned because "cf"
is
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
receive internal frame representation within the ring buffer
of a struct
rtcan_socketand structrtcan_rb_frameis a genericstructure used in all rtcan drivers .
Well, if you fix
rtcan_rb_frameto be aligned, it will be aligned
for
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
all drivers, so that looks like a worthwile improvement...
I had a closer look. The CAN message (frame) queuing is optimized for
size to get as much as possible messages into the queue. Therefore
the
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
CAN data are copied using memcpy, but only the real bytes. Directly
behind the real data is the 64 bit timestamp, if requested, which is
also not aligned. Therefore I suggest to use memcpy or byte accesses
in
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
the flexcan driver as well. If this was a good decision is another
question.
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Aligning the data begining costs 2 bytes by struct
rtcan_rb_frame. Howmany such structures are there for a typical driver?
Any message in the queue will require two bytes more. I did not say
that
Quoted 1 line
Quoted 1 line
optimizing for size is necessary, but that's how it was implemented
long
Quoted 11 lines
Quoted 3 lines
time ago. And I do not see a need to break that just because of the
Flexcan driver.
IMO, it is not just for the flexcan driver, it will avoid unaligned
accesses for all drivers which access data 4 bytes at a time. And I do
not think it "breaks" anything. What I do not know is:
But it's just the Flexcan driver which is doing unaligned accesses.
Quoted 3 lines
- how many struct
rtcan_rb_frameare typically in use? If only a few,then adding 2 bytes should not be a problem.
This depends on the size of the queue. But if the message size changes
it will also change run-time behaviour because less messages will fit
into the queue. That's what I'm more concerned about than the extra
2 bytes.
Quoted 1 line
- do all drivers access data 4 bytes at a time? or only the flexcan
driver?
No, as far as I have seen only the Flexan driver. But I need to check.
Wolfgang.
Quoted 10 lines · Wolfgang Grandegger
On Sun, 26 Jan 2014 21:56:10 +0100, Gilles Chanteperdrix
Quoted 5 lines
IMO, it is not just for the flexcan driver, it will avoid unaligned
accesses for all drivers which access data 4 bytes at a time. And I do
not think it "breaks" anything. What I do not know is:
But it's just the Flexcan driver which is doing unaligned accesses.
Ok, can we agree on the following patch then?
ksrc/drivers/can/rtcan_flexcan.c +4 -5
@@ -38,6 +38,7 @@#if LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,5 ,0 )#include <linux/pinctrl/consumer.h> #endif +#include <asm/unaligned.h> #include <rtdm/rtdm_driver.h>
@@ -497,11 +498,9 @@ static void flexcan_rx_interrupt(struct rtcan_device *dev, cf->can_id |=CAN_RTR_FLAG ; skb->rb_frame_size =EMPTY_RB_FRAME_SIZE ; }else { - skb->rb_frame_size =EMPTY_RB_FRAME_SIZE + cf->can_dlc ; - *(__be32 *)(cf->data +0 ) = -cpu_to_be32 (flexcan_read (&mb->data[0 ])); - *(__be32 *)(cf->data +4 ) = -cpu_to_be32 (flexcan_read (&mb->data[1 ])); + skb->rb_frame_size =EMPTY_RB_FRAME_SIZE + cf->can_dlc; +put_unaligned_be32 (flexcan_read (&mb->data[0 ]), cf->data +0 ); +put_unaligned_be32 (flexcan_read (&mb->data[1 ]), cf->data +4 ); }/* Store the interface index */
Signature · 1 line
Gilles.
On Tue, 28 Jan 2014 23:06:54 +0100, Gilles Chanteperdrix
ksrc/drivers/can/rtcan_flexcan.c static void flexcan_rx_interrupt(struct
Quoted 55 lines · <[email protected]> wrote:
Quoted 18 lines · Wolfgang Grandegger
On Sun, 26 Jan 2014 21:56:10 +0100, Gilles Chanteperdrix
Quoted 9 lines
IMO, it is not just for the flexcan driver, it will avoid unaligned
accesses for all drivers which access data 4 bytes at a time. And I do
not think it "breaks" anything. What I do not know is:
Quoted 1 line
But it's just the Flexcan driver which is doing unaligned accesses.
Ok, can we agree on the following patch then?
(quoted diff) +0
-0
b/ksrc/drivers/can/rtcan_flexcan.cindex 8f0e8d1..1674b73 100644
---
a/ksrc/drivers/can/rtcan_flexcan.c+++
b/ksrc/drivers/can/rtcan_flexcan.cksrc/drivers/can/rtcan_flexcan.c +1
-0@@ -38,6 +38,7 @@#if LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,5 ,0 )#include <linux/pinctrl/consumer.h> #endif +#include <asm/unaligned.h> #include <rtdm/rtdm_driver.h> @@ -497,11 +498,9 @@ static void flexcan_rx_interrupt(struct
rtcan_device
Quoted 19 lines
(quoted diff) +1
-5*dev, cf->can_id |= CAN_RTR_FLAG; skb->rb_frame_size = EMPTY_RB_FRAME_SIZE; } else { - skb->rb_frame_size = EMPTY_RB_FRAME_SIZE + cf->can_dlc ; - *(__be32 *)(cf->data + 0) = - cpu_to_be32(flexcan_read(&mb->data[0])); - *(__be32 *)(cf->data + 4) = - cpu_to_be32(flexcan_read(&mb->data[1])); + skb->rb_frame_size = EMPTY_RB_FRAME_SIZE + cf->can_dlc;
Review static void flexcan_rx_interrupt(struct
Quoted 10 lines
(quoted diff) +2
-0+ put_unaligned_be32(flexcan_read(&mb->data[0]), cf->data + 0); + put_unaligned_be32(flexcan_read(&mb->data[1]), cf->data + 4); } /* Store the interface index */
D'accord, thanks.
Wolfgang.
Quoted 41 lines · Wolfgang Grandegger
ksrc/drivers/can/rtcan_flexcan.c static void flexcan_rx_interrupt(struct
Quoted 24 lines · Gilles Chanteperdrix
Quoted 7 lines · Wolfgang Grandegger
On Sun, 26 Jan 2014 21:56:10 +0100, Gilles Chanteperdrix
Quoted 3 lines
IMO, it is not just for the flexcan driver, it will avoid unaligned accesses for all drivers which access data 4 bytes at a time. And I do not think it "breaks" anything. What I do not know is:
But it's just the Flexcan driver which is doing unaligned accesses.
Ok, can we agree on the following patch then?
ksrc/drivers/can/rtcan_flexcan.c +1
-0@@ -38,6 +38,7 @@#if LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,5 ,0 )#include <linux/pinctrl/consumer.h> #endif +#include <asm/unaligned.h> #include <rtdm/rtdm_driver.h> @@ -497,11 +498,9 @@ static void flexcan_rx_interrupt(struct
rtcan_deviceQuoted 14 lines
ksrc/drivers/can/rtcan_flexcan.c +3
-5*dev, cf->can_id |=CAN_RTR_FLAG ; skb->rb_frame_size =EMPTY_RB_FRAME_SIZE ; }else { - skb->rb_frame_size =EMPTY_RB_FRAME_SIZE + cf->can_dlc ; - *(__be32 *)(cf->data +0 ) = -cpu_to_be32 (flexcan_read (&mb->data[0 ])); - *(__be32 *)(cf->data +4 ) = -cpu_to_be32 (flexcan_read (&mb->data[1 ])); + skb->rb_frame_size =EMPTY_RB_FRAME_SIZE + cf->can_dlc; +put_unaligned_be32 (flexcan_read (&mb->data[0 ]), cf->data +0 ); +put_unaligned_be32 (flexcan_read (&mb->data[1 ]), cf->data +4 ); }
Quoted 5 lines
Quoted 1 line
/* Store the interface index */
D'accord, thanks.
Wolfgang.
Thank you all for your replies
Alexandre.
Quoted 43 lines · Alexandre COFFIGNAL
Quoted 41 lines · Wolfgang Grandegger
ksrc/drivers/can/rtcan_flexcan.c static void flexcan_rx_interrupt(struct
Quoted 24 lines · Gilles Chanteperdrix
Quoted 7 lines · Wolfgang Grandegger
On Sun, 26 Jan 2014 21:56:10 +0100, Gilles Chanteperdrix
Quoted 3 lines
IMO, it is not just for the flexcan driver, it will avoid unaligned accesses for all drivers which access data 4 bytes at a time. And I do not think it "breaks" anything. What I do not know is:
But it's just the Flexcan driver which is doing unaligned accesses.
Ok, can we agree on the following patch then?
ksrc/drivers/can/rtcan_flexcan.c +1
-0@@ -38,6 +38,7 @@#if LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,5 ,0 )#include <linux/pinctrl/consumer.h> #endif +#include <asm/unaligned.h> #include <rtdm/rtdm_driver.h> @@ -497,11 +498,9 @@ static void flexcan_rx_interrupt(struct
rtcan_deviceQuoted 14 lines
ksrc/drivers/can/rtcan_flexcan.c +3
-5*dev, cf->can_id |=CAN_RTR_FLAG ; skb->rb_frame_size =EMPTY_RB_FRAME_SIZE ; }else { - skb->rb_frame_size =EMPTY_RB_FRAME_SIZE + cf->can_dlc ; - *(__be32 *)(cf->data +0 ) = -cpu_to_be32 (flexcan_read (&mb->data[0 ])); - *(__be32 *)(cf->data +4 ) = -cpu_to_be32 (flexcan_read (&mb->data[1 ])); + skb->rb_frame_size =EMPTY_RB_FRAME_SIZE + cf->can_dlc; +put_unaligned_be32 (flexcan_read (&mb->data[0 ]), cf->data +0 ); +put_unaligned_be32 (flexcan_read (&mb->data[1 ]), cf->data +4 ); }
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
/* Store the interface index */D'accord, thanks.
Wolfgang.
Thank you all for your replies
Hi Alexandre,
Did you check the last patch? Does it compile and work for you?
Regards.
Signature · 1 line
Gilles.
Quoted 49 lines · Gilles Chanteperdrix
Quoted 48 lines · Alexandre COFFIGNAL
Quoted 46 lines · Wolfgang Grandegger
ksrc/drivers/can/rtcan_flexcan.c static void flexcan_rx_interrupt(struct
Quoted 24 lines · Gilles Chanteperdrix
Quoted 7 lines · Wolfgang Grandegger
On Sun, 26 Jan 2014 21:56:10 +0100, Gilles Chanteperdrix
Quoted 3 lines
IMO, it is not just for the flexcan driver, it will avoid unaligned accesses for all drivers which access data 4 bytes at a time. And I do not think it "breaks" anything. What I do not know is:
But it's just the Flexcan driver which is doing unaligned accesses.
Ok, can we agree on the following patch then?
ksrc/drivers/can/rtcan_flexcan.c +1
-0@@ -38,6 +38,7 @@#if LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,5 ,0 )#include <linux/pinctrl/consumer.h> #endif +#include <asm/unaligned.h> #include <rtdm/rtdm_driver.h> @@ -497,11 +498,9 @@ static void flexcan_rx_interrupt(struct
rtcan_deviceQuoted 14 lines
ksrc/drivers/can/rtcan_flexcan.c +3
-5*dev, cf->can_id |=CAN_RTR_FLAG ; skb->rb_frame_size =EMPTY_RB_FRAME_SIZE ; }else { - skb->rb_frame_size =EMPTY_RB_FRAME_SIZE + cf->can_dlc ; - *(__be32 *)(cf->data +0 ) = -cpu_to_be32 (flexcan_read (&mb->data[0 ])); - *(__be32 *)(cf->data +4 ) = -cpu_to_be32 (flexcan_read (&mb->data[1 ])); + skb->rb_frame_size =EMPTY_RB_FRAME_SIZE + cf->can_dlc; +put_unaligned_be32 (flexcan_read (&mb->data[0 ]), cf->data +0 ); +put_unaligned_be32 (flexcan_read (&mb->data[1 ]), cf->data +4 ); }Quoted 1 line
/* Store the interface index */D'accord, thanks.
Wolfgang.
Quoted 8 lines
Quoted 1 line
Thank you all for your replies
Hi Alexandre,
Did you check the last patch? Does it compile and work for you?
Regards.
I tested this patch, it works perfectly on i.MX28. Thank you very much.
Regards.