Re: [PATCH/RFC] dmaengine: add a slave parameter to__dma_request_channel()

From: Russell King - ARM Linux
Date: Fri Mar 16 2012 - 06:32:15 EST


On Fri, Mar 16, 2012 at 11:16:14AM +0100, Linus Walleij wrote:
> And Russell IIRC already suggested a request-and-config
> channel inline for the simple cases, and if you still need to
> explicitly runtime-reconfigure then that's for a good
> reason.

Here's a patch which does request-and-configure - untested at the moment
apart from build-testing for my Assabet platform. Haven't converted any
drivers to use it yet either.

drivers/dma/dmaengine.c | 14 ++++++++++++--
include/linux/dmaengine.h | 13 +++++++++----
2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index a6c6051..9c920a6 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -485,7 +485,8 @@ static struct dma_chan *private_candidate(dma_cap_mask_t *mask, struct dma_devic
* @fn: optional callback to disposition available channels
* @fn_param: opaque parameter to pass to dma_filter_fn
*/
-struct dma_chan *__dma_request_channel(dma_cap_mask_t *mask, dma_filter_fn fn, void *fn_param)
+struct dma_chan *__dma_request_config_channel(dma_cap_mask_t *mask,
+ dma_filter_fn fn, void *fn_param, struct dma_slave_config *cfg)
{
struct dma_device *device, *_d;
struct dma_chan *chan = NULL;
@@ -521,12 +522,21 @@ struct dma_chan *__dma_request_channel(dma_cap_mask_t *mask, dma_filter_fn fn, v
}
mutex_unlock(&dma_list_mutex);

+ if (chan && cfg) {
+ int ret = device->device_control(chan, DMA_SLAVE_CONFIG,
+ (unsigned long)cfg);
+ if (ret) {
+ dma_release_channel(chan);
+ chan = NULL;
+ }
+ }
+
pr_debug("%s: %s (%s)\n", __func__, chan ? "success" : "fail",
chan ? dma_chan_name(chan) : NULL);

return chan;
}
-EXPORT_SYMBOL_GPL(__dma_request_channel);
+EXPORT_SYMBOL_GPL(__dma_request_config_channel);

void dma_release_channel(struct dma_chan *chan)
{
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 4b17ca8..9a4e9e9 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -924,7 +924,8 @@ enum dma_status dma_sync_wait(struct dma_chan *chan, dma_cookie_t cookie);
#ifdef CONFIG_DMA_ENGINE
enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx);
void dma_issue_pending_all(void);
-struct dma_chan *__dma_request_channel(dma_cap_mask_t *mask, dma_filter_fn fn, void *fn_param);
+struct dma_chan *__dma_request_config_channel(dma_cap_mask_t *mask,
+ dma_filter_fn fn, void *fn_param, struct dma_slave_config *cfg);
void dma_release_channel(struct dma_chan *chan);
#else
static inline enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx)
@@ -934,8 +935,9 @@ static inline enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descript
static inline void dma_issue_pending_all(void)
{
}
-static inline struct dma_chan *__dma_request_channel(dma_cap_mask_t *mask,
- dma_filter_fn fn, void *fn_param)
+static inline struct dma_chan *__dma_request_config_channel(
+ dma_cap_mask_t *mask, dma_filter_fn fn, void *fn_param,
+ struct dma_slave_config *cfg)
{
return NULL;
}
@@ -950,7 +952,10 @@ int dma_async_device_register(struct dma_device *device);
void dma_async_device_unregister(struct dma_device *device);
void dma_run_dependencies(struct dma_async_tx_descriptor *tx);
struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type);
-#define dma_request_channel(mask, x, y) __dma_request_channel(&(mask), x, y)
+#define dma_request_channel(mask, x, y) \
+ __dma_request_config_channel(&(mask), x, y, NULL)
+#define dma_request_config_channel(mask, x, y, cfg) \
+ __dma_request_config_channel(&(mask), x, y, cfg)

/* --- Helper iov-locking functions --- */


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/