linux-stable/drivers/misc
Christophe Leroy 5b47b751b7 eeprom: at25: Use DMA safe buffers
Reading EEPROM fails with following warning:

[   16.357496] ------------[ cut here ]------------
[   16.357529] fsl_spi b01004c0.spi: rejecting DMA map of vmalloc memory
[   16.357698] WARNING: CPU: 0 PID: 371 at include/linux/dma-mapping.h:326 fsl_spi_cpm_bufs+0x2a0/0x2d8
[   16.357775] CPU: 0 PID: 371 Comm: od Not tainted 5.16.11-s3k-dev-01743-g19beecbfe9d6-dirty #109
[   16.357806] NIP:  c03fbc9c LR: c03fbc9c CTR: 00000000
[   16.357825] REGS: e68d9b20 TRAP: 0700   Not tainted  (5.16.11-s3k-dev-01743-g19beecbfe9d6-dirty)
[   16.357849] MSR:  00029032 <EE,ME,IR,DR,RI>  CR: 24002282  XER: 00000000
[   16.357931]
[   16.357931] GPR00: c03fbc9c e68d9be0 c26d06a0 00000039 00000001 c0d36364 c0e96428 00000027
[   16.357931] GPR08: 00000001 00000000 00000023 3fffc000 24002282 100d3dd6 100a2ffc 00000000
[   16.357931] GPR16: 100cd280 100b0000 00000000 aff54f7e 100d0000 100d0000 00000001 100cf328
[   16.357931] GPR24: 100cf328 00000000 00000003 e68d9e30 c156b410 e67ab4c0 e68d9d38 c24ab278
[   16.358253] NIP [c03fbc9c] fsl_spi_cpm_bufs+0x2a0/0x2d8
[   16.358292] LR [c03fbc9c] fsl_spi_cpm_bufs+0x2a0/0x2d8
[   16.358325] Call Trace:
[   16.358336] [e68d9be0] [c03fbc9c] fsl_spi_cpm_bufs+0x2a0/0x2d8 (unreliable)
[   16.358388] [e68d9c00] [c03fcb44] fsl_spi_bufs.isra.0+0x94/0x1a0
[   16.358436] [e68d9c20] [c03fd970] fsl_spi_do_one_msg+0x254/0x3dc
[   16.358483] [e68d9cb0] [c03f7e50] __spi_pump_messages+0x274/0x8a4
[   16.358529] [e68d9ce0] [c03f9d30] __spi_sync+0x344/0x378
[   16.358573] [e68d9d20] [c03fb52c] spi_sync+0x34/0x60
[   16.358616] [e68d9d30] [c03b4dec] at25_ee_read+0x138/0x1a8
[   16.358667] [e68d9e50] [c04a8fb8] bin_attr_nvmem_read+0x98/0x110
[   16.358725] [e68d9e60] [c0204b14] kernfs_fop_read_iter+0xc0/0x1fc
[   16.358774] [e68d9e80] [c0168660] vfs_read+0x284/0x410
[   16.358821] [e68d9f00] [c016925c] ksys_read+0x6c/0x11c
[   16.358863] [e68d9f30] [c00160e0] ret_from_syscall+0x0/0x28
...
[   16.359608] ---[ end trace a4ce3e34afef0cb5 ]---
[   16.359638] fsl_spi b01004c0.spi: unable to map tx dma

This is due to the AT25 driver using buffers on stack, which is not
possible with CONFIG_VMAP_STACK.

As mentionned in kernel Documentation (Documentation/spi/spi-summary.rst):

  - Follow standard kernel rules, and provide DMA-safe buffers in
    your messages.  That way controller drivers using DMA aren't forced
    to make extra copies unless the hardware requires it (e.g. working
    around hardware errata that force the use of bounce buffering).

Modify the driver to use a buffer located in the at25 device structure
which is allocated via kmalloc during probe.

Protect writes in this new buffer with the driver's mutex.

