Commit bfa4133
mtd: spi-nor: fix DMA unsafe buffer issue in spi_nor_read_sfdp()
spi_nor_read_sfdp() calls nor->read() to read the SFDP data.
When the m25p80 driver is used (pretty common case), nor->read() is then
implemented by the m25p80_read() function, which is likely to initialize a
'struct spi_transfer' from its buf argument before appending this
structure inside the 'struct spi_message' argument of spi_sync().
Besides the SPI sub-system states that both .tx_buf and .rx_buf members of
'struct spi_transfer' must point into dma-safe memory. However, two of the
three calls of spi_nor_read_sfdp() were given pointers to stack allocated
memory as buf argument, hence not in a dma-safe area.
Hopefully, the third and last call of spi_nor_read_sfdp() was already
given a kmalloc'ed buffer argument, hence dma-safe.
So this patch fixes this issue by introducing a
spi_nor_read_sfdp_dma_unsafe() function which simply wraps the existing
spi_nor_read_sfdp() function and uses some kmalloc'ed memory as a bounce
buffer.
Fixes: f384b35 ("mtd: spi-nor: parse Serial Flash Discoverable Parameters (SFDP) tables")
Reported-by: Geert Uytterhoeven <[email protected]>
Signed-off-by: Cyrille Pitchen <[email protected]>
Signed-off-by: Boris Brezillon <[email protected]>1 parent b8f3911 commit bfa4133
1 file changed
+33
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1784 | 1784 | | |
1785 | 1785 | | |
1786 | 1786 | | |
1787 | | - | |
| 1787 | + | |
1788 | 1788 | | |
1789 | 1789 | | |
1790 | 1790 | | |
| |||
1829 | 1829 | | |
1830 | 1830 | | |
1831 | 1831 | | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
1832 | 1862 | | |
1833 | 1863 | | |
1834 | 1864 | | |
| |||
2101 | 2131 | | |
2102 | 2132 | | |
2103 | 2133 | | |
2104 | | - | |
| 2134 | + | |
2105 | 2135 | | |
2106 | 2136 | | |
2107 | 2137 | | |
| |||
2252 | 2282 | | |
2253 | 2283 | | |
2254 | 2284 | | |
2255 | | - | |
| 2285 | + | |
2256 | 2286 | | |
2257 | 2287 | | |
2258 | 2288 | | |
| |||
0 commit comments