Skip to content

Commit 599d49d

Browse files
davejiangVinod Koul
authored andcommitted
dmaengine: ioatdma: move dma prep functions to single location
Move all DMA descriptor prepping functions to prep.c file. Fixup all broken bits caused by the move. Signed-off-by: Dave Jiang <[email protected]> Acked-by: Dan Williams <[email protected]> Signed-off-by: Vinod Koul <[email protected]>
1 parent c0f28ce commit 599d49d

File tree

6 files changed

+769
-749
lines changed

6 files changed

+769
-749
lines changed

drivers/dma/ioat/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
obj-$(CONFIG_INTEL_IOATDMA) += ioatdma.o
2-
ioatdma-y := init.o dma.o dma_v3.o dca.o sysfs.o
2+
ioatdma-y := init.o dma.o dma_v3.o prep.o dca.o sysfs.o

drivers/dma/ioat/dma.c

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -578,50 +578,3 @@ int ioat_check_space_lock(struct ioatdma_chan *ioat_chan, int num_descs)
578578

579579
return -ENOMEM;
580580
}
581-
582-
struct dma_async_tx_descriptor *
583-
ioat_dma_prep_memcpy_lock(struct dma_chan *c, dma_addr_t dma_dest,
584-
dma_addr_t dma_src, size_t len, unsigned long flags)
585-
{
586-
struct ioatdma_chan *ioat_chan = to_ioat_chan(c);
587-
struct ioat_dma_descriptor *hw;
588-
struct ioat_ring_ent *desc;
589-
dma_addr_t dst = dma_dest;
590-
dma_addr_t src = dma_src;
591-
size_t total_len = len;
592-
int num_descs, idx, i;
593-
594-
num_descs = ioat_xferlen_to_descs(ioat_chan, len);
595-
if (likely(num_descs) &&
596-
ioat_check_space_lock(ioat_chan, num_descs) == 0)
597-
idx = ioat_chan->head;
598-
else
599-
return NULL;
600-
i = 0;
601-
do {
602-
size_t copy = min_t(size_t, len, 1 << ioat_chan->xfercap_log);
603-
604-
desc = ioat_get_ring_ent(ioat_chan, idx + i);
605-
hw = desc->hw;
606-
607-
hw->size = copy;
608-
hw->ctl = 0;
609-
hw->src_addr = src;
610-
hw->dst_addr = dst;
611-
612-
len -= copy;
613-
dst += copy;
614-
src += copy;
615-
dump_desc_dbg(ioat_chan, desc);
616-
} while (++i < num_descs);
617-
618-
desc->txd.flags = flags;
619-
desc->len = total_len;
620-
hw->ctl_f.int_en = !!(flags & DMA_PREP_INTERRUPT);
621-
hw->ctl_f.fence = !!(flags & DMA_PREP_FENCE);
622-
hw->ctl_f.compl_write = 1;
623-
dump_desc_dbg(ioat_chan, desc);
624-
/* we leave the channel locked to ensure in order submission */
625-
626-
return &desc->txd;
627-
}

drivers/dma/ioat/dma.h

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737

3838
#define chan_num(ch) ((int)((ch)->reg_base - (ch)->ioat_dma->reg_base) / 0x80)
3939

40+
/* ioat hardware assumes at least two sources for raid operations */
41+
#define src_cnt_to_sw(x) ((x) + 2)
42+
#define src_cnt_to_hw(x) ((x) - 2)
43+
#define ndest_to_sw(x) ((x) + 1)
44+
#define ndest_to_hw(x) ((x) - 1)
45+
#define src16_cnt_to_sw(x) ((x) + 9)
46+
#define src16_cnt_to_hw(x) ((x) - 9)
47+
4048
/*
4149
* workaround for IOAT ver.3.0 null descriptor issue
4250
* (channel returns error when size is 0)
@@ -190,15 +198,22 @@ struct ioat_ring_ent {
190198
struct ioat_sed_ent *sed;
191199
};
192200

201+
extern const struct sysfs_ops ioat_sysfs_ops;
202+
extern struct ioat_sysfs_entry ioat_version_attr;
203+
extern struct ioat_sysfs_entry ioat_cap_attr;
204+
extern int ioat_pending_level;
205+
extern int ioat_ring_alloc_order;
206+
extern struct kobj_type ioat_ktype;
207+
extern struct kmem_cache *ioat_cache;
208+
extern int ioat_ring_max_alloc_order;
209+
extern struct kmem_cache *ioat_sed_cache;
210+
193211
static inline struct ioatdma_chan *to_ioat_chan(struct dma_chan *c)
194212
{
195213
return container_of(c, struct ioatdma_chan, dma_chan);
196214
}
197215

198-
199-
200216
/* wrapper around hardware descriptor format + additional software fields */
201-
202217
#ifdef DEBUG
203218
#define set_desc_id(desc, i) ((desc)->id = (i))
204219
#define desc_id(desc) ((desc)->id)
@@ -381,13 +396,10 @@ ioat_set_chainaddr(struct ioatdma_chan *ioat_chan, u64 addr)
381396
ioat_chan->reg_base + IOAT2_CHAINADDR_OFFSET_HIGH);
382397
}
383398

