lkml.org 
[lkml]   [2004]   [Jan]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: 2.6.1-mm4: ALSA es1968 DMA alloc problem
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
--- 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) {
\
 
 \ /
  Last update: 2005-03-22 14:00    [W:0.049 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site