Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2384665rda; Wed, 25 Oct 2023 00:42:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYvAFLBs6HkDe0f8YgNiswHjIsgBSb9/Cn2eKmxQn+6ZAkvMMbhsafj6AGH0hWcsdd/qbw X-Received: by 2002:a0d:e84d:0:b0:5a7:d938:c5e2 with SMTP id r74-20020a0de84d000000b005a7d938c5e2mr14634549ywe.14.1698219768940; Wed, 25 Oct 2023 00:42:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698219768; cv=none; d=google.com; s=arc-20160816; b=GSzZLG7+rkm2RYCGWPZyAhXtYBc82ZV6V5UifI5ROOT+Zcdon8BbCqhgRqaoSNfcgP cZMfw3FnqsWfVn+VBiXLh9Jos+NNbmHrhoKyUbLw/Rqt6ZmSH+d4kKyqaELEvm49xERJ fKl3a2ouUS5OVCXjTJESCZrVt9hrKuF8XOws7byY0SrgmQt0g3m/CUElhS3efRW7Yw2g JLI7j6JCDYKHtdByJXSqbVdBNDFHh+5n0NIDZDvdKZZSEod2R8K/HXWMvM0vVTFoi4BJ GnW0JwMMBqFvYDloEO/YASJzWNnWxNko7iV3vmhXIMRZbAl1mOLmpOUHuEzfpex7upT2 VueQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=rczZnqmf2oJWEm+utFuMjU8M9oOjD9zBSJMHjBMd3Yg=; fh=zAnFVRAAY3Wj9MefkcNInGCZKp1SfaAzpylKazQkzw0=; b=h8mq0qs5C1rK8zYY+oqBcfQe3L20BZvcf+e6xHDFdXKoF65uluukx1HerjlEe+2FYu /Jc0pjgXA9QgSGdGoIIvVc4HxdbqCUQWemaNuU1SGZwtfM5X+5gGEXpdu3Sa06FHO8WW qWKClnPPRdjF9DPi5Nb7v9zMVjTbeqMubykYRjT/qLUzuN+tvf9Ct93h264POIg/2gI3 hR+qMA0ITOysXIfdja+Z9D4RkYjZgSFDuCdap53oYFz9AlktVz/yjfrvOp5qnsSlq5JA TUEPqIHredqwRLhzdiWRV2USJAo+DhdXb1YQfqRjJykoO87pqAoE+PItHNtVSkxeIoZp r+WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=SQ6wcvyd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id y198-20020a81a1cf000000b005a7f9634341si9852047ywg.151.2023.10.25.00.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 00:42:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=SQ6wcvyd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 8C0A68075287; Wed, 25 Oct 2023 00:42:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234043AbjJYHmi (ORCPT + 99 others); Wed, 25 Oct 2023 03:42:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234033AbjJYHmV (ORCPT ); Wed, 25 Oct 2023 03:42:21 -0400 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB4551FEC; Wed, 25 Oct 2023 00:41:44 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 66F98FF805; Wed, 25 Oct 2023 07:41:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1698219703; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rczZnqmf2oJWEm+utFuMjU8M9oOjD9zBSJMHjBMd3Yg=; b=SQ6wcvydOl+EbbCwlao/yg42LxLjOgNbvxFhi1TAviQhp47LC+0zS1vX0CVsm8mP0q/mhm e8YkylyHcVOA8MNDtAQipZYZDEmkE8Q2bRortE8oBpkKvYTa6fQJzdsofbtW6129c6QNZI kaMSnJaC/ff6Zip4gRnTBTTtlNqgQdOK8SY0SH6asFFhz15bMtmcDNCjaA37WgwmD+RdYd iU/8ZEKKA9I9NHaDOvhXx69pgRtqPoawGDQ1inilN/UMnDViiP+zx88OvSoGUQke9oomCo JLe7dzVSd6Awjvcbo+EN35gF7KcZBRpKKKgcth3OOWlqk14qxuqrnnzD0jtc0g== Date: Wed, 25 Oct 2023 09:41:40 +0200 From: Miquel Raynal To: Edward Chow Cc: Rob Herring , Richard Weinberger , Vignesh Raghavendra , Krzysztof Kozlowski , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] dt-bindings: mtd-partitions: Export special values Message-ID: <20231025094140.3da9ad71@xps-13> In-Reply-To: <20231025052937.830813-1-equu@openmail.cc> References: <20231025052937.830813-1-equu@openmail.cc> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: miquel.raynal@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 25 Oct 2023 00:42:46 -0700 (PDT) Hi Edward, Thanks for the proposal! equu@openmail.cc wrote on Wed, 25 Oct 2023 13:29:37 +0800: > There are special "offset" and "size" values defined and documented in > linux/mtd/partitions.h: >=20 > // consume as much as possible, leaving size after the end of partition. >=20 > // the partition will start at the next erase block. >=20 > // the partition will start where the previous one ended. >=20 > (Though not explicitly, they are compared against variables in uint64_t > in drivers/mtd/mtdpart.c, so they had better be considered as such.) >=20 > // the partition will extend to the end of the master MTD device. >=20 > These special values could be used to define partitions automatically > fitting to the size of the master MTD device at runtime. >=20 > However, these values used not to be exported to dt-bindings, thus > seldom used before, since they might have been only used in numeric form, > such as "(-1) (-3)" for MTDPART_OFS_RETAIN. >=20 > Now, they are exported in dt-bindings/mtd/partitions.h as 32-bit cell > values, so 2-cell addressed should be defined to use special offset value= s, > such as "MTDPART_OFS_SPECIAL MTDPART_OFS_RETAIN" for MTDPART_OFS_RETAIN in > linux/mtd/partitions.h. An example is added to fixed-partitions.yaml. I don't think this has ever been used in DT, it comes from a previous era where everything was declared in machine code and was never intended to be part of the official bindings. We've been trying to clarify the partitions binding to make them clean and easily usable and I believe this comes from old times and is way too legacy and backwards to be exposed. Typically, this comes from times where the storage devices were so small that an erase block boundary would be way too big and one would want to store different "partitions" in a single block. It is close to impossible to find such devices today so I don't think it really matters and, as a general advice, should not be used anymore. > Signed-off-by: Edward Chow > --- > .../mtd/partitions/fixed-partitions.yaml | 29 +++++++++++++++++++ > MAINTAINERS | 2 ++ > include/dt-bindings/mtd/partitions.h | 15 ++++++++++ > 3 files changed, 46 insertions(+) > create mode 100644 include/dt-bindings/mtd/partitions.h >=20 > diff --git a/Documentation/devicetree/bindings/mtd/partitions/fixed-parti= tions.yaml b/Documentation/devicetree/bindings/mtd/partitions/fixed-partiti= ons.yaml > index 331e564f29dc..a939fb52ef76 100644 > --- a/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.y= aml > +++ b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.y= aml > @@ -164,3 +164,32 @@ examples: > read-only; > }; > }; > + > + - | > + partitions { > + compatible =3D "fixed-partitions"; > + #address-cells =3D <2>; > + #size-cells =3D <1>; > + > + partition@0 { > + label =3D "bootloader"; > + reg =3D <0 0x000000 0x020000>; > + read-only; > + }; > + > + firmware@1 { > + label =3D "firmware"; > + /* From the end of the last partition, occupying as mush > + * as possible, retaining 0x010000 after it, > + * "MTDPART_OFS_SPECIAL MTDPART_OFS_NXTBLK" similar to > + * this, but always beginning at erase block boundary. */ > + reg =3D ; > + }; > + > + calibration@2 { > + compatible =3D "fixed-partitions"; > + label =3D "calibration"; > + /* Appending to the last partition, occupying 0x010000 */ > + reg =3D ; > + }; > + }; > diff --git a/MAINTAINERS b/MAINTAINERS > index 668d1e24452d..7d6beadc8b36 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -13771,9 +13771,11 @@ T: git git://git.kernel.org/pub/scm/linux/kernel= /git/mtd/linux.git mtd/fixes > T: git git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/n= ext > F: Documentation/devicetree/bindings/mtd/ > F: drivers/mtd/ > +F: include/dt-bindings/mtd/ > F: include/linux/mtd/ > F: include/uapi/mtd/ This is a nice addition but totally unrelated, please make a separated patch. > =20 > + > MEMSENSING MICROSYSTEMS MSA311 DRIVER > M: Dmitry Rokosov > L: linux-iio@vger.kernel.org > diff --git a/include/dt-bindings/mtd/partitions.h b/include/dt-bindings/m= td/partitions.h > new file mode 100644 > index 000000000000..456a54a1259a > --- /dev/null > +++ b/include/dt-bindings/mtd/partitions.h > @@ -0,0 +1,15 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * Device Tree constants identical to those in include/linux/mtd/partiti= ons.h > + */ > + > +#ifndef _DT_BINDINGS_MTD_PARTITIONS_H > +#define _DT_BINDINGS_MTD_PARTITIONS_H > + > +#define MTDPART_OFS_SPECIAL (-1) This one does not exist, maybe -1 is hardcoded in the code and defining it close to the existing definitions (not shared with the bindings) make sense, but that is a different patch. > +#define MTDPART_OFS_RETAIN (-3) > +#define MTDPART_OFS_NXTBLK (-2) > +#define MTDPART_OFS_APPEND (-1) > +#define MTDPART_SIZ_FULL (0) Just as an FYI, I would have expected the existing definitions to be dropped if we were to take the patch. Thanks, Miqu=C3=A8l