mirror-linux/drivers
Gabor Juhos 65cb56d49f
spi: spi-qpic-snand: validate user/chip specific ECC properties
The driver only supports 512 bytes ECC step size and 4 bit ECC strength
at the moment, however it does not reject unsupported step/strength
configurations. Due to this, whenever the driver is used with a flash
chip which needs stronger ECC protection, the following warning is shown
in the kernel log:

  [    0.574648] spi-nand spi0.0: GigaDevice SPI NAND was found.
  [    0.635748] spi-nand spi0.0: 256 MiB, block size: 128 KiB, page size: 2048, OOB size: 128
  [    0.649079] nand: WARNING: (null): the ECC used on your system is too weak compared to the one required by the NAND chip

Although the message indicates that something is wrong, but it often gets
unnoticed, which can cause serious problems. For example when the user
writes something into the flash chip despite the warning, the written data
may won't be readable by the bootloader or by the boot ROM. In the worst
case, when the attached SPI NAND chip is the boot device, the board may not
be able to boot anymore.

Also, it is not even possible to create a backup of the flash, because
reading its content results in bogus data. For example, dumping the first
page of the flash gives this:

  # hexdump -C -n 2048 /dev/mtd0
  00000000  0f 0f 0f 0f 0f 0f 0f 0f  0f 0f 0f 0f 0f 0f 0f 0f  |................|
  *
  00000040  0f 0f 0f 0f 0f 0f 0f 0d  0f 0f 0f 0f 0f 0f 0f 0f  |................|
  00000050  0f 0f 0f 0f 0f 0f 0f 0f  0f 0f 0f 0f 0f 0f 0f 0f  |................|
  *
  000001c0  0f 0f 0f 0f ff 0f 0f 0f  0f 0f 0f 0f 0f 0f 0f 0f  |................|
  000001d0  0f 0f 0f 0f 0f 0f 0f 0f  0f 0f 0f 0f 0f 0f 0f 0f  |................|
  *
  00000200  0f 0f 0f 0f f5 5b ff ff  0f 0f 0f 0f 0f 0f 0f 0f  |.....[..........|
  00000210  0f 0f 0f 0f 0f 0f 0f 0f  0f 0f 0f 0f 0f 0f 0f 0f  |................|
  *
  000002f0  0f 0f 0f 0f 0f 0f 0f 0f  0f 0f 0f 0f 0f 1f 0f 0f  |................|
  00000300  0f 0f 0f 0f 0f 0f 0f 0f  0f 0f 0f 0f 0f 0f 0f 0f  |................|
  *
  000003c0  0f 0f 0f 0f 0f 0f 0f 0f  0f 0f 0f 0f ff 0f 0f 0f  |................|
  000003d0  0f 0f 0f 0f 0f 0f 0f 0f  0f 0f 0f 0f 0f 0f 0f 0f  |................|
  *
  00000400  0f 0f 0f 0f 0f 0f 0f 0f  e9 74 c9 06 f5 5b ff ff  |.........t...[..|
  00000410  0f 0f 0f 0f 0f 0f 0f 0f  0f 0f 0f 0f 0f 0f 0f 0f  |................|
  *
  000005d0  0f 0f 0f 0f ff 0f 0f 0f  0f 0f 0f 0f 0f 0f 0f 0f  |................|
  000005e0  0f 0f 0f 0f 0f 0f 0f 0f  0f 0f 0f 0f 0f 0f 0f 0f  |................|
  *
  00000600  0f 0f 0f 0f 0f 0f 0f 0f  0f 0f 0f 0f c6 be 0f c3  |................|
  00000610  e9 74 c9 06 f5 5b ff ff  0f 0f 0f 0f 0f 0f 0f 0f  |.t...[..........|
  00000620  0f 0f 0f 0f 0f 0f 0f 0f  0f 0f 0f 0f 0f 0f 0f 0f  |................|
  *
  00000770  0f 0f 0f 0f 8f 0f 0f 0f  0f 0f 0f 0f 0f 0f 0f 0f  |................|
  00000780  0f 0f 0f 0f 0f 0f 0f 0f  0f 0f 0f 0f 0f 0f 0f 0f  |................|
  *
  00000800
  #

Doing the same by using the downstream kernel results in different output:

  # hexdump -C -n 2048 /dev/mtd0
  00000000  0f 0f 0f 0f 0f 0f 0f 0f  0f 0f 0f 0f 0f 0f 0f 0f  |................|
  *
  00000800
  #

This patch adds some sanity checks to the code to prevent using the driver
with unsupported ECC step/strength configurations. After the change, probing
of the driver fails in such cases:

  [    0.655038] spi-nand spi0.0: GigaDevice SPI NAND was found.
  [    0.659159] spi-nand spi0.0: 256 MiB, block size: 128 KiB, page size: 2048, OOB size: 128
  [    0.669138] qcom_snand 79b0000.spi: only 4 bits ECC strength is supported
  [    0.677476] nand: No suitable ECC configuration
  [    0.689909] spi-nand spi0.0: probe with driver spi-nand failed with error -95

This helps to avoid the aforementioned hassles until support for 8 bit ECC
strength gets implemented.

Fixes: 7304d19090 ("spi: spi-qpic: add driver for QCOM SPI NAND flash Interface")
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
Link: https://patch.msgid.link/20250501-qpic-snand-validate-ecc-v1-1-532776581a66@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2025-05-14 10:56:48 +02:00
..
accel accel/ivpu: Fix the D0i2 disable test mode 2025-04-25 10:29:43 +02:00
accessibility treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
acpi gcc-15: disable '-Wunterminated-string-initialization' entirely for now 2025-04-20 15:30:53 -07:00
amba
android binder: fix offset calculation in debug log 2025-04-15 15:11:12 +02:00
ata ata: libata-scsi: Improve CDL control 2025-04-22 16:06:05 +09:00
atm treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
auxdisplay treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
base Add more devm_ functions to fix PM imbalance in 2025-05-12 11:28:54 +09:00
bcma
block block-6.15-20250502 2025-05-02 10:24:37 -07:00
bluetooth Bluetooth: btintel_pcie: Add additional to checks to clear TX/RX paths 2025-04-25 15:03:19 -04:00
bus treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
cache
cdrom
cdx Merge branches 'apple/dart', 'arm/smmu/updates', 'arm/smmu/bindings', 'rockchip', 's390', 'core', 'intel/vt-d' and 'amd/amd-vi' into next 2025-03-20 09:11:09 +01:00
char Char/Misc driver fixes for 6.15-rc4 2025-04-25 10:30:40 -07:00
clk ARM and clkdev updates for 6.15-rc1 2025-04-03 12:21:44 -07:00
clocksource RISC-V Patches for the 6.15 Merge Window, Part 1 2025-04-04 09:49:17 -07:00
comedi comedi: jr3_pci: Fix synchronous deletion of timer 2025-04-15 15:18:55 +02:00
connector
counter Char/Misc fixes for 6.15-rc1 2025-04-02 18:03:34 -07:00
cpufreq cpufreq: intel_pstate: Unchecked MSR aceess in legacy mode 2025-04-30 16:27:34 +02:00
cpuidle pmdomain core: 2025-03-25 20:40:51 -07:00
crypto crypto: atmel-sha204a - Set hwrng quality to lowest possible 2025-04-23 09:32:57 +08:00
cxl cxl/core/regs.c: Skip Memory Space Enable check for RCD and RCH Ports 2025-04-21 08:30:13 -07:00
dax device/dax: properly refcount device dax pages when mapping 2025-03-17 22:06:41 -07:00
dca
devfreq
dio
dma treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
dma-buf dma-buf/sw_sync: Decrement refcount on error in sw_sync_ioctl_get_deadline() 2025-04-11 14:22:22 +02:00
dpll Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2025-03-20 21:38:01 +01:00
edac EDAC/altera: Set DDR and SDMMC interrupt mask before registration 2025-04-28 12:38:53 +02:00
eisa
extcon
firewire treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
firmware ASoC: stm32: sai: fix kernel rate configuration 2025-05-01 14:43:44 +09:00
fpga fpga: tests: add module descriptions 2025-04-11 17:32:38 -07:00
fsi
fwctl fwctl: Fix repeated device word in log message 2025-04-11 20:47:45 -03:00
gnss
gpio gpiolib: Allow to use setters with return value for output-only gpios 2025-04-14 20:31:00 +02:00
gpu Driver Changes: 2025-05-02 14:12:52 +10:00
greybus treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
hid treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
hsi treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
hte treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
hv Drivers: hv: Fix bad ref to hv_synic_eventring_tail when CPU goes offline 2025-04-25 21:13:53 +00:00
hwmon treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
hwspinlock hwspinlock: Remove unused hwspin_lock_get_id() 2025-03-21 17:12:04 -05:00
hwtracing intel_th: avoid using deprecated page->mapping, index fields 2025-04-15 13:29:03 +02:00
i2c i2c: imx-lpi2c: Fix clock count when probe defers 2025-04-29 10:18:51 +02:00
i3c i3c: Add NULL pointer check in i3c_master_queue_ibi() 2025-03-31 11:44:00 +02:00
idle Power management updates for 6.15-rc1 2025-03-25 15:00:18 -07:00
iio gcc-15: add '__nonstring' markers to byte arrays 2025-04-20 11:57:54 -07:00
infiniband RDMA/bnxt_re: Remove unusable nq variable 2025-04-10 14:47:55 -03:00
input gcc-15: add '__nonstring' markers to byte arrays 2025-04-20 11:57:54 -07:00
interconnect
iommu IOMMU Fixes for Linux v6.15-rc4: 2025-05-02 08:57:00 -07:00
ipack
irqchip irqchip/qcom-mpm: Prevent crash when trying to handle non-wake GPIOs 2025-05-02 21:07:02 +02:00
isdn treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
leds treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
macintosh treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
mailbox treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
mcb mcb: fix a double free bug in chameleon_parse_gdd() 2025-04-15 18:21:39 +02:00
md - dm: always update the array size in realloc_argv on success 2025-04-28 12:18:21 -07:00
media treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
memory memory: renesas-rpc-if: Add missing static keyword 2025-05-08 10:59:07 +02:00
memstick treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
message SCSI misc on 20250326 2025-03-26 19:57:34 -07:00
mfd * Maxim MAX77705: 2025-03-29 14:33:13 -07:00
misc pci-v6.15-fixes-3 2025-04-26 13:02:36 -07:00
mmc mmc: renesas_sdhi: disable clocks if registering regulator failed 2025-04-07 17:58:41 +02:00
most treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
mtd mtd: rawnand: Add status chack in r852_ready() 2025-04-07 09:02:49 +02:00
mux
net net: vertexcom: mse102x: Fix RX error handling 2025-05-01 07:24:05 -07:00
nfc treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
ntb Bug fixes for NTB Switchtec driver mw negative shift, Intel NTB link 2025-04-04 14:23:07 -07:00
nubus
nvdimm libnvdimm additions for 6.15 2025-04-02 20:27:18 -07:00
nvme block-6.15-20250502 2025-05-02 10:24:37 -07:00
nvmem nvmem: qfprom: switch to 4-byte aligned reads 2025-04-11 14:41:22 +02:00
of Devicetree for v6.15: 2025-03-29 11:23:16 -07:00
opp
parisc
parport treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
pci pci-v6.15-fixes-3 2025-04-26 13:02:36 -07:00
pcmcia treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
peci
perf pci-v6.15-changes 2025-03-28 19:36:53 -07:00
phy phy-for-6.15 2025-04-01 12:47:11 -07:00
pinctrl pinctrl: qcom: Fix PINGROUP definition for sm8750 2025-04-29 10:27:25 +02:00
platform platform/x86: ideapad-laptop: add support for some new buttons 2025-04-23 13:05:26 +03:00
pmdomain pmdomain: arm: scmi_pm_domain: Remove redundant state verification 2025-03-17 11:12:01 +01:00
pnp Staging driver updates for 6.15-rc1 2025-04-02 18:09:17 -07:00
power gcc-15: get rid of misc extra NUL character padding 2025-04-20 11:57:54 -07:00
powercap Power management updates for 6.15-rc1 2025-03-25 15:00:18 -07:00
pps pps: generators: tio: fix platform_set_drvdata() 2025-04-15 18:22:32 +02:00
ps3
ptp ptp: ocp: Fix NULL dereference in Adva board SMA sysfs operations 2025-05-01 07:01:31 -07:00
pwm pwm: A set of fixes for pwm core and various drivers 2025-04-12 08:11:19 -07:00
rapidio
ras RAS/AMD/FMPM: Get masked address 2025-04-08 19:30:58 +02:00
regulator These are objtool fixes and updates by Josh Poimboeuf, centered 2025-04-02 10:30:10 -07:00
remoteproc remoteproc: qcom_q6v5_pas: Make single-PD handling more robust 2025-03-22 08:42:39 -05:00
reset remoteproc updates for v6.15 2025-03-29 17:18:50 -07:00
rpmsg
rtc treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
s390 s390/virtio_ccw: Don't allocate/assign airqs for non-existing queues 2025-04-09 12:12:41 +02:00
sbus
scsi SCSI fixes on 20250502 2025-05-02 11:14:58 -07:00
sh
siox
slimbus
soc soc: drivers for 6.15, part 2 2025-04-04 09:06:32 -07:00
soundwire soundwire: intel_auxdevice: Fix system suspend/resume handling 2025-04-30 16:23:37 +02:00
spi spi: spi-qpic-snand: validate user/chip specific ECC properties 2025-05-14 10:56:48 +02:00
spmi
ssb
staging treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
target scsi: target: iscsi: Fix timeout on deleted connection 2025-04-11 22:13:00 -04:00
tc
tee
thermal thermal: intel: int340x: Fix Panther Lake DLVR support 2025-04-15 18:57:25 +02:00
thunderbolt USB/Thunderbolt update for 6.15-rc1 2025-04-02 18:23:31 -07:00
tty serial: sifive: lock port in startup()/shutdown() callbacks 2025-04-15 15:02:39 +02:00
ufs scsi: ufs: core: Remove redundant query_complete trace 2025-04-28 21:23:29 -04:00
uio
usb USB-serial device ids for 6.15-rc3 2025-04-18 06:49:40 +02:00
vdpa
vfio vfio/pci: Virtualize zero INTx PIN if no pdev->irq 2025-04-14 08:31:45 -06:00
vhost vhost-scsi: Fix vhost_scsi_send_status() 2025-04-18 10:08:11 -04:00
video treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
virt treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
virtio virtgpu: don't reset on shutdown 2025-04-18 10:05:49 -04:00
w1
watchdog treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
xen x86/xen: fix balloon target initialization for PVH dom0 2025-04-07 11:24:12 +02:00
zorro
Kconfig
Makefile