Skip to contentSkip to conversation

Drop support for qdev taddr properties

PATCH Superseded Peter Maydell 2 participants 9 messages Apr 2, 2013 Arm/Zynq architecture

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Drop support for qdev taddr properties

There is currently only one user of the qdev taddr (target addr, now hwaddr) property code, and that user is wrong anyway, since the property it's trying to set isn't actually a taddr property. Fix the erroneous use in sm501 and drop all the taddr property code.

The justification for dropping the support is that a device should generally not be exposing properties whose width (conceptually) depends on the target CPU type. (This is the same rationale for not supporting hwaddr fields in migration state.) Instead the device should expose either a 32 bit or 64 bit property, depending on what the actual hardware does.

Aside: I may try to get rid of the DMAADDR property too at some point, because what the sysbus-ohci device should actually be doing is taking a MemoryRegion* [or maybe a DMAContext*] representing what it should be DMAing into, rather than the current "DMA into the system address space at addr + some constant offset" hack. One thing at a time, though.

Peter Maydell (2):
hw/sm501: Use correct setter for sysbus-ohci dma-address property
qdev: Drop taddr properties

 hw/Makefile.objs        |  1 -
 hw/fdc.c                |  1 -
 hw/milkymist-hw.h       |  1 -
 hw/milkymist-minimac2.c |  1 -
 hw/qdev-addr.c          | 78 -------------------------------------------------
 hw/qdev-addr.h          | 10 -------
 hw/sm501.c              |  3 +-
 hw/sparc/sun4m.c        |  1 -
 hw/tcx.c                |  1 -
 hw/xilinx_axidma.c      |  1 -
 10 files changed, 1 insertion(+), 97 deletions(-)
 delete mode 100644 hw/qdev-addr.c
 delete mode 100644 hw/qdev-addr.h
Signature · 1 line
1.7.11.4
#1 lore raw

PATCH 1/2 hw/sm501: Use correct setter for sysbus-ohci dma-address property

The sysbus-ohci dma-address property is declared as a HEX64 property, not a TADDR, so use the correct setter for it.

---
 hw/sm501.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/sm501.c +1 -1
index 93a06c9..0ef6b8a 100644
@@ -1430,7 +1430,7 @@ void sm501_init(MemoryRegion *address_space_mem, uint32_t base,
     /* bridge to usb host emulation module */
     dev = qdev_create(NULL, "sysbus-ohci");
     qdev_prop_set_uint32(dev, "num-ports", 2);
-    qdev_prop_set_taddr(dev, "dma-offset", base);
+    qdev_prop_set_uint64(dev, "dma-offset", base);
     qdev_init_nofail(dev);
     sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0,
                     base + MMIO_BASE_OFFSET + SM501_USB_HOST);
Signature · 1 line
1.7.11.4
#2 lore raw

PATCH 2/2 qdev: Drop taddr properties

In reply to Peter Maydell

Drop all the infrastructure for taddr properties (ie ones which are 'hwaddr' sized). These are now unused, and any further desired use would be rather questionable since device properties shouldn't generally depend on a type that is conceptually variable based on the target CPU. 32 or 64 bit integer properties should be used instead as appropriate for the specific device.

---
 hw/Makefile.objs        |  1 -
 hw/fdc.c                |  1 -
 hw/milkymist-hw.h       |  1 -
 hw/milkymist-minimac2.c |  1 -
 hw/qdev-addr.c          | 78 -------------------------------------------------
 hw/qdev-addr.h          | 10 -------
 hw/sm501.c              |  1 -
 hw/sparc/sun4m.c        |  1 -
 hw/tcx.c                |  1 -
 hw/xilinx_axidma.c      |  1 -
 10 files changed, 96 deletions(-)
 delete mode 100644 hw/qdev-addr.c
 delete mode 100644 hw/qdev-addr.h
hw/Makefile.objs +0 -1
index d0b2ecb..bee5736 100644
@@ -134,7 +134,6 @@ common-obj-$(CONFIG_ESP) += esp.o
 common-obj-$(CONFIG_ESP_PCI) += esp-pci.o
 
 common-obj-y += sysbus.o isa-bus.o
