diff mbox series

[v2,12/18] test/qtest/aspeed_smc-test: Introducing a "page_addr" data field

Message ID 20241022094110.1574011-13-jamin_lin@aspeedtech.com (mailing list archive)
State New
Headers show
Series Fix write incorrect data into flash in user mode | expand

Commit Message

Jamin Lin Oct. 22, 2024, 9:41 a.m. UTC
Currently, these test cases used the hardcode offset 0x1400000 (0x14000 * 256)
which was beyond the 16MB flash size for flash page read/write command testing.
However, the default fmc flash model of ast1030-a1 EVB is "w25q80bl" whose size
is 1MB. To test all flash models, introduces a new page_addr member in TestData
structure, so users can set the offset for flash parge read/write command
testing.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
---
 tests/qtest/aspeed_smc-test.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

Comments

Cédric Le Goater Oct. 22, 2024, 1:48 p.m. UTC | #1
On 10/22/24 11:41, Jamin Lin wrote:
> Currently, these test cases used the hardcode offset 0x1400000 (0x14000 * 256)
> which was beyond the 16MB flash size for flash page read/write command testing.
> However, the default fmc flash model of ast1030-a1 EVB is "w25q80bl" whose size
> is 1MB. To test all flash models, introduces a new page_addr member in TestData

I will change : s/all/SoC/

> structure, so users can set the offset for flash parge read/write command
> testing.
> 
> Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>

with that,

Reviewed-by: Cédric Le Goater <clg@redhat.com>

Thanks,

C.


