Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: Jonas Gorski <jogo@openwrt.org>
Cc: Ralf Baechle <ralf@linux-mips.org>,
	linux-mips@linux-mips.org, Kevin Cernekee <cernekee@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	John Crispin <john@phrozen.org>,
	Paul Burton <paul.burton@imgtec.com>,
	James Hogan <james.hogan@imgtec.com>, Alban Bedel <albeu@free.fr>,
	Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
Subject: Re: [PATCH 1/2] MIPS: ZBOOT: copy appended dtb to the end of the kernel
Date: Fri, 17 Jun 2016 18:06:41 +0300	[thread overview]
Message-ID: <20160617180641.b8996bd61014fa1aae68e4b8@gmail.com> (raw)
In-Reply-To: <b57eb27d-f7fe-b457-1915-75e995668a06@openwrt.org>

On Fri, 17 Jun 2016 16:44:09 +0200
Jonas Gorski <jogo@openwrt.org> wrote:

> Hi Antony,
> 
> On 17.06.2016 16:01, Antony Pavlov wrote:
> > On Fri, 17 Jun 2016 14:07:39 +0200
> > Jonas Gorski <jogo@openwrt.org> wrote:
> > 
> >> Instead of rewriting the arguments, just move the appended dtb to where
> >> the decompressed kernel expects it. This eliminates the need for special
> >> casing vmlinuz.bin appended dtb files.
> >>
> >> Signed-off-by: Jonas Gorski <jogo@openwrt.org>
> >> ---
> >>  arch/mips/Kconfig                      | 22 ++--------------------
> >>  arch/mips/boot/compressed/Makefile     |  1 +
> >>  arch/mips/boot/compressed/decompress.c | 21 +++++++++++++++++++++
> >>  arch/mips/boot/compressed/head.S       | 16 ----------------
> >>  4 files changed, 24 insertions(+), 36 deletions(-)
> >>
> >> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> >> index ac91939..0d0f71e 100644
> >> --- a/arch/mips/Kconfig
> >> +++ b/arch/mips/Kconfig
> >> @@ -2885,10 +2885,10 @@ choice
> >>  		  the documented boot protocol using a device tree.
> >>  
> >>  	config MIPS_RAW_APPENDED_DTB
> >> -		bool "vmlinux.bin"
> >> +		bool "vmlinux.bin or vmlinuz.bin"
> >>  		help
> >>  		  With this option, the boot code will look for a device tree binary
> >> -		  DTB) appended to raw vmlinux.bin (without decompressor).
> >> +		  DTB) appended to raw vmlinux.bin or vmlinuz.bin.
> >>  		  (e.g. cat vmlinux.bin <filename>.dtb > vmlinux_w_dtb).
> >>  
> >>  		  This is meant as a backward compatibility convenience for those
> >> @@ -2900,24 +2900,6 @@ choice
> >>  		  look like a DTB header after a reboot if no actual DTB is appended
> >>  		  to vmlinux.bin.  Do not leave this option active in a production kernel
> >>  		  if you don't intend to always append a DTB.
> >> -
> >> -	config MIPS_ZBOOT_APPENDED_DTB
> >> -		bool "vmlinuz.bin"
> >> -		depends on SYS_SUPPORTS_ZBOOT
> >> -		help
> >> -		  With this option, the boot code will look for a device tree binary
> >> -		  DTB) appended to raw vmlinuz.bin (with decompressor).
> >> -		  (e.g. cat vmlinuz.bin <filename>.dtb > vmlinuz_w_dtb).
> >> -
> >> -		  This is meant as a backward compatibility convenience for those
> >> -		  systems with a bootloader that can't be upgraded to accommodate
> >> -		  the documented boot protocol using a device tree.
> >> -
> >> -		  Beware that there is very little in terms of protection against
> >> -		  this option being confused by leftover garbage in memory that might
> >> -		  look like a DTB header after a reboot if no actual DTB is appended
> >> -		  to vmlinuz.bin.  Do not leave this option active in a production kernel
> >> -		  if you don't intend to always append a DTB.
> >>  endchoice
> >>  
> >>  choice
> >> diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile
> >> index 90aca95..f31ec89 100644
> >> --- a/arch/mips/boot/compressed/Makefile
> >> +++ b/arch/mips/boot/compressed/Makefile
> >> @@ -29,6 +29,7 @@ KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
> >>  	-DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \
> >>  	-DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS)
> >>  
> >> +
> > 
> > Could you please remote this extra empty line?
> 
> Oops, that must have slipped through. Fixed locally.
> 
> >>  # decompressor objects (linked with vmlinuz)
> >>  vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o
> >>  
> >> diff --git a/arch/mips/boot/compressed/decompress.c b/arch/mips/boot/compressed/decompress.c
> >> index 080cd53..e18ab3e 100644
> >> --- a/arch/mips/boot/compressed/decompress.c
> >> +++ b/arch/mips/boot/compressed/decompress.c
> >> @@ -36,6 +36,12 @@ extern void puthex(unsigned long long val);
> >>  #define puthex(val) do {} while (0)
> >>  #endif
> >>  
> >> +#ifdef CONFIG_MIPS_RAW_APPENDED_DTB
> > 
> > Do we really need this '#ifdef' here?
> 
> No we don't, I was under the assumption the __appended_dtb is
> only available when appended dtb support is enabled, for for
> the decompressor it is always defined. At least gcc doesn't
> seem to complain about it being unused in a quick test
> compile. Fixed locally.

Now the __appended_dtb variable is always available.
You can make the next step and try to transform your

  +#ifdef CONFIG_MIPS_RAW_APPENDED_DTB
  +	if (fdt_magic((void *)&__appended_dtb) == FDT_MAGIC) {
  +		unsigned int image_size, dtb_size;

into something like this

  +     if (IS_ENABLED(CONFIG_MIPS_RAW_APPENDED_DTB) &&
  +	    fdt_magic((void *)&__appended_dtb) == FDT_MAGIC) {
  +		unsigned int image_size, dtb_size;


Using IS_ENABLED instead of #if/#ifdef the compiler can check
all the code.

-- 
Best regards,
  Antony Pavlov

  reply	other threads:[~2016-06-17 15:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-17 12:07 [PATCH 0/2] MIPS: keep firmwmare arguments with appended dtb Jonas Gorski
2016-06-17 12:07 ` [PATCH 1/2] MIPS: ZBOOT: copy appended dtb to the end of the kernel Jonas Gorski
2016-06-17 14:01   ` Antony Pavlov
2016-06-17 14:44     ` Jonas Gorski
2016-06-17 15:06       ` Antony Pavlov [this message]
2016-06-17 12:07 ` [PATCH 2/2] MIPS: store the appended dtb address in a variable Jonas Gorski
2016-06-17 16:56   ` Daniel Gimpelevich
2016-06-20  9:31     ` Jonas Gorski

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=20160617180641.b8996bd61014fa1aae68e4b8@gmail.com \
    --to=antonynpavlov@gmail.com \
    --cc=albeu@free.fr \
    --cc=cernekee@gmail.com \
    --cc=daniel@gimpelevich.san-francisco.ca.us \
    --cc=f.fainelli@gmail.com \
    --cc=james.hogan@imgtec.com \
    --cc=jogo@openwrt.org \
    --cc=john@phrozen.org \
    --cc=linux-mips@linux-mips.org \
    --cc=paul.burton@imgtec.com \
    --cc=ralf@linux-mips.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