diff options
author | Ronny Hegewald <ronny.hegewald@online.de> | 2012-08-31 05:57:52 -0400 |
---|---|---|
committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2012-09-05 10:50:27 -0400 |
commit | b5031ed1be0aa419250557123633453753181643 (patch) | |
tree | a1c23701bda262f1576d2c1a8d3833110c9f0916 | |
parent | ce7184bdbd38d920fb515266fbbdc585ad2e5493 (diff) |
xen: Use correct masking in xen_swiotlb_alloc_coherent.
When running 32-bit pvops-dom0 and a driver tries to allocate a coherent
DMA-memory the xen swiotlb-implementation returned memory beyond 4GB.
The underlaying reason is that if the supplied driver passes in a
DMA_BIT_MASK(64) ( hwdev->coherent_dma_mask is set to 0xffffffffffffffff)
our dma_mask will be u64 set to 0xffffffffffffffff even if we set it to
DMA_BIT_MASK(32) previously. Meaning we do not reset the upper bits.
By using the dma_alloc_coherent_mask function - it does the proper casting
and we get 0xfffffffff.
This caused not working sound on a system with 4 GB and a 64-bit
compatible sound-card with sets the DMA-mask to 64bit.
On bare-metal and the forward-ported xen-dom0 patches from OpenSuse a coherent
DMA-memory is always allocated inside the 32-bit address-range by calling
dma_alloc_coherent_mask.
This patch adds the same functionality to xen swiotlb and is a rebase of the
original patch from Ronny Hegewald which never got upstream b/c the
underlaying reason was not understood until now.
The original email with the original patch is in:
http://old-list-archives.xen.org/archives/html/xen-devel/2010-02/msg00038.html
the original thread from where the discussion started is in:
http://old-list-archives.xen.org/archives/html/xen-devel/2010-01/msg00928.html
Signed-off-by: Ronny Hegewald <ronny.hegewald@online.de>
Signed-off-by: Stefano Panella <stefano.panella@citrix.com>
Acked-By: David Vrabel <david.vrabel@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: stable@vger.kernel.org
-rw-r--r-- | drivers/xen/swiotlb-xen.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c index 1afb4fba11b4..4d519488d304 100644 --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c | |||
@@ -232,7 +232,7 @@ xen_swiotlb_alloc_coherent(struct device *hwdev, size_t size, | |||
232 | return ret; | 232 | return ret; |
233 | 233 | ||
234 | if (hwdev && hwdev->coherent_dma_mask) | 234 | if (hwdev && hwdev->coherent_dma_mask) |
235 | dma_mask = hwdev->coherent_dma_mask; | 235 | dma_mask = dma_alloc_coherent_mask(hwdev, flags); |
236 | 236 | ||
237 | phys = virt_to_phys(ret); | 237 | phys = virt_to_phys(ret); |
238 | dev_addr = xen_phys_to_bus(phys); | 238 | dev_addr = xen_phys_to_bus(phys); |