diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c index 7bd8d44..d0311c1 100644 --- a/drivers/dma/ioat/dma.c +++ b/drivers/dma/ioat/dma.c @@ -271,14 +271,14 @@ static dma_cookie_t ioat1_tx_submit(struct dma_async_tx_descriptor *tx) static struct ioat_desc_sw * ioat_dma_alloc_descriptor(struct ioat_dma_chan *ioat, gfp_t flags) { + struct ioatdma_device *ioatdma_device = ioat->base.device; struct ioat_dma_descriptor *desc; struct ioat_desc_sw *desc_sw; - struct ioatdma_device *ioatdma_device; + struct pci_dev *pdev = ioatdma_device->pdev; dma_addr_t phys; - ioatdma_device = ioat->base.device; desc = pci_pool_alloc(ioatdma_device->dma_pool, flags, &phys); - if (unlikely(!desc)) + if (unlikely(!desc || pci_dma_mapping_error(pdev, phys))) return NULL; desc_sw = kzalloc(sizeof(*desc_sw), flags); @@ -329,6 +329,13 @@ static int ioat1_dma_alloc_chan_resources(struct dma_chan *c) writel(chanerr, chan->reg_base + IOAT_CHANERR_OFFSET); } + /* allocate a completion writeback area */ + chan->completion = pci_pool_alloc(chan->device->completion_pool, + GFP_KERNEL, &chan->completion_dma); + if (pci_dma_mapping_error(chan->device->pdev, chan->completion_dma)) + return -EAGAIN; + memset(chan->completion, 0, sizeof(*chan->completion)); + /* Allocate descriptors */ for (i = 0; i < ioat_initial_desc_count; i++) { desc = ioat_dma_alloc_descriptor(ioat, GFP_KERNEL); @@ -344,11 +351,7 @@ static int ioat1_dma_alloc_chan_resources(struct dma_chan *c) list_splice(&tmp_list, &ioat->free_desc); spin_unlock_bh(&ioat->desc_lock); - /* allocate a completion writeback area */ /* doing 2 32bit writes to mmio since 1 64b write doesn't work */ - chan->completion = pci_pool_alloc(chan->device->completion_pool, - GFP_KERNEL, &chan->completion_dma); - memset(chan->completion, 0, sizeof(*chan->completion)); writel(((u64) chan->completion_dma) & 0x00000000FFFFFFFF, chan->reg_base + IOAT_CHANCMP_OFFSET_LOW); writel(((u64) chan->completion_dma) >> 32,