[Qemu-devel] [PATCH 07/10] mips_malta: Clean up definition of flash memory size somewhat

Markus Armbruster posted 10 patches 6 years, 11 months ago
Maintainers: Aurelien Jarno <aurelien@aurel32.net>, Jan Kiszka <jan.kiszka@web.de>, Magnus Damm <magnus.damm@gmail.com>, Aleksandar Markovic <amarkovic@wavecomp.com>, Eduardo Habkost <ehabkost@redhat.com>, Aleksandar Rikalo <arikalo@wavecomp.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Kevin Wolf <kwolf@redhat.com>, Alistair Francis <alistair@alistair23.me>, "Philippe Mathieu-Daudé" <f4bug@amsat.org>, Peter Maydell <peter.maydell@linaro.org>, BALATON Zoltan <balaton@eik.bme.hu>, Andrzej Zaborowski <balrogg@gmail.com>, Richard Henderson <rth@twiddle.net>, Michael Walle <michael@walle.cc>, Antony Pavlov <antonynpavlov@gmail.com>, Max Filippov <jcmvbkbc@gmail.com>, "Michael S. Tsirkin" <mst@redhat.com>, Max Reitz <mreitz@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, David Gibson <david@gibson.dropbear.id.au>
There is a newer version of this series
[Qemu-devel] [PATCH 07/10] mips_malta: Clean up definition of flash memory size somewhat
Posted by Markus Armbruster 6 years, 11 months ago
pflash_cfi01_register() takes a size in bytes, a block size in bytes
and a number of blocks.  mips_malta_init() passes BIOS_SIZE, 65536,
FLASH_SIZE >> 16.  Actually consistent only because BIOS_SIZE (defined
in include/hw/mips/bios.h as (4 * MiB)) matches FLASH_SIZE (defined
locally as 0x400000).  Confusing all the same.

Pass FLASH_SIZE instead of BIOS_SIZE.

There are more uses of BIOS_SIZE, but I don't sufficiently understand
them to attempt cleanup.

Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Aleksandar Rikalo <arikalo@wavecomp.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/mips/mips_malta.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index fff5ed19bd..65cdda4881 100644
--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -1269,12 +1269,12 @@ void mips_malta_init(MachineState *machine)
     if (dinfo) {
         printf("Register parallel flash %d size " TARGET_FMT_lx " at "
                "addr %08llx '%s' %x\n",
-               fl_idx, bios_size, FLASH_ADDRESS,
+               fl_idx, FLASH_SIZE, FLASH_ADDRESS,
                blk_name(dinfo->bdrv), fl_sectors);
     }
 #endif
     fl = pflash_cfi01_register(FLASH_ADDRESS, NULL, "mips_malta.bios",
-                               BIOS_SIZE,
+                               FLASH_SIZE,
                                dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
                                65536, fl_sectors,
                                4, 0x0000, 0x0000, 0x0000, 0x0000, be);
-- 
2.17.2


Re: [Qemu-devel] [PATCH 07/10] mips_malta: Clean up definition of flash memory size somewhat
Posted by Philippe Mathieu-Daudé 6 years, 11 months ago
On 2/18/19 1:56 PM, Markus Armbruster wrote:
> pflash_cfi01_register() takes a size in bytes, a block size in bytes
> and a number of blocks.  mips_malta_init() passes BIOS_SIZE, 65536,
> FLASH_SIZE >> 16.  Actually consistent only because BIOS_SIZE (defined
> in include/hw/mips/bios.h as (4 * MiB)) matches FLASH_SIZE (defined
> locally as 0x400000).  Confusing all the same.
> 
> Pass FLASH_SIZE instead of BIOS_SIZE.

Your cleanup is correct.

> 
> There are more uses of BIOS_SIZE, but I don't sufficiently understand
> them to attempt cleanup.

BIOS_SIZE is a MIPS architecture definition, incorrectly used around.
This simply means "Top of 32bit address space - Boot Vector address".
There is nothing wrong in plugging bigger/smaller flashes around the
boot vector.
(I have a series cleaning this definition, but I'm throttling my MIPS
apports).

