All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Johannes Stezenbach <js@convergence.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: 2.6.1-mm4: ALSA es1968 DMA alloc problem
Date: Mon, 19 Jan 2004 17:29:52 +0100	[thread overview]
Message-ID: <s5hwu7n6gvz.wl@alsa2.suse.de> (raw)
In-Reply-To: <20040117161013.GA3303@convergence.de>

[-- 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 */
 


  reply	other threads:[~2004-01-19 16:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-17 16:10 2.6.1-mm4: ALSA es1968 DMA alloc problem Johannes Stezenbach
2004-01-19 16:29 ` Takashi Iwai [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hwu7n6gvz.wl@alsa2.suse.de \
    --to=tiwai@suse.de \
    --cc=js@convergence.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.