From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49043) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bK1IU-00051Q-5L for qemu-devel@nongnu.org; Mon, 04 Jul 2016 06:40:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bK1IP-0007yt-6w for qemu-devel@nongnu.org; Mon, 04 Jul 2016 06:40:13 -0400 Received: from 6.mo3.mail-out.ovh.net ([188.165.43.173]:50805) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bK1IP-0007yX-0Z for qemu-devel@nongnu.org; Mon, 04 Jul 2016 06:40:09 -0400 Received: from player761.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo3.mail-out.ovh.net (Postfix) with ESMTP id 2D00DFFB9E5 for ; Mon, 4 Jul 2016 12:40:08 +0200 (CEST) References: <1467138270-32481-1-git-send-email-clg@kaod.org> <1467138270-32481-10-git-send-email-clg@kaod.org> <5778025A.9020608@gmail.com> <8ace1056-de8d-cfbb-9e63-e0e26df71952@kaod.org> From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= Message-ID: <30d38fa7-2434-5d02-232c-62439be1f84e@kaod.org> Date: Mon, 4 Jul 2016 11:50:38 +0200 MIME-Version: 1.0 In-Reply-To: <8ace1056-de8d-cfbb-9e63-e0e26df71952@kaod.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 9/9] tests: add a m25p80 test List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "mar.krzeminski" , Peter Maydell , Peter Crosthwaite Cc: kwolf@redhat.com, Andrew Jeffery , qemu-devel@nongnu.org, armbru@redhat.com, qemu-arm@nongnu.org >>> +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.