Skip to contentSkip to conversation

various easy cleanups

PATCH Applied Philippe Mathieu-Daudé 9 participants 39 messages May 8, 2017 – Sep 5, 2017

lore
Share & tools
lore
#0 lore raw

cover various easy cleanups

various easy patchs added while coding around:
- remove old comments
- add/remove includes
- use TYPE_ names when available
- use ARRAY_SIZE() macro

Philippe Mathieu-Daudé (11):
hw/net: removed obsolete comments
hw/pci: define msi_nonbroken in pci-stub
hw/misc: add missing includes
ide/ahci: add missing includes
hw/mips: add missing include
hw/arm: removed unnecessary include
hw/arm: use defined type name instead of hard-coded string. hw/sparc: use ARRAY_SIZE() macro
target/sparc: fix DEBUG_MMU DPRINTF() arguments
register: display register prefix (name) since it is available
MAINTAINERS: self-appoint me as reviewer of the Register API

 MAINTAINERS                |  1 +
 hw/arm/armv7m.c            |  4 ++--
 hw/arm/exynos4210.c        |  4 ++--
 hw/arm/highbank.c          | 11 +++++++----
 hw/arm/realview.c          |  6 ++++--
 hw/arm/vexpress.c          |  6 ++++--
 hw/arm/xilinx_zynq.c       | 14 ++++++++------
 hw/core/register.c         |  8 ++++----
 hw/net/pcnet-pci.c         | 10 ----------
 hw/pci/pci-stub.c          |  3 +++
 hw/sparc64/sun4u.c         |  2 +-
 include/hw/arm/arm.h       |  1 -
 include/hw/ide/ahci.h      |  2 ++
 include/hw/mips/mips.h     |  1 +
 include/hw/misc/unimp.h    |  3 +++
 target/sparc/ldst_helper.c |  4 ++--
 16 files changed, 44 insertions(+), 36 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/11 hw/net: removed obsolete comments

---
 hw/net/pcnet-pci.c | 10 ----------
 1 file changed, 10 deletions(-)
hw/net/pcnet-pci.c +0 -10
index 0acf8a4879..bdb533436e 100644
@@ -38,14 +38,6 @@
 
 #include "pcnet.h"
 
-//#define PCNET_DEBUG
-//#define PCNET_DEBUG_IO
-//#define PCNET_DEBUG_BCR
-//#define PCNET_DEBUG_CSR
-//#define PCNET_DEBUG_RMD
-//#define PCNET_DEBUG_TMD
-//#define PCNET_DEBUG_MATCH
-
 #define TYPE_PCI_PCNET "pcnet"
 
 #define PCI_PCNET(obj) \
@@ -239,8 +231,6 @@ static const VMStateDescription vmstate_pci_pcnet = {
     }
 };
 
