lkml.org 
[lkml]   [2008]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: cdrom: use kmalloced buffers instead of buffers on stack
On Tue, Apr 22 2008, Thomas Bogendoerfer wrote:
> On Mon, Apr 21, 2008 at 10:01:26PM -0400, Jeff Garzik wrote:
> > > cdrom: use kmalloced buffers instead of buffers on stack
> > >
> > > If cdrom commands are issued to a scsi drive in most cases the buffer
> > > will be
> > > filled via dma. This leads to bad stack corruption on non coherent
> > > platforms,
> > > because the buffers are neither cache line aligned nor is the size a
> > > multiple
> > > of the cache line size. Using kmalloced buffers avoids this.
> > >
> > > Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> > > Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
> > >---
> > > drivers/cdrom/cdrom.c | 274
> > > ++++++++++++++++++++++++++++++++-----------------
> > > 1 files changed, 181 insertions(+), 93 deletions(-)
> >
> > Eh... AFAICS this is only really useful in two of the cases converted.
> >
> > For all the other cases (<= 32 bytes), it is _far_ less complex, far
> > less code to simply communicate the additional alignment requirements to
> > the compiler.
> >
> > What about __attribute__ __aligned__? Was that tried?
>
> I used that while narrowing down the bug. But not only the alignment is
> important, but also size needs to be a multiple of the cache line size.
> Which means it needs to be 128 bytes for most SGI machines. That
> and the following in DMA-mapping.txt
>
> "This rule also means that you may use neither kernel image addresses
> (items in data/text/bss segments), nor module image addresses, nor
> stack addresses for DMA."
>
> let me choose the kmalloc() solution.

Which is good, the patch has been due for years :-)

--
Jens Axboe



\
 
 \ /
  Last update: 2008-04-22 08:35    [W:0.059 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site