diff options
author | Maciej Sosnowski <maciej.sosnowski@intel.com> | 2009-04-23 06:31:51 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2009-05-12 17:41:47 -0400 |
commit | 4f005dbe5584fe54c9f6d6d4f0acd3fb29be84da (patch) | |
tree | d9a4add9553af6c50fae59a79e9ab217945a7090 /drivers/dma/dmaengine.c | |
parent | ca50a51e890b0a62b44b5642c1ba5049909e5a8b (diff) |
ioatdma: fix "ioatdma frees DMA memory with wrong function"
as reported by Alexander Beregalov <a.beregalov@gmail.com>
ioatdma 0000:00:08.0: DMA-API: device driver frees DMA memory with
wrong function [device address=0x000000007f76f800] [size=2000 bytes]
[map
ped as single] [unmapped as page]
The ioatdma driver was unmapping all regions
(either allocated as page or single) using unmap_page.
This patch lets dma driver recognize if unmap_single or unmap_page should be used.
It introduces two new dma control flags:
DMA_COMPL_SRC_UNMAP_SINGLE and DMA_COMPL_DEST_UNMAP_SINGLE.
They should be set to indicate dma driver to do dma-unmapping as single
(first one for the source, tha latter for the destination).
If respective flag is not set, the driver assumes dma-unmapping as page.
Signed-off-by: Maciej Sosnowski <maciej.sosnowski@intel.com>
Reported-by: Alexander Beregalov <a.beregalov@gmail.com>
Tested-by: Alexander Beregalov <a.beregalov@gmail.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/dma/dmaengine.c')
-rw-r--r-- | drivers/dma/dmaengine.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 92438e9dacc3..5a87384ea4ff 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c | |||
@@ -804,11 +804,14 @@ dma_async_memcpy_buf_to_buf(struct dma_chan *chan, void *dest, | |||
804 | dma_addr_t dma_dest, dma_src; | 804 | dma_addr_t dma_dest, dma_src; |
805 | dma_cookie_t cookie; | 805 | dma_cookie_t cookie; |
806 | int cpu; | 806 | int cpu; |
807 | unsigned long flags; | ||
807 | 808 | ||
808 | dma_src = dma_map_single(dev->dev, src, len, DMA_TO_DEVICE); | 809 | dma_src = dma_map_single(dev->dev, src, len, DMA_TO_DEVICE); |
809 | dma_dest = dma_map_single(dev->dev, dest, len, DMA_FROM_DEVICE); | 810 | dma_dest = dma_map_single(dev->dev, dest, len, DMA_FROM_DEVICE); |
810 | tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, | 811 | flags = DMA_CTRL_ACK | |
811 | DMA_CTRL_ACK); | 812 | DMA_COMPL_SRC_UNMAP_SINGLE | |
813 | DMA_COMPL_DEST_UNMAP_SINGLE; | ||
814 | tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, flags); | ||
812 | 815 | ||
813 | if (!tx) { | 816 | if (!tx) { |
814 | dma_unmap_single(dev->dev, dma_src, len, DMA_TO_DEVICE); | 817 | dma_unmap_single(dev->dev, dma_src, len, DMA_TO_DEVICE); |
@@ -850,11 +853,12 @@ dma_async_memcpy_buf_to_pg(struct dma_chan *chan, struct page *page, | |||
850 | dma_addr_t dma_dest, dma_src; | 853 | dma_addr_t dma_dest, dma_src; |
851 | dma_cookie_t cookie; | 854 | dma_cookie_t cookie; |
852 | int cpu; | 855 | int cpu; |
856 | unsigned long flags; | ||
853 | 857 | ||
854 | dma_src = dma_map_single(dev->dev, kdata, len, DMA_TO_DEVICE); | 858 | dma_src = dma_map_single(dev->dev, kdata, len, DMA_TO_DEVICE); |
855 | dma_dest = dma_map_page(dev->dev, page, offset, len, DMA_FROM_DEVICE); | 859 | dma_dest = dma_map_page(dev->dev, page, offset, len, DMA_FROM_DEVICE); |
856 | tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, | 860 | flags = DMA_CTRL_ACK | DMA_COMPL_SRC_UNMAP_SINGLE; |
857 | DMA_CTRL_ACK); | 861 | tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, flags); |
858 | 862 | ||
859 | if (!tx) { | 863 | if (!tx) { |
860 | dma_unmap_single(dev->dev, dma_src, len, DMA_TO_DEVICE); | 864 | dma_unmap_single(dev->dev, dma_src, len, DMA_TO_DEVICE); |
@@ -898,12 +902,13 @@ dma_async_memcpy_pg_to_pg(struct dma_chan *chan, struct page *dest_pg, | |||
898 | dma_addr_t dma_dest, dma_src; | 902 | dma_addr_t dma_dest, dma_src; |
899 | dma_cookie_t cookie; | 903 | dma_cookie_t cookie; |
900 | int cpu; | 904 | int cpu; |
905 | unsigned long flags; | ||
901 | 906 | ||
902 | dma_src = dma_map_page(dev->dev, src_pg, src_off, len, DMA_TO_DEVICE); | 907 | dma_src = dma_map_page(dev->dev, src_pg, src_off, len, DMA_TO_DEVICE); |
903 | dma_dest = dma_map_page(dev->dev, dest_pg, dest_off, len, | 908 | dma_dest = dma_map_page(dev->dev, dest_pg, dest_off, len, |
904 | DMA_FROM_DEVICE); | 909 | DMA_FROM_DEVICE); |
905 | tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, | 910 | flags = DMA_CTRL_ACK; |
906 | DMA_CTRL_ACK); | 911 | tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, flags); |
907 | 912 | ||
908 | if (!tx) { | 913 | if (!tx) { |
909 | dma_unmap_page(dev->dev, dma_src, len, DMA_TO_DEVICE); | 914 | dma_unmap_page(dev->dev, dma_src, len, DMA_TO_DEVICE); |