From: Peter Maydell <peter.maydell@linaro.org>
To: Jean-Christophe Dubois <jcd@tribudubois.net>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
Peter Chubb <peter.chubb@nicta.com.au>,
Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: Re: [Qemu-devel] [PATCH 2/3] i.MX6UL: Add i.MX6UL SOC
Date: Tue, 17 Jul 2018 15:58:10 +0100 [thread overview]
Message-ID: <CAFEAcA-pdtV-rsPLGBvW8nyk5P1F-WeOWOGMpxVy0AUNgg7LGw@mail.gmail.com> (raw)
In-Reply-To: <b6c55b0c843ec3164f86e4b40225be0d5ab5b0fa.1530395710.git.jcd@tribudubois.net>
On 30 June 2018 at 22:58, Jean-Christophe Dubois <jcd@tribudubois.net> wrote:
> Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
> ---
> default-configs/arm-softmmu.mak | 1 +
> hw/arm/Makefile.objs | 1 +
> hw/arm/fsl-imx6ul.c | 649 ++++++++++++++++++++++++++++++++
> include/hw/arm/fsl-imx6ul.h | 339 +++++++++++++++++
> 4 files changed, 990 insertions(+)
> create mode 100644 hw/arm/fsl-imx6ul.c
> create mode 100644 include/hw/arm/fsl-imx6ul.h
>
> diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
> index 834d45cfaf..311584fd74 100644
> --- a/default-configs/arm-softmmu.mak
> +++ b/default-configs/arm-softmmu.mak
> @@ -133,6 +133,7 @@ CONFIG_FSL_IMX6=y
> CONFIG_FSL_IMX31=y
> CONFIG_FSL_IMX25=y
> CONFIG_FSL_IMX7=y
> +CONFIG_FSL_IMX6UL=y
>
> CONFIG_IMX_I2C=y
>
> diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
> index d51fcecaf2..e419ad040b 100644
> --- a/hw/arm/Makefile.objs
> +++ b/hw/arm/Makefile.objs
> @@ -36,3 +36,4 @@ obj-$(CONFIG_MSF2) += msf2-soc.o msf2-som.o
> obj-$(CONFIG_IOTKIT) += iotkit.o
> obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o mcimx7d-sabre.o
> obj-$(CONFIG_ARM_SMMUV3) += smmu-common.o smmuv3.o
> +obj-$(CONFIG_FSL_IMX6UL) += fsl-imx6ul.o
> diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c
> new file mode 100644
> index 0000000000..25d6c3f7c2
> --- /dev/null
> +++ b/hw/arm/fsl-imx6ul.c
> @@ -0,0 +1,649 @@
> +/*
> + * Copyright (c) 2018 Jean-Christophe Dubois <jcd@tribudubois.net>
> + *
> + * i.MX6UL SOC emulation.
> + *
> + * Based on hw/arm/fsl-imx7.c
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qapi/error.h"
> +#include "qemu-common.h"
> +#include "hw/arm/fsl-imx6ul.h"
> +#include "hw/misc/unimp.h"
> +#include "sysemu/sysemu.h"
> +#include "qemu/error-report.h"
> +
> +#define NAME_SIZE 20
> +
> +static void fsl_imx6ul_init(Object *obj)
> +{
> + BusState *sysbus = sysbus_get_default();
> + FslIMX6ULState *s = FSL_IMX6UL(obj);
> + char name[NAME_SIZE];
> + int i;
> +
> +
> + for (i = 0; i < MIN(smp_cpus, FSL_IMX6UL_NUM_CPUS); i++) {
> + object_initialize(&s->cpu[i], sizeof(s->cpu[i]),
> + ARM_CPU_TYPE_NAME("cortex-a7"));
> + snprintf(name, NAME_SIZE, "cpu%d", i);
> + object_property_add_child(obj, name, OBJECT(&s->cpu[i]),
> + &error_fatal);
> + }
It's been discovered recently that initializing child QOM objects
like this leaks a reference count to them, which can cause crashes
if the device is introspected via the QMP interface.
This has been fixed for various devices including the in-tree FSL
SoC containers in commits 0210b39d0e8..ccf02d73d18 (which just
got pushed to master this afternoon).
Commit e9e4d4d3e18 is the one that fixes fsl-imx6.c, and we should
follow that here. Specifically, rather than separate calls to
object_initialize() and object_property_add_child() we can have
one call to the new object_initialize_child():
object_initialize_child(obj, name, &s->cpu[i], sizeof(s->cpu[i]),
ARM_CPU_TYPE_NAME("cortex-a7"),
&error_abort, NULL);
> +
> + /*
> + * A7MPCORE
> + */
> + object_initialize(&s->a7mpcore, sizeof(s->a7mpcore), TYPE_A15MPCORE_PRIV);
> + qdev_set_parent_bus(DEVICE(&s->a7mpcore), sysbus);
> + object_property_add_child(obj, "a7mpcore",
> + OBJECT(&s->a7mpcore), &error_fatal);
and for sysbus devices like this there is now a single sysbus_init_child_obj()
which does the work of all three of these calls:
sysbus_init_child_obj(obj, "a7mpcore", &s->a7mpcore, sizeof(s->a7mpcore),
TYPE_A7MPCORE_PRIV);
Similarly with the various other child objects here.
thanks
-- PMM
next prev parent reply other threads:[~2018-07-17 14:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-30 21:57 [Qemu-devel] [PATCH 0/3] i.MX: Add the i.MX6UL SOC and a reference board Jean-Christophe Dubois
2018-06-30 21:58 ` [Qemu-devel] [PATCH 1/3] i.MX6UL: Add i.MX6UL specific CCM device Jean-Christophe Dubois
2018-07-17 14:48 ` Peter Maydell
2018-06-30 21:58 ` [Qemu-devel] [PATCH 2/3] i.MX6UL: Add i.MX6UL SOC Jean-Christophe Dubois
2018-07-17 14:58 ` Peter Maydell [this message]
2018-06-30 21:58 ` [Qemu-devel] [PATCH 3/3] i.MX6UL: Add Freescale i.MX6 UltraLite 14x14 EVK Board Jean-Christophe Dubois
2018-07-17 15:01 ` Peter Maydell
2018-07-01 10:44 ` [Qemu-devel] [PATCH 0/3] i.MX: Add the i.MX6UL SOC and a reference board Peter Maydell
2018-07-05 13:06 ` Jean-Christophe DUBOIS
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFEAcA-pdtV-rsPLGBvW8nyk5P1F-WeOWOGMpxVy0AUNgg7LGw@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=andrew.smirnov@gmail.com \
--cc=jcd@tribudubois.net \
--cc=peter.chubb@nicta.com.au \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).