From: Nick Piggin on
On Wed, May 19, 2010 at 03:44:30PM +0200, Johannes Weiner wrote:
> On Wed, May 19, 2010 at 11:36:56PM +1000, Nick Piggin wrote:
> > On Wed, May 19, 2010 at 02:17:47PM +0100, David Woodhouse wrote:
> > >
> > > The 'cacheline aligned' misconception did manage to get into the ad7877
> > > driver in commit 3843384a though -- it now uses ____cacheline_aligned
> > > instead of __attribute__((__aligned__(ARCH_KMALLOC_MINALIGN))) as it
> > > should.
> >
> > OK so long as there is not a "must be cacheline aligned" requirement.
> > Your proposal for a __dma_aligned attribute in an arch header looks
> > like a good idea there.
>
> Would you happen to know of other potential users? At this point I'd
> much rather just allocate the buffers dynamically and hide the issue
> nicely behind kmalloc().

I don't think we need to hide the fact that some platforms have
specific alignment restrictions for DMA. So if any drivers make use
of the alignment, I see no problem with __dma_aligned.

--
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: FUJITA Tomonori on
On Wed, 19 May 2010 23:52:26 +1000
Nick Piggin <npiggin(a)suse.de> wrote:

> On Wed, May 19, 2010 at 03:44:30PM +0200, Johannes Weiner wrote:
> > On Wed, May 19, 2010 at 11:36:56PM +1000, Nick Piggin wrote:
> > > On Wed, May 19, 2010 at 02:17:47PM +0100, David Woodhouse wrote:
> > > >
> > > > The 'cacheline aligned' misconception did manage to get into the ad7877
> > > > driver in commit 3843384a though -- it now uses ____cacheline_aligned
> > > > instead of __attribute__((__aligned__(ARCH_KMALLOC_MINALIGN))) as it
> > > > should.
> > >
> > > OK so long as there is not a "must be cacheline aligned" requirement.
> > > Your proposal for a __dma_aligned attribute in an arch header looks
> > > like a good idea there.
> >
> > Would you happen to know of other potential users? At this point I'd
> > much rather just allocate the buffers dynamically and hide the issue
> > nicely behind kmalloc().
>
> I don't think we need to hide the fact that some platforms have
> specific alignment restrictions for DMA. So if any drivers make use
> of the alignment, I see no problem with __dma_aligned.

IIRC, such was proposed several times:

http://www.mail-archive.com/linux-scsi(a)vger.kernel.org/msg12633.html

I guess that we agreed that it's better to tell driver writers to just
use kmalloc.
--
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: David Woodhouse on
On Wed, 2010-05-19 at 23:38 +0900, FUJITA Tomonori wrote:
>
> > I don't think we need to hide the fact that some platforms have
> > specific alignment restrictions for DMA. So if any drivers make use
> > of the alignment, I see no problem with __dma_aligned.
>
> IIRC, such was proposed several times:
>
> http://www.mail-archive.com/linux-scsi(a)vger.kernel.org/msg12633.html
>
> I guess that we agreed that it's better to tell driver writers to just
> use kmalloc.

Perhaps -- but only a few days ago in this thread, they were being
advised to use ____cacheline_aligned instead!

And for this case it really does seem to make sense to keep the buffer
in the parent structure rather than allocating it separately. The DMA
buffers are tiny and on cache-coherent architectures it's _much_ more
efficient just to have them in the original structure and use
__dma_aligned.

--
dwmw2

--
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: Johannes Weiner on
On Wed, May 19, 2010 at 11:52:26PM +1000, Nick Piggin wrote:
> On Wed, May 19, 2010 at 03:44:30PM +0200, Johannes Weiner wrote:
> > On Wed, May 19, 2010 at 11:36:56PM +1000, Nick Piggin wrote:
> > > On Wed, May 19, 2010 at 02:17:47PM +0100, David Woodhouse wrote:
> > > >
> > > > The 'cacheline aligned' misconception did manage to get into the ad7877
> > > > driver in commit 3843384a though -- it now uses ____cacheline_aligned
> > > > instead of __attribute__((__aligned__(ARCH_KMALLOC_MINALIGN))) as it
> > > > should.
> > >
> > > OK so long as there is not a "must be cacheline aligned" requirement.
> > > Your proposal for a __dma_aligned attribute in an arch header looks
> > > like a good idea there.
> >
> > Would you happen to know of other potential users? At this point I'd
> > much rather just allocate the buffers dynamically and hide the issue
> > nicely behind kmalloc().
>
> I don't think we need to hide the fact that some platforms have
> specific alignment restrictions for DMA. So if any drivers make use
> of the alignment, I see no problem with __dma_aligned.

In this case, the slave driver does not know whether the master driver
is even using DMA. That's the reason we do not use dma_alloc_* for
the buffers in the first place. And that's why I'd prefer to leave
the slave agnostic about it. Use kmalloc(), don't worry about the
details.

Of course, there may still be more appropriate users for the macro,
that's why I asked.
--
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: Dmitry Torokhov on
On Wed, May 19, 2010 at 11:38:34PM +0900, FUJITA Tomonori wrote:
> On Wed, 19 May 2010 23:52:26 +1000
> Nick Piggin <npiggin(a)suse.de> wrote:
>
> > On Wed, May 19, 2010 at 03:44:30PM +0200, Johannes Weiner wrote:
> > > On Wed, May 19, 2010 at 11:36:56PM +1000, Nick Piggin wrote:
> > > > On Wed, May 19, 2010 at 02:17:47PM +0100, David Woodhouse wrote:
> > > > >
> > > > > The 'cacheline aligned' misconception did manage to get into the ad7877
> > > > > driver in commit 3843384a though -- it now uses ____cacheline_aligned
> > > > > instead of __attribute__((__aligned__(ARCH_KMALLOC_MINALIGN))) as it
> > > > > should.
> > > >
> > > > OK so long as there is not a "must be cacheline aligned" requirement.
> > > > Your proposal for a __dma_aligned attribute in an arch header looks
> > > > like a good idea there.
> > >
> > > Would you happen to know of other potential users? At this point I'd
> > > much rather just allocate the buffers dynamically and hide the issue
> > > nicely behind kmalloc().
> >
> > I don't think we need to hide the fact that some platforms have
> > specific alignment restrictions for DMA. So if any drivers make use
> > of the alignment, I see no problem with __dma_aligned.
>
> IIRC, such was proposed several times:
>
> http://www.mail-archive.com/linux-scsi(a)vger.kernel.org/msg12633.html
>
> I guess that we agreed that it's better to tell driver writers to just
> use kmalloc.

It really dpeends on the size of the buffer. When I need a single byte I
really do not want to mess with separate kmalloced buffer.

If somebody coudl pick David's patch that would be great.

--
Dmitry
--
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/