From nobody Tue Feb 10 01:19:56 2026 Received: from mail-il1-f175.google.com (mail-il1-f175.google.com [209.85.166.175]) (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 C79A832C93C for ; Fri, 14 Nov 2025 14:28:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763130501; cv=none; b=JNkqS64Lgqv+xpgKGixsRVREZnzTZINGbjGqD6ZXXw7SOb3eHUT0fjibj8mvhx3//IXpADfVBfJeEi4pfHz9rr/X9GUHkMxP9nB0i8BdPVjWHQfEAex4y6E7fKnAN4pU/aSK5pFqiRkvW+MBWFHfmHKmPe1LmjkWpAx4f5cvJTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763130501; c=relaxed/simple; bh=iRwr4aWqYl4kIwimtlljRUSeu5ezG3oP5PG69wjW44g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Lca6bQAaZfyz7n6KBKa9wljaSR6vBmpAhjpboJSrwZgKUz5hB3F19lVC7Gl5FYcFrXr/DSMXYpAA2C+mJWhdOdPfQcmY1H3zKXnP/KWKyJXsebZ07wDJb2vDWdWrlNkoIfzyRei/N7+pJUE3oEBuKEVnieDTnkrga+gAWSyQ0M4= 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=fiiNJ/nE; arc=none smtp.client-ip=209.85.166.175 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="fiiNJ/nE" Received: by mail-il1-f175.google.com with SMTP id e9e14a558f8ab-43470d98f77so9497955ab.2 for ; Fri, 14 Nov 2025 06:28:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1763130499; x=1763735299; 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=b318BeGWA3r29XTQ0vNTU6rijD9/dIK2iMOcNHHPjBE=; b=fiiNJ/nER4yVJ6alDCyLzYJfdrlRo/XHmSxLEPiORSNQd+HGRK5hVj8chLMqHCikRZ tERfp2qfKuo3Z6wThF8Zggm8BZkuvwzVUI0UAttqDHYTlYW0fKlYuCR2W9GPnXhF05i6 YxUNHRcLrHLAa6sQL7pmSgJuNxGQCk7Kl0kD4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763130499; x=1763735299; 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=b318BeGWA3r29XTQ0vNTU6rijD9/dIK2iMOcNHHPjBE=; b=VL39vEj12GKS2GychqxGWw3HYDLgKn3MFll9ZdlLBgzuhuqQLAuAM8LP6jIwTaPPWH Y1qD48X5oR5iygQDLWk3Btkv+jiBNAAXH6geumZ9omkHFzXO4E/YM3EUJcB1Y31S7LYs ldnQUx2SVkLyMrxoF9fq+0qEWm2veFW1ytKZrXwKt0lOd1OEZyBu/4Ov3qEpzO9IXw7d YJ3TjWbDi4zgE7/NxGCScYFDmpVQWBQWJtSJj125gZ2ZiEFSzEV9/gyu/VuB2NCpcEF3 RlRo2V1pst3aWDVh5arEqGFJJrWUj6QKSD86XYoLGDeJjWqA8RzYS0q/84c6QrlTPZgo 9JjQ== X-Forwarded-Encrypted: i=1; AJvYcCU1xXk7ZytcPxOgtW9YxKQOTyQya0Rlfr7F3/OQbnpEo61rZ/tco5JqXlDmgiVw9Ey5JhwKiWXKfxMpaXY=@vger.kernel.org X-Gm-Message-State: AOJu0YyDLvTBH6AJ+cShsLVQfDL+t/3iV3i4aebH19GqySJpL7mtfa2f tsMimFCZqmwOkPCwagDDl015ecx4d1Vqg07b7mNXCF3tBECCGcjkXLCSz2Ro70J8xg== X-Gm-Gg: ASbGncs8jYrtUc8cA19vUm4UjJMPdb2Hror8/8zgSqSqSlw/g5Vd/mUDaC8kvm0u38N NRu01xm2iVnzo7BA049gNOI9dLfCMp1P9xIi5RSe9gtarAOacP6oBDJ32e2lPaG1r887RbKjkx5 gQYEEd9bNdlBjz9II29xgVD+6wg8F5S3prPhoblzWg7/9hkMil2A7lXcIkUHnruHk0o1PhL1+Lt Wd1ghdOZRQn0u4hRv+SD/+240laCuXN3Ch0xt8CESncIc2Ui045OAvP/Fmcia/lQvt4c+Fyumh5 KpzYTxRtPhMBXvF8jbwUTFtZUbbmylrcdaxKy4auREunnz8lgVyY+d4cjGHYbIbHTaO3lPRRh7d zoyAXS+Vh3Pa+fdzsDTQYpLFgc7HysB+NSot6PR8ncYwTH2cLiOGqCPfhHsUh+mYohKoGEe6SQD 96io93 X-Google-Smtp-Source: AGHT+IEsHcIFm8dXTBDkdjl5jk0rVOZMeytOzdSeMB9ux68T/mGruUqL+yzI070U3lDQqZZhTkEkSg== X-Received: by 2002:a05:6e02:5e8a:b0:434:96ea:ff56 with SMTP id e9e14a558f8ab-43496eb00b0mr156465ab.39.1763130498831; Fri, 14 Nov 2025 06:28:18 -0800 (PST) Received: from chromium.org ([73.34.74.121]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-434839cdb10sm27500205ab.32.2025.11.14.06.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Nov 2025 06:28:17 -0800 (PST) From: Simon Glass To: linux-arm-kernel@lists.infradead.org Cc: Nicolas Schier , Masahiro Yamada , Chen-Yu Tsai , Tom Rini , Ahmad Fatoum , =?UTF-8?q?J=20=2E=20Neusch=C3=A4fer?= , Simon Glass , linux-kernel@vger.kernel.org Subject: [PATCH v5 8/8] scripts/make_fit: Compress dtbs in parallel Date: Fri, 14 Nov 2025 07:27:34 -0700 Message-ID: <20251114142741.1919072-9-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251114142741.1919072-1-sjg@chromium.org> References: <20251114142741.1919072-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 --- (no changes since v1) 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 10a040f4eb83..d1af496f3a57 100755 --- a/scripts/make_fit.py +++ b/scripts/make_fit.py @@ -43,6 +43,7 @@ as U-Boot, Linuxboot, Tianocore, etc. =20 import argparse import collections +import multiprocessing import os import shutil import subprocess @@ -237,15 +238,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)) @@ -253,9 +270,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 build_ramdisk(args, tmpdir): @@ -366,6 +384,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': @@ -377,11 +400,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