[for-5.0 PATCH v2 0/3] cpu: Clarify overloading of reset QOM methods

Greg Kurz posted 3 patches 4 years, 4 months ago
Failed in applying to current master (apply log)
There is a newer version of this series
hw/core/cpu.c                   |    8 ++++++++
include/hw/core/cpu.h           |    8 +++++++-
target/alpha/cpu-qom.h          |    2 +-
target/arm/cpu-qom.h            |    2 +-
target/arm/cpu.c                |    3 +--
target/cris/cpu-qom.h           |    2 +-
target/cris/cpu.c               |    3 +--
target/hppa/cpu-qom.h           |    2 +-
target/i386/cpu-qom.h           |    2 +-
target/i386/cpu.c               |    3 +--
target/lm32/cpu-qom.h           |    2 +-
target/lm32/cpu.c               |    3 +--
target/m68k/cpu-qom.h           |    2 +-
target/m68k/cpu.c               |    3 +--
target/microblaze/cpu-qom.h     |    2 +-
target/microblaze/cpu.c         |    3 +--
target/mips/cpu-qom.h           |    2 +-
target/mips/cpu.c               |    3 +--
target/moxie/cpu.c              |    3 +--
target/moxie/cpu.h              |    2 +-
target/nios2/cpu.c              |    3 +--
target/nios2/cpu.h              |    2 +-
target/openrisc/cpu.c           |    3 +--
target/openrisc/cpu.h           |    2 +-
target/ppc/cpu-qom.h            |    2 +-
target/ppc/translate_init.inc.c |    3 +--
target/riscv/cpu.c              |    3 +--
target/riscv/cpu.h              |    2 +-
target/s390x/cpu-qom.h          |    2 +-
target/s390x/cpu.c              |    3 +--
target/sh4/cpu-qom.h            |    2 +-
target/sh4/cpu.c                |    3 +--
target/sparc/cpu-qom.h          |    2 +-
target/sparc/cpu.c              |    3 +--
target/tilegx/cpu.c             |    3 +--
target/tilegx/cpu.h             |    2 +-
target/tricore/cpu-qom.h        |    2 +-
target/tricore/cpu.c            |    3 +--
target/xtensa/cpu-qom.h         |    2 +-
target/xtensa/cpu.c             |    3 +--
40 files changed, 53 insertions(+), 57 deletions(-)
[for-5.0 PATCH v2 0/3] cpu: Clarify overloading of reset QOM methods
Posted by Greg Kurz 4 years, 4 months ago
Each cpu subclass overloads the reset method of its parent class with
its own. But since it needs to call the parent method as well, it keeps
a parent_reset pointer to do so. This causes the same not very explicit
boiler plate to be duplicated all around the place:

    pcc->parent_reset = cc->reset;
    cc->reset = ppc_cpu_reset;

A similar concern was addressed some time back by Philippe Mathieu-Daudé
in qdev, with the addition of device_class_set_parent_reset() and friends:

https://git.qemu.org/?p=qemu.git;a=commit;h=46795cf2e2f6
https://git.qemu.org/?p=qemu.git;a=commit;h=bf853881690d

Follow the same approach with cpus.

Changes in v2:
- added Reviewed-by and Acked-by tags
- rebased on top of https://github.com/cohuck/qemu.git s390-next
  SHA1 dd6252f035a2

--
Greg

---

