diff options
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/dma/ioat/dma.h | 1 | ||||
| -rw-r--r-- | drivers/dma/ioat/dma_v2.c | 182 | ||||
| -rw-r--r-- | drivers/dma/ioat/dma_v2.h | 15 | ||||
| -rw-r--r-- | drivers/dma/ioat/dma_v3.c | 117 |
4 files changed, 134 insertions, 181 deletions
diff --git a/drivers/dma/ioat/dma.h b/drivers/dma/ioat/dma.h index 86b97ac8774e..0c76578e9911 100644 --- a/drivers/dma/ioat/dma.h +++ b/drivers/dma/ioat/dma.h | |||
| @@ -96,6 +96,7 @@ struct ioat_chan_common { | |||
| 96 | #define IOAT_COMPLETION_ACK 1 | 96 | #define IOAT_COMPLETION_ACK 1 |
| 97 | #define IOAT_RESET_PENDING 2 | 97 | #define IOAT_RESET_PENDING 2 |
| 98 | #define IOAT_KOBJ_INIT_FAIL 3 | 98 | #define IOAT_KOBJ_INIT_FAIL 3 |
| 99 | #define IOAT_RESHAPE_PENDING 4 | ||
| 99 | struct timer_list timer; | 100 | struct timer_list timer; |
| 100 | #define COMPLETION_TIMEOUT msecs_to_jiffies(100) | 101 | #define COMPLETION_TIMEOUT msecs_to_jiffies(100) |
| 101 | #define IDLE_TIMEOUT msecs_to_jiffies(2000) | 102 | #define IDLE_TIMEOUT msecs_to_jiffies(2000) |
diff --git a/drivers/dma/ioat/dma_v2.c b/drivers/dma/ioat/dma_v2.c index b6699a350989..e75d0299bb82 100644 --- a/drivers/dma/ioat/dma_v2.c +++ b/drivers/dma/ioat/dma_v2.c | |||
| @@ -56,8 +56,6 @@ void __ioat2_issue_pending(struct ioat2_dma_chan *ioat) | |||
| 56 | 56 | ||
| 57 | ioat->dmacount += ioat2_ring_pending(ioat); | 57 | ioat->dmacount += ioat2_ring_pending(ioat); |
| 58 | ioat->issued = ioat->head; | 58 | ioat->issued = ioat->head; |
| 59 | /* make descriptor updates globally visible before notifying channel */ | ||
| 60 | wmb(); | ||
| 61 | writew(ioat->dmacount, chan->reg_base + IOAT_CHAN_DMACOUNT_OFFSET); | 59 | writew(ioat->dmacount, chan->reg_base + IOAT_CHAN_DMACOUNT_OFFSET); |
| 62 | dev_dbg(to_dev(chan), | 60 | dev_dbg(to_dev(chan), |
| 63 | "%s: head: %#x tail: %#x issued: %#x count: %#x\n", | 61 | "%s: head: %#x tail: %#x issued: %#x count: %#x\n", |
| @@ -69,9 +67,9 @@ void ioat2_issue_pending(struct dma_chan *c) | |||
| 69 | struct ioat2_dma_chan *ioat = to_ioat2_chan(c); | 67 | struct ioat2_dma_chan *ioat = to_ioat2_chan(c); |
| 70 | 68 | ||
| 71 | if (ioat2_ring_pending(ioat)) { | 69 | if (ioat2_ring_pending(ioat)) { |
| 72 | spin_lock_bh(&ioat->ring_lock); | 70 | spin_lock_bh(&ioat->prep_lock); |
| 73 | __ioat2_issue_pending(ioat); | 71 | __ioat2_issue_pending(ioat); |
| 74 | spin_unlock_bh(&ioat->ring_lock); | 72 | spin_unlock_bh(&ioat->prep_lock); |
| 75 | } | 73 | } |
| 76 | } | 74 | } |
| 77 | 75 | ||
| @@ -80,7 +78,7 @@ void ioat2_issue_pending(struct dma_chan *c) | |||
| 80 | * @ioat: ioat2+ channel | 78 | * @ioat: ioat2+ channel |
| 81 | * | 79 | * |
| 82 | * Check if the number of unsubmitted descriptors has exceeded the | 80 | * Check if the number of unsubmitted descriptors has exceeded the |
| 83 | * watermark. Called with ring_lock held | 81 | * watermark. Called with prep_lock held |
| 84 | */ | 82 | */ |
| 85 | static void ioat2_update_pending(struct ioat2_dma_chan *ioat) | 83 | static void ioat2_update_pending(struct ioat2_dma_chan *ioat) |
| 86 | { | 84 | { |
| @@ -92,7 +90,6 @@ static void __ioat2_start_null_desc(struct ioat2_dma_chan *ioat) | |||
| 92 | { | 90 | { |
| 93 | struct ioat_ring_ent *desc; | 91 | struct ioat_ring_ent *desc; |
| 94 | struct ioat_dma_descriptor *hw; | 92 | struct ioat_dma_descriptor *hw; |
| 95 | int idx; | ||
| 96 | 93 | ||
| 97 | if (ioat2_ring_space(ioat) < 1) { | 94 | if (ioat2_ring_space(ioat) < 1) { |
| 98 | dev_err(to_dev(&ioat->base), | 95 | dev_err(to_dev(&ioat->base), |
| @@ -102,8 +99,7 @@ static void __ioat2_start_null_desc(struct ioat2_dma_chan *ioat) | |||
| 102 | 99 | ||
| 103 | dev_dbg(to_dev(&ioat->base), "%s: head: %#x tail: %#x issued: %#x\n", | 100 | dev_dbg(to_dev(&ioat->base), "%s: head: %#x tail: %#x issued: %#x\n", |
| 104 | __func__, ioat->head, ioat->tail, ioat->issued); | 101 | __func__, ioat->head, ioat->tail, ioat->issued); |
| 105 | idx = ioat2_desc_alloc(ioat, 1); | 102 | desc = ioat2_get_ring_ent(ioat, ioat->head); |
| 106 | desc = ioat2_get_ring_ent(ioat, idx); | ||
| 107 | 103 | ||
| 108 | hw = desc->hw; | 104 | hw = desc->hw; |
| 109 | hw->ctl = 0; | 105 | hw->ctl = 0; |
| @@ -117,14 +113,16 @@ static void __ioat2_start_null_desc(struct ioat2_dma_chan *ioat) | |||
| 117 | async_tx_ack(&desc->txd); | 113 | async_tx_ack(&desc->txd); |
| 118 | ioat2_set_chainaddr(ioat, desc->txd.phys); | 114 | ioat2_set_chainaddr(ioat, desc->txd.phys); |
| 119 | dump_desc_dbg(ioat, desc); | 115 | dump_desc_dbg(ioat, desc); |
| 116 | wmb(); | ||
| 117 | ioat->head += 1; | ||
| 120 | __ioat2_issue_pending(ioat); | 118 | __ioat2_issue_pending(ioat); |
| 121 | } | 119 | } |
| 122 | 120 | ||
| 123 | static void ioat2_start_null_desc(struct ioat2_dma_chan *ioat) | 121 | static void ioat2_start_null_desc(struct ioat2_dma_chan *ioat) |
| 124 | { | 122 | { |
| 125 | spin_lock_bh(&ioat->ring_lock); | 123 | spin_lock_bh(&ioat->prep_lock); |
| 126 | __ioat2_start_null_desc(ioat); | 124 | __ioat2_start_null_desc(ioat); |
| 127 | spin_unlock_bh(&ioat->ring_lock); | 125 | spin_unlock_bh(&ioat->prep_lock); |
| 128 | } | 126 | } |
| 129 | 127 | ||
| 130 | static void __cleanup(struct ioat2_dma_chan *ioat, unsigned long phys_complete) | 128 | static void __cleanup(struct ioat2_dma_chan *ioat, unsigned long phys_complete) |
| @@ -134,15 +132,16 @@ static void __cleanup(struct ioat2_dma_chan *ioat, unsigned long phys_complete) | |||
| 134 | struct ioat_ring_ent *desc; | 132 | struct ioat_ring_ent *desc; |
| 135 | bool seen_current = false; | 133 | bool seen_current = false; |
| 136 | u16 active; | 134 | u16 active; |
| 137 | int i; | 135 | int idx = ioat->tail, i; |
| 138 | 136 | ||
| 139 | dev_dbg(to_dev(chan), "%s: head: %#x tail: %#x issued: %#x\n", | 137 | dev_dbg(to_dev(chan), "%s: head: %#x tail: %#x issued: %#x\n", |
| 140 | __func__, ioat->head, ioat->tail, ioat->issued); | 138 | __func__, ioat->head, ioat->tail, ioat->issued); |
| 141 | 139 | ||
| 142 | active = ioat2_ring_active(ioat); | 140 | active = ioat2_ring_active(ioat); |
| 143 | for (i = 0; i < active && !seen_current; i++) { | 141 | for (i = 0; i < active && !seen_current; i++) { |
| 144 | prefetch(ioat2_get_ring_ent(ioat, ioat->tail + i + 1)); | 142 | smp_read_barrier_depends(); |
| 145 | desc = ioat2_get_ring_ent(ioat, ioat->tail + i); | 143 | prefetch(ioat2_get_ring_ent(ioat, idx + i + 1)); |
| 144 | desc = ioat2_get_ring_ent(ioat, idx + i); | ||
| 146 | tx = &desc->txd; | 145 | tx = &desc->txd; |
| 147 | dump_desc_dbg(ioat, desc); | 146 | dump_desc_dbg(ioat, desc); |
| 148 | if (tx->cookie) { | 147 | if (tx->cookie) { |
| @@ -158,11 +157,12 @@ static void __cleanup(struct ioat2_dma_chan *ioat, unsigned long phys_complete) | |||
| 158 | if (tx->phys == phys_complete) | 157 | if (tx->phys == phys_complete) |
| 159 | seen_current = true; | 158 | seen_current = true; |
| 160 | } | 159 | } |
| 161 | ioat->tail += i; | 160 | smp_mb(); /* finish all descriptor reads before incrementing tail */ |
| 161 | ioat->tail = idx + i; | ||
| 162 | BUG_ON(active && !seen_current); /* no active descs have written a completion? */ | 162 | BUG_ON(active && !seen_current); /* no active descs have written a completion? */ |
| 163 | 163 | ||
| 164 | chan->last_completion = phys_complete; | 164 | chan->last_completion = phys_complete; |
| 165 | if (ioat->head == ioat->tail) { | 165 | if (active - i == 0) { |
| 166 | dev_dbg(to_dev(chan), "%s: cancel completion timeout\n", | 166 | dev_dbg(to_dev(chan), "%s: cancel completion timeout\n", |
| 167 | __func__); | 167 | __func__); |
| 168 | clear_bit(IOAT_COMPLETION_PENDING, &chan->state); | 168 | clear_bit(IOAT_COMPLETION_PENDING, &chan->state); |
| @@ -179,24 +179,9 @@ static void ioat2_cleanup(struct ioat2_dma_chan *ioat) | |||
| 179 | struct ioat_chan_common *chan = &ioat->base; | 179 | struct ioat_chan_common *chan = &ioat->base; |
| 180 | unsigned long phys_complete; | 180 | unsigned long phys_complete; |
| 181 | 181 | ||
| 182 | prefetch(chan->completion); | 182 | spin_lock_bh(&chan->cleanup_lock); |
| 183 | 183 | if (ioat_cleanup_preamble(chan, &phys_complete)) | |
| 184 | if (!spin_trylock_bh(&chan->cleanup_lock)) | 184 | __cleanup(ioat, phys_complete); |
| 185 | return; | ||
| 186 | |||
| 187 | if (!ioat_cleanup_preamble(chan, &phys_complete)) { | ||
| 188 | spin_unlock_bh(&chan->cleanup_lock); | ||
| 189 | return; | ||
| 190 | } | ||
| 191 | |||
| 192 | if (!spin_trylock_bh(&ioat->ring_lock)) { | ||
| 193 | spin_unlock_bh(&chan->cleanup_lock); | ||
| 194 | return; | ||
| 195 | } | ||
| 196 | |||
| 197 | __cleanup(ioat, phys_complete); | ||
| 198 | |||
| 199 | spin_unlock_bh(&ioat->ring_lock); | ||
| 200 | spin_unlock_bh(&chan->cleanup_lock); | 185 | spin_unlock_bh(&chan->cleanup_lock); |
| 201 | } | 186 | } |
| 202 | 187 | ||
| @@ -287,12 +272,10 @@ void ioat2_timer_event(unsigned long data) | |||
| 287 | struct ioat2_dma_chan *ioat = to_ioat2_chan((void *) data); | 272 | struct ioat2_dma_chan *ioat = to_ioat2_chan((void *) data); |
| 288 | struct ioat_chan_common *chan = &ioat->base; | 273 | struct ioat_chan_common *chan = &ioat->base; |
| 289 | 274 | ||
| 290 | spin_lock_bh(&chan->cleanup_lock); | ||
| 291 | if (test_bit(IOAT_COMPLETION_PENDING, &chan->state)) { | 275 | if (test_bit(IOAT_COMPLETION_PENDING, &chan->state)) { |
| 292 | unsigned long phys_complete; | 276 | unsigned long phys_complete; |
| 293 | u64 status; | 277 | u64 status; |
| 294 | 278 | ||
| 295 | spin_lock_bh(&ioat->ring_lock); | ||
| 296 | status = ioat_chansts(chan); | 279 | status = ioat_chansts(chan); |
| 297 | 280 | ||
| 298 | /* when halted due to errors check for channel | 281 | /* when halted due to errors check for channel |
| @@ -311,26 +294,31 @@ void ioat2_timer_event(unsigned long data) | |||
| 311 | * acknowledged a pending completion once, then be more | 294 | * acknowledged a pending completion once, then be more |
| 312 | * forceful with a restart | 295 | * forceful with a restart |
| 313 | */ | 296 | */ |
| 314 | if (ioat_cleanup_preamble(chan, &phys_complete)) | 297 | spin_lock_bh(&chan->cleanup_lock); |
| 298 | if (ioat_cleanup_preamble(chan, &phys_complete)) { | ||
| 315 | __cleanup(ioat, phys_complete); | 299 | __cleanup(ioat, phys_complete); |
| 316 | else if (test_bit(IOAT_COMPLETION_ACK, &chan->state)) | 300 | } else if (test_bit(IOAT_COMPLETION_ACK, &chan->state)) { |
| 301 | spin_lock_bh(&ioat->prep_lock); | ||
| 317 | ioat2_restart_channel(ioat); | 302 | ioat2_restart_channel(ioat); |
| 318 | else { | 303 | spin_unlock_bh(&ioat->prep_lock); |
| 304 | } else { | ||
| 319 | set_bit(IOAT_COMPLETION_ACK, &chan->state); | 305 | set_bit(IOAT_COMPLETION_ACK, &chan->state); |
| 320 | mod_timer(&chan->timer, jiffies + COMPLETION_TIMEOUT); | 306 | mod_timer(&chan->timer, jiffies + COMPLETION_TIMEOUT); |
| 321 | } | 307 | } |
| 322 | spin_unlock_bh(&ioat->ring_lock); | 308 | spin_unlock_bh(&chan->cleanup_lock); |
| 323 | } else { | 309 | } else { |
| 324 | u16 active; | 310 | u16 active; |
| 325 | 311 | ||
| 326 | /* if the ring is idle, empty, and oversized try to step | 312 | /* if the ring is idle, empty, and oversized try to step |
| 327 | * down the size | 313 | * down the size |
| 328 | */ | 314 | */ |
| 329 | spin_lock_bh(&ioat->ring_lock); | 315 | spin_lock_bh(&chan->cleanup_lock); |
| 316 | spin_lock_bh(&ioat->prep_lock); | ||
| 330 | active = ioat2_ring_active(ioat); | 317 | active = ioat2_ring_active(ioat); |
| 331 | if (active == 0 && ioat->alloc_order > ioat_get_alloc_order()) | 318 | if (active == 0 && ioat->alloc_order > ioat_get_alloc_order()) |
| 332 | reshape_ring(ioat, ioat->alloc_order-1); | 319 | reshape_ring(ioat, ioat->alloc_order-1); |
| 333 | spin_unlock_bh(&ioat->ring_lock); | 320 | spin_unlock_bh(&ioat->prep_lock); |
| 321 | spin_unlock_bh(&chan->cleanup_lock); | ||
| 334 | 322 | ||
| 335 | /* keep shrinking until we get back to our minimum | 323 | /* keep shrinking until we get back to our minimum |
| 336 | * default size | 324 | * default size |
| @@ -338,7 +326,6 @@ void ioat2_timer_event(unsigned long data) | |||
| 338 | if (ioat->alloc_order > ioat_get_alloc_order()) | 326 | if (ioat->alloc_order > ioat_get_alloc_order()) |
| 339 | mod_timer(&chan->timer, jiffies + IDLE_TIMEOUT); | 327 | mod_timer(&chan->timer, jiffies + IDLE_TIMEOUT); |
| 340 | } | 328 | } |
| 341 | spin_unlock_bh(&chan->cleanup_lock); | ||
| 342 | } | 329 | } |
| 343 | 330 | ||
| 344 | static int ioat2_reset_hw(struct ioat_chan_common *chan) | 331 | static int ioat2_reset_hw(struct ioat_chan_common *chan) |
| @@ -392,7 +379,7 @@ int ioat2_enumerate_channels(struct ioatdma_device *device) | |||
| 392 | 379 | ||
| 393 | ioat_init_channel(device, &ioat->base, i); | 380 | ioat_init_channel(device, &ioat->base, i); |
| 394 | ioat->xfercap_log = xfercap_log; | 381 | ioat->xfercap_log = xfercap_log; |
| 395 | spin_lock_init(&ioat->ring_lock); | 382 | spin_lock_init(&ioat->prep_lock); |
| 396 | if (device->reset_hw(&ioat->base)) { | 383 | if (device->reset_hw(&ioat->base)) { |
| 397 | i = 0; | 384 | i = 0; |
| 398 | break; | 385 | break; |
| @@ -418,8 +405,17 @@ static dma_cookie_t ioat2_tx_submit_unlock(struct dma_async_tx_descriptor *tx) | |||
| 418 | 405 | ||
| 419 | if (!test_and_set_bit(IOAT_COMPLETION_PENDING, &chan->state)) | 406 | if (!test_and_set_bit(IOAT_COMPLETION_PENDING, &chan->state)) |
| 420 | mod_timer(&chan->timer, jiffies + COMPLETION_TIMEOUT); | 407 | mod_timer(&chan->timer, jiffies + COMPLETION_TIMEOUT); |
| 408 | |||
| 409 | /* make descriptor updates visible before advancing ioat->head, | ||
| 410 | * this is purposefully not smp_wmb() since we are also | ||
| 411 | * publishing the descriptor updates to a dma device | ||
| 412 | */ | ||
| 413 | wmb(); | ||
| 414 | |||
| 415 | ioat->head += ioat->produce; | ||
| 416 | |||
| 421 | ioat2_update_pending(ioat); | 417 | ioat2_update_pending(ioat); |
| 422 | spin_unlock_bh(&ioat->ring_lock); | 418 | spin_unlock_bh(&ioat->prep_lock); |
| 423 | 419 | ||
| 424 | return cookie; | 420 | return cookie; |
| 425 | } | 421 | } |
| @@ -531,13 +527,15 @@ int ioat2_alloc_chan_resources(struct dma_chan *c) | |||
| 531 | if (!ring) | 527 | if (!ring) |
| 532 | return -ENOMEM; | 528 | return -ENOMEM; |
| 533 | 529 | ||
| 534 | spin_lock_bh(&ioat->ring_lock); | 530 | spin_lock_bh(&chan->cleanup_lock); |
| 531 | spin_lock_bh(&ioat->prep_lock); | ||
| 535 | ioat->ring = ring; | 532 | ioat->ring = ring; |
| 536 | ioat->head = 0; | 533 | ioat->head = 0; |
| 537 | ioat->issued = 0; | 534 | ioat->issued = 0; |
| 538 | ioat->tail = 0; | 535 | ioat->tail = 0; |
| 539 | ioat->alloc_order = order; | 536 | ioat->alloc_order = order; |
| 540 | spin_unlock_bh(&ioat->ring_lock); | 537 | spin_unlock_bh(&ioat->prep_lock); |
| 538 | spin_unlock_bh(&chan->cleanup_lock); | ||
| 541 | 539 | ||
| 542 | tasklet_enable(&chan->cleanup_task); | 540 | tasklet_enable(&chan->cleanup_task); |
| 543 | ioat2_start_null_desc(ioat); | 541 | ioat2_start_null_desc(ioat); |
| @@ -653,54 +651,61 @@ bool reshape_ring(struct ioat2_dma_chan *ioat, int order) | |||
| 653 | } | 651 | } |
| 654 | 652 | ||
| 655 | /** | 653 | /** |
| 656 | * ioat2_alloc_and_lock - common descriptor alloc boilerplate for ioat2,3 ops | 654 | * ioat2_check_space_lock - verify space and grab ring producer lock |
| 657 | * @idx: gets starting descriptor index on successful allocation | ||
| 658 | * @ioat: ioat2,3 channel (ring) to operate on | 655 | * @ioat: ioat2,3 channel (ring) to operate on |
| 659 | * @num_descs: allocation length | 656 | * @num_descs: allocation length |
| 660 | */ | 657 | */ |
| 661 | int ioat2_alloc_and_lock(u16 *idx, struct ioat2_dma_chan *ioat, int num_descs) | 658 | int ioat2_check_space_lock(struct ioat2_dma_chan *ioat, int num_descs) |
| 662 | { | 659 | { |
| 663 | struct ioat_chan_common *chan = &ioat->base; | 660 | struct ioat_chan_common *chan = &ioat->base; |
| 661 | bool retry; | ||
| 664 | 662 | ||
| 665 | spin_lock_bh(&ioat->ring_lock); | 663 | retry: |
| 664 | spin_lock_bh(&ioat->prep_lock); | ||
| 666 | /* never allow the last descriptor to be consumed, we need at | 665 | /* never allow the last descriptor to be consumed, we need at |
| 667 | * least one free at all times to allow for on-the-fly ring | 666 | * least one free at all times to allow for on-the-fly ring |
| 668 | * resizing. | 667 | * resizing. |
| 669 | */ | 668 | */ |
| 670 | while (unlikely(ioat2_ring_space(ioat) <= num_descs)) { | 669 | if (likely(ioat2_ring_space(ioat) > num_descs)) { |
| 671 | if (reshape_ring(ioat, ioat->alloc_order + 1) && | 670 | dev_dbg(to_dev(chan), "%s: num_descs: %d (%x:%x:%x)\n", |
| 672 | ioat2_ring_space(ioat) > num_descs) | 671 | __func__, num_descs, ioat->head, ioat->tail, ioat->issued); |
| 673 | break; | 672 | ioat->produce = num_descs; |
| 674 | 673 | return 0; /* with ioat->prep_lock held */ | |
| 675 | if (printk_ratelimit()) | ||
| 676 | dev_dbg(to_dev(chan), | ||
| 677 | "%s: ring full! num_descs: %d (%x:%x:%x)\n", | ||
| 678 | __func__, num_descs, ioat->head, ioat->tail, | ||
| 679 | ioat->issued); | ||
| 680 | spin_unlock_bh(&ioat->ring_lock); | ||
| 681 | |||
| 682 | /* progress reclaim in the allocation failure case we | ||
| 683 | * may be called under bh_disabled so we need to trigger | ||
| 684 | * the timer event directly | ||
| 685 | */ | ||
| 686 | spin_lock_bh(&chan->cleanup_lock); | ||
| 687 | if (jiffies > chan->timer.expires && | ||
| 688 | timer_pending(&chan->timer)) { | ||
| 689 | struct ioatdma_device *device = chan->device; | ||
| 690 | |||
| 691 | mod_timer(&chan->timer, jiffies + COMPLETION_TIMEOUT); | ||
| 692 | spin_unlock_bh(&chan->cleanup_lock); | ||
| 693 | device->timer_fn((unsigned long) &chan->common); | ||
| 694 | } else | ||
| 695 | spin_unlock_bh(&chan->cleanup_lock); | ||
| 696 | return -ENOMEM; | ||
| 697 | } | 674 | } |
| 675 | retry = test_and_set_bit(IOAT_RESHAPE_PENDING, &chan->state); | ||
| 676 | spin_unlock_bh(&ioat->prep_lock); | ||
| 698 | 677 | ||
| 699 | dev_dbg(to_dev(chan), "%s: num_descs: %d (%x:%x:%x)\n", | 678 | /* is another cpu already trying to expand the ring? */ |
| 700 | __func__, num_descs, ioat->head, ioat->tail, ioat->issued); | 679 | if (retry) |
| 680 | goto retry; | ||
| 701 | 681 | ||
| 702 | *idx = ioat2_desc_alloc(ioat, num_descs); | 682 | spin_lock_bh(&chan->cleanup_lock); |
| 703 | return 0; /* with ioat->ring_lock held */ | 683 | spin_lock_bh(&ioat->prep_lock); |
| 684 | retry = reshape_ring(ioat, ioat->alloc_order + 1); | ||
| 685 | clear_bit(IOAT_RESHAPE_PENDING, &chan->state); | ||
| 686 | spin_unlock_bh(&ioat->prep_lock); | ||
| 687 | spin_unlock_bh(&chan->cleanup_lock); | ||
| 688 | |||
| 689 | /* if we were able to expand the ring retry the allocation */ | ||
| 690 | if (retry) | ||
| 691 | goto retry; | ||
| 692 | |||
| 693 | if (printk_ratelimit()) | ||
| 694 | dev_dbg(to_dev(chan), "%s: ring full! num_descs: %d (%x:%x:%x)\n", | ||
| 695 | __func__, num_descs, ioat->head, ioat->tail, ioat->issued); | ||
| 696 | |||
| 697 | /* progress reclaim in the allocation failure case we may be | ||
| 698 | * called under bh_disabled so we need to trigger the timer | ||
| 699 | * event directly | ||
| 700 | */ | ||
| 701 | if (jiffies > chan->timer.expires && timer_pending(&chan->timer)) { | ||
| 702 | struct ioatdma_device *device = chan->device; | ||
| 703 | |||
| 704 | mod_timer(&chan->timer, jiffies + COMPLETION_TIMEOUT); | ||
| 705 | device->timer_fn((unsigned long) &chan->common); | ||
| 706 | } | ||
| 707 | |||
| 708 | return -ENOMEM; | ||
| 704 | } | 709 | } |
| 705 | 710 | ||
| 706 | struct dma_async_tx_descriptor * | 711 | struct dma_async_tx_descriptor * |
| @@ -713,14 +718,11 @@ ioat2_dma_prep_memcpy_lock(struct dma_chan *c, dma_addr_t dma_dest, | |||
| 713 | dma_addr_t dst = dma_dest; | 718 | dma_addr_t dst = dma_dest; |
| 714 | dma_addr_t src = dma_src; | 719 | dma_addr_t src = dma_src; |
| 715 | size_t total_len = len; | 720 | size_t total_len = len; |
| 716 | int num_descs; | 721 | int num_descs, idx, i; |
| 717 | u16 idx; | ||
| 718 | int i; | ||
| 719 | 722 | ||
| 720 | num_descs = ioat2_xferlen_to_descs(ioat, len); | 723 | num_descs = ioat2_xferlen_to_descs(ioat, len); |
| 721 | if (likely(num_descs) && | 724 | if (likely(num_descs) && ioat2_check_space_lock(ioat, num_descs) == 0) |
| 722 | ioat2_alloc_and_lock(&idx, ioat, num_descs) == 0) | 725 | idx = ioat->head; |
| 723 | /* pass */; | ||
| 724 | else | 726 | else |
| 725 | return NULL; | 727 | return NULL; |
| 726 | i = 0; | 728 | i = 0; |
| @@ -777,7 +779,8 @@ void ioat2_free_chan_resources(struct dma_chan *c) | |||
| 777 | device->cleanup_fn((unsigned long) c); | 779 | device->cleanup_fn((unsigned long) c); |
| 778 | device->reset_hw(chan); | 780 | device->reset_hw(chan); |
| 779 | 781 | ||
| 780 | spin_lock_bh(&ioat->ring_lock); | 782 | spin_lock_bh(&chan->cleanup_lock); |
| 783 | spin_lock_bh(&ioat->prep_lock); | ||
| 781 | descs = ioat2_ring_space(ioat); | 784 | descs = ioat2_ring_space(ioat); |
| 782 | dev_dbg(to_dev(chan), "freeing %d idle descriptors\n", descs); | 785 | dev_dbg(to_dev(chan), "freeing %d idle descriptors\n", descs); |
| 783 | for (i = 0; i < descs; i++) { | 786 | for (i = 0; i < descs; i++) { |
| @@ -800,7 +803,8 @@ void ioat2_free_chan_resources(struct dma_chan *c) | |||
| 800 | ioat->alloc_order = 0; | 803 | ioat->alloc_order = 0; |
| 801 | pci_pool_free(device->completion_pool, chan->completion, | 804 | pci_pool_free(device->completion_pool, chan->completion, |
| 802 | chan->completion_dma); | 805 | chan->completion_dma); |
| 803 | spin_unlock_bh(&ioat->ring_lock); | 806 | spin_unlock_bh(&ioat->prep_lock); |
| 807 | spin_unlock_bh(&chan->cleanup_lock); | ||
| 804 | 808 | ||
| 805 | chan->last_completion = 0; | 809 | chan->last_completion = 0; |
| 806 | chan->completion_dma = 0; | 810 | chan->completion_dma = 0; |
diff --git a/drivers/dma/ioat/dma_v2.h b/drivers/dma/ioat/dma_v2.h index d7b64f188f78..a2c413b2b8d8 100644 --- a/drivers/dma/ioat/dma_v2.h +++ b/drivers/dma/ioat/dma_v2.h | |||
| @@ -50,8 +50,9 @@ extern int ioat_ring_alloc_order; | |||
| 50 | * @tail: cleanup index | 50 | * @tail: cleanup index |
| 51 | * @dmacount: identical to 'head' except for occasionally resetting to zero | 51 | * @dmacount: identical to 'head' except for occasionally resetting to zero |
| 52 | * @alloc_order: log2 of the number of allocated descriptors | 52 | * @alloc_order: log2 of the number of allocated descriptors |
| 53 | * @produce: number of descriptors to produce at submit time | ||
| 53 | * @ring: software ring buffer implementation of hardware ring | 54 | * @ring: software ring buffer implementation of hardware ring |
| 54 | * @ring_lock: protects ring attributes | 55 | * @prep_lock: serializes descriptor preparation (producers) |
| 55 | */ | 56 | */ |
| 56 | struct ioat2_dma_chan { | 57 | struct ioat2_dma_chan { |
| 57 | struct ioat_chan_common base; | 58 | struct ioat_chan_common base; |
| @@ -61,8 +62,9 @@ struct ioat2_dma_chan { | |||
| 61 | u16 tail; | 62 | u16 tail; |
| 62 | u16 dmacount; | 63 | u16 dmacount; |
| 63 | u16 alloc_order; | 64 | u16 alloc_order; |
| 65 | u16 produce; | ||
| 64 | struct ioat_ring_ent **ring; | 66 | struct ioat_ring_ent **ring; |
| 65 | spinlock_t ring_lock; | 67 | spinlock_t prep_lock; |
| 66 | }; | 68 | }; |
| 67 | 69 | ||
| 68 | static inline struct ioat2_dma_chan *to_ioat2_chan(struct dma_chan *c) | 70 | static inline struct ioat2_dma_chan *to_ioat2_chan(struct dma_chan *c) |
| @@ -94,13 +96,6 @@ static inline u16 ioat2_ring_space(struct ioat2_dma_chan *ioat) | |||
| 94 | return ioat2_ring_size(ioat) - ioat2_ring_active(ioat); | 96 | return ioat2_ring_size(ioat) - ioat2_ring_active(ioat); |
| 95 | } | 97 | } |
| 96 | 98 | ||
| 97 | /* assumes caller already checked space */ | ||
| 98 | static inline u16 ioat2_desc_alloc(struct ioat2_dma_chan *ioat, u16 len) | ||
| 99 | { | ||
| 100 | ioat->head += len; | ||
| 101 | return ioat->head - len; | ||
| 102 | } | ||
| 103 | |||
| 104 | static inline u16 ioat2_xferlen_to_descs(struct ioat2_dma_chan *ioat, size_t len) | 99 | static inline u16 ioat2_xferlen_to_descs(struct ioat2_dma_chan *ioat, size_t len) |
| 105 | { | 100 | { |
| 106 | u16 num_descs = len >> ioat->xfercap_log; | 101 | u16 num_descs = len >> ioat->xfercap_log; |
| @@ -164,7 +159,7 @@ int __devinit ioat2_dma_probe(struct ioatdma_device *dev, int dca); | |||
| 164 | int __devinit ioat3_dma_probe(struct ioatdma_device *dev, int dca); | 159 | int __devinit ioat3_dma_probe(struct ioatdma_device *dev, int dca); |
| 165 | struct dca_provider * __devinit ioat2_dca_init(struct pci_dev *pdev, void __iomem *iobase); | 160 | struct dca_provider * __devinit ioat2_dca_init(struct pci_dev *pdev, void __iomem *iobase); |
| 166 | struct dca_provider * __devinit ioat3_dca_init(struct pci_dev *pdev, void __iomem *iobase); | 161 | struct dca_provider * __devinit ioat3_dca_init(struct pci_dev *pdev, void __iomem *iobase); |
| 167 | int ioat2_alloc_and_lock(u16 *idx, struct ioat2_dma_chan *ioat, int num_descs); | 162 | int ioat2_check_space_lock(struct ioat2_dma_chan *ioat, int num_descs); |
| 168 | int ioat2_enumerate_channels(struct ioatdma_device *device); | 163 | int ioat2_enumerate_channels(struct ioatdma_device *device); |
| 169 | struct dma_async_tx_descriptor * | 164 | struct dma_async_tx_descriptor * |
| 170 | ioat2_dma_prep_memcpy_lock(struct dma_chan *c, dma_addr_t dma_dest, | 165 | ioat2_dma_prep_memcpy_lock(struct dma_chan *c, dma_addr_t dma_dest, |
diff --git a/drivers/dma/ioat/dma_v3.c b/drivers/dma/ioat/dma_v3.c index 6740e319c9cf..8b573fac2a25 100644 --- a/drivers/dma/ioat/dma_v3.c +++ b/drivers/dma/ioat/dma_v3.c | |||
| @@ -260,8 +260,8 @@ static void __cleanup(struct ioat2_dma_chan *ioat, unsigned long phys_complete) | |||
| 260 | struct ioat_chan_common *chan = &ioat->base; | 260 | struct ioat_chan_common *chan = &ioat->base; |
| 261 | struct ioat_ring_ent *desc; | 261 | struct ioat_ring_ent *desc; |
| 262 | bool seen_current = false; | 262 | bool seen_current = false; |
| 263 | int idx = ioat->tail, i; | ||
| 263 | u16 active; | 264 | u16 active; |
| 264 | int i; | ||
| 265 | 265 | ||
| 266 | dev_dbg(to_dev(chan), "%s: head: %#x tail: %#x issued: %#x\n", | 266 | dev_dbg(to_dev(chan), "%s: head: %#x tail: %#x issued: %#x\n", |
| 267 | __func__, ioat->head, ioat->tail, ioat->issued); | 267 | __func__, ioat->head, ioat->tail, ioat->issued); |
| @@ -270,13 +270,14 @@ static void __cleanup(struct ioat2_dma_chan *ioat, unsigned long phys_complete) | |||
| 270 | for (i = 0; i < active && !seen_current; i++) { | 270 | for (i = 0; i < active && !seen_current; i++) { |
| 271 | struct dma_async_tx_descriptor *tx; | 271 | struct dma_async_tx_descriptor *tx; |
| 272 | 272 | ||
| 273 | prefetch(ioat2_get_ring_ent(ioat, ioat->tail + i + 1)); | 273 | smp_read_barrier_depends(); |
| 274 | desc = ioat2_get_ring_ent(ioat, ioat->tail + i); | 274 | prefetch(ioat2_get_ring_ent(ioat, idx + i + 1)); |
| 275 | desc = ioat2_get_ring_ent(ioat, idx + i); | ||
| 275 | dump_desc_dbg(ioat, desc); | 276 | dump_desc_dbg(ioat, desc); |
| 276 | tx = &desc->txd; | 277 | tx = &desc->txd; |
| 277 | if (tx->cookie) { | 278 | if (tx->cookie) { |
| 278 | chan->completed_cookie = tx->cookie; | 279 | chan->completed_cookie = tx->cookie; |
| 279 | ioat3_dma_unmap(ioat, desc, ioat->tail + i); | 280 | ioat3_dma_unmap(ioat, desc, idx + i); |
| 280 | tx->cookie = 0; | 281 | tx->cookie = 0; |
| 281 | if (tx->callback) { | 282 | if (tx->callback) { |
| 282 | tx->callback(tx->callback_param); | 283 | tx->callback(tx->callback_param); |
| @@ -293,69 +294,30 @@ static void __cleanup(struct ioat2_dma_chan *ioat, unsigned long phys_complete) | |||
| 293 | i++; | 294 | i++; |
| 294 | } | 295 | } |
| 295 | } | 296 | } |
| 296 | ioat->tail += i; | 297 | smp_mb(); /* finish all descriptor reads before incrementing tail */ |
| 298 | ioat->tail = idx + i; | ||
| 297 | BUG_ON(active && !seen_current); /* no active descs have written a completion? */ | 299 | BUG_ON(active && !seen_current); /* no active descs have written a completion? */ |
| 298 | chan->last_completion = phys_complete; | 300 | chan->last_completion = phys_complete; |
| 299 | 301 | ||
| 300 | active = ioat2_ring_active(ioat); | 302 | if (active - i == 0) { |
| 301 | if (active == 0) { | ||
| 302 | dev_dbg(to_dev(chan), "%s: cancel completion timeout\n", | 303 | dev_dbg(to_dev(chan), "%s: cancel completion timeout\n", |
| 303 | __func__); | 304 | __func__); |
| 304 | clear_bit(IOAT_COMPLETION_PENDING, &chan->state); | 305 | clear_bit(IOAT_COMPLETION_PENDING, &chan->state); |
| 305 | mod_timer(&chan->timer, jiffies + IDLE_TIMEOUT); | 306 | mod_timer(&chan->timer, jiffies + IDLE_TIMEOUT); |
| 306 | } | 307 | } |
| 307 | /* 5 microsecond delay per pending descriptor */ | 308 | /* 5 microsecond delay per pending descriptor */ |
| 308 | writew(min((5 * active), IOAT_INTRDELAY_MASK), | 309 | writew(min((5 * (active - i)), IOAT_INTRDELAY_MASK), |
| 309 | chan->device->reg_base + IOAT_INTRDELAY_OFFSET); | 310 | chan->device->reg_base + IOAT_INTRDELAY_OFFSET); |
| 310 | } | 311 | } |
| 311 | 312 | ||
| 312 | /* try to cleanup, but yield (via spin_trylock) to incoming submissions | 313 | static void ioat3_cleanup(struct ioat2_dma_chan *ioat) |
| 313 | * with the expectation that we will immediately poll again shortly | ||
| 314 | */ | ||
| 315 | static void ioat3_cleanup_poll(struct ioat2_dma_chan *ioat) | ||
| 316 | { | 314 | { |
| 317 | struct ioat_chan_common *chan = &ioat->base; | 315 | struct ioat_chan_common *chan = &ioat->base; |
| 318 | unsigned long phys_complete; | 316 | unsigned long phys_complete; |
| 319 | 317 | ||
| 320 | prefetch(chan->completion); | ||
| 321 | |||
| 322 | if (!spin_trylock_bh(&chan->cleanup_lock)) | ||
| 323 | return; | ||
| 324 | |||
| 325 | if (!ioat_cleanup_preamble(chan, &phys_complete)) { | ||
| 326 | spin_unlock_bh(&chan->cleanup_lock); | ||
| 327 | return; | ||
| 328 | } | ||
| 329 | |||
| 330 | if (!spin_trylock_bh(&ioat->ring_lock)) { | ||
| 331 | spin_unlock_bh(&chan->cleanup_lock); | ||
| 332 | return; | ||
| 333 | } | ||
| 334 | |||
| 335 | __cleanup(ioat, phys_complete); | ||
| 336 | |||
| 337 | spin_unlock_bh(&ioat->ring_lock); | ||
| 338 | spin_unlock_bh(&chan->cleanup_lock); | ||
| 339 | } | ||
| 340 | |||
| 341 | /* run cleanup now because we already delayed the interrupt via INTRDELAY */ | ||
| 342 | static void ioat3_cleanup_sync(struct ioat2_dma_chan *ioat) | ||
| 343 | { | ||
| 344 | struct ioat_chan_common *chan = &ioat->base; | ||
| 345 | unsigned long phys_complete; | ||
| 346 | |||
| 347 | prefetch(chan->completion); | ||
| 348 | |||
| 349 | spin_lock_bh(&chan->cleanup_lock); | 318 | spin_lock_bh(&chan->cleanup_lock); |
| 350 | if (!ioat_cleanup_preamble(chan, &phys_complete)) { | 319 | if (ioat_cleanup_preamble(chan, &phys_complete)) |
| 351 | spin_unlock_bh(&chan->cleanup_lock); | 320 | __cleanup(ioat, phys_complete); |
| 352 | return; | ||
| 353 | } | ||
| 354 | spin_lock_bh(&ioat->ring_lock); | ||
| 355 | |||
| 356 | __cleanup(ioat, phys_complete); | ||
| 357 | |||
| 358 | spin_unlock_bh(&ioat->ring_lock); | ||
| 359 | spin_unlock_bh(&chan->cleanup_lock); | 321 | spin_unlock_bh(&chan->cleanup_lock); |
| 360 | } | 322 | } |
| 361 | 323 | ||
| @@ -363,7 +325,7 @@ static void ioat3_cleanup_event(unsigned long data) | |||
| 363 | { | 325 | { |
| 364 | struct ioat2_dma_chan *ioat = to_ioat2_chan((void *) data); | 326 | struct ioat2_dma_chan *ioat = to_ioat2_chan((void *) data); |
| 365 | 327 | ||
| 366 | ioat3_cleanup_sync(ioat); | 328 | ioat3_cleanup(ioat); |
| 367 | writew(IOAT_CHANCTRL_RUN, ioat->base.reg_base + IOAT_CHANCTRL_OFFSET); | 329 | writew(IOAT_CHANCTRL_RUN, ioat->base.reg_base + IOAT_CHANCTRL_OFFSET); |
| 368 | } | 330 | } |
| 369 | 331 | ||
| @@ -384,12 +346,10 @@ static void ioat3_timer_event(unsigned long data) | |||
| 384 | struct ioat2_dma_chan *ioat = to_ioat2_chan((void *) data); | 346 | struct ioat2_dma_chan *ioat = to_ioat2_chan((void *) data); |
| 385 | struct ioat_chan_common *chan = &ioat->base; | 347 | struct ioat_chan_common *chan = &ioat->base; |
| 386 | 348 | ||
| 387 | spin_lock_bh(&chan->cleanup_lock); | ||
| 388 | if (test_bit(IOAT_COMPLETION_PENDING, &chan->state)) { | 349 | if (test_bit(IOAT_COMPLETION_PENDING, &chan->state)) { |
| 389 | unsigned long phys_complete; | 350 | unsigned long phys_complete; |
| 390 | u64 status; | 351 | u64 status; |
| 391 | 352 | ||
| 392 | spin_lock_bh(&ioat->ring_lock); | ||
| 393 | status = ioat_chansts(chan); | 353 | status = ioat_chansts(chan); |
| 394 | 354 | ||
| 395 | /* when halted due to errors check for channel | 355 | /* when halted due to errors check for channel |
| @@ -408,26 +368,31 @@ static void ioat3_timer_event(unsigned long data) | |||
| 408 | * acknowledged a pending completion once, then be more | 368 | * acknowledged a pending completion once, then be more |
| 409 | * forceful with a restart | 369 | * forceful with a restart |
| 410 | */ | 370 | */ |
| 371 | spin_lock_bh(&chan->cleanup_lock); | ||
| 411 | if (ioat_cleanup_preamble(chan, &phys_complete)) | 372 | if (ioat_cleanup_preamble(chan, &phys_complete)) |
| 412 | __cleanup(ioat, phys_complete); | 373 | __cleanup(ioat, phys_complete); |
| 413 | else if (test_bit(IOAT_COMPLETION_ACK, &chan->state)) | 374 | else if (test_bit(IOAT_COMPLETION_ACK, &chan->state)) { |
| 375 | spin_lock_bh(&ioat->prep_lock); | ||
| 414 | ioat3_restart_channel(ioat); | 376 | ioat3_restart_channel(ioat); |
| 415 | else { | 377 | spin_unlock_bh(&ioat->prep_lock); |
| 378 | } else { | ||
| 416 | set_bit(IOAT_COMPLETION_ACK, &chan->state); | 379 | set_bit(IOAT_COMPLETION_ACK, &chan->state); |
| 417 | mod_timer(&chan->timer, jiffies + COMPLETION_TIMEOUT); | 380 | mod_timer(&chan->timer, jiffies + COMPLETION_TIMEOUT); |
| 418 | } | 381 | } |
| 419 | spin_unlock_bh(&ioat->ring_lock); | 382 | spin_unlock_bh(&chan->cleanup_lock); |
| 420 | } else { | 383 | } else { |
| 421 | u16 active; | 384 | u16 active; |
| 422 | 385 | ||
| 423 | /* if the ring is idle, empty, and oversized try to step | 386 | /* if the ring is idle, empty, and oversized try to step |
| 424 | * down the size | 387 | * down the size |
| 425 | */ | 388 | */ |
| 426 | spin_lock_bh(&ioat->ring_lock); | 389 | spin_lock_bh(&chan->cleanup_lock); |
| 390 | spin_lock_bh(&ioat->prep_lock); | ||
| 427 | active = ioat2_ring_active(ioat); | 391 | active = ioat2_ring_active(ioat); |
| 428 | if (active == 0 && ioat->alloc_order > ioat_get_alloc_order()) | 392 | if (active == 0 && ioat->alloc_order > ioat_get_alloc_order()) |
| 429 | reshape_ring(ioat, ioat->alloc_order-1); | 393 | reshape_ring(ioat, ioat->alloc_order-1); |
| 430 | spin_unlock_bh(&ioat->ring_lock); | 394 | spin_unlock_bh(&ioat->prep_lock); |
| 395 | spin_unlock_bh(&chan->cleanup_lock); | ||
| 431 | 396 | ||
| 432 | /* keep shrinking until we get back to our minimum | 397 | /* keep shrinking until we get back to our minimum |
| 433 | * default size | 398 | * default size |
| @@ -435,7 +400,6 @@ static void ioat3_timer_event(unsigned long data) | |||
| 435 | if (ioat->alloc_order > ioat_get_alloc_order()) | 400 | if (ioat->alloc_order > ioat_get_alloc_order()) |
| 436 | mod_timer(&chan->timer, jiffies + IDLE_TIMEOUT); | 401 | mod_timer(&chan->timer, jiffies + IDLE_TIMEOUT); |
| 437 | } | 402 | } |
| 438 | spin_unlock_bh(&chan->cleanup_lock); | ||
| 439 | } | 403 | } |
| 440 | 404 | ||
| 441 | static enum dma_status | 405 | static enum dma_status |
| @@ -447,7 +411,7 @@ ioat3_is_complete(struct dma_chan *c, dma_cookie_t cookie, | |||
| 447 | if (ioat_is_complete(c, cookie, done, used) == DMA_SUCCESS) | 411 | if (ioat_is_complete(c, cookie, done, used) == DMA_SUCCESS) |
| 448 | return DMA_SUCCESS; | 412 | return DMA_SUCCESS; |
| 449 | 413 | ||
| 450 | ioat3_cleanup_poll(ioat); | 414 | ioat3_cleanup(ioat); |
| 451 | 415 | ||
| 452 | return ioat_is_complete(c, cookie, done, used); | 416 | return ioat_is_complete(c, cookie, done, used); |
| 453 | } | 417 | } |
| @@ -460,15 +424,12 @@ ioat3_prep_memset_lock(struct dma_chan *c, dma_addr_t dest, int value, | |||
| 460 | struct ioat_ring_ent *desc; | 424 | struct ioat_ring_ent *desc; |
| 461 | size_t total_len = len; | 425 | size_t total_len = len; |
| 462 | struct ioat_fill_descriptor *fill; | 426 | struct ioat_fill_descriptor *fill; |
| 463 | int num_descs; | ||
| 464 | u64 src_data = (0x0101010101010101ULL) * (value & 0xff); | 427 | u64 src_data = (0x0101010101010101ULL) * (value & 0xff); |
| 465 | u16 idx; | 428 | int num_descs, idx, i; |
| 466 | int i; | ||
| 467 | 429 | ||
| 468 | num_descs = ioat2_xferlen_to_descs(ioat, len); | 430 | num_descs = ioat2_xferlen_to_descs(ioat, len); |
| 469 | if (likely(num_descs) && | 431 | if (likely(num_descs) && ioat2_check_space_lock(ioat, num_descs) == 0) |
| 470 | ioat2_alloc_and_lock(&idx, ioat, num_descs) == 0) | 432 | idx = ioat->head; |
| 471 | /* pass */; | ||
| 472 | else | 433 | else |
| 473 | return NULL; | 434 | return NULL; |
| 474 | i = 0; | 435 | i = 0; |
| @@ -513,11 +474,8 @@ __ioat3_prep_xor_lock(struct dma_chan *c, enum sum_check_flags *result, | |||
| 513 | struct ioat_xor_descriptor *xor; | 474 | struct ioat_xor_descriptor *xor; |
| 514 | struct ioat_xor_ext_descriptor *xor_ex = NULL; | 475 | struct ioat_xor_ext_descriptor *xor_ex = NULL; |
| 515 | struct ioat_dma_descriptor *hw; | 476 | struct ioat_dma_descriptor *hw; |
| 477 | int num_descs, with_ext, idx, i; | ||
| 516 | u32 offset = 0; | 478 | u32 offset = 0; |
| 517 | int num_descs; | ||
| 518 | int with_ext; | ||
| 519 | int i; | ||
| 520 | u16 idx; | ||
| 521 | u8 op = result ? IOAT_OP_XOR_VAL : IOAT_OP_XOR; | 479 | u8 op = result ? IOAT_OP_XOR_VAL : IOAT_OP_XOR; |
| 522 | 480 | ||
| 523 | BUG_ON(src_cnt < 2); | 481 | BUG_ON(src_cnt < 2); |
| @@ -537,9 +495,8 @@ __ioat3_prep_xor_lock(struct dma_chan *c, enum sum_check_flags *result, | |||
| 537 | * (legacy) descriptor to ensure all completion writes arrive in | 495 | * (legacy) descriptor to ensure all completion writes arrive in |
| 538 | * order. | 496 | * order. |
| 539 | */ | 497 | */ |
| 540 | if (likely(num_descs) && | 498 | if (likely(num_descs) && ioat2_check_space_lock(ioat, num_descs+1) == 0) |
| 541 | ioat2_alloc_and_lock(&idx, ioat, num_descs+1) == 0) | 499 | idx = ioat->head; |
| 542 | /* pass */; | ||
| 543 | else | 500 | else |
| 544 | return NULL; | 501 | return NULL; |
| 545 | i = 0; | 502 | i = 0; |
| @@ -657,11 +614,8 @@ __ioat3_prep_pq_lock(struct dma_chan *c, enum sum_check_flags *result, | |||
| 657 | struct ioat_pq_ext_descriptor *pq_ex = NULL; | 614 | struct ioat_pq_ext_descriptor *pq_ex = NULL; |
| 658 | struct ioat_dma_descriptor *hw; | 615 | struct ioat_dma_descriptor *hw; |
| 659 | u32 offset = 0; | 616 | u32 offset = 0; |
| 660 | int num_descs; | ||
| 661 | int with_ext; | ||
| 662 | int i, s; | ||
| 663 | u16 idx; | ||
| 664 | u8 op = result ? IOAT_OP_PQ_VAL : IOAT_OP_PQ; | 617 | u8 op = result ? IOAT_OP_PQ_VAL : IOAT_OP_PQ; |
| 618 | int i, s, idx, with_ext, num_descs; | ||
| 665 | 619 | ||
| 666 | dev_dbg(to_dev(chan), "%s\n", __func__); | 620 | dev_dbg(to_dev(chan), "%s\n", __func__); |
| 667 | /* the engine requires at least two sources (we provide | 621 | /* the engine requires at least two sources (we provide |
| @@ -687,8 +641,8 @@ __ioat3_prep_pq_lock(struct dma_chan *c, enum sum_check_flags *result, | |||
| 687 | * order. | 641 | * order. |
| 688 | */ | 642 | */ |
| 689 | if (likely(num_descs) && | 643 | if (likely(num_descs) && |
| 690 | ioat2_alloc_and_lock(&idx, ioat, num_descs+1) == 0) | 644 | ioat2_check_space_lock(ioat, num_descs+1) == 0) |
| 691 | /* pass */; | 645 | idx = ioat->head; |
| 692 | else | 646 | else |
| 693 | return NULL; | 647 | return NULL; |
| 694 | i = 0; | 648 | i = 0; |
| @@ -851,10 +805,9 @@ ioat3_prep_interrupt_lock(struct dma_chan *c, unsigned long flags) | |||
| 851 | struct ioat2_dma_chan *ioat = to_ioat2_chan(c); | 805 | struct ioat2_dma_chan *ioat = to_ioat2_chan(c); |
| 852 | struct ioat_ring_ent *desc; | 806 | struct ioat_ring_ent *desc; |
| 853 | struct ioat_dma_descriptor *hw; | 807 | struct ioat_dma_descriptor *hw; |
| 854 | u16 idx; | ||
| 855 | 808 | ||
| 856 | if (ioat2_alloc_and_lock(&idx, ioat, 1) == 0) | 809 | if (ioat2_check_space_lock(ioat, 1) == 0) |
| 857 | desc = ioat2_get_ring_ent(ioat, idx); | 810 | desc = ioat2_get_ring_ent(ioat, ioat->head); |
| 858 | else | 811 | else |
| 859 | return NULL; | 812 | return NULL; |
| 860 | 813 | ||
