From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796309501; b=PeAJeXBw+FuqsWac95HAwGbhbow8a5ZRcHwdPhQpTq7fgKEqVWUGGqg0xEzS6Z7RgLAo Lst7KN2jDcrr+2GbGpdbvxFf2GzsRJRlupGRqum3GsWNIwig/8/uHzSJ1lUEpn7ehZA3m BkKqNXgKKPAvpuabW6/AI/aSJfMNL8y3Y3D5STOxn4HYYt/lO/5iISNdDSBnZsbDx19r8 zJMcGo9SLTSdcAWnhA0AueNCQcgQn7h7TmEYzvcDppx545macdXG6qWBis+d6BguGVjO6 wVbnVJH+vmAtjRinNyDbMecEbtu2HWfnfWaL/nfyvqV6ATDJJ/lRiIuDYr1w5rFPxBA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796309501; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:Content-Language:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=eq8I0UpHtyifPJeCyfC/OTDMeiKSaA5K07bECvJswh4=; b=ATrBlN2Pi7EPKvZqD82RY+X7AlMfM/qWchbWX4LOUt4TIO0sn5WF4ICXVIuQ/0fPMzqp Wsls/XoiVZuo32t1uHse09JWUtrAJLZoFdY0K+/zF1IhToalGQUN8kCJbR+QCnCZE+WPt ORRhnKq34ljnjFzJY9HGyR669HaXFPlxRRRri5pX014xfBJevWQXFNDklJXnnbFq5h3AT qTfFX3u2eSeBurWhv/nPwTssYhxTHDtSXKPBX81CVQc4XqPGsG4LflbMPl1B8TqU3i6Er olI74HIyDSkyUqcHxq5ZD9gXANecL5viqNJddbFfgOK25XvfDsgEpi3oDb9fjgxw7FQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FZHfxu8B; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07383606A333; Thu, 3 Dec 2026 14:51:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FZHfxu8B Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32DCA1F00A27; Thu, 3 Dec 2026 14:51:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796309500; bh=eq8I0UpHtyifPJeCyfC/OTDMeiKSaA5K07bECvJswh4=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=FZHfxu8BOiYqYkoI3EEfoKdfZ5RJG80Ddc2/gbF972YG+GjPDcNQnd5Hmlw1P021w 4Ogzoln0S7tiMQJF0hSND3y27fi7mMk9OlYbxTsPC/bhNkeygdHhXdQK4BglbEAFTw PfojwZieN1jpWENxZtvPPE5Q4QF+1hFs4KeNoMoiMeoqP48Y5rgh+mGkZIju2jH+FO siuIIGpLx6uTRcYjUl2cZlH4hB/q7hv78M4SgbhojYnur8t2d0tkrP3FWm8Iz2uO5+ UdRrlYC6NC+zoRGevHHoVWWAlWQe3oDXvX7YWQViNMfeQfYo+ZdfJN4N3STlcrVAap ZfEvJZ0gtnRlA== Message-ID: <29c36614-a32a-410f-9b27-774cea90cc3c@kernel.org> Date: Thu, 3 Dec 2026 14:51:37 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 0/3] nvmem: Add byte-mask support for non-contiguous byte selection To: Loic Poulain , Srinivas Kandagatla Cc: Hongmei Xu , Rob Herring , Krzysztof Kozlowski , Conor Dooley , =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <20261202-nvmem-byte-mask-for-split-macaddr-v4-0-039f1b0afeca@oss.qualcomm.com> <7c3d76ef-3f87-478b-889a-cdc6e321d83c@kernel.org> <841dec9d-dbfb-410a-86b3-16c4b7c6d295@kernel.org> From: Srinivas Kandagatla Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 12/3/26 12:27 PM, Loic Poulain wrote: > On Thu, Dec 3, 2026 at 12:31 PM Srinivas Kandagatla wrote: >> >> >> >> On 12/3/26 11:26 AM, Loic Poulain wrote: >>> Hi Srini, >>> >>> On Wed, Dec 2, 2026 at 5:30 PM Srinivas Kandagatla wrote: >>>> >>>> >>>> >>>> On 12/2/26 11:36 AM, Hongmei Xu wrote: >>>>> Some hardware stores NVMEM cell data in non-contiguous bytes. For >>>>> example, a MAC address cell may span 7 physical bytes with one byte >>>>> unused, requiring the driver to skip that byte during readout. >>>>> >>>>> The existing 'bits' property can only selects a contiguous range of >>>>> bits within a cell's declared region. This series adds a 'byte-mask' >>>>> property to the fixed-cell binding and implements it in the nvmem >>>>> core, allowing consumers to describe and read cells whose bytes are >>>>> non-contiguous within the NVMEM device. >>>> >>>> This belongs to a custom nvmem layout driver not in the core. >>>> >>>> For that reason NAK in the current form. >>> >>> I think the commit message makes it sound very specific, but this is >>> not really a new layout format. The underlying storage is still a >>> fixed-layout NVMEM region, with no header, format parsing, or >> >> Fixed-layout as it suggests is fixed and i dont think we should try to >> add more post processing to this logic. That way it keeps simple and >> most common usecase. >> i think there was such (creating generic ones) attempts in the past, but Am happy to review once the patches hit the list. --srini >> --srini >>> variable-sized records involved. What we have here is simply a cell >>> value that requires some translation before being exposed to >>> consumers, similar to the transformations we already support through >>> offsets, bit offsets, etc. As such, introducing a dedicated layout >>> driver would effectively reimplement fixed-layout with a >>> post-processing hook on top, is it really the right abstraction layer >>> for that? >>> >>> The requirement itself also seems fairly generic. Rather than creating >>> a dedicated layout driver for each such use case, wouldn't it make >>> more sense to support a generic transformation mechanism, through a >>> byte map/remap property. Could we reconsider this approach, possibly >>> with a different implementation shape? >>> >>> Alternatively, if NVMEM core is not the right place for this, we could >>> still keep using fixed-layout and introduce a dedicated cell >>> compatible (e.g. different from mac-base) handled by the generic >>> layout code, rather than defining an entirely new layout type. > > Ok, in that case, would you be fine with the introduction of a vendor > agnostic layout driver such as 'mapped-layout' or 'composite-layout' > that would handle such more complexe but generic processing? Or should > it be a vendor qcom,composite-layout driver. > > Regards, > Loic > >>> >>> Cheers, >>> Loic >>> >>>> >>>> --srini >>>>> >>>>> An example: assume a MAC address is assembled from efuse registers >>>>> 0xFFFF4320[31:0] (bytes 0-3), 0xFFFF4324[7:0] (byte 4), and >>>>> 0xFFFF4324[23:16] (byte 6), with 0xFFFF4324[15:8] unused (byte 5). >>>>> Map the efuse region as an 8-byte nvmem device and define the cell >>>>> skipping byte 5: >>>>> >>>>> efuse: efuse@ffff4320 { >>>>> compatible = "..."; >>>>> reg = <0x0 0xffff4320 0x0 0x8>; >>>>> #address-cells = <1>; >>>>> #size-cells = <1>; >>>>> >>>>> nvmem-layout { >>>>> compatible = "fixed-layout"; >>>>> #address-cells = <1>; >>>>> #size-cells = <1>; >>>>> >>>>> mac_addr: mac-addr@0 { >>>>> reg = <0x0 0x6>; >>>>> byte-mask = <0x5f>; >>>>> }; >>>>> }; >>>>> }; >>>>> >>>>> With byte-mask = 0x5f (0101_1111), bytes 0-4 and 6 are selected >>>>> (byte 5 is skipped), forming the 6-byte MAC address output. >>>>> >>>>> Signed-off-by: Hongmei Xu >>>>> --- >>>>> Changes in v4: >>>>> - Add nvmem-layout eFuse node in Nord dtsi to expose EMAC0/EMAC1 >>>>> MAC address cells using the new byte-mask property >>>>> - Update cover letter usage example to use nvmem-layout style >>>>> - Link to v3: https://patch.msgid.link/20261117-nvmem-byte-mask-for-split-macaddr-v3-0-c02177658f66@oss.qualcomm.com >>>>> >>>>> Changes in v3: >>>>> - Align cell->raw_len to word_size in byte-mask branch to avoid false >>>>> unaligned error log >>>>> - Remove redundant nvmem_validate_byte_mask() call from >>>>> nvmem_add_cells_from_dt(); validation already happens inside >>>>> nvmem_cell_info_to_nvmem_cell_entry_nodup() >>>>> - Fix DT binding commit message: remove misleading "multiple reg >>>>> entries" comparison >>>>> - Update cover letter description for bits property limitation >>>>> - Link to v2: https://patch.msgid.link/20261116-nvmem-byte-mask-for-split-macaddr-v2-0-96f4a0c08264@oss.qualcomm.com >>>>> >>>>> Changes in v2: >>>>> - Move nvmem_validate_byte_mask() before the nbits block so byte_mask+nbits >>>>> is rejected even when nbits is set (mutual exclusion bypass fix). >>>>> - Run nvmem_validate_byte_mask() after fixup_dt_cell_info() in the DT path >>>>> so the provider callback can adjust cell info before validation. >>>>> - Set cell->raw_len = fls(byte_mask) instead of nvmem->size - cell->offset, >>>>> limiting the physical read to only the bytes needed; avoids large >>>>> allocations and read failures on providers with protected trailing regions >>>>> (e.g. sec-qfprom). >>>>> - Tighten the device-size check to ALIGN(fls(byte_mask), word_size) so >>>>> word-alignment cannot push the read past the device end. >>>>> - Zero-fill output bytes beyond the last selected byte with memset. >>>>> - Simplify compaction loop guard from i < raw_len && i < 32 to i < raw_len >>>>> since raw_len is now bounded by fls(byte_mask) <= 32. >>>>> - Link to v1: https://patch.msgid.link/20261113-nvmem-byte-mask-for-split-macaddr-v1-0-138f715f18c1@oss.qualcomm.com >>>>> >>>>> --- >>>>> Hongmei Xu (3): >>>>> dt-bindings: nvmem: add byte-mask property for non-contiguous byte selection >>>>> nvmem: core: add byte-mask support for non-contiguous cell bytes >>>>> arm64: dts: qcom: Add eFuse nvmem cells for Ethernet MAC addresses >>>>> >>>>> .../bindings/nvmem/layouts/fixed-cell.yaml | 21 +++++ >>>>> .../devicetree/bindings/nvmem/qcom,qfprom.yaml | 1 + >>>>> arch/arm64/boot/dts/qcom/nord.dtsi | 22 +++++ >>>>> drivers/nvmem/core.c | 95 ++++++++++++++++++++-- >>>>> include/linux/nvmem-provider.h | 8 ++ >>>>> 5 files changed, 141 insertions(+), 6 deletions(-) >>>>> --- >>>>> base-commit: d26955e57475434b59d43ba372b2a50d33d5e0ed >>>>> change-id: 20261110-nvmem-byte-mask-for-split-macaddr-a4698a128057 >>>>> >>>>> Best regards, >>>>> -- >>>>> Hongmei Xu >>>>> >>>> >>>> >>