login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2010
»
May
»
11
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cache lines
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Dmitry Torokhov
Subject:
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cache lines
Date: Monday, May 10, 2010 - 11:21 pm
On Tue, May 11, 2010 at 02:11:41AM -0400, Mike Frysinger wrote:
quoted text
> On Tue, May 11, 2010 at 02:05, Dmitry Torokhov wrote: > > On Mon, May 10, 2010 at 02:22:25PM -0700, Andrew Morton wrote: > >> On Mon, 10 May 2010 12:42:34 +0200 Oskar Schirmer wrote: > >> > 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. > >> > >> This sounds odd. Doesn't it imply that some code somewhere is missing > >> some DMA synchronisation actions? > >> > >> > > >> > v2: add a comment to explain why alignment is needed > >> > > >> > v3: fix the typo in comment and layout (- to end of line) > >> > > >> > diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c > >> > index 885354c..9ebb1b4 100644 > >> > --- a/drivers/input/touchscreen/ad7877.c > >> > +++ b/drivers/input/touchscreen/ad7877.c > >> > @@ -153,15 +153,29 @@ enum { > >> > */ > >> > > >> > struct ser_req { > >> > + u16 sample; > >> > + /* > >> > + * DMA (thus cache coherency maintenance) requires the > >> > + * transfer buffers to live in their own cache lines. > >> > + */ > >> > + char __padalign[L1_CACHE_BYTES - sizeof(u16)]; > >> > >> It would be better to use __cacheline_aligned, rather than open-coding > >> things in this manner. > >> > > > > OK, then I have the following which I will apply unless someone shouts. > > > > -- > > Dmitry > > > > Input: ad7877 - keep dma rx buffers in seperate cache lines > > > > From: Oskar Schirmer <os@emlix.com> > > > > 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> > > Acked-by: Mike Frysinger <vapier@gentoo.org> > > [dtor@mail.ru - changed to use ___cacheline_aligned at suggestion > > of akpm] > > Signed-off-by: Dmitry Torokhov <dtor@mail.ru> > > --- > > > > drivers/input/touchscreen/ad7877.c | 15 ++++++++++++--- > > 1 files changed, 12 insertions(+), 3 deletions(-) > > > > > > diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c > > index e019d53..0d2d7e5 100644 > > --- a/drivers/input/touchscreen/ad7877.c > > +++ b/drivers/input/touchscreen/ad7877.c > > @@ -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; > > }; > > i'm not sure this is correct. the cached_aligned attribute makes sure > it starts on a cache boundary, but it doesnt make sure it pads out to > one. so it might work more of the time, but i dont think it's > guaranteed.
The buffers are moved to the end of the structure - there is nothing else there. -- Dmitry --
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
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: keep dma rx buffers in seperate cache ...
, Mike Frysinger
, (Thu May 6, 11:46 am)
Re: [PATCH] ad7877: fix spi word size to 16 bit
, Daniel Glöckner
, (Fri May 7, 2:41 am)
Re: [PATCH] ad7877: keep dma rx buffers in seperate cache ...
, Oskar Schirmer
, (Fri May 7, 3:15 am)
Re: [PATCH] ad7877: keep dma rx buffers in seperate cache ...
, Johannes Weiner
, (Fri May 7, 5:07 am)
Re: [PATCH] ad7877: fix spi word size to 16 bit
, Mike Frysinger
, (Fri May 7, 11:23 am)
Re: [PATCH] ad7877: keep dma rx buffers in seperate cache ...
, Mike Frysinger
, (Fri May 7, 11:28 am)
Re: [PATCH] ad7877: keep dma rx buffers in seperate cache ...
, Johannes Weiner
, (Sat May 8, 3:32 pm)
Re: [PATCH] ad7877: keep dma rx buffers in seperate cache ...
, Mike Frysinger
, (Sat May 8, 9:45 pm)
Re: [PATCH] ad7877: keep dma rx buffers in seperate cache ...
, Oskar Schirmer
, (Sun May 9, 1:50 am)
[PATCH v2] ad7877: keep dma rx buffers in seperate cache lines
, Oskar Schirmer
, (Mon May 10, 3:34 am)
[PATCH v3] ad7877: keep dma rx buffers in seperate cache lines
, Oskar Schirmer
, (Mon May 10, 3:42 am)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Mike Frysinger
, (Mon May 10, 9:39 am)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Dmitry Torokhov
, (Mon May 10, 1:54 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Andrew Morton
, (Mon May 10, 2:22 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Mike Frysinger
, (Mon May 10, 2:27 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Andrew Morton
, (Mon May 10, 8:20 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Dmitry Torokhov
, (Mon May 10, 11:05 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Mike Frysinger
, (Mon May 10, 11:11 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Dmitry Torokhov
, (Mon May 10, 11:21 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Mike Frysinger
, (Mon May 10, 11:23 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Dmitry Torokhov
, (Mon May 10, 11:33 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Mike Frysinger
, (Mon May 10, 11:37 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Pekka Enberg
, (Mon May 10, 11:42 pm)
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 ...
, Oskar Schirmer
, (Tue May 11, 7:12 am)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Dmitry Torokhov
, (Tue May 11, 9:52 am)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Mike Frysinger
, (Tue May 11, 10:31 am)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Pekka Enberg
, (Tue May 11, 11:59 am)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Mike Frysinger
, (Tue May 11, 1:03 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Matt Mackall
, (Tue May 11, 1:07 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Mike Frysinger
, (Tue May 11, 1:10 pm)
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 ...
, Pekka Enberg
, (Tue May 11, 1:22 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Mike Frysinger
, (Tue May 11, 1:34 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Pekka Enberg
, (Tue May 11, 1:38 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Mike Frysinger
, (Tue May 11, 1:43 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Christoph Lameter
, (Tue May 11, 1:46 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Pekka Enberg
, (Tue May 11, 1:47 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Mike Frysinger
, (Tue May 11, 1:54 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Pekka Enberg
, (Tue May 11, 2:01 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Mike Frysinger
, (Tue May 11, 2:11 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Dmitry Torokhov
, (Tue May 11, 2:53 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Alan Cox
, (Tue May 11, 3:37 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Mike Frysinger
, (Tue May 11, 3:39 pm)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, FUJITA Tomonori
, (Tue May 11, 6:58 pm)
RE: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, Marc Gauthier
, (Tue May 11, 7:07 pm)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, Nick Piggin
, (Tue May 11, 8:03 pm)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, FUJITA Tomonori
, (Tue May 11, 8:23 pm)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, Mike Frysinger
, (Tue May 11, 9:35 pm)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, FUJITA Tomonori
, (Tue May 11, 10:28 pm)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, Johannes Weiner
, (Wed May 12, 3:36 am)
RE: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, Marc Gauthier
, (Wed May 12, 5:35 am)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, Mike Frysinger
, (Wed May 12, 7:36 am)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, Mike Frysinger
, (Wed May 12, 7:37 am)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, Dmitry Torokhov
, (Wed May 12, 11:11 am)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, Mike Frysinger
, (Wed May 12, 11:28 am)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, Paul Mundt
, (Wed May 12, 11:21 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 v3] ad7877: keep dma rx buffers in seperate cac ...
, Michal Simek
, (Sun May 16, 11:12 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)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, David Woodhouse
, (Wed May 19, 5:48 am)
Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cac ...
, David Woodhouse
, (Wed May 19, 6:00 am)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, Nick Piggin
, (Wed May 19, 6:07 am)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, David Woodhouse
, (Wed May 19, 6:17 am)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, Nick Piggin
, (Wed May 19, 6:36 am)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, Johannes Weiner
, (Wed May 19, 6:44 am)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, Nick Piggin
, (Wed May 19, 6:52 am)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, FUJITA Tomonori
, (Wed May 19, 7:38 am)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, David Woodhouse
, (Wed May 19, 7:58 am)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, Johannes Weiner
, (Wed May 19, 8:00 am)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, Dmitry Torokhov
, (Wed May 19, 9:37 am)
Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in s ...
, FUJITA Tomonori
, (Wed May 19, 9:42 pm)
Navigation
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Michael Trimarchi
Re: [PATCH] VFS: make file->f_pos access atomic on 32bit arch
Miklos Szeredi
[patch 14/15] vfs: more path_permission() conversions
Serge E. Hallyn
Re: [RFC v5][PATCH 7/8] Infrastructure for shared objects
Bernd Schmidt
Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3
Takashi Iwai
[PATCH 2/2] input: Add LED support to Synaptics device
git
:
Junio C Hamano
Re: mingw, windows, crlf/lf, and git
Eyvind Bernhardsen
Re: Where has "git ls-remote" reference pattern matching gone?
Shawn O. Pearce
Re: Switching from CVS to GIT
Todd Zullinger
Re: [PATCH 2/2] send-email: rfc2047-quote subject lines with non-ascii characters
Santi Béjar
Re: How to use git-fmt-merge-msg?
linux-netdev
:
Ramkrishna Vepa
[net-2.6 PATCH 1/10] Neterion: New driver: Driver help file
Mark Anthony
invitation / inquiry
Ingo Molnar
Re: [PATCH 08/16] dma-debug: add core checking functions
David Miller
Re: [PATCH 1/3] f_phonet: dev_kfree_skb instead of dev_kfree_skb_any in TX callback
Sascha Hauer
[PATCH 03/12] fec: do not typedef struct types
git-commits-head
:
Linux Kernel Mailing List
amba: struct device - replace bus_id with dev_name(), dev_set_name()
Linux Kernel Mailing List
MIPS: Yosemite: Convert SMP startup lock to arch spinlock.
Linux Kernel Mailing List
ARM: S5PC100: IRQ and timer
Linux Kernel Mailing List
davinci: edma: clear interrupt status for interrupt enabled channels only
Linux Kernel Mailing List
x86, mm, kprobes: fault.c, simplify notify_page_fault()
openbsd-misc
:
Daniel A. Ramaley
Re: [semi-OT] Can anyone recommend an OpenBSD-compatible colour laser printer?
Matthias Kilian
Re: can't get vesa @ 1280x800 or nv
Tobias Ulmer
Re: Problem after upgrade 4.5 to 4.6: ERR M
Philip Guenther
Re: SIGCHLD and libpthread.so
J.C. Roberts
Re: [semi-OT] Can anyone recommend an OpenBSD-compatible colour laser printer?
Colocation donated by:
Syndicate