2009-06-14 18:56:43

by Stefan Richter

[permalink] [raw]
Subject: dma-debug: check_for_stack background?

Hi,

it took a while but I finally noticed that the DMA debug facility warns
about mappings of on-stack memory. What's the problem with that? Are
there architectures which don't support such mappings, or is it a
question of caution not to DMA-map the stack?
--
Stefan Richter
-=====-==--= -==- -===-
http://arcgraph.de/sr/


2009-06-14 21:20:41

by Ben Dooks

[permalink] [raw]
Subject: Re: dma-debug: check_for_stack background?

On Sun, Jun 14, 2009 at 08:56:29PM +0200, Stefan Richter wrote:
> Hi,
>
> it took a while but I finally noticed that the DMA debug facility warns
> about mappings of on-stack memory. What's the problem with that? Are
> there architectures which don't support such mappings, or is it a
> question of caution not to DMA-map the stack?

I'm not sure if it is possible on all architectures, however the
DMA mapping documentation prohibts the use of stack memory.

--
Ben ([email protected], http://www.fluff.org/)

'a smiley only costs 4 bytes'

2009-06-14 21:43:58

by Stefan Richter

[permalink] [raw]
Subject: Re: dma-debug: check_for_stack background?

Ben Dooks wrote:
> On Sun, Jun 14, 2009 at 08:56:29PM +0200, Stefan Richter wrote:
>> the DMA debug facility warns
>> about mappings of on-stack memory. What's the problem with that?
...
> I'm not sure if it is possible on all architectures, however the
> DMA mapping documentation prohibts the use of stack memory.

Ah, it has all been documented in plain sight for ages. Thanks for the
pointer.
--
Stefan Richter
-=====-==--= -==- -===-
http://arcgraph.de/sr/

2009-06-15 08:14:16

by Joerg Roedel

[permalink] [raw]
Subject: Re: dma-debug: check_for_stack background?

On Sun, Jun 14, 2009 at 11:43:42PM +0200, Stefan Richter wrote:
> Ben Dooks wrote:
>> On Sun, Jun 14, 2009 at 08:56:29PM +0200, Stefan Richter wrote:
>>> the DMA debug facility warns about mappings of on-stack memory.
>>> What's the problem with that?
> ...
>> I'm not sure if it is possible on all architectures, however the
>> DMA mapping documentation prohibts the use of stack memory.
>
> Ah, it has all been documented in plain sight for ages. Thanks for the
> pointer.

Problem is that the stack might go away or could be otherwise reused
while the DMA is in-flight. This could cause really hard to debug
problems.

Joerg

--
| Advanced Micro Devices GmbH
Operating | Karl-Hammerschmidt-Str. 34, 85609 Dornach bei M?nchen
System |
Research | Gesch?ftsf?hrer: Thomas M. McCoy, Giuliano Meroni
Center | Sitz: Dornach, Gemeinde Aschheim, Landkreis M?nchen
| Registergericht M?nchen, HRB Nr. 43632

2009-06-16 06:17:21

by FUJITA Tomonori

[permalink] [raw]
Subject: Re: dma-debug: check_for_stack background?

On Mon, 15 Jun 2009 10:13:55 +0200
Joerg Roedel <[email protected]> wrote:

> On Sun, Jun 14, 2009 at 11:43:42PM +0200, Stefan Richter wrote:
> > Ben Dooks wrote:
> >> On Sun, Jun 14, 2009 at 08:56:29PM +0200, Stefan Richter wrote:
> >>> the DMA debug facility warns about mappings of on-stack memory.
> >>> What's the problem with that?
> > ...
> >> I'm not sure if it is possible on all architectures, however the
> >> DMA mapping documentation prohibts the use of stack memory.
> >
> > Ah, it has all been documented in plain sight for ages. Thanks for the
> > pointer.
>
> Problem is that the stack might go away or could be otherwise reused
> while the DMA is in-flight. This could cause really hard to debug
> problems.

Not true. Even if you use the stack buffer for DMA synchronously, it
doesn't work (we had the bad code like starting dma and waiting for
the completion).

On some architectures, we can't use the stack buffer for DMA. That's
why the DMA mapping documentation prohibits the use of stack memory
for DMA.

2009-06-16 06:41:49

by Ming Lei

[permalink] [raw]
Subject: Re: dma-debug: check_for_stack background?

2009/6/16 FUJITA Tomonori <[email protected]>:
> On Mon, 15 Jun 2009 10:13:55 +0200
> Joerg Roedel <[email protected]> wrote:
>
>> On Sun, Jun 14, 2009 at 11:43:42PM +0200, Stefan Richter wrote:
>> > Ben Dooks wrote:
>> >> On Sun, Jun 14, 2009 at 08:56:29PM +0200, Stefan Richter wrote:
>> >>> the DMA debug facility warns ?about mappings of on-stack memory.
>> >>> What's the problem with that?
>> > ...
>> >> I'm not sure if it is possible on all architectures, however the
>> >> DMA mapping documentation prohibts the use of stack memory.
>> >
>> > Ah, it has all been documented in plain sight for ages. ?Thanks for the
>> > pointer.
>>
>> Problem is that the stack might go away or could be otherwise reused
>> while the DMA is in-flight. This could cause really hard to debug
>> problems.
>
> Not true. Even if you use the stack buffer for DMA synchronously, it
> doesn't work (we had the bad code like starting dma and waiting for
> the completion).

Yes, there is cache alignement problem for stack buffer also.

>
> On some architectures, we can't use the stack buffer for DMA. That's
> why the DMA mapping documentation prohibits the use of stack memory
> for DMA.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at ?http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at ?http://www.tux.org/lkml/
>



--
Lei Ming

2009-06-16 08:15:00

by Joerg Roedel

[permalink] [raw]
Subject: Re: dma-debug: check_for_stack background?

On Tue, Jun 16, 2009 at 03:16:37PM +0900, FUJITA Tomonori wrote:
> On Mon, 15 Jun 2009 10:13:55 +0200
> Joerg Roedel <[email protected]> wrote:
>
> > On Sun, Jun 14, 2009 at 11:43:42PM +0200, Stefan Richter wrote:
> > > Ben Dooks wrote:
> > >> On Sun, Jun 14, 2009 at 08:56:29PM +0200, Stefan Richter wrote:
> > >>> the DMA debug facility warns about mappings of on-stack memory.
> > >>> What's the problem with that?
> > > ...
> > >> I'm not sure if it is possible on all architectures, however the
> > >> DMA mapping documentation prohibts the use of stack memory.
> > >
> > > Ah, it has all been documented in plain sight for ages. Thanks for the
> > > pointer.
> >
> > Problem is that the stack might go away or could be otherwise reused
> > while the DMA is in-flight. This could cause really hard to debug
> > problems.
>
> Not true. Even if you use the stack buffer for DMA synchronously, it
> doesn't work (we had the bad code like starting dma and waiting for
> the completion).

I've not written that this is the only problem. I know that there may be
others like the one you experienced. But what I wrote could also happen
and is a problem :)

Joerg

--
| Advanced Micro Devices GmbH
Operating | Karl-Hammerschmidt-Str. 34, 85609 Dornach bei M?nchen
System |
Research | Gesch?ftsf?hrer: Thomas M. McCoy, Giuliano Meroni
Center | Sitz: Dornach, Gemeinde Aschheim, Landkreis M?nchen
| Registergericht M?nchen, HRB Nr. 43632