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: 6723531 Return-Path: X-Original-To: patchwork-linux-kbuild@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 89878C05AC for ; Mon, 6 Jul 2015 12:47:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9FCA520644 for ; Mon, 6 Jul 2015 12:47:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A74C220643 for ; Mon, 6 Jul 2015 12:47:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754474AbbGFMrR (ORCPT ); Mon, 6 Jul 2015 08:47:17 -0400 Received: from condef002-v.nifty.com ([210.131.4.239]:38255 "EHLO condef002-v.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754855AbbGFMrQ (ORCPT ); Mon, 6 Jul 2015 08:47:16 -0400 X-Greylist: delayed 372 seconds by postgrey-1.27 at vger.kernel.org; Mon, 06 Jul 2015 08:47:16 EDT Received: from conuserg011-v.nifty.com ([10.16.229.198])by condef002-v.nifty.com with ESMTP id t66Cc9vG016591 for ; Mon, 6 Jul 2015 21:38:10 +0900 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 Cc: Michal Marek , linux-kbuild@vger.kernel.org, Masahiro Yamada , Russell King , linux-kernel@vger.kernel.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 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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)/$@