linux/drivers/nvmem
Arnd Bergmann e20f378d99 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+ #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: 0331c61194 ("nvmem: core: Expose cells through sysfs")
Link: https://github.com/AsahiLinux/linux/blob/bd0a1a7d4/arch/arm64/boot/dts/apple/t600x-dieX.dtsi#L156
Cc:  <regressions@lists.linux.dev>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Rafał Miłecki <rafal@milecki.pl>
Cc: Chen-Yu Tsai <wenst@chromium.org>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc:  <asahi@lists.linux.dev>
Cc: Sven Peter <sven@svenpeter.dev>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Eric Curtin <ecurtin@redhat.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20240209163454.98051-1-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-02-14 16:28:16 +01:00
..
layouts nvmem: layouts: refactor .add_cells() callback arguments 2024-01-04 17:01:13 +01:00
apple-efuses.c
bcm-ocotp.c
brcm_nvram.c nvmem: brcm_nvram: store a copy of NVRAM content 2023-12-15 13:15:02 +01:00
core.c nvmem: include bit index in cell sysfs file name 2024-02-14 16:28:16 +01:00
imx-iim.c
imx-ocotp-ele.c
imx-ocotp-scu.c
imx-ocotp.c nvmem: Move and rename ->fixup_cell_info() 2023-12-15 13:30:07 +01:00
internals.h nvmem: core: Expose cells through sysfs 2023-12-15 13:30:08 +01:00
jz4780-efuse.c
Kconfig nvmem: core: Rework layouts to become regular devices 2023-12-15 13:30:07 +01:00
lan9662-otpc.c
layerscape-sfp.c
layouts.c nvmem: core: Rework layouts to become regular devices 2023-12-15 13:30:07 +01:00
lpc18xx_eeprom.c
lpc18xx_otp.c
Makefile nvmem: core: Rework layouts to become regular devices 2023-12-15 13:30:07 +01:00
meson-efuse.c
meson-mx-efuse.c
microchip-otpc.c
mtk-efuse.c nvmem: Move and rename ->fixup_cell_info() 2023-12-15 13:30:07 +01:00
mxs-ocotp.c
nintendo-otp.c
qcom-spmi-sdam.c
qfprom.c
qoriq-efuse.c
rave-sp-eeprom.c
rmem.c
rockchip-efuse.c
rockchip-otp.c
sc27xx-efuse.c
sec-qfprom.c
snvs_lpgpr.c
sprd-efuse.c
stm32-bsec-optee-ta.c
stm32-bsec-optee-ta.h
stm32-romem.c nvmem: stm32: add support for STM32MP25 BSEC to control OTP data 2023-12-15 13:30:08 +01:00
sunplus-ocotp.c
sunxi_sid.c
u-boot-env.c nvmem: u-boot-env: improve coding style 2024-01-04 17:01:13 +01:00
uniphier-efuse.c
vf610-ocotp.c
zynqmp_nvmem.c