[2/4] serial: 8250_lpss: Configure DMA also w/o DMA filter

Message ID 20221107110708.58223-3-ilpo.jarvinen@linux.intel.com
State New
Headers
Series 8250: DMA Fixes |

Commit Message

Ilpo Järvinen Nov. 7, 2022, 11:07 a.m. UTC
  If the platform doesn't use DMA device filter (as is the case with
Elkhart Lake), whole lpss8250_dma_setup() setup is skipped. This
results in skipping also *_maxburst setup which is undesirable.
Refactor lpss8250_dma_setup() to configure DMA even if filter is not
setup.

Cc: stable <stable@kernel.org>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/serial/8250/8250_lpss.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
  

Comments

Andy Shevchenko Nov. 7, 2022, 11:36 a.m. UTC | #1
On Mon, Nov 07, 2022 at 01:07:06PM +0200, Ilpo Järvinen wrote:
> If the platform doesn't use DMA device filter (as is the case with
> Elkhart Lake), whole lpss8250_dma_setup() setup is skipped. This
> results in skipping also *_maxburst setup which is undesirable.
> Refactor lpss8250_dma_setup() to configure DMA even if filter is not
> setup.

...


> +	if (!lpss->dma_param.dma_dev) {
> +		dma = port->dma;
> +		goto confonly;

Perhaps

		if (dma)
			goto out_configuration_only;

		return 0;

(note the label naming as well).

> +	}

...

> +confonly:

> +	if (dma) {

But you know that previous code has dma != NULL. See above.

> +		dma->rxconf.src_maxburst = lpss->dma_maxburst;
> +		dma->txconf.dst_maxburst = lpss->dma_maxburst;
> +	}
  

Patch

diff --git a/drivers/tty/serial/8250/8250_lpss.c b/drivers/tty/serial/8250/8250_lpss.c
index 44cc755b1a29..ed281445a97d 100644
--- a/drivers/tty/serial/8250/8250_lpss.c
+++ b/drivers/tty/serial/8250/8250_lpss.c
@@ -277,8 +277,10 @@  static int lpss8250_dma_setup(struct lpss8250 *lpss, struct uart_8250_port *port
 	struct dw_dma_slave *rx_param, *tx_param;
 	struct device *dev = port->port.dev;
 
-	if (!lpss->dma_param.dma_dev)
-		return 0;
+	if (!lpss->dma_param.dma_dev) {
+		dma = port->dma;
+		goto confonly;
+	}
 
 	rx_param = devm_kzalloc(dev, sizeof(*rx_param), GFP_KERNEL);
 	if (!rx_param)
@@ -289,16 +291,20 @@  static int lpss8250_dma_setup(struct lpss8250 *lpss, struct uart_8250_port *port
 		return -ENOMEM;
 
 	*rx_param = lpss->dma_param;
-	dma->rxconf.src_maxburst = lpss->dma_maxburst;
-
 	*tx_param = lpss->dma_param;
-	dma->txconf.dst_maxburst = lpss->dma_maxburst;
 
 	dma->fn = lpss8250_dma_filter;
 	dma->rx_param = rx_param;
 	dma->tx_param = tx_param;
 
 	port->dma = dma;
+
+confonly:
+	if (dma) {
+		dma->rxconf.src_maxburst = lpss->dma_maxburst;
+		dma->txconf.dst_maxburst = lpss->dma_maxburst;
+	}
+
 	return 0;
 }