dmaengine: urgent fix to prevent regression in UART
Subsystems (5)
cover dmaengine: urgent fix to prevent regression in UART
There are two patches, first of which is an urgent fix to prevent a regression when UART driver can't acquire DMA channel due to DMA engine which doesn't support DMA_CYCLIC.
Andy Shevchenko (2):
dmaengine: slave means at least one of DMA_SLAVE, DMA_CYCLIC
dmaengine: rename cmd_pause to cmd_suspend
drivers/dma/dmaengine.c | 8 ++++---- drivers/tty/serial/8250/8250_dma.c | 2 +- include/linux/dmaengine.h | 4 ++-- sound/soc/soc-generic-dmaengine-pcm.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-)
Signature · 1 line
2.8.1
PATCH 1/2 dmaengine: slave means at least one of DMA_SLAVE, DMA_CYCLIC
When check for capabilities recognize slave support by eother DMA_SLAVE or DMA_CYCLIC bit set. If we don't do that the user can't get a normally worked DMA support for engines that doesn't have one of the mentioned bits set.
--- drivers/dma/dmaengine.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/dmaengine.c +2 -2
@@ -482,8 +482,8 @@ int dma_get_slave_caps(struct dma_chan *chan, struct dma_slave_caps *caps) device = chan->device;/* check if the channel supports slave transactions */ -if ((!test_bit (DMA_SLAVE , device->cap_mask.bits)) || - (!test_bit (DMA_CYCLIC , device->cap_mask.bits))) +if (!(test_bit (DMA_SLAVE , device->cap_mask.bits) || +test_bit (DMA_CYCLIC , device->cap_mask.bits)))return -ENXIO ;/*
Signature · 1 line
2.8.1
Re: [PATCH v1 1/2] dmaengine: slave means at least one of DMA_SLAVE, DMA_CYCLIC
Quoted 1 line · Andy Shevchenko
When check for capabilities recognize slave support by eother
DMA_SLAVEor
^^^^^^^
typo
Quoted 26 lines
DMA_CYCLICbit set. If we don't do that the user can't get a normally worked DMA support for engines that doesn't have one of the mentioned bits set.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/dma/dmaengine.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/dma/dmaengine.c +2
-2@@ -482,8 +482,8 @@ int dma_get_slave_caps(struct dma_chan *chan, struct dma_slave_caps *caps) device = chan->device;/* check if the channel supports slave transactions */ -if ((!test_bit (DMA_SLAVE , device->cap_mask.bits)) || - (!test_bit (DMA_CYCLIC , device->cap_mask.bits))) +if (!(test_bit (DMA_SLAVE , device->cap_mask.bits) || +test_bit (DMA_CYCLIC , device->cap_mask.bits)))return -ENXIO ;/* Signature · 1 line
2.8.1
Signature · 1 line
~Vinod
Re: [PATCH v1 1/2] dmaengine: slave means at least one of DMA_SLAVE, DMA_CYCLIC
Quoted 6 lines · Vinod Koul
Quoted 3 lines · Andy Shevchenko
When check for capabilities recognize slave support by eother
DMA_SLAVEor^^^^^^^typo
Indeed, thanks.
Do I need to resend this one?
--
Andy Shevchenko <[email protected]> Intel Finland Oy
Re: [PATCH v1 1/2] dmaengine: slave means at least one of DMA_SLAVE, DMA_CYCLIC
Quoted 10 lines · Andy Shevchenko
Quoted 6 lines · Vinod Koul
Quoted 3 lines · Andy Shevchenko
When check for capabilities recognize slave support by eother
DMA_SLAVEor^^^^^^^typo
Indeed, thanks.
Do I need to resend this one?
Yes please.
Also instead of OR, AND will do the same, but your approach works too, so either way am fine..
And I do not get correlation with fix on patch 1. This should be independent change..
Signature · 1 line
~Vinod
PATCH 2/2 dmaengine: rename cmd_pause to cmd_suspend
In reply to Andy ShevchenkoRename cmd_pause to cmd_suspend to be clear that latter capability reflects pause AND resume.
--- drivers/dma/dmaengine.c | 4 ++-- drivers/tty/serial/8250/8250_dma.c | 2 +- include/linux/dmaengine.h | 4 ++-- sound/soc/soc-generic-dmaengine-pcm.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
drivers/dma/dmaengine.c +2 -2
@@ -503,9 +503,9 @@ int dma_get_slave_caps(struct dma_chan *chan, struct dma_slave_caps *caps)/* * Some devices implement only pause (e.g. to get residuum) but no -* resume. However cmd_pause is advertised as pause AND resume. +* resume. However cmd_suspend is advertised as pause AND resume. */ - caps->cmd_pause = !!(device->device_pause && device->device_resume); + caps->cmd_suspend = !!(device->device_pause && device->device_resume); caps->cmd_terminate = !!device->device_terminate_all;return 0 ;
drivers/tty/serial/8250/8250_dma.c +1 -1
@@ -180,7 +180,7 @@ int serial8250_request_dma(struct uart_8250_port *p) ret =dma_get_slave_caps (dma->rxchan, &caps);if (ret) goto release_rx; -if (!caps.cmd_pause || !caps.cmd_terminate || +if (!caps.cmd_suspend || !caps.cmd_terminate || caps.residue_granularity ==DMA_RESIDUE_GRANULARITY_DESCRIPTOR ) { ret = -EINVAL ; goto release_rx;
include/linux/dmaengine.h +2 -2
@@ -402,7 +402,7 @@ enum dma_residue_granularity {* type of direction, the dma controller should fill (1 << <TYPE>) and same * should be checked by controller as well * @max_burst: max burst capability per-transfer -* @cmd_pause: true, if pause and thereby resume is supported +* @cmd_suspend: true, if pause and thereby resume is supported * @cmd_terminate: true, if terminate cmd is supported * @residue_granularity: granularity of the reported transfer residue * @descriptor_reuse: if a descriptor can be reused by client and
@@ -413,7 +413,7 @@ struct dma_slave_caps {u32 dst_addr_widths;u32 directions;u32 max_burst; -bool cmd_pause; +bool cmd_suspend;bool cmd_terminate;enum dma_residue_granularity residue_granularity;bool descriptor_reuse;
sound/soc/soc-generic-dmaengine-pcm.c +1 -1
@@ -151,7 +151,7 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea ret =dma_get_slave_caps (chan, &dma_caps);if (ret ==0 ) { -if (dma_caps.cmd_pause) +if (dma_caps.cmd_suspend) hw.info |=SNDRV_PCM_INFO_PAUSE |SNDRV_PCM_INFO_RESUME ;if (dma_caps.residue_granularity <=DMA_RESIDUE_GRANULARITY_SEGMENT ) hw.info |=SNDRV_PCM_INFO_BATCH ;
Signature · 1 line
2.8.1
Re: [PATCH v1 2/2] dmaengine: rename cmd_pause to cmd_suspend
Quoted 2 lines · Andy Shevchenko
Rename
cmd_pausetocmd_suspendto be clear that latter capability reflects pause AND resume.
How does cmd_suspend be any clearer to reflect that channel is paused and not. One can argue this might be related to power management suspend ...
Quoted 76 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/dma/dmaengine.c | 4 ++-- drivers/tty/serial/8250/8250_dma.c | 2 +- include/linux/dmaengine.h | 4 ++-- sound/soc/soc-generic-dmaengine-pcm.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)drivers/dma/dmaengine.c +2
-2@@ -503,9 +503,9 @@ int dma_get_slave_caps(struct dma_chan *chan, struct dma_slave_caps *caps)/* * Some devices implement only pause (e.g. to get residuum) but no -* resume. However cmd_pause is advertised as pause AND resume. +* resume. However cmd_suspend is advertised as pause AND resume. */ - caps->cmd_pause = !!(device->device_pause && device->device_resume); + caps->cmd_suspend = !!(device->device_pause && device->device_resume); caps->cmd_terminate = !!device->device_terminate_all;return 0 ;drivers/tty/serial/8250/8250_dma.c +1
-1@@ -180,7 +180,7 @@ int serial8250_request_dma(struct uart_8250_port *p) ret =dma_get_slave_caps (dma->rxchan, &caps);if (ret) goto release_rx; -if (!caps.cmd_pause || !caps.cmd_terminate || +if (!caps.cmd_suspend || !caps.cmd_terminate || caps.residue_granularity ==DMA_RESIDUE_GRANULARITY_DESCRIPTOR ) { ret = -EINVAL ; goto release_rx;include/linux/dmaengine.h +2
-2@@ -402,7 +402,7 @@ enum dma_residue_granularity {* type of direction, the dma controller should fill (1 << <TYPE>) and same * should be checked by controller as well * @max_burst: max burst capability per-transfer -* @cmd_pause: true, if pause and thereby resume is supported +* @cmd_suspend: true, if pause and thereby resume is supported * @cmd_terminate: true, if terminate cmd is supported * @residue_granularity: granularity of the reported transfer residue * @descriptor_reuse: if a descriptor can be reused by client and @@ -413,7 +413,7 @@ struct dma_slave_caps {u32 dst_addr_widths;u32 directions;u32 max_burst; -bool cmd_pause; +bool cmd_suspend;bool cmd_terminate;enum dma_residue_granularity residue_granularity;bool descriptor_reuse;sound/soc/soc-generic-dmaengine-pcm.c +1
-1@@ -151,7 +151,7 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea ret =dma_get_slave_caps (chan, &dma_caps);if (ret ==0 ) { -if (dma_caps.cmd_pause) +if (dma_caps.cmd_suspend) hw.info |=SNDRV_PCM_INFO_PAUSE |SNDRV_PCM_INFO_RESUME ;if (dma_caps.residue_granularity <=DMA_RESIDUE_GRANULARITY_SEGMENT ) hw.info |=SNDRV_PCM_INFO_BATCH ;Signature · 1 line
2.8.1
Signature · 1 line
~Vinod
Re: [PATCH v1 2/2] dmaengine: rename cmd_pause to cmd_suspend
Quoted 8 lines · Vinod Koul
Quoted 4 lines · Andy Shevchenko
Rename
cmd_pausetocmd_suspendto be clear that latter capability reflects
pause AND resume.How does
cmd_suspendbe any clearer to reflect that channel is paused and
not. One can argue this might be related to power management suspend
Okay, I'm open to suggestions. My main point that name should not represent only pause or resume, rather both.
Quoted 95 lines
...
Quoted 93 lines
Signed-off-by Andy Shevchenko <[email protected]>---
drivers/dma/dmaengine.c | 4 ++--
drivers/tty/serial/8250/8250_dma.c | 2 +-
include/linux/dmaengine.h | 4 ++--
sound/soc/soc-generic-dmaengine-pcm.c | 2 +-4 files changed, 6 insertions(+), 6 deletions(-)drivers/dma/dmaengine.c +0
-0@@ -503,9 +503,9 @@ int dma_get_slave_caps(struct dma_chan *chan, struct dma_slave_caps *caps)
/*
* Some devices implement only pause (e.g. to get residuum) but nodrivers/dma/dmaengine.c +0
-1- * resume. However cmd_pause is advertised as pause ANDresume.
drivers/dma/dmaengine.c +1
-0+ * resume. However cmd_suspend is advertised as pause ANDresume.
*/drivers/dma/dmaengine.c +0
-1- caps->cmd_pause = !!(device->device_pause && device-Quoted 1 line
device_resume);drivers/dma/dmaengine.c +1
-0+ caps->cmd_suspend = !!(device->device_pause && device-Quoted 1 line
device_resume);
caps->cmd_terminate= !!device->device_terminate_all;
return 0;drivers/tty/serial/8250/8250_dma.c +1
-1@@ -180,7 +180,7 @@ int serial8250_request_dma(struct uart_8250_port *p) ret = dma_get_slave_caps(dma->rxchan, &caps); if (ret) goto release_rx; - if (!caps.cmd_pause || !caps.cmd_terminate || + if (!caps.cmd_suspend || !caps.cmd_terminate ||caps.residue_granularity ==
DMA_RESIDUE_GRANULARITY_DESCRIPTOR) {
ret =-EINVAL;
gotorelease_rx;include/linux/dmaengine.h +0
-0@@ -402,7 +402,7 @@ enum dma_residue_granularity { * type of direction, the dma controller should fill (1 <<<TYPE>) and same
* should be checked by controller as well
* @max_burst: max burst capability per-transfer
- * @cmd_pause: true, if pause and thereby resume is supported
+ * @cmd_suspend: true, if pause and thereby resume is supported
* @cmd_terminate: true, if terminate cmd is supported
* @residue_granularity: granularity of the reported transfer residue
* @descriptor_reuse: if a descriptor can be reused by client andinclude/linux/dmaengine.h +1
-1@@ -413,7 +413,7 @@ struct dma_slave_caps { u32 dst_addr_widths; u32 directions; u32 max_burst; -bool cmd_pause; +bool cmd_suspend; bool cmd_terminate; enum dma_residue_granularity residue_granularity; bool descriptor_reuse;sound/soc/soc- renamed from sound/soc/soc-generic-dmaengine-pcm.c +0
-0
generic-dmaengine-pcm.c
index 6cef397..73fc20e 100644sound/soc/soc-generic-dmaengine-pcm.c +0
-0@@ -151,7 +151,7 @@ static intdmaengine_pcm_set_runtime_hwparams(struct
snd_pcm_substream*substrea
ret =dma_get_slave_caps(chan, &dma_caps); if (ret == 0) {sound/soc/soc-generic-dmaengine-pcm.c +1
-1-if (dma_caps.cmd_pause) +if (dma_caps.cmd_suspend)hw.info |=
SNDRV_PCM_INFO_PAUSE|SNDRV_PCM_INFO_RESUME;
if (dma_caps.residue_granularity <=DMA_RESIDUE_GRANULARITY_SEGMENT)
hw.info |=SNDRV_PCM_INFO_BATCH; --
2.8.1
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Re: [PATCH v1 2/2] dmaengine: rename cmd_pause to cmd_suspend
Quoted 6 lines · Andy Shevchenko
Quoted 5 lines · Vinod Koul
Quoted 4 lines · Andy Shevchenko
Rename
cmd_pausetocmd_suspendto be clear that latter capability reflects
pause AND resume.
Quoted 6 lines
Quoted 3 lines
How does
cmd_suspendbe any clearer to reflect that channel is paused and
not. One can argue this might be related to power management suspendOkay, I'm open to suggestions. My main point that name should not represent only pause or resume, rather both.
I am actually okay with this name, but while getting the capablities, we should rather tell user if both are supported or not. Perhaps make it a bit mask?
Signature · 1 line
~Vinod
+Cc: Heikki
Quoted 5 lines · Andy Shevchenko
There are two patches, first of which is an urgent fix to prevent a regression
when UART driver can't acquire DMA channel due to DMA engine which doesn't
supportDMA_CYCLIC.
Have to add the following.
The commit ec5a11a91eec ("serial: 8250: Validate dmaengine rx chan meets requirements") brought a check for DMA capabilities and UART will not acquire a DMA channel if DMA engine doesn't support both DMA_CYCLIC _and_ DMA_SLAVE. The first patch in the series changes the logic from _and_ to _or_.
Quoted 11 lines
Andy Shevchenko (2):
dmaengine: slave means at least one ofDMA_SLAVE,DMA_CYCLIC
dmaengine: renamecmd_pausetocmd_suspenddrivers/dma/dmaengine.c | 8 ++++---- drivers/tty/serial/8250/8250_dma.c | 2 +- include/linux/dmaengine.h | 4 ++--
sound/soc/soc-generic-dmaengine-pcm.c| 2 +-4 files changed, 8 insertions(+), 8 deletions(-)
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy