Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 1 | /* |
Maciej Sosnowski | 211a22c | 2009-02-26 11:05:43 +0100 | [diff] [blame] | 2 | * Copyright(c) 2004 - 2009 Intel Corporation. All rights reserved. |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of the GNU General Public License as published by the Free |
| 6 | * Software Foundation; either version 2 of the License, or (at your option) |
| 7 | * any later version. |
| 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 | * |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 14 | * The full GNU General Public License is included in this distribution in the |
| 15 | * file called COPYING. |
| 16 | */ |
| 17 | #ifndef IOATDMA_H |
| 18 | #define IOATDMA_H |
| 19 | |
| 20 | #include <linux/dmaengine.h> |
Dan Williams | 584ec22 | 2009-07-28 14:32:12 -0700 | [diff] [blame] | 21 | #include "hw.h" |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 22 | #include "registers.h" |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 23 | #include <linux/init.h> |
| 24 | #include <linux/dmapool.h> |
| 25 | #include <linux/cache.h> |
David S. Miller | 57c651f | 2006-05-23 17:39:49 -0700 | [diff] [blame] | 26 | #include <linux/pci_ids.h> |
Maciej Sosnowski | 16a37ac | 2008-07-22 17:30:57 -0700 | [diff] [blame] | 27 | #include <net/tcp.h> |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 28 | |
Dan Williams | 3208ca5 | 2009-09-10 11:27:36 -0700 | [diff] [blame] | 29 | #define IOAT_DMA_VERSION "4.00" |
Shannon Nelson | 5149fd0 | 2007-10-18 03:07:13 -0700 | [diff] [blame] | 30 | |
Shannon Nelson | 7bb67c1 | 2007-11-14 16:59:51 -0800 | [diff] [blame] | 31 | #define IOAT_DMA_DCA_ANY_CPU ~0 |
| 32 | |
Dan Williams | 1f27adc2 | 2009-09-08 17:29:02 -0700 | [diff] [blame] | 33 | #define to_ioatdma_device(dev) container_of(dev, struct ioatdma_device, common) |
Dan Williams | bc3c702 | 2009-07-28 14:33:42 -0700 | [diff] [blame] | 34 | #define to_dev(ioat_chan) (&(ioat_chan)->device->pdev->dev) |
Dave Jiang | 3f09ede | 2013-03-26 15:43:09 -0700 | [diff] [blame] | 35 | #define to_pdev(ioat_chan) ((ioat_chan)->device->pdev) |
Dan Williams | 1f27adc2 | 2009-09-08 17:29:02 -0700 | [diff] [blame] | 36 | |
| 37 | #define chan_num(ch) ((int)((ch)->reg_base - (ch)->device->reg_base) / 0x80) |
| 38 | |
Dan Williams | 1f27adc2 | 2009-09-08 17:29:02 -0700 | [diff] [blame] | 39 | /* |
| 40 | * workaround for IOAT ver.3.0 null descriptor issue |
| 41 | * (channel returns error when size is 0) |
| 42 | */ |
| 43 | #define NULL_DESC_BUFFER_SIZE 1 |
| 44 | |
Dave Jiang | 8a52b9f | 2013-03-26 15:42:47 -0700 | [diff] [blame] | 45 | enum ioat_irq_mode { |
| 46 | IOAT_NOIRQ = 0, |
| 47 | IOAT_MSIX, |
Dave Jiang | 8a52b9f | 2013-03-26 15:42:47 -0700 | [diff] [blame] | 48 | IOAT_MSI, |
| 49 | IOAT_INTX |
| 50 | }; |
| 51 | |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 52 | /** |
Shannon Nelson | 8ab8956 | 2007-10-16 01:27:39 -0700 | [diff] [blame] | 53 | * struct ioatdma_device - internal representation of a IOAT device |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 54 | * @pdev: PCI-Express device |
| 55 | * @reg_base: MMIO register space base address |
| 56 | * @dma_pool: for allocating DMA descriptors |
| 57 | * @common: embedded struct dma_device |
Shannon Nelson | 8ab8956 | 2007-10-16 01:27:39 -0700 | [diff] [blame] | 58 | * @version: version of ioatdma device |
Shannon Nelson | 7bb67c1 | 2007-11-14 16:59:51 -0800 | [diff] [blame] | 59 | * @msix_entries: irq handlers |
| 60 | * @idx: per channel data |
Dan Williams | f2427e2 | 2009-07-28 14:42:38 -0700 | [diff] [blame] | 61 | * @dca: direct cache access context |
| 62 | * @intr_quirk: interrupt setup quirk (for ioat_v1 devices) |
Dan Williams | 5cbafa6 | 2009-08-26 13:01:44 -0700 | [diff] [blame] | 63 | * @enumerate_channels: hw version specific channel enumeration |
Dan Williams | a6d52d7 | 2009-12-19 15:36:02 -0700 | [diff] [blame] | 64 | * @reset_hw: hw version specific channel (re)initialization |
Dan Williams | aa4d72a | 2010-03-03 21:21:13 -0700 | [diff] [blame] | 65 | * @cleanup_fn: select between the v2 and v3 cleanup routines |
Dan Williams | bf40a68 | 2009-09-08 17:42:55 -0700 | [diff] [blame] | 66 | * @timer_fn: select between the v2 and v3 timer watchdog routines |
Dan Williams | 9de6fc7 | 2009-09-08 17:42:58 -0700 | [diff] [blame] | 67 | * @self_test: hardware version specific self test for each supported op type |
Dan Williams | bf40a68 | 2009-09-08 17:42:55 -0700 | [diff] [blame] | 68 | * |
| 69 | * Note: the v3 cleanup routine supports raid operations |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 70 | */ |
Shannon Nelson | 8ab8956 | 2007-10-16 01:27:39 -0700 | [diff] [blame] | 71 | struct ioatdma_device { |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 72 | struct pci_dev *pdev; |
Al Viro | 47b1653 | 2006-10-10 22:45:47 +0100 | [diff] [blame] | 73 | void __iomem *reg_base; |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 74 | struct pci_pool *dma_pool; |
| 75 | struct pci_pool *completion_pool; |
Dave Jiang | 7727eaa | 2013-04-15 10:25:56 -0700 | [diff] [blame] | 76 | #define MAX_SED_POOLS 5 |
| 77 | struct dma_pool *sed_hw_pool[MAX_SED_POOLS]; |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 78 | struct dma_device common; |
Shannon Nelson | 8ab8956 | 2007-10-16 01:27:39 -0700 | [diff] [blame] | 79 | u8 version; |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 80 | struct msix_entry msix_entries[4]; |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 81 | struct ioatdma_chan *idx[4]; |
Dan Williams | f2427e2 | 2009-07-28 14:42:38 -0700 | [diff] [blame] | 82 | struct dca_provider *dca; |
Dave Jiang | 8a52b9f | 2013-03-26 15:42:47 -0700 | [diff] [blame] | 83 | enum ioat_irq_mode irq_mode; |
Dave Jiang | 75c6f0a | 2013-04-10 16:44:39 -0700 | [diff] [blame] | 84 | u32 cap; |
Dan Williams | f2427e2 | 2009-07-28 14:42:38 -0700 | [diff] [blame] | 85 | void (*intr_quirk)(struct ioatdma_device *device); |
Dan Williams | 5cbafa6 | 2009-08-26 13:01:44 -0700 | [diff] [blame] | 86 | int (*enumerate_channels)(struct ioatdma_device *device); |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 87 | int (*reset_hw)(struct ioatdma_chan *ioat_chan); |
Dan Williams | aa4d72a | 2010-03-03 21:21:13 -0700 | [diff] [blame] | 88 | void (*cleanup_fn)(unsigned long data); |
Dan Williams | bf40a68 | 2009-09-08 17:42:55 -0700 | [diff] [blame] | 89 | void (*timer_fn)(unsigned long data); |
Dan Williams | 9de6fc7 | 2009-09-08 17:42:58 -0700 | [diff] [blame] | 90 | int (*self_test)(struct ioatdma_device *device); |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 91 | }; |
| 92 | |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 93 | struct ioatdma_chan { |
| 94 | struct dma_chan dma_chan; |
Al Viro | 47b1653 | 2006-10-10 22:45:47 +0100 | [diff] [blame] | 95 | void __iomem *reg_base; |
Dan Williams | 2750293 | 2012-03-23 13:36:42 -0700 | [diff] [blame] | 96 | dma_addr_t last_completion; |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 97 | spinlock_t cleanup_lock; |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 98 | unsigned long state; |
| 99 | #define IOAT_COMPLETION_PENDING 0 |
| 100 | #define IOAT_COMPLETION_ACK 1 |
| 101 | #define IOAT_RESET_PENDING 2 |
Dan Williams | 5669e31 | 2009-09-08 17:42:56 -0700 | [diff] [blame] | 102 | #define IOAT_KOBJ_INIT_FAIL 3 |
Dan Williams | 074cc47 | 2010-05-01 15:22:55 -0700 | [diff] [blame] | 103 | #define IOAT_RESHAPE_PENDING 4 |
Dan Williams | 556ab45 | 2010-07-23 15:47:56 -0700 | [diff] [blame] | 104 | #define IOAT_RUN 5 |
Dave Jiang | 4dec23d | 2013-02-07 14:38:32 -0700 | [diff] [blame] | 105 | #define IOAT_CHAN_ACTIVE 6 |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 106 | struct timer_list timer; |
| 107 | #define COMPLETION_TIMEOUT msecs_to_jiffies(100) |
Dan Williams | a309218 | 2009-09-08 12:02:01 -0700 | [diff] [blame] | 108 | #define IDLE_TIMEOUT msecs_to_jiffies(2000) |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 109 | #define RESET_DELAY msecs_to_jiffies(100) |
Shannon Nelson | 8ab8956 | 2007-10-16 01:27:39 -0700 | [diff] [blame] | 110 | struct ioatdma_device *device; |
Dan Williams | 4fb9b9e | 2009-09-08 12:01:04 -0700 | [diff] [blame] | 111 | dma_addr_t completion_dma; |
| 112 | u64 *completion; |
Shannon Nelson | 3e03745 | 2007-10-16 01:27:40 -0700 | [diff] [blame] | 113 | struct tasklet_struct cleanup_task; |
Dan Williams | 5669e31 | 2009-09-08 17:42:56 -0700 | [diff] [blame] | 114 | struct kobject kobj; |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 115 | |
| 116 | /* ioat v2 / v3 channel attributes |
| 117 | * @xfercap_log; log2 of channel max transfer length (for fast division) |
| 118 | * @head: allocated index |
| 119 | * @issued: hardware notification point |
| 120 | * @tail: cleanup index |
| 121 | * @dmacount: identical to 'head' except for occasionally resetting to zero |
| 122 | * @alloc_order: log2 of the number of allocated descriptors |
| 123 | * @produce: number of descriptors to produce at submit time |
| 124 | * @ring: software ring buffer implementation of hardware ring |
| 125 | * @prep_lock: serializes descriptor preparation (producers) |
| 126 | */ |
| 127 | size_t xfercap_log; |
| 128 | u16 head; |
| 129 | u16 issued; |
| 130 | u16 tail; |
| 131 | u16 dmacount; |
| 132 | u16 alloc_order; |
| 133 | u16 produce; |
| 134 | struct ioat_ring_ent **ring; |
| 135 | spinlock_t prep_lock; |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 136 | }; |
| 137 | |
Dan Williams | 5669e31 | 2009-09-08 17:42:56 -0700 | [diff] [blame] | 138 | struct ioat_sysfs_entry { |
| 139 | struct attribute attr; |
| 140 | ssize_t (*show)(struct dma_chan *, char *); |
| 141 | }; |
Dan Williams | 5cbafa6 | 2009-08-26 13:01:44 -0700 | [diff] [blame] | 142 | |
Dan Williams | dcbc853 | 2009-07-28 14:44:50 -0700 | [diff] [blame] | 143 | /** |
Dave Jiang | 7727eaa | 2013-04-15 10:25:56 -0700 | [diff] [blame] | 144 | * struct ioat_sed_ent - wrapper around super extended hardware descriptor |
| 145 | * @hw: hardware SED |
| 146 | * @sed_dma: dma address for the SED |
| 147 | * @list: list member |
| 148 | * @parent: point to the dma descriptor that's the parent |
| 149 | */ |
| 150 | struct ioat_sed_ent { |
| 151 | struct ioat_sed_raw_descriptor *hw; |
| 152 | dma_addr_t dma; |
| 153 | struct ioat_ring_ent *parent; |
| 154 | unsigned int hw_pool; |
| 155 | }; |
| 156 | |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 157 | static inline struct ioatdma_chan *to_ioat_chan(struct dma_chan *c) |
Dan Williams | dcbc853 | 2009-07-28 14:44:50 -0700 | [diff] [blame] | 158 | { |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 159 | return container_of(c, struct ioatdma_chan, dma_chan); |
Dan Williams | dcbc853 | 2009-07-28 14:44:50 -0700 | [diff] [blame] | 160 | } |
| 161 | |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 162 | |
| 163 | |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 164 | /* wrapper around hardware descriptor format + additional software fields */ |
| 165 | |
Dan Williams | 6df9183 | 2009-09-08 12:00:55 -0700 | [diff] [blame] | 166 | #ifdef DEBUG |
| 167 | #define set_desc_id(desc, i) ((desc)->id = (i)) |
| 168 | #define desc_id(desc) ((desc)->id) |
| 169 | #else |
| 170 | #define set_desc_id(desc, i) |
| 171 | #define desc_id(desc) (0) |
| 172 | #endif |
| 173 | |
| 174 | static inline void |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 175 | __dump_desc_dbg(struct ioatdma_chan *ioat_chan, struct ioat_dma_descriptor *hw, |
Dan Williams | 6df9183 | 2009-09-08 12:00:55 -0700 | [diff] [blame] | 176 | struct dma_async_tx_descriptor *tx, int id) |
| 177 | { |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 178 | struct device *dev = to_dev(ioat_chan); |
Dan Williams | 6df9183 | 2009-09-08 12:00:55 -0700 | [diff] [blame] | 179 | |
| 180 | dev_dbg(dev, "desc[%d]: (%#llx->%#llx) cookie: %d flags: %#x" |
Dave Jiang | 50f9f97 | 2013-03-04 10:59:54 -0700 | [diff] [blame] | 181 | " ctl: %#10.8x (op: %#x int_en: %d compl: %d)\n", id, |
Dan Williams | 6df9183 | 2009-09-08 12:00:55 -0700 | [diff] [blame] | 182 | (unsigned long long) tx->phys, |
| 183 | (unsigned long long) hw->next, tx->cookie, tx->flags, |
| 184 | hw->ctl, hw->ctl_f.op, hw->ctl_f.int_en, hw->ctl_f.compl_write); |
| 185 | } |
| 186 | |
| 187 | #define dump_desc_dbg(c, d) \ |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 188 | ({ if (d) __dump_desc_dbg(c, d->hw, &d->txd, desc_id(d)); 0; }) |
Dan Williams | 6df9183 | 2009-09-08 12:00:55 -0700 | [diff] [blame] | 189 | |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 190 | static inline struct ioatdma_chan * |
Dan Williams | 5cbafa6 | 2009-08-26 13:01:44 -0700 | [diff] [blame] | 191 | ioat_chan_by_index(struct ioatdma_device *device, int index) |
| 192 | { |
| 193 | return device->idx[index]; |
| 194 | } |
| 195 | |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 196 | static inline u64 ioat_chansts_32(struct ioatdma_chan *ioat_chan) |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 197 | { |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 198 | u8 ver = ioat_chan->device->version; |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 199 | u64 status; |
| 200 | u32 status_lo; |
| 201 | |
| 202 | /* We need to read the low address first as this causes the |
| 203 | * chipset to latch the upper bits for the subsequent read |
| 204 | */ |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 205 | status_lo = readl(ioat_chan->reg_base + IOAT_CHANSTS_OFFSET_LOW(ver)); |
| 206 | status = readl(ioat_chan->reg_base + IOAT_CHANSTS_OFFSET_HIGH(ver)); |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 207 | status <<= 32; |
| 208 | status |= status_lo; |
| 209 | |
| 210 | return status; |
| 211 | } |
| 212 | |
Dave Jiang | d92a8d7 | 2013-03-26 15:42:41 -0700 | [diff] [blame] | 213 | #if BITS_PER_LONG == 64 |
| 214 | |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 215 | static inline u64 ioat_chansts(struct ioatdma_chan *ioat_chan) |
Dave Jiang | d92a8d7 | 2013-03-26 15:42:41 -0700 | [diff] [blame] | 216 | { |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 217 | u8 ver = ioat_chan->device->version; |
Dave Jiang | d92a8d7 | 2013-03-26 15:42:41 -0700 | [diff] [blame] | 218 | u64 status; |
| 219 | |
| 220 | /* With IOAT v3.3 the status register is 64bit. */ |
| 221 | if (ver >= IOAT_VER_3_3) |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 222 | status = readq(ioat_chan->reg_base + IOAT_CHANSTS_OFFSET(ver)); |
Dave Jiang | d92a8d7 | 2013-03-26 15:42:41 -0700 | [diff] [blame] | 223 | else |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 224 | status = ioat_chansts_32(ioat_chan); |
Dave Jiang | d92a8d7 | 2013-03-26 15:42:41 -0700 | [diff] [blame] | 225 | |
| 226 | return status; |
| 227 | } |
| 228 | |
| 229 | #else |
| 230 | #define ioat_chansts ioat_chansts_32 |
| 231 | #endif |
| 232 | |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 233 | static inline u64 ioat_chansts_to_addr(u64 status) |
| 234 | { |
| 235 | return status & IOAT_CHANSTS_COMPLETED_DESCRIPTOR_ADDR; |
| 236 | } |
| 237 | |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 238 | static inline u32 ioat_chanerr(struct ioatdma_chan *ioat_chan) |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 239 | { |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 240 | return readl(ioat_chan->reg_base + IOAT_CHANERR_OFFSET); |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 241 | } |
| 242 | |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 243 | static inline void ioat_suspend(struct ioatdma_chan *ioat_chan) |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 244 | { |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 245 | u8 ver = ioat_chan->device->version; |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 246 | |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 247 | writeb(IOAT_CHANCMD_SUSPEND, |
| 248 | ioat_chan->reg_base + IOAT_CHANCMD_OFFSET(ver)); |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 249 | } |
| 250 | |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 251 | static inline void ioat_reset(struct ioatdma_chan *ioat_chan) |
Dan Williams | a6d52d7 | 2009-12-19 15:36:02 -0700 | [diff] [blame] | 252 | { |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 253 | u8 ver = ioat_chan->device->version; |
Dan Williams | a6d52d7 | 2009-12-19 15:36:02 -0700 | [diff] [blame] | 254 | |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 255 | writeb(IOAT_CHANCMD_RESET, |
| 256 | ioat_chan->reg_base + IOAT_CHANCMD_OFFSET(ver)); |
Dan Williams | a6d52d7 | 2009-12-19 15:36:02 -0700 | [diff] [blame] | 257 | } |
| 258 | |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 259 | static inline bool ioat_reset_pending(struct ioatdma_chan *ioat_chan) |
Dan Williams | a6d52d7 | 2009-12-19 15:36:02 -0700 | [diff] [blame] | 260 | { |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 261 | u8 ver = ioat_chan->device->version; |
Dan Williams | a6d52d7 | 2009-12-19 15:36:02 -0700 | [diff] [blame] | 262 | u8 cmd; |
| 263 | |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 264 | cmd = readb(ioat_chan->reg_base + IOAT_CHANCMD_OFFSET(ver)); |
Dan Williams | a6d52d7 | 2009-12-19 15:36:02 -0700 | [diff] [blame] | 265 | return (cmd & IOAT_CHANCMD_RESET) == IOAT_CHANCMD_RESET; |
| 266 | } |
| 267 | |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 268 | static inline bool is_ioat_active(unsigned long status) |
| 269 | { |
| 270 | return ((status & IOAT_CHANSTS_STATUS) == IOAT_CHANSTS_ACTIVE); |
| 271 | } |
| 272 | |
| 273 | static inline bool is_ioat_idle(unsigned long status) |
| 274 | { |
| 275 | return ((status & IOAT_CHANSTS_STATUS) == IOAT_CHANSTS_DONE); |
| 276 | } |
| 277 | |
| 278 | static inline bool is_ioat_halted(unsigned long status) |
| 279 | { |
| 280 | return ((status & IOAT_CHANSTS_STATUS) == IOAT_CHANSTS_HALTED); |
| 281 | } |
| 282 | |
| 283 | static inline bool is_ioat_suspended(unsigned long status) |
| 284 | { |
| 285 | return ((status & IOAT_CHANSTS_STATUS) == IOAT_CHANSTS_SUSPENDED); |
| 286 | } |
| 287 | |
| 288 | /* channel was fatally programmed */ |
| 289 | static inline bool is_ioat_bug(unsigned long err) |
| 290 | { |
Dan Williams | b57014d | 2009-11-19 17:10:07 -0700 | [diff] [blame] | 291 | return !!err; |
Dan Williams | 09c8a5b | 2009-09-08 12:01:49 -0700 | [diff] [blame] | 292 | } |
| 293 | |
Greg Kroah-Hartman | 4bf27b8 | 2012-12-21 15:09:59 -0800 | [diff] [blame] | 294 | int ioat_probe(struct ioatdma_device *device); |
| 295 | int ioat_register(struct ioatdma_device *device); |
Greg Kroah-Hartman | 4bf27b8 | 2012-12-21 15:09:59 -0800 | [diff] [blame] | 296 | int ioat_dma_self_test(struct ioatdma_device *device); |
| 297 | void ioat_dma_remove(struct ioatdma_device *device); |
| 298 | struct dca_provider *ioat_dca_init(struct pci_dev *pdev, void __iomem *iobase); |
Dan Williams | 5cbafa6 | 2009-08-26 13:01:44 -0700 | [diff] [blame] | 299 | void ioat_init_channel(struct ioatdma_device *device, |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 300 | struct ioatdma_chan *ioat_chan, int idx); |
Linus Walleij | 0793448 | 2010-03-26 16:50:49 -0700 | [diff] [blame] | 301 | enum dma_status ioat_dma_tx_status(struct dma_chan *c, dma_cookie_t cookie, |
| 302 | struct dma_tx_state *txstate); |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 303 | bool ioat_cleanup_preamble(struct ioatdma_chan *ioat_chan, |
Dan Williams | 2750293 | 2012-03-23 13:36:42 -0700 | [diff] [blame] | 304 | dma_addr_t *phys_complete); |
Dan Williams | 5669e31 | 2009-09-08 17:42:56 -0700 | [diff] [blame] | 305 | void ioat_kobject_add(struct ioatdma_device *device, struct kobj_type *type); |
| 306 | void ioat_kobject_del(struct ioatdma_device *device); |
Dave Jiang | 8a52b9f | 2013-03-26 15:42:47 -0700 | [diff] [blame] | 307 | int ioat_dma_setup_interrupts(struct ioatdma_device *device); |
Dave Jiang | 5a97688 | 2015-08-11 08:48:21 -0700 | [diff] [blame^] | 308 | void ioat_stop(struct ioatdma_chan *ioat_chan); |
Emese Revfy | 52cf25d | 2010-01-19 02:58:23 +0100 | [diff] [blame] | 309 | extern const struct sysfs_ops ioat_sysfs_ops; |
Dan Williams | 5669e31 | 2009-09-08 17:42:56 -0700 | [diff] [blame] | 310 | extern struct ioat_sysfs_entry ioat_version_attr; |
| 311 | extern struct ioat_sysfs_entry ioat_cap_attr; |
Chris Leech | 0bbd5f4 | 2006-05-23 17:35:34 -0700 | [diff] [blame] | 312 | #endif /* IOATDMA_H */ |