public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix DMA on Dreamcast
@ 2007-07-19 19:30 Adrian McMenamin
  2007-07-20 19:04 ` Andrew Morton
  0 siblings, 1 reply; 10+ messages in thread
From: Adrian McMenamin @ 2007-07-19 19:30 UTC (permalink / raw)
  To: linux-kernel; +Cc: lethal

[-- Attachment #1: Type: text/plain, Size: 136 bytes --]

I think my first attempt to post this may have got lost in space somewhere.

Signed-off by: Adrian McMenamin <adrian@mcmen.demon.co.uk>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: dma-patch.diff --]
[-- Type: text/x-patch; name="dma-patch.diff", Size: 1958 bytes --]

diff --git a/arch/sh/drivers/dma/dma-api.c b/arch/sh/drivers/dma/dma-api.c
index cf8e119..0c9b3bc 100644
--- a/arch/sh/drivers/dma/dma-api.c
+++ b/arch/sh/drivers/dma/dma-api.c
@@ -31,8 +31,8 @@ struct dma_info *get_dma_info(unsigned int chan)
 	 * the channel is.
 	 */
 	list_for_each_entry(info, &registered_dmac_list, list) {
-		if ((chan <  info->first_channel_nr) ||
-		    (chan >= info->first_channel_nr + info->nr_channels))
+		if ((chan <  info->first_vchannel_nr) ||
+		    (chan >= info->first_vchannel_nr + info->nr_channels))
 			continue;
 
 		return info;
@@ -82,7 +82,7 @@ struct dma_channel *get_dma_channel(unsigned int chan)
 
 	for (i = 0; i < info->nr_channels; i++) {
 		channel = &info->channels[i];
-		if (channel->chan == chan)
+		if (channel->chan == (chan - info->first_vchannel_nr))
 			return channel;
 	}
 
@@ -183,6 +183,7 @@ int dmac_search_free_channel(const char *dev_id)
 			return result;
 
 		atomic_set(&channel->busy, 1);
+
 		return channel->chan;
 	}
 
@@ -194,7 +195,6 @@ int request_dma(unsigned int chan, const char *dev_id)
 	struct dma_channel *channel = { 0 };
 	struct dma_info *info = get_dma_info(chan);
 	int result;
-
 	channel = get_dma_channel(chan);
 	if (atomic_xchg(&channel->busy, 1))
 		return -EBUSY;
@@ -369,6 +369,7 @@ int register_dmac(struct dma_info *info)
 	}
 
 	total_channels = get_nr_channels();
+	info->first_vchannel_nr = total_channels;
 	for (i = 0; i < info->nr_channels; i++) {
 		struct dma_channel *chan = &info->channels[i];
 
@@ -387,7 +388,7 @@ int register_dmac(struct dma_info *info)
 	}
 
 	list_add(&info->list, &registered_dmac_list);
-
+	
 	return 0;
 }
 EXPORT_SYMBOL(register_dmac);
diff --git a/include/asm-sh/dma.h b/include/asm-sh/dma.h
index 6034d4a..4c75b70 100644
--- a/include/asm-sh/dma.h
+++ b/include/asm-sh/dma.h
@@ -111,6 +111,7 @@ struct dma_info {
 
 	struct list_head list;
 	int first_channel_nr;
+	int first_vchannel_nr;
 };
 
 struct dma_chan_caps {

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix DMA on Dreamcast
  2007-07-19 19:30 [PATCH] Fix DMA on Dreamcast Adrian McMenamin
@ 2007-07-20 19:04 ` Andrew Morton
  2007-07-21 10:22   ` Adrian McMenamin
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Morton @ 2007-07-20 19:04 UTC (permalink / raw)
  To: Adrian McMenamin; +Cc: linux-kernel, lethal

On Thu, 19 Jul 2007 20:30:34 +0100
"Adrian McMenamin" <adrianmcmenamin@gmail.com> wrote:

> I think my first attempt to post this may have got lost in space somewhere.
> 
> Signed-off by: Adrian McMenamin <adrian@mcmen.demon.co.uk>

Please provide a description of what problem this change is solving, and how
it solves it.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix DMA on Dreamcast
  2007-07-20 19:04 ` Andrew Morton
@ 2007-07-21 10:22   ` Adrian McMenamin
  2007-07-21 11:24     ` Peter Bortas
  0 siblings, 1 reply; 10+ messages in thread
From: Adrian McMenamin @ 2007-07-21 10:22 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, lethal

