>>> +static void test_erase_sector(void) >>> +{ >>> + uint32_t some_page_addr = 0x600 * PAGE_SIZE; >>> + uint32_t page[PAGE_SIZE / 4]; >>> + int i; >>> + >>> + spi_conf(CONF_ENABLE_W0); >>> + >>> + spi_ctrl_start_user(); >>> + writeb(AST2400_FLASH_BASE, WREN); >>> + writeb(AST2400_FLASH_BASE, EN_4BYTE_ADDR); >>> + writeb(AST2400_FLASH_BASE, ERASE_SECTOR); >>> + writel(AST2400_FLASH_BASE, cpu_to_be32(some_page_addr)); >> Hi, >> >> I think you should not make any byte swapping because >> qtest for all write* instructions (see qtest.c:377). > > yes. on a BE, we should not byte swap. > > When on a LE host, the cpu_to_be32() call in the test byte-swaps > the address, tswap32() in qtest.c does nothing as the host endian > and guest endian are in sync and so the address reaches the > controller region in the expected order. > > When on a BE host, the cpu_to_be32() does nothing but tswap32() in > qtest.c reverses the order and so the address reaches the controller > region in the wrong order (LE). > > I see two possible fixes : > > 1 - replace the read* routines by out* (no tswap there) > 2 - add an extra byteswap on BE hosts using qtest_big_endian() as > in virtio-blk-test.c. see virtio_blk_fix_request()
or : 3 - use memwrite/read which is I think the appropriate fix. Thanks, C.