-common-obj-y += qdev-addr.o
 
 # VGA
 common-obj-$(CONFIG_VGA_PCI) += vga-pci.o
hw/fdc.c +0 -1
index a4bb129..3220538 100644
@@ -33,7 +33,6 @@
 #include "qemu/timer.h"
 #include "hw/isa.h"
 #include "hw/sysbus.h"
-#include "hw/qdev-addr.h"
 #include "sysemu/blockdev.h"
 #include "sysemu/sysemu.h"
 #include "qemu/log.h"
hw/milkymist-hw.h +0 -1
index 4e86c4e..5317ce6 100644
@@ -2,7 +2,6 @@
 #define QEMU_HW_MILKYMIST_H
 
 #include "hw/qdev.h"
-#include "hw/qdev-addr.h"
 #include "net/net.h"
 
 static inline DeviceState *milkymist_uart_create(hwaddr base,
hw/milkymist-minimac2.c +0 -1
index 29618e8..4ef6318 100644
@@ -27,7 +27,6 @@
 #include "trace.h"
 #include "net/net.h"
 #include "qemu/error-report.h"
-#include "hw/qdev-addr.h"
 
 #include <zlib.h>
 
hw/qdev-addr.c deleted +0 -78

78 lines not on this page · raw message

hw/qdev-addr.h deleted +0 -10
deleted file mode 100644
index 79708e6..0000000
@@ -1,10 +0,0 @@
-#ifndef HW_QDEV_ADDR_H
-#define HW_QDEV_ADDR_H 1
-
-#define DEFINE_PROP_TADDR(_n, _s, _f, _d)                               \
-    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_taddr, hwaddr)
-
-extern PropertyInfo qdev_prop_taddr;
-void qdev_prop_set_taddr(DeviceState *dev, const char *name, hwaddr value);
-
-#endif
hw/sm501.c +0 -1
index 0ef6b8a..5f89fb2 100644
@@ -28,7 +28,6 @@
 #include "ui/console.h"
 #include "hw/devices.h"
 #include "hw/sysbus.h"
-#include "hw/qdev-addr.h"
 #include "qemu/range.h"
 #include "ui/pixel_ops.h"
 
hw/sparc/sun4m.c +0 -1
index 9ebda02..fc282e2 100644
@@ -37,7 +37,6 @@
 #include "hw/fw_cfg.h"
 #include "hw/escc.h"
 #include "hw/empty_slot.h"
-#include "hw/qdev-addr.h"
 #include "hw/loader.h"
 #include "elf.h"
 #include "sysemu/blockdev.h"
hw/tcx.c +0 -1
index c44068e..55abaee 100644
@@ -26,7 +26,6 @@
 #include "ui/console.h"
 #include "ui/pixel_ops.h"
 #include "hw/sysbus.h"
-#include "hw/qdev-addr.h"
 
 #define MAXX 1024
 #define MAXY 768
hw/xilinx_axidma.c +0 -1
index 8db1a74..997b06e 100644
@@ -26,7 +26,6 @@
 #include "qemu/timer.h"
 #include "hw/ptimer.h"
 #include "qemu/log.h"
-#include "hw/qdev-addr.h"
 
 #include "hw/stream.h"
 
Signature · 1 line
1.7.11.4
#3 lore raw
In reply to Peter Maydell

Il 02/04/2013 18:10, Peter Maydell ha scritto:

Quoted 12 lines

There is currently only one user of the qdev taddr (target addr, now hwaddr) property code, and that user is wrong anyway, since the property it's trying to set isn't actually a taddr property. Fix the erroneous use in sm501 and drop all the taddr property code.

The justification for dropping the support is that a device should generally not be exposing properties whose width (conceptually) depends on the target CPU type. (This is the same rationale for not supporting hwaddr fields in migration state.) Instead the device should expose either a 32 bit or 64 bit property, depending on what the actual hardware does.

Quoted 3 lines

Aside: I may try to get rid of the DMAADDR property too at some point, because what the sysbus-ohci device should actually be doing is taking a MemoryRegion* [or maybe a DMAContext*]

Avi had patches to unify DMAContext and MemoryRegion. I should revive them perhaps.

Quoted 4 lines

representing what
it should be DMAing into, rather than the current "DMA into the system address space at addr + some constant offset" hack. One thing at a time, though.

That's a general problem with sysbus. I guess if you need another address space you should define your own bus, like PCI does.

Paolo

Quoted 18 lines

Peter Maydell (2):
hw/sm501: Use correct setter for sysbus-ohci dma-address property
qdev: Drop taddr properties

 hw/Makefile.objs        |  1 -
 hw/fdc.c                |  1 -
 hw/milkymist-hw.h       |  1 -
 hw/milkymist-minimac2.c |  1 -
 hw/qdev-addr.c          | 78 -------------------------------------------------
 hw/qdev-addr.h          | 10 -------
 hw/sm501.c              |  3 +-
 hw/sparc/sun4m.c        |  1 -
 hw/tcx.c                |  1 -
 hw/xilinx_axidma.c      |  1 -
 10 files changed, 1 insertion(+), 97 deletions(-)
 delete mode 100644 hw/qdev-addr.c
 delete mode 100644 hw/qdev-addr.h
#4 lore raw
Quoted 7 lines · Paolo Bonzini

Il 02/04/2013 18:10, Peter Maydell ha scritto:

Quoted 3 lines

Aside: I may try to get rid of the DMAADDR property too at some point, because what the sysbus-ohci device should actually be doing is taking a MemoryRegion* [or maybe a DMAContext*]

Avi had patches to unify DMAContext and MemoryRegion. I should revive them perhaps.

Yes please.

Quoted 7 lines
Quoted 4 lines

representing what
it should be DMAing into, rather than the current "DMA into the system address space at addr + some constant offset" hack. One thing at a time, though.

That's a general problem with sysbus. I guess if you need another address space you should define your own bus, like PCI does.

It's not a problem with sysbus, it's a problem with people being lazy about implementing things that do DMA. For instance PCI doesn't take a MemoryRegion* for DMA, it just assumes it can DMA into the system address space. (it does let you pass a DMAContext, but maybe that goes away with the patches you mention above; it's only used for spapr.)

