All of lore.kernel.org
 help / color / mirror / Atom feed
* 2.6.1-mm4: ALSA es1968 DMA alloc problem
@ 2004-01-17 16:10 Johannes Stezenbach
  2004-01-19 16:29 ` Takashi Iwai
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Stezenbach @ 2004-01-17 16:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: Takashi Iwai

Hi,

the ALSA driver snd_es1968 for my Terratec DMX (ES1978 Maestro 2E)
fails in 2.6.1-mm4 with the following message:

Jan 16 01:59:15 abc vmunix: PCI: Found IRQ 10 for device 0000:00:0e.0
Jan 16 01:59:15 abc vmunix: es1968: not attempting power management.
Jan 16 01:59:16 abc vmunix: es1968: DMA buffer beyond 256MB.
Jan 16 01:59:16 abc vmunix: ES1968 (ESS Maestro): probe of 0000:00:0e.0 failed with error -12

The seems to be caused by the following change:

--- linux-2.6.1/sound/pci/es1968.c      2003-09-27 18:57:48.000000000 -0700
+++ 25/sound/pci/es1968.c       2004-01-15 22:25:44.000000000 -0800
@@ -2538,7 +2567,7 @@ static int __devinit snd_es1968_create(s
                snd_printk("architecture does not support 28bit PCI busmaster DMA\n");
                return -ENXIO;
        }
-       pci_set_dma_mask(pci, 0x0fffffff);
+       pci_set_consistent_dma_mask(pci, 0x0fffffff);
 
        chip = (es1968_t *) snd_magic_kcalloc(es1968_t, 0, GFP_KERNEL);
        if (! chip)

I don't fully understand Documentation/DMA-mapping.txt, and
Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
says to use pci_set_consistent_dma_mask(). I decided to call
both pci_set_dma_mask() and pci_set_consistent_dma_mask(), and
then the driver works again.

Regards,
Johannes

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

* Re: 2.6.1-mm4: ALSA es1968 DMA alloc problem
  2004-01-17 16:10 2.6.1-mm4: ALSA es1968 DMA alloc problem Johannes Stezenbach
@ 2004-01-19 16:29 ` Takashi Iwai
  2004-01-19 16:43   ` Arjan van de Ven
  2004-01-19 17:05   ` Arjan van de Ven
  0 siblings, 2 replies; 8+ messages in thread
From: Takashi Iwai @ 2004-01-19 16:29 UTC (permalink / raw)
  To: Johannes Stezenbach; +Cc: linux-kernel

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

At Sat, 17 Jan 2004 17:10:13 +0100,
Johannes Stezenbach wrote:
> 
> Hi,
> 
> the ALSA driver snd_es1968 for my Terratec DMX (ES1978 Maestro 2E)
> fails in 2.6.1-mm4 with the following message:
> 
> Jan 16 01:59:15 abc vmunix: PCI: Found IRQ 10 for device 0000:00:0e.0
> Jan 16 01:59:15 abc vmunix: es1968: not attempting power management.
> Jan 16 01:59:16 abc vmunix: es1968: DMA buffer beyond 256MB.
> Jan 16 01:59:16 abc vmunix: ES1968 (ESS Maestro): probe of 0000:00:0e.0 failed with error -12
(snip)
> I don't fully understand Documentation/DMA-mapping.txt, and
> Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
> says to use pci_set_consistent_dma_mask(). I decided to call
> both pci_set_dma_mask() and pci_set_consistent_dma_mask(), and
> then the driver works again.

it looks like calling pci_set_consistent_dma_mask() isn't enough for
i386...  could you try the attached patch?


--
Takashi Iwai <tiwai@suse.de>		ALSA Developer - www.alsa-project.org

