]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
ALSA: ctxfi: Fallback DMA mask to 32bit
authorTakashi Iwai <tiwai@suse.de>
Tue, 28 Feb 2017 16:16:48 +0000 (17:16 +0100)
committerTim Gardner <tim.gardner@canonical.com>
Mon, 13 Mar 2017 21:20:54 +0000 (15:20 -0600)
BugLink: http://bugs.launchpad.net/bugs/1672544
commit 15c75b09f8d190f89ab4db463b87d411ca349dfe upstream.

Currently ctxfi driver tries to set only the 64bit DMA mask on 64bit
architectures, and bails out if it fails.  This causes a problem on
some platforms since the 64bit DMA isn't always guaranteed.  We should
fall back to the default 32bit DMA when 64bit DMA fails.

Fixes: 6d74b86d3c0f ("ALSA: ctxfi - Allow 64bit DMA")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
sound/pci/ctxfi/cthw20k1.c
sound/pci/ctxfi/cthw20k2.c

index 9667cbfb0ca2b38eae7e76f45f742195631b271e..ab4cdab5cfa57abf3db2a8da806d0bf7031fed67 100644 (file)
 #include "cthw20k1.h"
 #include "ct20k1reg.h"
 
-#if BITS_PER_LONG == 32
-#define CT_XFI_DMA_MASK                DMA_BIT_MASK(32) /* 32 bit PTE */
-#else
-#define CT_XFI_DMA_MASK                DMA_BIT_MASK(64) /* 64 bit PTE */
-#endif
-
 struct hw20k1 {
        struct hw hw;
        spinlock_t reg_20k1_lock;
@@ -1904,19 +1898,18 @@ static int hw_card_start(struct hw *hw)
 {
        int err;
        struct pci_dev *pci = hw->pci;
+       const unsigned int dma_bits = BITS_PER_LONG;
 
        err = pci_enable_device(pci);
        if (err < 0)
                return err;
 
        /* Set DMA transfer mask */
-       if (dma_set_mask(&pci->dev, CT_XFI_DMA_MASK) < 0 ||
-           dma_set_coherent_mask(&pci->dev, CT_XFI_DMA_MASK) < 0) {
-               dev_err(hw->card->dev,
-                       "architecture does not support PCI busmaster DMA with mask 0x%llx\n",
-                       CT_XFI_DMA_MASK);
-               err = -ENXIO;
-               goto error1;
+       if (dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
+               dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
+       } else {
+               dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
+               dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));
        }
 
        if (!hw->io_base) {
index 6414ecf93efaa293683fd065886070a91584b699..18ee7768b7c4021b3d1f9b5a8f748a68521ee938 100644 (file)
 #include "cthw20k2.h"
 #include "ct20k2reg.h"
 
-#if BITS_PER_LONG == 32
-#define CT_XFI_DMA_MASK                DMA_BIT_MASK(32) /* 32 bit PTE */
-#else
-#define CT_XFI_DMA_MASK                DMA_BIT_MASK(64) /* 64 bit PTE */
-#endif
-
 struct hw20k2 {
        struct hw hw;
        /* for i2c */
@@ -2029,19 +2023,18 @@ static int hw_card_start(struct hw *hw)
        int err = 0;
        struct pci_dev *pci = hw->pci;
        unsigned int gctl;
+       const unsigned int dma_bits = BITS_PER_LONG;
 
        err = pci_enable_device(pci);
        if (err < 0)
                return err;
 
        /* Set DMA transfer mask */
-       if (dma_set_mask(&pci->dev, CT_XFI_DMA_MASK) < 0 ||
-           dma_set_coherent_mask(&pci->dev, CT_XFI_DMA_MASK) < 0) {
-               dev_err(hw->card->dev,
-                       "architecture does not support PCI busmaster DMA with mask 0x%llx\n",
-                       CT_XFI_DMA_MASK);
-               err = -ENXIO;
-               goto error1;
+       if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
+               dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
+       } else {
+               dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
+               dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));
        }
 
        if (!hw->io_base) {