384-
irqreturn_t ioat_dma_do_interrupt(int irq, void *data);
385-
irqreturn_t ioat_dma_do_interrupt_msix(int irq, void *data);
386-
struct ioat_ring_ent **
387-
ioat_alloc_ring(struct dma_chan *c, int order, gfp_t flags);
388-
void ioat_start_null_desc(struct ioatdma_chan *ioat_chan);
389-
void ioat_free_ring_ent(struct ioat_ring_ent *desc, struct dma_chan *chan);
390-
int ioat_reset_hw(struct ioatdma_chan *ioat_chan);
399+
/* IOAT Prep functions */
400+
struct dma_async_tx_descriptor *
401+
ioat_dma_prep_memcpy_lock(struct dma_chan *c, dma_addr_t dma_dest,
402+
dma_addr_t dma_src, size_t len, unsigned long flags);
391403
struct dma_async_tx_descriptor *
392404
ioat_prep_interrupt_lock(struct dma_chan *c, unsigned long flags);
393405
struct dma_async_tx_descriptor *
@@ -412,53 +424,38 @@ struct dma_async_tx_descriptor *
412424
ioat_prep_pqxor_val(struct dma_chan *chan, dma_addr_t *src,
413425
unsigned int src_cnt, size_t len,
414426
enum sum_check_flags *result, unsigned long flags);
427+
428+
/* IOAT Operation functions */
429+
irqreturn_t ioat_dma_do_interrupt(int irq, void *data);
430+
irqreturn_t ioat_dma_do_interrupt_msix(int irq, void *data);
431+
struct ioat_ring_ent **
432+
ioat_alloc_ring(struct dma_chan *c, int order, gfp_t flags);
433+
void ioat_start_null_desc(struct ioatdma_chan *ioat_chan);
434+
void ioat_free_ring_ent(struct ioat_ring_ent *desc, struct dma_chan *chan);
435+
int ioat_reset_hw(struct ioatdma_chan *ioat_chan);
415436
enum dma_status
416437
ioat_tx_status(struct dma_chan *c, dma_cookie_t cookie,
417438
struct dma_tx_state *txstate);
418439
void ioat_cleanup_event(unsigned long data);
419440
void ioat_timer_event(unsigned long data);
420-
bool is_bwd_ioat(struct pci_dev *pdev);
421-
int ioat_probe(struct ioatdma_device *ioat_dma);
422-
int ioat_register(struct ioatdma_device *ioat_dma);
423-
int ioat_dma_self_test(struct ioatdma_device *ioat_dma);
424-
void ioat_dma_remove(struct ioatdma_device *ioat_dma);
425-
struct dca_provider *ioat_dca_init(struct pci_dev *pdev, void __iomem *iobase);
426-
void ioat_init_channel(struct ioatdma_device *ioat_dma,
427-
struct ioatdma_chan *ioat_chan, int idx);
428441
enum dma_status ioat_dma_tx_status(struct dma_chan *c, dma_cookie_t cookie,
429442
struct dma_tx_state *txstate);
430443
bool ioat_cleanup_preamble(struct ioatdma_chan *ioat_chan,
431444
dma_addr_t *phys_complete);
432-
void ioat_kobject_add(struct ioatdma_device *ioat_dma, struct kobj_type *type);
433-
void ioat_kobject_del(struct ioatdma_device *ioat_dma);
434-
int ioat_dma_setup_interrupts(struct ioatdma_device *ioat_dma);
435-
void ioat_stop(struct ioatdma_chan *ioat_chan);
436-
int ioat_dma_probe(struct ioatdma_device *ioat_dma, int dca);
437-
int ioat3_dma_probe(struct ioatdma_device *ioat_dma, int dca);
438-
struct dca_provider *ioat3_dca_init(struct pci_dev *pdev, void __iomem *iobase);
439445
int ioat_check_space_lock(struct ioatdma_chan *ioat_chan, int num_descs);
440-
int ioat_enumerate_channels(struct ioatdma_device *ioat_dma);
441-
struct dma_async_tx_descriptor *
442-
ioat_dma_prep_memcpy_lock(struct dma_chan *c, dma_addr_t dma_dest,
443-
dma_addr_t dma_src, size_t len, unsigned long flags);
444446
void ioat_issue_pending(struct dma_chan *chan);
445-
int ioat_alloc_chan_resources(struct dma_chan *c);
446-
void ioat_free_chan_resources(struct dma_chan *c);
447-
void __ioat_restart_chan(struct ioatdma_chan *ioat_chan);
448447
bool reshape_ring(struct ioatdma_chan *ioat, int order);
449448
void __ioat_issue_pending(struct ioatdma_chan *ioat_chan);
450449
void ioat_timer_event(unsigned long data);
451450
int ioat_quiesce(struct ioatdma_chan *ioat_chan, unsigned long tmo);
452451
int ioat_reset_sync(struct ioatdma_chan *ioat_chan, unsigned long tmo);
452+
void __ioat_restart_chan(struct ioatdma_chan *ioat_chan);
453453

454-
extern const struct sysfs_ops ioat_sysfs_ops;
455-
extern struct ioat_sysfs_entry ioat_version_attr;
456-
extern struct ioat_sysfs_entry ioat_cap_attr;
457-
extern int ioat_pending_level;
458-
extern int ioat_ring_alloc_order;
459-
extern struct kobj_type ioat_ktype;
460-
extern struct kmem_cache *ioat_cache;
461-
extern int ioat_ring_max_alloc_order;
462-
extern struct kmem_cache *ioat_sed_cache;
463-
454+
/* IOAT Init functions */
455+
bool is_bwd_ioat(struct pci_dev *pdev);
456+
void ioat_kobject_add(struct ioatdma_device *ioat_dma, struct kobj_type *type);
457+
void ioat_kobject_del(struct ioatdma_device *ioat_dma);
458+
int ioat_dma_setup_interrupts(struct ioatdma_device *ioat_dma);
459+
void ioat_stop(struct ioatdma_chan *ioat_chan);
460+
struct dca_provider *ioat3_dca_init(struct pci_dev *pdev, void __iomem *iobase);
464461
#endif /* IOATDMA_H */

0 commit comments

Comments
 (0)