Skip to contentSkip to conversation

spi: pxa2xx: Introduce DMA burst size support

PATCH Superseded Andy Shevchenko 2 participants 4 messages Feb 26, 2019 – Mar 4, 2019

Subsystems (3)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Andy Shevchenko

author reviewer
#0 lore raw

PATCH v2 1/2 spi: pxa2xx: Introduce DMA burst size support

Some masters may have different DMA burst size than hard coded default. In such case respect the value given by DMA burst size provided via platform data.

---
 drivers/spi/spi-pxa2xx-dma.c   | 4 +++-
 drivers/spi/spi-pxa2xx-pci.c   | 5 ++++-
 drivers/spi/spi-pxa2xx.c       | 1 +
 include/linux/spi/pxa2xx_spi.h | 1 +
 4 files changed, 9 insertions(+), 2 deletions(-)
drivers/spi/spi-pxa2xx-dma.c +3 -1
index 2fa7f4b43492..3343fff81c7b 100644
@@ -239,13 +239,15 @@ int pxa2xx_spi_set_dma_burst_and_threshold(struct chip_data *chip,
 					   u32 *threshold)
 {
 	struct pxa2xx_spi_chip *chip_info = spi->controller_data;
+	struct driver_data *drv_data = spi_controller_get_devdata(spi->controller);
+	u32 dma_burst_size = drv_data->master_info->dma_burst_size;
 
 	/*
 	 * If the DMA burst size is given in chip_info we use that,
 	 * otherwise we use the default. Also we use the default FIFO
 	 * thresholds for now.
 	 */
-	*burst_code = chip_info ? chip_info->dma_burst_size : 1;
+	*burst_code = chip_info ? chip_info->dma_burst_size : dma_burst_size;
 	*threshold = SSCR1_RxTresh(RX_THRESH_DFLT)
 		   | SSCR1_TxTresh(TX_THRESH_DFLT);
 
drivers/spi/spi-pxa2xx-pci.c +4 -1
index d3de925892cb..3faef7335137 100644
@@ -5,7 +5,6 @@
  */
 #include <linux/clk-provider.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
 #include <linux/spi/pxa2xx_spi.h>
@@ -35,6 +34,8 @@ struct pxa_spi_info {
 	void *tx_param;
 	void *rx_param;
 
+	int dma_burst_size;
+
 	int (*setup)(struct pci_dev *pdev, struct pxa_spi_info *c);
 };
 
@@ -133,6 +134,7 @@ static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 	rx->dma_dev = &dma_dev->dev;
 
 	c->dma_filter = lpss_dma_filter;
+	c->dma_burst_size = 8;
 	return 0;
 }
 
@@ -223,6 +225,7 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
 	spi_pdata.tx_param = c->tx_param;
 	spi_pdata.rx_param = c->rx_param;
 	spi_pdata.enable_dma = c->rx_param && c->tx_param;
+	spi_pdata.dma_burst_size = c->dma_burst_size ? c->dma_burst_size : 1;
 
 	ssp = &spi_pdata.ssp;
 	ssp->phys_base = pci_resource_start(dev, 0);
drivers/spi/spi-pxa2xx.c +1 -0
index 8dd67d722aae..7a86654045fc 100644
@@ -1569,6 +1569,7 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev)
 	pdata->is_slave = of_property_read_bool(pdev->dev.of_node, "spi-slave");
 	pdata->num_chipselect = 1;
 	pdata->enable_dma = true;
+	pdata->dma_burst_size = 1;
 
 	return pdata;
 }
include/linux/spi/pxa2xx_spi.h +1 -0
index b0674e330ef6..154da8cd4781 100644
@@ -25,6 +25,7 @@ struct dma_chan;
 struct pxa2xx_spi_master {
 	u16 num_chipselect;
 	u8 enable_dma;
+	u8 dma_burst_size;
 	bool is_slave;
 
 	/* DMA engine specific config */
Signature · 1 line
2.20.1
author reviewer
#1 lore raw

PATCH v2 2/2 spi: pxa2xx: Debug print DMA burst and threshold

It's useful during debug to see what DMA burst and threshold sizes are.

---
 drivers/spi/spi-pxa2xx.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/spi/spi-pxa2xx.c +3 -0
index 7a86654045fc..7cc4e85290b0 100644
@@ -1338,6 +1338,9 @@ static int setup(struct spi_device *spi)
 			dev_warn(&spi->dev,
 				 "in setup: DMA burst size reduced to match bits_per_word\n");
 		}
+		dev_dbg(&spi->dev,
+			"in setup: DMA burst and threshold set to %u, %u\n",
+			chip->dma_burst_size, chip->dma_threshold);
 	}
 
 	switch (drv_data->ssp_type) {
Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH v2 2/2] spi: pxa2xx: Debug print DMA burst and threshold

Quoted 12 lines · Andy Shevchenko

It's useful during debug to see what DMA burst and threshold sizes are.

---
  drivers/spi/spi-pxa2xx.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/spi/spi-pxa2xx.c +0 -0
index 7a86654045fc..7cc4e85290b0 100644

drivers/spi/spi-pxa2xx.c static int setup(struct spi_device *spi) · line 1343

Quoted 6 lines
drivers/spi/spi-pxa2xx.c +3 -0
@@ -1338,6 +1338,9 @@ static int setup(struct spi_device *spi)
  			dev_warn(&spi->dev,
  				 "in setup: DMA burst size reduced to match bits_per_word\n");
  		}
+		dev_dbg(&spi->dev,
+			"in setup: DMA burst and threshold set to %u, %u\n",
+			chip->dma_burst_size, chip->dma_threshold);

Printing chip->dma_threshold is not very informal here just after the pxa2xx_spi_set_dma_burst_and_threshold() call which sets it to (8 - 1 ) << 10 | (8 - 1) << 6 = 7616.

Signature · 1 line
Jarkko
#3 lore raw
In reply to Andy Shevchenko
Quoted 38 lines · Andy Shevchenko

Some masters may have different DMA burst size than hard coded default. In such case respect the value given by DMA burst size provided via platform data.

---
  drivers/spi/spi-pxa2xx-dma.c   | 4 +++-
  drivers/spi/spi-pxa2xx-pci.c   | 5 ++++-
  drivers/spi/spi-pxa2xx.c       | 1 +
  include/linux/spi/pxa2xx_spi.h | 1 +
  4 files changed, 9 insertions(+), 2 deletions(-)
drivers/spi/spi-pxa2xx-dma.c +3 -1
index 2fa7f4b43492..3343fff81c7b 100644
@@ -239,13 +239,15 @@ int pxa2xx_spi_set_dma_burst_and_threshold(struct chip_data *chip,
  					   u32 *threshold)
  {
  	struct pxa2xx_spi_chip *chip_info = spi->controller_data;
+	struct driver_data *drv_data = spi_controller_get_devdata(spi->controller);
+	u32 dma_burst_size = drv_data->master_info->dma_burst_size;
 
  	/*
  	 * If the DMA burst size is given in chip_info we use that,
  	 * otherwise we use the default. Also we use the default FIFO
  	 * thresholds for now.
  	 */
-	*burst_code = chip_info ? chip_info->dma_burst_size : 1;
+	*burst_code = chip_info ? chip_info->dma_burst_size : dma_burst_size;
  	*threshold = SSCR1_RxTresh(RX_THRESH_DFLT)
  		   | SSCR1_TxTresh(TX_THRESH_DFLT);
 
drivers/spi/spi-pxa2xx-pci.c +0 -0
index d3de925892cb..3faef7335137 100644

drivers/spi/spi-pxa2xx-pci.c line 8

Quoted 4 lines
drivers/spi/spi-pxa2xx-pci.c +0 -1
@@ -5,7 +5,6 @@
   */
  #include <linux/clk-provider.h>
  #include <linux/module.h>
-#include <linux/of_device.h>

Minor note, no need to resend if ok to maintainers:
Unrelated change. Looks like already commit 0202775bc3a2 ("spi/pxa2xx-pci: switch to use pcim_* interfaces") made this needless.

Otherwise looks ok to me.

Signature · 1 line
Jarkko