Skip to content

Commit 0adcdee

Browse files
author
Vinod Koul
committed
Merge branch 'topic/of' into for-linus
Conflicts: drivers/dma/mmp_pdma.c Signed-off-by: Vinod Koul <vinod.koul@intel.com>
2 parents 4fce628 + 8010dad commit 0adcdee

File tree

3 files changed

+33
-13
lines changed

3 files changed

+33
-13
lines changed

drivers/dma/dmaengine.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,34 @@ struct dma_chan *dma_get_slave_channel(struct dma_chan *chan)
535535
}
536536
EXPORT_SYMBOL_GPL(dma_get_slave_channel);
537537

538+
struct dma_chan *dma_get_any_slave_channel(struct dma_device *device)
539+
{
540+
dma_cap_mask_t mask;
541+
struct dma_chan *chan;
542+
int err;
543+
544+
dma_cap_zero(mask);
545+
dma_cap_set(DMA_SLAVE, mask);
546+
547+
/* lock against __dma_request_channel */
548+
mutex_lock(&dma_list_mutex);
549+
550+
chan = private_candidate(&mask, device, NULL, NULL);
551+
if (chan) {
552+
err = dma_chan_get(chan);
553+
if (err) {
554+
pr_debug("%s: failed to get %s: (%d)\n",
555+
__func__, dma_chan_name(chan), err);
556+
chan = NULL;
557+
}
558+
}
559+
560+
mutex_unlock(&dma_list_mutex);
561+
562+
return chan;
563+
}
564+
EXPORT_SYMBOL_GPL(dma_get_any_slave_channel);
565+
538566
/**
539567
* __dma_request_channel - try to allocate an exclusive channel
540568
* @mask: capabilities that the channel must satisfy

drivers/dma/mmp_pdma.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -898,20 +898,11 @@ static struct dma_chan *mmp_pdma_dma_xlate(struct of_phandle_args *dma_spec,
898898
struct of_dma *ofdma)
899899
{
900900
struct mmp_pdma_device *d = ofdma->of_dma_data;
901-
struct dma_chan *chan, *candidate;
901+
struct dma_chan *chan;
902+
struct mmp_pdma_chan *c;
902903

903-
retry:
904-
candidate = NULL;
905-
906-
/* walk the list of channels registered with the current instance and
907-
* find one that is currently unused */
908-
list_for_each_entry(chan, &d->device.channels, device_node)
909-
if (chan->client_count == 0) {
910-
candidate = chan;
911-
break;
912-
}
913-
914-
if (!candidate)
904+
chan = dma_get_any_slave_channel(&d->device);
905+
if (!chan)
915906
return NULL;
916907

917908
/* dma_get_slave_channel will return NULL if we lost a race between

include/linux/dmaengine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,7 @@ int dma_async_device_register(struct dma_device *device);
10861086
void dma_async_device_unregister(struct dma_device *device);
10871087
void dma_run_dependencies(struct dma_async_tx_descriptor *tx);
10881088
struct dma_chan *dma_get_slave_channel(struct dma_chan *chan);
1089+
struct dma_chan *dma_get_any_slave_channel(struct dma_device *device);
10891090
struct dma_chan *net_dma_find_channel(void);
10901091
#define dma_request_channel(mask, x, y) __dma_request_channel(&(mask), x, y)
10911092
#define dma_request_slave_channel_compat(mask, x, y, dev, name) \

0 commit comments

Comments
 (0)