On 20/07/07, Andrew Morton <akpm@linux-foundation.org> wrote:
> On Thu, 19 Jul 2007 20:30:34 +0100
> "Adrian McMenamin" <adrianmcmenamin@gmail.com> wrote:
>
> > I think my first attempt to post this may have got lost in space somewhere.
> >
> > Signed-off by: Adrian McMenamin <adrian@mcmen.demon.co.uk>
>
> Please provide a description of what problem this change is solving, and how
> it solves it.
>
Andrew

Sorry, just noticed this. Without this patch the Dreamcast won't boot
when configured with the correct DMA settings in Kbuild. You can
either patch the kernel or use the wrong settings in the build.

Essentially the SH DMA API code is broken in that it doesn't correctly
match the DMA virtual channel to the DMAC.

The patch seems to fix this, though further testing has reveled there
may either be an issue with the patch or an issue with other drivers
using DMA and which have worked because they inadvertently relied on
the breakage in the DMA API code.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix DMA on Dreamcast
  2007-07-21 10:22   ` Adrian McMenamin
@ 2007-07-21 11:24     ` Peter Bortas
  2007-07-21 12:06       ` Adrian McMenamin
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Bortas @ 2007-07-21 11:24 UTC (permalink / raw)
  To: Adrian McMenamin; +Cc: Andrew Morton, linux-kernel, lethal

On 7/21/07, Adrian McMenamin <adrianmcmenamin@gmail.com> wrote:
> On 20/07/07, Andrew Morton <akpm@linux-foundation.org> wrote:
> > On Thu, 19 Jul 2007 20:30:34 +0100
> > "Adrian McMenamin" <adrianmcmenamin@gmail.com> wrote:
> >
> > > I think my first attempt to post this may have got lost in space somewhere.
> > >
> > > Signed-off by: Adrian McMenamin <adrian@mcmen.demon.co.uk>
> >
> > Please provide a description of what problem this change is solving, and how
> > it solves it.
> >
> Andrew
>
> Sorry, just noticed this. Without this patch the Dreamcast won't boot
> when configured with the correct DMA settings in Kbuild. You can
> either patch the kernel or use the wrong settings in the build.
>
> Essentially the SH DMA API code is broken in that it doesn't correctly
> match the DMA virtual channel to the DMAC.
>
> The patch seems to fix this, though further testing has reveled there
> may either be an issue with the patch or an issue with other drivers
> using DMA and which have worked because they inadvertently relied on
> the breakage in the DMA API code.

Sidenote: Does Linux handle the Dreamcast DMA errata?

-- 
Peter Bortas

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix DMA on Dreamcast
  2007-07-21 11:24     ` Peter Bortas
@ 2007-07-21 12:06       ` Adrian McMenamin
  2007-07-21 14:13         ` Peter Bortas
  0 siblings, 1 reply; 10+ messages in thread
From: Adrian McMenamin @ 2007-07-21 12:06 UTC (permalink / raw)
  To: Peter Bortas; +Cc: Andrew Morton, linux-kernel, lethal

On 21/07/07, Peter Bortas <bortas@gmail.com> wrote:

>
> Sidenote: Does Linux handle the Dreamcast DMA errata?
>

You need to explain what you mean (at least to me!).

If you mean will it degrade gracefully - not without this patch if set
to the (correct) defconfig. With iffy settings it will.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix DMA on Dreamcast
  2007-07-21 12:06       ` Adrian McMenamin
@ 2007-07-21 14:13         ` Peter Bortas
  2007-07-26 10:10           ` Marcus Comstedt
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Bortas @ 2007-07-21 14:13 UTC (permalink / raw)
  To: Adrian McMenamin; +Cc: Andrew Morton, linux-kernel, lethal, marcus

On 7/21/07, Adrian McMenamin <adrianmcmenamin@gmail.com> wrote:
> On 21/07/07, Peter Bortas <bortas@gmail.com> wrote:
>
> >
> > Sidenote: Does Linux handle the Dreamcast DMA errata?
> >
>
> You need to explain what you mean (at least to me!).
>
> If you mean will it degrade gracefully - not without this patch if set
> to the (correct) defconfig. With iffy settings it will.

If I remember correctly (and that's a big if since I last looked at it
in 2001) some revisions of the Dreamcast hardware would sporadically
lock up if you scheduled a new DMA request to quickly after a previous
one, even if you checked the ready bit. It's worked around by a delay
of X microseconds as recommended by Sega engineers. I don't remember
the value of X, nor where exactly in the flow this workaround should
be applied.

Adding Marcus in case he has a better memory than me.

-- 
Peter Bortas

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix DMA on Dreamcast
  2007-07-21 14:13         ` Peter Bortas
@ 2007-07-26 10:10           ` Marcus Comstedt
  2007-07-26 12:59             ` Peter Bortas
  0 siblings, 1 reply; 10+ messages in thread
From: Marcus Comstedt @ 2007-07-26 10:10 UTC (permalink / raw)
  To: Peter Bortas; +Cc: Adrian McMenamin, Andrew Morton, linux-kernel, lethal


"Peter Bortas" <bortas@gmail.com> writes:

> On 7/21/07, Adrian McMenamin <adrianmcmenamin@gmail.com> wrote:
>> On 21/07/07, Peter Bortas <bortas@gmail.com> wrote:
>>
>> >
>> > Sidenote: Does Linux handle the Dreamcast DMA errata?
>> >
>>
>> You need to explain what you mean (at least to me!).
>>
>> If you mean will it degrade gracefully - not without this patch if set
>> to the (correct) defconfig. With iffy settings it will.
>
> If I remember correctly (and that's a big if since I last looked at it
> in 2001) some revisions of the Dreamcast hardware would sporadically
> lock up if you scheduled a new DMA request to quickly after a previous
> one, even if you checked the ready bit. It's worked around by a delay
> of X microseconds as recommended by Sega engineers. I don't remember
> the value of X, nor where exactly in the flow this workaround should
> be applied.
>
> Adding Marcus in case he has a better memory than me.


I don't remeber any such delay.  Are you sure you're not thinking
about the G2 bus problem (where accesses need to be programatically
serialized, whether they are PIO or DMA)?


  // Marcus



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix DMA on Dreamcast
  2007-07-26 10:10           ` Marcus Comstedt
@ 2007-07-26 12:59             ` Peter Bortas
  2007-07-26 13:06               ` Paul Mundt
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Bortas @ 2007-07-26 12:59 UTC (permalink / raw)
  To: Marcus Comstedt; +Cc: Adrian McMenamin, Andrew Morton, linux-kernel, lethal

On 7/26/07, Marcus Comstedt <marcus@mc.pp.se> wrote:
>
> "Peter Bortas" <bortas@gmail.com> writes:
>
> > On 7/21/07, Adrian McMenamin <adrianmcmenamin@gmail.com> wrote:
> >> On 21/07/07, Peter Bortas <bortas@gmail.com> wrote:
> >>
> >> >
> >> > Sidenote: Does Linux handle the Dreamcast DMA errata?
> >> >
> >>
> >> You need to explain what you mean (at least to me!).
> >>
> >> If you mean will it degrade gracefully - not without this patch if set
> >> to the (correct) defconfig. With iffy settings it will.
> >
> > If I remember correctly (and that's a big if since I last looked at it
> > in 2001) some revisions of the Dreamcast hardware would sporadically
> > lock up if you scheduled a new DMA request to quickly after a previous
> > one, even if you checked the ready bit. It's worked around by a delay
> > of X microseconds as recommended by Sega engineers. I don't remember
> > the value of X, nor where exactly in the flow this workaround should
> > be applied.
> >
> > Adding Marcus in case he has a better memory than me.
>
>
> I don't remeber any such delay.  Are you sure you're not thinking
> about the G2 bus problem (where accesses need to be programatically
> serialized, whether they are PIO or DMA)?

In that case my memory is worse than I thought. I'll see if I can dig
up my old notes.

-- 
Peter Bortas

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix DMA on Dreamcast
  2007-07-26 12:59             ` Peter Bortas
@ 2007-07-26 13:06               ` Paul Mundt
  2007-07-28  1:50                 ` Peter Bortas
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Mundt @ 2007-07-26 13:06 UTC (permalink / raw)
  To: Peter Bortas
  Cc: Marcus Comstedt, Adrian McMenamin, Andrew Morton, linux-kernel

