Re: mcp251x: probing unreliable, MCP251X_OST_DELAY_MS too low.

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

 



Hello Alexander Shiyan,

Alexander Shiyan wrote:
> On Fri, Jan 25, 2019 at 01:01:46PM +0100, Andreas Henriksson wrote:
[...]
>> According to my personal testing I can make the probing reliable just by
>> raising MCP251X_OST_DELAY_MS [1] to 30ms which seems to be the sweet
>> spot for me. (25ms isn't enough, while 40ms as suggested in last comment
>> in the raspberrypi issue doesn't seem to be needed either.)
[...]
> Re-examining the code, I do not see obvious errors. However, the problem
> is probably the implementation of the mdelay() for the ARM platform.

(Can you please clue me in on the arm specific mdelay? I can't find any
arm-specific bits overriding the default mdelay define[1], and
with MCP251X_OST_DELAY_MS set to 5 that should be directly equivalent
to 'udelay(5000);' as MAX_UDELAY_MS is also 5. Right?)

> Can you do the test by replacing the lines mdelay(MCP251X_OST_DELAY_MS)
> by udelay(2000)? Yes, exactly 2000.

I've tested this now but no improvement. The interfaces comes up
on every other "rmmod mcp251x; sleep 1 ; modprobe mcp251x" just like
with plain 4.20.0. Attaching patch of my changes just to verify
I didn't misunderstand what you wanted me to test.

(I noticed in
https://www.kernel.org/doc/Documentation/timers/timers-howto.txt
that mdelay is discuraged in favour of msleep, but I'm not sure I
really understood what the correct approach is after reading that doc.)

Regards,
Andreas Henriksson

[1]: https://elixir.bootlin.com/linux/latest/source/include/linux/delay.h#L43
>From e4bf7421ba4f159e1c9023d4a890c82f28fa3806 Mon Sep 17 00:00:00 2001
From: Andreas Henriksson <andreas.henriksson@xxxxxxxxx>
Date: Mon, 28 Jan 2019 09:54:31 +0100
Subject: [PATCH] TEST: mcp251x: use udelay(2000) instead of mdelay(5)

https://www.spinics.net/lists/linux-can/msg01050.html
---
 drivers/net/can/spi/mcp251x.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c
index e90817608645..97b27a85fbd2 100644
--- a/drivers/net/can/spi/mcp251x.c
+++ b/drivers/net/can/spi/mcp251x.c
@@ -215,8 +215,6 @@
 
 #define TX_ECHO_SKB_MAX	1
 
-#define MCP251X_OST_DELAY_MS	(5)
-
 #define DEVICE_NAME "mcp251x"
 
 static int mcp251x_enable_dma; /* Enable SPI DMA. Default: 0 (Off) */
@@ -630,7 +628,7 @@ static int mcp251x_hw_reset(struct spi_device *spi)
 	int ret;
 
 	/* Wait for oscillator startup timer after power up */
-	mdelay(MCP251X_OST_DELAY_MS);
+	udelay(2000);
 
 	priv->spi_tx_buf[0] = INSTRUCTION_RESET;
 	ret = mcp251x_spi_trans(spi, 1);
@@ -638,7 +636,7 @@ static int mcp251x_hw_reset(struct spi_device *spi)
 		return ret;
 
 	/* Wait for oscillator startup timer after reset */
-	mdelay(MCP251X_OST_DELAY_MS);
+	udelay(2000);
 	
 	reg = mcp251x_read_reg(spi, CANSTAT);
 	if ((reg & CANCTRL_REQOP_MASK) != CANCTRL_REQOP_CONF)
-- 
2.20.1


[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