Fixes: b587b13a4f ("[PATCH] SPI eeprom driver")
Cc: stable <stable@kernel.org>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/230a9486fc68ea0182df46255e42a51099403642.1648032613.git.christophe.leroy@csgroup.eu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-04-24 17:25:10 +02:00
..
altera-stapl
bcm-vk Char/Misc and other driver updates for 5.18-rc1 2022-03-28 12:27:35 -07:00
c2port
cardreader misc: rtsx: clean up one inconsistent indenting 2022-03-18 13:52:30 +01:00
cb710 cb710: avoid NULL pointer subtraction 2021-10-05 15:50:05 +02:00
cxl Char/Misc and other driver changes for 5.17-rc1 2022-01-14 16:02:28 +01:00
echo
eeprom eeprom: at25: Use DMA safe buffers 2022-04-24 17:25:10 +02:00
genwqe Merge 5.15-rc3 into char-misc next 2021-09-27 15:39:40 +02:00
habanalabs habanalabs: Fix test build failures 2022-04-04 17:03:04 +02:00
ibmasm Char / Misc driver updates for 5.14-rc1 2021-07-05 13:42:16 -07:00
lis3lv02d spi: make remove callback a void function 2022-02-09 13:00:45 +00:00
lkdtm Char/Misc and other driver updates for 5.18-rc1 2022-03-28 12:27:35 -07:00
mei mei: avoid iterator usage outside of list_for_each_entry 2022-03-18 13:48:30 +01:00
ocxl ocxl: Make use of the helper macro LIST_HEAD() 2022-02-25 12:09:56 +01:00
pvpanic pvpanic: Indentation fixes here and there 2021-09-14 11:07:13 +02:00
sgi-gru misc: sgi-gru: Fix spelling mistake "unexpect" -> "unexpected" 2022-03-18 14:02:15 +01:00
sgi-xp net: sgi-xp: Use netif_rx(). 2022-03-04 12:02:19 +00:00
ti-st
uacce uacce: use sysfs_emit instead of sprintf 2021-12-21 10:13:34 +01:00
vmw_vmci VMCI: Release notification_bitmap in error path 2022-03-18 13:47:48 +01:00
ad525x_dpot-i2c.c misc: ad525x_dpot: Make ad_dpot_remove() return void 2021-10-13 14:35:37 +02:00
ad525x_dpot-spi.c spi: make remove callback a void function 2022-02-09 13:00:45 +00:00
ad525x_dpot.c misc: ad525x_dpot: Make ad_dpot_remove() return void 2021-10-13 14:35:37 +02:00
ad525x_dpot.h misc: ad525x_dpot: Make ad_dpot_remove() return void 2021-10-13 14:35:37 +02:00
apds990x.c
apds9802als.c
atmel-ssc.c
bh1770glc.c
cs5535-mfgpt.c
ds1682.c
dummy-irq.c
dw-xdata-pcie.c
enclosure.c misc: enclosure: replace snprintf in show functions with sysfs_emit 2021-10-22 11:25:39 +02:00
fastrpc.c Char/Misc and other driver updates for 5.18-rc1 2022-03-28 12:27:35 -07:00
gehc-achc.c misc: gehc: Add SPI ID table 2021-10-05 15:47:18 +02:00
hi6421v600-irq.c misc: hi6421-spmi-pmic: Use generic_handle_irq_safe(). 2022-03-02 22:28:50 +01:00
hisi_hikey_usb.c misc: hisi_hikey_usb: change the DT schema 2021-09-14 10:57:31 +02:00
hmc6352.c
hpilo.c
hpilo.h
ibmvmc.c
ibmvmc.h
ics932s401.c
isl29003.c
isl29020.c
Kconfig misc: fastrpc: Add support to secure memory map 2022-03-18 14:11:00 +01:00
kgdbts.c kgdbts: fix return value of __setup handler 2022-03-18 14:17:56 +01:00
lattice-ecp3-config.c spi: make remove callback a void function 2022-02-09 13:00:45 +00:00
Makefile misc: open-dice: Add driver to expose DICE data to userspace 2022-02-04 16:45:39 +01:00
open-dice.c misc: open-dice: Add driver to expose DICE data to userspace 2022-02-04 16:45:39 +01:00
pch_phub.c
pci_endpoint_test.c misc: pci_endpoint_test: Terminate statement with semicolon 2022-01-11 10:19:59 -06:00
phantom.c
qcom-coincell.c
sram-exec.c
sram.c misc: sram: Add compatible string for Tegra234 SYSRAM 2021-12-08 15:16:05 +01:00
sram.h misc: sram: Only map reserved areas in Tegra SYSRAM 2021-08-05 14:27:46 +02:00
tifm_7xx1.c tifm: Remove usage of the deprecated "pci-dma-compat.h" API 2021-09-21 17:33:31 +02:00
tifm_core.c tifm: Remove usage of the deprecated "pci-dma-compat.h" API 2021-09-21 17:33:31 +02:00
tsl2550.c
vmw_balloon.c
xilinx_sdfec.c