Alexander Stein wrote on 2011-05-04: > Hello, > > I just encountered a problem on my ARMv5 (AT91SAM9263 based) board > while using > ads7843 or ads7846 (I replaced it). I tried reading > /sys/class/hwmon/hwmon0/device/in0_input and got 0 most of the time. > Sometimes the correct voltage was shown. > After digging a bit in the code I found out that sample (and command > for Tx) from the following struct gets DMA mapped by the underlying > atmel_spi driver for SPI Rx-Buffer. > > struct ser_req { > u8 ref_on; > u8 command; > u8 ref_off; > u16 scratch; > __be16 sample; > struct spi_message msg; > struct spi_transfer xfer[6]; > }; > > The atmel_spi driver does proper dma_{,un}map_signgle on the Rx and Tx > buffers. Now when the cache line for scratch is cleared and > invalidated and the spi subsystem access msg (and maybe xfer) the > cache line gets filled again, rendering the cache clear and > invalidation before as useless. > As the ARMv5 core has 32Byte cache lines I added "char dummy[25];" > after sample, so the spi structs are in a different cache line. > But this seem only to be a workaround as the cache lines might differ > across each CPU. > Somebody an idea how to fix this in general? Take a look at the AD7877 Touchscreen driver. To work around the same issue we use ____cacheline_aligned /* * DMA (thus cache coherency maintenance) requires the * transfer buffers to live in their own cache lines. */ u16 conversion_data[AD7877_NR_SENSE] ____cacheline_aligned; Alternatively you can kmalloc the transfer buffers. Greetings, Michael -- Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368; Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Margaret Seif -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html