On Thu, Jul 26, 2007 at 02:59:51PM +0200, Peter Bortas wrote:
> On 7/26/07, Marcus Comstedt <marcus@mc.pp.se> wrote:
> > "Peter Bortas" <bortas@gmail.com> writes:
> > > On 7/21/07, Adrian McMenamin <adrianmcmenamin@gmail.com> wrote:
> > >> On 21/07/07, Peter Bortas <bortas@gmail.com> wrote:
> > >> > Sidenote: Does Linux handle the Dreamcast DMA errata?
> > >>
> > >> You need to explain what you mean (at least to me!).
> > >>
> > >> If you mean will it degrade gracefully - not without this patch if set
> > >> to the (correct) defconfig. With iffy settings it will.
> > >
> > > If I remember correctly (and that's a big if since I last looked at it
> > > in 2001) some revisions of the Dreamcast hardware would sporadically
> > > lock up if you scheduled a new DMA request to quickly after a previous
> > > one, even if you checked the ready bit. It's worked around by a delay
> > > of X microseconds as recommended by Sega engineers. I don't remember
> > > the value of X, nor where exactly in the flow this workaround should
> > > be applied.
> > >
> > > Adding Marcus in case he has a better memory than me.
> >
> > I don't remeber any such delay.  Are you sure you're not thinking
> > about the G2 bus problem (where accesses need to be programatically
> > serialized, whether they are PIO or DMA)?
> 
> In that case my memory is worse than I thought. I'll see if I can dig
> up my old notes.
> 
We've never hit any problems with the SH DMAC, so it would be interesting
if you had some more information on this. The G2 problems are well known
and documented, and the driver takes care of those issues already.

Is this problem specifically an SH7091 errata, or have you heard of it
happening on normal SH7750 parts also? SH7091 is unfortunately not very
well documented ;-)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix DMA on Dreamcast
  2007-07-26 13:06               ` Paul Mundt
@ 2007-07-28  1:50                 ` Peter Bortas
  0 siblings, 0 replies; 10+ messages in thread
From: Peter Bortas @ 2007-07-28  1:50 UTC (permalink / raw)
  To: Paul Mundt, Peter Bortas, Marcus Comstedt, Adrian McMenamin,
	Andrew Morton, linux-kernel

On 7/26/07, Paul Mundt <lethal@linux-sh.org> wrote:
> On Thu, Jul 26, 2007 at 02:59:51PM +0200, Peter Bortas wrote:
> > On 7/26/07, Marcus Comstedt <marcus@mc.pp.se> wrote:
> > > "Peter Bortas" <bortas@gmail.com> writes:
> > > > On 7/21/07, Adrian McMenamin <adrianmcmenamin@gmail.com> wrote:
> > > >> On 21/07/07, Peter Bortas <bortas@gmail.com> wrote:
> > > >> > Sidenote: Does Linux handle the Dreamcast DMA errata?
> > > >>
> > > >> You need to explain what you mean (at least to me!).
> > > >>
> > > >> If you mean will it degrade gracefully - not without this patch if set
> > > >> to the (correct) defconfig. With iffy settings it will.
> > > >
> > > > If I remember correctly (and that's a big if since I last looked at it
> > > > in 2001) some revisions of the Dreamcast hardware would sporadically
> > > > lock up if you scheduled a new DMA request to quickly after a previous
> > > > one, even if you checked the ready bit. It's worked around by a delay
> > > > of X microseconds as recommended by Sega engineers. I don't remember
> > > > the value of X, nor where exactly in the flow this workaround should
> > > > be applied.
> > > >
> > > > Adding Marcus in case he has a better memory than me.
> > >
> > > I don't remeber any such delay.  Are you sure you're not thinking
> > > about the G2 bus problem (where accesses need to be programatically
> > > serialized, whether they are PIO or DMA)?
> >
> > In that case my memory is worse than I thought. I'll see if I can dig
> > up my old notes.
> >
> We've never hit any problems with the SH DMAC, so it would be interesting
> if you had some more information on this. The G2 problems are well known
> and documented, and the driver takes care of those issues already.

After grep-ing through some 8GiB of archived mails and notes it seems
marcus is absolutely correct, I'm thinking of the known G2 problem.

-- 
Peter

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-07-28  1:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-19 19:30 [PATCH] Fix DMA on Dreamcast Adrian McMenamin
2007-07-20 19:04 ` Andrew Morton
2007-07-21 10:22   ` Adrian McMenamin
2007-07-21 11:24     ` Peter Bortas
2007-07-21 12:06       ` Adrian McMenamin
2007-07-21 14:13         ` Peter Bortas
2007-07-26 10:10           ` Marcus Comstedt
2007-07-26 12:59             ` Peter Bortas
2007-07-26 13:06               ` Paul Mundt
2007-07-28  1:50                 ` Peter Bortas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox