aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/ioat/dma.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/dma/ioat/dma.c')
-rw-r--r--drivers/dma/ioat/dma.c46
1 files changed, 20 insertions, 26 deletions
diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c
index dcc4ab78b32..5d0e42b263d 100644
--- a/drivers/dma/ioat/dma.c
+++ b/drivers/dma/ioat/dma.c
@@ -94,16 +94,12 @@ static irqreturn_t ioat_dma_do_interrupt_msix(int irq, void *data)
94 return IRQ_HANDLED; 94 return IRQ_HANDLED;
95} 95}
96 96
97static void ioat1_cleanup_tasklet(unsigned long data);
98
99/* common channel initialization */ 97/* common channel initialization */
100void ioat_init_channel(struct ioatdma_device *device, 98void ioat_init_channel(struct ioatdma_device *device, struct ioat_chan_common *chan, int idx)
101 struct ioat_chan_common *chan, int idx,
102 void (*timer_fn)(unsigned long),
103 void (*tasklet)(unsigned long),
104 unsigned long ioat)
105{ 99{
106 struct dma_device *dma = &device->common; 100 struct dma_device *dma = &device->common;
101 struct dma_chan *c = &chan->common;
102 unsigned long data = (unsigned long) c;
107 103
108 chan->device = device; 104 chan->device = device;
109 chan->reg_base = device->reg_base + (0x80 * (idx + 1)); 105 chan->reg_base = device->reg_base + (0x80 * (idx + 1));
@@ -112,14 +108,12 @@ void ioat_init_channel(struct ioatdma_device *device,
112 list_add_tail(&chan->common.device_node, &dma->channels); 108 list_add_tail(&chan->common.device_node, &dma->channels);
113 device->idx[idx] = chan; 109 device->idx[idx] = chan;
114 init_timer(&chan->timer); 110 init_timer(&chan->timer);
115 chan->timer.function = timer_fn; 111 chan->timer.function = device->timer_fn;
116 chan->timer.data = ioat; 112 chan->timer.data = data;
117 tasklet_init(&chan->cleanup_task, tasklet, ioat); 113 tasklet_init(&chan->cleanup_task, device->cleanup_fn, data);
118 tasklet_disable(&chan->cleanup_task); 114 tasklet_disable(&chan->cleanup_task);
119} 115}
120 116
121static void ioat1_timer_event(unsigned long data);
122
123/** 117/**
124 * ioat1_dma_enumerate_channels - find and initialize the device's channels 118 * ioat1_dma_enumerate_channels - find and initialize the device's channels
125 * @device: the device to be enumerated 119 * @device: the device to be enumerated
@@ -155,10 +149,7 @@ static int ioat1_enumerate_channels(struct ioatdma_device *device)
155 if (!ioat) 149 if (!ioat)
156 break; 150 break;
157 151
158 ioat_init_channel(device, &ioat->base, i, 152 ioat_init_channel(device, &ioat->base, i);
159 ioat1_timer_event,
160 ioat1_cleanup_tasklet,
161 (unsigned long) ioat);
162 ioat->xfercap = xfercap; 153 ioat->xfercap = xfercap;
163 spin_lock_init(&ioat->desc_lock); 154 spin_lock_init(&ioat->desc_lock);
164 INIT_LIST_HEAD(&ioat->free_desc); 155 INIT_LIST_HEAD(&ioat->free_desc);
@@ -532,12 +523,12 @@ ioat1_dma_prep_memcpy(struct dma_chan *c, dma_addr_t dma_dest,
532 return &desc->txd; 523 return &desc->txd;
533} 524}
534 525
535static void ioat1_cleanup_tasklet(unsigned long data) 526static void ioat1_cleanup_event(unsigned long data)
536{ 527{
537 struct ioat_dma_chan *chan = (void *)data; 528 struct ioat_dma_chan *ioat = to_ioat_chan((void *) data);
538 529
539 ioat1_cleanup(chan); 530 ioat1_cleanup(ioat);
540 writew(IOAT_CHANCTRL_RUN, chan->base.reg_base + IOAT_CHANCTRL_OFFSET); 531 writew(IOAT_CHANCTRL_RUN, ioat->base.reg_base + IOAT_CHANCTRL_OFFSET);
541} 532}
542 533
543void ioat_dma_unmap(struct ioat_chan_common *chan, enum dma_ctrl_flags flags, 534void ioat_dma_unmap(struct ioat_chan_common *chan, enum dma_ctrl_flags flags,
@@ -687,7 +678,7 @@ static void ioat1_cleanup(struct ioat_dma_chan *ioat)
687 678
688static void ioat1_timer_event(unsigned long data) 679static void ioat1_timer_event(unsigned long data)
689{ 680{
690 struct ioat_dma_chan *ioat = (void *) data; 681 struct ioat_dma_chan *ioat = to_ioat_chan((void *) data);
691 struct ioat_chan_common *chan = &ioat->base; 682 struct ioat_chan_common *chan = &ioat->base;
692 683
693 dev_dbg(to_dev(chan), "%s: state: %lx\n", __func__, chan->state); 684 dev_dbg(to_dev(chan), "%s: state: %lx\n", __func__, chan->state);
@@ -734,16 +725,17 @@ static void ioat1_timer_event(unsigned long data)
734 spin_unlock_bh(&chan->cleanup_lock); 725 spin_unlock_bh(&chan->cleanup_lock);
735} 726}
736 727
737static enum dma_status 728enum dma_status
738ioat1_dma_is_complete(struct dma_chan *c, dma_cookie_t cookie, 729ioat_is_dma_complete(struct dma_chan *c, dma_cookie_t cookie,
739 dma_cookie_t *done, dma_cookie_t *used) 730 dma_cookie_t *done, dma_cookie_t *used)
740{ 731{
741 struct ioat_dma_chan *ioat = to_ioat_chan(c); 732 struct ioat_chan_common *chan = to_chan_common(c);
733 struct ioatdma_device *device = chan->device;
742 734
743 if (ioat_is_complete(c, cookie, done, used) == DMA_SUCCESS) 735 if (ioat_is_complete(c, cookie, done, used) == DMA_SUCCESS)
744 return DMA_SUCCESS; 736 return DMA_SUCCESS;
745 737
746 ioat1_cleanup(ioat); 738 device->cleanup_fn((unsigned long) c);
747 739
748 return ioat_is_complete(c, cookie, done, used); 740 return ioat_is_complete(c, cookie, done, used);
749} 741}
@@ -1199,12 +1191,14 @@ int __devinit ioat1_dma_probe(struct ioatdma_device *device, int dca)
1199 device->intr_quirk = ioat1_intr_quirk; 1191 device->intr_quirk = ioat1_intr_quirk;
1200 device->enumerate_channels = ioat1_enumerate_channels; 1192 device->enumerate_channels = ioat1_enumerate_channels;
1201 device->self_test = ioat_dma_self_test; 1193 device->self_test = ioat_dma_self_test;
1194 device->timer_fn = ioat1_timer_event;
1195 device->cleanup_fn = ioat1_cleanup_event;
1202 dma = &device->common; 1196 dma = &device->common;
1203 dma->device_prep_dma_memcpy = ioat1_dma_prep_memcpy; 1197 dma->device_prep_dma_memcpy = ioat1_dma_prep_memcpy;
1204 dma->device_issue_pending = ioat1_dma_memcpy_issue_pending; 1198 dma->device_issue_pending = ioat1_dma_memcpy_issue_pending;
1205 dma->device_alloc_chan_resources = ioat1_dma_alloc_chan_resources; 1199 dma->device_alloc_chan_resources = ioat1_dma_alloc_chan_resources;
1206 dma->device_free_chan_resources = ioat1_dma_free_chan_resources; 1200 dma->device_free_chan_resources = ioat1_dma_free_chan_resources;
1207 dma->device_is_tx_complete = ioat1_dma_is_complete; 1201 dma->device_is_tx_complete = ioat_is_dma_complete;
1208 1202
1209 err = ioat_probe(device); 1203 err = ioat_probe(device);
1210 if (err) 1204 if (err)