NB that "the PCI address space", ie the view of the world that the host controller sees when it makes a PCI access, is not the same as the address space that another bus mastering PCI device sees when it does a DMA access. Chances are good that the former shouldn't have any of the system's RAM in it and the latter should. (This is easy to handle though, you just create container MemoryRegions for each and pass them to the PCI code and make sure that you're using the right one at any particular point.)

-- PMM

#5 lore raw

Il 02/04/2013 19:07, Peter Maydell ha scritto:

Quoted 16 lines · Paolo Bonzini
Quoted 7 lines

Il 02/04/2013 18:10, Peter Maydell ha scritto:

Quoted 3 lines

Aside: I may try to get rid of the DMAADDR property too at some point, because what the sysbus-ohci device should actually be doing is taking a MemoryRegion* [or maybe a DMAContext*]

Avi had patches to unify DMAContext and MemoryRegion. I should revive them perhaps.

Yes please.

Quoted 5 lines
Quoted 4 lines

representing what
it should be DMAing into, rather than the current "DMA into the system address space at addr + some constant offset" hack. One thing at a time, though.

Quoted 7 lines
Quoted 2 lines

That's a general problem with sysbus. I guess if you need another address space you should define your own bus, like PCI does.

It's not a problem with sysbus, it's a problem with people being lazy about implementing things that do DMA. For instance PCI doesn't take a MemoryRegion* for DMA, it just assumes it can DMA into the system address space.

PCI does provide its own DMAContext*, which includes an AddressSpace. This address space ("view of the world") is different for each device.

Quoted 3 lines

(it does let you pass
a DMAContext, but maybe that goes away with the patches you mention above; it's only used for spapr.)

It is extended so that it is also used for spapr with those patches.

Paolo

Quoted 13 lines

NB that "the PCI address space", ie the view of the world that the host controller sees when it makes a PCI access, is not the same as the address space that another bus mastering PCI device sees when it does a DMA access. Chances are good that the former shouldn't have any of the system's RAM in it and the latter should. (This is easy to handle though, you just create container MemoryRegions for each and pass them to the PCI code and make sure that you're using the right one at any particular point.)

-- PMM

#6 lore raw
Quoted 8 lines · Paolo Bonzini

Il 02/04/2013 19:07, Peter Maydell ha scritto:

Quoted 4 lines

It's not a problem with sysbus, it's a problem with people being lazy about implementing things that do DMA. For instance PCI doesn't take a MemoryRegion* for DMA, it just assumes it can DMA into the system address space.

PCI does provide its own DMAContext*, which includes an AddressSpace. This address space ("view of the world") is different for each device.

Yes, but (unless you're using the legacy stuff spapr uses) it generates it via get_system_memory(), which is always wrong (though often close enough that Linux will work right).

Quoted 5 lines
Quoted 3 lines

(it does let you pass
a DMAContext, but maybe that goes away with the patches you mention above; it's only used for spapr.)

It is extended so that it is also used for spapr with those patches.

I'm confused. Do you mean that it's changed so that spapr passes a MemoryRegion* rather than a DMAContext*, or so that everything uses a DMAContext* ? (The comments in pci.c suggest that the former is the intended approach.)

-- PMM

#7 lore raw

----- Messaggio originale -----

Quoted 14 lines

Da: "Peter Maydell" <[email protected]>
A: "Paolo Bonzini" <[email protected]>
Cc: "Anthony Liguori" <[email protected]>, [email protected], [email protected], "David Gibson" <[email protected]>
Inviato: Martedì, 2 aprile 2013 22:33:48
Oggetto: Re: [PATCH 0/2] Drop support for qdev taddr properties

Quoted 6 lines · Paolo Bonzini

Il 02/04/2013 19:07, Peter Maydell ha scritto:

Quoted 4 lines

It's not a problem with sysbus, it's a problem with people being lazy about implementing things that do DMA. For instance PCI doesn't take a MemoryRegion* for DMA, it just assumes it can DMA into the system address space.

Quoted 6 lines
Quoted 2 lines

PCI does provide its own DMAContext*, which includes an AddressSpace. This address space ("view of the world") is different for each device.

Yes, but (unless you're using the legacy stuff spapr uses) it generates it via get_system_memory(), which is always wrong (though often close enough that Linux will work right).

It also respects the bus master enable bit:

        memory_region_init_alias(&pci_dev->bus_master_enable_region, "bus master",
                                 get_system_memory(), 0,
                                 memory_region_size(get_system_memory()));
        memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
        address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region);
Quoted 10 lines
Quoted 5 lines
Quoted 3 lines

(it does let you pass
a DMAContext, but maybe that goes away with the patches you mention above; it's only used for spapr.)

It is extended so that it is also used for spapr with those patches.

I'm confused. Do you mean that it's changed so that spapr passes a MemoryRegion* rather than a DMAContext*, or so that everything uses a DMAContext* ? (The comments in pci.c suggest that the former is the intended approach.)

Yes, the former. More precisely, everything uses an AddressSpace*, in fact (that was the part that Avi didn't write) dma-helpers.c can use AddressSpace* instead of DMAContext*.

spapr right now needs a special translate pointer embedded in the DMAContext. With the iommu MemoryRegion patches, it can put the translate function pointer into a translation MemoryRegion. Then the AddressSpace points to that MemoryRegion.

Paolo

#8 lore raw
Quoted 6 lines · Paolo Bonzini
Quoted 4 lines · Peter Maydell

I'm confused. Do you mean that it's changed so that spapr passes a MemoryRegion* rather than a DMAContext*, or so that everything uses a DMAContext* ? (The comments in pci.c suggest that the former is the intended approach.)

Quoted 8 lines

Yes, the former. More precisely, everything uses an AddressSpace*, in fact (that was the part that Avi didn't write) dma-helpers.c can use AddressSpace* instead of DMAContext*.

spapr right now needs a special translate pointer embedded in the DMAContext. With the iommu MemoryRegion patches, it can put the translate function pointer into a translation MemoryRegion. Then the AddressSpace points to that MemoryRegion.

Ah, right, good. It would certainly be good to see those patches; there's a potential followup to the versatile_pci patches that implements the device-to-system access windows properly which should probably be based on top of them.

-- PMM