Skip to contentSkip to conversation

s3c64xx debug prints

PATCH New Michal Suchanek 2 participants 4 messages Jul 24, 2015 – Jul 28, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover s3c64xx debug prints

Hello,

while debugging spi failures I found that debug prints provided by the driver are insufficient.

The hardware specific driver is the only place in kernel where things like SPI bus speed, used clock, transfer mode, etc. are known.

Thanks

Michal

Michal Suchanek (2):
spi: s3c64xx: print fifo size on probe.
spi: s3c64xx: add more debug prints.

 drivers/spi/spi-s3c64xx.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/2 spi: s3c64xx: print fifo size on probe.

Printing the FIFO depth does not add much noise in the log and can be useful for debugging transfer issues.

---
 drivers/spi/spi-s3c64xx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-s3c64xx.c +2 -2
index 2a8c513..cd1cfac 100644
@@ -1191,8 +1191,8 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
 
 	dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Slaves attached\n",
 					sdd->port_id, master->num_chipselect);
-	dev_dbg(&pdev->dev, "\tIOmem=[%pR]\tDMA=[Rx-%d, Tx-%d]\n",
-					mem_res,
+	dev_dbg(&pdev->dev, "\tIOmem=[%pR]\tFIFO %dbytes\tDMA=[Rx-%d, Tx-%d]\n",
+					mem_res, (FIFO_LVL_MASK(sdd) >> 1) + 1,
 					sdd->rx_dma.dmach, sdd->tx_dma.dmach);
 
 	return 0;
Signature · 1 line
2.1.4
#2 lore raw

PATCH v2 2/2 spi: s3c64xx: add more debug prints.

In reply to Michal Suchanek

The SPI transfers can mysteriously fail so add more debug prints about SPI parameters set by the driver.

The hardware specific SPI driver is the only place where the programmed SPI parameters are known so there is no other reasonable place for these prints.

--

- simplify by using dev_dbg and %pC

---
 drivers/spi/spi-s3c64xx.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
drivers/spi/spi-s3c64xx.c +23 -0
index cd1cfac..3574525 100644
@@ -469,6 +469,7 @@ static int wait_for_dma(struct s3c64xx_spi_driver_data *sdd,
 {
 	void __iomem *regs = sdd->regs;
 	unsigned long val;
+	unsigned long start, end;
 	u32 status;
 	int ms;
 
@@ -476,8 +477,17 @@ static int wait_for_dma(struct s3c64xx_spi_driver_data *sdd,
 	ms = xfer->len * 8 * 1000 / sdd->cur_speed;
 	ms += 10; /* some tolerance */
 
+	dev_dbg(&sdd->master->dev,
+		"%s: waiting for %ims transferring %zubytes@%iHz",
+		 __func__, ms, xfer->len, sdd->cur_speed);
+
 	val = msecs_to_jiffies(ms) + 10;
+	start = jiffies;
 	val = wait_for_completion_timeout(&sdd->xfer_completion, val);
+	end = jiffies;
+
+	dev_dbg(&sdd->master->dev, "%s: waited %u ms",
+		 __func__, jiffies_to_msecs(end - start));
 
 	/*
 	 * If the previous xfer was completed within timeout, then
@@ -576,6 +586,13 @@ static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd)
 	void __iomem *regs = sdd->regs;
 	u32 val;
 
+	dev_dbg(&sdd->master->dev,
+		"%s: clk_from_cmu %i src_clk %pC mode%s%s bpw %i",
+		 __func__, sdd->port_conf->clk_from_cmu, sdd->src_clk,
+		 (sdd->cur_mode & SPI_CPOL) ? " SPI_CPOL" : "",
+		 (sdd->cur_mode & SPI_CPHA) ? " SPI_CPHA" : "",
+		 sdd->cur_bpw);
+
 	/* Disable Clock */
 	if (sdd->port_conf->clk_from_cmu) {
 		clk_disable_unprepare(sdd->src_clk);
@@ -678,6 +695,9 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master,
 	unsigned long flags;
 	int use_dma;
 
+	dev_dbg(&master->dev, "%s %s: xfer bpw %i speed %i",
+		 dev_name(&spi->dev), __func__,
+		 xfer->bits_per_word, xfer->speed_hz);
 	reinit_completion(&sdd->xfer_completion);
 
 	/* Only BPW and Speed may change across transfers */
@@ -696,6 +716,9 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master,
 	    (sdd->rx_dma.ch && sdd->tx_dma.ch &&
 	     (xfer->len > ((FIFO_LVL_MASK(sdd) >> 1) + 1))))
 		use_dma = 1;
+	dev_dbg(&master->dev, "%s %s: %susing dma",
+		 dev_name(&spi->dev), __func__,
+		 use_dma ? "" : "not ");
 
 	spin_lock_irqsave(&sdd->lock, flags);
 
Signature · 1 line
2.1.4
maintainer
#3 lore raw

Re: [PATCH v2 2/2] spi: s3c64xx: add more debug prints.

Quoted 6 lines · Michal Suchanek

The SPI transfers can mysteriously fail so add more debug prints about SPI parameters set by the driver.

The hardware specific SPI driver is the only place where the programmed SPI parameters are known so there is no other reasonable place for these prints.

For timing things there should already be enough information in the
trace points with better resolution.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150728/88b96f41/attachment.sig>