MIPS: Fix compile warning in au1x00_eth.c
PATCH 1/1 MIPS: Fix compile warning in au1x00_eth.c
This patch fixes this compilation warning:
./MAKEALL dbau1000
Configuring for dbau1x00 board...au1x00_eth.c: In function 'au1x00_send':
au1x00_eth.c:158: warning: passing argument 1 of 'virt_to_phys' discards
qualifiers from pointer target type
...
Seens with ELDK 4.2 (GCC 4.2.2).
--- cpu/mips/au1x00_eth.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
cpu/mips/au1x00_eth.c +5 -3
@@ -155,7 +155,7 @@ static int au1x00_send(struct eth_device* dev, volatile void *packet, int length/* tx fifo should always be idle */ fifo_tx[next_tx].len = length; - fifo_tx[next_tx].addr = (virt_to_phys (packet))|TX_DMA_ENABLE ; + fifo_tx[next_tx].addr = (virt_to_phys ((void *)packet))|TX_DMA_ENABLE ;au_sync ();udelay (1 );
@@ -208,7 +208,8 @@ static int au1x00_recv(struct eth_device* dev){NetReceive (NetRxPackets[next_rx], length -4 ); } - fifo_rx[next_rx].addr = (virt_to_phys (NetRxPackets[next_rx]))|RX_DMA_ENABLE ; + fifo_rx[next_rx].addr = +virt_to_phys ((void *)NetRxPackets[next_rx])|RX_DMA_ENABLE ; next_rx++;if (next_rx>=NO_OF_FIFOS ){
@@ -249,7 +250,8 @@ static int au1x00_init(struct eth_device* dev, bd_t * bd){for (i=0 ;i<NO_OF_FIFOS ;i++){ fifo_tx[i].len =0 ; fifo_tx[i].addr =virt_to_phys (&txbuf[0 ]); - fifo_rx[i].addr = (virt_to_phys (NetRxPackets[i]))|RX_DMA_ENABLE ; + fifo_rx[i].addr = +virt_to_phys ((void *)NetRxPackets[i])|RX_DMA_ENABLE ; }/* Put mac addr in little endian */
Signature · 1 line
1.6.1.1.230.gdfb04
PATCH 1/1 MIPS: Fix compile warning in au1x00_eth.c
Quoted 9 lines · Stefan Roese
This patch fixes this compilation warning:
./MAKEALL dbau1000
Configuring for dbau1x00 board...au1x00_eth.c: In function 'au1x00_send':
au1x00_eth.c:158: warning: passing argument 1 of 'virt_to_phys' discards
qualifiers from pointer target type
...
Quoted 3 lines
Seens with ELDK 4.2 (GCC 4.2.2).
Signed-off-by Stefan Roese <[email protected]>
The number of warnings decreases by half, but we're still warned. Comments? I've not took a look of the patch itself, yet. Just let you know.
skuribay at ubuntu:u-boot.git$ mips-linux-gnu-gcc --version mips-linux-gnu-gcc (Sourcery G++ Lite 4.2-177) 4.2.3
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
skuribay at ubuntu:u-boot.git$
skuribay at ubuntu:u-boot.git$ CROSS_COMPILE=mips-linux-gnu- ./MAKEALL dbau1000 Configuring for dbau1x00 board...au1x00_eth.c: In function 'au1x00_send':
au1x00_eth.c:158: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type au1x00_eth.c: In function 'au1x00_recv':
au1x00_eth.c:211: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type au1x00_eth.c: In function 'au1x00_init':
au1x00_eth.c:252: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type au1x00_eth.c: In function 'au1x00_recv':
au1x00_eth.c:211: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type au1x00_eth.c: In function 'au1x00_init':
au1x00_eth.c:252: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type au1x00_eth.c: In function 'au1x00_send':
au1x00_eth.c:158: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type
text data bss dec hex filename
118780 5264 20648 144692 23534 ./u-boot
skuribay at ubuntu:u-boot.git$
skuribay at ubuntu:u-boot.git$
skuribay at ubuntu:u-boot.git$ stg push
Checking for changes in the working directory ... done
Fast-forwarded patch "mips-fix-dbau1000-warning.patch"
Now at patch "mips-fix-dbau1000-warning.patch"
skuribay at ubuntu:u-boot.git$
skuribay at ubuntu:u-boot.git$ CROSS_COMPILE=mips-linux-gnu- ./MAKEALL dbau1000 Configuring for dbau1x00 board...au1x00_eth.c: In function 'au1x00_recv':
au1x00_eth.c:211: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type au1x00_eth.c: In function 'au1x00_init':
au1x00_eth.c:253: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type au1x00_eth.c: In function 'au1x00_send':
au1x00_eth.c:158: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type
text data bss dec hex filename
118780 5264 20648 144692 23534 ./u-boot
skuribay at ubuntu:u-boot.git$
PATCH 1/1 MIPS: Fix compile warning in au1x00_eth.c
Quoted 10 lines · Shinya Kuribayashi
Quoted 9 lines · Stefan Roese
This patch fixes this compilation warning:
./MAKEALL dbau1000
Configuring for dbau1x00 board...au1x00_eth.c: In function 'au1x00_send':
au1x00_eth.c:158: warning: passing argument 1 of 'virt_to_phys' discards
qualifiers from pointer target type
...
Quoted 7 lines
Quoted 3 lines
Seens with ELDK 4.2 (GCC 4.2.2).
Signed-off-by Stefan Roese <[email protected]>The number of warnings decreases by half, but we're still warned. Comments? I've not took a look of the patch itself, yet. Just let you know.
Hmmm, strange. I only see 3 warnings which are resolved with my patch:
[stefan at kubuntu u-boot (master)]$ ./MAKEALL dbau1000
Configuring for dbau1x00 board...au1x00_eth.c: In function 'au1x00_send':
au1x00_eth.c:158: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type au1x00_eth.c: In function 'au1x00_recv':
au1x00_eth.c:211: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type au1x00_eth.c: In function 'au1x00_init':
au1x00_eth.c:252: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type
text data bss dec hex filename
120028 5408 20648 146084 23aa4 ./u-boot
[stefan at kubuntu u-boot (master)]$ git am patches_stefan/0001-MIPS-Fix-compile-warning-in-au1x00_eth.c.patch
Applying: MIPS: Fix compile warning in au1x00_eth.c
[stefan at kubuntu u-boot (master)]$ ./MAKEALL dbau1000
Configuring for dbau1x00 board...
text data bss dec hex filename
120028 5408 20648 146084 23aa4 ./u-boot
This is on TOT (git ID 2b6fd5c77db9c6ed3cea9799c86ff922cf0107b2).
Ah, there's something I noticed in your test. Please see below.
Quoted 21 lines
skuribay at ubuntu:u-boot.git$ mips-linux-gnu-gcc --version mips-linux-gnu-gcc (Sourcery G++ Lite 4.2-177) 4.2.3
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.skuribay at ubuntu:u-boot.git$
skuribay at ubuntu:u-boot.git$ CROSS_COMPILE=mips-linux-gnu- ./MAKEALL dbau1000 Configuring for dbau1x00 board...au1x00_eth.c: In function 'au1x00_send':
au1x00_eth.c:158: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target typeau1x00_eth.c: In function 'au1x00_recv':
au1x00_eth.c:211: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target typeau1x00_eth.c: In function 'au1x00_init':
au1x00_eth.c:252: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target typeau1x00_eth.c: In function 'au1x00_recv':
au1x00_eth.c:211: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target typeau1x00_eth.c: In function
Quoted 8 lines
'
au1x00_init':
au1x00_eth.c:252: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target typeau1x00_eth.c: In function 'au1x00_send':
au1x00_eth.c:158: warning: passing argument 1 of 'virt_to_phys' discards
qualifiers from pointer target type text data bss dec hex
filename
118780 5264 20648 144692 23534 ./u-boot
Those errors occur twice. Seems that you are compiling this file twice. Any idea why?
Quoted 13 lines
skuribay at ubuntu:u-boot.git$
skuribay at ubuntu:u-boot.git$
skuribay at ubuntu:u-boot.git$ stg push
Checking for changes in the working directory ... done Fast-forwarded patch "mips-fix-dbau1000-warning.patch"
Now at patch "mips-fix-dbau1000-warning.patch"
skuribay at ubuntu:u-boot.git$
skuribay at ubuntu:u-boot.git$ CROSS_COMPILE=mips-linux-gnu- ./MAKEALL dbau1000 Configuring for dbau1x00 board...au1x00_eth.c: In function 'au1x00_recv':
au1x00_eth.c:211: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target typeau1x00_eth.c: In function 'au1x00_init':
Quoted 8 lines
au1x00_eth.c:253: warning: passing argument 1 of '
virt_to_phys' discards qualifiers from pointer target typeau1x00_eth.c: In function 'au1x00_send':
au1x00_eth.c:158: warning: passing argument 1 of 'virt_to_phys' discards
qualifiers from pointer target type text data bss dec hex
filename
118780 5264 20648 144692 23534 ./u-boot
skuribay at ubuntu:u-boot.git$
And now one version of the errors are solved, only one is remaining. Perhaps you are compiling a 2nd version of this driver again. Just guessing...
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
PATCH 1/1 MIPS: Fix compile warning in au1x00_eth.c
Quoted 30 lines · Stefan Roese
Quoted 21 lines
skuribay at ubuntu:u-boot.git$ mips-linux-gnu-gcc --version mips-linux-gnu-gcc (Sourcery G++ Lite 4.2-177) 4.2.3
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.skuribay at ubuntu:u-boot.git$
skuribay at ubuntu:u-boot.git$ CROSS_COMPILE=mips-linux-gnu- ./MAKEALL dbau1000 Configuring for dbau1x00 board...au1x00_eth.c: In function 'au1x00_send':
au1x00_eth.c:158: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target typeau1x00_eth.c: In function 'au1x00_recv':
au1x00_eth.c:211: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target typeau1x00_eth.c: In function 'au1x00_init':
au1x00_eth.c:252: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target typeau1x00_eth.c: In function 'au1x00_recv':
au1x00_eth.c:211: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target typeau1x00_eth.c: In functionQuoted 8 lines
'
au1x00_init':
au1x00_eth.c:252: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target typeau1x00_eth.c: In function 'au1x00_send':
au1x00_eth.c:158: warning: passing argument 1 of 'virt_to_phys' discards
qualifiers from pointer target type text data bss dec hex
filename
118780 5264 20648 144692 23534 ./u-boot
Quoted 2 lines
Those errors occur twice. Seems that you are compiling this file twice. Any idea why?
Probably it's due to the GCC 4.2.x minor version difference.
Googling[1][2] and playing for a while, I finally managed to quiet the GCC with the following patch.
cpu/mips/au1x00_eth.c +3 -3
@@ -155,7 +155,7 @@ static int au1x00_send(struct eth_device* dev, volatile void *packet, int length/* tx fifo should always be idle */ fifo_tx[next_tx].len = length; - fifo_tx[next_tx].addr = (virt_to_phys (packet))|TX_DMA_ENABLE ; + fifo_tx[next_tx].addr = (virt_to_phys ((void *)(unsigned long )packet))|TX_DMA_ENABLE ;au_sync ();udelay (1 );
@@ -208,7 +208,7 @@ static int au1x00_recv(struct eth_device* dev){NetReceive (NetRxPackets[next_rx], length -4 ); } - fifo_rx[next_rx].addr = (virt_to_phys (NetRxPackets[next_rx]))|RX_DMA_ENABLE ; + fifo_rx[next_rx].addr = (virt_to_phys ((void *)(unsigned long )NetRxPackets[next_rx]))|RX_DMA_ENABLE ; next_rx++;if (next_rx>=NO_OF_FIFOS ){
@@ -249,7 +249,7 @@ static int au1x00_init(struct eth_device* dev, bd_t * bd){for (i=0 ;i<NO_OF_FIFOS ;i++){ fifo_tx[i].len =0 ; fifo_tx[i].addr =virt_to_phys (&txbuf[0 ]); - fifo_rx[i].addr = (virt_to_phys (NetRxPackets[i]))|RX_DMA_ENABLE ; + fifo_rx[i].addr = (virt_to_phys ((void *)(unsigned long )NetRxPackets[i]))|RX_DMA_ENABLE ; }/* Put mac addr in little endian */
Well, what will we do? Are there any othrer desirable fixes?
[1] http://lists.denx.de/pipermail/u-boot/2008-December/044960.html
[PATCH 01/11] powerpc: fix io.h build warning with CONFIG_PHYS_64BIT
[2] http://lkml.org/lkml/2009/1/27/67
Interestingly, this only happens with gcc-4.2; gcc <= 4.1 and gcc-4.3 are OK.
Signature · 2 lines
Shinya Kuribayashi NEC Electronics
PATCH 1/1 MIPS: Fix compile warning in au1x00_eth.c
Quoted 11 lines · Shinya Kuribayashi
cpu/mips/au1x00_eth.c +1
-1@@ -249,7 +249,7 @@ static int au1x00_init(struct eth_device* dev, bd_t * bd){ for(i=0;i<NO_OF_FIFOS;i++){ fifo_tx[i].len =0 ; fifo_tx[i].addr =virt_to_phys (&txbuf[0 ]); - fifo_rx[i].addr = (virt_to_phys (NetRxPackets[i]))|RX_DMA_ENABLE ; + fifo_rx[i].addr = (virt_to_phys ((void *)(unsigned long )NetRxPackets[i]))|RX_DMA_ENABLE ; }/* Put mac addr in little endian */
Quoted 1 line
Well, what will we do? Are there any othrer desirable fixes?
Hmmm, strange that such a double cast is really needed.
BTW: I'm beginning to wonder if we really need the "volatile" in the net related parameters. Perhaps this should be reviewed again.
PS: I'm leaving for a short vacation in a few hours. I'll be back on Thursday next week.
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
[U-Boot] MIPS: Fix GCC-4.2 'discards qualifiers from pointer target type' warnings
Compiling dbau1x00 and gth2 boards with GCC-4.2, you would see new warnings like this:
skuribay at ubuntu:u-boot.git$ ./MAKEALL dbau1000
Configuring for dbau1x00 board...au1x00_eth.c: In function 'au1x00_send':
au1x00_eth.c:158: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type au1x00_eth.c: In function 'au1x00_recv':
au1x00_eth.c:211: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type au1x00_eth.c: In function 'au1x00_init':
au1x00_eth.c:252: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type au1x00_eth.c: In function 'au1x00_recv':
au1x00_eth.c:211: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type au1x00_eth.c: In function 'au1x00_init':
au1x00_eth.c:252: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type au1x00_eth.c: In function 'au1x00_send':
au1x00_eth.c:158: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type
We're passing a volatile pointer to a function which is expecting a non- volatile pointer. That's potentially dangerous, so gcc warns about it. Confirmed with ELDK 4.2 (GCC 4.2.2) and Sourcey G++ 4.2 (GCC 4.2.3).
To fix this, we add a volatile attribute to the argument in question. The virt_to_phys function in Linux kernel also does the same thing.
---
Sorry for late reply,
Stefan: I think this is a reasonable fix. I believe this works for ELDK as well, of course.
Walfgang: Please pick this up directly, thanks in advance.
include/asm-mips/io.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
include/asm-mips/io.h +1 -1
@@ -118,7 +118,7 @@ static inline void set_io_port_base(unsigned long base)* Change virtual addresses to physical addresses and vv. * These are trivial on the 1:1 Linux/MIPS mapping */ -extern inline phys_addr_t virt_to_phys (void * address) +extern inline phys_addr_t virt_to_phys (volatile void * address) {return CPHYSADDR (address); }
Wolfgang Denk
Applied[U-Boot] MIPS: Fix GCC-4.2 'discards qualifiers from pointer target type' warnings
Dear Shinya Kuribayashi,
Quoted 30 lines · In message <[email protected]> you wrote:
Compiling dbau1x00 and gth2 boards with GCC-4.2, you would see new warnings like this:
skuribay at ubuntu:u-boot.git$ ./MAKEALL dbau1000
Configuring for dbau1x00 board...au1x00_eth.c: In function 'au1x00_send':
au1x00_eth.c:158: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target typeau1x00_eth.c: In function 'au1x00_recv':
au1x00_eth.c:211: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target typeau1x00_eth.c: In function 'au1x00_init':
au1x00_eth.c:252: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target typeau1x00_eth.c: In function 'au1x00_recv':
au1x00_eth.c:211: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target typeau1x00_eth.c: In function 'au1x00_init':
au1x00_eth.c:252: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target typeau1x00_eth.c: In function 'au1x00_send':
au1x00_eth.c:158: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target typeWe're passing a volatile pointer to a function which is expecting a non- volatile pointer. That's potentially dangerous, so gcc warns about it. Confirmed with ELDK 4.2 (GCC 4.2.2) and Sourcey G++ 4.2 (GCC 4.2.3).
To fix this, we add a volatile attribute to the argument in question. The
virt_to_physfunction in Linux kernel also does the same thing.Signed-off-by Stefan Roese <[email protected]>Signed-off-by Shinya Kuribayashi <[email protected]>---
Sorry for late reply,
Quoted 8 lines
Stefan: I think this is a reasonable fix. I believe this works for ELDK as well, of course.
Walfgang: Please pick this up directly, thanks in advance.
include/asm-mips/io.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de God runs electromagnetics by wave theory on Monday, Wednesday, and Friday, and the Devil runs them by quantum theory on Tuesday, Thurs- day, and Saturday. -- William Bragg