From nobody Tue Feb 10 01:59:08 2026 Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4F2031D726 for ; Sat, 27 Dec 2025 14:22:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766845357; cv=none; b=dDBwnH+gt4V+/ExnSOkNAL3fqYlMOzakJtWRUm08m08FRrIOTpyJkUQPAqCCniVwuAEiv+LFAO79jyUlHF/m92OWpOr7aIRkZAx3fwYTFUOIaxpw86VcIzfnJyphriFqs9H15sNqsVsZGJYgbuZsAPKkbkeamqjLPJ+SYz4PxFc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766845357; c=relaxed/simple; bh=2v9Ov13bzeY9YTAeY6kGNre6+aj8ZdSVZ65J0kCe5fM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dUKYuV7oJd/odQajocprxGYwc0DDRHxup4XYQfWPjeHBfuGpltU9HXCsFRtI8pD+tMZ0/K0jqdBVLcZb2lsr+gEc8SoE9nUDH4Watxmp7lDf4hhEaT813DXpwT0p61osrW+xaGhsgmuRsV1eXNSr0BIaRLsfOpih4Qf/PsA17Yo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=gIdweX3u; arc=none smtp.client-ip=209.85.210.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="gIdweX3u" Received: by mail-ot1-f51.google.com with SMTP id 46e09a7af769-7cac9225485so6274577a34.3 for ; Sat, 27 Dec 2025 06:22:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1766845354; x=1767450154; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dkOl3+2E5uBM0wxWZy4TsfgVfQXwCyjeP1JIoSVkCIk=; b=gIdweX3uFZUegh/3JjfcS/SgtjJfYd+kv85cmA4wXBE2T+IT5F4OkTp8oYibcvzckZ JRYAMtw5wK33VwgX095LcmpW/kkbVlAsCIbbI3BrbyTmCHD7cz4S2EwfYSxNTA4F6YbD C/pyX6Vqr5Ywk83aBQ9c/mKO5xPYSzb+VjpQI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766845354; x=1767450154; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=dkOl3+2E5uBM0wxWZy4TsfgVfQXwCyjeP1JIoSVkCIk=; b=Twq2J8cQReSIoIpBSpKOBCIkbg1FTCrjBieUE2Y4NT0XGPFoqLy05Bu0cR5rojLlSS 3GPCxtYdr2E1sjbRne86WdnpX/oa93XoDoTEm2P6mWcnNdGf1x/9kzPZ7Y+O4P23+mJ8 uG5x+v3hmqe3J1QTUjx1wY60cvsRV0y3cKvv8es5noi9+7lDOXOdDicjxSJB3kmkqpDA w6sB9WdKzC+V8DKplPSlh0yYlKPFC1EQ+0LT1jGNNeHFJdwQFghmMzBp086yR82dnv2E /cWkyHTUof3xTJ5KUy5dntP4D2fMyTNGxoMG8YXpLdYuy3u+y1CnJG3zmqnfYYNVRDou XimA== X-Forwarded-Encrypted: i=1; AJvYcCUpeq1Saxj+ZKugbJZt1GS/LfAuNqOU2Zkjhg9NbUm8cWX/Ilc5CsLHmBJZYstSuWaomRha3jgzlq9pMUY=@vger.kernel.org X-Gm-Message-State: AOJu0YxoGKPijGuBsMJMtsLaWvmCFpe8S4Hpjrxdl/fDh5neQxN+Dz8y nskWc20xJvAXnSsT4zHU1tTo06BqT03ay8/aMVsD8kx2KihlgjPnzgIgzIOeqosmTA== X-Gm-Gg: AY/fxX7+wGhb/wG1nCJYzTKesbw1xY7tMi3cNDsn9SeiWolToXQAqI7ghiPekdKX734 JT6m+Q18UR3OSKo200NPEWjAswd4sTO0dm+G+kvXCmsNwvimnxCqKgo7OcbbjVF02gCbs55+WHp WEbxPXPLoucyb2QjUpmCm/llKYkPPld7KfQcT6FmiAbKU19qGE4Gxg2QQGA7uxVrGzlweA50RHF R995JfstXQuMgi8F+3pnCb4TwRHMkeES7pXfodXm1ZqjSzxAQT3Zx7xNNQe/O1RQ8ExT6HhhQtO FrgUhh3vv8VfqxiV2LdJghlZxZAS0NOKUaGcY5JJE1rS6KPTMT1cqEwBAF7XYli/ObHWO7rV1Mf 6gtEz07UmP7qL6EtoGRIvL1h8TFZSMCuTWl7Xl9/60OnXJmdDkSfGwXmmqpya156aSFIeVGKScn m5PglB X-Google-Smtp-Source: AGHT+IH+2fFfhpMMxFeukqxtBdzObwyT8Ia+HitEAnOFLETYjHsbEDshOLHe3rAQCd4FWWRGCErwog== X-Received: by 2002:a05:6830:4104:b0:7c7:62d0:b462 with SMTP id 46e09a7af769-7cc668ffda5mr13302862a34.6.1766845354627; Sat, 27 Dec 2025 06:22:34 -0800 (PST) Received: from chromium.org ([73.34.74.121]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7cc66727e11sm17352660a34.3.2025.12.27.06.22.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Dec 2025 06:22:33 -0800 (PST) From: Simon Glass To: linux-arm-kernel@lists.infradead.org Cc: Masahiro Yamada , Chen-Yu Tsai , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Nicolas Schier , =?UTF-8?q?J=20=2E=20Neusch=C3=A4fer?= , Ahmad Fatoum , Tom Rini , Simon Glass , linux-kernel@vger.kernel.org Subject: [PATCH v8 6/6] scripts/make_fit: Compress dtbs in parallel Date: Sat, 27 Dec 2025 07:21:50 -0700 Message-ID: <20251227142200.2241198-7-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251227142200.2241198-1-sjg@chromium.org> References: <20251227142200.2241198-1-sjg@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When there are 1500 device tree files it takes quite a while to compress them. Do it in parallel. Signed-off-by: Simon Glass --- Changes in v8: - Drop erroneous line 'kbuild: Allow adding modules into the FIT ...' scripts/make_fit.py | 56 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/scripts/make_fit.py b/scripts/make_fit.py index defb87f223d7..e923cc8b05b7 100755 --- a/scripts/make_fit.py +++ b/scripts/make_fit.py @@ -37,6 +37,7 @@ as U-Boot, Linuxboot, Tianocore, etc. =20 import argparse import collections +import multiprocessing import os import subprocess import sys @@ -225,15 +226,31 @@ def compress_data(inf, compress): return comp_data =20 =20 -def output_dtb(fsw, seq, fname, arch, compress): +def compress_dtb(fname, compress): + """Compress a single DTB file + + Args: + fname (str): Filename containing the DTB + compress (str): Compression algorithm, e.g. 'gzip' + + Returns: + tuple: (str: fname, bytes: compressed_data) + """ + with open(fname, 'rb') as inf: + compressed =3D compress_data(inf, compress) + return fname, compressed + + +def output_dtb(fsw, seq, fname, arch, compress, data=3DNone): """Write out a single devicetree to the FIT =20 Args: fsw (libfdt.FdtSw): Object to use for writing seq (int): Sequence number (1 for first) fname (str): Filename containing the DTB - arch: FIT architecture, e.g. 'arm64' + arch (str): FIT architecture, e.g. 'arm64' compress (str): Compressed algorithm, e.g. 'gzip' + data (bytes): Pre-compressed data (optional) """ with fsw.add_node(f'fdt-{seq}'): fsw.property_string('description', os.path.basename(fname)) @@ -241,9 +258,10 @@ def output_dtb(fsw, seq, fname, arch, compress): fsw.property_string('arch', arch) fsw.property_string('compression', compress) =20 - with open(fname, 'rb') as inf: - compressed =3D compress_data(inf, compress) - fsw.property('data', compressed) + if data is None: + with open(fname, 'rb') as inf: + data =3D compress_data(inf, compress) + fsw.property('data', data) =20 =20 def process_dtb(fname, args): @@ -300,6 +318,11 @@ def _process_dtbs(args, fsw, entries, fdts): """ seq =3D 0 size =3D 0 + + # First figure out the unique DTB files that need compression + todo =3D [] + file_info =3D [] # List of (fname, model, compat, files) tuples + for fname in args.dtbs: # Ignore non-DTB (*.dtb) files if os.path.splitext(fname)[1] !=3D '.dtb': @@ -311,11 +334,32 @@ def _process_dtbs(args, fsw, entries, fdts): sys.stderr.write(f'Error processing {fname}:\n') raise e =20 + file_info.append((fname, model, compat, files)) + for fn in files: + if fn not in fdts and fn not in todo: + todo.append(fn) + + # Compress all DTBs in parallel + cache =3D {} + if todo and args.compress !=3D 'none': + if args.verbose: + print(f'Compressing {len(todo)} DTBs...') + + with multiprocessing.Pool() as pool: + compress_args =3D [(fn, args.compress) for fn in todo] + # unpacks each tuple, calls compress_dtb(fn, compress) in para= llel + results =3D pool.starmap(compress_dtb, compress_args) + + cache =3D dict(results) + + # Now write all DTBs to the FIT using pre-compressed data + for fname, model, compat, files in file_info: for fn in files: if fn not in fdts: seq +=3D 1 size +=3D os.path.getsize(fn) - output_dtb(fsw, seq, fn, args.arch, args.compress) + output_dtb(fsw, seq, fn, args.arch, args.compress, + cache.get(fn)) fdts[fn] =3D seq =20 files_seq =3D [fdts[fn] for fn in files] --=20 2.43.0