Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

DMAENGINE: COH 901 318 rename confusing vars

This fixes up the code with a lot of comments that make it readable,
rename things with opaque names like "data" into something more
appropriate, and remove some very confusing BUG() statements.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

authored by

Linus Walleij and committed by
Dan Williams
cecd87da 220bf991

+65 -38
+65 -38
drivers/dma/coh901318.c
··· 37 37 struct list_head node; 38 38 struct scatterlist *sg; 39 39 unsigned int sg_len; 40 - struct coh901318_lli *data; 40 + struct coh901318_lli *lli; 41 41 enum dma_data_direction dir; 42 42 unsigned long flags; 43 43 }; ··· 283 283 } 284 284 285 285 static int coh901318_prep_linked_list(struct coh901318_chan *cohc, 286 - struct coh901318_lli *data) 286 + struct coh901318_lli *lli) 287 287 { 288 288 int channel = cohc->id; 289 289 void __iomem *virtbase = cohc->base->virtbase; ··· 292 292 COH901318_CX_STAT_SPACING*channel) & 293 293 COH901318_CX_STAT_ACTIVE); 294 294 295 - writel(data->src_addr, 295 + writel(lli->src_addr, 296 296 virtbase + COH901318_CX_SRC_ADDR + 297 297 COH901318_CX_SRC_ADDR_SPACING * channel); 298 298 299 - writel(data->dst_addr, virtbase + 299 + writel(lli->dst_addr, virtbase + 300 300 COH901318_CX_DST_ADDR + 301 301 COH901318_CX_DST_ADDR_SPACING * channel); 302 302 303 - writel(data->link_addr, virtbase + COH901318_CX_LNK_ADDR + 303 + writel(lli->link_addr, virtbase + COH901318_CX_LNK_ADDR + 304 304 COH901318_CX_LNK_ADDR_SPACING * channel); 305 305 306 - writel(data->control, virtbase + COH901318_CX_CTRL + 306 + writel(lli->control, virtbase + COH901318_CX_CTRL + 307 307 COH901318_CX_CTRL_SPACING * channel); 308 308 309 309 return 0; ··· 565 565 */ 566 566 static struct coh901318_desc *coh901318_queue_start(struct coh901318_chan *cohc) 567 567 { 568 - struct coh901318_desc *cohd_que; 568 + struct coh901318_desc *cohd; 569 569 570 - /* start queued jobs, if any 570 + /* 571 + * start queued jobs, if any 571 572 * TODO: transmit all queued jobs in one go 572 573 */ 573 - cohd_que = coh901318_first_queued(cohc); 574 + cohd = coh901318_first_queued(cohc); 574 575 575 - if (cohd_que != NULL) { 576 + if (cohd != NULL) { 576 577 /* Remove from queue */ 577 - coh901318_desc_remove(cohd_que); 578 + coh901318_desc_remove(cohd); 578 579 /* initiate DMA job */ 579 580 cohc->busy = 1; 580 581 581 - coh901318_desc_submit(cohc, cohd_que); 582 + coh901318_desc_submit(cohc, cohd); 582 583 583 - coh901318_prep_linked_list(cohc, cohd_que->data); 584 + coh901318_prep_linked_list(cohc, cohd->lli); 584 585 585 - /* start dma job */ 586 + /* start dma job on this channel */ 586 587 coh901318_start(cohc); 587 588 588 589 } 589 590 590 - return cohd_que; 591 + return cohd; 591 592 } 592 593 593 594 /* ··· 623 622 cohc->completed = cohd_fin->desc.cookie; 624 623 625 624 /* release the lli allocation and remove the descriptor */ 626 - coh901318_lli_free(&cohc->base->pool, &cohd_fin->data); 625 + coh901318_lli_free(&cohc->base->pool, &cohd_fin->lli); 627 626 628 627 /* return desc to free-list */ 629 628 coh901318_desc_remove(cohd_fin); ··· 667 666 /* called from interrupt context */ 668 667 static void dma_tc_handle(struct coh901318_chan *cohc) 669 668 { 670 - BUG_ON(!cohc->allocated && (list_empty(&cohc->active) || 671 - list_empty(&cohc->queue))); 672 - 673 - if (!cohc->allocated) 669 + /* 670 + * If the channel is not allocated, then we shouldn't have 671 + * any TC interrupts on it. 672 + */ 673 + if (!cohc->allocated) { 674 + dev_err(COHC_2_DEV(cohc), "spurious interrupt from " 675 + "unallocated channel\n"); 674 676 return; 677 + } 675 678 676 679 spin_lock(&cohc->lock); 677 680 681 + /* 682 + * When we reach this point, at least one queue item 683 + * should have been moved over from cohc->queue to 684 + * cohc->active and run to completion, that is why we're 685 + * getting a terminal count interrupt is it not? 686 + * If you get this BUG() the most probable cause is that 687 + * the individual nodes in the lli chain have IRQ enabled, 688 + * so check your platform config for lli chain ctrl. 689 + */ 690 + BUG_ON(list_empty(&cohc->active)); 691 + 678 692 cohc->nbr_active_done++; 679 693 694 + /* 695 + * This attempt to take a job from cohc->queue, put it 696 + * into cohc->active and start it. 697 + */ 680 698 if (coh901318_queue_start(cohc) == NULL) 681 699 cohc->busy = 0; 682 700 683 - BUG_ON(list_empty(&cohc->active)); 684 - 685 701 spin_unlock(&cohc->lock); 686 702 703 + /* 704 + * This tasklet will remove items from cohc->active 705 + * and thus terminates them. 706 + */ 687 707 if (cohc_chan_conf(cohc)->priority_high) 688 708 tasklet_hi_schedule(&cohc->tasklet); 689 709 else ··· 892 870 coh901318_prep_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src, 893 871 size_t size, unsigned long flags) 894 872 { 895 - struct coh901318_lli *data; 873 + struct coh901318_lli *lli; 896 874 struct coh901318_desc *cohd; 897 875 unsigned long flg; 898 876 struct coh901318_chan *cohc = to_coh901318_chan(chan); ··· 914 892 if ((lli_len << MAX_DMA_PACKET_SIZE_SHIFT) < size) 915 893 lli_len++; 916 894 917 - data = coh901318_lli_alloc(&cohc->base->pool, lli_len); 895 + lli = coh901318_lli_alloc(&cohc->base->pool, lli_len); 918 896 919 - if (data == NULL) 897 + if (lli == NULL) 920 898 goto err; 921 899 922 900 ret = coh901318_lli_fill_memcpy( 923 - &cohc->base->pool, data, src, size, dest, 901 + &cohc->base->pool, lli, src, size, dest, 924 902 cohc_chan_param(cohc)->ctrl_lli_chained, 925 903 ctrl_last); 926 904 if (ret) 927 905 goto err; 928 906 929 - COH_DBG(coh901318_list_print(cohc, data)); 907 + COH_DBG(coh901318_list_print(cohc, lli)); 930 908 931 909 /* Pick a descriptor to handle this transfer */ 932 910 cohd = coh901318_desc_get(cohc); 933 - cohd->data = data; 911 + cohd->lli = lli; 934 912 cohd->flags = flags; 935 913 cohd->desc.tx_submit = coh901318_tx_submit; 936 914 ··· 948 926 unsigned long flags) 949 927 { 950 928 struct coh901318_chan *cohc = to_coh901318_chan(chan); 951 - struct coh901318_lli *data; 929 + struct coh901318_lli *lli; 952 930 struct coh901318_desc *cohd; 953 931 const struct coh901318_params *params; 954 932 struct scatterlist *sg; ··· 1021 999 } 1022 1000 1023 1001 pr_debug("Allocate %d lli:s for this transfer\n", len); 1024 - data = coh901318_lli_alloc(&cohc->base->pool, len); 1002 + lli = coh901318_lli_alloc(&cohc->base->pool, len); 1025 1003 1026 - if (data == NULL) 1004 + if (lli == NULL) 1027 1005 goto err_dma_alloc; 1028 1006 1029 - /* initiate allocated data list */ 1030 - ret = coh901318_lli_fill_sg(&cohc->base->pool, data, sgl, sg_len, 1007 + /* initiate allocated lli list */ 1008 + ret = coh901318_lli_fill_sg(&cohc->base->pool, lli, sgl, sg_len, 1031 1009 cohc_dev_addr(cohc), 1032 1010 ctrl_chained, 1033 1011 ctrl, ··· 1036 1014 if (ret) 1037 1015 goto err_lli_fill; 1038 1016 1039 - COH_DBG(coh901318_list_print(cohc, data)); 1017 + COH_DBG(coh901318_list_print(cohc, lli)); 1040 1018 1041 1019 /* Pick a descriptor to handle this transfer */ 1042 1020 cohd = coh901318_desc_get(cohc); 1043 1021 cohd->dir = direction; 1044 1022 cohd->flags = flags; 1045 1023 cohd->desc.tx_submit = coh901318_tx_submit; 1046 - cohd->data = data; 1024 + cohd->lli = lli; 1047 1025 1048 1026 spin_unlock_irqrestore(&cohc->lock, flg); 1049 1027 ··· 1087 1065 1088 1066 spin_lock_irqsave(&cohc->lock, flags); 1089 1067 1090 - /* Busy means that pending jobs are already being processed */ 1068 + /* 1069 + * Busy means that pending jobs are already being processed, 1070 + * and then there is no point in starting the queue: the 1071 + * terminal count interrupt on the channel will take the next 1072 + * job on the queue and execute it anyway. 1073 + */ 1091 1074 if (!cohc->busy) 1092 1075 coh901318_queue_start(cohc); 1093 1076 ··· 1126 1099 1127 1100 while ((cohd = coh901318_first_active_get(cohc))) { 1128 1101 /* release the lli allocation*/ 1129 - coh901318_lli_free(&cohc->base->pool, &cohd->data); 1102 + coh901318_lli_free(&cohc->base->pool, &cohd->lli); 1130 1103 1131 1104 /* return desc to free-list */ 1132 1105 coh901318_desc_remove(cohd); ··· 1135 1108 1136 1109 while ((cohd = coh901318_first_queued(cohc))) { 1137 1110 /* release the lli allocation*/ 1138 - coh901318_lli_free(&cohc->base->pool, &cohd->data); 1111 + coh901318_lli_free(&cohc->base->pool, &cohd->lli); 1139 1112 1140 1113 /* return desc to free-list */ 1141 1114 coh901318_desc_remove(cohd);