From: Christoph Lameter on 11 May 2010 16:30 On Tue, 11 May 2010, Mike Frysinger wrote: > and like i said, that doesnt sound like a reasonable solution when > every single SPI driver (over 100 atm) out there is affected If you are on an embedded arch then you can of course set the default kmalloc alignment. The requirement for kmalloc is that it returns memory that can be used for DMA. If the arch can only DMA into cacheline aligned objects then the correct method is to force kmalloc alignment to cacheline size. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Pekka Enberg on 11 May 2010 16:30 On Tue, May 11, 2010 at 11:10 PM, Mike Frysinger <vapier.adi(a)gmail.com> wrote: >> Make your own slab cache with the alignment flag set, as Pekka already >> mentioned. > > and like i said, that doesnt sound like a reasonable solution when > every single SPI driver (over 100 atm) out there is affected Why do you need to do it in every driver? Why not create a cache of size cache_line_size()*2 or something in the SPI stack and add a helper function spi_alloc_whatever_this_is_about() for the drivers to use? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Mike Frysinger on 11 May 2010 16:40 On Tue, May 11, 2010 at 16:21, Christoph Lameter wrote: > On Tue, 11 May 2010, Mike Frysinger wrote: >> and like i said, that doesnt sound like a reasonable solution when >> every single SPI driver (over 100 atm) out there is affected > > If you are on an embedded arch then you can of course set the default > kmalloc alignment. > > The requirement for kmalloc is that it returns memory that can be used for > DMA. If the arch can only DMA into cacheline aligned objects then the > correct method is to force kmalloc alignment to cacheline size. these are SPI drivers and are usable on any arch that supports a SPI bus (which is pretty much every arch). forget about "embedded" arches. the issue here is simple: a SPI driver (AD7877) needs to do a receive SPI transfer into a DMA safe buffer. what is the exact API to dynamically allocate memory for the structure with this buffer embedded in it such that the start of the structure is cached aligned ? creating a dedicated kmem cache may work, but it isnt a scalable solution if every SPI driver needs to create its own cache. On Tue, May 11, 2010 at 16:22, Pekka Enberg wrote: > Why do you need to do it in every driver? Why not create a cache of > size cache_line_size()*2 or something in the SPI stack and add a > helper function spi_alloc_whatever_this_is_about() for the drivers to > use? that is a question for David/Grant. i'm not the SPI core maintainer, i'm merely watching over some SPI drivers. however, this answer also doesnt sound like it's thinking big enough because what you're proposing isnt specific to the SPI bus -- any time a DMA safe buffer is needed dynamically, this function could be used. -mike -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Pekka Enberg on 11 May 2010 16:40 Mike Frysinger wrote: > that is a question for David/Grant. i'm not the SPI core maintainer, > i'm merely watching over some SPI drivers. however, this answer also > doesnt sound like it's thinking big enough because what you're > proposing isnt specific to the SPI bus -- any time a DMA safe buffer > is needed dynamically, this function could be used. Well, we have dma_alloc_coherent(), shouldn't you be using that instead? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Mike Frysinger on 11 May 2010 16:50
On Tue, May 11, 2010 at 16:38, Pekka Enberg wrote: > Mike Frysinger wrote: >> that is a question for David/Grant. i'm not the SPI core maintainer, >> i'm merely watching over some SPI drivers. however, this answer also >> doesnt sound like it's thinking big enough because what you're >> proposing isnt specific to the SPI bus -- any time a DMA safe buffer >> is needed dynamically, this function could be used. > > Well, we have dma_alloc_coherent(), shouldn't you be using that instead? my understanding is that dma_alloc_coherent() gives you a buffer that is always coherent. the SPI layers take care of flushing and such on the fly which means allocating coherent memory is overkill and bad for performance. -mike -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |