aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/ioat_dma.c
diff options
context:
space:
mode:
authorMaciej Sosnowski <maciej.sosnowski@intel.com>2009-04-23 06:31:51 -0400
committerDan Williams <dan.j.williams@intel.com>2009-05-12 17:41:47 -0400
commit4f005dbe5584fe54c9f6d6d4f0acd3fb29be84da (patch)
treed9a4add9553af6c50fae59a79e9ab217945a7090 /drivers/dma/ioat_dma.c
parentca50a51e890b0a62b44b5642c1ba5049909e5a8b (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/ioat_dma.c')
-rw-r--r--drivers/dma/ioat_dma.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/drivers/dma/ioat_dma.c b/drivers/dma/ioat_dma.c
index e4fc33c1c32f..1955ee8d6d20 100644
--- a/drivers/dma/ioat_dma.c
+++ b/drivers/dma/ioat_dma.c
@@ -1063,22 +1063,31 @@ static void ioat_dma_cleanup_tasklet(unsigned long data)
1063static void 1063static void
1064ioat_dma_unmap(struct ioat_dma_chan *ioat_chan, struct ioat_desc_sw *desc) 1064ioat_dma_unmap(struct ioat_dma_chan *ioat_chan, struct ioat_desc_sw *desc)
1065{ 1065{
1066 /* 1066 if (!(desc->async_tx.flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
1067 * yes we are unmapping both _page and _single 1067 if (desc->async_tx.flags & DMA_COMPL_DEST_UNMAP_SINGLE)
1068 * alloc'd regions with unmap_page. Is this 1068 pci_unmap_single(ioat_chan->device->pdev,
1069 * *really* that bad? 1069 pci_unmap_addr(desc, dst),
1070 */ 1070 pci_unmap_len(desc, len),
1071 if (!(desc->async_tx.flags & DMA_COMPL_SKIP_DEST_UNMAP)) 1071 PCI_DMA_FROMDEVICE);
1072 pci_unmap_page(ioat_chan->device->pdev, 1072 else
1073 pci_unmap_addr(desc, dst), 1073 pci_unmap_page(ioat_chan->device->pdev,
1074 pci_unmap_len(desc, len), 1074 pci_unmap_addr(desc, dst),
1075 PCI_DMA_FROMDEVICE); 1075 pci_unmap_len(desc, len),
1076 1076 PCI_DMA_FROMDEVICE);
1077 if (!(desc->async_tx.flags & DMA_COMPL_SKIP_SRC_UNMAP)) 1077 }
1078 pci_unmap_page(ioat_chan->device->pdev, 1078
1079 pci_unmap_addr(desc, src), 1079 if (!(desc->async_tx.flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
1080 pci_unmap_len(desc, len), 1080 if (desc->async_tx.flags & DMA_COMPL_SRC_UNMAP_SINGLE)
1081 PCI_DMA_TODEVICE); 1081 pci_unmap_single(ioat_chan->device->pdev,
1082 pci_unmap_addr(desc, src),
1083 pci_unmap_len(desc, len),
1084 PCI_DMA_TODEVICE);
1085 else
1086 pci_unmap_page(ioat_chan->device->pdev,
1087 pci_unmap_addr(desc, src),
1088 pci_unmap_len(desc, len),
1089 PCI_DMA_TODEVICE);
1090 }
1082} 1091}
1083 1092
1084/** 1093/**
@@ -1363,6 +1372,7 @@ static int ioat_dma_self_test(struct ioatdma_device *device)
1363 int err = 0; 1372 int err = 0;
1364 struct completion cmp; 1373 struct completion cmp;
1365 unsigned long tmo; 1374 unsigned long tmo;
1375 unsigned long flags;
1366 1376
1367 src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL); 1377 src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL);
1368 if (!src) 1378 if (!src)
@@ -1392,8 +1402,9 @@ static int ioat_dma_self_test(struct ioatdma_device *device)
1392 DMA_TO_DEVICE); 1402 DMA_TO_DEVICE);
1393 dma_dest = dma_map_single(dma_chan->device->dev, dest, IOAT_TEST_SIZE, 1403 dma_dest = dma_map_single(dma_chan->device->dev, dest, IOAT_TEST_SIZE,
1394 DMA_FROM_DEVICE); 1404 DMA_FROM_DEVICE);
1405 flags = DMA_COMPL_SRC_UNMAP_SINGLE | DMA_COMPL_DEST_UNMAP_SINGLE;
1395 tx = device->common.device_prep_dma_memcpy(dma_chan, dma_dest, dma_src, 1406 tx = device->common.device_prep_dma_memcpy(dma_chan, dma_dest, dma_src,
1396 IOAT_TEST_SIZE, 0); 1407 IOAT_TEST_SIZE, flags);
1397 if (!tx) { 1408 if (!tx) {
1398 dev_err(&device->pdev->dev, 1409 dev_err(&device->pdev->dev,
1399 "Self-test prep failed, disabling\n"); 1410 "Self-test prep failed, disabling\n");