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

[-- 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) {


  reply	other threads:[~2004-01-19 18:05 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
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 [this message]
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=s5hhdyru84m.wl@alsa2.suse.de \
    --to=tiwai@suse.de \
    --cc=arjanv@redhat.com \
    --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.