mbox series

[v2,0/3] bulk: Remove legacy cpu_physical_memory_rw() API

Message ID 20241210140112.43313-1-philmd@linaro.org
Headers show
Series bulk: Remove legacy cpu_physical_memory_rw() API | expand

Message

Philippe Mathieu-Daudé Dec. 10, 2024, 2:01 p.m. UTC
cpu_physical_memory_rw() API is documented as legacy
since 2017 (commit b7ecba0f6f6). Replace it by a more
recent API. Noticed while discussing with Peter:
https://lore.kernel.org/qemu-devel/e979b3ba-e701-4ac6-962a-19e4598ba947@linaro.org

Philippe Mathieu-Daudé (3):
  dump/dump: Include missing 'exec/memory.h' header
  bulk: Replace legacy cpu_physical_memory_rw() API
  system: Remove mentions of cpu_physical_memory_rw() API

 docs/devel/loads-stores.rst            | 23 -------
 scripts/coccinelle/exec_rw_const.cocci | 29 ---------
 hw/xtensa/bootparam.h                  |  7 +-
 include/exec/cpu-common.h              | 12 ----
 accel/kvm/kvm-all.c                    |  5 +-
 dump/dump.c                            |  5 +-
 gdbstub/system.c                       |  7 +-
 hw/acpi/ghes.c                         | 19 ++++--
 hw/acpi/nvdimm.c                       | 21 ++++--
 hw/acpi/vmgenid.c                      |  6 +-
 hw/arm/omap1.c                         | 18 ++++--
 hw/audio/marvell_88w8618.c             |  4 +-
 hw/char/riscv_htif.c                   |  8 ++-
 hw/display/omap_lcdc.c                 | 13 ++--
 hw/dma/i8257.c                         | 17 +++--
 hw/dma/omap_dma.c                      | 15 +++--
 hw/dma/rc4030.c                        |  3 +-
 hw/dma/sifive_pdma.c                   | 13 ++--
 hw/gpio/zaurus.c                       |  5 +-
 hw/i386/kvm/clock.c                    |  4 +-
 hw/i386/vapic.c                        | 42 +++++++-----
 hw/intc/apic.c                         |  6 +-
 hw/m68k/next-cube.c                    |  4 +-
 hw/microblaze/boot.c                   |  4 +-
 hw/net/fsl_etsec/rings.c               | 24 ++++---
 hw/net/mcf_fec.c                       | 16 +++--
 hw/net/opencores_eth.c                 | 15 +++--
 hw/net/xgmac.c                         | 13 ++--
 hw/ppc/e500.c                          |  4 +-
 hw/ppc/pegasos2.c                      |  6 +-
 hw/ppc/pnv.c                           |  4 +-
 hw/ppc/ppc405_boards.c                 |  5 +-
 hw/ppc/spapr.c                         |  4 +-
 hw/ppc/spapr_drc.c                     |  7 +-
 hw/ppc/spapr_events.c                  | 21 +++---
 hw/ppc/spapr_hcall.c                   | 15 +++--
 hw/ppc/spapr_rtas.c                    |  7 +-
 hw/ppc/spapr_tpm_proxy.c               |  7 +-
 hw/ppc/virtex_ml507.c                  |  4 +-
 hw/s390x/css.c                         |  6 +-
 hw/s390x/ipl.c                         |  8 ++-
 hw/s390x/sclp.c                        | 11 ++--
 hw/scsi/vmw_pvscsi.c                   | 16 +++--
 hw/xen/xen-hvm-common.c                | 10 ++-
 hw/xen/xen_pt_graphics.c               |  4 +-
 hw/xtensa/xtfpga.c                     |  7 +-
 system/cpus.c                          |  4 +-
 system/physmem.c                       |  7 --
 target/i386/kvm/xen-emu.c              |  3 +-
 target/i386/monitor.c                  | 90 ++++++++++++++++++--------
 target/i386/nvmm/nvmm-all.c            |  3 +-
 target/i386/whpx/whpx-all.c            |  5 +-
 target/riscv/kvm/kvm-cpu.c             |  6 +-
 target/riscv/monitor.c                 |  4 +-
 target/s390x/diag.c                    | 13 +++-
 target/s390x/helper.c                  |  5 +-
 target/s390x/mmu_helper.c              |  6 +-
 57 files changed, 391 insertions(+), 259 deletions(-)

Comments

Peter Maydell Dec. 10, 2024, 3 p.m. UTC | #1
On Tue, 10 Dec 2024 at 14:01, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> cpu_physical_memory_rw() API is documented as legacy
> since 2017 (commit b7ecba0f6f6). Replace it by a more
> recent API. Noticed while discussing with Peter:
> https://lore.kernel.org/qemu-devel/e979b3ba-e701-4ac6-962a-19e4598ba947@linaro.org

I'm not sure we want to do this as a bulk automated
transformation, because in each case there is likely
a better thing we can do with the call than to use
address_space_memory. For example most of the uses in
devices probably want to have the device have an
AddressSpace property that the board wires up.

thanks
-- PMM
Peter Maydell Dec. 10, 2024, 3:03 p.m. UTC | #2
On Tue, 10 Dec 2024 at 15:00, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Tue, 10 Dec 2024 at 14:01, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
> >
> > cpu_physical_memory_rw() API is documented as legacy
> > since 2017 (commit b7ecba0f6f6). Replace it by a more
> > recent API. Noticed while discussing with Peter:
> > https://lore.kernel.org/qemu-devel/e979b3ba-e701-4ac6-962a-19e4598ba947@linaro.org
>
> I'm not sure we want to do this as a bulk automated
> transformation, because in each case there is likely
> a better thing we can do with the call than to use
> address_space_memory. For example most of the uses in
> devices probably want to have the device have an
> AddressSpace property that the board wires up.

