Commit 3843384a authored by Oskar Schirmer's avatar Oskar Schirmer Committed by Dmitry Torokhov

Input: ad7877 - keep dma rx buffers in seperate cache lines

With dma based spi transmission, data corruption is observed
occasionally. With dma buffers located right next to msg and
xfer fields, cache lines correctly flushed in preparation for
dma usage may be polluted again when writing to fields in the
same cache line.

Make sure cache fields used with dma do not share cache lines
with fields changed during dma handling. As both fields are part
of a struct that is allocated via kzalloc, thus cache aligned,
moving the fields to the 1st position and insert padding for
alignment does the job.
Signed-off-by: default avatarOskar Schirmer <os@emlix.com>
Signed-off-by: default avatarDaniel Glöckner <dg@emlix.com>
Signed-off-by: default avatarOliver Schneidewind <osw@emlix.com>
Signed-off-by: default avatarJohannes Weiner <jw@emlix.com>
Acked-by: default avatarMike Frysinger <vapier@gentoo.org>
[dtor@mail.ru - changed to use ___cacheline_aligned as suggested
 by akpm]
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent ef110b24
......@@ -156,9 +156,14 @@ struct ser_req {
u16 reset;
u16 ref_on;
u16 command;
u16 sample;
struct spi_message msg;
struct spi_transfer xfer[6];
/*
* DMA (thus cache coherency maintenance) requires the
* transfer buffers to live in their own cache lines.
*/
u16 sample ____cacheline_aligned;
};
struct ad7877 {
......@@ -182,8 +187,6 @@ struct ad7877 {
u8 averaging;
u8 pen_down_acc_interval;
u16 conversion_data[AD7877_NR_SENSE];
struct spi_transfer xfer[AD7877_NR_SENSE + 2];
struct spi_message msg;
......@@ -195,6 +198,12 @@ struct ad7877 {
spinlock_t lock;
struct timer_list timer; /* P: lock */
unsigned pending:1; /* P: lock */
/*
* DMA (thus cache coherency maintenance) requires the
* transfer buffers to live in their own cache lines.
*/
u16 conversion_data[AD7877_NR_SENSE] ____cacheline_aligned;
};
static int gpio3;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment