diff options
-rw-r--r-- | drivers/dma/edma.c | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index 4b2ccc9de0ad..8d9169b7f208 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c | |||
@@ -227,16 +227,16 @@ struct edma_cc { | |||
227 | enum dma_event_q default_queue; | 227 | enum dma_event_q default_queue; |
228 | 228 | ||
229 | bool unused_chan_list_done; | 229 | bool unused_chan_list_done; |
230 | /* The edma_inuse bit for each PaRAM slot is clear unless the | 230 | /* The slot_inuse bit for each PaRAM slot is clear unless the |
231 | * channel is in use ... by ARM or DSP, for QDMA, or whatever. | 231 | * channel is in use ... by ARM or DSP, for QDMA, or whatever. |
232 | */ | 232 | */ |
233 | unsigned long *edma_inuse; | 233 | unsigned long *slot_inuse; |
234 | 234 | ||
235 | /* The edma_unused bit for each channel is clear unless | 235 | /* The channel_unused bit for each channel is clear unless |
236 | * it is not being used on this platform. It uses a bit | 236 | * it is not being used on this platform. It uses a bit |
237 | * of SOC-specific initialization code. | 237 | * of SOC-specific initialization code. |
238 | */ | 238 | */ |
239 | unsigned long *edma_unused; | 239 | unsigned long *channel_unused; |
240 | 240 | ||
241 | struct dma_device dma_slave; | 241 | struct dma_device dma_slave; |
242 | struct edma_chan *slave_chans; | 242 | struct edma_chan *slave_chans; |
@@ -452,7 +452,7 @@ static int prepare_unused_channel_list(struct device *dev, void *data) | |||
452 | continue; | 452 | continue; |
453 | 453 | ||
454 | clear_bit(EDMA_CHAN_SLOT(dma_spec.args[0]), | 454 | clear_bit(EDMA_CHAN_SLOT(dma_spec.args[0]), |
455 | ecc->edma_unused); | 455 | ecc->channel_unused); |
456 | of_node_put(dma_spec.np); | 456 | of_node_put(dma_spec.np); |
457 | } | 457 | } |
458 | return 0; | 458 | return 0; |
@@ -469,7 +469,7 @@ static int prepare_unused_channel_list(struct device *dev, void *data) | |||
469 | dma_req = (int)res->start; | 469 | dma_req = (int)res->start; |
470 | if (dma_req >= dma_req_min && dma_req < dma_req_max) | 470 | if (dma_req >= dma_req_min && dma_req < dma_req_max) |
471 | clear_bit(EDMA_CHAN_SLOT(pdev->resource[i].start), | 471 | clear_bit(EDMA_CHAN_SLOT(pdev->resource[i].start), |
472 | ecc->edma_unused); | 472 | ecc->channel_unused); |
473 | } | 473 | } |
474 | 474 | ||
475 | return 0; | 475 | return 0; |
@@ -533,17 +533,17 @@ static int edma_alloc_slot(struct edma_cc *ecc, int slot) | |||
533 | if (slot < 0) { | 533 | if (slot < 0) { |
534 | slot = ecc->num_channels; | 534 | slot = ecc->num_channels; |
535 | for (;;) { | 535 | for (;;) { |
536 | slot = find_next_zero_bit(ecc->edma_inuse, | 536 | slot = find_next_zero_bit(ecc->slot_inuse, |
537 | ecc->num_slots, | 537 | ecc->num_slots, |
538 | slot); | 538 | slot); |
539 | if (slot == ecc->num_slots) | 539 | if (slot == ecc->num_slots) |
540 | return -ENOMEM; | 540 | return -ENOMEM; |
541 | if (!test_and_set_bit(slot, ecc->edma_inuse)) | 541 | if (!test_and_set_bit(slot, ecc->slot_inuse)) |
542 | break; | 542 | break; |
543 | } | 543 | } |
544 | } else if (slot < ecc->num_channels || slot >= ecc->num_slots) { | 544 | } else if (slot < ecc->num_channels || slot >= ecc->num_slots) { |
545 | return -EINVAL; | 545 | return -EINVAL; |
546 | } else if (test_and_set_bit(slot, ecc->edma_inuse)) { | 546 | } else if (test_and_set_bit(slot, ecc->slot_inuse)) { |
547 | return -EBUSY; | 547 | return -EBUSY; |
548 | } | 548 | } |
549 | 549 | ||
@@ -559,7 +559,7 @@ static void edma_free_slot(struct edma_cc *ecc, unsigned slot) | |||
559 | return; | 559 | return; |
560 | 560 | ||
561 | edma_write_slot(ecc, slot, &dummy_paramset); | 561 | edma_write_slot(ecc, slot, &dummy_paramset); |
562 | clear_bit(slot, ecc->edma_inuse); | 562 | clear_bit(slot, ecc->slot_inuse); |
563 | } | 563 | } |
564 | 564 | ||
565 | /** | 565 | /** |
@@ -631,7 +631,7 @@ static int edma_start(struct edma_cc *ecc, unsigned channel) | |||
631 | unsigned int mask = BIT(channel & 0x1f); | 631 | unsigned int mask = BIT(channel & 0x1f); |
632 | 632 | ||
633 | /* EDMA channels without event association */ | 633 | /* EDMA channels without event association */ |
634 | if (test_bit(channel, ecc->edma_unused)) { | 634 | if (test_bit(channel, ecc->channel_unused)) { |
635 | dev_dbg(ecc->dev, "ESR%d %08x\n", j, | 635 | dev_dbg(ecc->dev, "ESR%d %08x\n", j, |
636 | edma_shadow0_read_array(ecc, SH_ESR, j)); | 636 | edma_shadow0_read_array(ecc, SH_ESR, j)); |
637 | edma_shadow0_write_array(ecc, SH_ESR, j, mask); | 637 | edma_shadow0_write_array(ecc, SH_ESR, j, mask); |
@@ -835,11 +835,11 @@ static int edma_alloc_channel(struct edma_cc *ecc, int channel, | |||
835 | if (channel < 0) { | 835 | if (channel < 0) { |
836 | channel = 0; | 836 | channel = 0; |
837 | for (;;) { | 837 | for (;;) { |
838 | channel = find_next_bit(ecc->edma_unused, | 838 | channel = find_next_bit(ecc->channel_unused, |
839 | ecc->num_channels, channel); | 839 | ecc->num_channels, channel); |
840 | if (channel == ecc->num_channels) | 840 | if (channel == ecc->num_channels) |
841 | break; | 841 | break; |
842 | if (!test_and_set_bit(channel, ecc->edma_inuse)) { | 842 | if (!test_and_set_bit(channel, ecc->slot_inuse)) { |
843 | done = 1; | 843 | done = 1; |
844 | break; | 844 | break; |
845 | } | 845 | } |
@@ -849,7 +849,7 @@ static int edma_alloc_channel(struct edma_cc *ecc, int channel, | |||
849 | return -ENOMEM; | 849 | return -ENOMEM; |
850 | } else if (channel >= ecc->num_channels) { | 850 | } else if (channel >= ecc->num_channels) { |
851 | return -EINVAL; | 851 | return -EINVAL; |
852 | } else if (test_and_set_bit(channel, ecc->edma_inuse)) { | 852 | } else if (test_and_set_bit(channel, ecc->slot_inuse)) { |
853 | return -EBUSY; | 853 | return -EBUSY; |
854 | } | 854 | } |
855 | 855 | ||
@@ -895,7 +895,7 @@ static void edma_free_channel(struct edma_cc *ecc, unsigned channel) | |||
895 | /* REVISIT should probably take out of shadow region 0 */ | 895 | /* REVISIT should probably take out of shadow region 0 */ |
896 | 896 | ||
897 | edma_write_slot(ecc, channel, &dummy_paramset); | 897 | edma_write_slot(ecc, channel, &dummy_paramset); |
898 | clear_bit(channel, ecc->edma_inuse); | 898 | clear_bit(channel, ecc->slot_inuse); |
899 | } | 899 | } |
900 | 900 | ||
901 | /* Move channel to a specific event queue */ | 901 | /* Move channel to a specific event queue */ |
@@ -2137,14 +2137,15 @@ static int edma_probe(struct platform_device *pdev) | |||
2137 | if (!ecc->slave_chans) | 2137 | if (!ecc->slave_chans) |
2138 | return -ENOMEM; | 2138 | return -ENOMEM; |
2139 | 2139 | ||
2140 | ecc->edma_unused = devm_kcalloc(dev, BITS_TO_LONGS(ecc->num_channels), | 2140 | ecc->channel_unused = devm_kcalloc(dev, |
2141 | sizeof(unsigned long), GFP_KERNEL); | 2141 | BITS_TO_LONGS(ecc->num_channels), |
2142 | if (!ecc->edma_unused) | 2142 | sizeof(unsigned long), GFP_KERNEL); |
2143 | if (!ecc->channel_unused) | ||
2143 | return -ENOMEM; | 2144 | return -ENOMEM; |
2144 | 2145 | ||
2145 | ecc->edma_inuse = devm_kcalloc(dev, BITS_TO_LONGS(ecc->num_slots), | 2146 | ecc->slot_inuse = devm_kcalloc(dev, BITS_TO_LONGS(ecc->num_slots), |
2146 | sizeof(unsigned long), GFP_KERNEL); | 2147 | sizeof(unsigned long), GFP_KERNEL); |
2147 | if (!ecc->edma_inuse) | 2148 | if (!ecc->slot_inuse) |
2148 | return -ENOMEM; | 2149 | return -ENOMEM; |
2149 | 2150 | ||
2150 | ecc->default_queue = info->default_queue; | 2151 | ecc->default_queue = info->default_queue; |
@@ -2153,7 +2154,7 @@ static int edma_probe(struct platform_device *pdev) | |||
2153 | edma_write_slot(ecc, i, &dummy_paramset); | 2154 | edma_write_slot(ecc, i, &dummy_paramset); |
2154 | 2155 | ||
2155 | /* Mark all channels as unused */ | 2156 | /* Mark all channels as unused */ |
2156 | memset(ecc->edma_unused, 0xff, sizeof(ecc->edma_unused)); | 2157 | memset(ecc->channel_unused, 0xff, sizeof(ecc->channel_unused)); |
2157 | 2158 | ||
2158 | if (info->rsv) { | 2159 | if (info->rsv) { |
2159 | /* Clear the reserved channels in unused list */ | 2160 | /* Clear the reserved channels in unused list */ |
@@ -2162,7 +2163,7 @@ static int edma_probe(struct platform_device *pdev) | |||
2162 | for (i = 0; rsv_chans[i][0] != -1; i++) { | 2163 | for (i = 0; rsv_chans[i][0] != -1; i++) { |
2163 | off = rsv_chans[i][0]; | 2164 | off = rsv_chans[i][0]; |
2164 | ln = rsv_chans[i][1]; | 2165 | ln = rsv_chans[i][1]; |
2165 | clear_bits(off, ln, ecc->edma_unused); | 2166 | clear_bits(off, ln, ecc->channel_unused); |
2166 | } | 2167 | } |
2167 | } | 2168 | } |
2168 | 2169 | ||
@@ -2172,7 +2173,7 @@ static int edma_probe(struct platform_device *pdev) | |||
2172 | for (i = 0; rsv_slots[i][0] != -1; i++) { | 2173 | for (i = 0; rsv_slots[i][0] != -1; i++) { |
2173 | off = rsv_slots[i][0]; | 2174 | off = rsv_slots[i][0]; |
2174 | ln = rsv_slots[i][1]; | 2175 | ln = rsv_slots[i][1]; |
2175 | set_bits(off, ln, ecc->edma_inuse); | 2176 | set_bits(off, ln, ecc->slot_inuse); |
2176 | } | 2177 | } |
2177 | } | 2178 | } |
2178 | } | 2179 | } |
@@ -2182,7 +2183,7 @@ static int edma_probe(struct platform_device *pdev) | |||
2182 | if (xbar_chans) { | 2183 | if (xbar_chans) { |
2183 | for (i = 0; xbar_chans[i][1] != -1; i++) { | 2184 | for (i = 0; xbar_chans[i][1] != -1; i++) { |
2184 | off = xbar_chans[i][1]; | 2185 | off = xbar_chans[i][1]; |
2185 | clear_bits(off, 1, ecc->edma_unused); | 2186 | clear_bits(off, 1, ecc->channel_unused); |
2186 | } | 2187 | } |
2187 | } | 2188 | } |
2188 | 2189 | ||
@@ -2301,7 +2302,7 @@ static int edma_pm_resume(struct device *dev) | |||
2301 | edma_direct_dmach_to_param_mapping(ecc); | 2302 | edma_direct_dmach_to_param_mapping(ecc); |
2302 | 2303 | ||
2303 | for (i = 0; i < ecc->num_channels; i++) { | 2304 | for (i = 0; i < ecc->num_channels; i++) { |
2304 | if (test_bit(i, ecc->edma_inuse)) { | 2305 | if (test_bit(i, ecc->slot_inuse)) { |
2305 | /* ensure access through shadow region 0 */ | 2306 | /* ensure access through shadow region 0 */ |
2306 | edma_or_array2(ecc, EDMA_DRAE, 0, i >> 5, | 2307 | edma_or_array2(ecc, EDMA_DRAE, 0, i >> 5, |
2307 | BIT(i & 0x1f)); | 2308 | BIT(i & 0x1f)); |