dmaengine: add dma_slave_get_caps api
RFC 1/1 dmaengine: add dma_slave_get_caps api
add new device callback .device_slave_caps api which can be used by clients to query the dma channel capablties before they program the channel. This can help is removing errors during the channel programming. Also add helper dma_slave_get_caps API
This patch folds the work done by Matt earlier
https://patchwork.kernel.org/patch/2094891/
--- include/linux/dmaengine.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-)
include/linux/dmaengine.h +45 -0
@@ -371,6 +371,37 @@ struct dma_slave_config {unsigned int slave_id; }; +/* struct dma_slave_caps - expose capabilities of a slave channel only +* +* @src_addr_widths: bit mask of src addr widths the channel supports +* @dstn_addr_widths: bit mask of dstn addr widths the channel supports +* @src_burst_lengths: bit mask of src slave burst lengths supported +* @dstn_burst_lengths: bit mask of dstn slave burst lengths supported +* @directions: bit mask of slave direction the channel supported +* since the enum dma_transfer_direction is not defined as bits for each +* type of direction, the dma controller should fill (1 << <TYPE>) and same +* should be checked by controller as well +* @cmd_pause: true, if pause and thereby resume is supported +* @cmd_terminate: true, if terminate cmd is supported +* +* @max_seg_nr: maximum number of SG segments supported +* 0 for no maximum +* @max_seg_len: maximum length of a SG segment supported +* 0 for no maximum +*/ +struct dma_slave_caps { +u32 src_addr_widths; +u32 dstn_addr_widths; +u32 src_burst_lengths; +u32 dstn_burst_lengths; +u32 directions; +bool cmd_pause; +bool cmd_terminate; + +u32 max_sg_nr; +u32 max_sg_len; +}; +static inline const char *dma_chan_name (struct dma_chan *chan) {return dev_name (&chan->dev->device);
@@ -534,6 +565,7 @@ struct dma_tx_state {* struct with auxiliary transfer status information, otherwise the call * will just return a simple status code * @device_issue_pending: push pending transactions to hardware +* @device_slave_caps: return the slave channel capabilities */ struct dma_device {
@@ -602,6 +634,7 @@ struct dma_device {dma_cookie_t cookie, struct dma_tx_state *txstate);void (*device_issue_pending)(struct dma_chan *chan); +struct dma_slave_caps *(*device_slave_caps)(struct dma_chan *chan); }; static inline int dmaengine_device_control(struct dma_chan *chan,
@@ -675,6 +708,18 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_interleaved_dma(return chan->device->device_prep_interleaved_dma (chan, xt, flags); } +static inline struct dma_slave_caps *dma_get_slave_caps (struct dma_chan *chan) +{ +/* check if the channel supports slave transactions */ +if (!test_bit (DMA_SLAVE , chan->device->cap_mask.bits)) +return NULL ; + +if (chan->device->device_slave_caps) +return chan->device->device_slave_caps (chan); + +return NULL ; +} +static inline int dmaengine_terminate_all (struct dma_chan *chan) {return dmaengine_device_control (chan,DMA_TERMINATE_ALL ,0 );
Signature · 1 line
1.7.0.4
Quoted 8 lines · Vinod Koul
add new device callback .device_slave_caps api which can be used by clients to query the dma channel capablties before they program the channel. This can help is removing errors during the channel programming. Also add helper
dma_slave_get_capsAPIThis patch folds the work done by Matt earlier
https://patchwork.kernel.org/patch/2094891/
Hi,
Thanks for taking care of this.
Quoted 10 lines
Signed-off-by Vinod Koul <[email protected]>--- include/linux/dmaengine.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-)include/linux/dmaengine.h +0
-0
include/linux/dmaengine.h struct dma_slave_config { · line 379
Quoted 9 lines
include/linux/dmaengine.h +6
-0@@ -371,6 +371,37 @@ struct dma_slave_config {unsigned int slave_id; }; +/* struct dma_slave_caps - expose capabilities of a slave channel only +* +* @src_addr_widths: bit mask of src addr widths the channel supports +* @dstn_addr_widths: bit mask of dstn addr widths the channel supports +* @src_burst_lengths: bit mask of src slave burst lengths supported +* @dstn_burst_lengths: bit mask of dstn slave burst lengths supported
I'm not sure if we need the burst_lengths fields. For one we can only express a max burst length up 32. And usually it is fine if the dma controller does not support the burst length requested by the slave driver, since this only specifies the maximum and the dma controller driver can choose a value below this limit. E.g. if the max burst length is set to 16 it is still fine if the controller only supports a burst length of 8.
Quoted 45 lines
include/linux/dmaengine.h +27
-0+* @directions: bit mask of slave direction the channel supported +* since the enum dma_transfer_direction is not defined as bits for each +* type of direction, the dma controller should fill (1 << <TYPE>) and same +* should be checked by controller as well +* @cmd_pause: true, if pause and thereby resume is supported +* @cmd_terminate: true, if terminate cmd is supported +* +* @max_seg_nr: maximum number of SG segments supported +* 0 for no maximum +* @max_seg_len: maximum length of a SG segment supported +* 0 for no maximum +*/ +struct dma_slave_caps { +u32 src_addr_widths; +u32 dstn_addr_widths; +u32 src_burst_lengths; +u32 dstn_burst_lengths; +u32 directions; +bool cmd_pause; +bool cmd_terminate; + +u32 max_sg_nr; +u32 max_sg_len; +}; +static inline const char *dma_chan_name (struct dma_chan *chan) {return dev_name (&chan->dev->device);@@ -534,6 +565,7 @@ struct dma_tx_state {* struct with auxiliary transfer status information, otherwise the call * will just return a simple status code * @device_issue_pending: push pending transactions to hardware +* @device_slave_caps: return the slave channel capabilities */ struct dma_device {@@ -602,6 +634,7 @@ struct dma_device {dma_cookie_t cookie, struct dma_tx_state *txstate);void (*device_issue_pending)(struct dma_chan *chan); +struct dma_slave_caps *(*device_slave_caps)(struct dma_chan *chan); }; static inline int dmaengine_device_control(struct dma_chan *chan,
include/linux/dmaengine.h static inline struct dma_async_tx_descriptor *dmaengine_prep_interleaved_dma( · line 711
Quoted 4 lines
include/linux/dmaengine.h +1
-0@@ -675,6 +708,18 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_interleaved_dma(return chan->device->device_prep_interleaved_dma (chan, xt, flags); } +static inline struct dma_slave_caps *dma_get_slave_caps (struct dma_chan *chan)
Same comment as for Matt's patch. The caller of the dma_get_slave_caps() should pass in a pointer to a dma_slave_caps struct which the dma driver will then fill in. This makes it much clearer to the caller what the lifetime of the struct is.
Quoted 10 lines
include/linux/dmaengine.h +10
-0+{ +/* check if the channel supports slave transactions */ +if (!test_bit (DMA_SLAVE , chan->device->cap_mask.bits)) +return NULL ; + +if (chan->device->device_slave_caps) +return chan->device->device_slave_caps (chan); + +return NULL ; +}
Quoted 8 lines · Lars-Peter Clausen
Quoted 6 lines · Vinod Koul
+/* struct
dma_slave_caps- expose capabilities of a slave channel only
+ *
+ * @src_addr_widths: bit mask of src addr widths the channel supports
+ * @dstn_addr_widths: bit mask of dstn addr widths the channel supports
+ * @src_burst_lengths: bit mask of src slave burst lengths supported
+ * @dstn_burst_lengths: bit mask of dstn slave burst lengths supported
Quoted 6 lines
I'm not sure if we need the
burst_lengthsfields. For one we can only express a max burst length up 32. And usually it is fine if the dma controller does not support the burst length requested by the slave driver, since this only specifies the maximum and the dma controller driver can choose a value below this limit. E.g. if the max burst length is set to 16 it is still fine if the controller only supports a burst length of 8.
well how are you picking up which one to use?
The idea is that you query and match that with system and client to get best throughput. If you have IP block which over generations change capablities you can runtime query and then program the channel smartly!
Quoted 6 lines
Quoted 1 line
+static inline struct
dma_slave_caps*dma_get_slave_caps(structdma_chan*chan)Same comment as for Matt's patch. The caller of the
dma_get_slave_caps()should pass in a pointer to adma_slave_capsstruct which the dma driver will then fill in. This makes it much clearer to the caller what the lifetime of the struct is.
Yup i agree, will update...
~Vinod
Quoted 15 lines · Vinod Koul
Quoted 8 lines · Lars-Peter Clausen
Quoted 6 lines · Vinod Koul
+/* struct
dma_slave_caps- expose capabilities of a slave channel only
+ *
+ * @src_addr_widths: bit mask of src addr widths the channel supports
+ * @dstn_addr_widths: bit mask of dstn addr widths the channel supports
+ * @src_burst_lengths: bit mask of src slave burst lengths supported
+ * @dstn_burst_lengths: bit mask of dstn slave burst lengths supportedQuoted 6 lines
I'm not sure if we need the
burst_lengthsfields. For one we can only express a max burst length up 32. And usually it is fine if the dma controller does not support the burst length requested by the slave driver, since this only specifies the maximum and the dma controller driver can choose a value below this limit. E.g. if the max burst length is set to 16 it is still fine if the controller only supports a burst length of 8.
Quoted 4 lines
well how are you picking up which one to use?
The idea is that you query and match that with system and client to get best throughput. If you have IP block which over generations change capablities you can runtime query and then program the channel smartly!
The client would always request the largest burst size it can support, and the dma master would then select a burst size equal or smaller to it depending on what it can support.
E.g. if the client has an internal FIFO with room for 16 samples and it sends a request once the FIFO is half empty, max_burst would be set to 8. If the master supports burst sizes of 8 sample it would send 8 samples, if it only supported burst sizes of 4 it might send either one burst of 4 or two of 4.
- Lars
Quoted 16 lines · Lars-Peter Clausen
Quoted 15 lines · Vinod Koul
Quoted 14 lines · Lars-Peter Clausen
Quoted 6 lines · Vinod Koul
+/* struct
dma_slave_caps- expose capabilities of a slave channel only
+ *
+ * @src_addr_widths: bit mask of src addr widths the channel supports
+ * @dstn_addr_widths: bit mask of dstn addr widths the channel supports
+ * @src_burst_lengths: bit mask of src slave burst lengths supported
+ * @dstn_burst_lengths: bit mask of dstn slave burst lengths supportedI'm not sure if we need the
burst_lengthsfields. For one we can only express a max burst length up 32. And usually it is fine if the dma controller does not support the burst length requested by the slave driver, since this only specifies the maximum and the dma controller driver can choose a value below this limit. E.g. if the max burst length is set to 16 it is still fine if the controller only supports a burst length of 8.
Quoted 8 lines
Quoted 4 lines
well how are you picking up which one to use?
The idea is that you query and match that with system and client to get best throughput. If you have IP block which over generations change capablities you can runtime query and then program the channel smartly!The client would always request the largest burst size it can support, and the dma master would then select a burst size equal or smaller to it depending on what it can support.
not really, most dmac drivers will return an error when they find a value is not in the supported list. And that is precisely what we would like to prevent. If you look at current model, it mostly program value which we know is already a capablity and works model.
Quoted 4 lines
E.g. if the client has an internal FIFO with room for 16 samples and it sends a request once the FIFO is half empty,
max_burstwould be set to 8. If the master supports burst sizes of 8 sample it would send 8 samples, if it only supported burst sizes of 4 it might send either one burst of 4 or two of 4.
~Vinod
Quoted 22 lines · Vinod Koul
Quoted 21 lines · Lars-Peter Clausen
Quoted 19 lines · Vinod Koul
Quoted 8 lines · Lars-Peter Clausen
Quoted 6 lines · Vinod Koul
+/* struct
dma_slave_caps- expose capabilities of a slave channel only
+ *
+ * @src_addr_widths: bit mask of src addr widths the channel supports
+ * @dstn_addr_widths: bit mask of dstn addr widths the channel supports
+ * @src_burst_lengths: bit mask of src slave burst lengths supported
+ * @dstn_burst_lengths: bit mask of dstn slave burst lengths supportedQuoted 6 lines
I'm not sure if we need the
burst_lengthsfields. For one we can only express a max burst length up 32. And usually it is fine if the dma controller does not support the burst length requested by the slave driver, since this only specifies the maximum and the dma controller driver can choose a value below this limit. E.g. if the max burst length is set to 16 it is still fine if the controller only supports a burst length of 8.well how are you picking up which one to use?
The idea is that you query and match that with system and client to get best throughput. If you have IP block which over generations change capablities you can runtime query and then program the channel smartly!
Quoted 7 lines
Quoted 3 lines
The client would always request the largest burst size it can support, and the dma master would then select a burst size equal or smaller to it depending on what it can support.
not really, most dmac drivers will return an error when they find a value is not in the supported list. And that is precisely what we would like to prevent. If you look at current model, it mostly program value which we know is already a capablity and works model.
The majority of the DMA drivers will either accept any maxburst value (which is probably broken) or round down. The only ones which accept only a fixed set of burst sizes seem to be mmp_pdma, mmp_tdma and sa11x0-dma.
- Lars
PATCH 1/1 dmaengine: add dma_slave_get_caps api
In reply to Vinod Kouladd new device callback .device_slave_caps api which can be used by clients to query the dma channel capablties before they program the channel. This can help is removing errors during the channel programming. Also add helper dma_slave_get_caps API
This patch folds the work done by Matt earlier
https://patchwork.kernel.org/patch/2094891/
--
this version
changes api to include struct dma_slave_caps as arg removed burst lengths, can be added when we have users
--
include/linux/dmaengine.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-)
include/linux/dmaengine.h +45 -0
@@ -370,6 +370,37 @@ struct dma_slave_config {unsigned int slave_id; }; +/* struct dma_slave_caps - expose capabilities of a slave channel only +* +* @src_addr_widths: bit mask of src addr widths the channel supports +* @dstn_addr_widths: bit mask of dstn addr widths the channel supports +* @src_burst_lengths: bit mask of src slave burst lengths supported +* @dstn_burst_lengths: bit mask of dstn slave burst lengths supported +* @directions: bit mask of slave direction the channel supported +* since the enum dma_transfer_direction is not defined as bits for each +* type of direction, the dma controller should fill (1 << <TYPE>) and same +* should be checked by controller as well +* @cmd_pause: true, if pause and thereby resume is supported +* @cmd_terminate: true, if terminate cmd is supported +* +* @max_seg_nr: maximum number of SG segments supported +* 0 for no maximum +* @max_seg_len: maximum length of a SG segment supported +* 0 for no maximum +*/ +struct dma_slave_caps { +u32 src_addr_widths; +u32 dstn_addr_widths; +u32 src_burst_lengths; +u32 dstn_burst_lengths; +u32 directions; +bool cmd_pause; +bool cmd_terminate; + +u32 max_sg_nr; +u32 max_sg_len; +}; +static inline const char *dma_chan_name (struct dma_chan *chan) {return dev_name (&chan->dev->device);
@@ -532,6 +563,7 @@ struct dma_tx_state {* struct with auxiliary transfer status information, otherwise the call * will just return a simple status code * @device_issue_pending: push pending transactions to hardware +* @device_slave_caps: return the slave channel capabilities */ struct dma_device {
@@ -597,6 +629,7 @@ struct dma_device {dma_cookie_t cookie, struct dma_tx_state *txstate);void (*device_issue_pending)(struct dma_chan *chan); +struct dma_slave_caps *(*device_slave_caps)(struct dma_chan *chan); }; static inline int dmaengine_device_control(struct dma_chan *chan,
@@ -670,6 +703,18 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_interleaved_dma(return chan->device->device_prep_interleaved_dma (chan, xt, flags); } +static inline struct dma_slave_caps *dma_get_slave_caps (struct dma_chan *chan) +{ +/* check if the channel supports slave transactions */ +if (!test_bit (DMA_SLAVE , chan->device->cap_mask.bits)) +return NULL ; + +if (chan->device->device_slave_caps) +return chan->device->device_slave_caps (chan); + +return NULL ; +} +static inline int dmaengine_terminate_all (struct dma_chan *chan) {return dmaengine_device_control (chan,DMA_TERMINATE_ALL ,0 );
Signature · 1 line
1.7.0.4
Quoted 5 lines · Vinod Koul
add new device callback .device_slave_caps api which can be used by clients to query the dma channel capablties before they program the channel. This can help is removing errors during the channel programming. Also add helper
dma_slave_get_capsAPI
Quoted 8 lines
This patch folds the work done by Matt earlier
https://patchwork.kernel.org/patch/2094891/Signed-off-by Vinod Koul <[email protected]>--
this version
changes api to include structdma_slave_capsas arg removed burst lengths, can be added when we have users
Hi,
it looks like you did send out v1 by accident.
- Lars
Quoted 83 lines
--
include/linux/dmaengine.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-)include/linux/dmaengine.h +45
-0@@ -370,6 +370,37 @@ struct dma_slave_config {unsigned int slave_id; }; +/* struct dma_slave_caps - expose capabilities of a slave channel only +* +* @src_addr_widths: bit mask of src addr widths the channel supports +* @dstn_addr_widths: bit mask of dstn addr widths the channel supports +* @src_burst_lengths: bit mask of src slave burst lengths supported +* @dstn_burst_lengths: bit mask of dstn slave burst lengths supported +* @directions: bit mask of slave direction the channel supported +* since the enum dma_transfer_direction is not defined as bits for each +* type of direction, the dma controller should fill (1 << <TYPE>) and same +* should be checked by controller as well +* @cmd_pause: true, if pause and thereby resume is supported +* @cmd_terminate: true, if terminate cmd is supported +* +* @max_seg_nr: maximum number of SG segments supported +* 0 for no maximum +* @max_seg_len: maximum length of a SG segment supported +* 0 for no maximum +*/ +struct dma_slave_caps { +u32 src_addr_widths; +u32 dstn_addr_widths; +u32 src_burst_lengths; +u32 dstn_burst_lengths; +u32 directions; +bool cmd_pause; +bool cmd_terminate; + +u32 max_sg_nr; +u32 max_sg_len; +}; +static inline const char *dma_chan_name (struct dma_chan *chan) {return dev_name (&chan->dev->device);@@ -532,6 +563,7 @@ struct dma_tx_state {* struct with auxiliary transfer status information, otherwise the call * will just return a simple status code * @device_issue_pending: push pending transactions to hardware +* @device_slave_caps: return the slave channel capabilities */ struct dma_device {@@ -597,6 +629,7 @@ struct dma_device {dma_cookie_t cookie, struct dma_tx_state *txstate);void (*device_issue_pending)(struct dma_chan *chan); +struct dma_slave_caps *(*device_slave_caps)(struct dma_chan *chan); }; static inline int dmaengine_device_control(struct dma_chan *chan,@@ -670,6 +703,18 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_interleaved_dma(return chan->device->device_prep_interleaved_dma (chan, xt, flags); } +static inline struct dma_slave_caps *dma_get_slave_caps (struct dma_chan *chan) +{ +/* check if the channel supports slave transactions */ +if (!test_bit (DMA_SLAVE , chan->device->cap_mask.bits)) +return NULL ; + +if (chan->device->device_slave_caps) +return chan->device->device_slave_caps (chan); + +return NULL ; +} +static inline int dmaengine_terminate_all (struct dma_chan *chan) {return dmaengine_device_control (chan,DMA_TERMINATE_ALL ,0 );
Quoted 15 lines · Lars-Peter Clausen
Quoted 5 lines · Vinod Koul
add new device callback .device_slave_caps api which can be used by clients to query the dma channel capablties before they program the channel. This can help is removing errors during the channel programming. Also add helper
dma_slave_get_capsAPIQuoted 8 lines
This patch folds the work done by Matt earlier
https://patchwork.kernel.org/patch/2094891/Signed-off-by Vinod Koul <[email protected]>--
this version
changes api to include structdma_slave_capsas arg removed burst lengths, can be added when we have users
Quoted 3 lines
Hi,
it looks like you did send out v1 by accident.
Yes but problem wasnt sending wrong patch but generating patch without comitting!
resent now...
I am planning to keep this on a branch which I wont rebase. That way users (mostly ASoC for now), can merge this and get drivers converted.
~Vinod
PATCH 1/1 dmaengine: add dma_slave_get_caps api
In reply to Vinod Kouladd new device callback .device_slave_caps api which can be used by clients to query the dma channel capablties before they program the channel. This can help is removing errors during the channel programming. Also add helper dma_slave_get_caps API
This patch folds the work done by Matt earlier
https://patchwork.kernel.org/patch/2094891/
---
this version
changes api to include struct dma_slave_caps as arg removed burst lengths, can be added when we have users
--
include/linux/dmaengine.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-)
include/linux/dmaengine.h +44 -0
@@ -370,6 +370,33 @@ struct dma_slave_config {unsigned int slave_id; }; +/* struct dma_slave_caps - expose capabilities of a slave channel only +* +* @src_addr_widths: bit mask of src addr widths the channel supports +* @dstn_addr_widths: bit mask of dstn addr widths the channel supports +* @directions: bit mask of slave direction the channel supported +* since the enum dma_transfer_direction is not defined as bits for each +* type of direction, the dma controller should fill (1 << <TYPE>) and same +* should be checked by controller as well +* @cmd_pause: true, if pause and thereby resume is supported +* @cmd_terminate: true, if terminate cmd is supported +* +* @max_seg_nr: maximum number of SG segments supported +* 0 for no maximum +* @max_seg_len: maximum length of a SG segment supported +* 0 for no maximum +*/ +struct dma_slave_caps { +u32 src_addr_widths; +u32 dstn_addr_widths; +u32 directions; +bool cmd_pause; +bool cmd_terminate; + +u32 max_sg_nr; +u32 max_sg_len; +}; +static inline const char *dma_chan_name (struct dma_chan *chan) {return dev_name (&chan->dev->device);
@@ -532,6 +559,7 @@ struct dma_tx_state {* struct with auxiliary transfer status information, otherwise the call * will just return a simple status code * @device_issue_pending: push pending transactions to hardware +* @device_slave_caps: return the slave channel capabilities */ struct dma_device {
@@ -597,6 +625,7 @@ struct dma_device {dma_cookie_t cookie, struct dma_tx_state *txstate);void (*device_issue_pending)(struct dma_chan *chan); +int (*device_slave_caps)(struct dma_chan *chan,struct dma_slave_caps *caps); }; static inline int dmaengine_device_control(struct dma_chan *chan,
@@ -670,6 +699,21 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_interleaved_dma(return chan->device->device_prep_interleaved_dma (chan, xt, flags); } +static inline int dma_get_slave_caps (struct dma_chan *chan,struct dma_slave_caps *caps) +{ +if (!chan || !caps) +return -EINVAL ; + +/* check if the channel supports slave transactions */ +if (!test_bit (DMA_SLAVE , chan->device->cap_mask.bits)) +return -ENXIO ; + +if (chan->device->device_slave_caps) +return chan->device->device_slave_caps (chan, caps); + +return -ENXIO ; +} +static inline int dmaengine_terminate_all (struct dma_chan *chan) {return dmaengine_device_control (chan,DMA_TERMINATE_ALL ,0 );
Signature · 1 line
1.7.0.4
Quoted 9 lines · Vinod Koul
add new device callback .device_slave_caps api which can be used by clients to query the dma channel capablties before they program the channel. This can help is removing errors during the channel programming. Also add helper
dma_slave_get_capsAPIThis patch folds the work done by Matt earlier
https://patchwork.kernel.org/patch/2094891/Signed-off-by Vinod Koul <[email protected]>
Thanks, looks good to me. I already had some changes to the dmaengine PCM driver based on Matt's patch, I'll rework them on top of this one.
- Lars
Quoted 86 lines
---
this version
changes api to include structdma_slave_capsas arg removed burst lengths, can be added when we have users
--include/linux/dmaengine.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-)include/linux/dmaengine.h +44
-0@@ -370,6 +370,33 @@ struct dma_slave_config {unsigned int slave_id; }; +/* struct dma_slave_caps - expose capabilities of a slave channel only +* +* @src_addr_widths: bit mask of src addr widths the channel supports +* @dstn_addr_widths: bit mask of dstn addr widths the channel supports +* @directions: bit mask of slave direction the channel supported +* since the enum dma_transfer_direction is not defined as bits for each +* type of direction, the dma controller should fill (1 << <TYPE>) and same +* should be checked by controller as well +* @cmd_pause: true, if pause and thereby resume is supported +* @cmd_terminate: true, if terminate cmd is supported +* +* @max_seg_nr: maximum number of SG segments supported +* 0 for no maximum +* @max_seg_len: maximum length of a SG segment supported +* 0 for no maximum +*/ +struct dma_slave_caps { +u32 src_addr_widths; +u32 dstn_addr_widths; +u32 directions; +bool cmd_pause; +bool cmd_terminate; + +u32 max_sg_nr; +u32 max_sg_len; +}; +static inline const char *dma_chan_name (struct dma_chan *chan) {return dev_name (&chan->dev->device);@@ -532,6 +559,7 @@ struct dma_tx_state {* struct with auxiliary transfer status information, otherwise the call * will just return a simple status code * @device_issue_pending: push pending transactions to hardware +* @device_slave_caps: return the slave channel capabilities */ struct dma_device {@@ -597,6 +625,7 @@ struct dma_device {dma_cookie_t cookie, struct dma_tx_state *txstate);void (*device_issue_pending)(struct dma_chan *chan); +int (*device_slave_caps)(struct dma_chan *chan,struct dma_slave_caps *caps); }; static inline int dmaengine_device_control(struct dma_chan *chan,@@ -670,6 +699,21 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_interleaved_dma(return chan->device->device_prep_interleaved_dma (chan, xt, flags); } +static inline int dma_get_slave_caps (struct dma_chan *chan,struct dma_slave_caps *caps) +{ +if (!chan || !caps) +return -EINVAL ; + +/* check if the channel supports slave transactions */ +if (!test_bit (DMA_SLAVE , chan->device->cap_mask.bits)) +return -ENXIO ; + +if (chan->device->device_slave_caps) +return chan->device->device_slave_caps (chan, caps); + +return -ENXIO ; +} +static inline int dmaengine_terminate_all (struct dma_chan *chan) {return dmaengine_device_control (chan,DMA_TERMINATE_ALL ,0 );
On 07/15/2013 12:21 PM, Vinod Koul wrote:
[...]
Quoted 4 lines
+ * @max_seg_nr: maximum number of SG segments supported
+ * 0 for no maximum
+ * @max_seg_len: maximum length of a SG segment supported
+ * 0 for no maximum
[...]
include/linux/dmaengine.h struct dma_slave_config { · line 397
Quoted 2 lines
include/linux/dmaengine.h +2
-0+u32 max_sg_nr; +u32 max_sg_len;
seg vs. sg
Quoted 11 lines · Lars-Peter Clausen
On 07/15/2013 12:21 PM, Vinod Koul wrote:
[...]Quoted 4 lines
+ * @max_seg_nr: maximum number of SG segments supported
+ * 0 for no maximum
+ * @max_seg_len: maximum length of a SG segment supported
+ * 0 for no maximum[...]
include/linux/dmaengine.h struct dma_slave_config { · line 397
Quoted 2 lines
include/linux/dmaengine.h +2
-0+u32 max_sg_nr; +u32 max_sg_len;seg vs. sg
Thanks, fixed and applied now to topic/api_caps
--
~Vinod