linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: stmmac: Read user ID muliple times if needed.
@ 2019-10-02  7:07 Hans Andersson
  2019-10-02  7:52 ` Jose Abreu
  0 siblings, 1 reply; 4+ messages in thread
From: Hans Andersson @ 2019-10-02  7:07 UTC (permalink / raw)
  To: mcoquelin.stm32
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, davem, netdev,
	linux-stm32, linux-arm-kernel, linux-kernel, Hans Andersson

From: Hans Andersson <hans.andersson@cellavision.se>

When we read user ID / Synopsys ID we might still be in reset,
so read muliple times if needed.

Signed-off-by: Hans Andersson <hans.andersson@cellavision.se>
---
 drivers/net/ethernet/stmicro/stmmac/hwif.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ethernet/stmicro/stmmac/hwif.c
index 6c61b75..3347164 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.c
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c
@@ -10,7 +10,16 @@
 
 static u32 stmmac_get_id(struct stmmac_priv *priv, u32 id_reg)
 {
-	u32 reg = readl(priv->ioaddr + id_reg);
+	u32 reg;
+	int i;
+
+	/* We might still be in reset when we read, */
+	/* so read multiple times if needed. */
+	for (i = 0; i < 10; i++) {
+		reg = readl(priv->ioaddr + id_reg);
+		if (reg)
+			break;
+	}
 
 	if (!reg) {
 		dev_info(priv->device, "Version ID not available\n");
-- 
2.17.1


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

* RE: [PATCH] net: stmmac: Read user ID muliple times if needed.
  2019-10-02  7:07 [PATCH] net: stmmac: Read user ID muliple times if needed Hans Andersson
@ 2019-10-02  7:52 ` Jose Abreu
  2019-10-02  8:02   ` Hans Andersson
  0 siblings, 1 reply; 4+ messages in thread
From: Jose Abreu @ 2019-10-02  7:52 UTC (permalink / raw)
  To: Hans Andersson, mcoquelin.stm32
  Cc: peppe.cavallaro, alexandre.torgue, davem, netdev, linux-stm32,
	linux-arm-kernel, linux-kernel, Hans Andersson

From: Hans Andersson <haan@cellavision.se>
Date: Oct/02/2019, 08:07:21 (UTC+00:00)

> When we read user ID / Synopsys ID we might still be in reset,
> so read muliple times if needed.

We shouldn't even try to read it if IP is in reset ... 

---
Thanks,
Jose Miguel Abreu

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

* RE: [PATCH] net: stmmac: Read user ID muliple times if needed.
  2019-10-02  7:52 ` Jose Abreu
@ 2019-10-02  8:02   ` Hans Andersson
  2019-10-02  8:08     ` Jose Abreu
  0 siblings, 1 reply; 4+ messages in thread
From: Hans Andersson @ 2019-10-02  8:02 UTC (permalink / raw)
  To: Jose Abreu, mcoquelin.stm32
  Cc: peppe.cavallaro, alexandre.torgue, davem, netdev, linux-stm32,
	linux-arm-kernel, linux-kernel

We assert / de-assert the reset line, but the CPU is too fast and the IP is still 
in reset when we later try to read user ID / Synopsys ID. Another option would
be to add a delay after we reset.

-----Original Message-----
From: Jose Abreu <Jose.Abreu@synopsys.com> 
Sent: den 2 oktober 2019 09:52
To: Hans Andersson <Hans.Andersson@CELLAVISION.SE>; mcoquelin.stm32@gmail.com
Cc: peppe.cavallaro@st.com; alexandre.torgue@st.com; davem@davemloft.net; netdev@vger.kernel.org; linux-stm32@st-md-mailman.stormreply.com; linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; Hans Andersson <Hans.Andersson@CELLAVISION.SE>
Subject: RE: [PATCH] net: stmmac: Read user ID muliple times if needed.

From: Hans Andersson <haan@cellavision.se>
Date: Oct/02/2019, 08:07:21 (UTC+00:00)

> When we read user ID / Synopsys ID we might still be in reset, so read 
> muliple times if needed.

We shouldn't even try to read it if IP is in reset ... 

---
Thanks,
Jose Miguel Abreu

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

* RE: [PATCH] net: stmmac: Read user ID muliple times if needed.
  2019-10-02  8:02   ` Hans Andersson
@ 2019-10-02  8:08     ` Jose Abreu
  0 siblings, 0 replies; 4+ messages in thread
From: Jose Abreu @ 2019-10-02  8:08 UTC (permalink / raw)
  To: Hans Andersson, Jose Abreu, mcoquelin.stm32
  Cc: peppe.cavallaro, alexandre.torgue, davem, netdev, linux-stm32,
	linux-arm-kernel, linux-kernel

From: Hans Andersson <Hans.Andersson@CELLAVISION.SE>
Date: Oct/02/2019, 09:02:02 (UTC+00:00)

> We assert / de-assert the reset line, but the CPU is too fast and the IP is still 
> in reset when we later try to read user ID / Synopsys ID. Another option would
> be to add a delay after we reset.

Then I think you should fix the reset driver to only return when the 
reset is fully done.

---
Thanks,
Jose Miguel Abreu

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

end of thread, other threads:[~2019-10-02  8:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-02  7:07 [PATCH] net: stmmac: Read user ID muliple times if needed Hans Andersson
2019-10-02  7:52 ` Jose Abreu
2019-10-02  8:02   ` Hans Andersson
2019-10-02  8:08     ` Jose Abreu

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