[PATCH] ad7877: keep dma rx buffers in seperate cache lines

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Oskar Schirmer
Date: Thursday, May 6, 2010 - 3:37 am

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: Oskar Schirmer <os@emlix.com>
Signed-off-by: Daniel Glöckner <dg@emlix.com>
Signed-off-by: Oliver Schneidewind <osw@emlix.com>
Signed-off-by: Johannes Weiner <jw@emlix.com>
---
 drivers/input/touchscreen/ad7877.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c
index 92acd85..9719368 100644
--- a/drivers/input/touchscreen/ad7877.c
+++ b/drivers/input/touchscreen/ad7877.c
@@ -153,15 +153,21 @@ enum {
  */
 
 struct ser_req {
+	u16			sample;
+	char			__padalign[L1_CACHE_BYTES - sizeof(u16)];
+
 	u16			reset;
 	u16			ref_on;
 	u16			command;
-	u16			sample;
 	struct spi_message	msg;
 	struct spi_transfer	xfer[6];
 };
 
 struct ad7877 {
+	u16			conversion_data[AD7877_NR_SENSE];
+	char			__padalign[L1_CACHE_BYTES
+					- AD7877_NR_SENSE * sizeof(u16)];
+
 	struct input_dev	*input;
 	char			phys[32];
 
@@ -182,8 +188,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;
 
-- 
1.5.3.7

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] ad7877: fix spi word size to 16 bit, Oskar Schirmer, (Thu May 6, 3:37 am)
[PATCH] ad7877: keep dma rx buffers in seperate cache lines, Oskar Schirmer, (Thu May 6, 3:37 am)
RE: [PATCH] ad7877: fix spi word size to 16 bit, Hennerich, Michael, (Thu May 6, 4:18 am)
Re: [PATCH] ad7877: fix spi word size to 16 bit, Mike Frysinger, (Thu May 6, 11:26 am)
Re: [PATCH] ad7877: fix spi word size to 16 bit, Daniel Glöckner, (Fri May 7, 2:41 am)
Re: [PATCH] ad7877: fix spi word size to 16 bit, Mike Frysinger, (Fri May 7, 11:23 am)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ..., Christoph Lameter, (Tue May 11, 6:57 am)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ..., Christoph Lameter, (Tue May 11, 1:21 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ..., Christoph Lameter, (Tue May 11, 1:46 pm)
Re: [PATCH] ad7877: fix spi word size to 16 bit, Dmitry Torokhov, (Thu May 13, 12:53 am)
Re: [PATCH] ad7877: fix spi word size to 16 bit, Oskar Schirmer, (Sat May 15, 11:15 am)
Re: [PATCH] ad7877: fix spi word size to 16 bit, Mike Frysinger, (Sun May 16, 12:25 pm)
Re: [PATCH] ad7877: fix spi word size to 16 bit, Oskar Schirmer, (Mon May 17, 12:29 am)
RE: [PATCH] ad7877: fix spi word size to 16 bit, Hennerich, Michael, (Mon May 17, 1:14 am)
Re: [PATCH] ad7877: fix spi word size to 16 bit, Oskar Schirmer, (Mon May 17, 1:41 am)
Re: [PATCH] ad7877: fix spi word size to 16 bit, Mike Frysinger, (Mon May 17, 4:49 pm)
RE: [PATCH] ad7877: fix spi word size to 16 bit, H Hartley Sweeten, (Mon May 17, 5:18 pm)
Re: [PATCH] ad7877: fix spi word size to 16 bit, Oskar Schirmer, (Tue May 18, 1:32 am)
[PATCH v2] ad7877: fix spi word size to 16 bit, Oskar Schirmer, (Tue May 18, 1:34 am)
Re: [PATCH] ad7877: fix spi word size to 16 bit, Daniel Glöckner, (Tue May 18, 2:37 am)