Skip to contentSkip to conversation

dmaengine: urgent fix to prevent regression in UART

PATCH Superseded Andy Shevchenko 2 participants 10 messages May 4, 2016 – May 10, 2016

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 5ff79a0..59eb4fa 100644
@@ -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
#2 lore raw

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_SLAVE or

							^^^^^^^

typo

Quoted 26 lines

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
index 5ff79a0..59eb4fa 100644
@@ -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
#3 lore raw

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_SLAVE or

							^^^^^^^

typo

Indeed, thanks.
Do I need to resend this one?

--
Andy Shevchenko <[email protected]> Intel Finland Oy

#4 lore raw

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_SLAVE or

							^^^^^^^

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
#5 lore raw

PATCH 2/2 dmaengine: rename cmd_pause to cmd_suspend

In reply to Andy Shevchenko

Rename 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
index 59eb4fa..e9917a4 100644
@@ -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
index 8ccbf53..2db57b0 100644
@@ -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
index 30de019..af9c97c 100644
@@ -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
index 6cef397..73fc20e 100644
@@ -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
#6 lore raw

Re: [PATCH v1 2/2] dmaengine: rename cmd_pause to cmd_suspend

Quoted 2 lines · Andy Shevchenko

Rename cmd_pause to cmd_suspend to 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
---
 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
index 59eb4fa..e9917a4 100644
@@ -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
index 8ccbf53..2db57b0 100644
@@ -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
index 30de019..af9c97c 100644
@@ -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
index 6cef397..73fc20e 100644
@@ -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
#7 lore raw

Re: [PATCH v1 2/2] dmaengine: rename cmd_pause to cmd_suspend

Quoted 8 lines · Vinod Koul
Quoted 4 lines · Andy Shevchenko

Rename cmd_pause to cmd_suspend to 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

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

---
 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
index 59eb4fa..e9917a4 100644
@@ -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

drivers/dma/dmaengine.c +0 -1
-	 * resume. However cmd_pause is advertised as pause AND

resume.

drivers/dma/dmaengine.c +1 -0
+	 * resume. However cmd_suspend is advertised as pause AND

resume.
   */

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
index 8ccbf53..2db57b0 100644
@@ -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 +0 -0
index 30de019..af9c97c 100644
@@ -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

include/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 100644

sound/soc/soc-generic-dmaengine-pcm.c +0 -0
@@ -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) {

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
#8 lore raw

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_pause to cmd_suspend to be clear that latter capability reflects
pause AND resume.

Quoted 6 lines
Quoted 3 lines

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

Okay, 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
#9 lore raw
In reply to Andy Shevchenko

+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
support DMA_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 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 · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy