mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Anže Lešnik" <anze.lesnik@norik.com>
To: barebox@lists.infradead.org
Cc: "Anže Lešnik" <anze.lesnik@norik.com>
Subject: [PATCH] drivers: net: fec_imx: Fix system halt after FEC reinit
Date: Tue,  5 Jul 2022 10:55:34 +0200	[thread overview]
Message-ID: <20220705085534.34251-1-anze.lesnik@norik.com> (raw)

Fix problem with system hang when trying to re-init ethernet interface
on i.MX devices. The problem is that RX and TX buffer descriptor address
registers are only being set in fec_probe(). When fec_halt() is called
when bringing down the interface, this resets the FEC and values are
lost. As per documentation, these registers should be reconfigured
before re-enabling the FEC. Additionally, move fec_init() call from
probe to open, since the FEC needs to re-initialized after every reset.

Signed-off-by: Anže Lešnik <anze.lesnik@norik.com>
Link: https://lore.barebox.org/barebox/c51b2c94-61b7-df44-5d4c-025d18c4b24f@norik.com
---
 drivers/net/fec_imx.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 0c2d600d1..673555a48 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -320,6 +320,10 @@ static int fec_init(struct eth_device *dev)
 	/* size of each buffer */
 	writel(FEC_MAX_PKT_SIZE, fec->regs + FEC_EMRBR);
 
+	/* set rx and tx buffer descriptor base address */
+	writel(virt_to_phys(fec->tbd_base), fec->regs + FEC_ETDSR);
+	writel(virt_to_phys(fec->rbd_base), fec->regs + FEC_ERDSR);
+
 	return 0;
 }
 
@@ -359,6 +363,8 @@ static int fec_open(struct eth_device *edev)
 	if (fec->phy_init)
 		fec->phy_init(edev->phydev);
 
+	fec_init(edev);
+
 	/*
 	 * Initialize RxBD/TxBD rings
 	 */
@@ -839,9 +845,6 @@ static int fec_probe(struct device_d *dev)
 	base += FEC_RBD_NUM * sizeof(struct buffer_descriptor);
 	fec->tbd_base = base;
 
-	writel(virt_to_phys(fec->tbd_base), fec->regs + FEC_ETDSR);
-	writel(virt_to_phys(fec->rbd_base), fec->regs + FEC_ERDSR);
-
 	ret = fec_alloc_receive_packets(fec, FEC_RBD_NUM, FEC_MAX_PKT_SIZE);
 	if (ret < 0)
 		goto free_xbd;
@@ -861,8 +864,6 @@ static int fec_probe(struct device_d *dev)
 	if (ret)
 		goto free_receive_packets;
 
-	fec_init(edev);
-
 	fec->miibus.read = fec_miibus_read;
 	fec->miibus.write = fec_miibus_write;
 
-- 
2.37.0




             reply	other threads:[~2022-07-05  9:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-05  8:55 Anže Lešnik [this message]
2022-07-05 14:00 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220705085534.34251-1-anze.lesnik@norik.com \
    --to=anze.lesnik@norik.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox