All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions
@ 2018-06-11  1:14 Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 01/40] include: Add IEC binary prefixes in "qemu/units.h" Philippe Mathieu-Daudé
                   ` (41 more replies)
  0 siblings, 42 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil, Nikunj A Dadhania
  Cc: Philippe Mathieu-Daudé,
	qemu-arm, qemu-block, qemu-devel, qemu-ppc, qemu-s390x,
	qemu-trivial, Fabien Chouteau, Alistair Francis, Aurelien Jarno,
	Anthony Perard, Christian Borntraeger, Marek Vasut,
	Sagar Karandikar, David Gibson, Antony Pavlov, Artyom Tarasenko,
	Andrzej Zaborowski, Beniamino Galvani, Peter Crosthwaite,
	Chris Wulff, Dmitry Fleytman, Edgar E . Iglesias, Igor Mitsyanko,
	Max Filippov, Magnus Damm, Marcel Apfelbaum, Subbaraya Sundeep,
	Alberto Garcia, Mark Cave-Ayland, Keith Busch,
	Stefano Stabellini, Peter Maydell, Stefan Berger,
	Bastian Koppelmann, Paul Burton, Yongbok Kim, Peter Chubb,
	Yuval Shaia, Hervé Poussineau, Alex Williamson,
	Markus Armbruster, Cornelia Huck, David Hildenbrand, Eric Blake,
	Eduardo Habkost, Fam Zheng, Igor Mammedov, Jason Wang,
	Gerd Hoffmann, Kevin Wolf, Max Reitz, Michael S . Tsirkin,
	Paolo Bonzini, Michael Clark, Palmer Dabbelt, Jiri Slaby,
	Alexander Graf, Richard Henderson, Michael Walle, Jan Kiszka

Hi,

This series:

- split the byte-based definitions from "qemu/cutils.h" to "qemu/units.h"
  (this now triggers WARNING: 1 added file, does MAINTAINERS need updating?)
- clean hw/ includes;
- replace different constants used for byte size with their corresponding
  IEC binary prefix definitions.

Since v3:
- use IEC binary prefix definitions (Stefan Weil)
- rebased
- added R-b tags

Since v2:
- use "qemu/units.h" instead of "qemu/cunits.h" (Daniel P. Berrangé)
- avoid rebuilding the world including "qemu/units.h" in "hw/hw.h" (Thomas Huth)
- more constant replaced

Since v1:
- corrected Xen mult -> div (Alan Robinson)
- tagged 'include "qemu/cunits.h" in "hw/hw.h" as RFC
- fixed mips_r4k 'params_size' (Thomas Huth)
- added command used to generate patch in each commit (Alistair Francis)
- use G_BYTE for the raspi3 machine
- added Reviewed-by tags

Regards,

Phil.

Philippe Mathieu-Daudé (40):
  include: Add IEC binary prefixes in "qemu/units.h"
  vdi: Use definitions from "qemu/units.h"
  x86/cpu: Use definitions from "qemu/units.h"
  checkpatch: Recognize IEC binary prefix definitions
  hw: Use IEC binary prefix definitions from "qemu/units.h"
  hw: Directly use "qemu/units.h" instead of "qemu/cutils.h"
  hw/ivshmem: Use the IEC binary prefix definitions
  hw/ipack: Use the IEC binary prefix definitions
  hw/scsi: Use the IEC binary prefix definitions
  hw/smbios: Use the IEC binary prefix definitions
  hw/xen: Use the IEC binary prefix definitions
  hw/tpm: Use the IEC binary prefix definitions
  hw/block: Use the IEC binary prefix definitions
  hw/display: Use the IEC binary prefix definitions
  hw/misc: Use the IEC binary prefix definitions
  hw/riscv: Use the IEC binary prefix definitions
  hw/m68k: Use the IEC binary prefix definitions
  hw/sparc: Use the IEC binary prefix definitions
  hw/s390x: Use the IEC binary prefix definitions
  hw/hppa: Use the IEC binary prefix definitions
  hw/xtensa: Use the IEC binary prefix definitions
  hw/alpha: Use the IEC binary prefix definitions
  hw/tricore: Use the IEC binary prefix definitions
  hw/microblaze: Use the IEC binary prefix definitions
  hw/nios2: Use the IEC binary prefix definitions
  hw/cris: Use the IEC binary prefix definitions
  hw/lm32: Use the IEC binary prefix definitions
  hw/sh4: Use the IEC binary prefix definitions
  hw/mips/r4k: Constify params_size
  hw/mips: Use the IEC binary prefix definitions
  hw/arm: Use the IEC binary prefix definitions
  hw/ppc: Use the IEC binary prefix definitions
  hw/i386: Use the IEC binary prefix definitions
  hw/net: Use the IEC binary prefix definitions
  hw/usb: Use the IEC binary prefix definitions
  hw/sd: Use the IEC binary prefix definitions
  hw/vfio: Use the IEC binary prefix definitions
  hw/virtio: Use the IEC binary prefix definitions
  hw/rdma: Use the IEC binary prefix definitions
  cutils: Do not include "qemu/units.h" directly

 hw/net/ne2000.h                          |  5 ++--
 hw/ppc/mac.h                             |  3 ++-
 hw/rdma/vmw/pvrdma.h                     |  3 ++-
 include/hw/acpi/tpm.h                    |  3 ++-
 include/hw/arm/fsl-imx7.h                |  5 ++--
 include/hw/arm/stm32f205_soc.h           |  5 ++--
 include/hw/display/xlnx_dp.h             |  5 ++--
 include/hw/i386/ich9.h                   |  3 ++-
 include/hw/intc/mips_gic.h               |  3 ++-
 include/hw/mips/bios.h                   |  3 ++-
 include/hw/net/allwinner_emac.h          |  5 ++--
 include/hw/ppc/spapr.h                   |  5 ++--
 include/hw/virtio/virtio-net.h           |  3 ++-
 include/qemu/cutils.h                    |  7 ------
 include/qemu/units.h                     | 20 ++++++++++++++++
 block/vdi.c                              |  8 +++----
 hw/alpha/typhoon.c                       | 17 +++++++-------
 hw/arm/bcm2835_peripherals.c             |  3 ++-
 hw/arm/boot.c                            |  7 +++---
 hw/arm/collie.c                          |  5 ++--
 hw/arm/digic_boards.c                    |  7 +++---
 hw/arm/exynos4_boards.c                  |  3 ++-
 hw/arm/gumstix.c                         |  3 ++-
 hw/arm/integratorcp.c                    |  3 ++-
 hw/arm/mainstone.c                       |  3 ++-
 hw/arm/msf2-soc.c                        |  6 ++---
 hw/arm/msf2-som.c                        |  8 +++----
 hw/arm/musicpal.c                        |  9 +++----
 hw/arm/omap_sx1.c                        | 11 +++++----
 hw/arm/raspi.c                           |  5 ++--
 hw/arm/smmu-common.c                     |  3 ++-
 hw/arm/stellaris.c                       |  5 ++--
 hw/arm/versatilepb.c                     |  5 ++--
 hw/arm/vexpress.c                        |  7 +++---
 hw/arm/virt.c                            |  5 ++--
 hw/arm/xilinx_zynq.c                     |  7 +++---
 hw/block/m25p80.c                        |  5 ++--
 hw/block/nvme.c                          |  3 ++-
 hw/block/tc58128.c                       |  3 ++-
 hw/block/xen_disk.c                      |  5 ++--
 hw/core/loader-fit.c                     |  3 ++-
 hw/core/machine.c                        |  4 ++--
 hw/cris/axis_dev88.c                     |  3 ++-
 hw/display/bochs-display.c               |  9 +++----
 hw/display/cirrus_vga.c                  | 10 ++++----
 hw/display/g364fb.c                      |  4 ++--
 hw/display/qxl.c                         | 28 ++++++++++------------
 hw/display/sm501.c                       | 16 ++++++-------
 hw/display/vga-isa-mm.c                  |  5 ++--
 hw/display/vga.c                         |  5 ++--
 hw/display/virtio-gpu.c                  |  4 ++--
 hw/display/vmware_vga.c                  |  3 ++-
 hw/display/xenfb.c                       |  3 ++-
 hw/hppa/dino.c                           |  3 ++-
 hw/hppa/machine.c                        | 12 +++++-----
 hw/i386/acpi-build.c                     |  5 ++--
 hw/i386/pc.c                             | 19 ++++++++-------
 hw/i386/pc_piix.c                        |  4 ++--
 hw/i386/pc_q35.c                         |  3 ++-
 hw/i386/pc_sysfw.c                       |  9 +++----
 hw/i386/xen/xen-mapcache.c               |  3 ++-
 hw/intc/apic_common.c                    |  3 ++-
 hw/ipack/tpci200.c                       |  5 ++--
 hw/lm32/lm32_boards.c                    | 13 +++++-----
 hw/lm32/milkymist.c                      | 10 ++++----
 hw/m68k/mcf5208.c                        |  3 ++-
 hw/microblaze/petalogix_ml605_mmu.c      |  7 +++---
 hw/microblaze/petalogix_s3adsp1800_mmu.c |  7 +++---
 hw/mips/boston.c                         | 30 ++++++++++++------------
 hw/mips/mips_fulong2e.c                  |  7 +++---
 hw/mips/mips_malta.c                     | 23 ++++++++++--------
 hw/mips/mips_r4k.c                       | 15 ++++++------
 hw/misc/aspeed_sdmc.c                    |  9 +++----
 hw/misc/auxbus.c                         |  3 ++-
 hw/misc/edu.c                            |  3 ++-
 hw/misc/imx7_gpr.c                       |  3 ++-
 hw/misc/ivshmem.c                        |  3 ++-
 hw/misc/mips_itu.c                       |  3 ++-
 hw/misc/omap_gpmc.c                      |  5 ++--
 hw/net/e1000e.c                          |  7 +++---
 hw/net/e1000x_common.c                   |  3 ++-
 hw/net/eepro100.c                        |  3 +--
 hw/nios2/boot.c                          |  6 ++---
 hw/nvram/spapr_nvram.c                   | 10 ++++----
 hw/pci-host/designware.c                 |  3 ++-
 hw/pci-host/gpex.c                       |  3 ++-
 hw/pci-host/piix.c                       |  5 ++--
 hw/pci-host/prep.c                       |  3 ++-
 hw/pci-host/q35.c                        | 17 +++++++-------
 hw/pci-host/xilinx-pcie.c                |  5 ++--
 hw/ppc/e500.c                            | 13 +++++-----
 hw/ppc/e500plat.c                        |  3 ++-
 hw/ppc/mac_newworld.c                    |  1 -
 hw/ppc/mac_oldworld.c                    |  9 ++++---
 hw/ppc/pnv.c                             |  6 ++---
 hw/ppc/ppc405_boards.c                   |  9 +++----
 hw/ppc/ppc405_uc.c                       |  7 +++---
 hw/ppc/ppc440_bamboo.c                   |  6 +++--
 hw/ppc/ppc440_uc.c                       | 28 +++++++++++-----------
 hw/ppc/ppc4xx_devs.c                     | 22 +++++++++--------
 hw/ppc/ppce500_spin.c                    |  3 ++-
 hw/ppc/prep.c                            |  6 ++---
 hw/ppc/rs6000_mc.c                       | 13 +++++-----
 hw/ppc/sam460ex.c                        | 20 +++++++++-------
 hw/ppc/spapr.c                           | 12 +++++-----
 hw/ppc/spapr_rtas.c                      |  2 +-
 hw/ppc/virtex_ml507.c                    |  7 +++---
 hw/riscv/virt.c                          |  3 ++-
 hw/s390x/s390-skeys.c                    |  3 ++-
 hw/s390x/s390-stattrib.c                 |  3 ++-
 hw/s390x/sclp.c                          |  4 ++--
 hw/scsi/scsi-disk.c                      |  9 +++----
 hw/sd/sd.c                               |  8 +++----
 hw/sd/sdhci.c                            |  6 ++---
 hw/sh4/r2d.c                             |  3 ++-
 hw/smbios/smbios.c                       | 15 +++++-------
 hw/sparc/leon3.c                         |  9 +++----
 hw/sparc/sun4m.c                         |  9 ++++---
 hw/sparc64/niagara.c                     |  3 ++-
 hw/sparc64/sun4u.c                       |  4 ++--
 hw/ssi/aspeed_smc.c                      | 29 ++++++++++++-----------
 hw/tricore/tricore_testboard.c           | 13 +++++-----
 hw/usb/ccid-card-passthru.c              |  5 ++--
 hw/usb/combined-packet.c                 |  3 ++-
 hw/usb/dev-smartcard-reader.c            |  3 ++-
 hw/usb/redirect.c                        |  3 ++-
 hw/vfio/pci-quirks.c                     |  9 +++----
 hw/vfio/pci.c                            |  3 ++-
 hw/xenpv/xen_domainbuild.c               | 13 +++++-----
 hw/xtensa/xtfpga.c                       |  5 ++--
 target/i386/cpu.c                        |  4 +---
 tests/test-cutils.c                      | 18 +++++++-------
 tests/test-keyval.c                      |  6 ++---
 tests/test-qemu-opts.c                   |  7 +++---
 scripts/checkpatch.pl                    |  1 +
 135 files changed, 533 insertions(+), 431 deletions(-)
 create mode 100644 include/qemu/units.h

-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 01/40] include: Add IEC binary prefixes in "qemu/units.h"
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-12 20:42   ` Richard Henderson
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 02/40] vdi: Use definitions from "qemu/units.h" Philippe Mathieu-Daudé
                   ` (40 subsequent siblings)
  41 siblings, 1 reply; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Nikunj A Dadhania, Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-trivial

Loosely based on 076b35b5a56.

Suggested-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
I suppose the following warning is irrelevant:

  WARNING: 1 added file, does MAINTAINERS need updating

 include/qemu/units.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 include/qemu/units.h

diff --git a/include/qemu/units.h b/include/qemu/units.h
new file mode 100644
index 0000000000..e3a39ed59e
--- /dev/null
+++ b/include/qemu/units.h
@@ -0,0 +1,20 @@
+/*
+ * IEC binary prefixes definitions
+ *
+ * Copyright (C) 2015 Nikunj A Dadhania, IBM Corporation
+ * Copyright (C) 2018 Philippe Mathieu-Daudé <f4bug@amsat.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef QEMU_UNITS_H
+#define QEMU_UNITS_H
+
+#define KiB     (1ULL << 10)
+#define MiB     (1ULL << 20)
+#define GiB     (1ULL << 30)
+#define TiB     (1ULL << 40)
+#define PiB     (1ULL << 50)
+#define EiB     (1ULL << 60)
+
+#endif
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 02/40] vdi: Use definitions from "qemu/units.h"
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 01/40] include: Add IEC binary prefixes in "qemu/units.h" Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11 19:27   ` Stefan Weil
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 03/40] x86/cpu: " Philippe Mathieu-Daudé
                   ` (39 subsequent siblings)
  41 siblings, 1 reply; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Kevin Wolf, Max Reitz, open list:VDI

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

diff --git a/block/vdi.c b/block/vdi.c
index 668af0a828..35b51dc5c5 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -50,6 +50,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qobject-input-visitor.h"
@@ -83,9 +84,6 @@
 /* Command line option for static images. */
 #define BLOCK_OPT_STATIC "static"
 
-#define KiB     1024
-#define MiB     (KiB * KiB)
-
 #define SECTOR_SIZE 512
 #define DEFAULT_CLUSTER_SIZE (1 * MiB)
 
@@ -250,7 +248,7 @@ static void vdi_header_print(VdiHeader *header)
     logout("heads       0x%04x\n", header->heads);
     logout("sectors     0x%04x\n", header->sectors);
     logout("sector size 0x%04x\n", header->sector_size);
-    logout("image size  0x%" PRIx64 " B (%" PRIu64 " MiB)\n",
+    logout("image size  0x%" PRIx64 " B (%llu MiB)\n",
            header->disk_size, header->disk_size / MiB);
     logout("block size  0x%04x\n", header->block_size);
     logout("block extra 0x%04x\n", header->block_extra);
@@ -434,7 +432,7 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
         goto fail;
     } else if (header.block_size != DEFAULT_CLUSTER_SIZE) {
         error_setg(errp, "unsupported VDI image (block size %" PRIu32
-                   " is not %u)", header.block_size, DEFAULT_CLUSTER_SIZE);
+                   " is not %llu)", header.block_size, DEFAULT_CLUSTER_SIZE);
         ret = -ENOTSUP;
         goto fail;
     } else if (header.disk_size >
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 03/40] x86/cpu: Use definitions from "qemu/units.h"
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 01/40] include: Add IEC binary prefixes in "qemu/units.h" Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 02/40] vdi: Use definitions from "qemu/units.h" Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11 18:42   ` Eduardo Habkost
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 04/40] checkpatch: Recognize IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (38 subsequent siblings)
  41 siblings, 1 reply; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Paolo Bonzini, Richard Henderson,
	Eduardo Habkost

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/i386/cpu.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 94260412e2..56c63615fe 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/cutils.h"
 
 #include "cpu.h"
@@ -64,9 +65,6 @@ struct CPUID2CacheDescriptorInfo {
     int associativity;
 };
 
-#define KiB 1024
-#define MiB (1024 * 1024)
-
 /*
  * Known CPUID 2 cache descriptors.
  * From Intel SDM Volume 2A, CPUID instruction
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 04/40] checkpatch: Recognize IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 03/40] x86/cpu: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-13 19:54   ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 05/40] hw: Use IEC binary prefix definitions from "qemu/units.h" Philippe Mathieu-Daudé
                   ` (37 subsequent siblings)
  41 siblings, 1 reply; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Eric Blake, Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-trivial

This fixes:

    ERROR: "foo * bar" should be "foo *bar"
    #310: FILE: hw/ppc/ppc440_uc.c:564:
    +        size = 8 * MiB * sh;
    total: 1 errors, 0 warnings, 433 lines checked

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 scripts/checkpatch.pl | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e3d8c2cdfc..4923674c71 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -322,6 +322,7 @@ sub build_types {
 				(?:${all}\b)
 			)
 			(?:\s+$Modifier|\s+const)*
+			(?:[KMGTPE]iB)
 		  }x;
 	$Type	= qr{
 			$NonptrType
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 05/40] hw: Use IEC binary prefix definitions from "qemu/units.h"
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 04/40] checkpatch: Recognize IEC binary prefix definitions Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  2:11   ` David Gibson
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 06/40] hw: Directly use "qemu/units.h" instead of "qemu/cutils.h" Philippe Mathieu-Daudé
                   ` (36 subsequent siblings)
  41 siblings, 1 reply; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil, Nikunj A Dadhania
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Subbaraya Sundeep, Peter Maydell,
	Paul Burton, Eduardo Habkost, Marcel Apfelbaum,
	Richard Henderson, Aurelien Jarno, Yongbok Kim, David Gibson,
	Alexander Graf, Hervé Poussineau, Markus Armbruster,
	open list:ARM, open list:PowerPC

Code change produced with:

  $ git ls-files | egrep '\.[ch]$' | \
    xargs sed -i -e 's/\(\W[KMGTPE]\)_BYTE/\1iB/g'

Suggested-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/qemu/cutils.h  |  8 +-------
 hw/arm/msf2-soc.c      |  4 ++--
 hw/arm/msf2-som.c      |  6 +++---
 hw/core/loader-fit.c   |  3 ++-
 hw/core/machine.c      |  2 +-
 hw/display/sm501.c     | 14 +++++++-------
 hw/hppa/machine.c      |  2 +-
 hw/mips/boston.c       | 28 ++++++++++++++--------------
 hw/ppc/pnv.c           |  4 ++--
 hw/ppc/ppc440_uc.c     | 26 +++++++++++++-------------
 hw/ppc/prep.c          |  2 +-
 hw/ppc/sam460ex.c      |  2 +-
 hw/ppc/spapr.c         | 10 +++++-----
 hw/ppc/spapr_rtas.c    |  2 +-
 hw/sd/sd.c             |  4 ++--
 hw/sd/sdhci.c          |  2 +-
 tests/test-cutils.c    | 18 +++++++++---------
 tests/test-keyval.c    |  6 +++---
 tests/test-qemu-opts.c |  7 +++----
 19 files changed, 72 insertions(+), 78 deletions(-)

diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
index a663340b23..056e6629bb 100644
--- a/include/qemu/cutils.h
+++ b/include/qemu/cutils.h
@@ -2,6 +2,7 @@
 #define QEMU_CUTILS_H
 
 #include "qemu/fprintf-fn.h"
+#include "qemu/units.h"
 
 /**
  * pstrcpy:
@@ -147,13 +148,6 @@ int qemu_strtosz(const char *nptr, char **end, uint64_t *result);
 int qemu_strtosz_MiB(const char *nptr, char **end, uint64_t *result);
 int qemu_strtosz_metric(const char *nptr, char **end, uint64_t *result);
 
-#define K_BYTE     (1ULL << 10)
-#define M_BYTE     (1ULL << 20)
-#define G_BYTE     (1ULL << 30)
-#define T_BYTE     (1ULL << 40)
-#define P_BYTE     (1ULL << 50)
-#define E_BYTE     (1ULL << 60)
-
 /* used to print char* safely */
 #define STR_OR_NULL(str) ((str) ? (str) : "null")
 
diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
index 75c44adf7d..530e461c42 100644
--- a/hw/arm/msf2-soc.c
+++ b/hw/arm/msf2-soc.c
@@ -40,14 +40,14 @@
 
 #define SRAM_BASE_ADDRESS     0x20000000
 
-#define MSF2_ENVM_MAX_SIZE    (512 * K_BYTE)
+#define MSF2_ENVM_MAX_SIZE    (512 * KiB)
 
 /*
  * eSRAM max size is 80k without SECDED(Single error correction and
  * dual error detection) feature and 64k with SECDED.
  * We do not support SECDED now.
  */
-#define MSF2_ESRAM_MAX_SIZE       (80 * K_BYTE)
+#define MSF2_ESRAM_MAX_SIZE       (80 * KiB)
 
 static const uint32_t spi_addr[MSF2_NUM_SPIS] = { 0x40001000 , 0x40011000 };
 static const uint32_t uart_addr[MSF2_NUM_UARTS] = { 0x40000000 , 0x40010000 };
diff --git a/hw/arm/msf2-som.c b/hw/arm/msf2-som.c
index 0795a3a3a1..ed533bbde1 100644
--- a/hw/arm/msf2-som.c
+++ b/hw/arm/msf2-som.c
@@ -33,10 +33,10 @@
 #include "cpu.h"
 
 #define DDR_BASE_ADDRESS      0xA0000000
-#define DDR_SIZE              (64 * M_BYTE)
+#define DDR_SIZE              (64 * MiB)
 
-#define M2S010_ENVM_SIZE      (256 * K_BYTE)
-#define M2S010_ESRAM_SIZE     (64 * K_BYTE)
+#define M2S010_ENVM_SIZE      (256 * KiB)
+#define M2S010_ESRAM_SIZE     (64 * KiB)
 
 static void emcraft_sf2_s2s010_init(MachineState *machine)
 {
diff --git a/hw/core/loader-fit.c b/hw/core/loader-fit.c
index 6387854b54..447f60857d 100644
--- a/hw/core/loader-fit.c
+++ b/hw/core/loader-fit.c
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "exec/memory.h"
 #include "hw/loader.h"
 #include "hw/loader-fit.h"
@@ -194,7 +195,7 @@ static int fit_load_fdt(const struct fit_loader *ldr, const void *itb,
 
     err = fit_image_addr(itb, img_off, "load", &load_addr);
     if (err == -ENOENT) {
-        load_addr = ROUND_UP(kernel_end, 64 * K_BYTE) + (10 * M_BYTE);
+        load_addr = ROUND_UP(kernel_end, 64 * KiB) + (10 * MiB);
     } else if (err) {
         ret = err;
         goto out;
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 617e5f8d75..ccf3a4b9c7 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -522,7 +522,7 @@ static void machine_class_init(ObjectClass *oc, void *data)
     MachineClass *mc = MACHINE_CLASS(oc);
 
     /* Default 128 MB as guest ram size */
-    mc->default_ram_size = 128 * M_BYTE;
+    mc->default_ram_size = 128 * MiB;
     mc->rom_file_has_mr = true;
 
     /* numa node memory size aligned on 8MB by default.
diff --git a/hw/display/sm501.c b/hw/display/sm501.c
index e47be99451..1c6c9445c5 100644
--- a/hw/display/sm501.c
+++ b/hw/display/sm501.c
@@ -452,12 +452,12 @@
 
 /* SM501 local memory size taken from "linux/drivers/mfd/sm501.c" */
 static const uint32_t sm501_mem_local_size[] = {
-    [0] = 4 * M_BYTE,
-    [1] = 8 * M_BYTE,
-    [2] = 16 * M_BYTE,
-    [3] = 32 * M_BYTE,
-    [4] = 64 * M_BYTE,
-    [5] = 2 * M_BYTE,
+    [0] = 4 * MiB,
+    [1] = 8 * MiB,
+    [2] = 16 * MiB,
+    [3] = 32 * MiB,
+    [4] = 64 * MiB,
+    [5] = 2 * MiB,
 };
 #define get_local_mem_size(s) sm501_mem_local_size[(s)->local_mem_size_index]
 
@@ -1826,7 +1826,7 @@ static void sm501_realize_pci(PCIDevice *dev, Error **errp)
 }
 
 static Property sm501_pci_properties[] = {
-    DEFINE_PROP_UINT32("vram-size", SM501PCIState, vram_size, 64 * M_BYTE),
+    DEFINE_PROP_UINT32("vram-size", SM501PCIState, vram_size, 64 * MiB),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index aba269bb85..2ba26962f9 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -275,7 +275,7 @@ static void machine_hppa_machine_init(MachineClass *mc)
     mc->max_cpus = HPPA_MAX_CPUS;
     mc->default_cpus = 1;
     mc->is_default = 1;
-    mc->default_ram_size = 512 * M_BYTE;
+    mc->default_ram_size = 512 * MiB;
     mc->default_boot_order = "cd";
 }
 
diff --git a/hw/mips/boston.c b/hw/mips/boston.c
index 52cce19766..512c60c03e 100644
--- a/hw/mips/boston.c
+++ b/hw/mips/boston.c
@@ -200,7 +200,7 @@ static uint64_t boston_platreg_read(void *opaque, hwaddr addr,
         val |= PLAT_BUILD_CFG_PCIE2_EN;
         return val;
     case PLAT_DDR_CFG:
-        val = s->mach->ram_size / G_BYTE;
+        val = s->mach->ram_size / GiB;
         assert(!(val & ~PLAT_DDR_CFG_SIZE));
         val |= PLAT_DDR_CFG_MHZ;
         return val;
@@ -355,7 +355,7 @@ static const void *boston_fdt_filter(void *opaque, const void *fdt_orig,
         return NULL;
     }
 
-    ram_low_sz = MIN(256 * M_BYTE, machine->ram_size);
+    ram_low_sz = MIN(256 * MiB, machine->ram_size);
     ram_high_sz = machine->ram_size - ram_low_sz;
     qemu_fdt_setprop_sized_cells(fdt, "/memory@0", "reg",
                                  1, 0x00000000, 1, ram_low_sz,
@@ -436,8 +436,8 @@ static void boston_mach_init(MachineState *machine)
     int fw_size, fit_err;
     bool is_64b;
 
-    if ((machine->ram_size % G_BYTE) ||
-        (machine->ram_size > (2 * G_BYTE))) {
+    if ((machine->ram_size % GiB) ||
+        (machine->ram_size > (2 * GiB))) {
         error_report("Memory size must be 1GB or 2GB");
         exit(1);
     }
@@ -472,7 +472,7 @@ static void boston_mach_init(MachineState *machine)
 
     flash =  g_new(MemoryRegion, 1);
     memory_region_init_rom_nomigrate(flash, NULL,
-                                     "boston.flash", 128 * M_BYTE, &err);
+                                     "boston.flash", 128 * MiB, &err);
     memory_region_add_subregion_overlap(sys_mem, 0x18000000, flash, 0);
 
     ddr = g_new(MemoryRegion, 1);
@@ -482,22 +482,22 @@ static void boston_mach_init(MachineState *machine)
 
     ddr_low_alias = g_new(MemoryRegion, 1);
     memory_region_init_alias(ddr_low_alias, NULL, "boston_low.ddr",
-                             ddr, 0, MIN(machine->ram_size, (256 * M_BYTE)));
+                             ddr, 0, MIN(machine->ram_size, (256 * MiB)));
     memory_region_add_subregion_overlap(sys_mem, 0, ddr_low_alias, 0);
 
     xilinx_pcie_init(sys_mem, 0,
-                     0x10000000, 32 * M_BYTE,
-                     0x40000000, 1 * G_BYTE,
+                     0x10000000, 32 * MiB,
+                     0x40000000, 1 * GiB,
                      get_cps_irq(s->cps, 2), false);
 
     xilinx_pcie_init(sys_mem, 1,
-                     0x12000000, 32 * M_BYTE,
-                     0x20000000, 512 * M_BYTE,
+                     0x12000000, 32 * MiB,
+                     0x20000000, 512 * MiB,
                      get_cps_irq(s->cps, 1), false);
 
     pcie2 = xilinx_pcie_init(sys_mem, 2,
-                             0x14000000, 32 * M_BYTE,
-                             0x16000000, 1 * M_BYTE,
+                             0x14000000, 32 * MiB,
+                             0x16000000, 1 * MiB,
                              get_cps_irq(s->cps, 0), true);
 
     platreg = g_new(MemoryRegion, 1);
@@ -527,7 +527,7 @@ static void boston_mach_init(MachineState *machine)
 
     if (machine->firmware) {
         fw_size = load_image_targphys(machine->firmware,
-                                      0x1fc00000, 4 * M_BYTE);
+                                      0x1fc00000, 4 * MiB);
         if (fw_size == -1) {
             error_printf("unable to load firmware image '%s'\n",
                           machine->firmware);
@@ -553,7 +553,7 @@ static void boston_mach_class_init(MachineClass *mc)
     mc->desc = "MIPS Boston";
     mc->init = boston_mach_init;
     mc->block_default_type = IF_IDE;
-    mc->default_ram_size = 1 * G_BYTE;
+    mc->default_ram_size = 1 * GiB;
     mc->max_cpus = 16;
     mc->default_cpu_type = MIPS_CPU_TYPE_NAME("I6400");
 }
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 0314881316..bdb6f63d2c 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -559,7 +559,7 @@ static void pnv_init(MachineState *machine)
     char *chip_typename;
 
     /* allocate RAM */
-    if (machine->ram_size < (1 * G_BYTE)) {
+    if (machine->ram_size < (1 * GiB)) {
         warn_report("skiboot may not work with < 1GB of RAM");
     }
 
@@ -1096,7 +1096,7 @@ static void pnv_machine_class_init(ObjectClass *oc, void *data)
                                       * storage */
     mc->no_parallel = 1;
     mc->default_boot_order = NULL;
-    mc->default_ram_size = 1 * G_BYTE;
+    mc->default_ram_size = 1 * GiB;
     xic->icp_get = pnv_icp_get;
     xic->ics_get = pnv_ics_get;
     xic->ics_resend = pnv_ics_resend;
diff --git a/hw/ppc/ppc440_uc.c b/hw/ppc/ppc440_uc.c
index 123f4ac09d..b5b31b4b9b 100644
--- a/hw/ppc/ppc440_uc.c
+++ b/hw/ppc/ppc440_uc.c
@@ -215,13 +215,13 @@ void ppc4xx_l2sram_init(CPUPPCState *env)
     l2sram = g_malloc0(sizeof(*l2sram));
     /* XXX: Size is 4*64kB for 460ex, cf. U-Boot, ppc4xx-isram.h */
     memory_region_init_ram(&l2sram->bank[0], NULL, "ppc4xx.l2sram_bank0",
-                           64 * K_BYTE, &error_abort);
+                           64 * KiB, &error_abort);
     memory_region_init_ram(&l2sram->bank[1], NULL, "ppc4xx.l2sram_bank1",
-                           64 * K_BYTE, &error_abort);
+                           64 * KiB, &error_abort);
     memory_region_init_ram(&l2sram->bank[2], NULL, "ppc4xx.l2sram_bank2",
-                           64 * K_BYTE, &error_abort);
+                           64 * KiB, &error_abort);
     memory_region_init_ram(&l2sram->bank[3], NULL, "ppc4xx.l2sram_bank3",
-                           64 * K_BYTE, &error_abort);
+                           64 * KiB, &error_abort);
     qemu_register_reset(&l2sram_reset, l2sram);
     ppc_dcr_register(env, DCR_L2CACHE_CFG,
                      l2sram, &dcr_read_l2sram, &dcr_write_l2sram);
@@ -513,28 +513,28 @@ static uint32_t sdram_bcr(hwaddr ram_base, hwaddr ram_size)
     uint32_t bcr;
 
     switch (ram_size) {
-    case (8 * M_BYTE):
+    case (8 * MiB):
         bcr = 0xffc0;
         break;
-    case (16 * M_BYTE):
+    case (16 * MiB):
         bcr = 0xff80;
         break;
-    case (32 * M_BYTE):
+    case (32 * MiB):
         bcr = 0xff00;
         break;
-    case (64 * M_BYTE):
+    case (64 * MiB):
         bcr = 0xfe00;
         break;
-    case (128 * M_BYTE):
+    case (128 * MiB):
         bcr = 0xfc00;
         break;
-    case (256 * M_BYTE):
+    case (256 * MiB):
         bcr = 0xf800;
         break;
-    case (512 * M_BYTE):
+    case (512 * MiB):
         bcr = 0xf000;
         break;
-    case (1 * G_BYTE):
+    case (1 * GiB):
         bcr = 0xe000;
         break;
     default:
@@ -561,7 +561,7 @@ static target_ulong sdram_size(uint32_t bcr)
     if (sh == 0) {
         size = -1;
     } else {
-        size = 8 * M_BYTE * sh;
+        size = 8 * MiB * sh;
     }
 
     return size;
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index a1e7219db6..a8d26f74fc 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -886,7 +886,7 @@ static void ibm_40p_machine_init(MachineClass *mc)
     mc->init = ibm_40p_init;
     mc->max_cpus = 1;
     mc->pci_allow_0_address = true;
-    mc->default_ram_size = 128 * M_BYTE;
+    mc->default_ram_size = 128 * MiB;
     mc->block_default_type = IF_SCSI;
     mc->default_boot_order = "c";
     mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("604");
diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
index bdc53d2603..2a98c10664 100644
--- a/hw/ppc/sam460ex.c
+++ b/hw/ppc/sam460ex.c
@@ -597,7 +597,7 @@ static void sam460ex_machine_init(MachineClass *mc)
     mc->desc = "aCube Sam460ex";
     mc->init = sam460ex_init;
     mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("460exb");
-    mc->default_ram_size = 512 * M_BYTE;
+    mc->default_ram_size = 512 * MiB;
 }
 
 DEFINE_MACHINE("sam460ex", sam460ex_machine_init)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 2375cbee12..3ba3bc8b6c 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2317,7 +2317,7 @@ static void spapr_validate_node_memory(MachineState *machine, Error **errp)
         error_setg(errp, "Memory size 0x" RAM_ADDR_FMT
                    " is not aligned to %llu MiB",
                    machine->ram_size,
-                   SPAPR_MEMORY_BLOCK_SIZE / M_BYTE);
+                   SPAPR_MEMORY_BLOCK_SIZE / MiB);
         return;
     }
 
@@ -2325,7 +2325,7 @@ static void spapr_validate_node_memory(MachineState *machine, Error **errp)
         error_setg(errp, "Maximum memory size 0x" RAM_ADDR_FMT
                    " is not aligned to %llu MiB",
                    machine->ram_size,
-                   SPAPR_MEMORY_BLOCK_SIZE / M_BYTE);
+                   SPAPR_MEMORY_BLOCK_SIZE / MiB);
         return;
     }
 
@@ -2335,7 +2335,7 @@ static void spapr_validate_node_memory(MachineState *machine, Error **errp)
                        "Node %d memory size 0x%" PRIx64
                        " is not aligned to %llu MiB",
                        i, numa_info[i].node_mem,
-                       SPAPR_MEMORY_BLOCK_SIZE / M_BYTE);
+                       SPAPR_MEMORY_BLOCK_SIZE / MiB);
             return;
         }
     }
@@ -3195,7 +3195,7 @@ static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
 
     if (size % SPAPR_MEMORY_BLOCK_SIZE) {
         error_setg(errp, "Hotplugged memory size must be a multiple of "
-                      "%lld MB", SPAPR_MEMORY_BLOCK_SIZE / M_BYTE);
+                      "%lld MB", SPAPR_MEMORY_BLOCK_SIZE / MiB);
         return;
     }
 
@@ -3975,7 +3975,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
     mc->max_cpus = 1024;
     mc->no_parallel = 1;
     mc->default_boot_order = "";
-    mc->default_ram_size = 512 * M_BYTE;
+    mc->default_ram_size = 512 * MiB;
     mc->kvm_type = spapr_kvm_type;
     machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SPAPR_PCI_HOST_BRIDGE);
     mc->pci_allow_0_address = true;
diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
index 7f9738daed..f32740b947 100644
--- a/hw/ppc/spapr_rtas.c
+++ b/hw/ppc/spapr_rtas.c
@@ -241,7 +241,7 @@ static void rtas_ibm_get_system_parameter(PowerPCCPU *cpu,
                                           "DesProcs=%d,"
                                           "MaxPlatProcs=%d",
                                           max_cpus,
-                                          current_machine->ram_size / M_BYTE,
+                                          current_machine->ram_size / MiB,
                                           smp_cpus,
                                           max_cpus);
         ret = sysparm_st(buffer, length, param_val, strlen(param_val) + 1);
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 540bccb8d1..9a16b768ed 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -305,7 +305,7 @@ static void sd_ocr_powerup(void *opaque)
     /* card power-up OK */
     sd->ocr = FIELD_DP32(sd->ocr, OCR, CARD_POWER_UP, 1);
 
-    if (sd->size > 1 * G_BYTE) {
+    if (sd->size > 1 * GiB) {
         sd->ocr = FIELD_DP32(sd->ocr, OCR, CARD_CAPACITY, 1);
     }
 }
@@ -377,7 +377,7 @@ static void sd_set_csd(SDState *sd, uint64_t size)
     uint32_t sectsize = (1 << (SECTOR_SHIFT + 1)) - 1;
     uint32_t wpsize = (1 << (WPGROUP_SHIFT + 1)) - 1;
 
