diff mbox series

[v4,2/3] xilink-zynq-devcfg: Fix up for memory address range size not set correctly

Message ID fbaff99d74262f52fe62696fe08d617296f6ea1a.1728299530.git.chao.liu@yeah.net (mailing list archive)
State New, archived
Headers show
Series Drop ignore_memory_transaction_failures for xilink_zynq | expand

Commit Message

Chao Liu Oct. 7, 2024, 11:24 a.m. UTC
Signed-off-by: Chao Liu <chao.liu@yeah.net>
---
 hw/dma/xlnx-zynq-devcfg.c         | 2 +-
 include/hw/dma/xlnx-zynq-devcfg.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Peter Maydell Oct. 14, 2024, 3:13 p.m. UTC | #1
On Mon, 7 Oct 2024 at 12:25, Chao Liu <chao.liu@yeah.net> wrote:
>
> Signed-off-by: Chao Liu <chao.liu@yeah.net>
> ---
>  hw/dma/xlnx-zynq-devcfg.c         | 2 +-
>  include/hw/dma/xlnx-zynq-devcfg.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/dma/xlnx-zynq-devcfg.c b/hw/dma/xlnx-zynq-devcfg.c
> index b8544d0731..e5eff9abc0 100644
> --- a/hw/dma/xlnx-zynq-devcfg.c
> +++ b/hw/dma/xlnx-zynq-devcfg.c
> @@ -365,7 +365,7 @@ static void xlnx_zynq_devcfg_init(Object *obj)
>
>      sysbus_init_irq(sbd, &s->irq);
>
> -    memory_region_init(&s->iomem, obj, "devcfg", XLNX_ZYNQ_DEVCFG_R_MAX * 4);
> +    memory_region_init(&s->iomem, obj, "devcfg", XLNX_ZYNQ_DEVCFG_R_MAX);
>      reg_array =
>          register_init_block32(DEVICE(obj), xlnx_zynq_devcfg_regs_info,
>                                ARRAY_SIZE(xlnx_zynq_devcfg_regs_info),
> diff --git a/include/hw/dma/xlnx-zynq-devcfg.h b/include/hw/dma/xlnx-zynq-devcfg.h
> index e4cf085d70..fc26132069 100644
> --- a/include/hw/dma/xlnx-zynq-devcfg.h
> +++ b/include/hw/dma/xlnx-zynq-devcfg.h
> @@ -35,7 +35,7 @@
>
>  OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqDevcfg, XLNX_ZYNQ_DEVCFG)
>
> -#define XLNX_ZYNQ_DEVCFG_R_MAX (0x100 / 4)
> +#define XLNX_ZYNQ_DEVCFG_R_MAX 0x100

This doesn't look right. The device tree in Linux says this
device is 0x100 bytes long. In QEMU the _R_MAX type constant
generally is the number of (32-bit) registers, hence the
division by 4 here to go from bytes to words, and the multiply
by 4 to get the memory_region_init() argument which is bytes
again.

What is this patch trying to fix?

("What is this change fixing" is the kind of thing you
should explain in the commit message.)

thanks
-- PMM
diff mbox series

Patch

diff --git a/hw/dma/xlnx-zynq-devcfg.c b/hw/dma/xlnx-zynq-devcfg.c
index b8544d0731..e5eff9abc0 100644
--- a/hw/dma/xlnx-zynq-devcfg.c
+++ b/hw/dma/xlnx-zynq-devcfg.c
@@ -365,7 +365,7 @@  static void xlnx_zynq_devcfg_init(Object *obj)
 
     sysbus_init_irq(sbd, &s->irq);
 
-    memory_region_init(&s->iomem, obj, "devcfg", XLNX_ZYNQ_DEVCFG_R_MAX * 4);
+    memory_region_init(&s->iomem, obj, "devcfg", XLNX_ZYNQ_DEVCFG_R_MAX);
     reg_array =
         register_init_block32(DEVICE(obj), xlnx_zynq_devcfg_regs_info,
                               ARRAY_SIZE(xlnx_zynq_devcfg_regs_info),
diff --git a/include/hw/dma/xlnx-zynq-devcfg.h b/include/hw/dma/xlnx-zynq-devcfg.h
index e4cf085d70..fc26132069 100644
--- a/include/hw/dma/xlnx-zynq-devcfg.h
+++ b/include/hw/dma/xlnx-zynq-devcfg.h
@@ -35,7 +35,7 @@ 
 
 OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqDevcfg, XLNX_ZYNQ_DEVCFG)
 
-#define XLNX_ZYNQ_DEVCFG_R_MAX (0x100 / 4)
+#define XLNX_ZYNQ_DEVCFG_R_MAX 0x100
 
 #define XLNX_ZYNQ_DEVCFG_DMA_CMD_FIFO_LEN 10