Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 1 | /* |
Shannon Nelson | 43d6e36 | 2007-10-16 01:27:39 -0700 | [diff] [blame] | 2 | * Intel I/OAT DMA Linux driver |
Dave Jiang | 85596a1 | 2015-08-11 08:48:10 -0700 | [diff] [blame^] | 3 | * Copyright(c) 2004 - 2015 Intel Corporation. |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
Shannon Nelson | 43d6e36 | 2007-10-16 01:27:39 -0700 | [diff] [blame] | 6 | * under the terms and conditions of the GNU General Public License, |
| 7 | * version 2, as published by the Free Software Foundation. |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
Shannon Nelson | 43d6e36 | 2007-10-16 01:27:39 -0700 | [diff] [blame] | 14 | * The full GNU General Public License is included in this distribution in |
| 15 | * the file called "COPYING". |
| 16 | * |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 17 | */ |
| 18 | |
| 19 | /* |
| 20 | * This driver supports an Intel I/OAT DMA engine, which does asynchronous |
| 21 | * copy operations. |
| 22 | */ |
| 23 | |
| 24 | #include <linux/init.h> |
| 25 | #include <linux/module.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 26 | #include <linux/slab.h> |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 27 | #include <linux/pci.h> |
| 28 | #include <linux/interrupt.h> |
| 29 | #include <linux/dmaengine.h> |
| 30 | #include <linux/delay.h> |
David S. Miller | 6b00c92 | 2006-05-23 17:37:58 -0700 | [diff] [blame] | 31 | #include <linux/dma-mapping.h> |
Maciej Sosnowski | 09177e8 | 2008-07-22 10:07:33 -0700 | [diff] [blame] | 32 | #include <linux/workqueue.h> |
Paul Gortmaker | 70c7160 | 2011-05-22 16:47:17 -0400 | [diff] [blame] | 33 | #include <linux/prefetch.h> |
Venki Pallipadi | 3ad0b02 | 2008-10-22 16:34:52 -0700 | [diff] [blame] | 34 | #include <linux/i7300_idle.h> |
Dan Williams | 584ec22 | 2009-07-28 14:32:12 -0700 | [diff] [blame] | 35 | #include "dma.h" |
| 36 | #include "registers.h" |
| 37 | #include "hw.h" |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 38 | |
Russell King - ARM Linux | d2ebfb3 | 2012-03-06 22:34:26 +0000 | [diff] [blame] | 39 | #include "../dmaengine.h" |
| 40 | |
Dan Williams | 5cbafa6 | 2009-08-26 13:01:44 -0700 | [diff] [blame] | 41 | int ioat_pending_level = 4; |
Shannon Nelson | 7bb67c1 | 2007-11-14 16:59:51 -0800 | [diff] [blame] | 42 | module_param(ioat_pending_level, int, 0644); |
| 43 | MODULE_PARM_DESC(ioat_pending_level, |
| 44 | "high-water mark for pushing ioat descriptors (default: 4)"); |
| 45 | |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 46 | /** |
| 47 | * ioat_dma_do_interrupt - handler used for single vector interrupt mode |
| 48 | * @irq: interrupt id |
| 49 | * @data: interrupt data |
| 50 | */ |
| 51 | static irqreturn_t ioat_dma_do_interrupt(int irq, void *data) |
| 52 | { |
| 53 | struct ioatdma_device *instance = data; |
Dan Williams | dcbc853 | 2009-07-28 14:44:50 -0700 | [diff] [blame] | 54 | struct ioat_chan_common *chan; |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 55 | unsigned long attnstatus; |
| 56 | int bit; |
| 57 | u8 intrctrl; |
| 58 | |
| 59 | intrctrl = readb(instance->reg_base + IOAT_INTRCTRL_OFFSET); |
| 60 | |
| 61 | if (!(intrctrl & IOAT_INTRCTRL_MASTER_INT_EN)) |
| 62 | return IRQ_NONE; |
| 63 | |
| 64 | if (!(intrctrl & IOAT_INTRCTRL_INT_STATUS)) { |
| 65 | writeb(intrctrl, instance->reg_base + IOAT_INTRCTRL_OFFSET); |
| 66 | return IRQ_NONE; |
| 67 | } |
| 68 | |
| 69 | attnstatus = readl(instance->reg_base + IOAT_ATTNSTATUS_OFFSET); |
Akinobu Mita | 984b3f5 | 2010-03-05 13:41:37 -0800 | [diff] [blame] | 70 | for_each_set_bit(bit, &attnstatus, BITS_PER_LONG) { |
Dan Williams | dcbc853 | 2009-07-28 14:44:50 -0700 | [diff] [blame] | 71 | chan = ioat_chan_by_index(instance, bit); |
Dan Williams | da87ca4 | 2014-02-19 16:19:35 -0800 | [diff] [blame] | 72 | if (test_bit(IOAT_RUN, &chan->state)) |
| 73 | tasklet_schedule(&chan->cleanup_task); |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | writeb(intrctrl, instance->reg_base + IOAT_INTRCTRL_OFFSET); |
| 77 | return IRQ_HANDLED; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * ioat_dma_do_interrupt_msix - handler used for vector-per-channel interrupt mode |
| 82 | * @irq: interrupt id |
| 83 | * @data: interrupt data |
| 84 | */ |
| 85 | static irqreturn_t ioat_dma_do_interrupt_msix(int irq, void *data) |
| 86 | { |
Dan Williams | dcbc853 | 2009-07-28 14:44:50 -0700 | [diff] [blame] | 87 | struct ioat_chan_common *chan = data; |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 88 | |
Dan Williams | da87ca4 | 2014-02-19 16:19:35 -0800 | [diff] [blame] | 89 | if (test_bit(IOAT_RUN, &chan->state)) |
| 90 | tasklet_schedule(&chan->cleanup_task); |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 91 | |
| 92 | return IRQ_HANDLED; |
| 93 | } |
| 94 | |
Dan Williams | 5cbafa6 | 2009-08-26 13:01:44 -0700 | [diff] [blame] | 95 | /* common channel initialization */ |
Dan Williams | aa4d72a | 2010-03-03 21:21:13 -0700 | [diff] [blame] | 96 | void ioat_init_channel(struct ioatdma_device *device, struct ioat_chan_common *chan, int idx) |
Dan Williams | 5cbafa6 | 2009-08-26 13:01:44 -0700 | [diff] [blame] | 97 | { |
| 98 | struct dma_device *dma = &device->common; |
Dan Williams | aa4d72a | 2010-03-03 21:21:13 -0700 | [diff] [blame] | 99 | struct dma_chan *c = &chan->common; |
| 100 | unsigned long data = (unsigned long) c; |
Dan Williams | 5cbafa6 | 2009-08-26 13:01:44 -0700 | [diff] [blame] | 101 | |
| 102 | chan->device = device; |
| 103 | chan->reg_base = device->reg_base + (0x80 * (idx + 1)); |
Dan Williams | 5cbafa6 | 2009-08-26 13:01:44 -0700 | [diff] [blame] | 104 | spin_lock_init(&chan->cleanup_lock); |
| 105 | chan->common.device = dma; |
Russell King - ARM Linux | 8ac6954 | 2012-03-06 22:36:27 +0000 | [diff] [blame] | 106 | dma_cookie_init(&chan->common); |
Dan Williams | 5cbafa6 | 2009-08-26 13:01:44 -0700 | [diff] [blame] | 107 | list_add_tail(&chan->common.device_node, &dma->channels); |
| 108 | device->idx[idx] = chan; |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 109 | init_timer(&chan->timer); |
Dan Williams | aa4d72a | 2010-03-03 21:21:13 -0700 | [diff] [blame] | 110 | chan->timer.function = device->timer_fn; |
| 111 | chan->timer.data = data; |
| 112 | tasklet_init(&chan->cleanup_task, device->cleanup_fn, data); |
Dan Williams | 5cbafa6 | 2009-08-26 13:01:44 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Dan Williams | da87ca4 | 2014-02-19 16:19:35 -0800 | [diff] [blame] | 115 | void ioat_stop(struct ioat_chan_common *chan) |
| 116 | { |
| 117 | struct ioatdma_device *device = chan->device; |
| 118 | struct pci_dev *pdev = device->pdev; |
| 119 | int chan_id = chan_num(chan); |
| 120 | struct msix_entry *msix; |
| 121 | |
| 122 | /* 1/ stop irq from firing tasklets |
| 123 | * 2/ stop the tasklet from re-arming irqs |
| 124 | */ |
| 125 | clear_bit(IOAT_RUN, &chan->state); |
| 126 | |
| 127 | /* flush inflight interrupts */ |
| 128 | switch (device->irq_mode) { |
| 129 | case IOAT_MSIX: |
| 130 | msix = &device->msix_entries[chan_id]; |
| 131 | synchronize_irq(msix->vector); |
| 132 | break; |
| 133 | case IOAT_MSI: |
| 134 | case IOAT_INTX: |
| 135 | synchronize_irq(pdev->irq); |
| 136 | break; |
| 137 | default: |
| 138 | break; |
| 139 | } |
| 140 | |
| 141 | /* flush inflight timers */ |
| 142 | del_timer_sync(&chan->timer); |
| 143 | |
| 144 | /* flush inflight tasklet runs */ |
| 145 | tasklet_kill(&chan->cleanup_task); |
| 146 | |
| 147 | /* final cleanup now that everything is quiesced and can't re-arm */ |
| 148 | device->cleanup_fn((unsigned long) &chan->common); |
| 149 | } |
| 150 | |
Dan Williams | 2750293 | 2012-03-23 13:36:42 -0700 | [diff] [blame] | 151 | dma_addr_t ioat_get_current_completion(struct ioat_chan_common *chan) |
Dan Williams | 5cbafa6 | 2009-08-26 13:01:44 -0700 | [diff] [blame] | 152 | { |
Dan Williams | 2750293 | 2012-03-23 13:36:42 -0700 | [diff] [blame] | 153 | dma_addr_t phys_complete; |
Dan Williams | 4fb9b9e | 2009-09-08 12:01:04 -0700 | [diff] [blame] | 154 | u64 completion; |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 155 | |
Dan Williams | 4fb9b9e | 2009-09-08 12:01:04 -0700 | [diff] [blame] | 156 | completion = *chan->completion; |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 157 | phys_complete = ioat_chansts_to_addr(completion); |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 158 | |
Dan Williams | 6df9183 | 2009-09-08 12:00:55 -0700 | [diff] [blame] | 159 | dev_dbg(to_dev(chan), "%s: phys_complete: %#llx\n", __func__, |
| 160 | (unsigned long long) phys_complete); |
| 161 | |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 162 | if (is_ioat_halted(completion)) { |
| 163 | u32 chanerr = readl(chan->reg_base + IOAT_CHANERR_OFFSET); |
Dan Williams | dcbc853 | 2009-07-28 14:44:50 -0700 | [diff] [blame] | 164 | dev_err(to_dev(chan), "Channel halted, chanerr = %x\n", |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 165 | chanerr); |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 166 | |
| 167 | /* TODO do something to salvage the situation */ |
| 168 | } |
| 169 | |
Dan Williams | 5cbafa6 | 2009-08-26 13:01:44 -0700 | [diff] [blame] | 170 | return phys_complete; |
| 171 | } |
| 172 | |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 173 | bool ioat_cleanup_preamble(struct ioat_chan_common *chan, |
Dan Williams | 2750293 | 2012-03-23 13:36:42 -0700 | [diff] [blame] | 174 | dma_addr_t *phys_complete) |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 175 | { |
| 176 | *phys_complete = ioat_get_current_completion(chan); |
| 177 | if (*phys_complete == chan->last_completion) |
| 178 | return false; |
| 179 | clear_bit(IOAT_COMPLETION_ACK, &chan->state); |
| 180 | mod_timer(&chan->timer, jiffies + COMPLETION_TIMEOUT); |
| 181 | |
| 182 | return true; |
| 183 | } |
| 184 | |
Dan Williams | aa4d72a | 2010-03-03 21:21:13 -0700 | [diff] [blame] | 185 | enum dma_status |
Linus Walleij | 0793448 | 2010-03-26 16:50:49 -0700 | [diff] [blame] | 186 | ioat_dma_tx_status(struct dma_chan *c, dma_cookie_t cookie, |
| 187 | struct dma_tx_state *txstate) |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 188 | { |
Dan Williams | aa4d72a | 2010-03-03 21:21:13 -0700 | [diff] [blame] | 189 | struct ioat_chan_common *chan = to_chan_common(c); |
| 190 | struct ioatdma_device *device = chan->device; |
Russell King - ARM Linux | 96a2af4 | 2012-03-06 22:35:27 +0000 | [diff] [blame] | 191 | enum dma_status ret; |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 192 | |
Russell King - ARM Linux | 96a2af4 | 2012-03-06 22:35:27 +0000 | [diff] [blame] | 193 | ret = dma_cookie_status(c, cookie, txstate); |
Vinod Koul | 2f16f80 | 2013-10-16 20:48:52 +0530 | [diff] [blame] | 194 | if (ret == DMA_COMPLETE) |
Russell King - ARM Linux | 96a2af4 | 2012-03-06 22:35:27 +0000 | [diff] [blame] | 195 | return ret; |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 196 | |
Dan Williams | aa4d72a | 2010-03-03 21:21:13 -0700 | [diff] [blame] | 197 | device->cleanup_fn((unsigned long) c); |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 198 | |
Russell King - ARM Linux | 96a2af4 | 2012-03-06 22:35:27 +0000 | [diff] [blame] | 199 | return dma_cookie_status(c, cookie, txstate); |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 200 | } |
| 201 | |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 202 | /* |
| 203 | * Perform a IOAT transaction to verify the HW works. |
| 204 | */ |
| 205 | #define IOAT_TEST_SIZE 2000 |
| 206 | |
Greg Kroah-Hartman | 4bf27b8 | 2012-12-21 15:09:59 -0800 | [diff] [blame] | 207 | static void ioat_dma_test_callback(void *dma_async_param) |
Shannon Nelson | 9521843 | 2007-10-18 03:07:15 -0700 | [diff] [blame] | 208 | { |
Dan Williams | b9bdcbb | 2009-01-06 11:38:22 -0700 | [diff] [blame] | 209 | struct completion *cmp = dma_async_param; |
| 210 | |
| 211 | complete(cmp); |
Shannon Nelson | 9521843 | 2007-10-18 03:07:15 -0700 | [diff] [blame] | 212 | } |
| 213 | |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 214 | /** |
| 215 | * ioat_dma_self_test - Perform a IOAT transaction to verify the HW works. |
| 216 | * @device: device to be tested |
| 217 | */ |
Greg Kroah-Hartman | 4bf27b8 | 2012-12-21 15:09:59 -0800 | [diff] [blame] | 218 | int ioat_dma_self_test(struct ioatdma_device *device) |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 219 | { |
| 220 | int i; |
| 221 | u8 *src; |
| 222 | u8 *dest; |
Dan Williams | bc3c702 | 2009-07-28 14:33:42 -0700 | [diff] [blame] | 223 | struct dma_device *dma = &device->common; |
| 224 | struct device *dev = &device->pdev->dev; |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 225 | struct dma_chan *dma_chan; |
Shannon Nelson | 711924b | 2007-12-17 16:20:08 -0800 | [diff] [blame] | 226 | struct dma_async_tx_descriptor *tx; |
Dan Williams | 0036731 | 2008-02-02 19:49:57 -0700 | [diff] [blame] | 227 | dma_addr_t dma_dest, dma_src; |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 228 | dma_cookie_t cookie; |
| 229 | int err = 0; |
Dan Williams | b9bdcbb | 2009-01-06 11:38:22 -0700 | [diff] [blame] | 230 | struct completion cmp; |
Dan Williams | 0c33e1c | 2009-03-02 13:31:35 -0700 | [diff] [blame] | 231 | unsigned long tmo; |
Maciej Sosnowski | 4f005db | 2009-04-23 12:31:51 +0200 | [diff] [blame] | 232 | unsigned long flags; |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 233 | |
Christoph Lameter | e94b176 | 2006-12-06 20:33:17 -0800 | [diff] [blame] | 234 | src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL); |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 235 | if (!src) |
| 236 | return -ENOMEM; |
Christoph Lameter | e94b176 | 2006-12-06 20:33:17 -0800 | [diff] [blame] | 237 | dest = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL); |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 238 | if (!dest) { |
| 239 | kfree(src); |
| 240 | return -ENOMEM; |
| 241 | } |
| 242 | |
| 243 | /* Fill in src buffer */ |
| 244 | for (i = 0; i < IOAT_TEST_SIZE; i++) |
| 245 | src[i] = (u8)i; |
| 246 | |
| 247 | /* Start copy, using first DMA channel */ |
Dan Williams | bc3c702 | 2009-07-28 14:33:42 -0700 | [diff] [blame] | 248 | dma_chan = container_of(dma->channels.next, struct dma_chan, |
Shannon Nelson | 43d6e36 | 2007-10-16 01:27:39 -0700 | [diff] [blame] | 249 | device_node); |
Dan Williams | bc3c702 | 2009-07-28 14:33:42 -0700 | [diff] [blame] | 250 | if (dma->device_alloc_chan_resources(dma_chan) < 1) { |
| 251 | dev_err(dev, "selftest cannot allocate chan resource\n"); |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 252 | err = -ENODEV; |
| 253 | goto out; |
| 254 | } |
| 255 | |
Dan Williams | bc3c702 | 2009-07-28 14:33:42 -0700 | [diff] [blame] | 256 | dma_src = dma_map_single(dev, src, IOAT_TEST_SIZE, DMA_TO_DEVICE); |
Jiang Liu | 3532e56 | 2014-01-02 12:58:52 -0800 | [diff] [blame] | 257 | if (dma_mapping_error(dev, dma_src)) { |
| 258 | dev_err(dev, "mapping src buffer failed\n"); |
| 259 | goto free_resources; |
| 260 | } |
Dan Williams | bc3c702 | 2009-07-28 14:33:42 -0700 | [diff] [blame] | 261 | dma_dest = dma_map_single(dev, dest, IOAT_TEST_SIZE, DMA_FROM_DEVICE); |
Jiang Liu | 3532e56 | 2014-01-02 12:58:52 -0800 | [diff] [blame] | 262 | if (dma_mapping_error(dev, dma_dest)) { |
| 263 | dev_err(dev, "mapping dest buffer failed\n"); |
| 264 | goto unmap_src; |
| 265 | } |
Bartlomiej Zolnierkiewicz | 0776ae7 | 2013-10-18 19:35:33 +0200 | [diff] [blame] | 266 | flags = DMA_PREP_INTERRUPT; |
Dan Williams | 0036731 | 2008-02-02 19:49:57 -0700 | [diff] [blame] | 267 | tx = device->common.device_prep_dma_memcpy(dma_chan, dma_dest, dma_src, |
Maciej Sosnowski | 4f005db | 2009-04-23 12:31:51 +0200 | [diff] [blame] | 268 | IOAT_TEST_SIZE, flags); |
Shannon Nelson | 5149fd0 | 2007-10-18 03:07:13 -0700 | [diff] [blame] | 269 | if (!tx) { |
Dan Williams | bc3c702 | 2009-07-28 14:33:42 -0700 | [diff] [blame] | 270 | dev_err(dev, "Self-test prep failed, disabling\n"); |
Shannon Nelson | 5149fd0 | 2007-10-18 03:07:13 -0700 | [diff] [blame] | 271 | err = -ENODEV; |
Bartlomiej Zolnierkiewicz | 522d974 | 2012-11-05 10:00:13 +0000 | [diff] [blame] | 272 | goto unmap_dma; |
Shannon Nelson | 5149fd0 | 2007-10-18 03:07:13 -0700 | [diff] [blame] | 273 | } |
| 274 | |
Dan Williams | 7405f74 | 2007-01-02 11:10:43 -0700 | [diff] [blame] | 275 | async_tx_ack(tx); |
Dan Williams | b9bdcbb | 2009-01-06 11:38:22 -0700 | [diff] [blame] | 276 | init_completion(&cmp); |
Shannon Nelson | 9521843 | 2007-10-18 03:07:15 -0700 | [diff] [blame] | 277 | tx->callback = ioat_dma_test_callback; |
Dan Williams | b9bdcbb | 2009-01-06 11:38:22 -0700 | [diff] [blame] | 278 | tx->callback_param = &cmp; |
Shannon Nelson | 7bb67c1 | 2007-11-14 16:59:51 -0800 | [diff] [blame] | 279 | cookie = tx->tx_submit(tx); |
Shannon Nelson | 7f2b291 | 2007-10-18 03:07:14 -0700 | [diff] [blame] | 280 | if (cookie < 0) { |
Dan Williams | bc3c702 | 2009-07-28 14:33:42 -0700 | [diff] [blame] | 281 | dev_err(dev, "Self-test setup failed, disabling\n"); |
Shannon Nelson | 7f2b291 | 2007-10-18 03:07:14 -0700 | [diff] [blame] | 282 | err = -ENODEV; |
Bartlomiej Zolnierkiewicz | 522d974 | 2012-11-05 10:00:13 +0000 | [diff] [blame] | 283 | goto unmap_dma; |
Shannon Nelson | 7f2b291 | 2007-10-18 03:07:14 -0700 | [diff] [blame] | 284 | } |
Dan Williams | bc3c702 | 2009-07-28 14:33:42 -0700 | [diff] [blame] | 285 | dma->device_issue_pending(dma_chan); |
Dan Williams | 532d3b1 | 2008-12-03 17:16:55 -0700 | [diff] [blame] | 286 | |
Dan Williams | 0c33e1c | 2009-03-02 13:31:35 -0700 | [diff] [blame] | 287 | tmo = wait_for_completion_timeout(&cmp, msecs_to_jiffies(3000)); |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 288 | |
Dan Williams | 0c33e1c | 2009-03-02 13:31:35 -0700 | [diff] [blame] | 289 | if (tmo == 0 || |
Linus Walleij | 0793448 | 2010-03-26 16:50:49 -0700 | [diff] [blame] | 290 | dma->device_tx_status(dma_chan, cookie, NULL) |
Vinod Koul | 2f16f80 | 2013-10-16 20:48:52 +0530 | [diff] [blame] | 291 | != DMA_COMPLETE) { |
Dan Williams | bc3c702 | 2009-07-28 14:33:42 -0700 | [diff] [blame] | 292 | dev_err(dev, "Self-test copy timed out, disabling\n"); |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 293 | err = -ENODEV; |
Bartlomiej Zolnierkiewicz | 522d974 | 2012-11-05 10:00:13 +0000 | [diff] [blame] | 294 | goto unmap_dma; |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 295 | } |
| 296 | if (memcmp(src, dest, IOAT_TEST_SIZE)) { |
Dan Williams | bc3c702 | 2009-07-28 14:33:42 -0700 | [diff] [blame] | 297 | dev_err(dev, "Self-test copy failed compare, disabling\n"); |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 298 | err = -ENODEV; |
| 299 | goto free_resources; |
| 300 | } |
| 301 | |
Bartlomiej Zolnierkiewicz | 522d974 | 2012-11-05 10:00:13 +0000 | [diff] [blame] | 302 | unmap_dma: |
Bartlomiej Zolnierkiewicz | 522d974 | 2012-11-05 10:00:13 +0000 | [diff] [blame] | 303 | dma_unmap_single(dev, dma_dest, IOAT_TEST_SIZE, DMA_FROM_DEVICE); |
Jiang Liu | 3532e56 | 2014-01-02 12:58:52 -0800 | [diff] [blame] | 304 | unmap_src: |
| 305 | dma_unmap_single(dev, dma_src, IOAT_TEST_SIZE, DMA_TO_DEVICE); |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 306 | free_resources: |
Dan Williams | bc3c702 | 2009-07-28 14:33:42 -0700 | [diff] [blame] | 307 | dma->device_free_chan_resources(dma_chan); |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 308 | out: |
| 309 | kfree(src); |
| 310 | kfree(dest); |
| 311 | return err; |
| 312 | } |
| 313 | |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 314 | static char ioat_interrupt_style[32] = "msix"; |
| 315 | module_param_string(ioat_interrupt_style, ioat_interrupt_style, |
| 316 | sizeof(ioat_interrupt_style), 0644); |
| 317 | MODULE_PARM_DESC(ioat_interrupt_style, |
Dan Williams | 4c5d961 | 2013-11-13 16:29:52 -0800 | [diff] [blame] | 318 | "set ioat interrupt style: msix (default), msi, intx"); |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 319 | |
| 320 | /** |
| 321 | * ioat_dma_setup_interrupts - setup interrupt handler |
| 322 | * @device: ioat device |
| 323 | */ |
Dave Jiang | 8a52b9f | 2013-03-26 15:42:47 -0700 | [diff] [blame] | 324 | int ioat_dma_setup_interrupts(struct ioatdma_device *device) |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 325 | { |
Dan Williams | dcbc853 | 2009-07-28 14:44:50 -0700 | [diff] [blame] | 326 | struct ioat_chan_common *chan; |
Dan Williams | e6c0b69 | 2009-09-08 17:29:44 -0700 | [diff] [blame] | 327 | struct pci_dev *pdev = device->pdev; |
| 328 | struct device *dev = &pdev->dev; |
| 329 | struct msix_entry *msix; |
| 330 | int i, j, msixcnt; |
| 331 | int err = -EINVAL; |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 332 | u8 intrctrl = 0; |
| 333 | |
| 334 | if (!strcmp(ioat_interrupt_style, "msix")) |
| 335 | goto msix; |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 336 | if (!strcmp(ioat_interrupt_style, "msi")) |
| 337 | goto msi; |
| 338 | if (!strcmp(ioat_interrupt_style, "intx")) |
| 339 | goto intx; |
Dan Williams | e6c0b69 | 2009-09-08 17:29:44 -0700 | [diff] [blame] | 340 | dev_err(dev, "invalid ioat_interrupt_style %s\n", ioat_interrupt_style); |
Shannon Nelson | 5149fd0 | 2007-10-18 03:07:13 -0700 | [diff] [blame] | 341 | goto err_no_irq; |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 342 | |
| 343 | msix: |
| 344 | /* The number of MSI-X vectors should equal the number of channels */ |
| 345 | msixcnt = device->common.chancnt; |
| 346 | for (i = 0; i < msixcnt; i++) |
| 347 | device->msix_entries[i].entry = i; |
| 348 | |
Alexander Gordeev | 368da99 | 2014-03-06 21:11:21 +0100 | [diff] [blame] | 349 | err = pci_enable_msix_exact(pdev, device->msix_entries, msixcnt); |
Dan Williams | 4c5d961 | 2013-11-13 16:29:52 -0800 | [diff] [blame] | 350 | if (err) |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 351 | goto msi; |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 352 | |
| 353 | for (i = 0; i < msixcnt; i++) { |
Dan Williams | e6c0b69 | 2009-09-08 17:29:44 -0700 | [diff] [blame] | 354 | msix = &device->msix_entries[i]; |
Dan Williams | dcbc853 | 2009-07-28 14:44:50 -0700 | [diff] [blame] | 355 | chan = ioat_chan_by_index(device, i); |
Dan Williams | e6c0b69 | 2009-09-08 17:29:44 -0700 | [diff] [blame] | 356 | err = devm_request_irq(dev, msix->vector, |
| 357 | ioat_dma_do_interrupt_msix, 0, |
Dan Williams | dcbc853 | 2009-07-28 14:44:50 -0700 | [diff] [blame] | 358 | "ioat-msix", chan); |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 359 | if (err) { |
| 360 | for (j = 0; j < i; j++) { |
Dan Williams | e6c0b69 | 2009-09-08 17:29:44 -0700 | [diff] [blame] | 361 | msix = &device->msix_entries[j]; |
Dan Williams | dcbc853 | 2009-07-28 14:44:50 -0700 | [diff] [blame] | 362 | chan = ioat_chan_by_index(device, j); |
| 363 | devm_free_irq(dev, msix->vector, chan); |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 364 | } |
Dan Williams | 4c5d961 | 2013-11-13 16:29:52 -0800 | [diff] [blame] | 365 | goto msi; |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 366 | } |
| 367 | } |
| 368 | intrctrl |= IOAT_INTRCTRL_MSIX_VECTOR_CONTROL; |
Dave Jiang | 8a52b9f | 2013-03-26 15:42:47 -0700 | [diff] [blame] | 369 | device->irq_mode = IOAT_MSIX; |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 370 | goto done; |
| 371 | |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 372 | msi: |
Dan Williams | e6c0b69 | 2009-09-08 17:29:44 -0700 | [diff] [blame] | 373 | err = pci_enable_msi(pdev); |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 374 | if (err) |
| 375 | goto intx; |
| 376 | |
Dan Williams | e6c0b69 | 2009-09-08 17:29:44 -0700 | [diff] [blame] | 377 | err = devm_request_irq(dev, pdev->irq, ioat_dma_do_interrupt, 0, |
| 378 | "ioat-msi", device); |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 379 | if (err) { |
Dan Williams | e6c0b69 | 2009-09-08 17:29:44 -0700 | [diff] [blame] | 380 | pci_disable_msi(pdev); |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 381 | goto intx; |
| 382 | } |
Dan Williams | 779e561 | 2013-11-13 16:30:43 -0800 | [diff] [blame] | 383 | device->irq_mode = IOAT_MSI; |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 384 | goto done; |
| 385 | |
| 386 | intx: |
Dan Williams | e6c0b69 | 2009-09-08 17:29:44 -0700 | [diff] [blame] | 387 | err = devm_request_irq(dev, pdev->irq, ioat_dma_do_interrupt, |
| 388 | IRQF_SHARED, "ioat-intx", device); |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 389 | if (err) |
| 390 | goto err_no_irq; |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 391 | |
Dave Jiang | 8a52b9f | 2013-03-26 15:42:47 -0700 | [diff] [blame] | 392 | device->irq_mode = IOAT_INTX; |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 393 | done: |
Dan Williams | f2427e2 | 2009-07-28 14:42:38 -0700 | [diff] [blame] | 394 | if (device->intr_quirk) |
| 395 | device->intr_quirk(device); |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 396 | intrctrl |= IOAT_INTRCTRL_MASTER_INT_EN; |
| 397 | writeb(intrctrl, device->reg_base + IOAT_INTRCTRL_OFFSET); |
| 398 | return 0; |
| 399 | |
| 400 | err_no_irq: |
| 401 | /* Disable all interrupt generation */ |
| 402 | writeb(0, device->reg_base + IOAT_INTRCTRL_OFFSET); |
Dave Jiang | 8a52b9f | 2013-03-26 15:42:47 -0700 | [diff] [blame] | 403 | device->irq_mode = IOAT_NOIRQ; |
Dan Williams | e6c0b69 | 2009-09-08 17:29:44 -0700 | [diff] [blame] | 404 | dev_err(dev, "no usable interrupts\n"); |
| 405 | return err; |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 406 | } |
Dave Jiang | 8a52b9f | 2013-03-26 15:42:47 -0700 | [diff] [blame] | 407 | EXPORT_SYMBOL(ioat_dma_setup_interrupts); |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 408 | |
Dan Williams | e6c0b69 | 2009-09-08 17:29:44 -0700 | [diff] [blame] | 409 | static void ioat_disable_interrupts(struct ioatdma_device *device) |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 410 | { |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 411 | /* Disable all interrupt generation */ |
| 412 | writeb(0, device->reg_base + IOAT_INTRCTRL_OFFSET); |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 413 | } |
| 414 | |
Greg Kroah-Hartman | 4bf27b8 | 2012-12-21 15:09:59 -0800 | [diff] [blame] | 415 | int ioat_probe(struct ioatdma_device *device) |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 416 | { |
Dan Williams | f2427e2 | 2009-07-28 14:42:38 -0700 | [diff] [blame] | 417 | int err = -ENODEV; |
| 418 | struct dma_device *dma = &device->common; |
| 419 | struct pci_dev *pdev = device->pdev; |
Dan Williams | e6c0b69 | 2009-09-08 17:29:44 -0700 | [diff] [blame] | 420 | struct device *dev = &pdev->dev; |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 421 | |
| 422 | /* DMA coherent memory pool for DMA descriptor allocations */ |
| 423 | device->dma_pool = pci_pool_create("dma_desc_pool", pdev, |
Shannon Nelson | 8ab8956 | 2007-10-16 01:27:39 -0700 | [diff] [blame] | 424 | sizeof(struct ioat_dma_descriptor), |
| 425 | 64, 0); |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 426 | if (!device->dma_pool) { |
| 427 | err = -ENOMEM; |
| 428 | goto err_dma_pool; |
| 429 | } |
| 430 | |
Shannon Nelson | 43d6e36 | 2007-10-16 01:27:39 -0700 | [diff] [blame] | 431 | device->completion_pool = pci_pool_create("completion_pool", pdev, |
| 432 | sizeof(u64), SMP_CACHE_BYTES, |
| 433 | SMP_CACHE_BYTES); |
Dan Williams | 5cbafa6 | 2009-08-26 13:01:44 -0700 | [diff] [blame] | 434 | |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 435 | if (!device->completion_pool) { |
| 436 | err = -ENOMEM; |
| 437 | goto err_completion_pool; |
| 438 | } |
| 439 | |
Dan Williams | 5cbafa6 | 2009-08-26 13:01:44 -0700 | [diff] [blame] | 440 | device->enumerate_channels(device); |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 441 | |
Dan Williams | f2427e2 | 2009-07-28 14:42:38 -0700 | [diff] [blame] | 442 | dma_cap_set(DMA_MEMCPY, dma->cap_mask); |
Dan Williams | f2427e2 | 2009-07-28 14:42:38 -0700 | [diff] [blame] | 443 | dma->dev = &pdev->dev; |
Shannon Nelson | 7bb67c1 | 2007-11-14 16:59:51 -0800 | [diff] [blame] | 444 | |
Dan Williams | bc3c702 | 2009-07-28 14:33:42 -0700 | [diff] [blame] | 445 | if (!dma->chancnt) { |
Dan Williams | a6d52d7 | 2009-12-19 15:36:02 -0700 | [diff] [blame] | 446 | dev_err(dev, "channel enumeration error\n"); |
Maciej Sosnowski | 8b794b1 | 2009-02-26 11:04:54 +0100 | [diff] [blame] | 447 | goto err_setup_interrupts; |
| 448 | } |
| 449 | |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 450 | err = ioat_dma_setup_interrupts(device); |
Shannon Nelson | 8ab8956 | 2007-10-16 01:27:39 -0700 | [diff] [blame] | 451 | if (err) |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 452 | goto err_setup_interrupts; |
Shannon Nelson | 8ab8956 | 2007-10-16 01:27:39 -0700 | [diff] [blame] | 453 | |
Dan Williams | 9de6fc7 | 2009-09-08 17:42:58 -0700 | [diff] [blame] | 454 | err = device->self_test(device); |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 455 | if (err) |
| 456 | goto err_self_test; |
| 457 | |
Dan Williams | f2427e2 | 2009-07-28 14:42:38 -0700 | [diff] [blame] | 458 | return 0; |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 459 | |
| 460 | err_self_test: |
Dan Williams | e6c0b69 | 2009-09-08 17:29:44 -0700 | [diff] [blame] | 461 | ioat_disable_interrupts(device); |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 462 | err_setup_interrupts: |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 463 | pci_pool_destroy(device->completion_pool); |
| 464 | err_completion_pool: |
| 465 | pci_pool_destroy(device->dma_pool); |
| 466 | err_dma_pool: |
Dan Williams | f2427e2 | 2009-07-28 14:42:38 -0700 | [diff] [blame] | 467 | return err; |
| 468 | } |
| 469 | |
Greg Kroah-Hartman | 4bf27b8 | 2012-12-21 15:09:59 -0800 | [diff] [blame] | 470 | int ioat_register(struct ioatdma_device *device) |
Dan Williams | f2427e2 | 2009-07-28 14:42:38 -0700 | [diff] [blame] | 471 | { |
| 472 | int err = dma_async_device_register(&device->common); |
| 473 | |
| 474 | if (err) { |
| 475 | ioat_disable_interrupts(device); |
| 476 | pci_pool_destroy(device->completion_pool); |
| 477 | pci_pool_destroy(device->dma_pool); |
| 478 | } |
| 479 | |
| 480 | return err; |
| 481 | } |
| 482 | |
Dan Williams | 5669e31 | 2009-09-08 17:42:56 -0700 | [diff] [blame] | 483 | static ssize_t cap_show(struct dma_chan *c, char *page) |
| 484 | { |
| 485 | struct dma_device *dma = c->device; |
| 486 | |
Bartlomiej Zolnierkiewicz | 48a9db4 | 2013-07-03 15:05:06 -0700 | [diff] [blame] | 487 | return sprintf(page, "copy%s%s%s%s%s\n", |
Dan Williams | 5669e31 | 2009-09-08 17:42:56 -0700 | [diff] [blame] | 488 | dma_has_cap(DMA_PQ, dma->cap_mask) ? " pq" : "", |
| 489 | dma_has_cap(DMA_PQ_VAL, dma->cap_mask) ? " pq_val" : "", |
| 490 | dma_has_cap(DMA_XOR, dma->cap_mask) ? " xor" : "", |
| 491 | dma_has_cap(DMA_XOR_VAL, dma->cap_mask) ? " xor_val" : "", |
Dan Williams | 5669e31 | 2009-09-08 17:42:56 -0700 | [diff] [blame] | 492 | dma_has_cap(DMA_INTERRUPT, dma->cap_mask) ? " intr" : ""); |
| 493 | |
| 494 | } |
| 495 | struct ioat_sysfs_entry ioat_cap_attr = __ATTR_RO(cap); |
| 496 | |
| 497 | static ssize_t version_show(struct dma_chan *c, char *page) |
| 498 | { |
| 499 | struct dma_device *dma = c->device; |
| 500 | struct ioatdma_device *device = to_ioatdma_device(dma); |
| 501 | |
| 502 | return sprintf(page, "%d.%d\n", |
| 503 | device->version >> 4, device->version & 0xf); |
| 504 | } |
| 505 | struct ioat_sysfs_entry ioat_version_attr = __ATTR_RO(version); |
| 506 | |
Dan Williams | 5669e31 | 2009-09-08 17:42:56 -0700 | [diff] [blame] | 507 | static ssize_t |
| 508 | ioat_attr_show(struct kobject *kobj, struct attribute *attr, char *page) |
| 509 | { |
| 510 | struct ioat_sysfs_entry *entry; |
| 511 | struct ioat_chan_common *chan; |
| 512 | |
| 513 | entry = container_of(attr, struct ioat_sysfs_entry, attr); |
| 514 | chan = container_of(kobj, struct ioat_chan_common, kobj); |
| 515 | |
| 516 | if (!entry->show) |
| 517 | return -EIO; |
| 518 | return entry->show(&chan->common, page); |
| 519 | } |
| 520 | |
Emese Revfy | 52cf25d | 2010-01-19 02:58:23 +0100 | [diff] [blame] | 521 | const struct sysfs_ops ioat_sysfs_ops = { |
Dan Williams | 5669e31 | 2009-09-08 17:42:56 -0700 | [diff] [blame] | 522 | .show = ioat_attr_show, |
| 523 | }; |
| 524 | |
Dan Williams | 5669e31 | 2009-09-08 17:42:56 -0700 | [diff] [blame] | 525 | void ioat_kobject_add(struct ioatdma_device *device, struct kobj_type *type) |
| 526 | { |
| 527 | struct dma_device *dma = &device->common; |
| 528 | struct dma_chan *c; |
| 529 | |
| 530 | list_for_each_entry(c, &dma->channels, device_node) { |
| 531 | struct ioat_chan_common *chan = to_chan_common(c); |
| 532 | struct kobject *parent = &c->dev->device.kobj; |
| 533 | int err; |
| 534 | |
| 535 | err = kobject_init_and_add(&chan->kobj, type, parent, "quickdata"); |
| 536 | if (err) { |
| 537 | dev_warn(to_dev(chan), |
| 538 | "sysfs init error (%d), continuing...\n", err); |
| 539 | kobject_put(&chan->kobj); |
| 540 | set_bit(IOAT_KOBJ_INIT_FAIL, &chan->state); |
| 541 | } |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | void ioat_kobject_del(struct ioatdma_device *device) |
| 546 | { |
| 547 | struct dma_device *dma = &device->common; |
| 548 | struct dma_chan *c; |
| 549 | |
| 550 | list_for_each_entry(c, &dma->channels, device_node) { |
| 551 | struct ioat_chan_common *chan = to_chan_common(c); |
| 552 | |
| 553 | if (!test_bit(IOAT_KOBJ_INIT_FAIL, &chan->state)) { |
| 554 | kobject_del(&chan->kobj); |
| 555 | kobject_put(&chan->kobj); |
| 556 | } |
| 557 | } |
| 558 | } |
| 559 | |
Greg Kroah-Hartman | 4bf27b8 | 2012-12-21 15:09:59 -0800 | [diff] [blame] | 560 | void ioat_dma_remove(struct ioatdma_device *device) |
Dan Aloni | 428ed60 | 2007-03-08 09:57:36 -0800 | [diff] [blame] | 561 | { |
Dan Williams | bc3c702 | 2009-07-28 14:33:42 -0700 | [diff] [blame] | 562 | struct dma_device *dma = &device->common; |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 563 | |
Dan Williams | e6c0b69 | 2009-09-08 17:29:44 -0700 | [diff] [blame] | 564 | ioat_disable_interrupts(device); |
Shannon Nelson | 8ab8956 | 2007-10-16 01:27:39 -0700 | [diff] [blame] | 565 | |
Dan Williams | 5669e31 | 2009-09-08 17:42:56 -0700 | [diff] [blame] | 566 | ioat_kobject_del(device); |
| 567 | |
Dan Williams | bc3c702 | 2009-07-28 14:33:42 -0700 | [diff] [blame] | 568 | dma_async_device_unregister(dma); |
Shannon Nelson | dfe2299 | 2007-10-18 03:07:13 -0700 | [diff] [blame] | 569 | |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 570 | pci_pool_destroy(device->dma_pool); |
| 571 | pci_pool_destroy(device->completion_pool); |
Shannon Nelson | 8ab8956 | 2007-10-16 01:27:39 -0700 | [diff] [blame] | 572 | |
Dan Williams | dcbc853 | 2009-07-28 14:44:50 -0700 | [diff] [blame] | 573 | INIT_LIST_HEAD(&dma->channels); |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 574 | } |