> ---
>   tests/qtest/aspeed_smc-test.c | 17 ++++++++++-------
>   1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c
> index b8ab20b43d..6db18451d2 100644
> --- a/tests/qtest/aspeed_smc-test.c
> +++ b/tests/qtest/aspeed_smc-test.c
> @@ -72,6 +72,7 @@ typedef struct TestData {
>       char *tmp_path;
>       uint8_t cs;
>       const char *node;
> +    uint32_t page_addr;
>   } TestData;
>   
>   /*
> @@ -256,7 +257,7 @@ static void assert_page_mem(const TestData *data, uint32_t addr,
>   static void test_erase_sector(const void *data)
>   {
>       const TestData *test_data = (const TestData *)data;
> -    uint32_t some_page_addr = 0x600 * FLASH_PAGE_SIZE;
> +    uint32_t some_page_addr = test_data->page_addr;
>       uint32_t page[FLASH_PAGE_SIZE / 4];
>       int i;
>   
> @@ -308,7 +309,7 @@ static void test_erase_sector(const void *data)
>   static void test_erase_all(const void *data)
>   {
>       const TestData *test_data = (const TestData *)data;
> -    uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE;
> +    uint32_t some_page_addr = test_data->page_addr;
>       uint32_t page[FLASH_PAGE_SIZE / 4];
>       int i;
>   
> @@ -358,8 +359,8 @@ static void test_erase_all(const void *data)
>   static void test_write_page(const void *data)
>   {
>       const TestData *test_data = (const TestData *)data;
> -    uint32_t my_page_addr = 0x14000 * FLASH_PAGE_SIZE; /* beyond 16MB */
> -    uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE;
> +    uint32_t my_page_addr = test_data->page_addr;
> +    uint32_t some_page_addr = my_page_addr + FLASH_PAGE_SIZE;
>       uint32_t page[FLASH_PAGE_SIZE / 4];
>       int i;
>   
> @@ -395,8 +396,8 @@ static void test_write_page(const void *data)
>   static void test_read_page_mem(const void *data)
>   {
>       const TestData *test_data = (const TestData *)data;
> -    uint32_t my_page_addr = 0x14000 * FLASH_PAGE_SIZE; /* beyond 16MB */
> -    uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE;
> +    uint32_t my_page_addr = test_data->page_addr;
> +    uint32_t some_page_addr = my_page_addr + FLASH_PAGE_SIZE;
>       uint32_t page[FLASH_PAGE_SIZE / 4];
>       int i;
>   
> @@ -438,7 +439,7 @@ static void test_read_page_mem(const void *data)
>   static void test_write_page_mem(const void *data)
>   {
>       const TestData *test_data = (const TestData *)data;
> -    uint32_t my_page_addr = 0x15000 * FLASH_PAGE_SIZE;
> +    uint32_t my_page_addr = test_data->page_addr;
>       uint32_t page[FLASH_PAGE_SIZE / 4];
>       int i;
>   
> @@ -679,6 +680,8 @@ static void test_palmetto_bmc(TestData *data)
>       data->jedec_id = 0x20ba19;
>       data->cs = 0;
>       data->node = "/machine/soc/fmc/ssi.0/child[0]";
> +    /* beyond 16MB */
> +    data->page_addr = 0x14000 * FLASH_PAGE_SIZE;
>   
>       qtest_add_data_func("/ast2400/smc/read_jedec", data, test_read_jedec);
>       qtest_add_data_func("/ast2400/smc/erase_sector", data, test_erase_sector);
Jamin Lin Oct. 23, 2024, 1:40 a.m. UTC | #2
Hi Cedric,

> Subject: Re: [PATCH v2 12/18] test/qtest/aspeed_smc-test: Introducing a
> "page_addr" data field
> 
> On 10/22/24 11:41, Jamin Lin wrote:
> > Currently, these test cases used the hardcode offset 0x1400000
> > (0x14000 * 256) which was beyond the 16MB flash size for flash page
> read/write command testing.
> > However, the default fmc flash model of ast1030-a1 EVB is "w25q80bl"
> > whose size is 1MB. To test all flash models, introduces a new
> > page_addr member in TestData
> 
> I will change : s/all/SoC/
> 
Thanks for help.
If I need to re-send v3 patch, I will fix it.
Thanks-Jamin

> > structure, so users can set the offset for flash parge read/write 
> > command testing.
> >
> > Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
> 
> with that,
> 
> Reviewed-by: Cédric Le Goater <clg@redhat.com>
> 
> Thanks,
> 
> C.
> 
> 
> > ---
> >   tests/qtest/aspeed_smc-test.c | 17 ++++++++++-------
> >   1 file changed, 10 insertions(+), 7 deletions(-)
> >
> > diff --git a/tests/qtest/aspeed_smc-test.c
> > b/tests/qtest/aspeed_smc-test.c index b8ab20b43d..6db18451d2 100644
> > --- a/tests/qtest/aspeed_smc-test.c
> > +++ b/tests/qtest/aspeed_smc-test.c
> > @@ -72,6 +72,7 @@ typedef struct TestData {
> >       char *tmp_path;
> >       uint8_t cs;
> >       const char *node;
> > +    uint32_t page_addr;
> >   } TestData;
> >
> >   /*
> > @@ -256,7 +257,7 @@ static void assert_page_mem(const TestData *data,
> uint32_t addr,
> >   static void test_erase_sector(const void *data)
> >   {
> >       const TestData *test_data = (const TestData *)data;
> > -    uint32_t some_page_addr = 0x600 * FLASH_PAGE_SIZE;
> > +    uint32_t some_page_addr = test_data->page_addr;
> >       uint32_t page[FLASH_PAGE_SIZE / 4];
> >       int i;
> >
> > @@ -308,7 +309,7 @@ static void test_erase_sector(const void *data)
> >   static void test_erase_all(const void *data)
> >   {
> >       const TestData *test_data = (const TestData *)data;
> > -    uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE;
> > +    uint32_t some_page_addr = test_data->page_addr;
> >       uint32_t page[FLASH_PAGE_SIZE / 4];
> >       int i;
> >
> > @@ -358,8 +359,8 @@ static void test_erase_all(const void *data)
> >   static void test_write_page(const void *data)
> >   {
> >       const TestData *test_data = (const TestData *)data;
> > -    uint32_t my_page_addr = 0x14000 * FLASH_PAGE_SIZE; /* beyond
> 16MB */
> > -    uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE;
> > +    uint32_t my_page_addr = test_data->page_addr;
> > +    uint32_t some_page_addr = my_page_addr + FLASH_PAGE_SIZE;
> >       uint32_t page[FLASH_PAGE_SIZE / 4];
> >       int i;
> >
> > @@ -395,8 +396,8 @@ static void test_write_page(const void *data)
> >   static void test_read_page_mem(const void *data)
> >   {
> >       const TestData *test_data = (const TestData *)data;
> > -    uint32_t my_page_addr = 0x14000 * FLASH_PAGE_SIZE; /* beyond
> 16MB */
> > -    uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE;
> > +    uint32_t my_page_addr = test_data->page_addr;
> > +    uint32_t some_page_addr = my_page_addr + FLASH_PAGE_SIZE;
> >       uint32_t page[FLASH_PAGE_SIZE / 4];
> >       int i;
> >
> > @@ -438,7 +439,7 @@ static void test_read_page_mem(const void *data)
> >   static void test_write_page_mem(const void *data)
> >   {
> >       const TestData *test_data = (const TestData *)data;
> > -    uint32_t my_page_addr = 0x15000 * FLASH_PAGE_SIZE;
> > +    uint32_t my_page_addr = test_data->page_addr;
> >       uint32_t page[FLASH_PAGE_SIZE / 4];
> >       int i;
> >
> > @@ -679,6 +680,8 @@ static void test_palmetto_bmc(TestData *data)
> >       data->jedec_id = 0x20ba19;
> >       data->cs = 0;
> >       data->node = "/machine/soc/fmc/ssi.0/child[0]";
> > +    /* beyond 16MB */
> > +    data->page_addr = 0x14000 * FLASH_PAGE_SIZE;
> >
> >       qtest_add_data_func("/ast2400/smc/read_jedec", data,
> test_read_jedec);
> >       qtest_add_data_func("/ast2400/smc/erase_sector", data,
> > test_erase_sector);
diff mbox series

Patch

diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c
index b8ab20b43d..6db18451d2 100644
--- a/tests/qtest/aspeed_smc-test.c
+++ b/tests/qtest/aspeed_smc-test.c
@@ -72,6 +72,7 @@  typedef struct TestData {
     char *tmp_path;
     uint8_t cs;
     const char *node;
+    uint32_t page_addr;
 } TestData;
 
 /*
@@ -256,7 +257,7 @@  static void assert_page_mem(const TestData *data, uint32_t addr,
 static void test_erase_sector(const void *data)
 {
     const TestData *test_data = (const TestData *)data;
-    uint32_t some_page_addr = 0x600 * FLASH_PAGE_SIZE;
+    uint32_t some_page_addr = test_data->page_addr;
     uint32_t page[FLASH_PAGE_SIZE / 4];
     int i;
 
@@ -308,7 +309,7 @@  static void test_erase_sector(const void *data)
 static void test_erase_all(const void *data)
 {
     const TestData *test_data = (const TestData *)data;
-    uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE;
+    uint32_t some_page_addr = test_data->page_addr;
     uint32_t page[FLASH_PAGE_SIZE / 4];
     int i;
 
@@ -358,8 +359,8 @@  static void test_erase_all(const void *data)
 static void test_write_page(const void *data)
 {
     const TestData *test_data = (const TestData *)data;
-    uint32_t my_page_addr = 0x14000 * FLASH_PAGE_SIZE; /* beyond 16MB */
-    uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE;
+    uint32_t my_page_addr = test_data->page_addr;
+    uint32_t some_page_addr = my_page_addr + FLASH_PAGE_SIZE;
     uint32_t page[FLASH_PAGE_SIZE / 4];
     int i;
 
@@ -395,8 +396,8 @@  static void test_write_page(const void *data)
 static void test_read_page_mem(const void *data)
 {
     const TestData *test_data = (const TestData *)data;
-    uint32_t my_page_addr = 0x14000 * FLASH_PAGE_SIZE; /* beyond 16MB */
-    uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE;
+    uint32_t my_page_addr = test_data->page_addr;
+    uint32_t some_page_addr = my_page_addr + FLASH_PAGE_SIZE;
     uint32_t page[FLASH_PAGE_SIZE / 4];
     int i;
 
@@ -438,7 +439,7 @@  static void test_read_page_mem(const void *data)
 static void test_write_page_mem(const void *data)
 {
     const TestData *test_data = (const TestData *)data;
-    uint32_t my_page_addr = 0x15000 * FLASH_PAGE_SIZE;
+    uint32_t my_page_addr = test_data->page_addr;
     uint32_t page[FLASH_PAGE_SIZE / 4];
     int i;
 
@@ -679,6 +680,8 @@  static void test_palmetto_bmc(TestData *data)
     data->jedec_id = 0x20ba19;
     data->cs = 0;
     data->node = "/machine/soc/fmc/ssi.0/child[0]";
+    /* beyond 16MB */
+    data->page_addr = 0x14000 * FLASH_PAGE_SIZE;
 
     qtest_add_data_func("/ast2400/smc/read_jedec", data, test_read_jedec);
     qtest_add_data_func("/ast2400/smc/erase_sector", data, test_erase_sector);