[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH v3 09/22] memory-device: drop get_region_size()
From: |
David Gibson |
Subject: |
Re: [Qemu-ppc] [PATCH v3 09/22] memory-device: drop get_region_size() |
Date: |
Fri, 21 Sep 2018 15:19:54 +1000 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
On Thu, Sep 20, 2018 at 12:32:30PM +0200, David Hildenbrand wrote:
> We now have get_memory_region(), which can be used generically to detect
> the region size. Use memory_device_get_region_size() where
> get_region_size() was used and use memory_device_get_region_size() as
> callback for get_plugged_size() (pc-dimm only for now).
The commit message reads a little oddly. I'm guessing it was written
before you split out the introduction of the
memory_device_get_region_size() wrapper into an earlier patch?
>
> Signed-off-by: David Hildenbrand <address@hidden>
Nonetheless,
Reviewed-by: David Gibson <address@hidden>
> ---
> hw/mem/memory-device.c | 11 +++++++++--
> hw/mem/pc-dimm.c | 18 +-----------------
> include/hw/mem/memory-device.h | 3 ---
> 3 files changed, 10 insertions(+), 22 deletions(-)
>
> diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c
> index 2fa68b3730..1ab28e42cf 100644
> --- a/hw/mem/memory-device.c
> +++ b/hw/mem/memory-device.c
> @@ -270,9 +270,16 @@ void memory_device_unplug_region(MachineState *ms,
> MemoryRegion *mr)
> uint64_t memory_device_get_region_size(const MemoryDeviceState *md,
> Error **errp)
> {
> - MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(md);
> + const MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(md);
> + MemoryRegion *mr;
>
> - return mdc->get_region_size(md, errp);
> + /* dropping const here is fine as we don't touch the memory region */
> + mr = mdc->get_memory_region((MemoryDeviceState *)md, errp);
> + if (!mr) {
> + return 0;
> + }
> +
> + return memory_region_size(mr);
> }
>
> static const TypeInfo memory_device_info = {
> diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
> index 49ad8bac2d..95c3c4bd76 100644
> --- a/hw/mem/pc-dimm.c
> +++ b/hw/mem/pc-dimm.c
> @@ -235,21 +235,6 @@ static uint64_t pc_dimm_md_get_addr(const
> MemoryDeviceState *md)
> return dimm->addr;
> }
>
> -static uint64_t pc_dimm_md_get_region_size(const MemoryDeviceState *md,
> - Error **errp)
> -{
> - MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(md);
> - MemoryRegion *mr;
> -
> - /* dropping const here is fine as we don't touch the memory region */
> - mr = mdc->get_memory_region((MemoryDeviceState *)md, errp);
> - if (!mr) {
> - return 0;
> - }
> -
> - return memory_region_size(mr);
> -}
> -
> static MemoryRegion *pc_dimm_md_get_memory_region(MemoryDeviceState *md,
> Error **errp)
> {
> @@ -301,8 +286,7 @@ static void pc_dimm_class_init(ObjectClass *oc, void
> *data)
>
> mdc->get_addr = pc_dimm_md_get_addr;
> /* for a dimm plugged_size == region_size */
> - mdc->get_plugged_size = pc_dimm_md_get_region_size;
> - mdc->get_region_size = pc_dimm_md_get_region_size;
> + mdc->get_plugged_size = memory_device_get_region_size;
> mdc->get_memory_region = pc_dimm_md_get_memory_region;
> mdc->fill_device_info = pc_dimm_md_fill_device_info;
> }
> diff --git a/include/hw/mem/memory-device.h b/include/hw/mem/memory-device.h
> index 0feed4ec0d..64df232919 100644
> --- a/include/hw/mem/memory-device.h
> +++ b/include/hw/mem/memory-device.h
> @@ -36,8 +36,6 @@ typedef struct MemoryDeviceState {
> * assigned yet.
> * @get_plugged_size: The amount of memory provided by this @md currently
> * usable ("plugged") by the guest.
> - * @get_region_size: The size of the memory region of the @md that's mapped
> - * in guest physical memory at @get_addr.
> * @get_memory_region: The memory region of the @md of the @md that's
> * mapped in guest physical memory at @get_addr. If a @md is ever composed
> * of multiple successive memory regions, a covering memory region is to
> @@ -51,7 +49,6 @@ typedef struct MemoryDeviceClass {
> /* public */
> uint64_t (*get_addr)(const MemoryDeviceState *md);
> uint64_t (*get_plugged_size)(const MemoryDeviceState *md, Error **errp);
> - uint64_t (*get_region_size)(const MemoryDeviceState *md, Error **errp);
> MemoryRegion *(*get_memory_region)(MemoryDeviceState *md, Error **errp);
> void (*fill_device_info)(const MemoryDeviceState *md,
> MemoryDeviceInfo *info);
--
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
signature.asc
Description: PGP signature
- Re: [Qemu-ppc] [PATCH v3 07/22] memory-device: add and use memory_device_get_region_size(), (continued)
- Re: [Qemu-ppc] [PATCH v3 07/22] memory-device: add and use memory_device_get_region_size(), David Gibson, 2018/09/21
- Re: [Qemu-ppc] [PATCH v3 07/22] memory-device: add and use memory_device_get_region_size(), David Hildenbrand, 2018/09/21
- Re: [Qemu-ppc] [PATCH v3 07/22] memory-device: add and use memory_device_get_region_size(), David Gibson, 2018/09/21
- Re: [Qemu-ppc] [PATCH v3 07/22] memory-device: add and use memory_device_get_region_size(), David Hildenbrand, 2018/09/24
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v3 07/22] memory-device: add and use memory_device_get_region_size(), Igor Mammedov, 2018/09/24
- Re: [Qemu-ppc] [PATCH v3 07/22] memory-device: add and use memory_device_get_region_size(), David Gibson, 2018/09/25
[Qemu-ppc] [PATCH v3 08/22] memory-device: factor out get_memory_region() from pc-dimm, David Hildenbrand, 2018/09/20
[Qemu-ppc] [PATCH v3 09/22] memory-device: drop get_region_size(), David Hildenbrand, 2018/09/20
- Re: [Qemu-ppc] [PATCH v3 09/22] memory-device: drop get_region_size(),
David Gibson <=
[Qemu-ppc] [PATCH v3 10/22] memory-device: add device class function set_addr(), David Hildenbrand, 2018/09/20
[Qemu-ppc] [PATCH v3 11/22] memory-device: complete factoring out pre_plug handling, David Hildenbrand, 2018/09/20
[Qemu-ppc] [PATCH v3 14/22] memory-device: trace when pre_assigning/assigning/unassigning addresses, David Hildenbrand, 2018/09/20