aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-davinci/dma.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/arch/arm/mach-davinci/dma.c b/arch/arm/mach-davinci/dma.c
index 8eda4c3be940..b097592a862e 100644
--- a/arch/arm/mach-davinci/dma.c
+++ b/arch/arm/mach-davinci/dma.c
@@ -515,17 +515,30 @@ static int reserve_contiguous_params(int ctlr, unsigned int id,
515{ 515{
516 int i, j; 516 int i, j;
517 unsigned int count = num_params; 517 unsigned int count = num_params;
518 int stop_param = start_param;
519 DECLARE_BITMAP(tmp_inuse, EDMA_MAX_PARAMENTRY);
518 520
519 for (i = start_param; i < edma_info[ctlr]->num_slots; ++i) { 521 for (i = start_param; i < edma_info[ctlr]->num_slots; ++i) {
520 j = EDMA_CHAN_SLOT(i); 522 j = EDMA_CHAN_SLOT(i);
521 if (!test_and_set_bit(j, edma_info[ctlr]->edma_inuse)) 523 if (!test_and_set_bit(j, edma_info[ctlr]->edma_inuse)) {
524 /* Record our current beginning slot */
525 if (count == num_params)
526 stop_param = i;
527
522 count--; 528 count--;
529 set_bit(j, tmp_inuse);
530
523 if (count == 0) 531 if (count == 0)
524 break; 532 break;
525 else if (id == EDMA_CONT_PARAMS_FIXED_EXACT) 533 } else {
526 break; 534 clear_bit(j, tmp_inuse);
527 else 535
528 count = num_params; 536 if (id == EDMA_CONT_PARAMS_FIXED_EXACT) {
537 stop_param = i;
538 break;
539 } else
540 count = num_params;
541 }
529 } 542 }
530 543
531 /* 544 /*
@@ -534,12 +547,15 @@ static int reserve_contiguous_params(int ctlr, unsigned int id,
534 * of contiguous parameter RAMs but do not find the exact number 547 * of contiguous parameter RAMs but do not find the exact number
535 * requested as we may reach the total number of parameter RAMs 548 * requested as we may reach the total number of parameter RAMs
536 */ 549 */
537 if (count) { 550 if (i == edma_info[ctlr]->num_slots)
538 for (j = i - num_params + count + 1; j <= i ; ++j) 551 stop_param = i;
552
553 for (j = start_param; j < stop_param; j++)
554 if (test_bit(j, tmp_inuse))
539 clear_bit(j, edma_info[ctlr]->edma_inuse); 555 clear_bit(j, edma_info[ctlr]->edma_inuse);
540 556
557 if (count)
541 return -EBUSY; 558 return -EBUSY;
542 }
543 559
544 for (j = i - num_params + 1; j <= i; ++j) 560 for (j = i - num_params + 1; j <= i; ++j)
545 memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(j), 561 memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(j),