-/* PCI interface */
-
 static const MemoryRegionOps pcnet_mmio_ops = {
     .old_mmio = {
         .read = { pcnet_mmio_readb, pcnet_mmio_readw, pcnet_mmio_readl },
Signature · 1 line
2.11.0
#2 lore raw

Re: [Qemu-devel] [PATCH 01/11] hw/net: removed obsolete comments

Quoted 11 lines · Philippe Mathieu-Daudé
---
 hw/net/pcnet-pci.c | 10 ----------
 1 file changed, 10 deletions(-)
hw/net/pcnet-pci.c +0 -0
index 0acf8a4879..bdb533436e 100644
@@ -38,14 +38,6 @@
 

hw/net/pcnet-pci.c line 48

Quoted 10 lines
hw/net/pcnet-pci.c +0 -8
 #include "pcnet.h"
 
-//#define PCNET_DEBUG
-//#define PCNET_DEBUG_IO
-//#define PCNET_DEBUG_BCR
-//#define PCNET_DEBUG_CSR
-//#define PCNET_DEBUG_RMD
-//#define PCNET_DEBUG_TMD
-//#define PCNET_DEBUG_MATCH
-

I guess - although I notice there are some #if 0's in the file that could be converted to proper non-bitrotting debug prints or removed as well.

hw/net/pcnet-pci.c static const VMStateDescription vmstate_pci_pcnet = { · line 243

Quoted 9 lines
hw/net/pcnet-pci.c +0 -2
 #define TYPE_PCI_PCNET "pcnet"
 
 #define PCI_PCNET(obj) \
@@ -239,8 +231,6 @@ static const VMStateDescription vmstate_pci_pcnet = {
     }
 };
 
-/* PCI interface */
-

Was this intentional?

hw/net/pcnet-pci.c static const VMStateDescription vmstate_pci_pcnet = { · line 236

Quoted 3 lines
hw/net/pcnet-pci.c +0 -0
 static const MemoryRegionOps pcnet_mmio_ops = {
     .old_mmio = {
         .read = { pcnet_mmio_readb, pcnet_mmio_readw, pcnet_mmio_readl },

--
Alex Bennée

#3 lore raw

RFC PATCH 2/11 hw/pci: define msi_nonbroken in pci-stub

In reply to Philippe Mathieu-Daudé

This field is accessed in hw/intc/arm_gicv[23*].c

---
 hw/pci/pci-stub.c | 3 +++
 1 file changed, 3 insertions(+)
hw/pci/pci-stub.c +3 -0
index 36d2c430c5..ecad664946 100644
@@ -24,6 +24,9 @@
 #include "qapi/qmp/qerror.h"
 #include "hw/pci/pci.h"
 #include "qmp-commands.h"
+#include "hw/pci/msi.h"
+
+bool msi_nonbroken;
 
 PciInfoList *qmp_query_pci(Error **errp)
 {
Signature · 1 line
2.11.0
#4 lore raw

Re: [Qemu-devel] [RFC PATCH 02/11] hw/pci: define msi_nonbroken in pci-stub

Quoted 1 line · Philippe Mathieu-Daudé

This field is accessed in hw/intc/arm_gicv[23*].c

default-configs/arm-softmmu.mak sets CONFIG_PCI, so this should not be necessary, I think. Otherwise, you should extend your patch description, to elaborate on what you're trying to do here.

Thomas

#5 lore raw

Re: [Qemu-devel] [RFC PATCH 02/11] hw/pci: define msi_nonbroken in pci-stub

Hi Thomas,

Quoted 8 lines · Thomas Huth
Quoted 1 line · Philippe Mathieu-Daudé

This field is accessed in hw/intc/arm_gicv[23*].c

default-configs/arm-softmmu.mak sets CONFIG_PCI, so this should not be necessary, I think. Otherwise, you should extend your patch description, to elaborate on what you're trying to do here.

Thomas

Sure, I'm willing to add basic support for the TI Hercules MCU which is a big endian SoC (without PCI support).

I'm using the following config:

$ cat default-configs/armeb-softmmu.mak
# Default configuration for armeb-softmmu
CONFIG_ECC=y
CONFIG_SERIAL=y
CONFIG_PTIMER=y
CONFIG_SD=y
CONFIG_SSI=y
#CONFIG_USB=y
CONFIG_PLATFORM_BUS=y
CONFIG_ARM_V7M=y
CONFIG_ARM_GIC=y
CONFIG_ARM_TIMER=y
CONFIG_PL011=y
CONFIG_PL022=y
CONFIG_PL031=y
CONFIG_PL041=y
CONFIG_PL050=y
CONFIG_PL061=y
CONFIG_PL080=y
CONFIG_PL181=y
CONFIG_PL190=y
CONFIG_PL310=y
CONFIG_PL330=y
CONFIG_BITBANG_I2C=y
CONFIG_GPIO_KEY=y
CONFIG_HERCULES=y

I had to modify default-configs/arm-softmmu.mak to restrict a bit hw/arm/Makefile.objs, see:

https://github.com/qemu/qemu/compare/master...philmd:armeb_wip

In this branch I run:

$ ../configure --target-list=armeb-softmmu && make -j
[...]
  LINK    armeb-softmmu/qemu-system-armeb
../hw/intc/arm_gicv2m.o: In function `gicv2m_realize':
qemu/hw/intc/arm_gicv2m.c:154: undefined reference to `msi_nonbroken'
../hw/intc/arm_gicv3_its_common.o: In function `gicv3_its_init_mmio':
qemu/hw/intc/arm_gicv3_its_common.c:110: undefined reference to `msi_nonbroken'
collect2: error: ld returned 1 exit status
Makefile:201: recipe for target 'qemu-system-armeb' failed
make[1]: *** [qemu-system-armeb] Error 1
Makefile:327: recipe for target 'subdir-armeb-softmmu' failed
make: *** [subdir-armeb-softmmu] Error 2

This MCU does not use a GIC so I can also remove it, but this error seems odd to me.

As I understand the 'msi_nonbroken' is a kludge (there is no intrinsic relationship between PCI/MSI and this particular interrupt controller). Since it is declared as extern in "hw/pci/msi.h" why not define it in pci-stub?

Regards,

Phil.

#6 lore raw

Re: [Qemu-arm] [Qemu-devel] [RFC PATCH 02/11] hw/pci: define msi_nonbroken in pci-stub

Hi Philippe,

Quoted 10 lines · Philippe Mathieu-Daudé

Hi Thomas,

Quoted 7 lines · Thomas Huth
Quoted 1 line · Philippe Mathieu-Daudé

This field is accessed in hw/intc/arm_gicv[23*].c

default-configs/arm-softmmu.mak sets CONFIG_PCI, so this should not be necessary, I think. Otherwise, you should extend your patch description, to elaborate on what you're trying to do here.

Quoted 8 lines
Quoted 1 line

Thomas

Sure, I'm willing to add basic support for the TI Hercules MCU which is a big endian SoC (without PCI support).

I'm using the following config:

$ cat default-configs/armeb-softmmu.mak
$ cat default-configs/armeb-softmmu.mak
cat: default-configs/armeb-softmmu.mak: No such file or directory

... so you're planning for a new armeb config file here? That's the kind of information that I was missing in the patch description.

[...]

Quoted 4 lines

As I understand the 'msi_nonbroken' is a kludge (there is no intrinsic relationship between PCI/MSI and this particular interrupt controller). Since it is declared as extern in "hw/pci/msi.h" why not define it in pci-stub?

Sure, your patch is fine, IMHO it just lacks some rationale in its description.

Thomas

#7 lore raw

PATCH 3/11 hw/misc: add missing includes

In reply to Philippe Mathieu-Daudé
---
 include/hw/misc/unimp.h | 3 +++
 1 file changed, 3 insertions(+)
include/hw/misc/unimp.h +3 -0
index 3462d85836..353ee19abf 100644
@@ -8,6 +8,9 @@
 #ifndef HW_MISC_UNIMP_H
 #define HW_MISC_UNIMP_H
 
+#include "qemu/osdep.h"
+#include "hw/sysbus.h"
+
 #define TYPE_UNIMPLEMENTED_DEVICE "unimplemented-device"
 
 /**
Signature · 1 line
2.11.0
#8 lore raw

Re: [Qemu-devel] [PATCH 03/11] hw/misc: add missing includes

Quoted 10 lines · Philippe Mathieu-Daudé
---
 include/hw/misc/unimp.h | 3 +++
 1 file changed, 3 insertions(+)
include/hw/misc/unimp.h +0 -0
index 3462d85836..353ee19abf 100644

include/hw/misc/unimp.h line 11

Quoted 4 lines
include/hw/misc/unimp.h +1 -0
@@ -8,6 +8,9 @@
 #ifndef HW_MISC_UNIMP_H
 #define HW_MISC_UNIMP_H
 
+#include "qemu/osdep.h"

NACK. .h files should not include osdep.h, because the .c file that is using the .h file should have already done so. This is mentioned in HACKING.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#9 lore raw

Re: [Qemu-devel] [PATCH 03/11] hw/misc: add missing includes

Quoted 14 lines · Eric Blake
Quoted 13 lines · Philippe Mathieu-Daudé
---
 include/hw/misc/unimp.h | 3 +++
 1 file changed, 3 insertions(+)
include/hw/misc/unimp.h +0 -0
index 3462d85836..353ee19abf 100644
@@ -8,6 +8,9 @@
 #ifndef HW_MISC_UNIMP_H
 #define HW_MISC_UNIMP_H
 
Quoted 5 lines

include/hw/misc/unimp.h line 11

Quoted 1 line
include/hw/misc/unimp.h +1 -0
+#include "qemu/osdep.h"

NACK. .h files should not include osdep.h, because the .c file that is using the .h file should have already done so. This is mentioned in HACKING.

Ok! Indeed my .c doesn't include osdep.h, sorry for the noise.

#10 lore raw

Re: [Qemu-devel] [PATCH 03/11] hw/misc: add missing includes

Hi Eric,

Quoted 15 lines · Philippe Mathieu-Daudé
Quoted 14 lines · Eric Blake
Quoted 13 lines · Philippe Mathieu-Daudé
---
 include/hw/misc/unimp.h | 3 +++
 1 file changed, 3 insertions(+)
include/hw/misc/unimp.h +0 -0
index 3462d85836..353ee19abf 100644
@@ -8,6 +8,9 @@
 #ifndef HW_MISC_UNIMP_H
 #define HW_MISC_UNIMP_H
 
Quoted 7 lines
Quoted 5 lines

include/hw/misc/unimp.h line 11

Quoted 1 line
include/hw/misc/unimp.h +1 -0
+#include "qemu/osdep.h"

NACK. .h files should not include osdep.h, because the .c file that is using the .h file should have already done so. This is mentioned in HACKING.

Ok! Indeed my .c doesn't include osdep.h, sorry for the noise.

I attentively read the HACKING after a good night's sleep.

What about the other include, "hw/sysbus.h"?
The inlined function create_unimplemented_device() calls sysbus_mmio_map_overlap(). Anyone willing to use "hw/misc/unimp.h" will get a compilation failure if he does not include "hw/sysbus.h" and I don't think it belongs to "qemu/osdep.h".

Regards,

Phil.

#11 lore raw

Re: [Qemu-devel] [PATCH 03/11] hw/misc: add missing includes

Quoted 5 lines · Philippe Mathieu-Daudé

What about the other include, "hw/sysbus.h"?
The inlined function create_unimplemented_device() calls sysbus_mmio_map_overlap(). Anyone willing to use "hw/misc/unimp.h" will get a compilation failure if he does not include "hw/sysbus.h" and I don't think it belongs to "qemu/osdep.h".

That one's probably okay.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#12 lore raw

Re: [Qemu-devel] [PATCH 03/11] hw/misc: add missing includes

In reply to Eric Blake
Quoted 13 lines · Eric Blake
Quoted 13 lines
---
  include/hw/misc/unimp.h | 3 +++
  1 file changed, 3 insertions(+)
include/hw/misc/unimp.h +0 -0
index 3462d85836..353ee19abf 100644
@@ -8,6 +8,9 @@
  #ifndef HW_MISC_UNIMP_H
  #define HW_MISC_UNIMP_H
 
Quoted 5 lines

include/hw/misc/unimp.h line 11

Quoted 1 line
include/hw/misc/unimp.h +1 -0
+#include "qemu/osdep.h"

NACK. .h files should not include osdep.h, because the .c file that is using the .h file should have already done so. This is mentioned in HACKING.

I'm not sure this kind of mistake happens often enough, but it might worth add a such test in checkpatch.pl (easier to say than to implement :p)

#13 lore raw

Re: [Qemu-devel] [PATCH 03/11] hw/misc: add missing includes

Quoted 2 lines · Philippe Mathieu-Daudé

I'm not sure this kind of mistake happens often enough, but it might worth add a such test in checkpatch.pl (easier to say than to implement :p)

It doesn't run automatically, but you can run scripts/clean-includes on your new files to remove unneeded includes and add osdep.h if it's missing.

thanks
-- PMM

#14 lore raw

PATCH 4/11 ide/ahci: add missing includes

In reply to Philippe Mathieu-Daudé

qemu/include/hw/ide/ahci.h:260:16: error: field ‘sglist’ has incomplete type

     QEMUSGList sglist;
                ^~~~~~
/qemu/include/hw/ide/ahci.h:272:5: error: unknown type name ‘IDEDMA’
     IDEDMA dma;
     ^~~~~~
qemu/include/hw/ide/ahci.h:273:5: error: unknown type name ‘IDEBus’
     IDEBus port;
     ^~~~~~
qemu/include/hw/ide/ahci.h:305:15: error: field ‘parent_obj’ has incomplete type
     PCIDevice parent_obj;
               ^~~~~~~~~~
---
 include/hw/ide/ahci.h | 2 ++
 1 file changed, 2 insertions(+)
include/hw/ide/ahci.h +2 -0
index 0ca7c65820..293f9ebcd0 100644
@@ -25,6 +25,8 @@
 #define HW_IDE_AHCI_H
 
 #include "hw/sysbus.h"
+#include "hw/ide/internal.h"
+#include "sysemu/dma.h"
 
 #define AHCI_MEM_BAR_SIZE         0x1000
 #define AHCI_MAX_PORTS            32
Signature · 1 line
2.11.0
#15 lore raw

Re: [Qemu-devel] [PATCH 04/11] ide/ahci: add missing includes

Quoted 3 lines · Philippe Mathieu-Daudé

qemu/include/hw/ide/ahci.h:260:16: error: field ‘sglist’ has incomplete type

     QEMUSGList sglist;
                ^~~~~~

What are you doing to get this compilation error (configure options, platform, compiler, etc)? I can't reproduce it. Is it something that pops up later when you remove includes from somewhere else, and you're just pre-emptively adding includes here to allow removal of includes later?

Quoted 29 lines

/qemu/include/hw/ide/ahci.h:272:5: error: unknown type name ‘IDEDMA’

     IDEDMA dma;
     ^~~~~~
qemu/include/hw/ide/ahci.h:273:5: error: unknown type name ‘IDEBus’
     IDEBus port;
     ^~~~~~
qemu/include/hw/ide/ahci.h:305:15: error: field ‘parent_obj’ has incomplete type
     PCIDevice parent_obj;
               ^~~~~~~~~~
---
 include/hw/ide/ahci.h | 2 ++
 1 file changed, 2 insertions(+)
include/hw/ide/ahci.h +2 -0
index 0ca7c65820..293f9ebcd0 100644
@@ -25,6 +25,8 @@
 #define HW_IDE_AHCI_H
 
 #include "hw/sysbus.h"
+#include "hw/ide/internal.h"
+#include "sysemu/dma.h"
 
 #define AHCI_MEM_BAR_SIZE         0x1000
 #define AHCI_MAX_PORTS            32
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#16 lore raw

Re: [Qemu-devel] [PATCH 04/11] ide/ahci: add missing includes

Quoted 10 lines · Eric Blake
Quoted 3 lines · Philippe Mathieu-Daudé

qemu/include/hw/ide/ahci.h:260:16: error: field ‘sglist’ has incomplete type

     QEMUSGList sglist;
                ^~~~~~

What are you doing to get this compilation error (configure options, platform, compiler, etc)? I can't reproduce it. Is it something that pops up later when you remove includes from somewhere else, and you're just pre-emptively adding includes here to allow removal of includes later?

"What he said," but if I had to guess, Philippe is testing that each header can be compiled separately.

Quoted 29 lines
Quoted 28 lines

/qemu/include/hw/ide/ahci.h:272:5: error: unknown type name ‘IDEDMA’

     IDEDMA dma;
     ^~~~~~
qemu/include/hw/ide/ahci.h:273:5: error: unknown type name ‘IDEBus’
     IDEBus port;
     ^~~~~~
qemu/include/hw/ide/ahci.h:305:15: error: field ‘parent_obj’ has incomplete type
     PCIDevice parent_obj;
               ^~~~~~~~~~
---
 include/hw/ide/ahci.h | 2 ++
 1 file changed, 2 insertions(+)
include/hw/ide/ahci.h +1 -0
index 0ca7c65820..293f9ebcd0 100644
@@ -25,6 +25,8 @@
 #define HW_IDE_AHCI_H
 
 #include "hw/sysbus.h"
+#include "hw/ide/internal.h">> +#include "sysemu/dma.h"
 
 #define AHCI_MEM_BAR_SIZE         0x1000
 #define AHCI_MAX_PORTS            32
#17 lore raw

cover ide/ahci: add missing includes

Hi Eric, John.

The patch 07/11 "hw/arm: use defined type name instead of hard-coded string." triggered this problem.

I split the previous series to only include the 2 commits involved to reproduce.

As you will see, calxeda_init() from highbank.c uses the sysbus type name "sysbus-ahci" which is already defined in "hw/ide/ahci.h" as TYPE_SYSBUS_AHCI. As mentioned in HACKING highbank.c first include is "qemu/osdep.h". However compiling highbank.c fails (as reported in patch "04/11" commit comments).

I don't think appropriate to include "hw/ide/internal.h" and "sysemu/dma.h" in highbank.c. Eventually another source including "hw/ide/ahci.h" will hit the same error.

Do you see another place where those includes should go?

I think I did a mistake sending these both patchs in a series thinking they were unrelated, I should have send them altogether, my bad :/

Regards,

Phil.

Philippe Mathieu-Daudé (2):
arm/highbank: use defined type name instead of hard-coded string ide/ahci: add missing includes

 hw/arm/highbank.c     | 3 ++-
 include/hw/ide/ahci.h | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
2.11.0
#18 lore raw

RFC PATCH 1/2 arm/highbank: use defined type name instead of hard-coded string

---
 hw/arm/highbank.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/arm/highbank.c +2 -1
index d209b97dee..dd809b404b 100644
@@ -31,6 +31,7 @@
 #include "exec/address-spaces.h"
 #include "qemu/error-report.h"
 #include "hw/char/pl011.h"
+#include "hw/ide/ahci.h"
 
 #define SMP_BOOT_ADDR           0x100
 #define SMP_BOOT_REG            0x40
@@ -341,7 +342,7 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
     sysbus_create_simple("pl031", 0xfff35000, pic[19]);
     sysbus_create_simple("pl022", 0xfff39000, pic[23]);
 
-    sysbus_create_simple("sysbus-ahci", 0xffe08000, pic[83]);
+    sysbus_create_simple(TYPE_SYSBUS_AHCI, 0xffe08000, pic[83]);
 
     if (nd_table[0].used) {
         qemu_check_nic_model(&nd_table[0], "xgmac");
Signature · 1 line
2.11.0
#19 lore raw

Re: [Qemu-devel] [RFC PATCH 1/2] arm/highbank: use defined type name instead of hard-coded string

Quoted 19 lines · Philippe Mathieu-Daudé
---
 hw/arm/highbank.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/arm/highbank.c +1 -0
index d209b97dee..dd809b404b 100644
@@ -31,6 +31,7 @@
 #include "exec/address-spaces.h"
 #include "qemu/error-report.h"
 #include "hw/char/pl011.h"
+#include "hw/ide/ahci.h"
 
 #define SMP_BOOT_ADDR           0x100
 #define SMP_BOOT_REG            0x40

hw/arm/highbank.c static void calxeda_init(MachineState *machine, enum cxmachines machine_id) · line 348

Quoted 8 lines
hw/arm/highbank.c +1 -1
@@ -341,7 +342,7 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
     sysbus_create_simple("pl031", 0xfff35000, pic[19]);
     sysbus_create_simple("pl022", 0xfff39000, pic[23]);
 
-    sysbus_create_simple("sysbus-ahci", 0xffe08000, pic[83]);
+    sysbus_create_simple(TYPE_SYSBUS_AHCI, 0xffe08000, pic[83]);
 
     if (nd_table[0].used) {
         qemu_check_nic_model(&nd_table[0], "xgmac");

This patch is fine, I took a stab at fixing the include issues in a separate series. Try it all out and let me know.

--js

#20 lore raw

Re: [Qemu-devel] [RFC PATCH 1/2] arm/highbank: use defined type name instead of hard-coded string

Quoted 2 lines · John Snow

This patch is fine, I took a stab at fixing the include issues in a separate series. Try it all out and let me know.

Thank John, your series does fix my include issues :)

#21 lore raw

RFC PATCH 2/2 ide/ahci: add missing includes

In reply to Philippe Mathieu-Daudé

CC arm-softmmu/hw/arm/highbank.o
In file included from qemu/hw/arm/highbank.c:34:0:
qemu/include/hw/ide/ahci.h:260:16: error: field ‘sglist’ has incomplete type

     QEMUSGList sglist;
                ^~~~~~
/qemu/include/hw/ide/ahci.h:272:5: error: unknown type name ‘IDEDMA’
     IDEDMA dma;
     ^~~~~~
qemu/include/hw/ide/ahci.h:273:5: error: unknown type name ‘IDEBus’
     IDEBus port;
     ^~~~~~
qemu/include/hw/ide/ahci.h:305:15: error: field ‘parent_obj’ has incomplete type
     PCIDevice parent_obj;
               ^~~~~~~~~~

qemu/rules.mak:69: recipe for target 'hw/arm/highbank.o' failed make[1]: *** [hw/arm/highbank.o] Error 1
make: *** [subdir-arm-softmmu] Error 2

---
 include/hw/ide/ahci.h | 2 ++
 1 file changed, 2 insertions(+)
include/hw/ide/ahci.h +2 -0
index 0ca7c65820..293f9ebcd0 100644
@@ -25,6 +25,8 @@
 #define HW_IDE_AHCI_H
 
 #include "hw/sysbus.h"
+#include "hw/ide/internal.h"
+#include "sysemu/dma.h"
 
 #define AHCI_MEM_BAR_SIZE         0x1000
 #define AHCI_MAX_PORTS            32
Signature · 1 line
2.11.0
#22 lore raw

PATCH 5/11 hw/mips: add missing include

In reply to Philippe Mathieu-Daudé
---
 include/hw/mips/mips.h | 1 +
 1 file changed, 1 insertion(+)
include/hw/mips/mips.h +1 -0
index e0065ce808..16412dc150 100644
@@ -6,6 +6,7 @@
 #define INITRD_PAGE_MASK (~((1 << 16) - 1))
 
 #include "exec/memory.h"
+#include "hw/irq.h"
 
 /* gt64xxx.c */
 PCIBus *gt64120_register(qemu_irq *pic);
Signature · 1 line
2.11.0
Acked-by on v1 5/11
#23 lore raw

Re: [Qemu-devel] [PATCH 05/11] hw/mips: add missing include

Quoted 10 lines · Philippe Mathieu-Daudé
---
 include/hw/mips/mips.h | 1 +
 1 file changed, 1 insertion(+)
include/hw/mips/mips.h +0 -0
index e0065ce808..16412dc150 100644

include/hw/mips/mips.h line 12

Quoted 7 lines
include/hw/mips/mips.h +1 -0
@@ -6,6 +6,7 @@
 #define INITRD_PAGE_MASK (~((1 << 16) - 1))
 
 #include "exec/memory.h"
+#include "hw/irq.h"
 
 /* gt64xxx.c */
 PCIBus *gt64120_register(qemu_irq *pic);
Signature · 2 lines
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
[email protected]                 http://www.aurel32.net
#25 lore raw

PATCH 6/11 hw/arm: removed unnecessary include

In reply to Philippe Mathieu-Daudé

"exec/memory.h" already includes it.

---
 include/hw/arm/arm.h | 1 -
 1 file changed, 1 deletion(-)
include/hw/arm/arm.h +0 -1
index a3f79d3379..b9c11d3fb8 100644
@@ -14,7 +14,6 @@
 #include "exec/memory.h"
 #include "target/arm/cpu-qom.h"
 #include "hw/irq.h"
-#include "qemu/notify.h"
 
 typedef enum {
     ARM_ENDIANNESS_UNKNOWN = 0,
Signature · 1 line
2.11.0
#26 lore raw

Re: [Qemu-devel] [PATCH 06/11] hw/arm: removed unnecessary include

Quoted 1 line · Philippe Mathieu-Daudé

"exec/memory.h" already includes it.

I think this sort of include cleanups isn't really necessary. For a regular include file, it's better to include it if the .c file in question uses definitions from there, no matter if other .h files include that header already or not.

Thanks,

/mjt

Quoted 18 lines
---
 include/hw/arm/arm.h | 1 -
 1 file changed, 1 deletion(-)
include/hw/arm/arm.h +0 -1
index a3f79d3379..b9c11d3fb8 100644
@@ -14,7 +14,6 @@
 #include "exec/memory.h"
 #include "target/arm/cpu-qom.h"
 #include "hw/irq.h"
-#include "qemu/notify.h"
 
 typedef enum {
     ARM_ENDIANNESS_UNKNOWN = 0,
#27 lore raw

Re: [Qemu-arm] [PATCH 06/11] hw/arm: removed unnecessary include

Quoted 4 lines · Michael Tokarev
Quoted 1 line · Philippe Mathieu-Daudé

"exec/memory.h" already includes it.

I think this sort of include cleanups isn't really necessary.

Some are useful ;)

Quoted 3 lines

For a regular include file, it's better to include it if the .c file in question uses definitions from there, no matter if other .h files include that header already or not.

Ok. This one was incorrect anyway :( thank for the review!

Quoted 24 lines

Thanks,

/mjt

Quoted 18 lines
---
 include/hw/arm/arm.h | 1 -
 1 file changed, 1 deletion(-)
include/hw/arm/arm.h +0 -1
index a3f79d3379..b9c11d3fb8 100644
@@ -14,7 +14,6 @@
 #include "exec/memory.h"
 #include "target/arm/cpu-qom.h"
 #include "hw/irq.h"
-#include "qemu/notify.h"
 
 typedef enum {
     ARM_ENDIANNESS_UNKNOWN = 0,
#28 lore raw

PATCH 8/11 hw/sparc: use ARRAY_SIZE() macro

In reply to Philippe Mathieu-Daudé
---
 hw/sparc64/sun4u.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/sparc64/sun4u.c +1 -1
index d347b6616d..525d6f44a0 100644
@@ -214,7 +214,7 @@ static void isa_irq_handler(void *opaque, int n, int level)
     qemu_irq *irqs = opaque;
     int ivec;
 
-    assert(n < 16);
+    assert(n < ARRAY_SIZE(isa_irq_to_ivec));
     ivec = isa_irq_to_ivec[n];
     EBUS_DPRINTF("Set ISA IRQ %d level %d -> ivec 0x%x\n", n, level, ivec);
     if (ivec) {
Signature · 1 line
2.11.0
Reviewed-by on v1 8/11
#29 lore raw

Re: [Qemu-devel] [PATCH 08/11] hw/sparc: use ARRAY_SIZE() macro

Quoted 10 lines · Philippe Mathieu-Daudé
---
 hw/sparc64/sun4u.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/sparc64/sun4u.c +0 -0
index d347b6616d..525d6f44a0 100644

hw/sparc64/sun4u.c static void isa_irq_handler(void *opaque, int n, int level) · line 220

Quoted 8 lines
hw/sparc64/sun4u.c +1 -1
@@ -214,7 +214,7 @@ static void isa_irq_handler(void *opaque, int n, int level)
     qemu_irq *irqs = opaque;
     int ivec;
 
-    assert(n < 16);
+    assert(n < ARRAY_SIZE(isa_irq_to_ivec));
     ivec = isa_irq_to_ivec[n];
     EBUS_DPRINTF("Set ISA IRQ %d level %d -> ivec 0x%x\n", n, level, ivec);
     if (ivec) {

--
Alex Bennée

#31 lore raw

PATCH 9/11 target/sparc: fix DEBUG_MMU DPRINTF() arguments

In reply to Philippe Mathieu-Daudé

invalid since 96df2bc99f9

---
 target/sparc/ldst_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/sparc/ldst_helper.c +2 -2
index 57968d9143..aa83a49a88 100644
@@ -1631,7 +1631,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val,
 
             if (oldreg != env->immu.mmuregs[reg]) {
                 DPRINTF_MMU("immu change reg[%d]: 0x%016" PRIx64 " -> 0x%016"
-                            PRIx64 "\n", reg, oldreg, env->immuregs[reg]);
+                            PRIx64 "\n", reg, oldreg, env->immu.mmuregs[reg]);
             }
 #ifdef DEBUG_MMU
             dump_mmu(stdout, fprintf, env);
@@ -1715,7 +1715,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val,
 
             if (oldreg != env->dmmu.mmuregs[reg]) {
                 DPRINTF_MMU("dmmu change reg[%d]: 0x%016" PRIx64 " -> 0x%016"
-                            PRIx64 "\n", reg, oldreg, env->dmmuregs[reg]);
+                            PRIx64 "\n", reg, oldreg, env->dmmu.mmuregs[reg]);
             }
 #ifdef DEBUG_MMU
             dump_mmu(stdout, fprintf, env);
Signature · 1 line
2.11.0
#32 lore raw

Re: [Qemu-devel] [PATCH 09/11] target/sparc: fix DEBUG_MMU DPRINTF() arguments

Quoted 12 lines · Philippe Mathieu-Daudé

invalid since 96df2bc99f9

---
 target/sparc/ldst_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/sparc/ldst_helper.c +0 -0
index 57968d9143..aa83a49a88 100644

target/sparc/ldst_helper.c void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, · line 1634

Quoted 5 lines
target/sparc/ldst_helper.c +1 -1
@@ -1631,7 +1631,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val,
 
             if (oldreg != env->immu.mmuregs[reg]) {
                 DPRINTF_MMU("immu change reg[%d]: 0x%016" PRIx64 " -> 0x%016"
-                            PRIx64 "\n", reg, oldreg, env->immuregs[reg]);
+                            PRIx64 "\n", reg, oldreg, env->immu.mmuregs[reg]);

Please take this opportunity to fix the broken definitions of DPRINTF_MMU() and friends so that they don't bit-rot when not defined. There are plenty of other examples of re-writing broken #defines to instead favor an if (0) { printf(...) } to benefit from -Wformat checking even when the debugging is disabled.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#33 lore raw

Re: [Qemu-devel] [PATCH 09/11] target/sparc: fix DEBUG_MMU DPRINTF() arguments

Quoted 14 lines · Eric Blake
Quoted 13 lines · Philippe Mathieu-Daudé

invalid since 96df2bc99f9

---
 target/sparc/ldst_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/sparc/ldst_helper.c +0 -0
index 57968d9143..aa83a49a88 100644
@@ -1631,7 +1631,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val,
 
Quoted 10 lines

target/sparc/ldst_helper.c void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, · line 1634

Quoted 4 lines
target/sparc/ldst_helper.c +1 -1
             if (oldreg != env->immu.mmuregs[reg]) {
                 DPRINTF_MMU("immu change reg[%d]: 0x%016" PRIx64 " -> 0x%016"
-                            PRIx64 "\n", reg, oldreg, env->immuregs[reg]);
+                            PRIx64 "\n", reg, oldreg, env->immu.mmuregs[reg]);

Please take this opportunity to fix the broken definitions of DPRINTF_MMU() and friends so that they don't bit-rot when not defined. There are plenty of other examples of re-writing broken #defines to instead favor an if (0) { printf(...) } to benefit from -Wformat checking even when the debugging is disabled.

Sure, will do it.

#34 lore raw

PATCH 10/11 register: display register prefix (name) since it is available

In reply to Philippe Mathieu-Daudé
---
 hw/core/register.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/core/register.c +4 -4
index dc335a79a9..b5988c9cc3 100644
@@ -195,8 +195,8 @@ void register_write_memory(void *opaque, hwaddr addr,
     }
 
     if (!reg) {
-        qemu_log_mask(LOG_GUEST_ERROR, "Write to unimplemented register at " \
-                      "address: %#" PRIx64 "\n", addr);
+        qemu_log_mask(LOG_GUEST_ERROR, "%s: write to unimplemented register " \
+                      "at address: %#" PRIx64 "\n", reg_array->prefix, addr);
         return;
     }
 
@@ -224,8 +224,8 @@ uint64_t register_read_memory(void *opaque, hwaddr addr,
     }
 
     if (!reg) {
-        qemu_log_mask(LOG_GUEST_ERROR, "Read to unimplemented register at " \
-                      "address: %#" PRIx64 "\n", addr);
+        qemu_log_mask(LOG_GUEST_ERROR, "%s:  read to unimplemented register " \
+                      "at address: %#" PRIx64 "\n", reg_array->prefix, addr);
         return 0;
     }
 
Signature · 1 line
2.11.0
Reviewed-by on v1 10/11
#35 lore raw

Re: [Qemu-devel] [PATCH 10/11] register: display register prefix (name) since it is available

Quoted 1 line · Philippe Mathieu-Daudé

Thanks,

Alistair

Quoted 34 lines
---
 hw/core/register.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/core/register.c +4 -5
index dc335a79a9..b5988c9cc3 100644
@@ -195,8 +195,8 @@ void register_write_memory(void *opaque, hwaddr addr,
     }
 
     if (!reg) {
-        qemu_log_mask(LOG_GUEST_ERROR, "Write to unimplemented register at " \
-                      "address: %#" PRIx64 "\n", addr);
+        qemu_log_mask(LOG_GUEST_ERROR, "%s: write to unimplemented register " \
+                      "at address: %#" PRIx64 "\n", reg_array->prefix, addr);
         return;
     }
 
@@ -224,8 +224,8 @@ uint64_t register_read_memory(void *opaque, hwaddr addr,
     }
 
     if (!reg) {
-        qemu_log_mask(LOG_GUEST_ERROR, "Read to unimplemented register at " \
-                      "address: %#" PRIx64 "\n", addr);
+        qemu_log_mask(LOG_GUEST_ERROR, "%s:  read to unimplemented register " \
+                      "at address: %#" PRIx64 "\n", reg_array->prefix, addr);
         return 0;
     }
 
--

2.11.0

#37 lore raw

PATCH 11/11 MAINTAINERS: self-appoint me as reviewer of the Register API

In reply to Philippe Mathieu-Daudé
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index efdec47319..de32165059 100644
@@ -1431,6 +1431,7 @@ T: git git://repo.or.cz/qemu/armbru.git qapi-next
 
 Register API
 M: Alistair Francis <[email protected]>
+R: Philippe Mathieu-Daudé <[email protected]>
 S: Maintained
 F: hw/core/register.c
 F: include/hw/register.h
Signature · 1 line
2.11.0
#38 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 19 lines · Philippe Mathieu-Daudé

various easy patchs added while coding around:
- remove old comments
- add/remove includes
- use TYPE_ names when available
- use ARRAY_SIZE() macro

Philippe Mathieu-Daudé (11):
hw/net: removed obsolete comments
hw/pci: define msi_nonbroken in pci-stub
hw/misc: add missing includes
ide/ahci: add missing includes
hw/mips: add missing include
hw/arm: removed unnecessary include
hw/arm: use defined type name instead of hard-coded string. hw/sparc: use ARRAY_SIZE() macro
target/sparc: fix DEBUG_MMU DPRINTF() arguments
register: display register prefix (name) since it is available
MAINTAINERS: self-appoint me as reviewer of the Register API

Quoted 1 line

From this set, I've applied 4 patches:

[PATCH 05/11] hw/mips: add missing include
[PATCH 06/11] hw/arm: removed unnecessary include
[PATCH 08/11] hw/sparc: use ARRAY_SIZE() macro
[PATCH 10/11] register: display register prefix (name) since it is available

Thanks,

/mjt