Adrian McMenamin | 1 May 20:59 2006
Picon
Picon

Re: Dreamcast G2 DMA interrupt handling

On Sun, 2006-04-30 at 18:19 +0100, Adrian McMenamin wrote:
> On Sun, 2006-04-30 at 13:46 +0100, Adrian McMenamin wrote:
> > I am trying to patch the G2 interrupt handling to get my sound driver to
> > work as expected.
> > 

> > 
> 
> Further testing shows that this is because *dev_id does not point to
> dma_channel or points to an unitialised dma_channel.
> 
> NB: I know there is an error in the code above!
> 
> unsigned int chan_nr = 0; crept in through pasting in some code used for
> testing
> 
> 
Using this:

static irqreturn_t g2_dma_interrupt(int irq, void *dev_id, struct
pt_regs *regs)
{
	/* FIXME: Do some meaningful completion work here.. */

	struct dma_channel *chan = dev_id;
	printk("dma_channel here  dev_id is 0x%X\n", dev_id);
	if (dev_id) {
        	unsigned int chan_nr = chan->chan;
		printk("now here\n");
        	unsigned int bytes;
(Continue reading)

Adrian McMenamin | 2 May 00:18 2006
Picon
Picon

[PATCH] dma-g2.c

Patch to get g2 dma to work as intended. Please apply.

Signed-off by Adrian McMenamin <adrian <at> mcmen.co.uk>

--- ./b/dma-g2.c	2006-05-01 23:12:38.000000000 +0100
+++ ./a/dma-g2.c	2006-05-01 23:13:54.000000000 +0100
 <at>  <at>  -49,7 +49,14  <at>  <at> 

 static irqreturn_t g2_dma_interrupt(int irq, void *dev_id, struct
pt_regs *regs)
 {
-	/* FIXME: Do some meaningful completion work here.. */
+
+	struct dma_channel *chan = dev_id;
+        unsigned int chan_nr = chan->chan;
+        unsigned int bytes;
+
+        bytes = (g2_dma->channel[chan_nr].size -
g2_dma->status[chan_nr].size) & 0x2FFFFF;
+        if (likely(bytes == 0))
+               	wake_up(&chan->wait_queue);
 	return IRQ_HANDLED;
 }

 <at>  <at>  -62,6 +69,7  <at>  <at> 
 static int g2_enable_dma(struct dma_channel *chan)
 {
 	unsigned int chan_nr = chan->chan;
+	g2_dma_irq.dev_id = chan;

(Continue reading)

Adrian McMenamin | 2 May 00:22 2006
Picon
Picon

Re: [PATCH] dma-g2.c

On Mon, 2006-05-01 at 23:18 +0100, Adrian McMenamin wrote:
> Patch to get g2 dma to work as intended. Please apply.
> 
> Signed-off by Adrian McMenamin <adrian <at> mcmen.co.uk>
> 
Urgh. Looks like evolution managed that a bit. Here it is as an
attachment

Attachment (dma-g2.patch): text/x-patch, 1123 bytes
Paul Mundt | 2 May 17:53 2006

Re: [PATCH] dma-g2.c

On Mon, May 01, 2006 at 11:22:16PM +0100, Adrian McMenamin wrote:
> --- ./b/dma-g2.c	2006-05-01 23:12:38.000000000 +0100
> +++ ./a/dma-g2.c	2006-05-01 23:13:54.000000000 +0100
>  <at>  <at>  -49,7 +49,14  <at>  <at> 
>  
>  static irqreturn_t g2_dma_interrupt(int irq, void *dev_id, struct pt_regs *regs)
>  {
> -	/* FIXME: Do some meaningful completion work here.. */
> +
> +	struct dma_channel *chan = dev_id;
> +        unsigned int chan_nr = chan->chan;

Mangled whitespace.

> +        unsigned int bytes;
> +
> +        bytes = (g2_dma->channel[chan_nr].size - g2_dma->status[chan_nr].size) & 0x2FFFFF;

Should probably make a macro for this, as it's used in a couple places,
and not entirely intuitive by itself.

>  <at>  <at>  -62,6 +69,7  <at>  <at> 
>  static int g2_enable_dma(struct dma_channel *chan)
>  {
>  	unsigned int chan_nr = chan->chan;
> +	g2_dma_irq.dev_id = chan;
>  
>  	g2_dma->channel[chan_nr].chan_enable = 1;
>  	g2_dma->channel[chan_nr].xfer_enable = 1;

(Continue reading)

Adrian McMenamin | 2 May 19:57 2006
Picon
Picon

Re: [PATCH] dma-g2.c

On Tue, 2006-05-02 at 18:53 +0300, Paul Mundt wrote:

> No, not only is that never going to work for multiple channels, it's also
> an oops waiting to happen as soon as the IRQ gets unmasked. We'll have to
> pass it off at request_irq() time, and then figure out which channel
> raised the interrupt from IRQ context in order to find the proper
> dma_channel pointer.

What does "pass it off" mean?

-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Paul Mundt | 2 May 20:24 2006

Re: [PATCH] dma-g2.c

On Tue, May 02, 2006 at 06:57:49PM +0100, Adrian McMenamin wrote:
> On Tue, 2006-05-02 at 18:53 +0300, Paul Mundt wrote:
> > No, not only is that never going to work for multiple channels, it's also
> > an oops waiting to happen as soon as the IRQ gets unmasked. We'll have to
> > pass it off at request_irq() time, and then figure out which channel
> > raised the interrupt from IRQ context in order to find the proper
> > dma_channel pointer.
> 
> What does "pass it off" mean?
> 
Setting the private data at the time the IRQ is reserved so that dev_id
isn't NULL when the interrupt handler is invoked of course..

On the other hand, g2_dma is global, so you can just reference that
directly if you can figure out which channel has raised the IRQ, there
will be some status bit that you can check for the channel number.
Adrian McMenamin | 2 May 22:44 2006
Picon
Picon

Re: [PATCH] dma-g2.c

On Tue, 2006-05-02 at 21:24 +0300, Paul Mundt wrote:
> On Tue, May 02, 2006 at 06:57:49PM +0100, Adrian McMenamin wrote:
> > On Tue, 2006-05-02 at 18:53 +0300, Paul Mundt wrote:
> > > No, not only is that never going to work for multiple channels, it's also
> > > an oops waiting to happen as soon as the IRQ gets unmasked. We'll have to
> > > pass it off at request_irq() time, and then figure out which channel
> > > raised the interrupt from IRQ context in order to find the proper
> > > dma_channel pointer.
> > 
> > What does "pass it off" mean?
> > 
> Setting the private data at the time the IRQ is reserved so that dev_id
> isn't NULL when the interrupt handler is invoked of course..
> 
> On the other hand, g2_dma is global, so you can just reference that
> directly if you can figure out which channel has raised the IRQ, there
> will be some status bit that you can check for the channel number.

For the life of me I cannot work out how to do this. I can see that it
is probably possible to work out which g2 channel is responsible, but
not how to access the wait queue.

 How come the handler is registered in a way that doesn't point to a
device or any other useful structure? Is that not fixable?

-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
(Continue reading)

Manuel Lauss | 3 May 14:01 2006
Picon

[PATCH] fix /proc/interrupts output for dma-sh

Hi everyone,

dma-sh.c displays random kernel memory in /proc/interrupts:

 16:       9537         IPR-IRQ  timer
 34:          0         IPR-IRQ  8H
 38:          0         IPR-IRQ  DMAC Address Error

With this patch:
 16:       7340         IPR-IRQ  timer
 34:          0         IPR-IRQ  DMAC Transfer End (Channel 0)
 38:          0         IPR-IRQ  DMAC Address Error

Comments welcome!

--

-- 
 ml.

--- linux-2.6.16-shcvs/include/asm-sh/dma.h	2005-10-16 20:27:54.000000000 +0200
+++ linux-2.6.16-work/include/asm-sh/dma.h	2006-05-03 10:51:31.242256000 +0200
 <at>  <at>  -90,6 +90,7  <at>  <at> 
 	wait_queue_head_t wait_queue;

 	struct sys_device dev;
+	char* name;
 };

 struct dma_info {
--- linux-2.6.16-shcvs/arch/sh/drivers/dma/dma-sh.c	2006-02-05 16:25:52.000000000 +0100
+++ linux-2.6.16-work/arch/sh/drivers/dma/dma-sh.c	2006-05-03 11:00:44.022256000 +0200
(Continue reading)

Paul Mundt | 3 May 14:12 2006

Re: [PATCH] fix /proc/interrupts output for dma-sh

On Wed, May 03, 2006 at 02:01:00PM +0200, Manuel Lauss wrote:
> --- linux-2.6.16-shcvs/arch/sh/drivers/dma/dma-sh.c	2006-02-05 16:25:52.000000000 +0100
> +++ linux-2.6.16-work/arch/sh/drivers/dma/dma-sh.c	2006-05-03 11:00:44.022256000 +0200
>  <at>  <at>  -81,21 +81,23  <at>  <at> 
>  
>  static int sh_dmac_request_dma(struct dma_channel *chan)
>  {
> -	char name[32];
> -
>  	if (unlikely(!chan->flags & DMA_TEI_CAPABLE))
>  		return 0;
>  
> -	snprintf(name, sizeof(name), "DMAC Transfer End (Channel %d)",
> +	chan->name = kzalloc(32, GFP_KERNEL);
> +	if (!chan->name)
> +		return -ENOMEM;

unlikely().

Looks fine, this was a pretty stupid bug, feel free to commit.
Adrian McMenamin | 6 May 19:30 2006
Picon
Picon

2.6.16 kernel booting on Dreamcast

I can get the 2.6.16 kernel to boot my Dreamcast, but only if I turn DMA
support off. Anybody else had a similar experience on other boards and
any clues as to how to fix:

[4294667.296000] Linux version 2.6.16-sh (adrian <at> bossclass) (gcc version
3.4.2) #7 PREEMPT Sat May 6 18:22:42 BST 2006
[4294667.296000] Built 1 zonelists
[4294667.296000] Kernel command line: console=ttySC1,115200 panic=3
root=/dev/nfs rw
[4294667.296000] PID hash table entries: 128 (order: 7, 2048 bytes)
[4294667.296000] Interval = 12469
[4294667.296000] Using tmu for system timer
[4294667.296000] Linux version 2.6.16-sh (adrian <at> bossclass) (gcc version
3.4.2) #7 PREEMPT Sat May 6 18:22:42 BST 2006
[4294667.296000] Built 1 zonelists
[4294667.296000] Kernel command line: console=ttySC1,115200 panic=3
root=/dev/nfs rw
[4294667.296000] PID hash table entries: 128 (order: 7, 2048 bytes)
[4294667.296000] Interval = 12469
[4294667.296000] Using tmu for system timer
[4294667.296000] Console: colour dummy device 80x25
[4294667.297000] Dentry cache hash table entries: 4096 (order: 2, 16384
bytes)
[4294667.299000] Inode-cache hash table entries: 2048 (order: 1, 8192
bytes)
[4294667.302000] Memory: 13644k/16384k available (2104k kernel code,
2740k reserved, 268k data, 88k init)
[4294667.303000] PVR=040205c1 CVR=00000000 PRR=00000000
[4294667.304000] I-cache : n_ways=1 n_sets=256 way_incr=8192
[4294667.305000] I-cache : entry_mask=0x00001fe0 alias_mask=0x00001000
(Continue reading)


Gmane