* [PATCH v3.18] net: fec: introduce fec_ptp_stop and use in probe fail path
@ 2018-03-06 23:23 Guenter Roeck
2018-03-07 17:23 ` Greg Kroah-Hartman
0 siblings, 1 reply; 2+ messages in thread
From: Guenter Roeck @ 2018-03-06 23:23 UTC (permalink / raw)
To: David S . Miller, Greg Kroah-Hartman
Cc: netdev, stable, Lucas Stach, Guenter Roeck
From: Lucas Stach <l.stach@pengutronix.de>
[ upstream commit 32cba57ba74be58589aeb4cb6496183e46a5e3e5 ]
This function frees resources and cancels delayed work item that
have been initialized in fec_ptp_init().
Use this to do proper error handling if something goes wrong in
probe function after fec_ptp_init has been called.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Acked-by: Fugang Duan <B38611@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[groeck: backport: context changes in .../fec_main.c]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
Not really sure if I should send this one to David or Greg, since v3.18 is no
longer officially supported, so I am sending it to both. Sorry for the noise.
This patch fixes a crash seen when running sabrelite images in a version
of qemu which fixes https://bugs.launchpad.net/qemu/+bug/1753309.
drivers/net/ethernet/freescale/fec.h | 1 +
drivers/net/ethernet/freescale/fec_main.c | 5 ++---
drivers/net/ethernet/freescale/fec_ptp.c | 10 ++++++++++
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index 9af296a1ca99..c16b6deff5ea 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -546,6 +546,7 @@ struct fec_enet_private {
};
void fec_ptp_init(struct platform_device *pdev);
+void fec_ptp_stop(struct platform_device *pdev);
void fec_ptp_start_cyclecounter(struct net_device *ndev);
int fec_ptp_set(struct net_device *ndev, struct ifreq *ifr);
int fec_ptp_get(struct net_device *ndev, struct ifreq *ifr);
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 065a7616e961..f1224c2d112a 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -3312,6 +3312,7 @@ failed_register:
failed_mii_init:
failed_irq:
failed_init:
+ fec_ptp_stop(pdev);
if (fep->reg_phy)
regulator_disable(fep->reg_phy);
failed_regulator:
@@ -3331,14 +3332,12 @@ fec_drv_remove(struct platform_device *pdev)
struct net_device *ndev = platform_get_drvdata(pdev);
struct fec_enet_private *fep = netdev_priv(ndev);
- cancel_delayed_work_sync(&fep->time_keep);
cancel_work_sync(&fep->tx_timeout_work);
+ fec_ptp_stop(pdev);
unregister_netdev(ndev);
fec_enet_mii_remove(fep);
if (fep->reg_phy)
regulator_disable(fep->reg_phy);
- if (fep->ptp_clock)
- ptp_clock_unregister(fep->ptp_clock);
fec_enet_clk_enable(ndev, false);
of_node_put(fep->phy_node);
free_netdev(ndev);
diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
index 992c8c3db553..9b2dcf4261a5 100644
--- a/drivers/net/ethernet/freescale/fec_ptp.c
+++ b/drivers/net/ethernet/freescale/fec_ptp.c
@@ -620,6 +620,16 @@ void fec_ptp_init(struct platform_device *pdev)
schedule_delayed_work(&fep->time_keep, HZ);
}
+void fec_ptp_stop(struct platform_device *pdev)
+{
+ struct net_device *ndev = platform_get_drvdata(pdev);
+ struct fec_enet_private *fep = netdev_priv(ndev);
+
+ cancel_delayed_work_sync(&fep->time_keep);
+ if (fep->ptp_clock)
+ ptp_clock_unregister(fep->ptp_clock);
+}
+
/**
* fec_ptp_check_pps_event
* @fep: the fec_enet_private structure handle
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3.18] net: fec: introduce fec_ptp_stop and use in probe fail path
2018-03-06 23:23 [PATCH v3.18] net: fec: introduce fec_ptp_stop and use in probe fail path Guenter Roeck
@ 2018-03-07 17:23 ` Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2018-03-07 17:23 UTC (permalink / raw)
To: Guenter Roeck; +Cc: David S . Miller, netdev, stable, Lucas Stach
On Tue, Mar 06, 2018 at 03:23:23PM -0800, Guenter Roeck wrote:
> From: Lucas Stach <l.stach@pengutronix.de>
>
> [ upstream commit 32cba57ba74be58589aeb4cb6496183e46a5e3e5 ]
>
> This function frees resources and cancels delayed work item that
> have been initialized in fec_ptp_init().
>
> Use this to do proper error handling if something goes wrong in
> probe function after fec_ptp_init has been called.
>
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> Acked-by: Fugang Duan <B38611@freescale.com>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> [groeck: backport: context changes in .../fec_main.c]
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> Not really sure if I should send this one to David or Greg, since v3.18 is no
> longer officially supported, so I am sending it to both. Sorry for the noise.
>
> This patch fixes a crash seen when running sabrelite images in a version
> of qemu which fixes https://bugs.launchpad.net/qemu/+bug/1753309.
This works for me, now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-07 17:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-06 23:23 [PATCH v3.18] net: fec: introduce fec_ptp_stop and use in probe fail path Guenter Roeck
2018-03-07 17:23 ` Greg Kroah-Hartman
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).