Stefano Panella 932e9dec38 ALSA: memalloc.h - fix wrong truncation of dma_addr_t
When running a 32bit kernel the hda_intel driver is still reporting
a 64bit dma_mask if the HW supports it.

From sound/pci/hda/hda_intel.c:

        /* allow 64bit DMA address if supported by H/W */
        if ((gcap & ICH6_GCAP_64OK) && !pci_set_dma_mask(pci, DMA_BIT_MASK(64)))
                pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(64));
        else {
                pci_set_dma_mask(pci, DMA_BIT_MASK(32));
                pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32));
        }

which means when there is a call to dma_alloc_coherent from
snd_malloc_dev_pages a machine address bigger than 32bit can be returned.
This can be true in particular if running  the 32bit kernel as a pv dom0
under the Xen Hypervisor or PAE on bare metal.

The problem is that when calling setup_bdle to program the BLE the
dma_addr_t returned from the dma_alloc_coherent is wrongly truncated
from snd_sgbuf_get_addr if running a 32bit kernel:

static inline dma_addr_t snd_sgbuf_get_addr(struct snd_dma_buffer *dmab,
                                           size_t offset)
{
        struct snd_sg_buf *sgbuf = dmab->private_data;
        dma_addr_t addr = sgbuf->table[offset >> PAGE_SHIFT].addr;
        addr &= PAGE_MASK;
        return addr + offset % PAGE_SIZE;
}

where PAGE_MASK in a 32bit kernel is zeroing the upper 32bit af addr.

Without this patch the HW will fetch the 32bit truncated address,
which is not the one obtained from dma_alloc_coherent and will result
to a non working audio but can corrupt host memory at a random location.

The current patch apply to v3.13-rc3-74-g6c843f5

Signed-off-by: Stefano Panella <stefano.panella@citrix.com>
Reviewed-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-12-10 15:30:46 +01:00
..
2012-10-09 07:07:14 +09:00
2012-10-09 07:07:14 +09:00
2011-08-17 00:53:54 +09:00
2011-05-19 14:10:45 -07:00
2013-08-19 15:48:33 +02:00
2013-02-14 17:27:17 +00:00
2012-09-28 14:21:54 +01:00
2009-02-05 09:17:50 +01:00
2006-03-22 10:24:57 +01:00
2012-01-03 22:54:56 -05:00
2008-11-17 11:45:39 +00:00
2010-10-18 16:46:27 -07:00
2011-02-14 17:10:11 +01:00
2006-01-03 12:18:06 +01:00
2013-06-12 17:46:54 +01:00
2012-12-24 15:57:20 +00:00
2013-05-08 15:43:56 +02:00
2011-09-20 16:02:16 +01:00
2009-12-18 13:06:47 +00:00
2011-08-08 14:30:37 +09:00
2010-04-30 16:12:44 +01:00