Re: [PATCH 9/9] can: mcp251x: remove custom DMA mapped buffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 19/08/2019 17.38, Marc Kleine-Budde wrote:
There is no need to duplicate what SPI core already does, i.e. mapping buffers
for DMA capable transfers. This patch removes all related pices of code.

Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
Tested-by: Sean Nyekjaer <sean@xxxxxxxxxx>
---
  drivers/net/can/spi/mcp251x.c | 58 ++++++-----------------------------
  1 file changed, 10 insertions(+), 48 deletions(-)

diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c
index 0cdb88a9525f..78d44801a0b5 100644
--- a/drivers/net/can/spi/mcp251x.c
+++ b/drivers/net/can/spi/mcp251x.c
@@ -47,7 +47,6 @@
  #include <linux/completion.h>
  #include <linux/delay.h>
  #include <linux/device.h>
-#include <linux/dma-mapping.h>
  #include <linux/freezer.h>
  #include <linux/interrupt.h>
  #include <linux/io.h>
@@ -202,10 +201,6 @@
#define DEVICE_NAME "mcp251x" -static int mcp251x_enable_dma; /* Enable SPI DMA. Default: 0 (Off) */
-module_param(mcp251x_enable_dma, int, 0444);
-MODULE_PARM_DESC(mcp251x_enable_dma, "Enable SPI DMA. Default: 0 (Off)");
-
  static const struct can_bittiming_const mcp251x_bittiming_const = {
  	.name = DEVICE_NAME,
  	.tseg1_min = 3,
@@ -234,8 +229,6 @@ struct mcp251x_priv {
u8 *spi_tx_buf;
  	u8 *spi_rx_buf;
-	dma_addr_t spi_tx_dma;
-	dma_addr_t spi_rx_dma;
struct sk_buff *tx_skb;
  	int tx_len;
@@ -304,13 +297,6 @@ static int mcp251x_spi_trans(struct spi_device *spi, int len)
  	int ret;
spi_message_init(&m);
-
-	if (mcp251x_enable_dma) {
-		t.tx_dma = priv->spi_tx_dma;
-		t.rx_dma = priv->spi_rx_dma;
-		m.is_dma_mapped = 1;
-	}
-
  	spi_message_add_tail(&t, &m);
ret = spi_sync(spi, &m);
@@ -1101,42 +1087,18 @@ static int mcp251x_can_probe(struct spi_device *spi)
  	priv->spi = spi;
  	mutex_init(&priv->mcp_lock);
- /* If requested, allocate DMA buffers */
-	if (mcp251x_enable_dma) {
-		spi->dev.coherent_dma_mask = ~0;
-
-		/* Minimum coherent DMA allocation is PAGE_SIZE, so allocate
-		 * that much and share it between Tx and Rx DMA buffers.
-		 */
-		priv->spi_tx_buf = dmam_alloc_coherent(&spi->dev,
-						       PAGE_SIZE,
-						       &priv->spi_tx_dma,
-						       GFP_DMA);
-
-		if (priv->spi_tx_buf) {
-			priv->spi_rx_buf = (priv->spi_tx_buf + (PAGE_SIZE / 2));
-			priv->spi_rx_dma = (dma_addr_t)(priv->spi_tx_dma +
-							(PAGE_SIZE / 2));
-		} else {
-			/* Fall back to non-DMA */
-			mcp251x_enable_dma = 0;
-		}
+	priv->spi_tx_buf = devm_kzalloc(&spi->dev, SPI_TRANSFER_BUF_LEN,
+					GFP_KERNEL);
+	if (!priv->spi_tx_buf) {
+		ret = -ENOMEM;
+		goto error_probe;
  	}
- /* Allocate non-DMA buffers */
-	if (!mcp251x_enable_dma) {
-		priv->spi_tx_buf = devm_kzalloc(&spi->dev, SPI_TRANSFER_BUF_LEN,
-						GFP_KERNEL);
-		if (!priv->spi_tx_buf) {
-			ret = -ENOMEM;
-			goto error_probe;
-		}
-		priv->spi_rx_buf = devm_kzalloc(&spi->dev, SPI_TRANSFER_BUF_LEN,
-						GFP_KERNEL);
-		if (!priv->spi_rx_buf) {
-			ret = -ENOMEM;
-			goto error_probe;
-		}
+	priv->spi_rx_buf = devm_kzalloc(&spi->dev, SPI_TRANSFER_BUF_LEN,
+					GFP_KERNEL);
+	if (!priv->spi_rx_buf) {
+		ret = -ENOMEM;
+		goto error_probe;
  	}
SET_NETDEV_DEV(net, &spi->dev);




[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux