linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] spi: s3c64xx: print fifo size on probe.
  2015-07-28  9:29 [PATCH 0/2] s3c64xx debug prints Michal Suchanek
@ 2015-07-24 15:36 ` Michal Suchanek
  2015-07-28  9:37 ` [PATCH v2 2/2] spi: s3c64xx: add more debug prints Michal Suchanek
  1 sibling, 0 replies; 4+ messages in thread
From: Michal Suchanek @ 2015-07-24 15:36 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Michal Suchanek <hramrach@gmail.com>
---
 drivers/spi/spi-s3c64xx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 2a8c513..cd1cfac 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -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;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 0/2] s3c64xx debug prints
@ 2015-07-28  9:29 Michal Suchanek
  2015-07-24 15:36 ` [PATCH 1/2] spi: s3c64xx: print fifo size on probe Michal Suchanek
  2015-07-28  9:37 ` [PATCH v2 2/2] spi: s3c64xx: add more debug prints Michal Suchanek
  0 siblings, 2 replies; 4+ messages in thread
From: Michal Suchanek @ 2015-07-28  9:29 UTC (permalink / raw)
  To: linux-arm-kernel

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(-)

-- 
2.1.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] spi: s3c64xx: add more debug prints.
  2015-07-28  9:29 [PATCH 0/2] s3c64xx debug prints Michal Suchanek
  2015-07-24 15:36 ` [PATCH 1/2] spi: s3c64xx: print fifo size on probe Michal Suchanek
@ 2015-07-28  9:37 ` Michal Suchanek
  2015-07-28 14:52   ` Mark Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Michal Suchanek @ 2015-07-28  9:37 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Michal Suchanek <hramrach@gmail.com>

--

 - simplify by using dev_dbg and %pC
---
 drivers/spi/spi-s3c64xx.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index cd1cfac..3574525 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -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);
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] spi: s3c64xx: add more debug prints.
  2015-07-28  9:37 ` [PATCH v2 2/2] spi: s3c64xx: add more debug prints Michal Suchanek
@ 2015-07-28 14:52   ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2015-07-28 14:52 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jul 28, 2015 at 09:37:03AM -0000, Michal Suchanek wrote:
> 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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-07-28 14:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-28  9:29 [PATCH 0/2] s3c64xx debug prints Michal Suchanek
2015-07-24 15:36 ` [PATCH 1/2] spi: s3c64xx: print fifo size on probe Michal Suchanek
2015-07-28  9:37 ` [PATCH v2 2/2] spi: s3c64xx: add more debug prints Michal Suchanek
2015-07-28 14:52   ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).