Re: [PATCH] Fix OMAP McSPI DMA corruption

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Monday 11 February 2008, Klaus Pedersen wrote:
> Because the dma_map_single() on ARM only flushes and invalidates 
> the cache-lines occupied by the transfer buffer, care should be
> taken not to touch memory that share the same cache-lines before
> starting the DMA transfer.
> 
> In the McSPI driver dma_map_single() was called before the driver
> was finished touching the spi_message and spi_transfer structures,
> causing potential corruption of the transfer buffer.
> 
> With a layout like this:
> 
> 	struct spi_message	read_msg;
> 	u16                     data[4];

Which is actually the source of the bug -- not omap2_mcspi.


I probably wrote code like that at one point, since some of
the earliest SPI framework code was done with omap1_uwire
(a non-DMA driver, although ISTR the TX side could use DMA)
where such idioms would not cause problems.

In fact, I know for a fact that the ads7846 driver has that
same bug.  (Along with various others, which I'd like to see
fixed first.  Someone sent me a completely unreviewable and
unmergeable patch that claims to fix "a bunch of stuff" in
that driver.  If anyone would like to help sort out the mess,
let me know -- a lot of the problems seem to have come from
that debounce logic added on Nokia's behalf.)

I think that the tsc2046 + omap2_mcspi combination (on
the omap2430 SDP?) won't hit that problem since none of
its data buffers are large enough to kick in DMA.


> - my (touchscreen) driver would get

Best to fix your (touchscreen) driver ...


> [    5.875000]     0     0  1002  3334
> [    6.695312]     0     0  1363  3234
> 
> after playing with the layout so that data[] starts on
> a new cache-line I would get:
> 
> [    5.890625]  1507   788  1278  2720
> [    5.890625]  1507   819  1242  2779
> 
> This patch solves the problem by moving the dma_map_single()
> calls to just before the DMA is started.

Best to just fix your driver.  Have a separate data buffer.

- Dave

-
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux