Skip to content

Commit b588e2d

Browse files
arndbSrinivas-Kandagatla
authored andcommitted
nvmem: include bit index in cell sysfs file name
Creating sysfs files for all Cells caused a boot failure for linux-6.8-rc1 on Apple M1, which (in downstream dts files) has multiple nvmem cells that use the same byte address. This causes the device probe to fail with [ 0.605336] sysfs: cannot create duplicate filename '/devices/platform/soc@200000000/2922bc000.efuse/apple_efuses_nvmem0/cells/efuse@a10' [ 0.605347] CPU: 7 PID: 1 Comm: swapper/0 Tainted: G S 6.8.0-rc1-arnd-5+ torvalds#133 [ 0.605355] Hardware name: Apple Mac Studio (M1 Ultra, 2022) (DT) [ 0.605362] Call trace: [ 0.605365] show_stack+0x18/0x2c [ 0.605374] dump_stack_lvl+0x60/0x80 [ 0.605383] dump_stack+0x18/0x24 [ 0.605388] sysfs_warn_dup+0x64/0x80 [ 0.605395] sysfs_add_bin_file_mode_ns+0xb0/0xd4 [ 0.605402] internal_create_group+0x268/0x404 [ 0.605409] sysfs_create_groups+0x38/0x94 [ 0.605415] devm_device_add_groups+0x50/0x94 [ 0.605572] nvmem_populate_sysfs_cells+0x180/0x1b0 [ 0.605682] nvmem_register+0x38c/0x470 [ 0.605789] devm_nvmem_register+0x1c/0x6c [ 0.605895] apple_efuses_probe+0xe4/0x120 [ 0.606000] platform_probe+0xa8/0xd0 As far as I can tell, this is a problem for any device with multiple cells on different bits of the same address. Avoid the issue by changing the file name to include the first bit number. Fixes: 0331c61 ("nvmem: core: Expose cells through sysfs") Link: https://github.com/AsahiLinux/linux/blob/bd0a1a7d4/arch/arm64/boot/dts/apple/t600x-dieX.dtsi#L156 Cc: [email protected] Cc: Miquel Raynal <[email protected]> Cc: Rafał Miłecki <[email protected]> Cc: Chen-Yu Tsai <[email protected]> Cc: Srinivas Kandagatla <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: [email protected] Cc: Sven Peter <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]>
1 parent 6613476 commit b588e2d

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

Diff for: Documentation/ABI/testing/sysfs-nvmem-cells

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ KernelVersion: 6.5
44
Contact: Miquel Raynal <[email protected]>
55
Description:
66
The "cells" folder contains one file per cell exposed by the
7-
NVMEM device. The name of the file is: <name>@<where>, with
8-
<name> being the cell name and <where> its location in the NVMEM
9-
device, in hexadecimal (without the '0x' prefix, to mimic device
10-
tree node names). The length of the file is the size of the cell
11-
(when known). The content of the file is the binary content of
12-
the cell (may sometimes be ASCII, likely without trailing
13-
character).
7+
NVMEM device. The name of the file is: "<name>@<byte>,<bit>",
8+
with <name> being the cell name and <where> its location in
9+
the NVMEM device, in hexadecimal bytes and bits (without the
10+
'0x' prefix, to mimic device tree node names). The length of
11+
the file is the size of the cell (when known). The content of
12+
the file is the binary content of the cell (may sometimes be
13+
ASCII, likely without trailing character).
1414
Note: This file is only present if CONFIG_NVMEM_SYSFS
1515
is enabled.
1616

1717
Example::
1818

19-
hexdump -C /sys/bus/nvmem/devices/1-00563/cells/product-name@d
19+
hexdump -C /sys/bus/nvmem/devices/1-00563/cells/product-name@d,0
2020
00000000 54 4e 34 38 4d 2d 50 2d 44 4e |TN48M-P-DN|
2121
0000000a

Diff for: drivers/nvmem/core.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,9 @@ static int nvmem_populate_sysfs_cells(struct nvmem_device *nvmem)
460460
list_for_each_entry(entry, &nvmem->cells, node) {
461461
sysfs_bin_attr_init(&attrs[i]);
462462
attrs[i].attr.name = devm_kasprintf(&nvmem->dev, GFP_KERNEL,
463-
"%s@%x", entry->name,
464-
entry->offset);
463+
"%s@%x,%x", entry->name,
464+
entry->offset,
465+
entry->bit_offset);
465466
attrs[i].attr.mode = 0444;
466467
attrs[i].size = entry->bytes;
467468
attrs[i].read = &nvmem_cell_attr_read;

0 commit comments

Comments
 (0)