Re: [OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-30 Thread Luiz Angelo Daros de Luca
Thanks you all for the fix. --- Luiz Angelo Daros de Luca, Me. luizl...@gmail.com 2013/4/30 Jonas Gorski > On Mon, Apr 29, 2013 at 4:54 PM, Jonas Gorski wrote: > > Still build testing, but as a addendum, vanilla 4.6.x is *not* > > affected, so selecting 4.6.3 instead of 4.6-l

Re: [OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-30 Thread Jonas Gorski
On Mon, Apr 29, 2013 at 4:54 PM, Jonas Gorski wrote: > Still build testing, but as a addendum, vanilla 4.6.x is *not* > affected, so selecting 4.6.3 instead of 4.6-linaro avoids the error, > too. The fix is now committed to both trunk (r36486) and Attitude Adjustment (r36500) for all affected gcc

Re: [OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-29 Thread Wojciech Kromer
W dniu 29.04.2013 16:54, Jonas Gorski pisze: The appropriate bug report is >. I'll backport the >fix to 4.6 and 4.7. Still build testing, but as a addendum, vanilla 4.6.x is*not* affected, so selecting 4.6.3 instead of 4.6-linaro avoids the erro

Re: [OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-29 Thread Jonas Gorski
On Mon, Apr 29, 2013 at 2:46 PM, Jonas Gorski wrote: > On Sun, Apr 28, 2013 at 10:04 PM, Luiz Angelo Daros de Luca > wrote: >> Hello, >> >> I tested the patch and it works. I can see all partitions inside my disk. I >> just cleaned the first typecast as it was useless and I'll send in a cleaner >

Re: [OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-29 Thread Jonas Gorski
On Sun, Apr 28, 2013 at 10:04 PM, Luiz Angelo Daros de Luca wrote: > Hello, > > I tested the patch and it works. I can see all partitions inside my disk. I > just cleaned the first typecast as it was useless and I'll send in a cleaner > patch email to this list. > > Now what would be the next step

Re: [OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-28 Thread Luiz Angelo Daros de Luca
Hello, I tested the patch and it works. I can see all partitions inside my disk. I just cleaned the first typecast as it was useless and I'll send in a cleaner patch email to this list. Now what would be the next steps? Is it worth to submit to gcc? Should I submit this directly to kernel mainstr

Re: [OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-28 Thread Sergey Vlasov
On Sat, Apr 27, 2013 at 08:55:35PM -0300, Luiz Angelo Daros de Luca wrote: > I was curious about the "undefined". I found the text: > >The integer promotions are performed on each of the operands. The >type of the result is that of the promoted left operand. If the >value of the right

Re: [OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-27 Thread Luiz Angelo Daros de Luca
Hello Wojciech, I'm really no gcc expert and, please, correct if I'm wrong. Maybe the problem lies when gcc is evaluating the "| p[2] << 16 | p[3] << 24;" part. As "<<" has precedence over "|", it is evaluated before. At that time, the evaluated expression would be "p[3] << 24" and the left oper

Re: [OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-27 Thread Wojciech Kromer
So, as left operand is 8bit, the right operant must not be over 8. Does a simple typecast solves it? return (u32)((u32)p[0] | (u32)p[1] << 8 | (u32)p[2] << 16 | (u32)p[3] << 24); return (u32)p[0] | (u32)p[1] << 8 | (u32)p[2] << 16 | (u32)p[3] << 24; is correct for all compilers, and this ve

Re: [OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-27 Thread Luiz Angelo Daros de Luca
I was curious about the "undefined". I found the text: The integer promotions are performed on each of the operands. The type of the result is that of the promoted left operand. If the value of the right operand is negative or is greater than or equal to the width of the promoted left ope

Re: [OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-27 Thread Sergey Vlasov
On Sat, Apr 27, 2013 at 09:24:41PM +0200, Wojciech Kromer wrote: > > > Note that adding an explicit u32 cast avoids the problem even with a buggy > > compiler: > > > > static inline u32 get_unaligned_le32(const u8 *p) > > { > > return (u32)p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24; > > } > >

Re: [OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-27 Thread Wojciech Kromer
Note that adding an explicit u32 cast avoids the problem even with a buggy compiler: static inline u32 get_unaligned_le32(const u8 *p) { return (u32)p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24; } Generally it's a good idea to write explicit type conversions like in this example. Poor p

Re: [OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-27 Thread Sergey Vlasov
On Sat, Apr 27, 2013 at 07:40:38PM +0200, Jonas Gorski wrote: > On Sat, Apr 27, 2013 at 3:38 PM, Sergey Vlasov wrote: [...] > > The "madd $3,$2" command here is incorrect - it performs sign > > extension of its arguments; it should be "maddu $3,$2". > > I came to the same conclusion after looking

Re: [OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-27 Thread Jonas Gorski
On Sat, Apr 27, 2013 at 3:38 PM, Sergey Vlasov wrote: > On Sat, Apr 27, 2013 at 02:09:22AM -0300, Luiz Angelo Daros de Luca wrote: >> The usage of sign-extension might be cause. The problem is that all these >> variables are sector_t, which as far as I know, is a u64. >> Even if it was using signe

Re: [OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-27 Thread Luiz Angelo Daros de Luca
Hello, I checked sizeof(sector_t) and it is 8. The assembly code I get is similar to what Sergey posted. If it really is a compiler problem, which are the options? Would removing the inline help? --- Luiz Angelo Daros de Luca, Me. luizl...@gmail.com 2013/4/27 Sergey Vlasov >

Re: [OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-27 Thread Sergey Vlasov
On Sat, Apr 27, 2013 at 02:09:22AM -0300, Luiz Angelo Daros de Luca wrote: > The usage of sign-extension might be cause. The problem is that all these > variables are sector_t, which as far as I know, is a u64. > Even if it was using signed variable, all of them are 64bit and using > values much lo

Re: [OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-26 Thread Wojciech Kromer
W dniu 27.04.2013 03:45, Luiz Angelo Daros de Luca pisze: /block/partitions/msdos.c: this_sector = first_sector + start_sect(p) * sector_size; please look at linux/types.h maybe CONFIG_LBDAF is not set #ifdef CONFIG_LBDAF typedef u64 sector_t; typedef u64 blkcnt_t; #else typedef unsign

Re: [OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-26 Thread Luiz Angelo Daros de Luca
The usage of sign-extension might be cause. The problem is that all these variables are sector_t, which as far as I know, is a u64. Even if it was using signed variable, all of them are 64bit and using values much lower that 2^63. As mips is not a 64-bit processor, the compiler must do it by parts

Re: [OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-26 Thread David Newall
On 27/04/13 11:15, Luiz Angelo Daros de Luca wrote: The correct output would be 2273342085 and not 18446744071687926405. Comparing both, the MSB 32bit of first_sector becomes all 1. 2273342085 = 0x87807285 18446744071687926405 = 0x87807285 Any idea of why? Maybe th

[OpenWrt-Devel] Math operation gets wrong result on ar71xx for AA

2013-04-26 Thread Luiz Angelo Daros de Luca
Hello, I reported a bug that prevents partitions in a large disk (1.5TB) to be used here: https://dev.openwrt.org/ticket/13420 I already isolated it to this line: /block/partitions/msdos.c: this_sector = first_sector + start_sect(p) * sector_size; And some printk show their values: [ 98.230