[PATCH 1/6] target/microblaze: Use the IEC binary prefix definitions

Philippe Mathieu-Daudé posted 6 patches 4 years, 8 months ago
[PATCH 1/6] target/microblaze: Use the IEC binary prefix definitions
Posted by Philippe Mathieu-Daudé 4 years, 8 months ago
IEC binary prefixes ease code review: the unit is explicit.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/microblaze/mmu.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/target/microblaze/mmu.c b/target/microblaze/mmu.c
index cc40f275eaf..1481e2769f1 100644
--- a/target/microblaze/mmu.c
+++ b/target/microblaze/mmu.c
@@ -19,14 +19,15 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "cpu.h"
 #include "exec/exec-all.h"
 
 static unsigned int tlb_decode_size(unsigned int f)
 {
     static const unsigned int sizes[] = {
-        1 * 1024, 4 * 1024, 16 * 1024, 64 * 1024, 256 * 1024,
-        1 * 1024 * 1024, 4 * 1024 * 1024, 16 * 1024 * 1024
+        1 * KiB, 4 * KiB, 16 * KiB, 64 * KiB, 256 * KiB,
+        1 * MiB, 4 * MiB, 16 * MiB
     };
     assert(f < ARRAY_SIZE(sizes));
     return sizes[f];
-- 
2.26.3

Re: [PATCH 1/6] target/microblaze: Use the IEC binary prefix definitions
Posted by Edgar E. Iglesias 4 years, 8 months ago
On Thu, Jun 03, 2021 at 11:03:05AM +0200, Philippe Mathieu-Daudé wrote:
> IEC binary prefixes ease code review: the unit is explicit.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>



> ---
>  target/microblaze/mmu.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/target/microblaze/mmu.c b/target/microblaze/mmu.c
> index cc40f275eaf..1481e2769f1 100644
> --- a/target/microblaze/mmu.c
> +++ b/target/microblaze/mmu.c
> @@ -19,14 +19,15 @@
>   */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "cpu.h"
>  #include "exec/exec-all.h"
>  
>  static unsigned int tlb_decode_size(unsigned int f)
>  {
>      static const unsigned int sizes[] = {
> -        1 * 1024, 4 * 1024, 16 * 1024, 64 * 1024, 256 * 1024,
> -        1 * 1024 * 1024, 4 * 1024 * 1024, 16 * 1024 * 1024
> +        1 * KiB, 4 * KiB, 16 * KiB, 64 * KiB, 256 * KiB,
> +        1 * MiB, 4 * MiB, 16 * MiB
>      };
>      assert(f < ARRAY_SIZE(sizes));
>      return sizes[f];
> -- 
> 2.26.3
> 

Re: [PATCH 1/6] target/microblaze: Use the IEC binary prefix definitions
Posted by Richard Henderson 4 years, 8 months ago
On 6/3/21 2:03 AM, Philippe Mathieu-Daudé wrote:
>   static unsigned int tlb_decode_size(unsigned int f)
>   {
>       static const unsigned int sizes[] = {
> -        1 * 1024, 4 * 1024, 16 * 1024, 64 * 1024, 256 * 1024,
> -        1 * 1024 * 1024, 4 * 1024 * 1024, 16 * 1024 * 1024
> +        1 * KiB, 4 * KiB, 16 * KiB, 64 * KiB, 256 * KiB,
> +        1 * MiB, 4 * MiB, 16 * MiB
>       };
>       assert(f < ARRAY_SIZE(sizes));
>       return sizes[f];

I guess this is clearer, but I'll also note that this is 4**f KiB, so could 
just as well be computed by

     assert(f < 8);
     return KiB << (f * 2);

Either way,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~

Re: [PATCH 1/6] target/microblaze: Use the IEC binary prefix definitions
Posted by Alistair Francis 4 years, 8 months ago
On Thu, Jun 3, 2021 at 7:03 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> IEC binary prefixes ease code review: the unit is explicit.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  target/microblaze/mmu.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/target/microblaze/mmu.c b/target/microblaze/mmu.c
> index cc40f275eaf..1481e2769f1 100644
> --- a/target/microblaze/mmu.c
> +++ b/target/microblaze/mmu.c
> @@ -19,14 +19,15 @@
>   */
>
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "cpu.h"
>  #include "exec/exec-all.h"
>
>  static unsigned int tlb_decode_size(unsigned int f)
>  {
>      static const unsigned int sizes[] = {
> -        1 * 1024, 4 * 1024, 16 * 1024, 64 * 1024, 256 * 1024,
> -        1 * 1024 * 1024, 4 * 1024 * 1024, 16 * 1024 * 1024
> +        1 * KiB, 4 * KiB, 16 * KiB, 64 * KiB, 256 * KiB,
> +        1 * MiB, 4 * MiB, 16 * MiB
>      };
>      assert(f < ARRAY_SIZE(sizes));
>      return sizes[f];
> --
> 2.26.3
>
>