From patchwork Mon Jul 6 12:37:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 6723521 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9A475C05AC for ; Mon, 6 Jul 2015 12:39:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BE6B42062F for ; Mon, 6 Jul 2015 12:39:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 730832062C for ; Mon, 6 Jul 2015 12:39:38 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZC5ei-000751-0X; Mon, 06 Jul 2015 12:37:52 +0000 Received: from conuserg011.nifty.com ([202.248.44.37] helo=conuserg011-v.nifty.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZC5ef-0006vp-HA for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2015 12:37:50 +0000 Received: from beagle.diag.org (KD111107168053.au-net.ne.jp [111.107.168.53]) (authenticated) by conuserg011-v.nifty.com with ESMTP id t66Cb8bE019642; Mon, 6 Jul 2015 21:37:19 +0900 X-Nifty-SrcIP: [111.107.168.53] From: Masahiro Yamada To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: add boot image dependencies not to generate invalid images Date: Mon, 6 Jul 2015 21:37:04 +0900 Message-Id: <1436186224-6673-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150706_053749_796872_BF674603 X-CRM114-Status: GOOD ( 10.64 ) X-Spam-Score: 0.2 (/) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Marek , Masahiro Yamada , Russell King , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP U-Boot is often used to boot the kernel on ARM boards, but uImage is not built by "make all", so we are often inclined to do "make all uImage" in a single command, but we should notice a pitfall behind it. In fact, "make all uImage" could generate an invalid uImage if it is run with the parallel option (-j). You can reproduce this problem with the following procedure: [1] First, build "all" and "uImage" separately. You will get a valid uImage $ export CROSS_COMPILE= $ make -s -j8 ARCH=arm multi_v7_defconfig $ make -s -j8 ARCH=arm all $ make -s -j8 ARCH=arm UIMAGE_LOADADDR=0x80208000 uImage Image Name: Linux-4.2.0-rc1-00008-g1c4c715 Created: Mon Jul 6 17:49:52 2015 Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 6145624 Bytes = 6001.59 kB = 5.86 MB Load Address: 80208000 Entry Point: 80208000 $ cat arch/arm/boot/uImage | wc 17553 107879 6145688 [2] Update some source file(s) $ touch init/main.c [3] Then, re-build "all" and "uImage" simultaneously. You will get an invalid uImage at random. $ make -s -j8 ARCH=arm UIMAGE_LOADADDR=0x80208000 all uImage Image Name: Linux-4.2.0-rc1-00008-g1c4c715-d Created: Mon Jul 6 17:52:22 2015 Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 26768 Bytes = 26.14 kB = 0.03 MB Load Address: 80208000 Entry Point: 80208000 $ cat arch/arm/boot/uImage | wc 266 1063 26832 Please notice the uImage is extremely small when this issue is encountered. The root cause of this is the race condition between zImage and uImage targets. "make uImage" could descend into arch/arm/boot/Makefile before "make zImage" is completed because arch/arm/Makefile describes no dependency among boot targets. The same problem could happen on bootpImage. Add correct dependencies among Image, zImage, uImage, and bootpImage to eliminate this pit-fall. Signed-off-by: Masahiro Yamada --- arch/arm/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 07ab3d2..7451b44 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -312,6 +312,9 @@ INSTALL_TARGETS = zinstall uinstall install PHONY += bzImage $(BOOT_TARGETS) $(INSTALL_TARGETS) +bootpImage uImage: zImage +zImage: Image + $(BOOT_TARGETS): vmlinux $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/$@