> 
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: Aleksandar Rikalo <arikalo@wavecomp.com>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  hw/mips/mips_malta.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
> index fff5ed19bd..65cdda4881 100644
> --- a/hw/mips/mips_malta.c
> +++ b/hw/mips/mips_malta.c
> @@ -1269,12 +1269,12 @@ void mips_malta_init(MachineState *machine)
>      if (dinfo) {
>          printf("Register parallel flash %d size " TARGET_FMT_lx " at "
>                 "addr %08llx '%s' %x\n",
> -               fl_idx, bios_size, FLASH_ADDRESS,
> +               fl_idx, FLASH_SIZE, FLASH_ADDRESS,
>                 blk_name(dinfo->bdrv), fl_sectors);
>      }
>  #endif
>      fl = pflash_cfi01_register(FLASH_ADDRESS, NULL, "mips_malta.bios",
> -                               BIOS_SIZE,
> +                               FLASH_SIZE,
>                                 dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
>                                 65536, fl_sectors,
>                                 4, 0x0000, 0x0000, 0x0000, 0x0000, be);
> 

Does that mean you can remove the "hw/mips/bios.h" include now?

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Re: [Qemu-devel] [PATCH 07/10] mips_malta: Clean up definition of flash memory size somewhat
Posted by Markus Armbruster 6 years, 11 months ago
Philippe Mathieu-Daudé <philmd@redhat.com> writes:

> On 2/18/19 1:56 PM, Markus Armbruster wrote:
>> pflash_cfi01_register() takes a size in bytes, a block size in bytes
>> and a number of blocks.  mips_malta_init() passes BIOS_SIZE, 65536,
>> FLASH_SIZE >> 16.  Actually consistent only because BIOS_SIZE (defined
>> in include/hw/mips/bios.h as (4 * MiB)) matches FLASH_SIZE (defined
>> locally as 0x400000).  Confusing all the same.
>> 
>> Pass FLASH_SIZE instead of BIOS_SIZE.
>
> Your cleanup is correct.
>
>> 
>> There are more uses of BIOS_SIZE, but I don't sufficiently understand
>> them to attempt cleanup.
>
> BIOS_SIZE is a MIPS architecture definition, incorrectly used around.
> This simply means "Top of 32bit address space - Boot Vector address".
> There is nothing wrong in plugging bigger/smaller flashes around the
> boot vector.
> (I have a series cleaning this definition, but I'm throttling my MIPS
> apports).
>
>> 
>> Cc: Aurelien Jarno <aurelien@aurel32.net>
>> Cc: Aleksandar Rikalo <arikalo@wavecomp.com>
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>  hw/mips/mips_malta.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
>> index fff5ed19bd..65cdda4881 100644
>> --- a/hw/mips/mips_malta.c
>> +++ b/hw/mips/mips_malta.c
>> @@ -1269,12 +1269,12 @@ void mips_malta_init(MachineState *machine)
>>      if (dinfo) {
>>          printf("Register parallel flash %d size " TARGET_FMT_lx " at "
>>                 "addr %08llx '%s' %x\n",
>> -               fl_idx, bios_size, FLASH_ADDRESS,
>> +               fl_idx, FLASH_SIZE, FLASH_ADDRESS,
>>                 blk_name(dinfo->bdrv), fl_sectors);
>>      }
>>  #endif
>>      fl = pflash_cfi01_register(FLASH_ADDRESS, NULL, "mips_malta.bios",
>> -                               BIOS_SIZE,
>> +                               FLASH_SIZE,
>>                                 dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
>>                                 65536, fl_sectors,
>>                                 4, 0x0000, 0x0000, 0x0000, 0x0000, be);
>> 
>
> Does that mean you can remove the "hw/mips/bios.h" include now?

No, since there are more uses of BIOS_SIZE in this file.  They feel
inappropriate to me, but I don't feel confident enough to attempt
cleanup.

> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Thanks!

