From: Andrew Lunn <andrew@lunn.ch>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Wei Fang <wei.fang@nxp.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Shenwei Wang <shenwei.wang@nxp.com>,
Clark Wang <xiaoning.wang@nxp.com>,
NXP Linux Team <linux-imx@nxp.com>,
netdev@vger.kernel.org, kernel@pengutronix.de
Subject: Re: [PATCH net-next 2/9] net: fec: Don't return early on error in .remove()
Date: Mon, 13 Mar 2023 16:07:12 +0100 [thread overview]
Message-ID: <e84585f2-e3d9-4a87-bfd4-a9ba458553b9@lunn.ch> (raw)
In-Reply-To: <20230313103653.2753139-3-u.kleine-koenig@pengutronix.de>
On Mon, Mar 13, 2023 at 11:36:46AM +0100, Uwe Kleine-König wrote:
> If waking up the device in .remove() fails, exiting early results in
> strange state: The platform device will be unbound but not all resources
> are freed. E.g. the network device continues to exist without an parent.
>
> Instead of an early error return, only skip the cleanup that was already
> done by suspend and release the remaining resources.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/net/ethernet/freescale/fec_main.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index c73e25f8995e..31d1dc5e9196 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -4465,15 +4465,13 @@ fec_drv_remove(struct platform_device *pdev)
> struct device_node *np = pdev->dev.of_node;
> int ret;
>
> - ret = pm_runtime_resume_and_get(&pdev->dev);
> - if (ret < 0)
> - return ret;
> + ret = pm_runtime_get_sync(&pdev->dev);
>
> cancel_work_sync(&fep->tx_timeout_work);
> fec_ptp_stop(pdev);
> unregister_netdev(ndev);
> fec_enet_mii_remove(fep);
> - if (fep->reg_phy)
> + if (ret >= 0 && fep->reg_phy)
> regulator_disable(fep->reg_phy);
>
> if (of_phy_is_fixed_link(np))
I'm not sure this is correct. My experience with the FEC is that if
the device is run time suspended, access to the hardware does not
work. In the case i was debugging, MDIO bus reads/writes time out. I
think IO reads and writes turn into NOPs, but i don't actually know.
So if pm_runtime_resume_and_get() fails, fec_ptp_stop() probably does
not work if it touches the hardware. I guess fec_enet_mii_remove()
unregisters any PHYs, which could cause MDIO bus access to shut down
the PHYs, so i expect that also does not work. regulator_disable()
probably does actually work because that is a different hardware block
unaffected by the suspend.
So i think you need to decide:
exit immediately if resume fails, leaving dangling PHYs, netdev,
regulator etc
Keep going, but maybe everything is going to grind to a halt soon
afterwards when accessing the hardware.
You seem to prefer keep going, so i would also suggest you disable the
regulator.
Andrew
next prev parent reply other threads:[~2023-03-13 15:07 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-13 10:36 [PATCH net-next 0/9] net: freescale: Convert to platform remove callback returning void Uwe Kleine-König
2023-03-13 10:36 ` Uwe Kleine-König
2023-03-13 10:36 ` [PATCH net-next 1/9] net: dpaa: Improve error reporting Uwe Kleine-König
2023-03-13 11:12 ` Madalin Bucur
2023-03-13 10:36 ` [PATCH net-next 2/9] net: fec: Don't return early on error in .remove() Uwe Kleine-König
2023-03-13 15:07 ` Andrew Lunn [this message]
2023-03-13 16:21 ` Uwe Kleine-König
2023-03-14 0:30 ` Andrew Lunn
2023-03-14 22:13 ` Uwe Kleine-König
2023-03-13 10:36 ` [PATCH net-next 3/9] net: dpaa: Convert to platform remove callback returning void Uwe Kleine-König
2023-03-13 10:36 ` [PATCH net-next 4/9] net: fec: " Uwe Kleine-König
2023-03-14 22:15 ` Uwe Kleine-König
2023-03-15 5:28 ` Jakub Kicinski
2023-03-15 6:29 ` Uwe Kleine-König
2023-03-13 10:36 ` [PATCH net-next 5/9] net: fman: " Uwe Kleine-König
2023-03-13 10:36 ` [PATCH net-next 6/9] net: fs_enet: " Uwe Kleine-König
2023-03-13 10:36 ` Uwe Kleine-König
2023-03-13 10:36 ` [PATCH net-next 7/9] net: fsl_pq_mdio: " Uwe Kleine-König
2023-03-13 10:36 ` [PATCH net-next 8/9] net: gianfar: " Uwe Kleine-König
2023-03-13 10:36 ` [PATCH net-next 9/9] net: ucc_geth: " Uwe Kleine-König
2023-03-13 11:15 ` [PATCH net-next 0/9] net: freescale: " Madalin Bucur
2023-03-13 11:15 ` Madalin Bucur
2023-03-13 15:05 ` Michal Kubiak
2023-03-13 15:05 ` Michal Kubiak
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=e84585f2-e3d9-4a87-bfd4-a9ba458553b9@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-imx@nxp.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shenwei.wang@nxp.com \
--cc=u.kleine-koenig@pengutronix.de \
--cc=wei.fang@nxp.com \
--cc=xiaoning.wang@nxp.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.