Also, examining each use gives us an opportunity to
consider the error handling (cpu_physical_memory_*()
drop errors silently) and whether there's an appropriate
MemTxAttrs we want to use.

thanks
-- PMM
Philippe Mathieu-Daudé Dec. 10, 2024, 3:10 p.m. UTC | #3
On 10/12/24 16:03, Peter Maydell wrote:
> On Tue, 10 Dec 2024 at 15:00, Peter Maydell <peter.maydell@linaro.org> wrote:
>>
>> On Tue, 10 Dec 2024 at 14:01, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>>
>>> cpu_physical_memory_rw() API is documented as legacy
>>> since 2017 (commit b7ecba0f6f6). Replace it by a more
>>> recent API. Noticed while discussing with Peter:
>>> https://lore.kernel.org/qemu-devel/e979b3ba-e701-4ac6-962a-19e4598ba947@linaro.org
>>
>> I'm not sure we want to do this as a bulk automated
>> transformation, because in each case there is likely
>> a better thing we can do with the call than to use
>> address_space_memory. For example most of the uses in
>> devices probably want to have the device have an
>> AddressSpace property that the board wires up.
> 
> Also, examining each use gives us an opportunity to
> consider the error handling (cpu_physical_memory_*()
> drop errors silently) and whether there's an appropriate
> MemTxAttrs we want to use.

Yes I noticed that and agree, but do we really want to improve
these devices? They have been using the legacy API for 7 years
without caring much.

I can repost split in 50 patches, hoping a dozen get merged
directly. But then I expect discussions requiring too much
unimportant work to happen, and the series being abandoned,
giving this legacy API 10 more years...

I'm being a bit negative so I'll post a v2, and then we can
open GitLab issues for devices needing to be improved.

Regards,

Phil.
Peter Maydell Dec. 10, 2024, 3:36 p.m. UTC | #4
On Tue, 10 Dec 2024 at 15:10, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> On 10/12/24 16:03, Peter Maydell wrote:
> > On Tue, 10 Dec 2024 at 15:00, Peter Maydell <peter.maydell@linaro.org> wrote:
> >>
> >> On Tue, 10 Dec 2024 at 14:01, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
> >>>
> >>> cpu_physical_memory_rw() API is documented as legacy
> >>> since 2017 (commit b7ecba0f6f6). Replace it by a more
> >>> recent API. Noticed while discussing with Peter:
> >>> https://lore.kernel.org/qemu-devel/e979b3ba-e701-4ac6-962a-19e4598ba947@linaro.org
> >>
> >> I'm not sure we want to do this as a bulk automated
> >> transformation, because in each case there is likely
> >> a better thing we can do with the call than to use
> >> address_space_memory. For example most of the uses in
> >> devices probably want to have the device have an
> >> AddressSpace property that the board wires up.
> >
> > Also, examining each use gives us an opportunity to
> > consider the error handling (cpu_physical_memory_*()
> > drop errors silently) and whether there's an appropriate
> > MemTxAttrs we want to use.
>
> Yes I noticed that and agree, but do we really want to improve
> these devices? They have been using the legacy API for 7 years
> without caring much.
>
> I can repost split in 50 patches, hoping a dozen get merged
> directly. But then I expect discussions requiring too much
> unimportant work to happen, and the series being abandoned,
> giving this legacy API 10 more years..

Well, it's legacy in the sense of "don't use it for new
stuff", but also is it doing any harm in the old code?
If we want to improve the places that use it we can,
but I'm not sure I would worry about moving from one
"this isn't really the ideal" to a different "this isn't
really the ideal"...

If the existence of the function is blocking a separate
cleanup, that's a different matter, of course.

thanks
-- PMM
Peter Maydell Dec. 10, 2024, 3:43 p.m. UTC | #5
On Tue, 10 Dec 2024 at 15:10, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> On 10/12/24 16:03, Peter Maydell wrote:
> > On Tue, 10 Dec 2024 at 15:00, Peter Maydell <peter.maydell@linaro.org> wrote:
> >>
> >> On Tue, 10 Dec 2024 at 14:01, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
> >>>
> >>> cpu_physical_memory_rw() API is documented as legacy
> >>> since 2017 (commit b7ecba0f6f6). Replace it by a more
> >>> recent API. Noticed while discussing with Peter:
> >>> https://lore.kernel.org/qemu-devel/e979b3ba-e701-4ac6-962a-19e4598ba947@linaro.org
> >>
> >> I'm not sure we want to do this as a bulk automated
> >> transformation, because in each case there is likely
> >> a better thing we can do with the call than to use
> >> address_space_memory. For example most of the uses in
> >> devices probably want to have the device have an
> >> AddressSpace property that the board wires up.
> >
> > Also, examining each use gives us an opportunity to
> > consider the error handling (cpu_physical_memory_*()
> > drop errors silently) and whether there's an appropriate
> > MemTxAttrs we want to use.
>
> Yes I noticed that and agree, but do we really want to improve
> these devices? They have been using the legacy API for 7 years
> without caring much.
>
> I can repost split in 50 patches, hoping a dozen get merged
> directly. But then I expect discussions requiring too much
> unimportant work to happen, and the series being abandoned,
> giving this legacy API 10 more years...

Also, just to be clear, in the "do a mechanical transform
in a single patch" it is not the "single patch" part that
I'm unhappy about here -- it's the "do a mechanical transform"
bit. Splitting it into 50 patches wouldn't address that.

thanks
-- PMM