From 4980c4d3063381175a6858114286adea74efda79 Mon Sep 17 00:00:00 2001 From: Volodymyr Babchuk Date: Thu, 2 Feb 2023 23:39:13 +0200 Subject: [PATCH] net: rswtich: disable GWCA when removing driver We need to disable GWCA for two reasons: 1. There may be packets coming to the device when U-Boot already transferred control to Linux, but Linux didn't had chance to re-configure GWCA. This may lead to memory corruption, as chains are already active. 2. Linux will not be able to switch GWCA to DISABLED state, because transition from OPERATION to DISABLED requires that all buffer pointers are released and all transactions are finished. But there are no one who can handle those operations, as U-Boot already exited and Linux is still trying to initialize R-Switch driver. This fixes issue with DomD unable to initialize network in the parallel mode. Signed-off-by: Volodymyr Babchuk --- drivers/net/rswitch.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/rswitch.c b/drivers/net/rswitch.c index 01b928972f3..5a3a1761b8f 100644 --- a/drivers/net/rswitch.c +++ b/drivers/net/rswitch.c @@ -1299,6 +1299,7 @@ static int rswitch_probe(struct udevice *dev) static int rswitch_remove(struct udevice *dev) { struct rswitch_priv *priv = dev_get_priv(dev); + int ret; if (!priv->parallel_mode) { clk_disable(&priv->rsw_clk); @@ -1308,6 +1309,11 @@ static int rswitch_remove(struct udevice *dev) mdio_unregister(priv->etha.bus); } + /* Turn off GWCA to make sure that there will be no new packets */ + ret = rswitch_gwca_change_mode(priv, GWMC_OPC_DISABLE); + if (ret) + pr_err("Failed to disable GWCA: %d\n", ret); + unmap_physmem(priv->addr, MAP_NOCACHE); unmap_physmem(priv->etha.serdes_addr, MAP_NOCACHE);