Greg Kurz (3):
      cpu: Introduce CPUReset callback typedef
      cpu: Introduce cpu_class_set_parent_reset()
      cpu: Use cpu_class_set_parent_reset()


 hw/core/cpu.c                   |    8 ++++++++
 include/hw/core/cpu.h           |    8 +++++++-
 target/alpha/cpu-qom.h          |    2 +-
 target/arm/cpu-qom.h            |    2 +-
 target/arm/cpu.c                |    3 +--
 target/cris/cpu-qom.h           |    2 +-
 target/cris/cpu.c               |    3 +--
 target/hppa/cpu-qom.h           |    2 +-
 target/i386/cpu-qom.h           |    2 +-
 target/i386/cpu.c               |    3 +--
 target/lm32/cpu-qom.h           |    2 +-
 target/lm32/cpu.c               |    3 +--
 target/m68k/cpu-qom.h           |    2 +-
 target/m68k/cpu.c               |    3 +--
 target/microblaze/cpu-qom.h     |    2 +-
 target/microblaze/cpu.c         |    3 +--
 target/mips/cpu-qom.h           |    2 +-
 target/mips/cpu.c               |    3 +--
 target/moxie/cpu.c              |    3 +--
 target/moxie/cpu.h              |    2 +-
 target/nios2/cpu.c              |    3 +--
 target/nios2/cpu.h              |    2 +-
 target/openrisc/cpu.c           |    3 +--
 target/openrisc/cpu.h           |    2 +-
 target/ppc/cpu-qom.h            |    2 +-
 target/ppc/translate_init.inc.c |    3 +--
 target/riscv/cpu.c              |    3 +--
 target/riscv/cpu.h              |    2 +-
 target/s390x/cpu-qom.h          |    2 +-
 target/s390x/cpu.c              |    3 +--
 target/sh4/cpu-qom.h            |    2 +-
 target/sh4/cpu.c                |    3 +--
 target/sparc/cpu-qom.h          |    2 +-
 target/sparc/cpu.c              |    3 +--
 target/tilegx/cpu.c             |    3 +--
 target/tilegx/cpu.h             |    2 +-
 target/tricore/cpu-qom.h        |    2 +-
 target/tricore/cpu.c            |    3 +--
 target/xtensa/cpu-qom.h         |    2 +-
 target/xtensa/cpu.c             |    3 +--
 40 files changed, 53 insertions(+), 57 deletions(-)


Re: [for-5.0 PATCH v2 0/3] cpu: Clarify overloading of reset QOM methods
Posted by Cornelia Huck 4 years, 4 months ago
On Mon, 09 Dec 2019 18:55:12 +0100
Greg Kurz <groug@kaod.org> wrote:

> Each cpu subclass overloads the reset method of its parent class with
> its own. But since it needs to call the parent method as well, it keeps
> a parent_reset pointer to do so. This causes the same not very explicit
> boiler plate to be duplicated all around the place:
> 
>     pcc->parent_reset = cc->reset;
>     cc->reset = ppc_cpu_reset;
> 
> A similar concern was addressed some time back by Philippe Mathieu-Daudé
> in qdev, with the addition of device_class_set_parent_reset() and friends:
> 
> https://git.qemu.org/?p=qemu.git;a=commit;h=46795cf2e2f6
> https://git.qemu.org/?p=qemu.git;a=commit;h=bf853881690d
> 
> Follow the same approach with cpus.
> 
> Changes in v2:
> - added Reviewed-by and Acked-by tags
> - rebased on top of https://github.com/cohuck/qemu.git s390-next
>   SHA1 dd6252f035a2

My apologies for the churn. I'll try to flush my queue ASAP after 5.0
development opens.

> 
> --
> Greg
> 
> ---
> 
> Greg Kurz (3):
>       cpu: Introduce CPUReset callback typedef
>       cpu: Introduce cpu_class_set_parent_reset()
>       cpu: Use cpu_class_set_parent_reset()
> 
> 
>  hw/core/cpu.c                   |    8 ++++++++
>  include/hw/core/cpu.h           |    8 +++++++-
>  target/alpha/cpu-qom.h          |    2 +-
>  target/arm/cpu-qom.h            |    2 +-
>  target/arm/cpu.c                |    3 +--
>  target/cris/cpu-qom.h           |    2 +-
>  target/cris/cpu.c               |    3 +--
>  target/hppa/cpu-qom.h           |    2 +-
>  target/i386/cpu-qom.h           |    2 +-
>  target/i386/cpu.c               |    3 +--
>  target/lm32/cpu-qom.h           |    2 +-
>  target/lm32/cpu.c               |    3 +--
>  target/m68k/cpu-qom.h           |    2 +-
>  target/m68k/cpu.c               |    3 +--
>  target/microblaze/cpu-qom.h     |    2 +-
>  target/microblaze/cpu.c         |    3 +--
>  target/mips/cpu-qom.h           |    2 +-
>  target/mips/cpu.c               |    3 +--
>  target/moxie/cpu.c              |    3 +--
>  target/moxie/cpu.h              |    2 +-
>  target/nios2/cpu.c              |    3 +--
>  target/nios2/cpu.h              |    2 +-
>  target/openrisc/cpu.c           |    3 +--
>  target/openrisc/cpu.h           |    2 +-
>  target/ppc/cpu-qom.h            |    2 +-
>  target/ppc/translate_init.inc.c |    3 +--
>  target/riscv/cpu.c              |    3 +--
>  target/riscv/cpu.h              |    2 +-
>  target/s390x/cpu-qom.h          |    2 +-
>  target/s390x/cpu.c              |    3 +--
>  target/sh4/cpu-qom.h            |    2 +-
>  target/sh4/cpu.c                |    3 +--
>  target/sparc/cpu-qom.h          |    2 +-
>  target/sparc/cpu.c              |    3 +--
>  target/tilegx/cpu.c             |    3 +--
>  target/tilegx/cpu.h             |    2 +-
>  target/tricore/cpu-qom.h        |    2 +-
>  target/tricore/cpu.c            |    3 +--
>  target/xtensa/cpu-qom.h         |    2 +-
>  target/xtensa/cpu.c             |    3 +--
>  40 files changed, 53 insertions(+), 57 deletions(-)
> 


Re: [for-5.0 PATCH v2 0/3] cpu: Clarify overloading of reset QOM methods
Posted by Greg Kurz 4 years, 4 months ago
On Mon, 9 Dec 2019 19:21:43 +0100
Cornelia Huck <cohuck@redhat.com> wrote:

> On Mon, 09 Dec 2019 18:55:12 +0100
> Greg Kurz <groug@kaod.org> wrote:
> 
> > Each cpu subclass overloads the reset method of its parent class with
> > its own. But since it needs to call the parent method as well, it keeps
> > a parent_reset pointer to do so. This causes the same not very explicit
> > boiler plate to be duplicated all around the place:
> > 
> >     pcc->parent_reset = cc->reset;
> >     cc->reset = ppc_cpu_reset;
> > 
> > A similar concern was addressed some time back by Philippe Mathieu-Daudé
> > in qdev, with the addition of device_class_set_parent_reset() and friends:
> > 
> > https://git.qemu.org/?p=qemu.git;a=commit;h=46795cf2e2f6
> > https://git.qemu.org/?p=qemu.git;a=commit;h=bf853881690d
> > 
> > Follow the same approach with cpus.
> > 
> > Changes in v2:
> > - added Reviewed-by and Acked-by tags
> > - rebased on top of https://github.com/cohuck/qemu.git s390-next
> >   SHA1 dd6252f035a2
> 
> My apologies for the churn. I'll try to flush my queue ASAP after 5.0
> development opens.
> 

No problems. It is perfectly fine to queue patches during freeze :)

> > 
> > --
> > Greg
> > 
> > ---
> > 
> > Greg Kurz (3):
> >       cpu: Introduce CPUReset callback typedef
> >       cpu: Introduce cpu_class_set_parent_reset()
> >       cpu: Use cpu_class_set_parent_reset()
> > 
> > 
> >  hw/core/cpu.c                   |    8 ++++++++
> >  include/hw/core/cpu.h           |    8 +++++++-
> >  target/alpha/cpu-qom.h          |    2 +-
> >  target/arm/cpu-qom.h            |    2 +-
> >  target/arm/cpu.c                |    3 +--
> >  target/cris/cpu-qom.h           |    2 +-
> >  target/cris/cpu.c               |    3 +--
> >  target/hppa/cpu-qom.h           |    2 +-
> >  target/i386/cpu-qom.h           |    2 +-
> >  target/i386/cpu.c               |    3 +--
> >  target/lm32/cpu-qom.h           |    2 +-
> >  target/lm32/cpu.c               |    3 +--
> >  target/m68k/cpu-qom.h           |    2 +-
> >  target/m68k/cpu.c               |    3 +--
> >  target/microblaze/cpu-qom.h     |    2 +-
> >  target/microblaze/cpu.c         |    3 +--
> >  target/mips/cpu-qom.h           |    2 +-
> >  target/mips/cpu.c               |    3 +--
> >  target/moxie/cpu.c              |    3 +--
> >  target/moxie/cpu.h              |    2 +-
> >  target/nios2/cpu.c              |    3 +--
> >  target/nios2/cpu.h              |    2 +-
> >  target/openrisc/cpu.c           |    3 +--
> >  target/openrisc/cpu.h           |    2 +-
> >  target/ppc/cpu-qom.h            |    2 +-
> >  target/ppc/translate_init.inc.c |    3 +--
> >  target/riscv/cpu.c              |    3 +--
> >  target/riscv/cpu.h              |    2 +-
> >  target/s390x/cpu-qom.h          |    2 +-
> >  target/s390x/cpu.c              |    3 +--
> >  target/sh4/cpu-qom.h            |    2 +-
> >  target/sh4/cpu.c                |    3 +--
> >  target/sparc/cpu-qom.h          |    2 +-
> >  target/sparc/cpu.c              |    3 +--
> >  target/tilegx/cpu.c             |    3 +--
> >  target/tilegx/cpu.h             |    2 +-
> >  target/tricore/cpu-qom.h        |    2 +-
> >  target/tricore/cpu.c            |    3 +--
> >  target/xtensa/cpu-qom.h         |    2 +-
> >  target/xtensa/cpu.c             |    3 +--
> >  40 files changed, 53 insertions(+), 57 deletions(-)
> > 
> 