Re: [Qemu-devel] [PATCH 07/10] mips_malta: Clean up definition of flash memory size somewhat
Posted by Philippe Mathieu-Daudé 6 years, 11 months ago
On 2/19/19 2:43 PM, Markus Armbruster wrote:
> Philippe Mathieu-Daudé <philmd@redhat.com> writes:
> 
>> On 2/18/19 1:56 PM, Markus Armbruster wrote:
>>> pflash_cfi01_register() takes a size in bytes, a block size in bytes
>>> and a number of blocks.  mips_malta_init() passes BIOS_SIZE, 65536,
>>> FLASH_SIZE >> 16.  Actually consistent only because BIOS_SIZE (defined
>>> in include/hw/mips/bios.h as (4 * MiB)) matches FLASH_SIZE (defined
>>> locally as 0x400000).  Confusing all the same.
>>>
>>> Pass FLASH_SIZE instead of BIOS_SIZE.
>>
>> Your cleanup is correct.
>>
>>>
>>> There are more uses of BIOS_SIZE, but I don't sufficiently understand
>>> them to attempt cleanup.
>>
>> BIOS_SIZE is a MIPS architecture definition, incorrectly used around.
>> This simply means "Top of 32bit address space - Boot Vector address".
>> There is nothing wrong in plugging bigger/smaller flashes around the
>> boot vector.
>> (I have a series cleaning this definition, but I'm throttling my MIPS
>> apports).
>>
>>>
>>> Cc: Aurelien Jarno <aurelien@aurel32.net>
>>> Cc: Aleksandar Rikalo <arikalo@wavecomp.com>
>>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>>> ---
>>>  hw/mips/mips_malta.c | 4 ++--
>>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
>>> index fff5ed19bd..65cdda4881 100644
>>> --- a/hw/mips/mips_malta.c
>>> +++ b/hw/mips/mips_malta.c
>>> @@ -1269,12 +1269,12 @@ void mips_malta_init(MachineState *machine)
>>>      if (dinfo) {
>>>          printf("Register parallel flash %d size " TARGET_FMT_lx " at "
>>>                 "addr %08llx '%s' %x\n",
>>> -               fl_idx, bios_size, FLASH_ADDRESS,
>>> +               fl_idx, FLASH_SIZE, FLASH_ADDRESS,
>>>                 blk_name(dinfo->bdrv), fl_sectors);
>>>      }
>>>  #endif
>>>      fl = pflash_cfi01_register(FLASH_ADDRESS, NULL, "mips_malta.bios",
>>> -                               BIOS_SIZE,
>>> +                               FLASH_SIZE,
>>>                                 dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
>>>                                 65536, fl_sectors,
>>>                                 4, 0x0000, 0x0000, 0x0000, 0x0000, be);
>>>
>>
>> Does that mean you can remove the "hw/mips/bios.h" include now?
> 
> No, since there are more uses of BIOS_SIZE in this file.  They feel
> inappropriate to me, but I don't feel confident enough to attempt
> cleanup.

OK, since I already did it twice, I'll do it once your work get merged.

> 
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> 
> Thanks!
> 

Re: [Qemu-devel] [PATCH 07/10] mips_malta: Clean up definition of flash memory size somewhat
Posted by Alex Bennée 6 years, 11 months ago
Markus Armbruster <armbru@redhat.com> writes:

> pflash_cfi01_register() takes a size in bytes, a block size in bytes
> and a number of blocks.  mips_malta_init() passes BIOS_SIZE, 65536,
> FLASH_SIZE >> 16.  Actually consistent only because BIOS_SIZE (defined
> in include/hw/mips/bios.h as (4 * MiB)) matches FLASH_SIZE (defined
> locally as 0x400000).  Confusing all the same.
>
> Pass FLASH_SIZE instead of BIOS_SIZE.
>
> There are more uses of BIOS_SIZE, but I don't sufficiently understand
> them to attempt cleanup.
>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: Aleksandar Rikalo <arikalo@wavecomp.com>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  hw/mips/mips_malta.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
> index fff5ed19bd..65cdda4881 100644
> --- a/hw/mips/mips_malta.c
> +++ b/hw/mips/mips_malta.c
> @@ -1269,12 +1269,12 @@ void mips_malta_init(MachineState *machine)
>      if (dinfo) {
>          printf("Register parallel flash %d size " TARGET_FMT_lx " at "
>                 "addr %08llx '%s' %x\n",
> -               fl_idx, bios_size, FLASH_ADDRESS,
> +               fl_idx, FLASH_SIZE, FLASH_ADDRESS,
>                 blk_name(dinfo->bdrv), fl_sectors);
>      }
>  #endif
>      fl = pflash_cfi01_register(FLASH_ADDRESS, NULL, "mips_malta.bios",
> -                               BIOS_SIZE,
> +                               FLASH_SIZE,
>                                 dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
>                                 65536, fl_sectors,
>                                 4, 0x0000, 0x0000, 0x0000, 0x0000, be);


--
Alex Bennée