From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: Re: [PATCH RFC 20/35] xen/arm: Prepare a min DT for DOM0 Date: Thu, 05 Feb 2015 03:48:40 +0000 Message-ID: <54D2E818.30301@linaro.org> References: <1423058539-26403-1-git-send-email-parth.dixit@linaro.org> <1423058539-26403-21-git-send-email-parth.dixit@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1423058539-26403-21-git-send-email-parth.dixit@linaro.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: parth.dixit@linaro.org, xen-devel@lists.xen.org Cc: ian.campbell@citrix.com, Naresh Bhat , tim@xen.org, stefano.stabellini@citrix.com, jbeulich@suse.com, christoffer.dall@linaro.org List-Id: xen-devel@lists.xenproject.org Hi Parth, On 04/02/2015 14:02, parth.dixit@linaro.org wrote: > From: Naresh Bhat > > This patch prepare a DT from scratch for DOM0 for > ACPI-case only. Basically the DT contains minmal > required informations such as DOM0 bootargs, memory > and ACPI RSDP informations only. > > Signed-off-by: Naresh Bhat > --- > xen/arch/arm/domain_build.c | 67 ++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 66 insertions(+), 1 deletion(-) > > diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c > index de180d8..bb7f043 100644 > --- a/xen/arch/arm/domain_build.c > +++ b/xen/arch/arm/domain_build.c > @@ -18,6 +18,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -61,6 +62,9 @@ custom_param("dom0_mem", parse_dom0_mem); > */ > #define DOM0_FDT_EXTRA_SIZE (128 + sizeof(struct fdt_reserve_entry)) > > +/* Reserve DOM0 FDT size in ACPI case only */ > +#define DOM0_FDT_MIN_SIZE 4096 > + > struct vcpu *__init alloc_dom0_vcpu0(struct domain *dom0) > { > if ( opt_dom0_max_vcpus == 0 ) > @@ -1151,6 +1155,63 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, > return res; > } > > +/* > + * Prepare a minimal DTB for DOM0 which contains > + * bootargs, memory information, > + * ACPI RSDP pointer. > + */ > +static int prepare_dtb_acpi(struct domain *d, struct kernel_info *kinfo) > +{ > + int new_size; > + int ret; > + > + DPRINT("Prepare a min DTB for DOM0\n"); > + > + /* Allocate min size for DT */ > + new_size = DOM0_FDT_MIN_SIZE; > + kinfo->fdt = xmalloc_bytes(DOM0_FDT_MIN_SIZE); > + > + if ( kinfo->fdt == NULL ) > + return -ENOMEM; > + > + /* Create a new empty DT for DOM0 */ > + ret = fdt_create(kinfo->fdt, new_size); > + if ( ret < 0 ) > + goto err; > + > + /* Reserve the memory space for new DT */ Wrong comment. > + ret = fdt_finish_reservemap(kinfo->fdt); > + if ( ret < 0 ) > + goto err; > + > + ret = fdt_begin_node(kinfo->fdt, "/"); > + if ( ret < 0 ) > + goto err; > + > + ret = fdt_property_cell(kinfo->fdt, "#address-cells", 2); > + if ( ret ) > + return ret; > + > + ret = fdt_property_cell(kinfo->fdt, "#size-cells", 1); > + if ( ret ) > + return ret; > + > + ret = fdt_end_node(kinfo->fdt); > + if ( ret < 0 ) > + goto err; > + > + ret = fdt_finish(kinfo->fdt); > + if ( ret < 0 ) > + goto err; > + > + return 0; > + > + err: > + printk("Device tree generation failed (%d).\n", ret); > + xfree(kinfo->fdt); > + return -EINVAL; > +} > + > static int prepare_dtb(struct domain *d, struct kernel_info *kinfo) > { > const void *fdt; > @@ -1305,7 +1366,11 @@ int construct_dom0(struct domain *d) > I bet the change in construct_dom0 should be more complex than the 4 lines. For instance, initrd_load fixup the DTB when the initrd is present. How initrd should be loaded in presence of ACPI? > allocate_memory(d, &kinfo); > > - rc = prepare_dtb(d, &kinfo); > + if (acpi_disabled) > + rc = prepare_dtb(d, &kinfo); The name prepare_dtb is now confusing. We should find a better name. > + else > + rc = prepare_dtb_acpi(d, &kinfo); > + > if ( rc < 0 ) > return rc; > > Regards, -- Julien Grall