Skip to contentSkip to conversation

spi: pxa2xx: Adjust DMA burst size per platform

PATCH Superseded Andy Shevchenko 1 participant 4 messages Mar 18, 2019

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Andy Shevchenko

author reviewer
#0 lore raw

v3 cover spi: pxa2xx: Adjust DMA burst size per platform

On some platforms DMA burst size is not the same as hard coded default. Fix the driver to support them.

In v3:
- drop threshold print since it's easy to calculate constant (Jarkko)
- split one more unrelated change to a separate patch,
but independent from this series (Jarkko)

In v2:
- drop unrelated changes (Jarkko, Robert)
- don't include Robert's tag due to changes in the patch

Andy Shevchenko (2):
spi: pxa2xx: Introduce DMA burst size support
spi: pxa2xx: Debug print DMA burst size

 drivers/spi/spi-pxa2xx-dma.c   | 4 +++-
 drivers/spi/spi-pxa2xx-pci.c   | 4 ++++
 drivers/spi/spi-pxa2xx.c       | 4 ++++
 include/linux/spi/pxa2xx_spi.h | 1 +
 4 files changed, 12 insertions(+), 1 deletion(-)
Signature · 1 line
2.20.1
author reviewer
#1 lore raw

PATCH v3 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   | 4 ++++
 drivers/spi/spi-pxa2xx.c       | 1 +
 include/linux/spi/pxa2xx_spi.h | 1 +
 4 files changed, 9 insertions(+), 1 deletion(-)
drivers/spi/spi-pxa2xx-dma.c +3 -1
index 15592598273e..17424cc98006 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 -0
index 1727fdfbac28..33029ca0687a 100644
@@ -35,6 +35,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 +135,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 +226,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 b6ddba833d02..461c6b796b8f 100644
@@ -1564,6 +1564,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 c1c59473cef9..6005f0126631 100644
@@ -25,6 +25,7 @@ struct dma_chan;
 struct pxa2xx_spi_controller {
 	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
#2 lore raw

PATCH v3 2/2 spi: pxa2xx: Debug print DMA burst size

In reply to Andy Shevchenko

It's useful during debug to see what DMA burst size is.

---
 drivers/spi/spi-pxa2xx.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/spi/spi-pxa2xx.c +3 -0
index 461c6b796b8f..f008836f7e27 100644
@@ -1333,6 +1333,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 size set to %u\n",
+			chip->dma_burst_size);
 	}
 
 	switch (drv_data->ssp_type) {
Signature · 1 line
2.20.1
author reviewer
#3 lore raw
In reply to Andy Shevchenko
Quoted 7 lines · Andy Shevchenko

On some platforms DMA burst size is not the same as hard coded default. Fix the driver to support them.

In v3:
- drop threshold print since it's easy to calculate constant (Jarkko)
- split one more unrelated change to a separate patch,
but independent from this series (Jarkko)

Forgot to rebase.
It will not compile on v5.1-rc1 due to s/master/controller/g changes.

Quoted 18 lines

In v2:
- drop unrelated changes (Jarkko, Robert)
- don't include Robert's tag due to changes in the patch

Andy Shevchenko (2):
spi: pxa2xx: Introduce DMA burst size support
spi: pxa2xx: Debug print DMA burst size

 drivers/spi/spi-pxa2xx-dma.c   | 4 +++-
 drivers/spi/spi-pxa2xx-pci.c   | 4 ++++
 drivers/spi/spi-pxa2xx.c       | 4 ++++
 include/linux/spi/pxa2xx_spi.h | 1 +
 4 files changed, 12 insertions(+), 1 deletion(-)
Signature · 1 line
2.20.1
Signature · 2 lines
With Best Regards,
Andy Shevchenko