dmaengine: at_xdmac: fix slave configuration issue
Subsystems (3)
PATCH 1/1 dmaengine: at_xdmac: fix slave configuration issue
When doing the slave configuration, an error is returned if the maxburst value is not supported. The bug comes from the fact that we always check the maxburst for both directions but in the case of an unidirectional channel, only one is set.
--- drivers/dma/at_xdmac.c | 97 +++++++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 45 deletions(-)
drivers/dma/at_xdmac.c +52 -45
@@ -501,54 +501,61 @@ static int at_xdmac_set_slave_config(struct dma_chan *chan,u8 dwidth;int csize; - atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ] = -AT91_XDMAC_DT_PERID (atchan->perid) - |AT_XDMAC_CC_DAM_INCREMENTED_AM - |AT_XDMAC_CC_SAM_FIXED_AM - |AT_XDMAC_CC_DIF (atchan->memif) - |AT_XDMAC_CC_SIF (atchan->perif) - |AT_XDMAC_CC_SWREQ_HWR_CONNECTED - |AT_XDMAC_CC_DSYNC_PER2MEM - |AT_XDMAC_CC_MBSIZE_SIXTEEN - |AT_XDMAC_CC_TYPE_PER_TRAN ; - csize =at_xdmac_csize (sconfig->src_maxburst); -if (csize <0 ) { -dev_err (chan2dev (chan),"invalid src maxburst value\n" ); -return -EINVAL ; - } - atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ] |=AT_XDMAC_CC_CSIZE (csize); - dwidth =ffs (sconfig->src_addr_width) -1 ; - atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ] |=AT_XDMAC_CC_DWIDTH (dwidth); - - - atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ] = -AT91_XDMAC_DT_PERID (atchan->perid) - |AT_XDMAC_CC_DAM_FIXED_AM - |AT_XDMAC_CC_SAM_INCREMENTED_AM - |AT_XDMAC_CC_DIF (atchan->perif) - |AT_XDMAC_CC_SIF (atchan->memif) - |AT_XDMAC_CC_SWREQ_HWR_CONNECTED - |AT_XDMAC_CC_DSYNC_MEM2PER - |AT_XDMAC_CC_MBSIZE_SIXTEEN - |AT_XDMAC_CC_TYPE_PER_TRAN ; - csize =at_xdmac_csize (sconfig->dst_maxburst); -if (csize <0 ) { -dev_err (chan2dev (chan),"invalid src maxburst value\n" ); -return -EINVAL ; +if (sconfig->src_addr) { + atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ] = +AT91_XDMAC_DT_PERID (atchan->perid) + |AT_XDMAC_CC_DAM_INCREMENTED_AM + |AT_XDMAC_CC_SAM_FIXED_AM + |AT_XDMAC_CC_DIF (atchan->memif) + |AT_XDMAC_CC_SIF (atchan->perif) + |AT_XDMAC_CC_SWREQ_HWR_CONNECTED + |AT_XDMAC_CC_DSYNC_PER2MEM + |AT_XDMAC_CC_MBSIZE_SIXTEEN + |AT_XDMAC_CC_TYPE_PER_TRAN ; + csize =at_xdmac_csize (sconfig->src_maxburst); +if (csize <0 ) { +dev_err (chan2dev (chan),"invalid src maxburst value\n" ); +return -EINVAL ; + } + atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ] |=AT_XDMAC_CC_CSIZE (csize); + dwidth =ffs (sconfig->src_addr_width) -1 ; + atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ] |=AT_XDMAC_CC_DWIDTH (dwidth); +/* Src addr is needed to configure the link list descriptor. */ + atchan->per_src_addr = sconfig->src_addr; + +dev_dbg (chan2dev (chan), +"%s: cfg[dev2mem]=0x%08x, per_src_addr=0x%08x\n" , + __func__, atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ], + atchan->per_src_addr); } - atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ] |=AT_XDMAC_CC_CSIZE (csize); - dwidth =ffs (sconfig->dst_addr_width) -1 ; - atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ] |=AT_XDMAC_CC_DWIDTH (dwidth); -/* Src and dst addr are needed to configure the link list descriptor. */ - atchan->per_src_addr = sconfig->src_addr; - atchan->per_dst_addr = sconfig->dst_addr; +if (sconfig->dst_addr) { + atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ] = +AT91_XDMAC_DT_PERID (atchan->perid) + |AT_XDMAC_CC_DAM_FIXED_AM + |AT_XDMAC_CC_SAM_INCREMENTED_AM + |AT_XDMAC_CC_DIF (atchan->perif) + |AT_XDMAC_CC_SIF (atchan->memif) + |AT_XDMAC_CC_SWREQ_HWR_CONNECTED + |AT_XDMAC_CC_DSYNC_MEM2PER + |AT_XDMAC_CC_MBSIZE_SIXTEEN + |AT_XDMAC_CC_TYPE_PER_TRAN ; + csize =at_xdmac_csize (sconfig->dst_maxburst); +if (csize <0 ) { +dev_err (chan2dev (chan),"invalid src maxburst value\n" ); +return -EINVAL ; + } + atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ] |=AT_XDMAC_CC_CSIZE (csize); + dwidth =ffs (sconfig->dst_addr_width) -1 ; + atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ] |=AT_XDMAC_CC_DWIDTH (dwidth); +/* Dst addr is needed to configure the link list descriptor. */ + atchan->per_dst_addr = sconfig->dst_addr; -dev_dbg (chan2dev (chan), -"%s: cfg[dev2mem]=0x%08x, cfg[mem2dev]=0x%08x, per_src_addr=0x%08x, per_dst_addr=0x%08x\n" , - __func__, atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ], - atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ], - atchan->per_src_addr, atchan->per_dst_addr); +dev_dbg (chan2dev (chan), +"%s: cfg[mem2dev]=0x%08x, per_dst_addr=0x%08x\n" , + __func__, atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ], + atchan->per_dst_addr); + }return 0 ; }
Signature · 1 line
2.2.0
PATCH 1/1 dmaengine: at_xdmac: fix slave configuration issue
Quoted 4 lines · Ludovic Desroches
When doing the slave configuration, an error is returned if the maxburst value is not supported. The bug comes from the fact that we always check the maxburst for both directions but in the case of an unidirectional channel, only one is set.
While setting the slave configuration we are not tied to a channel direction, the direction is passed usin prep_ method. So from that prespective a channle can be used for tx and rx with same slave config set.
Now if we were invoking at_xdmac_set_slave_config from prep_ calls then it would have been fine but here we are checking when the slave config is set so this is not right. You should check maxburst at runtime then...
Signature · 1 line
~Vinod
Quoted 120 lines
Signed-off-by Ludovic Desroches <[email protected]>Cc <[email protected]> # 3.19 and later--- drivers/dma/at_xdmac.c | 97 +++++++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 45 deletions(-)drivers/dma/at_xdmac.c +52
-45@@ -501,54 +501,61 @@ static int at_xdmac_set_slave_config(struct dma_chan *chan,u8 dwidth;int csize; - atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ] = -AT91_XDMAC_DT_PERID (atchan->perid) - |AT_XDMAC_CC_DAM_INCREMENTED_AM - |AT_XDMAC_CC_SAM_FIXED_AM - |AT_XDMAC_CC_DIF (atchan->memif) - |AT_XDMAC_CC_SIF (atchan->perif) - |AT_XDMAC_CC_SWREQ_HWR_CONNECTED - |AT_XDMAC_CC_DSYNC_PER2MEM - |AT_XDMAC_CC_MBSIZE_SIXTEEN - |AT_XDMAC_CC_TYPE_PER_TRAN ; - csize =at_xdmac_csize (sconfig->src_maxburst); -if (csize <0 ) { -dev_err (chan2dev (chan),"invalid src maxburst value\n" ); -return -EINVAL ; - } - atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ] |=AT_XDMAC_CC_CSIZE (csize); - dwidth =ffs (sconfig->src_addr_width) -1 ; - atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ] |=AT_XDMAC_CC_DWIDTH (dwidth); - - - atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ] = -AT91_XDMAC_DT_PERID (atchan->perid) - |AT_XDMAC_CC_DAM_FIXED_AM - |AT_XDMAC_CC_SAM_INCREMENTED_AM - |AT_XDMAC_CC_DIF (atchan->perif) - |AT_XDMAC_CC_SIF (atchan->memif) - |AT_XDMAC_CC_SWREQ_HWR_CONNECTED - |AT_XDMAC_CC_DSYNC_MEM2PER - |AT_XDMAC_CC_MBSIZE_SIXTEEN - |AT_XDMAC_CC_TYPE_PER_TRAN ; - csize =at_xdmac_csize (sconfig->dst_maxburst); -if (csize <0 ) { -dev_err (chan2dev (chan),"invalid src maxburst value\n" ); -return -EINVAL ; +if (sconfig->src_addr) { + atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ] = +AT91_XDMAC_DT_PERID (atchan->perid) + |AT_XDMAC_CC_DAM_INCREMENTED_AM + |AT_XDMAC_CC_SAM_FIXED_AM + |AT_XDMAC_CC_DIF (atchan->memif) + |AT_XDMAC_CC_SIF (atchan->perif) + |AT_XDMAC_CC_SWREQ_HWR_CONNECTED + |AT_XDMAC_CC_DSYNC_PER2MEM + |AT_XDMAC_CC_MBSIZE_SIXTEEN + |AT_XDMAC_CC_TYPE_PER_TRAN ; + csize =at_xdmac_csize (sconfig->src_maxburst); +if (csize <0 ) { +dev_err (chan2dev (chan),"invalid src maxburst value\n" ); +return -EINVAL ; + } + atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ] |=AT_XDMAC_CC_CSIZE (csize); + dwidth =ffs (sconfig->src_addr_width) -1 ; + atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ] |=AT_XDMAC_CC_DWIDTH (dwidth); +/* Src addr is needed to configure the link list descriptor. */ + atchan->per_src_addr = sconfig->src_addr; + +dev_dbg (chan2dev (chan), +"%s: cfg[dev2mem]=0x%08x, per_src_addr=0x%08x\n" , + __func__, atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ], + atchan->per_src_addr); } - atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ] |=AT_XDMAC_CC_CSIZE (csize); - dwidth =ffs (sconfig->dst_addr_width) -1 ; - atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ] |=AT_XDMAC_CC_DWIDTH (dwidth); -/* Src and dst addr are needed to configure the link list descriptor. */ - atchan->per_src_addr = sconfig->src_addr; - atchan->per_dst_addr = sconfig->dst_addr; +if (sconfig->dst_addr) { + atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ] = +AT91_XDMAC_DT_PERID (atchan->perid) + |AT_XDMAC_CC_DAM_FIXED_AM + |AT_XDMAC_CC_SAM_INCREMENTED_AM + |AT_XDMAC_CC_DIF (atchan->perif) + |AT_XDMAC_CC_SIF (atchan->memif) + |AT_XDMAC_CC_SWREQ_HWR_CONNECTED + |AT_XDMAC_CC_DSYNC_MEM2PER + |AT_XDMAC_CC_MBSIZE_SIXTEEN + |AT_XDMAC_CC_TYPE_PER_TRAN ; + csize =at_xdmac_csize (sconfig->dst_maxburst); +if (csize <0 ) { +dev_err (chan2dev (chan),"invalid src maxburst value\n" ); +return -EINVAL ; + } + atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ] |=AT_XDMAC_CC_CSIZE (csize); + dwidth =ffs (sconfig->dst_addr_width) -1 ; + atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ] |=AT_XDMAC_CC_DWIDTH (dwidth); +/* Dst addr is needed to configure the link list descriptor. */ + atchan->per_dst_addr = sconfig->dst_addr; -dev_dbg (chan2dev (chan), -"%s: cfg[dev2mem]=0x%08x, cfg[mem2dev]=0x%08x, per_src_addr=0x%08x, per_dst_addr=0x%08x\n" , - __func__, atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ], - atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ], - atchan->per_src_addr, atchan->per_dst_addr); +dev_dbg (chan2dev (chan), +"%s: cfg[mem2dev]=0x%08x, per_dst_addr=0x%08x\n" , + __func__, atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ], + atchan->per_dst_addr); + }return 0 ; }Signature · 1 line
2.2.0
PATCH 1/1 dmaengine: at_xdmac: fix slave configuration issue
Hi Vinod,
Quoted 5 lines · Vinod Koul
Quoted 4 lines · Ludovic Desroches
When doing the slave configuration, an error is returned if the maxburst value is not supported. The bug comes from the fact that we always check the maxburst for both directions but in the case of an unidirectional channel, only one is set.
Quoted 8 lines
While setting the slave configuration we are not tied to a channel direction, the direction is passed usin
prep_method. So from that prespective a channle can be used for tx and rx with same slave config set.Now if we were invoking
at_xdmac_set_slave_configfromprep_calls then it would have been fine but here we are checking when the slave config is set so this is not right. You should check maxburst at runtime then...
I don't understand why we should wait before checking the configuration... Some channels are unidirectionnal so implicitly we know the direction at configuration time because the device will fill only a part of the dma_slave_config structure. For example, the atmel usart requests a tx and a rx channels. When configuring the tx channel, only the dst_ fields of the dma_slave_config structure are filled. Is it a bad behavior?
The change introduced by this patch doesn't really care about the direction, it only tells that if the device only fills src_ fields then I don't have to check fields not configured.
Regards
Ludovic
Quoted 124 lines
Signature · 1 line
~VinodQuoted 120 lines
Signed-off-by Ludovic Desroches <[email protected]>Cc <[email protected]> # 3.19 and later--- drivers/dma/at_xdmac.c | 97 +++++++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 45 deletions(-)drivers/dma/at_xdmac.c +52
-45@@ -501,54 +501,61 @@ static int at_xdmac_set_slave_config(struct dma_chan *chan,u8 dwidth;int csize; - atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ] = -AT91_XDMAC_DT_PERID (atchan->perid) - |AT_XDMAC_CC_DAM_INCREMENTED_AM - |AT_XDMAC_CC_SAM_FIXED_AM - |AT_XDMAC_CC_DIF (atchan->memif) - |AT_XDMAC_CC_SIF (atchan->perif) - |AT_XDMAC_CC_SWREQ_HWR_CONNECTED - |AT_XDMAC_CC_DSYNC_PER2MEM - |AT_XDMAC_CC_MBSIZE_SIXTEEN - |AT_XDMAC_CC_TYPE_PER_TRAN ; - csize =at_xdmac_csize (sconfig->src_maxburst); -if (csize <0 ) { -dev_err (chan2dev (chan),"invalid src maxburst value\n" ); -return -EINVAL ; - } - atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ] |=AT_XDMAC_CC_CSIZE (csize); - dwidth =ffs (sconfig->src_addr_width) -1 ; - atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ] |=AT_XDMAC_CC_DWIDTH (dwidth); - - - atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ] = -AT91_XDMAC_DT_PERID (atchan->perid) - |AT_XDMAC_CC_DAM_FIXED_AM - |AT_XDMAC_CC_SAM_INCREMENTED_AM - |AT_XDMAC_CC_DIF (atchan->perif) - |AT_XDMAC_CC_SIF (atchan->memif) - |AT_XDMAC_CC_SWREQ_HWR_CONNECTED - |AT_XDMAC_CC_DSYNC_MEM2PER - |AT_XDMAC_CC_MBSIZE_SIXTEEN - |AT_XDMAC_CC_TYPE_PER_TRAN ; - csize =at_xdmac_csize (sconfig->dst_maxburst); -if (csize <0 ) { -dev_err (chan2dev (chan),"invalid src maxburst value\n" ); -return -EINVAL ; +if (sconfig->src_addr) { + atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ] = +AT91_XDMAC_DT_PERID (atchan->perid) + |AT_XDMAC_CC_DAM_INCREMENTED_AM + |AT_XDMAC_CC_SAM_FIXED_AM + |AT_XDMAC_CC_DIF (atchan->memif) + |AT_XDMAC_CC_SIF (atchan->perif) + |AT_XDMAC_CC_SWREQ_HWR_CONNECTED + |AT_XDMAC_CC_DSYNC_PER2MEM + |AT_XDMAC_CC_MBSIZE_SIXTEEN + |AT_XDMAC_CC_TYPE_PER_TRAN ; + csize =at_xdmac_csize (sconfig->src_maxburst); +if (csize <0 ) { +dev_err (chan2dev (chan),"invalid src maxburst value\n" ); +return -EINVAL ; + } + atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ] |=AT_XDMAC_CC_CSIZE (csize); + dwidth =ffs (sconfig->src_addr_width) -1 ; + atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ] |=AT_XDMAC_CC_DWIDTH (dwidth); +/* Src addr is needed to configure the link list descriptor. */ + atchan->per_src_addr = sconfig->src_addr; + +dev_dbg (chan2dev (chan), +"%s: cfg[dev2mem]=0x%08x, per_src_addr=0x%08x\n" , + __func__, atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ], + atchan->per_src_addr); } - atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ] |=AT_XDMAC_CC_CSIZE (csize); - dwidth =ffs (sconfig->dst_addr_width) -1 ; - atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ] |=AT_XDMAC_CC_DWIDTH (dwidth); -/* Src and dst addr are needed to configure the link list descriptor. */ - atchan->per_src_addr = sconfig->src_addr; - atchan->per_dst_addr = sconfig->dst_addr; +if (sconfig->dst_addr) { + atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ] = +AT91_XDMAC_DT_PERID (atchan->perid) + |AT_XDMAC_CC_DAM_FIXED_AM + |AT_XDMAC_CC_SAM_INCREMENTED_AM + |AT_XDMAC_CC_DIF (atchan->perif) + |AT_XDMAC_CC_SIF (atchan->memif) + |AT_XDMAC_CC_SWREQ_HWR_CONNECTED + |AT_XDMAC_CC_DSYNC_MEM2PER + |AT_XDMAC_CC_MBSIZE_SIXTEEN + |AT_XDMAC_CC_TYPE_PER_TRAN ; + csize =at_xdmac_csize (sconfig->dst_maxburst); +if (csize <0 ) { +dev_err (chan2dev (chan),"invalid src maxburst value\n" ); +return -EINVAL ; + } + atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ] |=AT_XDMAC_CC_CSIZE (csize); + dwidth =ffs (sconfig->dst_addr_width) -1 ; + atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ] |=AT_XDMAC_CC_DWIDTH (dwidth); +/* Dst addr is needed to configure the link list descriptor. */ + atchan->per_dst_addr = sconfig->dst_addr; -dev_dbg (chan2dev (chan), -"%s: cfg[dev2mem]=0x%08x, cfg[mem2dev]=0x%08x, per_src_addr=0x%08x, per_dst_addr=0x%08x\n" , - __func__, atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG ], - atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ], - atchan->per_src_addr, atchan->per_dst_addr); +dev_dbg (chan2dev (chan), +"%s: cfg[mem2dev]=0x%08x, per_dst_addr=0x%08x\n" , + __func__, atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG ], + atchan->per_dst_addr); + }return 0 ; }Signature · 1 line
2.2.0
PATCH 1/1 dmaengine: at_xdmac: fix slave configuration issue
Quoted 25 lines · Ludovic Desroches
Hi Vinod,
Quoted 5 lines · Vinod Koul
Quoted 4 lines · Ludovic Desroches
When doing the slave configuration, an error is returned if the maxburst value is not supported. The bug comes from the fact that we always check the maxburst for both directions but in the case of an unidirectional channel, only one is set.
Quoted 8 lines
While setting the slave configuration we are not tied to a channel direction, the direction is passed usin
prep_method. So from that prespective a channle can be used for tx and rx with same slave config set.Now if we were invoking
at_xdmac_set_slave_configfromprep_calls then it would have been fine but here we are checking when the slave config is set so this is not right. You should check maxburst at runtime then...I don't understand why we should wait before checking the configuration... Some channels are unidirectionnal so implicitly we know the direction at configuration time because the device will fill only a part of the
dma_slave_configstructure. For example, the atmel usart requests a tx and a rx channels. When configuring the tx channel, only thedst_fields of thedma_slave_configstructure are filled. Is it a bad behavior?
Quoted 3 lines
The change introduced by this patch doesn't really care about the direction, it only tells that if the device only fills
src_fields then I don't have to check fields not configured.
Well that is because we started with the assumption that channels are uni-direction and we know that. From client side we shouldn't care how channel looks like and which dma controller we are talking. The point is to make clients unaware and use the dmaengine API
Signature · 1 line
~Vinod
PATCH 1/1 dmaengine: at_xdmac: fix slave configuration issue
Quoted 26 lines · Vinod Koul
Quoted 25 lines · Ludovic Desroches
Hi Vinod,
Quoted 5 lines · Vinod Koul
Quoted 4 lines · Ludovic Desroches
When doing the slave configuration, an error is returned if the maxburst value is not supported. The bug comes from the fact that we always check the maxburst for both directions but in the case of an unidirectional channel, only one is set.
Quoted 8 lines
While setting the slave configuration we are not tied to a channel direction, the direction is passed usin
prep_method. So from that prespective a channle can be used for tx and rx with same slave config set.Now if we were invoking
at_xdmac_set_slave_configfromprep_calls then it would have been fine but here we are checking when the slave config is set so this is not right. You should check maxburst at runtime then...I don't understand why we should wait before checking the configuration... Some channels are unidirectionnal so implicitly we know the direction at configuration time because the device will fill only a part of the
dma_slave_configstructure. For example, the atmel usart requests a tx and a rx channels. When configuring the tx channel, only thedst_fields of thedma_slave_configstructure are filled. Is it a bad behavior?
Quoted 7 lines
Quoted 3 lines
The change introduced by this patch doesn't really care about the direction, it only tells that if the device only fills
src_fields then I don't have to check fields not configured.Well that is because we started with the assumption that channels are uni-direction and we know that. From client side we shouldn't care how channel looks like and which dma controller we are talking. The point is to make clients unaware and use the dmaengine API
I am sorry but I don't understand what is wrong with your vision and this patch.
I think it is the case you describe, the client doesn't care how the channel looks like, it wants a channel for doing transmission so it fills only the configuration part for this purpose. In this case there is no reason the dma controller returns an error by checking unset values.
It's true I can check the configuration requested by the client at runtime. But why waiting so long? If there is an issue, it's better to return the error as soon as possible. On client side, even at this moment it is difficult to manage an error. For example, my dma controller doesn't support the max burst requested, how the client will know what is the maxburst size it can ask?
Regards
Ludovic
PATCH 1/1 dmaengine: at_xdmac: fix slave configuration issue
Quoted 35 lines · Ludovic Desroches
Quoted 26 lines · Vinod Koul
Quoted 25 lines · Ludovic Desroches
Hi Vinod,
Quoted 5 lines · Vinod Koul
Quoted 4 lines · Ludovic Desroches
When doing the slave configuration, an error is returned if the maxburst value is not supported. The bug comes from the fact that we always check the maxburst for both directions but in the case of an unidirectional channel, only one is set.
Quoted 8 lines
While setting the slave configuration we are not tied to a channel direction, the direction is passed usin
prep_method. So from that prespective a channle can be used for tx and rx with same slave config set.Now if we were invoking
at_xdmac_set_slave_configfromprep_calls then it would have been fine but here we are checking when the slave config is set so this is not right. You should check maxburst at runtime then...I don't understand why we should wait before checking the configuration... Some channels are unidirectionnal so implicitly we know the direction at configuration time because the device will fill only a part of the
dma_slave_configstructure. For example, the atmel usart requests a tx and a rx channels. When configuring the tx channel, only thedst_fields of thedma_slave_configstructure are filled. Is it a bad behavior?Quoted 7 lines
Quoted 3 lines
The change introduced by this patch doesn't really care about the direction, it only tells that if the device only fills
src_fields then I don't have to check fields not configured.Well that is because we started with the assumption that channels are uni-direction and we know that. From client side we shouldn't care how channel looks like and which dma controller we are talking. The point is to make clients unaware and use the dmaengine API
Quoted 8 lines
I am sorry but I don't understand what is wrong with your vision and this patch.
I think it is the case you describe, the client doesn't care how the channel looks like, it wants a channel for doing transmission so it fills only the configuration part for this purpose. In this case there is no reason the dma controller returns an error by checking unset values.
As i said earlier, if the checks were in prepare call then they would be fine, but they are in slave_dma_config API. You dont know the direction at this point so checking here is not good. You should copy the parameters here as most do and move the checks to prepare_ calls where you know the direction for argument of prepare and return accordingly.
Quoted 7 lines
It's true I can check the configuration requested by the client at runtime. But why waiting so long? If there is an issue, it's better to return the error as soon as possible. On client side, even at this moment it is difficult to manage an error. For example, my dma controller doesn't support the max burst requested, how the client will know what is the maxburst size it can ask?
Because you dont have the complete information. And failing prepare at that time makese sense because parameters have not be set properly!
Signature · 1 line
~Vinod
Quoted 4 lines
Regards
Ludovic
PATCH 1/1 dmaengine: at_xdmac: fix slave configuration issue
Quoted 51 lines · Vinod Koul
Quoted 35 lines · Ludovic Desroches
Quoted 26 lines · Vinod Koul
Quoted 25 lines · Ludovic Desroches
Hi Vinod,
Quoted 5 lines · Vinod Koul
Quoted 4 lines · Ludovic Desroches
When doing the slave configuration, an error is returned if the maxburst value is not supported. The bug comes from the fact that we always check the maxburst for both directions but in the case of an unidirectional channel, only one is set.
Quoted 8 lines
While setting the slave configuration we are not tied to a channel direction, the direction is passed usin
prep_method. So from that prespective a channle can be used for tx and rx with same slave config set.Now if we were invoking
at_xdmac_set_slave_configfromprep_calls then it would have been fine but here we are checking when the slave config is set so this is not right. You should check maxburst at runtime then...I don't understand why we should wait before checking the configuration... Some channels are unidirectionnal so implicitly we know the direction at configuration time because the device will fill only a part of the
dma_slave_configstructure. For example, the atmel usart requests a tx and a rx channels. When configuring the tx channel, only thedst_fields of thedma_slave_configstructure are filled. Is it a bad behavior?Quoted 7 lines
Quoted 3 lines
The change introduced by this patch doesn't really care about the direction, it only tells that if the device only fills
src_fields then I don't have to check fields not configured.Well that is because we started with the assumption that channels are uni-direction and we know that. From client side we shouldn't care how channel looks like and which dma controller we are talking. The point is to make clients unaware and use the dmaengine API
Quoted 8 lines
I am sorry but I don't understand what is wrong with your vision and this patch.
I think it is the case you describe, the client doesn't care how the channel looks like, it wants a channel for doing transmission so it fills only the configuration part for this purpose. In this case there is no reason the dma controller returns an error by checking unset values.
As i said earlier, if the checks were in prepare call then they would be fine, but they are in
slave_dma_configAPI. You dont know the direction at this point so checking here is not good. You should copy the parameters here as most do and move the checks toprepare_calls where you know the direction for argument of prepare and return accordingly.Quoted 1 line
Quoted 9 lines
Quoted 6 lines
It's true I can check the configuration requested by the client at runtime. But why waiting so long? If there is an issue, it's better to return the error as soon as possible. On client side, even at this moment it is difficult to manage an error. For example, my dma controller doesn't support the max burst requested, how the client will know what is the maxburst size it can ask?
Because you dont have the complete information. And failing prepare at that time makese sense because parameters have not be set properly!
Sorry but I still don't understand why I don't have the complete information. The only thing missing is the direction and I don't care about it.
I was updating my patch but I realize I have no benefit to do it in prep. Worse if I simply copy the slave configuration and check it in prep, I'll check the maxburst value several times instead of one and it will always be the same...
Ludovic
PATCH 1/1 dmaengine: at_xdmac: fix slave configuration issue
Quoted 62 lines · Ludovic Desroches
Quoted 51 lines · Vinod Koul
Quoted 35 lines · Ludovic Desroches
Quoted 26 lines · Vinod Koul
Quoted 25 lines · Ludovic Desroches
Hi Vinod,
Quoted 5 lines · Vinod Koul
Quoted 4 lines · Ludovic Desroches
When doing the slave configuration, an error is returned if the maxburst value is not supported. The bug comes from the fact that we always check the maxburst for both directions but in the case of an unidirectional channel, only one is set.
Quoted 8 lines
While setting the slave configuration we are not tied to a channel direction, the direction is passed usin
prep_method. So from that prespective a channle can be used for tx and rx with same slave config set.Now if we were invoking
at_xdmac_set_slave_configfromprep_calls then it would have been fine but here we are checking when the slave config is set so this is not right. You should check maxburst at runtime then...I don't understand why we should wait before checking the configuration... Some channels are unidirectionnal so implicitly we know the direction at configuration time because the device will fill only a part of the
dma_slave_configstructure. For example, the atmel usart requests a tx and a rx channels. When configuring the tx channel, only thedst_fields of thedma_slave_configstructure are filled. Is it a bad behavior?Quoted 7 lines
Quoted 3 lines
The change introduced by this patch doesn't really care about the direction, it only tells that if the device only fills
src_fields then I don't have to check fields not configured.Well that is because we started with the assumption that channels are uni-direction and we know that. From client side we shouldn't care how channel looks like and which dma controller we are talking. The point is to make clients unaware and use the dmaengine API
Quoted 8 lines
I am sorry but I don't understand what is wrong with your vision and this patch.
I think it is the case you describe, the client doesn't care how the channel looks like, it wants a channel for doing transmission so it fills only the configuration part for this purpose. In this case there is no reason the dma controller returns an error by checking unset values.
As i said earlier, if the checks were in prepare call then they would be fine, but they are in
slave_dma_configAPI. You dont know the direction at this point so checking here is not good. You should copy the parameters here as most do and move the checks toprepare_calls where you know the direction for argument of prepare and return accordingly.Quoted 1 line
Quoted 9 lines
Quoted 6 lines
It's true I can check the configuration requested by the client at runtime. But why waiting so long? If there is an issue, it's better to return the error as soon as possible. On client side, even at this moment it is difficult to manage an error. For example, my dma controller doesn't support the max burst requested, how the client will know what is the maxburst size it can ask?
Because you dont have the complete information. And failing prepare at that time makese sense because parameters have not be set properly!
Quoted 8 lines
Sorry but I still don't understand why I don't have the complete information. The only thing missing is the direction and I don't care about it.
I was updating my patch but I realize I have no benefit to do it in prep. Worse if I simply copy the slave configuration and check it in prep, I'll check the maxburst value several times instead of one and it will always be the same...
ah yes but then you can use the channel for either direction without setting slave_dma_config...
Signature · 1 line
~Vinod
PATCH 1/1 dmaengine: at_xdmac: fix slave configuration issue
Quoted 67 lines · Vinod Koul
Quoted 66 lines · Ludovic Desroches
Quoted 51 lines · Vinod Koul
Quoted 35 lines · Ludovic Desroches
Quoted 26 lines · Vinod Koul
Quoted 25 lines · Ludovic Desroches
Hi Vinod,
Quoted 5 lines · Vinod Koul
Quoted 4 lines · Ludovic Desroches
When doing the slave configuration, an error is returned if the maxburst value is not supported. The bug comes from the fact that we always check the maxburst for both directions but in the case of an unidirectional channel, only one is set.
Quoted 8 lines
While setting the slave configuration we are not tied to a channel direction, the direction is passed usin
prep_method. So from that prespective a channle can be used for tx and rx with same slave config set.Now if we were invoking
at_xdmac_set_slave_configfromprep_calls then it would have been fine but here we are checking when the slave config is set so this is not right. You should check maxburst at runtime then...I don't understand why we should wait before checking the configuration... Some channels are unidirectionnal so implicitly we know the direction at configuration time because the device will fill only a part of the
dma_slave_configstructure. For example, the atmel usart requests a tx and a rx channels. When configuring the tx channel, only thedst_fields of thedma_slave_configstructure are filled. Is it a bad behavior?Quoted 7 lines
Quoted 3 lines
The change introduced by this patch doesn't really care about the direction, it only tells that if the device only fills
src_fields then I don't have to check fields not configured.Well that is because we started with the assumption that channels are uni-direction and we know that. From client side we shouldn't care how channel looks like and which dma controller we are talking. The point is to make clients unaware and use the dmaengine API
Quoted 8 lines
I am sorry but I don't understand what is wrong with your vision and this patch.
I think it is the case you describe, the client doesn't care how the channel looks like, it wants a channel for doing transmission so it fills only the configuration part for this purpose. In this case there is no reason the dma controller returns an error by checking unset values.
As i said earlier, if the checks were in prepare call then they would be fine, but they are in
slave_dma_configAPI. You dont know the direction at this point so checking here is not good. You should copy the parameters here as most do and move the checks toprepare_calls where you know the direction for argument of prepare and return accordingly.Quoted 1 line
Quoted 9 lines
Quoted 6 lines
It's true I can check the configuration requested by the client at runtime. But why waiting so long? If there is an issue, it's better to return the error as soon as possible. On client side, even at this moment it is difficult to manage an error. For example, my dma controller doesn't support the max burst requested, how the client will know what is the maxburst size it can ask?
Because you dont have the complete information. And failing prepare at that time makese sense because parameters have not be set properly!
Sorry but I still don't understand why I don't have the complete information. The only thing missing is the direction and I don't care about it.
Quoted 7 lines
Quoted 4 lines
I was updating my patch but I realize I have no benefit to do it in prep. Worse if I simply copy the slave configuration and check it in prep, I'll check the maxburst value several times instead of one and it will always be the same...
ah yes but then you can use the channel for either direction without setting
slave_dma_config...
I still need dma_slave_config. In my device_config function, I don't copy the dma_slave_config but I take information from it to compute a dev2mem and mem2dev configuration. Then I will select the right one in the prep function. I think it's quite close from that you want.
In the device_config, I convert the maxburst value to a comprehensive one for my controller. If it is not a supported one then I'll return an error?
Are you okay with this procedure? If not, I have totally misunderstood what you want...
My concern is that a device can fill only what it needs in the dma_slave_config structure. When doing the configuration, the controller doesn't care about the direction as you asked but if a maxburst configuration is not set, I will have a zero value which is not a valid one. I will return an error but is not...
Ludovic
PATCH 1/1 dmaengine: at_xdmac: fix slave configuration issue
Quoted 8 lines · Ludovic Desroches
Quoted 3 lines
ah yes but then you can use the channel for either direction without setting
slave_dma_config...I still need
dma_slave_config. In mydevice_configfunction, I don't copy thedma_slave_configbut I take information from it to compute a dev2mem and mem2dev configuration. Then I will select the right one in the prep function. I think it's quite close from that you want.
since you do not know the direction here, you dont know how to compute dev2mem or mem2dev configurations
Quoted 4 lines
In the
device_config, I convert the maxburst value to a comprehensive one for my controller. If it is not a supported one then I'll return an error?
thats fine as long as direction is not used, implicitly as well
Quoted 8 lines
Are you okay with this procedure? If not, I have totally misunderstood what you want...
My concern is that a device can fill only what it needs in the
dma_slave_configstructure. When doing the configuration, the controller doesn't care about the direction as you asked but if a maxburst configuration is not set, I will have a zero value which is not a valid one. I will return an error but is not...
Yes that is why many drivers will save configuration. Checking values for sanity makes sense. No point in accepting config for 64 max burst if device support upto 32!
Then you use direction is prepare_ api to compute parameters and if you detect further errors in configuration for said txn then you are valid to return error. Again if client has sent one direction parameters and in prepare you will not return error as direction will be apt so current issue will be fixed as well
Signature · 1 line
~Vinod