Skip to content

Commit 63f89ca

Browse files
christopherpfreemanVinod Koul
authored andcommitted
dmaengine: increment privatecnt when using dma_get_any_slave_channel
Channels allocated via dma_get_any_slave_channel were not increasing the counter tracking private allocations. When these channels were released, privatecnt may erroneously fall to zero. The DMA device would then lose its DMA_PRIVATE cap and fail to allocate future private channels (via private_candidate) as any allocations still outstanding would incorrectly be seen as public allocations. Signed-off-by: Christopher Freeman <cfreeman@nvidia.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
1 parent 8016614 commit 63f89ca

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/dma/dmaengine.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,11 +571,15 @@ struct dma_chan *dma_get_any_slave_channel(struct dma_device *device)
571571

572572
chan = private_candidate(&mask, device, NULL, NULL);
573573
if (chan) {
574+
dma_cap_set(DMA_PRIVATE, device->cap_mask);
575+
device->privatecnt++;
574576
err = dma_chan_get(chan);
575577
if (err) {
576578
pr_debug("%s: failed to get %s: (%d)\n",
577579
__func__, dma_chan_name(chan), err);
578580
chan = NULL;
581+
if (--device->privatecnt == 0)
582+
dma_cap_clear(DMA_PRIVATE, device->cap_mask);
579583
}
580584
}
581585

0 commit comments

Comments
 (0)