[U-Boot] [RFC PATCH v2] ARM: Avoid compiler optimization for usages of readb, writeb and friends.

Alexander Holler
2010-12-20T17:12:21Z

Hello,

Am 20.12.2010 07:07, schrieb John Rigby:
> With your patch and the following hack nand works:
>
>
> diff --git a/drivers/mtd/nand/omap_gpmc.c b/drivers/mtd/nand/omap_gpmc.c
> index 99b9cef..5e94155 100644
> --- a/drivers/mtd/nand/omap_gpmc.c
> +++ b/drivers/mtd/nand/omap_gpmc.c
> @@ -29,6 +29,8 @@
> #include<linux/mtd/nand_ecc.h>
> #include<nand.h>
>
> +#define origwriteb(v,a) __arch_putb(v,a)
> +
> static uint8_t cs;
> static struct nand_ecclayout hw_nand_oob = GPMC_NAND_HW_ECC_LAYOUT;
>
> @@ -58,7 +60,7 @@ static void omap_nand_hwcontrol(struct mtd_info
> *mtd, int32_t cmd,
> }
>
> if (cmd != NAND_CMD_NONE)
> - writeb(cmd, this->IO_ADDR_W);
> + origwriteb(cmd, this->IO_ADDR_W);
> }
>
> /*
>
> The working assembly looks like this:
>
> if (cmd != NAND_CMD_NONE)
> 80024d28: e3710001 cmn r1, #1
> origwriteb(cmd, this->IO_ADDR_W);
> 80024d2c: 15933004 ldrne r3, [r3, #4]
> 80024d30: 120110ff andne r1, r1, #255 ; 0xff
> 80024d34: 15c31000 strbne r1, [r3]
> 80024d38: e8bd8010 pop {r4, pc}
>
> The broken assembly looks like this:
>
> if (cmd != NAND_CMD_NONE)
> 80024d28: e3710001 cmn r1, #1
> 80024d2c: 08bd8010 popeq {r4, pc}
> writeb(cmd, this->IO_ADDR_W);
> 80024d30: e5933004 ldr r3, [r3, #4]
> 80024d34: e20110ff and r1, r1, #255 ; 0xff
> 80024d38: e5c31000 strb r1, [r3]
> 80024d3c: e5d33000 ldrb r3, [r3]
> 80024d40: e8bd8010 pop {r4, pc}
>
> This is with gcc version "(Ubuntu/Linaro 4.4.4-14ubuntu4) 4.4.5".
> I'll try a 4.5.2 version next and see what happens.

There must be more problems. Using gcc 4.5.1, the read*/write*-patch and
your hack, my kernel doesn't boot. Using gcc 4.3.5 and the same source
to compile u-boot the kernel comes up. Here is the output for the
non-working u-boot:

----------------
U-Boot 2010.12-rc3-00015-g3ae9687-dirty (Dec 20 2010 - 18:01:41, gcc 4.5.1)

OMAP3530-GP ES3.1, CPU-OPP2, L3-165MHz, Max CPU Clock 720 mHz
OMAP3 Beagle board + LPDDR/NAND
I2C: ready
DRAM: 256 MiB
NAND: 256 MiB
MMC: OMAP SD/MMC: 0
In: serial
Out: serial
Err: serial
Beagle Rev C4
timed out in wait_for_pin: I2C_STAT=0
No EEPROM on expansion board
Die ID #062a000400000000040365fa16019019
Hit any key to stop autoboot: 0
reading boot.scr

422 bytes read
Running bootscript from mmc ...
## Executing script at 82000000
reading uImage

2419940 bytes read
Booting from mmc ...
## Booting kernel from Legacy Image at 82000000 ...
Image Name: Linux-2.6.37-rc5-beagleboard-000
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2419876 Bytes = 2.3 MiB
Load Address: 80008000
Entry Point: 80008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK
----------------

Nothing else.

Regards,

Alexander