Re: [for-5.0 PATCH v2 0/3] cpu: Clarify overloading of reset QOM methods
Posted by David Hildenbrand 4 years, 4 months ago
On 09.12.19 18:55, Greg Kurz wrote:
> Each cpu subclass overloads the reset method of its parent class with
> its own. But since it needs to call the parent method as well, it keeps
> a parent_reset pointer to do so. This causes the same not very explicit
> boiler plate to be duplicated all around the place:
> 
>     pcc->parent_reset = cc->reset;
>     cc->reset = ppc_cpu_reset;
> 
> A similar concern was addressed some time back by Philippe Mathieu-Daudé
> in qdev, with the addition of device_class_set_parent_reset() and friends:
> 
> https://git.qemu.org/?p=qemu.git;a=commit;h=46795cf2e2f6
> https://git.qemu.org/?p=qemu.git;a=commit;h=bf853881690d
> 
> Follow the same approach with cpus.
> 
> Changes in v2:
> - added Reviewed-by and Acked-by tags
> - rebased on top of https://github.com/cohuck/qemu.git s390-next
>   SHA1 dd6252f035a2
> 
> --
> Greg
> 
> ---
> 
> Greg Kurz (3):
>       cpu: Introduce CPUReset callback typedef
>       cpu: Introduce cpu_class_set_parent_reset()
>       cpu: Use cpu_class_set_parent_reset()
> 
> 
>  hw/core/cpu.c                   |    8 ++++++++
>  include/hw/core/cpu.h           |    8 +++++++-
>  target/alpha/cpu-qom.h          |    2 +-
>  target/arm/cpu-qom.h            |    2 +-
>  target/arm/cpu.c                |    3 +--
>  target/cris/cpu-qom.h           |    2 +-
>  target/cris/cpu.c               |    3 +--
>  target/hppa/cpu-qom.h           |    2 +-
>  target/i386/cpu-qom.h           |    2 +-
>  target/i386/cpu.c               |    3 +--
>  target/lm32/cpu-qom.h           |    2 +-
>  target/lm32/cpu.c               |    3 +--
>  target/m68k/cpu-qom.h           |    2 +-
>  target/m68k/cpu.c               |    3 +--
>  target/microblaze/cpu-qom.h     |    2 +-
>  target/microblaze/cpu.c         |    3 +--
>  target/mips/cpu-qom.h           |    2 +-
>  target/mips/cpu.c               |    3 +--
>  target/moxie/cpu.c              |    3 +--
>  target/moxie/cpu.h              |    2 +-
>  target/nios2/cpu.c              |    3 +--
>  target/nios2/cpu.h              |    2 +-
>  target/openrisc/cpu.c           |    3 +--
>  target/openrisc/cpu.h           |    2 +-
>  target/ppc/cpu-qom.h            |    2 +-
>  target/ppc/translate_init.inc.c |    3 +--
>  target/riscv/cpu.c              |    3 +--
>  target/riscv/cpu.h              |    2 +-
>  target/s390x/cpu-qom.h          |    2 +-
>  target/s390x/cpu.c              |    3 +--
>  target/sh4/cpu-qom.h            |    2 +-
>  target/sh4/cpu.c                |    3 +--
>  target/sparc/cpu-qom.h          |    2 +-
>  target/sparc/cpu.c              |    3 +--
>  target/tilegx/cpu.c             |    3 +--
>  target/tilegx/cpu.h             |    2 +-
>  target/tricore/cpu-qom.h        |    2 +-
>  target/tricore/cpu.c            |    3 +--
>  target/xtensa/cpu-qom.h         |    2 +-
>  target/xtensa/cpu.c             |    3 +--
>  40 files changed, 53 insertions(+), 57 deletions(-)
> 

Acked-by: David Hildenbrand <david@redhat.com>

For all patches (this sorts out something that was bugging me a while
ago :) )

-- 
Thanks,

David / dhildenb