[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 19/19] hw: m25p80: fixing individual test failure when tests are r
From: |
Cédric Le Goater |
Subject: |
[PULL 19/19] hw: m25p80: fixing individual test failure when tests are running in isolation |
Date: |
Wed, 22 Jun 2022 11:55:20 +0200 |
From: Iris Chen <irischenlj@fb.com>
Signed-off-by: Iris Chen <irischenlj@fb.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
tests/qtest/aspeed_smc-test.c | 74 +++++++++++++++++++++++++++++------
1 file changed, 63 insertions(+), 11 deletions(-)
diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c
index ec233315e6c6..b1e682db6545 100644
--- a/tests/qtest/aspeed_smc-test.c
+++ b/tests/qtest/aspeed_smc-test.c
@@ -135,6 +135,9 @@ static void flash_reset(void)
spi_ctrl_start_user();
writeb(ASPEED_FLASH_BASE, RESET_ENABLE);
writeb(ASPEED_FLASH_BASE, RESET_MEMORY);
+ writeb(ASPEED_FLASH_BASE, WREN);
+ writeb(ASPEED_FLASH_BASE, BULK_ERASE);
+ writeb(ASPEED_FLASH_BASE, WRDI);
spi_ctrl_stop_user();
spi_conf_remove(CONF_ENABLE_W0);
@@ -195,21 +198,41 @@ static void test_erase_sector(void)
spi_conf(CONF_ENABLE_W0);
+ /*
+ * Previous page should be full of 0xffs after backend is
+ * initialized
+ */
+ read_page(some_page_addr - FLASH_PAGE_SIZE, page);
+ for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
+ g_assert_cmphex(page[i], ==, 0xffffffff);
+ }
+
spi_ctrl_start_user();
- writeb(ASPEED_FLASH_BASE, WREN);
writeb(ASPEED_FLASH_BASE, EN_4BYTE_ADDR);
- writeb(ASPEED_FLASH_BASE, ERASE_SECTOR);
+ writeb(ASPEED_FLASH_BASE, WREN);
+ writeb(ASPEED_FLASH_BASE, PP);
writel(ASPEED_FLASH_BASE, make_be32(some_page_addr));
+
+ /* Fill the page with its own addresses */
+ for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
+ writel(ASPEED_FLASH_BASE, make_be32(some_page_addr + i * 4));
+ }
spi_ctrl_stop_user();
- /* Previous page should be full of zeroes as backend is not
- * initialized */
- read_page(some_page_addr - FLASH_PAGE_SIZE, page);
+ /* Check the page is correctly written */
+ read_page(some_page_addr, page);
for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
- g_assert_cmphex(page[i], ==, 0x0);
+ g_assert_cmphex(page[i], ==, some_page_addr + i * 4);
}
- /* But this one was erased */
+ spi_ctrl_start_user();
+ writeb(ASPEED_FLASH_BASE, WREN);
+ writeb(ASPEED_FLASH_BASE, EN_4BYTE_ADDR);
+ writeb(ASPEED_FLASH_BASE, ERASE_SECTOR);
+ writel(ASPEED_FLASH_BASE, make_be32(some_page_addr));
+ spi_ctrl_stop_user();
+
+ /* Check the page is erased */
read_page(some_page_addr, page);
for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
g_assert_cmphex(page[i], ==, 0xffffffff);
@@ -226,11 +249,31 @@ static void test_erase_all(void)
spi_conf(CONF_ENABLE_W0);
- /* Check some random page. Should be full of zeroes as backend is
- * not initialized */
+ /*
+ * Previous page should be full of 0xffs after backend is
+ * initialized
+ */
+ read_page(some_page_addr - FLASH_PAGE_SIZE, page);
+ for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
+ g_assert_cmphex(page[i], ==, 0xffffffff);
+ }
+
+ spi_ctrl_start_user();
+ writeb(ASPEED_FLASH_BASE, EN_4BYTE_ADDR);
+ writeb(ASPEED_FLASH_BASE, WREN);
+ writeb(ASPEED_FLASH_BASE, PP);
+ writel(ASPEED_FLASH_BASE, make_be32(some_page_addr));
+
+ /* Fill the page with its own addresses */
+ for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
+ writel(ASPEED_FLASH_BASE, make_be32(some_page_addr + i * 4));
+ }
+ spi_ctrl_stop_user();
+
+ /* Check the page is correctly written */
read_page(some_page_addr, page);
for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
- g_assert_cmphex(page[i], ==, 0x0);
+ g_assert_cmphex(page[i], ==, some_page_addr + i * 4);
}
spi_ctrl_start_user();
@@ -238,7 +281,7 @@ static void test_erase_all(void)
writeb(ASPEED_FLASH_BASE, BULK_ERASE);
spi_ctrl_stop_user();
- /* Recheck that some random page */
+ /* Check the page is erased */
read_page(some_page_addr, page);
for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
g_assert_cmphex(page[i], ==, 0xffffffff);
@@ -299,6 +342,14 @@ static void test_read_page_mem(void)
spi_conf(CONF_ENABLE_W0);
spi_ctrl_start_user();
writeb(ASPEED_FLASH_BASE, EN_4BYTE_ADDR);
+ writeb(ASPEED_FLASH_BASE, WREN);
+ writeb(ASPEED_FLASH_BASE, PP);
+ writel(ASPEED_FLASH_BASE, make_be32(my_page_addr));
+
+ /* Fill the page with its own addresses */
+ for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
+ writel(ASPEED_FLASH_BASE, make_be32(my_page_addr + i * 4));
+ }
spi_ctrl_stop_user();
spi_conf_remove(CONF_ENABLE_W0);
@@ -417,6 +468,7 @@ int main(int argc, char **argv)
qtest_add_func("/ast2400/smc/write_page_mem", test_write_page_mem);
qtest_add_func("/ast2400/smc/read_status_reg", test_read_status_reg);
+ flash_reset();
ret = g_test_run();
qtest_quit(global_qtest);
--
2.35.3
- [PULL 09/19] aspeed: i2c: Use reg array instead of individual vars, (continued)
- [PULL 09/19] aspeed: i2c: Use reg array instead of individual vars, Cédric Le Goater, 2022/06/22
- [PULL 11/19] aspeed: i2c: Add PKT_DONE IRQ to trace, Cédric Le Goater, 2022/06/22
- [PULL 12/19] aspeed: i2c: Move regs and helpers to header file, Cédric Le Goater, 2022/06/22
- [PULL 13/19] aspeed/i2c: Add ast1030 controller models, Cédric Le Goater, 2022/06/22
- [PULL 14/19] aspeed: Add I2C buses to AST1030 model, Cédric Le Goater, 2022/06/22
- [PULL 10/19] aspeed: i2c: Add new mode support, Cédric Le Goater, 2022/06/22
- [PULL 15/19] hw/i2c/aspeed: rework raise interrupt trace event, Cédric Le Goater, 2022/06/22
- [PULL 16/19] hw/i2c/aspeed: add DEV_ADDR in old register mode, Cédric Le Goater, 2022/06/22
- [PULL 17/19] aspeed/i2c: Enable SLAVE_ADDR_RX_MATCH always, Cédric Le Goater, 2022/06/22
- [PULL 18/19] aspeed/hace: Add missing newlines to unimp messages, Cédric Le Goater, 2022/06/22
- [PULL 19/19] hw: m25p80: fixing individual test failure when tests are running in isolation,
Cédric Le Goater <=
- Re: [PULL 00/19] aspeed queue, Richard Henderson, 2022/06/22