[-- Attachment #2: Type: text/plain, Size: 8225 bytes --]

Fix the DMA allocation for i386 arch and clean up.
Replaced pci_dma_supported() with  pci_set_dma_mask() (together
with pci_set_consistent_dma_mask()) for avoid double checks.

diff -u -r1.19 writing-an-alsa-driver.tmpl
--- linux/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl	2 Jan 2004 13:39:33 -0000	1.19
+++ linux/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl	19 Jan 2004 11:53:24 -0000
@@ -1291,7 +1291,7 @@
           // check PCI availability (28bit DMA)
           if ((err = pci_enable_device(pci)) < 0)
                   return err;
-          if (!pci_dma_supported(pci, 0x0fffffff)) {
+          if (pci_set_dma_mask(pci, 0x0fffffff)) {
                   printk(KERN_ERR "error to set 28bit mask DMA\n");
                   return -ENXIO;
           }
@@ -1409,7 +1409,7 @@
 <![CDATA[
   if ((err = pci_enable_device(pci)) < 0)
           return err;
-  if (!pci_dma_supported(pci, 0x0fffffff)) {
+  if (pci_set_dma_mask(pci, 0x0fffffff)) {
           printk(KERN_ERR "error to set 28bit mask DMA\n");
           return -ENXIO;
   }
diff -u -r1.20 memalloc.c
--- linux/sound/core/memalloc.c	15 Jan 2004 16:17:36 -0000	1.20
+++ linux/sound/core/memalloc.c	19 Jan 2004 11:52:21 -0000
@@ -94,16 +94,19 @@
 				    dma_addr_t *dma_handle)
 {
 	void *ret;
-	u64 dma_mask;
+	u64 dma_mask, cdma_mask;
 	unsigned long mask;
 
 	if (hwdev == NULL)
 		return pci_alloc_consistent(hwdev, size, dma_handle);
-	dma_mask = hwdev->consistent_dma_mask;
-	mask = (unsigned long)dma_mask;
+	dma_mask = hwdev->dma_mask;
+	cdma_mask = hwdev->consistent_dma_mask;
+	mask = (unsigned long)dma_mask && (unsigned long)cdma_mask;
+	hwdev->dma_mask = 0xffffffff; /* do without masking */
 	hwdev->consistent_dma_mask = 0xffffffff; /* do without masking */
 	ret = pci_alloc_consistent(hwdev, size, dma_handle);
-	hwdev->consistent_dma_mask = dma_mask; /* restore */
+	hwdev->dma_mask = dma_mask; /* restore */
+	hwdev->consistent_dma_mask = cdma_mask; /* restore */
 	if (ret) {
 		/* obtained address is out of range? */
 		if (((unsigned long)*dma_handle + size - 1) & ~mask) {
@@ -841,10 +844,11 @@
 			continue;
 		}
 			
-		if (pci_set_consistent_dma_mask(pci, dev->dma_mask) < 0) {
+		if (pci_set_dma_mask(pci, dev->dma_mask) < 0) {
 			printk(KERN_ERR "snd-page-alloc: cannot set DMA mask %lx for pci %04x:%04x\n", dev->dma_mask, dev->vendor, dev->device);
 			continue;
 		}
+		pci_set_consistent_dma_mask(pci, dev->dma_mask);
 		for (i = 0; i < dev->buffers; i++) {
 			struct snd_mem_list *mem;
 			mem = kmalloc(sizeof(*mem), GFP_KERNEL);
diff -u -r1.22 als4000.c
--- linux/sound/pci/als4000.c	20 Nov 2003 12:03:01 -0000	1.22
+++ linux/sound/pci/als4000.c	19 Jan 2004 11:47:21 -0000
@@ -621,7 +621,7 @@
 		return err;
 	}
 	/* check, if we can restrict PCI DMA transfers to 24 bits */
-	if (!pci_dma_supported(pci, 0x00ffffff)) {
+	if (pci_set_dma_mask(pci, 0x00ffffff)) {
 		snd_printk("architecture does not support 24bit PCI busmaster DMA\n");
 		return -ENXIO;
 	}
diff -u -r1.8 azt3328.c
--- linux/sound/pci/azt3328.c	20 Nov 2003 12:03:01 -0000	1.8
+++ linux/sound/pci/azt3328.c	19 Jan 2004 11:50:01 -0000
@@ -1361,7 +1361,7 @@
 	chip->irq = -1;
 
 	/* check if we can restrict PCI DMA transfers to 24 bits */
-	if (!pci_dma_supported(pci, 0x00ffffff)) {
+	if (pci_set_dma_mask(pci, 0x00ffffff)) {
 		snd_printk("architecture does not support 24bit PCI busmaster DMA\n");
 		return -ENXIO;
 	}
diff -u -r1.26 es1938.c
--- linux/sound/pci/es1938.c	20 Nov 2003 12:03:01 -0000	1.26
+++ linux/sound/pci/es1938.c	19 Jan 2004 11:48:22 -0000
@@ -1398,7 +1398,7 @@
 	if ((err = pci_enable_device(pci)) < 0)
 		return err;
         /* check, if we can restrict PCI DMA transfers to 24 bits */
-        if (!pci_dma_supported(pci, 0x00ffffff)) {
+	if (pci_set_dma_mask(pci, 0x00ffffff)) {
                 snd_printk("architecture does not support 24bit PCI busmaster DMA\n");
                 return -ENXIO;
         }
diff -u -r1.52 es1968.c
--- linux/sound/pci/es1968.c	20 Nov 2003 12:03:01 -0000	1.52
+++ linux/sound/pci/es1968.c	19 Jan 2004 11:48:29 -0000
@@ -2563,7 +2563,7 @@
 	if ((err = pci_enable_device(pci)) < 0)
 		return err;
 	/* check, if we can restrict PCI DMA transfers to 28 bits */
-	if (!pci_dma_supported(pci, 0x0fffffff)) {
+	if (pci_set_dma_mask(pci, 0x0fffffff)) {
 		snd_printk("architecture does not support 28bit PCI busmaster DMA\n");
 		return -ENXIO;
 	}
diff -u -r1.46 maestro3.c
--- linux/sound/pci/maestro3.c	20 Nov 2003 12:03:01 -0000	1.46
+++ linux/sound/pci/maestro3.c	19 Jan 2004 11:49:08 -0000
@@ -2547,7 +2547,7 @@
 		return -EIO;
 
 	/* check, if we can restrict PCI DMA transfers to 28 bits */
-	if (!pci_dma_supported(pci, 0x0fffffff)) {
+	if (pci_set_dma_mask(pci, 0x0fffffff)) {
 		snd_printk("architecture does not support 28bit PCI busmaster DMA\n");
 		return -ENXIO;
 	}
diff -u -r1.25 sonicvibes.c
--- linux/sound/pci/sonicvibes.c	20 Nov 2003 12:03:01 -0000	1.25
+++ linux/sound/pci/sonicvibes.c	19 Jan 2004 11:49:24 -0000
@@ -1249,7 +1249,7 @@
 	if ((err = pci_enable_device(pci)) < 0)
 		return err;
 	/* check, if we can restrict PCI DMA transfers to 24 bits */
-        if (!pci_dma_supported(pci, 0x00ffffff)) {
+        if (pci_set_dma_mask(pci, 0x00ffffff)) {
                 snd_printk("architecture does not support 24bit PCI busmaster DMA\n");
                 return -ENXIO;
         }
diff -u -r1.38 ali5451.c
--- linux/sound/pci/ali5451/ali5451.c	20 Nov 2003 12:03:01 -0000	1.38
+++ linux/sound/pci/ali5451/ali5451.c	19 Jan 2004 11:49:16 -0000
@@ -2106,7 +2106,7 @@
 	if ((err = pci_enable_device(pci)) < 0)
 		return err;
 	/* check, if we can restrict PCI DMA transfers to 31 bits */
-	if (!pci_dma_supported(pci, 0x7fffffff)) {
+	if (pci_set_dma_mask(pci, 0x7fffffff)) {
 		snd_printk("architecture does not support 31bit PCI busmaster DMA\n");
 		return -ENXIO;
 	}
diff -u -r1.27 emu10k1_main.c
--- linux/sound/pci/emu10k1/emu10k1_main.c	2 Jan 2004 13:39:33 -0000	1.27
+++ linux/sound/pci/emu10k1/emu10k1_main.c	19 Jan 2004 11:47:55 -0000
@@ -599,11 +599,12 @@
 		return -ENOMEM;
 	/* set the DMA transfer mask */
 	emu->dma_mask = is_audigy ? AUDIGY_DMA_MASK : EMU10K1_DMA_MASK;
-	if (pci_set_consistent_dma_mask(pci, emu->dma_mask) < 0) {
+	if (pci_set_dma_mask(pci, emu->dma_mask)) {
 		snd_printk(KERN_ERR "architecture does not support PCI busmaster DMA with mask 0x%lx\n", emu->dma_mask);
 		snd_magic_kfree(emu);
 		return -ENXIO;
 	}
+	pci_set_consistent_dma_mask(pci, emu->dma_mask);
 	emu->card = card;
 	spin_lock_init(&emu->reg_lock);
 	spin_lock_init(&emu->emu_lock);
diff -u -r1.26 ice1712.c
--- linux/sound/pci/ice1712/ice1712.c	2 Jan 2004 13:39:34 -0000	1.26
+++ linux/sound/pci/ice1712/ice1712.c	19 Jan 2004 11:49:30 -0000
@@ -2363,7 +2363,7 @@
 	if ((err = pci_enable_device(pci)) < 0)
 		return err;
 	/* check, if we can restrict PCI DMA transfers to 28 bits */
-	if (!pci_dma_supported(pci, 0x0fffffff)) {
+	if (pci_set_dma_mask(pci, 0x0fffffff)) {
 		snd_printk("architecture does not support 28bit PCI busmaster DMA\n");
 		return -ENXIO;
 	}
diff -u -r1.21 ice1724.c
--- linux/sound/pci/ice1712/ice1724.c	20 Nov 2003 12:03:01 -0000	1.21
+++ linux/sound/pci/ice1712/ice1724.c	19 Jan 2004 11:49:50 -0000
@@ -1801,7 +1801,6 @@
         /* enable PCI device */
 	if ((err = pci_enable_device(pci)) < 0)
 		return err;
-	pci_set_consistent_dma_mask(pci, 0xffffffff); 
 
 	ice = snd_magic_kcalloc(ice1712_t, 0, GFP_KERNEL);
 	if (ice == NULL)
diff -u -r1.43 trident_main.c
--- linux/sound/pci/trident/trident_main.c	20 Nov 2003 12:03:01 -0000	1.43
+++ linux/sound/pci/trident/trident_main.c	19 Jan 2004 11:48:59 -0000
@@ -3523,7 +3523,7 @@
 	if ((err = pci_enable_device(pci)) < 0)
 		return err;
 	/* check, if we can restrict PCI DMA transfers to 30 bits */
-	if (!pci_dma_supported(pci, 0x3fffffff)) {
+	if (pci_set_dma_massk(pci, 0x3fffffff)) {
 		snd_printk("architecture does not support 30bit PCI busmaster DMA\n");
 		return -ENXIO;
 	}
@@ -3952,6 +3952,7 @@
 		return;
 
 	pci_enable_device(trident->pci);
+	pci_set_dma_mask(trident->pci, 0x3fffffff); /* FIXME: correct? */
 	pci_set_consistent_dma_mask(trident->pci, 0x3fffffff); /* FIXME: correct? */
 	pci_set_master(trident->pci); /* to be sure */
 


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

* Re: 2.6.1-mm4: ALSA es1968 DMA alloc problem
  2004-01-19 16:29 ` Takashi Iwai
@ 2004-01-19 16:43   ` Arjan van de Ven
  2004-01-19 16:56     ` Takashi Iwai
  2004-01-19 17:05   ` Arjan van de Ven
  1 sibling, 1 reply; 8+ messages in thread
From: Arjan van de Ven @ 2004-01-19 16:43 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Johannes Stezenbach, linux-kernel

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

On Mon, 2004-01-19 at 17:29, Takashi Iwai wrote:
> At Sat, 17 Jan 2004 17:10:13 +0100,


all throughout the patch:
pci_set_dma_mask() and friends need their return value checked!


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: 2.6.1-mm4: ALSA es1968 DMA alloc problem
  2004-01-19 16:43   ` Arjan van de Ven
@ 2004-01-19 16:56     ` Takashi Iwai
  0 siblings, 0 replies; 8+ messages in thread
From: Takashi Iwai @ 2004-01-19 16:56 UTC (permalink / raw)
  To: arjanv; +Cc: Johannes Stezenbach, linux-kernel

Hi,

At Mon, 19 Jan 2004 17:43:22 +0100,
Arjan van de Ven wrote:
> 
> [1  <text/plain (quoted-printable)>]
> On Mon, 2004-01-19 at 17:29, Takashi Iwai wrote:
> > At Sat, 17 Jan 2004 17:10:13 +0100,
> 
> 
> all throughout the patch:
> pci_set_dma_mask() and friends need their return value checked!

it does check.  the patch replaces the code like

	if (! pci_dma_support(pci, XXXX))
		error;
	pci_set_dma_mask(pci, XXXX);

with
	if (pci_dma_set_mask(pci, XXXX))
		error;

(there is one place which doesn't check, but it's in the resume
 callback.)

the problem is that in the former version only
pci_set_consistent_dma_mask() was called without pci_dma_set_mask().
apparently, this doesn't work properly.


ciao,

Takashi

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

* Re: 2.6.1-mm4: ALSA es1968 DMA alloc problem
  2004-01-19 16:29 ` Takashi Iwai
  2004-01-19 16:43   ` Arjan van de Ven
@ 2004-01-19 17:05   ` Arjan van de Ven
  2004-01-19 17:14     ` Takashi Iwai
  1 sibling, 1 reply; 8+ messages in thread
From: Arjan van de Ven @ 2004-01-19 17:05 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Johannes Stezenbach, linux-kernel

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

On Mon, 2004-01-19 at 17:29, Takashi Iwai wrote:
> --- linux/sound/core/memalloc.c	15 Jan 2004 16:17:36 -0000	1.20
> +++ linux/sound/core/memalloc.c	19 Jan 2004 11:52:21 -0000
> @@ -841,10 +844,11 @@
>  			continue;
>  		}
>  			
> -		if (pci_set_consistent_dma_mask(pci, dev->dma_mask) < 0) {
> +		if (pci_set_dma_mask(pci, dev->dma_mask) < 0) {
>  			printk(KERN_ERR "snd-page-alloc: cannot set DMA mask %lx for pci %04x:%04x\n", dev->dma_mask, dev->vendor, dev->device);
>  			continue;
>  		}
> +		pci_set_consistent_dma_mask(pci, dev->dma_mask);
>  		for (i = 0; i < dev->buffers; i++) {
>  			struct snd_mem_list *mem;
>  			mem = kmalloc(sizeof(*mem), GFP_KERNEL);

unchecked 


> --- linux/sound/pci/emu10k1/emu10k1_main.c	2 Jan 2004 13:39:33 -0000	1.27
> +++ linux/sound/pci/emu10k1/emu10k1_main.c	19 Jan 2004 11:47:55 -0000
> @@ -599,11 +599,12 @@
>  		return -ENOMEM;
>  	/* set the DMA transfer mask */
>  	emu->dma_mask = is_audigy ? AUDIGY_DMA_MASK : EMU10K1_DMA_MASK;
> -	if (pci_set_consistent_dma_mask(pci, emu->dma_mask) < 0) {
> +	if (pci_set_dma_mask(pci, emu->dma_mask)) {
>  		snd_printk(KERN_ERR "architecture does not support PCI busmaster DMA with mask 0x%lx\n", emu->dma_mask);
>  		snd_magic_kfree(emu);
>  		return -ENXIO;
>  	}
> +	pci_set_consistent_dma_mask(pci, emu->dma_mask);
>  	emu->card = card;
>  	spin_lock_init(&emu->reg_lock);
>  	spin_lock_init(&emu->emu_lock);

unchecked
> --- linux/sound/pci/trident/trident_main.c	20 Nov 2003 12:03:01 -0000	1.43
> +++ linux/sound/pci/trident/trident_main.c	19 Jan 2004 11:48:59 -0000
> @@ -3952,6 +3952,7 @@
>  		return;
>  
>  	pci_enable_device(trident->pci);
> +	pci_set_dma_mask(trident->pci, 0x3fffffff); /* FIXME: correct? */
>  	pci_set_consistent_dma_mask(trident->pci, 0x3fffffff); /* FIXME: correct? */
>  	pci_set_master(trident->pci); /* to be sure */
>  

unchecked


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: 2.6.1-mm4: ALSA es1968 DMA alloc problem
  2004-01-19 17:05   ` Arjan van de Ven
@ 2004-01-19 17:14     ` Takashi Iwai
  2004-01-19 18:05       ` Takashi Iwai
  0 siblings, 1 reply; 8+ messages in thread
From: Takashi Iwai @ 2004-01-19 17:14 UTC (permalink / raw)
  To: arjanv; +Cc: Johannes Stezenbach, linux-kernel

At Mon, 19 Jan 2004 18:05:54 +0100,
Arjan van de Ven wrote:
> 
> [1  <text/plain (quoted-printable)>]
> On Mon, 2004-01-19 at 17:29, Takashi Iwai wrote:
> > --- linux/sound/core/memalloc.c	15 Jan 2004 16:17:36 -0000	1.20
> > +++ linux/sound/core/memalloc.c	19 Jan 2004 11:52:21 -0000
> > @@ -841,10 +844,11 @@
> >  			continue;
> >  		}
> >  			
> > -		if (pci_set_consistent_dma_mask(pci, dev->dma_mask) < 0) {
> > +		if (pci_set_dma_mask(pci, dev->dma_mask) < 0) {
> >  			printk(KERN_ERR "snd-page-alloc: cannot set DMA mask %lx for pci %04x:%04x\n", dev->dma_mask, dev->vendor, dev->device);
> >  			continue;
> >  		}
> > +		pci_set_consistent_dma_mask(pci, dev->dma_mask);
> >  		for (i = 0; i < dev->buffers; i++) {
> >  			struct snd_mem_list *mem;
> >  			mem = kmalloc(sizeof(*mem), GFP_KERNEL);
> 
> unchecked 
> 
> 
> > --- linux/sound/pci/emu10k1/emu10k1_main.c	2 Jan 2004 13:39:33 -0000	1.27
> > +++ linux/sound/pci/emu10k1/emu10k1_main.c	19 Jan 2004 11:47:55 -0000
> > @@ -599,11 +599,12 @@
> >  		return -ENOMEM;
> >  	/* set the DMA transfer mask */
> >  	emu->dma_mask = is_audigy ? AUDIGY_DMA_MASK : EMU10K1_DMA_MASK;
> > -	if (pci_set_consistent_dma_mask(pci, emu->dma_mask) < 0) {
> > +	if (pci_set_dma_mask(pci, emu->dma_mask)) {
> >  		snd_printk(KERN_ERR "architecture does not support PCI busmaster DMA with mask 0x%lx\n", emu->dma_mask);
> >  		snd_magic_kfree(emu);
> >  		return -ENXIO;
> >  	}
> > +	pci_set_consistent_dma_mask(pci, emu->dma_mask);
> >  	emu->card = card;
> >  	spin_lock_init(&emu->reg_lock);
> >  	spin_lock_init(&emu->emu_lock);
> 
> unchecked

hmm, can calling pci_set_consistent_dma_mask() after
pci_set_dma_mask() fail?  then we need to fix
Documentation/DMA-mapping.txt, too.


> > --- linux/sound/pci/trident/trident_main.c	20 Nov 2003 12:03:01 -0000	1.43
> > +++ linux/sound/pci/trident/trident_main.c	19 Jan 2004 11:48:59 -0000
> > @@ -3952,6 +3952,7 @@
> >  		return;
> >  
> >  	pci_enable_device(trident->pci);
> > +	pci_set_dma_mask(trident->pci, 0x3fffffff); /* FIXME: correct? */
> >  	pci_set_consistent_dma_mask(trident->pci, 0x3fffffff); /* FIXME: correct? */
> >  	pci_set_master(trident->pci); /* to be sure */
> >  
> 
> unchecked

this one is in the resume callback.


Takashi

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

* Re: 2.6.1-mm4: ALSA es1968 DMA alloc problem
  2004-01-19 17:14     ` Takashi Iwai
@ 2004-01-19 18:05       ` Takashi Iwai
  2004-01-20  1:17         ` Johannes Stezenbach
  0 siblings, 1 reply; 8+ messages in thread
From: Takashi Iwai @ 2004-01-19 18:05 UTC (permalink / raw)
  To: arjanv; +Cc: Johannes Stezenbach, linux-kernel

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

At Mon, 19 Jan 2004 18:14:12 +0100,
I wrote:
> 
> hmm, can calling pci_set_consistent_dma_mask() after
> pci_set_dma_mask() fail?  then we need to fix
> Documentation/DMA-mapping.txt, too.

well, anyway, the attached is one with checks of both returns.


Takashi

[-- Attachment #2: Type: text/plain, Size: 9891 bytes --]

--- linux/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl	2 Jan 2004 13:39:33 -0000	1.19
+++ linux/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl	19 Jan 2004 17:27:35 -0000
@@ -1291,11 +1291,11 @@
           // check PCI availability (28bit DMA)
           if ((err = pci_enable_device(pci)) < 0)
                   return err;
-          if (!pci_dma_supported(pci, 0x0fffffff)) {
+          if (pci_set_dma_mask(pci, 0x0fffffff) < 0 ||
+              pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) {
                   printk(KERN_ERR "error to set 28bit mask DMA\n");
                   return -ENXIO;
           }
-          pci_set_consistent_dma_mask(pci, 0x0fffffff);
 
           chip = snd_magic_kcalloc(mychip_t, 0, GFP_KERNEL);
           if (chip == NULL)
@@ -1409,11 +1409,12 @@
 <![CDATA[
   if ((err = pci_enable_device(pci)) < 0)
           return err;
-  if (!pci_dma_supported(pci, 0x0fffffff)) {
+  if (pci_set_dma_mask(pci, 0x0fffffff) < 0 ||
+      pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) {
           printk(KERN_ERR "error to set 28bit mask DMA\n");
           return -ENXIO;
   }
-  pci_set_consistent_dma_mask(pci, 0x0fffffff);
+  
 ]]>
           </programlisting>
         </informalexample>
--- linux/sound/core/memalloc.c	15 Jan 2004 16:17:36 -0000	1.20
+++ linux/sound/core/memalloc.c	19 Jan 2004 17:24:18 -0000
@@ -94,16 +94,19 @@
 				    dma_addr_t *dma_handle)
 {
 	void *ret;
-	u64 dma_mask;
+	u64 dma_mask, cdma_mask;
 	unsigned long mask;
 
 	if (hwdev == NULL)
 		return pci_alloc_consistent(hwdev, size, dma_handle);
-	dma_mask = hwdev->consistent_dma_mask;
-	mask = (unsigned long)dma_mask;
+	dma_mask = hwdev->dma_mask;
+	cdma_mask = hwdev->consistent_dma_mask;
+	mask = (unsigned long)dma_mask && (unsigned long)cdma_mask;
+	hwdev->dma_mask = 0xffffffff; /* do without masking */
 	hwdev->consistent_dma_mask = 0xffffffff; /* do without masking */
 	ret = pci_alloc_consistent(hwdev, size, dma_handle);
-	hwdev->consistent_dma_mask = dma_mask; /* restore */
+	hwdev->dma_mask = dma_mask; /* restore */
+	hwdev->consistent_dma_mask = cdma_mask; /* restore */
 	if (ret) {
 		/* obtained address is out of range? */
 		if (((unsigned long)*dma_handle + size - 1) & ~mask) {
@@ -841,7 +844,8 @@
 			continue;
 		}
 			
-		if (pci_set_consistent_dma_mask(pci, dev->dma_mask) < 0) {
+		if (pci_set_dma_mask(pci, dev->dma_mask) < 0 ||
+		    pci_set_consistent_dma_mask(pci, dev->dma_mask) < 0) {
 			printk(KERN_ERR "snd-page-alloc: cannot set DMA mask %lx for pci %04x:%04x\n", dev->dma_mask, dev->vendor, dev->device);
 			continue;
 		}
--- linux/sound/pci/als4000.c	20 Nov 2003 12:03:01 -0000	1.22
+++ linux/sound/pci/als4000.c	19 Jan 2004 17:27:51 -0000
@@ -621,11 +621,11 @@
 		return err;
 	}
 	/* check, if we can restrict PCI DMA transfers to 24 bits */
-	if (!pci_dma_supported(pci, 0x00ffffff)) {
+	if (pci_set_dma_mask(pci, 0x00ffffff) < 0 ||
+	    pci_set_consistent_dma_mask(pci, 0x00ffffff) < 0) {
 		snd_printk("architecture does not support 24bit PCI busmaster DMA\n");
 		return -ENXIO;
 	}
-	pci_set_consistent_dma_mask(pci, 0x00ffffff);
 
 	gcr = pci_resource_start(pci, 0);
 	if ((res_gcr_port = request_region(gcr, 0x40, "ALS4000")) == NULL) {
--- linux/sound/pci/azt3328.c	20 Nov 2003 12:03:01 -0000	1.8
+++ linux/sound/pci/azt3328.c	19 Jan 2004 17:29:23 -0000
@@ -1361,11 +1361,11 @@
 	chip->irq = -1;
 
 	/* check if we can restrict PCI DMA transfers to 24 bits */
-	if (!pci_dma_supported(pci, 0x00ffffff)) {
+	if (pci_set_dma_mask(pci, 0x00ffffff) < 0 ||
+	    pci_set_consistent_dma_mask(pci, 0x00ffffff) < 0) {
 		snd_printk("architecture does not support 24bit PCI busmaster DMA\n");
 		return -ENXIO;
 	}
-	pci_set_consistent_dma_mask(pci, 0x00ffffff);
 
 	chip->codec_port = pci_resource_start(pci, 0);
 	if ((chip->res_codec_port = request_region(chip->codec_port, 0x80, "Aztech AZF3328 I/O")) == NULL) {
--- linux/sound/pci/es1938.c	20 Nov 2003 12:03:01 -0000	1.26
+++ linux/sound/pci/es1938.c	19 Jan 2004 17:28:03 -0000
@@ -1398,11 +1398,11 @@
 	if ((err = pci_enable_device(pci)) < 0)
 		return err;
         /* check, if we can restrict PCI DMA transfers to 24 bits */
-        if (!pci_dma_supported(pci, 0x00ffffff)) {
+	if (pci_set_dma_mask(pci, 0x00ffffff) < 0 ||
+	    pci_set_consistent_dma_mask(pci, 0x00ffffff) < 0) {
                 snd_printk("architecture does not support 24bit PCI busmaster DMA\n");
                 return -ENXIO;
         }
-	pci_set_consistent_dma_mask(pci, 0x00ffffff);
 
 	chip = snd_magic_kcalloc(es1938_t, 0, GFP_KERNEL);
 	if (chip == NULL)
--- linux/sound/pci/es1968.c	20 Nov 2003 12:03:01 -0000	1.52
+++ linux/sound/pci/es1968.c	19 Jan 2004 17:28:06 -0000
@@ -2563,11 +2563,11 @@
 	if ((err = pci_enable_device(pci)) < 0)
 		return err;
 	/* check, if we can restrict PCI DMA transfers to 28 bits */
-	if (!pci_dma_supported(pci, 0x0fffffff)) {
+	if (pci_set_dma_mask(pci, 0x0fffffff) < 0 ||
+	    pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) {
 		snd_printk("architecture does not support 28bit PCI busmaster DMA\n");
 		return -ENXIO;
 	}
-	pci_set_consistent_dma_mask(pci, 0x0fffffff);
 
 	chip = (es1968_t *) snd_magic_kcalloc(es1968_t, 0, GFP_KERNEL);
 	if (! chip)
--- linux/sound/pci/maestro3.c	20 Nov 2003 12:03:01 -0000	1.46
+++ linux/sound/pci/maestro3.c	19 Jan 2004 17:29:09 -0000
@@ -2547,11 +2547,11 @@
 		return -EIO;
 
 	/* check, if we can restrict PCI DMA transfers to 28 bits */
-	if (!pci_dma_supported(pci, 0x0fffffff)) {
+	if (pci_set_dma_mask(pci, 0x0fffffff) < 0 ||
+	    pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) {
 		snd_printk("architecture does not support 28bit PCI busmaster DMA\n");
 		return -ENXIO;
 	}
-	pci_set_consistent_dma_mask(pci, 0x0fffffff);
 
 	chip = snd_magic_kcalloc(m3_t, 0, GFP_KERNEL);
 	if (chip == NULL)
--- linux/sound/pci/sonicvibes.c	20 Nov 2003 12:03:01 -0000	1.25
+++ linux/sound/pci/sonicvibes.c	19 Jan 2004 17:29:15 -0000
@@ -1249,11 +1249,11 @@
 	if ((err = pci_enable_device(pci)) < 0)
 		return err;
 	/* check, if we can restrict PCI DMA transfers to 24 bits */
-        if (!pci_dma_supported(pci, 0x00ffffff)) {
+        if (pci_set_dma_mask(pci, 0x00ffffff) < 0 ||
+	    pci_set_consistent_dma_mask(pci, 0x00ffffff) < 0) {
                 snd_printk("architecture does not support 24bit PCI busmaster DMA\n");
                 return -ENXIO;
         }
-	pci_set_consistent_dma_mask(pci, 0x00ffffff);
 
 	sonic = snd_magic_kcalloc(sonicvibes_t, 0, GFP_KERNEL);
 	if (sonic == NULL)
--- linux/sound/pci/ali5451/ali5451.c	20 Nov 2003 12:03:01 -0000	1.38
+++ linux/sound/pci/ali5451/ali5451.c	19 Jan 2004 17:29:12 -0000
@@ -2106,11 +2106,11 @@
 	if ((err = pci_enable_device(pci)) < 0)
 		return err;
 	/* check, if we can restrict PCI DMA transfers to 31 bits */
-	if (!pci_dma_supported(pci, 0x7fffffff)) {
+	if (pci_set_dma_mask(pci, 0x7fffffff) < 0 ||
+	    pci_set_consistent_dma_mask(pci, 0x7fffffff) < 0) {
 		snd_printk("architecture does not support 31bit PCI busmaster DMA\n");
 		return -ENXIO;
 	}
-	pci_set_consistent_dma_mask(pci, 0x7fffffff);
 
 	if ((codec = snd_magic_kcalloc(ali_t, 0, GFP_KERNEL)) == NULL)
 		return -ENOMEM;
--- linux/sound/pci/emu10k1/emu10k1_main.c	2 Jan 2004 13:39:33 -0000	1.27
+++ linux/sound/pci/emu10k1/emu10k1_main.c	19 Jan 2004 17:27:59 -0000
@@ -599,7 +599,8 @@
 		return -ENOMEM;
 	/* set the DMA transfer mask */
 	emu->dma_mask = is_audigy ? AUDIGY_DMA_MASK : EMU10K1_DMA_MASK;
-	if (pci_set_consistent_dma_mask(pci, emu->dma_mask) < 0) {
+	if (pci_set_dma_mask(pci, emu->dma_mask) < 0 ||
+	    pci_set_consistent_dma_mask(pci, emu->dma_mask) < 0) {
 		snd_printk(KERN_ERR "architecture does not support PCI busmaster DMA with mask 0x%lx\n", emu->dma_mask);
 		snd_magic_kfree(emu);
 		return -ENXIO;
--- linux/sound/pci/ice1712/ice1712.c	2 Jan 2004 13:39:34 -0000	1.26
+++ linux/sound/pci/ice1712/ice1712.c	19 Jan 2004 17:29:19 -0000
@@ -2363,11 +2363,11 @@
 	if ((err = pci_enable_device(pci)) < 0)
 		return err;
 	/* check, if we can restrict PCI DMA transfers to 28 bits */
-	if (!pci_dma_supported(pci, 0x0fffffff)) {
+	if (pci_set_dma_mask(pci, 0x0fffffff) < 0 ||
+	    pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) {
 		snd_printk("architecture does not support 28bit PCI busmaster DMA\n");
 		return -ENXIO;
 	}
-	pci_set_consistent_dma_mask(pci, 0x0fffffff);
 
 	ice = snd_magic_kcalloc(ice1712_t, 0, GFP_KERNEL);
 	if (ice == NULL)
--- linux/sound/pci/ice1712/ice1724.c	20 Nov 2003 12:03:01 -0000	1.21
+++ linux/sound/pci/ice1712/ice1724.c	19 Jan 2004 12:08:49 -0000	1.22
@@ -1801,7 +1801,6 @@
         /* enable PCI device */
 	if ((err = pci_enable_device(pci)) < 0)
 		return err;
-	pci_set_consistent_dma_mask(pci, 0xffffffff); 
 
 	ice = snd_magic_kcalloc(ice1712_t, 0, GFP_KERNEL);
 	if (ice == NULL)
--- linux/sound/pci/trident/trident_main.c	20 Nov 2003 12:03:01 -0000	1.43
+++ linux/sound/pci/trident/trident_main.c	19 Jan 2004 17:28:59 -0000
@@ -3523,11 +3523,11 @@
 	if ((err = pci_enable_device(pci)) < 0)
 		return err;
 	/* check, if we can restrict PCI DMA transfers to 30 bits */
-	if (!pci_dma_supported(pci, 0x3fffffff)) {
+	if (pci_set_dma_massk(pci, 0x3fffffff) < 0 ||
+	    pci_set_consistent_dma_mask(pci, 0x3fffffff) < 0) {
 		snd_printk("architecture does not support 30bit PCI busmaster DMA\n");
 		return -ENXIO;
 	}
-	pci_set_consistent_dma_mask(pci, 0x3fffffff);
 	
 	trident = snd_magic_kcalloc(trident_t, 0, GFP_KERNEL);
 	if (trident == NULL)
@@ -3952,7 +3952,9 @@
 		return;
 
 	pci_enable_device(trident->pci);
-	pci_set_consistent_dma_mask(trident->pci, 0x3fffffff); /* FIXME: correct? */
+	if (pci_set_dma_mask(trident->pci, 0x3fffffff) < 0 ||
+	    pci_set_consistent_dma_mask(trident->pci, 0x3fffffff) < 0)
+		snd_printk(KERN_WARNING "trident: can't set the proper DMA mask\n");
 	pci_set_master(trident->pci); /* to be sure */
 
 	switch (trident->device) {


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

* Re: 2.6.1-mm4: ALSA es1968 DMA alloc problem
  2004-01-19 18:05       ` Takashi Iwai
@ 2004-01-20  1:17         ` Johannes Stezenbach
  0 siblings, 0 replies; 8+ messages in thread
From: Johannes Stezenbach @ 2004-01-20  1:17 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: arjanv, linux-kernel

On Mon, Jan 19, 2004 at 07:05:13PM +0100, Takashi Iwai wrote:
> At Mon, 19 Jan 2004 18:14:12 +0100,
> I wrote:
> > 
> > hmm, can calling pci_set_consistent_dma_mask() after
> > pci_set_dma_mask() fail?  then we need to fix
> > Documentation/DMA-mapping.txt, too.
> 
> well, anyway, the attached is one with checks of both returns.

The patch did not apply cleanly because it is against a newer
core/memalloc.c than the one in 2.6.1-mm4 (rev 1.19 vs. 1.20).
I fetched memalloc.c rev1.20 from ALSA CVS and applied the
patch on top of that: My es1968 soundcard works.

(To make sure the whole problem was not just caused by an
out-of-date memalloc.c in 2.6.1-mm4 I also tried just
the updated memalloc.c without your patch, but this did
not cure the "DMA buffer beyond 256MB" problem.)

Johannes

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

end of thread, other threads:[~2004-01-20  1:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-17 16:10 2.6.1-mm4: ALSA es1968 DMA alloc problem Johannes Stezenbach
2004-01-19 16:29 ` Takashi Iwai
2004-01-19 16:43   ` Arjan van de Ven
2004-01-19 16:56     ` Takashi Iwai
2004-01-19 17:05   ` Arjan van de Ven
2004-01-19 17:14     ` Takashi Iwai
2004-01-19 18:05       ` Takashi Iwai
2004-01-20  1:17         ` Johannes Stezenbach

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.