-    if (size <= 1 * G_BYTE) { /* Standard Capacity SD */
+    if (size <= 1 * GiB) { /* Standard Capacity SD */
         sd->csd[0] = 0x00;	/* CSD structure */
         sd->csd[1] = 0x26;	/* Data read access-time-1 */
         sd->csd[2] = 0x00;	/* Data read access-time-2 */
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index 3017e5a95a..a11e802485 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -414,7 +414,7 @@ static void sdhci_end_transfer(SDHCIState *s)
 /*
  * Programmed i/o data transfer
  */
-#define BLOCK_SIZE_MASK (4 * K_BYTE - 1)
+#define BLOCK_SIZE_MASK (4 * KiB - 1)
 
 /* Fill host controller's read buffer with BLKSIZE bytes of data from card */
 static void sdhci_read_block_from_card(SDHCIState *s)
diff --git a/tests/test-cutils.c b/tests/test-cutils.c
index 64a489c2e9..ee543ac4bf 100644
--- a/tests/test-cutils.c
+++ b/tests/test-cutils.c
@@ -2022,7 +2022,7 @@ static void test_qemu_strtosz_units(void)
     /* default is M */
     err = qemu_strtosz_MiB(none, &endptr, &res);
     g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, M_BYTE);
+    g_assert_cmpint(res, ==, MiB);
     g_assert(endptr == none + 1);
 
     err = qemu_strtosz(b, &endptr, &res);
@@ -2032,32 +2032,32 @@ static void test_qemu_strtosz_units(void)
 
     err = qemu_strtosz(k, &endptr, &res);
     g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, K_BYTE);
+    g_assert_cmpint(res, ==, KiB);
     g_assert(endptr == k + 2);
 
     err = qemu_strtosz(m, &endptr, &res);
     g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, M_BYTE);
+    g_assert_cmpint(res, ==, MiB);
     g_assert(endptr == m + 2);
 
     err = qemu_strtosz(g, &endptr, &res);
     g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, G_BYTE);
+    g_assert_cmpint(res, ==, GiB);
     g_assert(endptr == g + 2);
 
     err = qemu_strtosz(t, &endptr, &res);
     g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, T_BYTE);
+    g_assert_cmpint(res, ==, TiB);
     g_assert(endptr == t + 2);
 
     err = qemu_strtosz(p, &endptr, &res);
     g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, P_BYTE);
+    g_assert_cmpint(res, ==, PiB);
     g_assert(endptr == p + 2);
 
     err = qemu_strtosz(e, &endptr, &res);
     g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, E_BYTE);
+    g_assert_cmpint(res, ==, EiB);
     g_assert(endptr == e + 2);
 }
 
@@ -2070,7 +2070,7 @@ static void test_qemu_strtosz_float(void)
 
     err = qemu_strtosz(str, &endptr, &res);
     g_assert_cmpint(err, ==, 0);
-    g_assert_cmpint(res, ==, 12.345 * M_BYTE);
+    g_assert_cmpint(res, ==, 12.345 * MiB);
     g_assert(endptr == str + 7);
 }
 
@@ -2106,7 +2106,7 @@ static void test_qemu_strtosz_trailing(void)
 
     str = "123xxx";
     err = qemu_strtosz_MiB(str, &endptr, &res);
-    g_assert_cmpint(res, ==, 123 * M_BYTE);
+    g_assert_cmpint(res, ==, 123 * MiB);
     g_assert(endptr == str + 3);
 
     err = qemu_strtosz(str, NULL, &res);
diff --git a/tests/test-keyval.c b/tests/test-keyval.c
index 63cb14629b..92d8e9fa89 100644
--- a/tests/test-keyval.c
+++ b/tests/test-keyval.c
@@ -457,11 +457,11 @@ static void test_keyval_visit_size(void)
     visit_type_size(v, "sz2", &sz, &error_abort);
     g_assert_cmpuint(sz, ==, 1536);
     visit_type_size(v, "sz3", &sz, &error_abort);
-    g_assert_cmphex(sz, ==, 2 * M_BYTE);
+    g_assert_cmphex(sz, ==, 2 * MiB);
     visit_type_size(v, "sz4", &sz, &error_abort);
-    g_assert_cmphex(sz, ==, G_BYTE / 10);
+    g_assert_cmphex(sz, ==, GiB / 10);
     visit_type_size(v, "sz5", &sz, &error_abort);
-    g_assert_cmphex(sz, ==, 16777215 * T_BYTE);
+    g_assert_cmphex(sz, ==, 16777215 * TiB);
     visit_check_struct(v, &error_abort);
     visit_end_struct(v, NULL);
     visit_free(v);
diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c
index 7092e216f7..7074a176d7 100644
--- a/tests/test-qemu-opts.c
+++ b/tests/test-qemu-opts.c
@@ -704,13 +704,12 @@ static void test_opts_parse_size(void)
     g_assert_cmpuint(opts_count(opts), ==, 3);
     g_assert_cmphex(qemu_opt_get_size(opts, "size1", 0), ==, 8);
     g_assert_cmphex(qemu_opt_get_size(opts, "size2", 0), ==, 1536);
-    g_assert_cmphex(qemu_opt_get_size(opts, "size3", 0), ==, 2 * M_BYTE);
+    g_assert_cmphex(qemu_opt_get_size(opts, "size3", 0), ==, 2 * MiB);
     opts = qemu_opts_parse(&opts_list_02, "size1=0.1G,size2=16777215T",
                            false, &error_abort);
     g_assert_cmpuint(opts_count(opts), ==, 2);
-    g_assert_cmphex(qemu_opt_get_size(opts, "size1", 0), ==, G_BYTE / 10);
-    g_assert_cmphex(qemu_opt_get_size(opts, "size2", 0),
-                     ==, 16777215 * T_BYTE);
+    g_assert_cmphex(qemu_opt_get_size(opts, "size1", 0), ==, GiB / 10);
+    g_assert_cmphex(qemu_opt_get_size(opts, "size2", 0), ==, 16777215 * TiB);
 
     /* Beyond limit with suffix */
     opts = qemu_opts_parse(&opts_list_02, "size1=16777216T",
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 06/40] hw: Directly use "qemu/units.h" instead of "qemu/cutils.h"
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 05/40] hw: Use IEC binary prefix definitions from "qemu/units.h" Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  2:16   ` David Gibson
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 07/40] hw/ivshmem: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (35 subsequent siblings)
  41 siblings, 1 reply; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Subbaraya Sundeep, Peter Maydell,
	Eduardo Habkost, Marcel Apfelbaum, Paul Burton, Aurelien Jarno,
	Yongbok Kim, David Gibson, Alexander Graf, open list:ARM,
	open list:PowerPC

These files don't use anything exposed by "qemu/cutils.h",
simplify preprocessing including directly "qemu/units.h".

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/msf2-soc.c  | 2 +-
 hw/arm/msf2-som.c  | 2 +-
 hw/core/machine.c  | 2 +-
 hw/display/sm501.c | 2 +-
 hw/mips/boston.c   | 2 +-
 hw/ppc/pnv.c       | 2 +-
 hw/ppc/ppc440_uc.c | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
index 530e461c42..edb3ba824f 100644
--- a/hw/arm/msf2-soc.c
+++ b/hw/arm/msf2-soc.c
@@ -23,13 +23,13 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "hw/arm/arm.h"
 #include "exec/address-spaces.h"
 #include "hw/char/serial.h"
 #include "hw/boards.h"
-#include "qemu/cutils.h"
 #include "hw/arm/msf2-soc.h"
 #include "hw/misc/unimp.h"
 
diff --git a/hw/arm/msf2-som.c b/hw/arm/msf2-som.c
index ed533bbde1..2432b5e935 100644
--- a/hw/arm/msf2-som.c
+++ b/hw/arm/msf2-som.c
@@ -23,12 +23,12 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "hw/boards.h"
 #include "hw/arm/arm.h"
 #include "exec/address-spaces.h"
-#include "qemu/cutils.h"
 #include "hw/arm/msf2-soc.h"
 #include "cpu.h"
 
diff --git a/hw/core/machine.c b/hw/core/machine.c
index ccf3a4b9c7..2077328bcc 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -11,6 +11,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/boards.h"
 #include "qapi/error.h"
 #include "qapi/qapi-visit-common.h"
@@ -19,7 +20,6 @@
 #include "sysemu/sysemu.h"
 #include "sysemu/numa.h"
 #include "qemu/error-report.h"
-#include "qemu/cutils.h"
 #include "sysemu/qtest.h"
 
 static char *machine_get_accel(Object *obj, Error **errp)
diff --git a/hw/display/sm501.c b/hw/display/sm501.c
index 1c6c9445c5..bbb9274886 100644
--- a/hw/display/sm501.c
+++ b/hw/display/sm501.c
@@ -24,7 +24,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu/cutils.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "cpu.h"
diff --git a/hw/mips/boston.c b/hw/mips/boston.c
index 512c60c03e..b7bfeccf4c 100644
--- a/hw/mips/boston.c
+++ b/hw/mips/boston.c
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu-common.h"
 
 #include "exec/address-spaces.h"
@@ -32,7 +33,6 @@
 #include "hw/mips/cpudevs.h"
 #include "hw/pci-host/xilinx-pcie.h"
 #include "qapi/error.h"
-#include "qemu/cutils.h"
 #include "qemu/error-report.h"
 #include "qemu/log.h"
 #include "chardev/char.h"
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index bdb6f63d2c..0df4a4fd74 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/numa.h"
@@ -31,7 +32,6 @@
 #include "hw/ppc/pnv_core.h"
 #include "hw/loader.h"
 #include "exec/address-spaces.h"
-#include "qemu/cutils.h"
 #include "qapi/visitor.h"
 #include "monitor/monitor.h"
 #include "hw/intc/intc.h"
diff --git a/hw/ppc/ppc440_uc.c b/hw/ppc/ppc440_uc.c
index b5b31b4b9b..1ab2235f20 100644
--- a/hw/ppc/ppc440_uc.c
+++ b/hw/ppc/ppc440_uc.c
@@ -9,8 +9,8 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu-common.h"
-#include "qemu/cutils.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "cpu.h"
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 07/40] hw/ivshmem: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 06/40] hw: Directly use "qemu/units.h" instead of "qemu/cutils.h" Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 08/40] hw/ipack: " Philippe Mathieu-Daudé
                   ` (34 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-trivial

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/misc/ivshmem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index 16f03701b7..9a9f990867 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -17,6 +17,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu/cutils.h"
 #include "hw/hw.h"
@@ -1302,7 +1303,7 @@ static void ivshmem_realize(PCIDevice *dev, Error **errp)
     }
 
     if (s->sizearg == NULL) {
-        s->legacy_size = 4 << 20; /* 4 MB default */
+        s->legacy_size = 4 * MiB; /* 4 MB default */
     } else {
         int ret;
         uint64_t size;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 08/40] hw/ipack: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 07/40] hw/ivshmem: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 09/40] hw/scsi: " Philippe Mathieu-Daudé
                   ` (33 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-trivial, Alberto Garcia

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alberto Garcia <berto@igalia.com>
---
 hw/ipack/tpci200.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/ipack/tpci200.c b/hw/ipack/tpci200.c
index da05c8589d..cd3e79139d 100644
--- a/hw/ipack/tpci200.c
+++ b/hw/ipack/tpci200.c
@@ -9,6 +9,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/ipack/ipack.h"
 #include "hw/pci/pci.h"
 #include "qemu/bitops.h"
@@ -597,9 +598,9 @@ static void tpci200_realize(PCIDevice *pci_dev, Error **errp)
     memory_region_init_io(&s->las1, OBJECT(s), &tpci200_las1_ops,
                           s, "tpci200_las1", 1024);
     memory_region_init_io(&s->las2, OBJECT(s), &tpci200_las2_ops,
-                          s, "tpci200_las2", 1024*1024*32);
+                          s, "tpci200_las2", 32 * MiB);
     memory_region_init_io(&s->las3, OBJECT(s), &tpci200_las3_ops,
-                          s, "tpci200_las3", 1024*1024*16);
+                          s, "tpci200_las3", 16 * MiB);
     pci_register_bar(&s->dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mmio);
     pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_SPACE_IO,     &s->io);
     pci_register_bar(&s->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->las0);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 09/40] hw/scsi: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 08/40] hw/ipack: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 10/40] hw/smbios: " Philippe Mathieu-Daudé
                   ` (32 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Paolo Bonzini, Fam Zheng

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/scsi/scsi-disk.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index ded23d36ca..00c8fc571a 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -29,6 +29,7 @@ do { printf("scsi-disk: " fmt , ## __VA_ARGS__); } while (0)
 #endif
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "hw/scsi/scsi.h"
@@ -44,13 +45,13 @@ do { printf("scsi-disk: " fmt , ## __VA_ARGS__); } while (0)
 #include <scsi/sg.h>
 #endif
 
-#define SCSI_WRITE_SAME_MAX         524288
-#define SCSI_DMA_BUF_SIZE           131072
+#define SCSI_WRITE_SAME_MAX         (512 * KiB)
+#define SCSI_DMA_BUF_SIZE           (128 * KiB)
 #define SCSI_MAX_INQUIRY_LEN        256
 #define SCSI_MAX_MODE_LEN           256
 
-#define DEFAULT_DISCARD_GRANULARITY 4096
-#define DEFAULT_MAX_UNMAP_SIZE      (1 << 30)   /* 1 GB */
+#define DEFAULT_DISCARD_GRANULARITY (4 * KiB)
+#define DEFAULT_MAX_UNMAP_SIZE      (1 * GiB)
 #define DEFAULT_MAX_IO_SIZE         INT_MAX     /* 2 GB - 1 block */
 
 #define TYPE_SCSI_DISK_BASE         "scsi-disk-base"
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 10/40] hw/smbios: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (8 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 09/40] hw/scsi: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14   ` Philippe Mathieu-Daudé
                   ` (31 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Michael S. Tsirkin, Igor Mammedov

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/smbios/smbios.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index 27a07e96f4..a27e54b2fa 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -16,6 +16,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
@@ -625,10 +626,6 @@ static void smbios_build_type_11_table(void)
     SMBIOS_BUILD_TABLE_POST;
 }
 
-#define ONE_KB ((ram_addr_t)1 << 10)
-#define ONE_MB ((ram_addr_t)1 << 20)
-#define ONE_GB ((ram_addr_t)1 << 30)
-
 #define MAX_T16_STD_SZ 0x80000000 /* 2T in Kilobytes */
 
 static void smbios_build_type_16_table(unsigned dimm_cnt)
@@ -640,7 +637,7 @@ static void smbios_build_type_16_table(unsigned dimm_cnt)
     t->location = 0x01; /* Other */
     t->use = 0x03; /* System memory */
     t->error_correction = 0x06; /* Multi-bit ECC (for Microsoft, per SeaBIOS) */
-    size_kb = QEMU_ALIGN_UP(ram_size, ONE_KB) / ONE_KB;
+    size_kb = QEMU_ALIGN_UP(ram_size, KiB) / KiB;
     if (size_kb < MAX_T16_STD_SZ) {
         t->maximum_capacity = cpu_to_le32(size_kb);
         t->extended_maximum_capacity = cpu_to_le64(0);
@@ -668,7 +665,7 @@ static void smbios_build_type_17_table(unsigned instance, uint64_t size)
     t->memory_error_information_handle = cpu_to_le16(0xFFFE); /* Not provided */
     t->total_width = cpu_to_le16(0xFFFF); /* Unknown */
     t->data_width = cpu_to_le16(0xFFFF); /* Unknown */
-    size_mb = QEMU_ALIGN_UP(size, ONE_MB) / ONE_MB;
+    size_mb = QEMU_ALIGN_UP(size, MiB) / MiB;
     if (size_mb < MAX_T17_STD_SZ) {
         t->size = cpu_to_le16(size_mb);
         t->extended_size = cpu_to_le32(0);
@@ -707,8 +704,8 @@ static void smbios_build_type_19_table(unsigned instance,
 
     end = start + size - 1;
     assert(end > start);
-    start_kb = start / ONE_KB;
-    end_kb = end / ONE_KB;
+    start_kb = start / KiB;
+    end_kb = end / KiB;
     if (start_kb < UINT32_MAX && end_kb < UINT32_MAX) {
         t->starting_address = cpu_to_le32(start_kb);
         t->ending_address = cpu_to_le32(end_kb);
@@ -869,7 +866,7 @@ void smbios_get_tables(const struct smbios_phys_mem_area *mem_array,
 
         smbios_build_type_11_table();
 
-#define MAX_DIMM_SZ (16ll * ONE_GB)
+#define MAX_DIMM_SZ (16 * GiB)
 #define GET_DIMM_SZ ((i < dimm_cnt - 1) ? MAX_DIMM_SZ \
                                         : ((ram_size - 1) % MAX_DIMM_SZ) + 1)
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 11/40] hw/xen: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
@ 2018-06-11  1:14   ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 02/40] vdi: Use definitions from "qemu/units.h" Philippe Mathieu-Daudé
                     ` (40 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Stefano Stabellini, Anthony Perard,
	Kevin Wolf, Max Reitz, Paolo Bonzini, Richard Henderson,
	Eduardo Habkost, Michael S. Tsirkin, Marcel Apfelbaum,
	open list:X86, open list:Block layer core

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alan Robinson <Alan.Robinson@ts.fujitsu.com>
---
 hw/block/xen_disk.c        |  5 +++--
 hw/i386/xen/xen-mapcache.c |  3 ++-
 hw/xenpv/xen_domainbuild.c | 13 +++++++------
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
index 9fbc0cdb87..5e7f17ffa4 100644
--- a/hw/block/xen_disk.c
+++ b/hw/block/xen_disk.c
@@ -20,6 +20,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include <sys/ioctl.h>
 #include <sys/uio.h>
 
@@ -812,9 +813,9 @@ static int blk_connect(struct XenDevice *xendev)
     }
 
     xen_pv_printf(xendev, 1, "type \"%s\", fileproto \"%s\", filename \"%s\","
-                  " size %" PRId64 " (%" PRId64 " MB)\n",
+                  " size %" PRId64 " (%llu MB)\n",
                   blkdev->type, blkdev->fileproto, blkdev->filename,
-                  blkdev->file_size, blkdev->file_size >> 20);
+                  blkdev->file_size, blkdev->file_size / MiB);
 
     /* Fill in number of sector size and number of sectors */
     xenstore_write_be_int(xendev, "sector-size", blkdev->file_blk);
diff --git a/hw/i386/xen/xen-mapcache.c b/hw/i386/xen/xen-mapcache.c
index 628b813a11..4e4f069a24 100644
--- a/hw/i386/xen/xen-mapcache.c
+++ b/hw/i386/xen/xen-mapcache.c
@@ -9,6 +9,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/error-report.h"
 
 #include <sys/resource.h>
@@ -46,7 +47,7 @@
  * From empirical tests I observed that qemu use 75MB more than the
  * max_mcache_size.
  */
-#define NON_MCACHE_MEMORY_SIZE (80 * 1024 * 1024)
+#define NON_MCACHE_MEMORY_SIZE (80 * MiB)
 
 typedef struct MapCacheEntry {
     hwaddr paddr_index;
diff --git a/hw/xenpv/xen_domainbuild.c b/hw/xenpv/xen_domainbuild.c
index 027f76fad1..188acaca16 100644
--- a/hw/xenpv/xen_domainbuild.c
+++ b/hw/xenpv/xen_domainbuild.c
@@ -1,4 +1,5 @@
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/xen/xen_backend.h"
 #include "xen_domainbuild.h"
 #include "qemu/timer.h"
@@ -75,9 +76,9 @@ int xenstore_domain_init1(const char *kernel, const char *ramdisk,
     xenstore_write_str(dom, "vm",     vm);
 
     /* memory */
-    xenstore_write_int(dom, "memory/target", ram_size >> 10);  // kB
-    xenstore_write_int(vm, "memory",         ram_size >> 20);  // MB
-    xenstore_write_int(vm, "maxmem",         ram_size >> 20);  // MB
+    xenstore_write_int(dom, "memory/target", ram_size / KiB);
+    xenstore_write_int(vm, "memory",         ram_size / MiB);
+    xenstore_write_int(vm, "maxmem",         ram_size / MiB);
 
     /* cpus */
     for (i = 0; i < smp_cpus; i++) {
@@ -113,7 +114,7 @@ int xenstore_domain_init2(int xenstore_port, int xenstore_mfn,
 
     /* console */
     xenstore_write_str(dom, "console/type",     "ioemu");
-    xenstore_write_int(dom, "console/limit",    128 * 1024);
+    xenstore_write_int(dom, "console/limit",    128 * KiB);
     xenstore_write_int(dom, "console/ring-ref", console_mfn);
     xenstore_write_int(dom, "console/port",     console_port);
     xen_config_dev_console(0);
@@ -260,7 +261,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     }
 #endif
 
-    rc = xc_domain_setmaxmem(xen_xc, xen_domid, ram_size >> 10);
+    rc = xc_domain_setmaxmem(xen_xc, xen_domid, ram_size / KiB);
     if (rc < 0) {
         fprintf(stderr, "xen: xc_domain_setmaxmem() failed\n");
         goto err;
@@ -269,7 +270,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     xenstore_port = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0);
     console_port = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0);
 
-    rc = xc_linux_build(xen_xc, xen_domid, ram_size >> 20,
+    rc = xc_linux_build(xen_xc, xen_domid, ram_size / MiB,
                         kernel, ramdisk, cmdline,
                         0, flags,
                         xenstore_port, &xenstore_mfn,
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [PATCH v4 11/40] hw/xen: Use the IEC binary prefix definitions
@ 2018-06-11  1:14   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Kevin Wolf, Stefano Stabellini, Eduardo Habkost,
	open list:Block layer core, Michael S. Tsirkin, qemu-trivial,
	Philippe Mathieu-Daudé,
	qemu-devel, Marcel Apfelbaum, open list:X86, Anthony Perard,
	Paolo Bonzini, Max Reitz, Richard Henderson

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alan Robinson <Alan.Robinson@ts.fujitsu.com>
---
 hw/block/xen_disk.c        |  5 +++--
 hw/i386/xen/xen-mapcache.c |  3 ++-
 hw/xenpv/xen_domainbuild.c | 13 +++++++------
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
index 9fbc0cdb87..5e7f17ffa4 100644
--- a/hw/block/xen_disk.c
+++ b/hw/block/xen_disk.c
@@ -20,6 +20,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include <sys/ioctl.h>
 #include <sys/uio.h>
 
@@ -812,9 +813,9 @@ static int blk_connect(struct XenDevice *xendev)
     }
 
     xen_pv_printf(xendev, 1, "type \"%s\", fileproto \"%s\", filename \"%s\","
-                  " size %" PRId64 " (%" PRId64 " MB)\n",
+                  " size %" PRId64 " (%llu MB)\n",
                   blkdev->type, blkdev->fileproto, blkdev->filename,
-                  blkdev->file_size, blkdev->file_size >> 20);
+                  blkdev->file_size, blkdev->file_size / MiB);
 
     /* Fill in number of sector size and number of sectors */
     xenstore_write_be_int(xendev, "sector-size", blkdev->file_blk);
diff --git a/hw/i386/xen/xen-mapcache.c b/hw/i386/xen/xen-mapcache.c
index 628b813a11..4e4f069a24 100644
--- a/hw/i386/xen/xen-mapcache.c
+++ b/hw/i386/xen/xen-mapcache.c
@@ -9,6 +9,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/error-report.h"
 
 #include <sys/resource.h>
@@ -46,7 +47,7 @@
  * From empirical tests I observed that qemu use 75MB more than the
  * max_mcache_size.
  */
-#define NON_MCACHE_MEMORY_SIZE (80 * 1024 * 1024)
+#define NON_MCACHE_MEMORY_SIZE (80 * MiB)
 
 typedef struct MapCacheEntry {
     hwaddr paddr_index;
diff --git a/hw/xenpv/xen_domainbuild.c b/hw/xenpv/xen_domainbuild.c
index 027f76fad1..188acaca16 100644
--- a/hw/xenpv/xen_domainbuild.c
+++ b/hw/xenpv/xen_domainbuild.c
@@ -1,4 +1,5 @@
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/xen/xen_backend.h"
 #include "xen_domainbuild.h"
 #include "qemu/timer.h"
@@ -75,9 +76,9 @@ int xenstore_domain_init1(const char *kernel, const char *ramdisk,
     xenstore_write_str(dom, "vm",     vm);
 
     /* memory */
-    xenstore_write_int(dom, "memory/target", ram_size >> 10);  // kB
-    xenstore_write_int(vm, "memory",         ram_size >> 20);  // MB
-    xenstore_write_int(vm, "maxmem",         ram_size >> 20);  // MB
+    xenstore_write_int(dom, "memory/target", ram_size / KiB);
+    xenstore_write_int(vm, "memory",         ram_size / MiB);
+    xenstore_write_int(vm, "maxmem",         ram_size / MiB);
 
     /* cpus */
     for (i = 0; i < smp_cpus; i++) {
@@ -113,7 +114,7 @@ int xenstore_domain_init2(int xenstore_port, int xenstore_mfn,
 
     /* console */
     xenstore_write_str(dom, "console/type",     "ioemu");
-    xenstore_write_int(dom, "console/limit",    128 * 1024);
+    xenstore_write_int(dom, "console/limit",    128 * KiB);
     xenstore_write_int(dom, "console/ring-ref", console_mfn);
     xenstore_write_int(dom, "console/port",     console_port);
     xen_config_dev_console(0);
@@ -260,7 +261,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     }
 #endif
 
-    rc = xc_domain_setmaxmem(xen_xc, xen_domid, ram_size >> 10);
+    rc = xc_domain_setmaxmem(xen_xc, xen_domid, ram_size / KiB);
     if (rc < 0) {
         fprintf(stderr, "xen: xc_domain_setmaxmem() failed\n");
         goto err;
@@ -269,7 +270,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     xenstore_port = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0);
     console_port = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0);
 
-    rc = xc_linux_build(xen_xc, xen_domid, ram_size >> 20,
+    rc = xc_linux_build(xen_xc, xen_domid, ram_size / MiB,
                         kernel, ramdisk, cmdline,
                         0, flags,
                         xenstore_port, &xenstore_mfn,
-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 12/40] hw/tpm: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (10 preceding siblings ...)
  2018-06-11  1:14   ` Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 13/40] hw/block: " Philippe Mathieu-Daudé
                   ` (29 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Stefan Berger, Michael S. Tsirkin,
	Igor Mammedov

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/acpi/tpm.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/hw/acpi/tpm.h b/include/hw/acpi/tpm.h
index 46ac4dc581..3580ffd50c 100644
--- a/include/hw/acpi/tpm.h
+++ b/include/hw/acpi/tpm.h
@@ -16,6 +16,7 @@
 #ifndef HW_ACPI_TPM_H
 #define HW_ACPI_TPM_H
 
+#include "qemu/units.h"
 #include "hw/registerfields.h"
 
 #define TPM_TIS_ADDR_BASE           0xFED40000
@@ -176,7 +177,7 @@ REG32(CRB_DATA_BUFFER, 0x80)
 #define TPM_CRB_ADDR_CTRL           (TPM_CRB_ADDR_BASE + A_CRB_CTRL_REQ)
 #define TPM_CRB_R_MAX               R_CRB_DATA_BUFFER
 
-#define TPM_LOG_AREA_MINIMUM_SIZE   (64 * 1024)
+#define TPM_LOG_AREA_MINIMUM_SIZE   (64 * KiB)
 
 #define TPM_TCPA_ACPI_CLASS_CLIENT  0
 #define TPM_TCPA_ACPI_CLASS_SERVER  1
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 13/40] hw/block: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (11 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 12/40] hw/tpm: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14   ` Philippe Mathieu-Daudé
                   ` (28 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Peter Crosthwaite, Alistair Francis,
	Kevin Wolf, Max Reitz, Keith Busch, open list:Block layer core

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/block/m25p80.c  | 5 +++--
 hw/block/nvme.c    | 3 ++-
 hw/block/tc58128.c | 3 ++-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index a5ccffb4aa..38c69c81a9 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -22,6 +22,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/hw.h"
 #include "sysemu/block-backend.h"
 #include "hw/ssi/ssi.h"
@@ -541,12 +542,12 @@ static void flash_erase(Flash *s, int offset, FlashCMD cmd)
     switch (cmd) {
     case ERASE_4K:
     case ERASE4_4K:
-        len = 4 << 10;
+        len = 4 * KiB;
         capa_to_assert = ER_4K;
         break;
     case ERASE_32K:
     case ERASE4_32K:
-        len = 32 << 10;
+        len = 32 * KiB;
         capa_to_assert = ER_32K;
         break;
     case ERASE_SECTOR:
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 811084b6a7..ae2188c761 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -25,6 +25,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/block/block.h"
 #include "hw/hw.h"
 #include "hw/pci/msix.h"
@@ -648,7 +649,7 @@ static uint16_t nvme_identify_ns(NvmeCtrl *n, NvmeIdentify *c)
 
 static uint16_t nvme_identify_nslist(NvmeCtrl *n, NvmeIdentify *c)
 {
-    static const int data_len = 4096;
+    static const int data_len = 4 * KiB;
     uint32_t min_nsid = le32_to_cpu(c->nsid);
     uint64_t prp1 = le64_to_cpu(c->prp1);
     uint64_t prp2 = le64_to_cpu(c->prp2);
diff --git a/hw/block/tc58128.c b/hw/block/tc58128.c
index 1d9f7ee000..808ad76ba6 100644
--- a/hw/block/tc58128.c
+++ b/hw/block/tc58128.c
@@ -1,4 +1,5 @@
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/hw.h"
 #include "hw/sh4/sh.h"
 #include "hw/loader.h"
@@ -26,7 +27,7 @@ typedef struct {
 
 static tc58128_dev tc58128_devs[2];
 
-#define FLASH_SIZE (16*1024*1024)
+#define FLASH_SIZE (16 * MiB)
 
 static void init_dev(tc58128_dev * dev, const char *filename)
 {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 14/40] hw/display: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
@ 2018-06-11  1:14   ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 02/40] vdi: Use definitions from "qemu/units.h" Philippe Mathieu-Daudé
                     ` (40 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Gerd Hoffmann, Michael S. Tsirkin,
	Stefano Stabellini, Anthony Perard, Alistair Francis,
	Edgar E. Iglesias, open list:X86, open list:Xilinx ZynqMP

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
---
 include/hw/display/xlnx_dp.h |  5 +++--
 hw/display/bochs-display.c   |  9 +++++----
 hw/display/cirrus_vga.c      | 10 +++++-----
 hw/display/g364fb.c          |  4 ++--
 hw/display/qxl.c             | 28 ++++++++++++----------------
 hw/display/vga-isa-mm.c      |  5 +++--
 hw/display/vga.c             |  5 +++--
 hw/display/virtio-gpu.c      |  4 ++--
 hw/display/vmware_vga.c      |  3 ++-
 hw/display/xenfb.c           |  3 ++-
 10 files changed, 39 insertions(+), 37 deletions(-)

diff --git a/include/hw/display/xlnx_dp.h b/include/hw/display/xlnx_dp.h
index ee046a5fac..26b759cd44 100644
--- a/include/hw/display/xlnx_dp.h
+++ b/include/hw/display/xlnx_dp.h
@@ -29,14 +29,15 @@
 #include "hw/display/dpcd.h"
 #include "hw/i2c/i2c-ddc.h"
 #include "qemu/fifo8.h"
+#include "qemu/units.h"
 #include "hw/dma/xlnx_dpdma.h"
 #include "audio/audio.h"
 
 #ifndef XLNX_DP_H
 #define XLNX_DP_H
 
-#define AUD_CHBUF_MAX_DEPTH                 32768
-#define MAX_QEMU_BUFFER_SIZE                4096
+#define AUD_CHBUF_MAX_DEPTH                 (32 * KiB)
+#define MAX_QEMU_BUFFER_SIZE                (4 * KiB)
 
 #define DP_CORE_REG_ARRAY_SIZE              (0x3AF >> 2)
 #define DP_AVBUF_REG_ARRAY_SIZE             (0x238 >> 2)
diff --git a/hw/display/bochs-display.c b/hw/display/bochs-display.c
index 1187d77576..5e0c1f1914 100644
--- a/hw/display/bochs-display.c
+++ b/hw/display/bochs-display.c
@@ -5,6 +5,7 @@
  * See the COPYING file in the top-level directory.
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/hw.h"
 #include "hw/pci/pci.h"
 #include "hw/display/bochs-vbe.h"
@@ -70,7 +71,7 @@ static uint64_t bochs_display_vbe_read(void *ptr, hwaddr addr,
     case VBE_DISPI_INDEX_ID:
         return VBE_DISPI_ID5;
     case VBE_DISPI_INDEX_VIDEO_MEMORY_64K:
-        return s->vgamem / (64 * 1024);
+        return s->vgamem / (64 * KiB);
     }
 
     if (index >= ARRAY_SIZE(s->vbe_regs)) {
@@ -258,10 +259,10 @@ static void bochs_display_realize(PCIDevice *dev, Error **errp)
 
     s->con = graphic_console_init(DEVICE(dev), 0, &bochs_display_gfx_ops, s);
 
-    if (s->vgamem < (4 * 1024 * 1024)) {
+    if (s->vgamem < 4 * MiB) {
         error_setg(errp, "bochs-display: video memory too small");
     }
-    if (s->vgamem > (256 * 1024 * 1024)) {
+    if (s->vgamem > 256 * MiB) {
         error_setg(errp, "bochs-display: video memory too big");
     }
     s->vgamem = pow2ceil(s->vgamem);
@@ -323,7 +324,7 @@ static void bochs_display_exit(PCIDevice *dev)
 }
 
 static Property bochs_display_properties[] = {
-    DEFINE_PROP_SIZE("vgamem", BochsDisplayState, vgamem, 16 * 1024 * 1024),
+    DEFINE_PROP_SIZE("vgamem", BochsDisplayState, vgamem, 16 * MiB),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
index 138ae961b9..5e44f00f3f 100644
--- a/hw/display/cirrus_vga.c
+++ b/hw/display/cirrus_vga.c
@@ -27,6 +27,7 @@
  *   available at http://home.worldonline.dk/~finth/
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "trace.h"
 #include "hw/hw.h"
@@ -2218,7 +2219,7 @@ static inline void cirrus_cursor_compute_yrange(CirrusVGAState *s)
     uint32_t content;
     int y, y_min, y_max;
 
-    src = s->vga.vram_ptr + s->real_vram_size - 16 * 1024;
+    src = s->vga.vram_ptr + s->real_vram_size - 16 * KiB;
     if (s->vga.sr[0x12] & CIRRUS_CURSOR_LARGE) {
         src += (s->vga.sr[0x13] & 0x3c) * 256;
         y_min = 64;
@@ -2347,7 +2348,7 @@ static void cirrus_cursor_draw_line(VGACommonState *s1, uint8_t *d1, int scr_y)
         return;
     }
 
-    src = s->vga.vram_ptr + s->real_vram_size - 16 * 1024;
+    src = s->vga.vram_ptr + s->real_vram_size - 16 * KiB;
     if (s->vga.sr[0x12] & CIRRUS_CURSOR_LARGE) {
         src += (s->vga.sr[0x13] & 0x3c) * 256;
         src += (scr_y - s->vga.hw_cursor_y) * 16;
@@ -2995,8 +2996,7 @@ static void cirrus_init_common(CirrusVGAState *s, Object *owner,
 
     /* I/O handler for LFB */
     memory_region_init_io(&s->cirrus_linear_io, owner, &cirrus_linear_io_ops, s,
-                          "cirrus-linear-io", s->vga.vram_size_mb
-                                              * 1024 * 1024);
+                          "cirrus-linear-io", s->vga.vram_size_mb * MiB);
     memory_region_set_flush_coalesced(&s->cirrus_linear_io);
 
     /* I/O handler for LFB */
@@ -3013,7 +3013,7 @@ static void cirrus_init_common(CirrusVGAState *s, Object *owner,
     memory_region_set_flush_coalesced(&s->cirrus_mmio_io);
 
     s->real_vram_size =
-        (s->device_id == CIRRUS_ID_CLGD5446) ? 4096 * 1024 : 2048 * 1024;
+        (s->device_id == CIRRUS_ID_CLGD5446) ? 4 * MiB : 2 * MiB;
 
     /* XXX: s->vga.vram_size must be a power of two */
     s->cirrus_addr_mask = s->real_vram_size - 1;
diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c
index 3d75394e77..fbc2b2422d 100644
--- a/hw/display/g364fb.c
+++ b/hw/display/g364fb.c
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/hw.h"
 #include "qemu/error-report.h"
 #include "ui/console.h"
@@ -510,8 +511,7 @@ static void g364fb_sysbus_reset(DeviceState *d)
 }
 
 static Property g364fb_sysbus_properties[] = {
-    DEFINE_PROP_UINT32("vram_size", G364SysBusState, g364.vram_size,
-    8 * 1024 * 1024),
+    DEFINE_PROP_UINT32("vram_size", G364SysBusState, g364.vram_size, 8 * MiB),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index a71714ccb4..14eebb5d93 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -19,6 +19,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include <zlib.h>
 
 #include "qapi/error.h"
@@ -2012,11 +2013,11 @@ static void qxl_init_ramsize(PCIQXLDevice *qxl)
     if (qxl->vgamem_size_mb > 256) {
         qxl->vgamem_size_mb = 256;
     }
-    qxl->vgamem_size = qxl->vgamem_size_mb * 1024 * 1024;
+    qxl->vgamem_size = qxl->vgamem_size_mb * MiB;
 
     /* vga ram (bar 0, total) */
     if (qxl->ram_size_mb != -1) {
-        qxl->vga.vram_size = qxl->ram_size_mb * 1024 * 1024;
+        qxl->vga.vram_size = qxl->ram_size_mb * MiB;
     }
     if (qxl->vga.vram_size < qxl->vgamem_size * 2) {
         qxl->vga.vram_size = qxl->vgamem_size * 2;
@@ -2024,7 +2025,7 @@ static void qxl_init_ramsize(PCIQXLDevice *qxl)
 
     /* vram32 (surfaces, 32bit, bar 1) */
     if (qxl->vram32_size_mb != -1) {
-        qxl->vram32_size = qxl->vram32_size_mb * 1024 * 1024;
+        qxl->vram32_size = qxl->vram32_size_mb * MiB;
     }
     if (qxl->vram32_size < 4096) {
         qxl->vram32_size = 4096;
@@ -2032,7 +2033,7 @@ static void qxl_init_ramsize(PCIQXLDevice *qxl)
 
     /* vram (surfaces, 64bit, bar 4+5) */
     if (qxl->vram_size_mb != -1) {
-        qxl->vram_size = (uint64_t)qxl->vram_size_mb * 1024 * 1024;
+        qxl->vram_size = (uint64_t)qxl->vram_size_mb * MiB;
     }
     if (qxl->vram_size < qxl->vram32_size) {
         qxl->vram_size = qxl->vram32_size;
@@ -2134,13 +2135,10 @@ static void qxl_realize_common(PCIQXLDevice *qxl, Error **errp)
     }
 
     /* print pci bar details */
-    dprint(qxl, 1, "ram/%s: %d MB [region 0]\n",
-           qxl->id == 0 ? "pri" : "sec",
-           qxl->vga.vram_size / (1024*1024));
-    dprint(qxl, 1, "vram/32: %" PRIx64 "d MB [region 1]\n",
-           qxl->vram32_size / (1024*1024));
-    dprint(qxl, 1, "vram/64: %" PRIx64 "d MB %s\n",
-           qxl->vram_size / (1024*1024),
+    dprint(qxl, 1, "ram/%s: %llu MB [region 0]\n",
+           qxl->id == 0 ? "pri" : "sec", qxl->vga.vram_size / MiB);
+    dprint(qxl, 1, "vram/32: %llu MB [region 1]\n", qxl->vram32_size / MiB);
+    dprint(qxl, 1, "vram/64: %llu MB %s\n", qxl->vram_size / MiB,
            qxl->vram32_size < qxl->vram_size ? "[region 4]" : "[unmapped]");
 
     qxl->ssd.qxl.base.sif = &qxl_interface.base;
@@ -2167,7 +2165,7 @@ static void qxl_realize_primary(PCIDevice *dev, Error **errp)
     qxl->id = 0;
     qxl_init_ramsize(qxl);
     vga->vbe_size = qxl->vgamem_size;
-    vga->vram_size_mb = qxl->vga.vram_size >> 20;
+    vga->vram_size_mb = qxl->vga.vram_size / MiB;
     vga_common_init(vga, OBJECT(dev), true);
     vga_init(vga, OBJECT(dev),
              pci_address_space(dev), pci_address_space_io(dev), false);
@@ -2391,10 +2389,8 @@ static VMStateDescription qxl_vmstate = {
 };
 
 static Property qxl_properties[] = {
-        DEFINE_PROP_UINT32("ram_size", PCIQXLDevice, vga.vram_size,
-                           64 * 1024 * 1024),
-        DEFINE_PROP_UINT64("vram_size", PCIQXLDevice, vram32_size,
-                           64 * 1024 * 1024),
+        DEFINE_PROP_UINT32("ram_size", PCIQXLDevice, vga.vram_size, 64 * MiB),
+        DEFINE_PROP_UINT64("vram_size", PCIQXLDevice, vram32_size, 64 * MiB),
         DEFINE_PROP_UINT32("revision", PCIQXLDevice, revision,
                            QXL_DEFAULT_REVISION),
         DEFINE_PROP_UINT32("debug", PCIQXLDevice, debug, 0),
diff --git a/hw/display/vga-isa-mm.c b/hw/display/vga-isa-mm.c
index e887b45651..bd58141117 100644
--- a/hw/display/vga-isa-mm.c
+++ b/hw/display/vga-isa-mm.c
@@ -22,12 +22,13 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/hw.h"
 #include "hw/display/vga.h"
 #include "vga_int.h"
 #include "ui/pixel_ops.h"
 
-#define VGA_RAM_SIZE (8192 * 1024)
+#define VGA_RAM_SIZE (8 * MiB)
 
 typedef struct ISAVGAMMState {
     VGACommonState vga;
@@ -130,7 +131,7 @@ int isa_vga_mm_init(hwaddr vram_base,
 
     s = g_malloc0(sizeof(*s));
 
-    s->vga.vram_size_mb = VGA_RAM_SIZE >> 20;
+    s->vga.vram_size_mb = VGA_RAM_SIZE / MiB;
     vga_common_init(&s->vga, NULL, true);
     vga_mm_init(s, vram_base, ctrl_base, it_shift, address_space);
 
diff --git a/hw/display/vga.c b/hw/display/vga.c
index ed476e4e80..d7599182a8 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
 #include "hw/display/vga.h"
@@ -721,7 +722,7 @@ uint32_t vbe_ioport_read_data(void *opaque, uint32_t addr)
             val = s->vbe_regs[s->vbe_index];
         }
     } else if (s->vbe_index == VBE_DISPI_INDEX_VIDEO_MEMORY_64K) {
-        val = s->vbe_size / (64 * 1024);
+        val = s->vbe_size / (64 * KiB);
     } else {
         val = 0;
     }
@@ -2192,7 +2193,7 @@ void vga_common_init(VGACommonState *s, Object *obj, bool global_vmstate)
 
     s->vram_size_mb = uint_clamp(s->vram_size_mb, 1, 512);
     s->vram_size_mb = pow2ceil(s->vram_size_mb);
-    s->vram_size = s->vram_size_mb << 20;
+    s->vram_size = s->vram_size_mb * MiB;
 
     if (!s->vbe_size) {
         s->vbe_size = s->vram_size;
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 2dd3c3481a..71a00718e6 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -12,6 +12,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu-common.h"
 #include "qemu/iov.h"
 #include "ui/console.h"
@@ -1314,8 +1315,7 @@ static const VMStateDescription vmstate_virtio_gpu = {
 
 static Property virtio_gpu_properties[] = {
     DEFINE_PROP_UINT32("max_outputs", VirtIOGPU, conf.max_outputs, 1),
-    DEFINE_PROP_SIZE("max_hostmem", VirtIOGPU, conf.max_hostmem,
-                     256 * 1024 * 1024),
+    DEFINE_PROP_SIZE("max_hostmem", VirtIOGPU, conf.max_hostmem, 256 * MiB),
 #ifdef CONFIG_VIRGL
     DEFINE_PROP_BIT("virgl", VirtIOGPU, conf.flags,
                     VIRTIO_GPU_FLAG_VIRGL_ENABLED, true),
diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
index bd3e8b3586..08deb08783 100644
--- a/hw/display/vmware_vga.c
+++ b/hw/display/vmware_vga.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
 #include "hw/loader.h"
@@ -565,7 +566,7 @@ static inline int vmsvga_fifo_length(struct vmsvga_state_s *s)
         s->fifo_next >= SVGA_FIFO_SIZE) {
         return 0;
     }
-    if (s->fifo_max < s->fifo_min + 10 * 1024) {
+    if (s->fifo_max < s->fifo_min + 10 * KiB) {
         return 0;
     }
 
diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c
index f5afcc0358..180d205021 100644
--- a/hw/display/xenfb.c
+++ b/hw/display/xenfb.c
@@ -25,6 +25,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 
 #include "hw/hw.h"
 #include "ui/input.h"
@@ -889,7 +890,7 @@ static int fb_initialise(struct XenDevice *xendev)
 	return rc;
 
     fb_page = fb->c.page;
-    rc = xenfb_configure_fb(fb, videoram * 1024 * 1024U,
+    rc = xenfb_configure_fb(fb, videoram * MiB,
 			    fb_page->width, fb_page->height, fb_page->depth,
 			    fb_page->mem_length, 0, fb_page->line_length);
     if (rc != 0)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [PATCH v4 14/40] hw/display: Use the IEC binary prefix definitions
@ 2018-06-11  1:14   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Stefano Stabellini, Michael S. Tsirkin, qemu-trivial,
	Alistair Francis, Philippe Mathieu-Daudé,
	qemu-devel, open list:Xilinx ZynqMP, Gerd Hoffmann,
	open list:X86, Anthony Perard, Edgar E. Iglesias

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
---
 include/hw/display/xlnx_dp.h |  5 +++--
 hw/display/bochs-display.c   |  9 +++++----
 hw/display/cirrus_vga.c      | 10 +++++-----
 hw/display/g364fb.c          |  4 ++--
 hw/display/qxl.c             | 28 ++++++++++++----------------
 hw/display/vga-isa-mm.c      |  5 +++--
 hw/display/vga.c             |  5 +++--
 hw/display/virtio-gpu.c      |  4 ++--
 hw/display/vmware_vga.c      |  3 ++-
 hw/display/xenfb.c           |  3 ++-
 10 files changed, 39 insertions(+), 37 deletions(-)

diff --git a/include/hw/display/xlnx_dp.h b/include/hw/display/xlnx_dp.h
index ee046a5fac..26b759cd44 100644
--- a/include/hw/display/xlnx_dp.h
+++ b/include/hw/display/xlnx_dp.h
@@ -29,14 +29,15 @@
 #include "hw/display/dpcd.h"
 #include "hw/i2c/i2c-ddc.h"
 #include "qemu/fifo8.h"
+#include "qemu/units.h"
 #include "hw/dma/xlnx_dpdma.h"
 #include "audio/audio.h"
 
 #ifndef XLNX_DP_H
 #define XLNX_DP_H
 
-#define AUD_CHBUF_MAX_DEPTH                 32768
-#define MAX_QEMU_BUFFER_SIZE                4096
+#define AUD_CHBUF_MAX_DEPTH                 (32 * KiB)
+#define MAX_QEMU_BUFFER_SIZE                (4 * KiB)
 
 #define DP_CORE_REG_ARRAY_SIZE              (0x3AF >> 2)
 #define DP_AVBUF_REG_ARRAY_SIZE             (0x238 >> 2)
diff --git a/hw/display/bochs-display.c b/hw/display/bochs-display.c
index 1187d77576..5e0c1f1914 100644
--- a/hw/display/bochs-display.c
+++ b/hw/display/bochs-display.c
@@ -5,6 +5,7 @@
  * See the COPYING file in the top-level directory.
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/hw.h"
 #include "hw/pci/pci.h"
 #include "hw/display/bochs-vbe.h"
@@ -70,7 +71,7 @@ static uint64_t bochs_display_vbe_read(void *ptr, hwaddr addr,
     case VBE_DISPI_INDEX_ID:
         return VBE_DISPI_ID5;
     case VBE_DISPI_INDEX_VIDEO_MEMORY_64K:
-        return s->vgamem / (64 * 1024);
+        return s->vgamem / (64 * KiB);
     }
 
     if (index >= ARRAY_SIZE(s->vbe_regs)) {
@@ -258,10 +259,10 @@ static void bochs_display_realize(PCIDevice *dev, Error **errp)
 
     s->con = graphic_console_init(DEVICE(dev), 0, &bochs_display_gfx_ops, s);
 
-    if (s->vgamem < (4 * 1024 * 1024)) {
+    if (s->vgamem < 4 * MiB) {
         error_setg(errp, "bochs-display: video memory too small");
     }
-    if (s->vgamem > (256 * 1024 * 1024)) {
+    if (s->vgamem > 256 * MiB) {
         error_setg(errp, "bochs-display: video memory too big");
     }
     s->vgamem = pow2ceil(s->vgamem);
@@ -323,7 +324,7 @@ static void bochs_display_exit(PCIDevice *dev)
 }
 
 static Property bochs_display_properties[] = {
-    DEFINE_PROP_SIZE("vgamem", BochsDisplayState, vgamem, 16 * 1024 * 1024),
+    DEFINE_PROP_SIZE("vgamem", BochsDisplayState, vgamem, 16 * MiB),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
index 138ae961b9..5e44f00f3f 100644
--- a/hw/display/cirrus_vga.c
+++ b/hw/display/cirrus_vga.c
@@ -27,6 +27,7 @@
  *   available at http://home.worldonline.dk/~finth/
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "trace.h"
 #include "hw/hw.h"
@@ -2218,7 +2219,7 @@ static inline void cirrus_cursor_compute_yrange(CirrusVGAState *s)
     uint32_t content;
     int y, y_min, y_max;
 
-    src = s->vga.vram_ptr + s->real_vram_size - 16 * 1024;
+    src = s->vga.vram_ptr + s->real_vram_size - 16 * KiB;
     if (s->vga.sr[0x12] & CIRRUS_CURSOR_LARGE) {
         src += (s->vga.sr[0x13] & 0x3c) * 256;
         y_min = 64;
@@ -2347,7 +2348,7 @@ static void cirrus_cursor_draw_line(VGACommonState *s1, uint8_t *d1, int scr_y)
         return;
     }
 
-    src = s->vga.vram_ptr + s->real_vram_size - 16 * 1024;
+    src = s->vga.vram_ptr + s->real_vram_size - 16 * KiB;
     if (s->vga.sr[0x12] & CIRRUS_CURSOR_LARGE) {
         src += (s->vga.sr[0x13] & 0x3c) * 256;
         src += (scr_y - s->vga.hw_cursor_y) * 16;
@@ -2995,8 +2996,7 @@ static void cirrus_init_common(CirrusVGAState *s, Object *owner,
 
     /* I/O handler for LFB */
     memory_region_init_io(&s->cirrus_linear_io, owner, &cirrus_linear_io_ops, s,
-                          "cirrus-linear-io", s->vga.vram_size_mb
-                                              * 1024 * 1024);
+                          "cirrus-linear-io", s->vga.vram_size_mb * MiB);
     memory_region_set_flush_coalesced(&s->cirrus_linear_io);
 
     /* I/O handler for LFB */
@@ -3013,7 +3013,7 @@ static void cirrus_init_common(CirrusVGAState *s, Object *owner,
     memory_region_set_flush_coalesced(&s->cirrus_mmio_io);
 
     s->real_vram_size =
-        (s->device_id == CIRRUS_ID_CLGD5446) ? 4096 * 1024 : 2048 * 1024;
+        (s->device_id == CIRRUS_ID_CLGD5446) ? 4 * MiB : 2 * MiB;
 
     /* XXX: s->vga.vram_size must be a power of two */
     s->cirrus_addr_mask = s->real_vram_size - 1;
diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c
index 3d75394e77..fbc2b2422d 100644
--- a/hw/display/g364fb.c
+++ b/hw/display/g364fb.c
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/hw.h"
 #include "qemu/error-report.h"
 #include "ui/console.h"
@@ -510,8 +511,7 @@ static void g364fb_sysbus_reset(DeviceState *d)
 }
 
 static Property g364fb_sysbus_properties[] = {
-    DEFINE_PROP_UINT32("vram_size", G364SysBusState, g364.vram_size,
-    8 * 1024 * 1024),
+    DEFINE_PROP_UINT32("vram_size", G364SysBusState, g364.vram_size, 8 * MiB),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index a71714ccb4..14eebb5d93 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -19,6 +19,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include <zlib.h>
 
 #include "qapi/error.h"
@@ -2012,11 +2013,11 @@ static void qxl_init_ramsize(PCIQXLDevice *qxl)
     if (qxl->vgamem_size_mb > 256) {
         qxl->vgamem_size_mb = 256;
     }
-    qxl->vgamem_size = qxl->vgamem_size_mb * 1024 * 1024;
+    qxl->vgamem_size = qxl->vgamem_size_mb * MiB;
 
     /* vga ram (bar 0, total) */
     if (qxl->ram_size_mb != -1) {
-        qxl->vga.vram_size = qxl->ram_size_mb * 1024 * 1024;
+        qxl->vga.vram_size = qxl->ram_size_mb * MiB;
     }
     if (qxl->vga.vram_size < qxl->vgamem_size * 2) {
         qxl->vga.vram_size = qxl->vgamem_size * 2;
@@ -2024,7 +2025,7 @@ static void qxl_init_ramsize(PCIQXLDevice *qxl)
 
     /* vram32 (surfaces, 32bit, bar 1) */
     if (qxl->vram32_size_mb != -1) {
-        qxl->vram32_size = qxl->vram32_size_mb * 1024 * 1024;
+        qxl->vram32_size = qxl->vram32_size_mb * MiB;
     }
     if (qxl->vram32_size < 4096) {
         qxl->vram32_size = 4096;
@@ -2032,7 +2033,7 @@ static void qxl_init_ramsize(PCIQXLDevice *qxl)
 
     /* vram (surfaces, 64bit, bar 4+5) */
     if (qxl->vram_size_mb != -1) {
-        qxl->vram_size = (uint64_t)qxl->vram_size_mb * 1024 * 1024;
+        qxl->vram_size = (uint64_t)qxl->vram_size_mb * MiB;
     }
     if (qxl->vram_size < qxl->vram32_size) {
         qxl->vram_size = qxl->vram32_size;
@@ -2134,13 +2135,10 @@ static void qxl_realize_common(PCIQXLDevice *qxl, Error **errp)
     }
 
     /* print pci bar details */
-    dprint(qxl, 1, "ram/%s: %d MB [region 0]\n",
-           qxl->id == 0 ? "pri" : "sec",
-           qxl->vga.vram_size / (1024*1024));
-    dprint(qxl, 1, "vram/32: %" PRIx64 "d MB [region 1]\n",
-           qxl->vram32_size / (1024*1024));
-    dprint(qxl, 1, "vram/64: %" PRIx64 "d MB %s\n",
-           qxl->vram_size / (1024*1024),
+    dprint(qxl, 1, "ram/%s: %llu MB [region 0]\n",
+           qxl->id == 0 ? "pri" : "sec", qxl->vga.vram_size / MiB);
+    dprint(qxl, 1, "vram/32: %llu MB [region 1]\n", qxl->vram32_size / MiB);
+    dprint(qxl, 1, "vram/64: %llu MB %s\n", qxl->vram_size / MiB,
            qxl->vram32_size < qxl->vram_size ? "[region 4]" : "[unmapped]");
 
     qxl->ssd.qxl.base.sif = &qxl_interface.base;
@@ -2167,7 +2165,7 @@ static void qxl_realize_primary(PCIDevice *dev, Error **errp)
     qxl->id = 0;
     qxl_init_ramsize(qxl);
     vga->vbe_size = qxl->vgamem_size;
-    vga->vram_size_mb = qxl->vga.vram_size >> 20;
+    vga->vram_size_mb = qxl->vga.vram_size / MiB;
     vga_common_init(vga, OBJECT(dev), true);
     vga_init(vga, OBJECT(dev),
              pci_address_space(dev), pci_address_space_io(dev), false);
@@ -2391,10 +2389,8 @@ static VMStateDescription qxl_vmstate = {
 };
 
 static Property qxl_properties[] = {
-        DEFINE_PROP_UINT32("ram_size", PCIQXLDevice, vga.vram_size,
-                           64 * 1024 * 1024),
-        DEFINE_PROP_UINT64("vram_size", PCIQXLDevice, vram32_size,
-                           64 * 1024 * 1024),
+        DEFINE_PROP_UINT32("ram_size", PCIQXLDevice, vga.vram_size, 64 * MiB),
+        DEFINE_PROP_UINT64("vram_size", PCIQXLDevice, vram32_size, 64 * MiB),
         DEFINE_PROP_UINT32("revision", PCIQXLDevice, revision,
                            QXL_DEFAULT_REVISION),
         DEFINE_PROP_UINT32("debug", PCIQXLDevice, debug, 0),
diff --git a/hw/display/vga-isa-mm.c b/hw/display/vga-isa-mm.c
index e887b45651..bd58141117 100644
--- a/hw/display/vga-isa-mm.c
+++ b/hw/display/vga-isa-mm.c
@@ -22,12 +22,13 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/hw.h"
 #include "hw/display/vga.h"
 #include "vga_int.h"
 #include "ui/pixel_ops.h"
 
-#define VGA_RAM_SIZE (8192 * 1024)
+#define VGA_RAM_SIZE (8 * MiB)
 
 typedef struct ISAVGAMMState {
     VGACommonState vga;
@@ -130,7 +131,7 @@ int isa_vga_mm_init(hwaddr vram_base,
 
     s = g_malloc0(sizeof(*s));
 
-    s->vga.vram_size_mb = VGA_RAM_SIZE >> 20;
+    s->vga.vram_size_mb = VGA_RAM_SIZE / MiB;
     vga_common_init(&s->vga, NULL, true);
     vga_mm_init(s, vram_base, ctrl_base, it_shift, address_space);
 
diff --git a/hw/display/vga.c b/hw/display/vga.c
index ed476e4e80..d7599182a8 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
 #include "hw/display/vga.h"
@@ -721,7 +722,7 @@ uint32_t vbe_ioport_read_data(void *opaque, uint32_t addr)
             val = s->vbe_regs[s->vbe_index];
         }
     } else if (s->vbe_index == VBE_DISPI_INDEX_VIDEO_MEMORY_64K) {
-        val = s->vbe_size / (64 * 1024);
+        val = s->vbe_size / (64 * KiB);
     } else {
         val = 0;
     }
@@ -2192,7 +2193,7 @@ void vga_common_init(VGACommonState *s, Object *obj, bool global_vmstate)
 
     s->vram_size_mb = uint_clamp(s->vram_size_mb, 1, 512);
     s->vram_size_mb = pow2ceil(s->vram_size_mb);
-    s->vram_size = s->vram_size_mb << 20;
+    s->vram_size = s->vram_size_mb * MiB;
 
     if (!s->vbe_size) {
         s->vbe_size = s->vram_size;
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 2dd3c3481a..71a00718e6 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -12,6 +12,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu-common.h"
 #include "qemu/iov.h"
 #include "ui/console.h"
@@ -1314,8 +1315,7 @@ static const VMStateDescription vmstate_virtio_gpu = {
 
 static Property virtio_gpu_properties[] = {
     DEFINE_PROP_UINT32("max_outputs", VirtIOGPU, conf.max_outputs, 1),
-    DEFINE_PROP_SIZE("max_hostmem", VirtIOGPU, conf.max_hostmem,
-                     256 * 1024 * 1024),
+    DEFINE_PROP_SIZE("max_hostmem", VirtIOGPU, conf.max_hostmem, 256 * MiB),
 #ifdef CONFIG_VIRGL
     DEFINE_PROP_BIT("virgl", VirtIOGPU, conf.flags,
                     VIRTIO_GPU_FLAG_VIRGL_ENABLED, true),
diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
index bd3e8b3586..08deb08783 100644
--- a/hw/display/vmware_vga.c
+++ b/hw/display/vmware_vga.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
 #include "hw/loader.h"
@@ -565,7 +566,7 @@ static inline int vmsvga_fifo_length(struct vmsvga_state_s *s)
         s->fifo_next >= SVGA_FIFO_SIZE) {
         return 0;
     }
-    if (s->fifo_max < s->fifo_min + 10 * 1024) {
+    if (s->fifo_max < s->fifo_min + 10 * KiB) {
         return 0;
     }
 
diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c
index f5afcc0358..180d205021 100644
--- a/hw/display/xenfb.c
+++ b/hw/display/xenfb.c
@@ -25,6 +25,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 
 #include "hw/hw.h"
 #include "ui/input.h"
@@ -889,7 +890,7 @@ static int fb_initialise(struct XenDevice *xendev)
 	return rc;
 
     fb_page = fb->c.page;
-    rc = xenfb_configure_fb(fb, videoram * 1024 * 1024U,
+    rc = xenfb_configure_fb(fb, videoram * MiB,
 			    fb_page->width, fb_page->height, fb_page->depth,
 			    fb_page->mem_length, 0, fb_page->line_length);
     if (rc != 0)
-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 15/40] hw/misc: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (13 preceding siblings ...)
  2018-06-11  1:14   ` Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 16/40] hw/riscv: " Philippe Mathieu-Daudé
                   ` (26 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-trivial, Jiri Slaby

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/misc/auxbus.c | 3 ++-
 hw/misc/edu.c    | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/misc/auxbus.c b/hw/misc/auxbus.c
index b4cacd664b..b8a8721201 100644
--- a/hw/misc/auxbus.c
+++ b/hw/misc/auxbus.c
@@ -27,6 +27,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/log.h"
 #include "hw/misc/auxbus.h"
 #include "hw/i2c/i2c.h"
@@ -68,7 +69,7 @@ AUXBus *aux_init_bus(DeviceState *parent, const char *name)
 
     /* Memory related. */
     bus->aux_io = g_malloc(sizeof(*bus->aux_io));
-    memory_region_init(bus->aux_io, OBJECT(bus), "aux-io", (1 << 20));
+    memory_region_init(bus->aux_io, OBJECT(bus), "aux-io", 1 * MiB);
     address_space_init(&bus->aux_addr_space, bus->aux_io, "aux-io");
     return bus;
 }
diff --git a/hw/misc/edu.c b/hw/misc/edu.c
index 34eb05d213..df26a4d046 100644
--- a/hw/misc/edu.c
+++ b/hw/misc/edu.c
@@ -23,6 +23,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/pci/pci.h"
 #include "hw/pci/msi.h"
 #include "qemu/timer.h"
@@ -357,7 +358,7 @@ static void pci_edu_realize(PCIDevice *pdev, Error **errp)
                        edu, QEMU_THREAD_JOINABLE);
 
     memory_region_init_io(&edu->mmio, OBJECT(edu), &edu_mmio_ops, edu,
-                    "edu-mmio", 1 << 20);
+                    "edu-mmio", 1 * MiB);
     pci_register_bar(pdev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &edu->mmio);
 }
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 16/40] hw/riscv: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (14 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 15/40] hw/misc: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:22   ` Michael Clark
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 17/40] hw/m68k: " Philippe Mathieu-Daudé
                   ` (25 subsequent siblings)
  41 siblings, 1 reply; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Michael Clark, Palmer Dabbelt,
	Sagar Karandikar, Bastian Koppelmann

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/riscv/virt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index ad03113e0f..34d48993a2 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -19,6 +19,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/log.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
@@ -84,7 +85,7 @@ static hwaddr load_initrd(const char *filename, uint64_t mem_size,
      * halfway into RAM, and for boards with 256MB of RAM or more we put
      * the initrd at 128MB.
      */
-    *start = kernel_entry + MIN(mem_size / 2, 128 * 1024 * 1024);
+    *start = kernel_entry + MIN(mem_size / 2, 128 * MiB);
 
     size = load_ramdisk(filename, *start, mem_size - *start);
     if (size == -1) {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 17/40] hw/m68k: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (15 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 16/40] hw/riscv: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 18/40] hw/sparc: " Philippe Mathieu-Daudé
                   ` (24 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-trivial, Thomas Huth

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Thomas Huth <thuth@tuxfamily.org>
---
 hw/m68k/mcf5208.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c
index ae3dcc98c3..0f2245dd81 100644
--- a/hw/m68k/mcf5208.c
+++ b/hw/m68k/mcf5208.c
@@ -6,6 +6,7 @@
  * This code is licensed under the GPL
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
@@ -241,7 +242,7 @@ static void mcf5208evb_init(MachineState *machine)
     memory_region_add_subregion(address_space_mem, 0x40000000, ram);
 
     /* Internal SRAM.  */
-    memory_region_init_ram(sram, NULL, "mcf5208.sram", 16384, &error_fatal);
+    memory_region_init_ram(sram, NULL, "mcf5208.sram", 16 * KiB, &error_fatal);
     memory_region_add_subregion(address_space_mem, 0x80000000, sram);
 
     /* Internal peripherals.  */
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 18/40] hw/sparc: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (16 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 17/40] hw/m68k: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 19/40] hw/s390x: " Philippe Mathieu-Daudé
                   ` (23 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Fabien Chouteau, Mark Cave-Ayland,
	Artyom Tarasenko

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/sparc/leon3.c     | 9 +++++----
 hw/sparc/sun4m.c     | 9 ++++-----
 hw/sparc64/niagara.c | 3 ++-
 hw/sparc64/sun4u.c   | 4 ++--
 4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c
index 98fa6adae0..60400923d5 100644
--- a/hw/sparc/leon3.c
+++ b/hw/sparc/leon3.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
@@ -139,9 +140,9 @@ static void leon3_generic_hw_init(MachineState *machine)
     env->qemu_irq_ack = leon3_irq_manager;
 
     /* Allocate RAM */
-    if ((uint64_t)ram_size > (1UL << 30)) {
-        error_report("Too much memory for this machine: %d, maximum 1G",
-                     (unsigned int)(ram_size / (1024 * 1024)));
+    if (ram_size > 1 * GiB) {
+        error_report("Too much memory for this machine: %lluMB, maximum 1G",
+                     ram_size / MiB);
         exit(1);
     }
 
@@ -149,7 +150,7 @@ static void leon3_generic_hw_init(MachineState *machine)
     memory_region_add_subregion(address_space_mem, 0x40000000, ram);
 
     /* Allocate BIOS */
-    prom_size = 8 * 1024 * 1024; /* 8Mb */
+    prom_size = 8 * MiB;
     memory_region_init_ram(prom, NULL, "Leon3.bios", prom_size, &error_fatal);
     memory_region_set_readonly(prom, true);
     memory_region_add_subregion(address_space_mem, 0x00000000, prom);
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 0ee779fafe..d29411f013 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "cpu.h"
@@ -45,7 +46,6 @@
 #include "hw/loader.h"
 #include "elf.h"
 #include "trace.h"
-#include "qemu/cutils.h"
 
 /*
  * Sun4m architecture was used in the following machines:
@@ -66,7 +66,7 @@
 #define KERNEL_LOAD_ADDR     0x00004000
 #define CMDLINE_ADDR         0x007ff000
 #define INITRD_LOAD_ADDR     0x00800000
-#define PROM_SIZE_MAX        (1024 * 1024)
+#define PROM_SIZE_MAX        (1 * MiB)
 #define PROM_VADDR           0xffd00000
 #define PROM_FILENAME        "openbios-sparc32"
 #define CFG_ADDR             0xd00000510ULL
@@ -741,9 +741,8 @@ static void ram_init(hwaddr addr, ram_addr_t RAM_size,
 
     /* allocate RAM */
     if ((uint64_t)RAM_size > max_mem) {
-        error_report("Too much memory for this machine: %d, maximum %d",
-                     (unsigned int)(RAM_size / (1024 * 1024)),
-                     (unsigned int)(max_mem / (1024 * 1024)));
+        error_report("Too much memory for this machine: %llu, maximum %llu",
+                     RAM_size / MiB, max_mem / MiB);
         exit(1);
     }
     dev = qdev_create(NULL, "memory");
diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c
index 22c4655fde..4fa8cb2904 100644
--- a/hw/sparc64/niagara.c
+++ b/hw/sparc64/niagara.c
@@ -23,6 +23,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu-common.h"
 #include "cpu.h"
 #include "hw/hw.h"
@@ -84,7 +85,7 @@ typedef struct NiagaraBoardState {
 #define NIAGARA_PROM_BASE   0xfff0000000ULL
 #define NIAGARA_Q_OFFSET    0x10000ULL
 #define NIAGARA_OBP_OFFSET  0x80000ULL
-#define PROM_SIZE_MAX       (4 * 1024 * 1024)
+#define PROM_SIZE_MAX       (4 * MiB)
 
 static void add_rom_or_fail(const char *file, const hwaddr addr)
 {
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 1bede85370..fd07b36226 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
@@ -52,11 +53,10 @@
 #include "hw/loader.h"
 #include "elf.h"
 #include "trace.h"
-#include "qemu/cutils.h"
 
 #define KERNEL_LOAD_ADDR     0x00404000
 #define CMDLINE_ADDR         0x003ff000
-#define PROM_SIZE_MAX        (4 * 1024 * 1024)
+#define PROM_SIZE_MAX        (4 * MiB)
 #define PROM_VADDR           0x000ffd00000ULL
 #define PBM_SPECIAL_BASE     0x1fe00000000ULL
 #define PBM_MEM_BASE         0x1ff00000000ULL
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 19/40] hw/s390x: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (17 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 18/40] hw/sparc: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 20/40] hw/hppa: " Philippe Mathieu-Daudé
                   ` (22 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Richard Henderson, Alexander Graf,
	David Hildenbrand, Cornelia Huck, Christian Borntraeger,
	open list:S390

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Acked-by: Cornelia Huck <cohuck@redhat.com>
---
 hw/s390x/s390-skeys.c    | 3 ++-
 hw/s390x/s390-stattrib.c | 3 ++-
 hw/s390x/sclp.c          | 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c
index 76241c240e..15f7ab0e53 100644
--- a/hw/s390x/s390-skeys.c
+++ b/hw/s390x/s390-skeys.c
@@ -10,6 +10,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/boards.h"
 #include "hw/s390x/storage-keys.h"
 #include "qapi/error.h"
@@ -19,7 +20,7 @@
 #include "sysemu/kvm.h"
 #include "migration/register.h"
 
-#define S390_SKEYS_BUFFER_SIZE 131072  /* Room for 128k storage keys */
+#define S390_SKEYS_BUFFER_SIZE (128 * KiB)  /* Room for 128k storage keys */
 #define S390_SKEYS_SAVE_FLAG_EOS 0x01
 #define S390_SKEYS_SAVE_FLAG_SKEYS 0x02
 #define S390_SKEYS_SAVE_FLAG_ERROR 0x04
diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c
index 70b95550a8..5161a1659b 100644
--- a/hw/s390x/s390-stattrib.c
+++ b/hw/s390x/s390-stattrib.c
@@ -10,6 +10,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/boards.h"
 #include "cpu.h"
 #include "migration/qemu-file.h"
@@ -20,7 +21,7 @@
 #include "qapi/error.h"
 #include "qapi/qmp/qdict.h"
 
-#define CMMA_BLOCK_SIZE  (1 << 10)
+#define CMMA_BLOCK_SIZE  (1 * KiB)
 
 #define STATTR_FLAG_EOS     0x01ULL
 #define STATTR_FLAG_MORE    0x02ULL
diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index 047d577313..04b51fbd15 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -13,6 +13,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "cpu.h"
 #include "sysemu/sysemu.h"
@@ -288,8 +289,7 @@ static void sclp_realize(DeviceState *dev, Error **errp)
 
     ret = s390_set_memory_limit(machine->maxram_size, &hw_limit);
     if (ret == -E2BIG) {
-        error_setg(&err, "host supports a maximum of %" PRIu64 " GB",
-                   hw_limit >> 30);
+        error_setg(&err, "host supports a maximum of %llu GB", hw_limit / GiB);
     } else if (ret) {
         error_setg(&err, "setting the guest size failed");
     }
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 20/40] hw/hppa: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (18 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 19/40] hw/s390x: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 21/40] hw/xtensa: " Philippe Mathieu-Daudé
                   ` (21 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-trivial, Richard Henderson

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/hppa/dino.c    |  3 ++-
 hw/hppa/machine.c | 10 +++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index 26f2704cd5..564b938e3a 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -11,6 +11,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "cpu.h"
 #include "hw/hw.h"
@@ -76,7 +77,7 @@
 /* #define xxx    0x200 - bit 9 not used */
 #define RS232INT  0x400
 
-#define DINO_MEM_CHUNK_SIZE (8 * 1024 * 1024) /* 8MB */
+#define DINO_MEM_CHUNK_SIZE (8 * MiB)
 
 #define DINO_PCI_HOST_BRIDGE(obj) \
     OBJECT_CHECK(DinoState, (obj), TYPE_DINO_PCI_HOST_BRIDGE)
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 2ba26962f9..77513223b0 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -17,7 +17,7 @@
 #include "hw/timer/i8254.h"
 #include "hw/char/serial.h"
 #include "hppa_sys.h"
-#include "qemu/cutils.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu/log.h"
 
@@ -178,8 +178,8 @@ static void machine_hppa_init(MachineState *machine)
         }
         qemu_log_mask(CPU_LOG_PAGE, "Kernel loaded at 0x%08" PRIx64
                       "-0x%08" PRIx64 ", entry at 0x%08" PRIx64
-                      ", size %ld kB.\n",
-                      kernel_low, kernel_high, kernel_entry, size / 1024);
+                      ", size %llu kB\n",
+                      kernel_low, kernel_high, kernel_entry, size / KiB);
 
         if (kernel_cmdline) {
             cpu[0]->env.gr[24] = 0x4000;
@@ -203,8 +203,8 @@ static void machine_hppa_init(MachineState *machine)
                (1) Due to sign-extension problems and PDC,
                put the initrd no higher than 1G.
                (2) Reserve 64k for stack.  */
-            initrd_base = MIN(ram_size, 1024 * 1024 * 1024);
-            initrd_base = initrd_base - 64 * 1024;
+            initrd_base = MIN(ram_size, 1 * GiB);
+            initrd_base = initrd_base - 64 * KiB;
             initrd_base = (initrd_base - initrd_size) & TARGET_PAGE_MASK;
 
             if (initrd_base < kernel_high) {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 21/40] hw/xtensa: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (19 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 20/40] hw/hppa: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 22/40] hw/alpha: " Philippe Mathieu-Daudé
                   ` (20 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-trivial, Max Filippov

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
---
 hw/xtensa/xtfpga.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c
index 5dc13034f9..918cdadbb4 100644
--- a/hw/xtensa/xtfpga.c
+++ b/hw/xtensa/xtfpga.c
@@ -26,6 +26,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "cpu.h"
 #include "sysemu/sysemu.h"
@@ -152,7 +153,7 @@ static void xtfpga_net_init(MemoryRegion *address_space,
             sysbus_mmio_get_region(s, 1));
 
     ram = g_malloc(sizeof(*ram));
-    memory_region_init_ram_nomigrate(ram, OBJECT(s), "open_eth.ram", 16384,
+    memory_region_init_ram_nomigrate(ram, OBJECT(s), "open_eth.ram", 16 * KiB,
                            &error_fatal);
     vmstate_register_ram_global(ram);
     memory_region_add_subregion(address_space, buffers, ram);
@@ -229,7 +230,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)
     const char *kernel_cmdline = qemu_opt_get(machine_opts, "append");
     const char *dtb_filename = qemu_opt_get(machine_opts, "dtb");
     const char *initrd_filename = qemu_opt_get(machine_opts, "initrd");
-    const unsigned system_io_size = 224 * 1024 * 1024;
+    const unsigned system_io_size = 224 * MiB;
     int n;
 
     for (n = 0; n < smp_cpus; n++) {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 22/40] hw/alpha: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (20 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 21/40] hw/xtensa: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 23/40] hw/tricore: " Philippe Mathieu-Daudé
                   ` (19 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-trivial, Richard Henderson

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/alpha/typhoon.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/hw/alpha/typhoon.c b/hw/alpha/typhoon.c
index 6a40869488..f42b706a08 100644
--- a/hw/alpha/typhoon.c
+++ b/hw/alpha/typhoon.c
@@ -7,6 +7,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "cpu.h"
 #include "hw/hw.h"
@@ -812,8 +813,6 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
                      qemu_irq *p_rtc_irq,
                      AlphaCPU *cpus[4], pci_map_irq_fn sys_map_irq)
 {
-    const uint64_t MB = 1024 * 1024;
-    const uint64_t GB = 1024 * MB;
     MemoryRegion *addr_space = get_system_memory();
     DeviceState *dev;
     TyphoonState *s;
@@ -854,30 +853,30 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
 
     /* Pchip0 CSRs, 0x801.8000.0000, 256MB.  */
     memory_region_init_io(&s->pchip.region, OBJECT(s), &pchip_ops, s, "pchip0",
-                          256*MB);
+                          256 * MiB);
     memory_region_add_subregion(addr_space, 0x80180000000ULL,
                                 &s->pchip.region);
 
     /* Cchip CSRs, 0x801.A000.0000, 256MB.  */
     memory_region_init_io(&s->cchip.region, OBJECT(s), &cchip_ops, s, "cchip0",
-                          256*MB);
+                          256 * MiB);
     memory_region_add_subregion(addr_space, 0x801a0000000ULL,
                                 &s->cchip.region);
 
     /* Dchip CSRs, 0x801.B000.0000, 256MB.  */
     memory_region_init_io(&s->dchip_region, OBJECT(s), &dchip_ops, s, "dchip0",
-                          256*MB);
+                          256 * MiB);
     memory_region_add_subregion(addr_space, 0x801b0000000ULL,
                                 &s->dchip_region);
 
     /* Pchip0 PCI memory, 0x800.0000.0000, 4GB.  */
-    memory_region_init(&s->pchip.reg_mem, OBJECT(s), "pci0-mem", 4*GB);
+    memory_region_init(&s->pchip.reg_mem, OBJECT(s), "pci0-mem", 4 * GiB);
     memory_region_add_subregion(addr_space, 0x80000000000ULL,
                                 &s->pchip.reg_mem);
 
     /* Pchip0 PCI I/O, 0x801.FC00.0000, 32MB.  */
     memory_region_init_io(&s->pchip.reg_io, OBJECT(s), &alpha_pci_ignore_ops,
-                          NULL, "pci0-io", 32*MB);
+                          NULL, "pci0-io", 32 * MiB);
     memory_region_add_subregion(addr_space, 0x801fc000000ULL,
                                 &s->pchip.reg_io);
 
@@ -898,13 +897,13 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
 
     /* Pchip0 PCI special/interrupt acknowledge, 0x801.F800.0000, 64MB.  */
     memory_region_init_io(&s->pchip.reg_iack, OBJECT(s), &alpha_pci_iack_ops,
-                          b, "pci0-iack", 64*MB);
+                          b, "pci0-iack", 64 * MiB);
     memory_region_add_subregion(addr_space, 0x801f8000000ULL,
                                 &s->pchip.reg_iack);
 
     /* Pchip0 PCI configuration, 0x801.FE00.0000, 16MB.  */
     memory_region_init_io(&s->pchip.reg_conf, OBJECT(s), &alpha_pci_conf1_ops,
-                          b, "pci0-conf", 16*MB);
+                          b, "pci0-conf", 16 * MiB);
     memory_region_add_subregion(addr_space, 0x801fe000000ULL,
                                 &s->pchip.reg_conf);
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 23/40] hw/tricore: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (21 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 22/40] hw/alpha: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 24/40] hw/microblaze: " Philippe Mathieu-Daudé
                   ` (18 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Bastian Koppelmann

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Acked-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
---
 hw/tricore/tricore_testboard.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/hw/tricore/tricore_testboard.c b/hw/tricore/tricore_testboard.c
index 8e61dfc3e6..a58096f05e 100644
--- a/hw/tricore/tricore_testboard.c
+++ b/hw/tricore/tricore_testboard.c
@@ -19,6 +19,7 @@
 
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "cpu.h"
@@ -72,17 +73,17 @@ static void tricore_testboard_init(MachineState *machine, int board_id)
     cpu = TRICORE_CPU(cpu_create(machine->cpu_type));
     env = &cpu->env;
     memory_region_init_ram(ext_cram, NULL, "powerlink_ext_c.ram",
-                           2 * 1024 * 1024, &error_fatal);
+                           2 * MiB, &error_fatal);
     memory_region_init_ram(ext_dram, NULL, "powerlink_ext_d.ram",
-                           4 * 1024 * 1024, &error_fatal);
-    memory_region_init_ram(int_cram, NULL, "powerlink_int_c.ram", 48 * 1024,
+                           4 * MiB, &error_fatal);
+    memory_region_init_ram(int_cram, NULL, "powerlink_int_c.ram", 48 * KiB,
                            &error_fatal);
-    memory_region_init_ram(int_dram, NULL, "powerlink_int_d.ram", 48 * 1024,
+    memory_region_init_ram(int_dram, NULL, "powerlink_int_d.ram", 48 * KiB,
                            &error_fatal);
     memory_region_init_ram(pcp_data, NULL, "powerlink_pcp_data.ram",
-                           16 * 1024, &error_fatal);
+                           16 * KiB, &error_fatal);
     memory_region_init_ram(pcp_text, NULL, "powerlink_pcp_text.ram",
-                           32 * 1024, &error_fatal);
+                           32 * KiB, &error_fatal);
 
     memory_region_add_subregion(sysmem, 0x80000000, ext_cram);
     memory_region_add_subregion(sysmem, 0xa1000000, ext_dram);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 24/40] hw/microblaze: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (22 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 23/40] hw/tricore: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 25/40] hw/nios2: " Philippe Mathieu-Daudé
                   ` (17 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-trivial, Edgar E. Iglesias

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/microblaze/petalogix_ml605_mmu.c      | 7 ++++---
 hw/microblaze/petalogix_s3adsp1800_mmu.c | 7 ++++---
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c
index 6c4a544eac..c730878d25 100644
--- a/hw/microblaze/petalogix_ml605_mmu.c
+++ b/hw/microblaze/petalogix_ml605_mmu.c
@@ -26,6 +26,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "cpu.h"
@@ -44,8 +45,8 @@
 
 #include "hw/stream.h"
 
-#define LMB_BRAM_SIZE  (128 * 1024)
-#define FLASH_SIZE     (32 * 1024 * 1024)
+#define LMB_BRAM_SIZE  (128 * KiB)
+#define FLASH_SIZE     (32 * MiB)
 
 #define BINARY_DEVICE_TREE_FILE "petalogix-ml605.dtb"
 
@@ -109,7 +110,7 @@ petalogix_ml605_init(MachineState *machine)
     pflash_cfi01_register(FLASH_BASEADDR,
                           NULL, "petalogix_ml605.flash", FLASH_SIZE,
                           dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                          (64 * 1024), FLASH_SIZE >> 16,
+                          64 * KiB, FLASH_SIZE >> 16,
                           2, 0x89, 0x18, 0x0000, 0x0, 0);
 
 
diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c
index 0da3e62102..5cf7b84c79 100644
--- a/hw/microblaze/petalogix_s3adsp1800_mmu.c
+++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c
@@ -24,6 +24,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "cpu.h"
@@ -39,8 +40,8 @@
 
 #include "boot.h"
 
-#define LMB_BRAM_SIZE  (128 * 1024)
-#define FLASH_SIZE     (16 * 1024 * 1024)
+#define LMB_BRAM_SIZE  (128 * KiB)
+#define FLASH_SIZE     (16 * MiB)
 
 #define BINARY_DEVICE_TREE_FILE "petalogix-s3adsp1800.dtb"
 
@@ -87,7 +88,7 @@ petalogix_s3adsp1800_init(MachineState *machine)
     pflash_cfi01_register(FLASH_BASEADDR,
                           NULL, "petalogix_s3adsp1800.flash", FLASH_SIZE,
                           dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                          (64 * 1024), FLASH_SIZE >> 16,
+                          64 * KiB, FLASH_SIZE >> 16,
                           1, 0x89, 0x18, 0x0000, 0x0, 1);
 
     dev = qdev_create(NULL, "xlnx.xps-intc");
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 25/40] hw/nios2: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (23 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 24/40] hw/microblaze: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 26/40] hw/cris: " Philippe Mathieu-Daudé
                   ` (16 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Chris Wulff, Marek Vasut

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/nios2/boot.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/nios2/boot.c b/hw/nios2/boot.c
index 94f436e7fb..4bb5b601d3 100644
--- a/hw/nios2/boot.c
+++ b/hw/nios2/boot.c
@@ -29,6 +29,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu-common.h"
 #include "cpu.h"
 #include "qemu/option.h"
@@ -38,7 +39,6 @@
 #include "sysemu/sysemu.h"
 #include "hw/loader.h"
 #include "elf.h"
-#include "qemu/cutils.h"
 
 #include "boot.h"
 
@@ -177,7 +177,7 @@ void nios2_load_kernel(Nios2CPU *cpu, hwaddr ddr_base,
             high = ddr_base + kernel_size;
         }
 
-        high = ROUND_UP(high, 1024 * 1024);
+        high = ROUND_UP(high, 1 * MiB);
 
         /* If initrd is available, it goes after the kernel, aligned to 1M. */
         if (initrd_filename) {
@@ -213,7 +213,7 @@ void nios2_load_kernel(Nios2CPU *cpu, hwaddr ddr_base,
         high += fdt_size;
 
         /* Kernel command is at the end, 4k aligned. */
-        boot_info.cmdline = ROUND_UP(high, 4096);
+        boot_info.cmdline = ROUND_UP(high, 4 * KiB);
         if (kernel_cmdline && strlen(kernel_cmdline)) {
             pstrcpy_targphys("cmdline", boot_info.cmdline, 256, kernel_cmdline);
         }
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 26/40] hw/cris: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (24 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 25/40] hw/nios2: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 27/40] hw/lm32: " Philippe Mathieu-Daudé
                   ` (15 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-trivial, Edgar E. Iglesias

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/cris/axis_dev88.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/cris/axis_dev88.c b/hw/cris/axis_dev88.c
index 56ee398ee5..191292eebf 100644
--- a/hw/cris/axis_dev88.c
+++ b/hw/cris/axis_dev88.c
@@ -23,6 +23,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "cpu.h"
@@ -242,7 +243,7 @@ static const MemoryRegionOps gpio_ops = {
     },
 };
 
-#define INTMEM_SIZE (128 * 1024)
+#define INTMEM_SIZE (128 * KiB)
 
 static struct cris_load_info li;
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 27/40] hw/lm32: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (25 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 26/40] hw/cris: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 28/40] hw/sh4: " Philippe Mathieu-Daudé
                   ` (14 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-trivial, Michael Walle

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Acked-by: Michael Walle <michael@walle.cc>
---
 hw/lm32/lm32_boards.c | 13 +++++++------
 hw/lm32/milkymist.c   | 10 +++++-----
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/hw/lm32/lm32_boards.c b/hw/lm32/lm32_boards.c
index 167058348e..fd8eccca14 100644
--- a/hw/lm32/lm32_boards.c
+++ b/hw/lm32/lm32_boards.c
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/error-report.h"
 #include "qemu-common.h"
 #include "cpu.h"
@@ -87,10 +88,10 @@ static void lm32_evr_init(MachineState *machine)
 
     /* memory map */
     hwaddr flash_base  = 0x04000000;
-    size_t flash_sector_size       = 256 * 1024;
-    size_t flash_size              = 32 * 1024 * 1024;
+    size_t flash_sector_size       = 256 * KiB;
+    size_t flash_size              = 32 * MiB;
     hwaddr ram_base    = 0x08000000;
-    size_t ram_size                = 64 * 1024 * 1024;
+    size_t ram_size                = 64 * MiB;
     hwaddr timer0_base = 0x80002000;
     hwaddr uart0_base  = 0x80006000;
     hwaddr timer1_base = 0x8000a000;
@@ -173,10 +174,10 @@ static void lm32_uclinux_init(MachineState *machine)
 
     /* memory map */
     hwaddr flash_base   = 0x04000000;
-    size_t flash_sector_size        = 256 * 1024;
-    size_t flash_size               = 32 * 1024 * 1024;
+    size_t flash_sector_size        = 256 * KiB;
+    size_t flash_size               = 32 * MiB;
     hwaddr ram_base     = 0x08000000;
-    size_t ram_size                 = 64 * 1024 * 1024;
+    size_t ram_size                 = 64 * MiB;
     hwaddr uart0_base   = 0x80000000;
     hwaddr timer0_base  = 0x80002000;
     hwaddr timer1_base  = 0x80010000;
diff --git a/hw/lm32/milkymist.c b/hw/lm32/milkymist.c
index c36bbc4ae2..321f184595 100644
--- a/hw/lm32/milkymist.c
+++ b/hw/lm32/milkymist.c
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/error-report.h"
 #include "qemu-common.h"
 #include "cpu.h"
@@ -33,11 +34,10 @@
 #include "milkymist-hw.h"
 #include "lm32.h"
 #include "exec/address-spaces.h"
-#include "qemu/cutils.h"
 
 #define BIOS_FILENAME    "mmone-bios.bin"
 #define BIOS_OFFSET      0x00860000
-#define BIOS_SIZE        (512*1024)
+#define BIOS_SIZE        (512 * KiB)
 #define KERNEL_LOAD_ADDR 0x40000000
 
 typedef struct {
@@ -96,10 +96,10 @@ milkymist_init(MachineState *machine)
 
     /* memory map */
     hwaddr flash_base   = 0x00000000;
-    size_t flash_sector_size        = 128 * 1024;
-    size_t flash_size               = 32 * 1024 * 1024;
+    size_t flash_sector_size        = 128 * KiB;
+    size_t flash_size               = 32 * MiB;
     hwaddr sdram_base   = 0x40000000;
-    size_t sdram_size               = 128 * 1024 * 1024;
+    size_t sdram_size               = 128 * MiB;
 
     hwaddr initrd_base  = sdram_base + 0x1002000;
     hwaddr cmdline_base = sdram_base + 0x1000000;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 28/40] hw/sh4: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (26 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 27/40] hw/lm32: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 29/40] hw/mips/r4k: Constify params_size Philippe Mathieu-Daudé
                   ` (13 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Magnus Damm, Aurelien Jarno

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/sh4/r2d.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index 8fe8766eb9..6a5fc46a47 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -24,6 +24,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "cpu.h"
@@ -291,7 +292,7 @@ static void r2d_init(MachineState *machine)
     dinfo = drive_get(IF_PFLASH, 0, 0);
     pflash_cfi02_register(0x0, NULL, "r2d.flash", FLASH_SIZE,
                           dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                          (16 * 1024), FLASH_SIZE >> 16,
+                          16 * KiB, FLASH_SIZE >> 16,
                           1, 4, 0x0000, 0x0000, 0x0000, 0x0000,
                           0x555, 0x2aa, 0);
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 29/40] hw/mips/r4k: Constify params_size
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (27 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 28/40] hw/sh4: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 30/40] hw/mips: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (12 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Aurelien Jarno, Yongbok Kim

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/mips/mips_r4k.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
index e5cf8ed1a3..fc38b4bf99 100644
--- a/hw/mips/mips_r4k.c
+++ b/hw/mips/mips_r4k.c
@@ -79,8 +79,9 @@ typedef struct ResetData {
 
 static int64_t load_kernel(void)
 {
+    const size_t params_size = 264;
     int64_t entry, kernel_high;
-    long kernel_size, initrd_size, params_size;
+    long kernel_size, initrd_size;
     ram_addr_t initrd_offset;
     uint32_t *params_buf;
     int big_endian;
@@ -128,7 +129,6 @@ static int64_t load_kernel(void)
     }
 
     /* Store command line.  */
-    params_size = 264;
     params_buf = g_malloc(params_size);
 
     params_buf[0] = tswap32(ram_size);
@@ -143,7 +143,7 @@ static int64_t load_kernel(void)
     }
 
     rom_add_blob_fixed("params", params_buf, params_size,
-                       (16 << 20) - 264);
+                       (16 << 20) - params_size);
 
     g_free(params_buf);
     return entry;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 30/40] hw/mips: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (28 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 29/40] hw/mips/r4k: Constify params_size Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 32/40] hw/ppc: " Philippe Mathieu-Daudé
                   ` (11 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Yongbok Kim, Aurelien Jarno,
	Paul Burton

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
---
 include/hw/intc/mips_gic.h |  3 ++-
 include/hw/mips/bios.h     |  3 ++-
 hw/mips/mips_fulong2e.c    |  7 ++++---
 hw/mips/mips_malta.c       | 23 +++++++++++++----------
 hw/mips/mips_r4k.c         | 11 ++++++-----
 hw/misc/mips_itu.c         |  3 ++-
 hw/pci-host/xilinx-pcie.c  |  5 +++--
 7 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/include/hw/intc/mips_gic.h b/include/hw/intc/mips_gic.h
index b98d50094a..902a12b178 100644
--- a/include/hw/intc/mips_gic.h
+++ b/include/hw/intc/mips_gic.h
@@ -11,6 +11,7 @@
 #ifndef MIPS_GIC_H
 #define MIPS_GIC_H
 
+#include "qemu/units.h"
 #include "hw/timer/mips_gictimer.h"
 #include "cpu.h"
 /*
@@ -19,7 +20,7 @@
 
 /* The MIPS default location */
 #define GIC_BASE_ADDR           0x1bdc0000ULL
-#define GIC_ADDRSPACE_SZ        (128 * 1024)
+#define GIC_ADDRSPACE_SZ        (128 * KiB)
 
 /* Constants */
 #define GIC_POL_POS     1
diff --git a/include/hw/mips/bios.h b/include/hw/mips/bios.h
index b4b88ac43d..d67ef33e83 100644
--- a/include/hw/mips/bios.h
+++ b/include/hw/mips/bios.h
@@ -1,6 +1,7 @@
+#include "qemu/units.h"
 #include "cpu.h"
 
-#define BIOS_SIZE (4 * 1024 * 1024)
+#define BIOS_SIZE (4 * MiB)
 #ifdef TARGET_WORDS_BIGENDIAN
 #define BIOS_FILENAME "mips_bios.bin"
 #else
diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c
index 02fb2fdcc4..d22f50e97b 100644
--- a/hw/mips/mips_fulong2e.c
+++ b/hw/mips/mips_fulong2e.c
@@ -19,6 +19,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
 #include "hw/i386/pc.h"
@@ -159,7 +160,7 @@ static int64_t load_kernel (CPUMIPSState *env)
     /* Setup minimum environment variables */
     prom_set(prom_buf, index++, "busclock=33000000");
     prom_set(prom_buf, index++, "cpuclock=100000000");
-    prom_set(prom_buf, index++, "memsize=%i", loaderparams.ram_size/1024/1024);
+    prom_set(prom_buf, index++, "memsize=%llu", loaderparams.ram_size / MiB);
     prom_set(prom_buf, index++, "modetty0=38400n8r");
     prom_set(prom_buf, index++, NULL);
 
@@ -303,10 +304,10 @@ static void mips_fulong2e_init(MachineState *machine)
     qemu_register_reset(main_cpu_reset, cpu);
 
     /* fulong 2e has 256M ram. */
-    ram_size = 256 * 1024 * 1024;
+    ram_size = 256 * MiB;
 
     /* fulong 2e has a 1M flash.Winbond W39L040AP70Z */
-    bios_size = 1024 * 1024;
+    bios_size = 1 * MiB;
 
     /* allocate RAM */
     memory_region_allocate_system_memory(ram, NULL, "fulong2e.ram", ram_size);
diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index 494f84e290..c8ae477d75 100644
--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -23,6 +23,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu-common.h"
 #include "cpu.h"
 #include "hw/hw.h"
@@ -843,7 +844,8 @@ static int64_t load_kernel (void)
             /* The kernel allocates the bootmap memory in the low memory after
                the initrd.  It takes at most 128kiB for 2GB RAM and 4kiB
                pages.  */
-            initrd_offset = (loaderparams.ram_low_size - initrd_size - 131072
+            initrd_offset = (loaderparams.ram_low_size - initrd_size
+                             - (128 * KiB)
                              - ~INITRD_PAGE_MASK) & INITRD_PAGE_MASK;
             if (kernel_high >= initrd_offset) {
                 error_report("memory too small for initial ram disk '%s'",
@@ -1021,9 +1023,9 @@ void mips_malta_init(MachineState *machine)
     mips_create_cpu(s, machine->cpu_type, &cbus_irq, &i8259_irq);
 
     /* allocate RAM */
-    if (ram_size > (2048u << 20)) {
-        error_report("Too much memory for this machine: %dMB, maximum 2048MB",
-                     ((unsigned int)ram_size / (1 << 20)));
+    if (ram_size > 2 * GiB) {
+        error_report("Too much memory for this machine: %lluMB, maximum 2048MB",
+                     ram_size / MiB);
         exit(1);
     }
 
@@ -1034,17 +1036,18 @@ void mips_malta_init(MachineState *machine)
 
     /* alias for pre IO hole access */
     memory_region_init_alias(ram_low_preio, NULL, "mips_malta_low_preio.ram",
-                             ram_high, 0, MIN(ram_size, (256 << 20)));
+                             ram_high, 0, MIN(ram_size, 256 * MiB));
     memory_region_add_subregion(system_memory, 0, ram_low_preio);
 
     /* alias for post IO hole access, if there is enough RAM */
-    if (ram_size > (512 << 20)) {
+    if (ram_size > 512 * MiB) {
         ram_low_postio = g_new(MemoryRegion, 1);
         memory_region_init_alias(ram_low_postio, NULL,
                                  "mips_malta_low_postio.ram",
-                                 ram_high, 512 << 20,
-                                 ram_size - (512 << 20));
-        memory_region_add_subregion(system_memory, 512 << 20, ram_low_postio);
+                                 ram_high, 512 * MiB,
+                                 ram_size - 512 * MiB);
+        memory_region_add_subregion(system_memory, 512 * MiB,
+                                    ram_low_postio);
     }
 
 #ifdef TARGET_WORDS_BIGENDIAN
@@ -1076,7 +1079,7 @@ void mips_malta_init(MachineState *machine)
     bios = pflash_cfi01_get_memory(fl);
     fl_idx++;
     if (kernel_filename) {
-        ram_low_size = MIN(ram_size, 256 << 20);
+        ram_low_size = MIN(ram_size, 256 * MiB);
         /* For KVM we reserve 1MB of RAM for running bootloader */
         if (kvm_enabled()) {
             ram_low_size -= 0x100000;
diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
index fc38b4bf99..2be7ed5dc5 100644
--- a/hw/mips/mips_r4k.c
+++ b/hw/mips/mips_r4k.c
@@ -8,6 +8,7 @@
  * the standard PC ISA addresses.
 */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "cpu.h"
@@ -143,7 +144,7 @@ static int64_t load_kernel(void)
     }
 
     rom_add_blob_fixed("params", params_buf, params_size,
-                       (16 << 20) - params_size);
+                       16 * MiB - params_size);
 
     g_free(params_buf);
     return entry;
@@ -158,7 +159,7 @@ static void main_cpu_reset(void *opaque)
     env->active_tc.PC = s->vector;
 }
 
-static const int sector_len = 32 * 1024;
+static const int sector_len = 32 * KiB;
 static
 void mips_r4k_init(MachineState *machine)
 {
@@ -194,9 +195,9 @@ void mips_r4k_init(MachineState *machine)
     qemu_register_reset(main_cpu_reset, reset_info);
 
     /* allocate RAM */
-    if (ram_size > (256 << 20)) {
-        error_report("Too much memory for this machine: %dMB, maximum 256MB",
-                     ((unsigned int)ram_size / (1 << 20)));
+    if (ram_size > 256 * MiB) {
+        error_report("Too much memory for this machine: %lluMB, maximum 256MB",
+                     ram_size / MiB);
         exit(1);
     }
     memory_region_allocate_system_memory(ram, NULL, "mips_r4k.ram", ram_size);
diff --git a/hw/misc/mips_itu.c b/hw/misc/mips_itu.c
index ccc4c7d98a..43bbec46cf 100644
--- a/hw/misc/mips_itu.c
+++ b/hw/misc/mips_itu.c
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/log.h"
 #include "qapi/error.h"
 #include "cpu.h"
@@ -80,7 +81,7 @@ static void itc_reconfigure(MIPSITUState *tag)
     uint64_t *am = &tag->ITCAddressMap[0];
     MemoryRegion *mr = &tag->storage_io;
     hwaddr address = am[0] & ITC_AM0_BASE_ADDRESS_MASK;
-    uint64_t size = (1 << 10) + (am[1] & ITC_AM1_ADDR_MASK_MASK);
+    uint64_t size = (1 * KiB) + (am[1] & ITC_AM1_ADDR_MASK_MASK);
     bool is_enabled = (am[0] & ITC_AM0_EN_MASK) != 0;
 
     memory_region_transaction_begin();
diff --git a/hw/pci-host/xilinx-pcie.c b/hw/pci-host/xilinx-pcie.c
index 044e312dc1..ff0cf38156 100644
--- a/hw/pci-host/xilinx-pcie.c
+++ b/hw/pci-host/xilinx-pcie.c
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "hw/pci/pci_bridge.h"
 #include "hw/pci-host/xilinx-pcie.h"
@@ -158,9 +159,9 @@ static void xilinx_pcie_host_init(Object *obj)
 static Property xilinx_pcie_host_props[] = {
     DEFINE_PROP_UINT32("bus_nr", XilinxPCIEHost, bus_nr, 0),
     DEFINE_PROP_SIZE("cfg_base", XilinxPCIEHost, cfg_base, 0),
-    DEFINE_PROP_SIZE("cfg_size", XilinxPCIEHost, cfg_size, 32 << 20),
+    DEFINE_PROP_SIZE("cfg_size", XilinxPCIEHost, cfg_size, 32 * MiB),
     DEFINE_PROP_SIZE("mmio_base", XilinxPCIEHost, mmio_base, 0),
-    DEFINE_PROP_SIZE("mmio_size", XilinxPCIEHost, mmio_size, 1 << 20),
+    DEFINE_PROP_SIZE("mmio_size", XilinxPCIEHost, mmio_size, 1 * MiB),
     DEFINE_PROP_BOOL("link_up", XilinxPCIEHost, link_up, true),
     DEFINE_PROP_END_OF_LIST(),
 };
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 32/40] hw/ppc: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (29 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 30/40] hw/mips: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  8:09   ` [Qemu-devel] [Qemu-ppc] " BALATON Zoltan
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 34/40] hw/net: " Philippe Mathieu-Daudé
                   ` (10 subsequent siblings)
  41 siblings, 1 reply; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, David Gibson, Alexander Graf,
	Hervé Poussineau, Edgar E. Iglesias, open list:sPAPR

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/mac.h           |  3 ++-
 include/hw/ppc/spapr.h |  5 +++--
 hw/nvram/spapr_nvram.c | 10 ++++++----
 hw/pci-host/prep.c     |  3 ++-
 hw/ppc/e500.c          | 13 +++++++------
 hw/ppc/e500plat.c      |  3 ++-
 hw/ppc/mac_newworld.c  |  1 -
 hw/ppc/mac_oldworld.c  |  9 ++++-----
 hw/ppc/ppc405_boards.c |  9 +++++----
 hw/ppc/ppc405_uc.c     |  7 ++++---
 hw/ppc/ppc440_bamboo.c |  6 ++++--
 hw/ppc/ppc4xx_devs.c   | 22 ++++++++++++----------
 hw/ppc/ppce500_spin.c  |  3 ++-
 hw/ppc/prep.c          |  4 ++--
 hw/ppc/rs6000_mc.c     | 13 +++++++------
 hw/ppc/sam460ex.c      | 18 ++++++++++--------
 hw/ppc/spapr.c         |  2 +-
 hw/ppc/virtex_ml507.c  |  7 ++++---
 18 files changed, 77 insertions(+), 61 deletions(-)

diff --git a/hw/ppc/mac.h b/hw/ppc/mac.h
index 22a7efbed6..c0af576f8c 100644
--- a/hw/ppc/mac.h
+++ b/hw/ppc/mac.h
@@ -26,6 +26,7 @@
 #ifndef PPC_MAC_H
 #define PPC_MAC_H
 
+#include "qemu/units.h"
 #include "exec/memory.h"
 #include "hw/sysbus.h"
 #include "hw/ide/internal.h"
@@ -37,7 +38,7 @@
 /* SMP is not enabled, for now */
 #define MAX_CPUS 1
 
-#define BIOS_SIZE     (1024 * 1024)
+#define BIOS_SIZE        (1 * MiB)
 #define NVRAM_SIZE        0x2000
 #define PROM_FILENAME    "openbios-ppc"
 #define PROM_ADDR         0xfff00000
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 3388750fc7..210cbdd2ca 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -1,6 +1,7 @@
 #ifndef HW_SPAPR_H
 #define HW_SPAPR_H
 
+#include "qemu/units.h"
 #include "sysemu/dma.h"
 #include "hw/boards.h"
 #include "hw/ppc/xics.h"
@@ -747,8 +748,8 @@ int spapr_rng_populate_dt(void *fdt);
  */
 #define SPAPR_MAX_RAM_SLOTS     32
 
-/* 1GB alignment for device memory region */
-#define SPAPR_DEVICE_MEM_ALIGN (1ULL << 30)
+/* 1GB alignment for hotplug memory region */
+#define SPAPR_DEVICE_MEM_ALIGN (1 * GiB)
 
 /*
  * Number of 32 bit words in each LMB list entry in ibm,dynamic-memory
diff --git a/hw/nvram/spapr_nvram.c b/hw/nvram/spapr_nvram.c
index 4a0aec8e1d..3c88f42acf 100644
--- a/hw/nvram/spapr_nvram.c
+++ b/hw/nvram/spapr_nvram.c
@@ -23,6 +23,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "cpu.h"
@@ -47,9 +48,9 @@ typedef struct sPAPRNVRAM {
 #define VIO_SPAPR_NVRAM(obj) \
      OBJECT_CHECK(sPAPRNVRAM, (obj), TYPE_VIO_SPAPR_NVRAM)
 
-#define MIN_NVRAM_SIZE 8192
-#define DEFAULT_NVRAM_SIZE 65536
-#define MAX_NVRAM_SIZE 1048576
+#define MIN_NVRAM_SIZE      (8 * KiB)
+#define DEFAULT_NVRAM_SIZE  (64 * KiB)
+#define MAX_NVRAM_SIZE      (1 * MiB)
 
 static void rtas_nvram_fetch(PowerPCCPU *cpu, sPAPRMachineState *spapr,
                              uint32_t token, uint32_t nargs,
@@ -167,7 +168,8 @@ static void spapr_nvram_realize(VIOsPAPRDevice *dev, Error **errp)
     nvram->buf = g_malloc0(nvram->size);
 
     if ((nvram->size < MIN_NVRAM_SIZE) || (nvram->size > MAX_NVRAM_SIZE)) {
-        error_setg(errp, "spapr-nvram must be between %d and %d bytes in size",
+        error_setg(errp,
+                   "spapr-nvram must be between %llu and %llu bytes in size",
                    MIN_NVRAM_SIZE, MAX_NVRAM_SIZE);
         return;
     }
diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c
index 01f67f9db1..88f035c20b 100644
--- a/hw/pci-host/prep.c
+++ b/hw/pci-host/prep.c
@@ -24,6 +24,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
 #include "hw/pci/pci.h"
@@ -70,7 +71,7 @@ typedef struct PRePPCIState {
     int contiguous_map;
 } PREPPCIState;
 
-#define BIOS_SIZE (1024 * 1024)
+#define BIOS_SIZE (1 * MiB)
 
 static inline uint32_t raven_pci_io_config(hwaddr addr)
 {
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 826053edc8..7d19b1498c 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -15,6 +15,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "e500.h"
 #include "e500-ccsr.h"
@@ -46,11 +47,11 @@
 #define BINARY_DEVICE_TREE_FILE    "mpc8544ds.dtb"
 #define DTC_LOAD_PAD               0x1800000
 #define DTC_PAD_MASK               0xFFFFF
-#define DTB_MAX_SIZE               (8 * 1024 * 1024)
+#define DTB_MAX_SIZE               (8 * MiB)
 #define INITRD_LOAD_PAD            0x2000000
 #define INITRD_PAD_MASK            0xFFFFFF
 
-#define RAM_SIZES_ALIGN            (64UL << 20)
+#define RAM_SIZES_ALIGN            (64 * MiB)
 
 /* TODO: parameterize */
 #define MPC8544_CCSRBAR_SIZE       0x00100000ULL
@@ -603,7 +604,7 @@ static int ppce500_prep_device_tree(PPCE500MachineState *machine,
 /* Create -kernel TLB entries for BookE.  */
 hwaddr booke206_page_size_to_tlb(uint64_t size)
 {
-    return 63 - clz64(size >> 10);
+    return 63 - clz64(size / KiB);
 }
 
 static int booke206_initial_map_tsize(CPUPPCState *env)
@@ -671,7 +672,7 @@ static void ppce500_cpu_reset(void *opaque)
 
     /* Set initial guest state. */
     cs->halted = 0;
-    env->gpr[1] = (16<<20) - 8;
+    env->gpr[1] = (16 * MiB) - 8;
     env->gpr[3] = bi->dt_base;
     env->gpr[4] = 0;
     env->gpr[5] = 0;
@@ -1012,9 +1013,9 @@ void ppce500_init(MachineState *machine)
     }
 
     cur_base = loadaddr + payload_size;
-    if (cur_base < (32 * 1024 * 1024)) {
+    if (cur_base < 32 * MiB) {
         /* u-boot occupies memory up to 32MB, so load blobs above */
-        cur_base = (32 * 1024 * 1024);
+        cur_base = 32 * MiB;
     }
 
     /* Load bare kernel only if no bios/u-boot has been provided */
diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c
index d8e3f2066e..963d429cc8 100644
--- a/hw/ppc/e500plat.c
+++ b/hw/ppc/e500plat.c
@@ -10,6 +10,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu-common.h"
 #include "e500.h"
 #include "hw/net/fsl_etsec/etsec.h"
@@ -85,7 +86,7 @@ static void e500plat_machine_class_init(ObjectClass *oc, void *data)
     pmc->has_mpc8xxx_gpio = true;
     pmc->has_platform_bus = true;
     pmc->platform_bus_base = 0xf00000000ULL;
-    pmc->platform_bus_size = (128ULL * 1024 * 1024);
+    pmc->platform_bus_size = 128 * MiB;
     pmc->platform_bus_first_irq = 5;
     pmc->platform_bus_num_irqs = 10;
     pmc->ccsrbar_base = 0xFE0000000ULL;
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index 744acdfd2e..bf51ad6fdd 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -71,7 +71,6 @@
 #include "hw/usb.h"
 #include "exec/address-spaces.h"
 #include "hw/sysbus.h"
-#include "qemu/cutils.h"
 #include "trace.h"
 
 #define MAX_IDE_BUS 2
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index 4608bab014..31f4cea111 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -24,6 +24,7 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
 #include "hw/ppc/ppc.h"
@@ -46,7 +47,6 @@
 #include "sysemu/kvm.h"
 #include "kvm_ppc.h"
 #include "exec/address-spaces.h"
-#include "qemu/cutils.h"
 
 #define MAX_IDE_BUS 2
 #define CFG_ADDR 0xf0000510
@@ -118,10 +118,9 @@ static void ppc_heathrow_init(MachineState *machine)
     }
 
     /* allocate RAM */
-    if (ram_size > (2047 << 20)) {
-        fprintf(stderr,
-                "qemu: Too much memory for this machine: %d MB, maximum 2047 MB\n",
-                ((unsigned int)ram_size / (1 << 20)));
+    if (ram_size > 2047 * MiB) {
+        error_report("Too much memory for this machine: %llu MB, "
+                     "maximum 2047 MB", ram_size / MiB);
         exit(1);
     }
 
diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c
index d301067d3b..70111075b3 100644
--- a/hw/ppc/ppc405_boards.c
+++ b/hw/ppc/ppc405_boards.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "cpu.h"
@@ -40,7 +41,7 @@
 #include "exec/address-spaces.h"
 
 #define BIOS_FILENAME "ppc405_rom.bin"
-#define BIOS_SIZE (2048 * 1024)
+#define BIOS_SIZE (2 * MiB)
 
 #define KERNEL_LOAD_ADDR 0x00000000
 #define INITRD_LOAD_ADDR 0x01800000
@@ -216,14 +217,14 @@ static void ref405ep_init(MachineState *machine)
     memory_region_init(&ram_memories[1], NULL, "ef405ep.ram1", 0);
     ram_bases[1] = 0x00000000;
     ram_sizes[1] = 0x00000000;
-    ram_size = 128 * 1024 * 1024;
+    ram_size = 128 * MiB;
 #ifdef DEBUG_BOARD_INIT
     printf("%s: register cpu\n", __func__);
 #endif
     env = ppc405ep_init(sysmem, ram_memories, ram_bases, ram_sizes,
                         33333333, &pic, kernel_filename == NULL ? 0 : 1);
     /* allocate SRAM */
-    sram_size = 512 * 1024;
+    sram_size = 512 * KiB;
     memory_region_init_ram(sram, NULL, "ef405ep.sram", sram_size,
                            &error_fatal);
     memory_region_add_subregion(sysmem, 0xFFF00000, sram);
@@ -589,7 +590,7 @@ static void taihu_405ep_init(MachineState *machine)
 
         bios_size = blk_getlength(blk);
         /* XXX: should check that size is 32MB */
-        bios_size = 32 * 1024 * 1024;
+        bios_size = 32 * MiB;
         fl_sectors = (bios_size + 65535) >> 16;
 #ifdef DEBUG_BOARD_INIT
         printf("Register parallel flash %d size %lx"
diff --git a/hw/ppc/ppc405_uc.c b/hw/ppc/ppc405_uc.c
index 34f8d57b07..4bd9fbcc1e 100644
--- a/hw/ppc/ppc405_uc.c
+++ b/hw/ppc/ppc405_uc.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "cpu.h"
@@ -983,10 +984,10 @@ static void ppc405_ocm_init(CPUPPCState *env)
 
     ocm = g_malloc0(sizeof(ppc405_ocm_t));
     /* XXX: Size is 4096 or 0x04000000 */
-    memory_region_init_ram(&ocm->isarc_ram, NULL, "ppc405.ocm", 4096,
+    memory_region_init_ram(&ocm->isarc_ram, NULL, "ppc405.ocm", 4 * KiB,
                            &error_fatal);
-    memory_region_init_alias(&ocm->dsarc_ram, NULL, "ppc405.dsarc", &ocm->isarc_ram,
-                             0, 4096);
+    memory_region_init_alias(&ocm->dsarc_ram, NULL, "ppc405.dsarc",
+                             &ocm->isarc_ram, 0, 4 * KiB);
     qemu_register_reset(&ocm_reset, ocm);
     ppc_dcr_register(env, OCM0_ISARC,
                      ocm, &dcr_read_ocm, &dcr_write_ocm);
diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c
index 44e6a0c21b..8b37fc6182 100644
--- a/hw/ppc/ppc440_bamboo.c
+++ b/hw/ppc/ppc440_bamboo.c
@@ -12,6 +12,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/error-report.h"
 #include "qemu-common.h"
 #include "qemu/error-report.h"
@@ -49,7 +50,8 @@
 #define PPC440EP_SDRAM_NR_BANKS 4
 
 static const unsigned int ppc440ep_sdram_bank_sizes[] = {
-    256<<20, 128<<20, 64<<20, 32<<20, 16<<20, 8<<20, 0
+    256 * MiB, 128 * MiB, 64 * MiB,
+    32 * MiB, 16 * MiB, 8 * MiB, 0
 };
 
 static hwaddr entry;
@@ -151,7 +153,7 @@ static void main_cpu_reset(void *opaque)
     CPUPPCState *env = &cpu->env;
 
     cpu_reset(CPU(cpu));
-    env->gpr[1] = (16<<20) - 8;
+    env->gpr[1] = (16 * MiB) - 8;
     env->gpr[3] = FDT_ADDR;
     env->nip = entry;
 
diff --git a/hw/ppc/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c
index 2e963894fe..bc6b5c29c1 100644
--- a/hw/ppc/ppc4xx_devs.c
+++ b/hw/ppc/ppc4xx_devs.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "cpu.h"
 #include "hw/hw.h"
 #include "hw/ppc/ppc.h"
@@ -29,6 +30,7 @@
 #include "hw/boards.h"
 #include "qemu/log.h"
 #include "exec/address-spaces.h"
+#include "qemu/error-report.h"
 
 #define DEBUG_UIC
 
@@ -353,25 +355,25 @@ static uint32_t sdram_bcr (hwaddr ram_base,
     uint32_t bcr;
 
     switch (ram_size) {
-    case (4 * 1024 * 1024):
+    case 4 * MiB:
         bcr = 0x00000000;
         break;
-    case (8 * 1024 * 1024):
+    case 8 * MiB:
         bcr = 0x00020000;
         break;
-    case (16 * 1024 * 1024):
+    case 16 * MiB:
         bcr = 0x00040000;
         break;
-    case (32 * 1024 * 1024):
+    case 32 * MiB:
         bcr = 0x00060000;
         break;
-    case (64 * 1024 * 1024):
+    case 64 * MiB:
         bcr = 0x00080000;
         break;
-    case (128 * 1024 * 1024):
+    case 128 * MiB:
         bcr = 0x000A0000;
         break;
-    case (256 * 1024 * 1024):
+    case 256 * MiB:
         bcr = 0x000C0000;
         break;
     default:
@@ -399,7 +401,7 @@ static target_ulong sdram_size (uint32_t bcr)
     if (sh == 7)
         size = -1;
     else
-        size = (4 * 1024 * 1024) << sh;
+        size = (4 * MiB) << sh;
 
     return size;
 }
@@ -702,8 +704,8 @@ ram_addr_t ppc4xx_sdram_adjust(ram_addr_t ram_size, int nr_banks,
 
     ram_size -= size_left;
     if (size_left) {
-        printf("Truncating memory to %d MiB to fit SDRAM controller limits.\n",
-               (int)(ram_size >> 20));
+        error_report("Truncating memory to %llu MiB to fit SDRAM "
+                     "controller limits", ram_size / MiB);
     }
 
     memory_region_allocate_system_memory(ram, NULL, "ppc4xx.sdram", ram_size);
diff --git a/hw/ppc/ppce500_spin.c b/hw/ppc/ppce500_spin.c
index 69ca2d0e42..c45fc858de 100644
--- a/hw/ppc/ppce500_spin.c
+++ b/hw/ppc/ppce500_spin.c
@@ -28,6 +28,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/hw.h"
 #include "hw/sysbus.h"
 #include "sysemu/hw_accel.h"
@@ -89,7 +90,7 @@ static void spin_kick(CPUState *cs, run_on_cpu_data data)
     PowerPCCPU *cpu = POWERPC_CPU(cs);
     CPUPPCState *env = &cpu->env;
     SpinInfo *curspin = data.host_ptr;
-    hwaddr map_size = 64 * 1024 * 1024;
+    hwaddr map_size = 64 * MiB;
     hwaddr map_start;
 
     cpu_synchronize_state(cs);
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index a8d26f74fc..31c8d92a6a 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -50,7 +50,7 @@
 #include "exec/address-spaces.h"
 #include "trace.h"
 #include "elf.h"
-#include "qemu/cutils.h"
+#include "qemu/units.h"
 #include "kvm_ppc.h"
 
 /* SMP is not enabled, for now */
@@ -60,7 +60,7 @@
 
 #define CFG_ADDR 0xf0000510
 
-#define BIOS_SIZE (1024 * 1024)
+#define BIOS_SIZE (1 * MiB)
 #define BIOS_FILENAME "ppc_rom.bin"
 #define KERNEL_LOAD_ADDR 0x01000000
 #define INITRD_LOAD_ADDR 0x01800000
diff --git a/hw/ppc/rs6000_mc.c b/hw/ppc/rs6000_mc.c
index b6135650bd..2e7de729db 100644
--- a/hw/ppc/rs6000_mc.c
+++ b/hw/ppc/rs6000_mc.c
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/isa/isa.h"
 #include "exec/address-spaces.h"
 #include "hw/boards.h"
@@ -109,7 +110,7 @@ static void rs6000mc_port0820_write(void *opaque, uint32_t addr, uint32_t val)
             size = end_address - start_address;
             memory_region_set_enabled(&s->simm[socket - 1], size != 0);
             memory_region_set_address(&s->simm[socket - 1],
-                                      start_address * 8 * 1024 * 1024);
+                                      start_address * 8 * MiB);
         }
     }
 }
@@ -140,7 +141,7 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp)
 {
     RS6000MCState *s = RS6000MC_DEVICE(dev);
     int socket = 0;
-    unsigned int ram_size = s->ram_size / (1024 * 1024);
+    unsigned int ram_size = s->ram_size / MiB;
 
     while (socket < 6) {
         if (ram_size >= 64) {
@@ -163,8 +164,8 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp)
             char name[] = "simm.?";
             name[5] = socket + '0';
             memory_region_allocate_system_memory(&s->simm[socket], OBJECT(dev),
-                                                 name, s->simm_size[socket]
-                                                 * 1024 * 1024);
+                                                 name,
+                                                 s->simm_size[socket] * MiB);
             memory_region_add_subregion_overlap(get_system_memory(), 0,
                                                 &s->simm[socket], socket);
         }
@@ -172,8 +173,8 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp)
     if (ram_size) {
         /* unable to push all requested RAM in SIMMs */
         error_setg(errp, "RAM size incompatible with this board. "
-                   "Try again with something else, like %d MB",
-                   s->ram_size / 1024 / 1024 - ram_size);
+                   "Try again with something else, like %lld MB",
+                   s->ram_size / MiB - ram_size);
         return;
     }
 
diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
index 2a98c10664..b35e3fff1c 100644
--- a/hw/ppc/sam460ex.c
+++ b/hw/ppc/sam460ex.c
@@ -12,8 +12,9 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu-common.h"
-#include "qemu/cutils.h"
+#include "qemu/units.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
@@ -46,7 +47,7 @@
 /* from Sam460 U-Boot include/configs/Sam460ex.h */
 #define FLASH_BASE             0xfff00000
 #define FLASH_BASE_H           0x4
-#define FLASH_SIZE             (1 << 20)
+#define FLASH_SIZE             (1 * MiB)
 #define UBOOT_LOAD_BASE        0xfff80000
 #define UBOOT_SIZE             0x00080000
 #define UBOOT_ENTRY            0xfffffffc
@@ -71,7 +72,8 @@
 
 /* FIXME: See u-boot.git 8ac41e, also fix in ppc440_uc.c */
 static const unsigned int ppc460ex_sdram_bank_sizes[] = {
-    1024 << 20, 512 << 20, 256 << 20, 128 << 20, 64 << 20, 32 << 20, 0
+    1 * GiB, 512 * MiB, 256 * MiB, 128 * MiB,
+    64 * MiB, 32 * MiB, 0
 };
 
 struct boot_info {
@@ -225,7 +227,7 @@ static int sam460ex_load_uboot(void)
     fl_sectors = (bios_size + 65535) >> 16;
 
     if (!pflash_cfi01_register(base, NULL, "sam460ex.flash", bios_size,
-                               blk, (64 * 1024), fl_sectors,
+                               blk, 64 * KiB, fl_sectors,
                                1, 0x89, 0x18, 0x0000, 0x0, 1)) {
         error_report("qemu: Error registering flash memory.");
         /* XXX: return an error instead? */
@@ -359,14 +361,14 @@ static void main_cpu_reset(void *opaque)
 
     /* either we have a kernel to boot or we jump to U-Boot */
     if (bi->entry != UBOOT_ENTRY) {
-        env->gpr[1] = (16 << 20) - 8;
+        env->gpr[1] = (16 * MiB) - 8;
         env->gpr[3] = FDT_ADDR;
         env->nip = bi->entry;
 
         /* Create a mapping for the kernel.  */
         mmubooke_create_initial_mapping(env, 0, 0);
         env->gpr[6] = tswap32(EPAPR_MAGIC);
-        env->gpr[7] = (16 << 20) - 8; /*bi->ima_size;*/
+        env->gpr[7] = (16 * MiB) - 8; /* bi->ima_size; */
 
     } else {
         env->nip = UBOOT_ENTRY;
@@ -479,8 +481,8 @@ static void sam460ex_init(MachineState *machine)
     /* 256K of L2 cache as memory */
     ppc4xx_l2sram_init(env);
     /* FIXME: remove this after fixing l2sram mapping in ppc440_uc.c? */
-    memory_region_init_ram(l2cache_ram, NULL, "ppc440.l2cache_ram", 256 << 10,
-                           &error_abort);
+    memory_region_init_ram(l2cache_ram, NULL, "ppc440.l2cache_ram",
+                           256 * KiB, &error_abort);
     memory_region_add_subregion(address_space_mem, 0x400000000LL, l2cache_ram);
 
     /* USB */
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 3ba3bc8b6c..f8a3a711fd 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2756,7 +2756,7 @@ static void spapr_machine_init(MachineState *machine)
         }
     }
 
-    if (spapr->rma_size < (MIN_RMA_SLOF << 20)) {
+    if (spapr->rma_size < (MIN_RMA_SLOF * MiB)) {
         error_report(
             "pSeries SLOF firmware requires >= %ldM guest RMA (Real Mode Area memory)",
             MIN_RMA_SLOF);
diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
index b4bb90d50b..7891464cd9 100644
--- a/hw/ppc/virtex_ml507.c
+++ b/hw/ppc/virtex_ml507.c
@@ -23,6 +23,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "cpu.h"
 #include "hw/sysbus.h"
 #include "hw/hw.h"
@@ -45,7 +46,7 @@
 #include "ppc405.h"
 
 #define EPAPR_MAGIC    (0x45504150)
-#define FLASH_SIZE     (16 * 1024 * 1024)
+#define FLASH_SIZE     (16 * MiB)
 
 #define INTC_BASEADDR       0x81800000
 #define UART16550_BASEADDR  0x83e01003
@@ -127,7 +128,7 @@ static void main_cpu_reset(void *opaque)
        *   r8: 0
        *   r9: 0
     */
-    env->gpr[1] = (16<<20) - 8;
+    env->gpr[1] = (16 * MiB) - 8;
     /* Provide a device-tree.  */
     env->gpr[3] = bi->fdt;
     env->nip = bi->bootstrap_pc;
@@ -235,7 +236,7 @@ static void virtex_init(MachineState *machine)
     dinfo = drive_get(IF_PFLASH, 0, 0);
     pflash_cfi01_register(PFLASH_BASEADDR, NULL, "virtex.flash", FLASH_SIZE,
                           dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                          (64 * 1024), FLASH_SIZE >> 16,
+                          64 * KiB, FLASH_SIZE >> 16,
                           1, 0x89, 0x18, 0x0000, 0x0, 1);
 
     cpu_irq = (qemu_irq *) &env->irq_inputs[PPC40x_INPUT_INT];
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 34/40] hw/net: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (30 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 32/40] hw/ppc: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11 19:20   ` Stefan Weil
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 35/40] hw/usb: " Philippe Mathieu-Daudé
                   ` (9 subsequent siblings)
  41 siblings, 1 reply; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Dmitry Fleytman, Jason Wang,
	Beniamino Galvani, open list:Allwinner-a10

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
---
 hw/net/ne2000.h                 | 5 +++--
 include/hw/net/allwinner_emac.h | 5 +++--
 hw/net/e1000e.c                 | 7 ++++---
 hw/net/e1000x_common.c          | 3 ++-
 hw/net/eepro100.c               | 3 +--
 5 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/hw/net/ne2000.h b/hw/net/ne2000.h
index adb8021bd1..2cd193e4c6 100644
--- a/hw/net/ne2000.h
+++ b/hw/net/ne2000.h
@@ -1,11 +1,12 @@
 #ifndef HW_NE2000_H
 #define HW_NE2000_H
 
+#include "qemu/units.h"
 #include "hw/hw.h"
 #include "net/net.h"
 
-#define NE2000_PMEM_SIZE    (32*1024)
-#define NE2000_PMEM_START   (16*1024)
+#define NE2000_PMEM_SIZE    (32 * KiB)
+#define NE2000_PMEM_START   (16 * KiB)
 #define NE2000_PMEM_END     (NE2000_PMEM_SIZE+NE2000_PMEM_START)
 #define NE2000_MEM_SIZE     NE2000_PMEM_END
 
diff --git a/include/hw/net/allwinner_emac.h b/include/hw/net/allwinner_emac.h
index 4cc8aab7ec..905a43deb4 100644
--- a/include/hw/net/allwinner_emac.h
+++ b/include/hw/net/allwinner_emac.h
@@ -23,6 +23,7 @@
 #ifndef ALLWINNER_EMAC_H
 #define ALLWINNER_EMAC_H
 
+#include "qemu/units.h"
 #include "net/net.h"
 #include "qemu/fifo8.h"
 #include "hw/net/mii.h"
@@ -125,8 +126,8 @@
 #define EMAC_INT_RX         (1 << 8)
 
 /* Due to lack of specifications, size of fifos is chosen arbitrarily */
-#define TX_FIFO_SIZE        (4 * 1024)
-#define RX_FIFO_SIZE        (32 * 1024)
+#define TX_FIFO_SIZE        (4 * KiB)
+#define RX_FIFO_SIZE        (32 * KiB)
 
 #define NUM_TX_FIFOS        2
 #define RX_HDR_SIZE         8
diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c
index cda8d48333..510ddb3897 100644
--- a/hw/net/e1000e.c
+++ b/hw/net/e1000e.c
@@ -34,6 +34,7 @@
 */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "net/net.h"
 #include "net/tap.h"
 #include "qemu/range.h"
@@ -81,10 +82,10 @@ typedef struct E1000EState {
 #define E1000E_IO_IDX       2
 #define E1000E_MSIX_IDX     3
 
-#define E1000E_MMIO_SIZE    (128 * 1024)
-#define E1000E_FLASH_SIZE   (128 * 1024)
+#define E1000E_MMIO_SIZE    (128 * KiB)
+#define E1000E_FLASH_SIZE   (128 * KiB)
 #define E1000E_IO_SIZE      (32)
-#define E1000E_MSIX_SIZE    (16 * 1024)
+#define E1000E_MSIX_SIZE    (16 * KiB)
 
 #define E1000E_MSIX_TABLE   (0x0000)
 #define E1000E_MSIX_PBA     (0x2000)
diff --git a/hw/net/e1000x_common.c b/hw/net/e1000x_common.c
index eb0e097137..09047806f2 100644
--- a/hw/net/e1000x_common.c
+++ b/hw/net/e1000x_common.c
@@ -23,6 +23,7 @@
 */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/hw.h"
 #include "hw/pci/pci.h"
 #include "net/net.h"
@@ -111,7 +112,7 @@ bool e1000x_is_oversized(uint32_t *mac, size_t size)
     static const int maximum_ethernet_vlan_size = 1522;
     /* this is the size past which hardware will
        drop packets when setting LPE=1 */
-    static const int maximum_ethernet_lpe_size = 16384;
+    static const int maximum_ethernet_lpe_size = 16 * KiB;
 
     if ((size > maximum_ethernet_lpe_size ||
         (size > maximum_ethernet_vlan_size
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index a07a63247e..e761daf551 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -41,6 +41,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/hw.h"
 #include "hw/pci/pci.h"
 #include "net/net.h"
@@ -60,8 +61,6 @@
  * changed to pad short packets itself. */
 #define CONFIG_PAD_RECEIVED_FRAMES
 
-#define KiB 1024
-
 /* Debug EEPRO100 card. */
 #if 0
 # define DEBUG_EEPRO100
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 35/40] hw/usb: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (31 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 34/40] hw/net: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 36/40] hw/sd: " Philippe Mathieu-Daudé
                   ` (8 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-trivial, Gerd Hoffmann

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/usb/ccid-card-passthru.c   | 5 +++--
 hw/usb/combined-packet.c      | 3 ++-
 hw/usb/dev-smartcard-reader.c | 3 ++-
 hw/usb/redirect.c             | 3 ++-
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c
index 25fb19b0d7..e6c73116cc 100644
--- a/hw/usb/ccid-card-passthru.c
+++ b/hw/usb/ccid-card-passthru.c
@@ -9,6 +9,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include <libcacard.h>
 #include "chardev/char-fe.h"
 #include "qemu/error-report.h"
@@ -40,7 +41,7 @@ static const uint8_t DEFAULT_ATR[] = {
  0x13, 0x08
 };
 
-#define VSCARD_IN_SIZE 65536
+#define VSCARD_IN_SIZE      (64 * KiB)
 
 /* maximum size of ATR - from 7816-3 */
 #define MAX_ATR_SIZE        40
@@ -276,7 +277,7 @@ static void ccid_card_vscard_read(void *opaque, const uint8_t *buf, int size)
 
     if (card->vscard_in_pos + size > VSCARD_IN_SIZE) {
         error_report(
-            "no room for data: pos %d +  size %d > %d. dropping connection.",
+            "no room for data: pos %d +  size %d > %llu. dropping connection.",
             card->vscard_in_pos, size, VSCARD_IN_SIZE);
         ccid_card_vscard_drop_connection(card);
         return;
diff --git a/hw/usb/combined-packet.c b/hw/usb/combined-packet.c
index 48cac87f6a..01a7ed0848 100644
--- a/hw/usb/combined-packet.c
+++ b/hw/usb/combined-packet.c
@@ -20,6 +20,7 @@
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu-common.h"
 #include "hw/usb.h"
 #include "qemu/iov.h"
@@ -171,7 +172,7 @@ void usb_ep_combine_input_packets(USBEndpoint *ep)
         if ((p->iov.size % ep->max_packet_size) != 0 || !p->short_not_ok ||
                 next == NULL ||
                 /* Work around for Linux usbfs bulk splitting + migration */
-                (totalsize == 16348 && p->int_req)) {
+                (totalsize == (16 * KiB - 36) && p->int_req)) {
             usb_device_handle_data(ep->dev, first);
             assert(first->status == USB_RET_ASYNC);
             if (first->combined) {
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 2131e33d27..ec862c2082 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -35,6 +35,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "qemu/error-report.h"
@@ -63,7 +64,7 @@ do { \
  * or handle the migration complexity - VMState doesn't handle this case.
  * sizes are expected never to be exceeded, unless guest misbehaves.
  */
-#define BULK_OUT_DATA_SIZE 65536
+#define BULK_OUT_DATA_SIZE  (64 * KiB)
 #define PENDING_ANSWERS_NUM 128
 
 #define BULK_IN_BUF_SIZE 384
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 65a9196c1a..8580c08dbd 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -26,6 +26,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "qemu/timer.h"
@@ -1298,7 +1299,7 @@ static int usbredir_chardev_can_read(void *opaque)
     }
 
     /* usbredir_parser_do_read will consume *all* data we give it */
-    return 1024 * 1024;
+    return 1 * MiB;
 }
 
 static void usbredir_chardev_read(void *opaque, const uint8_t *buf, int size)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 36/40] hw/sd: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (32 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 35/40] hw/usb: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 37/40] hw/vfio: " Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-trivial

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/sd/sd.c    | 4 ++--
 hw/sd/sdhci.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 9a16b768ed..d4356e9b73 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -31,6 +31,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/qdev.h"
 #include "hw/hw.h"
 #include "hw/registerfields.h"
@@ -38,7 +39,6 @@
 #include "hw/sd/sd.h"
 #include "qapi/error.h"
 #include "qemu/bitmap.h"
-#include "qemu/cutils.h"
 #include "hw/qdev-properties.h"
 #include "qemu/error-report.h"
 #include "qemu/timer.h"
@@ -403,7 +403,7 @@ static void sd_set_csd(SDState *sd, uint64_t size)
             ((HWBLOCK_SHIFT << 6) & 0xc0);
         sd->csd[14] = 0x00;	/* File format group */
     } else {			/* SDHC */
-        size /= 512 * 1024;
+        size /= 512 * KiB;
         size -= 1;
         sd->csd[0] = 0x40;
         sd->csd[1] = 0x0e;
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index a11e802485..39c2b3a6e8 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -23,6 +23,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
@@ -32,7 +33,6 @@
 #include "hw/sd/sdhci.h"
 #include "sdhci-internal.h"
 #include "qemu/log.h"
-#include "qemu/cutils.h"
 #include "trace.h"
 
 #define TYPE_SDHCI_BUS "sdhci-bus"
@@ -790,7 +790,7 @@ static void sdhci_do_adma(SDHCIState *s)
             return;
         }
 
-        length = dscr.length ? dscr.length : 65536;
+        length = dscr.length ? dscr.length : 64 * KiB;
 
         switch (dscr.attr & SDHC_ADMA_ATTR_ACT_MASK) {
         case SDHC_ADMA_ATTR_ACT_TRAN:  /* data transfer */
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 37/40] hw/vfio: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (33 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 36/40] hw/sd: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 38/40] hw/virtio: " Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-trivial, Alex Williamson

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/vfio/pci-quirks.c | 9 +++++----
 hw/vfio/pci.c        | 3 ++-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
index 061259b86b..481fd08df7 100644
--- a/hw/vfio/pci-quirks.c
+++ b/hw/vfio/pci-quirks.c
@@ -11,6 +11,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 #include "qemu/range.h"
@@ -1448,9 +1449,9 @@ static int vfio_igd_gtt_max(VFIOPCIDevice *vdev)
         ggms = 1 << ggms;
     }
 
-    ggms *= 1024 * 1024;
+    ggms *= MiB;
 
-    return (ggms / (4 * 1024)) * (gen < 8 ? 4 : 8);
+    return (ggms / (4 * KiB)) * (gen < 8 ? 4 : 8);
 }
 
 /*
@@ -1705,7 +1706,7 @@ static void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr)
     igd->vdev = vdev;
     igd->index = ~0;
     igd->bdsm = vfio_pci_read_config(&vdev->pdev, IGD_BDSM, 4);
-    igd->bdsm &= ~((1 << 20) - 1); /* 1MB aligned */
+    igd->bdsm &= ~((1 * MiB) - 1); /* 1MB aligned */
 
     memory_region_init_io(&quirk->mem[0], OBJECT(vdev), &vfio_igd_index_quirk,
                           igd, "vfio-igd-index-quirk", 4);
@@ -1752,7 +1753,7 @@ static void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr)
      * config offset 0x5C.
      */
     bdsm_size = g_malloc(sizeof(*bdsm_size));
-    *bdsm_size = cpu_to_le64((ggms_mb + gms_mb) * 1024 * 1024);
+    *bdsm_size = cpu_to_le64((ggms_mb + gms_mb) * MiB);
     fw_cfg_add_file(fw_cfg_find(), "etc/igd-bdsm-size",
                     bdsm_size, sizeof(*bdsm_size));
 
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 18c493b49e..a1577dea7f 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -28,6 +28,7 @@
 #include "qemu/error-report.h"
 #include "qemu/option.h"
 #include "qemu/range.h"
+#include "qemu/units.h"
 #include "sysemu/kvm.h"
 #include "sysemu/sysemu.h"
 #include "pci.h"
@@ -1417,7 +1418,7 @@ static void vfio_pci_relocate_msix(VFIOPCIDevice *vdev, Error **errp)
     }
 
     /* 2GB max size for 32-bit BARs, cannot double if already > 1G */
-    if (vdev->bars[target_bar].size > (1 * 1024 * 1024 * 1024) &&
+    if (vdev->bars[target_bar].size > 1 * GiB &&
         !vdev->bars[target_bar].mem64) {
         error_setg(errp, "Invalid MSI-X relocation BAR %d, "
                    "no space to extend 32-bit BAR", target_bar);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 38/40] hw/virtio: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (34 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 37/40] hw/vfio: " Philippe Mathieu-Daudé
@ 2018-06-11  1:14 ` Philippe Mathieu-Daudé
  2018-06-11  1:15 ` [Qemu-devel] [PATCH v4 39/40] hw/rdma: " Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:14 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Michael S. Tsirkin

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/virtio/virtio-net.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index 02484dc94c..4d7f3c82ca 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -14,6 +14,7 @@
 #ifndef QEMU_VIRTIO_NET_H
 #define QEMU_VIRTIO_NET_H
 
+#include "qemu/units.h"
 #include "standard-headers/linux/virtio_net.h"
 #include "hw/virtio/virtio.h"
 
@@ -44,7 +45,7 @@ typedef struct virtio_net_conf
 } virtio_net_conf;
 
 /* Maximum packet size we can receive from tap device: header + 64k */
-#define VIRTIO_NET_MAX_BUFSIZE (sizeof(struct virtio_net_hdr) + (64 << 10))
+#define VIRTIO_NET_MAX_BUFSIZE (sizeof(struct virtio_net_hdr) + (64 * KiB))
 
 typedef struct VirtIONetQueue {
     VirtQueue *rx_vq;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 39/40] hw/rdma: Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (35 preceding siblings ...)
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 38/40] hw/virtio: " Philippe Mathieu-Daudé
@ 2018-06-11  1:15 ` Philippe Mathieu-Daudé
  2018-06-11  1:15 ` [Qemu-devel] [PATCH v4 40/40] cutils: Do not include "qemu/units.h" directly Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:15 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-trivial, Yuval Shaia, Marcel Apfelbaum

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>
---
 hw/rdma/vmw/pvrdma.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/rdma/vmw/pvrdma.h b/hw/rdma/vmw/pvrdma.h
index 0b46dc5a9b..81e0e0e99c 100644
--- a/hw/rdma/vmw/pvrdma.h
+++ b/hw/rdma/vmw/pvrdma.h
@@ -16,6 +16,7 @@
 #ifndef PVRDMA_PVRDMA_H
 #define PVRDMA_PVRDMA_H
 
+#include "qemu/units.h"
 #include "hw/pci/pci.h"
 #include "hw/pci/msix.h"
 
@@ -30,7 +31,7 @@
 #define RDMA_MSIX_BAR_IDX    0
 #define RDMA_REG_BAR_IDX     1
 #define RDMA_UAR_BAR_IDX     2
-#define RDMA_BAR0_MSIX_SIZE  (16 * 1024)
+#define RDMA_BAR0_MSIX_SIZE  (16 * KiB)
 #define RDMA_BAR1_REGS_SIZE  64
 #define RDMA_BAR2_UAR_SIZE   (0x1000 * MAX_UCS) /* each uc gets page */
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [Qemu-devel] [PATCH v4 40/40] cutils: Do not include "qemu/units.h" directly
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (36 preceding siblings ...)
  2018-06-11  1:15 ` [Qemu-devel] [PATCH v4 39/40] hw/rdma: " Philippe Mathieu-Daudé
@ 2018-06-11  1:15 ` Philippe Mathieu-Daudé
       [not found] ` <20180611011501.10235-34-f4bug@amsat.org>
                   ` (3 subsequent siblings)
  41 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  1:15 UTC (permalink / raw)
  To: Thomas Huth, Stefan Weil
  Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-trivial

All files using "qemu/units.h" definitions already include it directly,
we can now remove it from "qemu/cutils.h".

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
---
 include/qemu/cutils.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
index 056e6629bb..cdb0f0db75 100644
--- a/include/qemu/cutils.h
+++ b/include/qemu/cutils.h
@@ -2,7 +2,6 @@
 #define QEMU_CUTILS_H
 
 #include "qemu/fprintf-fn.h"
-#include "qemu/units.h"
 
 /**
  * pstrcpy:
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 16/40] hw/riscv: Use the IEC binary prefix definitions
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 16/40] hw/riscv: " Philippe Mathieu-Daudé
@ 2018-06-11  1:22   ` Michael Clark
  0 siblings, 0 replies; 70+ messages in thread
From: Michael Clark @ 2018-06-11  1:22 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Thomas Huth, Stefan Weil, QEMU Developers, qemu-trivial,
	Palmer Dabbelt, Sagar Karandikar, Bastian Koppelmann

On Mon, Jun 11, 2018 at 1:14 PM, Philippe Mathieu-Daudé <f4bug@amsat.org>
wrote:

> It eases code review, unit is explicit.
>
> Patch generated using:
>
>   $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/
> include/hw/
>
> and modified manually.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>

Reviewed-by: Michael Clark <mjc@sifive.com>


> ---
>  hw/riscv/virt.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
> index ad03113e0f..34d48993a2 100644
> --- a/hw/riscv/virt.c
> +++ b/hw/riscv/virt.c
> @@ -19,6 +19,7 @@
>   */
>
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "qemu/log.h"
>  #include "qemu/error-report.h"
>  #include "qapi/error.h"
> @@ -84,7 +85,7 @@ static hwaddr load_initrd(const char *filename, uint64_t
> mem_size,
>       * halfway into RAM, and for boards with 256MB of RAM or more we put
>       * the initrd at 128MB.
>       */
> -    *start = kernel_entry + MIN(mem_size / 2, 128 * 1024 * 1024);
> +    *start = kernel_entry + MIN(mem_size / 2, 128 * MiB);
>
>      size = load_ramdisk(filename, *start, mem_size - *start);
>      if (size == -1) {
> --
> 2.17.1
>
>

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 05/40] hw: Use IEC binary prefix definitions from "qemu/units.h"
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 05/40] hw: Use IEC binary prefix definitions from "qemu/units.h" Philippe Mathieu-Daudé
@ 2018-06-11  2:11   ` David Gibson
  0 siblings, 0 replies; 70+ messages in thread
From: David Gibson @ 2018-06-11  2:11 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Thomas Huth, Stefan Weil, Nikunj A Dadhania, qemu-devel,
	qemu-trivial, Subbaraya Sundeep, Peter Maydell, Paul Burton,
	Eduardo Habkost, Marcel Apfelbaum, Richard Henderson,
	Aurelien Jarno, Yongbok Kim, Alexander Graf,
	Hervé Poussineau, Markus Armbruster, open list:ARM,
	open list:PowerPC

[-- Attachment #1: Type: text/plain, Size: 23735 bytes --]

On Sun, Jun 10, 2018 at 10:14:26PM -0300, Philippe Mathieu-Daudé wrote:
> Code change produced with:
> 
>   $ git ls-files | egrep '\.[ch]$' | \
>     xargs sed -i -e 's/\(\W[KMGTPE]\)_BYTE/\1iB/g'
> 
> Suggested-by: Stefan Weil <sw@weilnetz.de>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

ppc parts
Acked-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  include/qemu/cutils.h  |  8 +-------
>  hw/arm/msf2-soc.c      |  4 ++--
>  hw/arm/msf2-som.c      |  6 +++---
>  hw/core/loader-fit.c   |  3 ++-
>  hw/core/machine.c      |  2 +-
>  hw/display/sm501.c     | 14 +++++++-------
>  hw/hppa/machine.c      |  2 +-
>  hw/mips/boston.c       | 28 ++++++++++++++--------------
>  hw/ppc/pnv.c           |  4 ++--
>  hw/ppc/ppc440_uc.c     | 26 +++++++++++++-------------
>  hw/ppc/prep.c          |  2 +-
>  hw/ppc/sam460ex.c      |  2 +-
>  hw/ppc/spapr.c         | 10 +++++-----
>  hw/ppc/spapr_rtas.c    |  2 +-
>  hw/sd/sd.c             |  4 ++--
>  hw/sd/sdhci.c          |  2 +-
>  tests/test-cutils.c    | 18 +++++++++---------
>  tests/test-keyval.c    |  6 +++---
>  tests/test-qemu-opts.c |  7 +++----
>  19 files changed, 72 insertions(+), 78 deletions(-)
> 
> diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
> index a663340b23..056e6629bb 100644
> --- a/include/qemu/cutils.h
> +++ b/include/qemu/cutils.h
> @@ -2,6 +2,7 @@
>  #define QEMU_CUTILS_H
>  
>  #include "qemu/fprintf-fn.h"
> +#include "qemu/units.h"
>  
>  /**
>   * pstrcpy:
> @@ -147,13 +148,6 @@ int qemu_strtosz(const char *nptr, char **end, uint64_t *result);
>  int qemu_strtosz_MiB(const char *nptr, char **end, uint64_t *result);
>  int qemu_strtosz_metric(const char *nptr, char **end, uint64_t *result);
>  
> -#define K_BYTE     (1ULL << 10)
> -#define M_BYTE     (1ULL << 20)
> -#define G_BYTE     (1ULL << 30)
> -#define T_BYTE     (1ULL << 40)
> -#define P_BYTE     (1ULL << 50)
> -#define E_BYTE     (1ULL << 60)
> -
>  /* used to print char* safely */
>  #define STR_OR_NULL(str) ((str) ? (str) : "null")
>  
> diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
> index 75c44adf7d..530e461c42 100644
> --- a/hw/arm/msf2-soc.c
> +++ b/hw/arm/msf2-soc.c
> @@ -40,14 +40,14 @@
>  
>  #define SRAM_BASE_ADDRESS     0x20000000
>  
> -#define MSF2_ENVM_MAX_SIZE    (512 * K_BYTE)
> +#define MSF2_ENVM_MAX_SIZE    (512 * KiB)
>  
>  /*
>   * eSRAM max size is 80k without SECDED(Single error correction and
>   * dual error detection) feature and 64k with SECDED.
>   * We do not support SECDED now.
>   */
> -#define MSF2_ESRAM_MAX_SIZE       (80 * K_BYTE)
> +#define MSF2_ESRAM_MAX_SIZE       (80 * KiB)
>  
>  static const uint32_t spi_addr[MSF2_NUM_SPIS] = { 0x40001000 , 0x40011000 };
>  static const uint32_t uart_addr[MSF2_NUM_UARTS] = { 0x40000000 , 0x40010000 };
> diff --git a/hw/arm/msf2-som.c b/hw/arm/msf2-som.c
> index 0795a3a3a1..ed533bbde1 100644
> --- a/hw/arm/msf2-som.c
> +++ b/hw/arm/msf2-som.c
> @@ -33,10 +33,10 @@
>  #include "cpu.h"
>  
>  #define DDR_BASE_ADDRESS      0xA0000000
> -#define DDR_SIZE              (64 * M_BYTE)
> +#define DDR_SIZE              (64 * MiB)
>  
> -#define M2S010_ENVM_SIZE      (256 * K_BYTE)
> -#define M2S010_ESRAM_SIZE     (64 * K_BYTE)
> +#define M2S010_ENVM_SIZE      (256 * KiB)
> +#define M2S010_ESRAM_SIZE     (64 * KiB)
>  
>  static void emcraft_sf2_s2s010_init(MachineState *machine)
>  {
> diff --git a/hw/core/loader-fit.c b/hw/core/loader-fit.c
> index 6387854b54..447f60857d 100644
> --- a/hw/core/loader-fit.c
> +++ b/hw/core/loader-fit.c
> @@ -18,6 +18,7 @@
>   */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "exec/memory.h"
>  #include "hw/loader.h"
>  #include "hw/loader-fit.h"
> @@ -194,7 +195,7 @@ static int fit_load_fdt(const struct fit_loader *ldr, const void *itb,
>  
>      err = fit_image_addr(itb, img_off, "load", &load_addr);
>      if (err == -ENOENT) {
> -        load_addr = ROUND_UP(kernel_end, 64 * K_BYTE) + (10 * M_BYTE);
> +        load_addr = ROUND_UP(kernel_end, 64 * KiB) + (10 * MiB);
>      } else if (err) {
>          ret = err;
>          goto out;
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index 617e5f8d75..ccf3a4b9c7 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -522,7 +522,7 @@ static void machine_class_init(ObjectClass *oc, void *data)
>      MachineClass *mc = MACHINE_CLASS(oc);
>  
>      /* Default 128 MB as guest ram size */
> -    mc->default_ram_size = 128 * M_BYTE;
> +    mc->default_ram_size = 128 * MiB;
>      mc->rom_file_has_mr = true;
>  
>      /* numa node memory size aligned on 8MB by default.
> diff --git a/hw/display/sm501.c b/hw/display/sm501.c
> index e47be99451..1c6c9445c5 100644
> --- a/hw/display/sm501.c
> +++ b/hw/display/sm501.c
> @@ -452,12 +452,12 @@
>  
>  /* SM501 local memory size taken from "linux/drivers/mfd/sm501.c" */
>  static const uint32_t sm501_mem_local_size[] = {
> -    [0] = 4 * M_BYTE,
> -    [1] = 8 * M_BYTE,
> -    [2] = 16 * M_BYTE,
> -    [3] = 32 * M_BYTE,
> -    [4] = 64 * M_BYTE,
> -    [5] = 2 * M_BYTE,
> +    [0] = 4 * MiB,
> +    [1] = 8 * MiB,
> +    [2] = 16 * MiB,
> +    [3] = 32 * MiB,
> +    [4] = 64 * MiB,
> +    [5] = 2 * MiB,
>  };
>  #define get_local_mem_size(s) sm501_mem_local_size[(s)->local_mem_size_index]
>  
> @@ -1826,7 +1826,7 @@ static void sm501_realize_pci(PCIDevice *dev, Error **errp)
>  }
>  
>  static Property sm501_pci_properties[] = {
> -    DEFINE_PROP_UINT32("vram-size", SM501PCIState, vram_size, 64 * M_BYTE),
> +    DEFINE_PROP_UINT32("vram-size", SM501PCIState, vram_size, 64 * MiB),
>      DEFINE_PROP_END_OF_LIST(),
>  };
>  
> diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
> index aba269bb85..2ba26962f9 100644
> --- a/hw/hppa/machine.c
> +++ b/hw/hppa/machine.c
> @@ -275,7 +275,7 @@ static void machine_hppa_machine_init(MachineClass *mc)
>      mc->max_cpus = HPPA_MAX_CPUS;
>      mc->default_cpus = 1;
>      mc->is_default = 1;
> -    mc->default_ram_size = 512 * M_BYTE;
> +    mc->default_ram_size = 512 * MiB;
>      mc->default_boot_order = "cd";
>  }
>  
> diff --git a/hw/mips/boston.c b/hw/mips/boston.c
> index 52cce19766..512c60c03e 100644
> --- a/hw/mips/boston.c
> +++ b/hw/mips/boston.c
> @@ -200,7 +200,7 @@ static uint64_t boston_platreg_read(void *opaque, hwaddr addr,
>          val |= PLAT_BUILD_CFG_PCIE2_EN;
>          return val;
>      case PLAT_DDR_CFG:
> -        val = s->mach->ram_size / G_BYTE;
> +        val = s->mach->ram_size / GiB;
>          assert(!(val & ~PLAT_DDR_CFG_SIZE));
>          val |= PLAT_DDR_CFG_MHZ;
>          return val;
> @@ -355,7 +355,7 @@ static const void *boston_fdt_filter(void *opaque, const void *fdt_orig,
>          return NULL;
>      }
>  
> -    ram_low_sz = MIN(256 * M_BYTE, machine->ram_size);
> +    ram_low_sz = MIN(256 * MiB, machine->ram_size);
>      ram_high_sz = machine->ram_size - ram_low_sz;
>      qemu_fdt_setprop_sized_cells(fdt, "/memory@0", "reg",
>                                   1, 0x00000000, 1, ram_low_sz,
> @@ -436,8 +436,8 @@ static void boston_mach_init(MachineState *machine)
>      int fw_size, fit_err;
>      bool is_64b;
>  
> -    if ((machine->ram_size % G_BYTE) ||
> -        (machine->ram_size > (2 * G_BYTE))) {
> +    if ((machine->ram_size % GiB) ||
> +        (machine->ram_size > (2 * GiB))) {
>          error_report("Memory size must be 1GB or 2GB");
>          exit(1);
>      }
> @@ -472,7 +472,7 @@ static void boston_mach_init(MachineState *machine)
>  
>      flash =  g_new(MemoryRegion, 1);
>      memory_region_init_rom_nomigrate(flash, NULL,
> -                                     "boston.flash", 128 * M_BYTE, &err);
> +                                     "boston.flash", 128 * MiB, &err);
>      memory_region_add_subregion_overlap(sys_mem, 0x18000000, flash, 0);
>  
>      ddr = g_new(MemoryRegion, 1);
> @@ -482,22 +482,22 @@ static void boston_mach_init(MachineState *machine)
>  
>      ddr_low_alias = g_new(MemoryRegion, 1);
>      memory_region_init_alias(ddr_low_alias, NULL, "boston_low.ddr",
> -                             ddr, 0, MIN(machine->ram_size, (256 * M_BYTE)));
> +                             ddr, 0, MIN(machine->ram_size, (256 * MiB)));
>      memory_region_add_subregion_overlap(sys_mem, 0, ddr_low_alias, 0);
>  
>      xilinx_pcie_init(sys_mem, 0,
> -                     0x10000000, 32 * M_BYTE,
> -                     0x40000000, 1 * G_BYTE,
> +                     0x10000000, 32 * MiB,
> +                     0x40000000, 1 * GiB,
>                       get_cps_irq(s->cps, 2), false);
>  
>      xilinx_pcie_init(sys_mem, 1,
> -                     0x12000000, 32 * M_BYTE,
> -                     0x20000000, 512 * M_BYTE,
> +                     0x12000000, 32 * MiB,
> +                     0x20000000, 512 * MiB,
>                       get_cps_irq(s->cps, 1), false);
>  
>      pcie2 = xilinx_pcie_init(sys_mem, 2,
> -                             0x14000000, 32 * M_BYTE,
> -                             0x16000000, 1 * M_BYTE,
> +                             0x14000000, 32 * MiB,
> +                             0x16000000, 1 * MiB,
>                               get_cps_irq(s->cps, 0), true);
>  
>      platreg = g_new(MemoryRegion, 1);
> @@ -527,7 +527,7 @@ static void boston_mach_init(MachineState *machine)
>  
>      if (machine->firmware) {
>          fw_size = load_image_targphys(machine->firmware,
> -                                      0x1fc00000, 4 * M_BYTE);
> +                                      0x1fc00000, 4 * MiB);
>          if (fw_size == -1) {
>              error_printf("unable to load firmware image '%s'\n",
>                            machine->firmware);
> @@ -553,7 +553,7 @@ static void boston_mach_class_init(MachineClass *mc)
>      mc->desc = "MIPS Boston";
>      mc->init = boston_mach_init;
>      mc->block_default_type = IF_IDE;
> -    mc->default_ram_size = 1 * G_BYTE;
> +    mc->default_ram_size = 1 * GiB;
>      mc->max_cpus = 16;
>      mc->default_cpu_type = MIPS_CPU_TYPE_NAME("I6400");
>  }
> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
> index 0314881316..bdb6f63d2c 100644
> --- a/hw/ppc/pnv.c
> +++ b/hw/ppc/pnv.c
> @@ -559,7 +559,7 @@ static void pnv_init(MachineState *machine)
>      char *chip_typename;
>  
>      /* allocate RAM */
> -    if (machine->ram_size < (1 * G_BYTE)) {
> +    if (machine->ram_size < (1 * GiB)) {
>          warn_report("skiboot may not work with < 1GB of RAM");
>      }
>  
> @@ -1096,7 +1096,7 @@ static void pnv_machine_class_init(ObjectClass *oc, void *data)
>                                        * storage */
>      mc->no_parallel = 1;
>      mc->default_boot_order = NULL;
> -    mc->default_ram_size = 1 * G_BYTE;
> +    mc->default_ram_size = 1 * GiB;
>      xic->icp_get = pnv_icp_get;
>      xic->ics_get = pnv_ics_get;
>      xic->ics_resend = pnv_ics_resend;
> diff --git a/hw/ppc/ppc440_uc.c b/hw/ppc/ppc440_uc.c
> index 123f4ac09d..b5b31b4b9b 100644
> --- a/hw/ppc/ppc440_uc.c
> +++ b/hw/ppc/ppc440_uc.c
> @@ -215,13 +215,13 @@ void ppc4xx_l2sram_init(CPUPPCState *env)
>      l2sram = g_malloc0(sizeof(*l2sram));
>      /* XXX: Size is 4*64kB for 460ex, cf. U-Boot, ppc4xx-isram.h */
>      memory_region_init_ram(&l2sram->bank[0], NULL, "ppc4xx.l2sram_bank0",
> -                           64 * K_BYTE, &error_abort);
> +                           64 * KiB, &error_abort);
>      memory_region_init_ram(&l2sram->bank[1], NULL, "ppc4xx.l2sram_bank1",
> -                           64 * K_BYTE, &error_abort);
> +                           64 * KiB, &error_abort);
>      memory_region_init_ram(&l2sram->bank[2], NULL, "ppc4xx.l2sram_bank2",
> -                           64 * K_BYTE, &error_abort);
> +                           64 * KiB, &error_abort);
>      memory_region_init_ram(&l2sram->bank[3], NULL, "ppc4xx.l2sram_bank3",
> -                           64 * K_BYTE, &error_abort);
> +                           64 * KiB, &error_abort);
>      qemu_register_reset(&l2sram_reset, l2sram);
>      ppc_dcr_register(env, DCR_L2CACHE_CFG,
>                       l2sram, &dcr_read_l2sram, &dcr_write_l2sram);
> @@ -513,28 +513,28 @@ static uint32_t sdram_bcr(hwaddr ram_base, hwaddr ram_size)
>      uint32_t bcr;
>  
>      switch (ram_size) {
> -    case (8 * M_BYTE):
> +    case (8 * MiB):
>          bcr = 0xffc0;
>          break;
> -    case (16 * M_BYTE):
> +    case (16 * MiB):
>          bcr = 0xff80;
>          break;
> -    case (32 * M_BYTE):
> +    case (32 * MiB):
>          bcr = 0xff00;
>          break;
> -    case (64 * M_BYTE):
> +    case (64 * MiB):
>          bcr = 0xfe00;
>          break;
> -    case (128 * M_BYTE):
> +    case (128 * MiB):
>          bcr = 0xfc00;
>          break;
> -    case (256 * M_BYTE):
> +    case (256 * MiB):
>          bcr = 0xf800;
>          break;
> -    case (512 * M_BYTE):
> +    case (512 * MiB):
>          bcr = 0xf000;
>          break;
> -    case (1 * G_BYTE):
> +    case (1 * GiB):
>          bcr = 0xe000;
>          break;
>      default:
> @@ -561,7 +561,7 @@ static target_ulong sdram_size(uint32_t bcr)
>      if (sh == 0) {
>          size = -1;
>      } else {
> -        size = 8 * M_BYTE * sh;
> +        size = 8 * MiB * sh;
>      }
>  
>      return size;
> diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
> index a1e7219db6..a8d26f74fc 100644
> --- a/hw/ppc/prep.c
> +++ b/hw/ppc/prep.c
> @@ -886,7 +886,7 @@ static void ibm_40p_machine_init(MachineClass *mc)
>      mc->init = ibm_40p_init;
>      mc->max_cpus = 1;
>      mc->pci_allow_0_address = true;
> -    mc->default_ram_size = 128 * M_BYTE;
> +    mc->default_ram_size = 128 * MiB;
>      mc->block_default_type = IF_SCSI;
>      mc->default_boot_order = "c";
>      mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("604");
> diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
> index bdc53d2603..2a98c10664 100644
> --- a/hw/ppc/sam460ex.c
> +++ b/hw/ppc/sam460ex.c
> @@ -597,7 +597,7 @@ static void sam460ex_machine_init(MachineClass *mc)
>      mc->desc = "aCube Sam460ex";
>      mc->init = sam460ex_init;
>      mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("460exb");
> -    mc->default_ram_size = 512 * M_BYTE;
> +    mc->default_ram_size = 512 * MiB;
>  }
>  
>  DEFINE_MACHINE("sam460ex", sam460ex_machine_init)
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 2375cbee12..3ba3bc8b6c 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -2317,7 +2317,7 @@ static void spapr_validate_node_memory(MachineState *machine, Error **errp)
>          error_setg(errp, "Memory size 0x" RAM_ADDR_FMT
>                     " is not aligned to %llu MiB",
>                     machine->ram_size,
> -                   SPAPR_MEMORY_BLOCK_SIZE / M_BYTE);
> +                   SPAPR_MEMORY_BLOCK_SIZE / MiB);
>          return;
>      }
>  
> @@ -2325,7 +2325,7 @@ static void spapr_validate_node_memory(MachineState *machine, Error **errp)
>          error_setg(errp, "Maximum memory size 0x" RAM_ADDR_FMT
>                     " is not aligned to %llu MiB",
>                     machine->ram_size,
> -                   SPAPR_MEMORY_BLOCK_SIZE / M_BYTE);
> +                   SPAPR_MEMORY_BLOCK_SIZE / MiB);
>          return;
>      }
>  
> @@ -2335,7 +2335,7 @@ static void spapr_validate_node_memory(MachineState *machine, Error **errp)
>                         "Node %d memory size 0x%" PRIx64
>                         " is not aligned to %llu MiB",
>                         i, numa_info[i].node_mem,
> -                       SPAPR_MEMORY_BLOCK_SIZE / M_BYTE);
> +                       SPAPR_MEMORY_BLOCK_SIZE / MiB);
>              return;
>          }
>      }
> @@ -3195,7 +3195,7 @@ static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>  
>      if (size % SPAPR_MEMORY_BLOCK_SIZE) {
>          error_setg(errp, "Hotplugged memory size must be a multiple of "
> -                      "%lld MB", SPAPR_MEMORY_BLOCK_SIZE / M_BYTE);
> +                      "%lld MB", SPAPR_MEMORY_BLOCK_SIZE / MiB);
>          return;
>      }
>  
> @@ -3975,7 +3975,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
>      mc->max_cpus = 1024;
>      mc->no_parallel = 1;
>      mc->default_boot_order = "";
> -    mc->default_ram_size = 512 * M_BYTE;
> +    mc->default_ram_size = 512 * MiB;
>      mc->kvm_type = spapr_kvm_type;
>      machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SPAPR_PCI_HOST_BRIDGE);
>      mc->pci_allow_0_address = true;
> diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
> index 7f9738daed..f32740b947 100644
> --- a/hw/ppc/spapr_rtas.c
> +++ b/hw/ppc/spapr_rtas.c
> @@ -241,7 +241,7 @@ static void rtas_ibm_get_system_parameter(PowerPCCPU *cpu,
>                                            "DesProcs=%d,"
>                                            "MaxPlatProcs=%d",
>                                            max_cpus,
> -                                          current_machine->ram_size / M_BYTE,
> +                                          current_machine->ram_size / MiB,
>                                            smp_cpus,
>                                            max_cpus);
>          ret = sysparm_st(buffer, length, param_val, strlen(param_val) + 1);
> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
> index 540bccb8d1..9a16b768ed 100644
> --- a/hw/sd/sd.c
> +++ b/hw/sd/sd.c
> @@ -305,7 +305,7 @@ static void sd_ocr_powerup(void *opaque)
>      /* card power-up OK */
>      sd->ocr = FIELD_DP32(sd->ocr, OCR, CARD_POWER_UP, 1);
>  
> -    if (sd->size > 1 * G_BYTE) {
> +    if (sd->size > 1 * GiB) {
>          sd->ocr = FIELD_DP32(sd->ocr, OCR, CARD_CAPACITY, 1);
>      }
>  }
> @@ -377,7 +377,7 @@ static void sd_set_csd(SDState *sd, uint64_t size)
>      uint32_t sectsize = (1 << (SECTOR_SHIFT + 1)) - 1;
>      uint32_t wpsize = (1 << (WPGROUP_SHIFT + 1)) - 1;
>  
> -    if (size <= 1 * G_BYTE) { /* Standard Capacity SD */
> +    if (size <= 1 * GiB) { /* Standard Capacity SD */
>          sd->csd[0] = 0x00;	/* CSD structure */
>          sd->csd[1] = 0x26;	/* Data read access-time-1 */
>          sd->csd[2] = 0x00;	/* Data read access-time-2 */
> diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
> index 3017e5a95a..a11e802485 100644
> --- a/hw/sd/sdhci.c
> +++ b/hw/sd/sdhci.c
> @@ -414,7 +414,7 @@ static void sdhci_end_transfer(SDHCIState *s)
>  /*
>   * Programmed i/o data transfer
>   */
> -#define BLOCK_SIZE_MASK (4 * K_BYTE - 1)
> +#define BLOCK_SIZE_MASK (4 * KiB - 1)
>  
>  /* Fill host controller's read buffer with BLKSIZE bytes of data from card */
>  static void sdhci_read_block_from_card(SDHCIState *s)
> diff --git a/tests/test-cutils.c b/tests/test-cutils.c
> index 64a489c2e9..ee543ac4bf 100644
> --- a/tests/test-cutils.c
> +++ b/tests/test-cutils.c
> @@ -2022,7 +2022,7 @@ static void test_qemu_strtosz_units(void)
>      /* default is M */
>      err = qemu_strtosz_MiB(none, &endptr, &res);
>      g_assert_cmpint(err, ==, 0);
> -    g_assert_cmpint(res, ==, M_BYTE);
> +    g_assert_cmpint(res, ==, MiB);
>      g_assert(endptr == none + 1);
>  
>      err = qemu_strtosz(b, &endptr, &res);
> @@ -2032,32 +2032,32 @@ static void test_qemu_strtosz_units(void)
>  
>      err = qemu_strtosz(k, &endptr, &res);
>      g_assert_cmpint(err, ==, 0);
> -    g_assert_cmpint(res, ==, K_BYTE);
> +    g_assert_cmpint(res, ==, KiB);
>      g_assert(endptr == k + 2);
>  
>      err = qemu_strtosz(m, &endptr, &res);
>      g_assert_cmpint(err, ==, 0);
> -    g_assert_cmpint(res, ==, M_BYTE);
> +    g_assert_cmpint(res, ==, MiB);
>      g_assert(endptr == m + 2);
>  
>      err = qemu_strtosz(g, &endptr, &res);
>      g_assert_cmpint(err, ==, 0);
> -    g_assert_cmpint(res, ==, G_BYTE);
> +    g_assert_cmpint(res, ==, GiB);
>      g_assert(endptr == g + 2);
>  
>      err = qemu_strtosz(t, &endptr, &res);
>      g_assert_cmpint(err, ==, 0);
> -    g_assert_cmpint(res, ==, T_BYTE);
> +    g_assert_cmpint(res, ==, TiB);
>      g_assert(endptr == t + 2);
>  
>      err = qemu_strtosz(p, &endptr, &res);
>      g_assert_cmpint(err, ==, 0);
> -    g_assert_cmpint(res, ==, P_BYTE);
> +    g_assert_cmpint(res, ==, PiB);
>      g_assert(endptr == p + 2);
>  
>      err = qemu_strtosz(e, &endptr, &res);
>      g_assert_cmpint(err, ==, 0);
> -    g_assert_cmpint(res, ==, E_BYTE);
> +    g_assert_cmpint(res, ==, EiB);
>      g_assert(endptr == e + 2);
>  }
>  
> @@ -2070,7 +2070,7 @@ static void test_qemu_strtosz_float(void)
>  
>      err = qemu_strtosz(str, &endptr, &res);
>      g_assert_cmpint(err, ==, 0);
> -    g_assert_cmpint(res, ==, 12.345 * M_BYTE);
> +    g_assert_cmpint(res, ==, 12.345 * MiB);
>      g_assert(endptr == str + 7);
>  }
>  
> @@ -2106,7 +2106,7 @@ static void test_qemu_strtosz_trailing(void)
>  
>      str = "123xxx";
>      err = qemu_strtosz_MiB(str, &endptr, &res);
> -    g_assert_cmpint(res, ==, 123 * M_BYTE);
> +    g_assert_cmpint(res, ==, 123 * MiB);
>      g_assert(endptr == str + 3);
>  
>      err = qemu_strtosz(str, NULL, &res);
> diff --git a/tests/test-keyval.c b/tests/test-keyval.c
> index 63cb14629b..92d8e9fa89 100644
> --- a/tests/test-keyval.c
> +++ b/tests/test-keyval.c
> @@ -457,11 +457,11 @@ static void test_keyval_visit_size(void)
>      visit_type_size(v, "sz2", &sz, &error_abort);
>      g_assert_cmpuint(sz, ==, 1536);
>      visit_type_size(v, "sz3", &sz, &error_abort);
> -    g_assert_cmphex(sz, ==, 2 * M_BYTE);
> +    g_assert_cmphex(sz, ==, 2 * MiB);
>      visit_type_size(v, "sz4", &sz, &error_abort);
> -    g_assert_cmphex(sz, ==, G_BYTE / 10);
> +    g_assert_cmphex(sz, ==, GiB / 10);
>      visit_type_size(v, "sz5", &sz, &error_abort);
> -    g_assert_cmphex(sz, ==, 16777215 * T_BYTE);
> +    g_assert_cmphex(sz, ==, 16777215 * TiB);
>      visit_check_struct(v, &error_abort);
>      visit_end_struct(v, NULL);
>      visit_free(v);
> diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c
> index 7092e216f7..7074a176d7 100644
> --- a/tests/test-qemu-opts.c
> +++ b/tests/test-qemu-opts.c
> @@ -704,13 +704,12 @@ static void test_opts_parse_size(void)
>      g_assert_cmpuint(opts_count(opts), ==, 3);
>      g_assert_cmphex(qemu_opt_get_size(opts, "size1", 0), ==, 8);
>      g_assert_cmphex(qemu_opt_get_size(opts, "size2", 0), ==, 1536);
> -    g_assert_cmphex(qemu_opt_get_size(opts, "size3", 0), ==, 2 * M_BYTE);
> +    g_assert_cmphex(qemu_opt_get_size(opts, "size3", 0), ==, 2 * MiB);
>      opts = qemu_opts_parse(&opts_list_02, "size1=0.1G,size2=16777215T",
>                             false, &error_abort);
>      g_assert_cmpuint(opts_count(opts), ==, 2);
> -    g_assert_cmphex(qemu_opt_get_size(opts, "size1", 0), ==, G_BYTE / 10);
> -    g_assert_cmphex(qemu_opt_get_size(opts, "size2", 0),
> -                     ==, 16777215 * T_BYTE);
> +    g_assert_cmphex(qemu_opt_get_size(opts, "size1", 0), ==, GiB / 10);
> +    g_assert_cmphex(qemu_opt_get_size(opts, "size2", 0), ==, 16777215 * TiB);
>  
>      /* Beyond limit with suffix */
>      opts = qemu_opts_parse(&opts_list_02, "size1=16777216T",

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 06/40] hw: Directly use "qemu/units.h" instead of "qemu/cutils.h"
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 06/40] hw: Directly use "qemu/units.h" instead of "qemu/cutils.h" Philippe Mathieu-Daudé
@ 2018-06-11  2:16   ` David Gibson
  0 siblings, 0 replies; 70+ messages in thread
From: David Gibson @ 2018-06-11  2:16 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Thomas Huth, Stefan Weil, qemu-devel, qemu-trivial,
	Subbaraya Sundeep, Peter Maydell, Eduardo Habkost,
	Marcel Apfelbaum, Paul Burton, Aurelien Jarno, Yongbok Kim,
	Alexander Graf, open list:ARM, open list:PowerPC

[-- Attachment #1: Type: text/plain, Size: 4193 bytes --]

On Sun, Jun 10, 2018 at 10:14:27PM -0300, Philippe Mathieu-Daudé wrote:
> These files don't use anything exposed by "qemu/cutils.h",
> simplify preprocessing including directly "qemu/units.h".
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

ppc parts
Acked-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  hw/arm/msf2-soc.c  | 2 +-
>  hw/arm/msf2-som.c  | 2 +-
>  hw/core/machine.c  | 2 +-
>  hw/display/sm501.c | 2 +-
>  hw/mips/boston.c   | 2 +-
>  hw/ppc/pnv.c       | 2 +-
>  hw/ppc/ppc440_uc.c | 2 +-
>  7 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
> index 530e461c42..edb3ba824f 100644
> --- a/hw/arm/msf2-soc.c
> +++ b/hw/arm/msf2-soc.c
> @@ -23,13 +23,13 @@
>   */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "qapi/error.h"
>  #include "qemu-common.h"
>  #include "hw/arm/arm.h"
>  #include "exec/address-spaces.h"
>  #include "hw/char/serial.h"
>  #include "hw/boards.h"
> -#include "qemu/cutils.h"
>  #include "hw/arm/msf2-soc.h"
>  #include "hw/misc/unimp.h"
>  
> diff --git a/hw/arm/msf2-som.c b/hw/arm/msf2-som.c
> index ed533bbde1..2432b5e935 100644
> --- a/hw/arm/msf2-som.c
> +++ b/hw/arm/msf2-som.c
> @@ -23,12 +23,12 @@
>   */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "qapi/error.h"
>  #include "qemu/error-report.h"
>  #include "hw/boards.h"
>  #include "hw/arm/arm.h"
>  #include "exec/address-spaces.h"
> -#include "qemu/cutils.h"
>  #include "hw/arm/msf2-soc.h"
>  #include "cpu.h"
>  
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index ccf3a4b9c7..2077328bcc 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -11,6 +11,7 @@
>   */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "hw/boards.h"
>  #include "qapi/error.h"
>  #include "qapi/qapi-visit-common.h"
> @@ -19,7 +20,6 @@
>  #include "sysemu/sysemu.h"
>  #include "sysemu/numa.h"
>  #include "qemu/error-report.h"
> -#include "qemu/cutils.h"
>  #include "sysemu/qtest.h"
>  
>  static char *machine_get_accel(Object *obj, Error **errp)
> diff --git a/hw/display/sm501.c b/hw/display/sm501.c
> index 1c6c9445c5..bbb9274886 100644
> --- a/hw/display/sm501.c
> +++ b/hw/display/sm501.c
> @@ -24,7 +24,7 @@
>   */
>  
>  #include "qemu/osdep.h"
> -#include "qemu/cutils.h"
> +#include "qemu/units.h"
>  #include "qapi/error.h"
>  #include "qemu-common.h"
>  #include "cpu.h"
> diff --git a/hw/mips/boston.c b/hw/mips/boston.c
> index 512c60c03e..b7bfeccf4c 100644
> --- a/hw/mips/boston.c
> +++ b/hw/mips/boston.c
> @@ -18,6 +18,7 @@
>   */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "qemu-common.h"
>  
>  #include "exec/address-spaces.h"
> @@ -32,7 +33,6 @@
>  #include "hw/mips/cpudevs.h"
>  #include "hw/pci-host/xilinx-pcie.h"
>  #include "qapi/error.h"
> -#include "qemu/cutils.h"
>  #include "qemu/error-report.h"
>  #include "qemu/log.h"
>  #include "chardev/char.h"
> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
> index bdb6f63d2c..0df4a4fd74 100644
> --- a/hw/ppc/pnv.c
> +++ b/hw/ppc/pnv.c
> @@ -18,6 +18,7 @@
>   */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "qapi/error.h"
>  #include "sysemu/sysemu.h"
>  #include "sysemu/numa.h"
> @@ -31,7 +32,6 @@
>  #include "hw/ppc/pnv_core.h"
>  #include "hw/loader.h"
>  #include "exec/address-spaces.h"
> -#include "qemu/cutils.h"
>  #include "qapi/visitor.h"
>  #include "monitor/monitor.h"
>  #include "hw/intc/intc.h"
> diff --git a/hw/ppc/ppc440_uc.c b/hw/ppc/ppc440_uc.c
> index b5b31b4b9b..1ab2235f20 100644
> --- a/hw/ppc/ppc440_uc.c
> +++ b/hw/ppc/ppc440_uc.c
> @@ -9,8 +9,8 @@
>   */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "qemu-common.h"
> -#include "qemu/cutils.h"
>  #include "qemu/error-report.h"
>  #include "qapi/error.h"
>  #include "cpu.h"

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 33/40] hw/i386: Use the IEC binary prefix definitions
       [not found] ` <20180611011501.10235-34-f4bug@amsat.org>
@ 2018-06-11  2:18   ` Michael S. Tsirkin
  2018-06-11  2:29     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 70+ messages in thread
From: Michael S. Tsirkin @ 2018-06-11  2:18 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Thomas Huth, Stefan Weil, qemu-devel, qemu-trivial,
	Igor Mammedov, Marcel Apfelbaum, Paolo Bonzini,
	Richard Henderson, Eduardo Habkost

On Sun, Jun 10, 2018 at 10:14:54PM -0300, Philippe Mathieu-Daudé wrote:
> @@ -1392,11 +1393,11 @@ void pc_memory_init(PCMachineState *pcms,
>          }
>  
>          machine->device_memory->base =
> -            ROUND_UP(0x100000000ULL + pcms->above_4g_mem_size, 1ULL << 30);
> +            ROUND_UP(0x100000000ULL + pcms->above_4g_mem_size, GiB);
>  


For some reason, GiB got special treatment. Why not 1* GiB?

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (38 preceding siblings ...)
       [not found] ` <20180611011501.10235-34-f4bug@amsat.org>
@ 2018-06-11  2:22 ` Michael S. Tsirkin
  2018-06-11  2:32   ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
  2018-06-11 15:55 ` [Qemu-devel] " Eric Blake
  2018-06-11 16:18 ` Cornelia Huck
  41 siblings, 1 reply; 70+ messages in thread
From: Michael S. Tsirkin @ 2018-06-11  2:22 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Thomas Huth, Stefan Weil, Nikunj A Dadhania, qemu-arm,
	qemu-block, qemu-devel, qemu-ppc, qemu-s390x, qemu-trivial,
	Fabien Chouteau, Alistair Francis, Aurelien Jarno,
	Anthony Perard, Christian Borntraeger, Marek Vasut,
	Sagar Karandikar, David Gibson, Antony Pavlov, Artyom Tarasenko,
	Andrzej Zaborowski, Beniamino Galvani, Peter Crosthwaite,
	Chris Wulff, Dmitry Fleytman, Edgar E . Iglesias, Igor Mitsyanko,
	Max Filippov, Magnus Damm, Marcel Apfelbaum, Subbaraya Sundeep,
	Alberto Garcia, Mark Cave-Ayland, Keith Busch,
	Stefano Stabellini, Peter Maydell, Stefan Berger,
	Bastian Koppelmann, Paul Burton, Yongbok Kim, Peter Chubb,
	Yuval Shaia, Hervé Poussineau, Alex Williamson,
	Markus Armbruster, Cornelia Huck, David Hildenbrand, Eric Blake,
	Eduardo Habkost, Fam Zheng, Igor Mammedov, Jason Wang,
	Gerd Hoffmann, Kevin Wolf, Max Reitz, Paolo Bonzini,
	Michael Clark, Palmer Dabbelt, Jiri Slaby, Alexander Graf,
	Richard Henderson, Michael Walle, Jan Kiszka

On Sun, Jun 10, 2018 at 10:14:21PM -0300, Philippe Mathieu-Daudé wrote:
> Hi,
> 
> This series:
> 
> - split the byte-based definitions from "qemu/cutils.h" to "qemu/units.h"
>   (this now triggers WARNING: 1 added file, does MAINTAINERS need updating?)
> - clean hw/ includes;
> - replace different constants used for byte size with their corresponding
>   IEC binary prefix definitions.
> 
> Since v3:
> - use IEC binary prefix definitions (Stefan Weil)
> - rebased
> - added R-b tags

It violates our coding style which requires KIB for macros.
But strangely, I like how this looks anyway.

So series

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>


but I think you need to update the coding style explaining
that there's an exception.

> Since v2:
> - use "qemu/units.h" instead of "qemu/cunits.h" (Daniel P. Berrangé)
> - avoid rebuilding the world including "qemu/units.h" in "hw/hw.h" (Thomas Huth)
> - more constant replaced
> 
> Since v1:
> - corrected Xen mult -> div (Alan Robinson)
> - tagged 'include "qemu/cunits.h" in "hw/hw.h" as RFC
> - fixed mips_r4k 'params_size' (Thomas Huth)
> - added command used to generate patch in each commit (Alistair Francis)
> - use G_BYTE for the raspi3 machine
> - added Reviewed-by tags
> 
> Regards,
> 
> Phil.
> 
> Philippe Mathieu-Daudé (40):
>   include: Add IEC binary prefixes in "qemu/units.h"
>   vdi: Use definitions from "qemu/units.h"
>   x86/cpu: Use definitions from "qemu/units.h"
>   checkpatch: Recognize IEC binary prefix definitions
>   hw: Use IEC binary prefix definitions from "qemu/units.h"
>   hw: Directly use "qemu/units.h" instead of "qemu/cutils.h"
>   hw/ivshmem: Use the IEC binary prefix definitions
>   hw/ipack: Use the IEC binary prefix definitions
>   hw/scsi: Use the IEC binary prefix definitions
>   hw/smbios: Use the IEC binary prefix definitions
>   hw/xen: Use the IEC binary prefix definitions
>   hw/tpm: Use the IEC binary prefix definitions
>   hw/block: Use the IEC binary prefix definitions
>   hw/display: Use the IEC binary prefix definitions
>   hw/misc: Use the IEC binary prefix definitions
>   hw/riscv: Use the IEC binary prefix definitions
>   hw/m68k: Use the IEC binary prefix definitions
>   hw/sparc: Use the IEC binary prefix definitions
>   hw/s390x: Use the IEC binary prefix definitions
>   hw/hppa: Use the IEC binary prefix definitions
>   hw/xtensa: Use the IEC binary prefix definitions
>   hw/alpha: Use the IEC binary prefix definitions
>   hw/tricore: Use the IEC binary prefix definitions
>   hw/microblaze: Use the IEC binary prefix definitions
>   hw/nios2: Use the IEC binary prefix definitions
>   hw/cris: Use the IEC binary prefix definitions
>   hw/lm32: Use the IEC binary prefix definitions
>   hw/sh4: Use the IEC binary prefix definitions
>   hw/mips/r4k: Constify params_size
>   hw/mips: Use the IEC binary prefix definitions
>   hw/arm: Use the IEC binary prefix definitions
>   hw/ppc: Use the IEC binary prefix definitions
>   hw/i386: Use the IEC binary prefix definitions
>   hw/net: Use the IEC binary prefix definitions
>   hw/usb: Use the IEC binary prefix definitions
>   hw/sd: Use the IEC binary prefix definitions
>   hw/vfio: Use the IEC binary prefix definitions
>   hw/virtio: Use the IEC binary prefix definitions
>   hw/rdma: Use the IEC binary prefix definitions
>   cutils: Do not include "qemu/units.h" directly
> 
>  hw/net/ne2000.h                          |  5 ++--
>  hw/ppc/mac.h                             |  3 ++-
>  hw/rdma/vmw/pvrdma.h                     |  3 ++-
>  include/hw/acpi/tpm.h                    |  3 ++-
>  include/hw/arm/fsl-imx7.h                |  5 ++--
>  include/hw/arm/stm32f205_soc.h           |  5 ++--
>  include/hw/display/xlnx_dp.h             |  5 ++--
>  include/hw/i386/ich9.h                   |  3 ++-
>  include/hw/intc/mips_gic.h               |  3 ++-
>  include/hw/mips/bios.h                   |  3 ++-
>  include/hw/net/allwinner_emac.h          |  5 ++--
>  include/hw/ppc/spapr.h                   |  5 ++--
>  include/hw/virtio/virtio-net.h           |  3 ++-
>  include/qemu/cutils.h                    |  7 ------
>  include/qemu/units.h                     | 20 ++++++++++++++++
>  block/vdi.c                              |  8 +++----
>  hw/alpha/typhoon.c                       | 17 +++++++-------
>  hw/arm/bcm2835_peripherals.c             |  3 ++-
>  hw/arm/boot.c                            |  7 +++---
>  hw/arm/collie.c                          |  5 ++--
>  hw/arm/digic_boards.c                    |  7 +++---
>  hw/arm/exynos4_boards.c                  |  3 ++-
>  hw/arm/gumstix.c                         |  3 ++-
>  hw/arm/integratorcp.c                    |  3 ++-
>  hw/arm/mainstone.c                       |  3 ++-
>  hw/arm/msf2-soc.c                        |  6 ++---
>  hw/arm/msf2-som.c                        |  8 +++----
>  hw/arm/musicpal.c                        |  9 +++----
>  hw/arm/omap_sx1.c                        | 11 +++++----
>  hw/arm/raspi.c                           |  5 ++--
>  hw/arm/smmu-common.c                     |  3 ++-
>  hw/arm/stellaris.c                       |  5 ++--
>  hw/arm/versatilepb.c                     |  5 ++--
>  hw/arm/vexpress.c                        |  7 +++---
>  hw/arm/virt.c                            |  5 ++--
>  hw/arm/xilinx_zynq.c                     |  7 +++---
>  hw/block/m25p80.c                        |  5 ++--
>  hw/block/nvme.c                          |  3 ++-
>  hw/block/tc58128.c                       |  3 ++-
>  hw/block/xen_disk.c                      |  5 ++--
>  hw/core/loader-fit.c                     |  3 ++-
>  hw/core/machine.c                        |  4 ++--
>  hw/cris/axis_dev88.c                     |  3 ++-
>  hw/display/bochs-display.c               |  9 +++----
>  hw/display/cirrus_vga.c                  | 10 ++++----
>  hw/display/g364fb.c                      |  4 ++--
>  hw/display/qxl.c                         | 28 ++++++++++------------
>  hw/display/sm501.c                       | 16 ++++++-------
>  hw/display/vga-isa-mm.c                  |  5 ++--
>  hw/display/vga.c                         |  5 ++--
>  hw/display/virtio-gpu.c                  |  4 ++--
>  hw/display/vmware_vga.c                  |  3 ++-
>  hw/display/xenfb.c                       |  3 ++-
>  hw/hppa/dino.c                           |  3 ++-
>  hw/hppa/machine.c                        | 12 +++++-----
>  hw/i386/acpi-build.c                     |  5 ++--
>  hw/i386/pc.c                             | 19 ++++++++-------
>  hw/i386/pc_piix.c                        |  4 ++--
>  hw/i386/pc_q35.c                         |  3 ++-
>  hw/i386/pc_sysfw.c                       |  9 +++----
>  hw/i386/xen/xen-mapcache.c               |  3 ++-
>  hw/intc/apic_common.c                    |  3 ++-
>  hw/ipack/tpci200.c                       |  5 ++--
>  hw/lm32/lm32_boards.c                    | 13 +++++-----
>  hw/lm32/milkymist.c                      | 10 ++++----
>  hw/m68k/mcf5208.c                        |  3 ++-
>  hw/microblaze/petalogix_ml605_mmu.c      |  7 +++---
>  hw/microblaze/petalogix_s3adsp1800_mmu.c |  7 +++---
>  hw/mips/boston.c                         | 30 ++++++++++++------------
>  hw/mips/mips_fulong2e.c                  |  7 +++---
>  hw/mips/mips_malta.c                     | 23 ++++++++++--------
>  hw/mips/mips_r4k.c                       | 15 ++++++------
>  hw/misc/aspeed_sdmc.c                    |  9 +++----
>  hw/misc/auxbus.c                         |  3 ++-
>  hw/misc/edu.c                            |  3 ++-
>  hw/misc/imx7_gpr.c                       |  3 ++-
>  hw/misc/ivshmem.c                        |  3 ++-
>  hw/misc/mips_itu.c                       |  3 ++-
>  hw/misc/omap_gpmc.c                      |  5 ++--
>  hw/net/e1000e.c                          |  7 +++---
>  hw/net/e1000x_common.c                   |  3 ++-
>  hw/net/eepro100.c                        |  3 +--
>  hw/nios2/boot.c                          |  6 ++---
>  hw/nvram/spapr_nvram.c                   | 10 ++++----
>  hw/pci-host/designware.c                 |  3 ++-
>  hw/pci-host/gpex.c                       |  3 ++-
>  hw/pci-host/piix.c                       |  5 ++--
>  hw/pci-host/prep.c                       |  3 ++-
>  hw/pci-host/q35.c                        | 17 +++++++-------
>  hw/pci-host/xilinx-pcie.c                |  5 ++--
>  hw/ppc/e500.c                            | 13 +++++-----
>  hw/ppc/e500plat.c                        |  3 ++-
>  hw/ppc/mac_newworld.c                    |  1 -
>  hw/ppc/mac_oldworld.c                    |  9 ++++---
>  hw/ppc/pnv.c                             |  6 ++---
>  hw/ppc/ppc405_boards.c                   |  9 +++----
>  hw/ppc/ppc405_uc.c                       |  7 +++---
>  hw/ppc/ppc440_bamboo.c                   |  6 +++--
>  hw/ppc/ppc440_uc.c                       | 28 +++++++++++-----------
>  hw/ppc/ppc4xx_devs.c                     | 22 +++++++++--------
>  hw/ppc/ppce500_spin.c                    |  3 ++-
>  hw/ppc/prep.c                            |  6 ++---
>  hw/ppc/rs6000_mc.c                       | 13 +++++-----
>  hw/ppc/sam460ex.c                        | 20 +++++++++-------
>  hw/ppc/spapr.c                           | 12 +++++-----
>  hw/ppc/spapr_rtas.c                      |  2 +-
>  hw/ppc/virtex_ml507.c                    |  7 +++---
>  hw/riscv/virt.c                          |  3 ++-
>  hw/s390x/s390-skeys.c                    |  3 ++-
>  hw/s390x/s390-stattrib.c                 |  3 ++-
>  hw/s390x/sclp.c                          |  4 ++--
>  hw/scsi/scsi-disk.c                      |  9 +++----
>  hw/sd/sd.c                               |  8 +++----
>  hw/sd/sdhci.c                            |  6 ++---
>  hw/sh4/r2d.c                             |  3 ++-
>  hw/smbios/smbios.c                       | 15 +++++-------
>  hw/sparc/leon3.c                         |  9 +++----
>  hw/sparc/sun4m.c                         |  9 ++++---
>  hw/sparc64/niagara.c                     |  3 ++-
>  hw/sparc64/sun4u.c                       |  4 ++--
>  hw/ssi/aspeed_smc.c                      | 29 ++++++++++++-----------
>  hw/tricore/tricore_testboard.c           | 13 +++++-----
>  hw/usb/ccid-card-passthru.c              |  5 ++--
>  hw/usb/combined-packet.c                 |  3 ++-
>  hw/usb/dev-smartcard-reader.c            |  3 ++-
>  hw/usb/redirect.c                        |  3 ++-
>  hw/vfio/pci-quirks.c                     |  9 +++----
>  hw/vfio/pci.c                            |  3 ++-
>  hw/xenpv/xen_domainbuild.c               | 13 +++++-----
>  hw/xtensa/xtfpga.c                       |  5 ++--
>  target/i386/cpu.c                        |  4 +---
>  tests/test-cutils.c                      | 18 +++++++-------
>  tests/test-keyval.c                      |  6 ++---
>  tests/test-qemu-opts.c                   |  7 +++---
>  scripts/checkpatch.pl                    |  1 +
>  135 files changed, 533 insertions(+), 431 deletions(-)
>  create mode 100644 include/qemu/units.h
> 
> -- 
> 2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 33/40] hw/i386: Use the IEC binary prefix definitions
  2018-06-11  2:18   ` [Qemu-devel] [PATCH v4 33/40] hw/i386: Use the IEC binary prefix definitions Michael S. Tsirkin
@ 2018-06-11  2:29     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  2:29 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Thomas Huth, Eduardo Habkost, qemu-trivial, Stefan Weil,
	qemu-devel, Paolo Bonzini, Igor Mammedov, Richard Henderson

On 06/10/2018 11:18 PM, Michael S. Tsirkin wrote:
> On Sun, Jun 10, 2018 at 10:14:54PM -0300, Philippe Mathieu-Daudé wrote:
>> @@ -1392,11 +1393,11 @@ void pc_memory_init(PCMachineState *pcms,
>>          }
>>  
>>          machine->device_memory->base =
>> -            ROUND_UP(0x100000000ULL + pcms->above_4g_mem_size, 1ULL << 30);
>> +            ROUND_UP(0x100000000ULL + pcms->above_4g_mem_size, GiB);
>>  
> 
> 
> For some reason, GiB got special treatment. Why not 1* GiB?

Oops I didn't notice, I really prefer "1 * GiB" too.

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [Qemu-arm] [PATCH v4 00/40] Use the IEC binary prefix definitions
  2018-06-11  2:22 ` [Qemu-devel] [PATCH v4 00/40] " Michael S. Tsirkin
@ 2018-06-11  2:32   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11  2:32 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Peter Maydell, Dmitry Fleytman, Jan Kiszka, Sagar Karandikar,
	David Hildenbrand, Jason Wang, Palmer Dabbelt, Mark Cave-Ayland,
	qemu-devel, Alexander Graf, Keith Busch, Max Filippov,
	Michael Clark, Gerd Hoffmann, Max Reitz, Yongbok Kim,
	Marek Vasut, Stefano Stabellini, Alberto Garcia, qemu-block,
	Stefan Berger, qemu-trivial, Eric Blake, Magnus Damm,
	Markus Armbruster, Michael Walle, Christian Borntraeger,
	Hervé Poussineau, Antony Pavlov, Marcel Apfelbaum,
	Anthony Perard, Richard Henderson, Andrzej Zaborowski,
	Artyom Tarasenko, Thomas Huth, Fam Zheng, Eduardo Habkost,
	Nikunj A Dadhania, Stefan Weil, Alistair Francis,
	Fabien Chouteau, Beniamino Galvani, qemu-s390x, qemu-arm,
	Peter Chubb, Yuval Shaia, Paolo Bonzini, Jiri Slaby,
	David Gibson, Kevin Wolf, Igor Mitsyanko, Bastian Koppelmann,
	Chris Wulff, Alex Williamson, Subbaraya Sundeep, Paul Burton,
	qemu-ppc, Cornelia Huck, Igor Mammedov, Aurelien Jarno

On 06/10/2018 11:22 PM, Michael S. Tsirkin wrote:
> On Sun, Jun 10, 2018 at 10:14:21PM -0300, Philippe Mathieu-Daudé wrote:
>> Hi,
>>
>> This series:
>>
>> - split the byte-based definitions from "qemu/cutils.h" to "qemu/units.h"
>>   (this now triggers WARNING: 1 added file, does MAINTAINERS need updating?)
>> - clean hw/ includes;
>> - replace different constants used for byte size with their corresponding
>>   IEC binary prefix definitions.
>>
>> Since v3:
>> - use IEC binary prefix definitions (Stefan Weil)
>> - rebased
>> - added R-b tags
> 
> It violates our coding style which requires KIB for macros.
> But strangely, I like how this looks anyway.

Each use this saves 3 char of the 80 columns limit!

> 
> So series
> 
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>

Thanks!

> 
> 
> but I think you need to update the coding style explaining
> that there's an exception.

OK, if there is no NACK/negative comment I'll simply add a patch
Based-on this series.

> 
>> Since v2:
>> - use "qemu/units.h" instead of "qemu/cunits.h" (Daniel P. Berrangé)
>> - avoid rebuilding the world including "qemu/units.h" in "hw/hw.h" (Thomas Huth)
>> - more constant replaced
>>
>> Since v1:
>> - corrected Xen mult -> div (Alan Robinson)
>> - tagged 'include "qemu/cunits.h" in "hw/hw.h" as RFC
>> - fixed mips_r4k 'params_size' (Thomas Huth)
>> - added command used to generate patch in each commit (Alistair Francis)
>> - use G_BYTE for the raspi3 machine
>> - added Reviewed-by tags
>>
>> Regards,
>>
>> Phil.
>>
>> Philippe Mathieu-Daudé (40):
>>   include: Add IEC binary prefixes in "qemu/units.h"
>>   vdi: Use definitions from "qemu/units.h"
>>   x86/cpu: Use definitions from "qemu/units.h"
>>   checkpatch: Recognize IEC binary prefix definitions
>>   hw: Use IEC binary prefix definitions from "qemu/units.h"
>>   hw: Directly use "qemu/units.h" instead of "qemu/cutils.h"
>>   hw/ivshmem: Use the IEC binary prefix definitions
>>   hw/ipack: Use the IEC binary prefix definitions
>>   hw/scsi: Use the IEC binary prefix definitions
>>   hw/smbios: Use the IEC binary prefix definitions
>>   hw/xen: Use the IEC binary prefix definitions
>>   hw/tpm: Use the IEC binary prefix definitions
>>   hw/block: Use the IEC binary prefix definitions
>>   hw/display: Use the IEC binary prefix definitions
>>   hw/misc: Use the IEC binary prefix definitions
>>   hw/riscv: Use the IEC binary prefix definitions
>>   hw/m68k: Use the IEC binary prefix definitions
>>   hw/sparc: Use the IEC binary prefix definitions
>>   hw/s390x: Use the IEC binary prefix definitions
>>   hw/hppa: Use the IEC binary prefix definitions
>>   hw/xtensa: Use the IEC binary prefix definitions
>>   hw/alpha: Use the IEC binary prefix definitions
>>   hw/tricore: Use the IEC binary prefix definitions
>>   hw/microblaze: Use the IEC binary prefix definitions
>>   hw/nios2: Use the IEC binary prefix definitions
>>   hw/cris: Use the IEC binary prefix definitions
>>   hw/lm32: Use the IEC binary prefix definitions
>>   hw/sh4: Use the IEC binary prefix definitions
>>   hw/mips/r4k: Constify params_size
>>   hw/mips: Use the IEC binary prefix definitions
>>   hw/arm: Use the IEC binary prefix definitions
>>   hw/ppc: Use the IEC binary prefix definitions
>>   hw/i386: Use the IEC binary prefix definitions
>>   hw/net: Use the IEC binary prefix definitions
>>   hw/usb: Use the IEC binary prefix definitions
>>   hw/sd: Use the IEC binary prefix definitions
>>   hw/vfio: Use the IEC binary prefix definitions
>>   hw/virtio: Use the IEC binary prefix definitions
>>   hw/rdma: Use the IEC binary prefix definitions
>>   cutils: Do not include "qemu/units.h" directly
>>
>>  hw/net/ne2000.h                          |  5 ++--
>>  hw/ppc/mac.h                             |  3 ++-
>>  hw/rdma/vmw/pvrdma.h                     |  3 ++-
>>  include/hw/acpi/tpm.h                    |  3 ++-
>>  include/hw/arm/fsl-imx7.h                |  5 ++--
>>  include/hw/arm/stm32f205_soc.h           |  5 ++--
>>  include/hw/display/xlnx_dp.h             |  5 ++--
>>  include/hw/i386/ich9.h                   |  3 ++-
>>  include/hw/intc/mips_gic.h               |  3 ++-
>>  include/hw/mips/bios.h                   |  3 ++-
>>  include/hw/net/allwinner_emac.h          |  5 ++--
>>  include/hw/ppc/spapr.h                   |  5 ++--
>>  include/hw/virtio/virtio-net.h           |  3 ++-
>>  include/qemu/cutils.h                    |  7 ------
>>  include/qemu/units.h                     | 20 ++++++++++++++++
>>  block/vdi.c                              |  8 +++----
>>  hw/alpha/typhoon.c                       | 17 +++++++-------
>>  hw/arm/bcm2835_peripherals.c             |  3 ++-
>>  hw/arm/boot.c                            |  7 +++---
>>  hw/arm/collie.c                          |  5 ++--
>>  hw/arm/digic_boards.c                    |  7 +++---
>>  hw/arm/exynos4_boards.c                  |  3 ++-
>>  hw/arm/gumstix.c                         |  3 ++-
>>  hw/arm/integratorcp.c                    |  3 ++-
>>  hw/arm/mainstone.c                       |  3 ++-
>>  hw/arm/msf2-soc.c                        |  6 ++---
>>  hw/arm/msf2-som.c                        |  8 +++----
>>  hw/arm/musicpal.c                        |  9 +++----
>>  hw/arm/omap_sx1.c                        | 11 +++++----
>>  hw/arm/raspi.c                           |  5 ++--
>>  hw/arm/smmu-common.c                     |  3 ++-
>>  hw/arm/stellaris.c                       |  5 ++--
>>  hw/arm/versatilepb.c                     |  5 ++--
>>  hw/arm/vexpress.c                        |  7 +++---
>>  hw/arm/virt.c                            |  5 ++--
>>  hw/arm/xilinx_zynq.c                     |  7 +++---
>>  hw/block/m25p80.c                        |  5 ++--
>>  hw/block/nvme.c                          |  3 ++-
>>  hw/block/tc58128.c                       |  3 ++-
>>  hw/block/xen_disk.c                      |  5 ++--
>>  hw/core/loader-fit.c                     |  3 ++-
>>  hw/core/machine.c                        |  4 ++--
>>  hw/cris/axis_dev88.c                     |  3 ++-
>>  hw/display/bochs-display.c               |  9 +++----
>>  hw/display/cirrus_vga.c                  | 10 ++++----
>>  hw/display/g364fb.c                      |  4 ++--
>>  hw/display/qxl.c                         | 28 ++++++++++------------
>>  hw/display/sm501.c                       | 16 ++++++-------
>>  hw/display/vga-isa-mm.c                  |  5 ++--
>>  hw/display/vga.c                         |  5 ++--
>>  hw/display/virtio-gpu.c                  |  4 ++--
>>  hw/display/vmware_vga.c                  |  3 ++-
>>  hw/display/xenfb.c                       |  3 ++-
>>  hw/hppa/dino.c                           |  3 ++-
>>  hw/hppa/machine.c                        | 12 +++++-----
>>  hw/i386/acpi-build.c                     |  5 ++--
>>  hw/i386/pc.c                             | 19 ++++++++-------
>>  hw/i386/pc_piix.c                        |  4 ++--
>>  hw/i386/pc_q35.c                         |  3 ++-
>>  hw/i386/pc_sysfw.c                       |  9 +++----
>>  hw/i386/xen/xen-mapcache.c               |  3 ++-
>>  hw/intc/apic_common.c                    |  3 ++-
>>  hw/ipack/tpci200.c                       |  5 ++--
>>  hw/lm32/lm32_boards.c                    | 13 +++++-----
>>  hw/lm32/milkymist.c                      | 10 ++++----
>>  hw/m68k/mcf5208.c                        |  3 ++-
>>  hw/microblaze/petalogix_ml605_mmu.c      |  7 +++---
>>  hw/microblaze/petalogix_s3adsp1800_mmu.c |  7 +++---
>>  hw/mips/boston.c                         | 30 ++++++++++++------------
>>  hw/mips/mips_fulong2e.c                  |  7 +++---
>>  hw/mips/mips_malta.c                     | 23 ++++++++++--------
>>  hw/mips/mips_r4k.c                       | 15 ++++++------
>>  hw/misc/aspeed_sdmc.c                    |  9 +++----
>>  hw/misc/auxbus.c                         |  3 ++-
>>  hw/misc/edu.c                            |  3 ++-
>>  hw/misc/imx7_gpr.c                       |  3 ++-
>>  hw/misc/ivshmem.c                        |  3 ++-
>>  hw/misc/mips_itu.c                       |  3 ++-
>>  hw/misc/omap_gpmc.c                      |  5 ++--
>>  hw/net/e1000e.c                          |  7 +++---
>>  hw/net/e1000x_common.c                   |  3 ++-
>>  hw/net/eepro100.c                        |  3 +--
>>  hw/nios2/boot.c                          |  6 ++---
>>  hw/nvram/spapr_nvram.c                   | 10 ++++----
>>  hw/pci-host/designware.c                 |  3 ++-
>>  hw/pci-host/gpex.c                       |  3 ++-
>>  hw/pci-host/piix.c                       |  5 ++--
>>  hw/pci-host/prep.c                       |  3 ++-
>>  hw/pci-host/q35.c                        | 17 +++++++-------
>>  hw/pci-host/xilinx-pcie.c                |  5 ++--
>>  hw/ppc/e500.c                            | 13 +++++-----
>>  hw/ppc/e500plat.c                        |  3 ++-
>>  hw/ppc/mac_newworld.c                    |  1 -
>>  hw/ppc/mac_oldworld.c                    |  9 ++++---
>>  hw/ppc/pnv.c                             |  6 ++---
>>  hw/ppc/ppc405_boards.c                   |  9 +++----
>>  hw/ppc/ppc405_uc.c                       |  7 +++---
>>  hw/ppc/ppc440_bamboo.c                   |  6 +++--
>>  hw/ppc/ppc440_uc.c                       | 28 +++++++++++-----------
>>  hw/ppc/ppc4xx_devs.c                     | 22 +++++++++--------
>>  hw/ppc/ppce500_spin.c                    |  3 ++-
>>  hw/ppc/prep.c                            |  6 ++---
>>  hw/ppc/rs6000_mc.c                       | 13 +++++-----
>>  hw/ppc/sam460ex.c                        | 20 +++++++++-------
>>  hw/ppc/spapr.c                           | 12 +++++-----
>>  hw/ppc/spapr_rtas.c                      |  2 +-
>>  hw/ppc/virtex_ml507.c                    |  7 +++---
>>  hw/riscv/virt.c                          |  3 ++-
>>  hw/s390x/s390-skeys.c                    |  3 ++-
>>  hw/s390x/s390-stattrib.c                 |  3 ++-
>>  hw/s390x/sclp.c                          |  4 ++--
>>  hw/scsi/scsi-disk.c                      |  9 +++----
>>  hw/sd/sd.c                               |  8 +++----
>>  hw/sd/sdhci.c                            |  6 ++---
>>  hw/sh4/r2d.c                             |  3 ++-
>>  hw/smbios/smbios.c                       | 15 +++++-------
>>  hw/sparc/leon3.c                         |  9 +++----
>>  hw/sparc/sun4m.c                         |  9 ++++---
>>  hw/sparc64/niagara.c                     |  3 ++-
>>  hw/sparc64/sun4u.c                       |  4 ++--
>>  hw/ssi/aspeed_smc.c                      | 29 ++++++++++++-----------
>>  hw/tricore/tricore_testboard.c           | 13 +++++-----
>>  hw/usb/ccid-card-passthru.c              |  5 ++--
>>  hw/usb/combined-packet.c                 |  3 ++-
>>  hw/usb/dev-smartcard-reader.c            |  3 ++-
>>  hw/usb/redirect.c                        |  3 ++-
>>  hw/vfio/pci-quirks.c                     |  9 +++----
>>  hw/vfio/pci.c                            |  3 ++-
>>  hw/xenpv/xen_domainbuild.c               | 13 +++++-----
>>  hw/xtensa/xtfpga.c                       |  5 ++--
>>  target/i386/cpu.c                        |  4 +---
>>  tests/test-cutils.c                      | 18 +++++++-------
>>  tests/test-keyval.c                      |  6 ++---
>>  tests/test-qemu-opts.c                   |  7 +++---
>>  scripts/checkpatch.pl                    |  1 +
>>  135 files changed, 533 insertions(+), 431 deletions(-)
>>  create mode 100644 include/qemu/units.h
>>
>> -- 
>> 2.17.1
> 

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [Qemu-ppc] [PATCH v4 32/40] hw/ppc: Use the IEC binary prefix definitions
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 32/40] hw/ppc: " Philippe Mathieu-Daudé
@ 2018-06-11  8:09   ` BALATON Zoltan
  2018-06-11 15:44     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 70+ messages in thread
From: BALATON Zoltan @ 2018-06-11  8:09 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Thomas Huth, Stefan Weil, open list:sPAPR, qemu-devel,
	qemu-trivial, Hervé Poussineau, David Gibson

On Sun, 10 Jun 2018, Philippe Mathieu-Daudé wrote:
> diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
> index 2a98c10664..b35e3fff1c 100644
> --- a/hw/ppc/sam460ex.c
> +++ b/hw/ppc/sam460ex.c
> @@ -12,8 +12,9 @@
>  */
>
> #include "qemu/osdep.h"
> +#include "qemu/units.h"
> #include "qemu-common.h"
> -#include "qemu/cutils.h"
> +#include "qemu/units.h"

I think one of these includes of qemu/units.h is enough.

> #include "qemu/error-report.h"
> #include "qapi/error.h"
> #include "hw/hw.h"
> @@ -46,7 +47,7 @@
> /* from Sam460 U-Boot include/configs/Sam460ex.h */
> #define FLASH_BASE             0xfff00000
> #define FLASH_BASE_H           0x4
> -#define FLASH_SIZE             (1 << 20)
> +#define FLASH_SIZE             (1 * MiB)
> #define UBOOT_LOAD_BASE        0xfff80000
> #define UBOOT_SIZE             0x00080000
> #define UBOOT_ENTRY            0xfffffffc
> @@ -71,7 +72,8 @@
>
> /* FIXME: See u-boot.git 8ac41e, also fix in ppc440_uc.c */
> static const unsigned int ppc460ex_sdram_bank_sizes[] = {
> -    1024 << 20, 512 << 20, 256 << 20, 128 << 20, 64 << 20, 32 << 20, 0
> +    1 * GiB, 512 * MiB, 256 * MiB, 128 * MiB,
> +    64 * MiB, 32 * MiB, 0
> };

You said elsewhere:

On Sun, 10 Jun 2018, Philippe Mathieu-Daudé wrote:
> Each use this saves 3 char of the 80 columns limit!

Except when not but at least should not be longer than before and maybe 
more readable. But why are you splitting this line into two? I prefer one 
line for readability if it's not over the line limit.

> struct boot_info {
> @@ -225,7 +227,7 @@ static int sam460ex_load_uboot(void)
>     fl_sectors = (bios_size + 65535) >> 16;
>
>     if (!pflash_cfi01_register(base, NULL, "sam460ex.flash", bios_size,
> -                               blk, (64 * 1024), fl_sectors,
> +                               blk, 64 * KiB, fl_sectors,
>                                1, 0x89, 0x18, 0x0000, 0x0, 1)) {
>         error_report("qemu: Error registering flash memory.");
>         /* XXX: return an error instead? */
> @@ -359,14 +361,14 @@ static void main_cpu_reset(void *opaque)
>
>     /* either we have a kernel to boot or we jump to U-Boot */
>     if (bi->entry != UBOOT_ENTRY) {
> -        env->gpr[1] = (16 << 20) - 8;
> +        env->gpr[1] = (16 * MiB) - 8;
>         env->gpr[3] = FDT_ADDR;
>         env->nip = bi->entry;
>
>         /* Create a mapping for the kernel.  */
>         mmubooke_create_initial_mapping(env, 0, 0);
>         env->gpr[6] = tswap32(EPAPR_MAGIC);
> -        env->gpr[7] = (16 << 20) - 8; /*bi->ima_size;*/
> +        env->gpr[7] = (16 * MiB) - 8; /* bi->ima_size; */
>
>     } else {
>         env->nip = UBOOT_ENTRY;
> @@ -479,8 +481,8 @@ static void sam460ex_init(MachineState *machine)
>     /* 256K of L2 cache as memory */
>     ppc4xx_l2sram_init(env);
>     /* FIXME: remove this after fixing l2sram mapping in ppc440_uc.c? */
> -    memory_region_init_ram(l2cache_ram, NULL, "ppc440.l2cache_ram", 256 << 10,
> -                           &error_abort);
> +    memory_region_init_ram(l2cache_ram, NULL, "ppc440.l2cache_ram",
> +                           256 * KiB, &error_abort);

Line is split differently here too for no apparent reason.

Regards,
BALATON Zoltan

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [Qemu-ppc] [PATCH v4 32/40] hw/ppc: Use the IEC binary prefix definitions
  2018-06-11  8:09   ` [Qemu-devel] [Qemu-ppc] " BALATON Zoltan
@ 2018-06-11 15:44     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-11 15:44 UTC (permalink / raw)
  To: BALATON Zoltan
  Cc: Thomas Huth, qemu-trivial, Stefan Weil, qemu-devel,
	open list:sPAPR, Hervé Poussineau, David Gibson

Hi Zoltan,

On 06/11/2018 05:09 AM, BALATON Zoltan wrote:
> On Sun, 10 Jun 2018, Philippe Mathieu-Daudé wrote:
>> diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
>> index 2a98c10664..b35e3fff1c 100644
>> --- a/hw/ppc/sam460ex.c
>> +++ b/hw/ppc/sam460ex.c
>> @@ -12,8 +12,9 @@
>>  */
>>
>> #include "qemu/osdep.h"
>> +#include "qemu/units.h"
>> #include "qemu-common.h"
>> -#include "qemu/cutils.h"
>> +#include "qemu/units.h"
> 
> I think one of these includes of qemu/units.h is enough.

Oops :) Rebase mistake.

> 
>> #include "qemu/error-report.h"
>> #include "qapi/error.h"
>> #include "hw/hw.h"
>> @@ -46,7 +47,7 @@
>> /* from Sam460 U-Boot include/configs/Sam460ex.h */
>> #define FLASH_BASE             0xfff00000
>> #define FLASH_BASE_H           0x4
>> -#define FLASH_SIZE             (1 << 20)
>> +#define FLASH_SIZE             (1 * MiB)
>> #define UBOOT_LOAD_BASE        0xfff80000
>> #define UBOOT_SIZE             0x00080000
>> #define UBOOT_ENTRY            0xfffffffc
>> @@ -71,7 +72,8 @@
>>
>> /* FIXME: See u-boot.git 8ac41e, also fix in ppc440_uc.c */
>> static const unsigned int ppc460ex_sdram_bank_sizes[] = {
>> -    1024 << 20, 512 << 20, 256 << 20, 128 << 20, 64 << 20, 32 << 20, 0
>> +    1 * GiB, 512 * MiB, 256 * MiB, 128 * MiB,
>> +    64 * MiB, 32 * MiB, 0
>> };
> 
> You said elsewhere:
> 
> On Sun, 10 Jun 2018, Philippe Mathieu-Daudé wrote:
>> Each use this saves 3 char of the 80 columns limit!

This was versus the M_BYTE/G_BYTE definitions, now I noticed the ML ate
this patch...
(it supposed to be 31/41 here)
http://patchew.org/QEMU/20180415234307.28132-1-f4bug@amsat.org/

Where the diff was:

 static const unsigned int ppc460ex_sdram_bank_sizes[] = {
-    1024 << 20, 512 << 20, 256 << 20, 128 << 20, 64 << 20, 32 << 20, 0
+    1 * G_BYTE, 512 * M_BYTE, 256 * M_BYTE, 128 * M_BYTE,
+    64 * M_BYTE, 32 * M_BYTE, 0
 };

> Except when not but at least should not be longer than before and maybe
> more readable. But why are you splitting this line into two? I prefer
> one line for readability if it's not over the line limit.

Sure, as it fits.

> 
>> struct boot_info {
>> @@ -225,7 +227,7 @@ static int sam460ex_load_uboot(void)
>>     fl_sectors = (bios_size + 65535) >> 16;
>>
>>     if (!pflash_cfi01_register(base, NULL, "sam460ex.flash", bios_size,
>> -                               blk, (64 * 1024), fl_sectors,
>> +                               blk, 64 * KiB, fl_sectors,
>>                                1, 0x89, 0x18, 0x0000, 0x0, 1)) {
>>         error_report("qemu: Error registering flash memory.");
>>         /* XXX: return an error instead? */
>> @@ -359,14 +361,14 @@ static void main_cpu_reset(void *opaque)
>>
>>     /* either we have a kernel to boot or we jump to U-Boot */
>>     if (bi->entry != UBOOT_ENTRY) {
>> -        env->gpr[1] = (16 << 20) - 8;
>> +        env->gpr[1] = (16 * MiB) - 8;
>>         env->gpr[3] = FDT_ADDR;
>>         env->nip = bi->entry;
>>
>>         /* Create a mapping for the kernel.  */
>>         mmubooke_create_initial_mapping(env, 0, 0);
>>         env->gpr[6] = tswap32(EPAPR_MAGIC);
>> -        env->gpr[7] = (16 << 20) - 8; /*bi->ima_size;*/
>> +        env->gpr[7] = (16 * MiB) - 8; /* bi->ima_size; */
>>
>>     } else {
>>         env->nip = UBOOT_ENTRY;
>> @@ -479,8 +481,8 @@ static void sam460ex_init(MachineState *machine)
>>     /* 256K of L2 cache as memory */
>>     ppc4xx_l2sram_init(env);
>>     /* FIXME: remove this after fixing l2sram mapping in ppc440_uc.c? */
>> -    memory_region_init_ram(l2cache_ram, NULL, "ppc440.l2cache_ram",
>> 256 << 10,
>> -                           &error_abort);
>> +    memory_region_init_ram(l2cache_ram, NULL, "ppc440.l2cache_ram",
>> +                           256 * KiB, &error_abort);
> 
> Line is split differently here too for no apparent reason.

Same explanation:

+    memory_region_init_ram(l2cache_ram, NULL, "ppc440.l2cache_ram",
+                           256 * K_BYTE, &error_abort);

I'll update.

> 
> Regards,
> BALATON Zoltan

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (39 preceding siblings ...)
  2018-06-11  2:22 ` [Qemu-devel] [PATCH v4 00/40] " Michael S. Tsirkin
@ 2018-06-11 15:55 ` Eric Blake
  2018-06-11 16:11   ` Peter Maydell
  2018-06-11 16:27   ` Michael S. Tsirkin
  2018-06-11 16:18 ` Cornelia Huck
  41 siblings, 2 replies; 70+ messages in thread
From: Eric Blake @ 2018-06-11 15:55 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Thomas Huth, Stefan Weil, Nikunj A Dadhania
  Cc: qemu-arm, qemu-block, qemu-devel, qemu-ppc, qemu-s390x,
	qemu-trivial, Fabien Chouteau, Alistair Francis, Aurelien Jarno,
	Anthony Perard, Christian Borntraeger, Marek Vasut,
	Sagar Karandikar, David Gibson, Antony Pavlov, Artyom Tarasenko,
	Andrzej Zaborowski, Beniamino Galvani, Peter Crosthwaite,
	Chris Wulff, Dmitry Fleytman, Edgar E . Iglesias, Igor Mitsyanko,
	Max Filippov, Magnus Damm, Marcel Apfelbaum, Subbaraya Sundeep,
	Alberto Garcia, Mark Cave-Ayland, Keith Busch,
	Stefano Stabellini, Peter Maydell, Stefan Berger,
	Bastian Koppelmann, Paul Burton, Yongbok Kim, Peter Chubb,
	Yuval Shaia, Hervé Poussineau, Alex Williamson,
	Markus Armbruster, Cornelia Huck, David Hildenbrand,
	Eduardo Habkost, Fam Zheng, Igor Mammedov, Jason Wang,
	Gerd Hoffmann, Kevin Wolf, Max Reitz, Michael S . Tsirkin,
	Paolo Bonzini, Michael Clark, Palmer Dabbelt, Jiri Slaby,
	Alexander Graf, Richard Henderson, Michael Walle, Jan Kiszka

On 06/10/2018 08:14 PM, Philippe Mathieu-Daudé wrote:
> Hi,
> 
> This series:
> 
> - split the byte-based definitions from "qemu/cutils.h" to "qemu/units.h"
>    (this now triggers WARNING: 1 added file, does MAINTAINERS need updating?)
> - clean hw/ includes;
> - replace different constants used for byte size with their corresponding
>    IEC binary prefix definitions.
> 
> Since v3:
> - use IEC binary prefix definitions (Stefan Weil)
> - rebased
> - added R-b tags
> 

>   hw/net/ne2000.h                          |  5 ++--
...
>   tests/test-qemu-opts.c                   |  7 +++---
>   scripts/checkpatch.pl                    |  1 +
>   135 files changed, 533 insertions(+), 431 deletions(-)
>   create mode 100644 include/qemu/units.h
> 

At least monitor.c and vl.c are missing from this list; a more general 
grep shows that the following are all potential candidates for this cleanup:

$ git grep -n '[<>][<>]= [1-5]0'
disas/m68k.c:787:      val >>= 10;
hw/mips/mips_malta.c:194:    ram_size >>= 20;
hw/ppc/sam460ex.c:129:    ram_size >>= 20;
hw/timer/sh_timer.c:112:        case 4: freq >>= 10; break;
linux-user/mips/cpu_loop.c:641:                                code >>= 10;
linux-user/mips/cpu_loop.c:664:                        code >>= 10;
monitor.c:3198:                    val <<= 20;
target/m68k/helper.c:386:    size >>= 10;
target/m68k/helper.c:390:        size >>= 10;
target/m68k/helper.c:394:            size >>= 10;
target/xtensa/helper.c:729:            sz >>= 20;
target/xtensa/helper.c:732:            sz >>= 10;
vl.c:2793:            sz <<= 20;

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions
  2018-06-11 15:55 ` [Qemu-devel] " Eric Blake
@ 2018-06-11 16:11   ` Peter Maydell
  2018-06-11 16:27   ` Michael S. Tsirkin
  1 sibling, 0 replies; 70+ messages in thread
From: Peter Maydell @ 2018-06-11 16:11 UTC (permalink / raw)
  To: Eric Blake
  Cc: Philippe Mathieu-Daudé,
	Thomas Huth, Stefan Weil, Nikunj A Dadhania, qemu-arm,
	Qemu-block, QEMU Developers, qemu-ppc, qemu-s390x, QEMU Trivial,
	Fabien Chouteau, Alistair Francis, Aurelien Jarno,
	Anthony Perard, Christian Borntraeger, Marek Vasut,
	Sagar Karandikar, David Gibson, Antony Pavlov, Artyom Tarasenko,
	Andrzej Zaborowski, Beniamino Galvani, Peter Crosthwaite,
	Chris Wulff, Dmitry Fleytman, Edgar E . Iglesias, Igor Mitsyanko,
	Max Filippov, Magnus Damm, Marcel Apfelbaum, Subbaraya Sundeep,
	Alberto Garcia, Mark Cave-Ayland, Keith Busch,
	Stefano Stabellini, Stefan Berger, Bastian Koppelmann,
	Paul Burton, Yongbok Kim, Peter Chubb, Yuval Shaia,
	Hervé Poussineau, Alex Williamson, Markus Armbruster,
	Cornelia Huck, David Hildenbrand, Eduardo Habkost, Fam Zheng,
	Igor Mammedov, Jason Wang, Gerd Hoffmann, Kevin Wolf, Max Reitz,
	Michael S . Tsirkin, Paolo Bonzini, Michael Clark,
	Palmer Dabbelt, Jiri Slaby, Alexander Graf, Richard Henderson,
	Michael Walle, Jan Kiszka

On 11 June 2018 at 16:55, Eric Blake <eblake@redhat.com> wrote:
> On 06/10/2018 08:14 PM, Philippe Mathieu-Daudé wrote:
>>
>> Hi,
>>
>> This series:
>>
>> - split the byte-based definitions from "qemu/cutils.h" to "qemu/units.h"
>>    (this now triggers WARNING: 1 added file, does MAINTAINERS need
>> updating?)
>> - clean hw/ includes;
>> - replace different constants used for byte size with their corresponding
>>    IEC binary prefix definitions.
>>
>> Since v3:
>> - use IEC binary prefix definitions (Stefan Weil)
>> - rebased
>> - added R-b tags
>>
>
>>   hw/net/ne2000.h                          |  5 ++--
>
> ...
>>
>>   tests/test-qemu-opts.c                   |  7 +++---
>>   scripts/checkpatch.pl                    |  1 +
>>   135 files changed, 533 insertions(+), 431 deletions(-)
>>   create mode 100644 include/qemu/units.h
>>
>
> At least monitor.c and vl.c are missing from this list; a more general grep
> shows that the following are all potential candidates for this cleanup:

This patchset is already 40 patches long, though; if we like it
then we should just go ahead with it and deal with the stragglers
in a second series.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions
  2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (40 preceding siblings ...)
  2018-06-11 15:55 ` [Qemu-devel] " Eric Blake
@ 2018-06-11 16:18 ` Cornelia Huck
  41 siblings, 0 replies; 70+ messages in thread
From: Cornelia Huck @ 2018-06-11 16:18 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Thomas Huth, Stefan Weil, Nikunj A Dadhania, qemu-arm,
	qemu-block, qemu-devel, qemu-ppc, qemu-s390x, qemu-trivial,
	Fabien Chouteau, Alistair Francis, Aurelien Jarno,
	Anthony Perard, Christian Borntraeger, Marek Vasut,
	Sagar Karandikar, David Gibson, Antony Pavlov, Artyom Tarasenko,
	Andrzej Zaborowski, Beniamino Galvani, Peter Crosthwaite,
	Chris Wulff, Dmitry Fleytman, Edgar E . Iglesias, Igor Mitsyanko,
	Max Filippov, Magnus Damm, Marcel Apfelbaum, Subbaraya Sundeep,
	Alberto Garcia, Mark Cave-Ayland, Keith Busch,
	Stefano Stabellini, Peter Maydell, Stefan Berger,
	Bastian Koppelmann, Paul Burton, Yongbok Kim, Peter Chubb,
	Yuval Shaia, Hervé Poussineau, Alex Williamson,
	Markus Armbruster, David Hildenbrand, Eric Blake,
	Eduardo Habkost, Fam Zheng, Igor Mammedov, Jason Wang,
	Gerd Hoffmann, Kevin Wolf, Max Reitz, Michael S . Tsirkin,
	Paolo Bonzini, Michael Clark, Palmer Dabbelt, Jiri Slaby,
	Alexander Graf, Richard Henderson, Michael Walle, Jan Kiszka

On Sun, 10 Jun 2018 22:14:21 -0300
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:

> Hi,
> 
> This series:
> 
> - split the byte-based definitions from "qemu/cutils.h" to "qemu/units.h"
>   (this now triggers WARNING: 1 added file, does MAINTAINERS need updating?)
> - clean hw/ includes;
> - replace different constants used for byte size with their corresponding
>   IEC binary prefix definitions.

Do we document preference for this somewhere? Can we automatically
check for this?

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions
  2018-06-11 15:55 ` [Qemu-devel] " Eric Blake
  2018-06-11 16:11   ` Peter Maydell
@ 2018-06-11 16:27   ` Michael S. Tsirkin
  1 sibling, 0 replies; 70+ messages in thread
From: Michael S. Tsirkin @ 2018-06-11 16:27 UTC (permalink / raw)
  To: Eric Blake
  Cc: Philippe Mathieu-Daudé,
	Thomas Huth, Stefan Weil, Nikunj A Dadhania, qemu-arm,
	qemu-block, qemu-devel, qemu-ppc, qemu-s390x, qemu-trivial,
	Fabien Chouteau, Alistair Francis, Aurelien Jarno,
	Anthony Perard, Christian Borntraeger, Marek Vasut,
	Sagar Karandikar, David Gibson, Antony Pavlov, Artyom Tarasenko,
	Andrzej Zaborowski, Beniamino Galvani, Peter Crosthwaite,
	Chris Wulff, Dmitry Fleytman, Edgar E . Iglesias, Igor Mitsyanko,
	Max Filippov, Magnus Damm, Marcel Apfelbaum, Subbaraya Sundeep,
	Alberto Garcia, Mark Cave-Ayland, Keith Busch,
	Stefano Stabellini, Peter Maydell, Stefan Berger,
	Bastian Koppelmann, Paul Burton, Yongbok Kim, Peter Chubb,
	Yuval Shaia, Hervé Poussineau, Alex Williamson,
	Markus Armbruster, Cornelia Huck, David Hildenbrand,
	Eduardo Habkost, Fam Zheng, Igor Mammedov, Jason Wang,
	Gerd Hoffmann, Kevin Wolf, Max Reitz, Paolo Bonzini,
	Michael Clark, Palmer Dabbelt, Jiri Slaby, Alexander Graf,
	Richard Henderson, Michael Walle, Jan Kiszka

On Mon, Jun 11, 2018 at 10:55:17AM -0500, Eric Blake wrote:
> On 06/10/2018 08:14 PM, Philippe Mathieu-Daudé wrote:
> > Hi,
> > 
> > This series:
> > 
> > - split the byte-based definitions from "qemu/cutils.h" to "qemu/units.h"
> >    (this now triggers WARNING: 1 added file, does MAINTAINERS need updating?)
> > - clean hw/ includes;
> > - replace different constants used for byte size with their corresponding
> >    IEC binary prefix definitions.
> > 
> > Since v3:
> > - use IEC binary prefix definitions (Stefan Weil)
> > - rebased
> > - added R-b tags
> > 
> 
> >   hw/net/ne2000.h                          |  5 ++--
> ...
> >   tests/test-qemu-opts.c                   |  7 +++---
> >   scripts/checkpatch.pl                    |  1 +
> >   135 files changed, 533 insertions(+), 431 deletions(-)
> >   create mode 100644 include/qemu/units.h
> > 
> 
> At least monitor.c and vl.c are missing from this list; a more general grep
> shows that the following are all potential candidates for this cleanup:
> 
> $ git grep -n '[<>][<>]= [1-5]0'
> disas/m68k.c:787:      val >>= 10;
> hw/mips/mips_malta.c:194:    ram_size >>= 20;
> hw/ppc/sam460ex.c:129:    ram_size >>= 20;
> hw/timer/sh_timer.c:112:        case 4: freq >>= 10; break;

Most likely not 4 kilobyte.


> linux-user/mips/cpu_loop.c:641:                                code >>= 10;
> linux-user/mips/cpu_loop.c:664:                        code >>= 10;

Seems to do with decoding machine code. Also unlikely to be in bytes.

> monitor.c:3198:                    val <<= 20;
> target/m68k/helper.c:386:    size >>= 10;
> target/m68k/helper.c:390:        size >>= 10;
> target/m68k/helper.c:394:            size >>= 10;
> target/xtensa/helper.c:729:            sz >>= 20;
> target/xtensa/helper.c:732:            sz >>= 10;
> vl.c:2793:            sz <<= 20;




> -- 
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.           +1-919-301-3266
> Virtualization:  qemu.org | libvirt.org

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 03/40] x86/cpu: Use definitions from "qemu/units.h"
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 03/40] x86/cpu: " Philippe Mathieu-Daudé
@ 2018-06-11 18:42   ` Eduardo Habkost
  0 siblings, 0 replies; 70+ messages in thread
From: Eduardo Habkost @ 2018-06-11 18:42 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Thomas Huth, Stefan Weil, qemu-devel, qemu-trivial,
	Paolo Bonzini, Richard Henderson

On Sun, Jun 10, 2018 at 10:14:24PM -0300, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Nice, thanks!

Acked-by: Eduardo Habkost <ehabkost@redhat.com>

> ---
>  target/i386/cpu.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index 94260412e2..56c63615fe 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -18,6 +18,7 @@
>   */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "qemu/cutils.h"
>  
>  #include "cpu.h"
> @@ -64,9 +65,6 @@ struct CPUID2CacheDescriptorInfo {
>      int associativity;
>  };
>  
> -#define KiB 1024
> -#define MiB (1024 * 1024)
> -
>  /*
>   * Known CPUID 2 cache descriptors.
>   * From Intel SDM Volume 2A, CPUID instruction
> -- 
> 2.17.1
> 

-- 
Eduardo

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 34/40] hw/net: Use the IEC binary prefix definitions
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 34/40] hw/net: " Philippe Mathieu-Daudé
@ 2018-06-11 19:20   ` Stefan Weil
  0 siblings, 0 replies; 70+ messages in thread
From: Stefan Weil @ 2018-06-11 19:20 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Thomas Huth
  Cc: Dmitry Fleytman, qemu-trivial, Jason Wang, qemu-devel,
	Beniamino Galvani, open list:Allwinner-a10

[-- Attachment #1: Type: text/plain, Size: 4217 bytes --]

Am 11.06.2018 um 03:14 schrieb Philippe Mathieu-Daudé:
> It eases code review, unit is explicit.
> 
> Patch generated using:
> 
>   $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
> 
> and modified manually.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Reviewed-by: Stefan Weil <sw@weilnetz.de>
> ---
>  hw/net/ne2000.h                 | 5 +++--
>  include/hw/net/allwinner_emac.h | 5 +++--
>  hw/net/e1000e.c                 | 7 ++++---
>  hw/net/e1000x_common.c          | 3 ++-
>  hw/net/eepro100.c               | 3 +--
>  5 files changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/hw/net/ne2000.h b/hw/net/ne2000.h
> index adb8021bd1..2cd193e4c6 100644
> --- a/hw/net/ne2000.h
> +++ b/hw/net/ne2000.h
> @@ -1,11 +1,12 @@
>  #ifndef HW_NE2000_H
>  #define HW_NE2000_H
>  
> +#include "qemu/units.h"
>  #include "hw/hw.h"
>  #include "net/net.h"
>  
> -#define NE2000_PMEM_SIZE    (32*1024)
> -#define NE2000_PMEM_START   (16*1024)
> +#define NE2000_PMEM_SIZE    (32 * KiB)
> +#define NE2000_PMEM_START   (16 * KiB)
>  #define NE2000_PMEM_END     (NE2000_PMEM_SIZE+NE2000_PMEM_START)
>  #define NE2000_MEM_SIZE     NE2000_PMEM_END
>  
> diff --git a/include/hw/net/allwinner_emac.h b/include/hw/net/allwinner_emac.h
> index 4cc8aab7ec..905a43deb4 100644
> --- a/include/hw/net/allwinner_emac.h
> +++ b/include/hw/net/allwinner_emac.h
> @@ -23,6 +23,7 @@
>  #ifndef ALLWINNER_EMAC_H
>  #define ALLWINNER_EMAC_H
>  
> +#include "qemu/units.h"
>  #include "net/net.h"
>  #include "qemu/fifo8.h"
>  #include "hw/net/mii.h"
> @@ -125,8 +126,8 @@
>  #define EMAC_INT_RX         (1 << 8)
>  
>  /* Due to lack of specifications, size of fifos is chosen arbitrarily */
> -#define TX_FIFO_SIZE        (4 * 1024)
> -#define RX_FIFO_SIZE        (32 * 1024)
> +#define TX_FIFO_SIZE        (4 * KiB)
> +#define RX_FIFO_SIZE        (32 * KiB)
>  
>  #define NUM_TX_FIFOS        2
>  #define RX_HDR_SIZE         8
> diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c
> index cda8d48333..510ddb3897 100644
> --- a/hw/net/e1000e.c
> +++ b/hw/net/e1000e.c
> @@ -34,6 +34,7 @@
>  */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "net/net.h"
>  #include "net/tap.h"
>  #include "qemu/range.h"
> @@ -81,10 +82,10 @@ typedef struct E1000EState {
>  #define E1000E_IO_IDX       2
>  #define E1000E_MSIX_IDX     3
>  
> -#define E1000E_MMIO_SIZE    (128 * 1024)
> -#define E1000E_FLASH_SIZE   (128 * 1024)
> +#define E1000E_MMIO_SIZE    (128 * KiB)
> +#define E1000E_FLASH_SIZE   (128 * KiB)
>  #define E1000E_IO_SIZE      (32)
> -#define E1000E_MSIX_SIZE    (16 * 1024)
> +#define E1000E_MSIX_SIZE    (16 * KiB)
>  
>  #define E1000E_MSIX_TABLE   (0x0000)
>  #define E1000E_MSIX_PBA     (0x2000)
> diff --git a/hw/net/e1000x_common.c b/hw/net/e1000x_common.c
> index eb0e097137..09047806f2 100644
> --- a/hw/net/e1000x_common.c
> +++ b/hw/net/e1000x_common.c
> @@ -23,6 +23,7 @@
>  */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "hw/hw.h"
>  #include "hw/pci/pci.h"
>  #include "net/net.h"
> @@ -111,7 +112,7 @@ bool e1000x_is_oversized(uint32_t *mac, size_t size)
>      static const int maximum_ethernet_vlan_size = 1522;
>      /* this is the size past which hardware will
>         drop packets when setting LPE=1 */
> -    static const int maximum_ethernet_lpe_size = 16384;
> +    static const int maximum_ethernet_lpe_size = 16 * KiB;
>  
>      if ((size > maximum_ethernet_lpe_size ||
>          (size > maximum_ethernet_vlan_size
> diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
> index a07a63247e..e761daf551 100644
> --- a/hw/net/eepro100.c
> +++ b/hw/net/eepro100.c
> @@ -41,6 +41,7 @@
>   */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "hw/hw.h"
>  #include "hw/pci/pci.h"
>  #include "net/net.h"
> @@ -60,8 +61,6 @@
>   * changed to pad short packets itself. */
>  #define CONFIG_PAD_RECEIVED_FRAMES
>  
> -#define KiB 1024
> -
>  /* Debug EEPRO100 card. */
>  #if 0
>  # define DEBUG_EEPRO100
> 

Reviewed-by: Stefan Weil <sw@weilnetz.de>

Thank you!



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 02/40] vdi: Use definitions from "qemu/units.h"
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 02/40] vdi: Use definitions from "qemu/units.h" Philippe Mathieu-Daudé
@ 2018-06-11 19:27   ` Stefan Weil
  0 siblings, 0 replies; 70+ messages in thread
From: Stefan Weil @ 2018-06-11 19:27 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Thomas Huth
  Cc: qemu-devel, qemu-trivial, Kevin Wolf, Max Reitz, open list:VDI

Am 11.06.2018 um 03:14 schrieb Philippe Mathieu-Daudé:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  block/vdi.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/block/vdi.c b/block/vdi.c
> index 668af0a828..35b51dc5c5 100644
> --- a/block/vdi.c
> +++ b/block/vdi.c
> @@ -50,6 +50,7 @@
>   */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "qapi/error.h"
>  #include "qapi/qmp/qdict.h"
>  #include "qapi/qobject-input-visitor.h"
> @@ -83,9 +84,6 @@
>  /* Command line option for static images. */
>  #define BLOCK_OPT_STATIC "static"
>  
> -#define KiB     1024
> -#define MiB     (KiB * KiB)
> -
>  #define SECTOR_SIZE 512
>  #define DEFAULT_CLUSTER_SIZE (1 * MiB)
>  
> @@ -250,7 +248,7 @@ static void vdi_header_print(VdiHeader *header)
>      logout("heads       0x%04x\n", header->heads);
>      logout("sectors     0x%04x\n", header->sectors);
>      logout("sector size 0x%04x\n", header->sector_size);
> -    logout("image size  0x%" PRIx64 " B (%" PRIu64 " MiB)\n",
> +    logout("image size  0x%" PRIx64 " B (%llu MiB)\n",
>             header->disk_size, header->disk_size / MiB);
>      logout("block size  0x%04x\n", header->block_size);
>      logout("block extra 0x%04x\n", header->block_extra);
> @@ -434,7 +432,7 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
>          goto fail;
>      } else if (header.block_size != DEFAULT_CLUSTER_SIZE) {
>          error_setg(errp, "unsupported VDI image (block size %" PRIu32
> -                   " is not %u)", header.block_size, DEFAULT_CLUSTER_SIZE);
> +                   " is not %llu)", header.block_size, DEFAULT_CLUSTER_SIZE);
>          ret = -ENOTSUP;
>          goto fail;
>      } else if (header.disk_size >
> 

Reviewed-by: Stefan Weil <sw@weilnetz.de>

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 01/40] include: Add IEC binary prefixes in "qemu/units.h"
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 01/40] include: Add IEC binary prefixes in "qemu/units.h" Philippe Mathieu-Daudé
@ 2018-06-12 20:42   ` Richard Henderson
  0 siblings, 0 replies; 70+ messages in thread
From: Richard Henderson @ 2018-06-12 20:42 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Nikunj A Dadhania, Thomas Huth, Stefan Weil
  Cc: qemu-trivial, qemu-devel

On 06/10/2018 03:14 PM, Philippe Mathieu-Daudé wrote:
> +#define KiB     (1ULL << 10)
> +#define MiB     (1ULL << 20)
> +#define GiB     (1ULL << 30)
> +#define TiB     (1ULL << 40)
> +#define PiB     (1ULL << 50)
> +#define EiB     (1ULL << 60)

Is there any particular reason to force these to be unsigned?
Or, for that matter, 64-bit (at least for the first 3).

I ask because this changes the types of some of the expressions
in which you use these.


r~

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 11/40] hw/xen: Use the IEC binary prefix definitions
  2018-06-11  1:14   ` Philippe Mathieu-Daudé
  (?)
  (?)
@ 2018-06-12 20:51   ` Richard Henderson
  2018-06-12 21:04     ` Eric Blake
  2018-06-12 21:04     ` Eric Blake
  -1 siblings, 2 replies; 70+ messages in thread
From: Richard Henderson @ 2018-06-12 20:51 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Thomas Huth, Stefan Weil
  Cc: Kevin Wolf, Stefano Stabellini, Eduardo Habkost,
	open list:Block layer core, Michael S. Tsirkin, qemu-trivial,
	qemu-devel, open list:X86, Anthony Perard, Paolo Bonzini,
	Max Reitz, Richard Henderson

On 06/10/2018 03:14 PM, Philippe Mathieu-Daudé wrote:
>      xen_pv_printf(xendev, 1, "type \"%s\", fileproto \"%s\", filename \"%s\","
> -                  " size %" PRId64 " (%" PRId64 " MB)\n",
> +                  " size %" PRId64 " (%llu MB)\n",
>                    blkdev->type, blkdev->fileproto, blkdev->filename,
> -                  blkdev->file_size, blkdev->file_size >> 20);
> +                  blkdev->file_size, blkdev->file_size / MiB);

Having to change printf markup is exactly why you shouldn't use ULL in MiB.


r~

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 11/40] hw/xen: Use the IEC binary prefix definitions
  2018-06-11  1:14   ` Philippe Mathieu-Daudé
  (?)
@ 2018-06-12 20:51   ` Richard Henderson
  -1 siblings, 0 replies; 70+ messages in thread
From: Richard Henderson @ 2018-06-12 20:51 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Thomas Huth, Stefan Weil
  Cc: Kevin Wolf, Stefano Stabellini, Eduardo Habkost,
	open list:Block layer core, Michael S. Tsirkin, qemu-trivial,
	qemu-devel, Max Reitz, Paolo Bonzini, Anthony Perard,
	open list:X86, Richard Henderson

On 06/10/2018 03:14 PM, Philippe Mathieu-Daudé wrote:
>      xen_pv_printf(xendev, 1, "type \"%s\", fileproto \"%s\", filename \"%s\","
> -                  " size %" PRId64 " (%" PRId64 " MB)\n",
> +                  " size %" PRId64 " (%llu MB)\n",
>                    blkdev->type, blkdev->fileproto, blkdev->filename,
> -                  blkdev->file_size, blkdev->file_size >> 20);
> +                  blkdev->file_size, blkdev->file_size / MiB);

Having to change printf markup is exactly why you shouldn't use ULL in MiB.


r~

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 11/40] hw/xen: Use the IEC binary prefix definitions
  2018-06-12 20:51   ` Richard Henderson
  2018-06-12 21:04     ` Eric Blake
@ 2018-06-12 21:04     ` Eric Blake
  2018-06-12 21:10       ` Richard Henderson
  2018-06-12 21:10       ` Richard Henderson
  1 sibling, 2 replies; 70+ messages in thread
From: Eric Blake @ 2018-06-12 21:04 UTC (permalink / raw)
  To: Richard Henderson, Philippe Mathieu-Daudé, Thomas Huth, Stefan Weil
  Cc: Kevin Wolf, Stefano Stabellini, Eduardo Habkost,
	open list:Block layer core, Michael S. Tsirkin, qemu-trivial,
	qemu-devel, Max Reitz, Paolo Bonzini, Anthony Perard,
	open list:X86, Richard Henderson

On 06/12/2018 03:51 PM, Richard Henderson wrote:
> On 06/10/2018 03:14 PM, Philippe Mathieu-Daudé wrote:
>>       xen_pv_printf(xendev, 1, "type \"%s\", fileproto \"%s\", filename \"%s\","
>> -                  " size %" PRId64 " (%" PRId64 " MB)\n",
>> +                  " size %" PRId64 " (%llu MB)\n",
>>                     blkdev->type, blkdev->fileproto, blkdev->filename,
>> -                  blkdev->file_size, blkdev->file_size >> 20);
>> +                  blkdev->file_size, blkdev->file_size / MiB);
> 
> Having to change printf markup is exactly why you shouldn't use ULL in MiB.

Conversely, M_BYTE was already ULL, so if you don't use it in MiB, 
you'll have to change other printf markup where you were changing those 
uses.

One benefit of using the widest possible type: we avoid risk of silent 
truncation.  Potential downsides: wasted processing time (when 32 bits 
was sufficient), and compilers might start warning when we narrow a 
64-bit value into a 32-bit variable (but I think we already ignore that).

One benefit of using the natural type that holds the value: use of 
64-bit math is explicit based on the type of what else is being 
multiplied by the macro.  Potential downside: 32*32 assigned to a 64-bit 
result may be botched (but hopefully Coverity will flag it).

So there's tradeoffs either way, and you at least need to document in 
your commit messages what auditing you have done that any type changes 
introduced by your changes are safe.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 11/40] hw/xen: Use the IEC binary prefix definitions
  2018-06-12 20:51   ` Richard Henderson
@ 2018-06-12 21:04     ` Eric Blake
  2018-06-12 21:04     ` Eric Blake
  1 sibling, 0 replies; 70+ messages in thread
From: Eric Blake @ 2018-06-12 21:04 UTC (permalink / raw)
  To: Richard Henderson, Philippe Mathieu-Daudé, Thomas Huth, Stefan Weil
  Cc: Kevin Wolf, Stefano Stabellini, Eduardo Habkost,
	open list:Block layer core, Michael S. Tsirkin, qemu-trivial,
	qemu-devel, Max Reitz, open list:X86, Anthony Perard,
	Paolo Bonzini, Richard Henderson

On 06/12/2018 03:51 PM, Richard Henderson wrote:
> On 06/10/2018 03:14 PM, Philippe Mathieu-Daudé wrote:
>>       xen_pv_printf(xendev, 1, "type \"%s\", fileproto \"%s\", filename \"%s\","
>> -                  " size %" PRId64 " (%" PRId64 " MB)\n",
>> +                  " size %" PRId64 " (%llu MB)\n",
>>                     blkdev->type, blkdev->fileproto, blkdev->filename,
>> -                  blkdev->file_size, blkdev->file_size >> 20);
>> +                  blkdev->file_size, blkdev->file_size / MiB);
> 
> Having to change printf markup is exactly why you shouldn't use ULL in MiB.

Conversely, M_BYTE was already ULL, so if you don't use it in MiB, 
you'll have to change other printf markup where you were changing those 
uses.

One benefit of using the widest possible type: we avoid risk of silent 
truncation.  Potential downsides: wasted processing time (when 32 bits 
was sufficient), and compilers might start warning when we narrow a 
64-bit value into a 32-bit variable (but I think we already ignore that).

One benefit of using the natural type that holds the value: use of 
64-bit math is explicit based on the type of what else is being 
multiplied by the macro.  Potential downside: 32*32 assigned to a 64-bit 
result may be botched (but hopefully Coverity will flag it).

So there's tradeoffs either way, and you at least need to document in 
your commit messages what auditing you have done that any type changes 
introduced by your changes are safe.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 11/40] hw/xen: Use the IEC binary prefix definitions
  2018-06-12 21:04     ` Eric Blake
  2018-06-12 21:10       ` Richard Henderson
@ 2018-06-12 21:10       ` Richard Henderson
  2018-06-13 12:13         ` Eric Blake
  2018-06-13 12:13         ` Eric Blake
  1 sibling, 2 replies; 70+ messages in thread
From: Richard Henderson @ 2018-06-12 21:10 UTC (permalink / raw)
  To: Eric Blake, Philippe Mathieu-Daudé, Thomas Huth, Stefan Weil
  Cc: Kevin Wolf, Stefano Stabellini, Eduardo Habkost,
	open list:Block layer core, Michael S. Tsirkin, qemu-trivial,
	qemu-devel, Max Reitz, Paolo Bonzini, Anthony Perard,
	open list:X86, Richard Henderson

On 06/12/2018 11:04 AM, Eric Blake wrote:
> On 06/12/2018 03:51 PM, Richard Henderson wrote:
>> On 06/10/2018 03:14 PM, Philippe Mathieu-Daudé wrote:
>>>       xen_pv_printf(xendev, 1, "type \"%s\", fileproto \"%s\", filename
>>> \"%s\","
>>> -                  " size %" PRId64 " (%" PRId64 " MB)\n",
>>> +                  " size %" PRId64 " (%llu MB)\n",
>>>                     blkdev->type, blkdev->fileproto, blkdev->filename,
>>> -                  blkdev->file_size, blkdev->file_size >> 20);
>>> +                  blkdev->file_size, blkdev->file_size / MiB);
>>
>> Having to change printf markup is exactly why you shouldn't use ULL in MiB.
> 
> Conversely, M_BYTE was already ULL, so if you don't use it in MiB, you'll have
> to change other printf markup where you were changing those uses.
> 
> One benefit of using the widest possible type: we avoid risk of silent
> truncation.  Potential downsides: wasted processing time (when 32 bits was
> sufficient), and compilers might start warning when we narrow a 64-bit value
> into a 32-bit variable (but I think we already ignore that).
> 
> One benefit of using the natural type that holds the value: use of 64-bit math
> is explicit based on the type of what else is being multiplied by the macro. 
> Potential downside: 32*32 assigned to a 64-bit result may be botched (but
> hopefully Coverity will flag it).
> 
> So there's tradeoffs either way, and you at least need to document in your
> commit messages what auditing you have done that any type changes introduced by
> your changes are safe.

I'm more concerned about unnecessary or unintended signed vs unsigned changes
than I am about width.  But if we're going to force a 64-bit type, use
(int64_t)1 not 1LL.  That way the type will match the existing PRId64 printf
markup.


r~

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 11/40] hw/xen: Use the IEC binary prefix definitions
  2018-06-12 21:04     ` Eric Blake
@ 2018-06-12 21:10       ` Richard Henderson
  2018-06-12 21:10       ` Richard Henderson
  1 sibling, 0 replies; 70+ messages in thread
From: Richard Henderson @ 2018-06-12 21:10 UTC (permalink / raw)
  To: Eric Blake, Philippe Mathieu-Daudé, Thomas Huth, Stefan Weil
  Cc: Kevin Wolf, Stefano Stabellini, Eduardo Habkost,
	open list:Block layer core, Michael S. Tsirkin, qemu-trivial,
	qemu-devel, Max Reitz, open list:X86, Anthony Perard,
	Paolo Bonzini, Richard Henderson

On 06/12/2018 11:04 AM, Eric Blake wrote:
> On 06/12/2018 03:51 PM, Richard Henderson wrote:
>> On 06/10/2018 03:14 PM, Philippe Mathieu-Daudé wrote:
>>>       xen_pv_printf(xendev, 1, "type \"%s\", fileproto \"%s\", filename
>>> \"%s\","
>>> -                  " size %" PRId64 " (%" PRId64 " MB)\n",
>>> +                  " size %" PRId64 " (%llu MB)\n",
>>>                     blkdev->type, blkdev->fileproto, blkdev->filename,
>>> -                  blkdev->file_size, blkdev->file_size >> 20);
>>> +                  blkdev->file_size, blkdev->file_size / MiB);
>>
>> Having to change printf markup is exactly why you shouldn't use ULL in MiB.
> 
> Conversely, M_BYTE was already ULL, so if you don't use it in MiB, you'll have
> to change other printf markup where you were changing those uses.
> 
> One benefit of using the widest possible type: we avoid risk of silent
> truncation.  Potential downsides: wasted processing time (when 32 bits was
> sufficient), and compilers might start warning when we narrow a 64-bit value
> into a 32-bit variable (but I think we already ignore that).
> 
> One benefit of using the natural type that holds the value: use of 64-bit math
> is explicit based on the type of what else is being multiplied by the macro. 
> Potential downside: 32*32 assigned to a 64-bit result may be botched (but
> hopefully Coverity will flag it).
> 
> So there's tradeoffs either way, and you at least need to document in your
> commit messages what auditing you have done that any type changes introduced by
> your changes are safe.

I'm more concerned about unnecessary or unintended signed vs unsigned changes
than I am about width.  But if we're going to force a 64-bit type, use
(int64_t)1 not 1LL.  That way the type will match the existing PRId64 printf
markup.


r~

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 11/40] hw/xen: Use the IEC binary prefix definitions
  2018-06-12 21:10       ` Richard Henderson
@ 2018-06-13 12:13         ` Eric Blake
  2018-06-13 19:31           ` Richard Henderson
  2018-06-13 19:31           ` Richard Henderson
  2018-06-13 12:13         ` Eric Blake
  1 sibling, 2 replies; 70+ messages in thread
From: Eric Blake @ 2018-06-13 12:13 UTC (permalink / raw)
  To: Richard Henderson, Philippe Mathieu-Daudé, Thomas Huth, Stefan Weil
  Cc: Kevin Wolf, Stefano Stabellini, Eduardo Habkost,
	open list:Block layer core, Michael S. Tsirkin, qemu-trivial,
	qemu-devel, Max Reitz, Paolo Bonzini, Anthony Perard,
	open list:X86, Richard Henderson

On 06/12/2018 04:10 PM, Richard Henderson wrote:
>> So there's tradeoffs either way, and you at least need to document in your
>> commit messages what auditing you have done that any type changes introduced by
>> your changes are safe.
> 
> I'm more concerned about unnecessary or unintended signed vs unsigned changes
> than I am about width.  But if we're going to force a 64-bit type, use
> (int64_t)1 not 1LL.  That way the type will match the existing PRId64 printf
> markup.

Or spell it UINT64_C(1) if you don't want a cast.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 11/40] hw/xen: Use the IEC binary prefix definitions
  2018-06-12 21:10       ` Richard Henderson
  2018-06-13 12:13         ` Eric Blake
@ 2018-06-13 12:13         ` Eric Blake
  1 sibling, 0 replies; 70+ messages in thread
From: Eric Blake @ 2018-06-13 12:13 UTC (permalink / raw)
  To: Richard Henderson, Philippe Mathieu-Daudé, Thomas Huth, Stefan Weil
  Cc: Kevin Wolf, Stefano Stabellini, Eduardo Habkost,
	open list:Block layer core, Michael S. Tsirkin, qemu-trivial,
	qemu-devel, Max Reitz, open list:X86, Anthony Perard,
	Paolo Bonzini, Richard Henderson

On 06/12/2018 04:10 PM, Richard Henderson wrote:
>> So there's tradeoffs either way, and you at least need to document in your
>> commit messages what auditing you have done that any type changes introduced by
>> your changes are safe.
> 
> I'm more concerned about unnecessary or unintended signed vs unsigned changes
> than I am about width.  But if we're going to force a 64-bit type, use
> (int64_t)1 not 1LL.  That way the type will match the existing PRId64 printf
> markup.

Or spell it UINT64_C(1) if you don't want a cast.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 11/40] hw/xen: Use the IEC binary prefix definitions
  2018-06-13 12:13         ` Eric Blake
  2018-06-13 19:31           ` Richard Henderson
@ 2018-06-13 19:31           ` Richard Henderson
  2018-06-13 20:02             ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 70+ messages in thread
From: Richard Henderson @ 2018-06-13 19:31 UTC (permalink / raw)
  To: Eric Blake, Philippe Mathieu-Daudé, Thomas Huth, Stefan Weil
  Cc: Kevin Wolf, Stefano Stabellini, Eduardo Habkost,
	open list:Block layer core, Michael S. Tsirkin, qemu-trivial,
	qemu-devel, Max Reitz, Paolo Bonzini, Anthony Perard,
	open list:X86, Richard Henderson

On 06/13/2018 02:13 AM, Eric Blake wrote:
> Or spell it UINT64_C(1) if you don't want a cast.

Not unsigned is what I want most.


r~

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 11/40] hw/xen: Use the IEC binary prefix definitions
  2018-06-13 12:13         ` Eric Blake
@ 2018-06-13 19:31           ` Richard Henderson
  2018-06-13 19:31           ` Richard Henderson
  1 sibling, 0 replies; 70+ messages in thread
From: Richard Henderson @ 2018-06-13 19:31 UTC (permalink / raw)
  To: Eric Blake, Philippe Mathieu-Daudé, Thomas Huth, Stefan Weil
  Cc: Kevin Wolf, Stefano Stabellini, Eduardo Habkost,
	open list:Block layer core, Michael S. Tsirkin, qemu-trivial,
	qemu-devel, Max Reitz, open list:X86, Anthony Perard,
	Paolo Bonzini, Richard Henderson

On 06/13/2018 02:13 AM, Eric Blake wrote:
> Or spell it UINT64_C(1) if you don't want a cast.

Not unsigned is what I want most.


r~

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 04/40] checkpatch: Recognize IEC binary prefix definitions
  2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 04/40] checkpatch: Recognize IEC binary prefix definitions Philippe Mathieu-Daudé
@ 2018-06-13 19:54   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-13 19:54 UTC (permalink / raw)
  To: Eric Blake; +Cc: Thomas Huth, Stefan Weil, qemu-devel, qemu-trivial

On 06/10/2018 10:14 PM, Philippe Mathieu-Daudé wrote:
> This fixes:
> 
>     ERROR: "foo * bar" should be "foo *bar"
>     #310: FILE: hw/ppc/ppc440_uc.c:564:
>     +        size = 8 * MiB * sh;
>     total: 1 errors, 0 warnings, 433 lines checked
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  scripts/checkpatch.pl | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index e3d8c2cdfc..4923674c71 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -322,6 +322,7 @@ sub build_types {
>  				(?:${all}\b)
>  			)
>  			(?:\s+$Modifier|\s+const)*
> +			(?:[KMGTPE]iB)
>  		  }x;
>  	$Type	= qr{
>  			$NonptrType
> 

Well this patch doesn't work like expected...

$ git diff --cached | \
  scripts/checkpatch.pl --no-signoff --debug values=2 -
 <E> <E> <_>WS(         )
 <E> <E> <_>IDENT(size)
 <E> <V> <_>WS( )
 <E> <V> <_>ASSIGN(=)
 <E> <N> <_>WS( )
 <E> <N> <_>IDENT(8)
 <E> <V> <_>WS( )
 <E> <V> <_>OPV(*)
 <E> <N> <_>WS( )
 <E> <N> <_>DECLARE(MiB * ) <------------
 <E> <T> <_>IDENT(sh)
 <E> <V> <_>END(;)
 <E> <E> <_>WS(
)
22 > .         size = 8 * MiB * sh;
22 > EEEEEEEEEEVVVVVNNVVNNTTTTTTVVEE
22 >  __________________B___________

Which looks OK, but then (example):

$ git diff --cached
diff --git a/include/net/net.h b/include/net/net.h
-void qemu_del_nic(NICState *nic);
+void qemu_del_nic(NICState *test);

$ git diff --cached | \
  scripts/checkpatch.pl --no-signoff --debug values=2 -

 void qemu_del_nic(NICState *test);

 <E> <E> <_>WS( )
 <E> <E> <_>IDENT(void)
 <E> <V> <_>WS( )
 <E> <V> <_>FUNC(qemu_del_nic)
 <E> <V> <V>PAREN('(')
 <EV> <N> <_>IDENT(NICState)
 <EV> <V> <_>WS( )
 <EV> <V> <_>OPV(*)
 <EV> <N> <_>IDENT(test)
 <EV> <V> <_>PAREN(')') -> V
 <E> <V> <_>END(;)
 <E> <E> <_>WS(
)
10 > . void qemu_del_nic(NICState *test);
10 > EEVVVVVVVVVVVVVVVVVNVVVVVVVVVNVVVVVEE
10 >  ____________________________B_______
ERROR: spaces required around that '*' (ctx:WxV)
#10: FILE: include/net/net.h:136:
+void qemu_del_nic(NICState *test);
                            ^

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [Qemu-devel] [PATCH v4 11/40] hw/xen: Use the IEC binary prefix definitions
  2018-06-13 19:31           ` Richard Henderson
@ 2018-06-13 20:02             ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 70+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-13 20:02 UTC (permalink / raw)
  To: Richard Henderson, Eric Blake
  Cc: Thomas Huth, Stefan Weil, Kevin Wolf, Stefano Stabellini,
	Eduardo Habkost, open list:Block layer core, Michael S. Tsirkin,
	qemu-trivial, qemu-devel, Max Reitz, Paolo Bonzini,
	Anthony Perard, Richard Henderson

On 06/13/2018 04:31 PM, Richard Henderson wrote:
> On 06/13/2018 02:13 AM, Eric Blake wrote:
>> Or spell it UINT64_C(1) if you don't want a cast.
> 
> Not unsigned is what I want most.

I used both of your suggestions, but now new format string errors
appeared due to ram_addr_t being unsigned, so code cleaned using
MachineState->ram_size now complains.

include/exec/cpu-common.h:53:typedef uintptr_t ram_addr_t;
include/hw/boards.h:259:    ram_addr_t ram_size;

Is the following snippet OK?

     /* allocate RAM */
-    if (ram_size > (2048u << 20)) {
-        error_report("Too much memory for this machine: %dMB, maximum
2048MB",
-                     ((unsigned int)ram_size / (1 << 20)));
+    if (ram_size > 2 * GiB) {
+        error_report("Too much memory for this machine: %luMB, maximum
2048MB",
+                     ram_size / MiB);
         exit(1);
     }

^ permalink raw reply	[flat|nested] 70+ messages in thread

end of thread, other threads:[~2018-06-13 20:03 UTC | newest]

Thread overview: 70+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-11  1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 01/40] include: Add IEC binary prefixes in "qemu/units.h" Philippe Mathieu-Daudé
2018-06-12 20:42   ` Richard Henderson
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 02/40] vdi: Use definitions from "qemu/units.h" Philippe Mathieu-Daudé
2018-06-11 19:27   ` Stefan Weil
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 03/40] x86/cpu: " Philippe Mathieu-Daudé
2018-06-11 18:42   ` Eduardo Habkost
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 04/40] checkpatch: Recognize IEC binary prefix definitions Philippe Mathieu-Daudé
2018-06-13 19:54   ` Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 05/40] hw: Use IEC binary prefix definitions from "qemu/units.h" Philippe Mathieu-Daudé
2018-06-11  2:11   ` David Gibson
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 06/40] hw: Directly use "qemu/units.h" instead of "qemu/cutils.h" Philippe Mathieu-Daudé
2018-06-11  2:16   ` David Gibson
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 07/40] hw/ivshmem: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 08/40] hw/ipack: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 09/40] hw/scsi: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 10/40] hw/smbios: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 11/40] hw/xen: " Philippe Mathieu-Daudé
2018-06-11  1:14   ` Philippe Mathieu-Daudé
2018-06-12 20:51   ` [Qemu-devel] " Richard Henderson
2018-06-12 20:51   ` Richard Henderson
2018-06-12 21:04     ` Eric Blake
2018-06-12 21:04     ` Eric Blake
2018-06-12 21:10       ` Richard Henderson
2018-06-12 21:10       ` Richard Henderson
2018-06-13 12:13         ` Eric Blake
2018-06-13 19:31           ` Richard Henderson
2018-06-13 19:31           ` Richard Henderson
2018-06-13 20:02             ` Philippe Mathieu-Daudé
2018-06-13 12:13         ` Eric Blake
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 12/40] hw/tpm: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 13/40] hw/block: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 14/40] hw/display: " Philippe Mathieu-Daudé
2018-06-11  1:14   ` Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 15/40] hw/misc: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 16/40] hw/riscv: " Philippe Mathieu-Daudé
2018-06-11  1:22   ` Michael Clark
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 17/40] hw/m68k: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 18/40] hw/sparc: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 19/40] hw/s390x: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 20/40] hw/hppa: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 21/40] hw/xtensa: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 22/40] hw/alpha: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 23/40] hw/tricore: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 24/40] hw/microblaze: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 25/40] hw/nios2: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 26/40] hw/cris: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 27/40] hw/lm32: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 28/40] hw/sh4: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 29/40] hw/mips/r4k: Constify params_size Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 30/40] hw/mips: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 32/40] hw/ppc: " Philippe Mathieu-Daudé
2018-06-11  8:09   ` [Qemu-devel] [Qemu-ppc] " BALATON Zoltan
2018-06-11 15:44     ` Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 34/40] hw/net: " Philippe Mathieu-Daudé
2018-06-11 19:20   ` Stefan Weil
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 35/40] hw/usb: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 36/40] hw/sd: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 37/40] hw/vfio: " Philippe Mathieu-Daudé
2018-06-11  1:14 ` [Qemu-devel] [PATCH v4 38/40] hw/virtio: " Philippe Mathieu-Daudé
2018-06-11  1:15 ` [Qemu-devel] [PATCH v4 39/40] hw/rdma: " Philippe Mathieu-Daudé
2018-06-11  1:15 ` [Qemu-devel] [PATCH v4 40/40] cutils: Do not include "qemu/units.h" directly Philippe Mathieu-Daudé
     [not found] ` <20180611011501.10235-34-f4bug@amsat.org>
2018-06-11  2:18   ` [Qemu-devel] [PATCH v4 33/40] hw/i386: Use the IEC binary prefix definitions Michael S. Tsirkin
2018-06-11  2:29     ` Philippe Mathieu-Daudé
2018-06-11  2:22 ` [Qemu-devel] [PATCH v4 00/40] " Michael S. Tsirkin
2018-06-11  2:32   ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2018-06-11 15:55 ` [Qemu-devel] " Eric Blake
2018-06-11 16:11   ` Peter Maydell
2018-06-11 16:27   ` Michael S. Tsirkin
2018-06-11 16:18 ` Cornelia Huck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.